test(runtime): deduplicate backend fixtures - #4946
Conversation
Astro-Han
left a comment
There was a problem hiding this comment.
Reviewed exact head db0cd4dce90f0f8fe22713027977b15340a2baec.
This is a test-only fixture refactor in packages/runtime/src/__tests__/ai-sdk-backend.test.ts. The suite-local createBackend wrapper at :15453-15467 supplies the six repeated defaults and spreads each scenario input afterward, so explicit overrides remain authoritative. I independently compared the old and new source: the test leaf-name set is unchanged, the 196 constructor sites become 181 wrapper calls plus the 15 intentionally specialized direct calls, and no migrated site retains a non-default value for a supplied key.
I found no P0-P3 correctness, ownership, concurrency, or test-integrity issue. The exact-head label and test checks passed; the merge-tree against current origin/main and diff check are clean, and changed-file Biome checking passed. The local worktree has no usable TypeScript compiler or built dist, so I did not independently run the runtime test file or typecheck locally.
Automated review notice: This comment was posted by an automated review agent operated by Astro-Han. It is not an independent human review and does not replace one.
5240480 to
2951f1b
Compare
195 of the suite's direct createTestAiSdkBackend call sites repeat the same six fixture properties (sessionId, header, appendMessage, apiKey, newId, now) byte-for-byte. A suite-local createBackend wrapper supplies those defaults once and lets each call pass only its scenario-specific input; a final spread keeps explicit overrides authoritative. The remaining createTestAiSdkBackend constructions are intentionally untouched: nine direct call sites (eight that deliberately rely on the constructor's internal defaults by omitting apiKey and/or newId/now/ appendMessage, and one whose input spreads a dynamically built object) plus the internals of three suite helpers (imageReplayBackend, the durable replay helper, and createBackend itself), which already centralize their own defaults. Constructor inputs are preserved exactly: every removed property is byte-identical to a default the wrapper supplies ahead of its spread, so each migrated input expands to the original input, and migrated call sites retain only scenario-specific keys. Test names, scenario values, and assertions are unchanged: the test-name inventory (219 test() sites, including both parameterized loops) is byte-identical to origin/main's source, and the suite passes 232/232. Rebased onto current origin/main: conflicts with apache#4958 and apache#4951 were resolved by keeping main's parameterized tests and migrating their fixture calls to createBackend. Generated-by: Claude (pi coding agent)
2951f1b to
52d0c22
Compare
Astro-Han
left a comment
There was a problem hiding this comment.
Thanks for the change. Approving exact head 52d0c22236482683163601382950fb742a738804 following the completed review and Astro-Han’s explicit acceptance of this merge batch. Current checks pass and no review threads remain unresolved.
Backend tests repeated the same fixture defaults at many call sites. Supply those defaults once in a suite-local helper, with explicit overrides last and specialized constructions preserved. No production behavior or test scenario is removed.
AI assistance: Codex performed the review and final-state verification; Astro-Han authorized approval and merge.
中文
感谢改动。基于已完成的审查和 Astro-Han 对本批次的明确认可,批准当前精确 head;检查通过,讨论已结清。此前说明的验证边界与后续事项保持不变。本次由 Codex 执行审查和状态核对,Astro-Han 授权批准与合并。
Summary
ai-sdk-backend.test.tscarries 204 directcreateTestAiSdkBackendcall sites onorigin/main; 195 of them repeat the same six fixture properties byte-for-byte (sessionId: 'session-1',header: header(),appendMessage: async () => {},apiKey: 'sk-test',newId: idGenerator(),now: monotonicClock()). A suite-localcreateBackendwrapper supplies those defaults once; the 195 eligible calls now pass only scenario-specific input, and a final spread keeps explicit overrides authoritative.Result: the backend fixture now exists once instead of 195 times — net −1058 lines (17,373 → 16,315), runtime test count matches origin/main's suite (232 pass / 0 fail, before and after), test-name inventory byte-identical to origin/main's source (219
test()sites, including both parameterized loops), no test deleted, no assertion or scenario value changed.The remaining
createTestAiSdkBackendconstructions are intentionally untouched: 9 direct call sites — 8 that deliberately rely on the constructor's internal defaults by omittingapiKeyand/ornewId/now/appendMessage(including the 4 Codex checkpoint calls), and 1 whose input spreads a dynamically built object — plus the internals of 3 suite helpers (imageReplayBackend, the durable replay helper, andcreateBackenditself), which already centralize their own defaults.Rebased onto current
origin/main(554b86445): conflicts with #4958 and #4951 were resolved by keeping main's parameterized tests (inheritedDenial× false/true,output× text/tool) and migrating their fixture calls tocreateBackend; main's newly added eligible call sites were migrated in the same sweep.Part of the 2026-09 scavenger sweep T1 claim; plan and measured targets in #4945. A follow-up consolidation PR (#4945 stage 2) lands after this one merges.
Refs #4945
Verification
npm --workspace @maka/runtime run build✓node --test --test-reporter=tap packages/runtime/dist/__tests__/ai-sdk-backend.test.js→ 232 pass / 0 fail before and after; test-name inventory (219test()sites) is byte-identical to origin/main's source (sorted diff empty)npm --workspace @maka/runtime run typecheck✓biome format/biome linton the target → no fixes needed;git diff --checkcleanBefore/after (one representative site):
AI use
Select exactly one:
Tool(s) and scope: Claude (via pi coding agent) implemented the migration as a source codemod with per-call input-preservation assertions, rebased the PR onto updated
origin/main(resolving the #4958/#4951 parameterized-test conflicts by keeping main's tests and migrating their fixture calls), migrated the newly added eligible call sites, ran the verification commands, and refreshed this description. The affected commit carries aGenerated-bytrailer.Checklist
Does this PR entail a change in behavior?