Skip to content

refactor: phase 3 foundation for node-based checks#154

Merged
benvinegar merged 1 commit intomainfrom
refactor/phase3-node-checks-foundation
Feb 24, 2026
Merged

refactor: phase 3 foundation for node-based checks#154
benvinegar merged 1 commit intomainfrom
refactor/phase3-node-checks-foundation

Conversation

@benvinegar
Copy link
Copy Markdown
Member

@benvinegar benvinegar commented Feb 24, 2026

Summary

  • start Phase 3 by moving startup integrity status parsing out of shell and into a dedicated Node check module
  • add bin/checks/integrity-status.mjs with normalized JSON output for missing/valid/invalid status files
  • update bin/doctor.sh and bin/security-audit.sh to consume the Node check output while keeping shell as orchestration/rendering layer
  • add tests for the new check module (test/integrity-status-check.test.mjs)

Validation

  • npx vitest run --config vitest.config.mjs test/integrity-status-check.test.mjs
  • npm run test:shell
  • npm run test:js

Phase tracking

  • starts TODO-66ba829f (Phase 3: Move complex checks to Node, keep shell thin)

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Feb 24, 2026

Greptile Summary

Refactors integrity status parsing from inline shell/jq to a dedicated Node.js check module (bin/checks/integrity-status.mjs), continuing Phase 3 migration toward Node-based checks with shell as thin orchestration layer.

Key changes:

  • New integrity-status.mjs module provides normalized JSON output with robust error handling for missing/invalid status files
  • Both doctor.sh and security-audit.sh refactored to call the Node check and parse results via json_get_string_stdin
  • Improved diagnostics distinguish between missing files, unreadable files, and parse errors
  • Comprehensive test coverage added with 3 test cases covering all error paths
  • All existing tests pass (123 total tests across JS and shell suites)

Confidence Score: 5/5

  • Safe to merge with no issues found
  • Clean refactor with comprehensive test coverage, follows established patterns, maintains backward compatibility, and all tests pass. The change improves code organization by moving parsing logic from shell to Node while keeping shell as orchestration layer, consistent with the stated Phase 3 architecture goals.
  • No files require special attention

Important Files Changed

Filename Overview
bin/checks/integrity-status.mjs New Node.js module to parse and normalize integrity status JSON files with robust error handling
test/integrity-status-check.test.mjs Comprehensive test coverage for the integrity status check module covering missing files, valid payloads, and parse errors
bin/doctor.sh Refactored to use Node check module instead of inline jq parsing, improved error handling and diagnostics
bin/security-audit.sh Parallel refactor to doctor.sh, replaced inline jq with Node check module for consistency

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[doctor.sh / security-audit.sh] -->|Resolve Node binary| B{Node available?}
    B -->|Yes| C[Execute integrity-status.mjs]
    B -->|No| D[Set empty payload]
    C -->|Success| E[Parse JSON output]
    C -->|Failure| D
    E --> F{Parse fields via json_get_string_stdin}
    F --> G[exists, status, checked_at, etc.]
    G --> H{exists == 1?}
    H -->|No| I[Warn: file missing]
    H -->|Yes| J{Switch on status}
    J -->|pass| K[Pass: integrity passed]
    J -->|warn| L[Warn: integrity issues]
    J -->|fail| M[Fail: integrity failed]
    J -->|skipped| N[Warn: check skipped]
    J -->|unknown| O[Warn: status unknown]
    D --> P[Warn: unreadable or missing]
    
    style C fill:#e1f5e1
    style E fill:#e1f5e1
    style K fill:#d4edda
    style M fill:#f8d7da
    style I fill:#fff3cd
    style L fill:#fff3cd
Loading

Last reviewed commit: bea4867

@benvinegar benvinegar merged commit f2f69fb into main Feb 24, 2026
10 checks passed
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