Repository navigation
feat(spec): the published JSON Schema states the marketplace taxonomy facets' no-duplicates rule as uniqueItems - #31047
Conversation
…ma projection The refinement projection gains a `unique-items` arm: a declared UNIQUE_SCALAR_ITEMS predicate (a Set over JSON scalars) is emitted as `uniqueItems: true`. The marketplace taxonomy's distinct() helper now passes that declared predicate instead of an inline arrow with the same expression, so businessFunctions and industries publish their no-duplicates rule; the eight dropped-refinement ledger rows retire. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibxH6kxj8gByoApv69p
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibxH6kxj8gByoApv69p
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibxH6kxj8gByoApv69p
📓 Docs Drift Check4 anchor(s) derived from 1 changed package(s); no hand-written page names any of them. What this run could not see
Coarse fallback — 171 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 c628fd23cd31b300e9bf1efb5f326e37c60166dd && git checkout c628fd23cd31b300e9bf1efb5f326e37c60166dd
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 115a43ad162cfe5ec96d2f7fe938afcae4290cf5 dd7ed18f7456bbcb3b08139245e919ad6bc7875f && git checkout -B drift-repro 115a43ad162cfe5ec96d2f7fe938afcae4290cf5 && git merge --no-ff dd7ed18f7456bbcb3b08139245e919ad6bc7875f
node scripts/docs-audit/affected-docs.mjs --json 115a43ad162cfe5ec96d2f7fe938afcae4290cf5 |
|
domain:spec#1 · os-tesla · session_01L9qibzzqHZdAVqgBAvxXKB Contract reviewServed-tier: ① Derived judgments
② Semver levelLevel:
③ Boundary flags
④ Design judgmentpackages/spec/src/shared/refinement-projection.ts — holds; one should-fix.
packages/spec/src/marketplace/taxonomy.zod.ts — holds.
Gates on the head (conclusions are the verdicts): green — Findings
Implemented-by: VERDICT: FAIL |
…dentity item parses The changeset now carries Clause-② no (narrowing), the BREAKING (published artifact narrows) banner and the ADR-0087 not-required marker. The unique-items arm and UNIQUE_SCALAR_ITEMS state that the item parse must be the identity on scalars: a coercing, trimming or transforming item would publish a file wider than the runtime. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibxH6kxj8gByoApv69p
|
domain:spec#1 · os-tesla · session_01L9qibzzqHZdAVqgBAvxXKB Contract reviewServed-tier: ① Derived judgments
② Semver levelResolved. Level
③ Boundary flags
④ Design judgmentpackages/spec/src/shared/refinement-projection.ts — holds; the should-fix is closed.
packages/spec/src/marketplace/taxonomy.zod.ts — unchanged on this head; the prior judgment holds (three lines inside Gates on the head (conclusions are the verdicts): 57 success, 11 skipped, no failure and nothing in progress — including Findings: none. Implemented-by: VERDICT: PASS |
|
domain:spec#1 · os-tesla · session_01L9qibzzqHZdAVqgBAvxXKB 维护者速读
席位意见:可以落地。 席位核对ACCEPT · seat
|
Requested by Tesla · project thread
Fixes #31036
Clause-②: no (narrowing)
Metadata-protocol: none
Skills-docs: none — no skill or doc teaches the facets' duplicate rule, and the reference renderer prints no
uniqueItems, so nothing inskills/**orcontent/docs/**states the narrowed rule.维护者速读
uniqueItems: true。businessFunctions、industries两个维度本身,以及嵌着它们的 6 个 schema(Package、CreatePackageRequest、UpdatePackageRequest、MarketplaceListing、TemplateManifest、MarketplaceSearchResponse)都带上了这条规则。['sales', 'sales']会被拒),但导出 JSON Schema 时丢了,编辑器提示和外部校验工具会放行重复值,作者要到发布时才被平台拒绝。packages/spec/src/shared/refinement-projection.ts(新的unique-items规则与「只对标量成立」的论证);packages/spec/src/marketplace/taxonomy.zod.ts(distinct()改用已声明的谓词,表达式不变);packages/spec/scripts/refinement-projection.test.ts(等价性与 Zod 行为不变的钉子)。pnpm --filter @objectstack/spec build && node -e "console.log(require('./packages/spec/json-schema/marketplace/MarketplaceBusinessFunctions.json').uniqueItems)",预期打印true。What changes
unique-items.src/shared/refinement-projection.tsadds the arm toProjectableRefinementandPROJECTABLE_REFINEMENT_PATTERNS, plus a declared predicateUNIQUE_SCALAR_ITEMS(new Set(values).size === values.length) and theJsonScalartype it takes. The generator half (scripts/lib/refinement-projection.ts) emits it as JSON Schema's ownuniqueItems: true, beside the node'stype/items/minItems/maxItems(noallOf:uniqueItemsis not a keyword the reference renderer reads as a type).Setcompares with SameValueZero,uniqueItemswith JSON equality. On strings, numbers, booleans andnullthose are one relation (0and-0are one value to both;"1"and1are two to both;NaNis not JSON). On objects they are not: aSetcompares by identity, so two equal objects would be two members to the runtime and one value to the file. The predicate's parameter isreadonly JsonScalar[], so composing it on a list of objects is a compile error rather than a wider-than-runtime file.distinct()insrc/marketplace/taxonomy.zod.tspassesUNIQUE_SCALAR_ITEMSinstead of an inline copy of the same expression, and its item type is bounded toz.ZodType<JsonScalar>so the call type-checks. Same message, samemin/max, same accept set. (Declared deviation below.)packages/spec/dropped-refinements.baseline.jsondeletes 8 entries (14 sites), and itsmeasuredblock is re-read from this build: 252 published schemas / 1023 dropped sites / 728 projected / 0 undecidable (was 260 / 1037 / 369 / 0; see Acceptance notes on the 369).@objectstack/specpatch with both declaration lines (Clause-②: no (narrowing),Metadata-protocol: none), the**BREAKING (published artifact narrows)**banner and oneadr-0087: not-required (no-migration-prescription)marker, as the earlier arms of this list carried.unique-itemsdocblock andUNIQUE_SCALAR_ITEMScarry a ⛔ paragraph: the item parse must be the identity on scalars (z.enum,z.literal,z.string(),z.number(),z.boolean(),z.null()), never a coercing, trimming, case-folding or transforming item, because the predicate judges the parsed output and the keyword the document, so such an item would publish a file wider than the runtime while the ledger readsprojected.Schemas that gain
uniqueItemsThe
distinct()helper is file-local totaxonomy.zod.tsand has exactly two callers. Every published schema that reaches them gains the keyword, and nothing else does (generator census:14 unique-items):projectedmarketplace/MarketplaceBusinessFunctionsmarketplace/MarketplaceIndustriesmarketplace/PackagebusinessFunctions,industriesmarketplace/CreatePackageRequestbusinessFunctions,industriesmarketplace/UpdatePackageRequestbusinessFunctions,industriesmarketplace/MarketplaceListingbusinessFunctions,industriesmarketplace/TemplateManifestbusinessFunctions,industriesmarketplace/MarketplaceSearchResponseitems.element.businessFunctions,items.element.industriesAll are intended: each is the facet itself or a schema whose property is the facet.
Tests
scripts/refinement-projection.test.ts(the arm's shared harness, two new top-leveldescribeblocks):unique-items;uniqueItems: truebeside the node's own keywords; it is idempotent;"1"vs1,0vs-0,1vs1.0afterJSON.parse,truevs1,null), a JSON-equalityuniqueItemsevaluator that is deliberately not aSetagrees with the predicate on every list;@ts-expect-errorpin that an array of objects cannot compose the predicate (live: the scripts tsconfig compiles the file);uniqueItems: trueand keep their array shape;Packagestates it at both properties; runtime and keyword agree on a facet corpus; the census reads every one of the 14 sitesprojectednamingunique-itemswith nothing dropped, for all 8 schemas;customcode and the helper's own message.Ablation (committed first,
scripts/ablation-replace.mjs, mutation proven on disk 1 → 0 anchor hits): with the emit body replaced byvoid jsonSchema;, 7 of the new cases go red (Tests 7 failed | 81 passed), including the census case, which shows the detector measures the generator's projection; restored,git diff HEADempty.Declared deviation
The claim's file surface lists the Zod schemas as out of bounds ("stop on breach"). The arm cannot see an inline arrow: the projection recognises only predicates registered through a factory in
refinement-projection.ts(aWeakMapkeyed on the function, and the design refusesfn.toString()matching). Sodistinct()intaxonomy.zod.tschanges three lines: the import, the inline predicate swapped forUNIQUE_SCALAR_ITEMS(same expression), and a type-only boundT extends z.ZodType<JsonScalar>, because Set equality matches JSONuniqueItemsonly on scalars and the bound keeps that guarantee at compile time instead of behind a cast. The seat ruled this in (seat thread, 2026-11-06 20:12Z ruling A for the swap, 20:14Z for the bound). No schema shape, message or accept set moves; the Zod-unchanged test above pins it.Acceptance notes
measured.refinementSitesThatDidProjectwas stale onmain. It read 369, while by arithmetic the generator onmainreads 714 (the 728 measured here minus the 14 sites this PR projects; not re-run onmain). The other threemeasuredvalues matched by arithmetic. The block is hand-kept and no gate reads it; I re-read all four from this build rather than moving only the three this change touches.Set-uniqueness refinements left alone.src/security/tenant-layer0-verdict.ts(organizationIds, a scalar list) is the same shape and could composeUNIQUE_SCALAR_ITEMS;src/data/object.zod.ts(groupsunique bykey) is uniqueness of a projection, not of items, so it is not this arm. Neither is in this card's surface.Clause-②: no (narrowing): nothing widens, and a narrowing of a published artifact is breaking. The level stayspatchbecause, under ruling A, it followsMetadata-protocol: nonealone; the sibling arm'sminor(170fd83) predates that ruling.distinct()restating the identity-parse rule. The seat's ruling cappedtaxonomy.zod.tsat three lines, so the rule lives inrefinement-projection.ts, whichdistinct()imports from.refinement-projection.ts(either half),dropped-refinements.baseline.jsonortaxonomy.zod.ts(read against the heads of the open code PRs around 20:30Z).content/docs/references/**do not move: the reference renderer does not printuniqueItems.Verification
Rework head `dd7ed18f` (contract review 6695604767)
check-adr-0087-registration --base origin/main:: exit 0, reading.changeset/31036-unique-items-projection.md [BREAKING+clause-②-narrowing] not-required (no-migration-prescription);check-changeset-no-major:: exit 0;check-empty-changeset:: exit 0;pnpm check:changeset-gate-self-tests:: exit 0.check:doc-authoring,check:spec-docblock-symbol-anchors,check:nul-bytes,check:issue-citations,check-closing-keyword-parity:: exit 0 each.tsc --noEmit:: exit 0;vitest run scripts/refinement-projection.test.ts scripts/dropped-refinements.test.ts src/marketplace::Test Files 9 passed (9),Tests 245 passed (245).(narrowing)arm):turbo run build --filter='./packages/**' --filter='@objectstack/dogfood^...'thenpnpm --filter @objectstack/dogfood test, underos-verify-lock, no shard, no path: VERDICT command-exit 0,Test Files 428 passed | 3 skipped (431),Tests 3562 passed | 41 skipped (3603), no failure.dd7ed18fat the time of this edit: 55 success, 9 skipped, 0 failure. The two reds onda4e41dd(TypeScript Type Check,Test UI) were aggregators over lanes cancelled at 21:11Z when this push superseded that head; no lane onda4e41ddconcluded failure.Earlier runs, on head
da4e41dd, baseorigin/main9d939c58(the rework moved only the changeset and a docblock):Build, generated artifacts, typecheck, tests
pnpm --filter @objectstack/spec build(real.d.ts, underos-verify-lock) :: exit 0. The generator census prints1023 refinement site(s) across 252 published schema(s)and728 ... DO reach the published JSON Schema, of which14 unique-items.json-schema/marketplace/MarketplaceBusinessFunctions.jsoncarries"uniqueItems": truebesideminItems: 1,maxItems: 3.pnpm --filter @objectstack/spec check:generated:: exit 0,All 14 generated artifacts are up to date(no reference page, api-surface or authorable-surface moves).pnpm --filter @objectstack/spec typecheck:: exit 0 (build program,tsconfig.scripts.json, which compiles the new test and its@ts-expect-error, and the test layer).pnpm --filter @objectstack/spec test:: VERDICT command-exit 0,Test Files 820 passed (820),Tests 25918 passed | 1 todo (25919).vitest run scripts/refinement-projection.test.ts scripts/dropped-refinements.test.ts src/marketplace::Test Files 9 passed (9),Tests 245 passed (245).Ablation
node scripts/ablation-replace.mjs --file packages/spec/scripts/lib/refinement-projection.ts --anchor " jsonSchema.uniqueItems = true;" --replacement " void jsonSchema;" -- ... vitest run scripts/refinement-projection.test.ts:ok mutation landed: anchor 1 -> 0,Tests 7 failed | 81 passed (88). The 7: emit, idempotence, the scalar equality pin, both live-seam shape cases, the facet corpus agreement and the 8-schema census. Restored:git diff HEADempty, anchor count 1. No build needed: the suite importssrc/andscripts/libdirectly.Derived gates (82 families)
node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstackderived 82 families onda4e41dd; all 82 exit 0. Record:31036-gates-ran-da4e41dd.listin the seat's out folder.--ranreconciliation:82 derived, 82 run, 0 NOT-MEASURED, 0 UNRUN.check-plugin-teardown-shape --self-test(git fetch --unshallow origin main), lintcheck:doc-formula-expressions,check:dual-build-cjs-loads,check:lean-entry-closure(turbo run build --filter='./packages/**' --filter='@objectstack/dogfood^...').check:skill-frame-freshnessexit 0;check:dev-prereqsexit 1 NOT MEASURED, reason: 34ui/workspace packages have nodist/in this worktree (box state, the diff touches noui/path).