Fix 8 launch-polish findings before v0.3.0#72
Merged
Conversation
Closes findings #1-8 logged on issue #71 during manual pre-release testing. §8 metrics: aggregate cost / tokens by agent_id before emitting Prometheus rows. The previous implementation emitted one row per (agent_id, model) which produced duplicate label sets and violated the Prom text format (a scraper would warn or reject). Affects /metrics endpoint. §3 + §4 export-config: file extension now `.jsonc` (matching the actual content, which contains // line comments) and the comment block indents at 6 spaces to align with the surrounding `routing_recommendations` object body. Files in ~/.config/tokenjam/exports/ can now be parsed by strict JSONC tooling. §5 compare semantics: `--compare last-7d` and `last-30d` now override `--since` so the analysis window matches the comparison period. Previously `tj optimize --compare last-7d` did 30d-vs-30d (because --since defaults to 30d) while `tj cost` did 7d-vs-7d — same flag, two shapes. New helper `override_since_for_compare()` is shared by both commands. §6 policy: `tj policy list` now accepts a command-level `--json` flag in addition to the root `tj --json policy list` form. §7 policy: capture row always emitted, even when all four toggles are off. An explicit "off" is still a policy choice worth surfacing. §2 backfill: friendlier error when daemon holds the DB write lock during `tj onboard --reconfigure` backfill. Raw IO error replaced with stop-and- retry instructions. §1 subscription rendering: when the user has reconfigured to a new plan but historical sessions reflect the previous plan, surface a divergence note explaining what's shown. Honest-output discipline preserved — the data is still rendered as it actually was generated; the note explains the gap rather than overwriting reality. Co-Authored-By: Claude Opus 4.7 (1M context) <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.
Summary
Patches the 8 findings logged on #71 during the v0.3.0 pre-release manual playbook. None were crashes or data-loss footguns — they were polish + documented-integration breakage that would have shown up in any new user's first hour. Fixing now keeps the v0.3.0 release clean.
Findings fixed
/metricsnow aggregates byagent_idbefore emitting (was emitting duplicate label sets per (agent_id, model), violating Prom format)--export-config claude-codewrites.jsonc(was.jsonwith//comments → invalid JSON)--compare last-7d/last-30dnow overrides--sinceso analysis window matches comparison period (was 30d-vs-30d on optimize, 7d-vs-7d on cost — same flag, two shapes)tj policy list --jsonworks as command-level flag (was root-flag-only)[capture]row always shown intj policy list, even when all toggles are off (it's still a policy choice)tj onboardbackfill hits the daemon write-lock (was raw DuckDB IO error)Test results
--jsonon policy list,.jsoncfilename + indent,last-7dwindow override,/metricsdeduplication confirmedTest plan
pytest tests/unit/ tests/synthetic/ tests/agents/ tests/integration/passestj policy list --jsonreturns JSONtj policy listshows the capture rowtj optimize --export-config claude-codewrites.jsoncwith aligned commentstj optimize --compare last-7duses a 7d analysis windowcurl /metrics | grep tj_cost_usd_totalshows one row per agent_idtj onboard --reconfigurewith daemon up to confirm friendly backfill message (deferred to first reviewer pass)Closes #71.
🤖 Generated with Claude Code