Skip to content

fix: improve handoff accuracy and add roadmap validation#25

Merged
pertrai1 merged 2 commits into
mainfrom
fix/forge-loop-handoff-drift
Apr 4, 2026
Merged

fix: improve handoff accuracy and add roadmap validation#25
pertrai1 merged 2 commits into
mainfrom
fix/forge-loop-handoff-drift

Conversation

@pertrai1

@pertrai1 pertrai1 commented Apr 4, 2026

Copy link
Copy Markdown
Owner

Summary

Changes

scripts/forge-helper.sh (+205 lines)

Issue #21 fixes:

  • _detect_wave_for_package() — scans root ROADMAP.md wave tables to find which wave a package+phase belongs to
  • _advance_next_phase_context() — rewrites the Next Phase Context section in HANDOFF.md by finding the next incomplete phase
  • Enhanced cmd_update_handoff() — populates Completed Work table via awk insertion, removes (none yet) placeholder, auto-advances Next Phase Context, includes wave labels in entries

Issue #22 fixes:

  • cmd_validate_roadmap() — scans ROADMAP for checked tasks with [deliverable: \path`]`, verifies each path exists on disk
  • Skips non-path deliverables (descriptive text) and multi-path deliverables (comma-separated)
  • Registered in header, show_usage(), and main() dispatch

packages/telemetry/ROADMAP.md

  • Phase 1 tasks marked [x] (was [ ]), header updated to (COMPLETE)

ROADMAP.md

  • Wave 1 telemetry Phase 1 status → "Complete"
  • Current State Summary updated for telemetry progress

Testing

  • bash -n syntax check passes
  • validate-roadmap --package telemetry → 4/4 deliverable paths valid ✅
  • validate-roadmap --package pipeline → correctly detects 4 drifted paths (real refactoring drift)
  • validate-roadmap --package mcp → correctly detects 25 drifted paths (structure diverged from original ROADMAP)
  • update-handoff manually tested: Completed Work insertion ✅, placeholder removal ✅, phase auto-advance ✅
  • npx nx affected -t build,test,lint → all pass (33 tests, 0 lint errors)

Not included (deferred)

Closes #21
Partially addresses #22

Summary by CodeRabbit

  • New Features

    • Added roadmap validation to verify completed deliverables reference existing resources.
    • Enhanced handoff generation with automated phase context updates and wave tracking.
  • Documentation

    • Updated project roadmap: top-level progress now shows Phase 0–1 complete, Phase 2–5 remaining.
    • Marked Phase 1 (Storage) complete and re-scoped telemetry phases (Phase 0–1); set Phase 2 as ready to start.
    • Adjusted immediate priority window to Telemetry Phases 2–4.

- Fix cmd_update_handoff() to populate Completed Work table, remove
  (none yet) placeholder, and auto-advance Next Phase Context
- Add _detect_wave_for_package() to find wave labels from root ROADMAP
- Add _advance_next_phase_context() to auto-fill next phase target/goal
- Add validate-roadmap command to check deliverable paths exist on disk
- Mark telemetry Phase 1 complete in both per-package and root ROADMAPs

Closes #21, partially addresses #22
@coderabbitai

coderabbitai Bot commented Apr 4, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Updates roadmap files to mark telemetry Phase 1 (Storage) complete and adjust critical-path phrasing; adds a validate-roadmap CLI subcommand and new helpers in scripts/forge-helper.sh to validate deliverable paths, populate the HANDOFF.md "Completed Work" table, and auto-advance the "Next Phase Context".

Changes

Cohort / File(s) Summary
Root & Package Roadmaps
ROADMAP.md, packages/telemetry/ROADMAP.md
Marked Phase 0–1 complete (Phase 1 storage tasks checked), adjusted Wave 1 phrasing and immediate priority window to Phases 2–4.
Forge helper script
scripts/forge-helper.sh
Added validate-roadmap subcommand; introduced _detect_wave_for_package() and _advance_next_phase_context() helpers; updated cmd_update_handoff() to populate "Completed Work", auto-advance ## Next Phase Context, and include wave label in changelog; updated CLI help and dispatcher.

Sequence Diagram(s)

sequenceDiagram
  participant CLI as CLI (`forge-helper.sh`)
  participant ROADMAP as ROADMAP.md (root or packages/...)
  participant FS as Filesystem (deliverable paths)
  participant HANDOFF as HANDOFF.md

  CLI->>ROADMAP: read selected ROADMAP.md
  CLI->>FS: validate checked deliverable backticked paths
  alt any missing path
    FS-->>CLI: missing path -> exit non-zero
  else all exist
    FS-->>CLI: OK
    CLI->>ROADMAP: determine wave/phase via _detect_wave_for_package
    CLI->>HANDOFF: update "Completed Work" table (insert row if absent)
    CLI->>HANDOFF: _advance_next_phase_context -> rewrite Next Phase Context
    HANDOFF-->>CLI: write complete
    CLI-->>CLI: append changelog entry with wave_label
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related issues

Possibly related PRs

Poem

🐰 I hopped through checkboxes, one by one,
Found deliverables, made sure none were undone.
I nudged the handoff, wrote what’s complete,
Now the roadmap and handoff finally meet.
A little hop, a tidy trail—automation done!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.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 accurately summarizes the main changes: fixing handoff accuracy issues and adding roadmap validation, which are the two primary focuses of the PR.
Linked Issues check ✅ Passed The PR successfully addresses Issue #21 objectives: cmd_update_handoff() now populates Completed Work table, auto-advances Next Phase Context, and detects wave labels. The roadmap validation (Issue #22) is implemented via cmd_validate_roadmap() and validates deliverable paths exist.
Out of Scope Changes check ✅ Passed All changes are scoped to the linked issues: ROADMAP bookkeeping updates reflect Phase 1 completion, forge-helper.sh adds the required functionality, and no unrelated modifications are present.

✏️ 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 fix/forge-loop-handoff-drift

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.

❤️ Share

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

@nx-cloud

nx-cloud Bot commented Apr 4, 2026

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit abfae6b

Command Status Duration Result
nx run-many -t lint test build typecheck ✅ Succeeded <1s View ↗
nx-cloud record -- npx nx format:check --base=r... ✅ Succeeded 3s View ↗

☁️ Nx Cloud last updated this comment at 2026-04-04 15:44:27 UTC

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
scripts/forge-helper.sh (1)

792-812: Consider deduplication of Completed Work entries.

The awk script inserts a new row after the last table line without checking if this phase was already recorded. If update-handoff is called multiple times for the same phase, duplicate rows will appear.

This may be acceptable if the workflow guarantees single invocation per phase, but you could add a guard:

Optional: Skip insertion if phase already recorded
+  # Check if this phase is already recorded
+  if grep -qE "^\| ${wave_label} \| ${pkg_label} \| Phase ${phase} \|" "$handoff_file" 2>/dev/null; then
+    log "Phase ${phase} already recorded in Completed Work — skipping"
+  else
    local cw_row="| ${wave_label} | ${pkg_label} | Phase ${phase} | ${phase_title} |"
    awk -v row="$cw_row" '
      /^## Completed Work/ { in_cw=1 }
      in_cw && /^\|/ { last_table_line=NR }
      in_cw && /^---$/ { in_cw=0 }
      { lines[NR]=$0 }
      END {
        for (i=1; i<=NR; i++) {
          print lines[i]
          if (i == last_table_line) print row
        }
      }
    ' "$handoff_file" > "${handoff_file}.tmp" && mv "${handoff_file}.tmp" "$handoff_file"
+  fi
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@scripts/forge-helper.sh` around lines 792 - 812, The awk insertion
unconditionally appends cw_row and can create duplicates when update-handoff
runs multiple times; modify the logic that builds/prints the table (the awk
block that uses cw_row and reads "$handoff_file") to first scan the table for an
existing matching row (compare full trimmed line to cw_row or match a regex
using ${pkg_label} and "Phase ${phase}") and set a flag (e.g., found_existing)
so the END block only prints cw_row if not found; alternatively perform a
pre-check using grep for the pattern and skip the awk insertion entirely when a
match exists; keep references to cw_row, the awk block, _detect_wave_for_package
and handoff_file when applying the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@scripts/forge-helper.sh`:
- Around line 792-812: The awk insertion unconditionally appends cw_row and can
create duplicates when update-handoff runs multiple times; modify the logic that
builds/prints the table (the awk block that uses cw_row and reads
"$handoff_file") to first scan the table for an existing matching row (compare
full trimmed line to cw_row or match a regex using ${pkg_label} and "Phase
${phase}") and set a flag (e.g., found_existing) so the END block only prints
cw_row if not found; alternatively perform a pre-check using grep for the
pattern and skip the awk insertion entirely when a match exists; keep references
to cw_row, the awk block, _detect_wave_for_package and handoff_file when
applying the change.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d7374327-e851-4354-b846-426c9fee33bc

📥 Commits

Reviewing files that changed from the base of the PR and between f132edb and 311bd12.

📒 Files selected for processing (3)
  • ROADMAP.md
  • packages/telemetry/ROADMAP.md
  • scripts/forge-helper.sh

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 311bd127f2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/forge-helper.sh Outdated
Comment thread scripts/forge-helper.sh Outdated
- P2: add word boundary to phase regex in _detect_wave_for_package()
  to prevent Phase 1 from matching Phase 10
- P1: extract and validate ALL backticked paths in multi-path
  deliverables instead of skipping comma-separated entries
- Dedup: guard against duplicate Completed Work entries in
  cmd_update_handoff() when called multiple times for same phase
- Bonus: fix BSD sed compatibility for task_id extraction (\s → [[:space:]])

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
scripts/forge-helper.sh (1)

805-817: Minor edge case: awk row insertion relies on last_table_line being set.

If the "## Completed Work" section has no table rows (only headers), last_table_line would be set to the header row line, which should still work correctly. However, if the section is malformed or missing entirely, the row insertion silently fails.

This is likely acceptable given HANDOFF.md is initialized from a template, but consider adding a warning if no insertion occurred.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@scripts/forge-helper.sh` around lines 805 - 817, The current awk insertion
may silently do nothing if the "## Completed Work" section is missing or
malformed; after running the awk/mv block that tries to insert cw_row into
handoff_file, add a post-check that verifies the row was actually inserted (for
example: grep -Fq "$cw_row" "$handoff_file") and if the check fails print a
warning to stderr (echo >&2) explaining insertion did not occur and include
handoff_file and cw_row in the message; use the existing variables cw_row and
handoff_file so you locate the code near the awk block and keep the shell exit
status unchanged (only emit a warning).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@scripts/forge-helper.sh`:
- Around line 805-817: The current awk insertion may silently do nothing if the
"## Completed Work" section is missing or malformed; after running the awk/mv
block that tries to insert cw_row into handoff_file, add a post-check that
verifies the row was actually inserted (for example: grep -Fq "$cw_row"
"$handoff_file") and if the check fails print a warning to stderr (echo >&2)
explaining insertion did not occur and include handoff_file and cw_row in the
message; use the existing variables cw_row and handoff_file so you locate the
code near the awk block and keep the shell exit status unchanged (only emit a
warning).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 57fb0f9c-d4f1-47a9-904e-c5798f1fe549

📥 Commits

Reviewing files that changed from the base of the PR and between 311bd12 and abfae6b.

📒 Files selected for processing (1)
  • scripts/forge-helper.sh

@pertrai1
pertrai1 merged commit 00259a2 into main Apr 4, 2026
3 checks passed
@pertrai1
pertrai1 deleted the fix/forge-loop-handoff-drift branch April 4, 2026 16:15
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.

fix(forge-loop): HANDOFF.md doesn't auto-advance phase context or populate completed work

1 participant