Skip to content
Source
Sign inSign up
pingdotgg/t3code

test(server): catch client transfer regressions in CI #5350

Mergedt3dotgg(GitHub profile, opens in a new tab)merged 10 commits intomain fromrefs/pull/5350/headmerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHub

Thread history can silently regress by sending an entire conversation or oversized projections back to the client. The test needs enough data pressure to catch that without making every CI run expensive.

This adds a deterministic stress history calibrated from heavy local Codex and Claude threads: 10 turns with five command tools and one retained 900 KB MCP result each, followed by a measured turn with 20 tools and a 1.1 MB retained result. It measures only thread transport: the gzip thread snapshot and the measured turn over the real RPC WebSocket with permessage-deflate. It also verifies that resuming the thread subscription from the HTTP snapshot sequence does not replay another snapshot.

PR and main CI runs upload a strict machine-readable result. A trusted workflow_run publisher, loaded only from the default branch, compares the PR result with the exact-base main result when available and updates one github-actions[bot] comment with baseline, observed impact, ceilings, and ceiling changes. The PR artifact is size-limited, schema-validated, rendered only as known numeric fields, and never executed. Stale workflow runs cannot overwrite a newer result.

The current calibration persists 9 MB of historical MCP results but projects them to a roughly 95 KiB decoded thread snapshot, about 5.5 KiB of snapshot wire traffic, and about 51 KiB decoded / 6 KiB wire for the live turn. Total client-bound wire traffic is about 11.6 KiB, with roughly 30% ceiling headroom. The focused test takes about 15 seconds. Blacksmith also publishes the exact measurements and compression diagnostics in the job summary.

Created by GPT-5.6 using the Codex harness in T3 Code.


Note

Medium Risk Touches CI and fork-PR comment publishing with artifact validation, but production server behavior changes are limited to exporting isThreadDetailEvent and test-only measurement paths.

Overview Adds end-to-end thread transfer budgeting so CI can catch regressions that ship oversized thread snapshots or live-turn WebSocket traffic to the client.

A new live integration test seeds a deterministic heavy history (10 turns with large retained MCP payloads, then one measured turn) for Codex and Claude, measures gzip HTTP snapshot wire/decoded size and WebSocket wire/decoded/message counts (with permessage-deflate), checks that resuming a subscription from the snapshot sequence does not replay another snapshot, and fails if configured ceilings are exceeded. Optional env paths write a markdown job report and a strict JSON artifact consumed by automation.

CI uploads thread-transfer-results and appends the budget report to the job summary. A separate workflow_run workflow loads only trusted default-branch publisher code, validates artifacts (size + fixed schema, never executed), resolves the PR run and a main baseline, and upserts one bot comment with baseline vs PR impact, ceilings, and stale-head guards. Supporting harness tweaks use deterministic test event IDs and drain hooks after quiescence; isThreadDetailEvent is exported for the test.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 344bc61d56c93e1a9cb94f6e7d5895953c93f981. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

Note

Add CI integration test to catch thread transfer budget regressions

  • Adds a deterministic integration test in server.test.ts that seeds a fixed thread history, measures HTTP and WebSocket wire transfer sizes, and asserts no budget violations per provider.
  • Introduces fixtures and scenario helpers in transferBudget.ts and TransferBudgetScenario.integration.ts to produce reproducible, size-calibrated provider event streams.
  • CI uploads the JSON result as an artifact and a new trusted workflow (thread-transfer-report.yml) posts/updates a PR comment with baseline deltas and ceiling comparisons via thread-transfer-report.cjs.
  • isThreadDetailEvent is exported from ws.ts and the provider adapter harness now uses deterministic incrementing event IDs instead of random UUIDs.
Macroscope summarized 344bc61.
    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Important

      Review skipped

      Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro Plus

      Run ID: 6c3f39b6-dd86-40b1-8f6d-2aea0e3bb157

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review

      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.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    3. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Approved 344bc61

      This PR adds CI infrastructure and integration tests to monitor thread transfer budgets. The only production code change is exporting one existing function. The unresolved review comments identify issues in the CI reporting scripts (not production code), which are quality-of-life concerns for the reporting feature itself.

      You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.

      Fix All in Cursor ❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the [Cursor dashboard](https://www.cursor.com/dashboard/bugbot). Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 344bc61d56c93e1a9cb94f6e7d5895953c93f981. Configure [here](https://www.cursor.com/dashboard/bugbot).
      @@ -0,0 +388,21 @@
      388+ COMMENT_MARKER,
      389+ "## Thread transfer impact",
      390+ "",
      391+ `⚠️ The latest [CI run](${currentRun.url}) did not produce a thread transfer result for \`${currentRun.sha.slice(0, 7)}\`.`,
      392+ "",
      393+ "_This comment will update automatically after the next completed run._",
      394+ ].join("\n"),
      395+ { preserveResultSha: currentRun.sha },
      396+ );
      397+ return;
      398+ }
      399+
      400+ const baseline = readResult(process.env.BASELINE_RESULT_DIR);
      401+ const baselineRun = baseline
      402+ ? {
      403+ sha: process.env.BASELINE_SHA,
      404+ matchesBase: process.env.BASELINE_MATCHES_BASE === "true",
      405+ url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${process.env.BASELINE_RUN_ID}`,
      406+ }
      407+ : undefined;
      408+ const body = renderComment({ current, baseline, currentRun, baselineRun });
      cursor[bot](GitHub profile, opens in a new tab)commented

      Corrupt baseline blocks PR report

      Medium Severity

      publish treats a missing baseline as optional, but readResult throws on an invalid or schema-mismatched baseline file. A bad main artifact then aborts the whole publish step, so a valid PR result never updates the comment.

      Additional Locations (1)
      Fix in Cursor Fix in Web
      Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 344bc61d56c93e1a9cb94f6e7d5895953c93f981. Configure [here](https://www.cursor.com/dashboard/bugbot).
      @@ -0,0 +1,20 @@
      1+name: Thread Transfer Report
      2+
      3+on:
      4+ workflow_run:
      5+ workflows: [CI]
      6+ types: [completed]
      7+
      8+permissions:
      9+ actions: read
      10+ contents: read
      11+ pull-requests: write
      12+
      13+jobs:
      14+ publish:
      15+ name: Publish PR comment
      16+ if: github.event.workflow_run.event == 'pull_request'
      17+ runs-on: ubuntu-24.04
      18+ concurrency:
      19+ group: thread-transfer-report-${{ github.event.workflow_run.pull_requests[0].number || github.event.workflow_run.id }}
      20+ cancel-in-progress: true

      Fork reports can duplicate comments

      Medium Severity

      The concurrency group falls back to workflow_run.id when pull_requests is empty, which is common for fork PR workflow_run events. Same-SHA publishes then race, and upsertComment can create multiple marked comments because each run sees none yet.

      Additional Locations (1)
      Fix in Cursor Fix in Web
      Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 344bc61d56c93e1a9cb94f6e7d5895953c93f981. Configure [here](https://www.cursor.com/dashboard/bugbot).

Sign in to join this conversation.