Repository navigation
docs: tj optimize coverage — README + manual test runbooks - #63
Merged
Merged
Conversation
…dex/CC sections - pre-release: add step 9b walking through the empty-DB short-circuit, backfill idempotency, the analyzer renderer, and JSON caveat enforcement. - release: add step 11 with a focused smoke check for the new commands and point the Codex + Claude Code integration blocks at the pre-release file instead of duplicating ~50 lines of multi-project / cross-sync coverage (these are exercised before release; re-doing them after release adds noise without catching new bugs). Net: +17 lines from new coverage, –24 from removed duplication; coverage of the new feature is now present in both docs at the appropriate depth. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
- New top-of-page block leads with the killer 3-line UX: install, onboard --claude-code (auto-backfills history), tj optimize. Shows a realistic terminal example with both analyzers — model-downgrade candidates carrying the mandatory caveat line, and a budget projection with exhaustion date. - Quick-start section now references `tj optimize` after `tj onboard --claude-code` so the demo path is visible. - New "tj optimize — what you actually get" subsection under Claude Code with the two analyzer descriptions, scoping flags, and a note that it works alongside a running tj serve via a read-only fallback. - CLI list grew by tj optimize and tj backfill claude-code. - Comparison table gained "Model-downgrade cost recommendations" row. - MCP tool count corrected (13 -> 14) and get_optimize_report added to the tools table at the top, with a description that mentions both phrasings the tool fires on (cost-saving / budget). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
The previous example used invented numbers and a different format from what the renderer actually produces (wrong decimal precision, missing lines, slightly different wording). Replaced with output captured directly from _render_report against a seeded DB so what's on the page is exactly what users see at the terminal. Also splits the showcase: one block for the natural `tj optimize` run (under-budget projection), one for the over-budget renderer triggered by `--budget-usd 50`. Both are real outputs of the shipping code. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Five real screenshots embedded in a 2x2 + 1 grid right after the Web UI section: Status, Traces, Cost, Alerts, Budget. Captured from a populated local instance so the data shown is recognizable (claude-code-<project> agents, real costs, real alerts) rather than placeholder. Total ~800KB added under docs/screenshots/. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
This was referenced Jul 2, 2026
anilmurty
added a commit
that referenced
this pull request
Jul 3, 2026
fix(#63): make `tj context` render while `tj serve` is running
anilmurty
pushed a commit
to tarun73/tokenjam
that referenced
this pull request
Jul 3, 2026
…s running `tj context` is the launch-hero command (issue Metabuilder-Labs#4 wedge), but the composition diagnostic reads the raw `attributes` column for recurring-inclusion detection — data the API shim never exposed. So whenever `tj serve` held the DuckDB write lock, the CLI fell back to `ApiBackend` (no `.conn`) and refused to run, telling users to stop the daemon on the exact command the launch drives them to. DuckDB permits only one writer OR many readers across processes (a concurrent read-only conn alongside the serve write-lock raises an IOException), so a client-side read-only workaround isn't available. Route the compute through the daemon instead — which already owns the direct connection — mirroring `/api/v1/reuse/clusters` (Metabuilder-Labs#154) and `/api/v1/optimize` (Metabuilder-Labs#68): * new `GET /api/v1/context` endpoint computes the diagnostic server-side (incl. recurring inclusions from raw `attributes`) plus a plan-tier `framing` block, exactly as the CLI's direct-conn path does * new `diagnostic_from_dict` inverse of `diagnostic_to_dict` so the CLI reconstructs the dataclass and renders identically through serve * `cmd_context` shim path: on `ApiBackend` (no `.conn`), fetch + render via `_render_via_serve`; on a truly non-conn/non-Api backend, still surface a clean error (guards on `isinstance(db, ApiBackend)`) Covered by `tests/integration/test_context_serve.py`: * endpoint computes diagnostic server-side, including the recurring file-read only surfaceable from raw `attributes` * `tj context` (plain + `--json`) renders through an in-process ASGI-wired `ApiBackend` — the exact daemon-is-running state * a non-conn/non-Api backend still errors cleanly (no traceback) Co-Authored-By: Claude <[email protected]>
anshss
added a commit
to Axiya3749/tokenjam
that referenced
this pull request
Jul 10, 2026
…x/quota-audit under a running daemon
Three analytics commands — `tj context`, `tj tokenmaxx`, `tj quota-audit` —
needed a direct DuckDB connection and errored while `tj serve` held the write
lock, i.e. from the moment onboarding installs the daemon. DuckDB permits only
one writer OR many readers across processes, so opening a read-only connection
alongside the serve write-lock is impossible — verified empirically in this
DuckDB version, it raises an IOException ("Conflicting lock is held"). The lock
was mitigated in four inconsistent places, each command duck-typing the backend
with `hasattr(db, "conn")` / `hasattr(db, "fetch_*")`; the two backends drifted
silently and tokenmaxx / quota-audit had no serve path at all.
Introduce one explicit `DataAccess` interface with two implementations —
`DirectDataAccess` (direct DuckDB) and `ServeDataAccess` (routed through the
daemon, which owns the connection) — resolved at a single choke point
(`resolve_data_access`). Commands ask for the computed diagnostic/audit and
never branch on the backend type.
- `tj tokenmaxx` reuses the existing `/api/v1/context` endpoint (it shares
`compute_context_diagnostic` with `tj context`) — no new endpoint.
- `tj quota-audit` gets a new `/api/v1/quota-audit` endpoint plus a proper
`audit_to_dict` / `audit_from_dict` round-trip pair (replacing a one-off
serializer) so the serve path can't silently drop a rendered field.
- `tj context` already had a bespoke serve path (Metabuilder-Labs#63); it now goes through the
same seam so all three commands share one consistent interface.
Existing behavior with no daemon running is unchanged.
Co-Authored-By: Claude <[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.
Follow-up to #62. Docs-only updates that surface the new
tj optimizeandtj backfill claude-codefeatures so users can find them.README
and a realistic terminal example with both analyzers. Mandatory caveat line
visible.
"tj optimize — what you actually get" subsection covering the two
analyzers, scoping flags, and the read-only fallback that lets it run
alongside
tj serve.tj optimizeandtj backfill claude-code.differentiator vs LangSmith / Langfuse / Datadog.
get_optimize_reportadded at thetop of the tools table with a description that surfaces both phrasings
the tool fires on (cost-saving questions AND budget-projection questions).
Manual test runbooks
tests/manual-pre-release-testing.md: new step 9b walking through theempty-DB short-circuit, backfill idempotency (re-runs report "Skipped …
spans already present"), the analyzer renderer (caveat must appear in
human output), and a JSON-output assertion that any downgrade finding
carries the caveat. Quick-test block now exercises
tj optimize.tests/manual-new-release-tests.md: new step 11 with a focused smokecheck for the new commands. Codex and Claude Code integration blocks
trimmed from ~33 / ~25 lines down to ~14 each — the multi-step cross-sync
and multi-project coverage already lives in the pre-release file and
doesn't catch new bugs when repeated post-release.
Net across both test docs: +57 / −49.
🤖 Generated with Claude Code