Skip to content

fix(server): publish ACP replay status before responses - #468

Merged
lukemaj merged 1 commit into
mainfrom
fix/244-acp-replay-atomic-status
Oct 18, 2026
Merged

lukemaj merged 1 commit into
mainfrom
fix/244-acp-replay-atomic-status

Conversation

@lukemaj

@lukemaj lukemaj commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

What ACP replay status is published atomically before responses allow the test to tear down its agent.
Why In-place writes and send-before-write ordering expose partial JSON or stale progress to concurrent readers and process teardown.
So what Luna review and CI, then the backlog coordinator merges.

The fixture writes status to a process-specific temp file beside the destination, then synchronously renames it. It constructs inbound frames, commits progress, then sends them; immediately following successful/cancelled runtime exits count in the same publication. The strict testkit decoder is unchanged. The carried upstream fixture is registered under fork maintenance.

Upstream-first: current pingdotgg/t3code main eb7b35ac32fb184ec6c8e6e9f84c7ecbba968f4a retains the same broken fixture. Read the complete diff of upstream #20113, closed unmerged at 2dfba44a6dc6bbd38051d3eb67430d801740c9ec; this PR ports its response/clean-exit ordering and adds atomic rename. Bounded upstream PR/Issue searches and exact source comparison are recorded on #244.

Proof on Linux / Node v26.8.2 (the available runtime; root requests Node 24):

  • Reproducible before/after stress probe and complete results. node probe.mjs <agent.ts> 40 runs 40 trials for each combination of SIGTERM/SIGKILL and native/1 MiB scenario labels, alternating six-entry mode exchanges and trailing clean exits. It reads concurrently, kills its own child on the final response, awaits exit, then strictly checks the actual status.
  • Baseline: 10,239 malformed concurrent read observations, 27 corrupt post-exit files, and 80 stale post-exit documents across 160 trials. Patched: 168,494 concurrent reads and 160/160 complete post-exit documents, zero malformed reads or incomplete results. This exercises the real fixture process, not the full Effect finalizer.
  • ./node_modules/.bin/vp lint apps/server/scripts/acp-replay-agent.ts: pass.
  • ./node_modules/.bin/vp fmt --check apps/server/scripts/acp-replay-agent.ts docs/fork-features.md: pass.
  • ./node_modules/.bin/tsc-rs --noEmit --target esnext --module nodenext --types node --skipLibCheck --strict apps/server/scripts/acp-replay-agent.ts: pass.
  • bash scripts/fork-check.sh: pass on the committed head, including carried-file allowlist and unique ownership.
  • git diff --check: pass.
  • ./node_modules/.bin/vp test run apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.test.ts apps/server/src/orchestration-v2/Adapters/AcpRegistryAdapterV2.test.ts apps/server/src/orchestration-v2/Adapters/GrokAdapterV2.test.ts: 3 files passed, 186 tests passed (258.31 s).

Only test infrastructure and its required fork registration change. No user-facing surface, contract, production path, website, version, release or deployment changes. No review requested or run by this implementation task. Full CI and independent Luna review remain with the backlog coordinator.

Requirements and who asked: User requests #244's atomic fixture status, publication completed before teardown-permitting responses, strict decoding, and before/after stress proof.
Deleted: Decoder retries, sleeps, production changes, new tracked probe machinery and version bumps.
Bottleneck: Readers and response-driven teardown can interrupt status publication and make unrelated CI fail.
Checked myself: Complete Issue/comments, origin/main reproduction, upstream main/source and complete #20113 diff, actual before/after stress artifacts, scoped static checks and committed fork-stack gate.

Closes #244

Implemented by GPT-6.1 Sol (medium) in the Codex harness through T3 Code.

@lukemaj

lukemaj commented Oct 18, 2026

Copy link
Copy Markdown
Contributor Author

What The background focused adapter invocation also passed all 186 tests across 3 files.
Why It exercised the same committed fixture after dependency setup completed, confirming a second green focused run.
So what Luna review and CI, then the backlog coordinator merges.

Exact unchanged PR head: 7158b8c394e73ad22ad4664dac139b93f3238115; worktree clean.

Command: npx --yes pnpm@11.10.0 exec vp test run apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.test.ts apps/server/src/orchestration-v2/Adapters/AcpRegistryAdapterV2.test.ts apps/server/src/orchestration-v2/Adapters/GrokAdapterV2.test.ts.

Result: exit 0, 3 files passed, 186 tests passed, 198.04 seconds. Both focused invocations are now complete, totaling 372 passing test executions. This supplements the before/after stress proof already linked in the PR; no source change or additional review action.

@lukemaj

lukemaj commented Oct 18, 2026

Copy link
Copy Markdown
Contributor Author

Luna review round 1 at 7158b8c: APPROVE

No blocking or non-blocking findings.

Verified the exact head against #244: status is written to a same-directory temporary file and renamed atomically; progress, including an immediately trailing clean runtime exit, is published before the inbound response is sent; strict decoding remains unchanged. The recorded before/after stress probe exercises concurrent reads and response-driven teardown and distinguishes the baseline failures from the fixed result. The upstream-first search is recorded, and the carried fixture has both fork feature registration and allowlist entry. No unrelated changes, version bump, or secrets found. Focused tests and current CI checks are green.

@github-actions github-actions Bot added the vouch:trusted Author is trusted by repo permissions or the VOUCHED list. label Oct 18, 2026
@github-actions

