Skip to content

feat(cli): runtime Node-version preflight guard (clear message instead of opaque crash below engines floor) #734

Closed

Description

@admarble

Problem

Sequant declares engines.node >= 22.12.0 (raised deliberately in #677/#679 to drop EOL Node 20), but nothing enforces it at runtime. engines is advisory — npm/npx only emits an EBADENGINE warning and proceeds (unless the user has the rare engine-strict=true). So a user on Node 20/21:

  1. Sees an easily-missed install-time warning, then
  2. Runs sequant anyway, and if Sequant or a dependency (commander, the agent SDK) trips a Node-22-only API, gets an opaque stack trace instead of "upgrade your Node."

CI only runs Node 22.x (.github/workflows/ci.yml), so Node-20 runtime behavior is untested — green CI does not imply it works. The /setup skill has a soft Node warning, but it's one-time and only fires if a user runs setup; it does not cover sequant run / sequant serve invocations or post-setup Node changes.

This was hit in practice during local dev: npx sequant run on Node 20.17.0 produced the EBADENGINE noise and was easy to blow past.

Proposed fix

A small runtime Node-version preflight guard: at CLI startup, if the running Node is below the declared floor, print a clear, actionable message (current vs required + upgrade paths) and exit non-zero — before any command logic runs. This converts "ignorable warning → later opaque crash" into one friendly, immediate message.

Design (already critiqued for overcomplexity)

Reuse what exists — this is ~10–15 lines, zero new dependencies:

  • Home: src/lib/version-check.ts (alongside the existing install-location guards isHomeStrayInstall / buildHomeStrayWarning), invoked from bin/cli.ts near the existing guard block (~bin/cli.ts:132, before program.parse()).
  • Comparison: reuse the existing compareVersions(a, b) in version-check.ts (:281). Do not add semver.
  • Floor source: derive from engines.node in package.json — single source of truth, reusing the same package.json walk-up read that getVersion() already does in bin/cli.ts. Do not hardcode a separate "22.12.0" literal that can drift.
  • Pure/side-effect split: a pure getNodeVersionError(current, floor): string | null (unit-testable), wrapped by a thin assertNodeVersion() that prints + process.exit(1).
  • Self-safe: guard uses only built-in globals / widely-supported syntax so it executes (not crashes) on the old Node it rejects; runs as early as practical after imports.
  • Behavior: hard fail-fast with non-zero exit and a message naming current vs required Node + 2–3 upgrade paths (fnm / nvm / nodejs.org).

Explicitly out of scope (rejected as overcomplexity)

  • No semver (or any new) dependency — reuse compareVersions.
  • No SEQUANT_SKIP_NODE_CHECK bypass env var — YAGNI; npm engine-strict already exists.
  • No auto-install / auto-upgrade of Node, no version-manager detection.
  • No checking npm/git/gh versions — that remains /setup's job.
  • No per-command guards or warn-vs-fail config knob — one guard at entry, hard fail.

Acceptance Criteria

  • AC-1 On Node below the engines.node floor, running any sequant command (including sequant serve) prints a clear message stating current vs required Node version and at least one upgrade path, and exits non-zero — before command logic runs.
  • AC-2 On Node at/above the floor, there is zero behavior change: no added output, exit 0.
  • AC-3 The floor is derived from engines.node in package.json (single source of truth), not a separately hardcoded version literal.
  • AC-4 The check reuses the existing compareVersions in src/lib/version-check.ts; no semver or other new runtime dependency is added.
  • AC-5 A pure, side-effect-free function (message-or-null) is unit-tested across boundary versions: 20.x → fail, 22.11.x → fail, 22.12.0 → pass, 22.12.1 → pass, 24.x → pass.
  • AC-6 The guard lives in src/lib/version-check.ts and is invoked from bin/cli.ts near the existing home-stray guard, using only built-in globals so it runs (does not crash) on the old Node it rejects.

Files affected

  • src/lib/version-check.ts — add getNodeVersionError (pure) + assertNodeVersion (exit shell), reuse compareVersions
  • bin/cli.ts — read engines.node floor (same walk-up read as getVersion()), call assertNodeVersion() near :132
  • src/lib/version-check.test.ts (or sibling) — boundary-version unit tests

References

Activity

  1. added
    enhancement
    cli
    on Jun 20, 2026
  2. admarble commented on Jun 21, 2026

    @admarble
    ContributorAuthor

    Complexity: Standard (6 ACs, 2 directories)

    AC Quality Check

    All 6 ACs are measurable with explicit boundaries (AC-5 even enumerates the version table). No vague/unmeasurable/open-ended patterns. No title/body tension. ✅ Clean.


    Scope Assessment

    Non-Goals: ✅ Present and unusually thorough — issue's "Explicitly out of scope" rejects semver, bypass env var, auto-upgrade, npm/git/gh checks, per-command guards.

    Metric Value Status
    Feature count 1 ✅
    AC items 6 ⚠️ (at yellow boundary)
    Directory spread 2 (bin/, src/lib/) ✅

    Verdict: ⚠️ SCOPE_WARNING (AC count hits the 6 boundary) — but this is an artifact of AC-3/4/5/6 being constraints on one ~15-line function, not 6 independent features. Real surface is one pure fn + one shell wrapper + one call site. Treat as effectively SCOPE_OK; quality-loop value is marginal here.


    Acceptance Criteria

    AC-1: Sub-floor Node prints current-vs-required + upgrade path, exits non-zero before command logic

    Verification: Integration Test — message assertions via the pure fn (AC-5); exit behavior via assertNodeVersion() with process.exit mocked. (True in-process Node-20 downgrade can't be simulated; inject current/floor instead.)
    Scenario: Given Node 20.17.0 → When sequant <any cmd> (incl. serve) → Then stderr shows "current 20.17.0 / required >=22.12.0" + ≥1 upgrade path, exit code ≠ 0, no command runs.

    AC-2: At/above floor → zero behavior change, exit 0

    Verification: Unit Test — getNodeVersionError(currentAtOrAbove, floor) returns null.
    Scenario: Given Node ≥22.12.0 → When any command → Then no added output, normal exit.

    AC-3: Floor derived from engines.node, not a hardcoded literal

    Verification: Integration Test — assert the floor passed to the guard equals package.json engines.node (strip range operator); grep confirms no "22.12.0" literal in the guard.
    Scenario: Given engines.node changes → When CLI starts → Then floor tracks it automatically.

    AC-4: Reuses compareVersions; no new runtime dependency

    Verification: Manual/Static — code review confirms compareVersions reuse; git diff package.json shows no added dep; no import "semver".

    AC-5: Pure side-effect-free fn unit-tested across boundaries

    Verification: Unit Test — 20.x→fail, 22.11.x→fail, 22.12.0→pass, 22.12.1→pass, 24.x→pass (message-or-null).
    Scenario: Table-driven test in src/lib/version-check.test.ts.

    AC-6: Guard lives in version-check.ts, invoked from bin/cli.ts near home-stray guard, built-in globals only

    Verification: Manual/Static — location check; review confirms only process.version/console/process.exit (no transpiled-down Node-22 syntax, no heavy imports inside the guard path).


    Implementation Plan

    Phase 1: Pure core + tests (src/lib/version-check.ts, .test.ts)

    1. Add getNodeVersionError(current: string, floor: string): string | null near compareVersions (:281). Returns null when compareVersions(current, floor) >= 0; else a multi-line message naming current vs required + 2–3 upgrade paths (fnm / nvm / nodejs.org).
    2. Strip the range operator from the floor before comparing. ⚠️ engines.node is ">=22.12.0"; compareVersions(">=22.12.0","20.17.0") returns -1 (wrong — would pass Node 20) because parseInt(">=22") → NaN → 0. Normalize with e.g. floor.replace(/^[^\d]*/, "") before the compare (do this inside getNodeVersionError or assertNodeVersion).
    3. Add boundary unit tests (AC-5 table) to src/lib/version-check.test.ts.

    Phase 2: Shell wrapper + wiring (src/lib/version-check.ts, bin/cli.ts)

    1. Add assertNodeVersion(floor: string): compute process.version, call getNodeVersionError; if non-null → console.error(...) + process.exit(1).
    2. In bin/cli.ts, read engines.node during the existing getVersion() walk-up (return the pkg's engines?.node alongside/like the version — single read), then call assertNodeVersion(floor) before the home-stray block (:130) so it fires ahead of any command logic.

    Design Review

    1. Where does this logic belong? src/lib/version-check.ts — co-located with isHomeStrayInstall/buildHomeStrayWarning, the established pure-predicate + builder pattern. ✅ Matches issue.
    2. Simplest correct approach? Pure getNodeVersionError (string|null) + thin exiting assertNodeVersion. Reject: a class, a config knob, env bypass — all in issue Non-Goals.
    3. Existing pattern? Mirrors the isHomeStrayInstall (pure) / buildHomeStrayWarning (message) / cli.ts emission split already in the file.
    4. What would a senior reviewer challenge?
      • "Does it actually run before the crash it prevents?" — ESM hoists all top-of-file imports (commander, agent SDK) and evaluates them before :130. If a dependency throws at import time on Node 20, the guard never fires. See Open Question 1.
      • "Did you handle the >= prefix?" — yes (Phase 1 step 2); this is the load-bearing detail.

    Feature Quality Planning

    Standard checks pass. Notable items:

    • Range-prefix parsing (above) — the single highest-risk gap; without it the guard silently no-ops/inverts. Must have a direct test (getNodeVersionError("20.17.0", ">=22.12.0") is non-null).
    • Self-safety scope — AC-6's "runs on the old Node it rejects" holds for the guard fn itself, but not for module imports that precede it. Worth a one-line check that chalk/commander import cleanly on Node 20 (they're runtime-incompatible, not import-incompatible — low risk).
    • getVersion() refactor — returning engines.node from the same walk-up avoids a second package.json read; keep the "0.0.0"-style fallback semantics (e.g. floor null → skip guard rather than crash).

    Open Questions

    1. Import-time ordering vs guard timing. Recommendation: keep the call at bin/cli.ts:~130 per the issue ("as early as practical after imports") — heavy deps here are runtime-incompatible, not import-incompatible, so they won't throw before the guard. Impact if wrong: an import crashes on Node 20 before the friendly message, reverting to an opaque trace for that one dependency. Cheap mitigation if observed: move assertNodeVersion into a tiny zero-dep module imported first.
    2. Floor missing/unparseable (engines.node absent or non-semver). Recommendation: treat as "skip guard" (return early), never crash the CLI on a metadata problem. Impact: guard silently disabled — acceptable, matches advisory nature.

    Recommended Workflow

    Phases: spec → testgen → exec → qa
    Quality Loop: disabled (small, well-bounded diff; SCOPE_WARNING is a boundary artifact)
    Reasoning: AC-2/AC-5 are Unit-Test ACs → testgen stubs the boundary table before exec. No UI → no test phase. Not security-sensitive. Tight ~15-line scope doesn't warrant the quality loop.


    Label Review

    Current: enhancement, cli
    Recommended: keep enhancement, cli (optionally simple-fix — diff is ~15 lines across 3 files)
    Reason: CLI behavior addition, no schema/UI/breaking surface.
    Quality Loop: Won't auto-enable (recommending disabled; SCOPE_WARNING is at-boundary only).

    → no label change required.

  3. added
    planned
    on Jun 21, 2026
  4. admarble commented on Jun 21, 2026

    @admarble
    ContributorAuthor

    /exec — Implementation Complete

    PR: #736 — #736

    AC Coverage

    AC Description Status
    AC-1 Sub-floor → clear message (current vs required + upgrade path), exit non-zero before command logic ✅ Implemented
    AC-2 At/above floor → zero behavior change, exit 0 ✅ Implemented
    AC-3 Floor derived from engines.node (single source of truth) ✅ Implemented
    AC-4 Reuses compareVersions; no semver/new runtime dep ✅ Implemented
    AC-5 Pure fn unit-tested across boundaries (20.x/22.11/22.12.0/22.12.1/24.x) ✅ Implemented
    AC-6 Guard in version-check.ts, invoked from bin/cli.ts, built-in globals only ✅ Implemented

    All 6 ACs satisfied.

    Files Changed

    • src/lib/version-check.ts — getNodeVersionError (pure, message-or-null, strips >= prefix) + assertNodeVersion (print + process.exit(1))
    • bin/cli.ts — getVersion → getPackageMeta (reads version + engines.node in one walk-up); assertNodeVersion(engineFloor) near home-stray guard
    • src/lib/version-check.test.ts — boundary table + range-strip + exit-behavior tests
    • CHANGELOG.md — [Unreleased] / Added entry

    Checks

    Check Result
    npm run build ✅ Pass
    npm run lint ✅ Pass (0 warnings)
    npx vitest run src/lib/version-check.test.ts ✅ 66 passed
    End-to-end (assertNodeVersion('>=999.0.0')) ✅ Prints message + exit 1; current Node passes silently

    Range-prefix handling (spec's highest-risk gap)

    getNodeVersionError strips the leading range operator before comparing, with a direct regression test: getNodeVersionError("20.17.0", ">=22.12.0") is non-null. A missing/unparseable floor returns null (guard skipped — never crashes the CLI on a metadata problem).

    Known gaps

    None. A true in-process Node-20 downgrade can't be simulated, so AC-1/AC-5 are verified by injecting current/floor into the pure fn and mocking process.exit for the shell wrapper — exactly as the /spec verification plan prescribed.

  5. admarble commented on Jun 21, 2026

    @admarble
    ContributorAuthor

    Test Stubs — Already Implemented (no stubs generated)

    /testgen ran after /exec for this issue, so the verification criteria from /spec are already covered by real, passing tests in src/lib/version-check.test.ts (66 passed). Emitting throw new Error(...) stubs now would overwrite passing tests or leave failing duplicates, so none were generated. Mapping below.

    AC Verification (per /spec) Coverage Where
    AC-1 Integration — message via pure fn + exit via assertNodeVersion (process.exit mocked) ✅ Covered getNodeVersionError "fails on Node 20.x" (asserts current + required strings); assertNodeVersion "prints message and exits non-zero when below the floor" (process.exit/console.error mocked)
    AC-2 Unit — getNodeVersionError(atOrAbove, floor) returns null ✅ Covered "passes on Node 22.12.0 / 22.12.1 / 24.x"
    AC-3 Integration/Static — floor derived from engines.node, no hardcoded literal ✅ Static (exec) getPackageMeta returns pkg.engines?.node; grep confirmed no 22.12.0 logic literal
    AC-4 Manual/Static — reuses compareVersions, no semver/new dep ✅ Static (exec) no semver import/dep in diff
    AC-5 Unit — boundary table (20.x→fail, 22.11.x→fail, 22.12.0→pass, 22.12.1→pass, 24.x→pass) ✅ Covered (full table) getNodeVersionError describe block — 5 boundary tests + >= range-strip regression test
    AC-6 Manual/Static — guard location + built-in globals only ✅ Static (exec) assertNodeVersion in version-check.ts, called in bin/cli.ts near home-stray guard; uses only process.version/console/process.exit

    Coverage summary

    • Unit-testable ACs (AC-1 msg/exit, AC-2, AC-5): fully covered by 12 tests across getNodeVersionError + assertNodeVersion describe blocks, including the load-bearing >=-prefix-strip regression and the missing/unparseable-floor skip path.
    • Static/Manual ACs (AC-3, AC-4, AC-6): no file-based stub applicable — verified by inspection during /exec and re-confirmed here.
    • Failure paths: below-floor message, process.exit(1), range-operator misparse, and missing-floor (guard-skip) are all exercised.

    Test run: npx vitest run src/lib/version-check.test.ts → 66 passed.

    Next step: /qa 734 — implementation + tests are in PR #736.


    Generated with Claude Code

  6. admarble commented on Jun 21, 2026

    @admarble
    ContributorAuthor

    QA Review for Issue #734

    AC Coverage

    AC Source Description Status Notes
    AC-1 Original Sub-floor prints current-vs-required + ≥1 upgrade path, exits non-zero before command logic (incl. serve) MET assertNodeVersion(engineFloor) at bin/cli.ts:132 runs at module-eval, before program.parse() → fires for every command incl. serve. Message names current + required + 3 paths (fnm/nvm/nodejs.org). E2E verified: real process.exit(1) + message
    AC-2 Original At/above floor → zero behavior change, exit 0 MET getNodeVersionError returns null ≥ floor; node dist/bin/cli.js --version/--help → no added output, exit 0
    AC-3 Original Floor derived from engines.node, not hardcoded MET getPackageMeta returns pkg.engines?.node ?? null; no 22.12.0 logic literal (only in a doc-comment example)
    AC-4 Original Reuses compareVersions; no semver/new dep MET getNodeVersionError calls compareVersions; grep semver package.json → 0
    AC-5 Original Pure fn unit-tested across boundaries (20.x/22.11/22.12.0/22.12.1/24.x) MET Full boundary table + >=-strip regression + missing/unparseable-floor skip (12 tests)
    AC-6 Original Guard in version-check.ts, invoked from bin/cli.ts near home-stray guard, built-in globals only MET assertNodeVersion in version-check.ts, called at cli.ts:132 immediately before home-stray block; uses only process.version/console/process.exit

    Coverage: 6/6 AC items fully met (no derived ACs)


    CI Status

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

    CI Summary: 4 passed, 0 pending, 0 failed. mergeable: MERGEABLE, mergeStateStatus: CLEAN.


    Quality Metrics

    Metric Value Status
    Type issues (any/as any) 0 OK
    Deleted tests 0 OK
    Files changed 4 OK
    Lines added +164 -
    Lines deleted -5 -
    Security patterns 0 OK

    Local: npm run build ✅ · npm run lint ✅ (0 warnings) · vitest run version-check.test.ts ✅ 66 passed.


    Test Coverage Analysis

    Changed File Tier Has Tests? Test File
    src/lib/version-check.ts Standard ✅ Yes src/lib/version-check.test.ts (12 new tests)
    bin/cli.ts Standard ⚠️ Indirect No cli.test.ts exists in repo; logic extracted to tested version-check.ts; getPackageMeta exercised via build + e2e run

    Coverage: 1/1 testable source unit covered. The bin/cli.ts glue (getPackageMeta + single call site) is integration-only by nature and consistent with the repo (no existing bin test).


    Test Quality Review

    Category Status Notes
    Behavior vs Implementation ✅ OK Asserts return value (message-or-null) and console.error/process.exit calls — behavior, not internals
    Coverage Depth ✅ OK Boundary table + >=-strip + missing/unparseable floor + both exit branches
    Mock Hygiene ✅ OK Mocks only process.exit/console.error (required to test the exit shell)
    Test Reliability ✅ OK Deterministic; assertNodeVersion tests vary the floor (runner Node is fixed) with an explanatory comment

    Code Review

    Strengths:

    • Clean pure/side-effect split mirrors the file's existing isHomeStrayInstall/buildHomeStrayWarning pattern.
    • The load-bearing >=-prefix strip is implemented and has a dedicated regression test — the spec's feat: Complete remaining v1.0 features (AC-10, AC-13, AC-14) #1 risk.
    • getVersion→getPackageMeta refactor reads version + floor in one walk-up (no second package.json read); preserves the "0.0.0"/null fallback semantics.
    • Missing/unparseable floor → guard skipped (never crashes the CLI on a metadata problem).

    Issues: None blocking.

    Suggestions: None — scope is exactly the spec's ~15-line core.


    Call-Site Review

    New exported functions: 2

    Function Call Sites Loop? Conditions AC Match
    getNodeVersionError version-check.ts:346 (inside assertNodeVersion) + tests No none ✅ pure helper
    assertNodeVersion bin/cli.ts:132 No unconditional, pre-program.parse() ✅ Matches AC-1/AC-6 (single entry guard)

    No dead exports. Verified the getVersion→getPackageMeta rename was local to bin/cli.ts — the shared getVersion in src/lib/version.ts (used by doctor.ts/serve.ts) is untouched, so no breakage (build confirms).


    Execution Evidence

    Test Type Command Result
    Sub-floor (AC-1) assertNodeVersion('>=999.0.0') via compiled module exit 1 + full message ✅
    At/above (AC-2) node dist/bin/cli.js --version / --help exit 0, no added output ✅

    Evidence status: Complete


    Product Review

    User-facing change: Node-version startup guard (no new flag).

    Question Finding
    First-time setup Improves it — Node-20/21 users get a clear message instead of EBADENGINE + later opaque crash
    Per-environment stderr message, no color dependency; fnm/nvm/nodejs.org cover macOS/Linux/Windows
    User sees 6-line message: current vs required + 3 upgrade paths, exit 1
    Failure modes Missing/unparseable engines.node → guard silently skipped (graceful, matches advisory nature)

    Gaps found: None.


    CHANGELOG Verification

    Check Status
    CHANGELOG.md exists ✅
    User-facing change ✅ feat(cli): commit
    [Unreleased] entry ✅ Present, references #734

    Result: CHANGELOG requirements met


    Risk Assessment

    • Likely failure mode: A static import at the top of bin/cli.ts (commander/chalk/command modules) throws at import time on Node 20 — before the guard at :132 runs — reverting to an opaque trace for that one dependency. The spec explicitly evaluated this (Open Question 1) and accepted it: these deps are runtime-incompatible, not import-incompatible. Documented, accepted design; cheap mitigation (tiny zero-dep first-import module) deferred unless observed.
    • Not tested: A true in-process Node-20 downgrade can't be simulated; AC-1/AC-5 are covered by injecting current/floor into the pure fn and mocking process.exit — exactly the /spec verification plan.
    • Sibling sites considered: none — serve/MCP and every other command route through the single bin/cli.ts entry, so one guard covers them all; there is no second binary needing the same check.
    • Sibling-line audit: none — single call site; getPackageMeta's walk-up resembles src/lib/version.ts:getVersion but is a distinct function with a different purpose, correctly left untouched.

    Adversarial Re-Read

    Findings: No gaps found because: (1) the issue body's verbatim motivating scenario ("npx sequant run on Node 20.17.0") is a literal test fixture — getNodeVersionError("20.17.0", ">=22.12.0") asserts non-null; (2) the e2e "evidence" is a post-fix validation (real exit 1 + message), not a pre-fix bug repro; (3) process state inspected — only an unrelated pre-existing package-lock.json platform churn is uncommitted (correctly excluded), branch in sync, mergeable CLEAN; (4) sibling sites cited above (cross-file: none — single entry; intra-file: none — single call site); (5) all issue Non-Goals held — no semver, no SEQUANT_SKIP_NODE_CHECK bypass, no auto-install, no npm/git/gh checks, no per-command guard or config knob.

    Status: Clean


    Verdict: READY_FOR_MERGE

    All 6 ACs MET, CI green and mergeable, zero type/security/scope issues, the spec's highest-risk detail (>= strip) is implemented and regression-tested, and scope held exactly to the spec's core. A+ implementation.

    Documentation

    Next Steps

    1. Optionally run /docs 734 (likely N/A — internal guard, no admin-facing surface).
    2. Merge PR feat(cli): runtime Node-version preflight guard (#734) #736.
  7. added
    ready-for-review
    on Jun 21, 2026
  8. admarble commented on Jun 21, 2026

    @admarble
    ContributorAuthor

    QA Review for Issue #734

    Runtime Node-version preflight guard — fail-fast with a clear message when running Node is below the engines.node floor. Reviewed PR #736 (commit cf3b1d0).

    AC Coverage

    AC Description Status Notes
    AC-1 Below floor → clear current-vs-required message + upgrade path, exit non-zero, before command logic (incl. serve) MET E2E verified: bumped engines.node to >=999.0.0, ran cli.js status → printed message, exit: 1. Guard runs at bin/cli.ts:130 before program.parse(); serve is a registered command (:522) so it routes through the same parse. Single bin entry (dist/bin/cli.js), single shebang — no bypass path.
    AC-2 At/above floor → zero behavior change, exit 0 MET cli.js --version on Node 22.23 → normal output, exit: 0, no added lines. Guard returns null and is a no-op.
    AC-3 Floor derived from engines.node (single source of truth), no hardcoded literal MET getPackageMeta() reads pkg.engines?.node via the same walk-up read as getVersion(); no "22.12.0" literal in source.
    AC-4 Reuses compareVersions; no semver/new runtime dep MET getNodeVersionError calls compareVersions; no package.json dependency change in diff.
    AC-5 Pure message-or-null function unit-tested across boundaries (20.x, 22.11.x, 22.12.0, 22.12.1, 24.x) MET All five boundaries tested + range-operator-strip + missing/unparseable-floor cases. 66/66 tests pass.
    AC-6 Guard in version-check.ts, invoked near home-stray guard, built-in globals only MET assertNodeVersion uses process.version / console.error / process.exit — self-safe on the old Node it rejects. Invoked at bin/cli.ts:130.

    Coverage: 6/6 AC items fully met

    CI Status

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

    CI Summary: 4 passed, 0 pending, 0 failed

    Quality Metrics

    Metric Value Status
    Type issues (any) 0 OK
    Deleted tests 0 OK
    Files changed 4 OK
    Lines added +164 -
    Lines deleted -5 -

    Local npx vitest run version-check.test.ts → 66 passed. npm run build (tsc) → clean.

    Test Coverage Analysis

    Changed File Tier Has Tests? Test File
    src/lib/version-check.ts Standard ✅ Yes src/lib/version-check.test.ts
    bin/cli.ts Standard ⚠️ Wiring (one-line assertNodeVersion(engineFloor) call) covered via E2E above

    Coverage: Pure logic fully unit-tested; the thin CLI wiring is exercised by the E2E smoke test.

    Code Review

    Strengths:

    • Pure/side-effect split (getNodeVersionError vs assertNodeVersion) makes the core logic trivially testable without touching process.exit.
    • Floor normalization (replace(/^[^\d]*/, "")) strips the >= range operator; a dedicated test guards this load-bearing detail (without it parseInt(">=22") → NaN → 0 would wrongly pass Node 20).
    • Fail-soft on missing/unparseable floor (returns null) — a package.json metadata problem can't brick the CLI.
    • getVersion() → getPackageMeta() refactor avoids a second package.json walk-up; clean reuse.

    Issues:

    • None blocking.

    Suggestions:

    • The worktree has an uncommitted package-lock.json modification (removal of libc fields from optional deps) — a local-checkout artifact, NOT part of PR feat(cli): runtime Node-version preflight guard (#734) #736's committed diff. Recommend git checkout package-lock.json in the worktree before merge to avoid accidentally staging it.

    Execution Evidence

    Test Command Result
    Above-floor no-op node dist/bin/cli.js --version exit 0, normal output ✅
    Below-floor fail-fast bumped engines.node=>=999.0.0, node dist/bin/cli.js status message + exit 1 ✅
    Pure fn message getNodeVersionError("v22.23.0", ">=999.0.0") actionable multi-line message ✅

    Evidence status: Complete

    Risk Assessment

    • Likely failure mode: Essentially none for consumers — worst case is a malformed engines.node value, which is handled by the fail-soft null return (guard skips rather than crashes).
    • Not tested: Actually executing on a sub-22 Node runtime (the test runner is ≥22.12). Mitigated: getNodeVersionError is pure and the boundary table covers the comparison logic; the guard uses only built-in globals so it can't crash the old Node it rejects.
    • Sibling sites considered: none — no cross-file siblings. There is exactly one CLI entry point (dist/bin/cli.js); the guard sits ahead of program.parse(), so every subcommand (including serve) is covered by the single guard.
    • Sibling-line audit: none — single guard insertion, no adjacent call sites with the same pattern.

    Adversarial Re-Read

    Findings: No gaps found because: (1) traced the only entry point — package.json bin maps solely to dist/bin/cli.js, only shebang file is bin/cli.ts, and serve is a registered command routing through program.parse() which runs after the guard, so the AC-1 serve requirement is genuinely covered; (2) the "evidence" is a post-fix E2E (bumped floor → exit 1, restored floor → exit 0), not a pre-fix bug repro; (3) inspected process state — found an uncommitted package-lock.json libc-field change in the worktree, confirmed it is NOT in the committed PR diff and flagged it for cleanup; (4) sibling sites cited above (single entry point, no cross-file or intra-file siblings); (5) checked Non-Goals — no semver added, no bypass env var, no per-command guards, no npm/git/gh version checks; implementation stays within scope.

    Status: Clean

    Verdict: READY_FOR_MERGE

    A+ implementation. All 6 ACs met and literally verified (flags/values traced, not assumed), CI green, pure logic fully unit-tested across the AC-5 boundary table, and the fail-fast path confirmed E2E. Clean reuse of compareVersions with zero new dependencies, scope held exactly to the (already overcomplexity-critiqued) design.

    Documentation

    Next Steps

    1. Discard the uncommitted package-lock.json change in the worktree before merge (git checkout package-lock.json).
    2. Merge PR feat(cli): runtime Node-version preflight guard (#734) #736.
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

    clienhancementplannedready-for-review

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions