axstack 0.65.0 → 0.67.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/README.md +2 -2
  2. package/docs/host-operations.md +6 -3
  3. package/package.json +1 -1
  4. package/skills/axstack/references/automations.md +8 -5
  5. package/skills/axstack/references/candidate-publication.md +7 -12
  6. package/skills/axstack/references/fleet-verification.md +3 -3
  7. package/skills/axstack/references/lifecycle.md +1 -1
  8. package/skills/axstack/references/pr-shape.md +8 -0
  9. package/skills/axstack/references/review-manager-prompt.md +16 -0
  10. package/skills/axstack/references/schedule-policy.json +123 -0
  11. package/skills/axstack/references/t3-runtime.md +5 -5
  12. package/skills/axstack/references/workspace-hygiene.md +9 -3
  13. package/skills/axstack/scripts/check-staged-file-tokens.js +1 -0
  14. package/skills/axstack/scripts/default-policy.js +1 -0
  15. package/skills/axstack/scripts/fleet-route-cli.js +2 -2
  16. package/skills/axstack/scripts/fleet-route-plan.js +2 -1
  17. package/skills/axstack/scripts/fleet-sample-io.js +1 -0
  18. package/skills/axstack/scripts/hub-usage.js +1 -1
  19. package/skills/axstack/scripts/pr-shape.js +161 -2
  20. package/skills/axstack/scripts/readiness-run.js +2 -0
  21. package/skills/axstack/scripts/readiness.js +10 -5
  22. package/skills/axstack/scripts/resolve-models.js +3 -1
  23. package/skills/axstack/scripts/schedule-drift.js +130 -0
  24. package/skills/axstack/scripts/scratch.js +201 -0
  25. package/skills/axstack/scripts/sync-default.js +1 -0
  26. package/skills/axstack/scripts/test-repository.js +1 -0
  27. package/skills/axstack/scripts/usage-split.js +286 -0
  28. package/skills/axstack-audit/SKILL.md +2 -0
  29. package/skills/axstack-review/references/review-receipt.md +1 -1
  30. package/skills/axstack-verify/SKILL.md +8 -1
  31. package/skills/voa/references/verification.md +5 -2
