betterwithage commited on
Commit
6eeba65
·
verified ·
1 Parent(s): b5398aa

chore(sync): mirror backend .py + Dockerfile to Space (hf-sync-backend)

Browse files

Automated backend sync from szl-holdings/a11oy main via hf-sync-backend.
Updated (differed from the Space): serve.py
Deleted (gone from the repo + Dockerfile COPY set): (none)

Keeps the Space-built backend (serve.py + the Dockerfile-COPY'd .py
modules) identical to GitHub main so the Space never rebuilds from a
stale backend, new endpoints don't 404 there, and orphaned modules
removed from the repo don't linger in the Space tree.

Files changed (1) hide show
  1. serve.py +20 -0
serve.py CHANGED
@@ -324,6 +324,26 @@ try:
324
  except Exception as _szl_el_e: # pragma: no cover
325
  print(f"[a11oy] Energy ledger NOT registered: {_szl_el_e!r}", file=__import__("sys").stderr)
326
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
327
  # -- Energy PROJECTION (honest measured-rate 1-day + scale projection) -- REGRESSION RESTORE.
328
  # Route /api/a11oy/v1/energy/projection?window=running is the projection surface the
329
  # /energy tab consumes. Its registration was dropped during a serve.py mesh refactor
 
324
  except Exception as _szl_el_e: # pragma: no cover
325
  print(f"[a11oy] Energy ledger NOT registered: {_szl_el_e!r}", file=__import__("sys").stderr)
326
 
327
+ # -- Energy OPERATOR -> LEDGER WIRING (the demo's CORE: every governed job mints a
328
+ # signed, hash-chained receipt) -- REGRESSION RESTORE. The operator and the ledger
329
+ # were each registered above but the subscription connecting the operator's completed-
330
+ # job emit stream to the ledger's receipt-minter was lost in the same serve.py mesh
331
+ # refactor that dropped the routes. Result: jobs MEASURED but receipt_chain depth 0.
332
+ # This subscribes the ledger's record_job to the running OperatorDaemon so each
333
+ # completed job mints a JouleCharge receipt into the durable chain in real time. The
334
+ # subscription is in place BEFORE the boot autostart presses play (below), so no job
335
+ # is missed; wire_operator_to_ledger is idempotent (sentinel-guarded, won't double-
336
+ # subscribe) and the ledger de-dupes by idempotency_key (won't double-mint), so it is
337
+ # safe to call here and cannot crash startup. See [[serve-route-regression-guard]].
338
+ try:
339
+ import szl_energy_operator as _szl_eo_wire
340
+ import szl_energy_ledger as _szl_el_wire
341
+ _eo_op = _szl_eo_wire.get_operator()
342
+ _wire_report = _szl_el_wire.wire_operator_to_ledger(_eo_op)
343
+ print(f"[a11oy] Energy operator->ledger wired: {_wire_report}", file=__import__("sys").stderr)
344
+ except Exception as _szl_wire_e: # pragma: no cover
345
+ print(f"[a11oy] Energy operator->ledger NOT wired: {_szl_wire_e!r}", file=__import__("sys").stderr)
346
+
347
  # -- Energy PROJECTION (honest measured-rate 1-day + scale projection) -- REGRESSION RESTORE.
348
  # Route /api/a11oy/v1/energy/projection?window=running is the projection surface the
349
  # /energy tab consumes. Its registration was dropped during a serve.py mesh refactor