Skip to content

first recorded vanilla wire-parity fixture (ai-sdk/acp) + symmetric cwd neutral-diff - #27

Closed
Yiminnn wants to merge 2 commits into
mainfrom
parity/symmetric-cwd
Closed

Yiminnn wants to merge 2 commits into
mainfrom
parity/symmetric-cwd

Conversation

@Yiminnn

@Yiminnn Yiminnn commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Lands the first passing recorded vanilla wire-parity fixture for ai-sdk/acp
and closes the sandbox-cwd capture asymmetry characterized in #26 by making the
collapse symmetric. After this change the standalone (vanilla) and
BenchFlow-hosted captures of the same task are byte-identical modulo the
reviewable NEUTRAL_DIFFS allowlist
— no new exception, no behavioral
divergence.

Supersedes #26. #26 recorded two static captures (vanilla-inside.jsonl +
vanilla-outside.jsonl) and a test that only diffed them, leaving the cwd
asymmetry as a documented gap (the hosted /app collapsed to <CWD> but the
standalone temp-dir was left verbatim, so two equivalent runs falsely diverged).
This PR fixes the root cause and replaces the static diff with a live offline
re-drive
guard.

What changed

1. Symmetric sandbox-cwd collapse (skills/adaptation-parity/scripts/)

  • parity.py: the sandbox-cwd neutral-diff is now parameterized by each
    captures own recorded cwd (_CAPTURE_CWD_KEY meta annotation) instead of a
    hard-coded /app token for one side and fragile system-prompt scraping for the
    other. load_capture stamps each records cwd field; normalize_request(cwd=...)
    pops it before equality so it never participates in comparison. _sub_cwd still
    collapses only the boundary-anchored cwd PREFIX, so a genuinely different
    write directory (src/ vs tests/) still FAILs and an unrelated longer path
    is never corrupted (/app does not turn /application into <CWD>lication).
  • acp_capture.mjs / mock_upstream.mjs: record each captures own cwd
    (MOCK_CWD) on every logged line. The hard-coded /app fallback is retained
    for captures that predate cwd recording.
  • test_parity.py: +4 guard tests (symmetry + over-collapse, unit and e2e).

2. First vanilla fixture + offline guard (ai-sdk/acp/tests/)

  • tests/fixtures/vanilla.jsonl: the standalone vanilla capture of the shipped
    server.mjs on the write-hello.txt parity task, carrying its own recorded cwd.
  • tests/test_wire_parity.py: an OFFLINE pytest that re-drives the shipped
    server.mjs through one prompt against the deterministic capturing mock upstream
    (no live model) and asserts byte-identical-modulo-allowlist wire parity with
    the fixture via assert_wire_parity + the symmetric-cwd normalizer. Each re-drive
    runs in a fresh temp cwd that collapses to <CWD> on both sides. It skips cleanly
    when the node deps are absent (CI runs no npm ci); the fixture self-consistency
    test always runs.