package/README.md CHANGED
@@ -121,8 +121,8 @@ subject to explicit stop-after-publication or observation requests.
121
121
  See [Host operations](docs/host-operations.md#chat-run-watch-activation) for wake activation and cadence.
122
122
  See [Chat-run PR watch](docs/workflows.md#chat-run-pr-watch) for the lifecycle and quiet cadence.
123
123
 
124
- An optional native T3 review manager runs finite peer-review passes hourly
125
- (`everyMs:3600000`); the review automation never merges for you. Activation needs live
124
+ An optional native T3 review manager runs finite peer-review passes every 30 minutes
125
+ (`everyMs:1800000`); the review automation never merges for you. Activation needs live
126
126
  host validation. See [PR-manager setup and safety](docs/host-operations.md#optional-native-peer-review-automation).
127
127
 
128
128
 
@@ -43,8 +43,8 @@ Every verified own-PR publication arms or joins the driver's chat-run watch.
43
43
  Its bound T3 schedule uses the cadence in [Chat-run watch activation](#chat-run-watch-activation).
44
44
  See [Chat-run PR watch](workflows.md#chat-run-pr-watch) for authority, schedule identity and stop conditions.
45
45
  Missing schedule capability holds activation.
46
- The optional review manager uses an unbound hourly T3 schedule
47
- (`everyMs:3600000`) and requires
46
+ The optional review manager uses an unbound 30-minute T3 schedule
47
+ (`everyMs:1800000`) and requires
48
48
  its separate native canary before activation. Installed guidance does not prove
49
49
  live behavior. See [Review manager](../skills/axstack/references/automations.md).
50
50
 
@@ -99,7 +99,10 @@ with the PR; remove the exact unit and route after settlement.
99
99
 
100
100
  The optional native review manager uses the VPS T3 project `axstack-review-lane`
101
101
  on the existing host clone. Configure and read back the lane's `axstack-owner`
102
- binding, then create an unbound hourly T3 schedule (`everyMs:3600000`).
102
+ binding. Before `schedule_task`, render the packaged prompt by filling every
103
+ `{{HOST_*}}` placeholder from the private host binding used by `schedule-drift.js`.
104
+ Never deploy a prompt containing an unfilled `{{HOST_*}}` placeholder.
105
+ Then create an unbound 30-minute T3 schedule (`everyMs:1800000`) with this rendered prompt.
103
106
  The packaged prompt checks for a quiet exit before skill loading; full passes
104
107
  follow the lifecycle below. Each pass starts in a fresh finite worktree from
105
108
  `origin/main`, fetches first, and checks its
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "axstack",
3
- "version": "0.65.0",
3
+ "version": "0.67.0",
4
4
  "description": "Axstack installer and setup CLI: installs owned chat skills and role data, configures supported harness settings, and checks T3 Code capabilities.",
5
5
  "keywords": [
6
6
  "claude-code",
@@ -49,8 +49,11 @@ The sections below govern full passes; a quiet exit bypasses their teardown
49
49
  except the guarded pass-end self-settle.
50
50
 
51
51
  The lane thread must use the recorded `axstack-owner` binding and verify its
52
- readback through `t3_thread_read`. Then `schedule_task` uses the packaged prompt,
53
- hourly with `everyMs:3600000`, `bindToCurrentThread:false`, and a stable `clientRequestId`.
52
+ readback through `t3_thread_read`. Before `schedule_task`, render the packaged prompt
53
+ by filling every `{{HOST_*}}` placeholder from the private host binding used by
54
+ `schedule-drift.js`. Never deploy a prompt containing an unfilled `{{HOST_*}}` placeholder.
55
+ Then `schedule_task` uses the rendered packaged prompt,
56
+ every 30 minutes with `everyMs:1800000`, `bindToCurrentThread:false`, and a stable `clientRequestId`.
54
57
  Record the schedule ID, project, lane binding and pass thread/run identities.
55
58
  Each pass compares native task status and thread reads for settings readback with the recorded binding
56
59
  after any owner-only instance update under [Provider bindings](t3-runtime.md#preflight-and-binding), before admission.
@@ -216,9 +219,9 @@ Settlement returns continuity to the manager rather than retaining an idle PR
216
219
  coordinator. Each reviewer uses a separate driver-made detached checkout and
217
220
  private evidence folder, with evidence read-back before removal.
218
221
 
219
- Set `TMPDIR` for manager and job commands to an owned 0700 directory under the
220
- system temp directory, named from the dispatch key and recorded in the receipt,
221
- following [Workspace hygiene](workspace-hygiene.md).
222
+ Run manager and job scratch commands through [scratch.js](../scripts/scratch.js);
223
+ follow its `--help` and the [repository command recipe](workspace-hygiene.md#safe-deletion)
224
+ for explicit repository selection and child exit checks. Record its JSON paths in the dispatch receipt.
222
225
  Evidence files stay in the private `<run dir>/evidence/<dispatch>/` folder.
223
226
  Never write temporary files under `/` or another shared root. Never delete
224
227
  through a broad `TMPDIR` glob, sweep a shared temporary root, or wipe a general
@@ -42,17 +42,12 @@ Before a history rewrite, confirm expected-old remote SHA and use a narrowly
42
42
  justified lease; a mismatch holds publication. If push outcome is ambiguous,
43
43
  inspect remote state before retrying.
44
44
 
45
- Before reviewer dispatch, read the remote ref back, confirm its SHA equals candidate SHA, pin
46
- current base and refresh PR body counts and base from confirmed candidate SHA
47
- and that base under [PR shape](pr-shape.md).
48
- After every push, before post-push diligence or merge-ready, compare the PR body's
49
- stated head SHA with `Confirmed remote SHA` and record `PR body head SHA: <sha or none>`.
50
- Accept `none` for a PR body without a stated head SHA.
51
- Accept a stated full head SHA only when it equals `Confirmed remote SHA`.
52
- Accept a stated abbreviated head SHA only when it is a matching prefix of
53
- `Confirmed remote SHA` with at least 7 hexadecimal characters.
54
- Hold on a mismatched head SHA or an abbreviation shorter than 7 characters.
55
- Leave other SHAs in the PR body unchanged.
45
+ Before reviewer dispatch, read the remote ref back, confirm its SHA equals candidate SHA,
46
+ pin the current base, and render and check the PR facts using
47
+ [PR body proof mode](pr-shape.md#pr-body).
48
+ After every push, before post-push diligence or merge-ready, run proof mode against
49
+ the live PR body and retain its JSON evidence. Hold publication progression on any
50
+ failed or unknown term; the helper grants no authority.
56
51
  Record:
57
52
 
58
53
  ```text
@@ -62,7 +57,7 @@ Base: <sha>
62
57
  Remote ref: <branch>
63
58
  Expected-old remote SHA: <sha | absent>
64
59
  Confirmed remote SHA: <sha>
65
- PR body head SHA: <sha or none>
60
+ PR proof: <proof-mode JSON evidence path>
66
61
  PR: <url>
67
62
  CI: <run ID or URL and triggered/pending/completed status>
68
63
  ```
@@ -58,9 +58,9 @@ matches, missing pages, wrong readback, never-started and silent first runs;
58
58
  all hold rather than creating a second driver. Do not create real orphaned
59
59
  production tasks for these negative controls. Mark unobserved live rows UNKNOWN.
60
60
 
61
- Create a fresh 0700 scratch outside HOME on each participating host; record each
62
- literal path with hostId/environmentId. Before use validate owner, realpath and
63
- no symlink. Use a separately owned persistent evidence folder on origin and target,
61
+ Use [scratch.js](../scripts/scratch.js) on each participating host, following
62
+ the [repository command recipe](workspace-hygiene.md#safe-deletion); record each
63
+ printed root with hostId/environmentId. Use a separately owned persistent evidence folder on origin and target,
64
64
  outside scratch selected for deletion. Put only a tiny fixture README/candidate in
65
65
  an explicitly provisioned test project. Record its root HEAD/status/all refs before
66
66
  and after; no shared project or unknown ignored artifacts may be cleaned.
@@ -193,7 +193,7 @@ Merge-ready differs from merged.
193
193
  ## Review automation health
194
194
 
195
195
  The native review manager uses fresh finite T3 pass threads from its dedicated
196
- lane project on an hourly T3 scheduled task (`everyMs:3600000`). It admits
196
+ lane project on a 30-minute T3 scheduled task (`everyMs:1800000`). It admits
197
197
  actionable PR events
198
198
  within measured host capacity; waiting PRs remain covered without reserving slots.
199
199
  Bounded PR jobs use driver-made detached checkouts and settle after descendants.
@@ -51,6 +51,14 @@ For repository title conventions, check recently merged PRs.
51
51
 
52
52
  Every own PR description must include a short `Proof` section:
53
53
  what was verified and how, with commands and observed results, CI or evidence links.
54
+ Render its facts with
55
+ `bun skills/axstack/scripts/pr-shape.js --proof --base <base> --head <head>`
56
+ and paste the JSON `block` under `Proof`. Keep the returned per-term evidence.
57
+ Check the published body against live GitHub facts with
58
+ `bun skills/axstack/scripts/pr-shape.js --proof --pr <number> --repo <owner/repo>`.
59
+ For a local body, use `--proof --base <base> --head <head> --body <path>`.
60
+ Use `--proof --help` for the block format, fact definitions and unknown-data behavior.
61
+
54
62
  For UI-related changes, embed screenshots in the PR description
55
63
  (before/after where meaningful).
56
64
  Screenshots are mandatory for UI-related changes, with the text fallback below as the only exception.
@@ -1,5 +1,7 @@
1
1
  # Review manager prompt
2
2
 
3
+ First command of every pass, quiet check included: use an owned 0700 TMPDIR under the system temp dir (never under $HOME or a shared root); give each PR job its own TMPDIR. The login shell is fish; write shell commands in bash syntax and run them with bash.
4
+
3
5
  Run the quiet check before invoking `axstack-review` or reading any `skills/**` file.
4
6
 
5
7
  Resolve self with `gh api user --jq .login`, then union two paginated `gh search prs`
@@ -67,3 +69,17 @@ has no pending receipt and is not held, wedged or a stalled owner.
67
69
  Follow [Finite-session teardown](automations.md#finite-session-teardown) for
68
70
  deferred self-settle and next-pass verification; this applies to quiet, skipped
69
71
  and empty passes too.
72
+
73
+ Host operating policy (user-authorized; adapted to T3). Except for the TMPDIR rule and guarded pass-end settlement/next-pass verification, it applies to full passes only; a quiet pass follows the quiet check and guarded settlement above:
74
+
75
+ Durable continuity: {{HOST_CONTINUITY_PATH}} — the fixed four-section template from run-record.md (Lane state, Open holds, Watermarks, Last pass), overwritten every full pass and read back before your turn ends. Superseded history goes once to progress.history.md beside it; read history only for a specific recovery question.
76
+
77
+ Apply the host-declared operational limits:
78
+
79
+ {{HOST_OPERATIONAL_LIMITS}}
80
+
81
+ Peer scope (user-decided 2026-10-15; supersedes the 2026-10-08 spec-decision holds): follow axstack-review Peer mode exactly. Review code and design only; never ask the author or a "spec approver" for approvals, sign-offs, scope, policy or process decisions, and never add a "Decision needed" section. Accept the author's statement that a point was decided elsewhere. Spec, scope, policy or licence questions are never holds. Security holds stay unpublished as before.
82
+
83
+ Leftover sweep: at the start of each full pass, after lane reconciliation, run the axstack-cleanup driver-start sweep for this host's repositories: remove settled pass worktrees and PR-job checkouts of this lane and other provably settled Axstack leftovers whose heads are on the remote (salvage bundle first where required), and list the rest in Open holds. Never touch user chats, live managers or workers, genuine user_takeover, or anything without provable Axstack provenance.
84
+
85
+ Pass branches: when you retire a settled pass worktree, or in the sweep, delete its local t3code/* branch with `git branch -D` only if no worktree has it checked out and `git merge-base --is-ancestor <branch> origin/main` succeeds after fetch; otherwise list it in Open holds.
@@ -0,0 +1,123 @@
1
+ {
2
+ "version": 1,
3
+ "provenance": "Clause SHA-256 covers the shipped exact UTF-8 line, excluding the line terminator; sourceClauseSha256 covers the original exported line. Source export hashes cover the complete private JSON bytes. No private exports or schedule identities are packaged.",
4
+ "clauses": [
5
+ {
6
+ "id": "operating-context",
7
+ "status": "imported",
8
+ "sha256": "4796b30d9b1bda286449d118962be7d2c74d60dc859752d0a1e98fe98ac6a40f",
9
+ "sourceClauseSha256": "53deef1cad7603e10ce6fbfcf4c13b4caa750c2a5f233a59a19ae4924dc2e430",
10
+ "sourceExportSha256": "fbb03192166b80423f5861ab79602fde87f1d5af97ec6f2ef762d3ce7f182a1c",
11
+ "promptFile": "review-manager-prompt.md",
12
+ "disposition": {
13
+ "kind": "edited",
14
+ "decidedAt": "2026-11-15",
15
+ "reason": "Remove historical manager provenance; retain operating scope."
16
+ }
17
+ },
18
+ {
19
+ "id": "durable-continuity",
20
+ "status": "imported",
21
+ "sha256": "243ef7be96dc3c5f5f75101ec12e836e316efa48b77a659ef8aa06ce2819231e",
22
+ "sourceClauseSha256": "0b97611ce39738ae739af27787062349bd293bb683b4d293fa8916e0e47bc998",
23
+ "sourceExportSha256": "fbb03192166b80423f5861ab79602fde87f1d5af97ec6f2ef762d3ce7f182a1c",
24
+ "promptFile": "review-manager-prompt.md",
25
+ "disposition": {
26
+ "kind": "edited",
27
+ "decidedAt": "2026-11-15",
28
+ "reason": "Bind the continuity path privately on the host."
29
+ }
30
+ },
31
+ {
32
+ "id": "temporary-directory-and-shell",
33
+ "status": "imported",
34
+ "sha256": "a5ba61875a968d5e56ed8365e9da733dd847d6fb6d52b824492549c7e2e3a203",
35
+ "sourceClauseSha256": "a5ba61875a968d5e56ed8365e9da733dd847d6fb6d52b824492549c7e2e3a203",
36
+ "sourceExportSha256": "fbb03192166b80423f5861ab79602fde87f1d5af97ec6f2ef762d3ce7f182a1c",
37
+ "promptFile": "review-manager-prompt.md",
38
+ "disposition": {
39
+ "kind": "verbatim",
40
+ "decidedAt": "2026-11-15"
41
+ }
42
+ },
43
+ {
44
+ "id": "peer-scope",
45
+ "status": "imported",
46
+ "sha256": "d6ce8d0d30e90a5c9844132fe45fbe37e4dca07cc387c0dcc09a76783d35b04a",
47
+ "sourceClauseSha256": "d6ce8d0d30e90a5c9844132fe45fbe37e4dca07cc387c0dcc09a76783d35b04a",
48
+ "sourceExportSha256": "fbb03192166b80423f5861ab79602fde87f1d5af97ec6f2ef762d3ce7f182a1c",
49
+ "promptFile": "review-manager-prompt.md",
50
+ "disposition": {
51
+ "kind": "verbatim",
52
+ "decidedAt": "2026-11-15"
53
+ }
54
+ },
55
+ {
56
+ "id": "leftover-sweep",
57
+ "status": "imported",
58
+ "sha256": "bd0a2144c4d3436a8379c642d2b8bf8d2c2c951ca9776889a9109fb30cff5b0d",
59
+ "sourceClauseSha256": "dbff4b530eeae1ad56ec828d46fe25a7d941e5dcf31179b07cff4ce6b1548d04",
60
+ "sourceExportSha256": "fbb03192166b80423f5861ab79602fde87f1d5af97ec6f2ef762d3ce7f182a1c",
61
+ "promptFile": "review-manager-prompt.md",
62
+ "disposition": {
63
+ "kind": "edited",
64
+ "decidedAt": "2026-11-15",
65
+ "reason": "Remove the legacy resource exclusion; preserve the remaining clause verbatim."
66
+ }
67
+ },
68
+ {
69
+ "id": "pass-branches",
70
+ "status": "imported",
71
+ "sha256": "329cf4d1392ca4425c08eab2c12e5228a5c7d4dc2c34cd7e2bdc03d64307d39f",
72
+ "sourceClauseSha256": "329cf4d1392ca4425c08eab2c12e5228a5c7d4dc2c34cd7e2bdc03d64307d39f",
73
+ "sourceExportSha256": "fbb03192166b80423f5861ab79602fde87f1d5af97ec6f2ef762d3ce7f182a1c",
74
+ "promptFile": "review-manager-prompt.md",
75
+ "disposition": {
76
+ "kind": "verbatim",
77
+ "decidedAt": "2026-11-15"
78
+ }
79
+ },
80
+ {
81
+ "id": "operational-limits",
82
+ "status": "host-only",
83
+ "sourceClauseSha256": "9c99d7e2cb60e54a190092001e164f2a2513b62c4ddafab7e0bfba038b5ed3d5",
84
+ "sourceExportSha256": "fbb03192166b80423f5861ab79602fde87f1d5af97ec6f2ef762d3ce7f182a1c",
85
+ "disposition": {
86
+ "kind": "host-only",
87
+ "decidedAt": "2026-11-15",
88
+ "reason": "Retain operational limits only in the private host binding; packaged guidance applies host-declared limits generically."
89
+ }
90
+ },
91
+ {
92
+ "id": "alert-command",
93
+ "status": "dropped",
94
+ "sourceClauseSha256": "d80e3cc4f5d026c3bc9218df7ec860a684806abf1bd4840160f7789dd2ae7ca1",
95
+ "sourceExportSha256": "fbb03192166b80423f5861ab79602fde87f1d5af97ec6f2ef762d3ce7f182a1c",
96
+ "disposition": {
97
+ "kind": "dropped",
98
+ "decidedAt": "2026-11-15",
99
+ "reason": "Drop external notifications entirely; retain neither prompt text nor a host binding."
100
+ }
101
+ }
102
+ ],
103
+ "review": {
104
+ "authority": "No authoritative head-age threshold, age clock semantics or pending-check policy found in the exported live prompt or packaged peer-mode admission/submission rules. Re-read state/head/base/draft rules do not define an age or pending-check policy. Private continuity contains historical approximate head-stability deferrals, without a general authorized threshold, specified clock or pending-check treatment; those observations are not promoted to policy.",
105
+ "admission": {
106
+ "status": "unknown",
107
+ "headAgeThresholdSeconds": null,
108
+ "clockSemantics": null,
109
+ "pendingCheckTreatment": null
110
+ },
111
+ "submission": {
112
+ "status": "unknown",
113
+ "headAgeThresholdSeconds": null,
114
+ "clockSemantics": null,
115
+ "pendingCheckTreatment": null
116
+ },
117
+ "dependentHold": "T30"
118
+ },
119
+ "inventory": {
120
+ "pr-triage-nightly.md": "No packaged nightly schedule found in the complete project inventory; user-owned queue triage excluded.",
121
+ "test-audit-weekly.md": "No packaged weekly schedule found in the complete project inventory."
122
+ }
123
+ }
@@ -37,8 +37,8 @@ preset and stable role IDs, requested provider/model/class/mode/effort, resolved
37
37
  ID, source and time once. Resume preserves that snapshot with no re-resolution;
38
38
  changes require the user's explicit decision. Bundled presets are setup inputs.
39
39
 
40
- Provider bindings must map codex→`codex`, claude→`claudeAgent` and grok→`grok`.
41
- For every dispatch or launch, claude must bind to `claudeAgent` and codex must bind to `codex`.
40
+ Every dispatch or launch takes its binding from dispatch-plan output;
41
+ [provider bindings](../scripts/resolve-models.js) are enforced in code.
42
42
  A usage-limited instance must hold the work without failover.
43
43
 
44
44
  For plan generation, run
@@ -498,10 +498,10 @@ and keep its link.
498
498
  Put the [Safe-deletion rule](workspace-hygiene.md#safe-deletion) in every worker brief.
499
499
  Name the private `<run>/evidence/<key>/` folder in the brief and completion receipt.
500
500
 
501
- Before use, commands must scope `TMPDIR` to an owned 0700 directory under the system temp directory, never under `$HOME`, named from the dispatch key and recorded in the receipt.
502
- Validate its real path, absence of symlinks and ownership before use and cleanup; remove it afterwards by literal absolute path.
501
+ Use [scratch.js](../scripts/scratch.js) for command scratch; follow its `--help`
502
+ and the [workspace recipe](workspace-hygiene.md#safe-deletion) for explicit repository selection and child exit checks. Record its JSON paths in the dispatch receipt.
503
503
  Evidence files still go to the private `<run>/evidence/<key>/` folder.
504
- Apply equivalent guards to worktree-local paths. Uncertain paths are preserved for reconciliation.
504
+ Apply equivalent guards to worktree-local paths: validate their real path, absence of symlinks and ownership before use and cleanup. Uncertain paths are preserved for reconciliation.
505
505
 
506
506
  Deletion must target an exact validated owned path inside evidence, TMPDIR or
507
507
  the worktree, using a literal absolute path or `${VAR:?}`-guarded path: no glob,
@@ -25,15 +25,21 @@ Driver Git commands in a worktree a worker has written must pass
25
25
 
26
26
  ## Safe deletion
27
27
 
28
- Before use, commands must scope `TMPDIR` to an owned 0700 directory under the system temp directory, never under `$HOME`, named from the dispatch key and recorded in the receipt.
29
- Validate its real path, absence of symlinks and ownership before use and cleanup; remove it afterwards by literal absolute path.
28
+ Use [scratch.js](../scripts/scratch.js) for command scratch. Repository commands
29
+ must explicitly select the repository, because the helper's cwd is empty:
30
+ `bun <installed-axstack>/scripts/scratch.js run -- bun --cwd=<repo> run test <test-path>`.
31
+ The `--cwd=` form is required because the spaced `bun --cwd <repo>` form prints help and exits 0, a false green.
32
+ For Git and other tools use their explicit repository/cwd option or absolute paths.
33
+ Check JSON `child.exitCode` and `child.signal`; helper exit 0 only means measured.
34
+ Record its JSON paths in the dispatch receipt; inspect declared roots with
35
+ `plan --root <root>` and consult `--help` for effects and cleanup responsibilities.
30
36
  Evidence files still go to the private `<run>/evidence/<key>/` folder.
31
37
 
32
38
  Run each cleanup as a single command.
33
39
  Never use `rm -f` or chain cleanup commands.
34
40
 
35
41
  Every shell deletion targets a literal absolute path or a `${VAR:?}`-guarded expansion, only inside the worker's own evidence folder, `TMPDIR`, or worktree.
36
- For validated owned scratch, use `rm -r /tmp/<dispatch-key>/scratch` on a literal absolute path inside the evidence folder, `TMPDIR`, or worktree.
42
+ Before deleting helper scratch by literal absolute path, require every term in `plan --root <recorded-root>` to pass for that exact recorded root, including ownership and path terms.
37
43
  Never use a bare `$VAR`, a glob on a variable, `/`, `HOME`, or a shared root as a deletion target.
38
44
  Prefer `git clean -- <exact prefix>` or tool-native cleanup. A safety prompt that
39
45
  still appears is a hold; agents do not answer it.
@@ -46,6 +46,7 @@ try {
46
46
  ${advisories.join('\n')}
47
47
  Review file structure and responsibilities; no size-only split or approval is required.`);
48
48
  }
49
+ console.log('Staged-file token check passed.');
49
50
  } catch (error) {
50
51
  console.error(`Staged-file token check failed: ${error.message}`);
51
52
  process.exit(1);
@@ -22,6 +22,7 @@ function pool(accounts, driver, now) {
22
22
  const rows = members.map((a) => {
23
23
  const u = a.usageLimits;
24
24
  if (u?.unavailable || !fresh(u?.checkedAt, now, 300000) || !Array.isArray(u?.windows)) throw Error(`unknown ${driver} telemetry`);
25
+ /** @type {{ used: number, elapsed: number | null, resetKnown?: boolean }[]} */
25
26
  const windows = ['session', 'weekly'].map((kind) => {
26
27
  const found = u.windows.filter((w) => w.kind === kind && !(driver === 'claudeAgent' && w.id?.startsWith('seven_day_')));
27
28
  const weeklyOnly = driver === 'codex' ? 'verified Codex weekly-only response' : 'verified Claude weekly-only response';
@@ -78,8 +78,8 @@ export async function main(argv) {
78
78
  const result = (planning ? planIntake : recommend)({ ...input, configText, configDigest,
79
79
  request: args['--task'] ? { ...input.request, task: args['--task'] } : input.request }, now);
80
80
  process.stdout.write(args['--json'] || planning ? `${JSON.stringify(result)}\n`
81
- : `${result.stage}: ${result.selected?.hostId ?? 'no host'} (${result.reason})\n`);
82
- return planning ? result.disposition === 'hold' ? 2 : 0 : result.selected ? 0 : 2;
81
+ : `${/** @type {ReturnType<typeof recommend>} */ (result).stage}: ${result.selected?.hostId ?? 'no host'} (${result.reason})\n`);
82
+ return planning ? /** @type {ReturnType<typeof planIntake>} */ (result).disposition === 'hold' ? 2 : 0 : result.selected ? 0 : 2;
83
83
  } catch (error) {
84
84
  process.stderr.write(`${JSON.stringify({ error: { code: error.message.split(':')[0], message: error.message } })}\n`);
85
85
  return 1;
@@ -45,6 +45,7 @@ export function planIntake(input, now) {
45
45
  const config = parseFleetConfig(input.configText, input.configDigest);
46
46
  if (input.request?.role !== 'driver') throw new Error('driver-role-required');
47
47
  const initial = recommend(input, now); // Validate and rank the unchanged supplied facts.
48
+ /** @type {{ code: string, state: string, environmentId?: string, evidence: unknown }[]} */
48
49
  const terms = initial.excluded.map((e) => ({ code: 'route-eligibility',
49
50
  state: e.reasons.some((r) => /unproven|missing/.test(r)) ? 'unknown' : 'fail',
50
51
  environmentId: e.environmentId, evidence: e }));
@@ -54,7 +55,7 @@ export function planIntake(input, now) {
54
55
  terms.push(...localTerms.map((t) => ({ ...t, environmentId: input.origin.environmentId })));
55
56
  return localTerms.every((t) => t.state === 'pass');
56
57
  };
57
- const result = (disposition, reason, selected = null, extra = {}) => structuredClone({
58
+ const result = (disposition, reason, selected = null, extra = /** @type {{ launch?: object }} */ ({})) => structuredClone({
58
59
  schemaVersion: 1, kind: 'intake-plan', configDigest: input.configDigest, evaluatedAt: now,
59
60
  request: input.request, disposition, reason, selected, terms,
60
61
  counts: Object.fromEntries(['pass', 'fail', 'unknown', 'n/a'].map((s) => [s, terms.filter((t) => t.state === s).length])),
@@ -7,6 +7,7 @@ export function sshArgv(host) {
7
7
  '-o', 'ClearAllForwardings=yes', '-o', 'PermitLocalCommand=no',
8
8
  ...(host.user ? ['-l', host.user] : []), '--', host.destination, PROC_COMMAND];
9
9
  }
10
+ /** @returns {Promise<void>} */
10
11
  export function wait(ms, signal) {
11
12
  return new Promise((resolve, reject) => {
12
13
  const cancel = () => { clearTimeout(timer); signal.removeEventListener('abort', cancel); reject(signal.reason); };
@@ -11,7 +11,7 @@ function claudeWeeklyOnly(usage, now) {
11
11
  || usage.seven_day_opus != null || usage.seven_day_sonnet != null) return false;
12
12
  const aggregate = usage.limits.filter((w) => w?.kind === 'weekly_all');
13
13
  return aggregate.length === 1 && usage.limits.every((w) => {
14
- if (!w || w.group !== 'weekly' || typeof w.is_active !== 'boolean' || !percent(w.percent)
14
+ if (w?.group !== 'weekly' || typeof w.is_active !== 'boolean' || !percent(w.percent)
15
15
  || !reset(w.resets_at)) return false;
16
16
  if (w.kind === 'weekly_all') return w.is_active === true && w.scope === null
17
17
  && w.percent === weekly.utilization && w.resets_at === weekly.resets_at;
@@ -1,5 +1,5 @@
1
1
  import { gitArgv } from './git-argv.js';
2
- import { existsSync } from 'node:fs';
2
+ import { existsSync, readFileSync } from 'node:fs';
3
3
 
4
4
  const lockfiles = ['bun.lock', 'bun.lockb', 'package-lock.json', 'npm-shrinkwrap.json', 'pnpm-lock.yaml', 'yarn.lock'];
5
5
  const help = `Usage: bun scripts/pr-shape.js --base <ref> --head <ref>
@@ -106,9 +106,168 @@ function summarize(rows, evidence) {
106
106
  } } };
107
107
  }
108
108
 
109
+ const proofFields = { files: 'Files', additions: 'Lines added', deletions: 'Lines removed',
110
+ commits: 'Commits', head: 'Head SHA', base: 'Base SHA' };
111
+ const proofHelp = `Usage: bun scripts/pr-shape.js --proof --base <ref> --head <ref> [--body <path>]
112
+ bun scripts/pr-shape.js --proof --pr <number> --repo <owner/repo> [--body <path>]
113
+
114
+ --proof Render/check PR Proof facts (separate from the unchanged shape mode)
115
+ --base Actual current PR base ref, resolved with read-only Git
116
+ --head Current candidate ref, resolved with read-only Git
117
+ --body Optional UTF-8 PR body file to check; never modified
118
+ --pr Positive PR number; read-only gh api fetches current facts and body
119
+ --repo Explicit owner/repo for --pr; cannot combine --pr with --base/--head
120
+ --help Show this mode's flags, output and exit codes
121
+
122
+ JSON: block (Markdown or null if facts unavailable), terms (each status, value,
123
+ evidence including reproducing commands, separate child exit codes/errors,
124
+ and stated body values when checked).
125
+ Git counts use the merge-base diff (-M numstat; binary lines count as zero),
126
+ and commits reachable from head but not base. PR mode reads REST pull facts,
127
+ including numeric commits (no truncated commit-list pagination), then resolves
128
+ the live base tip via git/ref/heads/<base.ref>. Evidence keeps snapshot/live SHAs.
129
+ No --body in Git mode renders only; PR mode checks the fetched body by default.
130
+ Checks require exactly one <!-- axstack:proof --> ... <!-- /axstack:proof -->
131
+ block and one line per field: Files, Lines added, Lines removed, Commits,
132
+ Head SHA, Base SHA. Counts must match; SHA prefixes need at least 7 hex digits.
133
+ Other prose and SHAs are ignored. Refresh refs before checking a local candidate.
134
+ Missing/duplicate/invalid body facts fail; unavailable Git/gh/body data is unknown.
135
+ This fact mode is read-only and stateless: writes nothing, grants no authority,
136
+ and supplies no aggregate verdict. No dispatch, retry, scheduling or merge.
137
+ Exit codes: 0 measured (including failed terms), 1 invalid input,
138
+ 2 incomplete (one or more unknown terms).
139
+ `;
140
+
141
+ function proofOptions(argv) {
142
+ const options = {};
143
+ for (let i = 0; i < argv.length; i += 2) {
144
+ const flag = argv[i], value = argv[i + 1];
145
+ if (!['--base', '--head', '--body', '--pr', '--repo'].includes(flag) ||
146
+ !value || value.startsWith('-') || flag in options) throw Error(`invalid proof argument ${flag}; use --proof --help`);
147
+ options[flag] = value;
148
+ }
149
+ if (options['--pr']) {
150
+ if (!/^[1-9]\d*$/.test(options['--pr']) || !/^[\w.-]+\/[\w.-]+$/.test(options['--repo'] ?? '') ||
151
+ options['--base'] || options['--head']) throw Error('--pr requires --repo owner/repo and excludes --base/--head');
152
+ } else if (!options['--base'] || !options['--head'] || options['--repo']) {
153
+ throw Error('proof requires --base and --head, or --pr and --repo');
154
+ }
155
+ return options;
156
+ }
157
+
158
+ function proof(argv, io) {
159
+ if (argv.includes('--help')) { io.stdout(proofHelp); return 0; }
160
+ const options = proofOptions(argv);
161
+ const terms = Object.keys(proofFields).map((id) => ({ id, status: 'unknown', value: null,
162
+ evidence: { cwd: process.cwd(), commands: [], results: [], reason: 'data unavailable' } }));
163
+ const term = (id) => terms.find((t) => t.id === id);
164
+ const query = (ids, args) => {
165
+ for (const id of ids) term(id).evidence.commands.push(args);
166
+ try {
167
+ const result = run(args);
168
+ for (const id of ids) term(id).evidence.results.push({ exitCode: result.code, stderr: result.stderr.trim() });
169
+ if (result.code) {
170
+ for (const id of ids) term(id).evidence.reason = result.stderr.trim() || `command exit ${result.code}`;
171
+ return null;
172
+ }
173
+ return result.stdout;
174
+ } catch (error) {
175
+ for (const id of ids) {
176
+ term(id).evidence.results.push({ exitCode: null, error: error.message });
177
+ term(id).evidence.reason = error.message;
178
+ }
179
+ return null;
180
+ }
181
+ };
182
+ const assign = (id, value) => {
183
+ const valid = ['head', 'base'].includes(id) ? /^[a-f0-9]{40}(?:[a-f0-9]{24})?$/i.test(value ?? '')
184
+ : Number.isSafeInteger(value) && value >= 0;
185
+ if (valid) Object.assign(term(id), { status: 'pass', value, evidence: { ...term(id).evidence, reason: 'observed current fact' } });
186
+ };
187
+ let body, bodyError;
188
+ if (options['--pr']) {
189
+ const raw = query(Object.keys(proofFields), ['gh', 'api', `repos/${options['--repo']}/pulls/${options['--pr']}`]);
190
+ try {
191
+ const data = JSON.parse(raw ?? '{}');
192
+ for (const [id, value] of Object.entries({ files: data.changed_files, additions: data.additions,
193
+ deletions: data.deletions, commits: data.commits, head: data.head?.sha })) assign(id, value);
194
+ const base = term('base');
195
+ Object.assign(base.evidence, { snapshotSha: data.base?.sha ?? null, liveSha: null,
196
+ baseRef: typeof data.base?.ref === 'string' ? data.base.ref : null });
197
+ if (base.evidence.baseRef) {
198
+ const ref = base.evidence.baseRef.split('/').map(encodeURIComponent).join('/');
199
+ const live = query(['base'], ['gh', 'api', `repos/${options['--repo']}/git/ref/heads/${ref}`]);
200
+ if (live !== null) {
201
+ try {
202
+ base.evidence.liveSha = JSON.parse(live)?.object?.sha ?? null;
203
+ base.evidence.reason = 'live base ref response has no valid commit SHA';
204
+ assign('base', base.evidence.liveSha);
205
+ } catch { base.evidence.reason = 'invalid live base ref JSON response'; }
206
+ }
207
+ } else base.evidence.reason = 'PR base.ref unavailable; cannot resolve live base tip';
208
+ if (typeof data.body === 'string') body = data.body;
209
+ else bodyError = 'PR body unavailable in gh response';
210
+ } catch { bodyError = 'invalid gh JSON response'; }
211
+ } else {
212
+ for (const id of ['base', 'head']) {
213
+ const raw = query([id], command('rev-parse', '--verify', '--end-of-options', `${options[`--${id}`]}^{commit}`));
214
+ if (raw !== null) assign(id, raw.trim());
215
+ }
216
+ const counts = ['files', 'additions', 'deletions', 'commits'];
217
+ if (term('base').value && term('head').value) {
218
+ const base = term('base').value, head = term('head').value;
219
+ const commits = query(['commits'], command('rev-list', '--count', `${base}..${head}`, '--'));
220
+ if (commits !== null && /^\d+\s*$/.test(commits)) assign('commits', Number(commits));
221
+ const ids = counts.slice(0, 3);
222
+ const merge = query(ids, command('merge-base', base, head));
223
+ if (merge !== null) {
224
+ const diff = query(ids, command('diff', '-M', '--no-relative', '--no-ext-diff', '--no-textconv', '--numstat', '-z', `${merge.trim()}..${head}`, '--'));
225
+ if (diff !== null) {
226
+ const rows = numstat(diff);
227
+ assign('files', rows.length);
228
+ assign('additions', rows.reduce((sum, row) => sum + row.additions, 0));
229
+ assign('deletions', rows.reduce((sum, row) => sum + row.deletions, 0));
230
+ }
231
+ }
232
+ } else {
233
+ for (const id of counts) term(id).evidence = { ...term(id).evidence,
234
+ commands: [...term('base').evidence.commands, ...term('head').evidence.commands],
235
+ results: [...term('base').evidence.results, ...term('head').evidence.results],
236
+ reason: 'base/head resolution unavailable; counts cannot be measured' };
237
+ }
238
+ }
239
+ const block = terms.every((t) => t.status === 'pass')
240
+ ? ['<!-- axstack:proof -->', ...terms.map((t) => `${proofFields[t.id]}: ${t.value}`), '<!-- /axstack:proof -->'].join('\n') : null;
241
+ if (options['--body']) {
242
+ try { body = readFileSync(options['--body'], 'utf8'); bodyError = null; }
243
+ catch (error) { bodyError = error.message; }
244
+ }
245
+ if (options['--body'] || options['--pr']) {
246
+ const blocks = [...(body ?? '').matchAll(/<!-- axstack:proof -->\r?\n([\s\S]*?)\r?\n<!-- \/axstack:proof -->/g)];
247
+ for (const t of terms) {
248
+ if (options['--body']) t.evidence.bodyPath = options['--body'];
249
+ if (bodyError) { t.status = 'unknown'; t.evidence.reason = bodyError; continue; }
250
+ if (t.status === 'unknown') continue;
251
+ const values = blocks.length === 1 ? blocks[0][1].split(/\r?\n/)
252
+ .filter((line) => line.startsWith(`${proofFields[t.id]}:`)).map((line) => line.slice(proofFields[t.id].length + 1).trim()) : [];
253
+ t.evidence.stated = values;
254
+ const stated = values[0] ?? '';
255
+ const matches = ['base', 'head'].includes(t.id)
256
+ ? /^[a-f0-9]{7,64}$/i.test(stated) && t.value.toLowerCase().startsWith(stated.toLowerCase())
257
+ : /^(0|[1-9]\d*)$/.test(stated) && Number(stated) === t.value;
258
+ t.status = values.length === 1 && matches ? 'pass' : 'fail';
259
+ t.evidence.reason = blocks.length === 0 ? 'no facts block; render with --proof and paste the returned block into the PR body'
260
+ : blocks.length !== 1 ? 'expected exactly one facts block' : 'compare stated value with current fact; one field required';
261
+ }
262
+ }
263
+ io.stdout(`${JSON.stringify({ block, terms })}\n`);
264
+ return terms.some((t) => t.status === 'unknown') ? 2 : 0;
265
+ }
266
+
109
267
  export function main(argv, io = { stdout: (text) => process.stdout.write(text), stderr: (text) => process.stderr.write(text) }) {
110
268
  try {
111
- if (argv.includes('--help')) { io.stdout(help); return 0; }
269
+ if (argv[0] === '--proof') return proof(argv.slice(1), io);
270
+ if (argv.includes('--help')) { io.stdout(`${help}\n${proofHelp}`); return 0; }
112
271
  const options = optionsFrom(argv);
113
272
  const root = run(command('rev-parse', '--show-toplevel'));
114
273
  if (root.code) throw new Error('run this helper from a Git checkout');
@@ -5,6 +5,7 @@ const installs = {
5
5
  bun: ['install', '--frozen-lockfile'], npm: ['ci'],
6
6
  pnpm: ['install', '--frozen-lockfile'], yarn: ['install', '--immutable'],
7
7
  };
8
+ /** @type {[string, string[]][]} */
8
9
  const groups = [['env.build', ['build']], ['testing.test', ['test']], ['testing.lint-typecheck', ['lint', 'typecheck']]];
9
10
  const drainGraceMs = 200;
10
11
  // No shell interpolation, and the wrapper preserves the command's allowlisted env.
@@ -57,6 +58,7 @@ async function runCommand(commands, paths, kind, argv, cwd, env, limits, state,
57
58
  clearTimeout(timer);
58
59
  killGroup(proc);
59
60
  });
61
+ /** @type {Promise<void>} */
60
62
  const timeout = new Promise((resolve) => {
61
63
  timer = setTimeout(() => { step.timedOut = true; killGroup(proc); resolve(); }, limits.timeoutMs);
62
64
  });