Skip to content

Usage push replaces every stored bucket of each hour it sends, so a seat move in .seats leaves no stale bucket (slice 2 of hq#1108) - #93

Merged
realRaghavGupta merged 1 commit into
mainfrom
agent/92-usage-push-replaces-every-stored-bucket
Nov 4, 2026
Merged

realRaghavGupta merged 1 commit into
mainfrom
agent/92-usage-push-replaces-every-stored-bucket

Conversation

@orion-setkernel

Copy link
Copy Markdown
Contributor

Summary

Usage.push only did INSERT OR REPLACE per (hour, seat, model, surface), so an hour first pushed as seat other and later as polaris kept both, and the echo and the usage page counted it twice. A push now replaces whole hours.

What changed

  • src/worker.js: push deletes every stored bucket of each distinct hour in the push, in the same transactionSync and before the inserts. Hours not named are untouched. The hours JSON is built once and reused for the echo. Comments above Usage and push say a push replaces whole hours.
  • test/worker/usage.test.js: new test pushes an hour as other, then as polaris; only polaris is stored, the echo counts it once, and another hour not in the push survives. The existing "replaces a bucket pushed again…" test is unchanged and passes.

Tested

  • npm run check: pass
  • npm test: 250 pass, 0 fail
  • npm run test:worker: 52 pass (3 files)
  • wrangler deploy --dry-run: not run (command denied in this session)

For the reviewer

R3 (src/**, deletes stored rows). Existing stale rows (2026-11-01T14/15/16/22) are only cleaned when those hours are re-pushed; Lead's backfill rerun after deploy does that and is the issue's last criterion.

Checks (setkernel:verify, read by the worker)

  • pass: npm run check
  • pass: npm test - 250 pass, 0 fail
  • pass: npm run test:worker - 52 tests pass
  • not run: wrangler deploy --dry-run - command denied in this session

Closes #92

Automated: @orion-setkernel's agent on orion-dev.

…92)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@orion-setkernel

Copy link
Copy Markdown
Contributor Author

Reviewer: no blockers.

Automated: @orion-setkernel's agent on orion-dev.

@orion-setkernel

Copy link
Copy Markdown
Contributor Author

Test-diff guard: this PR changes existing test files, and the issue it closes has no allow-test-changes: line the guard takes yet (it takes one only when Raghav's account or Claude Lead's bot saved the issue body last):

  • modified test/worker/usage.test.js

Claude Lead: if these test changes are right, add the line to the issue with the reason, then re-run the guard job; if not, ask for the tests to be restored. That is the only thing this PR waits on from you: peer review goes on meanwhile, and the failing guard stops the merge until the line is in.

Automated: @orion-setkernel's agent on orion-dev.

@orion-setkernel orion-setkernel added the agent-review Waiting for agent review label Nov 4, 2026

@lyra-setkernel lyra-setkernel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A push now deletes every stored bucket of each distinct hour it names inside the same transactionSync before inserting, which fixes the stale other/polaris double count; the new worker test covers it and npm run check and npm run test:worker (52) pass here.

Notes and nits (they block nothing)

  • README.md:226: The Usage section still says "A bucket pushed again replaces the stored one"; the behaviour is now that a push replaces whole hours (all seats, models, surfaces of each hour named).
  • src/worker.js:202: Replace-whole-hours means a pusher that splits one hour across several POSTs (e.g. to stay under the 256 KiB body cap) would have each later request delete the earlier chunks' buckets. Worth stating in the README contract that every bucket of an hour must go in one push.

Automated: @lyra-setkernel's agent on lyra-dev.

@lyra-setkernel

Copy link
Copy Markdown
Contributor

Approvals that count toward the two a merge needs: 1 (lyra-setkernel) on head 94da921, non-author, submitted after its push at 2026-11-04T19:01:51Z (the earliest check run's start). A second teammate is asked to review: vega-setkernel.

Automated: @lyra-setkernel's agent on lyra-dev.

@vega-setkernel vega-setkernel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meets the first three criteria: push deletes every stored bucket of each distinct pushed hour inside the same transactionSync, before the inserts, then re-inserts; unnamed hours are untouched; the new test and comments match. The last criterion (Lead's backfill rerun printing match) is post-deploy and not checkable here. As R3, it still needs Raghav's /approve .

Notes and nits (they block nothing)

  • src/worker.js:205: The whole-hour delete is only safe if every push carries all buckets of each hour it names; a pusher that split one hour across two requests would erase the first part. The issue says usage.py sends whole hours, but that script is in setkernel/hq, so I did not check it.
  • test/worker/usage.test.js:107: The test file gained one new test and no existing test was edited, so there is no test-edit to list for an allow-test-changes line.

Automated: @vega-setkernel's agent on vega-dev.

@vega-setkernel vega-setkernel removed the agent-review Waiting for agent review label Nov 4, 2026
@vega-setkernel

Copy link
Copy Markdown
Contributor

Approvals that count toward the two a merge needs: 2 (lyra-setkernel vega-setkernel) on head 94da921, non-author, submitted after its push at 2026-11-04T19:01:51Z (the earliest check run's start). The agent review is done; the merge gate takes it from here.

Automated: @vega-setkernel's agent on vega-dev.

@realRaghavGupta
realRaghavGupta merged commit 22a4221 into main Nov 4, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Usage push replaces every stored bucket of each hour it sends, so a seat move in .seats leaves no stale bucket (slice 2 of hq#1108)

4 participants