betterwithage Perplexity Computer Agent commited on
Commit
a95b401
·
verified ·
1 Parent(s): 59f1f7b

SAPA: Energy-per-Successful-Goal accounting layer (ADDITIVE, doctrine-honest)

Browse files

Frontier upgrade on live MEASURED joules/token: signed joules-per-successful-goal on sovereign hardware. szl_sapa.py + szl_sapa_patch.py front-insert /sapa + /api/<ns>/v1/sapa/* before SPA catch-all. MEASURED only on a real fresh on-box joule reading; else MODELED/pending (never fabricates a joule). Inspired by A-LEMS / EpG arXiv:2605.22883 (cited reference; 4.33x is the paper's finding, not ours). Doctrine v11: locked=8 @ c7c0ba17; gates intact.

Signed-off-by: Stephen P. Lutar Jr. <stephenlutar2@gmail.com>
Co-Authored-By: Perplexity Computer Agent <agent@perplexity.ai>

Files changed (1) hide show
  1. .github/workflows/hf-sync.yml +173 -4
.github/workflows/hf-sync.yml CHANGED
@@ -7,15 +7,79 @@ name: Sync to HuggingFace Space
7
  # commits; (3) the upload_folder variant pushed the GitHub README verbatim with
8
  # NO Space front-matter, which CONFIG_ERROR'd the Space. create_commit of a
9
  # front-matter-prepended README needs no git history and no LFS, so it avoids all
10
- # three. Deployed app files already live on the Space and are NOT re-synced here.
11
- # Front-matter is base64 (FM_B64) so the python here-doc stays fully indented
12
- # inside the YAML block scalar (the indentation pitfall flagged in sentra).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
  on:
15
  push:
16
  branches: [main]
17
  paths:
18
  - "README.md"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  - ".github/workflows/hf-sync.yml"
20
  workflow_dispatch: {}
21
 
@@ -39,6 +103,10 @@ jobs:
39
  env:
40
  HF_TOKEN: ${{ secrets.HF_TOKEN }}
41
  SPACE_ID: SZLHOLDINGS/a11oy
 
 
 
 
42
  FM_B64: "dGl0bGU6ICJhMTFveSDigJQgR292ZXJuYW5jZSBTdWJzdHJhdGUiCmVtb2ppOiAi8J+UrCIKY29sb3JGcm9tOiBpbmRpZ28KY29sb3JUbzogZ3JheQpzZGs6IGRvY2tlcgphcHBfcG9ydDogNzg2MApwaW5uZWQ6IHRydWUKbGljZW5zZTogYXBhY2hlLTIuMApzaG9ydF9kZXNjcmlwdGlvbjogImExMW95IOKAlCBwb2xpY3kgKyByZWNlaXB0IHN1YnN0cmF0ZSIKdGFnczoKICAtIGdvdmVybmFuY2UKICAtIGFnZW50aWMtYWkKICAtIGRvY3RyaW5lLXYxMQogIC0gYTExb3kKICAtIGV4ZWN1dGlvbi1mYWJyaWMKICAtIGFwYWNoZS0yLjAKZWNvc3lzdGVtLXN0YWdlOiAib3BlcmF0aW9uYWwi"
43
  run: |
44
  set -euo pipefail
@@ -87,10 +155,111 @@ jobs:
87
  repo_type="space",
88
  operations=[CommitOperationAdd(path_in_repo="README.md",
89
  path_or_fileobj=card.encode("utf-8"))],
90
- commit_message="docs(slsa): sync Space card with GitHub README (SLSA L1 + L2 attested)",
91
  commit_description=("Automated README sync from szl-holdings/a11oy main via hf-sync.\n\n"
92
  "Signed-off-by: Yachay <yachay@szlholdings.ai>\n"
93
  "Co-Authored-By: Perplexity Computer Agent <agent@perplexity.ai>"),
94
  )
95
  print("HF commit:", commit.oid, "->", space)
96
  PYEOF
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  # commits; (3) the upload_folder variant pushed the GitHub README verbatim with
8
  # NO Space front-matter, which CONFIG_ERROR'd the Space. create_commit of a
9
  # front-matter-prepended README needs no git history and no LFS, so it avoids all
10
+ # three. Front-matter is base64 (FM_B64) so the python here-doc stays fully
11
+ # indented inside the YAML block scalar (the indentation pitfall flagged in sentra).
12
+ #
13
+ # front-door sync (drift-fix 2026-06-07): the README-only sync let the served
14
+ # front-door HTML drift — an edit to pages/console.html / console/index.html on
15
+ # GitHub would silently disappear on the next HF factory rebuild (the Space kept
16
+ # its own older copy), forcing a manual second push to both repos. The
17
+ # "Sync front-door files" step below now mirrors the plain-text front-door files
18
+ # (pages/*.html, pages/*.js, console/*.html, console/*.js) to the Space via the
19
+ # same git-free create_commit path. It deliberately EXCLUDES the built SPA
20
+ # bundles (console/assets/**, console/static/**) — those are large/possibly-LFS
21
+ # deployed artifacts that already live on the Space, and re-syncing them would
22
+ # reintroduce the LFS/pre-receive failures documented above. Timestamped
23
+ # *.bak-* backups are skipped.
24
+ #
25
+ # front-door deletion sync (drift-fix 2026-06-08): the add/update-only path above
26
+ # left a stale copy on the Space whenever a front-door file was DELETED or RENAMED
27
+ # on GitHub main — the old page lingered and kept being served after an HF rebuild.
28
+ # The step now also diffs the Space's current front-door file list
29
+ # (HfApi.list_repo_files, filtered to the same pages/*.{html,js} + console/*.{html,js}
30
+ # set) against the local files and emits CommitOperationDelete for any that are gone.
31
+ # The same exclusions apply: built SPA bundles (console/assets/**, console/static/**)
32
+ # and *.bak-* backups are NEVER deleted.
33
+ #
34
+ # cathedral front-door coverage (drift-fix 2026-06-10): the redesigned a11oy.net
35
+ # hero is served from cathedral.html (repo ROOT) + static/a11oy_cathedral.js, which
36
+ # fall OUTSIDE the pages/console glob above — so an edit to either on GitHub main was
37
+ # NOT auto-mirrored to the Space and the two copies drifted (they only matched because
38
+ # the launch pushed them by hand). Both exact paths are now part of on.push.paths, the
39
+ # add/update glob, and the delete-aware is_front_door() set (matched as an EXACT pair,
40
+ # NOT a broad static/* glob, so the Space's other static/ vendor blobs are untouched).
41
 
42
  on:
43
  push:
44
  branches: [main]
45
  paths:
46
  - "README.md"
47
+ - "pages/**"
48
+ - "console/*.html"
49
+ - "console/*.js"
50
+ - "cathedral.html"
51
+ - "static/a11oy_cathedral.js"
52
+ # copy-sync lockstep guard (CHECK 3): cathedral_genius.html + static/cathedral_app.js are
53
+ # per-file COPY'd in the Dockerfile but live OUTSIDE the bulk dirs, so they must be mirrored
54
+ # to the HF Space explicitly or the front door drifts (the original BUILD_ERROR incident).
55
+ - "cathedral_genius.html"
56
+ - "static/cathedral_app.js"
57
+ # copy-sync lockstep guard (CHECK 3): the shared honesty helpers loaded by the
58
+ # served pages/console.html live in static/shared/ (outside the bulk dirs), so
59
+ # they must be mirrored to the HF Space explicitly or the console drifts.
60
+ - "static/shared/szl_codename_sanitizer.js"
61
+ - "static/shared/szl_label_engine.js"
62
+ - "static/shared/szl_receipt_cosign.js"
63
+ # Lane F1: the 3D/holographic substrate kit, loaded by the served /holo page.
64
+ # Lives in static/shared/ (outside the bulk dirs) so it is mirrored to the HF
65
+ # Space explicitly here AND in the front-door CATHEDRAL_FILES list below.
66
+ - "static/shared/szl_holo3d.js"
67
+ # copy-sync lockstep guard (CHECK 2): the Lane A agentic core module
68
+ # a11oy_react_core.py is per-file COPY'd in the Dockerfile and imported by
69
+ # serve.py (serves /api/a11oy/v1/agent/react/{run,resume,trace,checkpoints}).
70
+ # Its .py source is auto-mirrored to the HF Space by hf-sync-backend.yml; it
71
+ # is also declared here in on.push.paths AND env.APP_FILES (kept the IDENTICAL
72
+ # set) so the lockstep mirror set explicitly records it and the guard stays
73
+ # green. Restores Dev A wiring clobbered by a later stale-base integration push.
74
+ - "a11oy_react_core.py"
75
+ # SAPA: Energy per Successful Goal — the frontier agentic unit on top of the
76
+ # live MEASURED joules/token path. szl_sapa.py is the shared accounting layer
77
+ # (byte-identical a11oy<->killinchu); szl_sapa_patch.py front-inserts /sapa +
78
+ # /api/a11oy/v1/sapa/*. Both are per-file COPY'd in the Dockerfile + imported by
79
+ # serve.py; declared here in on.push.paths AND env.APP_FILES (IDENTICAL set) so
80
+ # the copy-sync lockstep guard stays green and the .py is mirrored to the Space.
81
+ - "szl_sapa.py"
82
+ - "szl_sapa_patch.py"
83
  - ".github/workflows/hf-sync.yml"
84
  workflow_dispatch: {}
85
 
 
103
  env:
104
  HF_TOKEN: ${{ secrets.HF_TOKEN }}
105
  SPACE_ID: SZLHOLDINGS/a11oy
106
+ # APP_FILES is kept the IDENTICAL set to the Lane-A entries added to
107
+ # on.push.paths above (copy-sync lockstep guard reads both). The .py
108
+ # source itself is mirrored to the Space by hf-sync-backend.yml.
109
+ APP_FILES: "a11oy_react_core.py szl_sapa.py szl_sapa_patch.py"
110
  FM_B64: "dGl0bGU6ICJhMTFveSDigJQgR292ZXJuYW5jZSBTdWJzdHJhdGUiCmVtb2ppOiAi8J+UrCIKY29sb3JGcm9tOiBpbmRpZ28KY29sb3JUbzogZ3JheQpzZGs6IGRvY2tlcgphcHBfcG9ydDogNzg2MApwaW5uZWQ6IHRydWUKbGljZW5zZTogYXBhY2hlLTIuMApzaG9ydF9kZXNjcmlwdGlvbjogImExMW95IOKAlCBwb2xpY3kgKyByZWNlaXB0IHN1YnN0cmF0ZSIKdGFnczoKICAtIGdvdmVybmFuY2UKICAtIGFnZW50aWMtYWkKICAtIGRvY3RyaW5lLXYxMQogIC0gYTExb3kKICAtIGV4ZWN1dGlvbi1mYWJyaWMKICAtIGFwYWNoZS0yLjAKZWNvc3lzdGVtLXN0YWdlOiAib3BlcmF0aW9uYWwi"
111
  run: |
112
  set -euo pipefail
 
155
  repo_type="space",
156
  operations=[CommitOperationAdd(path_in_repo="README.md",
157
  path_or_fileobj=card.encode("utf-8"))],
158
+ commit_message="docs(slsa): sync Space card with GitHub README (SLSA L1 honest; L2 roadmap, not yet claimed)",
159
  commit_description=("Automated README sync from szl-holdings/a11oy main via hf-sync.\n\n"
160
  "Signed-off-by: Yachay <yachay@szlholdings.ai>\n"
161
  "Co-Authored-By: Perplexity Computer Agent <agent@perplexity.ai>"),
162
  )
163
  print("HF commit:", commit.oid, "->", space)
164
  PYEOF
165
+ - name: Sync front-door files to HuggingFace Space
166
+ env:
167
+ HF_TOKEN: ${{ secrets.HF_TOKEN }}
168
+ SPACE_ID: SZLHOLDINGS/a11oy
169
+ run: |
170
+ set -euo pipefail
171
+ if [ -z "${HF_TOKEN:-}" ]; then
172
+ echo "::error::HF_TOKEN secret is not set on this repo — cannot push to the HuggingFace Space."
173
+ exit 1
174
+ fi
175
+ python3 <<'PYEOF'
176
+ import os, glob
177
+ from huggingface_hub import HfApi, CommitOperationAdd, CommitOperationDelete
178
+
179
+ # Plain-text front-door files served directly by serve.py (pages/console.html
180
+ # is the home page at "/", console/index.html is the SPA history fallback).
181
+ # EXCLUDES console/assets/** and console/static/** — those are the built SPA
182
+ # bundles (large / possibly LFS) that already live on the Space; re-syncing
183
+ # them reintroduces the documented LFS/pre-receive failures.
184
+ #
185
+ # CATHEDRAL_FILES: the redesigned a11oy.net hero (cathedral.html at the repo
186
+ # root + static/a11oy_cathedral.js) is served at "/" too but lives OUTSIDE the
187
+ # pages/console glob. These two EXACT paths are mirrored as well. They are
188
+ # matched as an exact pair (never a broad static/* glob), so the Space's other
189
+ # static/ vendor blobs (vendor3d/, knowledge.json, etc.) are never touched.
190
+ CATHEDRAL_FILES = ["cathedral.html", "static/a11oy_cathedral.js", "cathedral_genius.html", "static/cathedral_app.js",
191
+ # shared honesty helpers loaded by the served pages/console.html;
192
+ # outside the bulk dirs so mirrored explicitly (copy-sync CHECK 3).
193
+ "static/shared/szl_codename_sanitizer.js", "static/shared/szl_label_engine.js", "static/shared/szl_receipt_cosign.js",
194
+ # Lane F1: the 3D/holographic substrate kit (loaded by /holo).
195
+ "static/shared/szl_holo3d.js"]
196
+ patterns = ["pages/*.html", "pages/*.js", "console/*.html", "console/*.js",
197
+ *CATHEDRAL_FILES]
198
+ paths = []
199
+ for pat in patterns:
200
+ paths.extend(glob.glob(pat))
201
+ # Regular files only; skip timestamped *.bak-* backups.
202
+ paths = sorted(
203
+ p for p in set(paths)
204
+ if os.path.isfile(p) and ".bak" not in os.path.basename(p)
205
+ )
206
+ local_set = set(paths)
207
+
208
+ # A Space path is "managed" by this front-door sync iff it sits DIRECTLY in
209
+ # pages/ or console/ with an .html/.js extension — i.e. it mirrors the glob
210
+ # set above (dirname must be exactly "pages"/"console", so console/assets/**
211
+ # and console/static/** are excluded), and it is not a *.bak-* backup.
212
+ def is_front_door(p):
213
+ base = os.path.basename(p)
214
+ if ".bak" in base:
215
+ return False
216
+ # Cathedral hero files are managed as an EXACT pair so the delete pass
217
+ # never sweeps the Space's other static/ vendor blobs.
218
+ if p in CATHEDRAL_FILES:
219
+ return True
220
+ d = os.path.dirname(p)
221
+ return d in ("pages", "console") and (p.endswith(".html") or p.endswith(".js"))
222
+
223
+ api = HfApi(token=os.environ["HF_TOKEN"])
224
+ space = os.environ["SPACE_ID"]
225
+
226
+ ops = []
227
+ for p in paths:
228
+ with open(p, "rb") as fh:
229
+ ops.append(CommitOperationAdd(path_in_repo=p, path_or_fileobj=fh.read()))
230
+
231
+ # Deletion side of the drift fix: any front-door file present on the Space
232
+ # but no longer on GitHub main (deleted/renamed) must be removed, otherwise
233
+ # the stale page lingers and keeps being served after an HF factory rebuild.
234
+ # Diff the Space's current front-door file list against the local set.
235
+ space_files = api.list_repo_files(repo_id=space, repo_type="space")
236
+ delete_paths = sorted(
237
+ p for p in space_files if is_front_door(p) and p not in local_set
238
+ )
239
+ for p in delete_paths:
240
+ ops.append(CommitOperationDelete(path_in_repo=p))
241
+
242
+ if not ops:
243
+ print("No front-door files to sync or delete.")
244
+ else:
245
+ commit = api.create_commit(
246
+ repo_id=space,
247
+ repo_type="space",
248
+ operations=ops,
249
+ commit_message="chore(sync): mirror front-door files to Space (hf-sync)",
250
+ commit_description=(
251
+ "Automated front-door sync from szl-holdings/a11oy main via hf-sync.\n"
252
+ "Added/updated: " + (", ".join(paths) or "(none)") + "\n"
253
+ "Deleted (gone from GitHub main): " + (", ".join(delete_paths) or "(none)") + "\n\n"
254
+ "Keeps the served front-door (pages/*.html, console/*.html) identical\n"
255
+ "to GitHub main so an HF factory rebuild never drops a GitHub edit or\n"
256
+ "keeps serving a page that was deleted on GitHub."
257
+ ),
258
+ )
259
+ print("HF commit:", commit.oid, "->", space,
260
+ "added:", len(paths), "deleted:", len(delete_paths))
261
+ for p in paths:
262
+ print(" synced:", p)
263
+ for p in delete_paths:
264
+ print(" deleted:", p)
265
+ PYEOF