Skip to content

test(experiments): reconcile the Pi schema offline fixture with the host relay - #4037

Merged
schlessera merged 5 commits into
mainfrom
test/4031-pi-schema-relay-credential
Nov 16, 2026
Merged

schlessera merged 5 commits into
mainfrom
test/4031-pi-schema-relay-credential

Conversation

@schlessera

@schlessera schlessera commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Closes #4031
Closes #3888

Supersedes draft #4032, whose anchor-repair commit this branch carries unchanged.

What changed

  • experiments: the Pi schema measurement's source patches no longer find their anchors in run-session and worker-session #3888, the anchor repair from test(experiments): re-anchor Pi schema measurement patches #4032. The Pi schema measurement preload patches the hosted prompt in backend-entry.ts, the prepared prompt in worker-session.ts, the launch arguments and environment in worker-launch.ts, and receipt interception in worker-reader.ts. Its load filter names exactly those files plus bridge-tools.ts.
  • experiments: Pi schema offline fixture does not provision host relay credentials #4031, the host relay credential. The host inference relay now resolves a turn's credential from pi's auth store (preparePiHostInference, packages/ui-backend-pi/src/host-inference.ts:243-295) before the worker launches. scripts/pi-schema-offline-preload.ts now writes the fixture's existing fictional Codex identity (nativeCredential()) into the fresh PI_CODING_AGENT_DIR/auth.json. It does this on the host side only, with wx and mode 0600, and refuses when that directory is unset or already holds a store. The worker still gets the same fictional identity through its BRAIN_MEASURE_* environment and the measurement model runtime, so the fake transport and bearerMatchesNativeAccess receipts are unchanged.
  • A sixth drifted anchor, found once the relay passed. The worker preload's extensionFactories: [ anchor in session-resources.ts had drifted. More importantly, the managed worker now refuses any loaded Pi extension as uncollected input (unqualifiedResources, packages/ui-backend-pi/src/native-session-runtime.ts:134-137), so the measurement's inline guard extension would fail every turn with Input collection is not qualified for this runtime configuration, even on a namespace-enabled host. The guard is now measurementToolSafety. It wraps the worker's host tool-safety hook at both installPiToolSafety(...) sites in native-session-runtime.ts, with the same admission policy and tool-admission.jsonl receipt. A denied call records its reason as the host result, as Pi's blocked-extension path did. The guard's unit test now drives the wrapper and keeps its assertions. scripts/pi-schema-protocol.md describes both changes.

Product code and the table assertions are unchanged. The fixture stays keyless and offline, and no real credential is used.

Proof

