fix(cli): suppress boot stderr and Pino info logs in archon doctor/setup#1608
Conversation
…tup (#1606) `archon doctor` and `archon setup` were leaking `[archon] loaded N keys` boot lines and Pino `info` JSON events into their human-readable ○/✓ checklist output. Gate the loaded-keys lines behind ARCHON_VERBOSE_BOOT=1 or LOG_LEVEL= debug/trace, and default Pino to `warn` for the two interactive commands unless `--verbose` is passed. Changes: - packages/paths/src/env-loader.ts: add isVerboseBoot() helper; only emit `[archon] loaded` lines when verbose-boot or LOG_LEVEL=debug/trace is set - packages/cli/src/cli.ts: default Pino to `warn` for `setup` and `doctor` unless `--verbose` is passed (lazy logger init means this takes effect before any module logger is created) - packages/paths/src/env-loader.test.ts: existing loaded-line tests opt in via ARCHON_VERBOSE_BOOT=1; add coverage for default suppression and LOG_LEVEL=debug Fixes #1606
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (9)
📝 WalkthroughWalkthroughThe PR adds conditional boot logging for interactive commands by introducing an ChangesBoot Logging Verbosity Control
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Review: fix(cli) suppress boot stderr and Pino info logs in archon doctor/setupVerdict: Approve with one actionable fix and a few optional notes. The fix is correct and clean for the primary case. One edge case warrants attention before merge. C1 —
|
Comprehensive PR ReviewPR: #1608 — SummarySmall, focused fix that correctly gates Verdict:
🟡 Medium Issues (Consider Fixing Before Merge)M1: cli.ts comment block exceeds "one short line max" rule📍 The added 5-line comment block violates CLAUDE.md's "Never write multi-line comment blocks — one short line max" rule. The opening shorthand View suggested fixCurrent (5 lines): // Set log level from flags (quiet > verbose > default).
// Interactive commands (setup, doctor) default to warn so their human-readable
// ○/✓ checklist output isn't interleaved with Pino info JSON; --verbose opts
// back into structured logs. Lazy logger initialization in those commands
// means setLogLevel here takes effect before any logger is first created.
const isInteractiveCommand = command === 'setup' || command === 'doctor';Suggested (1 line, captures the non-obvious lazy-init constraint): // setup/doctor default to warn to avoid Pino info JSON interleaving with ○/✓ output; lazy loggers pick up this level at first creation
const isInteractiveCommand = command === 'setup' || command === 'doctor';M2:
|
| # | Issue | Location | Suggestion |
|---|---|---|---|
| L1 | isVerboseBoot() JSDoc is 3 lines |
env-loader.ts:45-48 |
Collapse to /** Env var gating: boot runs before parseArgs(), so CLI flags aren't available yet. */ |
| L2 | beforeEach comment is 2 lines |
env-loader.test.ts:38-39 |
Collapse to single line |
| L3 | LOG_LEVEL=trace activation path untested |
env-loader.ts:52-53 |
Add a LOG_LEVEL=trace test mirroring the existing debug test (low risk — same boolean arm) |
| L4 | isInteractiveCommand branch in main() untested |
cli.ts:290-292 |
Pre-existing structural constraint (cli.ts self-executes on import). Defer; if fixing, extract resolveLogLevel(command, flags) as a pure helper |
| L5 | .env.example LOG_LEVEL comment: --quiet (error) should be --quiet (warn) |
.env.example |
Minimal fix: # CLI can override with --quiet (warn) or --verbose (debug) |
| L6 | Shorthand (quiet > verbose > default) ambiguous |
cli.ts:285 |
Resolved automatically if M1 is fixed |
✅ What's Good
- Semantic correctness: Keys load unconditionally; only the stderr diagnostic line is gated. Cannot accidentally prevent env vars from loading.
- Consistent naming:
ARCHON_VERBOSE_BOOT=1follows theARCHON_SUPPRESS_NESTED_CLAUDE_WARNING=1convention fromstrip-cwd-env.ts. - Private encapsulation:
isVerboseBoot()is not exported — correct for a boot-only internal helper. --quietstill overrides:values.quiet || (isInteractiveCommand && !values.verbose)correctly preserves--quietas highest-priority flag.- Test isolation:
beforeEach/afterEachsave/restore forARCHON_VERBOSE_BOOTandLOG_LEVELis clean and consistent with existingARCHON_HOMEhandling. - Key test: "does not emit loaded lines by default even when keys are present" directly validates that suppressing output does not suppress loading — the most critical regression risk.
- No new error paths: All new logic is pure boolean guards; pre-existing
process.exit(1)handlers are unchanged and correctly covered. - No comment rot: The "prints only when N > 0" docblock line was updated to reflect the new gating behavior.
Reviewed by Archon prp-review-agents workflow
Full artifacts: /Users/rasmus/.archon/workspaces/coleam00/Archon/artifacts/runs/fb99fb1302cec1ce6197bae22181e076/review/
- Condense multi-line cli.ts comment to one line (CLAUDE.md compliance) - Respect LOG_LEVEL=debug/trace even for interactive commands (setup/doctor) - Collapse isVerboseBoot() JSDoc to single-line comment - Scope consoleErrorSpy to single test that uses it (was global fixture) - Add LOG_LEVEL=trace test for isVerboseBoot() coverage - Add ARCHON_VERBOSE_BOOT=true (non-'1') test to document strict-equality - Document ARCHON_VERBOSE_BOOT in configuration.md env var table - Update configuration.md operator log lines block to reflect gating - Update cli.md env startup steps 2/3 with verbosity gate note - Update cli-internals.md boot flow diagram with verbosity gate note - Add CHANGELOG.md [Unreleased] entry for #1606 - Fix .env.example --quiet level label (error → warn)
⚡ Self-Fix Report (Aggressive)Status: COMPLETE Fixes Applied (13 total)
View all fixes
Tests Added
Skipped (0)(none — all findings addressed) Suggested Follow-up Issues
Validation✅ Type check | ✅ Lint | ✅ Tests (10 passed) Self-fix by Archon · aggressive mode · fixes pushed to |
…tup (coleam00#1608) * fix(cli): suppress boot stderr and Pino info logs in archon doctor/setup (coleam00#1606) `archon doctor` and `archon setup` were leaking `[archon] loaded N keys` boot lines and Pino `info` JSON events into their human-readable ○/✓ checklist output. Gate the loaded-keys lines behind ARCHON_VERBOSE_BOOT=1 or LOG_LEVEL= debug/trace, and default Pino to `warn` for the two interactive commands unless `--verbose` is passed. Changes: - packages/paths/src/env-loader.ts: add isVerboseBoot() helper; only emit `[archon] loaded` lines when verbose-boot or LOG_LEVEL=debug/trace is set - packages/cli/src/cli.ts: default Pino to `warn` for `setup` and `doctor` unless `--verbose` is passed (lazy logger init means this takes effect before any module logger is created) - packages/paths/src/env-loader.test.ts: existing loaded-line tests opt in via ARCHON_VERBOSE_BOOT=1; add coverage for default suppression and LOG_LEVEL=debug Fixes coleam00#1606 * fix: address review findings from PR coleam00#1608 - Condense multi-line cli.ts comment to one line (CLAUDE.md compliance) - Respect LOG_LEVEL=debug/trace even for interactive commands (setup/doctor) - Collapse isVerboseBoot() JSDoc to single-line comment - Scope consoleErrorSpy to single test that uses it (was global fixture) - Add LOG_LEVEL=trace test for isVerboseBoot() coverage - Add ARCHON_VERBOSE_BOOT=true (non-'1') test to document strict-equality - Document ARCHON_VERBOSE_BOOT in configuration.md env var table - Update configuration.md operator log lines block to reflect gating - Update cli.md env startup steps 2/3 with verbosity gate note - Update cli-internals.md boot flow diagram with verbosity gate note - Add CHANGELOG.md [Unreleased] entry for coleam00#1606 - Fix .env.example --quiet level label (error → warn) * simplify: export isVerboseBoot and eliminate logLevelIsVerbose duplicate in cli
Summary
archon doctorandarchon setupleaking boot-time stderr noise ([archon] loaded N keys) and Pino JSON log events (doctor.run_started,db.connection_sqlite_selected,db.sqlite_schema_initialized) into their human-readable○/✓checklist output.[archon] loaded N keysstderr lines inenv-loader.tsbehindARCHON_VERBOSE_BOOT=1orLOG_LEVEL=debug/trace. (2) Default Pino towarnforsetupanddoctorincli.ts(unless--verboseis passed). (3) Updateenv-loader.test.tsto cover the new gating behavior.[archon] stripped N keys(security-relevant, stays unconditional), theCLAUDECODE=1nested-session warning, Pino verbosity for all other CLI commands (workflow run,serve, etc.).UX Journey
Before
After
Architecture Diagram
Before
After
Connection inventory:
cli.tsenv-loader.ts loadArchonEnv()env-loader.tsprocess.stderrisVerboseBoot()cli.tssetLogLevel()warnforsetup/doctorcli.tsdoctorCommand()doctorCommand()getLog().info()Label Snapshot
risk: lowsize: XScli,paths,testscli:doctor,paths:env-loaderChange Metadata
bugcliLinked Issue
Validation Evidence (required)
All six checks passed:
check:bundledcheck:bundled-skillbun run type-checkbun run lintbun run format:checkbun run testbun run validaterun completed without errors.Security Impact (required)
Compatibility / Migration
ARCHON_VERBOSE_BOOT=1restores the[archon] loadedlines for users who relied on them.ARCHON_VERBOSE_BOOT=1(additive). ExistingLOG_LEVEL=debugalso re-enables the lines.Human Verification (required)
Validated three modes against an
ARCHON_HOMEcontaining a populated.env:archon doctor(default) — clean ○/✓ checklist; no[archon] loadedline, no Pino JSON.archon doctor --verbose— checklist plus Pino info events;[archon] loadedstill absent (env-loader runs before parseArgs, so--verbosecan't reach it; onlyARCHON_VERBOSE_BOOT=1does).ARCHON_VERBOSE_BOOT=1 archon doctor—[archon] loaded 1 keys …appears before banner; Pino remains suppressed.Edge cases checked:
archon workflow run assist "test"(non-interactive command): Pino info logs unaffected.archon doctor --quiet: same as default (warn level).cli.doctor,db.connection,db.sqliteconfirmed —setLogLevel('warn')runs before anygetLog()call.What was not verified:
archon setupinteractive wizard (requires interactive TTY; covered by same code path asdoctor).Side Effects / Blast Radius (required)
archon doctorandarchon setupoutput;env-loader.tsstderr behavior.[archon] loadedlines for debugging will need to setARCHON_VERBOSE_BOOT=1orLOG_LEVEL=debug.Rollback Plan (required)
git revertthe single commit (e6466ffc); no database or config changes to undo.ARCHON_VERBOSE_BOOT=1restores the env-loader lines immediately without a code change.Risks and Mitigations
[archon] loadedlines to diagnose env-loading order lose them silently.ARCHON_VERBOSE_BOOT=1orLOG_LEVEL=debugrestores them. The[archon] strippedline instrip-cwd-env.tsis unchanged.Summary by CodeRabbit
Bug Fixes
archon doctorandarchon setupno longer interleave startup logs with interactive output, providing cleaner checklists by default.Documentation
ARCHON_VERBOSE_BOOTenvironment variable for restoring verbose startup logging when needed.