axstack 0.66.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.
- package/README.md +2 -2
- package/docs/host-operations.md +6 -3
- package/package.json +1 -1
- package/skills/axstack/references/automations.md +8 -5
- package/skills/axstack/references/candidate-publication.md +7 -12
- package/skills/axstack/references/fleet-verification.md +3 -3
- package/skills/axstack/references/lifecycle.md +1 -1
- package/skills/axstack/references/pr-shape.md +8 -0
- package/skills/axstack/references/review-manager-prompt.md +16 -0
- package/skills/axstack/references/schedule-policy.json +123 -0
- package/skills/axstack/references/t3-runtime.md +5 -5
- package/skills/axstack/references/workspace-hygiene.md +9 -3
- package/skills/axstack/scripts/pr-shape.js +161 -2
- package/skills/axstack/scripts/schedule-drift.js +130 -0
- package/skills/axstack/scripts/scratch.js +201 -0
- package/skills/axstack-audit/SKILL.md +2 -0
- package/skills/axstack-verify/SKILL.md +8 -1
- 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
|
|
125
|
-
(`everyMs:
|
|
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
|
|
package/docs/host-operations.md
CHANGED
|
@@ -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
|
|
47
|
-
(`everyMs:
|
|
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
|
|
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.
|
|
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`.
|
|
53
|
-
|
|
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
|
-
|
|
220
|
-
|
|
221
|
-
|
|
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,
|
|
46
|
-
current base and
|
|
47
|
-
|
|
48
|
-
After every push, before post-push diligence or merge-ready,
|
|
49
|
-
|
|
50
|
-
|
|
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
|
|
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
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
|
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
|
-
|
|
41
|
-
|
|
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
|
-
|
|
502
|
-
|
|
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
|
-
|
|
29
|
-
|
|
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
|
-
|
|
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.
|
|
@@ -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
|
|
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');
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
import { readFileSync } from 'node:fs';
|
|
3
|
+
|
|
4
|
+
const HELP = `schedule-drift — canonical schedule comparison (R2 fact mode)
|
|
5
|
+
bun schedule-drift.js --export FILE --bindings FILE [--prompts DIR] [--now ISO] [--max-age-seconds N]
|
|
6
|
+
--export FILE Saved JSON: {version:1,host,exportedAt,complete:true,tasks:[{scheduledTaskId,
|
|
7
|
+
projectId,prompt,schedule,enabled}]}. Export every relevant project; never use a live database.
|
|
8
|
+
--bindings FILE Private JSON: {host,schedules:[{promptFile,scheduledTaskId,projectId,enabled,schedule,
|
|
9
|
+
values:{HOST_TOKEN:"literal value"}}]}. Declare all three packaged prompt filenames exactly once.
|
|
10
|
+
For intentional host exclusions use {promptFile,absent:true,scheduledTaskId?:expectedId}.
|
|
11
|
+
Fresh complete matching-host coverage yields n/a; any matching declared task ID fails.
|
|
12
|
+
Without a task ID, absent:true is an explicit host-scope declaration, not identity discovery.
|
|
13
|
+
Values substitute only explicit {{HOST_TOKEN}} placeholders. No implicit trim or normalization.
|
|
14
|
+
A live prompt containing any unfilled {{HOST_ prefix fails, even if bound bytes match.
|
|
15
|
+
Schedule is the exact host declaration; review-manager additionally requires interval 1800000.
|
|
16
|
+
--prompts DIR Directory containing the three packaged prompt files; default: installed ../references.
|
|
17
|
+
--now ISO Observation time with timezone; default: current UTC. Saved times prove no live delivery.
|
|
18
|
+
--max-age-seconds N Maximum export age, inclusive; positive integer, default 300. Future exports are unknown.
|
|
19
|
+
--help Show flags, schema, effects and limitations.
|
|
20
|
+
No writes, subprocesses, network, database access, schedule mutations or persistent state.
|
|
21
|
+
Stdout reports per-term pass/fail/unknown/n/a with evidence and counts only; no aggregate verdict or authority.
|
|
22
|
+
Exports and bindings stay private. Output contains hashes and filenames, never prompts, IDs or host values.
|
|
23
|
+
Missing, malformed, unavailable, stale or incomplete evidence is unknown; no comparison passes without fresh coverage.
|
|
24
|
+
Exit: 0 measured (including failed facts), 1 invalid CLI/error, 2 incomplete (unknown facts).
|
|
25
|
+
`;
|
|
26
|
+
const files = ['review-manager-prompt.md', 'pr-triage-nightly.md', 'test-audit-weekly.md'];
|
|
27
|
+
const sha256 = (bytes) => new Bun.CryptoHasher('sha256').update(bytes).digest('hex');
|
|
28
|
+
const time = (value) => typeof value === 'string' && /T.*(?:Z|[+-]\d\d:\d\d)$/.test(value) ? Date.parse(value) : NaN;
|
|
29
|
+
const object = (v) => v !== null && typeof v === 'object' && !Array.isArray(v);
|
|
30
|
+
const nonempty = (v) => typeof v === 'string' && v.length > 0;
|
|
31
|
+
const ordered = (value) => Array.isArray(value) ? value.map(ordered) : object(value)
|
|
32
|
+
? Object.fromEntries(Object.keys(value).sort().map((key) => [key, ordered(value[key])])) : value;
|
|
33
|
+
const equal = (a, b) => JSON.stringify(ordered(a)) === JSON.stringify(ordered(b));
|
|
34
|
+
|
|
35
|
+
function options(argv) {
|
|
36
|
+
const args = { '--prompts': `${import.meta.dir}/../references`, '--now': new Date().toISOString(), '--max-age-seconds': '300' };
|
|
37
|
+
const seen = new Set();
|
|
38
|
+
for (let i = 0; i < argv.length; i += 2) {
|
|
39
|
+
const key = argv[i];
|
|
40
|
+
if (!['--export', '--bindings', '--prompts', '--now', '--max-age-seconds'].includes(key) || !argv[i + 1] || seen.has(key)) {
|
|
41
|
+
throw new Error(`invalid argument: ${key}`);
|
|
42
|
+
}
|
|
43
|
+
seen.add(key);
|
|
44
|
+
args[key] = argv[i + 1];
|
|
45
|
+
}
|
|
46
|
+
if (!args['--export'] || !args['--bindings'] || !Number.isFinite(time(args['--now'])) ||
|
|
47
|
+
!/^[1-9]\d*$/.test(args['--max-age-seconds']) || !Number.isSafeInteger(Number(args['--max-age-seconds']))) {
|
|
48
|
+
throw new Error('expected --export, --bindings, timezone-qualified --now and positive --max-age-seconds');
|
|
49
|
+
}
|
|
50
|
+
return args;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function compare(args) {
|
|
54
|
+
const terms = [];
|
|
55
|
+
const term = (id, status, evidence) => terms.push({ id, status, evidence });
|
|
56
|
+
let source, bindings, exportSha256 = null, bindingsSha256 = null;
|
|
57
|
+
try {
|
|
58
|
+
const bytes = readFileSync(args['--export']);
|
|
59
|
+
exportSha256 = sha256(bytes);
|
|
60
|
+
source = JSON.parse(bytes.toString());
|
|
61
|
+
const declared = readFileSync(args['--bindings']);
|
|
62
|
+
bindingsSha256 = sha256(declared);
|
|
63
|
+
bindings = JSON.parse(declared.toString());
|
|
64
|
+
} catch { /* A missing or malformed saved export/binding is unavailable evidence. */ }
|
|
65
|
+
const age = (time(args['--now']) - time(source?.exportedAt)) / 1000;
|
|
66
|
+
const fresh = source?.version === 1 && source.complete === true && nonempty(source.host) &&
|
|
67
|
+
Array.isArray(source.tasks) && Number.isFinite(age) && age >= 0 && age <= Number(args['--max-age-seconds']);
|
|
68
|
+
const declared = object(bindings) && nonempty(bindings.host) && Array.isArray(bindings.schedules);
|
|
69
|
+
term('export', fresh ? 'pass' : 'unknown', fresh ? `complete export; age ${age}s; sha256 ${exportSha256}` : 'unavailable, incomplete, malformed, stale or future export');
|
|
70
|
+
term('host', !fresh || !declared ? 'unknown' : source.host === bindings.host ? 'pass' : 'fail', 'export host compared with private declared host');
|
|
71
|
+
for (const file of files) {
|
|
72
|
+
const rows = declared ? bindings.schedules.filter((b) => b?.promptFile === file) : [];
|
|
73
|
+
const binding = rows.length === 1 ? rows[0] : null;
|
|
74
|
+
const tasks = fresh && nonempty(binding?.scheduledTaskId)
|
|
75
|
+
? source.tasks.filter((t) => t?.scheduledTaskId === binding.scheduledTaskId) : [];
|
|
76
|
+
const task = tasks.length === 1 ? tasks[0] : null;
|
|
77
|
+
if (binding?.absent === true) {
|
|
78
|
+
const status = !fresh || source.host !== bindings.host ? 'unknown' : tasks.length ? 'fail' : 'n/a';
|
|
79
|
+
for (const suffix of ['binding', 'prompt', 'cadence', 'enabled']) {
|
|
80
|
+
term(`${file}.${suffix}`, status, 'explicit host exclusion; fresh complete matching-host export required; any declared task ID must be absent');
|
|
81
|
+
}
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
const usable = fresh && declared && rows.length === 1 && task !== null;
|
|
85
|
+
const fact = (suffix, known, matches, evidence) => term(`${file}.${suffix}`,
|
|
86
|
+
!usable || !known ? 'unknown' : matches ? 'pass' : 'fail', evidence);
|
|
87
|
+
fact('binding', nonempty(binding?.projectId) && nonempty(task?.projectId),
|
|
88
|
+
task?.projectId === binding?.projectId, 'exact schedule ID and project binding; missing or duplicate identities are unknown');
|
|
89
|
+
let expected = null, packagedSha256 = null;
|
|
90
|
+
try {
|
|
91
|
+
const bytes = readFileSync(`${args['--prompts']}/${file}`);
|
|
92
|
+
packagedSha256 = sha256(bytes);
|
|
93
|
+
expected = new TextDecoder('utf-8', { fatal: true, ignoreBOM: true }).decode(bytes);
|
|
94
|
+
expected = expected.replace(/\{\{(HOST_[A-Z_]+)\}\}/g, (_, key) => {
|
|
95
|
+
if (!object(binding?.values) || typeof binding.values[key] !== 'string') throw new Error('unbound host token');
|
|
96
|
+
return binding.values[key];
|
|
97
|
+
});
|
|
98
|
+
} catch { expected = null; }
|
|
99
|
+
const unfilled = nonempty(task?.prompt) && task.prompt.includes('{{HOST_');
|
|
100
|
+
fact('prompt', nonempty(task?.prompt) && (unfilled || expected !== null), !unfilled && expected === task?.prompt,
|
|
101
|
+
`live host tokens must be filled; exact UTF-8 bytes after declared host-token substitution; packaged sha256 ${packagedSha256 ?? 'unavailable'}`);
|
|
102
|
+
const scheduleKnown = validSchedule(binding?.schedule) && validSchedule(task?.schedule);
|
|
103
|
+
const canonical = file !== files[0] || equal(binding?.schedule, { type: 'interval', everyMs: 1800000 });
|
|
104
|
+
fact('cadence', scheduleKnown, canonical && equal(task?.schedule, binding?.schedule), 'exact declared schedule; review-manager interval fixed at 1800000ms');
|
|
105
|
+
fact('enabled', typeof binding?.enabled === 'boolean' && typeof task?.enabled === 'boolean',
|
|
106
|
+
task?.enabled === binding?.enabled, 'enabled state compared with private declaration');
|
|
107
|
+
}
|
|
108
|
+
const counts = Object.fromEntries(['pass', 'fail', 'unknown', 'n/a'].map((s) => [s, terms.filter((t) => t.status === s).length]));
|
|
109
|
+
return { version: 1, observedAt: args['--now'], exportSha256, bindingsSha256, terms, counts };
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function validSchedule(s) {
|
|
113
|
+
if (!object(s)) return false;
|
|
114
|
+
if (s.type === 'interval') return Number.isSafeInteger(s.everyMs) && s.everyMs > 0;
|
|
115
|
+
if (s.type !== 'fixed_time' || !/^(?:[01]\d|2[0-3]):[0-5]\d$/.test(s.timeOfDay)) return false;
|
|
116
|
+
return s.weekdays === undefined || s.weekdays === null || Array.isArray(s.weekdays) && s.weekdays.length > 0 &&
|
|
117
|
+
s.weekdays.every((d) => Number.isSafeInteger(d) && d >= 0 && d <= 6);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
try {
|
|
121
|
+
if (process.argv.slice(2).length === 1 && process.argv[2] === '--help') console.log(HELP);
|
|
122
|
+
else {
|
|
123
|
+
const report = compare(options(process.argv.slice(2)));
|
|
124
|
+
console.log(JSON.stringify(report, null, 2));
|
|
125
|
+
process.exitCode = report.counts.unknown ? 2 : 0;
|
|
126
|
+
}
|
|
127
|
+
} catch (error) {
|
|
128
|
+
console.error(`schedule-drift: ${error.message}`);
|
|
129
|
+
process.exitCode = 1;
|
|
130
|
+
}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { chmodSync, lstatSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, writeFileSync } from 'node:fs';
|
|
2
|
+
|
|
3
|
+
const help = `Usage: bun scratch.js run [--root <existing-private-parent>] -- <command> [args...]
|
|
4
|
+
bun scratch.js plan --root <scratch-root> [--root <scratch-root> ...]
|
|
5
|
+
bun scratch.js --help
|
|
6
|
+
|
|
7
|
+
--root Absolute directory, with no symlink components. Run accepts one existing
|
|
8
|
+
owned 0700 parent outside realpath(HOME). Plan accepts named roots only.
|
|
9
|
+
--help Print flags, effects and exit codes; no writes or child process.
|
|
10
|
+
run Without --root, use a safe TMPDIR parent; if absent or unsafe, use /tmp.
|
|
11
|
+
Create a fresh axstack-scratch-<random>/ root (0700), owner.json (0600),
|
|
12
|
+
cwd/ (0700), tmp/ (0700). Print their declared absolute paths as JSON.
|
|
13
|
+
The owner stamp identifies this helper's paths, not execution authority.
|
|
14
|
+
plan Read only declared root metadata, owner.json and cwd/tmp metadata;
|
|
15
|
+
validate path components and realpath(HOME). No scan or deletion.
|
|
16
|
+
|
|
17
|
+
Process effects: run launches exactly the given command without a shell, waits
|
|
18
|
+
for its exit, sets cwd and TMPDIR to the declared children, inherits other env
|
|
19
|
+
(including HOME), and sends child stdout/stderr to this helper's stderr.
|
|
20
|
+
Filesystem effects: run creates only the paths above, retaining even partial
|
|
21
|
+
creation on error. Plan has no filesystem writes. Cleanup: none in any mode;
|
|
22
|
+
caller owns validated literal-path cleanup, including after failures.
|
|
23
|
+
Network/container effects: none by the helper. The child may start processes,
|
|
24
|
+
write files, use the network or containers under the caller's authority.
|
|
25
|
+
This is NOT filesystem containment: absolute paths and HOME remain the caller's
|
|
26
|
+
responsibility. It provides no process containment or descendant cleanup.
|
|
27
|
+
No dispatch, scheduling, retries, merging or phase selection.
|
|
28
|
+
|
|
29
|
+
Reports per-term pass/fail/unknown/n/a with evidence, no aggregate verdict.
|
|
30
|
+
Exit 0: measured, including failed plan criteria or a nonzero child exit.
|
|
31
|
+
Exit 1: invalid input or execution error. Exit 2: hold or incomplete observation.
|
|
32
|
+
Child exitCode and signal are stored separately in the JSON child field.
|
|
33
|
+
Check those fields: helper exit 0 does not mean the child passed.
|
|
34
|
+
Repository commands must select the repository explicitly.
|
|
35
|
+
The --cwd= form is required because the spaced bun --cwd <repo> form prints help
|
|
36
|
+
and exits 0, a false green. For example:
|
|
37
|
+
run -- bun --cwd=/absolute/repo run test tests/example.test.js
|
|
38
|
+
HOME means the canonical environment HOME at startup, not the account database.
|
|
39
|
+
With a fixture HOME, the caller must independently exclude the account's home.
|
|
40
|
+
Path components reject symlinks and world-writable directories without sticky
|
|
41
|
+
mode. Hostile concurrent path replacement remains the caller's responsibility.
|
|
42
|
+
`;
|
|
43
|
+
|
|
44
|
+
const normalize = (path) => path.replace(/\/+/g, '/').replace(/\/$/, '') || '/';
|
|
45
|
+
|
|
46
|
+
function options(argv) {
|
|
47
|
+
const mode = argv[0];
|
|
48
|
+
if (!['run', 'plan'].includes(mode)) throw Error('pass run or plan; see --help');
|
|
49
|
+
const separator = argv.indexOf('--');
|
|
50
|
+
const flags = argv.slice(1, separator < 0 ? undefined : separator);
|
|
51
|
+
const roots = [];
|
|
52
|
+
for (let i = 0; i < flags.length; i += 2) {
|
|
53
|
+
const path = flags[i + 1];
|
|
54
|
+
if (flags[i] !== '--root' || !path?.startsWith('/') || path.includes('\0') || path.split('/').some((p) => p === '..' || p === '.')) {
|
|
55
|
+
throw Error('pass --root <absolute-path> without dot components; see --help');
|
|
56
|
+
}
|
|
57
|
+
roots.push(normalize(path));
|
|
58
|
+
}
|
|
59
|
+
const command = separator < 0 ? [] : argv.slice(separator + 1);
|
|
60
|
+
if (mode === 'run' ? roots.length > 1 || !command.length : !roots.length || separator >= 0) {
|
|
61
|
+
throw Error('run needs one command and at most one parent; plan needs roots only; see --help');
|
|
62
|
+
}
|
|
63
|
+
return { mode, roots, command };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function unsafeComponent(path) {
|
|
67
|
+
let component = '';
|
|
68
|
+
for (const part of path.split('/').filter(Boolean)) {
|
|
69
|
+
component += `/${part}`;
|
|
70
|
+
const stat = lstatSync(component);
|
|
71
|
+
if (stat.isSymbolicLink()) return { component, reason: 'symlink; not followed' };
|
|
72
|
+
if ((stat.mode & 0o002) && !(stat.mode & 0o1000)) return { component, reason: 'world-writable without sticky mode' };
|
|
73
|
+
}
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function inspect(path, home, terms, systemParent = false) {
|
|
78
|
+
const add = (id, status, evidence) => terms.push({ root: path, id, status, evidence });
|
|
79
|
+
try {
|
|
80
|
+
if (!path.startsWith('/') || path.split('/').some((part) => part === '.' || part === '..')) {
|
|
81
|
+
add('path', 'fail', 'absolute path without dot components required');
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
const unsafe = unsafeComponent(path);
|
|
85
|
+
if (unsafe) {
|
|
86
|
+
add('path-components', 'fail', unsafe);
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
add('path-components', 'pass', 'no symlinks or world-writable non-sticky components');
|
|
90
|
+
const stat = lstatSync(path);
|
|
91
|
+
const actual = realpathSync(path);
|
|
92
|
+
const outside = actual !== home && !actual.startsWith(`${home === '/' ? '' : home}/`);
|
|
93
|
+
const owner = stat.uid === process.getuid() || (systemParent && stat.uid === 0);
|
|
94
|
+
const mode = stat.mode & 0o7777;
|
|
95
|
+
const permissions = systemParent ? (!(mode & 0o022) || !!(mode & 0o1000)) : mode === 0o700;
|
|
96
|
+
add('directory', stat.isDirectory() ? 'pass' : 'fail', { path });
|
|
97
|
+
add('owner', owner ? 'pass' : 'fail', { uid: stat.uid, expected: process.getuid(), systemParent });
|
|
98
|
+
add('mode', permissions ? 'pass' : 'fail', { mode: mode.toString(8), systemParent });
|
|
99
|
+
add('outside-home', outside ? 'pass' : 'fail', { home, path });
|
|
100
|
+
return stat.isDirectory() && owner && permissions && outside;
|
|
101
|
+
} catch (error) {
|
|
102
|
+
add('metadata', 'unknown', { code: error.code, message: error.message });
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function stampFor(root) {
|
|
108
|
+
return { version: 1, kind: 'axstack-scratch', uid: process.getuid(), root, cwd: `${root}/cwd`, tmp: `${root}/tmp` };
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function inspectStamp(root, terms) {
|
|
112
|
+
const path = `${root}/owner.json`;
|
|
113
|
+
try {
|
|
114
|
+
const stat = lstatSync(path);
|
|
115
|
+
if (!stat.isFile() || stat.uid !== process.getuid() || (stat.mode & 0o7777) !== 0o600) {
|
|
116
|
+
terms.push({ root, id: 'stamp', status: 'fail', evidence: { path, reason: 'need owned regular 0600 stamp; links not followed' } });
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const expected = stampFor(root);
|
|
120
|
+
let stamp;
|
|
121
|
+
try { stamp = JSON.parse(readFileSync(path, 'utf8')); } catch (error) {
|
|
122
|
+
if (!(error instanceof SyntaxError)) throw error;
|
|
123
|
+
terms.push({ root, id: 'stamp', status: 'fail', evidence: { path, reason: 'malformed JSON' } });
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
const matches = stamp && Object.entries(expected).every(([key, value]) => stamp[key] === value);
|
|
127
|
+
terms.push({ root, id: 'stamp', status: matches ? 'pass' : 'fail', evidence: { path, expected } });
|
|
128
|
+
} catch (error) {
|
|
129
|
+
terms.push({ root, id: 'stamp', status: 'unknown', evidence: { path, code: error.code, message: error.message } });
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export async function main(argv) {
|
|
134
|
+
if (argv.length === 1 && argv[0] === '--help') { console.log(help); return 0; }
|
|
135
|
+
const report = { mode: null, roots: [], terms: [], child: null };
|
|
136
|
+
try {
|
|
137
|
+
const { mode, roots, command } = options(argv);
|
|
138
|
+
Object.assign(report, { mode, roots });
|
|
139
|
+
let home;
|
|
140
|
+
try {
|
|
141
|
+
if (!process.env.HOME) throw Error('HOME unavailable; cannot establish real HOME boundary');
|
|
142
|
+
home = realpathSync(process.env.HOME);
|
|
143
|
+
} catch (error) {
|
|
144
|
+
report.terms.push({ id: 'home', status: 'unknown', evidence: error.message });
|
|
145
|
+
console.log(JSON.stringify(report));
|
|
146
|
+
return 2;
|
|
147
|
+
}
|
|
148
|
+
if (mode === 'plan') {
|
|
149
|
+
for (const root of roots) {
|
|
150
|
+
if (inspect(root, home, report.terms)) {
|
|
151
|
+
inspectStamp(root, report.terms);
|
|
152
|
+
inspect(`${root}/cwd`, home, report.terms);
|
|
153
|
+
inspect(`${root}/tmp`, home, report.terms);
|
|
154
|
+
} else {
|
|
155
|
+
report.terms.push({ root, id: 'stamp', status: 'n/a', evidence: 'root not safe to read' });
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
} else {
|
|
159
|
+
let parent = roots[0];
|
|
160
|
+
if (!parent && process.env.TMPDIR) {
|
|
161
|
+
// Rejected environment candidates are facts, but do not prevent fallback.
|
|
162
|
+
const candidate = normalize(process.env.TMPDIR);
|
|
163
|
+
if (inspect(candidate, home, report.terms)) parent = candidate;
|
|
164
|
+
else report.terms.push({ id: 'fallback', status: 'pass', evidence: 'unsafe TMPDIR ignored; using /tmp' });
|
|
165
|
+
}
|
|
166
|
+
if (roots.length ? !inspect(parent, home, report.terms) : !parent && !inspect('/tmp', home, report.terms, true)) {
|
|
167
|
+
console.log(JSON.stringify(report));
|
|
168
|
+
return 2;
|
|
169
|
+
}
|
|
170
|
+
parent ??= '/tmp';
|
|
171
|
+
report.terms.push({ id: 'parent', status: 'pass', evidence: parent });
|
|
172
|
+
const root = mkdtempSync(`${parent}/axstack-scratch-`);
|
|
173
|
+
Object.assign(report, stampFor(root));
|
|
174
|
+
chmodSync(root, 0o700);
|
|
175
|
+
writeFileSync(`${root}/owner.json`, `${JSON.stringify(stampFor(root))}\n`, { mode: 0o600, flag: 'wx' });
|
|
176
|
+
mkdirSync(`${root}/cwd`, { mode: 0o700 });
|
|
177
|
+
mkdirSync(`${root}/tmp`, { mode: 0o700 });
|
|
178
|
+
// Check the actual filesystem rather than assuming creation preserved mode/owner.
|
|
179
|
+
const created = [];
|
|
180
|
+
const safe = [root, `${root}/cwd`, `${root}/tmp`].every((path) => inspect(path, home, created));
|
|
181
|
+
report.terms.push(...created);
|
|
182
|
+
if (!safe) { console.log(JSON.stringify(report)); return 2; }
|
|
183
|
+
const child = Bun.spawn(command, {
|
|
184
|
+
cwd: `${root}/cwd`, env: { ...process.env, TMPDIR: `${root}/tmp` },
|
|
185
|
+
stdin: 'inherit', stdout: 2, stderr: 'inherit',
|
|
186
|
+
});
|
|
187
|
+
report.child = { exitCode: await child.exited, signal: child.signalCode };
|
|
188
|
+
report.terms.push({ id: 'child', status: report.child.exitCode === 0 && !report.child.signal ? 'pass' : 'fail', evidence: report.child });
|
|
189
|
+
}
|
|
190
|
+
console.log(JSON.stringify(report));
|
|
191
|
+
// An observed unsafe inherited TMPDIR is complete once the safe fallback runs.
|
|
192
|
+
return report.child ? 0 : report.terms.some((term) => term.status === 'unknown') ? 2 : 0;
|
|
193
|
+
} catch (error) {
|
|
194
|
+
const permissionGap = ['EACCES', 'EPERM'].includes(error.code);
|
|
195
|
+
report.terms.push({ id: 'execution', status: permissionGap ? 'unknown' : 'fail', evidence: { message: error.message, code: error.code } });
|
|
196
|
+
console.log(JSON.stringify(report));
|
|
197
|
+
return permissionGap ? 2 : 1;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
if (import.meta.main) process.exitCode = await main(process.argv.slice(2));
|
|
@@ -221,6 +221,8 @@ record. Material already covered with the same scope and meaning yields an
|
|
|
221
221
|
explicit already-covered no-op with pointers to the covering instructions when
|
|
222
222
|
no recurrence is recorded.
|
|
223
223
|
|
|
224
|
+
For recurring mechanical classes, learning candidates propose a code, structure or check fix before an instruction change.
|
|
225
|
+
|
|
224
226
|
If a covered rule recurs, never classify it as an already-covered no-op.
|
|
225
227
|
Record that recurrence as recurred.
|
|
226
228
|
Suggest `axstack-correct` for the recurrence.
|
|
@@ -78,7 +78,14 @@ Test helper logic red/green before implementation.
|
|
|
78
78
|
|
|
79
79
|
### Isolate every attempt
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
Use [scratch.js](../axstack/scripts/scratch.js) for command scratch; consult
|
|
82
|
+
`--help` and the [workspace recipe](../axstack/references/workspace-hygiene.md#safe-deletion)
|
|
83
|
+
for explicit repository selection and child exit checks.
|
|
84
|
+
Launch must allocate an owned 0700 directory outside HOME for data, home and port bookkeeping.
|
|
85
|
+
Keep the same directory from Launch through Doctor and Drive.
|
|
86
|
+
Allocate it once with `scratch.js run -- true`, save its JSON outside scratch,
|
|
87
|
+
and reuse the printed root for Launch state, creating the fixture home inside it.
|
|
88
|
+
Per-command scratch roots do not replace this persistent state root.
|
|
82
89
|
Listen on loopback only.
|
|
83
90
|
Never use production secrets.
|
|
84
91
|
Keep evidence in the private evidence folder after cleanup.
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
# Local verification and live boundary
|
|
2
2
|
|
|
3
3
|
In an Axstack source checkout, use the repository `verify-axstack` Launch and
|
|
4
|
-
Doctor with
|
|
5
|
-
offline network namespace.
|
|
4
|
+
Doctor with [scratch.js](../../axstack/scripts/scratch.js) command scratch,
|
|
5
|
+
an isolated fixture HOME and offline network namespace. Consult the helper's
|
|
6
|
+
`--help` for effects and the [repository command recipe](../../axstack/references/workspace-hygiene.md#safe-deletion)
|
|
7
|
+
for explicit repository selection and child exit checks. Run these actual interfaces
|
|
8
|
+
from the source checkout (or use `bun --cwd=<repo>` when wrapping them):
|
|
6
9
|
|
|
7
10
|
```bash
|
|
8
11
|
bun run test tests/workflows/voa-install.test.js \
|