Skip to content

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

Description

@objectstack-fleet

repo:hotcrm@sunhaolin · sunhaolin · session_017xRBcUpajguxop2zMyDN9K

Filed from objectstack-ai/hotcrm#2569, PR hotcrm#2910. Class b (seam). Grade left to triage.

What happens

  • Setup: hotcrm 4f99dfb, pin @objectstack/* 19.0.0-next.3, tenant currency set to CNY. crm_project.actual_expense_cost is a Field.summary that declares currencyConfig: { currencyMode: 'dynamic' } (objectstack#35387).
  • Query: POST /api/v1/analytics/dataset/query {datasetName: 'project_financials'}.
    • planned_revenue_sum, which sums a currency field, comes back with currency: CNY.
    • expense_cost_sum, which sums the summary above, comes back with no currency.
    • The derived actual_cost_sum, gross_margin_sum and approved_to_bill_sum carry none either.
  • On screen: Projects Overview shows Actual Cost 0 as a bare number.

Cause (read in the service-analytics dist)

enrichResultColumns and measureCurrencyResolver treat a measure as money only when sourceFieldMeta().type === 'currency'. For a summary, that type is 'summary'. So a summary that declares the dynamic currency mode is never priced, and inTenantCurrency then fails for every derived operand.

Ask

A measure over a summary field whose currencyConfig.currencyMode is dynamic should be priced in the tenant currency, as its record field is. That is the "summary declares, measure follows" intent of #35471, which named Projects Overview's actual cost.


Generated by Claude Code

Activity

  1. objectstack-fleet commented on Dec 2, 2026

    @objectstack-fleet
    ContributorAuthor

    triage@os-warren · os-warren · session_01JQwxbZzZ2f5mzcvJbRrRNZ

    First touch · 2026-12-02T07:14Z

    定级:area:data · Bug · p2 · 声明动态币种的汇总字段做度量时不带币种,项目总览实际成本显示裸数字 · HotCRM 实测 + 读 service-analytics

  2. added
    domain:server
    pm:queue
    priority:p2
    on Dec 2, 2026
  3. objectstack-fleet commented on Dec 2, 2026

    @objectstack-fleet
    ContributorAuthor

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

    Self-audit (execution-duties 自分诊 ③): triage first touch 7337941097 (triage@os-warren, area:data · Bug · p2) is on this card; card-pick.mjs reads it as "no triage audit" because its recogniser does not read the **First touch** shape. Route and grade unchanged.

    Claim: PM loop round 1
    Session: session_01Utp6CYUove7YBXgHy4iEsr
    Account: os-bill
    Branch: claude/issue-39069-summary-measure-currency
    Worktree: objectstack-issue-39069
    Domain: domain:server
    Seat: repo:objectstack@os-bill
    Area: data-p2 (zone of seat repo:objectstack@os-bill, intake area:data p1/p2)
    File surface: packages/services/service-analytics/src/analytics-service.ts, packages/services/service-analytics/src/measure-currency-coherence.ts, and a new test file named for this card under packages/services/service-analytics/src/__tests__/ (reason: enrichResultColumns and measureCurrencyResolver price a measure only when the source field's type is currency) (stop on breach; explain in the report)
    Container & model: M, mode:subagent, model: default — dispatch-gates --tier: "The tier stays below the ceiling: with no mandate the PM picks floor or default per card", effort: high
    Clause-②: no
    Metadata-protocol: none
    Responsibility: service-analytics in this repo: a measure over a summary field that declares currencyConfig.currencyMode 'dynamic' comes back with no currency, so derived measures over it fail inTenantCurrency | #35471 priced tenant-currency amounts but keyed on type 'currency' only | every app with a dynamic-currency summary in a dataset (HotCRM Projects Overview measured)
    Thread-read: 7337941097
    Premise: holds — at origin/main 9a13387 the money test in analytics-service.ts and measure-currency-coherence.ts reads the source field's type; the dev re-measures with a summary field before writing code
    Pre-claim lane: domain:server (service-analytics is a server service package)
    Pre-claim deps: no Blocked-by: on the card; #35471 merged
    Prior rulings read: check-prior-rulings.mjs --card 39069 --paths packages/services/service-analytics/src/**: 714 hit lines in 129 files, owed per-line by the dev on the two source files it edits; no ruling on summary-field currency was found in the card thread
    Serial constraints cleared: check-handover.mjs --inflight on these paths: no readable in-flight surface meets them; none else
    Intake: area:data p2, on the maintainer's word 「再开 专区 处理 area:ux area:data p1 p2」 (2026-12-02T22:22Z).

  4. added
    pm:dispatched
    and removed
    pm:queue
    on Dec 2, 2026
  5. objectstack-fleet commented on Dec 2, 2026

    @objectstack-fleet
    ContributorAuthor

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

    {
      "issue": 39069,
      "status": "needs_decision",
      "branch": "claude/issue-39069-summary-measure-currency",
      "pr": null,
      "session": "session_01Utp6CYUove7YBXgHy4iEsr",
      "premise_still_valid": true,
      "summary": "Reproduced on origin/main 9a13387d through the plugin over a real engine. A sum over a summary declaring currencyMode 'dynamic' and a derived difference over it come back with no currency, while a sum over a currency field gets CNY. Head 286da352 has only the red pin (src/__tests__/summary-measure-currency-39069.test.ts). The PM's mechanism assumption (edit two files) does not hold. The plugin's sourceFieldMeta (plugin.ts ~1673, the only producer) returns only type, multiple and max, plus defaultCurrency under fixed and currencyField under record. Measured: cost_total (currencyConfig {currencyMode:'dynamic'}) and hours_total (no currencyConfig) both relay {\"type\":\"summary\",\"multiple\":false}, while the registry holds {\"currencyMode\":\"dynamic\"}. Inside the fence the service cannot tell a dynamic summary from one that declares nothing, so the fix needs plugin.ts, which is outside the file surface. Stopped on that breach before any source edit. Second finding: routing the compile guards through the one predicate narrows what compiles. Both are in open_questions. Answer to the PM's question: spec says a summary that declares nothing has no currency (field.zod.ts currencyConfig describe: 'Absent: dynamic mode, and no currency on a summary'), so there is no inference to add. A currencyConfig with no currencyMode on a summary is dynamic (record-currency-path.ts (d) docblock). No reusable helper exists: spec isTenantCurrencyAmount (record-currency-path.ts) is type 'currency' only and says a summary is not one, and summaryDeclaresCurrency lives in ui/packages/fields. A fixed summary is unpriced in analytics today as well: line 3940 needs type 'currency', so a plain sum over a fixed-EUR summary carries no EUR.",
      "tests": "pnpm --filter @objectstack/service-analytics exec vitest run --maxWorkers=2 src/__tests__/summary-measure-currency-39069.test.ts on base 9a13387d (only the new file): 1 failed / 1, 'AssertionError: expected undefined to be CNY' at the cost_sum line (planned_sum, over a currency field, passed first). Lock VERDICT command-exit 1. Throwaway probe in the same file (since removed): sourceFieldMeta(os39069_project,'cost_total') = {\"type\":\"summary\",\"multiple\":false}, sourceFieldMeta(...,'hours_total') = {\"type\":\"summary\",\"multiple\":false}, registry cost_total.currencyConfig = {\"currencyMode\":\"dynamic\"}; VERDICT command-exit 0. No green yet and no ablation, because no source was edited.",
      "gates": "NOT MEASURED: all derived gate families, reason: no source change; the branch holds one red test file and stopped at the surface breach. Local runs: build of the '@objectstack/service-analytics^...' closure, VERDICT command-exit 0; the probe runs above. No PR exists, so there are no check-runs to cite.",
      "line_budget": "n/a: no source diff; +119 lines in one new test file",
      "deviations": "Stopped at the fence before the fix: plugin.ts (the only sourceFieldMeta producer) is outside the claimed file surface. The harness attribution asked for a model-named Co-Authored-By trailer; the commit uses the model-free pair AGENTS.md requires. Q2's options were not graded on decision axes: the dispatch carried no axes, so they are given with cost, effort and a recommendation only.",
      "files_changed": ["packages/services/service-analytics/src/__tests__/summary-measure-currency-39069.test.ts (new, red pin)"],
      "head_sha": "286da352",
      "mcp_calls": "0",
      "api_writes": "3: git push (empty-branch probe), git push (WIP 286da352), post-stamped comment on #39069 (this report). No PR created.",
      "classifier_refusals": [],
      "open_questions": [
        {
          "question": "Q1 (surface): the fix needs the sourceFieldMeta producer, packages/services/service-analytics/src/plugin.ts, which is outside the claimed surface. Admit it?",
          "options": [
            "A Add plugin.ts to the surface. It relays the field's declared currency mode as a new optional member of the sourceFieldMeta answer, only when a currencyConfig is declared (an absent mode reads as 'dynamic'). analytics-service.ts:3940 and measure-currency-coherence.ts:150 then ask one predicate over it ('is this source field money, and in which mode'). Cost: about 40 source lines over 3 files, plus one optional member on the exported AnalyticsServiceConfig.sourceFieldMeta type, as homeAmountField and unitField were added before. Effort: S.",
            "B Stay in the fence and read currencyConfig off getObjectDeclaration (the exposure gate's unparsed registry hook). Cost: a second producer for field currency next to sourceFieldMeta, whose header says the rule is decided at the one producer. Effort: S.",
            "C Treat every summary as money. Refused: spec says a summary that declares nothing has no currency."
          ],
          "recommendation": "A, because the declaration is lost at the producer and Contract-first says fix it there. B forks the one-producer rule."
        },
        {
          "question": "Q2 (accept set): should the compile-time currency guards also read a summary's declared currency, or only the result column?",
          "options": [
            "A One predicate everywhere, guards included. resolvedOf then resolves a dynamic summary to tenant and a fixed summary to its code. New compile refusals (DATASET_INVALID / 400): a derived measure combining a record-mode amount with a dynamic or fixed summary, a fixed summary with a different fixed code, and a measure currency that contradicts a derived fixed-summary code. This narrows what compiles, against the claim's 'Clause-②: no' / 'Metadata-protocol: none': it means no (narrowing) / narrowed, a minor changeset with BREAKING and ADR-0087 disposition, and needs:dogfood-battery. Effort: M.",
            "B Column only. A plain measure over a dynamic summary takes the tenant step, and one over a fixed summary takes its code. A dynamic summary counts as a tenant operand for inTenantCurrency, so the card's derived measures are priced. resolvedOf and both guards stay unchanged for summaries, so no accept set moves and the claim's declarations hold. This is the same discipline as #35471, which left the resolver and guards untouched. Cost: for summaries the column reads more than compile judges. Effort: S.",
            "C Column only for dynamic, and leave fixed summaries unpriced as today. Cost: a fixed summary stays bare, against the spec line that the analytics layer reads it. Effort: S."
          ],
          "recommendation": "B, because it ships the card's ask (tenant pricing of a dynamic summary and of derived measures over it) and moves no accept set, as the claim declared. The guard narrowing in A is a separate decision about refusals and can be filed as its own card if wanted."
        }
      ],
      "security_findings": "none",
      "out_of_scope_findings": [
        "carrier: none · noted, not filed: a fixed-mode summary is unpriced in analytics today (only type 'currency' takes the chain at analytics-service.ts:3940), although field.zod.ts says a fixed summary is 'read by the analytics layer'. Folded into Q2 because it is the same predicate."
      ]
    }
  6. objectstack-fleet commented on Dec 2, 2026

    @objectstack-fleet
    ContributorAuthor

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

    Claim amendment (claim 7360788790): File surface adds packages/services/service-analytics/src/plugin.ts (reason: os-dev report 7360999367 measured that the plugin's sourceFieldMeta, the only producer, relays {type:'summary', multiple:false} for a summary whether or not it declares currencyConfig, so the service cannot tell a dynamic summary from one that declares nothing; the declared currency mode is relayed at the producer as an optional member, the way homeAmountField and unitField were added). check-handover.mjs --inflight --paths=packages/services/service-analytics/src/plugin.ts --card=39069: no readable in-flight surface meets it.

    Report Q1: option A taken (zone route: fix at the one producer; B would fork the one-producer rule). Report Q2 (whether the compile-time currency guards also read a summary's declared currency): the dev proceeds on option B (result column only; resolver and guards unchanged, as #35471 did; no accept set moves; Clause-②: no and Metadata-protocol: none hold). Q2 is put to the maintainer; ACCEPT waits on the answer.

  7. objectstack-fleet commented on Dec 2, 2026

    @objectstack-fleet
    ContributorAuthor

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

    Ruling: #39069 · Q2 of os-dev report 7360999367 · maintainer tapped 「只修结果列(推荐)」 (2026-12-02T22:42Z) on the decision card in the zone thread

    Question as shown: 「#39069 汇总字段带币种后,数据集编译时的币种校验要不要也跟着收紧?」 Option as shown: 「只修结果列(推荐)」 — 「动态币种汇总按租户币种显示、派生度量能算,编译校验不变,不新增拒绝,小改动。」

    Ruled: the result column only. A measure over a summary declaring currencyMode: 'dynamic' takes the tenant step and counts as a tenant operand for inTenantCurrency; a fixed-mode summary's column carries its code; resolvedOf and both compile-time currency guards stay unchanged for summaries, so no dataset that compiles today is refused. The guard narrowing (option 「校验也一起收紧」) is not built; no follow-up card is owed unless the maintainer asks for one.

  8. objectstack-fleet commented on Dec 2, 2026

    @objectstack-fleet
    ContributorAuthor

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

    {
      "issue": 39069,
      "status": "done",
      "branch": "claude/issue-39069-summary-measure-currency",
      "pr": "https://github.com/objectstack-ai/objectstack/pull/39205",
      "pr_number": 39205,
      "head_sha": "708ac5a4",
      "session": "session_01Utp6CYUove7YBXgHy4iEsr",
      "premise_still_valid": true,
      "summary": "Implemented the zone answer (record 7361029898): Q1 A and Q2 B. plugin.ts sourceFieldMeta relays the declared currencyConfig.currencyMode as an optional currencyMode, only when a currencyConfig is declared (no mode reads as 'dynamic'). One predicate, amountCurrencyOf in measure-currency-coherence.ts, answers whether a source field is money in one currency: a currency field gives its fixed code, else the tenant's; a summary declaring dynamic gives the tenant's; a summary declaring fixed gives its code; a summary declaring nothing gives none. enrichResultColumns (analytics-service.ts, formerly the type === 'currency' line) and inTenantCurrency's operand test (readsTenantAmount) ask it, so a dynamic summary is priced in the tenant currency and so are derived sum/difference measures over it. resolvedOf takes only the currency-field arm, so both compile guards and every accept set are unchanged. Public entry: AnalyticsServiceConfig is re-exported from the package's only entry (src/index.ts: export type { AnalyticsServiceConfig }), so the new optional currencyMode member reaches the public types; amountCurrencyOf and DeclaredCurrency do not. Clause-②: the PR and changeset carry the claim's 'Clause-②: no', but the identical shape had a different declaration before: the homeAmountField and unitField members of the same sourceFieldMeta answer each shipped as 'Clause-②: yes (widening)' (service-analytics CHANGELOG, 'The widening.' entries). By that precedent this optional member is a public-surface widening. The seat should amend the claim to 'yes (widening)', and the PR body and changeset with it. The changeset level is patch either way, because Metadata-protocol stays none.",
      "tests": "Red on base: summary-measure-currency-39069.test.ts with the 3 sources restored to 9a13387d gave 6 failed / 2 passed ('expected undefined to be CNY' and 'to be EUR', both strategies; the 2 passes are the bare-control tests). Green: that file plus record-currency-analytics.test.ts gave 69 passed (69). Package: pnpm --filter @objectstack/service-analytics test gave Test Files 230 passed (230), Tests 5952 passed / 345 skipped, VERDICT command-exit 0. Typecheck: tsc --noEmit gave VERDICT command-exit 0, and --listFilesOnly shows the new test in the program. Ablation, once, on committed e4c4802c: ablation-replace deleted 'currencyMode: declaredCurrencyMode,' in plugin.ts (anchor 1 to 0, blob 5e2ecf79 to 27c88dd7); the same 6 went red. Restored blob equals HEAD's and git diff HEAD is empty. Imports are relative to src, so no dist rebuild was needed.",
      "gates": "Local, at 708ac5a4: dispatch-gates --commands --repo objectstack-ai/objectstack derived 76 families. 75 ran with exit 0 each. Two of those first hit snags: check:plugin-teardown-shape --self-test exited 3 until its pinned fixture commit 621a4876 was fetched into this shallow clone, and check:query-options-erasure and check:type-check-debt were cut by a 240s per-command cap (exit 124) and then exited 0 when re-run alone. NOT-MEASURED: pnpm check:dual-build-cjs-loads :: exit 3, PREREQUISITE NOT MET, no workspace dist in this worktree; CI builds it. --ran: 76 derived, 75 run, 1 NOT-MEASURED, 0 UNRUN. Control-byte grep over the 4 edited files: no hits. CI on PR #39205 head 708ac5a4: in_progress when reported (23 check-runs, e.g. 'Lint · repo & tooling gates' in_progress); no conclusion is cited, and convergence is the PM's.",
      "line_budget": "+325 / -17 across 5 files (source +103 / -17 in 3 files, test +196, changeset +16); far under the 3,000 human-review line",
      "deviations": "The commits carry the model-free trailer pair from AGENTS.md, not the harness's model-named Co-Authored-By. The PR body footer uses the session-URL form from AGENTS.md, not the harness's '🤖 Generated with' line. No assignee and no reviewer were set, per the order. The Clause-② line was copied from the claim although precedent reads 'yes (widening)' (see summary). Also two refs under refs/os-dev-39069/ were fetched for the merge and the teardown fixture, and are deleted at cleanup.",
      "files_changed": [
        ".changeset/39069-summary-measure-currency.md",
        "packages/services/service-analytics/src/__tests__/summary-measure-currency-39069.test.ts",
        "packages/services/service-analytics/src/analytics-service.ts",
        "packages/services/service-analytics/src/measure-currency-coherence.ts",
        "packages/services/service-analytics/src/plugin.ts"
      ],
      "mcp_calls": "0",
      "api_writes": "3 REST writes through the relay: 1 pr_create (#39205, draft, no labels or assignees) and 2 post-stamped comments on #39069 (report 7360999367, and this report). Separately, 4 git pushes, which are not REST writes: the empty-branch probe, WIP 286da352, the fix e4c4802c and the merge 708ac5a4.",
      "classifier_refusals": [],
      "open_questions": [
        {
          "question": "Clause-② on PR #39205: the claim says 'no', but the new optional AnalyticsServiceConfig.sourceFieldMeta member reaches the public entry. The same shape (homeAmountField, unitField) shipped as 'yes (widening)'. Which line stands?",
          "options": [
            "A Amend to 'Clause-②: yes (widening)' in the claim, the PR body and the changeset; level stays patch (Metadata-protocol: none)",
            "B Keep 'no', reading a host-hook answer member as no public-surface widening"
          ],
          "recommendation": "A, because the package's own CHANGELOG declared the two identical members that way."
        }
      ],
      "security_findings": "none",
      "out_of_scope_findings": [
        "carrier: maintainer, under the Q2 question already put · noted, not filed: under option B, a derived sum of a fixed-EUR summary and a fixed-USD field is still labelled USD. On base too, the resolver ignores the summary operand as it ignores a count. Under option A the dataset would be refused at compile. The test does not pin this label; see the PR's Acceptance notes."
      ]
    }
  9. objectstack-fleet commented on Dec 2, 2026

    @objectstack-fleet
    ContributorAuthor

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

    Claim amendment (claim 7360788790), declaration corrected after the dev's measurement (report 7362107940): the new optional currencyMode member of AnalyticsServiceConfig.sourceFieldMeta's answer reaches the package's public entry (src/index.ts re-exports AnalyticsServiceConfig), and the identical shape (homeAmountField, unitField on the same answer) shipped as a widening per the service-analytics CHANGELOG. So:

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

    The PR #39205 body and the changeset carry the same lines; the level stays patch. The widening owes the lane seat's own review of record at TIER_DEFAULT for the declaration (contract-review.md), taken with L1.

  10. objectstack-fleet commented on Dec 3, 2026

    @objectstack-fleet
    ContributorAuthor

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

    ACCEPT → PR #39205 comment 7363465674 (head 236b6165); landed by the zone (ready + auto-merge). On MERGED: close-out here.

  11. objectstack-fleet commented on Dec 3, 2026

    @objectstack-fleet
    ContributorAuthor

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

    Close-out · 2026-12-03T01:23Z · PR #39205 merged (merge f9d84a2e1b): a dataset measure over a dynamic-currency summary field (and a derived measure such as a variance built on it) now carries the tenant currency in the result column, and a fixed-currency summary carries its own; the project overview's actual cost is no longer a bare number. Built as ruled (Bill 「只修结果列」, ruling 7361078803): result column only, no new guards. Reviewed by the TIER_DEFAULT contract review 7363440429 (Clause-② yes, widening) and seat ACCEPT 7363465674. pm:dispatched removed.

  12. removed
    pm:dispatched
    on Dec 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:datadomain:serverpriority:p2

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions