harness-everything 0.53.0 → 0.54.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/AGENTS.md +3 -1
  4. package/CHANGELOG.md +18 -0
  5. package/bin/cli.js +1 -0
  6. package/ci/invariant-routing.test.js +22 -3
  7. package/ci/mechanism-2al-codex-hooks-compat.test.js +56 -2
  8. package/ci/mechanism-349-ci-change-scope.test.js +78 -57
  9. package/ci/mechanism-397-cycle-import.test.js +18 -3
  10. package/ci/mechanism-check-packet-write-set.test.js +232 -0
  11. package/ci/mechanism-codex-prompt-pass-through.test.js +8 -4
  12. package/ci/mechanism-error-handling-map.test.js +219 -0
  13. package/ci/mechanism-report-writer.test.js +335 -0
  14. package/ci/router-workflow-plan.test.js +50 -7
  15. package/docs/architecture.md +4 -3
  16. package/docs/error-handling/README.md +250 -0
  17. package/docs/error-handling/actions/c1-action-map.md +89 -0
  18. package/docs/error-handling/actions/c2-action-map.md +22 -0
  19. package/docs/error-handling/actions/c3-action-map.md +26 -0
  20. package/docs/error-handling/actions/c5-action-map.md +31 -0
  21. package/docs/error-handling/actions/c6-action-map.md +37 -0
  22. package/docs/error-handling/actions/c7-action-map.md +18 -0
  23. package/docs/error-handling/actions/e0002-action-map.md +101 -0
  24. package/docs/error-handling/activity.puml +84 -0
  25. package/docs/error-handling/details/c1-authority-conformance.md +93 -0
  26. package/docs/error-handling/details/c2-test-root-containment.md +35 -0
  27. package/docs/error-handling/details/c3-mode-ownership.md +50 -0
  28. package/docs/error-handling/details/c5-host-replay-contract.md +40 -0
  29. package/docs/error-handling/details/c6-packet-briefing.md +65 -0
  30. package/docs/error-handling/details/c7-write-set-check.md +54 -0
  31. package/docs/error-handling/details/e0002-capture-evidence.md +93 -0
  32. package/docs/error-handling/details/e0002-report-writer.md +116 -0
  33. package/docs/error-handling/nodes.yaml +44 -0
  34. package/docs/error-handling/registry.md +59 -0
  35. package/docs/error-handling/templates/packet-briefing.md +45 -0
  36. package/docs/platform-capabilities.md +3 -1
  37. package/hooks/scripts/codex-user-prompt.js +2 -3
  38. package/opencode-plugin/plugin.json +1 -1
  39. package/package.json +2 -1
  40. package/plugins/harness-everything/.codex-plugin/plugin.json +1 -1
  41. package/plugins/harness-everything/hooks/scripts/codex-user-prompt.js +2 -3
  42. package/plugins/harness-everything/plugin.json +1 -1
  43. package/sbom.cdx.json +7 -7
  44. package/scripts/check-packet-write-set.js +155 -0
  45. package/scripts/codex-hooks-compat.js +46 -5
  46. package/scripts/error-handling-map.js +288 -0
  47. package/scripts/report-writer.js +261 -0
