Skip to content

Sce trace#100

Open
davidabram wants to merge 10 commits into
mainfrom
sce-trace
Open

Sce trace#100
davidabram wants to merge 10 commits into
mainfrom
sce-trace

Conversation

@davidabram

Copy link
Copy Markdown
Member

No description provided.

davidabram and others added 9 commits June 30, 2026 17:38
…robe

Add a new `services::trace` module exposing `discover_agent_trace_dbs`,
which scans `<state_root>/sce/agent-trace-{checkout_id}.db`, sorts by
mtime descending with `checkout_id` ascending as a tiebreak, assigns
positional `agent_trace_{i}` aliases, and probes each DB for the six
required tables

Co-authored-by: SCE <sce@crocoder.dev>
Introduce the `sce trace` command group at the clap layer with
`trace db list` and `trace status [--all]` subcommands, both accepting
`--format text|json`. Register `services::trace::NAME` in the command
registry and dispatch parsed clap variants through `parse::command_runtime`
to a stub `TraceCommand` whose `execute` returns
"sce trace <subcommand>: not implemented".

Co-authored-by: SCE <sce@crocoder.dev>
Wire `sce trace db list` to discover_agent_trace_dbs() and render the
results through a new services::trace::render_list module. Text output
uses the shared style::heading helper with a dynamic-width Alias /
Status / Path table; JSON output emits a stable {status, command,
subcommand, databases:[{alias, checkout_id, path, status, skip_reason?,
mtime}]} shape. Empty discovery renders the heading plus an empty-state
message (text) or an empty databases array (JSON). Status subcommands
continue to return the not-implemented stub.

Co-authored-by: SCE <sce@crocoder.dev>
Introduce `services::trace::stats` with `collect_agent_trace_db_stats`,
which opens a single Agent Trace DB read-only and returns row counts for
`diff_traces`, `messages`, `parts`, `session_models`, `agent_traces`, and
`post_commit_patch_intersections` alongside a `last_activity` derived
from `MAX(diff_traces.time_ms)`, `MAX(messages.updated_at)`, and
`MAX(agent_traces.created_at)`.

Co-authored-by: SCE <sce@crocoder.dev>
Wire the `sce trace status` subcommand (without `--all`) to resolve the
cwd's checkout, locate `agent-trace-{id}.db`, run the stats probe, and
render the per-checkout block in text and JSON.

Co-authored-by: SCE <sce@crocoder.dev>
Wire `sce trace status --all` to walk every discovered AgentTraceDb
under the SCE directory, aggregate per-database stats from ready DBs
into combined totals (six counts plus max last_activity), and render
the Databases / Totals / By database blocks in both text and JSON.
Skipped DBs are excluded from totals but counted in the discovery
summary and surfaced in the per-database breakdown with their skip
reason. Empty discovery prints zeroed totals and omits the breakdown
table.

Co-authored-by: SCE <sce@crocoder.dev>
Remove the DoctorSubcommand::Dbs / DoctorAction::Dbs surface now that
checkout discovery lives in the trace group (sce trace db list). Drops
run_doctor_dbs, discover_checkouts_from_filesystem,
sort_checkouts_by_last_seen_desc, render_doctor_dbs_text,
render_doctor_dbs_json, DiscoveredCheckout, and the action field from
DoctorRequest. convert_doctor_command simplifies to a non-Result return
now that the only validation branch (--fix + dbs) is gone.

Context sync: context/cli/checkout-identity.md,
context/cli/cli-command-surface.md, context/sce/agent-trace-db.md, and
the plan file now reference sce trace db list instead of
sce doctor dbs.

Plan: sce-trace-cli T07

Co-authored-by: SCE <sce@crocoder.dev>
Update overview, architecture, glossary, context-map, and
trace-command docs to reflect that checkout DB discovery moved
from sce doctor dbs (removed) into the trace group
(sce trace db list). No stale 'doctor dbs' references remain in
root or domain context files.

Plan: sce-trace-cli T07

Co-authored-by: SCE <sce@crocoder.dev>
Co-authored-by: SCE <sce@crocoder.dev>
Add `sce trace db shell <uuid-or-alias>` as an in-process interactive SQL shell over discovered Agent Trace DBs. The command resolves a positional `agent_trace_N` alias or full checkout ID against `discover_agent_trace_dbs()`, rejects unknown, ambiguous, or skipped databases with validation-class guidance, then opens the selected DB directly through the Rust Turso adapter.

The embedded shell prints resolved alias, checkout ID, and path on startup, supports `.help`, `.tables`, `.exit`, and `.quit` dot commands, executes single-line SQL (including semicolon splits), renders query rows deterministically as `column | column` tables, and keeps running after SQL errors. `.tables` lists every visible table including internal SCE tables such as `__sce_migrations` in deterministic order without counts or schema details.

Add a new `TursoDb::query_values` helper that returns fully fetched column names and raw `turso::Value` rows for deterministic operator-facing rendering. The shell hands off locked stdin/stdout inside `TraceCommand` and returns an empty payload so the normal app renderer does not duplicate transcript output.

Co-authored-by: SCE <sce@crocoder.dev>
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