Skip to content

fix(units): raise the blank-unit debt of a unitField re-pointed at a new field; name unused code-keyed mapping entries; say what a capped walk did not judge - #37268

Queued
objectstack-fleet[bot] wants to merge 2 commits into
mainfrom
claude/issue-35885-unit-repoint-backfill-gaps
Queued

objectstack-fleet[bot] wants to merge 2 commits into
mainfrom
claude/issue-35885-unit-repoint-backfill-gaps

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

repo:objectstack#7 · os-alice · session_011y7As5bdhV5T4N9vpjmZzH
Part of #35885
Clause-②: no
Metadata-protocol: none

维护者速读

  • 管理员在一次保存里把某个数量字段的单位改指向一个新建字段时,保存会先被拦下,提示所有存量行将缺单位并给出补写办法;单位换算工具的报告会点出没被用上的映射条目,只扫了部分行时也会明说其余行未判定。用户的数据本身不变。
  • 属于"计量单位"标准里单位换算回填这一块的收尾,替转换大表或改表结构的运维人员补上三个提示缺口。
  • 若判断有误,管理员只会多看到一次可强制跳过的拦截提示,或报告里多一两行说明;不改任何已存数据,可以直接撤回。
  • 无

What changes

Three follow-up gaps of the unit-code backfill door (ADR-0158 R1), each inside the claim's file surface:

  1. A unitField re-pointed at a new field raises its blank-unit debt. detectDestructiveObjectChanges now raises 409 DESTRUCTIVE_CHANGE with unit_mode_to_record on a stored record-mode quantity whose unitField is re-pointed at a field that held no stored unit before the save (new in it, or unstored before it). The message names the re-point, the blank beside every stored quantity, and the "" entry of the unit-code run, CLI and REST. It reads no row and force: true lifts it. The once-only rule of newlyDeclaredUnitCodeFieldsOf is kept: a re-point onto a stored text field still raises unit_code_field_declared alone (it names the quantity), and a re-point onto a field that already was a unit code field still raises nothing (the currency_field_repointed sibling, out of R1). Code choice: the existing unit_mode_to_record, not a new unit_field_repointed. The debt is the same blank-unit debt, the spec's issues[].code describe text lists the codes and stays unchanged, and a new code would be a packages/spec edit outside the claim.
  2. N3, unused code-keyed mapping entries are named. A value stored as a unit code (member, retired, other-dimension) that is also a mapping key no row used now carries unusedEntry (the code that entry names) in the report, and the printed report adds one line per such entry. An entry that some row did use, for example in another organization where the text is not a unit, is not named.
  3. N4, a truncated walk says what it did not judge. Shape chosen: report, not refusal, to match the currency twin. record-currency-backfill.ts writes over a walk the maxRecords cap cut short and reports it. The unit backfill now does the same thing in the same words: the printed report says the rows past the cap were not judged, so any of them may hold a value with no mapping entry, and that an apply run wrote only the rows it examined. An unscoped run also gets the currency report's line that the organization check saw only the rows examined. The CLI prints these lines from the shared formatter, so no packages/cli edit was needed. Refusing apply over a truncated preview would be a narrowing the currency twin does not have.

The module header of unit-code-backfill.ts is amended. "One run converts the whole field or nothing" now holds over the rows the run examines.

Read first (by risk):

  1. packages/metadata-protocol/src/protocol-write-face.ts, the new re-point branch ahead of the unit_mode_to_record switch branch. The risk is the predicate: prevUnitField !== unitField and !prevUnitCodeFields.has(unitField), with the declaredUnitCodeFields gate shared with the switch branch.
  2. packages/objectql/src/protocol-destructive-unit-mode.test.ts, the new pin and the widened once-only it.each loop, which now also checks re-points.
  3. packages/objectql/src/unit-code-backfill.ts, the unusedEntry pass after the walk and the truncated lines in the formatter.

Tests