@@ -0,0 +1,18 @@
1
+ # C7 — Candidate write-set check
2
+
3
+ After a packet's local gates, the coordinator checks that the candidate slice stayed within its approved paths before accepting it. The checker reports path scope; the coordinator still reviews content and packet requirements.
4
+
5
+ ```mermaid
6
+ flowchart TD
7
+ GATES["Packet local gates complete"] --> RUN["Run checker with pinned base, candidate head and allow-list"]
8
+ RUN --> EXIT{"Exit code"}
9
+ EXIT -->|0| PATHS["Every observed path is allowed"]
10
+ PATHS --> REVIEW["Review same-file content and outline completeness"]
11
+ REVIEW --> ACCEPT["Accept only when the packet's other evidence also passes"]
12
+ EXIT -->|1| INSPECT["Inspect each OUT_OF_SET path against the approved scope"]
13
+ INSPECT -->|Files or approved scope corrected| RUN
14
+ EXIT -->|2| REPAIR["Correct usage, revision or Git error; keep result unverified"]
15
+ REPAIR --> RUN
16
+ ```
17
+
18
+ **Exit 0 is a path-scope result, not packet acceptance.** The checker cannot detect same-file content loss or an omitted approved outline row; the scoped review must compare those inputs directly (see [E-0014](../../../.agents/harness-everything/errors/E-0014-lossy-cleanup.md) and [E-0016](../../../.agents/harness-everything/errors/E-0016-adr-draft-omits-approved-outline-row.md)). Run it after local gates and before accepting the slice. It does not install a hook or change CI behavior.
@@ -0,0 +1,101 @@
1
+ # E-0002 — Level 2 Action Map (magnifying Level 1 behavior blocks)
2
+
3
+ > **Diagram-first design draft; not implemented.** This is the E-0002 lens over the [Level 1 Error Handling process](../README.md) for [#437](https://github.com/dyphn1/Harness-everything/issues/437) / [#402](https://github.com/dyphn1/Harness-everything/issues/402). Level 1 remains the authority for Action sequence, guards, exits, authority and one-Error-Occurrence boundary. A–G are drawing-local aliases, not new identities.
4
+ >
5
+ > **Level 2 describes WHAT THE AGENT SHOULD DO within the magnified behavior block.** It can expand one Action or a connected group of Actions; it need not reproduce each internal step as a new global rule. Level 3 holds HOW (scripts, return-code details, evidence and document format). Agent discretion over tactics stays intact if the Level 1 contract is met.
6
+
7
+ **Lookup:** [Registry table](../registry.md) locates this Level 2 behavior block and its Level 3 references. It maps *documents*, not control-flow arrows. The Level 1 Views are unchanged; whether their relationship to Levels confuses Agents will be tested by the owner rather than assumed.
8
+
9
+ **Action-contract scope:** this map defines what to do, **not** a mandatory per-Action I/O schema. Only a concrete machine interface (such as the proposed Report Script/CLI in Level 3) requires explicit parameters, outputs and return-code behavior. Agent-chosen tactics are valid when Level 1's necessary conditions are met.
10
+
11
+ ## Block 1 — ASSESS: capture, triage and identify this occurrence
12
+
13
+ ```mermaid
14
+ flowchart TD
15
+ START(["New occurrence from Level 1"]) --> A["A · Capture<br/>Retain observed report/turn evidence, source,<br/>raw ending and unknowns without editing it"]
16
+ A --> B["B · Triage<br/>Apply mode-dependent L1 path:<br/>Coordinator → Reviewer; Solo Main → evidence self-check"]
17
+ B --> BF{"Triage result?"}
18
+ BF -->|"Real finding"| C["C · Identify<br/>Compare evidence with existing E-0002<br/>signature/history for THIS new occurrence"]
19
+ BF -->|"Dismiss / hold / approved tolerate"| BEXIT["Follow matching Level 1 exit;<br/>UNVERIFIED never means PASS"]
20
+ C --> ID{"Identification complete?"}
21
+ ID -->|"No / approval pending"| HOLD["Hold: identification incomplete<br/>owner decision where required"]
22
+ ID -->|"Yes"| BLOCK{"Blocking main path?"}
23
+ BLOCK -->|"No"| DEFER["Record and defer treatment<br/>identified but non-blocking"]
24
+ BLOCK -->|"Yes"| NEXT(["Hand off to RESPOND block"])
25
+ ```
26
+
27
+ **P1-1 boundary:** *unidentified / pending class approval* leads to **Hold**, whereas *identified but non-blocking* leads to **Defer**. They are distinct Level 1 outcomes. Recognizing E-0002-like evidence at Capture does not automatically classify the case: formal classification and reusing history belong to Identify. A future recurrence is a new occurrence starting at Capture.
28
+
29
+ ## Block 2 — RESPOND: decide, act, deliver and accept
30
+
31
+ ```mermaid
32
+ flowchart TD
33
+ IN(["Blocking, identified E-0002<br/>from ASSESS"]) --> D["D · Decide<br/>Choose Converge / Avoid / Tolerate<br/>from evidence and available capability"]
34
+ D --> V["Validate selection using the relevant<br/>script/contract, including required approval"]
35
+ V --> VR{"Conditions satisfied?"}
36
+ VR -->|"nonzero / unmet"| DR["Return error and unmet condition to agent;<br/>revise within Decide, or keep unresolved"]
37
+ DR -->|"can revise within budget"| D
38
+ DR -->|"cannot satisfy"| DEXIT["Follow Level 1 unresolved exit;<br/>no Treat on invalid disposition"]
39
+ VR -->|"yes"| E["E · Treat<br/>Perform the selected bounded operation"]
40
+ E --> ET{"Selected treatment?"}
41
+ ET -->|"Converge"| WR["Agent prepares truthful content/status;<br/>feed codex -o raw output through script;<br/>script writes/checks final report"]
42
+ ET -->|"Avoid"| AV["Restrict or omit unnecessary action<br/>per validated disposition"]
43
+ ET -->|"Owner-approved Tolerate"| TO["Use approved bound / retry / escalation;<br/>no implied verification PASS"]
44
+ WR --> RC["Check return code and actual artifact"]
45
+ AV --> RC
46
+ TO --> RC
47
+ RC --> OK{"Treatment contract met?"}
48
+ OK -->|"nonzero / failed"| ERR["Agent handles return code,<br/>corrects within the same Treat block<br/>or preserves unresolved evidence"]
49
+ ERR -->|"correctable within budget"| E
50
+ ERR -->|"unresolved"| F
51
+ OK -->|"yes"| F["F · Deliver<br/>Hand off relevant operation/context<br/>and result (including failures)"]
52
+ F --> G["G · Accept<br/>Verify objective obligations and outcome"]
53
+ G --> MODE{"Main Agent mode?"}
54
+ MODE -->|"Coordinator"| GR["Main dispatches read-only independent Reviewer<br/>for outcome/evidence verification"]
55
+ MODE -->|"Solo executing Main"| GS["Objective Script/CI/contract checks<br/>no independent review claim"]
56
+ GR --> GOK{"Acceptance conditions met?"}
57
+ GS --> GOK
58
+ GOK -->|"yes"| DONE(["Accept current occurrence;<br/>retire unneeded lesson only"])
59
+ GOK -->|"nonzero / incomplete"| OPEN(["Keep occurrence open / unresolved;<br/>return failure context for follow-up"])
60
+ ```
61
+
62
+ **Reading rules:** This is a magnification of the **RESPOND behavior block**, not a new global controller. G inherits the same execution-mode distinction as Level 1: coordinated Main **must dispatch read-only independent Reviewer outcome verification**, while Solo Main uses objective checks and explicitly does not claim independent review. Reviewer is investigative by default and does not edit artifacts or run Treat; minor/trivial errors are not an automatic exemption. In D, a script can reject unmet conditions using a nonzero return code; the agent can revise the decision locally rather than creating a new Level 1 approval/retry workflow. An Owner-required authorization still has to exist to pass validation; a script must never manufacture permission.
63
+
64
+ In E, scripts verify deterministic conditions and return actionable diagnostics; the agent chooses a suitable correction, constrained by the currently accepted disposition and budget. A failure that cannot be corrected still reaches **F (deliver result/evidence)** and **G (open/unresolved acceptance outcome)**, not an orphan endpoint. G's nonzero/incomplete outcome does **not** retire a needed instruction or silently claim success. Neither this path nor future recurrence creates a G → D or G → Capture loop.
65
+
66
+ ## E-0002 instructions by behavior block
67
+
68
+ | Scope from Level 1 | What the agent should do (Level 2) | Handoff/condition |
69
+ | --- | --- | --- |
70
+ | **A Capture** | Preserve original report/turn data, the exact terminal lines and whether `-o` is involved; do not modify evidence. | Give B evidence plus explicit unknowns. |
71
+ | **B Triage → C Identify** | Apply common Triage guards, then identify using actual evidence and the existing E-0002 class. **Unidentified → Hold; identified non-blocking → Defer.** | Only identified, blocking observations proceed to D. |
72
+ | **D Decide (response block)** | Choose an applicable disposition. Validate approval, feasibility and required conditions through the applicable script/contract; a rejected choice returns to Agent for correction or unresolved handling. | Do not start E with an invalid choice. |
73
+ | **E Treat (response block)** | Execute the accepted treatment, with agent-selected tactics. For **Converge**, Agent determines the truthful status and prepares content; script/CLI owns atomic report writing and structural validation. For **Avoid/Tolerate**, execute their distinct approved operations. | Nonzero return code returns control to Agent inside this block; if still unresolved, preserve result for F/G. |
74
+ | **F Deliver (response block)** | Hand off the chosen procedure/available command and current outcome. Later, at **relevant** workflow steps, the Hook/Skill mechanism may expose the appropriate command; that future contextual exposure is *not another occurrence transition*. | No unsupported CLI is presented as installed; deliver failure evidence when unresolved. |
75
+ | **G Accept (response block)** | Use deterministic checks for mechanical obligations and assess substantive Evidence. In Coordinator mode, Main dispatches independent read-only Reviewer for the treatment outcome before acceptance; in Solo Main mode use objective checks and disclose lack of independent review. If verification fails, return explicit unmet conditions and keep open; retire only obsolete lesson prose, not a command still needed for routine work. | Only accepted outcomes may be reported as accepted; Tolerate remains bounded, not “fixed.” |
76
+
77
+ ## Mechanism and time boundary (the one-time response vs future use)
78
+
79
+ ```mermaid
80
+ flowchart LR
81
+ RESPONSE["Current occurrence: D → E → F → G<br/>decide, apply, hand off, accept"] -. "established reusable capability" .-> AVAILABLE["Relevant Skill / Script reference"]
82
+ AVAILABLE -. "at a later relevant workflow step<br/>via scoped Hook disclosure" .-> OP["Agent performs script-mediated operation<br/>and uses return code"]
83
+ ```
84
+
85
+ The dotted relations are **reuse/context**, not control-flow links between occurrences. Level 1 remains the only occurrence lifecycle. Future agents need to know **the action to perform at the current step**, not reload every past error report. Mechanism correctness and eventual recurrence reduction remain separate questions.
86
+
87
+ ### Script-first contract (Level 2 only)
88
+
89
+ - The **agent** determines content, substantive truth and how to react to failures; the **script** performs bounded write/check and returns exit code + clear unmet condition. A zero exit code proves only the specific script contract.
90
+ - For `codex exec -o`, `-o` is a **script-mediated raw output/input artifact**, not a report finalized by manual editing. Route raw output through the report script, which must validate/extract only under a specified host-aware contract and then write/check the designated report. If the transformation cannot satisfy that contract, return nonzero and preserve raw evidence; do not silently strip metadata or fabricate success.
91
+ - **No extra Level 1 branches or hard-coded retry counter** are added to make the script work. Agent correction after a failure is local to the magnified block and subject to existing constraints.
92
+ - Script contracts and actual commands are **proposals** (not currently shipped). Missing scripts cannot satisfy a required mechanical check; keep that outcome open, rather than pretending a command exists.
93
+
94
+ ## Level 3 — optional details consulted only when needed
95
+
96
+ - [Capture evidence and producer/artifact details](../details/e0002-capture-evidence.md)
97
+ - [Report writing / `-o` transformation / return-code contract](../details/e0002-report-writer.md)
98
+ - [Existing E-0002 Error Ledger](../../../.agents/harness-everything/errors/E-0002-report-missing-terminal-status.md): existing class/history, not duplicated here
99
+ - [ROUTE-001 delivery decision](../../adr/ROUTE-001-error-lesson-delivery.md): scoped delivery background, not proof of deployed writer
100
+
101
+ **Acceptance of this draft:** Level 1 alignment and Action guidance only. No end-to-end recurrence/cost conclusion until Error Handling, Script and Hook/Skill Delivery are actually integrated and exercised.
@@ -0,0 +1,84 @@
1
+ @startuml error-handling-overview
2
+ ' Issue #437 / #402: discussion-only view of one Error Occurrence.
3
+ ' ASSESS / RESPOND correspond to Views 1 and 2.
4
+ ' Decide disposition is expanded by View 3, not a hyperlink.
5
+ ' Recurrence is a NEW occurrence entering at Capture, never a G feedback loop.
6
+ title Error Handling — one occurrence (UML Activity draft)
7
+
8
+ start
9
+ :New Error Occurrence;
10
+ partition "ASSESS" {
11
+ :Capture;
12
+ :Triage;
13
+ if (Already-approved tolerate class?) then (yes)
14
+ :Retry this operation (at most 3);
15
+ if (Recovered?) then (yes)
16
+ :Resume interrupted work;
17
+ else (no)
18
+ :Mark step UNVERIFIED;
19
+ :Report; continue independent work only;
20
+ endif
21
+ stop
22
+ else (no)
23
+ if (Real problem, according to reviewer?) then (yes)
24
+ :Identify;
25
+ if (Identification complete?) then (yes)
26
+ if (Blocking main path?) then (no)
27
+ :Record / defer treatment;
28
+ stop
29
+ endif
30
+ else (no / owner decision pending)
31
+ :Hold pending identification decision;
32
+ stop
33
+ endif
34
+ else (no / unclear)
35
+ if (Reviewer cannot tell?) then (yes)
36
+ :Request owner decision; hold item;
37
+ else (no)
38
+ :Dismiss with reason;
39
+ endif
40
+ stop
41
+ endif
42
+ endif
43
+ }
44
+
45
+ partition "RESPOND" {
46
+ :Decide disposition
47
+ <b>expanded in View 3</b>;
48
+ if (Mechanical prevention feasible within budget?) then (yes)
49
+ if (Same class still yields new instances in bounded review?) then (yes)
50
+ :Consider Avoid / Tolerate;
51
+ else (no)
52
+ :Converge;
53
+ endif
54
+ else (no)
55
+ :Consider Avoid / Tolerate;
56
+ endif
57
+ if (Avoid or Tolerate under consideration?) then (yes)
58
+ if (Can drop or restrict action?) then (yes)
59
+ :Avoid;
60
+ else (no)
61
+ if (Owner approves Tolerate?) then (yes)
62
+ :Tolerate;
63
+ else (no / pending)
64
+ :Keep unresolved; do not bypass required checks;
65
+ stop
66
+ endif
67
+ endif
68
+ endif
69
+ :Treat (define acceptance first);
70
+ :Deliver relevant context;
71
+ :Accept and retire;
72
+ if (Converge / Avoid: acceptance met?) then (yes)
73
+ :Accept; retire unneeded lesson;
74
+ else (no)
75
+ if (Tolerate: cap and escalation recorded?) then (yes)
76
+ :Keep tolerate class active;
77
+ else (no)
78
+ :Keep open; report outstanding evidence;
79
+ endif
80
+ endif
81
+ }
82
+
83
+ stop
84
+ @enduml
@@ -0,0 +1,93 @@
1
+ # C1 — Level 3 conformance-test design (one authority per named split decision)
2
+
3
+ > **Proposed design / Level 3 supporting contract, NOT promoted to a test, NOT an implemented mechanism.** Companion to the [C1 Level 2 authority/consumer inventory](../actions/c1-action-map.md) and [Level 1](../README.md) in [#437](https://github.com/dyphn1/Harness-everything/issues/437) / [#402](https://github.com/dyphn1/Harness-everything/issues/402). This specifies **what a conformance test must check once a target is pinned**; it does not change production code, hooks, report rules or ledger state. Docs-only write-set. [source-traced: C1.md:L6-7; advisor-answer-4.md:L7,L21; class-common.md:L3]
4
+
5
+ **Claim convention:** every factual statement below is **source-traced** and tagged `[source-traced: <file>:<line>]`, using the same source keys as the [Level 2 map](../actions/c1-action-map.md). No claim here comes from an executed conformance run in this batch.
6
+
7
+ ## Problem to prevent
8
+
9
+ A split decision — the same decision answered independently at several sites — survives point fixes: each review closes one site and the next review finds another deciding differently. [source-traced: E-0001:L143,L147; E-0007:L108-110] The treatment is to name **one authority**, inventory **every consumer** (including unchanged ones), then gate promotion to a test on three named items. [source-traced: C1.md:L4; advisor-answer-4.md:L7]
10
+
11
+ **Promotion gate (verbatim authority):** promote to a test **only after** naming (1) a shipped authority, (2) every relevant consumer and (3) a current divergence witness. [source-traced: advisor-answer-4.md:L7] In this batch no in-scope product target is pinned — E-0001's stage-option work stays #445 and C1 owns docs only — so none of the three worked examples below is promoted; an unpinned mechanism stays a follow-up. [source-traced: C1.md:L4; advisor-answer-4.md:L7,L21; E-0001:L89-91,L162]
12
+
13
+ ## Level 3 · conformance design (supporting the Level 2 block)
14
+
15
+ ```mermaid
16
+ flowchart TD
17
+ IN["Authority + complete consumer list<br/>+ divergence witness (from Level 2)"] --> GATE{"All three named<br/>and a target pinned?"}
18
+ GATE -->|No| FOL["Follow-up only; no test promoted;<br/>no shipped authority claimed"]
19
+ GATE -->|Yes| NORMAL["Feed normal input to every consumer<br/>including unchanged consumers"]
20
+ NORMAL --> STALE["Feed the stale-input witness<br/>to the same consumers"]
21
+ STALE --> CMP["Compare each consumer's decision<br/>with the one authority"]
22
+ CMP --> AGREE{"Every consumer agrees with authority<br/>on normal AND stale input?"}
23
+ AGREE -->|No| RED["Divergence found: fail the conformance test<br/>and keep the decision open"]
24
+ AGREE -->|Yes| SECOND{"Any consumer making the same decision<br/>via a second authority?"}
25
+ SECOND -->|Yes| RED
26
+ SECOND -->|No| GREEN["Conformance test passes for this decision"]
27
+ ```
28
+
29
+ **Reading rule:** the test's unit is the *decision across all consumers*, not one site. A consumer that is untouched by the fix but still derives the decision on its own is a valid failure. [source-traced: E-0001:L147,L164-166; E-0007:L114,L116]
30
+
31
+ ## Normal vs stale-input outcome comparison (including unchanged consumers)
32
+
33
+ The gate requires comparing **normal** and **stale-input** outcomes **including unchanged consumers**. [source-traced: C1.md:L9; advisor-answer-4.md:L30] Rows below are designed expectations traced to the worked episodes; none is executed in this batch.
34
+
35
+ ### Example A — trusted doc-check identity
36
+
37
+ | Consumer | Normal input outcome | Stale-input outcome | Evidence |
38
+ | --- | --- | --- | --- |
39
+ | doc-check identity resolver (authority) | one decision via invariant I1 | same decision; stale candidate is rejected by the resolver | [source-traced: E-0001:L39,L45] |
40
+ | `doc-reconciliation-pilot.js` / `doc-reconciliation-provider.js` | agree with I1 | must not fall back to a parser/filter-local identity | [source-traced: E-0001:L7-L8,L143] |
41
+ | `ci/mechanism-397-cycle-import.test.js` (**unchanged consumer**) | agrees with I1 | must still agree though owned by another packet; its omission produced a P2 | [source-traced: E-0001:L18,L100-108,L164-166] |
42
+
43
+ Stale witnesses that must diverge from the authority: a self-authored checker printing passing JSON, and a case-variant invocation dropped from capture while the parser and candidate filter decided differently. [source-traced: E-0001:L33,L37]
44
+
45
+ ### Example B — stage-option / version-manifest identity
46
+
47
+ | Consumer | Normal input outcome | Stale-input outcome | Evidence |
48
+ | --- | --- | --- | --- |
49
+ | trained catalog + `manifest.js` (authority) | serves the one stage-option set | same source; no local re-derivation | [source-traced: E-0001:L85-87,L151; E-0007:L97-101] |
50
+ | `package.js` / `install.js` / `provider.js` | read the one source | installer must not reject a producer change (the F4 failure) | [source-traced: E-0001:L79,L151] |
51
+ | `score.py` (**unchanged consumer**) | reads the one source | must not cache a different option set | [source-traced: E-0001:L12,L151] |
52
+ | `system-one-curves.js` | reads the one source | the site F6 missed and R1 found — primary stale divergence witness | [source-traced: E-0001:L83,L151; E-0007:L93-95] |
53
+
54
+ Stale witnesses that must be caught: producer changed while installer expected the old identity (F4); three sites unified while one kept deciding on its own (F6/R1); P2-1 served text differing from trained text. [source-traced: E-0001:L79,L83,L89-91; E-0007:L116]
55
+
56
+ ### Example C — pinned target acceptance
57
+
58
+ | Consumer | Normal input outcome | Stale-input outcome | Evidence |
59
+ | --- | --- | --- | --- |
60
+ | exact-spelling recognizer `22dc944a` (authority) | accepts only the exact pinned spelling | rejects symlink and `./`/`..` aliases | [source-traced: E-0007:L73] |
61
+ | capture / all writer surfaces | agree with the recognizer | must not credit the aliases that survived round 1 | [source-traced: E-0007:L67,L71] |
62
+ | `agentResultSurface()` callers (**unchanged consumers**) | all callers use the shared helper | a caller patched outside the inventory is the third-seam failure | [source-traced: E-0007:L80-88] |
63
+
64
+ ## Proposed conformance test cases (design only)
65
+
66
+ | Test case | Expected observable result | Evidence / status |
67
+ | --- | --- | --- |
68
+ | Normal input, complete consumer list | every consumer's decision equals the authority's | design goal [source-traced: E-0001:L45,L147] |
69
+ | Stale-input witness, unchanged consumers included | every consumer still equals the authority; no local re-derivation | design goal [source-traced: E-0001:L164-166; E-0007:L114] |
70
+ | Second-authority probe | fail if any consumer makes the same decision via a different source | [source-traced: advisor-answer-4.md:L30; E-0007:L116] |
71
+ | Known divergence witness (e.g. `system-one-curves.js`, `./`/`..` alias) | test goes RED on the witness; passes only when the class is fixed at the source | [source-traced: E-0001:L83,L151; E-0007:L71] |
72
+ | Omitted-consumer probe (file owned by another packet / outside the write-set) | consumer is present in the inventory regardless of ownership | [source-traced: E-0001:L100-108,L164-166] |
73
+ | No pinned target / no current witness | no test promoted; result recorded as follow-up | [source-traced: advisor-answer-4.md:L7,L30] |
74
+
75
+ **What is measured after promotion (future, not this batch):** whether every consumer agrees with the authority on normal and stale inputs, whether a second authority is absent, and whether a known divergence witness turns the test RED. A green run proves only this decision's conformance, not substantive correctness of the product path. [source-traced: E-0001:L45; E-0007:L116]
76
+
77
+ ## Review blockers (independent review of this design)
78
+
79
+ | Blocker | Rule | Evidence |
80
+ | --- | --- | --- |
81
+ | Omitted consumer | every site making the decision is listed, including unchanged consumers and files owned by other packets | [source-traced: E-0001:L147,L164-166; E-0007:L114] |
82
+ | Multiple authorities | exactly one authority for the named decision; no second source decides the same thing | [source-traced: advisor-answer-4.md:L30; E-0001:L151; E-0007:L116] |
83
+ | Incorrect authority claim | only a pinned, shipped authority may be claimed; no product authority is claimed in this batch | [source-traced: advisor-answer-4.md:L7,L30; E-0001:L162] |
84
+ | Missing known consumer | a named consumer from the worked episodes cannot be absent from the inventory | [source-traced: E-0001:L7-L18; E-0007:L7-L12] |
85
+ | Unpinned mechanism | stays a follow-up, not a promoted test | [source-traced: advisor-answer-4.md:L30] |
86
+
87
+ ## E-ids applied and scope
88
+
89
+ - **E-0001** (identity split decision): applied its lesson to inventory every deciding site including unchanged consumers, to trace each to one source of truth, and to keep the #445 stage-option class out of this batch. [source-traced: E-0001:L147,L151,L162]
90
+ - **E-0007** (guard fix by instance): applied its lesson to fix the predicate class rather than one spelling and to require a pre/post caller inventory of any shared helper. [source-traced: E-0007:L108-110,L114,L116]
91
+ - Out-of-slice follow-ups (listed, not fixed): the #445 class fix and its owner go, a concrete in-scope product target with a current divergence witness, and promotion of any design case into an executable conformance test. [source-traced: E-0001:L89-91,L162; advisor-answer-4.md:L7,L21]
92
+
93
+ **Status of this design:** three named worked authorities, complete consumer inventories and divergence witnesses are source-traced here; no test is promoted because no in-scope target is pinned. [source-traced: advisor-answer-4.md:L7,L30; class-common.md:L3]
@@ -0,0 +1,35 @@
1
+ # C2 — Level 3 test-root containment contract
2
+
3
+ ## Decision
4
+
5
+ The cycle-import test's `isOutside(root, candidate, pathApi)` computes `relative = pathApi.relative(root, candidate)`. A candidate is outside when the relative result is absolute, is exactly `..`, or starts with `..` followed by that path API's separator. This recognizes parent escapes without mistaking an in-root name such as `..cache` for a parent segment.
6
+
7
+ On Windows, paths on different drives make `path.win32.relative` return an absolute path. A prefix-only `relative.startsWith('..')` check therefore accepts the cross-drive path as inside. A string-prefix check on the candidate also accepts a sibling such as `D:\repo-other` as inside `D:\repo`.
8
+
9
+ ## Deterministic boundary matrix
10
+
11
+ The test uses a GitHub runner-style root; the table abbreviates it to `D:\repo`.
12
+
13
+ | Root | Candidate | Expected `isOutside` | Boundary exercised |
14
+ | --- | --- | --- | --- |
15
+ | `D:\repo` | `D:\repo\ci` | `false` | Ordinary root child stays inside. |
16
+ | `D:\repo` | `D:\repo\..cache` | `false` | A child name beginning with two dots is not a parent segment. |
17
+ | `D:\repo` | `D:\repo-other` | `true` | Similar-prefix sibling stays outside; `candidate.startsWith(root)` is insufficient. |
18
+ | `D:\repo` | `D:\` | `true` | Parent escape stays outside. |
19
+ | `D:\repo` | `C:\Users\runner\AppData\Local\Temp\fixture` | `true` | Cross-drive result is absolute; the old prefix-only check misses it. |
20
+
21
+ These Windows cases use `path.win32`, so their semantics are exercised on non-Windows hosts too. The cycle-import fixture continues to check its real temporary directory with the host's default `path` API.
22
+
23
+ ## Verification
24
+
25
+ ```sh
26
+ node --test ci/mechanism-397-cycle-import.test.js
27
+ ```
28
+
29
+ A passing local test is deterministic mechanism evidence. The test does not establish a hosted Windows run; the repository's Windows CI lane provides that host evidence.
30
+
31
+ ## Provenance
32
+
33
+ - [E-0019: Windows cross-drive relative paths](../../../.agents/harness-everything/errors/E-0019-windows-cross-drive-relative-path.md)
34
+ - [C2 action map](../actions/c2-action-map.md)
35
+ - [Cycle-import mechanism test](../../../ci/mechanism-397-cycle-import.test.js)
@@ -0,0 +1,50 @@
1
+ # C3 Treat — Level 3 mode-ownership contract
2
+
3
+ > C3’s Level 3 detail for #449. Each routing test file owns the System One mode passed to every child process it spawns.
4
+
5
+ ## Failure shape
6
+
7
+ `HARNESS_SYSTEM_ONE_MODE=live` inherited from a developer shell reached three direct `kernel-router.js` children in `ci/router-workflow-plan.test.js`: `kernelUnknown`, `kernelIterative`, and `initialRetainedRoute`. They bypassed `runTier`, so the live classifier reference block could change deterministic routing assertions. E-0018 records the inherited-live failure class.
8
+
9
+ ## Fixture contract
10
+
11
+ Both files wrap Node’s `spawnSync` at file scope. The wrapper merges the parent environment and any per-child environment, then sets `HARNESS_SYSTEM_ONE_MODE` to `off`. A child opts into live mode only through the wrapper’s separate `systemOneMode: 'live'` option. Adding another `spawnSync` call in either file therefore inherits the same deterministic default.
12
+
13
+ ```mermaid
14
+ flowchart LR
15
+ CALL["Any spawnSync call"] --> ENV["File-level environment wrapper"]
16
+ ENV --> DEFAULT["HARNESS_SYSTEM_ONE_MODE=off"]
17
+ ENV -->|"explicit systemOneMode: live"| LIVE["HARNESS_SYSTEM_ONE_MODE=live"]
18
+ ```
19
+
20
+ ## Child-process inventory
21
+
22
+ Each row names a `spawnSync` source site. `execFileSync` is not used in either file.
23
+
24
+ | File / child | Environment supplied at the call site | Effective System One mode |
25
+ | --- | --- | --- |
26
+ | `ci/router-workflow-plan.test.js` — `runTier` | Parent env, optional `options.env`, and `HARNESS_ROUTER_CONTRACT_PATH` | `off`, except the explicit-live control passes `systemOneMode: 'live'` |
27
+ | `ci/router-workflow-plan.test.js` — `kernelUnknown` | No child env supplied; inherits parent env | `off` |
28
+ | `ci/router-workflow-plan.test.js` — `kernelNotificationPersistFailure` | Parent env plus `HARNESS_STATE_HOME` and `HARNESS_WORKSPACE_ROOT` | `off` |
29
+ | `ci/router-workflow-plan.test.js` — `kernelIterative` | No child env supplied; inherits parent env | `off` |
30
+ | `ci/router-workflow-plan.test.js` — `initialRetainedRoute` | `retainedEnv` (parent env plus `HARNESS_STATE_HOME` and `HARNESS_WORKSPACE_ROOT`; regression captures it while parent mode is `live`) | `off` |
31
+ | `ci/router-workflow-plan.test.js` — `sessionPathResult` | `retainedEnv` plus `TEST_SESSION_ID` | `off` |
32
+ | `ci/router-workflow-plan.test.js` — `planCommand` | `retainedEnv` | `off` |
33
+ | `ci/router-workflow-plan.test.js` — `startCommand` | `retainedEnv` | `off` |
34
+ | `ci/router-workflow-plan.test.js` — `reviewCommand` | `retainedEnv` | `off` |
35
+ | `ci/router-workflow-plan.test.js` — `hostNotification` | `retainedEnv` | `off` |
36
+ | `ci/invariant-routing.test.js` — `runKernel` | Parent env | `off`, except the explicit-live control passes `systemOneMode: 'live'` |
37
+
38
+ The invariant-routing file has one `spawnSync` source site, inside `runKernel`; the router-workflow file has ten, including the `runTier` helper. Every child uses the same file-level wrapper.
39
+
40
+ ## Regression and controls
41
+
42
+ | Input | Expected result |
43
+ | --- | --- |
44
+ | Parent mode is `live`; call `runTier` or default `runKernel` | No `SYSTEM ONE REFERENCE CONFIDENCE` block |
45
+ | Parent mode is `live`; spawn `kernelUnknown`, `kernelIterative`, or `initialRetainedRoute` | No `SYSTEM ONE REFERENCE CONFIDENCE` block |
46
+ | Explicit `systemOneMode: 'live'` control | The child emits the confidence block |
47
+ | `env HARNESS_SYSTEM_ONE_MODE=live npm run test:routing:invariants` | All routing assertions pass, including inherited-live checks |
48
+ | `env -u HARNESS_SYSTEM_ONE_MODE npm run test:routing:invariants` | The same assertions pass without ambient mode |
49
+
50
+ The block check is exercised against a live-mode child before the wrapper fix. A positive explicit-live control ensures the test still reaches live behavior when requested. Package/mechanism evidence is not a live-host result.
@@ -0,0 +1,40 @@
1
+ # C5 Treat — Level 3 host replay contract
2
+
3
+ > **Level 3 supporting contract for C5** (companion to [actions/c5-action-map.md](../actions/c5-action-map.md) and [Level 1](../README.md) in [#402](https://github.com/dyphn1/Harness-everything/issues/402)). Specifies what the agent should do next time and documents the evidence boundary. This document changes no production code, hooks, tests or ledger state. Per the packet gate: "With evidence missing, document the exact unavailable field or artifact."
4
+
5
+ ## Problem to prevent
6
+
7
+ **E-0006** (`live-kit-host-protocol-mismatch`): live-run kits repeatedly mismatched the real host and provider protocol. The #397 episode (2026-11-15) found three host-shape findings — router runtime under Bun, the V2 turn-end event, and the V2 message shape — and its lesson (memory) is: "record one live trace of the real shapes before a fix packet (#397: `session.execution.succeeded`, id at `data.sessionID`, `type`/`content[]`)." That trace was never retained in the packet sources, so the episode stays open (`closed: false`).
8
+
9
+ ## Retained payloads in the repo today
10
+
11
+ Searched the three packet-named locations: `benchmarks/results/live-host/`, `ci/*opencode*`, `opencode-plugin/`.
12
+
13
+ | Retained artifact | Provenance | Host / version / date | V2 host payload present? | Missing artifact |
14
+ | --- | --- | --- | --- | --- |
15
+ | `benchmarks/results/live-host/opencode-2026-09-16/` (`probe-control.md`, `run-commands.md`; under `state/sessions/ses_f5520f1d9ffeB8KLTIUKgA5ng8/`: `circuit-breaker.json`, `edit-state.json`, `compliance.json`, `zoom-out-report.md`) | Retained live-host evidence for the OpenCode enforcement plugin (README: limited mechanism/live-host evidence, post-reset snapshot, no raw transcript) | opencode 1.18.31 / macOS / 2026-09-16 / plugin rev `dc3ea80` (0.5.2) | **No.** V1-era `session.idle`-based evidence; no `session.execution.succeeded`, no `data.sessionID`, no V2 `type`/`content[]` messages. | The E-0006 V2 host payload (`session.execution.succeeded`, id at `data.sessionID`, `type`/`content[]`). |
16
+ | `benchmarks/results/live-host/opencode-2026-11-15-workspace/` (`live-workspace-trace-2026-11-15.jsonl`, `live-workspace-probe.js`, `README.md`) | Workspace-field attribution probe (`setup`/`prompt` events: `sessionID`, `messageID`, `prompt`, `metadata`, `delivery`; `ctx.session.get({sessionID})`) | OpenCode 2.1.4 / macOS / 2026-11-15 | **No.** Same date as #397, but it traces workspace fields, not the V2 turn-end/message shapes. Its README: "It is not a live reproduction of the workspace attribution defect or verification of the fix." | The E-0006 V2 host payload; expected translation; fixture owner. |
17
+ | `ci/mechanism-397-opencode-observations.test.js` (consumer test suite) | #397 mechanism test (fix/397-opencode-router-node); E-0006 O3 input `f7addfc0` resolves the session id from `data.sessionID` | OpenCode V2 consumer | **Partially — synthetic only.** Builds V2 fixtures inline via `v2Event(type, sessionID, data)` = `{id, created, type, durable: true, data: {sessionID, ...data}}` and pushes `session.execution.succeeded` as turn end. These are self-authored deterministic fixtures, not a retained live payload, with no pinned expected-translation fixture and no named fixture owner. | Retained live payload; pinned expected translation; fixture owner. |
18
+ | `opencode-plugin/index.mjs` (V2 default export `setup(ctx)`) | #397 consumer fix: OpenCode 2.x flat events with session id at `data.sessionID`; turn end on `session.idle` or `session.execution.succeeded`; event loop at `raw.sessionID` / `raw.data.sessionID` | OpenCode V2 host contract | **Source only, no payload.** The boundary itself, not evidence of it. | Retained live payload; expected translation; fixture owner. |
19
+
20
+ ## Exact consumer test that would host a replay
21
+
22
+ `ci/mechanism-397-opencode-observations.test.js` — the existing OpenCode V2 observation suite. Its `v2Event` helper and `session.execution.succeeded` pushes are the deterministic replay shape: flat `{id, created, type, durable, data}` events with the session id at `data.sessionID`. A replay would feed a retained real payload through this suite's assertions (e.g., the V2 completion and context-message tests around `session.execution.succeeded` / `type`/`content[]`).
23
+
24
+ ## Exact missing field or artifact (gate: evidence missing)
25
+
26
+ All three C5 replay prerequisites are unavailable in this repo snapshot:
27
+
28
+ 1. **Retained E-0006 host payload:** no retained live trace contains a real V2 `session.execution.succeeded` event with the id at `data.sessionID` and V2 context messages using `type`/`content[]`. E-0006 episode 2 (2026-11-15, #397): "That trace is not a closing review and the packet sources do not re-record it, so the episode stays closed false."
29
+ 2. **Expected translation:** no pinned fixture maps a retained V2 payload to the consumer's expected record/assertion fields.
30
+ 3. **Fixture owner:** no named owner for a replay fixture; the consumer test exists but no replay harness is wired to it.
31
+
32
+ Review probe areas named by the packet: version/event shape differences (opencode 1.18.31 `session.idle` vs OpenCode 2.1.4 `session.execution.succeeded`), stale session binding (a `data.sessionID` bound to a stale/dropped session), and fake evidence (a synthetic fixture passed off as a retained live trace — a fixture pass proves mechanism behavior only).
33
+
34
+ ## Replay contract (preconditions before dispatch)
35
+
36
+ 1. A retained payload file under `benchmarks/results/live-host/` (provenance: host, version, date, source revision) containing real V2 events including `session.execution.succeeded` with the id at `data.sessionID`.
37
+ 2. A pinned expected translation: assertions mapping those payload fields to the consumer's record format, owned by a named fixture owner (the consumer test's maintainer).
38
+ 3. Dispatch: run `ci/mechanism-397-opencode-observations.test.js` against the payload. A deliberately mistranslated event or session ID fails; the correct path passes. A fixture pass proves mechanism behavior only.
39
+
40
+ Until 1–3 exist, this Level 2 map and this contract are the shipped treatment; nothing in `opencode-plugin/`, `ci/`, hooks or the ledger is changed by this slice.
@@ -0,0 +1,65 @@
1
+ # C6 packet briefing — Level 3 field contract, walkthroughs and review cases
2
+
3
+ > Supporting contract for [C6 — Level 2 Action Map](../actions/c6-action-map.md) and the [C6 briefing template](../templates/packet-briefing.md) ([#402](https://github.com/dyphn1/Harness-everything/issues/402), advisor answer 4 class C6). Concrete inputs, outputs, gates and test cases only; it changes no runtime behavior.
4
+
5
+ ## Problem to prevent
6
+
7
+ - **E-0022** (`wrong-episode-rule-briefed`): a coordinator briefing gives a worker an episode/round rule that differs from the errors README, or shared briefing text drifts (stale input SHA, wrong report path; #448 W3 followed the shared common-gates file). Each packet's own input SHA is authoritative over the shared file.
8
+ - **E-0010** (`runtime-provenance-packet-local-reference`): a pin cited only inside a working packet cannot be followed by installed or public consumers; pins cite a durable public reference instead.
9
+
10
+ ## Template field contract
11
+
12
+ | Field | Source requirement | Value rule |
13
+ | --- | --- | --- |
14
+ | Runner / model / effort | Packet's own execution context | Filled with the runner's own values |
15
+ | Worktree + input SHA | The packet's own worktree at its pinned input SHA | Filled; the shared common-gates SHA is never authoritative |
16
+ | Scope anchor | Verbatim quote with source (issue/PR/comment/owner decision) | Copied verbatim, never paraphrased |
17
+ | Write-set | Paths this packet may touch | Enumerated; "Nothing else" |
18
+ | Gate (dependsOn) | The invocation this gate binds, verbatim | The exact command the worker runs |
19
+ | Verification commands | Commands with expected exit codes | Runnable in this worktree |
20
+ | Error-ledger instruction | Read errors README and every E-*.md first | Name applied E-ids in the report |
21
+ | Report path + report-writer invocation | `write --body-file … --output … --status DONE\|BLOCKED --reason …`, then `check --file …` | The packet's own report path, never another packet's |
22
+ | Terminal STATUS rule | Last line column-zero `STATUS: DONE` / `STATUS: BLOCKED: <reason>`, nothing after | Enforced by report-writer `check` |
23
+ | Real dispatch cite | Added by the coordinator on the next dispatch | `N/A: real dispatch cite added by the coordinator on the next dispatch` until retained |
24
+
25
+ ## Walkthrough: one stale shared default through the template
26
+
27
+ **Starting state:** class-common.md pins this slice at input SHA `e1a8f1ca` (branch `feat/402-eh-map`). The shared common-gates background carries a stale SHA (`fbdbf98b`, the W1 writer packet) and a stale report path (`.402-work/W1-report.md`).
28
+
29
+ **Input:** a packet draft that copies the shared file's SHA and report path into its own fields.
30
+
31
+ **Expected:** the packet's own fields win; the stale shared-gates SHA and inherited W1 output path are rejected; ambiguous instruction blocked.
32
+
33
+ **Actual (template applied):** input SHA field = `e1a8f1ca` (packet's own), report path = `.402-work/C6-report.md` (packet's own), gate invocation = this packet's gate commands. The conflicting common-gates SHA and the output path inherited from W1 do not reach the worker.
34
+
35
+ **Review rule applied:** a conflicting common-gates SHA or an output path inherited from a different packet blocks dispatch; a valid packet requiring invented values blocks dispatch.
36
+
37
+ ## Walkthrough: one complete packet through the template
38
+
39
+ **Packet:** this C6 packet (`.402-work/C6.md`), worktree `.worktrees/402-c6`, input SHA `e1a8f1ca`.
40
+
41
+ **Gate commands (local slice gates):** `npm run test:consistency`, `npm run test:references`, `npm run test:portability`, plus the walkthroughs above as the slice's focused activity.
42
+
43
+ **Report:** body `.402-work/C6-body.md`; `npm run report -- write --body-file .402-work/C6-body.md --output .402-work/C6-report.md --status DONE`; then `… check --file .402-work/C6-report.md`. Report-bearing packets require the #462 report writer. Pin a runnable `write` and `check` invocation and the packet-owned paths at dispatch. Use `npm run report` where installed, or name the available direct script and its base. If no writer is available, resolve a usable invocation before dispatch or record the report as unresolved at acceptance; never hand-write the terminal STATUS.
44
+
45
+ **Terminal STATUS:** report's last line is exactly one column-zero `STATUS: DONE` (or `STATUS: BLOCKED: <reason>`), nothing after it.
46
+
47
+ **Real dispatch cite:** pending — retained by the coordinator on the next dispatch (`N/A: real dispatch cite added by the coordinator on the next dispatch`).
48
+
49
+ ## Review cases (advisor gate, verbatim)
50
+
51
+ | Case | Input | Expected | Verdict rule |
52
+ | --- | --- | --- | --- |
53
+ | Conflicting common-gates SHA | Packet field filled from shared file instead of its own pinned SHA | Block dispatch | Blocks ambiguous instructions reaching dispatch |
54
+ | Output path inherited from another packet | `.402-work/W1-report.md` in a C6 packet | Block dispatch | Blocks a valid packet requiring invented values |
55
+ | Complete packet | All fields filled or `N/A: <reason>`, exact SHA/path/command | Gate passes | Packet briefing accepted |
56
+
57
+ ## Evidence applied
58
+
59
+ - E-0010: packet-local provenance references are not durable; cite public issue/PR/comment URLs or repository-relative paths.
60
+ - E-0022: the errors README "Episodes vs rounds" section is the authority; each packet's own input SHA is authoritative over the shared common-gates file; a gate clause binds the exact invocation and verb.
61
+ - Memory witness #448: W3 was misled by packet template drift (common-gates SHA, wrong report path).
62
+
63
+ ## Status of this detail
64
+
65
+ Structural contract only; no code, hooks, ledger schema, promotion or training-budget change. Effectiveness requires real dispatch evidence, which the coordinator retains on the next dispatch.
@@ -0,0 +1,54 @@
1
+ # C7 — Path-level packet write-set check
2
+
3
+ This detail implements the C7 action in [the action map](../actions/c7-action-map.md). It checks whether a candidate slice stayed inside a packet's approved path set, including generated files and uncommitted output.
4
+
5
+ The checker selects the target repository with `git rev-parse --show-toplevel` from its current working directory. Its own file may live in another checkout; reported paths are relative to the selected repository.
6
+
7
+ ## Command
8
+
9
+ ```sh
10
+ node scripts/check-packet-write-set.js --base BASE_SHA [--head HEAD_REV] --allow PATH_OR_GLOB... [--allow-file FILE]
11
+ ```
12
+
13
+ | Option | Contract |
14
+ | --- | --- |
15
+ | `--base` | Required pinned commit for the candidate comparison. |
16
+ | `--head` | Optional commit or ref; defaults to the selected repository's `HEAD`. |
17
+ | `--allow` | Repeatable repository-relative path or glob. |
18
+ | `--allow-file` | Optional newline-delimited path/glob list, relative to the invocation directory; empty lines are ignored and CRLF is accepted. |
19
+
20
+ At least one `--allow` or a non-empty `--allow-file` is required. Allow-file lines are patterns as written; `#` is not a comment marker. Use `/` between path segments on every platform.
21
+
22
+ Quote glob patterns in shell invocations so the shell passes them to the checker unchanged.
23
+
24
+ ## Paths examined
25
+
26
+ ```mermaid
27
+ flowchart LR
28
+ TREE["Base-to-head tree diff"] --> UNION["Deduplicate repository-relative paths"]
29
+ MODE{"--head omitted<br/>or resolves to HEAD?"} -->|yes| STAGED["Staged changes against HEAD"]
30
+ MODE -->|yes| UNSTAGED["Unstaged changes"]
31
+ MODE -->|yes| NEW["Non-ignored untracked paths"]
32
+ MODE -->|no| UNION
33
+ STAGED --> UNION
34
+ UNSTAGED --> UNION
35
+ NEW --> UNION
36
+ UNION --> MATCH["Match each path against every allow pattern"]
37
+ MATCH --> OUT["Print one JSON-quoted ALLOWED or OUT_OF_SET line per path"]
38
+ ```
39
+
40
+ When `--head` is omitted or resolves to the selected repository's current `HEAD`, the checker includes staged, unstaged and non-ignored untracked paths. When `--head` resolves to another commit, it compares only the base-to-head commits, excludes all working-tree changes, and prints `Comparison: commits only (--head is not the current HEAD).`
41
+
42
+ The tree comparisons use `git diff --no-renames`; a move therefore contributes both its old and new path. The staged check also disables rename detection. Ignored untracked files are excluded according to Git's ignore rules. Paths are deduplicated and sorted before output, and JSON quoting keeps spaces, tabs and newlines on one output line.
43
+
44
+ Patterns match the entire Git-style path (slash separators): `*` matches any characters except `/`, `?` matches one character except `/`, and `**` matches across path segments. `**/` also matches zero directory segments. For example, `docs/**` matches `docs/guide.md` but not `docs-extra/guide.md`.
45
+
46
+ ## Results and limits
47
+
48
+ | Exit | Meaning |
49
+ | --- | --- |
50
+ | `0` | Every observed path matched an allow pattern. |
51
+ | `1` | At least one `OUT_OF_SET` path needs disposition. |
52
+ | `2` | Usage, allow-file, revision or Git error; no scope result was established. |
53
+
54
+ The checker reads Git state with optional Git locks disabled; it does not stage, reset, clean, checkout or write repository files. A valid but incorrect base/head can still produce a misleading comparison, so the coordinator supplies the approved pinned revisions. Exit 0 says nothing about changes inside an allowed file: same-file content loss and omissions from an approved outline remain review obligations.