Skip to content

Fix 8 launch-polish findings before v0.3.0#72

Merged
anilmurty merged 2 commits into
mainfrom
fix/v0.3.0-final-polish
May 29, 2026
Merged

Fix 8 launch-polish findings before v0.3.0#72
anilmurty merged 2 commits into
mainfrom
fix/v0.3.0-final-polish

Conversation

@anilmurty
Copy link
Copy Markdown
Contributor

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

  • §8 /metrics now aggregates by agent_id before emitting (was emitting duplicate label sets per (agent_id, model), violating Prom format)
  • §3 --export-config claude-code writes .jsonc (was .json with // comments → invalid JSON)
  • §4 Export config comment block indents at 6 spaces to align with surrounding object body
  • §5 --compare last-7d / last-30d now overrides --since so analysis window matches comparison period (was 30d-vs-30d on optimize, 7d-vs-7d on cost — same flag, two shapes)
  • §6 tj policy list --json works as command-level flag (was root-flag-only)
  • §7 [capture] row always shown in tj policy list, even when all toggles are off (it's still a policy choice)
  • §2 Friendly error when tj onboard backfill hits the daemon write-lock (was raw DuckDB IO error)
  • §1 Honest divergence note when config-declared plan disagrees with historical session plan-tier mix — surfaces the mismatch without overriding the data-driven rendering

Test results

  • 575 tests green (453 unit/synthetic + 122 agents/integration)
  • Smoke-tested via CLI: --json on policy list, .jsonc filename + indent, last-7d window override, /metrics deduplication confirmed

Test plan

  • pytest tests/unit/ tests/synthetic/ tests/agents/ tests/integration/ passes
  • tj policy list --json returns JSON
  • tj policy list shows the capture row
  • tj optimize --export-config claude-code writes .jsonc with aligned comments
  • tj optimize --compare last-7d uses a 7d analysis window
  • curl /metrics | grep tj_cost_usd_total shows one row per agent_id
  • Smoke-test tj onboard --reconfigure with daemon up to confirm friendly backfill message (deferred to first reviewer pass)

Closes #71.

🤖 Generated with Claude Code

anilmurty and others added 2 commits May 28, 2026 21:04
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>
@anilmurty anilmurty merged commit 3318230 into main May 29, 2026
4 checks passed
@anilmurty anilmurty deleted the fix/v0.3.0-final-polish branch May 29, 2026 04:59
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.

v0.3.x follow-ups surfaced during pre-release playbook

1 participant