Readings taken on head 0237272ee3f (final commit; base d62f9e9c05a).

  • New pin: a stored record-mode quantity re-pointed at a new field gets 409 DESTRUCTIVE_CHANGE / unit_mode_to_record, asserting code and status. The test checks the message, reads no row, and confirms force: true lifts it. The once-only it.each gains two re-point cases, and its debt loop now covers re-points as well as switches.
  • New pins in unit-code-backfill.test.ts: unusedEntry and its report line, and an apply run capped at 2 rows. That run writes the 2 rows it examined, leaves the unseen unmatched rows as stored, prints the not-judged line, and the uncapped run is still refused VALIDATION_ERROR / 400.
Package tests and typecheck
  • pnpm --filter @objectstack/objectql --filter @objectstack/metadata-protocol typecheck, then each package's pnpm test, under the verify lock: VERDICT command-exit 0.
  • metadata-protocol: Test Files 370 passed | 9 skipped (379), Tests 23417 passed | 45 skipped (23462).
  • objectql: Test Files 638 passed (638), Tests 14428 passed (14428).
  • Targeted run before that: Test Files 3 passed (3), Tests 75 passed (75), for the destructive-unit-mode, unit-code backfill and record-currency backfill test files.
Ablations (one per fix, through scripts/ablation-replace.mjs; each restored, blob equals HEAD and git diff HEAD is empty)
  • A1, the re-point predicate: prevUnitField !== unitField was changed to a never-true comparison. metadata-protocol was rebuilt, and ablation-dist-preflight found the marker present in 2 built files. Result: 3 failed, 21 passed, namely the new pin and the two new it.each re-point cases. Restore leg: rebuilt, and the marker is absent from all 24 built files.
  • A2, the unusedEntry assignment was removed. Result: 1 failed, 28 passed, the new N3 pin.
  • A3, the truncated wording was blanked. Result: 1 failed, 28 passed, the new N4 pin.
Gates
  • Derived with node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack (69 families). Each one was run locally, with its exit code captured before any pipe.
  • 68 exited 0. pnpm check:dual-build-cjs-loads exited 3, PREREQUISITE NOT MET — this gate reads built output, and some package has no dist/. That is NOT MEASURED, because a full pnpm build was not run. CI's Lint & Repo Gates measures it.
  • --ran reconciliation: 69 derived, 69 run, 0 NOT-MEASURED, 0 UNRUN. The runner's NOT-MEASURED claim is corrected by the dual-build line above.
  • The PR check-runs are read by the seat (no CI polling here).