Test plan / evidence (run on the provisioned host)

  • pytest test_wire_parity.py -> 2 passed (offline re-drive + fixture
    self-consistency).
  • Load-bearing proof: perturbing server.mjs system prompt makes the
    re-driven request messages diverge from the fixture and the test FAILs
    (req#0/req#1: differing fields [messages], exit 1); restored via git.
  • Over-collapse guard (RIGOR): a genuinely different write directory still
    FAILs — only the boundary-anchored cwd prefix is collapsed, not a path wildcard
    (test_recorded_cwd_does_not_overcollapse_different_write_dir,
    test_write_directory_divergence_fails, test_app_substring_not_overcollapsed,
    test_cwd_replace_is_path_boundary_anchored).
  • PYTHONPATH=. pytest test_parity.py -> 22 passed (the tooling unit tests
    incl. the 4 new symmetric-cwd + over-collapse tests).
  • node --check clean on acp_capture.mjs, mock_upstream.mjs, server.mjs;
    ruff check src tests clean for the package.

CI

test-ai-sdk.yaml runs pytest -q + ruff check src tests on ai-sdk/** PRs and
does not npm ci, so the re-drive test SKIPs there while the fixture test runs;
test-parity.yaml runs test_parity.py (22 passed). No behavioral runtime code
(server.mjs) is changed — only the 4 parity-tooling scripts + the new fixture
and test.

symphony-bot added 2 commits June 28, 2026 00:33
…rded cwd

Parameterize the sandbox-cwd neutral-diff by each capture OWN recorded cwd
instead of a hard-coded /app token (hosted) plus fragile system-prompt scraping
(standalone). Closes the PR #26 asymmetry where the hosted /app collapsed to
<CWD> but the standalone temp-dir was left verbatim, falsely diverging two
equivalent runs inside the already-accepted sandbox-cwd neutral-diff category.

- parity.py: _CAPTURE_CWD_KEY meta annotation drives _rule_sandbox_cwd;
  load_capture stamps each record cwd field; normalize_request(cwd=...) pops it
  before equality so it never participates in comparison. _sub_cwd still collapses
  ONLY the boundary-anchored cwd PREFIX, so a genuinely different write directory
  (src/ vs tests/) still FAILs and an unrelated longer path is not corrupted.
- acp_capture.mjs / mock_upstream.mjs: record each capture own cwd (MOCK_CWD) on
  every logged line; hard-coded /app fallback kept for pre-cwd captures.
- test_parity.py: +4 guard tests (symmetry + over-collapse, unit and e2e); 22 pass.
…e re-drive

Add the first recorded standalone vanilla capture and a per-package OFFLINE guard.

- tests/fixtures/vanilla.jsonl: the standalone (outside) capture of the shipped
  server.mjs on the write-hello.txt parity task, carrying its OWN recorded cwd so
  the symmetric sandbox-cwd collapse can anchor on it.
- tests/test_wire_parity.py: re-drives the shipped server.mjs through one prompt
  against the deterministic capturing mock upstream (NO live model) and asserts
  byte-identical-modulo-allowlist wire parity with the fixture via
  assert_wire_parity + the symmetric-cwd normalizer. A fresh temp cwd each run is
  collapsed to <CWD> on both sides. Skips cleanly when node deps are absent (CI
  runs no npm ci); the fixture self-consistency test always runs.

Proven load-bearing: perturbing server.mjs system prompt makes the re-driven
request messages diverge from the fixture and the test FAILs (req#0/req#1
differing [messages]).
@Yiminnn Yiminnn closed this in #28 Jun 28, 2026
Yiminnn added a commit that referenced this pull request Jun 28, 2026
…dk/ path (#28)

* fix(parity): symmetric sandbox-cwd collapse via each capture own recorded cwd

Parameterize the sandbox-cwd neutral-diff by each capture OWN recorded cwd
instead of a hard-coded /app token (hosted) plus fragile system-prompt scraping
(standalone). Closes the PR #26 asymmetry where the hosted /app collapsed to
<CWD> but the standalone temp-dir was left verbatim, falsely diverging two
equivalent runs inside the already-accepted sandbox-cwd neutral-diff category.

- parity.py: _CAPTURE_CWD_KEY meta annotation drives _rule_sandbox_cwd;
  load_capture stamps each record cwd field; normalize_request(cwd=...) pops it
  before equality so it never participates in comparison. _sub_cwd still collapses
  ONLY the boundary-anchored cwd PREFIX, so a genuinely different write directory
  (src/ vs tests/) still FAILs and an unrelated longer path is not corrupted.
- acp_capture.mjs / mock_upstream.mjs: record each capture own cwd (MOCK_CWD) on
  every logged line; hard-coded /app fallback kept for pre-cwd captures.
- test_parity.py: +4 guard tests (symmetry + over-collapse, unit and e2e); 22 pass.

* test(ai-sdk/acp): first recorded vanilla wire-parity fixture + offline re-drive

Add the first recorded standalone vanilla capture and a per-package OFFLINE guard.

- tests/fixtures/vanilla.jsonl: the standalone (outside) capture of the shipped
  server.mjs on the write-hello.txt parity task, carrying its OWN recorded cwd so
  the symmetric sandbox-cwd collapse can anchor on it.
- tests/test_wire_parity.py: re-drives the shipped server.mjs through one prompt
  against the deterministic capturing mock upstream (NO live model) and asserts
  byte-identical-modulo-allowlist wire parity with the fixture via
  assert_wire_parity + the symmetric-cwd normalizer. A fresh temp cwd each run is
  collapsed to <CWD> on both sides. Skips cleanly when node deps are absent (CI
  runs no npm ci); the fixture self-consistency test always runs.

Proven load-bearing: perturbing server.mjs system prompt makes the re-driven
request messages diverge from the fixture and the test FAILs (req#0/req#1
differing [messages]).

* test(ai-sdk): one uniform offline wire-parity test for the whole ai-sdk/ path

Generalize the package-local acp wire-parity test (#27) into a single mechanism that
applies identically to every ai-sdk/<agent>/ package -- "one path fix, uniform for all
agents in this path". Upstream agent code is untouched; each agent contributes only
fixture DATA.

- skills/adaptation-parity/scripts/path_wire_parity.py: the logic, ONCE. Re-drives a
  package's shipped src/*/server.mjs through the deterministic mock upstream and asserts
  byte-identical-modulo-NEUTRAL_DIFFS wire parity vs the committed vanilla fixture, plus
  data-driven outcome parity vs tests/fixtures/summary.json.
- ai-sdk/<agent>/tests/test_wire_parity.py: a byte-identical shim (same md5 in all 4
  packages) -- no per-agent test code.
- ai-sdk/package.json + lockfile: ONE shared node manifest; ESM resolves up the dir
  chain, so a single npm ci at ai-sdk/ provides deps for every harness server.mjs.
- test-ai-sdk.yaml: add the npm ci step so the re-drive actually RUNS in CI (today it
  silently skips -- no committed package.json, only a local node_modules symlink).

acp runs green (byte-identical re-drive; load-bearing: perturbing its system prompt
fails the test). Sandbox/cloud-coupled harnesses skip with a documented reason until
captured in a representative env:
- harness-pi: just-bash bridges into a benchflow task cwd; a bare temp cwd has none.
- harness-codex / harness-claude-code: @ai-sdk/sandbox-vercel needs Vercel cloud infra.
harness-mimo keeps its own proxy-capture suite -- the right mechanism for it.

---------

Co-authored-by: symphony-bot <symphony@benchflow.ai>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant