Skip to content

docs: tj optimize coverage — README + manual test runbooks - #63

Merged
anilmurty merged 4 commits into
mainfrom
chore/manual-test-docs-optimize
May 15, 2026
Merged

anilmurty merged 4 commits into
mainfrom
chore/manual-test-docs-optimize

Conversation

@anilmurty

@anilmurty anilmurty commented May 15, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to #62. Docs-only updates that surface the new tj optimize and
tj backfill claude-code features so users can find them.

README

  • New top-of-page block leads with the 3-line UX (install → onboard → optimize)
    and a realistic terminal example with both analyzers. Mandatory caveat line
    visible.
  • Claude Code section now leads with the optimize workflow and gets a new
    "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.
  • CLI list adds tj optimize and tj backfill claude-code.
  • Comparison table gains "Model-downgrade cost recommendations" — a real
    differentiator vs LangSmith / Langfuse / Datadog.
  • MCP tool count corrected (13 → 14) and get_optimize_report added at the
    top 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 the
    empty-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 smoke
    check 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

anilmurty and others added 2 commits May 15, 2026 09:20
…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]>
@anilmurty anilmurty changed the title docs: cover tj optimize + tj backfill in manual test runbooks docs: tj optimize coverage — README + manual test runbooks May 15, 2026
anilmurty and others added 2 commits May 15, 2026 12:31
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]>
@anilmurty
anilmurty merged commit 8752a92 into main May 15, 2026
4 checks passed
@anilmurty anilmurty mentioned this pull request May 18, 2026
4 of 6 tasks
@anilmurty
anilmurty deleted the chore/manual-test-docs-optimize branch May 29, 2026 04:59
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]>
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.

1 participant