Acceptance notes

  • ADR-0158 amendment not in this PR. The card's Done-when asks for Open item 9's trailing note and Open item 12 to be amended. docs/adr/** is outside the claim's file surface and is a governed Tier H path, which would make this code PR Tier H. So this PR says Part of, and the amendment is left to the owning seat as its own ADR-note PR. Proposed text: in Open item 9, replace the sentence carried by the card with "A unitField re-pointed onto a field new in the same save, or unstored before it, raises unit_mode_to_record on the quantity, for the blanks beside it; one re-pointed onto a field that already was a unit code field raises nothing in R1 (the sibling of currency_field_repointed)". In Open item 12's Dry-run-and-apply point, replace "A preview cut short at its row limit is reported as truncated" with "A walk cut short at its row limit judges only the rows it examined: an apply run writes those, and the report says that the rows past the limit were not judged, as the currency backfill's does; a mapping entry whose key is stored as a unit code and that no row used is named in the report".
  • The unit_mode_to_record describe in the spec (issues[].code) and the generated protocol reference are unchanged: the code list did not move.
  • packages/cli untouched: the CLI prints the formatter's lines. Its own unit-codes tests were not run locally (the package's public face is additive, an optional field); CI's Test Core runs them.

Verification

Run pnpm --filter @objectstack/objectql exec vitest run --maxWorkers=2 src/protocol-destructive-unit-mode.test.ts src/unit-code-backfill.test.ts after building metadata-protocol. Expect every test to pass, including the three new pins named above.


Generated by Claude Code

…new field; name unused code-keyed mapping entries; say a capped walk judged only the rows it examined

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011y7As5bdhV5T4N9vpjmZzH
@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

6 anchor(s) derived from 2 changed package(s); no hand-written page names any of them, so this run has nothing to list — not a clean bill of health. This check sees only pages that NAME a derived anchor: one that documents this change in prose, or enumerates it in an authoring dialect, names none and stays invisible to it on every run.

What this run could not see
  • the SDK route bridge reached 69 of 252 client-bound route-ledger rows — the other 183 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 183: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 124 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 27 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 7939732f3520015a9201f924998632deda118ea6 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from f5ae5fb8f81f029b9a64b4db6adc8f5c36b3fb06 — the merge of head 0237272ee3f9eee0f4ed263f354ef3eb12dbb684 into base 7939732f3520015a9201f924998632deda118ea6, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin f5ae5fb8f81f029b9a64b4db6adc8f5c36b3fb06 && git checkout f5ae5fb8f81f029b9a64b4db6adc8f5c36b3fb06
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 7939732f3520015a9201f924998632deda118ea6 0237272ee3f9eee0f4ed263f354ef3eb12dbb684 && git checkout -B drift-repro 7939732f3520015a9201f924998632deda118ea6 && git merge --no-ff 0237272ee3f9eee0f4ed263f354ef3eb12dbb684

node scripts/docs-audit/affected-docs.mjs --json 7939732f3520015a9201f924998632deda118ea6

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · os-alice · session_011y7As5bdhV5T4N9vpjmZzH

L1 review — PR #37268 at 0237272ee3f9eee0f4ed263f354ef3eb12dbb684 (2026-11-25T10:05Z)

L1: PASS (one-shot reviewer subagent; card #35885, Part of #35885)

  • Shape: l1-face.mjs --pr 37268 CLEAN at this head (13 items: draft, base main, first line Part of #35885, no closing keyword, changeset covers both touched packages, floor checks success, 37 success / 16 expected skip as the seat read). Part of is right: item 4 (the ADR-0158 amendment) stays with the seat, so the card must not close; pm:dispatched comes off by hand at landing.
  • Item 1 (re-point onto a blank field): detectDestructiveObjectChanges (protocol-write-face.ts) raises unit_mode_to_record on the quantity when a stored record-mode quantity's unitField moves to a field that was no unit code field before the save and that newlyDeclaredUnitCodeFieldsOf does not claim. The three neighbours hold in the code as read: onto a stored text field ⇒ declaredUnitCodeFields has it, so unit_code_field_declared alone; onto a field already a unit code field ⇒ prevUnitCodeFields has it, nothing; the old mode-switch arm is the else if, so a quantity is never named twice. Reads no row. One caller only (protocol-save.ts:1209), which already carries force; no second path to miss.
  • Item 1 pin is real: protocol-destructive-unit-mode.test.ts:177 asserts code: 'DESTRUCTIVE_CHANGE', status: 409, the single issue's code and field, the wording, the remedy parts, readNoRow, and force: true ⇒ []. The once-only table gains two rows (mat_gross, mat_pair) and its "named exactly once" loop now covers a re-point. The sibling pins (:145 stored text field, :197 code field to code field ⇒ nothing) were already on main.
  • Item 2 (unusedEntry): set after the walk on member / retired / other-dimension values that are mapping keys; printed as one ⚠ line each. Pinned on the report value (toEqual, exact), the printed line, and the negative (no line without such an entry).
  • Item 3 (capped walk): the card allowed "refused, or said plainly"; the PR says it plainly and keeps the currency twin's shape, with the unscoped-organization line word for word that of record-currency-backfill.ts:537. Pinned: capped apply writes the 2 examined rows, the rows past the cap are untouched, unitCodeBackfillComplete is false, both lines exact, and the uncapped run is refused with code: 'VALIDATION_ERROR', status: 400.
  • Changeset read sentence by sentence against the diff: all three bullets hold ("a re-point onto a stored text field still raises unit_code_field_declared alone" = pin :145; "still raises nothing" = pin :197; "an apply run over such a walk still writes the rows it examined, as before" = no engine change in the diff, only the report).
  • No file outside the card; no generated artefact; no SQL or id materialisation added.

Findings

  • N1 (nit): the re-point arm's second cause, a target that existed before the save but was not stored, has no pin of its own; only the new-field cause is pinned at :177. The predicate is the same !prevUnitCodeFields.has test either way. Follow-up at most.
  • N2 (nit): in walkUnitCodes the !used.has(v.value) test can never be false for a value whose disposition is not mapped (values are keyed by value), so it is dead but harmless.

Contract review

Served-tier: TIER_DEFAULT
Head-sha: 0237272ee3f9eee0f4ed263f354ef3eb12dbb684
Local-runs: none
Scope: packages/metadata-protocol/src/protocol-write-face.ts, packages/objectql/src/unit-code-backfill.ts + packages/objectql/src/protocol-destructive-unit-mode.test.ts, packages/objectql/src/unit-code-backfill.test.ts, .changeset/35885-unit-repoint-backfill-gaps.md
Security-touching: no
Rule-change-verified: none

① Derived judgments

  • The diff touches no published schema (packages/spec/src/**) and no governed rule text; it declares Clause-②: no with no arm. The record is here because the new 409 refuses a save that main accepts, which would be a narrowing if the surface were published.
  • The claim "the unit surface is unreleased" holds, verified three ways. (a) At the last release tag @objectstack/metadata-protocol@18.6.0 (npm latest = 18.6.0), git grep finds no unit_mode_to_record, no unit_code_field_declared under packages/metadata-protocol/src or packages/objectql/src, and no unitConfig under packages/spec/src. (b) On origin/main the surface is carried only by pending changesets: 35489-unit-config, 35491-unit-raw-aggregate, 35492-unit-code-backfill, 35970-catalog-units, 36082-record-unit-summary. (c) No package CHANGELOG.md on origin/main mentions unit_mode_to_record, unitConfig or migrate unit-codes.
  • So the refusal narrows nothing a released version accepts: no 18.6.0 author can write a record-mode unitConfig at all. Clause-②: no holds, and no (narrowing) arm is owed.
  • Noted, not a finding: npm also carries a next dist-tag (0.0.0-next-… snapshot of main). A snapshot is the pending changesets, not a release; the card itself grades this "unpublished surface until the R1 release".

② Semver level

  • Metadata-protocol: none with patch on both packages is right: no key, value or type an author can write is added or removed. The finding is a force-liftable destructive-change guard under an existing code (unit_mode_to_record), not a refusal of a shape; force: true saves the same metadata. Both packages already take minor from the pending 35492 changeset (Clause-②: yes, Metadata-protocol: added), so the release level is unchanged.
  • unusedEntry is an optional field added to a report type that is itself unreleased; additive either way.

③ Boundary flags

  • Error envelope: the existing DESTRUCTIVE_CHANGE / 409 with an existing issue code; no new code for a client to learn, and the pin asserts code and status.
  • No row read in the detector (pinned by readNoRow); the backfill change is report-only, the walk and write paths are untouched. No id materialisation or in-application join added.
  • PR author is the fleet bot; nothing to name.

Implemented-by: claude/issue-35885-unit-repoint-backfill-gaps
Reviewed-by: session_011y7As5bdhV5T4N9vpjmZzH

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · os-alice · session_011y7As5bdhV5T4N9vpjmZzH

席位核对 — ACCEPT · head 0237272

  • L1 + Contract review PASS 7159229606 at this head; open [] / unreadable []. Two nits (N1 no pin for the "target existed but was unstored" cause; N2 a dead !used.has guard), neither blocking.
  • Unreleased claim verified by the reviewer: no unit_mode_to_record / unitConfig at tag @objectstack/metadata-protocol@18.6.0; the unit surface sits only in pending changesets. Clause-②: no, Metadata-protocol: none; no dogfood battery owed.
  • CI at this head: 37 success, 16 skipped, 0 failed (read by the seat).
  • Dev readings (os-dev report on units: a unitField re-pointed at a field new in the same save raises no finding, and two backfill report gaps (follow-up of PR #35865) #35885): objectql 14428 tests and metadata-protocol 23417 tests passed under the lock; 68 of 69 gate families exit 0, check:dual-build-cjs-loads NOT MEASURED locally (prerequisite), covered by CI Lint & Repo Gates.
  • Part of #35885 stands: Done-when item 4 (ADR-0158 Open item 9/12 amendment) is a Tier H docs/adr/** path; the seat carries it as its own PR from the proposed text in this PR's Acceptance notes, then closes the card.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · os-alice · session_011y7As5bdhV5T4N9vpjmZzH

Landing — seat arms #37268

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants