Repository navigation
test(perf): session-entries (#43932) and sender-index (#43768) flow contracts with exact work deltas - #44758
Conversation
…ontracts with exact work deltas
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Review status: readyReviews:
Standard-approach and reference comparison (whole PR): VERDICT: STANDARD. The design is a counting fake at the I/O boundary plus spies with exact counts. The fixture is one large fleet, the test makes a single change, and it asserts the before/after delta. Nothing is timed. remote-check: PASS on 4bf8aac (Omarchy, lane pg3-2). Since then, the only change is the JSDoc line. CI: green. The performance-contracts step adds about +40 s on ubuntu, +40 s on macOS and +37 s on Windows (table in the PR body). Almost all of it is transforming the renderer store graph that the session contract drives through the real wiring. QA:
|
Runs in CI?
Yes. Both files are
*.performance.test.ts, so the existingperformance-contracts.ymljob selects them on every production change. The regular unit suite also picks them up throughsrc/**/*.test.ts. The PR adds no new job and no new workflow.What runs: two count-only Vitest contracts. They make no wall-time assertions and start no Electron, builds or fleet gate. Fake timers drive the save debounce.
Measured cost: this was re-measured after ci(perf): run performance-contract files in parallel #44771 made contract files run in parallel. The table gives the contracts step, as the median of 3 GitHub runs each on main commit 6480d9f, alone and with this PR's two files:
The earlier +40 s per OS was measured when contract files still ran one at a time. The session contract now shares workers with the other contracts, and the existing store contract already loads the same renderer store code. All 9 runs with this PR's files passed on current main.
The fleet perf gate still doesn't run in CI.
Problem
These are flow budgets for the fleet-size class from the previous PR: work that grows with the number of worktrees or rows when only one changed. Two recent fixes are in that class:
Change
Two contracts, written the same way as the previous PR: one fleet of 100, warm up, snapshot the counters, act once, and assert the exact delta.
workspace-session-host-persistence.performance.test.ts:createTab, so unified tabs, groups and layouts exist. Saves go through the realcreateSessionWriteSubscriber→patchWorkspaceSessionByHostwith acknowledged entries.SessionApicounts writes and every entry sent, both throughpatchEntriesand through the whole-fieldpatchfallback. That way, falling back to whole fields can't hide.structuredLaunchSlotIds, which runs once per group of each rebuilt session.agent-sender-index.performance.test.ts:Setup: a 100-row whole-host publication, plus one worktree scope.
Counter: a call-through spy on
HostPartDraft.prototype.rowscounts the rows handed to the host's sender index, whether it edits the previous index or rebuilds it. Setup is pinned at 101.Result (counted per step):
What this does and doesn't cover: the contracts bound the entries sent, the session rebuilds and the sender rows joined in these two flows. They don't cover these:
use-app-session-persistence.tswould not fail it.Proof
The contracts fail when their fixes are reverted. Both runs were local, and the code was restored afterwards:
cache?.set){0, 2, 0, 2, 2}Standard-approach check: VERDICT: STANDARD. The pattern matches what similar projects do: a counting fake at the I/O boundary, spies with exact counts, one large fixture with a single change, and a before/after delta. Nothing is timed.