Skip to content

Surface error logging in non-verbose mode #403

Closed

Description

@admarble

Problem

Several failure paths in the run command only log warnings when --verbose is set. In normal usage, these failures are completely invisible to the user — they see success or unexpected behavior with no diagnostic information.

Silent failure locations

1. State reconciliation failure (run.ts:431-437)

} catch {
  if (config.verbose) {
    console.log(chalk.yellow(`  ⚠️  State reconciliation failed, continuing...`));
  }
}

If .sequant/state.json can't be reconciled (corruption, permission error), the user gets no feedback. Execution continues with potentially stale state.

2. Metrics recording failure (run.ts:852-858)

} catch (metricsError) {
  if (config.verbose) {
    console.log(chalk.yellow(`  ⚠️  Metrics recording error: ${metricsError}`));
  }
}

Metrics silently fail. The user's sequant stats will show incomplete data with no explanation.

3. State guard catch block (run.ts:463-466)

} catch {
  activeIssues.push(issueNumber);  // Silently includes issue on state lookup failure
}

If reading an issue's state throws (file corruption, race condition), the issue is silently added to the active list. Only verbose mode logs this.

Why this matters

Users running sequant run 123 456 in CI or in normal mode see clean output and assume everything worked. If state reconciliation failed, or metrics weren't recorded, they only discover it later when sequant stats is wrong or state is stale. The feedback loop is broken — they can't diagnose the problem without re-running with --verbose, by which point the transient error may not reproduce.

Acceptance Criteria

  • State reconciliation failures log a one-line warning (yellow) in all modes, not just verbose
  • Metrics recording failures log a one-line warning in all modes
  • State guard catch blocks log which issue failed state lookup and why
  • Verbose mode continues to show additional detail (stack trace, full error object) beyond the one-line warning
  • No change to control flow — these are all non-fatal, execution still continues
  • Existing tests pass; add test coverage for at least one of the warning paths

Files in Scope

  • src/commands/run.ts — lines 431-437, 463-466, 852-858

Design Notes

The pattern should be:

} catch (error) {
  console.log(chalk.yellow(`  ⚠️  State reconciliation failed, continuing...`));
  if (config.verbose) {
    console.log(chalk.gray(`    ${error}`));
  }
}

One-line summary always visible. Details in verbose. This is consistent with how other CLI tools (npm, git) handle non-fatal warnings.

