Repository navigation
fix(service-analytics): a measure over a summary that declares its currency is priced - #39205
Conversation
…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>
…-measure-currency
📓 Docs Drift CheckThis PR changes 1 package(s): 12 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 4 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 10 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 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
|
…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>
|
repo:objectstack@os-bill · os-bill · session_01Utp6CYUove7YBXgHy4iEsr Contract reviewServed-tier: ① Derived judgmentsThe ② Semver level
③ Boundary flagsAdditive optional members only; a host that builds the service by hand and omits Implemented-by: VERDICT: PASS |
|
repo:objectstack@os-bill · os-bill · session_01Utp6CYUove7YBXgHy4iEsr 维护者速读
席位核对ACCEPT — head
|
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.mdxsays a dataset measure over the stored home field "needs nothing special", which stays true)维护者速读
What changes
plugin.ts, the only producer ofsourceFieldMeta: it now relays the field's declaredcurrencyConfig.currencyModeas an optionalcurrencyMode, and only when acurrencyConfigis declared. A declared config with no mode answers'dynamic', the schema's default. Before this change, a summary declaringcurrencyMode: '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:currencyfield: itsfixedcode, else the tenant's;summarydeclaringdynamic: the tenant's;summarydeclaringfixed: its code;A
summaryflag on the answer says which arm answered.enrichResultColumns(analytics-service.ts) asks that predicate instead oftype === 'currency'. An amount aggregate over a dynamic summary therefore takes the chain's tenant step, and one over a fixed summary takes its code.inTenantCurrencyasks it for each plain operand (readsTenantAmount). A derivedsum/differenceover 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).
resolvedOftakes only thecurrency-field arm of the predicate; the guards still judgecurrencyfields, and fields of any type through a record-modecurrencyField, as before. They read no summary'sdynamicorfixeddeclaration, so no dataset that compiled before is refused now.The widening:
AnalyticsServiceConfig, re-exported from the package entry, gains the optionalcurrencyModemember on itssourceFieldMetaanswer, ashomeAmountFieldandunitFielddid 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 ofDatasetCompileOptions.declaredCurrency(also reachable from the package entry), gains the same optionalcurrencyMode?; it has no effect at compile.Tests
src/__tests__/summary-measure-currency-39069.test.tsruns through the plugin over a real engine (SQLite), on both strategies (native SQL and the ObjectQL aggregate):sumandmaxover a dynamic summary,CNY.difference(planned, cost)andsum(cost_sum, cost_max),CNY.sumover a summary fixed toEURcarriesEUR.currencyConfig;countover the dynamic summary;ratio.dynamiccurrency field givesCNY, afixedUSD field givesUSD.sumof the EUR summary and the USD field still compiles and is served.Red on base, green on head, one ablation
9a13387d(git restore --source, thengit checkout HEAD --, thengit diff HEADempty): 6 failed / 2 passed. The failures wereexpected undefined to be 'CNY'(tenant and derived) andexpected undefined to be 'EUR'(fixed), on both strategies.record-currency-analytics.test.ts, 69 passed (69).e4c4802c.scripts/ablation-replace.mjsdeleted the relay linecurrencyMode: declaredCurrencyMode,inplugin.ts(anchor 1 to 0, blob5e2ecf79to27c88dd7). The same 6 tests went red with the same assertions. Restored blob equals HEAD's, andgit diff HEADis empty. The suite importssrcthrough relative paths, so nodistrebuild was involved.Acceptance notes
count. So a derivedsumof a fixed-EURsummary and a fixed-USDfield carriesUSD, as it did before. Its EUR summary column now saysEUR, 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.tskeeps its owntype === '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 namesDeclaredCurrency.currencyMode, bare controls assert the column first).origin/main53ca7319was merged once at708ac5a4; it brought no change underservice-analytics,specorobjectql. On236b6165:pnpm --filter @objectstack/service-analytics test230 files passed, 5952 tests passed (345 skipped), andtypecheckexit 0, one lock VERDICT command-exit 0.Files to read first:
measure-currency-coherence.ts(amountCurrencyOf,readsTenantAmount, the!amount.summaryline inresolvedOf), then thecurrencyModerelay inplugin.ts.Two-minute check:
pnpm --filter @objectstack/service-analytics exec vitest run src/__tests__/summary-measure-currency-39069.test.tsshould 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;--listFilesOnlyshows the new test file is in its program): VERDICT command-exit 0.Derived gates (dispatch-gates --commands, 76 families)
708ac5a4, each exit 0.check:plugin-teardown-shape --self-testfirst exited 3: its pinned fixture commit was missing from this shallow clone. After fetching that one commit, it exited 0.check:query-options-erasureandcheck:type-check-debtwere cut by a 240 s per-command cap. Re-run alone, each exited 0.check:dual-build-cjs-loads. It refused with PREREQUISITE NOT MET (exit 3) because no workspacedistexists in this worktree. CI's build carries it.--ranreconciliation: 76 derived, 75 run, 1 NOT-MEASURED, 0 UNRUN.Generated by Claude Code