Repository navigation
spec(data): a shared NULL-distinct unique conformance case-set, scored by the driver census - #29808
Conversation
…d by the driver census UNIQUE_NULL_DISTINCT_CASES in packages/spec/src/data: two rows whose unique key holds a NULL in any key part both land, '' and equal values collide, on a field-level unique and a declared two-column unique index. Its test runs the table against a reference store and proves six wrong readings each fail it. The census registers the column with one tracked DEBT row per driver; no driver package changes. Claude-Session: https://claude.ai/code/session_01ADHkmR216nE71oPFuQMyRt Co-authored-by: Claude <noreply@anthropic.com>
…istinct case-set Claude-Session: https://claude.ai/code/session_01ADHkmR216nE71oPFuQMyRt Co-authored-by: Claude <noreply@anthropic.com>
…main Claude-Session: https://claude.ai/code/session_01ADHkmR216nE71oPFuQMyRt Co-authored-by: Claude <noreply@anthropic.com>
…tinct case-set Claude-Session: https://claude.ai/code/session_01ADHkmR216nE71oPFuQMyRt Co-authored-by: Claude <noreply@anthropic.com>
…main Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzfXhPVhbNCfA7cqGdi
📓 Docs Drift Check18 anchor(s) derived from 1 changed package(s); no hand-written page names any of them. What this run could not see
Coarse fallback — 168 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 151d96804ae7c5cabfb8a3cb3587987781e9eb00 && git checkout 151d96804ae7c5cabfb8a3cb3587987781e9eb00
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 0e4b0fa411de344a0c2f38500255c68fc1cdfdf2 4ee136f065201c8f6edbd7856a651ac212b2f86b && git checkout -B drift-repro 0e4b0fa411de344a0c2f38500255c68fc1cdfdf2 && git merge --no-ff 4ee136f065201c8f6edbd7856a651ac212b2f86b
node scripts/docs-audit/affected-docs.mjs --json 0e4b0fa411de344a0c2f38500255c68fc1cdfdf2 |
|
domain:spec#2 · os-support-ai · session_01WGufzhJG3tKnksHVa1krBz Contract reviewServed-tier: Delta record over 6583589505 (PR #29509, head Inputs: card #29377 (ruling 6595804527, claim 6595859623, dev report 6596443147, hand-off 6589445500, the earlier claim, amendment and Decision-needed), PR #29808 body and files, the net diff ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgment
Implemented-by: VERDICT: PASS |
|
domain:spec#2 · os-support-ai · session_01WGufzhJG3tKnksHVa1krBz 席位核对 — ACCEPT · domain:spec#2 · head
|
domain:spec#2 · os-support-ai · session_01WGufzhJG3tKnksHVa1krBz
Requested by Yibo Wang · project thread
Fixes #29377
Supersedes #29509 (same commits, resumed on a new branch)
Ruling-ref: 6595804527
Clause-②: yes (widening)
Metadata-protocol: none
维护者速读
@objectstack/spec/data新增一套共享的一致性用例UNIQUE_NULL_DISTINCT_CASES(10 条):唯一键任一列为空(null或没写)的两条记录都能保存;''和相同的非空值照旧冲突;单列unique与两列联合唯一索引各有覆盖。驱动一致性普查把它登记为新的一列,6 个驱动各记一条 DEBT 待接入。uniqueis built as a sparse index, so two explicitnullvalues collide, unlike the NULL-distinct rule of driver-sql and driver-memory #29278,已由 fix(driver-mongodb): two records with a null unique field are both admitted, as on driver-sql and driver-memory #29339 修好),期间普查全绿,因为没有任何用例问这个问题。有了这套用例,下一个驱动或回归再把空值合并成同一个键,就会在普查里被记为未覆盖、在驱动接入后直接变红。packages/spec/src/data/unique-null-distinct-conformance.ts(用例与实测出处);scripts/check-driver-conformance.mjs新增的 6 条 DEBT;unique-null-distinct-conformance.test.ts的六种错误读法。node scripts/check-driver-conformance.mjs,预期矩阵多出UNIQUE_NULL_DISTINCT一列、6 格DEBT,结尾OK — 66 covered cell(s), 6 in the DEBT ledger。Resume note
This PR carries #29509's five commits unchanged (head
0c0e86d0, contract review PASS, record 6583589505 on #29509), resumed on this branch because a card thread can push only its own branch. On top: one merge oforigin/main@25450217(no conflict; main had not movedscripts/check-driver-conformance.mjssince the old merge base, so the census and the six DEBT rows are byte-identical to #29509), and one regeneration commit forpackages/spec/api-surface/data.jsonandpackages/spec/export-origins/data.json(both moved on main;os-regen-merge.shtook main's side andcheck:generated --fixre-added exactly this PR's four names). The case-set, its test, the changeset and the census are unchanged from0c0e86d0.What changes
New case-set
packages/spec/src/data/unique-null-distinct-conformance.ts, besidevalue-roundtrip-conformance.tsandreadable-ids-conformance.ts, in their shape. Ten cases over two fixture objects:unique_null_single(field-levelunique: 'global'oncode) andunique_null_compound(declared index{ fields: ['region', 'tag'], unique: 'global' }).single_null_nullcode: nulltwicesingle_absent_absentcodeomitted twicesingle_null_absentnull, then omittedsingle_equal_valuesingle_empty_string''twicecompound_one_null(r1, null)twicecompound_leading_null(null, t2)twicecompound_one_absent(r3, omitted)twicecompound_equal(r4, t4)twicecompound_differs_in_one_part(r5, t5a),(r5, t5b)The consumption recipe is in the module docblock: sync both objects,
create()the first row (must be admitted),create()the second and recordrefusedonly whenisUniqueViolationError(@objectstack/types) recognises the error, count the rows labelled with the case, and hand both touniqueNullDistinctDivergence. The count is there because a driver can refuse a write and keep it. Every non-NULL key value belongs to one case, so a suite may run all ten on one synced pair of objects (pinned).Scope spelled
'global'on both surfaces. The scope ofunique(ADR-0120 D1, ADR-0131 D1) is a different axis and stays out of this table;'global'is the one spelling that means the same key on every driver with or without a tenant column. A baretrueon a declared index is refused since protocol 18, and the test parses both fixture objects throughObjectSchema.packages/spec/src/data/index.ts: theexport *line with its comment.Census registration in
scripts/check-driver-conformance.mjs: aCASE_SETSrow (file,marker: 'UNIQUE_NULL_DISTINCT_CASES',what), and oneLEDGERrow per driver (kind: 'DEBT',issue: '#29377'), each with its measured state inwhy. A history note aboveLEDGERrecords why the column opens with six rows (the FILTER_TEXT shape: the contract lands ahead of its suites) and how a row clears (the driver's PR adds the suite and deletes its row; RECONCILED reds a row kept beside a suite). No driver package is touched.Regenerated:
packages/spec/api-surface/data.json,packages/spec/export-origins/data.json(four added names each).Changeset
.changeset/29377-unique-null-distinct-conformance.md:@objectstack/specpatch.New public names
Under
@objectstack/spec(thedataentry), spelled like the sibling case-sets:UNIQUE_NULL_DISTINCT_CASESThe cases constant and the census marker (the census discovers
export const ..._CASES).UNIQUE_NULL_DISTINCT_OBJECTSThe two fixture objects, as
syncSchematakes them (cf.VALUE_ROUNDTRIP_FIELDS,READABLE_IDS_PARENT_OBJECT).UniqueNullDistinctCaseThe row type (cf.
ValueRoundTripCase,ReadableIdsCase).uniqueNullDistinctDivergenceThe shared judge,
(case, second, stored) => string | null(cf.valueRoundTripDivergence). A pure comparison over two observed values, no runtime logic.Why
PR #29339 (#29278) made driver-mongodb admit a second
nullin a unique field. Its old sparse index indexed an explicitnulllike a value. driver-sql and driver-memory already admitted it, and the census stayed green through the whole divergence because no case-set asked the question.value-roundtrip-conformance.tsdescribes the same gap for value storage: no case-set, no evidence.Tests
No existing test was edited. One new file,
packages/spec/src/data/unique-null-distinct-conformance.test.ts(23 tests):''is a value): each case alone, and all ten in order on one store.''treated as NULL (fails exactlysingle_empty_string), a compound keyed on its first column, a constraint never checked, and a refusal that keeps the row (both fail exactly the three refused rows).nullonly on the expected answer and the expected count.ObjectSchema.Acceptance notes
driver-memoryanddriver-sql(better-sqlite3) were run in-process over all ten cases onorigin/main@f95d0dba, judged byuniqueNullDistinctDivergenceandisUniqueViolationError: 10 of 10 agree on each (readings below).driver-mongodbwas not run against a server here: no mongod binary was reachable in this container (fastdl.mongodb.orgis blocked, and fetching the conda-forge build was refused). Its standing readings are PR fix(driver-mongodb): two records with a null unique field are both admitted, as on driver-sql and driver-memory #29339's real-mongod suite (mongod 8.3.7), which covers six of the ten rows:single_null_null,single_absent_absent,single_equal_value,single_empty_string,compound_one_null,compound_equal. The other four follow from the index shape that suite's server-free half pins (apartialFilterExpressionadmitting only non-NULL types on every key part). Its server-free half ran here:mongodb-unique-null-distinct.test.ts7 passed, 8 skipped (real-mongod, opt-in). The driver's adoption PR is the measurement for those four.nullbyupdate()was measured on driver-mongodb in fix(driver-mongodb): two records with a null unique field are both admitted, as on driver-sql and driver-memory #29339 only, so it is named as absent in the docblock rather than added without a measurement.syncSchemais a no-op (the remote service owns constraints). Its adoption card decides whether that cell is a suite or an EXEMPT row.⛔ MAINTAINER-ONLY. These six rows are what the card asks for (a case-set landing ahead of its drivers), so the maintainer's review of this PR is that agreement.Verification
Driver measurement, origin/main @ f95d0db (in-process, scratch script outside the tree; carried from #29509)
Every first write was admitted on both drivers.
Local runs on head 4ee136f (main merged at 2545021)
Heavy runs in one
os-verify-lock.shscript, VERDICTcommand-exit 0(held 22m32s on a shared box).turbo run build --concurrency=2(whole repo)pnpm --filter @objectstack/spec testpnpm --filter @objectstack/spec test:reponode scripts/check-driver-conformance.mjsOK — 66 covered cell(s), 6 in the DEBT ledger, 0 exemptpnpm --filter @objectstack/spec check:generated--fixre-added this PR's four names to api-surface/data.json and export-origins/data.json)dispatch-gates --commands(100 families, after the full build)--ran: 100 derived, 100 run, 0 NOT-MEASURED, 0 UNRUNcheck-changeset-no-major.mjs --base origin/main --event(this body)Clause-②: yes (widening)·Metadata-protocol: none· level stayspatch(a non-protocol change)Before opening,
origin/mainhad moved 13 commits to0e4b0fa4;git merge-treeagainst it reports no conflict, and none of the 13 touches the census,packages/spec/src/data/index.tsor the two generated files.No ablation: the diff changes no behaviour a test pinned before. The new test proves the table is not vacuous with six wrong readings instead (see Tests).
Human Minimum
packages/specholds no runtime logic. (Test-support constants and a pure judge, as invalue-roundtrip-conformance.ts.)pnpm lintpasses. (eslint over the four touched source files locally; the repo-wide run is CI's.)main, one pull request.packages/spectouched: its generated artifacts are regenerated and committed.content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.Generated by Claude Code