@shumkov/orchestra 0.11.3 → 0.12.1

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.
@@ -0,0 +1,340 @@
1
+ # SDK pending attribution compatibility correction
2
+
3
+ ## Current release integration — 2026-11-12
4
+
5
+ Published Codex Orchestra0.12.0 base706dab133bb2c696d34a950d8bdd4eebc22f02f5
6
+ is integrated by signed merge e086896 without conflicts or manual source changes.
7
+ All21upstream non-package changed files match that released base byte-for-byte;
8
+ accepted Claude SDK runtime SHA remains unchanged. Prepared aligned pin commit
9
+ f9ef1b8 follows bounded fix0664a00. Fresh main/npm showed0.12.0, so patch0.12.1
10
+ is selected for the reviewed correction and Claude SDK0.3.322/CLI2.1.322 pair.
11
+ The Orchestra publication hold has ended; PR/CI/OIDC release and exact registry
12
+ artifact verification are authorized and in progress. No deployment is performed.
13
+ Polygram consumer merge/version/publication remains held until coordinator supplies
14
+ its released0.46.0 base, then requires actual0.12.1 consumer artifact validation.
15
+ The accepted matrix23/23, existing runtime/focused receipts and strict focused
16
+ INCONCLUSIVE limits remain unchanged; no provider repeat or new gate is needed.
17
+ The coordinator owns staging and both mandatory24hsoaks. Earlier integration-hold
18
+ statements below are historical and superseded by this checkpoint.
19
+
20
+
21
+ ## Publication and integration checkpoint — 2026-11-12
22
+
23
+ Ivan authorized publication and planned rollout. Tracking issue
24
+ [Polygram #133](https://github.com/shumkov/polygram/issues/133) is OPEN; its complete
25
+ body was authoritatively read back and verified. The accepted matched matrix
26
+ remains 23/23 on signed gate 6cceb3b. Bounded runtime correction is signed commit
27
+ 0664a00dea8b1b4fd1f8c3ff803683171b2c69d8, preserving its exact tested source.
28
+ Local SDK 0.3.322 / CLI 2.1.322 pins and generated lock metadata are now prepared
29
+ and independently reviewed CLEAN by compatibility, isolation and scope reviewers.
30
+ Installed candidate entry/package/binary hashes equal the accepted matrix pair.
31
+ Focused local checks: 425 PASS, 0 FAIL, 19 existing capability skips; full corrected
32
+ runtime suite before the pin metadata change: 1,560 PASS, 19 existing skips.
33
+ No new provider call was made. Strict focused traces remain INCONCLUSIVE within
34
+ the accepted limits and no extra provider loop is mandatory.
35
+
36
+ Codex owns Orchestra 0.12.0. Claude release version/tag/main integration waits
37
+ for its authoritative published base; this worker does not deploy. Orchestra's
38
+ package version remains 0.11.3 only as unreleased branch metadata, never a release
39
+ claim. Consumer dependencies remain the coherent .283 pair until the actual
40
+ subsequent Claude Orchestra artifact exists. The existing consumer contract now
41
+ also verifies installed SDK/CLI metadata and shared physical SDK resolution;
42
+ 3/3 checks pass on that current .283 installation. Artifact-backed .322 consumer
43
+ update and independent diff review, Linux rollback preservation and both 24-hour
44
+ soaks remain. Earlier authorization/pin-status statements below describe their
45
+ historical checkpoints and are superseded by this section.
46
+
47
+
48
+ Historical pre-publication status: bounded correction accepted by the coordinator within the limits below.
49
+ Full matched matrix PASS 23/23; retained strict focused probes INCONCLUSIVE.
50
+ Pins remain SDK 0.3.283 / CLI 2.1.283; no publication or activation authorized.
51
+
52
+ ## Coordinator acceptance and retained limits
53
+
54
+ The coordinator accepts this bounded ownership correction on the completed
55
+ 23/23 matched matrix, all three distinct UUID-owned user completions observed on
56
+ both actual SDK/CLI pairs, observed peer/zero events preserving pending owners,
57
+ reviewed retained-shape RED 2 FAIL -> GREEN 2 PASS, the cancellation/drop
58
+ regressions, and independent clean code reviews. The former strict focused
59
+ oracle required unsupported standalone-report/notification-before-zero behavior
60
+ and its overlap holds were denied. Its INCONCLUSIVE verdicts remain unchanged;
61
+ those extra assumptions are not a release gate. No new live scheduling fixture,
62
+ provider query, or instrumentation loop is required or planned for this correction.
63
+ This accepts explicitly limited coverage; downstream delivery and every overlap
64
+ schedule remain unproven. Tracking-issue publication remains the explicit pre-pin
65
+ prerequisite, and pin/consumer reviews, release/activation authority, staging and
66
+ both 24-hour soaks remain. No runtime or package pin changes are made here.
67
+
68
+ ## Final full unit/integration verification
69
+
70
+ Ran the complete package test command once on the final corrected runtime with
71
+ Node 24.4.0: `node --test --test-force-exit --test-concurrency=1 tests/*.test.js`.
72
+ All 34 test files completed: 1,579 tests, 1,560 PASS, 0 FAIL, 19 existing contract
73
+ capability-N/A skips (17 channels-protocol, 2 Codex-capability), 0 cancelled.
74
+ Duration 103.370 seconds, exit 0. Runtime SHA-256 remains
75
+ `c6f61a85acd139a0c524a7726dc5eead02be34480305bcd3fbdde32005c72184`.
76
+ HOME/CODEX_HOME/TMP/tmux/vendor/versions were private synthetic trees, with an
77
+ allowlisted credential-free environment and disabled installer/updater. The suite
78
+ uses fake processes/bridges and local fixtures; no paid queries were repeated.
79
+ No failures required code changes. This is unit/integration proof, not additional
80
+ provider, downstream delivery, persistence, activation or soak proof. Full log,
81
+ command, times and per-skip receipts:
82
+ `/tmp/orchestra-claude-upgrade-research-3agLJs/compatibility-acceptance-full-suite/`.
83
+
84
+
85
+ ## Evidence and current callers
86
+
87
+ The reviewed focused streaming-input fixture ran real SdkProcess in auto mode
88
+ with actual SDK/CLI .322 and the old actual SDK/CLI .283 pair, in isolated
89
+ existing-account contexts. Both combined three synthetic normal send prompts
90
+ into the first response, then routed autonomous report results to later user
91
+ pendings. Candidate additionally emitted the documented success empty result
92
+ with num_turns:0, consuming pending source 3. The first two task_started events
93
+ in the candidate trace are direct background local_agent depth1 tasks. Later
94
+ Bash task events are excluded by the corrected observer; do not rewrite the
95
+ original evidence artifact. No claim that .321 introduced prompt coalescing.
96
+
97
+ Private traces: /tmp/orchestra-claude-upgrade-research-3agLJs/new-sdk-pending-a-artifacts/new-sdk-pending-a
98
+ and old-sdk-pending-a-artifacts/old-sdk-pending-a. The new SDK changelog .321
99
+ explicitly describes queued auto-mode reports sharing a model call, with an
100
+ empty zero-turn result for all but the last report. Both SDK declarations
101
+ already expose coalesced prompt correlation. Official source:
102
+ https://github.com/anthropics/claude-agent-sdk-typescript/blob/main/CHANGELOG.md .
103
+
104
+ SdkProcess.send eagerly pushes every queued prompt; _handleEvent selects the
105
+ FIFO head for all streams and pops it on every result. A peer-origin nonempty
106
+ report and task-notification empty result therefore complete unrelated user
107
+ work. Injection/steering intentionally enter an active turn; normal send and
108
+ those APIs must be considered separately. Blindly ignoring only empty results
109
+ leaves coalescing, nonempty report completion, and streamed-text attribution
110
+ incorrect. The five normal SDK matrix cells do not cover this concurrency.
111
+
112
+ ## Reviewed correction candidate
113
+
114
+ The public Process.send contract is one user turn, one completion; the explicit
115
+ inject/steer APIs perform intentional folds. Serialize only normal sends: retain
116
+ queued prompts in pendingQueue and submit a prompt only on activation. Queue cap
117
+ still drops the oldest waiting pending, whose prompt must never enter SDK input.
118
+ Activation, timer and onActivate behavior remain tied to the active head. Do not
119
+ change auto mode or SDK query lifetime.
120
+
121
+ Stamp each normal submission with crypto.randomUUID(). On retry use a fresh UUID
122
+ and retire the failed attempt's UUID. Echo correlation is supported by BOTH pinned
123
+ and candidate binaries: the provider-free native SDK loopback discovery
124
+ /tmp/orchestra-claude-upgrade-research-3agLJs/sdk-uuid-discovery-results.json
125
+ observed first assistant + result user_message_uuid and user_message_uuids on
126
+ .283/.283, .283/.322, .322/.322, one inference request each against loopback only.
127
+ SDK declarations describe first top-level assistant/partial-frame correlation,
128
+ then result correlation; a batched turn may list multiple consumed UUIDs.
129
+
130
+ Associate assistant/stream events with the active pending only when a supplied
131
+ UUID matches that pending's current submission or intentional active injection.
132
+ Bind to the pending AND physical submission attempt, keeping that binding for
133
+ subsequent unannotated frames until any top-level result. Explicit conflicting
134
+ UUIDs replace/invalidate the binding before partial/thinking early returns.
135
+ Exclude child partials as well as child assistant frames.
136
+ Matching current owned UUIDs take precedence over retired siblings in a consumed
137
+ list, so a legitimate current folded response still completes. Retain cancelled-attempt UUIDs until Query closes; their late frames and
138
+ subsequent unannotated frames are suppressed rather than delivered as autonomous
139
+ user replies. A genuinely unowned first frame, or a frame without a binding after
140
+ the prior result, is autonomous and uses the existing autonomous-assistant-message event even
141
+ while user work waits. Ignore child assistant frames for this binding. Never
142
+ stream unowned output through the head's streamer, reactor or usage counters.
143
+ An unannotated success cannot complete a pending unless its turn was already
144
+ bound by an assistant/partial echo. Explicit unmatched UUID or non-human origin
145
+ without a matching UUID is autonomous, including nonempty peer reports and empty
146
+ zero-turn results. Matching owned UUID takes precedence over peer origin when
147
+ an intentional user injection folds into a synthetic report turn. A bare error without echo or an existing bound turn cannot complete a user
148
+ pending: SDK documents singular UUID echo even for delivery failures (only the
149
+ plural list may be omitted). Terminal iterator failure still fails the session
150
+ and rejects pending work through the existing session-failure path. Unknown uncorrelated success fails closed
151
+ (wait for matching response or existing timeout), rather than guessing ownership.
152
+
153
+ Stamp steer/inject submissions too, associate them with the current active head
154
+ without submitting waiting normal sends; preserve priorities/shouldQuery and
155
+ bubble behavior. A fireUserMessage has its own unowned UUID and stays fire-and-
156
+ forget, never consuming an unrelated normal pending. Standalone steer/inject
157
+ remains autonomous. No public method signature or result shape changes.
158
+
159
+ Retry/drop/timeout/interrupt/drain requirements: a retry submits only its active
160
+ head; queue drops match input UUID rather than removing arbitrary waiting work;
161
+ input push failures settle the right pending and activate its successor. Timed
162
+ out/drained submission UUIDs cannot settle new work. Clear binding on retry
163
+ retirement, timeout, drain, reset and close. Timers and rejection codes stay unchanged. Track the physical submitted normal
164
+ attempt separately from the logical pending queue. After timeout, wait for the
165
+ existing Query.interrupt control acknowledgment before submitting the successor;
166
+ a matching terminal result may retire the attempt but does not bypass an in-flight
167
+ interrupt acknowledgment. Read the supported interrupt receipt: intersect
168
+ still_queued with submitted owned UUIDs and keep a survivor barrier until each
169
+ has a correlated terminal result or proven cancellation. Unknown internal UUIDs
170
+ are ignored. An acknowledgment with no receipt is insufficient to retire a
171
+ submitted attempt: wait for its terminal result. Never invoke undocumented
172
+ cancelAsyncMessage or cancel unrelated autonomous task notifications. A rejected interrupt fails waiting work through the
173
+ session failure path rather than blindly resubmitting into uncertain state.
174
+ Drain stays synchronous and does not invent an interrupt: it removes logical
175
+ work and buffered input. If its submitted input already reached SDK, future normal
176
+ sends wait for that physical result OR a caller interrupt receipt proving no owned UUID survives. Thus interrupt+drain remains reusable; drain alone lets existing SDK
177
+ work finish without coalescing a successor. An input removed before SDK consumed
178
+ it needs no physical-turn barrier. onActivate/timers begin only on submission. interrupt continues to signal Query.interrupt; drain rejects all
179
+ queued work while leaving the session reusable. Remove any not-yet-yielded
180
+ owned input by UUID on rejection/drain; preserve makeInputController.close()
181
+ semantics for unrelated callers. Do not submit rejected waiting
182
+ prompts later. Retain existing first-stream/onActivate and autonomous delivery
183
+ callbacks, including legitimate report text while another request is pending.
184
+
185
+ Alternatives rejected: only skip zero-turn results (nonempty reports still
186
+ misroute); only correlate eager submissions (one user request could still merge
187
+ with another); disable auto or discard reports (changes product behavior);
188
+ buffer every user stream until result (unnecessary latency with verified echoes).
189
+ Public streaming for supported .283/.322 remains live. Missing correlation is
190
+ explicitly inconclusive instead of silently attaching text to a different user.
191
+
192
+ ## Background MCP gate amendment candidate
193
+
194
+ The crossed old-SDK/new-CLI experiment remains FAIL and immutable. SDK .319 added
195
+ MCP-task support in SDK sessions; its absence in .283 may explain the failedtask
196
+ but exact transport cause is not proven. Shipped validation needs matched SDK/CLI
197
+ pairs with imported SDK identity + exact CLI identity attested before launch.
198
+ No production lib/ consumer in either repository reads membership/task edge
199
+ ordering; production does consume SDK results and remains subject to the separate
200
+ ownership correction above.
201
+
202
+ Official pinned SDK .292 changelog explicitly changes finishing membership to
203
+ AFTER task_updated and task_notification. The .322 type states snapshot-vs-edge
204
+ ordering unspecified. Current documented actual matched .322 trace has exactly
205
+ two successful, non-error results, the second a task-notification turn with
206
+ origin.runId equal to the task run_id. Results are per turn, not per Query.
207
+ Sources: https://github.com/anthropics/claude-agent-sdk-typescript/blob/v0.3.322/CHANGELOG.md#03292
208
+ and https://code.claude.com/docs/en/agent-sdk/typescript#sdkbackgroundtaskschangedmessage .
209
+
210
+ Proposed exact manifest-bound .322/.322 policy: retain every tool/task count,
211
+ identity, timing, marker uniqueness and membership list/clear check; require
212
+ completed update < completed notification < empty membership < marker. Correlate
213
+ nonempty run_id across membership/start/update/notification and followup result
214
+ origin.runId, with matching session. Require exactly two successful non-error
215
+ results: initial turn, then correlated task-notification completion after marker.
216
+ Unknown/missing SDK/CLI identity cannot select this policy. Keep the old pair's
217
+ existing policy and raw-source regeneration, reject every failed/stopped task,
218
+ extra/missing result, wrong run/session, duplicate marker/clear/notification and
219
+ mutated raw bytes. This is a documented version-specific oracle, not a waiver.
220
+
221
+ A gate implementation needs independent review of exact per-side SDK resolution.
222
+ Prefer literal matched-pair execution using an explicit Node resolution hook that
223
+ redirects ONLY the SDK package to predownloaded, integrity-verified exact SDK
224
+ roots, leaving the checked gate source identical on both sides; attest imported
225
+ SDK and its claudeCodeVersion. Alternative: stage two identical source prefixes
226
+ with different SDKs and attest every source hash; more copying and stale-source
227
+ risk. Holding SDK .322 constant on both sides is simpler but adds a second axis
228
+ to the old baseline and should be supplemental rather than relabeled matched.
229
+ The amended complete accepted matrix must pass on one recorded gate commit.
230
+ No gate runtime change is made until its resolution mechanism is independently
231
+ reviewed and the coordinator receives the exact proposed amendment.
232
+
233
+ ## Verification and scope boundary
234
+
235
+ Retain the existing explicit peer-result and task-notification-result RED spike.
236
+ Add deterministic RED cases for queued prompt coalescing/overflow leakage, stream
237
+ ownership and stale UUIDs after timeout/drain. GREEN must cover owned echoes,
238
+ nonempty peer reports, zero-turn reports, matching folded injection, independent
239
+ fire-and-forget output, retries, input drop/failure, queue limits, timeouts and
240
+ interrupt/drain reuse. Update fake events to model genuine SDK echo fields rather
241
+ than weakening the runtime to satisfy metadata-free success fixtures. Tests for
242
+ missing correlation must remain explicit and prove no false user completion.
243
+
244
+ After independent design reviews, implement only this bounded runtime correction,
245
+ obtain independent code reviews, then run the corrected focused real-SDK fixture
246
+ on both matched pairs and actual-new-SDK background lifecycle checks. Provider
247
+ runs keep existing deadlines/turn limits and isolated accounts. Preserve all
248
+ failed b796 evidence and do not repeat unaffected suites until full matrix is
249
+ required. All changes remain uncommitted for coordinator integration, except an
250
+ explicitly required recorded gate commit coordinated later. Publication, pins,
251
+ release, production activation and 24-hour soaks remain separate unmet gates.
252
+
253
+ ## Implemented checkpoint (2026-11-12)
254
+
255
+ The bounded correction above is implemented without changing runtime pins or
256
+ public method signatures. Three independent final code reviews are CLEAN after
257
+ concrete cancellation/drop findings were reproduced RED then fixed. Retained
258
+ focused verification: 104 PASS/0 skipped ownership and SDK tests; process-contract
259
+ verification 65 PASS/19 capability-inapplicable skips; matched gate suite 89
260
+ PASS/0 skipped, followed only by affected observer tests (12 PASS/0 skipped).
261
+ Receipts and red/green logs live under
262
+ `/tmp/orchestra-claude-upgrade-research-3agLJs`.
263
+
264
+ The Polygram child records the actual-pair gate source at signed commit
265
+ `e1870e26220746c2503cec7d660538b1bd18b49e`, with exact per-side SDK identities and
266
+ Orchestra runtime SHA-256
267
+ `c6f61a85acd139a0c524a7726dc5eead02be34480305bcd3fbdde32005c72184`.
268
+ The implementation uses the reviewed SDK-only Node resolution hook and private
269
+ load receipts, independently rehashes the selected SDK and actual imported
270
+ Orchestra runtime after each child, and validates those receipts at acceptance.
271
+ The immutable b796 crossed-pair failure remains separate.
272
+
273
+ Corrected old-pair provider probe `own-old-d` completed with correct ownership of
274
+ all three user markers, two completed task notifications, a task-correlated peer
275
+ report while follow-ups remained unchanged, and no provider error. It is
276
+ INCONCLUSIVE: the second autonomous terminal report has task-notification origin
277
+ but no run ID, so it cannot satisfy the retained distinct-task report oracle.
278
+ Do not weaken that oracle or call this a PASS. Candidate proof and the complete
279
+ recorded matched matrix are pending at this checkpoint. No new runtime subsystem
280
+ or wider queue refactor is proposed to work around an observation limitation.
281
+
282
+ ## Bounded retained-trace replay amendment
283
+
284
+ Independent final trace review found that auto permission denied the standalone
285
+ parent `sleep 30` and the follow-up hold in BOTH final traces; agent sleeps did
286
+ run. Therefore these calls prove observed stream ownership only, not the intended
287
+ 30-second hold schedule. No unchanged paid retry or permission bypass is planned.
288
+ The strict focused oracle remains INCONCLUSIVE and the complete scheduled matrix
289
+ remains unchanged on e1870e2. UUID-owned results and per-turn SDK semantics do not
290
+ promise one separate autonomous terminal per agent or two completed notification
291
+ edges before every zero-turn result; those are stronger fixture observations.
292
+
293
+ Add only a provider-free regression replay in the existing ownership test file,
294
+ using sanitized minimal shapes from old-d and new-d. Replay first UUID-owned user
295
+ completion, queue user2/3, and preserve two separate sequences. Old: peer terminal ->
296
+ normal2 completion -> runless task-notification terminal -> normal3 completion.
297
+ Candidate: first completed notification -> peer/zero-turn terminals -> second
298
+ completed notification -> normal2/3 completions. Assert that autonomous text
299
+ remains delivered and each report terminal leaves its then-current pending
300
+ owners unchanged ([2,3] for the early peer/zero, [3] for the old late report),
301
+ only normal2 submits before its completion, and all3correct
302
+ markers complete their own request. Preserve origin/UUID/list/num_turns fields
303
+ and observed ordering; replace synthetic IDs/text with stable fixture placeholders
304
+ and dynamically supplied submitted UUIDs only. This is regression proof for the
305
+ observed ownership shapes, not provider scheduling/hold coverage or focused PASS.
306
+ Run against a separate temporary copy of the old runtime to retain RED without
307
+ overwriting dirty source, then run the corrected source GREEN. No production or
308
+ gate source changes and no new runtime behavior are in scope for this amendment.
309
+
310
+ The replay amendment and actual code received independent compatibility/scope
311
+ reviews. Findings corrected the separate old/new order and removed invented
312
+ assistant origin metadata; only terminal results carry observed origin. The two
313
+ final tests fail against a temporary unchanged original runtime (3 SDK inputs
314
+ instead of2), then pass against corrected source (2PASS/0skip). Logs:
315
+ `pending-retained-replay-reviewed-red.log` and `pending-retained-replay-reviewed-green.log`.
316
+ Both final reviewers CLEAN. This adds no runtime/gate behavior and does not change
317
+ INCONCLUSIVE provider receipts, hold-schedule or downstream proof limitations.
318
+
319
+ ## Historical matched matrix checkpoint
320
+
321
+ The first actual-pair e1870e2 matrix is FAIL14PASS/1BLOCKED/8not-run. Candidate
322
+ background task, exact marker and independent raw/native/SDK/source checks pass;
323
+ the runner then incorrectly demands matching old evidence for the manifest's
324
+ explicitly waived old opt-in cell. A small reviewed comparison decision fixes
325
+ planning, execution and retained acceptance consistently without adding waivers
326
+ or weakening any per-cell oracle. Concrete RED true-versus-false plan assertion,
327
+ GREEN15focused checks/0skip and3final independent CLEAN reviews are retained.
328
+ Corrected signed gate commit6cceb3b3544f4efc74330c82f0557d7f1bfb31d6 records that
329
+ source; a new complete unfiltered matrix m-6cce-a is in flight. Old e187 and b796
330
+ failures remain immutable. No runtime or manifest identity changed for this fix.
331
+
332
+ Final readback: matched matrix m-6cce-a on signed6cceb3b completed23/23PASS,
333
+ 0FAIL/0BLOCKED/0NOT-APPLICABLE at2026-11-12T11:52:23.130Z after854.631s.
334
+ All23SDKload receipts bind exact old/newSDKs and unchanged corrected runtimeSHA.
335
+ This closes the full scheduled matched matrix requirement. Under the coordinator
336
+ acceptance above, the bounded local correction is accepted; the strict focused
337
+ provider receipts remain INCONCLUSIVE; preserved raw traces and reviewed local
338
+ replay prove observed ownership shapes, not intended sleep scheduling/downstream
339
+ provider delivery. No unchanged retry or runtime expansion is proposed. Issue is
340
+ still unpublished; pins/consumer update/release/staging24h/CLI24h remain separate.
@@ -2,6 +2,11 @@
2
2
 
3
3
  Date: 2026-07-26
4
4
 
5
+ This is historical 0.145.0 evidence. The unactivated 0.167.2 candidate,
6
+ independent gates and remaining blockers are recorded in
7
+ [the upgrade spec](CODEX_RUNTIME_UPGRADE_SPEC.md) and
8
+ [the upgrade report](CODEX_RUNTIME_UPGRADE_REPORT.md).
9
+
5
10
  Scope: U1a core protocol, steering, healthy stop, isolation, accepted
6
11
  native-beta containment contract, and U1b operational/security
7
12
  characterization
package/lib/claude-bin.js CHANGED
@@ -13,7 +13,7 @@ const { createRequire } = require('module');
13
13
  // package.json: that SDK's platform package supplies the vendored binary, and
14
14
  // a unit test fails when the two drift apart. It stays a literal because
15
15
  // consumers that omit optional dependencies have no SDK to derive it from.
16
- const CLAUDE_CLI_PINNED_VERSION = '2.1.283';
16
+ const CLAUDE_CLI_PINNED_VERSION = '2.1.322';
17
17
 
18
18
  /**
19
19
  * Resolve + verify the pinned claude CLI binary.
@@ -13,6 +13,10 @@ const os = require('node:os');
13
13
  const path = require('node:path');
14
14
  const { StringDecoder } = require('node:string_decoder');
15
15
  const { promisify } = require('node:util');
16
+ const { attestRuntimeCompanion, assertRuntimeCompanion } = require('./runtime-companion');
17
+
18
+ const COMPANION_ATTESTATIONS = new WeakMap();
19
+ const CLIENT_COMPANIONS = new WeakMap();
16
20
 
17
21
  function deepFreeze(value) {
18
22
  if (!value || typeof value !== 'object' || Object.isFrozen(value)) return value;
@@ -129,17 +133,19 @@ const HOOK_METADATA_REQUIRED_FIELDS = Object.freeze([
129
133
  'timeoutSec',
130
134
  'trustStatus',
131
135
  ]);
132
- // All five are reported on every entry; four of them always null. A missing or
136
+ // Nullable local-hook metadata is reported on every entry. A missing or
133
137
  // populated one means the reported shape is not the shape this pin was built
134
138
  // against, which is a refusal rather than something to interpret.
135
139
  const HOOK_METADATA_NULL_OPTIONAL_FIELDS = Object.freeze([
136
140
  'additionalContextLimit',
137
141
  'matcher',
142
+ 'environmentId',
138
143
  'pluginId',
139
144
  'statusMessage',
140
145
  ]);
141
146
  const HOOK_METADATA_FIELDS = Object.freeze([
142
147
  ...HOOK_METADATA_REQUIRED_FIELDS,
148
+ 'async',
143
149
  ...HOOK_METADATA_NULL_OPTIONAL_FIELDS,
144
150
  'command',
145
151
  ]);
@@ -527,13 +533,18 @@ async function attestPinnedCodexBinary(
527
533
  'CODEX_BINARY_MISMATCH',
528
534
  );
529
535
  }
530
- return {
536
+ const companion = await attestRuntimeCompanion(
537
+ binary, protocolSchema.codeModeHostSha256ByTarget[targetReceipt.target],
538
+ );
539
+ const attestation = {
531
540
  path: binary,
532
541
  target: targetReceipt.target,
533
542
  sha256,
534
543
  version: stdout.trim(),
535
544
  fingerprint,
536
545
  };
546
+ COMPANION_ATTESTATIONS.set(attestation, companion);
547
+ return attestation;
537
548
  }
538
549
 
539
550
  async function characterizePinnedSessionLauncher(launcher) {
@@ -1599,12 +1610,20 @@ function projectRpcResult(method, value, ownedCwd) {
1599
1610
  'plus',
1600
1611
  'pro',
1601
1612
  'prolite',
1613
+ 'promax',
1602
1614
  'team',
1615
+ 'self_serve_business_prolite',
1603
1616
  'self_serve_business_usage_based',
1604
1617
  'business',
1618
+ 'ent26',
1619
+ 'enterprise_cbp_automation',
1605
1620
  'enterprise_cbp_usage_based',
1606
1621
  'enterprise',
1607
1622
  'edu',
1623
+ 'edu_plus',
1624
+ 'edu_pro',
1625
+ 'sci',
1626
+ 'sci_plus',
1608
1627
  'unknown',
1609
1628
  ].includes(planType)) {
1610
1629
  throw new CodexAppServerError(
@@ -1939,7 +1958,8 @@ function hookEntryMatches(hook, descriptor, expectedTrustStatus) {
1939
1958
  if (hook[field] !== null) return false;
1940
1959
  }
1941
1960
  if (
1942
- typeof hook.command !== 'string'
1961
+ hook.async !== false
1962
+ || typeof hook.command !== 'string'
1943
1963
  || createHash('sha256').update(hook.command).digest('hex')
1944
1964
  !== descriptor.commandSha256
1945
1965
  ) return false;
@@ -2661,6 +2681,11 @@ class CodexAppServerClient extends EventEmitter {
2661
2681
  'CODEX_CLIENT_CLOSED',
2662
2682
  );
2663
2683
  }
2684
+ const companion = COMPANION_ATTESTATIONS.get(attestation);
2685
+ if (companion) {
2686
+ assertRuntimeCompanion(companion);
2687
+ CLIENT_COMPANIONS.set(this, companion);
2688
+ }
2664
2689
  this.child = this.spawnFn(command, commandArgs, {
2665
2690
  cwd: this.cwd,
2666
2691
  env: this.env,
@@ -2720,6 +2745,7 @@ class CodexAppServerClient extends EventEmitter {
2720
2745
  'CODEX_CONFIG_MISMATCH',
2721
2746
  );
2722
2747
  }
2748
+ if (companion) assertRuntimeCompanion(companion);
2723
2749
  this.state = 'initializing';
2724
2750
  const result = await dispatchRequest(this, 'initialize', {
2725
2751
  clientInfo: {
@@ -2844,6 +2870,8 @@ class CodexAppServerClient extends EventEmitter {
2844
2870
  if (params !== undefined) message.params = params;
2845
2871
  const line = this._serializeMessage(message);
2846
2872
  if (pending.stateChanging) {
2873
+ const companion = CLIENT_COMPANIONS.get(this);
2874
+ if (companion) assertRuntimeCompanion(companion);
2847
2875
  const controller = new AbortController();
2848
2876
  pending.sinkController = controller;
2849
2877
  try {
@@ -2867,6 +2895,7 @@ class CodexAppServerClient extends EventEmitter {
2867
2895
  }
2868
2896
  }
2869
2897
  if (this.pending.get(pending.id) !== pending) return;
2898
+ if (companion) assertRuntimeCompanion(companion);
2870
2899
  pending.writeAttempted = true;
2871
2900
  }
2872
2901
  await this._writeLine(line);
@@ -443,27 +443,30 @@ function normalizeExpectedProfile(value) {
443
443
 
444
444
  function assertExpectedPolicy(profile) {
445
445
  const config = plainObject(profile.expectedConfig, 'expected config projection');
446
+ const trusted = profile.permissionProfileId === 'polygram-trusted';
447
+ const expectedProviders = config.modelProvider === 'cliproxyapi'
448
+ ? { count: 1, keySha256: [digest('cliproxyapi')] }
449
+ : { count: 0, keySha256: [] };
446
450
  if (
447
451
  config.sha256 !== profile.expectedConfigSha256
448
- || config.modelProvider !== 'openai'
452
+ || !['openai', 'cliproxyapi'].includes(config.modelProvider)
449
453
  || config.defaultPermissions !== profile.permissionProfileId
450
454
  || config.approvalPolicy !== 'never'
451
455
  || config.approvalsReviewer !== 'user'
452
- || config.webSearch !== 'disabled'
456
+ || config.webSearch !== (trusted ? 'live' : 'disabled')
453
457
  || config.allowLoginShell !== false
454
458
  || config.shellEnvironmentInherit !== 'none'
455
459
  || config.mcpServers?.count !== 0
456
460
  || config.mcpServers?.keySha256?.length !== 0
457
461
  || config.plugins?.count !== 0
458
462
  || config.plugins?.keySha256?.length !== 0
459
- || config.modelProviders?.count !== 0
460
- || config.modelProviders?.keySha256?.length !== 0
461
463
  ) {
462
464
  throw new CodexPreflightError(
463
- 'Codex expected policy is outside the native beta contract',
465
+ 'Codex expected policy is outside the supported static policies',
464
466
  'CODEX_STATIC_PROFILE_MISMATCH',
465
467
  );
466
468
  }
469
+ exact(config.modelProviders, expectedProviders, 'model providers');
467
470
  if (!Array.isArray(config.permissionProfiles)) {
468
471
  throw new TypeError(
469
472
  'Codex preflight expected config permission profiles must be an array',
@@ -479,14 +482,25 @@ function assertExpectedPolicy(profile) {
479
482
  configured.length !== 1
480
483
  || listed.length !== 1
481
484
  || configured[0].extends !== null
482
- || configured[0].networkEnabled !== false
485
+ || configured[0].networkEnabled !== trusted
483
486
  || listed[0].allowed !== true
484
487
  ) {
485
488
  throw new CodexPreflightError(
486
- 'Codex expected permission profile is not uniquely allowed and isolated',
489
+ 'Codex expected permission profile is not uniquely allowed with the required network policy',
487
490
  'CODEX_STATIC_PROFILE_MISMATCH',
488
491
  );
489
492
  }
493
+ if (trusted) {
494
+ exact(configured[0].filesystem, [{
495
+ rootSha256: digest(':root'),
496
+ access: 'write',
497
+ }], 'trusted filesystem');
498
+ exact(
499
+ configured[0].filesystemSha256,
500
+ digest({ glob_scan_max_depth: null, ':root': 'write' }),
501
+ 'trusted filesystem digest',
502
+ );
503
+ }
490
504
  }
491
505
 
492
506
  function paginationCursor(value) {
@@ -1,11 +1,11 @@
1
1
  {
2
- "cliVersion": "codex-cli 0.145.0",
3
- "binarySha256": "1da3f4e0e96028b8a771814293c3033dafd1971f943f6c7e79b0897fe705f590",
2
+ "cliVersion": "codex-cli 0.167.2",
3
+ "binarySha256": "97bc82fd46f117cf10efb95e6ff0c81dc4784f5797bcdc2cb75093ba09e4def0",
4
4
  "binarySha256ByTarget": {
5
- "aarch64-apple-darwin": "1da3f4e0e96028b8a771814293c3033dafd1971f943f6c7e79b0897fe705f590",
6
- "x86_64-unknown-linux-musl": "a2a05dafaa1acb002a45eaec0a462de5b13694fcfcd7bc43305f14781ce7be14"
5
+ "aarch64-apple-darwin": "97bc82fd46f117cf10efb95e6ff0c81dc4784f5797bcdc2cb75093ba09e4def0",
6
+ "x86_64-unknown-linux-musl": "a9672d0fa0dd8fcf8cad136fa0d056b914bc046f5ac3d78f4a5cf390655af56b"
7
7
  },
8
- "generatedProtocolV2CanonicalSha256": "1bc09dedc506075562d4d49b702ecab6d947dd5a8c2a9014a5cde592a0938efb",
8
+ "generatedProtocolV2CanonicalSha256": "ca9811bd8310c9576f2acc1c37ba132afeef49c0cdbc3e02908b64ad12126163",
9
9
  "requestIdTypes": [
10
10
  "integer",
11
11
  "string"
@@ -172,7 +172,10 @@
172
172
  "configWarning",
173
173
  "account/rateLimits/updated",
174
174
  "remoteControl/status/changed",
175
- "mcpServer/startupStatus/updated"
175
+ "mcpServer/startupStatus/updated",
176
+ "thread/readState/changed",
177
+ "account/updated",
178
+ "turn/moderationMetadata"
176
179
  ],
177
180
  "deniedServerRequests": {
178
181
  "item/commandExecution/requestApproval": {
@@ -247,5 +250,9 @@
247
250
  "no active turn to interrupt"
248
251
  ]
249
252
  },
250
- "provenance": "Curated positive production subset derived from the pinned experimental v2 schema; the canonical generated bundle hash is verified by the U1 compatibility gate."
253
+ "provenance": "Curated positive production subset derived from the pinned experimental v2 schema; candidate canonical/raw schema hashes are independently regenerated by codex-runtime-schema-probe.mjs; historical U1 fixtures remain versioned.",
254
+ "codeModeHostSha256ByTarget": {
255
+ "aarch64-apple-darwin": "45acdb759c3ac0a6b30a5107329b364b7ac1579f2cdf270997f03bc8d6365ef6",
256
+ "x86_64-unknown-linux-musl": "007c62795a7215c27ee85486ecb95e714b33118a2d18c6d7b09b0d9793c72ff4"
257
+ }
251
258
  }
@@ -0,0 +1,66 @@
1
+ 'use strict';
2
+
3
+ const { createHash } = require('node:crypto');
4
+ const { createReadStream, lstatSync, realpathSync } = require('node:fs');
5
+ const path = require('node:path');
6
+
7
+ function mismatch() {
8
+ return Object.assign(new Error('pinned Codex code-mode companion or selection layout changed'), {
9
+ code: 'CODEX_BINARY_MISMATCH',
10
+ });
11
+ }
12
+
13
+ function absent(file) {
14
+ try { lstatSync(file); throw mismatch(); } catch (error) {
15
+ if (error.code !== 'ENOENT') throw error;
16
+ }
17
+ }
18
+
19
+ function fingerprint(binary) {
20
+ const dir = path.dirname(binary);
21
+ if (path.basename(dir) === 'codex-resources'
22
+ || (path.basename(dir) === 'MacOS' && path.basename(path.dirname(dir)) === 'Contents'
23
+ && path.basename(path.dirname(path.dirname(dir))) === 'CodexCLI.app')) throw mismatch();
24
+ // Upstream prefers packaged resources over the standalone sibling. Only the
25
+ // standalone layout is admitted, so later metadata cannot redirect execution.
26
+ absent(path.join(dir, 'codex-resources'));
27
+ absent(path.join(dir, 'codex-package.json'));
28
+ if (path.basename(dir) === 'bin') {
29
+ absent(path.join(path.dirname(dir), 'codex-package.json'));
30
+ absent(path.join(path.dirname(dir), 'codex-resources'));
31
+ }
32
+ const helper = path.join(dir, 'codex-code-mode-host');
33
+ if (realpathSync(helper) !== helper) throw mismatch();
34
+ let component = path.parse(helper).root;
35
+ for (const part of helper.slice(component.length).split(path.sep).filter(Boolean)) {
36
+ component = path.join(component, part);
37
+ const stat = lstatSync(component);
38
+ if (stat.isSymbolicLink() || ![0, process.getuid?.()].includes(stat.uid)
39
+ || (stat.mode & 0o022) !== 0) throw mismatch();
40
+ }
41
+ const stat = lstatSync(helper, { bigint: true });
42
+ if (!stat.isFile() || stat.nlink !== 1n || (stat.mode & 0o111n) === 0n) throw mismatch();
43
+ return {
44
+ path: helper,
45
+ identity: ['dev', 'ino', 'size', 'mtimeNs', 'ctimeNs', 'mode', 'uid', 'nlink']
46
+ .map(key => stat[key].toString()).join(':'),
47
+ };
48
+ }
49
+
50
+ async function attestRuntimeCompanion(binary, sha256) {
51
+ try {
52
+ const before = fingerprint(binary);
53
+ const hash = createHash('sha256');
54
+ for await (const chunk of createReadStream(before.path)) hash.update(chunk);
55
+ if (hash.digest('hex') !== sha256 || fingerprint(binary).identity !== before.identity) throw mismatch();
56
+ return Object.freeze({ binary, path: before.path, sha256, identity: before.identity });
57
+ } catch { throw mismatch(); }
58
+ }
59
+
60
+ function assertRuntimeCompanion(binding) {
61
+ try {
62
+ if (fingerprint(binding.binary).identity !== binding.identity) throw mismatch();
63
+ } catch { throw mismatch(); }
64
+ }
65
+
66
+ module.exports = { attestRuntimeCompanion, assertRuntimeCompanion };