harness-everything 1.3.1 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/.github/workflows/release.yml +7 -1
- package/AGENTS.md +1 -1
- package/CHANGELOG.md +25 -0
- package/RELEASING.md +2 -0
- package/behavioral-evals/ledger-pairs/README.md +53 -0
- package/behavioral-evals/ledger-pairs/arm.js +359 -0
- package/behavioral-evals/ledger-pairs/fixture.js +138 -0
- package/behavioral-evals/ledger-pairs/preflight.js +96 -0
- package/behavioral-evals/ledger-pairs/score.js +155 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/README.md +108 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-1-baseline/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-1-baseline/arm-result.json +35 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-1-treatment/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-1-treatment/arm-result.json +35 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-2-baseline/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-2-baseline/arm-result.json +35 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-2-treatment/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-2-treatment/arm-result.json +35 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-3-baseline/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-3-baseline/arm-result.json +35 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-3-treatment/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-3-treatment/arm-result.json +35 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-4-baseline/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-4-baseline/arm-result.json +28 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-4-treatment/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/agy/pair-4-treatment/arm-result.json +35 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-1-baseline/arm-plan.json +13 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-1-baseline/arm-result.json +56 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-1-treatment/arm-plan.json +13 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-1-treatment/arm-result.json +56 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-2-baseline/arm-plan.json +13 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-2-baseline/arm-result.json +56 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-2-treatment/arm-plan.json +13 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-2-treatment/arm-result.json +56 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-3-baseline/arm-plan.json +13 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-3-baseline/arm-result.json +49 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-3-treatment/arm-plan.json +13 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-3-treatment/arm-result.json +49 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-4-baseline/arm-plan.json +13 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-4-baseline/arm-result.json +49 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-4-treatment/arm-plan.json +13 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/codex/pair-4-treatment/arm-result.json +56 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-1-baseline/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-1-baseline/arm-result.json +44 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-1-baseline/receipt.jsonl +17 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-1-treatment/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-1-treatment/arm-result.json +41 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-1-treatment/receipt.jsonl +58 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-2-baseline/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-2-baseline/arm-result.json +50 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-2-baseline/receipt.jsonl +101 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-2-treatment/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-2-treatment/arm-result.json +44 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-2-treatment/receipt.jsonl +29 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-3-baseline/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-3-baseline/arm-result.json +44 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-3-baseline/receipt.jsonl +23 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-3-treatment/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-3-treatment/arm-result.json +34 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-3-treatment/receipt.jsonl +24 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-4-baseline/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-4-baseline/arm-result.json +47 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-4-baseline/receipt.jsonl +69 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-4-treatment/arm-plan.json +14 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-4-treatment/arm-result.json +44 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/opencode/pair-4-treatment/receipt.jsonl +65 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/run-order.sh +18 -0
- package/benchmarks/results/live-host/ledger-pairs-2026-11-28/score.json +1032 -0
- package/benchmarks/results/live-host/opencode-2026-11-28-397-turn-export/README.md +50 -0
- package/benchmarks/results/live-host/opencode-2026-11-28-397-turn-export/collect-rerun.txt +3 -0
- package/benchmarks/results/live-host/opencode-2026-11-28-397-turn-export/export-report.json +22 -0
- package/benchmarks/results/live-host/opencode-2026-11-28-397-turn-export/host-version.txt +1 -0
- package/benchmarks/results/live-host/opencode-2026-11-28-397-turn-export/import-report-1.json +18 -0
- package/benchmarks/results/live-host/opencode-2026-11-28-397-turn-export/import-report-2.json +18 -0
- package/benchmarks/results/live-host/opencode-2026-11-28-397-turn-export/labels-observed-excerpt.jsonl +2 -0
- package/benchmarks/results/live-host/opencode-2026-11-28-397-turn-export/observations-index-excerpt.json +26 -0
- package/benchmarks/results/live-host/opencode-2026-11-28-397-turn-export/plugin-load-lines.txt +1 -0
- package/benchmarks/results/live-host/opencode-2026-11-28-450-steering-trace/README.md +46 -0
- package/benchmarks/results/live-host/opencode-2026-11-28-450-steering-trace/observations-index-excerpt.json +16 -0
- package/benchmarks/results/live-host/opencode-2026-11-28-450-steering-trace/plugin-load-lines.txt +2 -0
- package/benchmarks/results/live-host/opencode-2026-11-28-450-steering-trace/run-marks.txt +6 -0
- package/benchmarks/results/live-host/opencode-2026-11-28-450-steering-trace/steering-probe.js +16 -0
- package/benchmarks/results/live-host/opencode-2026-11-28-450-steering-trace/steering-trace.jsonl +167 -0
- package/ci/mechanism-332-fable-directive.test.js +180 -0
- package/ci/mechanism-552-ledger-pairs.test.js +159 -0
- package/ci/mechanism-system-one-colab.test.js +450 -0
- package/ci/router-workflow-plan.test.js +61 -21
- package/ci/system-one-train-test.py +26 -0
- package/docs/platform-capabilities.md +28 -11
- package/docs/platform-compatibility.json +5 -5
- package/docs/system-one-cycle.md +10 -0
- package/docs/system-one-training.md +3 -1
- package/harness-everything/SKILL.md +1 -1
- package/harness-everything/scripts/routing-keywords.json +0 -2
- package/harness-everything/scripts/tier-router.js +105 -11
- package/opencode-plugin/plugin.json +1 -1
- package/package.json +1 -1
- package/plugins/harness-everything/.antigravity-plugin/plugin.json +1 -1
- package/plugins/harness-everything/.codex-plugin/plugin.json +1 -1
- package/plugins/harness-everything/plugin.json +1 -1
- package/plugins/harness-everything/rules/AGENTS.md +1 -1
- package/plugins/harness-everything/skills/harness-everything/SKILL.md +1 -1
- package/plugins/harness-everything/skills/harness-everything/scripts/routing-keywords.json +0 -2
- package/plugins/harness-everything/skills/harness-everything/scripts/tier-router.js +105 -11
- package/sbom.cdx.json +7 -7
- package/scripts/system-one-colab.js +238 -0
- package/scripts/system-one-train.py +36 -9
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"name": "harness-everything",
|
|
11
11
|
"source": "./",
|
|
12
12
|
"description": "Harness OS: an orchestrated agent operating system — tier routing, circuit breaker guardrails, verification gates, WAL session memory, and self-evolving workspace rules.",
|
|
13
|
-
"version": "1.
|
|
13
|
+
"version": "1.4.0",
|
|
14
14
|
"author": {
|
|
15
15
|
"name": "Miya Daniel"
|
|
16
16
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "harness-everything",
|
|
3
3
|
"description": "Harness OS: an orchestrated agent operating system — tier routing, circuit breaker guardrails, verification gates, WAL session memory, and self-evolving workspace rules.",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.4.0",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Miya Daniel"
|
|
7
7
|
},
|
|
@@ -34,6 +34,10 @@ jobs:
|
|
|
34
34
|
uses: actions/checkout@v7
|
|
35
35
|
with:
|
|
36
36
|
fetch-depth: 0
|
|
37
|
+
# #381 a1: ruleset main-protected requires status checks and cannot list the
|
|
38
|
+
# github-actions app as a bypass actor on a personal repo; the release commit
|
|
39
|
+
# and tag are pushed with this write deploy key, which the ruleset bypasses.
|
|
40
|
+
ssh-key: ${{ secrets.RELEASE_DEPLOY_KEY }}
|
|
37
41
|
|
|
38
42
|
# Release tooling uses the repository's primary Node runtime.
|
|
39
43
|
- name: Setup Node.js
|
|
@@ -70,7 +74,9 @@ jobs:
|
|
|
70
74
|
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
71
75
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
72
76
|
NPM_CONFIG_PROVENANCE: "true"
|
|
73
|
-
|
|
77
|
+
# An SSH repository URL makes semantic-release push with the deploy key
|
|
78
|
+
# (its SSH auth check runs before any token fallback).
|
|
79
|
+
run: npx --no-install semantic-release --repository-url "git@github.com:${{ github.repository }}.git"
|
|
74
80
|
|
|
75
81
|
- name: Upload release SBOM artifact
|
|
76
82
|
if: ${{ hashFiles('sbom.cdx.json') != '' }}
|
package/AGENTS.md
CHANGED
|
@@ -55,7 +55,7 @@ flowchart LR
|
|
|
55
55
|
- New features, fixes, tests, and host compatibility work target V2 only. No V1 public entrypoint, V1-only event fallback, V1 hook registration, or compatibility mode may be added.
|
|
56
56
|
- Retain historical V1 artifacts, but never promote them to current V2 capability evidence.
|
|
57
57
|
- Reintroducing V1 support requires an explicit owner-approved support-contract change; it is not a routine compatibility fix.
|
|
58
|
-
- State the V2 API family as the supported boundary. Tested V2 versions are recorded separately (`2.1.3` server-log load-only; `2.1.4` limited session workspace trace;
|
|
58
|
+
- State the V2 API family as the supported boundary. Tested V2 versions are recorded separately (`2.1.3` server-log load-only; `2.1.4` limited session workspace trace; one isolated `2.1.4` macOS 26.6.2 [V2 lifecycle trace](benchmarks/results/live-host/opencode-2026-11-24-v2-lifecycle/README.md) establishing V2 default-export load, V2 tool hooks, V2 event envelope + `session.execution.succeeded`, and completion → verification → reminder delivery on a long-lived server — standalone `opencode run` exits before verification finishes; and two isolated `2.4.1` macOS 26.7.3 long-lived server runs: [turn → export trace](benchmarks/results/live-host/opencode-2026-11-28-397-turn-export/README.md) establishing observation recording + idempotent training export, with router/context injection indirectly observed (model emitted the injected label contract) rather than a full injection trace, and [steering trace](benchmarks/results/live-host/opencode-2026-11-28-450-steering-trace/README.md) establishing mid-turn live steering delivery shape as witness-only for #450; ledger lessons, session create/delete reset, cancellation, global scope, npm install, and other versions/OSes remain unverified); none establishes a validated minimum patch version or coverage of every V2 release.
|
|
59
59
|
|
|
60
60
|
**Historical / unsupported V1 evidence:** the retained [OpenCode evidence](benchmarks/results/live-host/opencode-2026-09-16/README.md) documents project-scope `.js` loading and edit/verification state on OpenCode 1.18.31 (macOS). It is preserved as historical/unsupported evidence only and does not establish current V2 capability:
|
|
61
61
|
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project are documented in this file.
|
|
4
4
|
|
|
5
|
+
## [1.4.0](https://github.com/dyphn1/Harness-everything/compare/v1.3.2...v1.4.0) (2026-11-29)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
* **system-one:** add colab launcher for the train stage ([e7e45fd](https://github.com/dyphn1/Harness-everything/commit/e7e45fd47447259b608eedb56be5fc411f9a1cbb)), closes [#563](https://github.com/dyphn1/Harness-everything/issues/563)
|
|
10
|
+
* **system-one:** add trainer device selection for gpu training ([a5bafd1](https://github.com/dyphn1/Harness-everything/commit/a5bafd1b5404dcd0510d81cc7b1d2f1efcb57244)), closes [#563](https://github.com/dyphn1/Harness-everything/issues/563)
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* **system-one:** lift colab exec silence limit for training stages ([573c451](https://github.com/dyphn1/Harness-everything/commit/573c4512c93ead714092bd0cc35205bb3118a035))
|
|
15
|
+
* **system-one:** publish colab stages atomically and bind remote status ([47f29df](https://github.com/dyphn1/Harness-everything/commit/47f29dfc7b4f58f0a9a07bc115c55e8589b3425f)), closes [#563](https://github.com/dyphn1/Harness-everything/issues/563)
|
|
16
|
+
* **system-one:** verify colab stage success from downloaded status ([8fd8baa](https://github.com/dyphn1/Harness-everything/commit/8fd8baa5d1d95c83bfba46588f20ce1d77050b39)), closes [#563](https://github.com/dyphn1/Harness-everything/issues/563)
|
|
17
|
+
|
|
18
|
+
## [1.3.2](https://github.com/dyphn1/Harness-everything/compare/v1.3.1...v1.3.2) (2026-11-28)
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* **router:** decide fable directives by clause position and scope prohibitions ([#332](https://github.com/dyphn1/Harness-everything/issues/332)) ([000dbb1](https://github.com/dyphn1/Harness-everything/commit/000dbb16c9d4bd74612ce00791bc76a7d3f1a7e3))
|
|
23
|
+
* **router:** separate politeness prefixes from fable directive verbs ([#332](https://github.com/dyphn1/Harness-everything/issues/332)) ([0e488da](https://github.com/dyphn1/Harness-everything/commit/0e488da18c705964ee6a969256c9d48cecb2ca9c))
|
|
24
|
+
* **router:** treat a fable mention or negation as no fable request ([#332](https://github.com/dyphn1/Harness-everything/issues/332)) ([3b8b371](https://github.com/dyphn1/Harness-everything/commit/3b8b3710c56040347dc36f3576e1e04e4a3760ca))
|
|
25
|
+
|
|
5
26
|
## [1.3.1](https://github.com/dyphn1/Harness-everything/compare/v1.3.0...v1.3.1) (2026-11-28)
|
|
6
27
|
|
|
7
28
|
## [1.3.0](https://github.com/dyphn1/Harness-everything/compare/v1.2.2...v1.3.0) (2026-11-26)
|
|
@@ -296,6 +317,10 @@ Claude-Session: https://claude.ai/code/session_01RPz4xUrN12wGoL19istZUE
|
|
|
296
317
|
|
|
297
318
|
## [Unreleased]
|
|
298
319
|
|
|
320
|
+
### System One training on Colab
|
|
321
|
+
|
|
322
|
+
* **system-one:** `scripts/system-one-train.py` accepts `--device cpu|cuda|auto` (default `cpu`, CPU outputs unchanged) and records `device` and `torch` in the checkpoint metadata and `train-report.json`. The new `scripts/system-one-colab.js` runs the cycle `train` stage on a Google Colab VM through `google-colab-cli`: it uploads only the built `training/v1*` files plus the public trainer and catalog fixtures under a sha256 manifest, accepts each stage only from a downloaded `remote-status.json` with per-file hashes, always stops the VM, and leaves a run dir that the unchanged local `evaluate` → `package` path accepts (#563).
|
|
323
|
+
|
|
299
324
|
### E1 pilot retirement
|
|
300
325
|
|
|
301
326
|
* **e1:** the E1 doc-reconciliation pilot is retired (#553). Its runtime modules and the W6 `inventory`/`seal` CLI (`hooks/scripts/w6-state-operations.js`) have been removed, and every `HARNESS_DOC_RECONCILIATION_PILOT` value is now ignored. Finish in-flight E1 work on the previous release, or end it and open a new session to redo review and verification. Recorded evidence stays in place; `doc-check` and document governance are unchanged.
|
package/RELEASING.md
CHANGED
|
@@ -44,6 +44,8 @@ A push to `main` runs the full reusable CI gate and then semantic-release. A man
|
|
|
44
44
|
|
|
45
45
|
The SBOM is generated from the release `package.json`/`package-lock.json` as CycloneDX 1.7, the current 1.x format, to satisfy consumers and regulatory baselines requiring CycloneDX 1.6 or later. It is intentionally not committed to Git. The release publishes `sbom.cdx.json` in the npm tarball and as a GitHub Release asset, while the workflow also retains it as an Actions artifact.
|
|
46
46
|
|
|
47
|
+
The release commit and tag are pushed over SSH with the `RELEASE_DEPLOY_KEY` write deploy key, because ruleset `main-protected` requires status checks on `main` and a personal repository cannot list the GitHub Actions app as a bypass actor; the deploy key is the ruleset's only always-bypass actor besides PR-merge bypass for admins (#381). `GITHUB_TOKEN` stays in use for GitHub API calls (releases, comments).
|
|
48
|
+
|
|
47
49
|
Release concurrency is serialized so two updates to `main` cannot publish competing versions.
|
|
48
50
|
|
|
49
51
|
## Version ownership
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# E-0003 paired carrier experiment
|
|
2
|
+
|
|
3
|
+
## Design
|
|
4
|
+
|
|
5
|
+
```mermaid
|
|
6
|
+
flowchart LR
|
|
7
|
+
F[Identical fixture files and hooks] --> P[Same E-0003 trigger]
|
|
8
|
+
P --> B[Baseline: strip exact carrier fragment]
|
|
9
|
+
P --> T[Treatment: pass carrier fragment]
|
|
10
|
+
B --> R[Receipt and next-decision evidence]
|
|
11
|
+
T --> R
|
|
12
|
+
R --> S[Score by runner; retain every assigned arm]
|
|
13
|
+
A[AGY prompt injection] --> S
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
- Four baseline/treatment pairs per runner (12 pairs, 24 arms). Score Codex/Luna, OpenCode and AGY separately; never pool runners. Verdicts are **descriptive, inconclusive**.
|
|
17
|
+
- Baseline and treatment have byte-identical fixture files, initial commit, Git hook and permissions. Both can discover E-0003 in the workspace. OpenCode and Codex baseline probes strip only the exact `Cue`/`Lesson` carrier fragment after the Harness carrier appends it; treatment passes it through. This estimates the exploratory incremental effect of the carrier when the lesson is self-discoverable. Receipt files contain keyed statuses only, never command text.
|
|
18
|
+
- AGY remains a separate `agy-injection` intervention: same fixture files, with packet context added only to treatment.
|
|
19
|
+
- Luna's scored action is `prepared-commit`: Codex makes the source change, runs the test, stages `src/sample.js`, and writes `.commit-msg.txt`. The driver then performs `git add -A`, unstages the message file, verifies only `src/sample.js` is staged, and invokes `git commit -F` through the fixture hook. Do not pool this with direct commits from other runners.
|
|
20
|
+
- Token usage is post-hoc measurement including input, output and reasoning tokens when reported (cached usage is retained). Arms over 200,000 tokens are invalid and remain in the assigned-arm denominator. Every arm has a 45-minute timeout.
|
|
21
|
+
- Scoring requires an explicit correlated receipt before the matching scored decision. `unknown` remains unknown. Same-attempt diagnostics are merged; retries represent distinct attempts. File reads of the error ledger and `git log`/`git show` touching it are retained as a per-arm covariate.
|
|
22
|
+
|
|
23
|
+
## Preflight and dry-run
|
|
24
|
+
|
|
25
|
+
Run the same no-model trigger against both fixture arms, then dry-run each runner. Keep the output directory outside the repository.
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
node behavioral-evals/ledger-pairs/preflight.js --no-model --out "$OUT/pf"
|
|
29
|
+
node behavioral-evals/ledger-pairs/arm.js --runner codex --arm baseline --pair 1 --dry-run --out "$OUT/dry"
|
|
30
|
+
node behavioral-evals/ledger-pairs/arm.js --runner opencode --arm baseline --pair 1 --dry-run --out "$OUT/dry"
|
|
31
|
+
node behavioral-evals/ledger-pairs/arm.js --runner agy --arm baseline --pair 1 --dry-run --out "$OUT/dry"
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
The preflight checks equal fixture bytes, matching E-0003 selection and commitlint accept/reject controls. It sends no model request and cannot establish live receipt. Review isolated live receipts before launching arms; OpenCode requires the isolated long-lived V2 server and actual next-request capture. Keep raw host captures private.
|
|
35
|
+
|
|
36
|
+
## Balanced live order
|
|
37
|
+
|
|
38
|
+
Record a seed and shuffle pair IDs `1..4` separately for each runner. Assign exactly two pairs baseline-first and two treatment-first, run each pair consecutively, and retain the resulting order. For each arm, use an isolated HOME/XDG/TMPDIR/CODEX_HOME. Supply the coordinator's auth directory to Codex/OpenCode; OpenCode also needs `OPENCODE_PASSWORD`.
|
|
39
|
+
|
|
40
|
+
```sh
|
|
41
|
+
node behavioral-evals/ledger-pairs/arm.js --runner codex --arm baseline --pair 1 --out "$OUT/live" --auth-dir "$AUTH_DIR"
|
|
42
|
+
node behavioral-evals/ledger-pairs/arm.js --runner codex --arm treatment --pair 1 --out "$OUT/live" --auth-dir "$AUTH_DIR"
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Run the same two commands for every assigned pair and runner in the recorded balanced order. Stop/mark an arm invalid if post-hoc usage exceeds 200,000 or elapsed time exceeds 45 minutes. Keep every assigned arm and its missing/contamination reasons.
|
|
46
|
+
|
|
47
|
+
## Scoring
|
|
48
|
+
|
|
49
|
+
```sh
|
|
50
|
+
node behavioral-evals/ledger-pairs/score.js "$OUT"/*/pair-*/arm-result.json
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Report assigned arms, valid pairs, missing/contamination reasons, commit action, first attempt, retries, correct diff/test, hook bypass, file reads, token usage, elapsed time and receipt state per runner. A no-model preflight or mechanism test is not live-host evidence.
|
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const fs = require('node:fs');
|
|
4
|
+
const os = require('node:os');
|
|
5
|
+
const path = require('node:path');
|
|
6
|
+
const { spawn, spawnSync } = require('node:child_process');
|
|
7
|
+
const net = require('node:net');
|
|
8
|
+
const { buildFixture, TASK_TEXT } = require('./fixture');
|
|
9
|
+
|
|
10
|
+
const REPO = path.resolve(__dirname, '../..');
|
|
11
|
+
const LEDGER_RECORD = '.agents/harness-everything/errors/E-0003-commitlint-subject.md';
|
|
12
|
+
const RUNNERS = ['codex', 'opencode', 'agy'];
|
|
13
|
+
const ARMS = ['baseline', 'treatment'];
|
|
14
|
+
const COMMIT_TASK_TEXT = `${TASK_TEXT.split('\n')[0]}\nRun the test and stage only src/sample.js. Write the commit subject you intend to use to .commit-msg.txt; do not run git commit. The driver will make the commit through the fixture hook.`;
|
|
15
|
+
|
|
16
|
+
function filterCarrierContext(text, fragment, strip) {
|
|
17
|
+
const matched = typeof text === 'string' && typeof fragment === 'string' && text.includes(fragment);
|
|
18
|
+
return { matched, stripped: Boolean(matched && strip), text: matched && strip ? text.replace(fragment, '') : text };
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function parseArgs(argv) {
|
|
22
|
+
const args = { dryRun: false, timeoutMs: 45 * 60 * 1000 };
|
|
23
|
+
for (let i = 0; i < argv.length; i += 1) {
|
|
24
|
+
const key = argv[i];
|
|
25
|
+
if (key === '--dry-run') args.dryRun = true;
|
|
26
|
+
else if (['--runner', '--arm', '--pair', '--out', '--auth-dir', '--timeout-ms'].includes(key)) args[key.slice(2).replace(/-([a-z])/g, (_, c) => c.toUpperCase())] = argv[++i];
|
|
27
|
+
else throw new Error(`unknown argument: ${key}`);
|
|
28
|
+
}
|
|
29
|
+
if (!RUNNERS.includes(args.runner)) throw new Error('--runner must be codex|opencode|agy');
|
|
30
|
+
if (!ARMS.includes(args.arm)) throw new Error('--arm must be baseline|treatment');
|
|
31
|
+
if (!Number.isInteger(Number(args.pair)) || Number(args.pair) < 1 || Number(args.pair) > 4) throw new Error('--pair must be 1..4');
|
|
32
|
+
if (!args.out) throw new Error('--out is required');
|
|
33
|
+
args.pair = Number(args.pair);
|
|
34
|
+
args.timeoutMs = Number(args.timeoutMs);
|
|
35
|
+
if (!Number.isFinite(args.timeoutMs) || args.timeoutMs < 1 || args.timeoutMs > 45 * 60 * 1000) throw new Error('--timeout-ms must be between 1 and 2700000 (the 45-minute arm cap)');
|
|
36
|
+
return args;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function isolatedEnvironment(root, authDir, runner) {
|
|
40
|
+
const home = path.join(root, 'home');
|
|
41
|
+
const xdg = path.join(root, 'xdg');
|
|
42
|
+
const tmp = path.join(root, 'tmp');
|
|
43
|
+
const codexHome = path.join(root, 'codex-home');
|
|
44
|
+
for (const dir of [home, xdg, tmp, codexHome]) fs.mkdirSync(dir, { recursive: true });
|
|
45
|
+
// Minimal env: never inherit the coordinator's CLAUDE*/CODEX*/HARNESS_* session variables.
|
|
46
|
+
const base = {};
|
|
47
|
+
for (const k of ['PATH', 'LANG', 'TERM', 'SHELL', 'OPENCODE_PASSWORD']) if (process.env[k]) base[k] = process.env[k];
|
|
48
|
+
base.PONYTAIL_DEFAULT_MODE = 'off';
|
|
49
|
+
// agy keeps its login under ~/.gemini; isolating HOME logs it out, so agy keeps the real HOME (recorded in arm-plan).
|
|
50
|
+
if (runner === 'agy') return { ...base, HOME: process.env.HOME, TMPDIR: tmp };
|
|
51
|
+
const env = { ...base, HOME: home, USERPROFILE: home, XDG_CONFIG_HOME: path.join(xdg, 'config'), XDG_DATA_HOME: path.join(xdg, 'data'), XDG_STATE_HOME: path.join(xdg, 'state'), XDG_CACHE_HOME: path.join(xdg, 'cache'), TMPDIR: tmp, CODEX_HOME: codexHome };
|
|
52
|
+
for (const dir of [env.XDG_CONFIG_HOME, env.XDG_DATA_HOME, env.XDG_STATE_HOME, env.XDG_CACHE_HOME]) fs.mkdirSync(dir, { recursive: true });
|
|
53
|
+
if (authDir) copyAuth(path.resolve(authDir), { home, xdg, codexHome }, runner);
|
|
54
|
+
return env;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function copyAuth(source, destinations, runner) {
|
|
58
|
+
if (!fs.existsSync(source)) throw new Error(`auth directory not found: ${source}`);
|
|
59
|
+
const files = ['auth.json', 'credentials.json'];
|
|
60
|
+
for (const name of files) {
|
|
61
|
+
const from = path.join(source, name);
|
|
62
|
+
if (!fs.existsSync(from) || !fs.statSync(from).isFile()) continue;
|
|
63
|
+
// opencode reads auth from XDG_DATA_HOME/opencode; codex from CODEX_HOME.
|
|
64
|
+
const targets = runner === 'opencode' ? [path.join(destinations.xdg, 'data', 'opencode', name)] : [path.join(destinations.codexHome, name)];
|
|
65
|
+
for (const to of targets) {
|
|
66
|
+
fs.mkdirSync(path.dirname(to), { recursive: true });
|
|
67
|
+
fs.copyFileSync(from, to); fs.chmodSync(to, 0o600);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function quoteShell(value) {
|
|
73
|
+
return `'${String(value).replace(/'/g, "'\\''")}'`;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function commandPlan(args, fixture, env) {
|
|
77
|
+
if (args.runner === 'codex') {
|
|
78
|
+
return {
|
|
79
|
+
command: 'codex',
|
|
80
|
+
args: ['exec', '-m', 'gpt-6-luna', '-c', 'model_reasoning_effort="high"', '-s', 'workspace-write', '-C', fixture.repo, '--json', COMMIT_TASK_TEXT],
|
|
81
|
+
cwd: fixture.repo,
|
|
82
|
+
taskText: COMMIT_TASK_TEXT,
|
|
83
|
+
action: 'prepared-commit',
|
|
84
|
+
tokenCapEnforcement: 'post-hoc measurement',
|
|
85
|
+
carrier: 'Codex user-hook compatibility runtime installed under isolated CODEX_HOME; hooks/scripts/codex-ledger-lesson.js',
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
if (args.runner === 'opencode') {
|
|
89
|
+
const pluginPath = path.join(fixture.repo, '.opencode', 'plugins', 'harness-enforcement.js');
|
|
90
|
+
fs.mkdirSync(path.dirname(pluginPath), { recursive: true });
|
|
91
|
+
fs.writeFileSync(pluginPath, `export { default } from ${JSON.stringify(path.join(REPO, 'opencode-plugin/index.mjs'))};\n`);
|
|
92
|
+
fs.appendFileSync(path.join(fixture.repo, '.git', 'info', 'exclude'), '\n.opencode/\n');
|
|
93
|
+
return {
|
|
94
|
+
command: 'opencode',
|
|
95
|
+
args: ['run', '--server', '<isolated-long-lived-server>', '--auto', '--model', 'opencode/hy4-flash-free', '--format', 'json', TASK_TEXT],
|
|
96
|
+
cwd: fixture.repo,
|
|
97
|
+
taskText: TASK_TEXT,
|
|
98
|
+
action: 'commit',
|
|
99
|
+
tokenCapEnforcement: 'post-hoc measurement',
|
|
100
|
+
carrier: 'OpenCode V2 checkout plugin, one-line re-export, tool before/after to next context hook',
|
|
101
|
+
server: { command: 'opencode', args: ['serve', '--hostname', '127.0.0.1', '--port', '<ephemeral>'], requiredVersion: '2.4.1', env: 'OPENCODE_PASSWORD' },
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
const prompt = args.arm === 'treatment'
|
|
105
|
+
? `${TASK_TEXT}\n\nPacket-context intervention (agy-injection; not a repository-ledger carrier):\n${fs.readFileSync(path.join(fixture.repo, LEDGER_RECORD), 'utf8').split('## Lesson')[1]?.split(/^## /m)[0] || ''}`
|
|
106
|
+
: TASK_TEXT;
|
|
107
|
+
return {
|
|
108
|
+
command: 'agy',
|
|
109
|
+
args: ['-p', prompt, '--model', 'gemini-4-hydrogen-high', '--mode', 'accept-edits', '--sandbox', '--settings', '{"permissions":{"allow":["command(*)","read_file(*)"]}}'],
|
|
110
|
+
cwd: fixture.repo,
|
|
111
|
+
taskText: prompt,
|
|
112
|
+
action: 'commit',
|
|
113
|
+
tokenCapEnforcement: 'post-hoc measurement',
|
|
114
|
+
carrier: 'none; packet-context injection, reported as agy-injection only',
|
|
115
|
+
isolation: 'real HOME (agy login lives in ~/.gemini); TMPDIR isolated; global agy plugins load equally in both arms',
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
async function ephemeralPort() {
|
|
120
|
+
const server = net.createServer();
|
|
121
|
+
await new Promise((resolve, reject) => server.once('error', reject).listen(0, '127.0.0.1', resolve));
|
|
122
|
+
const port = server.address().port;
|
|
123
|
+
await new Promise(resolve => server.close(resolve));
|
|
124
|
+
return port;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// 200k cap (owner: post-hoc measurement) counts uncached input + output + reasoning; cache reads are retained separately.
|
|
128
|
+
function usageTotal(u) { return u ? Math.max(0, u.inputTokens - (u.inputIncludesCache ? u.cachedTokens : 0)) + u.outputTokens + u.reasoningTokens : 0; }
|
|
129
|
+
|
|
130
|
+
function parseUsage(stdout) {
|
|
131
|
+
const totals = { inputTokens: 0, outputTokens: 0, reasoningTokens: 0, cachedTokens: 0, totalTokens: 0 };
|
|
132
|
+
let found = false;
|
|
133
|
+
function visit(value) {
|
|
134
|
+
if (!value || typeof value !== 'object') return;
|
|
135
|
+
for (const [key, child] of Object.entries(value)) {
|
|
136
|
+
const target = ({ total_tokens: 'totalTokens', tokens: 'totalTokens', input_tokens: 'inputTokens', prompt_tokens: 'inputTokens', output_tokens: 'outputTokens', completion_tokens: 'outputTokens', reasoning_tokens: 'reasoningTokens', cached_input_tokens: 'cachedTokens', cached_tokens: 'cachedTokens' })[key];
|
|
137
|
+
// opencode --format json nests usage as tokens:{input,output,reasoning,cache:{read}}.
|
|
138
|
+
if (key === 'tokens' && child && typeof child === 'object') {
|
|
139
|
+
for (const [k, t] of [['input', 'inputTokens'], ['output', 'outputTokens'], ['reasoning', 'reasoningTokens']]) if (Number.isFinite(child[k])) { totals[t] += child[k]; found = true; }
|
|
140
|
+
if (Number.isFinite(child.cache?.read)) { totals.cachedTokens += child.cache.read; found = true; }
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
if (target && Number.isFinite(child)) { totals[target] += child; found = true; }
|
|
144
|
+
else if (child && typeof child === 'object') visit(child);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
for (const line of String(stdout || '').split(/\r?\n/)) { try { visit(JSON.parse(line)); } catch {} }
|
|
148
|
+
if (!found) return null;
|
|
149
|
+
if (!totals.totalTokens) totals.totalTokens = totals.inputTokens + totals.outputTokens + totals.reasoningTokens + totals.cachedTokens;
|
|
150
|
+
return totals;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function git(repo, args) {
|
|
154
|
+
return spawnSync('git', ['-C', repo, ...args], { encoding: 'utf8' });
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function sanitize(text, env) {
|
|
158
|
+
let result = String(text || '');
|
|
159
|
+
for (const key of ['GEMINI_API_KEY', 'OPENCODE_PASSWORD']) {
|
|
160
|
+
if (env[key]) result = result.split(env[key]).join('[REDACTED]');
|
|
161
|
+
}
|
|
162
|
+
return result.replace(/(sk-[A-Za-z0-9_-]{16,}|AIza[A-Za-z0-9_-]{20,})/g, '[REDACTED]');
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function runPreparedCommit(repo, env) {
|
|
166
|
+
const messagePath = path.join(repo, '.commit-msg.txt');
|
|
167
|
+
const staged = git(repo, ['add', '-A']);
|
|
168
|
+
if (fs.existsSync(messagePath)) git(repo, ['reset', '--', '.commit-msg.txt']);
|
|
169
|
+
const stagedFiles = git(repo, ['diff', '--cached', '--name-only']).stdout.trim().split(/\r?\n/).filter(Boolean);
|
|
170
|
+
if (staged.status !== 0 || !fs.existsSync(messagePath) || stagedFiles.length !== 1 || stagedFiles[0] !== 'src/sample.js') return { accepted: false, stagedFiles, failure: 'prepared-commit-missing-message-or-unexpected-stage', output: staged.stderr, diagnostics: [] };
|
|
171
|
+
const commit = spawnSync('git', ['-C', repo, 'commit', '-F', messagePath], { encoding: 'utf8', env });
|
|
172
|
+
const output = `${commit.stdout || ''}${commit.stderr || ''}`;
|
|
173
|
+
const diagnostics = ['subject-case', 'header-max-length', 'type-empty', 'subject-empty'].filter(diagnostic => output.includes(`[${diagnostic}]`));
|
|
174
|
+
return { accepted: commit.status === 0, stagedFiles, output, diagnostics };
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function runProcess(plan, env, timeoutMs, logFile) {
|
|
178
|
+
return new Promise(resolve => {
|
|
179
|
+
const child = spawn(plan.command, plan.args, { cwd: plan.cwd, env, stdio: ['ignore', 'pipe', 'pipe'], windowsHide: true });
|
|
180
|
+
let stdout = '';
|
|
181
|
+
let stderr = '';
|
|
182
|
+
let timedOut = false;
|
|
183
|
+
const timeout = setTimeout(() => { timedOut = true; child.kill('SIGTERM'); }, timeoutMs);
|
|
184
|
+
child.stdout.on('data', chunk => { stdout += chunk; });
|
|
185
|
+
child.stderr.on('data', chunk => { stderr += chunk; });
|
|
186
|
+
child.on('error', error => { stderr += `${error.message}\n`; });
|
|
187
|
+
child.on('close', code => {
|
|
188
|
+
clearTimeout(timeout);
|
|
189
|
+
const body = `EXIT_CODE=${code}\nTIMED_OUT=${timedOut}\n--- stdout ---\n${sanitize(stdout, env)}\n--- stderr ---\n${sanitize(stderr, env)}\n`;
|
|
190
|
+
fs.writeFileSync(logFile, body, { mode: 0o600 });
|
|
191
|
+
resolve({ code, timedOut, stdout: sanitize(stdout, env), stderr: sanitize(stderr, env) });
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function installCodexCarrierProbe(env, out, arm) {
|
|
197
|
+
const hooksFile = path.join(env.CODEX_HOME, 'hooks.json');
|
|
198
|
+
const wrapper = path.join(env.CODEX_HOME, 'ledger-probe.js');
|
|
199
|
+
const receiptFile = path.join(out, 'receipt.jsonl');
|
|
200
|
+
const sourceHook = path.join(REPO, 'hooks/scripts/codex-ledger-lesson.js');
|
|
201
|
+
const source = `'use strict';\nconst fs=require('node:fs');\nconst path=require('node:path');\nconst {spawnSync}=require('node:child_process');\nconst filter=${filterCarrierContext.toString()};\nconst input=fs.readFileSync(0,'utf8');\nconst payload=JSON.parse(input||'{}');\nconst result=spawnSync(process.execPath,[${JSON.stringify(sourceHook)}],{input,encoding:'utf8',cwd:payload.cwd,env:process.env});\nconst record=fs.readFileSync(path.join(payload.cwd,'.agents/harness-everything/errors/E-0003-commitlint-subject.md'),'utf8');const section=n=>{const m=record.match(new RegExp('^## '+n+'\\\\s*\\\\n([\\\\s\\\\S]*?)(?=^## |$)','m'));return m?m[1].trim():''};const fragment='Cue:\\n'+section('Cue')+'\\nLesson:\\n'+section('Lesson');\nlet output=result.stdout||'';let matched=false;let stripped=false;\ntry{const data=JSON.parse(output||'{}');const key=data.hookSpecificOutput?.additionalContext;const filtered=filter(key,fragment,${JSON.stringify(arm === 'baseline')});matched=filtered.matched;stripped=filtered.stripped;if(stripped){data.hookSpecificOutput.additionalContext=filtered.text;output=JSON.stringify(data)}}catch{}\nconst command=payload.tool_input?.command||'';const compound=/&&|\\|\\||\\n/.test(command);fs.appendFileSync(${JSON.stringify(receiptFile)},JSON.stringify({phase:payload.hook_event_name||'unknown',requestId:payload.turn_id||payload.turnId||null,matched,stripped,kind:compound?'compound':/^\\s*git\\s+commit\\b/.test(command)?'direct':'other',containsGitCommit:/\\bgit\\s+commit\\b/i.test(command)})+'\\n',{mode:0o600});\nprocess.stdout.write(output);process.stderr.write(result.stderr||'');process.exitCode=result.status||0;\n`;
|
|
202
|
+
fs.writeFileSync(wrapper, source, { mode: 0o700 });
|
|
203
|
+
const config = JSON.parse(fs.readFileSync(hooksFile, 'utf8'));
|
|
204
|
+
let changed = false;
|
|
205
|
+
function rewrite(value) {
|
|
206
|
+
if (Array.isArray(value)) return value.map(rewrite);
|
|
207
|
+
if (!value || typeof value !== 'object') return typeof value === 'string' && value.includes('codex-ledger-lesson.js') ? (changed = true, value.replace(/[^\s"']*codex-ledger-lesson\.js/, wrapper)) : value;
|
|
208
|
+
return Object.fromEntries(Object.entries(value).map(([key, child]) => [key, rewrite(child)]));
|
|
209
|
+
}
|
|
210
|
+
const rewritten = rewrite(config);
|
|
211
|
+
if (!changed) throw new Error('Codex compatibility hooks did not expose codex-ledger-lesson.js for probe wrapping');
|
|
212
|
+
fs.writeFileSync(hooksFile, `${JSON.stringify(rewritten, null, 2)}\n`, { mode: 0o600 });
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function installOpenCodeCarrierProbe(fixture, out, arm) {
|
|
216
|
+
const pluginPath = path.join(fixture.repo, '.opencode', 'plugins', 'zz-ledger-probe.js');
|
|
217
|
+
const receiptFile = path.join(out, 'receipt.jsonl');
|
|
218
|
+
fs.mkdirSync(path.dirname(pluginPath), { recursive: true });
|
|
219
|
+
fs.writeFileSync(pluginPath, `import fs from 'node:fs';\nimport path from 'node:path';\nconst filter=${filterCarrierContext.toString()};\nconst receipt=${JSON.stringify(receiptFile)};\nconst root=${JSON.stringify(fixture.repo)};\nconst baseline=${JSON.stringify(arm === 'baseline')};\nconst write=x=>fs.appendFileSync(receipt,JSON.stringify(x)+'\\n',{mode:0o600});\nconst fragment=()=>{const record=fs.readFileSync(path.join(root,'.agents/harness-everything/errors/E-0003-commitlint-subject.md'),'utf8');const section=n=>{const m=record.match(new RegExp('^## '+n+'\\\\s*\\\\n([\\\\s\\\\S]*?)(?=^## |$)','m'));return m?m[1].trim():''};return 'Cue:\\n'+section('Cue')+'\\nLesson:\\n'+section('Lesson')};\nconst toolReceipt=(phase,event)=>{const command=typeof event.input?.command==='string'?event.input.command:'';const kind=/&&|\\|\\||\\n/.test(command)?'compound':/^\\s*git\\s+commit\\b/.test(command)?'direct':'other';write({phase,requestId:event.messageID||event.messageId||null,kind,containsGitCommit:/\\bgit\\s+commit\\b/i.test(command)})};\nexport default {id:'fixture.ledger-probe',async setup(ctx){await ctx.session.hook('context',event=>{const exact=fragment();const system=Array.isArray(event.system)?event.system:[];for(const part of system){if(typeof part?.text!=='string')continue;const filtered=filter(part.text,exact,baseline);if(!filtered.matched)continue;write({phase:'context',requestId:event.messageID||event.messageId||null,matched:true,stripped:filtered.stripped});if(filtered.stripped)part.text=filtered.text}});await ctx.tool.hook('execute.before',event=>toolReceipt('tool.execute.before',event));await ctx.tool.hook('execute.after',event=>toolReceipt('tool.execute.after',event))}};\n`);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
async function runArm(args) {
|
|
223
|
+
const out = path.resolve(args.out, args.runner, `pair-${args.pair}-${args.arm}`);
|
|
224
|
+
fs.mkdirSync(out, { recursive: true });
|
|
225
|
+
const fixture = await buildFixture({ out: path.join(out, 'fixture'), arm: args.arm, sourceRoot: REPO });
|
|
226
|
+
const env = isolatedEnvironment(out, args.authDir, args.runner);
|
|
227
|
+
const plan = commandPlan(args, fixture, env);
|
|
228
|
+
const manifest = {
|
|
229
|
+
schemaVersion: 1,
|
|
230
|
+
runner: args.runner,
|
|
231
|
+
arm: args.arm,
|
|
232
|
+
pair: args.pair,
|
|
233
|
+
intervention: args.runner === 'agy' ? 'agy-injection' : 'repo-ledger-context-visibility',
|
|
234
|
+
visibility: fixture.visibility,
|
|
235
|
+
initialSha: fixture.initialSha,
|
|
236
|
+
taskText: plan.taskText,
|
|
237
|
+
carrier: plan.carrier,
|
|
238
|
+
tokenLimit: { max: 200000, enforcement: plan.tokenCapEnforcement },
|
|
239
|
+
timeoutMs: args.timeoutMs,
|
|
240
|
+
commitlintResolution: fixture.commitlintResolution,
|
|
241
|
+
command: plan,
|
|
242
|
+
liveHostEvidence: 'UNCHECKED until retained matcher receipt and next-request capture are reviewed',
|
|
243
|
+
};
|
|
244
|
+
fs.writeFileSync(path.join(out, 'arm-plan.json'), `${JSON.stringify(manifest, null, 2)}\n`, { mode: 0o600 });
|
|
245
|
+
if (args.dryRun) return { out, manifest };
|
|
246
|
+
|
|
247
|
+
if (args.runner === 'codex') {
|
|
248
|
+
const install = await runProcess({ command: process.execPath, args: [path.join(REPO, 'scripts/codex-hooks-compat.js'), 'install', '--codex-home', env.CODEX_HOME, '--allow-unreleased-source'], cwd: REPO }, env, 60000, path.join(out, 'hook-install.log'));
|
|
249
|
+
if (install.code !== 0) throw new Error(`isolated Codex hook install failed; see ${path.join(out, 'hook-install.log')}`);
|
|
250
|
+
installCodexCarrierProbe(env, out, args.arm);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
let server;
|
|
254
|
+
if (args.runner === 'opencode') {
|
|
255
|
+
if (!env.OPENCODE_PASSWORD) throw new Error('OPENCODE_PASSWORD is required for isolated opencode serve');
|
|
256
|
+
const version = spawnSync('opencode', ['--version'], { encoding: 'utf8', env });
|
|
257
|
+
const actualVersion = (version.stdout || '').trim();
|
|
258
|
+
if (version.status !== 0 || !/(^|[^0-9.])2\.4\.1($|[^0-9])/.test(actualVersion)) throw new Error(`OpenCode must be 2.4.1 for this packet; found ${actualVersion || 'unknown'}`);
|
|
259
|
+
manifest.runnerVersion = actualVersion;
|
|
260
|
+
installOpenCodeCarrierProbe(fixture, out, args.arm);
|
|
261
|
+
const port = await ephemeralPort();
|
|
262
|
+
server = spawn('opencode', ['serve', '--hostname', '127.0.0.1', '--port', String(port)], { cwd: fixture.repo, env, stdio: ['ignore', 'pipe', 'pipe'] });
|
|
263
|
+
fs.writeFileSync(path.join(out, 'server.pid'), `${server.pid}\n`, { mode: 0o600 });
|
|
264
|
+
const serverLog = fs.createWriteStream(path.join(out, 'server.log'), { mode: 0o600 });
|
|
265
|
+
server.stdout.pipe(serverLog);
|
|
266
|
+
server.stderr.pipe(serverLog);
|
|
267
|
+
await new Promise(resolve => setTimeout(resolve, 1500));
|
|
268
|
+
plan.args[2] = `http://127.0.0.1:${port}`;
|
|
269
|
+
fs.writeFileSync(path.join(out, 'arm-plan.json'), `${JSON.stringify(manifest, null, 2)}\n`, { mode: 0o600 });
|
|
270
|
+
}
|
|
271
|
+
const startedAt = new Date().toISOString();
|
|
272
|
+
const result = await runProcess(plan, env, args.timeoutMs, path.join(out, 'transcript.log'));
|
|
273
|
+
if (server) server.kill('SIGTERM');
|
|
274
|
+
let preparedCommit = null;
|
|
275
|
+
if (args.runner === 'codex') {
|
|
276
|
+
preparedCommit = runPreparedCommit(fixture.repo, { ...env, ...require('./fixture').FIXED_ENV });
|
|
277
|
+
fs.appendFileSync(path.join(out, 'transcript.log'), `\n--- prepared-commit driver ---\n${preparedCommit.output || preparedCommit.failure || ''}\n`);
|
|
278
|
+
}
|
|
279
|
+
const endedAt = new Date().toISOString();
|
|
280
|
+
const log = fs.readFileSync(path.join(out, 'transcript.log'), 'utf8');
|
|
281
|
+
const recordPath = path.join(fixture.repo, LEDGER_RECORD);
|
|
282
|
+
const recordBeforeRestore = fs.readFileSync(recordPath, 'utf8');
|
|
283
|
+
const visibilityUntouched = recordBeforeRestore === fixture.record;
|
|
284
|
+
const head = git(fixture.repo, ['rev-parse', 'HEAD']).stdout.trim();
|
|
285
|
+
const commits = head && head !== fixture.initialSha ? git(fixture.repo, ['rev-list', '--reverse', `${fixture.initialSha}..HEAD`]).stdout.trim().split(/\r?\n/).filter(Boolean) : [];
|
|
286
|
+
const changedFiles = head && head !== fixture.initialSha ? git(fixture.repo, ['diff', '--name-only', `${fixture.initialSha}..HEAD`]).stdout.trim().split(/\r?\n/).filter(Boolean) : [];
|
|
287
|
+
const finalSource = fs.readFileSync(path.join(fixture.repo, 'src/sample.js'), 'utf8');
|
|
288
|
+
const test = spawnSync(process.execPath, ['test.js'], { cwd: fixture.repo, encoding: 'utf8' });
|
|
289
|
+
const diagnostics = [];
|
|
290
|
+
for (const diagnostic of ['subject-case', 'header-max-length', 'type-empty', 'subject-empty']) {
|
|
291
|
+
const count = (log.match(new RegExp(`\\[${diagnostic}\\]`, 'g')) || []).length;
|
|
292
|
+
for (let i = 0; i < count; i += 1) diagnostics.push(diagnostic);
|
|
293
|
+
}
|
|
294
|
+
const events = diagnostics.length ? [{ kind: 'commit', accepted: false, attemptId: args.runner === 'codex' ? 'driver-commit-1' : 'unresolved-attempt-1', diagnostics: [...new Set(diagnostics)] }] : [];
|
|
295
|
+
const receiptFile = path.join(out, 'receipt.jsonl');
|
|
296
|
+
const probeRecords = fs.existsSync(receiptFile) ? fs.readFileSync(receiptFile, 'utf8').split(/\r?\n/).filter(Boolean).map(line => JSON.parse(line)) : [];
|
|
297
|
+
const receiptEvents = [];
|
|
298
|
+
if (args.runner === 'opencode') {
|
|
299
|
+
for (const receipt of probeRecords.filter(row => row.phase === 'context')) {
|
|
300
|
+
const linkedAction = receipt.requestId && probeRecords.find(row => row.phase === 'tool.execute.before' && row.requestId === receipt.requestId && row.containsGitCommit);
|
|
301
|
+
const requestId = receipt.requestId;
|
|
302
|
+
receiptEvents.push({ kind: 'receipt', requestId, correlated: Boolean(linkedAction), status: receipt.matched && !receipt.stripped ? 'delivered-before-decision' : receipt.stripped ? 'filtered' : 'unknown' });
|
|
303
|
+
if (linkedAction) receiptEvents.push({ kind: 'decision', requestId, actionKind: linkedAction.kind });
|
|
304
|
+
}
|
|
305
|
+
} else if (args.runner === 'codex') {
|
|
306
|
+
for (const receipt of probeRecords.filter(row => row.containsGitCommit)) {
|
|
307
|
+
const requestId = receipt.requestId;
|
|
308
|
+
if (requestId) receiptEvents.push({ kind: 'decision', requestId, actionKind: receipt.kind });
|
|
309
|
+
receiptEvents.push({ kind: 'receipt', requestId, correlated: Boolean(requestId), status: 'delivered-after-decision' });
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
events.push(...receiptEvents);
|
|
313
|
+
if (preparedCommit) {
|
|
314
|
+
events.push({ kind: 'prepared-commit', accepted: preparedCommit.accepted, stagedFiles: preparedCommit.stagedFiles });
|
|
315
|
+
}
|
|
316
|
+
for (const sha of commits) events.push({ kind: 'commit', accepted: true, sha, subject: git(fixture.repo, ['show', '-s', '--format=%s', sha]).stdout.trim() });
|
|
317
|
+
events.push({ kind: 'test', passed: test.status === 0 });
|
|
318
|
+
for (const line of log.split(/\r?\n/)) if (/--no-verify|HUSKY\s*=\s*0/i.test(line)) events.push({ kind: 'bypass', value: line });
|
|
319
|
+
const workingTree = git(fixture.repo, ['status', '--short']).stdout.trim();
|
|
320
|
+
// codex input_tokens already include cached_input_tokens; opencode input excludes cache reads.
|
|
321
|
+
const usage = parseUsage(result.stdout);
|
|
322
|
+
if (usage && args.runner === 'codex') usage.inputIncludesCache = true;
|
|
323
|
+
const record = {
|
|
324
|
+
runner: args.runner, arm: args.arm, pair: args.pair, action: plan.action, startedAt, endedAt,
|
|
325
|
+
elapsedMs: Date.parse(endedAt) - Date.parse(startedAt), tokenCapEnforcement: plan.tokenCapEnforcement,
|
|
326
|
+
usage, overCap: usageTotal(usage) > 200000, events,
|
|
327
|
+
initialFiles: { 'src/sample.js': "'use strict';\n\nmodule.exports = () => '';\n" },
|
|
328
|
+
finalFiles: { 'src/sample.js': finalSource },
|
|
329
|
+
manualIntervention: 0,
|
|
330
|
+
failures: [...(result.code === 0 ? [] : [`runner-exit-${result.code}`]), ...(!visibilityUntouched ? ['agent-modified-visibility-intervention'] : [])],
|
|
331
|
+
unknowns: ['matcher receipt and model-request delivery require coordinator review', 'manual intervention is zero only while the arm remains unattended'],
|
|
332
|
+
transcriptPath: 'transcript.log', transcriptSha256: require('node:crypto').createHash('sha256').update(log).digest('hex'),
|
|
333
|
+
gitLog: git(fixture.repo, ['log', '--format=%H%x09%s']).stdout.trim().split(/\r?\n/),
|
|
334
|
+
changedFiles,
|
|
335
|
+
correctDiff: visibilityUntouched && changedFiles.length === 1 && changedFiles[0] === 'src/sample.js' && finalSource.includes("module.exports = () => 'hello';"),
|
|
336
|
+
testPassed: test.status === 0,
|
|
337
|
+
hookRejections: diagnostics,
|
|
338
|
+
preparedCommit,
|
|
339
|
+
probeRecords,
|
|
340
|
+
fileReads: (log.match(/(?:read_file|read_file_tool|git\s+(?:log|show))[^\n]*(?:\.agents\/harness-everything\/errors|E-\d{4})/gi) || []).length,
|
|
341
|
+
probeReceiptPath: fs.existsSync(path.join(out, 'receipt.jsonl')) ? 'receipt.jsonl' : 'missing',
|
|
342
|
+
matcherReceipt: 'unknown; review sanitized host trace',
|
|
343
|
+
contextDelivery: 'unknown; review actual next-request capture',
|
|
344
|
+
workingTree,
|
|
345
|
+
treeClean: workingTree === '',
|
|
346
|
+
};
|
|
347
|
+
fs.writeFileSync(path.join(out, 'arm-result.json'), `${JSON.stringify(record, null, 2)}\n`, { mode: 0o600 });
|
|
348
|
+
return { out, manifest, result: { code: result.code, timedOut: result.timedOut } };
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
async function main(argv) {
|
|
352
|
+
const args = parseArgs(argv);
|
|
353
|
+
const result = await runArm(args);
|
|
354
|
+
process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
if (require.main === module) main(process.argv.slice(2)).catch(error => { console.error(error.message); process.exitCode = 2; });
|
|
358
|
+
|
|
359
|
+
module.exports = { commandPlan, filterCarrierContext, isolatedEnvironment, installCodexCarrierProbe, installOpenCodeCarrierProbe, main, parseArgs, runArm, runPreparedCommit, sanitize };
|