harness-everything 0.52.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 (71) 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 +38 -0
  5. package/benchmarks/results/live-host/opencode-2026-11-15-workspace/README.md +7 -0
  6. package/benchmarks/results/live-host/opencode-2026-11-15-workspace/live-workspace-probe.js +16 -0
  7. package/benchmarks/results/live-host/opencode-2026-11-15-workspace/live-workspace-trace-2026-11-15.jsonl +4 -0
  8. package/bin/cli.js +1 -0
  9. package/ci/invariant-routing.test.js +22 -3
  10. package/ci/mechanism-2al-codex-hooks-compat.test.js +56 -2
  11. package/ci/mechanism-2n-opencode-plugin.test.js +1 -1
  12. package/ci/mechanism-2p-opencode-v2-entrypoint.test.js +18 -3
  13. package/ci/mechanism-338-opencode-async.test.js +20 -3
  14. package/ci/mechanism-341-opencode-lane.test.js +7 -1
  15. package/ci/mechanism-349-ci-change-scope.test.js +78 -57
  16. package/ci/mechanism-397-cycle-import.test.js +414 -0
  17. package/ci/mechanism-397-host-acceptance.test.js +119 -0
  18. package/ci/mechanism-397-opencode-observations.test.js +1922 -0
  19. package/ci/mechanism-check-packet-write-set.test.js +232 -0
  20. package/ci/mechanism-codex-prompt-pass-through.test.js +8 -4
  21. package/ci/mechanism-error-handling-map.test.js +219 -0
  22. package/ci/mechanism-report-writer.test.js +335 -0
  23. package/ci/mechanism-system-one-curves.test.js +17 -0
  24. package/ci/mechanism-system-one-cycle.test.js +621 -2
  25. package/ci/router-workflow-plan.test.js +50 -7
  26. package/docs/architecture.md +4 -3
  27. package/docs/error-handling/README.md +250 -0
  28. package/docs/error-handling/actions/c1-action-map.md +89 -0
  29. package/docs/error-handling/actions/c2-action-map.md +22 -0
  30. package/docs/error-handling/actions/c3-action-map.md +26 -0
  31. package/docs/error-handling/actions/c5-action-map.md +31 -0
  32. package/docs/error-handling/actions/c6-action-map.md +37 -0
  33. package/docs/error-handling/actions/c7-action-map.md +18 -0
  34. package/docs/error-handling/actions/e0002-action-map.md +101 -0
  35. package/docs/error-handling/activity.puml +84 -0
  36. package/docs/error-handling/details/c1-authority-conformance.md +93 -0
  37. package/docs/error-handling/details/c2-test-root-containment.md +35 -0
  38. package/docs/error-handling/details/c3-mode-ownership.md +50 -0
  39. package/docs/error-handling/details/c5-host-replay-contract.md +40 -0
  40. package/docs/error-handling/details/c6-packet-briefing.md +65 -0
  41. package/docs/error-handling/details/c7-write-set-check.md +54 -0
  42. package/docs/error-handling/details/e0002-capture-evidence.md +93 -0
  43. package/docs/error-handling/details/e0002-report-writer.md +116 -0
  44. package/docs/error-handling/nodes.yaml +44 -0
  45. package/docs/error-handling/registry.md +59 -0
  46. package/docs/error-handling/templates/packet-briefing.md +45 -0
  47. package/docs/platform-capabilities.md +16 -7
  48. package/docs/system-one-cycle.md +12 -3
  49. package/docs/system-one-observations.md +35 -4
  50. package/hooks/scripts/codex-user-prompt.js +2 -3
  51. package/hooks/scripts/lib/observations.js +5 -3
  52. package/opencode-plugin/README.md +22 -8
  53. package/opencode-plugin/index.mjs +424 -44
  54. package/opencode-plugin/plugin.json +1 -1
  55. package/package.json +2 -1
  56. package/plugins/harness-everything/.codex-plugin/plugin.json +1 -1
  57. package/plugins/harness-everything/hooks/scripts/codex-user-prompt.js +2 -3
  58. package/plugins/harness-everything/hooks/scripts/lib/observations.js +5 -3
  59. package/plugins/harness-everything/plugin.json +1 -1
  60. package/sbom.cdx.json +7 -7
  61. package/scripts/check-packet-write-set.js +155 -0
  62. package/scripts/codex-hooks-compat.js +46 -5
  63. package/scripts/error-handling-map.js +288 -0
  64. package/scripts/report-writer.js +261 -0
  65. package/scripts/system-one-curves.js +154 -14
  66. package/scripts/system-one-cycle/collect.js +20 -3
  67. package/scripts/system-one-cycle/common.js +39 -1
  68. package/scripts/system-one-cycle/evaluate.js +8 -5
  69. package/scripts/system-one-cycle.js +7 -2
  70. package/scripts/system-one-observations-export.js +29 -0
  71. package/scripts/system-one-observations-import-store.js +128 -0
