Skip to content

fix(#407): commensurable term-fidelity byte meta + retain per-attempt artifacts - #410

Merged
khaliqgant merged 1 commit into
mainfrom
fix/term-fidelity-harness-debts
Jul 17, 2026
Merged

fix(#407): commensurable term-fidelity byte meta + retain per-attempt artifacts#410
khaliqgant merged 1 commit into
mainfrom
fix/term-fidelity-harness-debts

Conversation

@khaliqgant

@khaliqgant khaliqgant commented Jul 17, 2026

Copy link
Copy Markdown
Member

Closes #407. Two harness debts from the term-fidelity program.

(1) meta bytes/offset incommensurable — the exact-2.0 artifact

quiet.activity.bytes and brokerOffset read exactly 2.0 apart in 5/5 codex bundles. That was proven NOT to be double delivery (headless probe: client bytes / snapshot offset = 1.0000; BrokerManager does one IPC send per worker_stream event). The 2.0 was a derivation artifact — the two meta fields measure different things on different baselines:

field measures baseline unit
quiet.activity.bytes client-received broker:pty-chunk string bytes activity-probe install (pre-spawn ⇒ agent first byte) UTF-8 bytes of decoded IPC string
brokerOffset broker snapshot cumulative offset worker start (offset 0) raw PTY bytes

Fix: new dependency-free tests/term-fidelity/byte-accounting.ts derives a self-documenting byteAccounting block that replaces the bare pair. Each figure declares its baseline + unit, and clientToBrokerByteRatio is computed on a shared agent-start baseline (the probe is installed before spawn) so ~1.0 is the meaningful "one-to-one delivery" value. It carries an embedded note:

A ratio near an integer such as 2.0 is NOT proof of double PTY delivery … Never infer a delivery mechanism from this number; confirm by counting BrokerManager IPC sends per worker_stream event.

So the exact-2.0 can no longer be misread. Validated with the client-bytes-vs-snapshot-offset probe pattern (ratio derivation) and unit-tested.

(2) retry-then-pass erased first-attempt artifacts

Playwright retry-then-pass cleaned error-context/trace, and the harness wrote divergence bundles to a fixed test-results/term-fidelity/<cli>/<workload>/ path, so a retry overwrote the diverging first attempt (which twice was a REAL divergence event) — unexaminable afterward.

Fix:

  • Bundles + telemetry now write under attempt-<retry>/ (retry index threaded from test.info().retrylaunchFidelityHarnessharness.attemptoracle.ts), so a retry never overwrites a prior attempt.
  • playwright.term-fidelity.config.ts: preserveOutput: 'always' + documented trace: 'retain-on-failure' so Playwright's own error-context/trace for a failed attempt survive a later passing attempt.
  • README updated to document attempt segregation + byteAccounting.

Verification

  • npx vitest run tests/term-fidelity/byte-accounting.test.ts5 passed (1.0 ratio, 4dp rounding, the 2.0 forensic case + note, null-on-no-offset, divide-by-zero guard).
  • npx tsc --noEmit -p tests/term-fidelity/tsconfig.json → clean.
  • New pure unit is wired into the vitest node project via a tests/term-fidelity/**/*.test.ts include; Playwright testMatch is unchanged so it is not run as a browser test.

Note: the full Electron matrix (npm run test:fidelity / real agents, token burn) was not run here — these are harness-instrumentation + config changes with no product-runtime surface; the pure derivation and typechecks cover them. Flag if you want me to burn a real matrix run for end-to-end confirmation.

🤖 Generated with Claude Code

Review in cubic

…tempt artifacts

Two harness debts from the term-fidelity program.

(1) meta bytes/offset incommensurable (exact-2.0 artifact). `quiet.activity.bytes`
(client-received UTF-8 bytes of broker:pty-chunk strings, from probe install) and
`brokerOffset` (raw PTY bytes from worker start) were dropped into meta as a bare
pair that read as an exact-2.0 "double delivery" signal in 5/5 codex bundles —
proven NOT to be double delivery (headless probe: client/offset = 1.0000; one IPC
send per worker_stream event). New dependency-free `byte-accounting.ts` derives a
self-documenting `byteAccounting` block: each figure declares its baseline + unit,
and `clientToBrokerByteRatio` is computed on a shared agent-start baseline (probe
installs before spawn) so ~1.0 is the meaningful one-to-one value. An embedded
`note` states a near-integer ratio is a derivation artifact, never a mechanism
claim. Unit-tested (5 cases: 1.0, rounding, the 2.0 forensic case + note,
null-on-no-offset, divide-by-zero guard).

(2) retry-then-pass erased first-attempt artifacts. The failed first attempt is
exactly the REAL divergence event we need. Divergence + telemetry bundles now
write under `attempt-<retry>/` (threaded from test.info().retry) so a retry never
overwrites prior-attempt data; playwright config adds `preserveOutput: 'always'`
so Playwright's own error-context/trace for a failed attempt survive a later pass.
README updated.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@khaliqgant khaliqgant added the no-agent-relay-review Disable agent-relay automated PR review/fixes label Jul 17, 2026
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@khaliqgant, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 50 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 5b0a4e3f-4a1b-4305-bc2f-2ed8602743b2

📥 Commits

Reviewing files that changed from the base of the PR and between 188c3d5 and 38f92d5.

📒 Files selected for processing (9)
  • .gitignore
  • playwright.term-fidelity.config.ts
  • tests/term-fidelity/README.md
  • tests/term-fidelity/byte-accounting.test.ts
  • tests/term-fidelity/byte-accounting.ts
  • tests/term-fidelity/harness.ts
  • tests/term-fidelity/oracle.ts
  • tests/term-fidelity/term-fidelity.spec.ts
  • vitest.config.mjs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/term-fidelity-harness-debts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@khaliqgant
khaliqgant marked this pull request as ready for review July 17, 2026 16:21
@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@khaliqgant
khaliqgant merged commit a52d3a2 into main Jul 17, 2026
4 checks passed
@cursor

cursor Bot commented Jul 17, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@khaliqgant
khaliqgant deleted the fix/term-fidelity-harness-debts branch July 17, 2026 16:21

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 38f92d56ee

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +67 to +69
const ratio =
snapshotOffset !== null && snapshotOffset > 0
? round4(input.clientBytesReceived / snapshotOffset)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Normalize the counters before calling them commensurable

In the exact-2.0 scenario motivating this change, this still divides the unchanged quiet.activity.bytes by the unchanged full broker.offset; the parent harness already installed the activity probe before spawnRealAgent, so wrapping those values introduces no new shared-baseline adjustment. Moreover, re-encoded decoded-string bytes are not necessarily equal to raw PTY bytes. Consequently an existing 2.0 result remains 2.0 while the metadata marks it commensurable and describes it as an artifact, potentially obscuring an actual duplicate or missing-delivery signal. Record comparable offset/delta metadata from the received events or explicitly mark this ratio non-commensurable.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-agent-relay-review Disable agent-relay automated PR review/fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

term-fidelity harness: meta bytes/offset incommensurable (exact-2.0 artifact) + retain retry artifacts

1 participant