Skip to content

feat: add pipeline state rollup#146

Merged
richard-devbot merged 2 commits into
mainfrom
feat/ble-1-pipeline-state-rollup-113
Jun 27, 2026
Merged

feat: add pipeline state rollup#146
richard-devbot merged 2 commits into
mainfrom
feat/ble-1-pipeline-state-rollup-113

Conversation

@richard-devbot

@richard-devbot richard-devbot commented Jun 21, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add Node-native pipeline-state rollup for harness run directories
  • Derive current stage/task, stage statuses, attempts, retry/guardrail summaries, approval blockers, and cost/context totals from run files
  • Persist pipeline-state.json with existing file lock + atomic JSON write helpers
  • Export pipeline-state helpers from the package entrypoint

Test Plan

  • node --test tests/pipeline-state.test.js
  • node scripts/security-audit.mjs
  • npm test
  • npm run validate
  • npm run lint
  • git diff --check

Closes #113

Summary by CodeRabbit

  • New Features
    • Added pipeline state management to the public API, providing comprehensive run information.
    • Access run metadata, per-stage status/attempts/validation and resolved evidence paths.
    • Includes approval blocker details, event counters, cost context, and compact run/pipeline summaries.
    • Pipeline state is persisted locally and can be regenerated when missing.
  • Tests
    • Added automated coverage for building, persisting/regenerating, and summarizing pipeline state.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@coderabbitai

coderabbitai Bot commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: fcaa9c61-d620-4d97-99bb-b06e30a46cd6

📥 Commits

Reviewing files that changed from the base of the PR and between 11288c4 and 10ec064.

📒 Files selected for processing (2)
  • src/core/harness/pipeline-state.js
  • tests/pipeline-state.test.js
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/pipeline-state.test.js
  • src/core/harness/pipeline-state.js

📝 Walkthrough

Walkthrough

Adds src/core/harness/pipeline-state.js, which reads SDLC run artifacts (manifest.json, tasks.json, metrics.json, approvals.json, events.jsonl, evidence.jsonl) and derives per-stage status, attempts, validation, approval blockers, and cost context. Exposes four functions (buildPipelineState, writePipelineState, readPipelineState, summarizePipelineState) re-exported from src/index.js, with a comprehensive test suite covering derivation, persistence, and regeneration.

Changes

Pipeline State Rollup

Layer / File(s) Summary
Helper utilities and stage derivation logic
src/core/harness/pipeline-state.js
Module-wide constants, path helpers, safe JSON/JSONL readers, stage evidence discovery, task/approval normalizers, status normalizers, and derivation logic for per-stage status, validation, attempts, event summarization, and approval blocker extraction.
Public API functions and entry-point export
src/core/harness/pipeline-state.js, src/index.js
buildPipelineState assembles the full state object from canonical stages and run artifacts; writePipelineState acquires a file lock and writes atomically; readPipelineState returns existing state or regenerates when missing; summarizePipelineState emits a compact summary. All four are re-exported from the library's public entry point.
Test suite: derivation, persistence, and regeneration
tests/pipeline-state.test.js
Scaffolds a temporary run directory with all fixture files (manifest, tasks, metrics, approvals, events, evidence, stage artifacts). Asserts derived schema version, current stage/task, stage ordering against CANONICAL_SDLC_STAGES, per-stage status/attempts/validation/evidence paths, retry/guardrail totals, approval blockers, cost context, and verifies atomic write and regenerateIfMissing behavior.

Sequence Diagrams

sequenceDiagram
  participant Harness as Harness Files
  participant Build as buildPipelineState
  participant Write as writePipelineState
  participant Lock as File Lock
  participant Output as pipeline-state.json
  Harness->>Build: manifest, tasks, metrics, events, approvals, evidence
  Build->>Build: normalize and derive per-stage fields
  Build->>Build: compute current stage/task and aggregates
  Build-->>Write: structured state object
  Write->>Lock: acquire advisory lock
  Lock-->>Write: lock acquired
  Write->>Output: writeJsonAtomic(state)
  Output-->>Write: confirmed write
  Write-->>Lock: release lock
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • richard-devbot/SDLC-rstack#103: This PR's writePipelineState uses the atomic write and advisory file-locking utilities (withFileLock, writeJsonAtomic) introduced in that PR.

Poem

🐇 Hoppity-hop through the run directory,
I gather each artifact, carefully!
Manifest, tasks, events in a line —
Pipeline status derived, looking fine.
Atomic writes locked with a fluffy paw,
No missing state shall break the law! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: add pipeline state rollup' clearly and concisely describes the main change: adding pipeline state rollup functionality as specified in issue #113.
Linked Issues check ✅ Passed The implementation fully meets all requirements from issue #113: exports all four required functions, reads all specified file types, stores pipeline-state.json in correct location, derives stage IDs from CANONICAL_SDLC_STAGES, includes all required data fields, uses withFileLock and writeJsonAtomic for atomic writes, and provides regenerateIfMissing capability.
Out of Scope Changes check ✅ Passed All changes are directly scoped to implementing the pipeline-state rollup feature: new module for state building/persistence, public API exports, and comprehensive unit tests validating the implementation.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/ble-1-pipeline-state-rollup-113

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/core/harness/pipeline-state.js`:
- Around line 159-160: The current stage detection in the find operation within
the code snippet only checks for events with a status field that matches
RUNNING_STATUSES, but it misses type-driven events like stage_started that don't
have a status field. Expand the condition in the find method to also check for
event types (such as checking if event.type equals stage_started or similar
running event types) in addition to the existing status check, so that events
without a status field can still be properly identified as running stages.
- Around line 235-237: The filter condition for the evidencePaths variable only
checks event.stage_id but legitimate events can use event.stage instead, causing
those events to be dropped from the evidence paths. Modify the filter logic in
the line that filters evidenceEvents to handle both event.stage_id and
event.stage properties when comparing against stage.id, ensuring all valid
evidence entries are included in the evidence-path derivation regardless of
whether they use stage or stage_id.
🪄 Autofix (Beta)

❌ Autofix failed (check again to retry)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 58b26ceb-69f6-49e1-9079-c77a7d8fefbc

📥 Commits

Reviewing files that changed from the base of the PR and between b2b9b53 and 11288c4.

📒 Files selected for processing (3)
  • src/core/harness/pipeline-state.js
  • src/index.js
  • tests/pipeline-state.test.js

Comment thread src/core/harness/pipeline-state.js Outdated
Comment thread src/core/harness/pipeline-state.js
@coderabbitai

coderabbitai Bot commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

⚠️ Branch updated during autofix.

The branch was updated while autofix was in progress. Please try again.

@richard-devbot richard-devbot merged commit 7dd082b into main Jun 27, 2026
8 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.

[BLE-1.1] Add Node-native pipeline-state rollup

2 participants