Repository navigation
Pre-release fixes for v0.4.0: cache shim + downsize CLI empty-state - #153
Merged
anilmurty merged 1 commit intoJun 19, 2026
Merged
Conversation
Two bugs surfaced by the v0.4.0 pre-release test pass against an install with the daemon running, plus the testing-infra MD files that caught them. ## Bugs fixed **`tj cost` cache columns silently 0 with daemon up.** PR #149 added `cache_tokens` + `cache_write_tokens` to the DB row, API response, and CLI rendering — but missed the `ApiBackend` shim that the CLI uses when `tj serve` is running. The shim dropped the cache fields on the floor, so they defaulted to 0 even though the JSON response carried the real values. Two-line addition to mirror the wider contract. **`tj optimize` silently skips the Downsize section when no candidates exist.** The Optimize web tab fixed this in PR #130 (issue #126) by rendering an explicit "no candidates" state. The CLI render path was overlooked. When other analyzers find content (cache, script, trim, …), the catch-all "No candidates flagged" message doesn't fire either, so Downsize disappears without explanation — reviewers think the analyzer didn't run. Now mirrors the UI: explicit "Downsize: no candidates in this window — sessions don't match the smaller-model shape" empty state. Guarded by the positional `findings` filter so `tj optimize cache` (asking for just cache) doesn't add Downsize noise. ## Testing infrastructure (new) - `tests/manual-pre-release-runner.md` — generic instructions for a sub-agent: find the release-specific checklist, walk each step, capture output, write a structured log to `tests/results/`. - `tests/manual-pre-release-v0.4.0.md` — focused 12-step checklist for the v0.4.0 release. Each step has the structured shape the runner expects (Setup / Test / Expected / Assertions). - `.gitignore`: `tests/results/` — per-run logs are local artifacts, not committed. ## Verification - `pytest tests/unit/ tests/integration/`: 659 passed. - Live with daemon: `tj cost --since 30d --group-by model` now shows `CACHE R 698.8M`, `1530.9M`, etc. instead of `0`. - Live with daemon: `tj optimize --since 30d` prints "① Downsize: no candidates in this window …" when downsize finds nothing. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
anilmurty
deleted the
fix/prerelease-bugs-cache-shim-and-downsize-empty-state
branch
June 19, 2026 20:50
Merged
HoomanDgtl
pushed a commit
to HoomanDigital/tokenjam
that referenced
this pull request
Jun 20, 2026
TokenJam v0.4.0 — major release. Significant new product surface beyond the 0.3.x patch cadence: - TokenJam Lens UI rebrand: Overview triage front door, Optimize detail tab, real charts (uPlot, vendored offline), URL-state filters, plan-tier-aware framing on all dollar-bearing surfaces. - Reuse — the 5th analyzer + `tj report --reuse` artifact export (HTML + Markdown skeleton sidecars). - New `core/framing.py` — single source of truth for plan-tier rendering, consumed by both CLI and REST API. - `estimated_recoverable_usd` contract on every savings analyzer (Metabuilder-Labs#111), normalized to a single time basis (Metabuilder-Labs#122) so Overview tiles are directly comparable. - `cache_write_tokens` surfaced through DB → API → CLI → UI (Metabuilder-Labs#149) — fixed the ~91% hidden cost driver on cache-heavy workloads. - Security: `.tj/config.toml` untracked (Metabuilder-Labs#145) + CI guard (`tests/unit/test_no_tracked_dev_secrets.py`). - 17 v0.3.5 post-release findings closed (Metabuilder-Labs#141) + 5 Lens UI bug rounds (Metabuilder-Labs#126-Metabuilder-Labs#136) + onboard `--plan` honored on plain path (Metabuilder-Labs#148). ## Also in this commit **Step 6 in the pre-release checklist** is corrected to match real behavior: `tj report --reuse` with the daemon running exits with the "needs direct database access" hint (workaround: `tj stop`). Long-term fix tracked as Metabuilder-Labs#154 for v0.4.1. **Test outputs committed.** `tests/results/` was gitignored; flipping it so per-release pre-release test logs ship as part of the repo for historical reference. Two v0.4.0 result logs included: the first pass (which surfaced two bugs fixed in PR Metabuilder-Labs#153) and the clean re-run after those fixes landed. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
HoomanDgtl
pushed a commit
to HoomanDigital/tokenjam
that referenced
this pull request
Jun 20, 2026
TokenJam v0.4.1 — concurrency + cycle-aware run-rate + Reuse HTTP fallback + quality follow-ups across the Lens UI. ## What's in 0.4.1 Six issues closed, all branched off main as separate PRs that landed cleanly: | Issue | PR | What | |---|---|---| | Metabuilder-Labs#138 | Metabuilder-Labs#158 | Run-rate honors `[budget.<provider>] cycle_start_day` (per-tier `cycle_bounds` extracted into `core/cycle.py`, shared with `budget_projection`) | | Metabuilder-Labs#124 | Metabuilder-Labs#161 | Daemon DB concurrency: `DuckDBBackend.conn` is now a per-thread DuckDB cursor (`threading.local`) over one shared database. Cursors are independent connections safe for concurrent use, so the Overview fan-out + sync read routes in Starlette's threadpool no longer crash under load. | | Metabuilder-Labs#139 | Metabuilder-Labs#163 | `buildCostSeries` coarsens up an `hour → day → week` ladder instead of silently emptying long windows (closed-form bucket count, never allocates an oversized array). Same PR reverts the Overview's sequential-fetch workaround to `Promise.all` with deliberately-asymmetric error handling (`/cost` no-catch; the other five panels carry per-call fallbacks). | | Metabuilder-Labs#147 | Metabuilder-Labs#164 | `tj status` shows active (compute) time alongside wall-clock elapsed (`session_active_seconds` = Σ span durations). Both CLI and Lens Status tile rendered, plus `--json` carries both fields. `fmtDurLong` reads multi-day spans as `2d 3h` instead of `3087m`. | | Metabuilder-Labs#154 | Metabuilder-Labs#165 | New `GET /api/v1/reuse/clusters` endpoint + `ApiBackend.fetch_reuse_clusters` lets `tj report --reuse` work when the daemon holds the DB lock. Dedicated endpoint (not bolted onto `/optimize`) so per-cluster planning text isn't paid for on every 30s Overview poll. | | Metabuilder-Labs#162 | Metabuilder-Labs#166 | Recoverable Waste tile consistency: title-cased fallback for unknown analyzer names (`reuse` now renders as `Reuse`), em-dash dropped from the not-ready content line, regression guard locks all three states so the bold-title issue can't recur. | ## Pre-release verification Walked the focused 10-step v0.4.1 checklist via a sub-agent (`tests/agent-pre-release-v0.4.1.md`). Result: **10/10 PASS, 0 FAIL, 0 UNCLEAR**. Full log committed at `tests/results/agent-pre-release-v0.4.1-20260620T002546Z.md`. Validated end-to-end against the live daemon: - 90 concurrent reads against the Overview endpoint set: no SIGABRT, no 500s (was the Metabuilder-Labs#124 reproduction) - `tj cost` cache columns show non-zero values with daemon up (was 0 pre-Metabuilder-Labs#153) - `/api/v1/cost` returns a `cycle` block; UI consumes it - `tj status` shows `active 12m 3s · elapsed 2d 3h`; JSON carries both fields - `tj report --reuse` writes HTML + Markdown with the daemon running (was the Metabuilder-Labs#154 error) - Recoverable Waste tile titles render uniformly and "Reuse" is title-cased ## What's in this commit - `pyproject.toml`: `version = "0.4.1"` - `sdk-ts/package.json`: `"version": "0.4.1"` - `tests/agent-pre-release-v0.4.1.md`: the focused 10-step checklist used to validate this release - `tests/results/agent-pre-release-v0.4.1-20260620T002546Z.md`: the agent-run log proving 10/10 PASS Tests: 689 pass locally; mypy + ruff clean. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
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.
Two bugs surfaced by the v0.4.0 pre-release test pass against an install with the daemon running, plus the testing-infra MD files that caught them.
Bugs fixed
1. `tj cost` cache columns silently 0 with daemon up
PR #149 added `cache_tokens` + `cache_write_tokens` to the DB row, API response, and CLI rendering — but missed the `ApiBackend` shim that the CLI uses when `tj serve` is running. The shim dropped the cache fields on the floor, so they defaulted to 0 even though the JSON response carried the real values.
Before (with daemon running):
After:
Cost-transparency contract from #149 is now intact across both the direct-DB and daemon-up modes.
2. `tj optimize` silently skips the Downsize section when no candidates exist
The Optimize web tab fixed this in PR #130 (issue #126) by rendering an explicit "no candidates" state. The CLI render path was overlooked. When other analyzers find content (cache, script, trim, …), the catch-all "No candidates flagged" message doesn't fire either, so Downsize disappears without explanation — reviewers think the analyzer didn't run.
The CLI now mirrors the UI: explicit `① Downsize: no candidates in this window — sessions don't match the smaller-model shape (small input/output, few tool calls).` empty state. Guarded by the positional `findings` filter so `tj optimize cache` (asking for just cache) doesn't add Downsize noise.
Testing infrastructure (new)
Verification
What's NOT in this PR (filed as deferred)
🤖 Generated with Claude Code