feat(debug): `debug bundle` reports config, credentials, sessions and runtime health; add `debug probe`

SA
1d ago
+2593-19

Why

altimate-code debug bundle was built for one case: Altimate Code hanging or closing during a Snowflake connection. A recent field report, "new sessions keep the New session - <time> title", could not be answered from a bundle. The bundle recorded neither model nor small_model, had no finding for failed small-model calls, and title failures never reached opencode.log at all. Log.create writes to stderr only, and only with --print-logs.

The bundle still reports shape, never content: names, presence, counts, versions, timings and error classes. Prompts, tool inputs and outputs, file contents, credential values, env values and SQL stay out. It still starts no project instance, so it cannot hang on what it diagnoses.

What the bundle reports now

SectionFacts
ConfigurationConfig files in merge order, each substituted, parsed and validated as the loader's loadConfig does (ConfigVariable.substitute, ConfigParse.jsonc, validateLoaded), so "failed" means the loader rejects it. Also: model and small_model with the file that set each, the last model picked in the app, on/off settings, the permission mode (command patterns are only counted), plugin names, skill folders with SKILL.md counts, rules files, and the git root or the no-project sentinel. Remote and account configs need the network, so they are listed as not inspected.
CredentialsPer provider, where a credential was found: auth.json entry type, env var name from the model catalogue, or config apiKey. OAuth expiry. No values are read.
WorkspaceLinked or not and how, plus the status, last success and error class of each sync. Read without readLocalBinding, which migrates the cache when it reads.
Runtime healthBun and Node versions. Whether @altimateai/altimate-core, @parcel/watcher and DuckDB load, with versions. Log, database and cache sizes, free disk, and the newer release cached in kv.json (no network).
Sessions (14 days)A read-only bun:sqlite connection, never Database.Client, which migrates. Counts sessions, placeholder titles and error endings, the median time to the first output of the first reply, and failed replies by error class and HTTP status. Titles are matched in SQL and never returned. About 100 ms on a 4 GB database.
Telemetry idsThe machine id, and the launch id of the last non-debug launch (now on the startup line).

New findings: small-model failures (session titles, prompt enhancement) by model and error, with the file that set small_model. Also rejected provider sign-ins, repeated reply failures, config files the loader rejects, native modules that do not load, low disk, expired sign-ins and failing workspace sync.

altimate debug probe

Sends one tool-less request to the chat model and to the small model, resolved the way the title request resolves it. Prints the model, where it came from, the HTTP status, latency and error class, never reply text. Its output goes through the bundle's redaction. Exits 1 on failure. It is a separate command because it starts the project, and debug bundle keeps its no-hang guarantee.

small model (titles): anthropic/claude-haiku-4-5 (small_model)
  request FAILED: AI_APICallError, HTTP 401, class auth after 328 ms

Redaction

The bundle's existing redaction pass covers every new section. It now also removes keys recognisable by their shape with no key name before them: sk-…, ghp_…/github_pat_…, AKIA…, xox?-…, AIza…, JWTs, and 32+ character runs mixing upper case, lower case and digits. model, small_model and the last pick are shown only when they look like provider/model. Plugin specs lose user:token@, queries and fragments. The header says the report includes the telemetry machine id and launch id.

Changes outside the debug module

Each change in an upstream-owned file is inside an altimate_change block.

  • session/prompt.ts and altimate/enhance-prompt.ts: a failed title or prompt-enhancement request also writes a small model call failed line through fileLog, with class, kind and status but no message text.
  • src/index.ts: the startup line carries launch.
  • cli/tui/worker-console-guard.ts: the worker's console log goes to altimate-code/log, not opencode/log.
  • debug/report.ts: debug runs are no longer counted as app starts, and quoted log values are unescaped when parsed back.
  • cli/cmd/debug/v2.ts: default is the model id; the Effect was printed unrun.
  • altimate/workspace/state.ts: peekRowUnscoped returns adopted, and rowMatchesCurrentAccount checks a cached link against the signed-in account without migrating the cache.

Docs

The troubleshooting page gets "Debug report", "Testing the models" (debug probe) and "Model catalogue" (debug v2) sections. The existing "Debug Mode" heading stays, so its links keep working. The CLI reference mentions debug probe.

Testing

  • bun run typecheck is clean.
  • Debug, enhance-prompt, upstream guard, telemetry, provider, title-retry, workspace and CLI help suites: 2623 pass, 0 fail.
  • New test/altimate/debug/facts.test.ts covers every collector: config merge order and a file the loader rejects, permission summarising, skill and rules discovery, credential presence, session statistics on a fixture database (no titles or text in the result), native modules, sizes, workspace link, and a round trip of the failure line through fileLog.
  • New report tests cover each finding, and one test fills every new section with a home folder, a user name and message text, then checks that the bundle's redaction leaves none of it.
  • probe.test.ts runs probe() with the provider stubbed: both requests are tool-less, a 401 on the small model gives status and class but not the provider's message, the fallback to the chat model is labelled, and a small_model that is not a model id is shown only as its length.
  • Redaction tests cover each key shape, and check that model names, UUIDs, session ids, hashes and timestamps are left alone.
  • title-retry.test.ts now checks that a failed title writes the log line without the provider's message.
  • End to end: in a project with small_model set to a model with an invalid key, one run followed by debug bundle produces "Session titles failed on anthropic/claude-haiku-4-5 (1×)". The finding names the opencode.json that set it, HTTP 401 with kind auth, and 1 of 1 sessions still on the placeholder title, with no message text in the report.

Not in this PR

  • The telemetry opt-out reader (telemetry/config-state.ts) and the bundle still walk the config sources separately.
  • The bundle does not read the tui-worker-*.log files yet.
  • GitHub Copilot's utility title model: the fork registers plugin/copilot.ts, which has no experimental.provider.small_model handler, while upstream registers github-copilot/copilot.ts. Switching the registered plugin changes Copilot sign-in, so it is left for its own change.
  • "getSmallModel returns appropriate small model" in provider.test.ts fails when run alone with -t, on main too. It passes when the whole file runs.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Expanded diagnostic reports with configuration, credential-source, workspace, runtime, session, and model-failure details. Sensitive values are redacted.
    • Added debug probe to test chat and title models and show status and response time. Each test sends a live model request and counts toward provider usage.
    • debug v2 now displays model-catalogue data.
  • Documentation
    • Clarified report contents and when to create a report for support. Documented that debug bundle does not send model requests.