Skip to content

fix(service-analytics): drop a compareTo bucket with no current-window counterpart - #37318

Merged
objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/issue-36770-compare-unaligned-bucket
Nov 25, 2026
Merged

objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/issue-36770-compare-unaligned-bucket

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Alice · project thread
Fixes #36770
Clause-②: no
Metadata-protocol: none

维护者速读

仪表盘组件按周、按月画趋势并开启「和上一期对比」时,对比值不再错落到本期某一格上,也不再多出一根本期范围外的柱子(例如「本月按月」多出的十一月)。
为什么做:上一期比本期多切出一格时,那一格没有对应位置却保留了自己的日期,悄悄覆盖了本期第一周的对比数字,用户看到的对比是错的。
出错会怎样:只影响对比列;若判断有误,最坏是某一格的对比值显示为 0,可直接撤回本次改动恢复原样。
要你做的:无。

What changes

packages/services/service-analytics/src/dataset-executor.ts, compare pass of runCompare:

  • alignedCompareBucketKey now distinguishes its two "declined" answers. null still means "not a calendar position, leave the key alone" (the empty bucket, a raw timestamp, a key of another granularity). A key that IS a bucket of this granularity but whose shifted-back ordinal falls outside the current window now answers the new module-level sentinel NO_CURRENT_COUNTERPART.
  • The caller drops a compare row that answers NO_CURRENT_COUNTERPART instead of keeping its own key. Before, that own key either named a current bucket the value was never aligned to (December 2026 by week: the previous period's own 2026-W49, the single day 30 Nov, overwrote the comparison that 2026-W44 had aligned onto the current 2026-W49) or appended a row outside the window (an extra 2026-11 row on "this month" by month, an extra 2026-03 row on Q2 2026 by month).
  • NO_CURRENT_COUNTERPART is not re-exported from src/index.ts; the package's public surface is byte-unchanged (the dataset-compare-kind-refusal barrel pin stays green).

Tests

New top-level describe in src/__tests__/dataset-compare-bucket-alignment.test.ts (the shared harness for this behaviour):

  • this month by week, December 2026 (scripted fake, week keys validated against core's bucketKeyToCalendarRange): W49..W53 carry W44..W48's values, W49 is not overwritten.
  • this month by month, December 2026 (real-bucketing fake): one row, no November row.
  • this quarter by month, Q2 2026: three rows, no 2026-03 row.
  • control: the empty (null) bucket still merges with its counterpart.

Red first on origin/main d88c41e (pin commit 8c2bcea, fix not yet applied): 3 failed / 1 passed. W49 read opp_count__compare: 4900 where 4400 was expected; the month and quarter cases each carried an extra out-of-window row (2026-11, 2026-03).

Fixture triage (three pins encoded the removed fallback):

  • dataset-compare-bucket-alignment.test.ts unit pins: the outside-window cases now expect NO_CURRENT_COUNTERPART instead of null.
  • The same file's restated "fix(service-analytics): compareTo 带上 measure 自己的 filter,__compare 列不再是另一个 measure (#4820) #4870 pin" (a fake answering 2026-06 on both passes) pinned exactly the removed branch. Replaced by the collision in its smallest form: that key has no counterpart and June reads opp_count__compare: 0.
  • dataset-selection-window.test.ts "buckets the compareTo pass identically": its fake now answers each pass in the window it filtered to (June, then May). What it pins (both passes resolve the same GROUP BY granularity) is unchanged, and so is its assertion.

Acceptance notes

  • The ordinal rule itself (previousPeriod aligns the n-th bucket onto the n-th) is unchanged. On December by month this still means the previous period's single day 31 Oct is the comparison for December; that is the ruled semantic, not this card.

Verification

Local runs at the final head

See the os-dev report comment on #36770 for the head SHA, test counts and gate verdicts.

Two-minute check: pnpm --filter @objectstack/service-analytics exec vitest run --maxWorkers=2 src/__tests__/dataset-compare-bucket-alignment.test.ts -t "no counterpart": 4 passed.

Read first: dataset-executor.ts the runCompare row loop (the drop), then alignedCompareBucketKey's outside-window return.

🤖 Generated with Claude Code

https://claude.ai/code/session_011y7As6JrAPNfuwC2RLXXGu

@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 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

3 anchor(s) derived from 1 changed package(s); no hand-written page names any of them, so this run has nothing to list — not a clean bill of health. This check sees only pages that NAME a derived anchor: one that documents this change in prose, or enumerates it in an authoring dialect, names none and stays invisible to it on every run.

What this run could not see
  • the SDK route bridge reached 69 of 252 client-bound route-ledger rows — the other 183 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 183: 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; 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 d88c41e51d60224c286267657a2c328ce158eab1 → packageMentionDocs.

Which tree this was computed on

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

node scripts/docs-audit/affected-docs.mjs --json d88c41e51d60224c286267657a2c328ce158eab1

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

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · os-alice · session_011y7As6JrAPNfuwC2RLXXGu

  • 改了什么:「和上一期对比」时,上一期多出来、在本期找不到对应格子的时间桶现在直接丢弃,不再覆盖本期第一格的对比值,也不再在窗口外多出一根柱子。
  • 风险:只影响分析对比列的合并;空桶(null)照旧合并。可整体撤回。
  • 要你做什么:无(非受管面,座位落地)。
  • 跟进:无。

席位意见:ACCEPT,排队落地。

席位核对 — ACCEPT · head bc2fbbe (2026-11-25T15:50Z)

  1. Shape: 4 files, +220 / -35, inside the claimed surface (dataset-executor.ts, two test files under src/__tests__/, one patch changeset). Fixes #36770 delivers the whole card: the card's proposed fix shape (drop an unalignable compare row) with both named pins (this month by week, this quarter by month) plus this month by month. Not governed (check-governed-merges --pr 37318), under 3000 lines, no narrowing arm, no !. NO_CURRENT_COUNTERPART is a module export of dataset-executor.ts only; src/index.ts re-exports named symbols and does not list it, so the package's public surface is unchanged and Clause-②: no holds.
  2. Premise measured: red first on the unfixed tree (commit 8c2bcea): Tests 3 failed | 1 passed; December by week read opp_count__compare 4900 (previous period's own W49) instead of 4400; month and quarter grids grew an out-of-window 2026-11 / 2026-03 row. Green at head; the null-bucket control proves only calendar buckets are dropped.
  3. Gates: at this head 37 success, 16 expected skip, 0 failed, 0 pending (l1-face --pr 37318 CLEAN, 13 items). Package tests 227 files / 5901 passed, typecheck exit 0 (report). 4 families NOT MEASURED locally are covered by CI at this head. landing-k: K = 1 < 15.
  4. Accepted deviations: 试行偏离 — no in-agent CI or lock wait, local gates limited to package tests, typecheck and derived families. Two existing pins changed, read and accepted: the restated fix(service-analytics): compareTo 带上 measure 自己的 filter,__compare 列不再是另一个 measure (#4820) #4870 pin in dataset-compare-bucket-alignment.test.ts pinned the removed fallback (a key with no counterpart merged under its own key) and now asserts that collision does not happen; the dataset-selection-window.test.ts fake now answers each pass in the window it filtered to, with its assertion unchanged. The dev's report comment failed on a relay HTTP 500 and was reposted by the seat (comment 7167323350).
  5. Out of scope: none filed; dev reported no findings. Skills-docs: not owed. Changeset read sentence by sentence against the diff and pins: correct (six previous weeks against five; four previous months against three; null bucket unchanged).
  6. Landing: ordinary queue landing by the seat via label-write --land; the card closes on merge.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 25, 2026 16:09
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 25, 2026
Merged via the queue into main with commit ae97480 Nov 25, 2026
53 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-36770-compare-unaligned-bucket branch November 25, 2026 16:57
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.

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

2 participants