All runtime receipts below come from a namespace-enabled rootless container on this host, because the host itself refuses unshare -Ur. The container ran with --network none, seccomp and AppArmor unconfined, and SYS_ADMIN/NET_ADMIN for the tier's own bwrap preflight. It used Bun 1.4.4, with the worktree and its git dir mounted.

  • Failing first, base plus test(experiments): re-anchor Pi schema measurement patches #4032 only: real Pi/server flat/accepted fails with BACKEND_REQUEST_ERROR: This pi turn cannot run on the host inference relay: pi has no credential for openai-codex. There is no native request.
  • Credential only, guard still an extension: the run gets past the relay, then fails with Measurement source anchor drift. from pi-schema-worker-preload.ts (the extensionFactories anchor). Repairing only that anchor gives BACKEND_ERROR: Input collection is not qualified for this runtime configuration, in the container as on the host.
  • After the fix: bun run test ./experiments/pi-schema-measurement.test.ts gives 27 pass, 0 fail, including all 19 real Pi/server table cases.
  • Mutation 1, host fixture credential removed (provisioning block disabled): flat/accepted, shared/billing-header and shared/binary-error all fail with the relay refusal and No native request, before provider dispatch. The billing case fails at its existing JSON.parse of the physical receipts, and binary-error at its existing result.json read. Restored.
  • Mutation 2, guard wrapper removed (replacement keeps options.toolSafety): shared/tool-guard fails with ENOENT on receipts/tool-admission.jsonl (test line 193). Restored.
  • Mutation 3, new product anchor drifted (installPiToolSafety(session.agent, options.toolSafety, with a space, in native-session-runtime.ts): flat/accepted fails with Measurement source anchor drift. Restored. git diff on product source is empty.
  • From test(experiments): re-anchor Pi schema measurement patches #4032: each of the five re-anchored product strings, changed independently, failed flat/accepted with Measurement source anchor drift.
  • bun run build passed. bun run check:pr --base origin/main passed all five selected checks at this head (receipt below).
  • Refresh after merging main 849751e42: candidate verify failed strict typecheck in the guard test (TS2554/TS2769, lines 108–113). The test's fake host declared a parameterless permission(), which narrowed the wrapper's inferred type. Commit de5e282c1 types the fake as the real hook signature. The focused check:pr does not select strict typecheck, so I ran it on its own: root tsc --noEmit (bun run typecheck, NODE_OPTIONS=--max-old-space-size=8192, since the default heap aborts here) passes. bun run build passes. The Pi schema file is 27/27 again in the namespace-enabled container on the merged tree.
  • Experiment tier: bun run test:experiments after bun run build, in the same container at this head: 355 pass, 8 fail across 38 files, so no tier receipt is written. experiments/pi-schema-measurement.test.ts is 27/27. The 8 failures are in files this PR does not touch, and each is tracked: citations docs: reconcile accumulated citation drift before the next release #3626 (release check), measure-suggestions experiments: measure-suggestions still pins the suggestions rule at 336 characters after #3525 lengthened it #3889, turn-surface capture and overlap test: turn-surface capture and overlap retain stale deferred core inventories #4003 (3 cases), live collector experiments: the turn-surface live collector refuses every routed arm once the bridge roster passes the 64-entry catalogue bound #3886, runtime placement test: offline runtime placement probe exits before producing its receipt #4005, Git read qualification experiments: Git read qualification expects resolve after synchronous revision refusal #4033. Before this PR the same tier had 27 failures: these 8 plus the 19 Pi cases.
{"version":1,"kind":"brain-check-pr-receipt","head":"de5e282c141dc2034425ac7a120d0e40b7b0fb84","base":"origin/main","mode":"focused","startedAt":"2026-11-16T00:09:45.700Z","finishedAt":"2026-11-16T00:11:15.012Z","checks":[{"name":"all lint and leakage gates","categories":["changeset"],"outcome":"passed","elapsedMs":12605.65628},{"name":"environment documentation","categories":["changeset"],"outcome":"passed","elapsedMs":110.94743300000118},{"name":"pending changeset package names","categories":["changeset"],"outcome":"passed","elapsedMs":88.32112799999959},{"name":"contribution changeset","categories":["changeset"],"outcome":"passed","elapsedMs":19.395300000000134},{"name":"affected fast invariants","categories":["verify","unit"],"outcome":"passed","elapsedMs":76470.899074}]}

Collisions (bun scripts/collisions.ts --json --pr 4037 at head 9da07b14d, before the refresh): no path collisions. There are shared proof-closure overlaps only, with open PRs #3054, #3056, #3059, #3069, #3116, #3437, #3581, #3622, #3806, #4002, #4008, #4018, #4022, #4024, #4028, #4030, #4034, #4035 and #4036. Superseded #4032 is closed.

Checklist

  • Focused local preflight/behavioral receipts and complete selected hosted proof passed; actual head/base/job checkout evidence is in Proof.
  • Acceptance criteria from the issue are all met, or the gap is named below.
  • The PR and completed/advanced issues have verified release milestones under docs/process/github.md.
  • A changeset is included, or this changes nothing a consumer can see.
  • No personal data anywhere in the diff — the leakage gate covers the whole tree.
  • The integration contract index or relevant component is updated in this same commit, or nothing in the machine surface moved.
  • Docs under docs/ reflect the change, or nothing documented moved.
  • A fail-closed guard added or changed answers the proportionate-containment checklist in this body, or no guard changed.
  • Provider history stays append-only: nothing on a product turn's path changed.

Anything left open

No consumer changeset: this is measurement-only instrumentation. The provider-enabled runner (#1838) will also need a host credential for the relay; that stays in its scope. Hosted selected proof runs at candidate confirmation.

🤖 Generated with Claude Code

schlessera and others added 3 commits November 15, 2026 19:33
…ntial (#4031)

The host inference relay now resolves a turn's credential from pi's auth
store before the worker launches. The offline fixture provisions the same
fictional Codex identity into its fresh agent directory, host side only,
and refuses to write over an existing store.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s tool-safety hook (#3888)

The managed worker refuses any loaded Pi extension as uncollected input,
and the extension-factory anchor had drifted. The measurement guard now
wraps the host tool-safety hook in native-session-runtime instead, with
the same admission policy and receipt, and records a denied call's reason
as its host result as Pi's blocked path did.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@schlessera schlessera added this to the 0.45.0 milestone Nov 15, 2026
@schlessera schlessera added type: test Coverage, harness or proof work with no behaviour change. area: backends AgentBackend implementations and the seam they share. area: ci CI workflows, the gates they run, release scripts, packaging. labels Nov 15, 2026
@schlessera
schlessera marked this pull request as ready for review November 15, 2026 23:34
…ost (#3888)

Its parameterless permission() narrowed the wrapper's inferred type, so
strict typecheck rejected the three-argument calls and deny results.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@schlessera
schlessera marked this pull request as draft November 16, 2026 00:57
@schlessera
schlessera marked this pull request as ready for review November 16, 2026 00:57
@schlessera
schlessera merged commit 4452294 into main Nov 16, 2026
50 of 63 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: backends AgentBackend implementations and the seam they share. area: ci CI workflows, the gates they run, release scripts, packaging. type: test Coverage, harness or proof work with no behaviour change.

Projects

None yet

1 participant