Skip to content

分析对比:对不齐的上期时间桶保留原键,会覆盖本期首桶的对比值 #36770

Description

@objectstack-fleet

repo:objectstack#1 · os-warren · session_01JQwxbZeHNsF3RWcWpj7rGj

维护者速读

报表或仪表盘按「和上一期对比」画按周/按月的图时,如果上一期的时间段切出来的格子数和本期不一样,多出来的那一格没有对应位置,却保留了自己的日期键;它可能正好和本期第一格同名,于是悄悄覆盖掉本期第一格本该有的对比值,图上显示的对比数字是错的,而且不报错。
要你做的:无(等分诊定级)。

Defect

packages/services/service-analytics/src/dataset-executor.ts, in the compare pass (the sub.rows.map that renames measures to <measure>__compare):

const aligned = alignedCompareBucketKey(row[dimension], granularity, cmp.kind, range, shifted);
if (aligned != null) out[dimension] = aligned;

When alignedCompareBucketKey returns null (the shifted bucket's target ordinal falls outside the current window), the row keeps its OWN bucket key. If that key equals a bucket of the current window, mergeByDimensions writes the compare column onto that row, overwriting the value the aligned row put there, or appending an extra row outside the window.

Example (by reading, found by the contract review of PR #36767). "This month" in December 2026 on a week axis. previousPeriod is the 31 days ending Nov 30, and its weeks do not map one-to-one onto December's. A shifted bucket whose target falls outside December keeps a key that can collide with 2026-W49, so that week's comparison becomes the single day Nov 30 instead of the aligned week. On a month axis, the unaligned bucket appears as an extra bar outside the window (for example, an extra November bar for "this month" by month).

Reach. Dashboard widgets with compareTo on a time axis can hit it today. The report viewer's comparison switch (#36645, PR #36767) is not offered on the window's own date axis, so it does not reach this.

Fix shape (proposal)

Drop a compare row whose bucket cannot be aligned (aligned == null on a granular time dimension) instead of keeping its own key. Pin it with this month by week and this quarter by month: no compare value lands on a bucket it was not aligned to, and no row is added outside the current window.

Dedupe

#6007, #27111 and #30197 (closed) covered the alignment rule itself. No open issue covers the unaligned fallback.

Activity

  1. added
    bug
    pm:queue
    domain:server
    on Nov 23, 2026
  2. objectstack-fleet commented on Nov 23, 2026

    @objectstack-fleet
    ContributorAuthor

    triage#1 · os-warren · session_01JQwxbZKP5YM48rWMWTS7wE

    Triage: lands in area:data · domain:server · priority:p2 · Bug · pm:queue · size S; area and grade added (the card carried neither); type set to Bug.
    Rationale: a compare-to-previous-period bucket that cannot be aligned keeps its own key and can overwrite the current window's first bucket, so a dashboard shows a wrong comparison with no error. Aggregates and dashboards adding up is area:data core feature ③. Under North Star Priority rule 2 a value computed and shown wrongly (nothing stored is wrong) is Impeded; reach is end users reading compare widgets on a time axis ⇒ p2. Fix and pins stay in service-analytics, as the card proposes.

  3. objectstack-fleet commented on Nov 25, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#7 · os-alice · session_011y7As6JrAPNfuwC2RLXXGu

    Claim: PM loop round 1 (2026-11-25T14:54Z)
    Session: session_011y7As6JrAPNfuwC2RLXXGu
    Account: os-alice
    Branch: claude/issue-36770-compare-unaligned-bucket
    Worktree: objectstack-issue-36770
    Domain: domain:server
    Seat: repo:objectstack#7
    File surface: packages/services/service-analytics/src/dataset-executor.ts, new or existing tests under packages/services/service-analytics/src/__tests__/, one .changeset/*.md (stop on breach; explain in the report)
    Container & model: S, mode:subagent, model: default (dispatch-gates --tier: no path-derived mandate), effort: medium (S card)
    Clause-②: no
    Metadata-protocol: none
    Responsibility: platform code: packages/services/service-analytics (this repo) keeps an unaligned compare bucket's own key | none — no platform path drops it today | end users reading dashboard widgets with compareTo on a time axis; reachable today
    Thread-read: 7110281601
    Premise: holds — on origin/main d88c41e, dataset-executor.ts:1893-1894 still keeps the row's own key when alignedCompareBucketKey returns null (if (aligned != null) out[dimension] = aligned;).
    Serial constraints cleared: PR #37299 (same package, other files) merged; no in-flight claim on dataset-executor.ts.

    Note: trial deviations in force (试行偏离): fresh agent per rework, no in-agent waiting, local runs = affected tests + ratchet families with the rest cited from CI at the same head, dev runs l1-face.mjs before reporting.

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

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#7 · os-alice · session_011y7As6JrAPNfuwC2RLXXGu
    os-dev-report

    {
      "issue": 36770,
      "status": "done",
      "branch": "claude/issue-36770-compare-unaligned-bucket",
      "pr": "https://github.com/objectstack-ai/objectstack/pull/37318",
      "session": "session_011y7As6JrAPNfuwC2RLXXGu",
      "premise_still_valid": true,
      "summary": "Premise measured red on origin/main d88c41e5: with previousPeriod on December 2026 by week, the current 2026-W49 read opp_count__compare 4900 (the previous period's own W49, the single day 30 Nov) instead of the 4400 aligned from W44. 'This month' by month added an out-of-window 2026-11 row, and Q2 2026 by month added a 2026-03 row. Fix in dataset-executor.ts: alignedCompareBucketKey now answers a module-level sentinel NO_CURRENT_COUNTERPART (not re-exported from index.ts) when a real calendar bucket shifts back outside the current window. runCompare drops that compare row; null (empty bucket, raw timestamp, wrong-granularity key) still keeps its key. Fixture triage: two unit pins now expect the sentinel; the alignment file's restated #4870 pin (a fake answering 2026-06 on both passes) pinned the removed fallback and now asserts June reads compare 0; dataset-selection-window's #4870 fake now answers each pass in its own window, with its assertion unchanged.",
      "tests": "Red pin (commit 8c2bcea7, fix not applied): vitest run dataset-compare-bucket-alignment.test.ts -t 'no counterpart' -> 'Tests 3 failed | 1 passed'; week diff '- opp_count__compare: 4400 / + 4900'; month and quarter diffs '+ close_date: 2026-11' / '+ close_date: 2026-03'. At head bc2fbbea: pnpm --filter @objectstack/service-analytics test -> exit 0, 'Test Files 227 passed (227) · Tests 5901 passed | 345 skipped (6246)'; typecheck (tsc --noEmit) -> exit 0, and --listFiles confirms the test file is compiled (1 hit). The red-first run on the unfixed tree serves as the reverse verification. The tests import ../dataset-executor.js from src, so no dist ablation was needed.",
      "gates": "Local, at head bc2fbbea: dependency closure build (os-verify-lock VERDICT command-exit 0, waited 0s). dispatch-gates --repo objectstack-ai/objectstack --commands derived 65 families; 61 exited 0. NOT MEASURED: check:dual-build-cjs-loads exit 3 (needs full pnpm build); check-plugin-teardown-shape --self-test exit 3 (shallow clone prerequisite); check:query-options-erasure and check:type-check-debt each hit the 300s per-command timeout (exit 124). All four are cited to CI. --ran reconciliation: '65 derived famil(ies) accounted for — 61 run, 4 NOT-MEASURED', exit 0. CI at bc2fbbea per l1-face/pr-state: 37 success · 16 expected skip · 0 failed · 0 pending; Lint & Repo Gates: success; TypeScript Type Check: success. l1-face --pr 37318: exit 0, 'l1-face CLEAN — 13 item(s) read, none flagged' (pr-state marked mergeable_state unknown after 1 read).",
      "dogfood_battery": "n/a — no `!` in the PR title and no (narrowing) arm",
      "mcp_calls": "0",
      "api_writes": "2 — fleet relay pr_create (objectstack-ai/objectstack#37318, read-back 4396/4396 bytes identical); fleet relay issue comment on #36770 (this report via post-stamped). Plus 3 git pushes (empty-branch probe, red pin, fix), which are not REST.",
      "deviations": "Trial rules in force: no in-session CI/lock waits (lock acquired first try, waited 0s); local runs limited to package tests, package typecheck and the derived --commands families, with the rest cited to CI; l1-face run before reporting. scripts/pm source not read; pr_create keys learned from dry-run refusals because --help does not list them. The first gh pr view attempt hit a GraphQL 403, so REST was used. Two derived families were cut off by my own 300s per-command timeout, not by a gate verdict.",
      "open_questions": [],
      "security_findings": "none",
      "out_of_scope_findings": []
    }

    Generated by Claude Code

  6. objectstack-fleet commented on Nov 25, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#7 · os-alice · session_011y7As6JrAPNfuwC2RLXXGu

    Closed by PR #37318 (merged, read 2026-11-25T16:57Z). Clearing pm:dispatched.

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

Metadata

Metadata

Assignees

Labels

area:databugdomain:serverpriority:p2

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions