Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

5.0 KB
Raw Blame

Native hook installation stays with session control

Before this change, the shared optional hooks module was awaited by daemon startup and OpenCode preflight. Removing or stalling it can block readiness or a launch. Hook installation supplies session discovery and turn boundaries, so those mechanics must be eager too.

Before moving production code, the existing otherHooks.golden.spec.ts was re-recorded from main f6f1eef1ab3823effa1646ebce960cc1b007a574 on 2026-10-09, then verified with recording disabled. All 340 cases pass. The recorded artifact is byte-for-byte identical to the existing fixture, SHA-256 05013b28d8e42eec73598ac21d139130e4b5c65e2207aadbb1626bd5ee591197. This commit records that baseline before implementation. Linux is pinned, the environment uses UTC and /tmp, every home is disposable, and Node paths are placeholders.

The extraction declares vendor settings, plugin source, paths and migration facts beside each engine, with shared mechanics in engines/kit and eager composition. Existing JSON merging, YAML preservation, generated plugin bytes, permissions, symlinks, migration ownership checks and log output remain covered by that unchanged golden. Deliberate wiring and declaration mutations must fail assertions. The real bundle becomes ready with all thirteen installers selected, verifies each private native artifact, launches OpenCode and retains a sibling Claude Code/Codex Stop/resume while the obsolete shared hooks chunk is missing or stalled. The compatibility alias remains available for old imports, but core never requests it. The architecture guard rejects restoring that lazy dependency.

Compatibility is only the first step. The OpenCode control review separately identified swallowed plugin write/removal errors, the synchronous version probe, inconsistent preparation across dispatch paths and unavailable-service results lost by callers. Those require explicit held outcomes and shared preparation before any process or configuration mutation; an eager import alone does not establish that they are safe. See OpenCode control.

Validation plan: typecheck; architecture; unchanged native hook, Claude/Codex hook and admission goldens; installer and Hermes profile specs; eager-import guard; full core/services and master coverage; private-bundle shared-hook and OpenCode-reader fault cases; core, hook-client and crash/resume e2e lanes. Scope receipts include all CLI/Store sources, configs, fixtures and lockfiles plus Node, Vitest and tmux versions. CI covers the complete Linux unit suite. Runtime comparison uses frozen baseline/candidate bundles with the same thirteen-install startup and two OpenCode launches; measurements run separately from heavy validation.

Initial complete gates pass: 530 focused tests, 1,897 core/services tests and 265 master tests (one intentional skip), with every covered core/services/master file at 100% statements, branches, functions and lines. Seven bundle acceptance cases pass. The first wrong-generation mutant caused the golden's fixture-building step to fail before assertions; it was rejected as evidence and changed to keep v1 installation while wrongly installing the v1 plugin for v2. The golden fixture and spec are unchanged.

Final focused verification adds two literal-data cases: a $& in a path must appear verbatim in a log, and a plugin argument resembling template syntax must not be interpolated again. All 532 focused tests and typecheck pass. Twelve declaration/wiring mutants fail assertions: JSON event/failure policy/foreign preservation, port routing, version selection, legacy plugin ownership, YAML foreign preservation, profile discovery, approvals, installer routing, pre-spawn preparation and the lazy startup dependency. No setup failure is counted.

Runtime samples use Node 22.23.2 and tmux 3.5a on the same machine, all thirteen installers, and two native launches per fresh daemon. The two baseline readiness samples are 1,499–2,017 ms versus 1,584–1,633 ms for the candidate; core CPU at readiness is 300–310 ms versus 300 ms, and RSS 76.3–79.1 MiB versus 77.0–78.8 MiB. Launch latency varies across both samples. These four observations support no speed claim or numerical gate. Reproduce with frozen bundles at OPENCODE_COST_ROOT/{baseline,candidate}/cli.js and OPENCODE_COST_NATIVE_HOOKS=1 passed in the test process environment. The validation runner does not forward an env field in an individual check; the first opt-in invocation skipped and is not measurement evidence. The actual workload passed in 9.5 seconds.

The final bundled core/hook-client/crash-resume lane passes all 27 cases (342.5 seconds). The first ready-head Linux run found an obsolete lean-bundle assertion requiring native hook source to stay lazy. The replacement explicitly requires the native declaration in the core's static bundle while keeping the optional compatibility entry and native readers out. This is a test correction to the intended boundary; no production code changed after the passing local acceptance.