github-actions Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

ℹ️ The exact PR base did not have a successful artifact. Baseline uses the latest successful main measurement shown below.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire 4.9 KiB 5.0 KiB +23 B (+0.5%) 6.8 KiB ✅
Codex Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Codex Live turn WebSocket wire 1.2 KiB 1.2 KiB +23 B (+1.9%) 2.0 KiB ✅
Codex Live turn WebSocket decoded 20.8 KiB 20.9 KiB +41 B (+0.2%) 29.3 KiB ✅
Codex Live turn messages 1 2 +1 (+100.0%) 8 ✅
Claude Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Claude Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Claude Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Claude Live turn WebSocket decoded 21.2 KiB 21.2 KiB 0 B (0.0%) 29.3 KiB ✅
Claude Live turn messages 2 2 0 (0.0%) 8 ✅

Baseline: 4627ee7 · PR result: 056fc3f · Source CI: success

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 108.5 KiB
  • Claude decoded thread snapshot: 108.8 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

@lukemaj
lukemaj force-pushed the fix/244-acp-replay-atomic-status branch from 7158b8c to 056fc3f Compare October 18, 2026 22:36
@lukemaj

lukemaj commented Oct 18, 2026

Copy link
Copy Markdown
Contributor Author

What Rebased PR #468 onto fetched origin/main, preserving both sides of the fork registries.
Why Main's #417 additions overlapped the allowlist insertion; no replay implementation change was needed.
So what The backlog coordinator continues CI and merge handling; no review or merge was requested or performed by this task.

Old head: 7158b8c394e73ad22ad4664dac139b93f3238115.
New head: 056fc3feede2dc0f64966d7b21a542a70b6ff298.
Rebase base: 7f300491d3604af50c37001f0cfd1fea45114dc2.
Branch: fix/244-acp-replay-atomic-status.

docs/fork-features.md auto-merged, retaining main's registrations plus all three #244 additions. Resolved the allowlist conflict by retaining #345's legacy composer files, #157's launcher test, and #244's replay script. No merge commits were introduced.

Replay script is byte-for-byte identical to the previously approved head: both Git blobs are 320f86c8198376137130a60c5639a6c5e4115256. git diff --exit-code 7158b8c394e73ad22ad4664dac139b93f3238115 HEAD -- apps/server/scripts/acp-replay-agent.ts passed. Testkit decoder remains unchanged.

git range-diff f27d8ee146295ed2b76d8d15d415dd7cff574df5..7158b8c394e73ad22ad4664dac139b93f3238115 7f300491d3604af50c37001f0cfd1fea45114dc2..HEAD:

1:  7158b8c394 ! 1:  056fc3feed fix(server): publish ACP replay status before responses
    @@ docs/fork-features.md: only when that file set changes; this is not an exhaustiv
          "apps/server/src/device/LocalDeviceHost.test.ts",
     
      ## scripts/fork-upstream-edits.txt ##
    -@@ scripts/fork-upstream-edits.txt: apps/server/src/htmlRender/publicProxy.ts
    +@@ scripts/fork-upstream-edits.txt: packages/shared/src/composerContextLegacy.ts
      
    - # Public research rendering reuses the pinned browser/context owner (#442)
    - apps/server/src/preview/ServerBrowserContexts.ts
    + # Launcher test fixture ownership (#157)
    + apps/server/src/serviceLauncher.test.ts
     +
     +# Atomic ACP replay status publication before response-driven teardown (#244)
     +apps/server/scripts/acp-replay-agent.ts

Only the allowlist hunk context changes, moving the #244 addition after main's newly added launcher entry. The implementation and registry additions are unchanged.

Proof:

  • bash scripts/fork-check.sh: pass, fork-features: OK (49 features). Initially reported missing upstream/main; fetched canonical upstream main explicitly and reran successfully.
  • ./node_modules/.bin/vp test run apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.test.ts apps/server/src/orchestration-v2/Adapters/AcpRegistryAdapterV2.test.ts apps/server/src/orchestration-v2/Adapters/GrokAdapterV2.test.ts: one invocation, exit 0, 3 files passed, 186 tests passed, 200.91 seconds.
  • git diff --check: pass.
  • No merge commits in origin/main..HEAD; clean worktree.

Requirements and who asked: Coordinator requested rebase, preservation of both registries, one focused test run, fork-stack check, explicit force-with-lease and range-diff proof.
Deleted: Merge commits, implementation edits, version bumps, additional review and duplicate test invocations.
Bottleneck: Conflicting fork allowlist additions after #417 merged.
Checked myself: Both registry sides, complete range-diff, replay-script blob equality, clean worktree and successful fork-stack gate.

Pushed with git push --force-with-lease=refs/heads/fix/244-acp-replay-atomic-status:7158b8c394e73ad22ad4664dac139b93f3238115 origin HEAD:refs/heads/fix/244-acp-replay-atomic-status. Live PR head verified as the new SHA.

@lukemaj

lukemaj commented Oct 18, 2026

Copy link
Copy Markdown
Contributor Author

Luna review round 2 at 056fc3f: APPROVE

@lukemaj
lukemaj merged commit c4d77eb into main Oct 18, 2026
27 checks passed
@lukemaj
lukemaj deleted the fix/244-acp-replay-atomic-status branch October 18, 2026 23:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ACP replay tests flake: status file read while the replay agent rewrites it

1 participant