Skip to content

Usage store and write path (slice A of #66): Usage Durable Object, POST /ingest/usage #68

Closed

Description

@realRaghavGupta

Why

Part of setkernel-live#66 (the per-seat daily token table) and the v1 tracker setkernel/hq#721. PR #67 did all of #66 in 401 changed lines, one over the 400-line review limit, so it is split in two. Take the code from #67's branch agent/66-setkernel-live-usage-durable-object-with (head 642f2efb) onto current main, keeping only this slice's parts. Each slice leaves main deployable: this site deploys on every merge.

Slice A of 2: storage and ingest. Nothing can read usage yet.

Acceptance criteria

  • src/usage.js (cleanUsage, monthRange, sumByDay, keepFrom, COUNTS) with test/usage.test.mjs
  • The Usage SQLite Durable Object (migration tag v2, new_sqlite_classes), its table and push(), the USAGE binding in wrangler.jsonc; rows older than 400 days deleted
  • POST /ingest/usage checked against INGEST_AUD: body ≤ 256 KiB, seat and surface allowlists, non-negative integers, hour YYYY-MM-DDTHH, otherwise 400/413/403; the response echoes per-day per-seat totals for the hours pushed
  • Worker tests: a 48-bucket push and its echo, replace on re-push, the 400-day delete, the 400/413/403/405 cases, and the privacy check that /api/state, /api/replay and the first /ws frame contain none of the pushed numbers
  • README's ingest section and the AGENTS.md layout line; npm run validate passes; under 400 changed lines
  • The PR body says Closes setkernel/setkernel-live#<this issue> and Refs setkernel/hq#721

Files likely touched

  • src/usage.js
  • src/worker.js
  • wrangler.jsonc
  • test/usage.test.mjs
  • test/worker/usage.test.js
  • README.md
  • AGENTS.md

Risk class

R3: a new private data store and write route on a site that deploys on every merge

— Claude Lead

Activity

  1. added and removed
    agent-readyReady for an agent to pick up
    on Nov 1, 2026
  2. orion-setkernel commented on Nov 1, 2026

    @orion-setkernel
    Contributor

    Picked up. Working on branch agent/68-usage-store-and-write-path-slice-a-of-66. Automated: @orion-setkernel's agent on orion-dev.

  3. added
    agent-reviewWaiting for agent review
    and removed on Nov 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

agent-reviewWaiting for agent review

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions