The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.
fix(context): admit later Claude Code 2.1 patches
montjeffrey3ff4937f1f12
diff --git a/docs/design/context-profile-delivery.md b/docs/design/context-profile-delivery.mdindex 6d2dd8abf..abfbb8701 100644--- a/docs/design/context-profile-delivery.md+++ b/docs/design/context-profile-delivery.md@@ -72,9 +72,9 @@ The task call sends the query and selected reference content on standard input tA managed store with `--target claude` uses the same `prepare-native`, `native-status`, `native-rollback`, `native-recover`, `run` and `start` commands. Claude Code loads the carrier for each session with `--plugin-dir`; nothing is installed, no marketplace is registered and no settings are written. The generation holds a private `home/.claude` used as `CLAUDE_CONFIG_DIR`, an empty project and a verified copy of the carrier in `plugin/`. Every Claude call sets `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC` and `CLAUDE_CODE_DISABLE_OFFICIAL_MARKETPLACE_AUTOINSTALL`, so the isolated home gains no other plugins.-Preparation admits only Claude Code 2.1.292. It requires a clean `claude plugin validate --json` report, exactly one session plugin (`ecc-context-carrier@inline`, enabled, at the generation's `plugin/` path) from `claude --plugin-dir … plugin list --json`, and a `claude --plugin-dir … plugin details` inventory whose skills equal the carrier selection with zero agents, hooks, MCP servers and LSP servers. `details` has no JSON form; the pinned version fixes its layout and an unparseable report fails closed. The copied files must match the carrier digests after the provider calls.+Preparation admits Claude Code 2.1.292 and later 2.1 patches; the receipt records the exact version, and a changed binary needs a new preparation. It requires a clean `claude plugin validate --json` report, exactly one session plugin (`ecc-context-carrier@inline`, enabled, at the generation's `plugin/` path) from `claude --plugin-dir … plugin list --json`, and a `claude --plugin-dir … plugin details` inventory whose skills equal the carrier selection with zero agents, hooks, MCP servers and LSP servers. `details` has no JSON form; an unparseable or changed report fails closed, which is why the admitted range is bounded to the 2.1 series. The copied files must match the carrier digests after the provider calls.-The receipt records the host's always-on projection as `nativeObservation` (`surface: plugin-always-on-listing`, `method: [email protected]`, `approximate: true`). It is Claude Code's own estimate of the listing cost of this one plugin, not whole-context usage. `native-status` checks file integrity of the plugin copy, `CLAUDE.md`, user settings, skills, agents and commands in the isolated home; provider runtime state such as `.claude.json` and plugin bookkeeping is outside those controls, and plugin registration is verified again at each preparation.+The receipt records the host's always-on projection as `nativeObservation` (`surface: plugin-always-on-listing`, `method: claude-plugin-details@<version>`, `approximate: true`). It is Claude Code's own estimate of the listing cost of this one plugin, not whole-context usage. `native-status` checks file integrity of the plugin copy, `CLAUDE.md`, user settings, skills, agents and commands in the isolated home; provider runtime state such as `.claude.json` and plugin bookkeeping is outside those controls, and plugin registration is verified again at each preparation.Switching the managed profile makes the old native generation stale until `prepare-native` succeeds. To undo a switch, first `rollback` the managed store, then use `native-rollback` with both roots. `native-recover` handles a retained interruption journal without deleting provider data. Existing sessions retain their original context. These commands support isolated Codex and Claude generations, not migration of an existing global installation or native activation for other providers.diff --git a/docs/design/context-profile-delivery.tdd.md b/docs/design/context-profile-delivery.tdd.mdindex 3312fff79..7b16adcb1 100644--- a/docs/design/context-profile-delivery.tdd.md+++ b/docs/design/context-profile-delivery.tdd.md@@ -95,6 +95,7 @@ Session-only Claude discovery adapts the ownership and receipt intent of #2788 t- RED: 22 cases fail before the provider adapter (preview, prepare, version gate, nine discovery corruptions, details mismatch, static integrity, runtime-state tolerance, provider-home roots, Codex-to-Claude staleness, task launch and interactive start).- GREEN: all 22 pass. Codex native (39), interactive (8), launch (12), auto launch (5), evaluation (31), store (31) and profile CLI suites pass unchanged; Codex receipts keep their shape, and evaluator Claude launches without a plugin directory keep their arguments and environment.- Credential-free real run on Linux x64 with Claude Code 2.1.292 and the actual registry: Lean prepared ready with three skills and a 398-token always-on projection; Full prepared ready with 293 skills and 35,658 tokens; Full excluding `skill:python-patterns` verified 292 skills without it at 35,561 tokens. Switching profiles reported `stale`, and native rollback restored the Lean generation. `run --dry-run` resolved the pinned binary with `--plugin-dir`; `start --dry-run` proposed the Claude generation.+- Claude Code auto-updated to 2.1.293 during review, and the exact 2.1.292 pin rejected it. RED: tests for later 2.1 patches fail. GREEN admits 2.1.292 and later 2.1 patches while rejecting 2.1.291, 2.2.0, prereleases and malformed output. A real 2.1.293 run prepared Lean ready at the same 398-token projection; preparation took 2.4 s (provider calls 1.2 s), an unchanged re-preparation 0.9 s and status 11 ms.- No authenticated model call, interactive turn or native skill invocation ran. The projection is the host's estimate for the plugin listing, not whole-context truth.These boundaries keep the shipped behavior distinct from the M1 release gate. Authenticated outcome observations, a complete Tier 2 disk diff, live-install migration, other-provider activation, whole-context token truth and release defaults remain unverified until their explicit prerequisites are available.diff --git a/scripts/lib/context-profile-native.js b/scripts/lib/context-profile-native.jsindex 878cb965d..0de259630 100644--- a/scripts/lib/context-profile-native.js+++ b/scripts/lib/context-profile-native.js@@ -25,14 +25,17 @@ const CLAUDE_ISOLATION_ENV = Object.freeze({ CLAUDE_CODE_DISABLE_NONESSENTIAL_TRconst PROVIDERS = Object.freeze({codex: { label: 'Codex', command: 'codex', executableKey: 'codexPath',// 0.155.1: credential-free native-probe verified Lean, include, Full exclusion and resource relocation.- versions: ['0.154.0', '0.155.1'], versionOutput: version => `codex-cli ${version}`,+ requiredVersion: '0.154.0', versions: ['0.154.0', '0.155.1'], parseVersion: output => /^codex-cli (\S+)$/.exec(output)?.[1] ?? null,+ admits(version) { return this.versions.includes(version); },bootstrapPath: 'home/.codex/AGENTS.md',controls: ['marketplace', 'project', 'home/.agents', 'home/.codex/config.toml','home/.codex/AGENTS.md', 'home/.codex/AGENTS.override.md', 'home/.codex/hooks.json','home/.codex/requirements.toml', 'home/.codex/plugins', 'home/.codex/skills'] },- // 2.1.292: credential-free probe verified Lean and Full session-only discovery and host projections.+ // 2.1.292 and 2.1.293: credential-free probes verified Lean and Full session-only discovery and+ // host projections. Later 2.1 patches are admitted; every check fails closed on output drift.claude: { label: 'Claude', command: 'claude', executableKey: 'claudePath',- versions: ['2.1.292'], versionOutput: version => `${version} (Claude Code)`,+ requiredVersion: '2.1.292', versions: ['>=2.1.292 <2.2.0'], parseVersion: output => /^(2\.1\.(0|[1-9]\d*)) \(Claude Code\)$/.exec(output)?.[1] ?? null,+ admits(version) { return /^2\.1\.(0|[1-9]\d*)$/.test(version) && Number(version.split('.')[2]) >= 292; },bootstrapPath: 'home/.claude/CLAUDE.md',// Provider runtime state (.claude.json, projects, backups, plugin bookkeeping)// is not skill discovery state; plugin registration is re-verified on prepare.@@ -178,7 +181,7 @@ function loadReceipt(options, state, { allowRefresh = false } = {}) {const target = receipt.target ?? 'codex';if (digestObject(receipt) !== state.generationReceiptDigest || receipt.schemaVersion !== 'ecc.native-context-receipt.v1'|| receipt.generationId !== state.generationId || !Object.hasOwn(PROVIDERS, target)- || !PROVIDERS[target].versions.includes(receipt.providerVersion)+ || !PROVIDERS[target].admits(receipt.providerVersion)|| receipt.bindingDigest !== digestObject({ nativeRoot: options.nativeRoot, stateRoot: options.stateRoot })) {throw new Error('Native receipt integrity failed');}@@ -210,7 +213,7 @@ function response(options, state, current, pending = false, allowRefresh = falseconst base = { schemaVersion: 'ecc.native-context-status.v1', nativeRoot: options.nativeRoot,stateRoot: options.stateRoot, active: false, ready: false, revision: state?.revision || 0,status: pending ? 'recovery-required' : 'unconfigured', target: current.target,- providerVersion: providerFor(current.target).versions[0], home: null, ...providerPaths(current.target, null),+ providerVersion: providerFor(current.target).requiredVersion, home: null, ...providerPaths(current.target, null),carrierDigest: null, storeRevision: null,currentStoreRevision: current.revision, currentCarrierDigest: current.carrierDigest,discovery: 'unobserved', currentSessionChanged: false, credentialsCopied: false };@@ -250,7 +253,8 @@ function previewNativeProfile(input) {if (options.expectedRevision !== undefined && options.expectedRevision !== before.revision) throw new Error('Native revision changed since preview');const provider = providerFor(current.target);return { ...before, status: 'proposed', ready: false, proposedCarrierDigest: current.carrierDigest,- proposedStoreRevision: current.revision, requiredProviderVersion: provider.versions[0], supportedProviderVersions: [...provider.versions] };+ proposedStoreRevision: current.revision, requiredProviderVersion: provider.requiredVersion,+ supportedProviderVersions: [...provider.versions] };}function environment(root, target) {@@ -304,7 +308,7 @@ function parsePluginDetails(text) {}function verifyClaude(options, root, carrier, dependencies) {- if (command(options, root, ['--version'], dependencies) !== PROVIDERS.claude.versionOutput(options.providerVersion)) {+ if (PROVIDERS.claude.parseVersion(command(options, root, ['--version'], dependencies)) !== options.providerVersion) {throw new Error('Native Claude version changed since verification');}const pluginDir = path.join(root, 'plugin');@@ -403,8 +407,10 @@ function copyCarrier(root, destination, carrier, current) {function providerVersionFor(options, root, dependencies) {const provider = providerFor(options.target);const version = command(options, root, ['--version'], dependencies);- const providerVersion = provider.versions.find(value => version === provider.versionOutput(value));- if (!providerVersion) throw new Error(`Native ${provider.label} version must be exactly ${provider.versions.join(' or ')}`);+ const providerVersion = provider.parseVersion(version);+ if (!providerVersion || !provider.admits(providerVersion)) {+ throw new Error(`Native ${provider.label} version must be ${provider.versions.join(' or ')}`);+ }return providerVersion;}