feat(claude-team): keep a seat's overage reading per day, not per month - #2714
Merged
Conversation
The seat endpoint reports a running month-to-date total and no history, so one API object is one reading of a seat. Bronze keyed a reading by seat and extraction month over a ReplacingMergeTree, so every read inside a month was the same row and the newest replaced the rest: a month's closing figure survived and the trajectory that produced it did not. #2528 made the same move from seat-only to seat-and-month, for the same reason, and stopped one level short. Key a reading by the day it was taken and carry that day in the record as snapshot_date, matching the two ChatGPT Team snapshot streams — the only other streams in the repository whose key comes from the clock rather than the payload, and both already keyed by day. A re-run on the same day still replaces its own row rather than adding a second. `class_ai_overage_daily` carries the readings into silver beside the existing class_ai_overage, which is untouched: it holds a month's closing state, a data-quality check joins on it and the invoice-to-seat price join needs one row per seat per month. MINOR per ADR-0015, for the reason 2.1.0 was: existing rows keep their keys, nothing re-materializes, and a major bump would dispatch the one-shot `dbt --full-refresh` that this change exists to give something to rebuild from. Refs #2709 Signed-off-by: Gregory Gogin <grigoriy.gogin@constructor.tech>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
The committed snapshot under scripts/connectors-ddl is what a fresh warehouse is built from, and CI re-dumps it to fail on drift. class_ai_overage_daily creates a silver table, so the snapshot gains its DDL — taken from the dump the gate produced rather than reconstructed by hand. Refs #2709 Signed-off-by: Gregory Gogin <grigoriy.gogin@constructor.tech>
…readings Signed-off-by: Gregory Gogin <grigoriy.gogin@constructor.tech> # Conflicts: # src/ingestion/connectors/ai/claude-team/descriptor.yaml
Gregory91G
enabled auto-merge
August 21, 2026 07:49
hello1101n
approved these changes
Aug 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #2709.
Why. The seat endpoint reports a running month-to-date total and keeps no history, so one API object is one reading of a seat. Bronze keyed a reading by seat and extraction month over a ReplacingMergeTree, so every read inside a month was the same row and the newest replaced the rest: a month's closing figure survived, the trajectory that produced it did not. #2528 made this exact move from seat-only to seat-and-month, and stopped one level short.
What changed. The bronze key carries the read day, the record carries it as
snapshot_date, and a newclass_ai_overage_dailycarries the readings into silver.class_ai_overageis untouched. It holds a month's closing state, a data-quality check joins on it, and the invoice-to-seat price join needs one row per seat per month. The daily relation sits beside it rather than replacing it, and takes only the columns a trajectory needs — it is not a copy of the monthly model.MINOR, deliberately not MAJOR. Existing rows keep their keys and nothing re-materializes. A major bump dispatches the one-shot
dbt --full-refreshthat this change exists to give something to rebuild from — the same reasoning recorded for 2.1.0.A mirror this missed.
snapshot_datereached the connector schema and the bronze DDL but notsrc/ingestion/tests/e2e/metrics/schemas/bronze_claude_team.claude_team_overage_spend.yaml, the hand-maintained fixture mirror that carriesadditionalProperties: false. The gap stays latent until a fixture first sets the field, which is why this PR was green and #2715 was the one that failed on it. Fixed there.Deploy (void)
Do not run the sequence below. Its only window was the first build of
claude_team__ai_overage_daily, which has already happened, so there is nothing left for it to preserve. Kept because the model'sINVARIANT:comments refer to the reasoning.A ReplacingMergeTree collapses on merge, not on insert, so readings already replaced logically may still sit in unmerged parts. The first build of
claude_team__ai_overage_dailyis the one chance to keep them: it reads bronze withoutFINALand dedups per day rather than per bronze key, then never rebuilds. That rescues a tail of recent days, never a history, and how much depends only on what has not merged by then.Both properties are recorded as
INVARIANT:in the model — a later reader would reasonably take the missingFINALfor an oversight.Out of scope. Nothing reads the new relation yet. The metric that distributes the billed cost across days is #2709's other half and needs the e2e cases the metric-coverage gate requires, so it follows separately.
Verified.
dbt parseclean.audit_rmt_read_dedup.pyreports no new gap for either model. Connector, descriptor and silver schema parse as YAML. Not run: dbt cannot execute here, so the models are unbuilt and the window functions in the follow-up are unexercised — this PR adds none.