Skip to content

feat(formula): publish the home-amount conversion arithmetic - #31631

Merged
os-zhuang merged 3 commits into
mainfrom
claude/project-thread-hji3xr
Nov 8, 2026
Merged

os-zhuang merged 3 commits into
mainfrom
claude/project-thread-hji3xr

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Steve · project thread
Fixes #31609

Clause-②: yes (widening)
Metadata-protocol: none

维护者速读

  • 改了什么:把引擎换算本位币金额的四个纯函数(toScaledDecimal、divideToPlaces、formatScaledDecimal、documentDateOf)和 ScaledDecimal 类型原样从 objectql 内部文件搬到已发布包 @objectstack/formula 并导出;objectql 改为导入回来,行为不变。
  • 为什么改:ui: home field read-only with "converted at RATE on DATE"; live preview when a rate exists; Studio editor for homeAmount (multi-currency M3-2, epic #8345; the read-only display is released with M2) #27196 要在发票表单上实时预览「≈ 本位币金额」,数字必须与保存时引擎算出的一致;前端已依赖 formula、不依赖 objectql,不允许复制第二份。
  • 风险与回滚:纯搬移,两段函数体逐字节相同(下方 Verification 有比对);三个既有换算测试文件一行未改且全绿。因 ADR-0144 有两处路径锚点指向被搬的文件,本 PR 同时改了这两处括注(受管面,Tier H)。回滚即 revert。
  • 先看:packages/formula/src/home-amount-arithmetic.ts(搬来的函数),packages/objectql/src/home-amount-projection.ts 顶部的导入/再导出,ADR-0144 第 387、402 行附近的锚点改动。
  • 两分钟验证:pnpm --filter @objectstack/formula exec vitest run src/home-amount-arithmetic.test.ts,预期 5 个用例全绿(JPY 0 位、USD 2 位、KWD 3 位、平分远离零、时区取日)。
  • 需要你做的:批准本 PR(改动触及 docs/adr/**,需 GOVERNED_APPROVERS 批准后由席位落地)。

What changes

  • New module packages/formula/src/home-amount-arithmetic.ts. toScaledDecimal, divideToPlaces (with its private divideRoundHalfAwayFromZero and abs), formatScaledDecimal, documentDateOf (with its private calendarDayIn, CALENDAR_DATE) and the ScaledDecimal type, moved byte-identical out of packages/objectql/src/home-amount-projection.ts, under a new module header. The module imports nothing.
  • packages/formula/src/index.ts exports the four functions and the ScaledDecimal type under their engine names. No clash in formula's index (git grep for each name on origin/main hits only objectql and ADR-0144).
  • packages/objectql/src/home-amount-projection.ts imports them from @objectstack/formula and re-exports them, so home-amount-recompute.ts and the projection test keep their import site. toStoredNumber (a projection-only step) stays. CURRENCY_FRACTION_DIGITS stays in @objectstack/spec. No new dependency edge: objectql, ui/packages/core and ui/packages/app-shell already depend on @objectstack/formula, which depends only on @objectstack/spec.
  • Forced edit, governed: docs/adr/0144-…-write-time-home-projection.md (+4/−2, seat claim amendment on formula: export the home-amount conversion arithmetic (scaled-decimal divide, rounding, document date) so the ui preview reuses the engine rule (blocks #27196 PR 2) #31609). Two anchor parentheticals pointed at packages/objectql/src/home-amount-projection.ts#documentDateOf and #divideToPlaces, #divideRoundHalfAwayFromZero, #toScaledDecimal. divideRoundHalfAwayFromZero is private and moves, so pnpm check:adr-symbol-anchors (required, Lint & Repo Gates) reds on any move-only diff. Both now point at packages/formula/src/home-amount-arithmetic.ts, and the 402 parenthetical says the arithmetic moved there unchanged on 2026-11-08 in formula: export the home-amount conversion arithmetic (scaled-decimal divide, rounding, document date) so the ui preview reuses the engine rule (blocks #27196 PR 2) #31609. No decision text changed.
  • Changeset .changeset/31609-home-amount-arithmetic-formula.md: @objectstack/formula patch, @objectstack/objectql patch (see Acceptance notes on the level).

Tests

  • New: packages/formula/src/home-amount-arithmetic.test.ts (5 cases), imported through formula's index: exact-decimal reading (number, string, bigint; non-numbers spell none); the CLDR digits read from CURRENCY_FRACTION_DIGITS — JPY 100 ÷ 0.0065 → 15385, USD 100 ÷ 1.0857 → 92.11, KWD 100 ÷ 3.2468 → 30.800, CNY 10000 ÷ 0.1389 → 71994.24 (the ui: home field read-only with "converted at RATE on DATE"; live preview when a rate exists; Studio editor for homeAmount (multi-currency M3-2, epic #8345; the read-only display is released with M2) #27196 sample); the half-away-from-zero tie on both signs (0.125 → 0.13, -0.125 → -0.13, JPY 0.5 → 1, KWD -0.0005 → -0.001, 1.005 → 1.01); a datetime taken as its calendar day in Asia/Shanghai and America/New_York; UTC when the zone is unset, UTC or unknown.
  • Unchanged and green: home-amount-projection.test.ts, engine-home-amount-projection.test.ts, home-amount-write-paths.test.ts (0 lines changed). No other test file is edited.
  • No ablation: the diff changes no tested behaviour (move-only); the new pin's red leg is main itself (below).

Acceptance notes

  • Changeset level. The delta asked for minor on formula. scripts/check-changeset-no-major.mjs (the level axis, maintainer ruling A) requires a declared Metadata-protocol: none to grade every entry it introduces patch, so both entries are patch. Raised with the seat in the report.
  • New export names (toScaledDecimal, divideToPlaces, formatScaledDecimal, documentDateOf, ScaledDecimal) keep the engine's names; listed for the seat's ruling at ACCEPT.

Verification

Head cc6ea750a, worktree merged with origin/main 133f75ae.

Red first: the new test on main's source (before the move)
FAIL  src/home-amount-arithmetic.test.ts > … > reads an exact decimal from a number, a string and a bigint; spells none for a non-number
TypeError: toScaledDecimal is not a function
… (4 more, same: toScaledDecimal / documentDateOf is not a function)
Test Files  1 failed (1)
Move-only: both blocks byte-identical

A script compared git show 95df3459:packages/objectql/src/home-amount-projection.ts against the new module:

blockA (old L141-213, 73 lines) at new line 21    # ScaledDecimal … formatScaledDecimal
blockB (old L225-269, 45 lines) at new line 95    # "The document date" heading … calendarDayIn

git diff --color-moved=zebra 95df3459 f3715fe6 over the two files colours every changed line as moved except: in objectql, the 8 added import/re-export lines and one removed blank line; in formula, the 20-line module header (copyright, docblock, the Exact decimal arithmetic section heading, blank lines). No line of a function body is outside the moved set.

Package runs (os-verify-lock, VERDICT 0)
  • @objectstack/formula build + test + typecheck: Test Files 66 passed (66), Tests 1708 passed (1708); check:test-typecheck OK.
  • @objectstack/objectql build; the three projection suites: Test Files 3 passed (3), Tests 76 passed (76); full test: Test Files 570 passed (570), Tests 11571 passed (11571); typecheck (tsc --noEmit + check:test-typecheck OK).
  • After the merge: turbo run build --filter='./packages/**': 81 successful, 81 total.
  • Lint: eslint packages/formula packages/objectql --no-inline-config exit 0.
ADR anchor gate, red then green

Move commit f3715fe6, before the ADR edit:

❌ check-adr-symbol-anchors: 1 finding(s) across 151 records.
  [unresolved-symbol] docs/adr/0144-…-write-time-home-projection.md:402  `#divideRoundHalfAwayFromZero`
      `divideRoundHalfAwayFromZero` has no declaration site or string-literal token in `packages/objectql/src/home-amount-projection.ts`

After cc6ea750a:

✅ check-adr-symbol-anchors: 3274 anchors across 151 records resolve — 856 symbol (829 declaration, 27 literal), 2367 file-level, 51 cross-repo, 6 exempt, 48 continuation.
Derived gates (dispatch-gates --commands, reconciled with --ran)

node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack on cc6ea750a: 73 commands (the ADR hunk adds check-adr-links ×2, check:adr-anchors, check:adr-index, check:pm-governed-merges, check:pm-prior-rulings and lint's check:doc-formula-expressions to the 66 the move derived).

  • 71 exit 0 on the first pass.
  • pnpm check:dts-closure and pnpm check:dual-build-cjs-loads exit 1 on that pass: six packages this diff does not touch (cloud-connection, connector-mcp, connector-openapi, connector-rest, trigger-record-change, trigger-schedule) had no .d.ts in this worktree's dist/ while a second gate sweep ran in the same tree. After turbo run build --force of those six (44/44), both exit 0: 256/256 declared declaration file(s) present across 80 package(s); 122/72/2525/1 entries over floors 90/58/520/1.
  • node scripts/check-plugin-teardown-shape.mjs --self-test needed its pinned fixture commit fetched (exit 3 → git fetch origin 621a4876… → exit 0, 48 cases).
  • --ran reconciliation: 73 derived famil(ies) accounted for — 73 run, 0 NOT-MEASURED.
  • Not in the derived list, run anyway: node scripts/check-platform-checklist.mjs --changed-from origin/main exit 0 (no anchored file in the change set).
  • No dogfood battery: no ! in the title and no (narrowing) arm.

Generated by Claude Code

Move toScaledDecimal, divideToPlaces (with divideRoundHalfAwayFromZero),
formatScaledDecimal, documentDateOf (with calendarDayIn) and the
ScaledDecimal type out of objectql's home-amount projection into
@objectstack/formula, byte-identical, and export them from its index.
objectql imports them back and re-exports them from the projection
module, so its callers and tests keep their import site.

A new formula test pins the exports on the engine's samples: JPY 0,
USD 2 and KWD 3 digits, the half-away-from-zero tie, a datetime's
calendar day in a non-UTC zone, and UTC when the zone is unset.

Claude-Session: https://claude.ai/code/session_01ADHkmQeo8gpywkDhZJu9nP
Co-authored-by: Claude <noreply@anthropic.com>
The home-amount arithmetic moved unchanged into @objectstack/formula;
the D5 settlement notes now anchor documentDateOf, divideToPlaces,
divideRoundHalfAwayFromZero and toScaledDecimal there, so
check:adr-symbol-anchors resolves them again.

Claude-Session: https://claude.ai/code/session_01ADHkmQeo8gpywkDhZJu9nP
Co-authored-by: Claude <noreply@anthropic.com>
@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 8, 2026
@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

9 anchor(s) derived from 2 changed package(s); no hand-written page names any of them. ⚠️ 1 changed file(s) yielded no anchor (packages/formula/src/index.ts), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

What this run could not see
  • 1 changed file(s) yielded no anchor (packages/formula/src/index.ts) — pages documenting those are invisible to this run
  • 3 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 64 of 227 client-bound route-ledger rows — the other 163 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 163: 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; 104 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 — 29 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 69244406b7e93b8856f3a5991ec18433a7e96dc4 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 4cc190191dc30f403527cb34bc25b93e0341eeae — the merge of head cc6ea750a12b616c7c77867e1d419b1c45059733 into base 69244406b7e93b8856f3a5991ec18433a7e96dc4, 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 4cc190191dc30f403527cb34bc25b93e0341eeae && git checkout 4cc190191dc30f403527cb34bc25b93e0341eeae
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 69244406b7e93b8856f3a5991ec18433a7e96dc4 cc6ea750a12b616c7c77867e1d419b1c45059733 && git checkout -B drift-repro 69244406b7e93b8856f3a5991ec18433a7e96dc4 && git merge --no-ff cc6ea750a12b616c7c77867e1d419b1c45059733

node scripts/docs-audit/affected-docs.mjs --json 69244406b7e93b8856f3a5991ec18433a7e96dc4

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

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#2 · os-steve · session_01ADHkmQKZzp4DLtqiCkZZRM

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: cc6ea750a12b616c7c77867e1d419b1c45059733
Local-runs: none
Scope: docs/adr/0144-multi-currency-record-currency-dated-rates-write-time-home-projection.md + packages/formula/src/home-amount-arithmetic.ts, packages/formula/src/index.ts, packages/objectql/src/home-amount-projection.ts

Inputs read: card #31609 (body and all five comments: triage 6724150397, claim 6724336691, triage H14 6724444852, claim amendment 6724651755, os-dev-report 6724915226), PR #31631 body and file list (6 files), the net diff 133f75ae..cc6ea750 (merge-base with origin/main; origin/main at 69244406 has not moved the three touched source files or the ADR since the merge-base), and the check-runs on the head. The rest of the diff (.changeset/31609-home-amount-arithmetic-formula.md, packages/formula/src/home-amount-arithmetic.test.ts) is the lane seat's ACCEPT at TIER_DEFAULT and is not reviewed here beyond what ② needs.

① Derived judgments

  • Face and tier — right. reviewFace on the file list returns hits = the ADR alone (rules face). docs/adr/** is a Tier H register row, so the whole PR is Tier H: it is a draft with no auto-merge, and the PR body says landing waits for a GOVERNED_APPROVERS approval. The seat's claim amendment 6724651755 ruled the anchor repoint rides this PR and ordered this review; the amendment is on the card.
  • Accept-set — unchanged, right. No packages/spec/** path, no Zod schema, no authorable key, value or default moves. CURRENCY_FRACTION_DIGITS stays in @objectstack/spec/data and objectql still imports it from there. Metadata-protocol: none is the correct kind.
  • Public surface of @objectstack/formula — widened, right. packages/formula/src/index.ts gains four value exports (toScaledDecimal, divideToPlaces, formatScaledDecimal, documentDateOf) and one type export (ScaledDecimal). Nothing is removed. A git grep of the head tree finds no earlier binding of any of these names in formula's index, so no clash. Clause-②: yes (widening) on the PR body and the changeset body is the right declaration.
  • Public surface of @objectstack/objectql — unchanged, right. packages/objectql/src/index.ts exported none of the five names at the merge-base and exports none at the head (it exports only HomeAmountReads, HomeAmountServing, ExchangeRateRow types from the projection module). The re-export added to home-amount-projection.ts keeps an internal import site (home-amount-recompute.ts L116-120, home-amount-projection.test.ts L21) and publishes nothing new from the package. The objectql changeset entry is earned by its moved published source, not by a surface change.
  • Dependency graph — no new edge, right. packages/objectql/package.json already lists @objectstack/formula: workspace:*, and eleven objectql src/ files already import from '@objectstack/formula' at the merge-base. packages/formula/package.json dependencies are unchanged (@marcbachmann/cel-js, @objectstack/spec); the new module imports nothing at all. No cycle: formula does not depend on objectql.
  • Browser safety of formula — holds. ui/packages/core and ui/packages/app-shell depend on @objectstack/formula (workspace:^), and ExpressionProvider.tsx imports it in browser code. The new module uses only BigInt, RegExp, Date, Intl.DateTimeFormat and String — no node: import, no Node global. A grep of packages/formula/src (tests excluded) for node:, fs or path imports finds none at the head.
  • Check-runs on the head as read at 2026-11-08T17:54Z (61 runs): 31 success, 9 skipped, 0 failure, 21 in_progress. Green: Lint & Repo Gates, Lint · docs & code guards, Lint · repo & tooling gates, Lint · CI, release & engine gates, Lint · ESLint, Lint · PM dispatch-gates, the three scoped lints, Type Check · source gates, Check Changeset, Governed Surface Queue Guard, PR-body guards, Check PR Size, Check Documentation Links, Flag docs affected by code changes, Build UI Deps, Live E2E UI, Dogfood Regression Gate, Plan Test Core shards, Auto Label, filter. Still running: Build Core, Test Core (1-8/8), Test UI (1-16/16), Type Check UI, Type Check · consumer gates, Type Check · debt ledger, Type Check · workspace, Build & E2E UI. The ADR anchor gate (check:adr-symbol-anchors) rides the lint families, all of which are green on this head. No conclusion read red.

② Semver level

  • Changeset .changeset/31609-home-amount-arithmetic-formula.md: @objectstack/formula: patch, @objectstack/objectql: patch. Both line-initial declarations are present in the changeset body and in the PR body, byte-identical: Clause-②: yes (widening) and Metadata-protocol: none.
  • Level is right. AGENTS.md Post-Task rule 3 and the level axis of scripts/check-changeset-no-major.mjs (maintainer ruling A): the level follows the metadata-protocol kind alone; none grades every introduced entry patch, and "a non-protocol change, widening or breaking, ships patch". A feat(formula): commit type may not lower a bump and does not raise one above what the kind allows. The dev's delta asked minor; patch is what the rule requires, so the shipped level is the correct one, not a compromise. Check Changeset is green on the head.
  • Not skip-changeset: two released packages publish moved source. Right.
  • No BREAKING banner, no ADR-0087 disposition owed: nothing an author or an importer could write is removed or renamed (objectql's package index never exported the four, and its internal module re-exports them).
  • Clause-②: yes (widening) — matches the diff exactly (new exports on formula, nothing removed anywhere).

③ Boundary flags

Dev report 6724915226 (os-dev-report), four deviations and two open questions:

  1. ADR-0144 edited (+4/-2), governed, Tier H — answered. The seat's claim amendment 6724651755 ruled the repoint rides this PR because check:adr-symbol-anchors cannot stay green across two PRs when a private symbol (divideRoundHalfAwayFromZero) moves. Verified in ④: the hunk is anchor-only. The PR is correctly left as a draft awaiting the maintainer's approval; this record does not lift Tier H.
  2. Changeset level patch where the delta said minor — answered in ②: patch is what the rule requires under Metadata-protocol: none. No exception is owed or available.
  3. Two overlapping local gate sweeps, dts reds cleared by rebuilding six untouched packages — a worktree-process matter with no footprint in the tree (the six packages are not in the diff). The head's check-runs are the gate verdicts of record; no local reading is adopted here.
  4. Harness attribution lines not used in commits — the two non-merge commits (f3715fe6, cc6ea750) end with the model-free pair Claude-Session: + Co-authored-by: Claude that AGENTS.md's commit-message rule requires; the harness-written trailer is the rule's named exemption, not a requirement. Compliant; nothing to escalate.

Open questions:

  • Q1 — keep the engine names (toScaledDecimal, divideToPlaces, formatScaledDecimal, documentDateOf, ScaledDecimal) on @objectstack/formula? Answered: A, keep. ADR-0144's anchors name these symbols; home-amount-recompute.ts and the projection test import them by these names; the card's step 3 says the ui imports them by name; a rename would force an alias layer in objectql's re-export with no reader gaining anything. No clash in formula's index.
  • Q2 — accept patch on formula? Answered: A, patch — see ②.

No flag is escalated; none needs the maintainer beyond the Tier H approval the PR already waits on.

④ Design judgment

The ADR hit, sentence by sentence. Both hunks sit under ## Open items (the dated settlement notes of items 2 and 3), not under any D1-D9 decision section; no decision text, status line, provenance or consequence changed.

  • Line 387 (item 2, the document date): the only change is the backticked path, packages/objectql/src/home-amount-projection.ts#documentDateOf to packages/formula/src/home-amount-arithmetic.ts#documentDateOf. The clause "the zone rides the same settings bridge as the home currency, item 4" is untouched, and remains true: documentDateOf still takes the zone objectql reads through serving.timezone (projection L398, recompute L492). Anchor resolves: documentDateOf is declared at packages/formula/src/home-amount-arithmetic.ts L111 in the head tree.
  • Lines 402-404 (item 3, arithmetic and rounding): the path swaps to packages/formula/src/home-amount-arithmetic.ts; the three symbol continuations #divideToPlaces, #divideRoundHalfAwayFromZero, #toScaledDecimal are unchanged and resolve at L81, L67 and L36 of the new file (the private one as a declaration site, which the gate accepts). The appended clause — "moved there unchanged from packages/objectql/src/home-amount-projection.ts, which imports them back, on 2026-11-08 in formula: export the home-amount conversion arithmetic (scaled-decimal divide, rounding, document date) so the ui preview reuses the engine rule (blocks #27196 PR 2) #31609, so the form's live home-amount preview reads the engine's one copy" — is provenance, true against the tree (byte-identity below; objectql imports them back at its L71), and adds a file-level anchor to the objectql module, which exists. It decides nothing; the sentence it extends (D7 parameter 3, exact BigInt arithmetic, one half-away rounding, the bare-number spelling) is unchanged.
  • Every other ADR-0144 anchor into the objectql file (#projectHomeAmounts L346, L382, L407, L426, L448; #memoizeHomeAmountServing L382; #HomeCurrencyUnsetError L425, L468; #ExchangeRateMissingError L467; #settleBulkHomeAmounts L473) names a symbol still declared in packages/objectql/src/home-amount-projection.ts at the head (L204, L249, L296, L355, L424). The scripts/adr-anchors/ JSON for home-amount-recompute.ts names no moved symbol. No other doc, ADR or ui/ file in the head tree cites the moved symbols under the old path.
  • First consumer: projectHomeAmounts (objectql L355-407) calls toScaledDecimal, divideToPlaces, formatScaledDecimal, documentDateOf at L369, L384, L398, L402, L406, L407 exactly as before, now through the import; toStoredNumber (the projection-only step) stays in objectql. The ADR's execution plan is unchanged (the record still "implements nothing").
  • Nit: the appended clause cites the card number as provenance inside the ADR; AGENTS.md treats tracker numbers as convenience links, and these notes already cite PR feat(objectql): store a record-mode amount converted into the home currency on every write (multi-currency M2-2) #28302 the same way, so this is consistent with the record's existing style. No action.

packages/formula/src/home-amount-arithmetic.ts — the move is byte-identical. Read-only comparison with git show and cmp (no build, no run): merge-base objectql L141-213 (73 lines: ScaledDecimal, DECIMAL_SPELLING, toScaledDecimal, abs, divideRoundHalfAwayFromZero, divideToPlaces, formatScaledDecimal) equals new L21-93, sha256 e2d14cd8…; merge-base L225-269 (45 lines: the document-date heading, CALENDAR_DATE, documentDateOf, calendarDayIn) equals new L95-139, sha256 bcd97179…. Every line outside those two blocks is the licence line, a 15-line module docblock, the Exact decimal arithmetic section heading and blank lines; no function body is outside the moved set. The docblock carries the ADR id (ADR-0144 D5, D7 parameter 3, Open items 2 and 3), satisfying Prime Directive 13's "leave its id in the code". Its claim "has no dependency of its own" is true. Behaviour is identical by construction; the three unchanged objectql projection suites are the lane seat's evidence and are not re-run here.

packages/formula/src/index.ts — six added lines, a four-line comment naming ADR-0144 D5 and the two readers, then export { toScaledDecimal, divideToPlaces, formatScaledDecimal, documentDateOf } and export type { ScaledDecimal } from ./home-amount-arithmetic. Placed after inferFormulaReturn, no other line touched. Nit: the comment says the form's live preview "reads this one copy" in the present tense while that consumer (#27196 PR 2) does not exist yet; the sentence states the purpose correctly and will be true on that PR. No action.

packages/objectql/src/home-amount-projection.ts — +8/-120. Added: a four-line comment, import { documentDateOf, divideToPlaces, formatScaledDecimal, toScaledDecimal, type ScaledDecimal } from '@objectstack/formula', export { … } of the four values and export type { ScaledDecimal }. Removed: exactly the two blocks above plus their two trailing blank lines. toStoredNumber, homeAmountsTouched, planHomeAmounts, projectHomeAmounts, memoizeHomeAmountServing, the two error classes and settleBulkHomeAmounts are untouched; the module's 60-line header still describes the arithmetic correctly (it states behaviour, not location). The re-export keeps both internal import sites and the projection test's import site working without edit. Nit: the // ── Exact decimal arithmetic ── section heading remains above only toStoredNumber; cosmetic.

Anything moved that the card did not name? No. The diff touches six files; the private helpers that moved (DECIMAL_SPELLING, abs, divideRoundHalfAwayFromZero, CALENDAR_DATE, calendarDayIn) are the "private helpers" step 1 of the card names with the four functions; CURRENCY_FRACTION_DIGITS stays in spec as step 4 requires; toStoredNumber stays in objectql as a projection-only step.

Attempts to break it, all held: a dependency cycle (none: formula depends on spec and cel-js only); a Node-only import reaching the browser through formula (none in the new module or anywhere in formula src/); a lost objectql export (objectql's package index never exported the four, before or after); a stale anchor elsewhere (none: every other anchor into the objectql module names a symbol that stays; no other file cites the old path for the moved symbols); a changed body (byte-identical by cmp); a semver mis-grade (patch is the rule's grade under none); an unresolved anchor in the head tree (all four resolve by declaration site, and the lint families carrying the anchor gate are green on the head).

Findings: must-fix 0; should-fix 0; nit 3 (ADR provenance cites the card number, index comment's present tense, orphaned section heading in objectql). None affects correctness or the contract.

Implemented-by: claude/project-thread-hji3xr
Reviewed-by: subagent-fable-of-session_01ADHkmQKZzp4DLtqiCkZZRM

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#2 · os-steve · session_01ADHkmQKZzp4DLtqiCkZZRM

维护者速读

  • 改了什么:金额折算用的四个精确小数工具(toScaledDecimal、divideToPlaces、formatScaledDecimal、documentDateOf)和 ScaledDecimal 类型原样搬到 @objectstack/formula 并导出;objectql 从那里导回。
  • 为什么改:表单的本位币金额实时预览(ui: home field read-only with "converted at RATE on DATE"; live preview when a rate exists; Studio editor for homeAmount (multi-currency M3-2, epic #8345; the read-only display is released with M2) #27196 第 2 个 PR)要在浏览器里用引擎同一份算法,不能另抄一份。
  • 风险与回滚:逐字节搬移(cmp 校验),objectql 对外接口不变,没有新依赖边;ADR-0144 只改了两处锚点路径。回滚即还原本 PR。
  • 先看:packages/formula/src/home-amount-arithmetic.ts,以及 ADR-0144 第 387、402 行的锚点。
  • 两分钟验证:pnpm --filter @objectstack/formula exec vitest run src/home-amount-arithmetic.test.ts。
  • 需要你做的:本 PR 动了 docs/adr/**(Tier H),需要 os-zhuang 或 hotlong 批准并手动合并。
  • 席位意见:ACCEPT。纯搬移,ADR 改动只是锚点重指,不含任何决策文字。

席位核对 — ACCEPT · domain:server#2 · Head-sha cc6ea750a12b616c7c77867e1d419b1c45059733 · 2026-11-08T18:14Z

  1. Shape: draft to main, first line Fixes #31609; Clause-②: yes (widening) and Metadata-protocol: none at line start in the body and the changeset. Patch changeset for @objectstack/formula and @objectstack/objectql.
  2. Premise measured: red first on main source: the new formula test 5/5 failed (is not a function). After the move: formula 1708/1708, full objectql 11571/11571, the three projection suites unchanged and green.
  3. Gates (check-runs on this head): Lint & Repo Gates (carries check:adr-symbol-anchors), Type Check, Test Core, Test UI, Check Changeset and Governed Surface Queue Guard success; 0 failed. Dev: dispatch-gates --ran 73/73, 0 NOT-MEASURED. check-governed-merges --pr 31631: Tier H (docs/adr/** ×1), 354 changed lines.
  4. Accepted deviations: ADR-0144 anchor repoint rides this PR (claim amendment 6724651755); the changeset ships patch where the delta said minor (the rule's grade under Metadata-protocol: none).
  5. Out of scope: none. Contract review at CONTRACT_REVIEW_TIER: PR comment 6725085493, VERDICT PASS (0 must-fix, 0 should-fix, 3 nits, none actioned).
  6. Landing: new public names ruled, accepted as named on @objectstack/formula: toScaledDecimal, divideToPlaces, formatScaledDecimal, documentDateOf, ScaledDecimal. Tier H: stays draft, no auto-merge; handed to GOVERNED_APPROVERS (os-zhuang, hotlong) for an APPROVED review and a human merge.

@objectstack-fleet objectstack-fleet Bot added the pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue label Nov 8, 2026
@os-zhuang
os-zhuang marked this pull request as ready for review November 8, 2026 21:09
@os-zhuang
os-zhuang added this pull request to the merge queue Nov 8, 2026
Merged via the queue into main with commit fe88ecd Nov 8, 2026
70 checks passed
@os-zhuang
os-zhuang deleted the claude/project-thread-hji3xr branch November 8, 2026 21:40
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 pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue 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

2 participants