Repository navigation
Record what each autonomous run consumes, privately - #9
Merged
Merged
Conversation
One JSON record per run into a private ledger repository. The public repository keeps no usage data, because its Actions logs and artifacts are public with it. Unknown usage is written as null and marked, so the rollup can exclude it rather than reporting a run that appeared to cost nothing. The step never fails a run: a loop that stops over bookkeeping is worse than a gap in the bookkeeping. Refs #8 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Closes #8
Achieved outcome
Each author and acceptor run now writes one JSON record of its own consumption into
the private repository
drevendev/zen-telemetry. The public repository stores nousage data at all.
Changed artifacts
scripts/record_usage.pyscripts/tests/test_record_usage.py.github/workflows/zendev-author.ymlid: claudeon the action step, plus a recording step that always runs.github/workflows/zendev-acceptor.ymlThe ledger repository was created separately and already holds its README, the rollup
script, and a daily workflow that aggregates records into
summaries/and a monthlyIssue.
Acceptance criteria
if: always()nulland markedusage_source: unavailable, never zeroChecks
python -m unittest discover -s scripts/testspassedpassedbuild-and-test,policy-guardnot_runNot checked
The whole path. No model run has happened yet, so the shape of the execution file is
taken from the action source, not observed. If the extraction is wrong, the first
armed run will record
usage_source: unavailablerather than silently reportingplausible-looking numbers — that is the failure mode this was designed for.
Assumptions and unknowns
execution_fileto a JSON array of messages, andthe formatter in its source reads
usage.input_tokens,usage.cache_creation_input_tokens,usage.cache_read_input_tokensandusage.output_tokens.resultmessage carries cumulative usage. If it does not,the summed fallback covers it, and
usage_sourcesays which was used.total_cost_usdis populated at all under subscriptionauthentication. If absent it is recorded as null and excluded from totals.
Highest-risk area for review
The cross-repository token. A write token for another repository now exists in the
environment of a public repository. It is scoped to one private repository that holds
no product;
policy-guardrefuses to let a workflow change ride along inside aproduct diff; and the acceptor may not merge workflow changes that widen authority.
Review whether that is a trade you want before merging.
Remaining gate
Requires the secret
TELEMETRY_PAT(fine-grained, onlydrevendev/zen-telemetry,Contents read and write). Until it exists the step warns and records nothing, which is
the intended degraded behavior rather than a failure.
🤖 Generated with Claude Code