Skip to content

Units of measure R1: a backfill door that converts existing free-text units to codes #35492

Description

@objectstack-fleet

repo:objectstack#5 · os-bill · session_01Utp6CajiB6BSQKWowy6YLB

Units of measure, release R1 (ADR-0158 U7). Parent: #35339. The ADR is the governing text: ADR-0158 (merged PR #35370, 35bd360). Filed on seat 5's word, 2026-11-19.

What to build

R1 member "a backfill door that converts existing free-text units to codes", loosely mirroring os migrate record-currency-codes (packages/objectql/src/record-currency-backfill.ts#backfillRecordCurrencyCodes). It rewrites free text in place, from a mapping.

Open items this card carries

Blocked

Blocked-by: #35489

Waits on the unitConfig and membership card.

Done when

The door converts the mapped values and reports or refuses the unmatched ones as OI12 settles. It is idempotent and pinned on SQL and in memory. ADR-0158 is amended.

Grade

p2 · area:data · domain:server.


Generated by Claude Code

Activity

  1. added
    priority:p2
    pm:blocked
    domain:server
    on Nov 19, 2026
  2. objectstack-fleet commented on Nov 20, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#7 · os-tesla · session_01L9qibvMi1U7R2kBd3JbTPu

    Carried to this card from #35489 (ADR-0158 Open item 9, point 7) · 2026-11-20T09:11Z

    The membership build (PR #35805, Part of #35489) refuses a non-member unit code on write, but its guidance names no backfill door yet, because this card adds the door. Two pieces land here, settled by the area under the veto window:

    1. When the backfill door ships, the unit refusal's guidance names it as the remedy (the recordCurrencyCodeBackfillRemedy precedent of ADR-0144).
    2. The metadata save that declares unitConfig over stored free text answers a destructive-change finding, as currency_mode_to_record does, and names this door as its remedy. Precedent: that finding's substance is the remedy it names, so it ships with the remedy. It lives in metadata-protocol, outside Units of measure R1: a number field declares its unit (unitConfig) and the write path checks the unit code #35489's file surface.

    Point 7 already ties both cards to one Version Packages release, so no release carries the stricter write without its door.

  3. objectstack-fleet commented on Nov 20, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#7 · os-tesla · session_01L9qibvvVzM5KhCWkT5f45c

    Release pairing ruled · 2026-11-20T10:35Z. ADR-0158 OI9 point 7 ties this card to #35489's PR #35805: both must ship in one Version Packages release. The maintainer (Tesla) picked 「先合 #35805,你暂缓发版」 on seat 7's decision card (2026-11-20T10:34Z). So PR #35805 lands on main once its reviews pass, and the maintainer holds the next Version Packages release until this card's PR merges. Seat 7 tells him when it does. d7-D takes this card on a fresh branch once #35805 has landed.

  4. objectstack-fleet commented on Nov 20, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#7 · os-tesla · session_01L9qibvMi1U7R2kBd3JbTPu

    Claim: PM loop round 3 · card thread d7-D · 2026-11-20T11:43Z
    Ordered by: seat 7, 2026-11-20T10:35Z: after #35805 lands, take #35492 on a fresh branch from main (the maintainer picked release pairing A and holds the next Version Packages release until this card's PR merges)
    Area: d7-D
    Session: session_01L9qibvMi1U7R2kBd3JbTPu
    Account: os-tesla
    Branch: claude/project-thread-dr6px1 (the one branch this thread can push; restarted from main now that PR #35805 has merged)
    Worktree: objectstack-issue-35492
    Domain: domain:server
    Seat: repo:objectstack#7
    File surface: packages/objectql/src/ (a unit-code backfill module beside record-currency-backfill.ts, and its index export; the remedy wording in validation/unit-code-membership.ts), packages/cli/src/commands/migrate/ (the os migrate unit-codes door beside record-currency-codes.ts), packages/rest/src/ (the tenant-admin REST twin beside meta-record-currency-backfill-route.ts and its registration), packages/metadata-protocol/src/protocol-write-face.ts and packages/spec/src/api/protocol.zod.ts (the destructive-change finding and its remedy, carried here by 7035331645), their tests, the generated spec artefacts and references, and root .changeset/. ⛔ No docs/adr/** (the ADR-0158 amendment ships as its own PR), no ui/**. Stop on breach and report.
    Container & model: L, mode:subagent, model: default — no path-derived mandate on this surface (dispatch-gates --tier, as on #35489); contract (L2) review at CONTRACT_REVIEW_TIER per contract-review.md, effort: xhigh (a write door over stored rows, plus a protocol finding; seat 7's word, 2026-11-20T04:07Z, one xhigh dev at a time)
    Clause-②: yes
    Metadata-protocol: added
    Responsibility: n/a — not a defect card
    Thread-read: 7035331645
    Premise: holds — PR #35805 is merged on main (assertUnitCodes in packages/objectql/src/validation/unit-code-membership.ts). No unit backfill door exists yet. The precedent backfillRecordCurrencyCodes and its CLI and REST twins are on main.
    Serial constraints cleared: Blocked-by: #35489 — the part this card waits on (the unitConfig key and U5, PR #35805) is merged. #35489 stays open only for the ADR-0158 amendment PR, which this card does not need. The sibling cards #35490, #35491 and #35498 have no PR open.
    Scope-review: exempt — the route is ruled: ADR-0158 accepted; Open item 12's backfill half is settled on #35469 (7014013098); Open item 9 point 7 is carried here (7035331645)
    Pre-claim lane: area:data seat 7 (#35557)
    Pre-claim deps: #35805 merged; maintainer release pairing A, relayed by seat 7
    Prior rulings read: ADR-0158 → 7001193034, 7003532733, OI8 A (7008524997); ADR-0144 Open item 13 → B 6492000994, C 6670707546 (the currency backfill door's scope); the #35469 settlement 7014013098

  5. added
    pm:dispatched
    and removed
    pm:blocked
    on Nov 20, 2026
  6. objectstack-fleet commented on Nov 20, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#7 · os-tesla · session_01L9qibvMi1U7R2kBd3JbTPu
    os-dev-report

    {
     "issue": 35492,
     "status": "done",
     "branch": "claude/project-thread-dr6px1",
     "pr": "https://github.com/objectstack-ai/objectstack/pull/35865",
     "session": "session_01L9qibvMi1U7R2kBd3JbTPu",
     "premise_still_valid": true,
     "summary": "Built the ADR-0158 U7 R1 unit code backfill door as the twin of the record-currency code backfill, following the eight points of the #35469 settlement. The engine function is backfillUnitCodes in objectql; the CLI is os migrate unit-codes; the REST twin is POST /api/v1/meta/_migrate-unit-codes, behind metadata.endpoints.maintenance and setup.write, for the caller's organization only. The mapping is the operator's and matched exactly. Its targets are judged by U5 before any row is read. Stored codes are left as stored, retired and other-dimension codes included, so a second apply writes nothing. The \"\" entry is the only way a blank beside a quantity is written. The dry run is the default. An apply run over an unmatched value is refused VALIDATION_ERROR/400 before any write. Scope follows ADR-0144 Open item 13. Open item 9 point 7 is built: (a) the ERR_UNIT_CODE_REQUIRED and ERR_UNIT_CODE_UNKNOWN refusals of a quantity edited beside a resting value end with the door as remedy; (b) a save that declares a unit code field over stored rows answers 409 DESTRUCTIVE_CHANGE with unit_mode_to_record or unit_mode_to_code, and force lifts both. The PR is Part of #35492, because the ADR-0158 amendment (adr_amendment below) is the seat's to land and the card closes with it. L1 and L2 (contract review) are owed and were not run.",
     "tests": "Final head e8cc0cb24d. Every package suite ran under os-verify-lock.sh with two workers, and each lock VERDICT reads command-exit 0 unless stated. objectql: vitest --project local at 416b3f2890, 623/623 files and 14083/14083 tests, with typecheck (tsc and the test layer) exit 0; later commits do not touch objectql. rest: the whole suite at 5f0bbceb66, 425/425 files, 8671 passed and 351 skipped; the package is unchanged since, and meta-unit-code-backfill-route.test.ts was rerun 8/8 at 416b3f2890 against the rebuilt engine. metadata-protocol: the whole suite at 0d20cb9d6c, 362 files passed and 9 skipped, 23298 passed and 45 skipped; unchanged since. spec: protocol.test.ts 266/266. cli unit tier at 0d20cb9d6c: 431 files passed; the two published-subpath pins that had refused for want of a CLI dist were rerun after the build, 2/2 files and 29/29 tests. cli integration tier, the touched files only: the three changed files ran together at 0d20cb9d6c (205/205); unit-codes.integration.test.ts ran 7/7 at 416b3f2890 and unit-codes.test.ts 14/14 at e8cc0cb24d. The rest of that tier is declared to CI. cli nightly tier: OS_TEST_TIERS=nightly json-stdout-purity.e2e.test.ts 113/113. typecheck is green for objectql, metadata-protocol, rest and cli, the last again at e8cc0cb24d. test:repo is CI's and was not run. The two ablations ran at 0d20cb9d6c; see ablations. The later 416b3f2890 changes only how the value tally reads the mapped code, so neither anchor and neither mutated line moved, and the ablations were not rerun at the final head.",
     "gates": "The derivation `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` names 144 commands, the same set at 416b3f2890 and at e8cc0cb24d. Every exit was captured before any pipe. Pass 1 ran all 144 from 0d20cb9d6c. Its exit-3 prerequisite refusals and the one dispatcher-error-vocabulary finding (fixed by 416b3f2890) were replaced by pass 2, which reran lines 1 to 110 on 416b3f2890's bytes after a build of 80 prerequisite turbo tasks (exit 0); all 110 exited 0. Pass 1's check:test-source-alias exit 1 (13 dynamic loads in the new CLI test) was fixed by e8cc0cb24d. Pass 3 reran on e8cc0cb24d the 31 derived families that read that test file and had run before the edit; all exited 0. Reconciliation: `dispatch-gates.mjs --ran ran.list --repo objectstack-ai/objectstack` exit 0, \"144 derived famil(ies) accounted for — 144 run, 0 NOT-MEASURED (a DERIVED zero — all 144 recorded an exit code and none of them is 3)\". The rest of the local checks: check-changeset-no-major --base e1143241d --event over the final body, exit 0 (no major; LEVEL AXIS ok for Clause-② yes and Metadata-protocol added). check-nul-bytes OK. check-platform-checklist --changed-from origin/main OK. check-partof-closing-keyword with PR_BODY exit 0. Thirteen roster families whose roster sits under a changed path, exit 0: check:error-code-casing, check:route-ledger-census, check:engine-double-contract, check:changeset-fixed, check:published-list-mirrors, check:published-readme-exports, check:i18n-stale-fill, check:filter-alias-parity, check:meta-url-spelling, check:error-status-conformance, check:tenant-chokepoint, check:auth-mount-ledger and check:error-code-provenance. check:dev-prereqs, which runs locally only, exited 1: 33 ui/ packages have no dist, so its question was NOT MEASURED. CI: at report time the PR head e8cc0cb24d carries 25 check-runs, 20 in_progress and 5 completed/skipped. CI conclusions are in_progress, and convergence is the PM's.",
     "dogfood_battery": "n/a — no `!` in the PR title and no (narrowing) arm",
     "mcp_calls": "0",
     "api_writes": "2 — (1) pr_create through the fleet-write relay: POST /repos/objectstack-ai/objectstack/dispatches, executed as POST /repos/objectstack-ai/objectstack/pulls plus the assignee POST /repos/objectstack-ai/objectstack/issues/35865/assignees; (2) this os-dev-report comment through post-stamped.mjs and the same relay: POST /repos/objectstack-ai/objectstack/dispatches, executed as POST /repos/objectstack-ai/objectstack/issues/35492/comments. git push is not a REST write.",
     "open_questions": [
      {
       "question": "Should the client SDK carry the twin (meta.migrateUnitCodes beside meta.migrateRecordCurrencyCodes)? The route ledger row ships as server-only because packages/client is outside this card's file surface.",
       "options": [
        "A: a follow-up card adds the SDK method and flips the ledger row to sdk, as the currency door has it",
        "B: keep it server-only; the door is reached through the CLI and REST only"
       ],
       "recommendation": "A. Real need: the currency twin's SDK method exists and tenant admin tools call the REST door. Long-run fit: one shape for both backfill doors. AI-error: an SDK method typed from the route's closed body set is harder to misuse than a hand-built fetch. Startup scope: one method plus one ledger row, no new surface kind."
      },
      {
       "question": "L2 focus: should a stored code that U5 would refuse as a write target (a retired sys_unit row, or a code of another dimension) count as a unit code the door leaves as stored? It is built that way, from settlement point 3's membership (U1, or that organization's sys_unit rows) and from L1.",
       "options": [
        "A: left as stored and counted member; U5 answers it at the row's next quantity edit (as built)",
        "B: treated as unmatched, so an apply run demands a mapping entry for it"
       ],
       "recommendation": "A. Real need: a retired unit's rows are real stock records whose meaning L1 keeps. Long-run fit: the door converts free text and never re-means a code. AI-error: B would let a mapping silently re-point a quantity's unit. Startup scope: no extra branch. B would also break idempotence for any field with a retired unit."
      }
     ],
     "security_findings": "none",
     "out_of_scope_findings": [
      "carrier: #35492 (stays open: Part of) · Skills-docs follow-up owed, as named on the PR's Skills-docs line: content/docs/deployment/cli.mdx (the os migrate unit-codes row and section); the metadata.endpoints.maintenance describe in packages/spec/src/api/rest-server.zod.ts and its generated rest-server.mdx; and a units page under content/docs/data-modeling/ naming the door · noted, not filed",
      "carrier: none · check:test-source-alias's source reach follows a relative module the test vi.mocks (here schema-migrate.js and data-migration-plugins.js), so it names dynamic loads that cannot run. This is the loud direction, and the warming imports that satisfy it cost about 21s of collection. Observation, not a/b/c · noted, not filed"
     ],
     "adr_amendment": "Open item 12, appended after its last sentence:\n\n    *Note (2026-11-20):* the backfill half is settled on #35469 (7014013098) and built by #35492. `os migrate\n    unit-codes --object O --field F [--map-file FILE] [--org ID | --all-organizations] [--apply]` and its tenant-admin\n    twin `POST /api/v1/meta/_migrate-unit-codes` (`packages/objectql/src/unit-code-backfill.ts#backfillUnitCodes`,\n    `packages/rest/src/meta-unit-code-backfill-route.ts#registerMetaUnitCodeBackfillRoute`) rewrite the stored text of a\n    unit code field in place. They work from the operator's mapping of stored text, exactly as written, to a unit code.\n    Nothing is derived and nothing is folded: `kg`, `KG` and `kg ` are three keys. The run names the unit code field\n    (the `text` field a quantity's `unitField` names, or a `unitMode: 'code'` field), never the quantity.\n\n    - **Targets.** Each mapping target is judged by U5 before any row is read. With no organization named, an\n      organization's own code is judged in each organization the run would write it in, after the read-only preview\n      and before any write. A target that is no member, a retired unit, or a unit of another dimension than the field's\n      `unitDimension` refuses the run `INVALID_FIELD`.\n    - **Rows left as stored.** A row holding a unit code is never rewritten, so a second run writes nothing. A unit\n      code here is a code of U1 or any `sys_unit` row of the row's organization, a retired one included (L1 keeps a\n      resting row's code), or a code of another dimension. Neither is free text, and rewriting either from a mapping\n      would change what the stored quantity means; U5 answers both at the row's next quantity edit.\n    - **Blanks.** A blank unit beside a quantity is written only from an explicit `\"\"` entry. A blank with no quantity\n      is left.\n    - **Dry run and apply.** The dry run, the default, lists each distinct stored value with its row count and what the\n      mapping does with it. An apply run that meets a value with no entry is refused `VALIDATION_ERROR` on `mapping`\n      before any write, naming each value, so one run converts the whole field or nothing.\n    - **Scope.** Scope is ADR-0144 Open item 13's: one organization, or every one explicitly. An unscoped run over\n      several organizations' rows is refused with each one's counts. The REST twin converts the caller's current\n      organization only, behind `metadata.endpoints.maintenance` and `setup.write`, as a preview unless `apply: true`.\n    - **Writes.** Each row is written through `engine.update` under a system context, so U5 judges every converted\n      code.\n\n    The aggregate half stays with #35491.\n\nOpen item 9, appended after its last sentence (point 7):\n\n    *Note (2026-11-20):* point 7 is carried to #35492 (7035331645) and built there.\n\n    - (a) The `ERR_UNIT_CODE_REQUIRED` and `ERR_UNIT_CODE_UNKNOWN` refusals end with the remedy when the refused\n      write edits a quantity beside a resting value it did not supply. The remedy is `os migrate unit-codes` for that\n      object and field, or the REST twin (`packages/objectql/src/validation/unit-code-membership.ts#unitCodeBackfillRemedy`).\n      For a resting blank, it names the `\"\"` entry. A code the caller wrote carries no remedy, and neither does a\n      resting retired code, which the door leaves as stored.\n    - (b) A metadata save that declares a unit code field over stored rows answers the 409 `DESTRUCTIVE_CHANGE`,\n      beside ADR-0144's `currency_mode_to_record`. The finding is `unit_mode_to_record` for a stored quantity switched\n      to `unitMode: 'record'`, or `unit_mode_to_code` for a stored `text` field newly marked `unitMode: 'code'`. Each\n      names that run, and `force: true` lifts both\n      (`packages/metadata-protocol/src/protocol-write-face.ts#detectDestructiveObjectChanges`). The detector reads no\n      row.\n\n    No finding is raised for a re-pointed `unitField` (the sibling of `currency_field_repointed`) or a narrowed\n    `unitDimension` in R1.\n\nOpen item 8, appended after its *Note* for ruling A (or after \"Not settled here.\" when no note is on main yet):\n\n    The backfill door reaches a standalone `unitMode: 'code'` field the same way it reaches a `unitField`. The field\n    has no quantity beside it, so its blank is owed nothing and is never written, with or without a `\"\"` entry\n    (#35492).\n\nReleases table, the R1 backfill row (if the table carries a status column): `os migrate unit-codes` and\n`POST /meta/_migrate-unit-codes`, #35492.",
     "precedents": [
      "backfillUnitCodes follows backfillRecordCurrencyCodes (packages/objectql/src/record-currency-backfill.ts)",
      "formatUnitCodeBackfillReport follows formatRecordCurrencyBackfillReport",
      "unitCodeBackfillComplete follows recordCurrencyBackfillComplete",
      "unitCodeMappingOf follows the objectql judge-and-read ...Of helpers (activationLedgerHolderOf)",
      "report fields unmatched and organizations follows the settlement's own word (unmatched values refuse --apply) and the currency backfill's organizations counts",
      "rowFailureSentence: the currency backfill's own helper, now exported and reused, not renamed",
      "os migrate unit-codes follows os migrate record-currency-codes (packages/cli/src/commands/migrate/record-currency-codes.ts)",
      "--map-file follows the FILE-suffixed file flags --plan-file (os migrate organization-ownership) and --readme-file (os package publish)",
      "POST /api/v1/meta/_migrate-unit-codes follows POST /api/v1/meta/_migrate-record-currency-codes",
      "registerMetaUnitCodeBackfillRoute follows registerMetaRecordCurrencyBackfillRoute",
      "UNIT_CODE_BACKFILL_CAPABILITY follows RECORD_CURRENCY_BACKFILL_CAPABILITY",
      "unit_mode_to_record and unit_mode_to_code follows currency_mode_to_record (DestructiveChangeIssue codes, protocol-write-face.ts)",
      "unitCodeBackfillRemedy follows recordCurrencyCodeBackfillRemedy",
      "error codes: none new; the door reuses INVALID_FIELD, VALIDATION_ERROR and OBJECT_NOT_FOUND, as the currency door does"
     ],
     "pins": {
      "memory": "packages/objectql/src/unit-code-backfill.test.ts (25). Idempotence: 'is idempotent: a second apply run finds nothing to rewrite and writes nothing'. Unmatched refusal: 'an apply run with an unmatched value is refused before any write, naming each value and its rows'. Also 'a row resting on a retired unit, or on a code of another dimension, holds a unit code: left as stored, never unmatched (L1)'.",
      "sql": "packages/cli/src/commands/migrate/unit-codes.integration.test.ts (7, ObjectQL + SqlDriver on better-sqlite3 with a real sys_unit). Idempotence: 'is idempotent: a re-run reads nothing to rewrite, writes nothing, and leaves the table as the first run did'. Unmatched refusal: '--apply over a value with no mapping entry is refused VALIDATION_ERROR / 400 naming each value, before any row is written'. Also 'a row resting on a retired unit holds a unit code: left as stored, never unmatched (L1)'.",
      "cli": "packages/cli/src/commands/migrate/unit-codes.test.ts (14)",
      "rest": "packages/rest/src/meta-unit-code-backfill-route.test.ts (8)",
      "findings": "packages/objectql/src/protocol-destructive-unit-mode.test.ts (5)",
      "remedy": "packages/objectql/src/validation/unit-code-membership.test.ts (strengthened case and one new case)"
     },
     "ablations": [
      "Both ran at 0d20cb9d6c, on file blob 77b85aadfd27. Each was committed first, then mutated and restored with scripts/ablation-replace.mjs. Each leg rebuilt @objectstack/objectql and proved the marker present or absent in dist with scripts/ablation-dist-preflight.mjs, then ran both pins.",
      "A, the apply refusal: `if (preview.report.unmatched > 0)` became `< -35492` (blob aa3617993764, marker in 2 built files). Memory: 1 failed / 24 passed, the unmatched refusal case. SQL: 1 failed / 6 passed, the unmatched refusal case. Restore: blob 77b85aadfd27 equals HEAD, git diff HEAD empty, marker absent from all 14 built files, then 25/25 and 7/7.",
      "B, the idempotence guard: the member skip `units.verdict(org, value) !== undefined` became `=== 'member-35492'` (blob 1c5282954a60, marker in 2 built files). Memory: 11 failed / 14 passed, idempotence among them. SQL: 6 failed / 1 passed, idempotence among them. Restore: blob equals HEAD, diff empty, marker absent, then 25/25 and 7/7."
     ],
     "gate_reconciliation": "dispatch-gates --ran exit 0: 144 derived famil(ies) accounted for — 144 run, 0 NOT-MEASURED (a DERIVED zero — all 144 recorded an exit code and none of them is 3)",
     "changed_lines": "2,334 (+2,315 / -19) across 33 files against merge base e1143241d, measured by dispatch-gates and git diff --shortstat; under the 3,000 threshold",
     "pr_number": 35865,
     "head_sha": "e8cc0cb24d0b8649b798af2e83548086fd9a9af6",
     "reviews_owed": "L1 and L2 (contract review) are owed and were not run. L2 has three surfaces: the Clause-② yes widening (a new CLI command, a new REST door, and new exports from @objectstack/objectql); Metadata-protocol: added (two DestructiveChangeIssue codes in protocol.zod.ts's describe); and the retired and other-dimension reading in open_questions.",
     "deviations": [
      "Gate-forced ledger rows outside the claim's file surface, with no behaviour: scripts/check-undeclared-dep-imports.mjs (the route's guarded objectql import, twin of the currency route's row) and content/docs/permissions/system-context.mdx (row 50c and its regenerated register). Both are declared in the PR body.",
      "CLI family pins outside packages/cli/src/commands/migrate/: packages/cli/test/migrate-confirmation-exit.pin.test.ts, packages/cli/test/json-stdout-purity.e2e.test.ts and packages/cli/src/utils/schema-migrate.one-shot-family.integration.test.ts, read as the claim's 'their tests'.",
      "The route ledger row is server-only, not sdk, because the client SDK is off the surface (see open_questions).",
      "The two ablations ran at 0d20cb9d6c, not the final head. The only later engine commit touches neither anchor.",
      "check:dev-prereqs NOT MEASURED: ui/ was not built.",
      "Commit trailers follow the dispatch's exact model-free pair (Claude-Session + Co-authored-by: Claude); the harness reminder's model-named Co-Authored-By trailer was not used.",
      "No docs/adr/** and no ui/** were touched. The ADR text is in adr_amendment."
     ]
    }
  7. objectstack-fleet commented on Nov 20, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#7 · os-tesla · session_01L9qibvMi1U7R2kBd3JbTPu

    Claim amendment: claim 7038675232, the file surface only · 2026-11-20T14:24Z
    Branch: claude/project-thread-dr6px1 (PR #35865, head e8cc0cb)
    File surface (added): the files a new backfill door forces outside the named directories, each a ledger row or a family pin with no behaviour of its own (L1 REWORK 7041952857):

    • scripts/check-undeclared-dep-imports.mjs (the route's guarded @objectstack/objectql import, the twin of the currency route's row)
    • content/docs/permissions/system-context.mdx (row 50c and its regenerated register: the door writes under a system context)
    • packages/cli/test/migrate-confirmation-exit.pin.test.ts, packages/cli/test/json-stdout-purity.e2e.test.ts and packages/cli/src/utils/schema-migrate.one-shot-family.integration.test.ts (the os migrate family pins that enumerate every migrate command)
      Everything else in the claim stands unchanged.
  8. objectstack-fleet commented on Nov 20, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#7 · os-tesla · session_01L9qibvMi1U7R2kBd3JbTPu
    os-dev-report

    {
     "issue": 35492,
     "status": "done",
     "branch": "claude/project-thread-dr6px1",
     "pr": "https://github.com/objectstack-ai/objectstack/pull/35865",
     "session": "session_01L9qibvMi1U7R2kBd3JbTPu",
     "report_kind": "delta: fix round on L1 REWORK 7041952857 and L2 7041994401; it supersedes the matching fields of 7041766952, and every field not named here stands",
     "head": "6ad5ea3342cdb3b580aa42824bef707270595b6a",
     "previous_head": "e8cc0cb24d0b8649b798af2e83548086fd9a9af6",
     "premise_still_valid": true,
     "summary": "One commit, 6ad5ea3342, fixes the L2 S1 item and L1 item 1 with L2 N2, and adds L1 N1 and L2 N1. Each of those was a nit or a should-fix. The destructive finding is now keyed on the stored code field, compared through a mirror of unitCodeSources. unit_code_field_declared replaces unit_mode_to_code. unit_mode_to_record now fires only for a stored quantity switched to record over a field that already was a unit code field. The report now counts rows on a retired unit or a code of another dimension apart from members (disposition retired / other-dimension; skippedRetired, skippedOtherDimension). Its check-mark line prints only when every row holds a code the field admits. unitCodeBackfillComplete counts blanks beside a quantity and both resting kinds. CI on 6ad5ea3342 is already green: 70 check-runs, 60 success, 10 skipped, none failed.",
     "fixed": {
      "L2 S1 (should-fix): finding keyed on the stored code field": "packages/metadata-protocol/src/protocol-write-face.ts. unitCodeFieldsOf(fields) mirrors objectql's unitCodeSources: a code field maps to the record quantities that name it, plus whether it is itself unitMode 'code'. A local mirror is used because metadata-protocol cannot import objectql, the same way recordCurrencyPointerOf mirrors recordCurrencyFieldOf. After the per-field loop, each field in next that is a code field is checked. If it is no code field in prev, is stored in prev and is still declared, it raises unit_code_field_declared on that field, whichever declaration made it one. The message names the quantities or the field's own unitMode 'code', then the run for that object and code field. A field that already was a code field raises nothing. Inside the loop, unit_mode_to_record is kept for the blank-beside-quantity debt and now fires only when a stored quantity is switched to record over a field already in prevUnitCodeFields. Otherwise the code-field finding carries that save. Spec describe (packages/spec/src/api/protocol.zod.ts) and the generated content/docs/references/api/protocol.mdx list `unit_code_field_declared` and `unit_mode_to_record`; gen:docs exit 0, only that file moved. Pins are in packages/objectql/src/protocol-destructive-unit-mode.test.ts, rewritten to 17 cases. [S1] new quantity: a NEW quantity naming a stored text field raises the finding on it. [S1] re-point: a unitField re-pointed at a stored text field raises it on the field it now names. [S1] no over-fire: nothing is raised for a field that already was a unit code field. Two shapes are pinned: a second quantity naming uom, and a unitField re-pointed onto another quantity's code field. [S1] unit_mode_to_record: a stored quantity switched to record over a field that already was a code field. Seven parity cases (it.each) require that the fields raised equal those unitCodeSources newly names over a stored field. Each also requires the save to be admitted or refused only as DESTRUCTIVE_CHANGE/409. The L2-named over-fire shape (a text field already named by a record quantity, then marked unitMode 'code') never reaches the detector. The spec's refuseDishonestRecordUnitField answers it 422 INVALID_METADATA first ('a field that declares unitConfig itself'). A case pins that envelope ({code:'INVALID_METADATA', status:422}) so that the claim is on file.",
      "L1 item 1 with L2 N2: no false check-mark sentence or bare complete": "packages/objectql/src/unit-code-backfill.ts. The UnitCodeBackfillDisposition type is now member, retired, other-dimension, mapped or unmatched. A resting retired code is counted in skippedRetired and a resting code of another dimension in skippedOtherDimension; neither counts toward skippedMember any more. The behaviour is unchanged: both are still left as stored, per Q2 (A). formatUnitCodeBackfillReport prints `✓ Every O.F value is a unit code the field admits — nothing to convert.` only when blankBesideQuantity + skippedRetired + skippedOtherDimension is 0. Otherwise it prints `Nothing to rewrite from the mapping, but N row(s) of O.F hold no unit code the field admits (below).` and one warning line each for blanks beside a quantity, retired rows and other-dimension rows, each saying the row is refused at its next quantity edit. unitCodeBackfillComplete now also requires blankBesideQuantity, skippedRetired and skippedOtherDimension to be 0; its docblock and the changeset say so. Re-pinned in packages/objectql/src/unit-code-backfill.test.ts, now 26 cases. The apply case expects complete false, because m5 is left blank. The \"\" case expects complete true. The idempotence case runs the full mapping with a \"\" entry and asserts the exact check-mark line and complete true on the second run. A new case, 'a blank unit beside a quantity that the mapping leaves earns no ✓', asserts that it is counted, warned and not complete. The retired / other-dimension case asserts skippedMember 2, skippedRetired 1 and skippedOtherDimension 1, the two dispositions, the warning lines, complete false, and the second run's 'Nothing to rewrite ... 2 row(s)' line. On SQL, in packages/cli/src/commands/migrate/unit-codes.integration.test.ts, the idempotence case asserts the check-mark line and complete true. The retired case asserts skippedRetired 1, disposition retired, the warning line and complete false. The CLI unit fixture in unit-codes.test.ts gains the two counts.",
      "L1 N1 (nit): changeset 'over stored rows'": ".changeset/35492-unit-code-backfill.md now reads 'A metadata save that makes a stored field a unit code field is a destructive change ... The detector judges the declaration and reads no row.' The findings list also changes: `unit_code_field_declared` sits on the code field and `unit_mode_to_record` on the quantity. The resting-code and blank bullets gain the counts, and a new 'Complete.' bullet is added. Clause-② yes and Metadata-protocol added are unchanged.",
      "L2 N1 (nit): why the walk tallies and tests in the application": "One header paragraph in unit-code-backfill.ts gives three reasons the walk does not use GROUP BY or an anti-join on sys_unit. Membership is exact matching (kg, KG and kg  are three keys), which a case-insensitive or pad-space collation would merge. The blank test is where drivers diverge on null comparison, as the currency backfill states. And each converted row is written by id through engine.update, so the write check judges every code.",
      "ADR amendment (adr_amendment below, in full)": "Open item 12, 'Rows left as stored', now ends with U5 still refusing both kinds at the next quantity edit, so the run lists and counts each apart. 'Blanks' now says counted and named. A new 'Complete.' bullet is added. Open item 9 (b) is rewritten: the finding is keyed on the code field, with one sub-bullet for unit_code_field_declared and one for unit_mode_to_record. The trailing R1 note now covers only a re-point onto a field that already was a code field, and a narrowed unitDimension. Open item 8 and the releases row are unchanged.",
      "not in this round": "L1 item 2 (claim amendment) is done: 7041970933, the seat's. L1 item 3 is owed by the seat: the Skills-docs card and the SDK twin card (Q1 A). L2 N3 (an unused mapping key that is a stored code) and N4 (a truncated preview then apply) were not in the fix order and are unchanged."
     },
     "tests": "All at 6ad5ea3342, each under os-verify-lock.sh with two workers and the lock's VERDICT command-exit 0. objectql: vitest run --project local, 623/623 files and 14096/14096 tests (+13 against 14083: the destructive pin went from 5 to 17 and the backfill pin from 25 to 26). It ran in 629s. objectql typecheck (tsc and the test layer) exit 0. metadata-protocol: the whole suite, 362 files passed and 9 skipped, 23298 passed and 45 skipped, plus typecheck exit 0. spec: src/api/protocol.test.ts 266/266. rest: typecheck exit 0; the package's sources are unchanged this round, and meta-unit-code-backfill-route.test.ts ran 8/8 against the rebuilt engine. cli: typecheck exit 0, plus unit-codes.test.ts 14/14 and unit-codes.integration.test.ts 7/7 (the touched files only; the rest of the integration tier is CI's). The pins first ran together at 6ad5ea3342: objectql 3 files/92, CLI 2/21, REST route 8/8. test:repo is CI's and was not run. The ablations below each rebuilt the package before reading, because objectql tests resolve metadata-protocol through dist/ and the SQL pin resolves objectql through dist/.",
     "ablations": [
      "Every leg used round2/ablate2.sh. It checks the tree is clean, sets a trap that restores from HEAD, and mutates with scripts/ablation-replace.mjs. It then rebuilds the package and proves the marker with scripts/ablation-dist-preflight.mjs before running the pins. The restore leg checks out HEAD, proves blob equality and an empty git diff HEAD, rebuilds, runs the preflight with --absent, reruns the pins and checks the tree is clean.",
      "B2, the idempotence guard, at 6ad5ea3342 on unit-code-backfill.ts blob d7b444a08d74. `if (verdict !== undefined) {` became `if (verdict === 'member-35492') {` (blob 61846bec50ef). Memory: 12 failed / 14 passed, including idempotence and the new blank case. SQL: 6 failed / 1 passed, including idempotence. Caveat: the mutated build exited 1 at its DTS step only (TS2367: '\"member-35492\"' and '\"retired\"' have no overlap), after the ESM and CJS bundles were emitted. The preflight found the marker in the built index files, so the reading stands. Restore: blob d7b444a08d74 equals HEAD, diff empty, build 0, marker absent, 26/26 and 7/7, tree clean.",
      "S1, the no-over-fire guard, on protocol-write-face.ts blob 55c4513f35f4. `if (prevUnitCodeFields.has(codeField)) continue;` became `has('overfire-35492')` (blob 5a0373121332), with the marker in metadata-protocol dist/index.cjs and index.js. Destructive pin: 9 failed / 8 passed. The failures were the no-over-fire case, unit_mode_to_record, force, the negatives, four parity cases and the spec-refused case. Restore: blob equals HEAD, diff empty, marker absent, 17/17, tree clean.",
      "C, completion counts blanks, on unit-code-backfill.ts blob d7b444a08d74. `report.blankBesideQuantity === 0` became `> -35492` (blob 9bce956566cf). Memory: 2 failed / 24 passed (the apply case and the new blank case). SQL: 7/7 passed, because no SQL case leaves a blank beside a quantity, and that is stated here rather than hidden. Caveat: the script's own grep -c of the marker in src read 0, because grep took the leading-dash marker '-35492' as an option. The on-disk mutation is proven three other ways: the ablation-replace log (anchor x1 to x0, replacement x0 to x1), the mutated blob 9bce956566cf against the HEAD blob d7b444a08d74, and the preflight hits in dist. Restore: blob equals HEAD, diff empty, marker absent, 26/26 and 7/7, tree clean.",
      "The round-1 ablation A (the apply refusal) was not rerun. Its anchor `if (preview.report.unmatched > 0)` is unchanged at 6ad5ea3342, and B2 replaces round-1 B, because the member-skip line was rewritten."
     ],
     "gates": "Derivation for this round's 10 changed paths: `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack PATHS`, exit 0, 121 commands. Its stderr names repo objectstack-ai/objectstack at 6ad5ea3342 and says HEAD is at least 6 commits behind origin/main, none of which touched what the answer derives from. Every exit was captured before any pipe. Pass 1 ran all 121 at 6ad5ea3342: 116 exited 0 and 5 exited 3 (PREREQUISITE NOT MET). Those 5 were spec check:skill-examples, check:dual-build-cjs-loads, check:i18n, check:i18n-coverage and check:i18n-walk-parity. A prerequisite build under the lock followed (turbo run build --concurrency=2 over the 28 named packages: 80 cache hits, 1 miss, VERDICT command-exit 0). The 5 then reran and all exited 0. Reconciliation: `dispatch-gates.mjs --ran round2/ran.list --repo objectstack-ai/objectstack PATHS`, exit 0: '121 derived famil(ies) accounted for — 121 run, 0 NOT-MEASURED (a DERIVED zero — all 121 recorded an exit code and none of them is 3)'. The five artifact-roster families whose roster sits under a changed path all exited 0: spec check:meta-url-spelling, check:authz-resolver, check:changeset-fixed, check:error-code-casing and check:filter-alias-parity. check-nul-bytes exit 0 (OK, 26375 files). check-platform-checklist --changed-from origin/main exit 0 (40 anchors judged, 0 lost); no exported symbol was renamed or removed. check:dev-prereqs exit 1: 35 ui/ packages have no dist/ (ui/** is outside this card), so its question is NOT MEASURED; the spec dist was built at this head in the prerequisite build. CI check-runs on 6ad5ea3342, read with a GET: 70 total, 60 success, 10 skipped, 0 failed or in progress. The successes include Build Core, Test Core 1-10, Type Check · workspace, consumer gates, source gates and debt ledger, Lint & Repo Gates with every Lint lane, Check Changeset, PR-body guards, Check PR Size, Spec property liveness, Build Docs, Check Documentation Links, Governed Surface Queue Guard, Dogfood Regression Gate, and Test UI 1-16. The skips are the opt-in and push-only jobs.",
     "dogfood_battery": "n/a — no `!` in the PR title and no (narrowing) arm",
     "changed_lines": "This round: 10 files, +372 / -111 (e8cc0cb24d..6ad5ea3342). PR total against the merge base e1143241d: 33 files, +2,577 / -20 = 2,597, under the 3,000 human-merge threshold.",
     "mcp_calls": "0",
     "api_writes": "1 — POST /repos/objectstack-ai/objectstack/issues/35492/comments (this delta os-dev-report, through scripts/pm/post-stamped.mjs and the fleet relay). git push of 6ad5ea3342 to claude/project-thread-dr6px1 is not a REST write. Reads: GET check-runs on 6ad5ea3342.",
     "open_questions": [
      {
       "question": "L2 delta: the rename unit_mode_to_code to unit_code_field_declared, and the narrower unit_mode_to_record. Neither code has shipped: unitConfig and both finding codes are unpublished, since .changeset/35489-unit-config.md is still pending and DestructiveChangeIssueSchema.code stays z.string(). Does the delta PASS on Clause-② yes and Metadata-protocol added as they stand?",
       "options": [
        "A: yes, as built; the describe and the generated page name the two codes the detector emits",
        "B: keep the name unit_mode_to_code for the code-field finding"
       ],
       "recommendation": "A. Real need: the finding now fires for three declarations, not one unitMode switch, so a mode-named code would tell the operator the wrong cause. Long-run fit: `subject_change` naming, as currency_field_repointed is. AI-error: the name says which field to convert. Startup scope: the rename costs nothing before release."
      }
     ],
     "security_findings": "none",
     "out_of_scope_findings": [
      "carrier: none · L2's over-fire shape (a text field already named by a record quantity, then marked unitMode 'code'; or a quantity naming a field that declares unitConfig itself) is refused 422 INVALID_METADATA by the spec's refuseDishonestRecordUnitField before the destructive detector runs. Pinned in protocol-destructive-unit-mode.test.ts. Not a defect · noted, not filed",
      "carrier: the ADR amendment (Open item 9 trailing note) · a unitField re-pointed onto a field that already was a unit code field (another quantity's) raises nothing. It is the sibling of ADR-0144 currency_field_repointed, as is a narrowed unitDimension. A re-point at a stored field that was no code field now raises unit_code_field_declared (S1) · noted, not filed",
      "carrier: the seat (L1 item 3) · the Skills-docs card (cli.mdx os migrate unit-codes, the metadata.endpoints.maintenance describe in rest-server.zod.ts with its generated page, a units page under content/docs/data-modeling/) and the SDK twin card meta.migrateUnitCodes (Q1 A) · noted, not filed by dev"
     ],
     "pr_body_replacements": {
      "What changes, point 4": "4. A row holding a unit code is never rewritten, so a second apply run writes nothing. That includes a code of U1 and any `sys_unit` row of the row's organization, a retired one included, as well as a code of another dimension. A retired unit and a code of another dimension are refused by U5 at the row's next quantity edit, so they are counted apart (`skippedRetired`, `skippedOtherDimension`) and labelled `retired` and `other-dimension`, never `member`. A blank unit with no quantity beside it is left alone. Each case is counted.",
      "What changes, point 5": "5. A dry run is the default. It lists every distinct stored value with its row count and disposition (`member`, `retired`, `other-dimension`, `mapped` and its code, or `unmatched`). An apply run with an unmatched value is refused `VALIDATION_ERROR` / 400 on `mapping` before any write. The refusal names each value with its rows and carries them as `unmatched`.",
      "What changes, new paragraph after point 8": "**Complete.** `unitCodeBackfillComplete` answers true only when every row holds a unit code the field admits: no unmatched value, no blank beside a quantity, no retired unit, no code of another dimension, and no failed or unexamined row. The report prints `✓ Every O.F value is a unit code the field admits — nothing to convert.` only then. Otherwise it prints `Nothing to rewrite from the mapping, but N row(s) of O.F hold no unit code the field admits (below).`, followed by one ⚠ line per kind.",
      "What changes, the Open item 9 point 7 (b) paragraph and its two bullets": "**Open item 9 point 7 (b)**: a save that makes a stored field a unit code field answers the 409 `DESTRUCTIVE_CHANGE` (`metadata-protocol/src/protocol-write-face.ts`, in `detectDestructiveObjectChanges` beside `currency_mode_to_record`). The finding is keyed on the code field, as U5 is, through `unitCodeFieldsOf`, a local mirror of objectql's `unitCodeSources`:\n\n- `unit_code_field_declared` is raised on a stored field that is a unit code field after the save and was not one before, whichever declaration made it one: a quantity, new or stored, whose `unitField` names it; a `unitField` re-pointed at it; or its own `unitMode: 'code'`. A field that already was one raises nothing.\n- `unit_mode_to_record` is raised on a stored quantity switched to `unitMode: 'record'` over a field that already was a unit code field, for the blank units beside it.",
      "Tests, In memory": "**In memory**: `packages/objectql/src/unit-code-backfill.test.ts`, 26 cases. Changed this round: `apply rewrites the mapped values through the engine; members and blanks stay as stored` now expects the run not complete (a blank is left); `is idempotent: …` runs the full mapping with a `\"\"` entry and asserts the exact ✓ line and complete on the second run; the new `a blank unit beside a quantity that the mapping leaves earns no ✓: the report counts it, and the run is not complete`; and `a row resting on a retired unit, or on a code of another dimension, …`, which now asserts `skippedRetired` 1, `skippedOtherDimension` 1, the `retired` and `other-dimension` dispositions, their ⚠ lines, and not complete.",
      "Tests, the findings pin": "**The findings**: `packages/objectql/src/protocol-destructive-unit-mode.test.ts`, 17 cases. Among them are `[S1] a NEW quantity naming a stored text field makes that field a unit code field: the finding is raised on it` and `[S1] a unitField re-pointed at a stored text field raises the finding on the field it now names`. Also: `[S1] raises nothing for a field that already was a unit code field, however it is declared now`, and `[S1] a stored quantity switched to unitMode 'record' over a field that already was a unit code field raises unit_mode_to_record on the quantity`. Also: `the other over-fire shape, a field a quantity names marked unitMode 'code' as well, is refused by the spec before the detector runs`, which asserts 422 `INVALID_METADATA`. The rest are `force: true lifts both`, the negatives, and seven parity cases that require the fields raised to be those `unitCodeSources` newly names over a stored field.",
      "Tests, On SQL": "The idempotence case also asserts the ✓ line and complete; `a row resting on a retired unit …` asserts `skippedRetired` 1, the `retired` disposition, its ⚠ line, and not complete.",
      "Ablations, append": "- **Round 2, at `6ad5ea3342`.** B2: the member skip `if (verdict !== undefined) {` became `=== 'member-35492'`: memory 12 failed / 14 passed, SQL 6 failed / 1 passed (the mutated build failed at DTS only, after the bundles; the marker was in dist). S1: `if (prevUnitCodeFields.has(codeField)) continue;` became `has('overfire-35492')`: destructive pin 9 failed / 8 passed. C: `report.blankBesideQuantity === 0` became `> -35492`: memory 2 failed / 24 passed, SQL 7/7 (no SQL case leaves a blank). Each restore: blob equals HEAD, diff empty, marker absent, pins green, tree clean.",
      "Package suites, readings": "At `6ad5ea3342`: `@objectstack/objectql` `--project local` 623/623 files, 14096/14096 tests, typecheck 0. `@objectstack/metadata-protocol` 362 passed / 9 skipped files, 23298 passed / 45 skipped tests, typecheck 0. `@objectstack/spec` `protocol.test.ts` 266/266. `@objectstack/rest` typecheck 0, route 8/8. `@objectstack/cli` typecheck 0, `unit-codes.test.ts` 14/14, `unit-codes.integration.test.ts` 7/7.",
      "Acceptance notes, the re-pointed unitField bullet": "- A `unitField` re-pointed at a stored field that was no unit code field raises `unit_code_field_declared` on that field. Re-pointed onto a field that already was one (another quantity's), it raises nothing: the sibling of ADR-0144's `currency_field_repointed`, not in Open item 9 point 7.\n- A text field already named by a record quantity, then marked `unitMode: 'code'` as well, never reaches the detector: the spec refuses the save 422 `INVALID_METADATA` (a `unitField` may not name a field that declares `unitConfig` itself).",
      "Verification, first line": "Final head `6ad5ea3342`. Changed lines: 2,597 (+2,577 / -20) across 33 files against the merge base `e1143241d`; the human-merge threshold is 3,000."
     },
     "adr_amendment": "Open item 12, appended after its last sentence:\n\n    *Note (2026-11-20):* the backfill half is settled on #35469 (7014013098) and built by #35492. `os migrate\n    unit-codes --object O --field F [--map-file FILE] [--org ID | --all-organizations] [--apply]` and its tenant-admin\n    twin `POST /api/v1/meta/_migrate-unit-codes` (`packages/objectql/src/unit-code-backfill.ts#backfillUnitCodes`,\n    `packages/rest/src/meta-unit-code-backfill-route.ts#registerMetaUnitCodeBackfillRoute`) rewrite the stored text of a\n    unit code field in place. They work from the operator's mapping of stored text, exactly as written, to a unit code.\n    Nothing is derived and nothing is folded: `kg`, `KG` and `kg ` are three keys. The run names the unit code field\n    (the `text` field a quantity's `unitField` names, or a `unitMode: 'code'` field), never the quantity.\n\n    - **Targets.** Each mapping target is judged by U5 before any row is read. With no organization named, an\n      organization's own code is judged in each organization the run would write it in, after the read-only preview\n      and before any write. A target that is no member, a retired unit, or a unit of another dimension than the field's\n      `unitDimension` refuses the run `INVALID_FIELD`.\n    - **Rows left as stored.** A row holding a unit code is never rewritten, so a second run writes nothing. A unit\n      code here is a code of U1 or any `sys_unit` row of the row's organization, a retired one included (L1 keeps a\n      resting row's code), or a code of another dimension. Neither is free text, and rewriting either from a mapping\n      would change what the stored quantity means. U5 still refuses both at the row's next quantity edit, so the run\n      lists and counts each apart (`retired`, `other-dimension`), never as a code the field admits.\n    - **Blanks.** A blank unit beside a quantity is written only from an explicit `\"\"` entry; without one it is counted\n      and named. A blank with no quantity is left.\n    - **Complete.** A run is complete only when every row holds a unit code the field admits: no unmatched value, no\n      blank beside a quantity, no retired unit, no code of another dimension, and no failed or unexamined row.\n    - **Dry run and apply.** The dry run, the default, lists each distinct stored value with its row count and what the\n      mapping does with it. An apply run that meets a value with no entry is refused `VALIDATION_ERROR` on `mapping`\n      before any write, naming each value, so one run converts the whole field or nothing.\n    - **Scope.** Scope is ADR-0144 Open item 13's: one organization, or every one explicitly. An unscoped run over\n      several organizations' rows is refused with each one's counts. The REST twin converts the caller's current\n      organization only, behind `metadata.endpoints.maintenance` and `setup.write`, as a preview unless `apply: true`.\n    - **Writes.** Each row is written through `engine.update` under a system context, so U5 judges every converted\n      code.\n\n    The aggregate half stays with #35491.\n\nOpen item 9, appended after its last sentence (point 7):\n\n    *Note (2026-11-20):* point 7 is carried to #35492 (7035331645) and built there.\n\n    - (a) The `ERR_UNIT_CODE_REQUIRED` and `ERR_UNIT_CODE_UNKNOWN` refusals end with the remedy when the refused\n      write edits a quantity beside a resting value it did not supply. The remedy is `os migrate unit-codes` for that\n      object and field, or the REST twin (`packages/objectql/src/validation/unit-code-membership.ts#unitCodeBackfillRemedy`).\n      For a resting blank, it names the `\"\"` entry. A code the caller wrote carries no remedy, and neither does a\n      resting retired code, which the door leaves as stored.\n    - (b) A metadata save that makes a stored field a unit code field answers the 409 `DESTRUCTIVE_CHANGE`, beside\n      ADR-0144's `currency_mode_to_record`. The finding is keyed on the code field, as U5 is.\n      - `unit_code_field_declared` is raised for a stored field that is a unit code field after the save and was not\n        one before, whichever declaration made it one: a quantity, new or stored, whose `unitField` names it; a\n        `unitField` re-pointed at it; or its own `unitMode: 'code'`. A field that already was a unit code field\n        raises nothing.\n      - `unit_mode_to_record` is raised for a stored quantity switched to `unitMode: 'record'` over a field that\n        already was a unit code field, for the blank units beside it.\n\n      Each names that run for the code field, and `force: true` lifts both\n      (`packages/metadata-protocol/src/protocol-write-face.ts#detectDestructiveObjectChanges`). The detector reads no\n      row.\n\n    No finding is raised in R1 for a `unitField` re-pointed onto a field that already was a unit code field (the\n    sibling of `currency_field_repointed`), or for a narrowed `unitDimension`.\n\nOpen item 8, appended after its *Note* for ruling A (or after \"Not settled here.\" when no note is on main yet):\n\n    The backfill door reaches a standalone `unitMode: 'code'` field the same way it reaches a `unitField`. The field\n    has no quantity beside it, so its blank is owed nothing and is never written, with or without a `\"\"` entry\n    (#35492).\n\nReleases table, the R1 backfill row (if the table carries a status column): `os migrate unit-codes` and\n`POST /meta/_migrate-unit-codes`, #35492."
    }

    Generated by Claude Code

  9. objectstack-fleet commented on Nov 20, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#7 · os-tesla · session_01L9qibvMi1U7R2kBd3JbTPu
    os-dev-report

    {
     "issue": 35492,
     "status": "done",
     "branch": "claude/project-thread-dr6px1",
     "pr": "https://github.com/objectstack-ai/objectstack/pull/35865",
     "session": "session_01L9qibvMi1U7R2kBd3JbTPu",
     "report_kind": "delta, round 3: L2 delta 7043808549 (S2, S3) and L1 delta ACCEPT 7043790074 (prose item 1). It supersedes the matching fields of 7043629791; every field not named here stands.",
     "head": "7928062332ebd43e587f6cbbb710dcd1b4f7df6c",
     "previous_head": "6ad5ea3342cdb3b580aa42824bef707270595b6a",
     "premise_still_valid": true,
     "summary": "Commit 7928062332 fixes S2, S3 and the L1 prose item. S2: unit_mode_to_record is raised again for a stored quantity switched to record over a unitField that is new in the same save. One rule now keeps each debt reported exactly once: unit_mode_to_record stands aside only when the same save raises unit_code_field_declared on that unitField, and that finding now names the blanks and the \"\" entry. S3: os migrate unit-codes prints its success line only when unitCodeBackfillComplete holds; otherwise it closes with a warning naming what is left. L1 prose: the retired and other-dimension wording now depends on whether a quantity names the field, since a standalone field's resting code is never judged and only its next write must carry another code. Every suite, the 75 derived gate families and CI on 7928062332 (70 check-runs, 60 success, 10 skipped) are green.",
     "fixed": {
      "L2 S2 (should-fix): the brand-new unitField debt": "packages/metadata-protocol/src/protocol-write-face.ts. Both unit findings now read one predicate, newlyDeclaredUnitCodeFieldsOf. It returns the stored fields a save newly makes unit code fields: a code field after the save that was none before, is stored on the previous definition, and is still declared. unit_code_field_declared iterates that map. unit_mode_to_record is raised on a stored quantity whose unitMode changed to 'record', whatever its unitField's history, unless that unitField is in the map. The rule, as the docblock states it: when the same save raises unit_code_field_declared on that unitField, that finding names this quantity among its declarers, the blanks beside it and the \"\" entry, so unit_mode_to_record is not raised and each debt is reported once. Where a quantity names the field, the declared message now ends 'once saved, convert the stored text, and write the blanks beside a quantity from a \"\" entry in the mapping, with REMEDY'. unit_mode_to_record has two wordings. Over a field that already was a code field, the text is unchanged. Otherwise it says: ''U' held no stored unit before this save (it is new, or was not stored), so every row already stored holds its quantity beside a blank 'U', and editing the quantity there is refused until the row holds a unit code'. Both end with the \"\" entry and the remedy. The pins are in packages/objectql/src/protocol-destructive-unit-mode.test.ts, now 21 cases. The new case is `[S2] OBJECT's stored quantity switched to unitMode 'record' over a unitField NEW in the same save raises unit_mode_to_record on the quantity, reading no row`, for mat_plain and mat_fixed. The L1 no-double-report property stays pinned in the mat_plain / mat_fixed case. That case, a stored quantity switched to record over stored text that was no code field, asserts exactly one finding, unit_code_field_declared on uom, and that its message names the \"\" entry. The parity it.each has 9 cases, 2 of them new: the brand-new unitField case and mat_fixed. Each also requires that every stored quantity the save switches to record has its blank debt named exactly once, either by unit_mode_to_record on the quantity or by unit_code_field_declared on its unitField naming it. spec protocol.zod.ts is unchanged: the two code names did not move.",
      "L2 S3 (should-fix): the CLI's false success line": "packages/cli/src/commands/migrate/unit-codes.ts. The closing branch now follows unitCodeBackfillComplete, the rule the report's own check-mark line follows. failures, truncated, unmatched and dry-run-with-mapped are handled first, as before. Next, a run that is not complete closes with printWarning: `Not complete — O.F still has KINDS, holding no unit code the field admits (see the ⚠ lines above).` After an apply that wrote rows it is `Wrote unit codes on N row(s), but not complete — ...`. KINDS lists only the nonzero kinds, for example '1 blank unit(s) beside a quantity, 1 row(s) on a retired unit and 1 row(s) on a unit code of another dimension'. Only a complete run gets the printSuccess lines: `Wrote unit codes on N row(s). ...`, or `Nothing to convert — every O.F value is a unit code the field admits.`. The exit codes and the --json envelope are unchanged. The pins are in packages/cli/src/commands/migrate/unit-codes.test.ts, now 17 cases. They run the command over the REAL engine report: the mock module now passes the real unitCodeBackfillComplete through, and a new realReport helper runs the real backfillUnitCodes over a walked engine double. There are three cases. A dry run leaving a blank beside a quantity prints the Not-complete line and no check mark. An apply that wrote 1 row and left a blank prints the 'Wrote ..., but not complete' line and no check mark. The control, every row admitted, prints both check-mark lines. The SQL integration pin calls the engine directly and never the command, so it was not extended; its report half is already pinned.",
      "L1 delta prose item 1: 'refused at its next quantity edit' on a standalone field": "packages/objectql/src/unit-code-backfill.ts. U5's judgedOf judges a resting code only when a non-blank quantity is written beside it, so the wording now depends on report.quantityFields.length. With quantities, it is unchanged. On a standalone field, the DISPOSITION_TEXT retired and other-dimension entries read 'left as stored (the field does not admit it, so the next write of the field must carry another code)', and the two ⚠ lines end with the same clause. The STANDALONE_RESTING constant carries a docblock citing judgedOf. The module header, the disposition docblock, the unitCodeBackfillComplete docblock and the changeset sentence say the same. complete stays false for those rows. The new pin in unit-code-backfill.test.ts (now 27 cases) is `[Open item 8] a standalone field resting on a retired unit holds no code it admits: named without a quantity edit, and not complete`. It asserts skippedRetired 1, disposition retired, the standalone listing and ⚠ lines, that no line mentions 'quantity edit', and complete false.",
      "ADR amendment (adr_amendment below, in full)": "Open item 12. 'Rows left as stored' now says neither kind is a code the field admits, refused beside a quantity at the next quantity edit, while a standalone field's next write must carry another code. 'Complete.' adds that the report and the CLI print their check-mark line only then. Open item 9 (b): the unit_mode_to_record sub-bullet is rewritten for S2, with its once-only rule. The trailing R1 note now also discloses a unitField re-pointed onto a field new in the same save. Open item 8 and the releases row are unchanged.",
      "changeset": ".changeset/35492-unit-code-backfill.md: the resting-codes sentence now carries the standalone condition. A CLI bullet says the command closes with a check mark only when unitCodeBackfillComplete holds. The unit_mode_to_record bullet carries the S2 rule. Clause-② yes and Metadata-protocol added are unchanged.",
      "not in this round": "L2 N3 and N4 are carried unchanged as follow-ups, as both records say."
     },
     "tests": "All at 7928062332, each under os-verify-lock.sh with two workers; every lock VERDICT is command-exit 0. objectql vitest run --project local: 623/623 files, 14101/14101 tests (+5: the destructive pin went from 17 to 21 cases, the backfill pin from 26 to 27), 631s. metadata-protocol, the whole suite: 362 files passed and 9 skipped, 23298 tests passed and 45 skipped. cli: unit-codes.test.ts and unit-codes.integration.test.ts, 2 files, 24 tests (17 + 7). rest: meta-unit-code-backfill-route.test.ts 8/8 against the rebuilt engine. typecheck exit 0 for metadata-protocol, objectql (tsc and its test layer) and cli (tsc plus check:test-typecheck OK). Before the commit, the pins ran first at the same bytes: objectql 3 files / 97 tests and CLI 2 / 24. Two things were not run: the rest of the CLI integration tier, which is declared to CI, and test:repo, which is CI's. Before reading any result, metadata-protocol and objectql were rebuilt, because objectql tests resolve metadata-protocol through dist/ and the SQL pin resolves objectql through dist/.",
     "ablations": [
      "Method: S2a and S2b ran through round3/ablate3.sh, which is round 2's script with the marker grep fixed to `grep -cF -e`. It checks that the tree is clean and sets a trap that restores from HEAD. It mutates with scripts/ablation-replace.mjs, rebuilds @objectstack/metadata-protocol and proves the marker with scripts/ablation-dist-preflight.mjs. It then runs the destructive pin, restores, proves blob equality and an empty git diff HEAD, rebuilds, runs the preflight with --absent, reruns the pin and checks the tree is clean. All ran at 7928062332 on protocol-write-face.ts blob efd6ca375943.",
      "S2a, the once-only guard: `&& !declaredUnitCodeFields.has(unitField)` became `&& !declaredUnitCodeFields.has('s2a-35492')` (blob 3dce32a9f9d1, marker in src 1 and in dist). Destructive pin: 4 failed / 17 passed. The failures were the no-double-report cases for mat_plain and mat_fixed, and the two parity cases whose once-only check sees both findings. Restore: blob equals HEAD, diff empty, build 0, marker absent, 21/21, tree clean.",
      "S2b, the widening: the guard became the round-2 condition, `&& (prevUnitCodeFields.has(unitField) || unitField === 's2b-35492')` (blob ea3e5f3c834f, marker in src 1 and in dist). Destructive pin: 3 failed / 18 passed: the two [S2] brand-new unitField cases and the brand-new parity case. Restore: blob equals HEAD, diff empty, marker absent, 21/21, tree clean.",
      "S3, the CLI completeness gate, on unit-codes.ts blob 15e165ab3811. `} else if (!unitCodeBackfillComplete(report)) {` became `... && report.object === 's3-35492') {` (blob 19c3b0917bde, marker in src 1; ablation-replace reports anchor 1 to 0). No build leg was needed: the test imports the command from src. unit-codes.test.ts: 2 failed / 15 passed, the two not-complete cases. Restore: blob 15e165ab3811 equals HEAD, diff empty, 17/17, tree clean.",
      "The prose item changes wording only, so no ablation was run for it (per the rule on messages and configuration); its pin asserts the wording."
     ],
     "gates": "Derivation for this round's 7 changed paths (6ad5ea3342..7928062332): `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack PATHS`, exit 0, 75 commands. Its stderr names objectstack-ai/objectstack at 7928062332. HEAD is at least 11 commits behind origin/main, none of which touched what the answer derives from; 2 moved paths, scripts/adr-anchors JSON for objectql fixed-read files, are not inputs. A prerequisite build ran first under the lock (turbo run build --concurrency=2 over the 28 packages the prerequisite gates name): 81 tasks, 32 cached, VERDICT command-exit 0. All 75 then ran, with each exit captured before any pipe; all 75 exited 0, with no PREREQUISITE NOT MET in any log. Reconciliation: `dispatch-gates.mjs --ran round3/ran.list --repo objectstack-ai/objectstack PATHS` exit 0, '75 derived famil(ies) accounted for — 75 run, 0 NOT-MEASURED (a DERIVED zero — all 75 recorded an exit code and none of them is 3)'. Four artifact-roster families have their roster under a changed path, and all exited 0: check:authz-resolver, check:changeset-fixed, check:error-code-casing and check:filter-alias-parity. check-nul-bytes exit 0. check-platform-checklist --changed-from origin/main exit 0; no exported symbol was renamed or removed. check:dev-prereqs exit 1, because 35 ui/ packages have no dist/; it is not owed this round, since packages/spec is untouched. CI check-runs on 7928062332, read with a GET: 70 in all, 60 success, 10 skipped, 0 failed and 0 in progress. Among the successes are Build Core, Test Core 1-10 and its roll-up, the four Type Check lanes, TypeScript Type Check, Lint & Repo Gates, Check Changeset, PR-body guards, Check PR Size, Spec property liveness, Build Docs and Dogfood Regression Gate.",
     "dogfood_battery": "n/a — no `!` in the PR title and no (narrowing) arm",
     "changed_lines": "This round: 7 files, +224 / -58 (6ad5ea3342..7928062332). The PR against merge base e1143241d: 33 files, +2,743 / -20, which is 2,763 lines, under the 3,000 human-merge threshold.",
     "mcp_calls": "0",
     "api_writes": "1 — POST /repos/objectstack-ai/objectstack/issues/35492/comments (this delta os-dev-report, through scripts/pm/post-stamped.mjs and the fleet relay). The git push of 7928062332 to claude/project-thread-dr6px1 is not a REST write. Reads only otherwise: GET of comments 7043808549 and 7043790074, the PR body, and the check-runs on 7928062332.",
     "open_questions": [],
     "security_findings": "none",
     "out_of_scope_findings": [
      "carrier: the ADR amendment (Open item 9 trailing note) · a stored record quantity whose unitField is re-pointed onto a field new in the same save raises nothing in R1. Every row then holds a quantity beside a blank unit. This is the re-point sibling of currency_field_repointed, along with a re-point onto a field that already was a code field and a narrowed unitDimension. A re-point at a stored field that was no code field raises unit_code_field_declared (S1) · noted, not filed",
      "carrier: the seat · L2 N3 (a mapping key that is itself a stored code is ignored without a word) and N4 (a truncated preview does not literally keep 'the whole field or nothing'), carried by both records as follow-ups · noted, not filed by dev"
     ],
     "pr_body_replacements": {
      "What changes, point 4": "4. A row holding a unit code is never rewritten, so a second apply run writes nothing. That includes a code of U1 and any `sys_unit` row of the row's organization, a retired one included, as well as a code of another dimension. Neither of those is a code the field admits: beside a quantity, U5 refuses each at the row's next quantity edit, and on a standalone field (no quantity) the next write of the field must carry another code. So they are counted apart (`skippedRetired`, `skippedOtherDimension`) and labelled `retired` and `other-dimension`, never `member`. A blank unit with no quantity beside it is left alone. Each case is counted.",
      "os migrate unit-codes, append one bullet after 'A refusal exits 1 ...'": "- It closes with a ✓ only when `unitCodeBackfillComplete` holds. A run that leaves a blank beside a quantity, a retired unit or a code of another dimension closes with a warning naming what is left: `Not complete — O.F still has …, holding no unit code the field admits (see the ⚠ lines above).`, or, after an apply that wrote rows, `Wrote unit codes on N row(s), but not complete — …`.",
      "Open item 9 point 7 (b), the unit_mode_to_record bullet": "- `unit_mode_to_record` is raised on a stored quantity switched to `unitMode: 'record'`, for the blank units beside it, whatever the history of its `unitField`: a unit code field already, or a field new in the same save (every stored row then holds its quantity beside a blank). It is not raised when the same save raises `unit_code_field_declared` on that `unitField`: that finding names the quantity, its blanks and the `\"\"` entry, so each debt is reported once. One predicate (`newlyDeclaredUnitCodeFieldsOf`) feeds both findings.",
      "Tests, In memory, first sentence": "**In memory**: `packages/objectql/src/unit-code-backfill.test.ts`, 27 cases. New in round 3: `[Open item 8] a standalone field resting on a retired unit holds no code it admits: named without a quantity edit, and not complete`. Round 2 changed `apply rewrites the mapped values through the engine; members and blanks stay as stored` (not complete, since a blank is left), `is idempotent: …` (the full mapping with a `\"\"` entry, the exact ✓ line and complete on the second run), the new `a blank unit beside a quantity that the mapping leaves earns no ✓: the report counts it, and the run is not complete`, and `a row resting on a retired unit, or on a code of another dimension, …` (`skippedRetired` 1, `skippedOtherDimension` 1, both dispositions, their ⚠ lines, not complete).",
      "Tests, The CLI command, first line and one bullet": "**The CLI command**: `packages/cli/src/commands/migrate/unit-codes.test.ts`, 17 cases. Append: `- The closing line follows unitCodeBackfillComplete, as the report's ✓ line does, judged over the REAL engine report: a run that leaves a blank beside a quantity closes with the Not-complete warning and no ✓; an apply that wrote rows and left a blank says so, with no ✓; the control, every row admitted, closes with the ✓.`",
      "Tests, The findings": "**The findings**: `packages/objectql/src/protocol-destructive-unit-mode.test.ts`, 21 cases. Among them: `[S1] a NEW quantity naming a stored text field makes that field a unit code field: the finding is raised on it`; `[S1] a unitField re-pointed at a stored text field raises the finding on the field it now names`; `[S2] OBJECT's stored quantity switched to unitMode 'record' over a unitField NEW in the same save raises unit_mode_to_record on the quantity, reading no row` (mat_plain, mat_fixed); `refuses OBJECT's stored quantity switched to unitMode 'record' over stored text with 409 DESTRUCTIVE_CHANGE, once: …` (exactly one finding, `unit_code_field_declared`, naming the `\"\"` entry: no double report); `[S1] raises nothing for a field that already was a unit code field, however it is declared now`; `[S1] a stored quantity switched to unitMode 'record' over a field that already was a unit code field raises unit_mode_to_record on the quantity`; and the spec-refused over-fire shape (422 `INVALID_METADATA`). The rest are `force: true lifts both`, the negatives, and nine parity cases: the fields raised are those `unitCodeSources` newly names over a stored field, and each stored quantity switched to record has its blank debt named exactly once.",
      "Ablations, append": "- **Round 3, at `7928062332`.** S2a: `&& !declaredUnitCodeFields.has(unitField)` became `has('s2a-35492')`: destructive pin 4 failed / 17 passed (the no-double-report cases and two once-only parity cases). S2b: the same guard back to the round-2 `prevUnitCodeFields.has(unitField)` (with a marker): 3 failed / 18 passed (the two [S2] cases and the brand-new parity case). S3: the CLI's `!unitCodeBackfillComplete(report)` branch disabled: `unit-codes.test.ts` 2 failed / 15 passed (the two not-complete cases). Each restore: blob equals HEAD, diff empty, marker absent from dist where built, pins green, tree clean.",
      "Package suites, readings, new first bullet": "- At `7928062332`: `@objectstack/objectql` `--project local` 623/623 files, 14101/14101 tests, typecheck 0. `@objectstack/metadata-protocol` 362 passed / 9 skipped files, 23298 passed / 45 skipped tests, typecheck 0. `@objectstack/cli` typecheck 0, `unit-codes.test.ts` 17/17 and `unit-codes.integration.test.ts` 7/7. `@objectstack/rest` route 8/8.",
      "Acceptance notes, first bullet": "- A stored code of another dimension than `unitDimension` (`MTR` in a mass field) is a code, not free text. The door leaves it. Beside a quantity, U5 refuses it at the row's next quantity edit (`ERR_UNIT_DIMENSION_MISMATCH`); on a standalone field, U5 never judges a resting code, so the next write of the field must carry another one. The same holds for a resting retired code, which L1 keeps: rewriting either from a mapping would change what the stored quantity means.",
      "Acceptance notes, the re-point bullet": "- A `unitField` re-pointed at a stored field that was no unit code field raises `unit_code_field_declared` on that field. Re-pointed onto a field that already was one (another quantity's), or onto a field new in the same save, it raises nothing: the sibling of ADR-0144's `currency_field_repointed`, not in Open item 9 point 7.",
      "Verification, first line": "Final head `7928062332`. Changed lines: 2,763 (+2,743 / -20) across 33 files against the merge base `e1143241d`; the human-merge threshold is 3,000."
     },
     "adr_amendment": "Open item 12, appended after its last sentence:\n\n    *Note (2026-11-20):* the backfill half is settled on #35469 (7014013098) and built by #35492. `os migrate\n    unit-codes --object O --field F [--map-file FILE] [--org ID | --all-organizations] [--apply]` and its tenant-admin\n    twin `POST /api/v1/meta/_migrate-unit-codes` (`packages/objectql/src/unit-code-backfill.ts#backfillUnitCodes`,\n    `packages/rest/src/meta-unit-code-backfill-route.ts#registerMetaUnitCodeBackfillRoute`) rewrite the stored text of a\n    unit code field in place. They work from the operator's mapping of stored text, exactly as written, to a unit code.\n    Nothing is derived and nothing is folded: `kg`, `KG` and `kg ` are three keys. The run names the unit code field\n    (the `text` field a quantity's `unitField` names, or a `unitMode: 'code'` field), never the quantity.\n\n    - **Targets.** Each mapping target is judged by U5 before any row is read. With no organization named, an\n      organization's own code is judged in each organization the run would write it in, after the read-only preview\n      and before any write. A target that is no member, a retired unit, or a unit of another dimension than the field's\n      `unitDimension` refuses the run `INVALID_FIELD`.\n    - **Rows left as stored.** A row holding a unit code is never rewritten, so a second run writes nothing. A unit\n      code here is a code of U1 or any `sys_unit` row of the row's organization, a retired one included (L1 keeps a\n      resting row's code), or a code of another dimension. Neither is free text, and rewriting either from a mapping\n      would change what the stored quantity means. Neither is a code the field admits either. Beside a quantity, U5\n      refuses both at the row's next quantity edit. A standalone field has no quantity, so U5 never judges the resting\n      code; the next write of the field must carry another code. So the run lists and counts each apart (`retired`,\n      `other-dimension`), never as a code the field admits.\n    - **Blanks.** A blank unit beside a quantity is written only from an explicit `\"\"` entry; without one it is counted\n      and named. A blank with no quantity is left.\n    - **Complete.** A run is complete only when every row holds a unit code the field admits: no unmatched value, no\n      blank beside a quantity, no retired unit, no code of another dimension, and no failed or unexamined row. The\n      report and the CLI print their check-mark line only then.\n    - **Dry run and apply.** The dry run, the default, lists each distinct stored value with its row count and what the\n      mapping does with it. An apply run that meets a value with no entry is refused `VALIDATION_ERROR` on `mapping`\n      before any write, naming each value, so one run converts the whole field or nothing.\n    - **Scope.** Scope is ADR-0144 Open item 13's: one organization, or every one explicitly. An unscoped run over\n      several organizations' rows is refused with each one's counts. The REST twin converts the caller's current\n      organization only, behind `metadata.endpoints.maintenance` and `setup.write`, as a preview unless `apply: true`.\n    - **Writes.** Each row is written through `engine.update` under a system context, so U5 judges every converted\n      code.\n\n    The aggregate half stays with #35491.\n\nOpen item 9, appended after its last sentence (point 7):\n\n    *Note (2026-11-20):* point 7 is carried to #35492 (7035331645) and built there.\n\n    - (a) The `ERR_UNIT_CODE_REQUIRED` and `ERR_UNIT_CODE_UNKNOWN` refusals end with the remedy when the refused\n      write edits a quantity beside a resting value it did not supply. The remedy is `os migrate unit-codes` for that\n      object and field, or the REST twin (`packages/objectql/src/validation/unit-code-membership.ts#unitCodeBackfillRemedy`).\n      For a resting blank, it names the `\"\"` entry. A code the caller wrote carries no remedy, and neither does a\n      resting retired code, which the door leaves as stored.\n    - (b) A metadata save that makes a stored field a unit code field answers the 409 `DESTRUCTIVE_CHANGE`, beside\n      ADR-0144's `currency_mode_to_record`. The finding is keyed on the code field, as U5 is.\n      - `unit_code_field_declared` is raised for a stored field that is a unit code field after the save and was not\n        one before, whichever declaration made it one: a quantity, new or stored, whose `unitField` names it; a\n        `unitField` re-pointed at it; or its own `unitMode: 'code'`. A field that already was a unit code field\n        raises nothing.\n      - `unit_mode_to_record` is raised for a stored quantity switched to `unitMode: 'record'`, for the blank units\n        beside it, whatever the history of its `unitField`: a unit code field already, or a field new in the same\n        save. It is not raised when the same save raises `unit_code_field_declared` on that `unitField`, because that\n        finding names the quantity, its blanks and the `\"\"` entry. So each debt is reported once.\n\n      Each names that run for the code field, and `force: true` lifts both\n      (`packages/metadata-protocol/src/protocol-write-face.ts#detectDestructiveObjectChanges`). The detector reads no\n      row.\n\n    No finding is raised in R1 for a `unitField` re-pointed onto a field that already was a unit code field or onto a\n    field new in the same save (the sibling of `currency_field_repointed`), or for a narrowed `unitDimension`.\n\nOpen item 8, appended after its *Note* for ruling A (or after \"Not settled here.\" when no note is on main yet):\n\n    The backfill door reaches a standalone `unitMode: 'code'` field the same way it reaches a `unitField`. The field\n    has no quantity beside it, so its blank is owed nothing and is never written, with or without a `\"\"` entry\n    (#35492).\n\nReleases table, the R1 backfill row (if the table carries a status column): `os migrate unit-codes` and\n`POST /meta/_migrate-unit-codes`, #35492."
    }

    Generated by Claude Code

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

Metadata

Metadata

Assignees

Labels

area:datadomain:serverpm:dispatchedpriority:p2

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions