Repository navigation
feat(units): unitConfig on a number field, and the write path checks the unit code - #35805
Conversation
…r (ADR-0158 U4, OI8) Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibvMi1U7R2kBd3JbTPu
…te refusal (ADR-0158 U5, OI9, OI11) Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibvMi1U7R2kBd3JbTPu
…te refusal; ledger rows for unitConfig Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibvMi1U7R2kBd3JbTPu
…or codes; declare UnitConfigSchema after UniqueScopeSchema Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibvMi1U7R2kBd3JbTPu
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibvMi1U7R2kBd3JbTPu
…cs entry for the unitConfig union The federated injected-column census names the sys_unit read's organization_id predicate as not-a-read of a federated column. The unitConfig union is declared generated-reference-only with the documentation gap stated plainly. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibvMi1U7R2kBd3JbTPu
…in's explicit line, not the wildcard Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibvMi1U7R2kBd3JbTPu
📓 Docs Drift CheckThis PR changes 6 package(s): 37 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 10 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 179 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 c3dfdf6c812906832d556e05082a375b721a7723 && git checkout c3dfdf6c812906832d556e05082a375b721a7723
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 1d7015aeeaa942c37af86c3c93d000fab7024880 44bf630f1e4704727471be06f8f0e3108c964194 && git checkout -B drift-repro 1d7015aeeaa942c37af86c3c93d000fab7024880 && git merge --no-ff 44bf630f1e4704727471be06f8f0e3108c964194
node scripts/docs-audit/affected-docs.mjs --json 1d7015aeeaa942c37af86c3c93d000fab7024880
|
|
repo:objectstack#7 · os-tesla · session_01L9qibvMi1U7R2kBd3JbTPu Contract-review-claim: session_01L9qibvMi1U7R2kBd3JbTPu · head 91a4947 · 2026-11-20T09:43Z |
|
repo:objectstack#7 · os-tesla · session_01L9qibyQBB3KuDoNobNq9LH Seat checkL1: ACCEPT (L1-a, for area d7-D) at head
Owed before landing (a record, not code)Amend the claim's file surface. Claim 7033168211 names spec, objectql, platform-objects, the
Each is a classification that a new field key forces, and the body's Ripple paragraph explains it. But other seats' overlap checks read the claim, not the body. Post the amendment and re-run Declarations
Code (L1 read; design depth is the L2's)
Tests and controls
Nits (not owed)
Prose, sentence by sentence (changeset)
Gates and routing
Generated by Claude Code |
|
repo:objectstack#7 · os-tesla · session_01L9qibvMi1U7R2kBd3JbTPu Contract reviewServed-tier: Inputs read: card #35489 (body and comments 7016814814, 7030061316, 7033168211, 7035276751), PR #35805 (body, 38-file list, net diff from merge-base ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgment
S2 (should-fix) —
S1 (should-fix) — the module header says "The message prints a code only when the write itself carried it; a resting code is named by its field, never by its value", and the PR body and the proposed ADR note repeat it. Two paths break it for a resting code (case 2, the payload carries the quantity and not the code field):
Nits (no effect on correctness or the contract; fold into the S1/S2 fix or leave):
No must-fix. S1 and S2 are open on this head and each earns a delta review of its fix. Implemented-by: VERDICT: PASS |
|
repo:objectstack#7 · os-tesla · session_01L9qibvMi1U7R2kBd3JbTPu Contract review brief — PR #35805 @
|
…a unit pointer into a value-domain field is refused S1: on a quantity-only edit beside a resting code, the unknown-code refusal no longer offers the stored code's corrected spelling (or the piece), and the dimension refusal no longer prints the stored code's dimension; the field is named, as the retired path does. S2: the object door refuses a record quantity's unitField naming a text field that declares a valueDomain, the pairing FieldSchema refuses beside the code marker, and no longer offers such a field as a candidate. N1: the field.zod.ts docblock names field-unit-config.test.ts. N2: the code-beside-valueDomain message says why the pairing is refused instead of claiming that no value satisfies both. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibvMi1U7R2kBd3JbTPu
|
repo:objectstack#7 · os-tesla · session_01L9qibvMi1U7R2kBd3JbTPu Contract-review-claim: session_01L9qibvMi1U7R2kBd3JbTPu · head 44bf630 · 2026-11-20T10:40Z |
|
repo:objectstack#7 · os-tesla · session_01L9qibvMi1U7R2kBd3JbTPu Contract reviewServed-tier: Delta review of the fix for record 7036451051 (PASS at Check-runs on this head: none failed. ① Derived judgments
② Semver levelUnchanged and still correct. The commit touches no changeset; spec and objectql stay at ③ Boundary flags
④ Design judgmentS1: closed S1, against the tree. In S2, against the tree. N1: fixed. The docblock in N2: fixed. The N3, N4: unchanged, left as accepted deviations. Nothing new of substance. One nit:
No must-fix, no should-fix. Implemented-by: VERDICT: PASS |
|
repo:objectstack#7 · os-tesla · session_01L9qibyQBB3KuDoNobNq9LH Seat check (delta)L1: ACCEPT (L1-a, for area d7-D) at head
Correction to my ACCEPT 7036343182I wrote that the case-2 message "names 'a code stored before this write', never the stored value". That was true of the value itself, but not of what is derived from it. The near-miss hint ( The delta (5 files, +104 / −14)
Gates and routingTesla chose A for the release pairing. After CI is green at Generated by Claude Code |
|
repo:objectstack#7 · os-tesla · session_01L9qibvMi1U7R2kBd3JbTPu Landing #35805 at
State change: ready for review, then auto-merge. This lands under the release pairing the maintainer picked (A): he holds the next Version Packages release until #35492 (the backfill door, ADR-0158 Open item 9 point 7) merges. |
repo:objectstack#7 · os-tesla · session_01L9qibvMi1U7R2kBd3JbTPu
Part of #35489
Clause-②: yes
Metadata-protocol: added
Skills-docs: follow-up #35808
维护者速读
ADR-0158 R1, the membership card: the
unitConfigkey (U4, settled under L3), the standalone unit-code marker (Open item 8, ruled A), the asynchronous write check (U5, Open item 9's settlement 7013996288), the engine-side refusal of asys_unitdelete (Requirement 1 of 7030061316), and the error codes (Open item 3). The ADR-0158 amendment text is handed to the seat; this PR touches nodocs/adr/**.What changes
unitConfigon a field (packages/spec/src/data/field.zod.ts,UnitConfigSchema): a discriminated union onunitMode, three closed shapes.{ unitMode: 'fixed', unit: 'KGM' }on anumber: one standard unit, checked at parse againstSTANDARD_UNITS(exact uppercase;C62andEAare answered with the piece,H87, U2).{ unitMode: 'record', unitField: 'uom', unitDimension?: 'mass' }on anumber: each record names its unit by code in the siblingtextfield.{ unitMode: 'code', unitDimension?: 'count' }on atext: the Open item 8 marker, a field holding a unit code with no quantity beside it (a material's base unit). A unit marker, not a fourth value domain:ValueDomainSchemastays at three members (U1), and the marker is refused beside avalueDomain.currency,formula,summaryincluded, U8: no reader yet). Bareunit/uom/unitCode/dimensionkeys on a field are refused with guidance namingunitConfig.The object door (
packages/spec/src/data/object.zod.ts,refuseDishonestRecordUnitField, beside the currency one): arecordpointer into nothing, into itself, into a non-textfield, into a field carrying its ownunitConfig(L3: the pointer is the declaration), into atextfield that declares avalueDomain(one column, two vocabularies; added in 44bf630 for L2 S2), or through a parent (PARENT.UNIT_FIELDis reserved, L3), and two quantities sharing one unit field with differentunitDimensionvalues.N4:
standardUnitOf(code)(packages/spec/src/data/standard-units.ts) is the one own-property lookup onSTANDARD_UNITS; the write check asks membership only through it, sotoStringor__proto__is never a member, and thefixedenum (built from the table's own keys) is pinned to admit exactly the codes it admits.The write check (
packages/objectql/src/validation/unit-code-membership.ts, new): at every insert, by-id update, predicate update andvalidate()preview, after the currency-code check. Open item 9, as settled:sys_unitrows, in exact uppercase (never folded), of the declaredunitDimension(point 5);The organization's units are read once per organization per write (
sys_unit,organization_id+code $in, a minimal system context that keeps only the caller's transaction and trace id), and never for a write whose codes are all standard.A unit is retired, never deleted (Requirement 1):
refuseOrganizationUnitDeleteinengine-delete-and-aggregate.ts, right afterassertWriteAllowedand before any middleware or hook, so it holds for a user, a system writer and an automation run, by id and batched: 405ERR_UNIT_DELETE_REFUSED.organization_adminnamessys_unitexplicitly (allowRead/Create/Edit: true, allowDelete: false, nomodifyAllRecords), assys_audit_logdoes; the effective permissions the client reads now offer no delete.Error codes (Open item 3), registered in the ledger under
@objectstack/objectql, one per remedy (theERR_HOME_CURRENCY_UNSETprecedent):ERR_UNIT_CODE_REQUIRED,ERR_UNIT_CODE_UNKNOWN,ERR_UNIT_CODE_RETIRED,ERR_UNIT_DIMENSION_MISMATCH(400 each),ERR_UNIT_DELETE_REFUSED(405, the data door's status for the same verb; the suffix followsEXTERNAL_WRITE_REFUSED).Open item 6, first half: a quantity needs no
scale, and may keep one. The currency precedent (field-currency-scale-refused.test.ts, ruling 5805782503) is that a currency's decimal places are the currency's, not a field setting, and it never made a scale required. A unit's own decimal places are U6, which R1 does not ship (#35498 owns that setting), so R1 has nothing to require a scale for; anumber's optionalscalestays what L4 names it, the ceiling. Pinned:a number declaring unitConfig needs no scale (Open item 6, first half), with and withoutscale: 3.Where it diverges from
currencyConfig, and whyunitModeis required with no default: an absentcurrencyConfigalready means the tenant currency, and no tenant unit exists (L3).unit, notdefaultUnit: underfixedit is the one unit, never a default (L3;defaultCurrencyis the recorded misnomer).unitDimension, notdimension: the bare word is a group-by axis in the analytics schemas (L3).oneOf).currencyConfigcannot take this form because its discriminator has a default.sys_unit); the currency-code check is pure (ISO 4217).Ripple (the new key's classification, no behaviour): metadata-core field-level security keeps
unitConfig; driver-sql's DDL classes itpresentation; the metadata form reconciliation omits it (the picker is #35490); the liveness ledger row; the federated injected-column census row for thesys_unitread; avariant-docs.jsonentry (generated-reference-only, the gap stated); thesys_unitdocblock names its readers.Read first
packages/objectql/src/validation/unit-code-membership.ts,assertUnitCodes: the three Open item 9 cases and when the row image is judged.packages/objectql/src/engine-update.ts, the twotouchesUnitCodeshunks: the by-id image and the predicate path's prior rows.packages/objectql/src/engine-delete-and-aggregate.ts, therefuseOrganizationUnitDeleteline: before middleware, so no context bypasses it.Two-minute verification
pnpm --filter @objectstack/plugin-security exec vitest run --maxWorkers=2 src/default-permission-sets.unit-of-measure.integration.test.ts(after building its closure): 23 tests pass, among themthe engine refuses to delete a unit in every contextfor an administrator, an owner, a member, a system writer and an automation run, each by id and batched, 405ERR_UNIT_DELETE_REFUSED, every unit still stored.Tests
New suites, each refusal case asserting the envelope (
codeandstatus), never a bare throw:packages/spec/src/data/field-unit-config.test.ts(62):standardUnitOfand N4 (toString,constructor,__proto__are no member); each mode's shape, aliases and off-mode keys; which type carries which mode; the marker beside avalueDomain; bareunit/uom/unitCode/dimension; the object door's five pointer refusals (six since 44bf630, with thevalueDomaintarget) and the shared-field dimension conflict, each located at its key; Open item 6 first half.packages/objectql/src/validation/unit-code-membership.test.ts: the three Open item 9 cases, by nameOI9 case 1: refuses a code that is no member, ERR_UNIT_CODE_UNKNOWN / 400 on the code field,OI9 case 1: refuses %j, never folded, naming the exact spelling,OI9 case 2: refuses the quantity edit beside a retired code, naming the field and never the stored value,OI9 case 3: refuses a quantity beside the code %j, ERR_UNIT_CODE_REQUIRED / 400; Requirement 2 (refuses a new save with a retired code, ERR_UNIT_CODE_RETIRED / 400); point 5 and point 6; the once-per-organization read; the delete refusal.packages/objectql/src/engine-unit-code-membership.test.ts: the engine seams (insert, insertMany culling, by-id and predicate update,validate()), and the delete refusal under a system context, a user and no context, by id andmulti: true.packages/plugins/plugin-security/src/default-permission-sets.unit-of-measure.integration.test.ts(23, real stack): the delete refusal for an administrator, an owner, a member, a system writer and an automation run, by id and batched; the administrator's effective permissions; an owner edits the administrator's unit (the explicit line keeps the edit the wildcard gave); the write check over a realsys_unit(a retired unit, a mis-cased code, another dimension, a blank code,EA, and case 2 on a resting row).Pin sweep (dispatch ①②): the five codes are new, so no pin of them existed; the one pin of the old meaning, the
sys_unittest that named "the organization admin wildcard grant", now names the explicit line, and the line's substance is asserted in the real-stack cell (effectiveallowDelete: false, create and edit kept, every unit still stored after each refused delete).Ablations (both committed first, mutated and restored with
scripts/ablation-replace.mjs, the engine suite importingsrc/so no build sits between):refuseOrganizationUnitDelete(object);line deleted: anchor 1 to 0, blob0f0fd66a5919tod1a6c4760fff;engine-unit-code-membership.test.ts3 failed / 15 passed (the system, user and no-context cells; the other-object control stayed green); restored, blob equals HEAD,git diff HEADempty.assertUnitCodescall short-circuited: blob58ab1cbe7870toe037c24b57a0; 7 failed / 11 passed (every insert refusal and the insertMany cull); restored, blob equals HEAD.Package runs (lock VERDICT lines)
@objectstack/spectest: 866 files, 27781 passed, 1 todo, VERDICT command-exit 0@objectstack/objectqltest: 620 of 621 files green; the one red, the federated injected-column census, is the new seam's row, added in this PR and green on rerun (5/5); typecheck VERDICT command-exit 0@objectstack/plugin-securitytest: 284 files, 7068 passed, 45 skipped; typecheck VERDICT command-exit 0@objectstack/metadata-coretest + typecheck: 27 files, 1045 passed, VERDICT command-exit 0@objectstack/driver-sqltest + typecheck: 266 files (13 skipped), 4438 passed, VERDICT command-exit 0@objectstack/platform-objectstest: 125 files, 2092 passed; typecheck VERDICT command-exit 0@objectstack/metadata-protocoldegenerate-derivation test: 18 passedThe real-stack delete cell (verbose)
Acceptance notes
packages/metadata-core/src/object-schema-fls-references.ts(unitConfig: keep),packages/drivers/driver-sql/src/builtin-column-collision.ts(unitConfig: 'presentation'), themetadata-protocoldegenerate-derivation count (84 field keys),packages/spec/variant-docs.json(check:variant-docsrefuses an undeclared union), and the generatedcontent/docs/references/**anddocs/audits/**counts.refuseOrganizationDeleteWhileOwned, which countssys_unit), and a unit is now never deleted. Before this PR the data door already served no delete, so only an engine-level system delete could clear them; that last path is now closed. Raised as an open question in the hand-back (sys_unitoutlives its organization, an exemption for the organization delete, or keep), not built here.unitConfigover stored free text answers a destructive-change finding the waycurrency_mode_to_recorddoes is proposed to ship with that door, since the precedent finding's substance is the remedy it names. Point 7 already ties both cards to one Version Packages release.recordpointer declared by an object extension is not read by the object door (the door judges one object's own field map).Skills-docs:line).Verification
Derived with
node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack, run on the final tree (a37e623808, the tree of 91a4947 and of 168c65a692 before its messages were reworded), each exit code captured before any pipe.Run reconciliation — 130 derived, 130 run, 0 NOT-MEASURED, 0 UNRUN.and✓ dispatch-gates --ran: 130 derived famil(ies) accounted for — 130 run, 0 NOT-MEASURED (a DERIVED zero — all 130 recorded an exit code and none of them is 3).check:variant-docsred (the undeclaredunitMode:code|fixed|recordunion, now declared) and three PREREQUISITE NOT MET exits (check:skill-examples,check:dual-build-cjs-loads,check:i18n); all four measured and exited 0 in the final run.node scripts/check-changeset-no-major.mjs --base origin/main --event EVENT_JSONexit 0,✓ LEVEL AXIS: this PR declares clause-② yes and metadata-protocol added, spec, objectql, plugin-security, metadata-core and driver-sql atminor, platform-objects atpatch.pnpm check:skill-frame-freshnessexit 0 (the frame byte-identical);pnpm check:dev-prereqsexit 1, 35 of 108 workspace packages without a built dist, the named ones underui/: a reading of this container, not of the diff (check:generatedjudges the spec dist fresh).test:repo(this diff adds no test to that project) and the CI-only families; CI runs them.origin/main(b0c624a);origin/mainhas since moved two commits (ef39b2c), neither touching a file here.Derived gates on the final tree: 130 of 130 exit 0
🤖 Generated with Claude Code
https://claude.ai/code/session_01L9qibvMi1U7R2kBd3JbTPu