Repository navigation
Conversation
`tj context` is the launch-hero command (issue #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` (#154) and `/api/v1/optimize` (#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]>
anilmurty
approved these changes
Jul 3, 2026
anilmurty
left a comment
Contributor
There was a problem hiding this comment.
Approving per review — tj context serve-fallback mirrors the optimize/reuse pattern, parity + honesty preserved, both paths tested. Merging for a clean board.
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
Fixes #63 —
tj context(the launch-hero command) refused to run whiletj servedaemon was up, telling users to stop the daemon on the exact command the launch drives them to.attributescolumn for recurring-inclusion detection, which the API shim never exposed row-by-row. DuckDB refuses a concurrent read-only connection alongside the write lock, so a client-side workaround isn't available./api/v1/reuse/clusters[follow-up] tj report --reuse needs an HTTP fallback when daemon holds the DB lock #154 and/api/v1/optimizePre-release testing findings (v0.3.0 sprint) — bugs and playbook fixes #68):GET /api/v1/contextcomputes the diagnostic + plan-tierframingserver-side (tokenjam/api/routes/context.py)diagnostic_from_dictinverse ofdiagnostic_to_dictintokenjam/core/context_diagnostic.pyso the CLI reconstructs the dataclass and renders identicallycmd_context.py: onApiBackend(no.conn), fetch + render via_render_via_serve; on a truly non-conn/non-Api backend, still surface a clean errorApiBackend.fetch_context_diagnosticHTTP client shimTest plan
tests/integration/test_context_serve.py(all 4 pass):attributessurfacestj contextrenders through in-process ASGI-wiredApiBackend(the exact daemon-is-running state) — old refuse-to-run error is gonetj context --jsonreturns identical payload through serveExisting
tests/unit/test_context_diagnostic.py(18 tests) still green.🤖 Generated with Claude Code