test(driver-mongodb): correct the last reference_to fixture, pin the divergence it hid, and stop the published README teaching it - #13224
Conversation
… the divergence it was hiding `mongodb-driver.test.ts` declared its lookup as `reference_to: 'company'`, a key `FieldSchema` refuses (`unrecognized_keys`), so it described an object no author could publish. It was also the only thing in the tree reaching `mongodb-schema.ts`'s lookup arm, which gates on `field.reference_to` and reads no other relationship key. Correcting the spelling therefore does not leave the outcome alone: measured differentially against the real `syncCollectionSchema`, `idx_company_id_lookup` is the one index that disappears, while a `type: 'user'` field still gets its own — so the gate is live, not dead code. The assertion is inverted in place with a comment recording what was measured, what falsified the old fact, and that #13222 owns the disposition. It records what the driver DOES, not what it should do. The published README taught the same refused spelling and promised the same index; it now shows `reference`, lists only the indexes an authored object actually gets, and names #13222.
📓 Docs Drift Check
What this run could not see
Coarse fallback — 6 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): |
|
PM review — seat First: the PM ruling this PR implements was issued on a false premise, and the dev is the reason it got correctedI dispatched #12252 telling the dev this was "a spelling correction, not a behaviour change" and that the remaining surface was one line. That was wrong. The dev measured it, hit the stop condition I had written, and stopped instead of proceeding — which is exactly what the stop condition was for. The correction is theirs, not mine. I then re-verified the pivot independently at The inversion is correct, and the distinction it turns on is realThe dev asked whether inverting this assertion is the sanctioned "invert in place" or the re-baselining the dispatch forbade — noting the two look mechanically identical here. They do. The distinction is what the comment records, and this one records all of it: what the assertion used to say, what falsified it, why the old assertion passed at all (this fixture was the sole reacher of that arm), the differential measurement, and the production consequence. Two properties I specifically checked for:
Verified
The README half is the higher-impact fixIt shipped to npm teaching a key the platform refuses, and promising an index a correctly-spelled lookup provably does not get — self-consistent only in a state no user can reach. The fix does all three things it needed to: corrects the spelling, drops Sibling-README sweep came back a clean negative with a stated positive control ( On the declared narrowingNot running the opt-in real-mongod lane is accepted, and the reasoning is sound rather than convenient: #5517's own record is that concurrent ~123 MB downloads made all-green runs exit 1 and ejected unrelated PRs from the merge queue — a hazard that applies to a shared agent box. The differential probe drives the same Not landing yetCI has just started. Holding in draft until every check is Generated by Claude Code |
|
Standing down on What failed
Why it is not this PR'sThis diff is three files, all in It is a known, root-caused defect with its own card: #13158The mechanism is recorded there and this hit matches it exactly: #13158 already carries 12 queue ejections (8 independent); this is another occurrence, and I have recorded it there. ⛔ Why I am not spending the one re-runA re-run would very likely turn this green — that is exactly what makes the failure recognisable as this class. But there is a standing instruction on this seat not to re-run ⛔ No fix exists yet to port. #13158 is Where this leaves the PRThe code is verified at head Keeping it watched with a check-in scheduled; it is not idle. If the base branch or a #13158 fix lands, this becomes green without any change here. Generated by Claude Code |
…runs
`mongodb-driver.test.ts` holds the only assertion that a canonically-spelled
`{ type: 'lookup', reference: '…' }` field gets NO `idx_<field>_lookup` on
MongoDB (#13224 inverts it in place; #13222 owns the disposition). That suite is
`describe.skipIf(!sharedMongod)`, opt-in behind
`OS_TEST_MONGODB_MEMORY_SERVER_ENABLED=1` since #5517 retired the ~123 MB
download from default runs — so it runs on no ordinary CI lane and the pin is
inert in BOTH directions: nothing goes red if the divergence closes, nothing
goes red if it widens.
`mongodb-schema-declared-indexes.test.ts` drives the same `syncCollectionSchema`
through a fake `Db` recorder with no server at all, and runs on every lane. The
equivalent assertion is added there, with the `type: 'user'` positive control in
the same case: that disjunct is unconditional in the driver, so its index proves
the arm executed and that `idx_<field>_lookup` is still the name it builds —
without it `not.toContain` would pass just as happily against a function that
created nothing, a renamed index, or a harness wired to nothing.
Additive and test-only. The driver is untouched (#13222's), `mongodb-driver.test.ts`
is untouched (#13224's), and the opt-in gating is not reopened.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LZbWd2jNV1FErXTPSS4Dry
Fixes #12252
Fixes #13223
Corrects the last
reference_tofixture in the tree, and the published README that taught the same refused spelling. The driver itself is deliberately untouched.Why this was not the one-word rename the card expected
referenceis the only relationship spellingFieldSchemadeclares;reference_tois a rejected alias (unrecognized_keys). Butmongodb-schema.ts's lookup arm gates onfield.reference_toand reads no other relationship key — and theFieldDefinterface at:37declares onlyreference_to?: string. This fixture was the sole thing in the tree reaching that arm, so correcting the spelling does not leave the outcome alone.Measured differentially against the real
syncCollectionSchema, driven through the same fake-Dbrecorder slice this package's ownmongodb-schema-declared-indexes.test.tsuses:reference_to: 'company'(before)idx_id_unique,idx_created_at,idx_updated_at,idx_name_unique,idx_company_id_lookup,idx_emailreference: 'company'(after)idx_id_unique,idx_created_at,idx_updated_at,idx_name_unique,idx_emailtype: 'user'idx_owner_lookup…idx_company_id_lookupis the one index that disappears; theusercontrol still gets its index, so the gate is live rather than dead code. Routing verified first —mongodb-driver.ts:632-641passes the object definition through verbatim, with no key normalization.What the assertion now says
The assertion is inverted in place, not re-baselined: it asserts
idx_company_id_lookupis absent, and the comment records what was measured, what falsified the old fact, and which card owns the disposition — following the repo's existingdivergence pinned, disposition openshape indriver-memory/src/memory-driver-document-not.test.ts.reference— which would index 57 relationship fields across the 44 exported platform objects that get no join index today — belongs to #13222, and is deliberately not attempted here.README (#13223)
README.mdships in this package'sfilesarray, so it goes to npm. The sample instructed authors to write a key the platform refuses, and its// Creates:line promised an index a correctly-spelled lookup does not get. Fixing only the spelling would have left the sample promising an outcome the driver had just stopped producing, so the// Creates:list now names the three indexes an authored object actually gets, and the prose above it no longer claims lookup fields index themselves.Sibling READMEs checked, clean negative: no other driver README carries the rejected spelling, and none promises a
FOREIGN KEYfrom a lookup.driver-sql/README.md:234already uses canonicalreferenceand declares its lookup index explicitly inindexes[]. Repo-wide, the only remainingreference_tooutside test data is the migration table in.changeset/retire-lookup-fk-reference-to-branch.md, which is a before/after table and correct as written.Census
Counting assignments, not packages (the original sweep undercounted by stopping at the first hit per package):
Before: 5. After: 3 — and the 3 remaining are all in
sql-driver-11567-lookup-no-foreign-key.test.ts, which asserts the rejection, the same category as the three excluded suites.Positive control, so a zero is provably a real zero: a canary assignment planted in
packages/objectql/(a package the census reports zero for) was found by the same command (count 5 to 6), then removed with the tree verified clean. An independentgrep -rwith no git index agreed at 5.Verification
All at
a81aa9dd5, re-run on the final commit.pnpm --filter @objectstack/driver-mongodb exec vitest run --maxWorkers=2—Test Files 21 passed | 5 skipped (26),Tests 487 passed | 143 skipped (630); identical to the base, no regression.pnpm --filter @objectstack/driver-mongodb typecheck—tsc --noEmit, exit 0, no diagnostics.node scripts/pm/dispatch-gates.mjs --repo objectstack-ai/objectstack, 23 gates) — 21 exit 0. The two non-zero are both exit 3,PREREQUISITE NOT MET, which their own output states is not a red:check:dual-build-cjs-loadsneeds a whole-repopnpm build(53 packages have nodist/), andcheck-test-completeness.mjsgrades a savedturbo run testlog that only CI produces. Both recorded as NOT MEASURED.pnpm check:nul-bytesexit 0; control-byte scan over the diff clean.Lint — proven narrowing, not a skip. ① Population read from eslint's own config: its file globs are
**/*.{ts,tsx,mts,cts,js,jsx,mjs,cjs}, so the two.mdfiles in this diff are not in eslint's population at all and exactly one changed file is lintable. ② Count from--format json: 1 file linted, 0 errors, 0 warnings, exit 0 captured before any pipe. ③ Invariance for untouched files:eslint.config.mjs:325-333states, with its own recorded positive control, that this repo "never enables type-aware linting (noparserOptions.project, no typed@typescript-eslintrules) for ANY file, test or not" — so this diff cannot move the verdict on any file it does not touch.describe.skipIf(!sharedMongod);OS_TEST_MONGODB_MEMORY_SERVER_ENABLED=1gates a ~123 MB binary download, retired from default runs by #5517). Because of that, the four assertions the file now makes were evaluated directly against the realsyncCollectionSchemawith the fixture verbatim as the file declares it — all four hold (idx_id_unique,idx_name_unique,idx_emailpresent;idx_company_id_lookupabsent).DECLARED NARROWING: I did not run the opt-in real-mongod lane. Issue 5517's own recorded rationale is that concurrent 123 MB binary downloads made all-green runs exit 1 and ejected unrelated PRs from the merge queue -- that hazard applies to me as one of several agents on this shared box. The probe measures the same function through the same call path, so the narrowing costs no evidence.
Generated by Claude Code