@@ -0,0 +1,93 @@
1
+ # E-0002 Capture — Level 3 evidence and provenance reference
2
+
3
+ > **Discussion-only / proposed; Level 3 reference.** Child of the [E-0002 Action Map](../actions/e0002-action-map.md) and [Level 1 overview](../README.md) for [#437](https://github.com/dyphn1/Harness-everything/issues/437) / [#402](https://github.com/dyphn1/Harness-everything/issues/402). No change to runtime, hooks, CLI, ledger schema, acceptance policy, or the Level 1 flow.
4
+ >
5
+ > **Action identity:** Capture is the existing A Action from [nodes.yaml](../nodes.yaml); A is a *diagram-local alias*, not a stable identifier. **E-0002 is a worked example, not the identity or mandatory type of this Action.**
6
+
7
+ **Level 3 scope:** This reference explains the evidence/provenance detail for the [E-0002 Level 2 Action Map](../actions/e0002-action-map.md). Capture alone does not solve the error; the actual prevention proposal and CLI contract are in [E · Treat — report writer](./e0002-report-writer.md).
8
+
9
+ ## Purpose and boundaries
10
+
11
+ Capture opens **one new Error Occurrence** and records *what was actually observed* with enough provenance for **B · Triage** to examine it. Capture may adapt its evidence-collection steps to the producer, artifact, or a known example such as E-0002. It **does not** decide whether the finding is real, approve a tolerate class, identify the canonical Error Class/signature, choose a disposition, repair an artifact, or declare a check passed.
12
+
13
+ A later recurrence starts a **new** Capture execution. Continuation of a pending occurrence is **not** a new one. The existing Error Ledger ([#359](https://github.com/dyphn1/Harness-everything/issues/359)) remains the system of record for class/episode association *after* Identify; this draft does not create a parallel ledger or allocate persistent IDs.
14
+
15
+ ## Level 3 · Capture evidence-detail diagram (supporting the Level 2 Action Map)
16
+
17
+ ```mermaid
18
+ flowchart TD
19
+ START((New Error Occurrence)) --> A0["Capture incoming observation<br/>producer / time if known / execution step / artifact reference"]
20
+ A0 --> SRC{"What is the observation source?"}
21
+
22
+ SRC -->|Agent report| AG["Retain report/command reference,<br/>reported failure and observable output"]
23
+ SRC -->|Reviewer finding| RV["Retain review finding,<br/>cited target and reviewer evidence"]
24
+ SRC -->|Later discovery| LT["Retain discovery context,<br/>original artifact and revision if available"]
25
+
26
+ AG --> C1["Gather available original evidence<br/>without editing the source"]
27
+ RV --> C1
28
+ LT --> C1
29
+ C1 --> AV{"Can original evidence be read?"}
30
+
31
+ AV -->|No| MISSING["Record missing/unavailable evidence<br/>and attempted source; do not assume PASS"]
32
+ AV -->|Yes| KIND{"Evidence relates to a report<br/>or final turn output?"}
33
+ KIND -->|No| GENERAL["Preserve relevant raw output and context"]
34
+ KIND -->|Yes| E2["E-0002-style evidence capture:<br/>report file vs final turn vs same artifact;<br/>raw terminal lines and material following STATUS"]
35
+ E2 --> E3["Retain the applicable rule reference,<br/>producer/host, -o usage if known,<br/>and any trailing harness-label observation"]
36
+ E3 --> REC["Describe observed facts only<br/>not an E-0002 classification"]
37
+ GENERAL --> REC
38
+ MISSING --> REC
39
+
40
+ REC --> OUT["Produce occurrence-local observation<br/>facts + evidence refs + unknowns"]
41
+ OUT --> B["Handoff to B · Triage"]
42
+ ```
43
+
44
+ **Reading rule:** The E-0002 box is a *conditional example of evidence capture*, not a branch that declares E-0002. Report-related evidence can enter via any of the three source types. Capture records an unreadable artifact as **unknown/unavailable**, never as a compliant report.
45
+
46
+ ## E-0002 · Artifact boundary (two outputs are not always the same)
47
+
48
+ The [existing E-0002 ledger record](../../../.agents/harness-everything/errors/E-0002-report-missing-terminal-status.md) describes a report protocol failure: a report must end with a plain column-zero `STATUS: DONE` or `STATUS: BLOCKED: <reason>` line. Some later observations involve a hidden harness-label *after* that line, especially in `codex exec -o` outputs. [ROUTE-001](../../adr/ROUTE-001-error-lesson-delivery.md) distinguishes report-file and turn-message obligations; its proposed report-turn exception is **not yet implemented**.
49
+
50
+ ```mermaid
51
+ flowchart TD
52
+ EXEC["Packet / review execution"] --> FILE["Report artifact<br/>file, e.g. -o output"]
53
+ EXEC --> TURN["Turn final message"]
54
+ FILE --> SAME{"Are they the same artifact?"}
55
+ TURN --> SAME
56
+ SAME -->|No| TWO["Capture two separate raw endings:<br/>report file terminal STATUS;<br/>turn message terminal harness-label"]
57
+ SAME -->|Yes| ONE["Capture the single shared ending<br/>and note the report-turn rule conflict<br/>or applicable exception as evidence"]
58
+ TWO --> OBS["Observed bytes / last non-empty line<br/>and rule provenance"]
59
+ ONE --> OBS
60
+ OBS --> TRIAGE["B · Triage examines the finding"]
61
+ ```
62
+
63
+ ### E-0002 evidence checklist (example, not a new schema)
64
+
65
+ | Field to observe | Why it matters |
66
+ | --- | --- |
67
+ | Observation source, producer, execution/PR/step and time **if known** | Keep actor and provenance; do not invent missing time |
68
+ | Report artifact location/revision and whether its full content was readable | Permit independent review of the original |
69
+ | Report file vs turn message vs shared artifact; host and `-o` use **if known** | Avoid comparing the wrong output against the wrong rule |
70
+ | Exact raw final lines, column-zero STATUS candidate, and any following line/label | Preserve whether a STATUS line was truly terminal; no normalization or silent repair |
71
+ | Applicable packet/report and harness-label rule reference **if known** | Make a possible rule conflict observable without deciding its validity |
72
+ | What is unavailable or ambiguous | Carry uncertainty into Triage instead of promoting it to PASS |
73
+
74
+ **No fields above imply a production schema, a new CLI verb or persistent storage.** An observation may be represented by existing review/task evidence until an owner-approved mechanism exists.
75
+
76
+ ## Worked observation cases
77
+
78
+ | Input case | Capture result (facts only) | What Capture must **not** infer |
79
+ | --- | --- | --- |
80
+ | Agent report ends with ordinary prose after `STATUS: DONE` | Preserve report tail, report path and producer | Do not auto-classify as E-0002 or edit the file |
81
+ | Reviewer finds `STATUS: DONE` followed by a harness-label in a `-o` file | Capture both raw lines, file/turn identity, review source and relevant rule references | Do not decide whether the reviewer is right or mark verification PASS |
82
+ | Report file ends at STATUS; a **separate** final turn ends with harness-label | Capture each artifact and its distinct ending | Do not assume a violation merely because the turn has a label |
83
+ | Report is also the final turn | Capture one artifact and the applicable/conflicting rule references | Do not assert that the proposed exception was shipped |
84
+ | Report content cannot be read | Record evidence as unavailable and cite the attempted source | Do not fabricate a valid terminal STATUS |
85
+ | A similar failure is discovered in a later PR | Start a new occurrence with its own evidence | Do not jump from G to D or reuse an occurrence implicitly |
86
+
87
+ ## Handoff and discussion acceptance
88
+
89
+ **Output:** one occurrence-local observation of what happened, with source/provenance, accessible raw evidence, unavailable evidence, and the active execution context needed by **B · Triage**. The source facts are not a verdict. **Next:** B decides approved-tolerate handling and whether a finding is real; **C · Identify** later maps the observation to an existing class/signature or proposes a new class.
90
+
91
+ A useful first-level review asks: (1) can a reviewer distinguish *report file* from *turn message*? (2) can the finding be independently checked without modifying evidence? (3) does a later recurrence start at Capture? (4) are missing facts left explicit? (5) can B make a decision without Capture pre-classifying E-0002?
92
+
93
+ **Out of scope for this draft:** code changes; E-0002 repair; automatic status inspection or enforcement; new CLI/state transitions; defining all specialized Capture paths; editing the historical blind-evaluation stimuli.
@@ -0,0 +1,116 @@
1
+ # E-0002 Treat — Level 3 report-writer contract and test cases
2
+
3
+ > **Proposed design / Level 3 supporting contract, NOT an implemented CLI.** Companion to the [E-0002 Level 2 Action Map](../actions/e0002-action-map.md) and [Level 1](../README.md) in [#437](https://github.com/dyphn1/Harness-everything/issues/437) and the Error Handling subtree [#402](https://github.com/dyphn1/Harness-everything/issues/402). This specifies **what the agent should do next time** and **which mechanical operation should prevent a repeat**. The proposed commands below do not exist yet; this document does not change production hooks, report rules or ledger state.
4
+
5
+ ## Problem to prevent
6
+
7
+ **E-0002** (`report-protocol`) recurs when a report lacks its required **raw, column-zero, terminal** `STATUS: DONE` or `STATUS: BLOCKED: <reason>` line, or when a harness-label appears after it. Some failures happen in `codex exec -o` outputs where the report is also the final turn text. Previous instructions and reminders were not enough: the next agent can make the same mistake again.
8
+
9
+ **Treatment direction (proposal):** stop using free-form report editing for the terminal protocol. The **agent supplies report content and an evidence-grounded status**, while one **scoped CLI/script writes and verifies the final report file**. Preserve free-form content authoring; restrict only the structured output operation. Do not add a global document governor, second Error Ledger, automatic report generation for unrelated tasks, or a count-driven lock.
10
+
11
+ **Action ownership:** A Capture records facts; B Triage and C Identify establish the case; D Decide chooses treatment. **E Treat defines/applies the mechanical report-writing method**; F Deliver gives the agent a concise instruction and the available CLI; G Accept checks its result. This is an **E-0002-specific Action detail**, not a second Level 1 flow or a claim that all classes have the same treatment.
12
+
13
+ ## Level 3 · Script-mediated operation (supporting the Level 2 block)
14
+
15
+ ```mermaid
16
+ flowchart TD
17
+ INPUT["D · Decide: valid selected disposition"] --> NEED{"Report-writing operation required?"}
18
+ NEED -->|No| OTHER["Perform only the selected applicable operation<br/>no automatic report requirement"]
19
+ NEED -->|Yes| AUTHOR["Agent supplies true task outcome and report body<br/>DONE / BLOCKED with reason"]
20
+ AUTHOR --> SOURCE{"Source of content?"}
21
+ SOURCE -->|"Ordinary body file"| STAGE["Provide body file to script"]
22
+ SOURCE -->|"codex exec -o"| RAW["Host -o writes raw output to staging input<br/>never finalized as the report directly"]
23
+ RAW --> EXTRACT["Script applies specified host-aware<br/>extraction/validation of raw output"]
24
+ EXTRACT --> STAGE
25
+ STAGE --> WRITE["Script writes terminal STATUS atomically<br/>then reads and checks finished artifact"]
26
+ WRITE --> RC{"Exit code 0?"}
27
+ RC -->|No| ERR["Return code + unmet condition;<br/>agent corrects inside Treat or records unresolved"]
28
+ ERR -->|"correctable"| AUTHOR
29
+ ERR -->|"not satisfied"| F
30
+ RC -->|Yes| F["F · Deliver actual result / usable guidance"]
31
+ OTHER --> F
32
+ F --> G["G · Accept against applicable contract<br/>and separate task evidence"]
33
+ ```
34
+
35
+ The E-0002 report script is **proposed, not deployed**. The Agent determines outcome; a mechanical script owns report assembly, validation and useful errors. The response block may choose a fitting operation without creating a new Level 1 branch. A failed script result does **not** bypass F/G or count as a successful report; unresolved evidence is delivered and the occurrence remains open.
36
+
37
+ ## Agent-facing procedure — proposed operational contract
38
+
39
+ For a step **explicitly required to produce a report**:
40
+
41
+ 1. **Perform the work and collect evidence.** The agent must decide the true task/packet status based on observed results. `DONE` is not inferred by the CLI from a successful invocation; `BLOCKED` requires an actual reason. A completed RED experiment is not automatically product GREEN.
42
+ 2. **Prepare only the free-form body** in a staging file. Do not add a terminal STATUS line or a harness-label to that body. If the host's `-o` captures the turn's final text, treat it as **script input / raw staging output**, not the finished report.
43
+ 3. **Call the report writer** with the body path, final output path, and explicit status; the writer adds exactly one terminal STATUS line and writes the complete report atomically.
44
+ 4. **Check the written file**, not merely the CLI stdout, and retain the result as evidence. Do not append to the finalized report; to revise, change the body and call the writer again.
45
+ 5. **Return the report reference and verified result** to the caller. A separate final turn keeps its own applicable host label contract. For any shared raw `-o` output, the **script** must apply an explicit host-aware extraction contract before writing the final report; return nonzero with raw evidence if it cannot do so. Do not silently strip arbitrary metadata or declare a contract exception deployed.
46
+
47
+ ### Proposed command interface — design examples, NOT currently executable
48
+
49
+ ```bash
50
+ # Positive result: content is provided by the agent; STATUS is written by the tool
51
+ harness report write --body-file work/report-body.md --output reports/review.md --status DONE
52
+ harness report check --file reports/review.md
53
+
54
+ # Blocked result: same writer; explicit failure reason is required
55
+ harness report write --body-file work/report-body.md --output reports/review.md --status BLOCKED --reason "required verification unavailable"
56
+ harness report check --file reports/review.md
57
+ ```
58
+
59
+ These are **candidate CLI verbs**, not a mandate to create a global `harness` binary. A small repository-local Node.js script with equivalent `write` / `check` operations is sufficient for the first vertical slice. The agent-facing instruction should reference the **actual installed command and version**, not copy these placeholders as if working already.
60
+
61
+ ### Minimal writer and checker contract
62
+
63
+ | Responsibility | Expected behavior |
64
+ | --- | --- |
65
+ | `write` input | Existing body file, designated report output path, explicit `DONE` / `BLOCKED`, mandatory non-empty reason for `BLOCKED` |
66
+ | `write` output | Preserve body content, add a single newline-separated terminal control line at **column zero**, write atomically, fail without corrupting the previous target |
67
+ | Structural validation | On the finished output, check exactly one terminal protocol line, nothing after it (including hidden label), and read-back matches what was written |
68
+ | Containing structured fields | Reject conflicting column-zero terminal STATUS lines and harness-label metadata in the submitted body; make the conflict explicit rather than silently discarding unknown content |
69
+ | Artifact roles | `codex exec -o` writes raw output as **script input**; the script converts and verifies the designated final report according to a host-aware contract. If ambiguous, return nonzero; no hidden manual rewrite |
70
+ | Failure outcome | Nonzero exit + actionable diagnostics; Agent may revise within Treat or deliver outstanding evidence via F/G; no automatic `DONE`, preserve prior target and raw source |
71
+ | Scope | Operate on explicitly designated report output only; do not rewrite unrelated files, judge semantic success, touch the Ledger, or automatically change permissions |
72
+ | Revision | Re-run `write` using the edited body + true status; never mutate the terminal report with ordinary append commands |
73
+
74
+ **Design constraint:** `-o` must be handled as script-mediated output. Parsing host metadata is a deterministic responsibility of the proposed script under a defined contract. If the script cannot distinguish required protocol from host-owned label safely, **return nonzero** with the original raw output and let the Agent handle that result; do not imply an unimplemented exception has shipped.
75
+
76
+ ## Interaction with other Actions and existing facilities
77
+
78
+ ```mermaid
79
+ flowchart LR
80
+ A["A–C · ASSESS<br/>observed/identified error"] --> D["D · Decide<br/>selected, validated disposition"]
81
+ D --> E["E · Treat<br/>agent uses script and return codes"]
82
+ E --> F["F · Deliver<br/>selected operation + result or failure"]
83
+ F --> G["G · Accept<br/>mechanical check + substantive evidence"]
84
+ F -. "reusable capability, not a flow edge" .-> HOOK["Later relevant Hook / Skill disclosure"]
85
+ ```
86
+
87
+ The future Hook/Skill reference is **not** a G feedback/recurrence edge, nor does F make future tasks part of this same Error Occurrence. A new recurrence starts as a **new Capture**; a correction after nonzero exit remains within the current local Action block when permitted.
88
+
89
+ - **#359:** existing E-0002 Ledger remains class/history authority; do not create a second database.
90
+ - **#394 / ROUTE-001:** Hook provides the **available command only when relevant**; it does not enforce task success or select the disposition. A retired lesson reminder does not remove still-needed operational instructions.
91
+ - **#437:** scoped CLI/script is a proposed deterministic validator, **not** a mandatory global document controller. Validation failures are returned for Agent handling, not converted to hidden branching rules.
92
+ - **Decide/Accept:** when a machine-checkable condition or approval is not met, the script returns nonzero with the unmet requirement. The Agent can revise appropriately or preserve unresolved status. Owner authorization cannot be fabricated by a script, and a zero script exit code never proves substantive task correctness.
93
+
94
+ ## Proposed acceptance before implementation
95
+
96
+ | Test case | Expected observable result |
97
+ | --- | --- |
98
+ | Valid body + DONE | Final file ends in exactly `STATUS: DONE`; CLI `check` passes |
99
+ | Valid body + BLOCKED + reason | Final file ends in `STATUS: BLOCKED: <reason>`; check passes |
100
+ | BLOCKED without reason | Write rejected; existing report left untouched |
101
+ | Body contains conflicting terminal STATUS or harness-label | Write rejected with useful explanation, no silent normalization |
102
+ | Agent revises body after earlier report | A new `write` replaces the report atomically; one terminal STATUS remains |
103
+ | `codex exec -o` emits trailing harness-label | Raw `-o` is routed **through the script** to produce/check the final report; script returns nonzero on unsafe/ambiguous transformation |
104
+ | Tool unavailable, bad path or read-back fails | Return nonzero with reason; Agent handles correction or delivers UNVERIFIED/unresolved result via F/G; raw evidence retained |
105
+ | Report not required | No invocation, no forced report |
106
+ | Writer produces compliant format but underlying result is wrong | Structural PASS only; review/behavior acceptance stays separate |
107
+
108
+ **What to measure:** E-0002 recurrence in later **real report-writing tasks**, whether the agent actually invoked the designated writer, structural violations after invocation, and elapsed/tool/review cost relative to hand-writing. Do not declare E-0002 rooted out merely because a diagram or a one-off check exists.
109
+
110
+ ## Owner discussion items
111
+
112
+ 1. Should the first implementation be a small Node.js `report write/check` script under the existing repository, rather than a new global CLI? **Recommended: yes.**
113
+ 2. For `codex exec -o`, route raw output to a **script**, and let the script generate/check the final report. No manual coordinator rewrite or output-contract exception is assumed.
114
+ 3. Define the **script's host-aware input/output and extraction contract** for shared `-o` artifacts; ambiguous input returns nonzero, not guessed normalization.
115
+
116
+ This design leaves A Capture focused on facts and E Treat on the executable operation: the next agent receives a repeatable action, **validated return codes**, and a way to handle a failed condition, not merely an explanation of the last mistake.
@@ -0,0 +1,44 @@
1
+ # Canonical Action identity source for the Error Handling map (#437 concept, #402 implementation).
2
+ # A-G are drawing-local aliases, NOT identity or ordered numbering.
3
+ # IDs use creation category/date/UUIDv4 and never change. Names can change independently.
4
+ # status: proposed | accepted | retired.
5
+ # links: Action-to-Action control flow of View 1 in README.md, where the path between the two
6
+ # Actions passes only through non-Action nodes (decisions, outcomes). Checked against the diagram.
7
+ schema: concept-v0
8
+ scope: error-handling
9
+ actions:
10
+ A:
11
+ identifier: ERR-20261112-a82f647f-c0b1-4c6c-b90b-fb2221fe66bd
12
+ name: Capture
13
+ status: proposed
14
+ B:
15
+ identifier: ERR-20261112-da72e7fa-a37c-48ab-81b9-a678673a7324
16
+ name: Triage
17
+ status: proposed
18
+ C:
19
+ identifier: ERR-20261112-ffbb1b17-edb3-4adb-92ff-df76ad8f101c
20
+ name: Identify
21
+ status: proposed
22
+ D:
23
+ identifier: ERR-20261112-cd6a0fd5-d354-4bcb-8d34-71fcc985e5e4
24
+ name: Decide disposition
25
+ status: proposed
26
+ E:
27
+ identifier: ERR-20261112-5349acf0-f23f-43dc-9a7b-c0ae49dbcfc9
28
+ name: Treat
29
+ status: proposed
30
+ F:
31
+ identifier: ERR-20261112-a1617b0f-e5a7-4d3d-8926-40cda9953b6a
32
+ name: Deliver relevant context
33
+ status: proposed
34
+ G:
35
+ identifier: ERR-20261112-5f7496e6-5e1a-4628-b818-5292dd011580
36
+ name: Accept and retire
37
+ status: proposed
38
+ links:
39
+ - { from: A, to: B }
40
+ - { from: B, to: C }
41
+ - { from: C, to: D }
42
+ - { from: D, to: E }
43
+ - { from: E, to: F }
44
+ - { from: F, to: G }
@@ -0,0 +1,59 @@
1
+ # Error Handling — lightweight layer registry (discussion prototype)
2
+
3
+ > **P2-2 decision for #437:** use a small registry that maps existing nodes, documents, and layer references **table to table**. This is a document lookup, not a workflow engine or a second graph. No runtime loader, CLI, enforcement, schema migration, or generated document pipeline is introduced here.
4
+ >
5
+ > **P2-1 intentionally unchanged:** whether agents confuse View and Level is **not an established defect**. The owner will validate it experimentally. Do not preemptively relabel or rewrite the previously tested Level 1 diagrams to address an unproven issue.
6
+
7
+ ## Identity source — reuse the existing Action table
8
+
9
+ The [Action identity registry](./nodes.yaml) is the only proposed source for the seven existing Action identities. Their UUIDs and names are **not copied into this file**, so edits to Action identity do not require changing two registries. A–G are drawing-local aliases, never global identifiers.
10
+
11
+ ## Table A — document registry (where to look)
12
+
13
+ | Local reference | Layer / role | Document | Purpose |
14
+ | --- | --- | --- | --- |
15
+ | `EH-overview` | Level 1 · process / three Views | [README.md](./README.md) | The canonical error-occurrence lifecycle, branches, guards and Action relationships |
16
+ | `EH-activity-source` | Level 1 · diagram representation | [activity.puml](./activity.puml) | UML activity representation of the **same** Level 1 route; not an independent controller |
17
+ | `E0002-actions` | Level 2 · context-specific behavior blocks | [actions/e0002-action-map.md](./actions/e0002-action-map.md) | E-0002 lens over ASSESS / RESPOND; what the Agent should do |
18
+ | `E0002-capture` | Level 3 · evidence reference | [details/e0002-capture-evidence.md](./details/e0002-capture-evidence.md) | Source and artifact preservation details, read only if relevant |
19
+ | `E0002-writer` | Level 3 · Script/CLI reference | [details/e0002-report-writer.md](./details/e0002-report-writer.md) | `-o` handling, input/output, return codes and mechanical checks; shipped as `scripts/report-writer.js` (`npm run report`, #462) |
20
+ | `E0002-ledger` | Existing external source · error history | [E-0002 ledger](../../.agents/harness-everything/errors/E-0002-report-missing-terminal-status.md) | Existing class/signature and history, **not** a new Level 3 state store |
21
+ | `C1-actions` | Level 2 · C1 split decision | [actions/c1-action-map.md](./actions/c1-action-map.md) | One authority per named decision; consumer inventory |
22
+ | `C1-detail` | Level 3 · C1 conformance design | [details/c1-authority-conformance.md](./details/c1-authority-conformance.md) | Conformance-test design; mechanism stays a follow-up until a target is pinned |
23
+ | `C2-actions` | Level 2 · C2 test oracle | [actions/c2-action-map.md](./actions/c2-action-map.md) | Test-root containment on Unix and Windows |
24
+ | `C2-detail` | Level 3 · C2 path predicate | [details/c2-test-root-containment.md](./details/c2-test-root-containment.md) | Predicate and matrix in `ci/mechanism-397-cycle-import.test.js` |
25
+ | `C3-actions` | Level 2 · C3 machine state | [actions/c3-action-map.md](./actions/c3-action-map.md) | Routing tests own their System One mode |
26
+ | `C3-detail` | Level 3 · C3 mode ownership | [details/c3-mode-ownership.md](./details/c3-mode-ownership.md) | Env builder in the routing fixtures (#449) |
27
+ | `C5-actions` | Level 2 · C5 host protocol | [actions/c5-action-map.md](./actions/c5-action-map.md) | Pin one host protocol at its real boundary |
28
+ | `C5-detail` | Level 3 · C5 replay contract | [details/c5-host-replay-contract.md](./details/c5-host-replay-contract.md) | Replay contract and the missing retained payload |
29
+ | `C6-actions` | Level 2 · C6 briefing | [actions/c6-action-map.md](./actions/c6-action-map.md) | A packet carries its own authoritative values |
30
+ | `C6-detail` | Level 3 · C6 briefing walkthrough | [details/c6-packet-briefing.md](./details/c6-packet-briefing.md) | Walkthroughs and the report-writer dependency |
31
+ | `C6-template` | Template · packet briefing | [templates/packet-briefing.md](./templates/packet-briefing.md) | Copy per packet; every field filled or `N/A: <reason>` |
32
+ | `C7-actions` | Level 2 · C7 write-set | [actions/c7-action-map.md](./actions/c7-action-map.md) | Did the slice stay inside its write-set |
33
+ | `C7-detail` | Level 3 · C7 checker | [details/c7-write-set-check.md](./details/c7-write-set-check.md) | `scripts/check-packet-write-set.js`, run by the coordinator before accepting a slice |
34
+
35
+ `Local reference` values are **table-local lookup keys only**, not new stable Action IDs, graph node identities, persistent state, or workflow instructions.
36
+
37
+ ## Table B — relationship registry (when to follow a reference)
38
+
39
+ | From | To | Relation / relevance | Expected reading behavior |
40
+ | --- | --- | --- | --- |
41
+ | `EH-overview` | `EH-activity-source` | Same Level 1 representation | Open when UML source/notation is needed; not a new Level |
42
+ | `EH-overview` | `E0002-actions` | Context-specific expansion: **E-0002** | Open when handling this Error Class/context, rather than loading all Action Maps |
43
+ | `E0002-actions` | `E0002-capture` | Detail supporting Capture / evidence | Read when raw evidence/provenance is required |
44
+ | `E0002-actions` | `E0002-writer` | Detail supporting Treat / Report CLI | Read when producing or validating a report through the proposed script |
45
+ | `E0002-actions` | `E0002-ledger` | Existing class evidence / history | Read for Identify/history relevance; do not copy or reclassify the ledger |
46
+
47
+ **Maintenance contract (lightweight):** when a document moves, update its **Table A path**; Table B continues to refer to the same local key. When a new Level 2 behavior block or Level 3 reference is added, add only the relevant row and reference. Removing an obsolete procedure removes its registry relationship without rewriting Level 1. **Do not re-encode Mermaid/PlantUML execution arrows as registry edges**: the source diagrams own flow semantics, while the tables own *navigation/lookup*.
48
+
49
+ ## P2-3 — no mandatory input/output contract for every Action
50
+
51
+ **Action / behavior block:** expresses the relevant behavior and keeps the Agent free to select appropriate means; no universal form of `input`, `output`, `precondition`, `postcondition` or handoff schema is imposed. Required lifecycle gates already belong to Level 1.
52
+
53
+ **Concrete technical boundary (Script, CLI, API, structured output):** document machine-checkable inputs/outputs, return code, errors, and any necessary validation in **the relevant Level 3 contract**. For E-0002, [Report Writer](./details/e0002-report-writer.md) already serves this purpose. A script can reject invalid data; it cannot fabricate approvals or declare the whole task done.
54
+
55
+ ## State of validation
56
+
57
+ - The owner will run **View vs Level comprehension tests**; P2-1 is **not** a presumed flaw or a reason to modify diagram text now.
58
+ - This registry is a **minimal design mapping** only. It has not been proven to improve Agent comprehension, navigation cost or runtime recurrence.
59
+ - Effectiveness and cost evaluation of Error Handling still requires complete Error Handling + Script + Hook/Skill integration, followed by real execution evidence.
@@ -0,0 +1,45 @@
1
+ # C6 packet briefing template (rev 1)
2
+
3
+ Copy this file per packet. **Every field is either filled with this packet's own authoritative value or `N/A: <reason>`.** Shared defaults (class-common.md, shared gates files) supply background only; they are never authoritative for this packet.
4
+
5
+ ## Runner / model / effort
6
+ runner: <e.g. one-shot `codex exec` (model, effort), `-s workspace-write`>
7
+ model: <model>
8
+ effort: <reasoning effort>
9
+
10
+ ## Worktree and input SHA
11
+ worktree: <cwd / path of this packet's own worktree>
12
+ input SHA: <pinned input SHA of this packet>
13
+ `N/A:` only if the packet performs no worktree-bound execution; state the reason.
14
+
15
+ ## Scope anchor (verbatim with source)
16
+ - Owner <id> (date): "<verbatim quote>" — source: <issue / PR / comment / owner decision>
17
+ - <additional source>: "<verbatim quote>" — source: <…>
18
+
19
+ ## Write-set
20
+ - <path> — <new / modify / read-only>
21
+ - …
22
+ Nothing else. Do not edit files outside the write-set.
23
+
24
+ ## Gate (dependsOn)
25
+ <verbatim gate clause or command this packet binds>
26
+ Depends on: <previous packets / steps, or none>
27
+
28
+ ## Verification commands
29
+ <commands to run, each with its expected exit code>
30
+
31
+ ## Error ledger
32
+ Read `.agents/harness-everything/errors/README.md` and every `E-*.md` before starting. Name the applied E-ids in the report.
33
+
34
+ ## Report path and report-writer invocation
35
+ 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.
36
+ Body in `.402-work/<ID>-body.md`, then:
37
+ `npm run report -- write --body-file .402-work/<ID>-body.md --output .402-work/<ID>-report.md --status DONE` (or `--status BLOCKED --reason "<why>"`), then:
38
+ `npm run report -- check --file .402-work/<ID>-report.md`.
39
+ Sections: files changed; RED/walkthrough evidence; GREEN; gates with exit codes; E-ids; open questions / follow-ups (out-of-slice → listed, not fixed).
40
+
41
+ ## Terminal STATUS rule
42
+ The report's last line is exactly one column-zero `STATUS: DONE` or `STATUS: BLOCKED: <reason>`; nothing after it.
43
+
44
+ ## Real dispatch cite
45
+ `N/A: real dispatch cite added by the coordinator on the next dispatch.` — retained by the coordinator when this packet is dispatched for real.
@@ -54,7 +54,7 @@ Source and packaged plugin self-evolve entrypoints use installation-relative can
54
54
  | Codex | `Supported` | `Mechanism verified` | `Partial`: user-hook compatibility capture is live-verified for `UserPromptSubmit` and `Stop` on one Windows Codex CLI host; native plugin hooks remain mechanism-verified | `.agents/skills/`, `AGENTS.md` | `~/.agents/skills/` | [Live evidence](../benchmarks/results/live-host/codex-2026-10-13/README.md) verifies two consecutive turns on Codex CLI 0.162.1; native plugin mounting, other lifecycle events, and other versions remain unverified. |
55
55
  | ChatGPT / OpenAI Plugin | `Unknown` for a repository-local standalone path | `Mechanism verified` | `Partial`: local Work/Codex hooks are separate from ordinary Chat | Managed workspace marketplace | Not established | The public Skills-only bundle is mechanically reproducible; import, approval, and live behavior remain `Unknown`. |
56
56
  | Claude Code | `Supported` | `Supported` | `Mechanism verified` for Harness configuration | `.claude/skills/` | `~/.claude/skills/` | Native Claude surfaces and the state-specific plugin sync command are mechanically checked; fresh-host execution is not preserved here. |
57
- | OpenCode | `Supported` | `Partial` live-host loading for the project-scope, `.js`-filename install path on OpenCode 1.18.31 (macOS); other install paths remain `Mechanism verified` | `Partial` live-host evidence for project-scope `.js` loading and edit/verification state; hard lock reported only, with no retained blocked-tool trace and a post-reset final snapshot | `.opencode/skills/`, `.agents/skills/`, `.opencode/plugins/` | `~/.config/opencode/skills/`, `~/.agents/skills/`, `~/.config/opencode/plugins/` | [Retained evidence](../benchmarks/results/live-host/opencode-2026-09-16/README.md): loading and state effects verified in one host session; final snapshot post-reset; hard lock only an interactive observation; reflection operator-seeded, then agent-rewritten; no raw transcript or behavioral-effectiveness claim. `.mjs` auto-discovery broken (issue #127); global scope, npm-package installation, and other host versions remain unverified; V2 default-export load verified live on OpenCode 2.1.3 (macOS, 2026-10-23, server-log evidence only). |
57
+ | OpenCode | `Supported` | `Partial` live-host loading for the project-scope, `.js`-filename install path on OpenCode 1.18.31 (macOS); router injection and observation capture are mechanism-tested on V2 | `Partial` live-host evidence for project-scope `.js` loading and edit/verification state; new prompt/context hooks have mechanism evidence only | `.opencode/skills/`, `.agents/skills/`, `.opencode/plugins/` | `~/.config/opencode/skills/`, `~/.agents/skills/`, `~/.config/opencode/plugins/` | [Retained evidence](../benchmarks/results/live-host/opencode-2026-09-16/README.md): loading and state effects verified in one host session; final snapshot post-reset; hard lock only an interactive observation, with no retained blocked-tool trace, and a post-reset final snapshot; reflection operator-seeded, then agent-rewritten; no raw transcript or behavioral-effectiveness claim. `.mjs` auto-discovery broken (issue #127); global scope, npm-package installation, and other host versions remain unverified; V2 default-export load verified live on OpenCode 2.1.3 (macOS, 2026-10-23, server-log evidence only). A separate [OpenCode 2.1.4/macOS session workspace trace](../benchmarks/results/live-host/opencode-2026-11-15-workspace/README.md) observed `ctx.session.get({sessionID})` returning `location.directory` for two sessions, both matching setup; it did not exercise a mismatch or fire the V2 hooks. Prompt/system injection and observation capture remain mechanism evidence only; no live-host behavior claim is made. |
58
58
  | GitHub Copilot agent surfaces | `Supported` | `Unknown` for a Harness-specific plugin install | `Unknown` | `.github/skills/`, `.agents/skills/`, repository instructions | `~/.copilot/skills/`, `~/.agents/skills/` | GitHub Agent Skills paths and installer behavior are checked; no live Copilot session or plugin install is preserved. |
59
59
  | Cursor | `Supported` | `Mechanism verified` for the portable package shape | `Unknown` for Harness | `.cursor/skills/`, `.agents/skills/` | `~/.cursor/skills/`, `~/.agents/skills/` | Official paths and package shape are checked; Cursor plugin loading and hooks remain unverified. |
60
60
  | Continue.dev | `Unknown` for standalone `SKILL.md` discovery | `Unknown` | `Unknown` | `.continue/rules/` is documented; `.continue/skills/` is only an installer candidate | `~/.continue/skills/` is only an installer candidate | The reviewed official docs establish rules, not an Agent Skills host contract. |
@@ -142,7 +142,9 @@ Updates retain at most two fingerprinted runtimes: the current runtime and the i
142
142
 
143
143
  Installs of a plugin source tracked by a linked Git worktree refuse before writing. For an ordinary checkout, only modified or untracked files inside the plugin source subtree cause refusal. The runtime is built from the subtree's Git-tracked files, so `.gitignore`-excluded files (for example `.DS_Store` or `__pycache__`) are neither copied nor fingerprinted and do not block installation. The operator can explicitly pass `--allow-unreleased-source`. Packaged copies whose plugin manifest is not tracked by an enclosing repository remain supported, including copies inside an unrelated dirty repository. The mechanism and self-regression runners give child processes temporary HOME/USERPROFILE and CODEX_HOME directories. Tests must pass temporary Codex homes or mock the hook installer; mocking host commands alone does not isolate filesystem writes.
144
144
 
145
- Ownership is deliberately strict: update/uninstall removes only exact entries recorded in the Harness compatibility manifest. If an installed Harness entry was edited after installation, the operation fails closed rather than overwriting or deleting that user-modified entry. Unrelated pre-existing and later-added user hooks are preserved.
145
+ By default, update and uninstall remove only exact entries recorded in the Harness compatibility manifest. If an installed Harness entry was edited after installation, restore it before retrying. These operations preserve other user hooks.
146
+
147
+ For #457, `harness codex-hooks status` lists candidate `legacyTierRouterHooks` in the Codex user hooks file, even before compatibility hooks are installed. After reviewing the list, run `harness codex-hooks install --remove-legacy-tier-router` to remove direct Node invocations of the npx-cached Harness `tier-router.js` from `UserPromptSubmit` and install or refresh the JSON adapter in the same operation. Other handlers in the same hook group are preserved. Ordinary installs and automatic plugin sync preserve these unmanaged entries. Review the resulting hook sources and trust in Codex with `/hooks`.
146
148
 
147
149
  The compatibility path registers hook commands in Codex user configuration and covers the missing plugin-mount route where user hooks dispatch. It does not repair a Codex carrier that fails to dispatch `PreToolUse` at all; those host-level execution-path limitations remain a live compatibility boundary.
148
150
 
@@ -169,16 +171,23 @@ The general installer merges shared files only through Harness-owned markers and
169
171
 
170
172
  The OpenCode adapter targets the V2 plugin contract: it default-exports
171
173
  `{ id: "harness.enforcement", setup(ctx) }` that registers
172
- `ctx.tool.hook("execute.before|after")` and `ctx.event.subscribe()` through the
173
- OpenCode 2 plugin context, and keeps the V1-shaped `HarnessEnforcement` factory
174
+ `ctx.session.hook("prompt|context")`, `ctx.tool.hook("execute.before|after")`,
175
+ and `ctx.event.subscribe()` through the OpenCode 2 plugin context, and keeps the V1-shaped `HarnessEnforcement` factory
174
176
  for OpenCode 1.x hosts. OpenCode 2 rejects named-export-only plugins with
175
177
  `Plugin must export a default definition with an id and an effect or setup
176
178
  function`; that failure (observed on OpenCode 2.1.3, macOS) and the recovery
177
179
  after the V2 entrypoint were verified live on one host, with retained evidence
178
180
  in the OpenCode server log only (loading succeeded after a plugin-file
179
- reload; no hook-fire artifact). The adapter itself has deterministic mechanism
181
+ reload; no hook-fire artifact). A separate OpenCode 2.1.4/macOS trace observed
182
+ that `ctx.session.get({sessionID})` returns `location.directory` for two
183
+ sessions whose directories matched setup; it establishes field availability,
184
+ not mismatch handling or V2 hook behavior ([trace notes](../benchmarks/results/live-host/opencode-2026-11-15-workspace/README.md)). The adapter itself has deterministic mechanism
180
185
  coverage (`ci/mechanism-2n-opencode-plugin.test.js`, V1 shapes;
181
- `ci/mechanism-2p-opencode-v2-entrypoint.test.js`, V2 shapes). Retained
186
+ `ci/mechanism-2p-opencode-v2-entrypoint.test.js`, V2 lifecycle shapes;
187
+ `ci/mechanism-397-opencode-observations.test.js`, router injection, turn capture,
188
+ malformed-label export counts and opt-out). The injection/capture path has
189
+ mechanism evidence only; no live-host hook-fire or mismatch-handling artifact
190
+ exists. Retained
182
191
  evidence supports project-scope `.js` loading and edit/verification state on
183
192
  OpenCode 1.18.31 (macOS): [live-host evidence](../benchmarks/results/live-host/opencode-2026-09-16/README.md). The
184
193
  retained snapshot predates #190 and remains historical evidence only. Current OpenCode removes the permanent post-reflection hard lock; only the third-failure reflection boundary pauses edits. Reflection was operator-seeded, then agent-rewritten, so do not promote this into a behavioral-effectiveness claim. `.mjs` auto-discovery is broken on this host version (issue #127). npm-package installation and behavioral V2-hook fire remain unverified.
@@ -193,7 +202,7 @@ remain unchanged.
193
202
 
194
203
  ## Official sources
195
204
 
196
- The matrix records the official documentation reviewed for each platform. Important source families include [OpenAI plugin packaging](https://developers.openai.com/plugins/build/plugins), [OpenAI public submission](https://developers.openai.com/plugins/deploy/submission), [Codex skills](https://learn.chatgpt.com/docs/build-skills), [Codex hooks](https://learn.chatgpt.com/docs/hooks), [Claude skills](https://code.claude.com/docs/en/skills), [OpenCode skills](https://opencode.ai/docs/skills), [GitHub Copilot Agent Skills](https://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-cloud-agent/add-skills), [Cursor skills](https://cursor.com/docs/skills), [Continue rules](https://docs.continue.dev/customize/rules), and [Hermes skills](https://hermes-agent.nousresearch.com/docs/user-guide/features/skills).
205
+ The matrix records the official documentation reviewed for each platform. Important source families include [OpenAI plugin packaging](https://developers.openai.com/plugins/build/plugins), [OpenAI public submission](https://developers.openai.com/plugins/deploy/submission), [Codex skills](https://learn.chatgpt.com/docs/build-skills), [Codex hooks](https://learn.chatgpt.com/docs/hooks), [Claude skills](https://code.claude.com/docs/en/skills), [OpenCode skills](https://opencode.ai/docs/skills), [OpenCode plugin hooks](https://opencode.ai/docs/build/plugins/server/), [OpenCode V1 plugin migration](https://opencode.ai/docs/build/plugins/migrate-v1/), [GitHub Copilot Agent Skills](https://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-cloud-agent/add-skills), [Cursor skills](https://cursor.com/docs/skills), [Continue rules](https://docs.continue.dev/customize/rules), and [Hermes skills](https://hermes-agent.nousresearch.com/docs/user-guide/features/skills).
197
206
 
198
207
  When a platform behavior changes, update this page, `docs/platform-compatibility.json`, and every affected current-state surface in the same change. `npm run test:docs:capabilities` and the compatibility mechanism suite enforce the repository-side contract; they do not replace manual live-host evidence.
199
208
  # Experimental System One routing
@@ -16,6 +16,7 @@ flowchart LR
16
16
  ## Before the monthly run
17
17
 
18
18
  - Use a fresh, private directory for this cycle, outside the Harness checkout. On POSIX hosts the scripts set directory permissions to `0700` and data files to `0600`; on Windows, use a user-private directory with a restrictive ACL.
19
+ - For cross-month comparisons, choose one absolute private history file outside the checkout and every cycle directory, then pass the same `--history` path to each month's `evaluate` or `all` command. If omitted, history remains at `<private-cycle-dir>/training/history.jsonl` for compatibility and is cycle-local.
19
20
  - Set `--since` to the last completed collection boundary. `collect` requires this date and accepts an optional `--sessions` path for a non-default Codex session directory.
20
21
  - Pick a version id containing letters, numbers, dots, underscores, or hyphens. Reuse the same data directory and version id to resume; use a new directory for the next month.
21
22
  - Replace the placeholders in the commands below with real paths, dates, and a version id.
@@ -29,7 +30,7 @@ flowchart LR
29
30
  | Judge | `node scripts/system-one-cycle.js judge --data-dir "<private-cycle-dir>"` | Self tier and text-only Luna tier disagreements → private `training/adjudication/input.jsonl` and `consensus.jsonl`. Two independent votes are collected from Luna and OpenCode using current text and candidate labels. | Two model calls per batch of up to 20 disagreements; low local memory. | Completed majority and no-majority rows are skipped. Failed batches have no consensus row and are retried. A split vote is dropped during build; it does not request human review. |
30
31
  | Build | `node scripts/system-one-cycle.js build --data-dir "<private-cycle-dir>"` | Observed text, Luna labels, consensus, behavior contradictions, and the existing frozen holdouts → consensus-adjusted tier/intent rows under `training/v1/`, raw Luna validity labels under `training/v1-validity/`, and a count-only report. | Usually seconds to minutes; memory grows with the dataset. | Safe to rerun; outputs are rebuilt from the current input files. Validation copies win over normalized train duplicates. |
31
32
  | Train | `node scripts/system-one-cycle.js train --data-dir "<private-cycle-dir>" --version <version-id>` | The validity task reads raw Luna labels from `training/v1-validity/`; tier and intent read the consensus-adjusted dataset in `training/v1/`. Outputs CUA-S1 checkpoints, catalog-keyed validation scores, a trainer report with the catalog IDs, calibration, and `resource-guard.json` under `training/runs/<version-id>/`. | CPU training with 4 threads by default and a 6144 MB RSS ceiling. Duration depends on row count and epochs. | Completed stages are reused. If interrupted inside a stage, that stage starts again; earlier completed stages are kept. |
32
- | Evaluate | `node scripts/system-one-cycle.js evaluate --data-dir "<private-cycle-dir>" --version <version-id>` | Candidate checkpoints, validation scores, and the existing frozen holdouts → score files, `curves.json`, and `trend.json` in a candidate version directory. The scorer follows the trainer catalog; curves uses the shared manifest validator and requires each score row's keys to match the stage options. It appends to the private history file. | CPU scoring at one thread plus the curve calculation; typically seconds to minutes after checkpoint loading. | If curves and trend were written before interruption, the next invocation reuses them instead of adding another history row. |
33
+ | Evaluate | `node scripts/system-one-cycle.js evaluate --data-dir "<private-cycle-dir>" --version <version-id> [--history "<absolute-private-history.jsonl>"]` | Candidate checkpoints, validation scores, and the existing frozen holdouts → score files, `curves.json`, and `trend.json` in a candidate version directory. The scorer follows the trainer catalog; curves uses the shared manifest validator and requires each score row's keys to match the stage options. It appends one immutable version row to the selected history file. | CPU scoring at one thread plus the curve calculation; typically seconds to minutes after checkpoint loading. | Cached curves and trend are reused. If the selected history lacks that version row, resume validates and appends the saved curves once without rescoring. Conflicting reuse fails. |
33
34
  | Package | `node scripts/system-one-cycle.js package --data-dir "<private-cycle-dir>" --version <version-id>` | Trained candidate and evaluation artifacts → `training/versions/<version-id>/manifest.json` with three stage entries, relative artifact paths, thresholds, and weight SHA-256 values. The trainer catalog is the source of truth: intent includes `unclassified`, and catalog IDs, score keys, manifest options, and threshold keys agree. A `null` calibration threshold becomes `1` and the stage lists that option under `referenceOnly`, so its score stays available while it is excluded from automatic decisions. | A local file copy and hashes; usually seconds. | Safe to rerun. Repackaging an older candidate that omitted only intent `unclassified` metadata restores it as reference-only without retraining. Evaluation references carry forward. |
34
35
  | Publish | `node scripts/system-one-cycle.js publish --data-dir "<private-cycle-dir>" --version <version-id>` | `training/versions/<version-id>/` → `models/cua-s1/<version-id>/` in the same private data directory. It prints the published path; it does not use Git. The installer reads this model directory. | A local file copy; usually seconds. | Published version ids are immutable. Use a new id for changed weights; an existing destination is not overwritten. |
35
36
 
@@ -45,10 +46,18 @@ shape discrepancy.
45
46
  Run the full cycle with one command:
46
47
 
47
48
  ```sh
48
- node scripts/system-one-cycle.js all --until publish --data-dir "<private-cycle-dir>" --since <YYYY-MM-DD> --version <version-id>
49
+ node scripts/system-one-cycle.js all --until publish --data-dir "<private-cycle-dir>" --since <YYYY-MM-DD> --version <version-id> --history "<absolute-private-history.jsonl>"
49
50
  ```
50
51
 
51
- `all` runs each step in order and stops at `--until`. Completed collection, label, and judge steps with their outputs are skipped. If a label or judge batch fails, `all` stops at that step without marking it complete; rerun the same command to resume. `build` can be rerun. Training resumes between completed stages; evaluation reuses complete curve artifacts; packaging can be repeated. Publish only after packaging, then use the private data directory as the install source described in the [System One routing guide](system-one-routing.md).
52
+ `all` runs each step in order and stops at `--until`; it passes `--history` through to evaluation. Completed collection, label, and judge steps with their outputs are skipped. If a label or judge batch fails, `all` stops at that step without marking it complete; rerun the same command to resume. `build` can be rerun. Training resumes between completed stages; evaluation reuses complete curve artifacts; packaging can be repeated. Publish only after packaging, then use the private data directory as the install source described in the [System One routing guide](system-one-routing.md).
53
+
54
+ ## Cross-cycle history and floor baseline
55
+
56
+ - History is append-only. Reusing a version id is allowed only when its saved curve content matches; duplicate or conflicting version rows fail without overwriting existing history.
57
+ - Cached resume is accepted only when the selected history reproduces its saved baseline, ordered predecessor comparisons, and verdict; incompatible history is rejected without changing history or saved artifacts.
58
+ - Each stage keeps the first compatible historical holdout row as its floor baseline. Later rows record the baseline version and compare against that same row, including after partial recovery.
59
+ - A supplied history path must resolve outside the repository and name a file. Malformed history fails visibly. On POSIX, newly created history directories and files use `0700` and `0600`; existing shared parent permissions are left alone. Windows ACLs remain the operator's responsibility.
60
+ - The two-consecutive-cycle detector uses the latest three evaluation rows as its active-trend proxy. It does not identify the version currently installed; active-version rollback semantics remain with #443.
52
61
 
53
62
  For a synthetic integration check that does not read local session data or invoke model engines, prepare the earlier stage artifacts and completion entries under `.s1-work/`, then run:
54
63
 
@@ -2,9 +2,10 @@
2
2
 
3
3
  Status: **accepted**, 2026-09-27. Owner decisions are recorded below.
4
4
  Implementation: `hooks/scripts/observation-hook.js`,
5
- `hooks/scripts/lib/observations.js`, `scripts/system-one-observations-export.js`, `scripts/system-one-observations-import-codex-sessions.js` and
5
+ `hooks/scripts/lib/observations.js`, `scripts/system-one-observations-export.js`, `scripts/system-one-observations-import-codex-sessions.js`,
6
+ `scripts/system-one-observations-import-store.js` and
6
7
  `scripts/system-one-observations-review.js`; tests in
7
- `ci/mechanism-34-observations.test.js`. Issue
8
+ `ci/mechanism-34-observations.test.js` and `ci/mechanism-397-cycle-import.test.js`. Issue
8
9
  [#233](https://github.com/dyphn1/Harness-everything/issues/233).
9
10
 
10
11
  ## Why
@@ -29,7 +30,7 @@ validity, intent, tier, workflow and skills.
29
30
  - Collection is **on by default**, with no environment variable needed to
30
31
  enable it. `HARNESS_OBSERVATIONS=off` turns it off; this opt-out exists
31
32
  because the plugin ships to other users.
32
- - Hosts: **Claude Code** and **Codex** first.
33
+ - Hosts: **Claude Code**, **Codex** and **OpenCode**.
33
34
  - This document is the specification; implementation follows
34
35
  docs → RED → GREEN.
35
36
 
@@ -173,6 +174,8 @@ warning sign. The review page samples the turns where they differ.
173
174
  cannot read Codex trust state.
174
175
  - The final message comes from the rollout's `task_complete` event.
175
176
  - Fresh live-host verification on Windows (Codex CLI 0.162.1, 2026-10-13) exercised the user-hook compatibility fallback: only the `UserPromptSubmit` and `Stop` observation hooks were individually reviewed/trusted. Two consecutive real turns produced `host: "codex"` records with distinct current `turn_id` values and their respective valid self-reports. The sanitized record excerpt and scope limits are preserved in [Codex live-host evidence](../benchmarks/results/live-host/codex-2026-10-13/README.md). This does not verify native plugin-bundled hooks, other lifecycle events, or tool behavior capture.
177
+ - **OpenCode 2.x:** the plugin's documented `prompt` hook captures the original user text and runs the canonical kernel router; its `context` hook adds that router output, including the exact label instruction, to primary model requests. OpenCode tool events and `session.idle` feed the shared observation library, which reads the current turn's final assistant text through the session context API. `HARNESS_OBSERVATIONS=off` disables capture while routing injection remains active. Deterministic mechanism tests cover injection, turn recording, malformed labels, and opt-out; there is no retained live-host artifact for these hooks yet.
178
+ - The OpenCode exporter reports malformed `label-invalid` and `label-unparseable` records by host in `malformedLabelsByHost`; missing labels remain a separate reason and count.
176
179
  - The final message must belong to the current turn. A transcript scan
177
180
  stops at the start of the current turn (Codex `task_started` or a user
178
181
  message; a Claude user prompt) and a Codex `task_complete` must carry the
@@ -195,15 +198,43 @@ The importer scans local Codex rollout files and pairs each completed turn with
195
198
 
196
199
  The importer accepts only valid label lines, applies the same email/home-path redaction, and appends idempotently to the private observations store. Backfill and live hook records deduplicate by `(host, writer.sessionId, writer.turnId)`. For older live records without a turn ID, an exact turn-and-text match is skipped; a partial match is counted as ambiguous and skipped to avoid silently duplicating training data. Duplicate and ambiguous legacy live matches are checked atomically under the store lock. A bounded lock timeout is reported as a persistence failure, not as a duplicate, and gives the importer a nonzero exit status; migration lock timeouts are reported the same way. Existing backfill behavior placeholders are migrated to `null`. Reports contain counts and generic error descriptions without printing session text. The cutoff defaults to the date the label contract was accepted. The importer never uploads or writes session content into the repository.
197
200
 
201
+ ## Cycle import boundary
202
+
203
+ The `collect` step writes only to its private cycle directory. It runs Codex
204
+ session backfill, then imports every in-window record from the live store at
205
+ `observations.storeRoot()` (overridable with `HARNESS_OBSERVATIONS_DIR`). The
206
+ store importer preserves unlabeled and malformed-label metadata, including
207
+ its reason code, and deduplicates through `appendRecordDetailed` by host,
208
+ session and turn. It copies text only while the source record's original
209
+ retention deadline permits it; missing or expired text stays unavailable.
210
+
211
+ ```mermaid
212
+ flowchart LR
213
+ OC[OpenCode and other live capture] --> LS[Private live observation store]
214
+ CS[Codex session backfill] --> CY[Private cycle observation store]
215
+ LS --> IM[Cycle store importer]
216
+ IM --> CY
217
+ CY --> EX[Prompt and label exports]
218
+ IM --> IR[Text-free import-report.json]
219
+ ```
220
+
221
+ `import-report.json` records each source's status and per-host persisted,
222
+ duplicate, ambiguous and failed import counts. It contains a stable label for
223
+ the live store rather than its path. Final label rows retain their `host` so
224
+ OpenCode and Codex examples remain attributable after collection.
225
+
198
226
  ## Export
199
227
 
200
228
  `scripts/system-one-observations-export.js` writes to the private data
201
229
  repository:
202
230
 
203
231
  - `prompts-observed.jsonl`: `{id, family, source: "observation", split, text}`
204
- - `labels-observed.jsonl`: `{id, validity, tier, tierSource, intents, workflow, skills, behaviorEvidence, contradictions, systemOne}`. `systemOne` is `{version, sha256, mode, decision}` or `null`; score maps stay in the private observation store.
232
+ - `labels-observed.jsonl`: `{id, validity, tier, tierSource, intents, workflow, skills, behaviorEvidence, contradictions, host, systemOne}`. `systemOne` is `{version, sha256, mode, decision}` or `null`; score maps stay in the private observation store.
205
233
  - `export-report.json`: `systemOne.versions[version]` counts exported rows for each version and reports tier agreement (`matches`, `comparisons`, `rate`) between the router decision and self-report. Comparisons include only rows where both tiers are known.
206
234
 
235
+ The text-free `export-report.json` includes `malformedLabelsByHost` for invalid
236
+ or unparseable self-reports, including those omitted by `--self-report-only`.
237
+
207
238
  `family` groups near-duplicate prompts. The split is by time: the newest 15%
208
239
  is validation. The existing holdouts stay frozen and separate. Observed data
209
240
  may later seed a new holdout, but only after owner review.
@@ -1,9 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  'use strict';
3
3
  // Codex UserPromptSubmit adapter (docs/system-one-observations.md#hosts).
4
- // Codex adds prompt-time context to the model only from JSON
5
- // hookSpecificOutput.additionalContext; the router's plain stdout never
6
- // reaches the model. This runs the kernel router and wraps its output.
4
+ // Wrap router output in JSON hookSpecificOutput.additionalContext. Codex
5
+ // treats stdout beginning with "[" (including routing banners) as JSON-like.
7
6
 
8
7
  const fs = require('fs');
9
8
  const path = require('path');