Repository navigation
fix: tighten openapi copy folding and the sqlite interrupt test - #60794
Conversation
There was a problem hiding this comment.
The fix looks good to me. On the base, the two new stabilize tests fail; with this PR they pass. check:generated shows no diff, the sqlite interrupt test passed 8 times in a row, and typecheck:tsc is clean in protocol and core.
The flattening step runs after the equality pass, so a copy whose parent stays unfolded still points to a schema that exists. Matching the unsuffixed <Base>Encoded only applies when a suffixed sibling exists, so authored names are left alone.
Public API: unchanged. The change touches only the spec-generation script and tests, and the generated openapi.json and clients stay the same.
One renameRefs walker and one canonical (sorted, optional inlining) serve both content addressing and copy folding. Copy equality compares canonical shapes with references resolved through the remaining copies, which also replaces the separate chain-flattening step. openapi.json is unchanged.
There was a problem hiding this comment.
The new commits look good. The refactor keeps the earlier behaviour: the stabilize tests pass (9), check:generated shows no diff in protocol and client, and typecheck:tsc is clean. Resolving references through the whole copy chain covers the dangling-reference case without the separate flattening loop. No new concerns. Public API: unchanged; this only touches the spec-generation script and tests, and the generated output is the same.
Three small fixes from the review of the Effect 4.1 upgrade, plus a simplify pass on
openapi-stabilize.ts.openapi.jsonand the generated clients don't change.❌ Before
X,X_2,X_2_1) was folded only one step, leaving a reference to a deleted schema.*Encodedschema kept its encounter-order name, so reordering events could change its meaning.✅ After
<Base>Encodedis renamed by content whenever a<Base>Encoded_Nsibling exists.The stabilize script also got smaller (151 → 102 lines): one ref walker and one canonical form now serve both content addressing and copy folding, and copy equality compares canonical shapes with references resolved through the copies still folding. That replaced the custom deep-equal, the one-step reference matcher and the separate chain-flattening loop.
Encodedtesttake(1)acquirerNew stabilize tests fail without the fix; the interrupt test passes on dev in about 90 ms.
👀 Read:
openapi-stabilize.ts, theanonymousfilter andcollapseCopies. The rest is routine.Follow-ups from the review of #60651 · no user reports
Checks run
bun test test/openapi-stabilize.test.ts(protocol): 9 pass; mutating chain resolution, theEncodedrule, the family rule or the fixed-point loop each fails a testbun test test/sqlite-interrupt.test.ts(core): 4 pass in 90 ms; 3 fail with the oldtake(1)acquirerbun run generate,check:generated(protocol, client): no diffbun run typecheck(protocol, core): clean