Skip to content

fix(service-analytics): a measure over a summary that declares its currency is priced - #39205

Merged
objectstack-fleet[bot] merged 5 commits into
mainfrom
claude/issue-39069-summary-measure-currency
Dec 3, 2026
Merged

objectstack-fleet[bot] merged 5 commits into
mainfrom
claude/issue-39069-summary-measure-currency

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Bill · project thread

repo:objectstack@os-bill · os-bill · session_01Utp6CYUove7YBXgHy4iEsr

Fixes #39069

Clause-②: yes (widening)
Metadata-protocol: none
Skills-docs: none (no file under skills/ says anything about a summary's currency in analytics; content/docs/data-modeling/currency.mdx says a dataset measure over the stored home field "needs nothing special", which stays true)

维护者速读

  1. 用户能看到什么变化:仪表盘和报表里,按子表合计字段(例如项目的实际成本合计)统计的金额,只要该合计声明了默认币种,现在会带上租户币种符号显示,不再是一串裸数字;由它和其他默认币种金额相加或相减得出的指标(例如毛利)也一样。声明了固定币种的合计显示它自己的币种。
  2. 为什么做:客户关系应用的项目总览里,“实际成本”一列显示为裸数字。这是“合计声明、度量自动跟随”方案中“度量跟随”这一半此前漏掉的情况。
  3. 出错会怎样:最坏是某个指标被标错币种,数值本身不变,只影响显示。原本能保存的数据集仍然都能保存。撤回本次改动即可恢复原来的裸数字。
  4. 要你做什么:无

What changes

  • plugin.ts, the only producer of sourceFieldMeta: it now relays the field's declared currencyConfig.currencyMode as an optional currencyMode, and only when a currencyConfig is declared. A declared config with no mode answers 'dynamic', the schema's default. Before this change, a summary declaring currencyMode: 'dynamic' and a summary declaring nothing relayed the same answer, {"type":"summary","multiple":false}, so no reader could tell them apart.

  • measure-currency-coherence.ts: one predicate, amountCurrencyOf, answers whether a source field is money in one currency, and which:

    • a currency field: its fixed code, else the tenant's;
    • a summary declaring dynamic: the tenant's;
    • a summary declaring fixed: its code;
    • a summary declaring nothing: none. Spec says "Absent: dynamic mode, and no currency on a summary", so nothing is inferred from the child field.

    A summary flag on the answer says which arm answered.

  • enrichResultColumns (analytics-service.ts) asks that predicate instead of type === 'currency'. An amount aggregate over a dynamic summary therefore takes the chain's tenant step, and one over a fixed summary takes its code. inTenantCurrency asks it for each plain operand (readsTenantAmount). A derived sum / difference over tenant amounts, with a dynamic summary among them, is priced too: Projects Overview's actual cost and margin.

  • Result column only, as ruled (ruling record 7361078803). resolvedOf takes only the currency-field arm of the predicate; the guards still judge currency fields, and fields of any type through a record-mode currencyField, as before. They read no summary's dynamic or fixed declaration, so no dataset that compiled before is refused now.

  • The widening: AnalyticsServiceConfig, re-exported from the package entry, gains the optional currencyMode member on its sourceFieldMeta answer, as homeAmountField and unitField did before (claim amendment 7362139221). A host that builds the service by hand and leaves it out keeps today's answer for summaries. DeclaredCurrency, the answer type of DatasetCompileOptions.declaredCurrency (also reachable from the package entry), gains the same optional currencyMode?; it has no effect at compile.

Tests

src/__tests__/summary-measure-currency-39069.test.ts runs through the plugin over a real engine (SQLite), on both strategies (native SQL and the ObjectQL aggregate):

  • Priced, tenant: sum and max over a dynamic summary, CNY.
  • Priced, derived: difference(planned, cost) and sum(cost_sum, cost_max), CNY.
  • Priced, fixed: sum over a summary fixed to EUR carries EUR.
  • Controls that stay bare:
    • a summary over the same currency child that declares no currencyConfig;
    • a number summary;
    • a count over the dynamic summary;
    • a derived sum with a number-summary operand;
    • a derived sum with an undeclared-summary operand;
    • a ratio.
  • Currency-field controls, unchanged: a dynamic currency field gives CNY, a fixed USD field gives USD.
  • Accept set unchanged: a derived sum of the EUR summary and the USD field still compiles and is served.
Red on base, green on head, one ablation
  • Red on base. The new test file ran with the three source files restored to base 9a13387d (git restore --source, then git checkout HEAD --, then git diff HEAD empty): 6 failed / 2 passed. The failures were expected undefined to be 'CNY' (tenant and derived) and expected undefined to be 'EUR' (fixed), on both strategies.
  • Green on head: the new file and record-currency-analytics.test.ts, 69 passed (69).
  • Ablation, once, on committed head e4c4802c. scripts/ablation-replace.mjs deleted the relay line currencyMode: declaredCurrencyMode, in plugin.ts (anchor 1 to 0, blob 5e2ecf79 to 27c88dd7). The same 6 tests went red with the same assertions. Restored blob equals HEAD's, and git diff HEAD is empty. The suite imports src through relative paths, so no dist rebuild was involved.

Acceptance notes

  • The ruled scope (result column only, ruling record 7361078803) leaves one mislabel, and this PR does not change it. On base, the resolver ignores a summary operand as it ignores a count. So a derived sum of a fixed-EUR summary and a fixed-USD field carries USD, as it did before. Its EUR summary column now says EUR, which makes this easier to see. Tightening the guards to read summaries, the option not taken, would have refused that dataset at compile. The test does not pin this label.
  • cube-registry.ts keeps its own type === 'currency' reads. They choose auto-generated cube measure types, not a currency label, so they are outside this predicate.

Verification

Head 236b6165 (L1 rework: ruling citation, guard wording, changeset names DeclaredCurrency.currencyMode, bare controls assert the column first). origin/main 53ca7319 was merged once at 708ac5a4; it brought no change under service-analytics, spec or objectql. On 236b6165: pnpm --filter @objectstack/service-analytics test 230 files passed, 5952 tests passed (345 skipped), and typecheck exit 0, one lock VERDICT command-exit 0.

Files to read first: measure-currency-coherence.ts (amountCurrencyOf, readsTenantAmount, the !amount.summary line in resolvedOf), then the currencyMode relay in plugin.ts.

Two-minute check: pnpm --filter @objectstack/service-analytics exec vitest run src/__tests__/summary-measure-currency-39069.test.ts should report 8 passed.

Package suite and typecheck
  • pnpm --filter @objectstack/service-analytics test: Test Files 230 passed (230), Tests 5952 passed and 345 skipped. Lock VERDICT command-exit 0.
  • pnpm --filter @objectstack/service-analytics typecheck (tsc --noEmit; --listFilesOnly shows the new test file is in its program): VERDICT command-exit 0.
Derived gates (dispatch-gates --commands, 76 families)
  • 75 of 76 ran at 708ac5a4, each exit 0.
    • check:plugin-teardown-shape --self-test first exited 3: its pinned fixture commit was missing from this shallow clone. After fetching that one commit, it exited 0.
    • check:query-options-erasure and check:type-check-debt were cut by a 240 s per-command cap. Re-run alone, each exited 0.
  • NOT MEASURED: check:dual-build-cjs-loads. It refused with PREREQUISITE NOT MET (exit 3) because no workspace dist exists in this worktree. CI's build carries it.
  • --ran reconciliation: 76 derived, 75 run, 1 NOT-MEASURED, 0 UNRUN.

Generated by Claude Code

…y (red on main)

WIP: the pin reproduces the card on origin/main 9a13387. A sum over a
summary declaring currencyMode 'dynamic' comes back with no currency, and so
does a derived difference over it. The fix waits on the surface question in
the report: the plugin's sourceFieldMeta relays the same answer for a
dynamic-currency summary and a summary that declares nothing.

Claude-Session: https://claude.ai/code/session_01Utp6CYUove7YBXgHy4iEsr
Co-authored-by: Claude <noreply@anthropic.com>
…its currency

The plugin's sourceFieldMeta relays the field's declared currencyConfig mode
(only when a currencyConfig is declared), and one predicate,
amountCurrencyOf, answers whether a source field is money in one currency
for the result column and the resolver alike. A dynamic summary takes the
tenant step and counts as a tenant operand for inTenantCurrency; a fixed
summary carries its code. The compile guards keep reading currency fields
only, so no accept set moves.

Claude-Session: https://claude.ai/code/session_01Utp6CYUove7YBXgHy4iEsr
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 Dec 2, 2026
@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/service-analytics, touching 8 documentable anchor(s).

12 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:

  • content/docs/api/data-api.mdx (via currencyMode (symbol, a field of interface DeclaredCurrency))
  • content/docs/data-modeling/currency.mdx (via currencyMode (symbol, a field of interface DeclaredCurrency))
  • content/docs/data-modeling/field-types.mdx (via currencyMode (symbol, a field of interface DeclaredCurrency))
  • content/docs/data-modeling/fields.mdx (via currencyMode (symbol, a field of interface DeclaredCurrency))
  • content/docs/data-modeling/formulas.mdx (via currencyMode (symbol, a field of interface DeclaredCurrency))
  • content/docs/data-modeling/units.mdx (via currencyMode (symbol, a field of interface DeclaredCurrency))
  • content/docs/data-modeling/validation-rules.mdx (via currencyMode (symbol, a field of interface DeclaredCurrency))
  • content/docs/deployment/cli.mdx (via currencyMode (symbol, a field of interface DeclaredCurrency))
  • content/docs/getting-started/common-patterns.mdx (via currencyMode (symbol, a field of interface DeclaredCurrency))
  • content/docs/plugins/packages.mdx (via AnalyticsServicePlugin (symbol, a top-level class))
  • content/docs/protocol/objectql/schema.mdx (via currencyMode (symbol, a field of interface DeclaredCurrency))
  • content/docs/protocol/objectql/types.mdx (via currencyMode (symbol, a field of interface DeclaredCurrency))

⛔ 4 release-owned page(s) also name something this change touched. These are read-only:

  • content/docs/releases/v17/17-6.mdx (via AnalyticsServicePlugin (symbol, a top-level class), sourceFieldMeta (symbol, a field of interface AnalyticsServiceConfig))
  • content/docs/releases/v17/17-7.mdx (via sourceFieldMeta (symbol, a field of interface AnalyticsServiceConfig))
  • content/docs/releases/v18/18-3.mdx (via currencyMode (symbol, a field of interface DeclaredCurrency))
  • content/docs/releases/v18/18-5.mdx (via currencyMode (symbol, a field of interface DeclaredCurrency))

content/docs/releases/ is RELEASE-OWNED (AGENTS.md "Documentation Guardrails"): release
notes are written centrally at release time, and a code PR that edits them is the exact PR
that guardrail exists to stop. They are still audited — read-only. If one of them is actually
wrong, file an issue or open a dedicated docs-only PR; do not edit it here.

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

Coarse fallback — 10 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 05e645b11873f5f53bcf9e8f8f3703f68b836daa → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 047722da85a2a526318d4e15ca531a88aa163233 — the merge of head 236b616583fce42bdf004c53bc14a87671a1d5ad into base 05e645b11873f5f53bcf9e8f8f3703f68b836daa, 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 047722da85a2a526318d4e15ca531a88aa163233 && git checkout 047722da85a2a526318d4e15ca531a88aa163233
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 05e645b11873f5f53bcf9e8f8f3703f68b836daa 236b616583fce42bdf004c53bc14a87671a1d5ad && git checkout -B drift-repro 05e645b11873f5f53bcf9e8f8f3703f68b836daa && git merge --no-ff 236b616583fce42bdf004c53bc14a87671a1d5ad

node scripts/docs-audit/affected-docs.mjs --json 05e645b11873f5f53bcf9e8f8f3703f68b836daa

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

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs 05e645b11873f5f53bcf9e8f8f3703f68b836daa → pass the list as
args.docs, on the commit named under Which tree this was computed on.

…idening

The new optional currencyMode on AnalyticsServiceConfig.sourceFieldMeta's
answer reaches the package's public entry, as homeAmountField and unitField
did, so the changeset declares Clause-② yes (widening). The level stays
patch.

Claude-Session: https://claude.ai/code/session_01Utp6CYUove7YBXgHy4iEsr
Co-authored-by: Claude <noreply@anthropic.com>
Cite the ruling record for the result-column-only scope, state what the
compile guards judge (currency fields and any record-mode currencyField),
name DeclaredCurrency.currencyMode in the changeset with its no-effect-at-
compile note, and assert each bare column exists before its currency.

Claude-Session: https://claude.ai/code/session_01Utp6CYUove7YBXgHy4iEsr
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-bill · os-bill · session_01Utp6CYUove7YBXgHy4iEsr

Contract review

Served-tier: TIER_DEFAULT
Head-sha: 236b616583fce42bdf004c53bc14a87671a1d5ad
Local-runs: none
Scope: packages/services/service-analytics/src/plugin.ts, packages/services/service-analytics/src/measure-currency-coherence.ts + packages/services/service-analytics/src/analytics-service.ts
Security-touching: no
Rule-change-verified: yes

① Derived judgments

The Clause-②: yes (widening) line is owed and complete: AnalyticsServiceConfig.sourceFieldMeta's answer gains an optional currencyMode (plugin.ts relays it only when a currencyConfig is declared), and DeclaredCurrency (answer type of DatasetCompileOptions.declaredCurrency, re-exported from src/index.ts) gains the same optional member; amountCurrencyOf / AmountCurrency are not re-exported. Both are named in the changeset. No accept set narrows: resolvedOf takes only the currency-field arm, so both compile-time guards judge as on main (ruling record 7361078803, result column only).

② Semver level

Metadata-protocol: none (no spec or metadata shape changed) ⇒ patch; the changeset is patch.

③ Boundary flags

Additive optional members only; a host that builds the service by hand and omits currencyMode keeps today's answer. No new id materialisation or app-side join. PR author objectstack-fleet[bot] (relay).

Implemented-by: claude/issue-39069-summary-measure-currency
Reviewed-by: session_01Utp6CYUove7YBXgHy4iEsr

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-bill · os-bill · session_01Utp6CYUove7YBXgHy4iEsr

维护者速读

  • 做了什么:数据集里对「动态币种汇总字段」做的度量(含派生的差额等)现在带租户币种,固定币种汇总带它自己的币种;项目总览的实际成本不再是裸数字。
  • 范围:按你选的「只修结果列」,编译期币种校验不变,原来能发布的数据集都还能发布。
  • 要你做什么:无,席位落地。
  • 风险:低;只新增两个可选类型成员(已在变更说明里写明为接口放宽)。

席位核对

ACCEPT — head 236b616583fce42bdf004c53bc14a87671a1d5ad (#39069, zone data-p2).

  • Shape: draft → main; Fixes #39069 is the first content line after attribution and signature; no closing keyword beside another number.
  • Premise measured: red pin on origin/main 9a13387 (expected undefined to be CNY), green after; ablation of the plugin relay turns 6 pins red (report 7362107940).
  • Ruling followed: record 7361078803 (result column only); resolvedOf and both compile guards unchanged for summaries (independent L1 read, term by term).
  • Gates: CI on this head 41 success / 20 expected skip / 0 failed; package suite 230 files, 5952 passed; typecheck exit 0.
  • Declarations: Clause-②: yes (widening) (sourceFieldMeta answer + DeclaredCurrency optional currencyMode), Metadata-protocol: none, patch; TIER_DEFAULT contract review PASS 7363440429.
  • Accepted deviations: a derived sum of a fixed-EUR summary and a fixed-USD field stays labelled USD, as on main (ruled scope; disclosed in Acceptance notes).
  • Out of scope: none filed. Skills-docs: none verified (grep skills/**, content/docs/**).
  • L1: independent review REWORK (body order, stale wording, changeset widening completeness, bare-control asserts, ruling cite) → all six closed on this head (delta read by the zone).
  • Landing: not governed (check-governed-merges.mjs --pr 39205), 348 lines ≤ 3000; zone lands.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review December 3, 2026 00:40
@objectstack-fleet
objectstack-fleet Bot enabled auto-merge December 3, 2026 00:40
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Dec 3, 2026
Merged via the queue into main with commit f9d84a2 Dec 3, 2026
62 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-39069-summary-measure-currency branch December 3, 2026 01:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Analytics: a measure over a summary field that declares currencyMode 'dynamic' gets no currency (only type 'currency' counts as money)

1 participant