axstack 0.68.0 → 0.69.1
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/docs/installation.md +2 -2
- package/docs/workflows.md +2 -2
- package/package.json +1 -1
- package/profiles/presets/claude-only.json +2 -2
- package/profiles/presets/codex-only.json +2 -2
- package/profiles/presets/mixed.json +2 -2
- package/skills/axstack/references/automations.md +17 -21
- package/skills/axstack/references/contracts.md +1 -1
- package/skills/axstack/references/default-routing.md +2 -2
- package/skills/axstack/references/local-artifacts.md +1 -1
- package/skills/axstack/references/review-manager-prompt.md +27 -33
- package/skills/axstack/references/role-roster.md +1 -1
- package/skills/axstack/references/run-record.md +5 -3
- package/skills/axstack/scripts/default-policy.js +4 -4
- package/skills/axstack/scripts/lane-owner.js +183 -0
- package/skills/axstack/scripts/pr-digest.js +17 -1
- package/skills/axstack/scripts/pr-fresh.js +139 -0
- package/skills/axstack/scripts/schedule-drift.js +216 -1
- package/skills/axstack-brainstorm/references/arena.md +5 -5
- package/skills/axstack-review/SKILL.md +2 -3
- package/skills/axstack-review/references/peer-mode.md +11 -12
package/docs/installation.md
CHANGED
|
@@ -315,8 +315,8 @@ unavailable adviser and round-2 seat remain explicit same-provider
|
|
|
315
315
|
`model: null` roles, which do not make installation unready;
|
|
316
316
|
Align and Spec still hold until both Codex and Claude advisers can return independent
|
|
317
317
|
receipts. Every brainstorm runs a light arena across configured families.
|
|
318
|
-
Use judges only for Rung 2 hard-to-reverse choices: round 1 needs
|
|
319
|
-
if invoked, needs
|
|
318
|
+
Use judges only for Rung 2 hard-to-reverse choices: round 1 needs escalation Fable; round 2,
|
|
319
|
+
if invoked, needs Opus and Astra; a required seat that is unavailable
|
|
320
320
|
holds that round. The current chat drives on whatever
|
|
321
321
|
model runs it; no preset carries a driver role. Every other missing, invalid, unsupported, or unavailable role value holds only
|
|
322
322
|
the affected work. Run helper examples below from trusted cwd `/`, resolving
|
package/docs/workflows.md
CHANGED
|
@@ -282,8 +282,8 @@ for explicit ownership transfer.
|
|
|
282
282
|
report-only. Every invocation compares independent Astra, Fable 5.2 and Grok
|
|
283
283
|
candidates, including premise and smallest-change/do-nothing
|
|
284
284
|
checks. The driver scores, picks and grafts; Rung 1 uses no judges. At Rung 2,
|
|
285
|
-
`axstack-
|
|
286
|
-
re-invocation with the user's rejection triggers fresh
|
|
285
|
+
`axstack-escalation-fable` judges round 1; disagreement on the base or caller
|
|
286
|
+
re-invocation with the user's rejection triggers fresh Opus/Astra round 2.
|
|
287
287
|
It returns a verdict, sketch and proposed questions, with no interview,
|
|
288
288
|
prototype or execution approval. Required seats hold; optional dropouts are
|
|
289
289
|
fenced. Fable also serves the bounded triggers in
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "axstack",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.69.1",
|
|
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",
|
|
@@ -279,7 +279,7 @@
|
|
|
279
279
|
"provider": "claude",
|
|
280
280
|
"modeId": "bypassPermissions",
|
|
281
281
|
"thinkingOptionId": "high",
|
|
282
|
-
"notes": "Fable escalation seat for arena round
|
|
282
|
+
"notes": "Fable escalation seat for arena round 1, high-stakes plain AGREE, or the bounded escalation trigger. Fresh session per use; never reuses adviser or candidate context. Read-only round 1 judge: scores every candidate by label; never authors a candidate. T3 resolves Claude classes from saved capabilities; a Claude rejection holds.",
|
|
283
283
|
"modelClass": "fable"
|
|
284
284
|
},
|
|
285
285
|
{
|
|
@@ -288,7 +288,7 @@
|
|
|
288
288
|
"provider": "claude",
|
|
289
289
|
"modeId": "bypassPermissions",
|
|
290
290
|
"thinkingOptionId": "xhigh",
|
|
291
|
-
"notes": "Read-only round
|
|
291
|
+
"notes": "Read-only round 2 arena judge. Receives the rubric and every candidate by label, scores each criterion, and recommends a base with rationale. Never authors a candidate, never cross-reads another judge, never mutates; the driver compares its verdict without averaging. T3 resolves Claude classes from saved capabilities; a Claude rejection holds.",
|
|
292
292
|
"modelClass": "opus"
|
|
293
293
|
},
|
|
294
294
|
{
|
|
@@ -278,7 +278,7 @@
|
|
|
278
278
|
"model": null,
|
|
279
279
|
"modeId": "full-access",
|
|
280
280
|
"thinkingOptionId": "xhigh",
|
|
281
|
-
"notes": "Fable escalation intentionally absent in codex-only; a required use holds without substitution. Read-only round
|
|
281
|
+
"notes": "Fable escalation intentionally absent in codex-only; a required use holds without substitution. Read-only round 1 judge; never authors a candidate."
|
|
282
282
|
},
|
|
283
283
|
{
|
|
284
284
|
"id": "axstack-arena-judge-opus",
|
|
@@ -287,7 +287,7 @@
|
|
|
287
287
|
"model": null,
|
|
288
288
|
"modeId": "full-access",
|
|
289
289
|
"thinkingOptionId": "xhigh",
|
|
290
|
-
"notes": "Read-only round
|
|
290
|
+
"notes": "Read-only round 2 arena judge. Receives the rubric and every candidate by label, scores each criterion, and recommends a base with rationale. Never authors a candidate, never cross-reads another judge, never mutates; the driver compares its verdict without averaging. Intentionally absent in the codex-only preset; round 2 holds without substitution."
|
|
291
291
|
},
|
|
292
292
|
{
|
|
293
293
|
"id": "axstack-arena-candidate-grok",
|
|
@@ -280,7 +280,7 @@
|
|
|
280
280
|
"provider": "claude",
|
|
281
281
|
"modeId": "bypassPermissions",
|
|
282
282
|
"thinkingOptionId": "high",
|
|
283
|
-
"notes": "Fable escalation seat for arena round
|
|
283
|
+
"notes": "Fable escalation seat for arena round 1, high-stakes plain AGREE, or the bounded escalation trigger. Fresh session per use; never reuses adviser or candidate context. Read-only round 1 judge: scores every candidate by label; never authors a candidate. T3 resolves Claude classes from saved capabilities; a Claude rejection holds.",
|
|
284
284
|
"modelClass": "fable"
|
|
285
285
|
},
|
|
286
286
|
{
|
|
@@ -289,7 +289,7 @@
|
|
|
289
289
|
"provider": "claude",
|
|
290
290
|
"modeId": "bypassPermissions",
|
|
291
291
|
"thinkingOptionId": "xhigh",
|
|
292
|
-
"notes": "Read-only round
|
|
292
|
+
"notes": "Read-only round 2 arena judge. Receives the rubric and every candidate by label, scores each criterion, and recommends a base with rationale. Never authors a candidate, never cross-reads another judge, never mutates; the driver compares its verdict without averaging. T3 resolves Claude classes from saved capabilities; a Claude rejection holds.",
|
|
293
293
|
"modelClass": "opus"
|
|
294
294
|
},
|
|
295
295
|
{
|
|
@@ -69,8 +69,7 @@ T3 sessions are exempt from Claude trust preflight.
|
|
|
69
69
|
The owner-of-record performs guarded retirement in [Finite-session teardown](#finite-session-teardown).
|
|
70
70
|
Lane identity requires exact thread/run identity, never a title or directory-name
|
|
71
71
|
guess; never infer lane ownership from an empty local workspace.
|
|
72
|
-
Reconcile saved state,
|
|
73
|
-
delegated tasks and liveness across the whole lane before discovery or admission.
|
|
72
|
+
Reconcile saved state, GitHub and native T3 lane before discovery or admission.
|
|
74
73
|
Discovery reads every page of PRs and native threads.
|
|
75
74
|
A truncated or failed inventory holds admission and cleanup.
|
|
76
75
|
A pass never admits a PR owned by a live or uncertain earlier pass.
|
|
@@ -79,8 +78,8 @@ The earlier pass wins only when ordering evidence exists.
|
|
|
79
78
|
Missing ordering or ownership evidence holds admission and never guesses a winner.
|
|
80
79
|
|
|
81
80
|
Once identified as a duplicate, the new pass does no PR work, makes no further
|
|
82
|
-
shared-record write and touches no PR-job thread or descendant owned by the
|
|
83
|
-
live manager. Besides its private pass note and the flag and alert exception below, a duplicate's only shared mutation is pass-start settlement of eligible
|
|
81
|
+
shared-record write except recording Open holds and touches no PR-job thread or descendant owned by the
|
|
82
|
+
live manager. Besides recording Open holds, its private pass note and the flag and alert exception below, a duplicate's only shared mutation is pass-start settlement of eligible
|
|
84
83
|
terminal lane pass threads under [Finite-session teardown](#finite-session-teardown).
|
|
85
84
|
A duplicate pass admits nothing and runs read-only discovery
|
|
86
85
|
into its own pass note in its private evidence folder, recording new eligible
|
|
@@ -115,18 +114,17 @@ jobs from GitHub and evidence. Only a verdict already published and read back
|
|
|
115
114
|
counts as served. Otherwise the event is unserved/`INCOMPLETE` and re-eligible.
|
|
116
115
|
A failed interrupt or unverified terminal state keeps the existing hold and
|
|
117
116
|
follows the flag and alert rule below when its resume needs the user.
|
|
118
|
-
Outside
|
|
119
|
-
|
|
117
|
+
Outside wedged-pass recovery, unknown liveness blocks admission, shared-record
|
|
118
|
+
writes except recording Open holds, takeover and cleanup even with recent activity.
|
|
120
119
|
Preserve user-taken-over threads.
|
|
121
|
-
|
|
122
|
-
Count all unsettled PR jobs and descendants.
|
|
120
|
+
No atomic lock.
|
|
123
121
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
122
|
+
Before any settle, run [lane-owner](../scripts/lane-owner.js) from `/` with
|
|
123
|
+
`bun --no-env-file` on a pre-settle snapshot; pass out-of-tree PR jobs via
|
|
124
|
+
`--job-thread`. Fail/unknown retains ownership holds: record an Open hold naming
|
|
125
|
+
owner thread/run in continuity. Never replace a potentially live owner.
|
|
126
|
+
This pass's settle never proves release; a completed or failed run row alone
|
|
127
|
+
proves neither predecessor exit nor release.
|
|
130
128
|
|
|
131
129
|
## Discovery and coverage
|
|
132
130
|
|
|
@@ -158,8 +156,7 @@ durable record under [PR shape](pr-shape.md#peer-sync-proof).
|
|
|
158
156
|
On sync pass, use no reviewer dispatch and submit nothing, record `sync skip`
|
|
159
157
|
with event identity for dedupe, and leave the PR for the user.
|
|
160
158
|
Sync fail or unknown follows ordinary review.
|
|
161
|
-
|
|
162
|
-
stale-round discard before each dispatch, before reconcile and before submission.
|
|
159
|
+
PR jobs follow [freshness](../../axstack-review/references/peer-mode.md#sync-admission-and-round-freshness).
|
|
163
160
|
|
|
164
161
|
The review manager admits all eligible actionable PR events
|
|
165
162
|
that measured host capacity can support across ticks. Before each admission,
|
|
@@ -400,13 +397,12 @@ If identity, guards or readback are unavailable, preserve the thread and report
|
|
|
400
397
|
that gap instead of settling it; the next eligible pass retries guarded verification.
|
|
401
398
|
Keep unresolved prior threadIds in the same record until verified settled.
|
|
402
399
|
Never guess thread identity from a title.
|
|
403
|
-
|
|
404
|
-
classification and on quiet exits
|
|
400
|
+
Beyond recording Open holds, the sole continuity-write exception records own pass threadId
|
|
401
|
+
before duplicate classification and on quiet exits.
|
|
405
402
|
|
|
406
|
-
Decisions outliving a finite manager pass retain
|
|
407
|
-
continuity, with the flagged thread or GitHub as the action route.
|
|
403
|
+
Decisions outliving a finite manager pass retain receipt and hold in durable continuity, with flagged thread or GitHub as action route.
|
|
408
404
|
|
|
409
|
-
After lane reconciliation at pass start, every pass, including a duplicate,
|
|
405
|
+
After lane reconciliation at pass start and pre-settle lane-owner facts, every pass, including a duplicate,
|
|
410
406
|
uses `t3_thread_organize` to settle finished predecessor and duplicate lane pass
|
|
411
407
|
threads as metadata only, before discovery or admission.
|
|
412
408
|
Settle another lane pass thread only with terminal run evidence, no unsettled
|
|
@@ -91,7 +91,7 @@ its effort and do not add a redundant reviewer. No single-provider high-stakes
|
|
|
91
91
|
mapping is defined: pause for an explicit user decision rather than borrowing
|
|
92
92
|
another preset or inventing a route. There is no silent fallback.
|
|
93
93
|
|
|
94
|
-
Use `axstack-escalation-fable` only for arena round
|
|
94
|
+
Use `axstack-escalation-fable` only for arena round 1, high-stakes decisions,
|
|
95
95
|
or when two attempts at the same named goal fail a stated acceptance check
|
|
96
96
|
(including debug L2 or a spec decision rejected twice). It also applies when
|
|
97
97
|
the Codex and Claude advisers still contradict after one reconciliation with no safe
|
|
@@ -37,8 +37,8 @@ required because usage sources do not establish which of several instances
|
|
|
37
37
|
shares which accounts. Refresh catalogs in T3 if held. These checks establish
|
|
38
38
|
catalog evidence, not successful provider execution.
|
|
39
39
|
|
|
40
|
-
Routes: Claude `claude-opus-5-5` medium; Codex `gpt-6-astra` medium;
|
|
41
|
-
Codex `gpt-6.
|
|
40
|
+
Routes: Claude `claude-opus-5-5` medium; Codex `gpt-6.2-astra` medium;
|
|
41
|
+
Codex `gpt-6.2-sol` xhigh. The configured instance IDs are discovered, not renamed.
|
|
42
42
|
Both source and account telemetry must be no older than five minutes, with
|
|
43
43
|
valid applicable session/weekly percentages and durations. A supplied reset must
|
|
44
44
|
be a valid future date within its window duration. Missing,
|
|
@@ -61,7 +61,7 @@ before dispatch; helpers validate role scope, not those procedural facts.
|
|
|
61
61
|
|
|
62
62
|
Use the selected preset's exact provider/model/effort/full-access bindings.
|
|
63
63
|
Configured optional Grok follows the arena's fenced absence rule; an uncertain
|
|
64
|
-
dispatch requires reconciliation. Fable is a required round-
|
|
64
|
+
dispatch requires reconciliation. Fable is a required round-1 judge when that
|
|
65
65
|
round applies, not an optional candidate. A missing required model or an
|
|
66
66
|
intentional null-model absence holds the applicable round without substitution.
|
|
67
67
|
An allowlisted role never makes an unavailable seat executable.
|
|
@@ -4,39 +4,31 @@ First command of every pass, quiet check included: use an owned 0700 TMPDIR unde
|
|
|
4
4
|
|
|
5
5
|
At start of every pass before quiet exit, follow [Sandbox reap](../sandbox/reap.md).
|
|
6
6
|
|
|
7
|
-
Run the quiet check before invoking `axstack-review` or reading any `skills/**` file except reap.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
Read `~/.local/share/axstack/runs/review-manager/progress.md` and
|
|
18
|
-
compare Watermarks with inventory:
|
|
19
|
-
|
|
20
|
-
- Run the full pass when reap fails or Docker is missing.
|
|
21
|
-
- Run the full pass when the sorted list differs from `Quiet gate:`.
|
|
22
|
-
- Run the full pass when any other lane thread is non-terminal.
|
|
23
|
-
- Run the full pass only when the recorded prior pass thread is unsettled and no guard keeps it unsettled.
|
|
24
|
-
- Run the full pass when continuity or either watermark is missing, malformed or unreadable.
|
|
25
|
-
- Run the full pass when `Last full pass:` is at least 4 hours old or in the future.
|
|
26
|
-
- Run the full pass when any call fails or pagination, PR head OIDs or thread/run liveness is incomplete or unknown.
|
|
27
|
-
- Run the full pass when continuity records any unserved, capacity-deferred, `INCOMPLETE` or re-eligible event, or any open hold with a resume condition beyond a user decision (such as capacity or remeasure).
|
|
28
|
-
|
|
29
|
-
Held or flagged prior passes never force a full pass or failure report by their unsettled state alone.
|
|
30
|
-
|
|
31
|
-
Holds awaiting only the user remain quiet-eligible: a user decision on the PR
|
|
32
|
-
changes `updatedAt`, and the 4 h full pass reconciles replies in flagged threads.
|
|
33
|
-
|
|
34
|
-
Before evaluating the quiet gate, read the recorded prior pass thread with
|
|
35
|
-
`t3_thread_read`; unknown identity or readback forces a full pass.
|
|
7
|
+
Run the quiet check before invoking `axstack-review` or reading any `skills/**` file except reap and this helper.
|
|
8
|
+
|
|
9
|
+
Save raw outputs per installed `schedule-drift.js quiet-facts --help`, with collection time,
|
|
10
|
+
repository and login (`gh api user --jq .login`):
|
|
11
|
+
`gh search prs --review-requested @me --state open --draft=false --json number,repository,updatedAt,isDraft,author --limit 1000`
|
|
12
|
+
`gh search prs --involves @me --state open --draft=false --json number,repository,updatedAt,isDraft,author --limit 1000`
|
|
13
|
+
Save `t3_thread_list` as `{args,value}` (includeSubagents:true, statuses:
|
|
14
|
+
preparing/queued/starting/running/waiting; merged pages, nextCursor:null, matching total), and continuity from
|
|
15
|
+
`~/.local/share/axstack/runs/review-manager/progress.md`.
|
|
16
|
+
Read the recorded prior pass once with `t3_thread_read` before replacing prior identity.
|
|
36
17
|
Record own pass threadId in review-manager continuity after reading the prior identity,
|
|
37
18
|
before duplicate classification, then read back the identity save.
|
|
38
|
-
|
|
39
|
-
|
|
19
|
+
After collection, the first decision step is the installed helper, from trusted cwd `/`:
|
|
20
|
+
`bun --no-env-file <resolved-schedule-drift.js> quiet-facts --input <saved-input.json> --continuity <saved-progress.md>`.
|
|
21
|
+
Lane scope is recorded pass/job identities and descendants, not the shared project.
|
|
22
|
+
PR comparison reuses `pr-digest.js`.
|
|
23
|
+
|
|
24
|
+
The pass agent applies quiet/full/hold rules to these facts, which grant nothing:
|
|
25
|
+
any fail or unknown runs the full pass; unknown discovery means full reconciliation,
|
|
26
|
+
and unknown ownership or prior identity forbids competing admission.
|
|
27
|
+
Guarded prior passes and user-only holds never force a full pass or failure report by themselves.
|
|
28
|
+
A user decision on the PR changes updatedAt; the 4 h full pass reconciles replies in flagged threads.
|
|
29
|
+
Run the full pass when reap fails or Docker is missing.
|
|
30
|
+
|
|
31
|
+
If no term fails or is unknown, apply the guarded pass-end self-settle below,
|
|
40
32
|
then end the turn with no text, no skill load, no sweep and no other continuity write.
|
|
41
33
|
Otherwise run the full pass; incomplete evidence retains admission/cleanup holds.
|
|
42
34
|
|
|
@@ -44,7 +36,7 @@ Otherwise run the full pass; incomplete evidence retains admission/cleanup holds
|
|
|
44
36
|
|
|
45
37
|
Follow [Provider bindings](t3-runtime.md#preflight-and-binding).
|
|
46
38
|
|
|
47
|
-
You are a fresh finite T3 review-manager pass in
|
|
39
|
+
You are a fresh finite T3 review-manager pass in the recorded lane on VPS's
|
|
48
40
|
`axatbhardwaj/axstack` clone. Fetch first; this unbound
|
|
49
41
|
pass worktree starts from `origin/main`. Enter through installed `axstack-review`,
|
|
50
42
|
which loads `../axstack/references/automations.md` relatively. Read [T3 runtime](t3-runtime.md). Reconcile lane ownership and duplicate status,
|
|
@@ -58,8 +50,10 @@ Report retained worktree count and disable the schedule and hold past its
|
|
|
58
50
|
authorized limit. Only the owner retires settled predecessors and saves/reads back
|
|
59
51
|
`~/.local/share/axstack/runs/review-manager/progress.md` using
|
|
60
52
|
`run-record.md#review-manager-continuity-template`.
|
|
61
|
-
|
|
53
|
+
Resolve heads with `gh pr view --repo REPO NUMBER --json headRefOid` in the full pass.
|
|
54
|
+
Full pass records Watermarks: `Quiet gate:` as the sorted list of JSON triples and
|
|
62
55
|
`Last full pass:` as UTC only as owner-of-record, then reads back the save.
|
|
56
|
+
Full passes record proven Non-lane roots for omitted idle parents.
|
|
63
57
|
Settle descendants and end the finite turn. Stay quiet when unchanged.
|
|
64
58
|
Never check out a PR branch here.
|
|
65
59
|
Follow [Peer execution](../sandbox/host-execution.md) in every peer-review brief
|
|
@@ -35,7 +35,7 @@ Engineering authors and code reviewers cannot acquire this artifact authority.
|
|
|
35
35
|
- `axstack-advisor-codex` (Astra high in mixed/codex-only) and
|
|
36
36
|
`axstack-advisor-claude` (Fable 5.2 high in mixed/claude-only) advise and author candidates;
|
|
37
37
|
`axstack-arena-candidate-grok` adds a family.
|
|
38
|
-
`axstack-
|
|
38
|
+
`axstack-escalation-fable` judges round 1; `axstack-arena-judge-opus`/`axstack-arena-judge-astra` judge round 2.
|
|
39
39
|
Fable escalation starts at high effort in mixed/claude-only.
|
|
40
40
|
High-stakes/trigger: fresh [contract](contracts.md) session.
|
|
41
41
|
`axstack-auditor` audits; `axstack-checker` reports discrepancies.
|
|
@@ -227,13 +227,15 @@ in the adjacent history file, not below this template.
|
|
|
227
227
|
## Lane state
|
|
228
228
|
- scheduledTaskId, threadId/runId, workspace and exact terminal receipt: <IDs>
|
|
229
229
|
- Active PR jobs and descendants: <PR, taskId/childThreadId/runId, owner, revision, state>
|
|
230
|
+
- Lane-owner facts: <report path, snapshot and exact identities>
|
|
230
231
|
|
|
231
232
|
## Open holds
|
|
232
|
-
- <
|
|
233
|
+
- <ID: reason; evidence: path; owner: ID; resume: CONDITION (user-only: resume: user decision only); or none>
|
|
233
234
|
|
|
234
235
|
## Watermarks
|
|
235
|
-
- Quiet gate: <sorted
|
|
236
|
-
- Last full pass: <UTC timestamp of the last full pass>
|
|
236
|
+
- Quiet gate: <sorted JSON [repo#number, headRefOid, updatedAt] triples; [] when empty>
|
|
237
|
+
- Last full pass: <UTC ISO timestamp of the last full pass>
|
|
238
|
+
- Non-lane roots: <JSON threadId array proven outside this lane; [] if none>
|
|
237
239
|
- <PR/event identity, exact head/base, last observed receipt; or none>
|
|
238
240
|
|
|
239
241
|
## Last pass
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { historyCounts } from './driver-history.js';
|
|
2
2
|
const routes = [
|
|
3
3
|
['claudeAgent', 'claude-opus-5-5', 'effort', 'medium'],
|
|
4
|
-
['codex', 'gpt-6-astra', 'reasoningEffort', 'medium'],
|
|
5
|
-
['codex', 'gpt-6.
|
|
4
|
+
['codex', 'gpt-6.2-astra', 'reasoningEffort', 'medium'],
|
|
5
|
+
['codex', 'gpt-6.2-sol', 'reasoningEffort', 'xhigh'],
|
|
6
6
|
];
|
|
7
7
|
const mean = (values) => values.reduce((a, b) => a + b, 0) / values.length;
|
|
8
8
|
const fresh = (date, now, age) => Number.isFinite(Date.parse(date)) && now >= Date.parse(date) && now - Date.parse(date) <= age;
|
|
@@ -101,8 +101,8 @@ export function decide(settings, snapshots, catalogs, now, history = null) {
|
|
|
101
101
|
const low = (driver) => Math.min(...[result.pools[driver].sessionRemaining,
|
|
102
102
|
result.pools[driver].weeklyRemaining].filter((v) => v !== null)) < 30;
|
|
103
103
|
const available = choices.filter((c) => result.pools[c.driver].eligibleAccounts > 0);
|
|
104
|
-
const sol = available.filter((c) => c.selection.model === 'gpt-6.
|
|
105
|
-
const primaries = available.filter((c) => c.selection.model !== 'gpt-6.
|
|
104
|
+
const sol = available.filter((c) => c.selection.model === 'gpt-6.2-sol');
|
|
105
|
+
const primaries = available.filter((c) => c.selection.model !== 'gpt-6.2-sol');
|
|
106
106
|
const nonLow = primaries.filter((c) => !low(c.driver));
|
|
107
107
|
// Apply the reserve before pacing, fairness and hysteresis can retain a forbidden default.
|
|
108
108
|
const eligible = low('claudeAgent') && low('codex') && sol.length ? sol
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
import { readFileSync } from 'node:fs';
|
|
3
|
+
|
|
4
|
+
const HELP = `lane-owner — saved T3 lane liveness facts (R2 fact)
|
|
5
|
+
bun --no-env-file /absolute/lane-owner.js --input FILE --owner-thread ID --owner-run ID [--job-thread ID ...]
|
|
6
|
+
--input FILE Saved {preSettle:true,args,value} from t3_thread_list before this pass
|
|
7
|
+
settles anything; preSettle is a caller assertion, not authenticated.
|
|
8
|
+
Missing/false preSettle keeps all facts unknown. value contains threads,
|
|
9
|
+
nextCursor:null and total matching the full merged inventory.
|
|
10
|
+
args must include includeSubagents:true and allProjects:true or
|
|
11
|
+
projectId matching the owner; no settled/snoozed/title filters.
|
|
12
|
+
Merge all pages first; preserve the first page args (cursor absent/0).
|
|
13
|
+
Full form: omit statuses. Scoped form: statuses must be exactly
|
|
14
|
+
idle,preparing,queued,starting,running,waiting (all nonterminal).
|
|
15
|
+
Add unsettled:{args,value}: same scope, settled:false, no statuses,
|
|
16
|
+
fully paged, so terminal-but-unsettled descendants remain uncertain.
|
|
17
|
+
Add readbacks:[{args:{threadId},value:{thread,recentRuns}}] from
|
|
18
|
+
t3_thread_read for owner, each --job-thread and missing ancestors
|
|
19
|
+
of listed rows until owner/job or a parentThreadId:null root.
|
|
20
|
+
Readbacks supply settled and the matching latestRunId run status;
|
|
21
|
+
runLimit:1 suffices. Timeline hasMore/text truncation is irrelevant.
|
|
22
|
+
All captures precede this pass's settles. Missing reads, ancestry,
|
|
23
|
+
latest-run evidence, conflicting views or incomplete pages hold.
|
|
24
|
+
--owner-thread ID Exact earlier pass thread from durable continuity, never a title.
|
|
25
|
+
--owner-run ID Exact earlier run from continuity; a resumed run is reported separately.
|
|
26
|
+
--job-thread ID Repeat for recorded PR jobs outside the owner's parentThreadId tree.
|
|
27
|
+
All descendants of owner/jobs are included automatically.
|
|
28
|
+
--help Show flags, input contract, effects and limitations.
|
|
29
|
+
Terms test complete inventory, matching owner run, inactive owner and inactive jobs.
|
|
30
|
+
Pass inactive requires terminal status AND settled:true; idle/unsettled is unknown.
|
|
31
|
+
Running/preparing/queued/starting/waiting fails inactive even with stale settled metadata.
|
|
32
|
+
Unknown/truncated inventory keeps liveness unknown. Failed terms remain measured facts.
|
|
33
|
+
No takeover, admission, retirement or cleanup authority; existing holds remain with driver.
|
|
34
|
+
Evidence is caller-supplied, not authenticated, freshened or an atomic lock. Snapshot facts
|
|
35
|
+
cannot prove process exit, user takeover, inactivity duration or continuity reconciliation.
|
|
36
|
+
Effects: reads only FILE, prints JSON to stdout; no writes, subprocess, network,
|
|
37
|
+
live T3 access, dispatch, schedule, retry, notify, merge or persistent state.
|
|
38
|
+
Exit: 0 measured (including fail), 1 invalid invocation/JSON, 2 incomplete/unknown.
|
|
39
|
+
`;
|
|
40
|
+
const ids = ['inventory.complete', 'owner.run', 'owner.inactive', 'jobs.inactive'];
|
|
41
|
+
const term = (id, status, evidence) => ({ id, status, evidence });
|
|
42
|
+
|
|
43
|
+
const text = value => typeof value === 'string' && value.length > 0;
|
|
44
|
+
const active = new Set(['preparing', 'queued', 'starting', 'running', 'waiting']);
|
|
45
|
+
const nonterminal = new Set(['idle', ...active]);
|
|
46
|
+
const terminal = new Set(['completed', 'interrupted', 'failed', 'cancelled', 'rolled_back']);
|
|
47
|
+
const observation = row => ({ threadId: row.threadId, runId: row.latestRunId ?? null,
|
|
48
|
+
status: row.status ?? null, settled: row.settled ?? null });
|
|
49
|
+
function inactive(row) {
|
|
50
|
+
if (!row || !text(row.latestRunId)) return 'unknown';
|
|
51
|
+
if (active.has(row.status)) return 'fail';
|
|
52
|
+
return terminal.has(row.status) && row.settled === true ? 'pass' : 'unknown';
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const validRow = row => row && text(row.threadId) && text(row.projectId)
|
|
56
|
+
&& (row.parentThreadId === null || text(row.parentThreadId)) && row.parentThreadId !== row.threadId;
|
|
57
|
+
function complete(saved, allowed = []) {
|
|
58
|
+
const args = saved?.args, value = saved?.value;
|
|
59
|
+
return args && Array.isArray(value?.threads) && !saved.isError && !value.isError
|
|
60
|
+
&& !value.truncated && !value.hasMore && value.complete !== false
|
|
61
|
+
&& Object.hasOwn(value, 'nextCursor') && value.nextCursor === null && value.total === value.threads.length
|
|
62
|
+
&& args.includeSubagents === true && (args.cursor === undefined || args.cursor === 0)
|
|
63
|
+
&& !['statuses', 'settled', 'snoozed', 'titleContains'].some(key => !allowed.includes(key) && Object.hasOwn(args, key));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function scopedRows(snapshot, roots) {
|
|
67
|
+
const { args, value, unsettled, readbacks } = snapshot;
|
|
68
|
+
if (!Array.isArray(args.statuses) || args.statuses.length !== nonterminal.size
|
|
69
|
+
|| new Set(args.statuses).size !== nonterminal.size || args.statuses.some(s => !nonterminal.has(s))
|
|
70
|
+
|| !complete(unsettled, ['settled']) || unsettled.args.settled !== false
|
|
71
|
+
|| (unsettled.args.allProjects === true) !== (args.allProjects === true)
|
|
72
|
+
|| unsettled.args.projectId !== args.projectId || !Array.isArray(readbacks)
|
|
73
|
+
|| value.threads.some(row => !nonterminal.has(row?.status))
|
|
74
|
+
|| unsettled.value.threads.some(row => row?.settled !== false)) return null;
|
|
75
|
+
const reads = new Map();
|
|
76
|
+
for (const saved of readbacks) {
|
|
77
|
+
const row = saved?.value?.thread, runs = saved?.value?.recentRuns;
|
|
78
|
+
if (!validRow(row) || saved.isError || saved.value.isError || saved.value.truncated
|
|
79
|
+
|| saved.value.complete === false || saved.args?.threadId !== row.threadId || reads.has(row.threadId)
|
|
80
|
+
|| !text(row.latestRunId) || !Array.isArray(runs)
|
|
81
|
+
|| runs.filter(run => run?.runId === row.latestRunId).length !== 1) return null;
|
|
82
|
+
const run = runs.find(run => run?.runId === row.latestRunId);
|
|
83
|
+
if (run.status !== row.status || (text(row.activeRunId) && !active.has(row.status))) return null;
|
|
84
|
+
reads.set(row.threadId, row);
|
|
85
|
+
}
|
|
86
|
+
if ([...roots].some(id => !reads.has(id))) return null;
|
|
87
|
+
const merged = new Map();
|
|
88
|
+
for (const batch of [value.threads, unsettled.value.threads, [...reads.values()]]) {
|
|
89
|
+
const seen = new Set();
|
|
90
|
+
for (const row of batch) {
|
|
91
|
+
if (!validRow(row) || seen.has(row.threadId)) return null;
|
|
92
|
+
seen.add(row.threadId);
|
|
93
|
+
const previous = merged.get(row.threadId);
|
|
94
|
+
if (previous && ['projectId', 'parentThreadId', 'latestRunId', 'status', 'settled']
|
|
95
|
+
.some(key => previous[key] !== row[key])) return null;
|
|
96
|
+
merged.set(row.threadId, row);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
// Filtered lists can omit terminal parents: absence cannot establish unrelatedness.
|
|
100
|
+
for (const row of merged.values()) {
|
|
101
|
+
if (roots.has(row.threadId)) continue;
|
|
102
|
+
let parent = row.parentThreadId;
|
|
103
|
+
const seen = new Set([row.threadId]);
|
|
104
|
+
while (parent !== null && !roots.has(parent)) {
|
|
105
|
+
if (!merged.has(parent) || seen.has(parent)) return null;
|
|
106
|
+
seen.add(parent); parent = merged.get(parent).parentThreadId;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return [...merged.values()];
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function facts(snapshot, ownerId, runId, jobs) {
|
|
113
|
+
const unknown = reason => ids.map(id => term(id, 'unknown', { reason }));
|
|
114
|
+
if (snapshot?.preSettle !== true) return unknown('pre-settle snapshot assertion missing or false');
|
|
115
|
+
const input = snapshot?.args, scoped = Object.hasOwn(input ?? {}, 'statuses');
|
|
116
|
+
if (!complete(snapshot, scoped ? ['statuses'] : [])) {
|
|
117
|
+
return unknown('missing, truncated or filtered thread inventory');
|
|
118
|
+
}
|
|
119
|
+
const rows = scoped ? scopedRows(snapshot, new Set([ownerId, ...jobs])) : snapshot.value.threads;
|
|
120
|
+
if (!rows) return unknown('incomplete scoped views, readbacks or ancestry');
|
|
121
|
+
const byId = new Map();
|
|
122
|
+
for (const row of rows) {
|
|
123
|
+
if (!validRow(row) || byId.has(row.threadId)) {
|
|
124
|
+
return unknown('malformed or duplicate thread identity/lineage');
|
|
125
|
+
}
|
|
126
|
+
byId.set(row.threadId, row);
|
|
127
|
+
}
|
|
128
|
+
const owner = byId.get(ownerId);
|
|
129
|
+
if (input.allProjects !== true && (!text(input.projectId) || owner?.projectId !== input.projectId
|
|
130
|
+
|| rows.some(row => row.projectId !== input.projectId))) return unknown('owner project scope unavailable or mismatched');
|
|
131
|
+
// A cycle cannot be a complete native ancestry tree.
|
|
132
|
+
for (const row of rows) {
|
|
133
|
+
const seen = new Set([row.threadId]);
|
|
134
|
+
let parent = row.parentThreadId;
|
|
135
|
+
while (byId.has(parent)) {
|
|
136
|
+
if (seen.has(parent)) return unknown('cyclic thread lineage');
|
|
137
|
+
seen.add(parent); parent = byId.get(parent).parentThreadId;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
const tree = new Set([ownerId, ...jobs]);
|
|
141
|
+
let added;
|
|
142
|
+
do {
|
|
143
|
+
added = false;
|
|
144
|
+
for (const row of rows) {
|
|
145
|
+
if (tree.has(row.parentThreadId) && !tree.has(row.threadId)) { tree.add(row.threadId); added = true; }
|
|
146
|
+
}
|
|
147
|
+
} while (added);
|
|
148
|
+
tree.delete(ownerId);
|
|
149
|
+
const jobRows = [...tree].map(id => byId.get(id));
|
|
150
|
+
const jobStates = jobRows.map(inactive);
|
|
151
|
+
const jobStatus = jobStates.includes('unknown') ? 'unknown' : jobStates.includes('fail') ? 'fail' : tree.size ? 'pass' : 'n/a';
|
|
152
|
+
return [
|
|
153
|
+
term('inventory.complete', 'pass', { count: rows.length, scope: scoped ? 'nonterminal+unsettled+readbacks' : 'full',
|
|
154
|
+
projectId: input.projectId ?? null, allProjects: input.allProjects === true }),
|
|
155
|
+
term('owner.run', !text(owner?.latestRunId) ? 'unknown' : owner.latestRunId === runId ? 'pass' : 'fail',
|
|
156
|
+
{ threadId: ownerId, expectedRunId: runId, current: owner ? observation(owner) : null }),
|
|
157
|
+
term('owner.inactive', inactive(owner), owner ? observation(owner) : { missingThreadId: ownerId }),
|
|
158
|
+
term('jobs.inactive', jobStatus, { threads: jobRows.filter(Boolean).map(observation),
|
|
159
|
+
missingThreadIds: [...tree].filter(id => !byId.has(id)) }),
|
|
160
|
+
];
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
try {
|
|
164
|
+
const argv = process.argv.slice(2), args = {}, jobs = [];
|
|
165
|
+
if (argv.length === 1 && argv[0] === '--help') { console.log(HELP); process.exit(0); }
|
|
166
|
+
for (let i = 0; i < argv.length; i += 2) {
|
|
167
|
+
const [key, value] = argv.slice(i, i + 2);
|
|
168
|
+
if (!['--input', '--owner-thread', '--owner-run', '--job-thread'].includes(key)
|
|
169
|
+
|| !value || value.startsWith('--') || (key !== '--job-thread' && args[key])) throw Error(`invalid argument: ${key}`);
|
|
170
|
+
if (key === '--job-thread') jobs.push(value); else args[key] = value;
|
|
171
|
+
}
|
|
172
|
+
if (!args['--input'] || !args['--owner-thread'] || !args['--owner-run']) throw Error('expected --input, --owner-thread and --owner-run');
|
|
173
|
+
let bytes;
|
|
174
|
+
try { bytes = readFileSync(args['--input']); } catch (error) {
|
|
175
|
+
if (error.code !== 'ENOENT' && error.code !== 'EACCES') throw error;
|
|
176
|
+
}
|
|
177
|
+
const snapshot = bytes ? JSON.parse(bytes.toString()) : null;
|
|
178
|
+
const terms = facts(snapshot, args['--owner-thread'], args['--owner-run'], jobs);
|
|
179
|
+
const summary = Object.fromEntries(['pass', 'fail', 'unknown', 'n/a'].map(s => [s, terms.filter(t => t.status === s).length]));
|
|
180
|
+
console.log(JSON.stringify({ schemaVersion: 1, input: { path: args['--input'],
|
|
181
|
+
sha256: bytes ? new Bun.CryptoHasher('sha256').update(bytes).digest('hex') : null }, terms, summary }));
|
|
182
|
+
process.exitCode = summary.unknown ? 2 : 0;
|
|
183
|
+
} catch (error) { console.error(`lane-owner: ${error.message}`); process.exitCode = 1; }
|
|
@@ -92,7 +92,23 @@ function snapshot(response) {
|
|
|
92
92
|
return prs;
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
|
|
95
|
+
// Quiet discovery owns completeness and identity; this function only compares PR tuples.
|
|
96
|
+
export function compareQuietPRs(previous, current, { optionalHeads = false } = {}) {
|
|
97
|
+
const valid = (rows, optional = false) => Array.isArray(rows) && rows.every((row) => Array.isArray(row) && row.length === 3 &&
|
|
98
|
+
row.every((value, index) => optional && index === 1 && value === null || typeof value === 'string' && value.length > 0) &&
|
|
99
|
+
/^[\w.-]+\/[\w.-]+#[1-9]\d*$/.test(row[0]) && (optional && row[1] === null || /^[a-f0-9]{40,64}$/.test(row[1])) &&
|
|
100
|
+
/T.*(?:Z|[+-]\d\d:\d\d)$/.test(row[2]) && Number.isFinite(Date.parse(row[2]))) &&
|
|
101
|
+
new Set(rows.map(row => row[0])).size === rows.length;
|
|
102
|
+
if (!valid(previous) || !valid(current, optionalHeads)) return { status: 'unknown', evidence: 'missing or malformed PR-list watermark' };
|
|
103
|
+
const before = ordered(previous.map((row) => [...row]));
|
|
104
|
+
const after = ordered(current.map((row) => [...row]));
|
|
105
|
+
const same = before.length === after.length && before.every((row, i) => row[0] === after[i][0] && row[2] === after[i][2] &&
|
|
106
|
+
(optionalHeads && after[i][1] === null || row[1] === after[i][1]));
|
|
107
|
+
return { status: same ? 'pass' : 'fail', evidence: { previous: before, current: after,
|
|
108
|
+
headScope: optionalHeads ? 'compare returned OIDs only; omitted OIDs remain unobserved' : 'all OIDs compared' } };
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (import.meta.main) try {
|
|
96
112
|
const args = options(process.argv.slice(2));
|
|
97
113
|
const current = snapshot(fetchCurrent(args));
|
|
98
114
|
let previous = {};
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
import { readFileSync } from 'node:fs';
|
|
3
|
+
|
|
4
|
+
const HELP = `pr-fresh — review event observations (R2 fact mode)
|
|
5
|
+
Run from trusted cwd / with bun --no-env-file <installed-script> and explicit:
|
|
6
|
+
--repo OWNER/NAME --pr N --head SHA --base SHA --base-ref NAME --phase admission|submission
|
|
7
|
+
--repo, --pr Expected repository and PR identity (also required with saved input).
|
|
8
|
+
--head, --base Pinned full commit SHAs; --base-ref pins the base branch identity.
|
|
9
|
+
--phase Select review.admission or review.submission in the policy artifact.
|
|
10
|
+
--policy FILE Default: installed ../references/schedule-policy.json (W2-1).
|
|
11
|
+
Supported version:1 review phase: {status:"known",headAgeThresholdSeconds:N,
|
|
12
|
+
clockSemantics:"head-commit-committed-date",pendingCheckTreatment:"defer"|"allow"}.
|
|
13
|
+
N is a nonnegative integer, inclusive. This clock is commit age, NOT push/settle age.
|
|
14
|
+
Driver: recorded age < N defers; age >= N meets the age term. defer waits on
|
|
15
|
+
pending checks; allow adds no pending gate. Unknown applicable gating terms hold.
|
|
16
|
+
status:"unknown" with all three gate fields null is unrecorded, with no gate.
|
|
17
|
+
policy.evidence.unrecorded distinguishes it from malformed/unavailable policy.
|
|
18
|
+
Both report unknown; the driver ignores non-event terms only for unrecorded phases.
|
|
19
|
+
--input FILE Saved gh api graphql response; no network. Saved bytes prove no live freshness.
|
|
20
|
+
--now ISO Timezone-qualified comparison time; default current UTC.
|
|
21
|
+
--help Show flags, effects and limitations.
|
|
22
|
+
Without --input, one read-only gh api graphql query observes the PR and head checks.
|
|
23
|
+
No writes, persistent state, retries, dispatch, submission, merge, scheduling or authority.
|
|
24
|
+
API/permission/pagination gaps are unknown; unobserved checks never imply success.
|
|
25
|
+
pendingChecks passes iff no observed pending checks; checksSuccessful measures terminal checks.
|
|
26
|
+
The driver applies the recorded policy and discard/hold rules, before dispatch and submission.
|
|
27
|
+
Stdout: per-term pass/fail/unknown/n/a with evidence and counts only, no aggregate verdict.
|
|
28
|
+
Exit: 0 measured (including failed facts), 1 invalid CLI/error, 2 incomplete (unknown facts).
|
|
29
|
+
`;
|
|
30
|
+
const time = (s) => typeof s === 'string' && /T.*(?:Z|[+-]\d\d:\d\d)$/.test(s) ? Date.parse(s) : NaN;
|
|
31
|
+
const sha = (s) => typeof s === 'string' && /^[a-f0-9]{40}$/.test(s);
|
|
32
|
+
function options(argv) {
|
|
33
|
+
const args = { '--policy': `${import.meta.dir}/../references/schedule-policy.json`, '--now': new Date().toISOString() };
|
|
34
|
+
const seen = new Set();
|
|
35
|
+
for (let i = 0; i < argv.length; i += 2) {
|
|
36
|
+
const key = argv[i], value = argv[i + 1];
|
|
37
|
+
if (!['--repo', '--pr', '--head', '--base', '--base-ref', '--phase', '--policy', '--input', '--now'].includes(key) ||
|
|
38
|
+
!value || value.startsWith('--') || seen.has(key)) throw Error(`invalid argument: ${key}`);
|
|
39
|
+
args[key] = value;
|
|
40
|
+
seen.add(key);
|
|
41
|
+
}
|
|
42
|
+
if (!/^[\w.-]+\/[\w.-]+$/.test(args['--repo'] ?? '') || !/^[1-9]\d*$/.test(args['--pr'] ?? '') ||
|
|
43
|
+
!Number.isSafeInteger(Number(args['--pr'])) || !sha(args['--head']) || !sha(args['--base']) ||
|
|
44
|
+
!args['--base-ref'] || !['admission', 'submission'].includes(args['--phase']) || !Number.isFinite(time(args['--now']))) {
|
|
45
|
+
throw Error('expected repo, PR, full head/base SHAs, base-ref, phase and timezone-qualified now; see --help');
|
|
46
|
+
}
|
|
47
|
+
return args;
|
|
48
|
+
}
|
|
49
|
+
function observe(args) {
|
|
50
|
+
if (args['--input']) return JSON.parse(readFileSync(args['--input'], 'utf8'));
|
|
51
|
+
const [owner, name] = args['--repo'].split('/');
|
|
52
|
+
const query = `query { repository(owner:${JSON.stringify(owner)},name:${JSON.stringify(name)}) {
|
|
53
|
+
nameWithOwner pullRequest(number:${args['--pr']}) {
|
|
54
|
+
number state isDraft merged headRefOid baseRefOid baseRefName
|
|
55
|
+
commits(last:1) { nodes { commit { oid committedDate statusCheckRollup {
|
|
56
|
+
contexts(first:100) { pageInfo { hasNextPage } nodes {
|
|
57
|
+
__typename ... on CheckRun { name status conclusion } ... on StatusContext { context state }
|
|
58
|
+
} }
|
|
59
|
+
} } } }
|
|
60
|
+
}
|
|
61
|
+
} }`;
|
|
62
|
+
const r = Bun.spawnSync(['gh', 'api', 'graphql', '-f', `query=${query}`], { cwd: '/', stdout: 'pipe', stderr: 'pipe' });
|
|
63
|
+
if (r.exitCode !== 0) throw Error('gh api unavailable or failed');
|
|
64
|
+
return JSON.parse(r.stdout.toString());
|
|
65
|
+
}
|
|
66
|
+
function report(args) {
|
|
67
|
+
const terms = [];
|
|
68
|
+
const add = (id, status, evidence) => terms.push({ id, status, evidence });
|
|
69
|
+
let policy, policySha256 = null, response, observationError;
|
|
70
|
+
try {
|
|
71
|
+
const bytes = readFileSync(args['--policy']);
|
|
72
|
+
policySha256 = new Bun.CryptoHasher('sha256').update(bytes).digest('hex');
|
|
73
|
+
policy = JSON.parse(bytes.toString());
|
|
74
|
+
} catch { /* Unavailable policy does not erase independently observed PR facts. */ }
|
|
75
|
+
const phase = policy?.review?.[args['--phase']];
|
|
76
|
+
const knownPolicy = policy?.version === 1 && phase?.status === 'known' &&
|
|
77
|
+
Number.isSafeInteger(phase.headAgeThresholdSeconds) && phase.headAgeThresholdSeconds >= 0 &&
|
|
78
|
+
phase.clockSemantics === 'head-commit-committed-date' && ['defer', 'allow'].includes(phase.pendingCheckTreatment);
|
|
79
|
+
const unrecorded = policy?.version === 1 && phase?.status === 'unknown' &&
|
|
80
|
+
phase.headAgeThresholdSeconds === null && phase.clockSemantics === null && phase.pendingCheckTreatment === null;
|
|
81
|
+
add('policy', knownPolicy ? 'pass' : 'unknown', { phase: args['--phase'], sha256: policySha256,
|
|
82
|
+
recorded: phase ?? null, unrecorded, malformed: !knownPolicy && !unrecorded,
|
|
83
|
+
reason: knownPolicy ? 'supported recorded policy' : unrecorded ? 'unrecorded phase; no gate' : 'absent, unreadable, malformed or unsupported policy' });
|
|
84
|
+
try { response = observe(args); } catch { observationError = 'saved input or gh api unavailable/malformed'; }
|
|
85
|
+
const repository = response?.data?.repository;
|
|
86
|
+
const pr = !response?.errors?.length && repository?.nameWithOwner?.toLowerCase() === args['--repo'].toLowerCase() &&
|
|
87
|
+
repository?.pullRequest?.number === Number(args['--pr']) ? repository.pullRequest : null;
|
|
88
|
+
const fact = (id, known, passes, evidence) => add(id, !pr || !known ? 'unknown' : passes ? 'pass' : 'fail',
|
|
89
|
+
pr ? evidence : { reason: observationError ?? 'incomplete API response or identity mismatch' });
|
|
90
|
+
fact('open', ['OPEN', 'CLOSED', 'MERGED'].includes(pr?.state), pr?.state === 'OPEN', { state: pr?.state });
|
|
91
|
+
fact('nonDraft', typeof pr?.isDraft === 'boolean', pr?.isDraft === false, { isDraft: pr?.isDraft });
|
|
92
|
+
fact('unmerged', typeof pr?.merged === 'boolean', pr?.merged === false, { merged: pr?.merged });
|
|
93
|
+
fact('pinnedHead', sha(pr?.headRefOid), pr?.headRefOid === args['--head'], { expected: args['--head'], observed: pr?.headRefOid });
|
|
94
|
+
fact('baseUnchanged', sha(pr?.baseRefOid) && typeof pr?.baseRefName === 'string',
|
|
95
|
+
pr?.baseRefOid === args['--base'] && pr?.baseRefName === args['--base-ref'],
|
|
96
|
+
{ expected: { sha: args['--base'], ref: args['--base-ref'] }, observed: { sha: pr?.baseRefOid, ref: pr?.baseRefName } });
|
|
97
|
+
const commits = pr?.commits?.nodes;
|
|
98
|
+
const commit = Array.isArray(commits) && commits.length === 1 && commits[0]?.commit?.oid === pr.headRefOid ? commits[0].commit : null;
|
|
99
|
+
const age = (time(args['--now']) - time(commit?.committedDate)) / 1000;
|
|
100
|
+
fact('headAge', knownPolicy && Number.isFinite(age) && age >= 0, age >= phase?.headAgeThresholdSeconds,
|
|
101
|
+
{ committedDate: commit?.committedDate, ageSeconds: Number.isFinite(age) ? age : null,
|
|
102
|
+
thresholdSeconds: knownPolicy ? phase.headAgeThresholdSeconds : null, clock: 'head-commit-committed-date' });
|
|
103
|
+
const rollup = commit?.statusCheckRollup;
|
|
104
|
+
const connection = rollup?.contexts;
|
|
105
|
+
const checks = rollup === null ? [] : connection?.pageInfo?.hasNextPage === false && Array.isArray(connection.nodes) ? connection.nodes : null;
|
|
106
|
+
const pending = [], failed = [], unknown = [], terminal = [];
|
|
107
|
+
for (const c of checks ?? []) {
|
|
108
|
+
const name = c?.name ?? c?.context ?? '(unnamed)';
|
|
109
|
+
if (c?.__typename === 'CheckRun' && ['QUEUED', 'IN_PROGRESS', 'WAITING', 'PENDING', 'REQUESTED'].includes(c.status) ||
|
|
110
|
+
c?.__typename === 'StatusContext' && ['PENDING', 'EXPECTED'].includes(c.state)) pending.push(name);
|
|
111
|
+
else if (c?.__typename === 'CheckRun' && c.status === 'COMPLETED' &&
|
|
112
|
+
['SUCCESS', 'NEUTRAL', 'SKIPPED', 'FAILURE', 'CANCELLED', 'TIMED_OUT', 'ACTION_REQUIRED', 'STALE', 'STARTUP_FAILURE'].includes(c.conclusion)) {
|
|
113
|
+
terminal.push(name);
|
|
114
|
+
if (!['SUCCESS', 'NEUTRAL', 'SKIPPED'].includes(c.conclusion)) failed.push(name);
|
|
115
|
+
} else if (c?.__typename === 'StatusContext' && ['SUCCESS', 'FAILURE', 'ERROR'].includes(c.state)) {
|
|
116
|
+
terminal.push(name);
|
|
117
|
+
if (c.state !== 'SUCCESS') failed.push(name);
|
|
118
|
+
} else unknown.push(name);
|
|
119
|
+
}
|
|
120
|
+
const evidence = { pending, failed, unknown, terminal, complete: checks !== null && unknown.length === 0 };
|
|
121
|
+
fact('pendingChecks', evidence.complete, pending.length === 0, evidence);
|
|
122
|
+
if (pr && evidence.complete && !terminal.length) add('checksSuccessful', 'n/a', evidence);
|
|
123
|
+
else fact('checksSuccessful', evidence.complete, failed.length === 0, evidence);
|
|
124
|
+
const counts = { pass: 0, fail: 0, unknown: 0, 'n/a': 0 };
|
|
125
|
+
for (const t of terms) counts[t.status]++;
|
|
126
|
+
return { version: 1, repo: args['--repo'], pr: Number(args['--pr']), phase: args['--phase'],
|
|
127
|
+
source: args['--input'] ? 'saved' : 'gh api graphql', comparedAt: args['--now'], terms, counts };
|
|
128
|
+
}
|
|
129
|
+
try {
|
|
130
|
+
if (process.argv.slice(2).length === 1 && process.argv[2] === '--help') console.log(HELP);
|
|
131
|
+
else {
|
|
132
|
+
const result = report(options(process.argv.slice(2)));
|
|
133
|
+
console.log(JSON.stringify(result, null, 2));
|
|
134
|
+
process.exitCode = result.counts.unknown ? 2 : 0;
|
|
135
|
+
}
|
|
136
|
+
} catch (error) {
|
|
137
|
+
console.error(`pr-fresh: ${error.message}`);
|
|
138
|
+
process.exitCode = 1;
|
|
139
|
+
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
import { readFileSync } from 'node:fs';
|
|
3
|
+
import { compareQuietPRs } from './pr-digest.js';
|
|
3
4
|
|
|
4
5
|
const HELP = `schedule-drift — canonical schedule comparison (R2 fact mode)
|
|
6
|
+
quiet-facts --help Saved-input review-manager observations (separate fact mode).
|
|
5
7
|
bun schedule-drift.js --export FILE --bindings FILE [--prompts DIR] [--now ISO] [--max-age-seconds N]
|
|
6
8
|
--export FILE Saved JSON: {version:1,host,exportedAt,complete:true,tasks:[{scheduledTaskId,
|
|
7
9
|
projectId,prompt,schedule,enabled}]}. Export every relevant project; never use a live database.
|
|
@@ -119,8 +121,221 @@ function validSchedule(s) {
|
|
|
119
121
|
s.weekdays.every((d) => Number.isSafeInteger(d) && d >= 0 && d <= 6);
|
|
120
122
|
}
|
|
121
123
|
|
|
124
|
+
const QUIET_HELP = `schedule-drift quiet-facts — raw saved-input observations
|
|
125
|
+
bun --no-env-file <installed>/schedule-drift.js quiet-facts --input FILE --continuity FILE [--now ISO]
|
|
126
|
+
--input FILE JSON enclosing raw outputs without projecting or inventing row fields:
|
|
127
|
+
{observedAt,repository:"owner/name",login,reap:{exitCode,dockerAvailable},
|
|
128
|
+
searches:[REVIEW_REQUESTED_ARRAY,INVOLVES_ARRAY],inventory:{args,value},prior:READ_RESPONSE}.
|
|
129
|
+
observedAt is the UTC collection time; repository/login/reap are the existing pass context/results.
|
|
130
|
+
searches are the two gh search prs --limit 1000 JSON arrays exactly as printed:
|
|
131
|
+
number, repository.nameWithOwner, updatedAt, isDraft, author.login; headRefOid when returned.
|
|
132
|
+
Completeness is array length <1000 for BOTH searches; errors/missing arrays are unknown.
|
|
133
|
+
Omitted head OIDs stay unobserved, never synthesized. Compare repository/number/updatedAt
|
|
134
|
+
and only returned OIDs via pr-digest; new/changed fingerprints fail even without an OID.
|
|
135
|
+
inventory is the T29 t3_thread_list {args,value} contract: merged pages, nextCursor:null,
|
|
136
|
+
total matching threads.length; first args include includeSubagents:true and projectId
|
|
137
|
+
(or allProjects:true), cursor absent/0. statuses may be exactly the five busy statuses below;
|
|
138
|
+
no settled/snoozed/titleContains filters. Completeness covers that query, not all history.
|
|
139
|
+
Keep native threadId/projectId/parentThreadId/status/settled/latestRunId and currentThreadId.
|
|
140
|
+
prior is ONE raw t3_thread_read of the recorded prior thread, including its thread metadata;
|
|
141
|
+
no other thread reads or caller-derived guard/liveness/completeness fields are required.
|
|
142
|
+
Raw MCP structuredContent or text-content wrappers are also accepted.
|
|
143
|
+
Native preparing/queued/starting/running/waiting are busy regardless of settlement/guards;
|
|
144
|
+
completed/failed/cancelled/interrupted/rolled_back are terminal. Idle has no active run.
|
|
145
|
+
Unknown status is unknown. Descendants come from native parentThreadId relationships.
|
|
146
|
+
--continuity FILE Saved progress.md with Lane state, Open holds, Watermarks, Last pass.
|
|
147
|
+
Lane state uses run-record.md's scheduledTaskId, threadId/runId, workspace and exact
|
|
148
|
+
terminal receipt: SCHEDULE, THREAD/RUN, WORKSPACE, RECEIPT; read before replacement.
|
|
149
|
+
Active PR jobs and descendants: none, or PR, TASK/CHILD/RUN, OWNER, REVISION, STATE.
|
|
150
|
+
Recorded pass/job IDs and native parent edges define the lane, never project membership.
|
|
151
|
+
Native scheduledTaskId, when present, identifies other passes; unknown lineage stays unknown.
|
|
152
|
+
Native user-created roots and their descendants are outside this lane.
|
|
153
|
+
The legacy '- threadId: ID' record is accepted during migration. Guards use recorded '- ID: held|flagged', '; state:' / '; guard:'
|
|
154
|
+
or '; resume: user decision only' on that exact thread's line, never agent judgment.
|
|
155
|
+
Open holds: '- none' or one line per hold; '; resume: user decision only' (optional final period) is user-only.
|
|
156
|
+
Pending rows in Lane state/Watermarks/Open holds start with unserved/capacity-deferred/
|
|
157
|
+
INCOMPLETE/re-eligible or use '; status: STATE'. Historical Last pass prose is not pending.
|
|
158
|
+
Watermarks: '- Quiet gate: JSON [repo#number,headRefOid,updatedAt] triples';
|
|
159
|
+
'- Last full pass: UTC ISO'. Optional '- Non-lane roots: JSON threadId array' records
|
|
160
|
+
roots proven unrelated during full reconciliation, including omitted idle parents.
|
|
161
|
+
Missing/malformed continuity stays unknown; exclusions never override a recorded lane root.
|
|
162
|
+
--now ISO Observation time with timezone; default current UTC; collection age must be 0..300s.
|
|
163
|
+
--help Show flags, input contract, effects and limitations.
|
|
164
|
+
No writes, subprocesses, network, T3 calls, database access or persistent state. Run from cwd /.
|
|
165
|
+
Facts only; counts, no aggregate verdict or authority. Driver applies quiet/full/hold rules.
|
|
166
|
+
Exit: 0 measured (including fail), 1 invalid CLI, 2 incomplete/unknown, including read/JSON failure.
|
|
167
|
+
`;
|
|
168
|
+
|
|
169
|
+
const terminalRuns = ['completed', 'failed', 'cancelled', 'interrupted', 'rolled_back'];
|
|
170
|
+
const activeRuns = ['preparing', 'queued', 'starting', 'running', 'waiting'];
|
|
171
|
+
const repoName = (v) => typeof v === 'string' && /^[\w.-]+\/[\w.-]+$/.test(v);
|
|
172
|
+
const section = (text, name) => text.match(new RegExp(`^## ${name}\\s*\\n([\\s\\S]*?)(?=^## |$(?![\\s\\S]))`, 'm'))?.[1];
|
|
173
|
+
function quietOptions(argv) {
|
|
174
|
+
const args = { '--now': new Date().toISOString() }, seen = new Set();
|
|
175
|
+
for (let i = 0; i < argv.length; i += 2) {
|
|
176
|
+
if (!['--input', '--continuity', '--now'].includes(argv[i]) || !argv[i + 1] || seen.has(argv[i])) throw Error('invalid quiet-facts argument');
|
|
177
|
+
seen.add(argv[i]); args[argv[i]] = argv[i + 1];
|
|
178
|
+
}
|
|
179
|
+
if (!args['--input'] || !args['--continuity'] || !Number.isFinite(time(args['--now']))) throw Error('expected --input, --continuity and timezone-qualified --now');
|
|
180
|
+
return args;
|
|
181
|
+
}
|
|
182
|
+
// Preserve tool outputs: unwrap MCP packaging, never project caller-invented row fields.
|
|
183
|
+
function nativeValue(value) {
|
|
184
|
+
if (value?.isError) return null;
|
|
185
|
+
if (value?.structuredContent) return value.structuredContent;
|
|
186
|
+
if (Array.isArray(value?.content)) {
|
|
187
|
+
try { return JSON.parse(value.content.find(item => item.type === 'text')?.text); } catch { return null; }
|
|
188
|
+
}
|
|
189
|
+
return value;
|
|
190
|
+
}
|
|
191
|
+
function rawQuietFacts(args, input, continuity, inputSha256, continuitySha256) {
|
|
192
|
+
const terms = [], term = (id, status, evidence) => terms.push({ id, status, evidence });
|
|
193
|
+
const age = (time(args['--now']) - time(input.observedAt)) / 1000;
|
|
194
|
+
const fresh = Number.isFinite(age) && age >= 0 && age <= 300;
|
|
195
|
+
term('observations', fresh ? 'pass' : 'unknown', { ageSeconds: Number.isFinite(age) ? age : null, inputSha256 });
|
|
196
|
+
const sections = Object.fromEntries(['Lane state', 'Open holds', 'Watermarks', 'Last pass'].map(name => [name, section(continuity, name)]));
|
|
197
|
+
const continuityKnown = Object.values(sections).every(nonempty);
|
|
198
|
+
term('continuity', continuityKnown ? 'pass' : 'unknown', { continuitySha256 });
|
|
199
|
+
const snapshot = input.inventory, call = snapshot?.args, value = nativeValue(snapshot?.value), rows = value?.threads;
|
|
200
|
+
const byId = new Map();
|
|
201
|
+
let complete = fresh && call && Array.isArray(rows) && !snapshot.isError && !value.isError && value.complete !== false && !value.truncated && !value.hasMore &&
|
|
202
|
+
value.nextCursor === null && value.total === rows.length && call.includeSubagents === true &&
|
|
203
|
+
(call.cursor === undefined || call.cursor === 0) && !['settled', 'snoozed', 'titleContains'].some(key => Object.hasOwn(call, key)) &&
|
|
204
|
+
(call.statuses === undefined || Array.isArray(call.statuses) && equal([...call.statuses].sort(), [...activeRuns].sort()));
|
|
205
|
+
for (const row of Array.isArray(rows) ? rows : []) {
|
|
206
|
+
if (!nonempty(row?.threadId) || !nonempty(row?.projectId) || byId.has(row.threadId) ||
|
|
207
|
+
!(row.parentThreadId === null || nonempty(row.parentThreadId)) || row.parentThreadId === row.threadId) { complete = false; continue; }
|
|
208
|
+
byId.set(row.threadId, row);
|
|
209
|
+
}
|
|
210
|
+
for (const row of byId.values()) {
|
|
211
|
+
const seen = new Set([row.threadId]); let parent = row.parentThreadId;
|
|
212
|
+
while (byId.has(parent)) {
|
|
213
|
+
if (seen.has(parent)) { complete = false; break; }
|
|
214
|
+
seen.add(parent); parent = byId.get(parent).parentThreadId;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
const self = byId.get(value?.currentThreadId), projectId = self?.projectId;
|
|
218
|
+
const scoped = complete && self && (call.allProjects === true || nonempty(call.projectId) && call.projectId === projectId &&
|
|
219
|
+
[...byId.values()].every(row => row.projectId === projectId));
|
|
220
|
+
const identity = !!scoped && repoName(input.repository);
|
|
221
|
+
term('identity', identity ? 'pass' : 'unknown', { repository: input.repository ?? null, projectId: projectId ?? null, selfThreadId: self?.threadId ?? null });
|
|
222
|
+
const reap = input.reap;
|
|
223
|
+
term('reap', !Number.isInteger(reap?.exitCode) || typeof reap?.dockerAvailable !== 'boolean' ? 'unknown' :
|
|
224
|
+
reap.exitCode === 0 && reap.dockerAvailable ? 'pass' : 'fail', reap ?? 'no saved reap result');
|
|
225
|
+
let discovery = fresh && nonempty(input.login) && Array.isArray(input.searches) && input.searches.length === 2;
|
|
226
|
+
const prs = new Map();
|
|
227
|
+
for (const raw of Array.isArray(input.searches) ? input.searches : []) {
|
|
228
|
+
const found = nativeValue(raw), seen = new Set();
|
|
229
|
+
if (!Array.isArray(found) || found.length >= 1000) { discovery = false; continue; }
|
|
230
|
+
for (const pr of found) {
|
|
231
|
+
const repository = pr?.repository?.nameWithOwner, key = `${repository}#${pr?.number}`;
|
|
232
|
+
if (!repoName(repository) || !Number.isSafeInteger(pr?.number) || pr.number < 1 || seen.has(key) ||
|
|
233
|
+
!nonempty(pr.author?.login) || typeof pr.isDraft !== 'boolean' || !Number.isFinite(time(pr.updatedAt)) ||
|
|
234
|
+
time(pr.updatedAt) > time(args['--now']) || pr.headRefOid !== undefined && !/^[a-f0-9]{40,64}$/.test(pr.headRefOid)) {
|
|
235
|
+
discovery = false; continue;
|
|
236
|
+
}
|
|
237
|
+
seen.add(key);
|
|
238
|
+
if (pr.author.login.toLowerCase() === input.login?.toLowerCase?.() || pr.isDraft || pr.state && pr.state.toLowerCase() !== 'open') continue;
|
|
239
|
+
const row = [key, pr.headRefOid ?? null, pr.updatedAt];
|
|
240
|
+
if (prs.has(key) && !equal(prs.get(key), row)) discovery = false;
|
|
241
|
+
prs.set(key, row);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
term('discovery', discovery ? 'pass' : 'unknown', { eligible: prs.size, resultCounts: input.searches?.map?.(r => nativeValue(r)?.length ?? null) ?? [] });
|
|
245
|
+
let previous;
|
|
246
|
+
try { previous = JSON.parse(sections.Watermarks?.match(/^- Quiet gate: (.+)$/m)?.[1]); } catch { /* unknown watermark */ }
|
|
247
|
+
const comparison = compareQuietPRs(previous, [...prs.values()], { optionalHeads: true });
|
|
248
|
+
term('pr-list', discovery && continuityKnown ? comparison.status : 'unknown', comparison.evidence);
|
|
249
|
+
const elapsed = time(args['--now']) - time(sections.Watermarks?.match(/^- Last full pass: (.+)$/m)?.[1]);
|
|
250
|
+
term('full-pass-age', !continuityKnown || !Number.isFinite(elapsed) ? 'unknown' : elapsed >= 0 && elapsed < 14400000 ? 'pass' : 'fail',
|
|
251
|
+
{ ageSeconds: Number.isFinite(elapsed) ? elapsed / 1000 : null });
|
|
252
|
+
const laneText = sections['Lane state'] ?? '';
|
|
253
|
+
const passRecords = [...laneText.matchAll(/^- scheduledTaskId, threadId\/runId, workspace and exact terminal receipt: ([^,]+), ([^/\s,]+)\/([^,]+), ([^,]+), (.+)$/gm)];
|
|
254
|
+
const priorIds = passRecords.length ? passRecords.map(m => m[2]) : [...laneText.matchAll(/^- threadId: (\S+)$/gm)].map(m => m[1]);
|
|
255
|
+
const schedules = new Set(passRecords.map(m => m[1]));
|
|
256
|
+
const jobs = laneText.match(/^- Active PR jobs and descendants: (.+)$/m)?.[1];
|
|
257
|
+
const jobRecords = jobs === 'none' ? [] : jobs?.split(/;\s*(?=[\w.-]+\/[\w.-]+#\d+,)/).map(row => row.match(/^[\w.-]+\/[\w.-]+#\d+, [^/\s,]+\/([^/\s,]+)\/[^,]+, [^,]+, [^,]+, .+$/));
|
|
258
|
+
const jobsKnown = jobs === 'none' || Array.isArray(jobRecords) && jobRecords.length > 0 && jobRecords.every(Boolean);
|
|
259
|
+
const read = nativeValue(input.prior?.value ?? input.prior), prior = read?.thread;
|
|
260
|
+
const knownStatus = row => row && [...terminalRuns, ...activeRuns, 'idle'].includes(row.status);
|
|
261
|
+
const priorKnown = identity && priorIds.length > 0 && prior?.threadId === priorIds[0] && prior.threadId !== self.threadId &&
|
|
262
|
+
prior.projectId === projectId && typeof prior.settled === 'boolean' && knownStatus(prior);
|
|
263
|
+
const laneIds = new Set([...priorIds, ...(jobRecords ?? []).filter(Boolean).map(m => m[1])]);
|
|
264
|
+
let outsideRoots = [], outsideKnown = true;
|
|
265
|
+
const outsideRecords = [...(sections.Watermarks ?? '').matchAll(/^- Non-lane roots: (.*)$/gm)];
|
|
266
|
+
if (outsideRecords.length) {
|
|
267
|
+
try { outsideRoots = JSON.parse(outsideRecords[0][1]); } catch { outsideRoots = null; }
|
|
268
|
+
outsideKnown = outsideRecords.length === 1 && Array.isArray(outsideRoots) && outsideRoots.every(nonempty) &&
|
|
269
|
+
new Set(outsideRoots).size === outsideRoots.length && outsideRoots.every(id => !laneIds.has(id) && id !== self?.threadId &&
|
|
270
|
+
!schedules.has(byId.get(id)?.scheduledTaskId) &&
|
|
271
|
+
(!byId.has(id) || byId.get(id).parentThreadId === null));
|
|
272
|
+
}
|
|
273
|
+
const outsideIds = new Set(outsideKnown ? outsideRoots : []);
|
|
274
|
+
const membership = new Map();
|
|
275
|
+
function member(row, seen = new Set()) {
|
|
276
|
+
if (membership.has(row.threadId)) return membership.get(row.threadId);
|
|
277
|
+
if (laneIds.has(row.threadId)) return true;
|
|
278
|
+
if (outsideIds.has(row.threadId)) return false;
|
|
279
|
+
if (nonempty(row.scheduledTaskId) && schedules.size) return schedules.has(row.scheduledTaskId);
|
|
280
|
+
if (seen.has(row.threadId)) return null;
|
|
281
|
+
seen.add(row.threadId);
|
|
282
|
+
if (laneIds.has(row.parentThreadId)) return true;
|
|
283
|
+
if (outsideIds.has(row.parentThreadId)) return false;
|
|
284
|
+
if (byId.has(row.parentThreadId)) return member(byId.get(row.parentThreadId), seen);
|
|
285
|
+
if (row.parentThreadId !== null) return null;
|
|
286
|
+
if (row.projectId !== projectId || row.scheduledTaskId === null ||
|
|
287
|
+
row.createdBy === 'user' || ['web', 'mobile'].includes(row.creationSource)) return false;
|
|
288
|
+
return null;
|
|
289
|
+
}
|
|
290
|
+
for (const row of byId.values()) membership.set(row.threadId, member(row));
|
|
291
|
+
const candidates = [...byId.values()].filter(row => row.threadId !== self?.threadId);
|
|
292
|
+
const laneRows = candidates.filter(row => membership.get(row.threadId) === true);
|
|
293
|
+
const ambiguous = candidates.filter(row => membership.get(row.threadId) === null && !terminalRuns.includes(row.status) && row.status !== 'idle');
|
|
294
|
+
const laneKnown = identity && priorIds.length > 0 && jobsKnown && outsideKnown && ambiguous.length === 0 && laneRows.every(knownStatus);
|
|
295
|
+
const threadsKnown = laneKnown && priorKnown;
|
|
296
|
+
const descendants = laneRows.filter(row => row.parentThreadId !== null).map(row => row.threadId);
|
|
297
|
+
term('thread-readbacks', threadsKnown ? 'pass' : 'unknown', { listed: laneRows.length, descendantThreadIds: descendants, priorThreadId: prior?.threadId ?? null, priorReads: prior ? 1 : 0 });
|
|
298
|
+
term('ownership', threadsKnown && continuityKnown ? 'pass' : 'unknown', { completeInventory: !!scoped, projectId: projectId ?? null, total: value?.total ?? null, recordedNonLaneRoots: outsideKnown ? outsideRoots : null, ambiguousThreadIds: ambiguous.map(row => row.threadId) });
|
|
299
|
+
const holds = sections['Open holds']?.trim().split('\n').filter(nonempty) ?? [];
|
|
300
|
+
const userOnly = line => /; resume: user decision only\.?$/i.test(line);
|
|
301
|
+
const holdKnown = holds.length > 0 && (holds.length === 1 && holds[0] === '- none' || holds.every(line => /^- .+: .+; resume: [^;]+$/.test(line)));
|
|
302
|
+
const priorLines = [...laneText.split('\n'), ...holds].filter(line => priorIds[0] &&
|
|
303
|
+
(line.startsWith(`- ${priorIds[0]}:`) || line === `- threadId: ${priorIds[0]}` || passRecords.some(m => m[2] === priorIds[0] && m[0] === line)));
|
|
304
|
+
const guarded = priorLines.some(line => /(?:^- \S+:\s*|;\s*(?:state|guard):\s*)(?:held|flagged|owned watch|pending receipt|wedged|stalled owner|protected)\b/i.test(line) || userOnly(line));
|
|
305
|
+
const terminal = row => terminalRuns.includes(row.status);
|
|
306
|
+
term('prior-pass', !priorKnown || !continuityKnown || !holdKnown ? 'unknown' : prior.settled || terminal(prior) && guarded ? 'pass' : 'fail',
|
|
307
|
+
{ threadId: prior?.threadId ?? null, status: prior?.status ?? null, settled: prior?.settled ?? null, recordedGuard: guarded });
|
|
308
|
+
const nonterminal = row => activeRuns.includes(row.status);
|
|
309
|
+
const busy = [...laneRows, ...(priorKnown ? [prior] : [])].filter(row => row.threadId !== self?.threadId && nonterminal(row)).map(row => row.threadId);
|
|
310
|
+
term('lane-idle', identity && busy.length ? 'fail' : !laneKnown ? 'unknown' : 'pass', { nonterminalThreadIds: [...new Set(busy)], ambiguousThreadIds: ambiguous.map(row => row.threadId) });
|
|
311
|
+
const recorded = [sections['Lane state'], sections.Watermarks, sections['Open holds']].filter(Boolean).join('\n');
|
|
312
|
+
const event = /^- (?:unserved|capacity-deferred|INCOMPLETE|re-eligible)\b|;\s*status:\s*(?:unserved|capacity-deferred|INCOMPLETE|re-eligible)\b/gm;
|
|
313
|
+
const pendingEvent = event.test(recorded);
|
|
314
|
+
const pending = pendingEvent || jobs !== 'none' || holds.some(line =>
|
|
315
|
+
!/^- none$/i.test(line) && !userOnly(line));
|
|
316
|
+
term('pending-work', continuityKnown && pendingEvent ? 'fail' : !continuityKnown || !holdKnown || !nonempty(jobs) ? 'unknown' : pending ? 'fail' : 'pass',
|
|
317
|
+
{ activeJobs: jobs ?? null, holds, pending });
|
|
318
|
+
const counts = Object.fromEntries(['pass', 'fail', 'unknown', 'n/a'].map(s => [s, terms.filter(t => t.status === s).length]));
|
|
319
|
+
return { version: 2, observedAt: args['--now'], terms, counts };
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
function quietFacts(args) {
|
|
323
|
+
let input, continuity = '', inputSha256 = null, continuitySha256 = null;
|
|
324
|
+
try { const bytes = readFileSync(args['--input']); inputSha256 = sha256(bytes); input = JSON.parse(bytes.toString()); } catch { /* unknown input */ }
|
|
325
|
+
try { const bytes = readFileSync(args['--continuity']); continuitySha256 = sha256(bytes); continuity = bytes.toString(); } catch { /* unknown continuity */ }
|
|
326
|
+
return rawQuietFacts(args, input ?? {}, continuity, inputSha256, continuitySha256);
|
|
327
|
+
}
|
|
328
|
+
|
|
122
329
|
try {
|
|
123
|
-
if (process.argv
|
|
330
|
+
if (process.argv[2] === 'quiet-facts') {
|
|
331
|
+
if (process.argv.length === 4 && process.argv[3] === '--help') console.log(QUIET_HELP);
|
|
332
|
+
else {
|
|
333
|
+
const report = quietFacts(quietOptions(process.argv.slice(3)));
|
|
334
|
+
console.log(JSON.stringify(report, null, 2));
|
|
335
|
+
process.exitCode = report.counts.unknown ? 2 : 0;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
else if (process.argv.slice(2).length === 1 && process.argv[2] === '--help') console.log(HELP);
|
|
124
339
|
else {
|
|
125
340
|
const report = compare(options(process.argv.slice(2)));
|
|
126
341
|
console.log(JSON.stringify(report, null, 2));
|
|
@@ -15,13 +15,13 @@ hard-to-reverse choices; they replace the critique round for that question.
|
|
|
15
15
|
and `axstack-arena-candidate-grok`.
|
|
16
16
|
Each gives a design, rationale, and rejected alternatives. The driver authors no candidate.
|
|
17
17
|
The driver drafts no recommendation until every candidate returns.
|
|
18
|
-
3. **Cross-judge (Rung 2 only).** After
|
|
19
|
-
`axstack-
|
|
18
|
+
3. **Cross-judge (Rung 2 only).** After candidates complete, give fresh round 1 judge
|
|
19
|
+
`axstack-escalation-fable` the anonymized, relabeled candidates and rubric to
|
|
20
20
|
score every candidate per criterion and recommend a base with a reason.
|
|
21
|
-
The driver compares its
|
|
22
|
-
and the
|
|
21
|
+
The driver compares its pick with the Fable verdict. Only if the driver
|
|
22
|
+
and the Fable judge disagree on the base, or the caller re-invokes with the user's rejection of the round-1
|
|
23
23
|
synthesis,
|
|
24
|
-
run round 2 with fresh sessions: `axstack-
|
|
24
|
+
run round 2 with fresh sessions: `axstack-arena-judge-opus` and `axstack-arena-judge-astra`
|
|
25
25
|
independently score the same anonymized candidates and rubric. Judges never
|
|
26
26
|
author, never cross-read each other, and never average verdicts. After round-2
|
|
27
27
|
verdicts return, the driver re-picks in step 4 and re-presents in step 6.
|
|
@@ -271,8 +271,7 @@ external write.
|
|
|
271
271
|
Submit a consolidated peer review only within explicit user authority and only
|
|
272
272
|
for a complete `APPROVE` or `REQUEST_CHANGES` verdict:
|
|
273
273
|
|
|
274
|
-
1.
|
|
275
|
-
candidate.
|
|
274
|
+
1. Apply [Peer mode](references/peer-mode.md).
|
|
276
275
|
2. Bind the submission to the actual GitHub commit parameter for that revision;
|
|
277
276
|
SHA text in prose is not binding.
|
|
278
277
|
3. Publish the owner-synthesized review with the mode-required peer receipts as evidence,
|
|
@@ -306,7 +305,7 @@ the disposition. A newly accepted explanation can turn same-head
|
|
|
306
305
|
`REQUEST_CHANGES` into `APPROVE`. Count every same-head `REQUEST_CHANGES`
|
|
307
306
|
submission toward the five-request cap.
|
|
308
307
|
|
|
309
|
-
Before every submission, re-check
|
|
308
|
+
Before every submission, re-check authorship and
|
|
310
309
|
allowlist, bind the verdict to the exact commit parameter, and end the body
|
|
311
310
|
with this marker line:
|
|
312
311
|
|
|
@@ -8,8 +8,7 @@ Never ask the author for approvals, sign-offs, a spec approver or a process
|
|
|
8
8
|
decision, except the `Pre-existing` filing request (the only exception). Accept the author's
|
|
9
9
|
statement that a scope or design point was approved or decided elsewhere.
|
|
10
10
|
That decision is not a finding. Peer review needs no Axstack-created approved
|
|
11
|
-
spec. Peer code stays readonly
|
|
12
|
-
current base, context and authority before dispatch.
|
|
11
|
+
spec. Peer code stays readonly. Record context and authority before dispatch.
|
|
13
12
|
|
|
14
13
|
### Sync admission and round freshness
|
|
15
14
|
|
|
@@ -19,16 +18,16 @@ On sync pass, use no reviewer dispatch and submit nothing, record `sync skip`
|
|
|
19
18
|
with event identity, and leave the PR for the user.
|
|
20
19
|
Sync fail or unknown enters ordinary review.
|
|
21
20
|
|
|
22
|
-
Before each dispatch
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
On discard, submit nothing
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
21
|
+
Before each dispatch/reconcile (`admission`) and submission (`submission`), run installed
|
|
22
|
+
[pr-fresh](../../axstack/scripts/pr-fresh.js) outside candidate, from `/` via `bun --no-env-file`.
|
|
23
|
+
With `evidence.unrecorded:true`, ignore policy, headAge, pendingChecks and checksSuccessful.
|
|
24
|
+
Absent/unreadable/malformed/unsupported policy holds.
|
|
25
|
+
Only explicit recorded policy gates age/pending/failed checks, holding unknown gating terms.
|
|
26
|
+
Event facts (open, nonDraft, unmerged, pinnedHead, baseUnchanged): discard failures, hold unknowns.
|
|
27
|
+
On discard, submit nothing; cancel owned tasks, verify
|
|
28
|
+
[settlement](../../axstack/references/automations.md#held-job-settlement), preserve evidence, record `discarded: <reason>`.
|
|
29
|
+
Merged or closed: existing cleanup.
|
|
30
|
+
New head: new event, never restart inside the job.
|
|
32
31
|
Add no polling loop or watcher.
|
|
33
32
|
|
|
34
33
|
A missing bot verdict marker selects the first review. An existing bot verdict
|