Activity

  1. added
    bug
    cli
    on Mar 23, 2026
  2. added a commit that references this issue on Mar 24, 2026
  3. admarble commented on Mar 24, 2026

    @admarble
    ContributorAuthor

    Exec Phase: Implementation Complete

    AC Coverage

    AC Description Status
    AC-1 State reconciliation warnings in all modes ✅
    AC-2 Metrics recording warnings in all modes ✅
    AC-3 State guard logs which issue failed and why ✅
    AC-4 Verbose shows additional detail ✅
    AC-5 No change to control flow ✅
    AC-6 Tests pass + new coverage ✅

    Key Changes

    • src/commands/run.ts — Removed if (config.verbose) guards from 3 catch blocks; extracted logNonFatalWarning helper
    • src/commands/run.test.ts — 3 new tests for the warning pattern (always-visible + verbose-only detail)
    • CHANGELOG.md — Added entry under ### Fixed

    Quality Gates

    Check Status
    npm run build ✅ Pass
    npm run lint ✅ Pass
    npm test ✅ 123/123 in run.test.ts

    PR

    Created: #415

    Quality Plan Alignment: N/A — No quality plan in issue

  4. admarble commented on Mar 24, 2026

    @admarble
    ContributorAuthor

    QA Review for Issue #403

    AC Coverage

    AC Source Description Status Notes
    AC-1 Original State reconciliation failures log warning in all modes MET logNonFatalWarning called unconditionally at run.ts:445
    AC-2 Original Metrics recording failures log warning in all modes MET logNonFatalWarning called at run.ts:871
    AC-3 Original State guard logs which issue failed and why MET Message includes #${issueNumber} at run.ts:477-478
    AC-4 Original Verbose mode shows additional detail MET logNonFatalWarning conditionally logs error object when verbose=true
    AC-5 Original No change to control flow MET All 3 catch blocks continue execution after logging; no returns/throws added
    AC-6 Original Tests pass; new coverage for warning paths MET 123/123 pass; 3 new tests cover always-visible, verbose-detail, no-detail paths

    Coverage: 6/6 AC items fully met


    CI Status

    Check State Bucket Impact
    build (20.x) SUCCESS pass ✅ MET
    build (22.x) SUCCESS pass ✅ MET
    typecheck SUCCESS pass ✅ MET
    validate-plugin SUCCESS pass ✅ MET
    validate-skills SUCCESS pass ✅ MET

    CI Summary: 5 passed, 0 pending, 0 failed


    Quality Metrics

    Metric Value Status
    Type issues (any) 0 OK
    Deleted tests 0 OK
    Files changed 3 OK
    Lines added +71 -
    Lines deleted -13 -

    Quality Plan Verification

    N/A — No quality plan found in issue comments


    Test Coverage Analysis

    Changed File Tier Has Tests? Test File
    src/commands/run.ts Standard ✅ Yes src/commands/run.test.ts
    CHANGELOG.md Optional N/A -

    Coverage: 1/1 changed source files have corresponding tests
    Critical paths without tests: None


    Code Review

    Strengths:

    • Clean extraction of logNonFatalWarning helper — DRY pattern applied consistently across all 3 catch blocks
    • Follows the exact design pattern from the issue (one-line always, detail in verbose)
    • Error parameter properly typed as unknown
    • @internal JSDoc tag correctly marks the function as not part of public API
    • CHANGELOG entry is well-formatted with sub-bullets explaining scope

    Issues:

    • None found

    Suggestions:

    • None — implementation is minimal and focused

    Test Quality Review

    Category Status Notes
    Behavior vs Implementation ✅ OK Tests assert on console output content, not internal state
    Coverage Depth ✅ OK Tests cover: always-visible warning, verbose detail, no-detail-when-not-verbose
    Mock Hygiene ✅ OK Only console.log is mocked — minimal and appropriate
    Test Reliability ✅ OK No timing dependencies; deterministic

    Anti-Pattern Detection

    Code Patterns

    No anti-patterns detected. No empty catch blocks, no await in loops, no hardcoded secrets in the diff.

    Dependency Audit

    N/A — No dependency changes


    Call-Site Review

    New exported functions detected: 1

    Function Call Sites Loop? Conditions AC Match
    logNonFatalWarning() run.ts:445 No catch block (state reconciliation) ✅ Matches AC-1
    run.ts:477 Yes (for..of issues) catch block (state lookup per issue) ✅ Matches AC-3
    run.ts:871 No catch block (metrics recording) ✅ Matches AC-2

    Findings: All call sites match AC constraints. The loop call at line 477 is correct — it should log per-issue when each issue's state lookup fails.


    Execution Evidence

    N/A — No scripts or CLI registration changes

    Skill Command Verification

    N/A — No skill files changed

    CLI Registration Verification

    N/A — No option interface changes

    Smoke Test

    Not Required — No workflow-affecting changes (no skills, scripts, or CLI commands modified)


    CHANGELOG Verification

    Check Status
    CHANGELOG.md exists ✅ Found
    User-facing changes ✅ Yes (fix: commit)
    [Unreleased] entry ✅ Present
    Entry format ✅ Valid (includes #403, starts with action verb)

    Result: CHANGELOG requirements met


    Self-Evaluation

    • Verified working: Yes — ran tests (123/123 pass), verified build compiles, confirmed all 3 catch blocks invoke logNonFatalWarning unconditionally
    • Test efficacy: High — tests directly verify the core behavior (warning always visible, detail only in verbose, detail hidden when not verbose)
    • Likely failure mode: Minimal risk. The function logs to console — if chalk is somehow unavailable, it would throw, but chalk is already used extensively throughout the codebase.
    • Verdict confidence: High — the change is small, focused, and directly addresses the stated problem

    Verdict: READY_FOR_MERGE

    All 6 AC items are met. The implementation follows the exact design pattern specified in the issue. Code is clean, tests are thorough, CI is green, CHANGELOG is updated. No issues found.

    Documentation

    • CHANGELOG entry added
    • N/A — No new features/flags requiring README or docs updates

    Next Steps

    1. Merge PR fix(#403): surface non-fatal warnings in all modes #415
  5. added
    ready-for-review
    on Mar 24, 2026
  6. added 2 commits that reference this issue on Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcliready-for-review

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions