Skip to content

t2060: fix(task-complete-helper): move completed entries to ## Done instead of in-place marking#18760

Closed
alex-solovyev wants to merge 2 commits intomainfrom
feature/auto-20260414-012652
Closed

t2060: fix(task-complete-helper): move completed entries to ## Done instead of in-place marking#18760
alex-solovyev wants to merge 2 commits intomainfrom
feature/auto-20260414-012652

Conversation

@alex-solovyev
Copy link
Copy Markdown
Collaborator

Summary

  • complete_task() in task-complete-helper.sh now extracts the task block (parent + indented children) from its current section and inserts it at the top of ## Done instead of doing in-place sed substitution.
  • One-time retroactive cleanup: moved 561 completed [x] entries from ## Ready (3) and ## Backlog (558) to ## Done. Total [x] count unchanged at 804.
  • New test harness tests/test-task-complete-move.sh with 10 assertions covering 7 edge cases.

Changes

.agents/scripts/task-complete-helper.sh

  • Replaces sed -i in-place substitution (line 353) with a two-pass awk approach:
    • Pass 1: Finds the - [ ] TASKID line + indented children, writes transformed block to temp file, outputs file without the block.
    • Pass 2: Inserts the block at the top of ## Done (after its blank-line separator).
  • Added pre-check: errors out clearly when ## Done header is missing.
  • Added post-move verification: confirms the entry is now in ## Done section via awk.
  • All existing subtask guards, backup/restore, and proof-log validation preserved unchanged.

TODO.md

  • Retroactive cleanup: all 561 [x] entries from ## Ready and ## Backlog moved to ## Done.
  • Updated ## Ready section comment to reflect the fix.

.agents/scripts/tests/test-task-complete-move.sh (new)

10 test assertions covering:

  1. Single-line task → moves to Done
  2. Task with indented subtasks → children move with parent
  3. Task blocked by open subtasks → errors out, parent unchanged
  4. Task already in Done → idempotent warn+exit 0
  5. Task in ## In Progress → moves to Done
  6. ## Done header missing → errors out, file unchanged
  7. Multiple consecutive entries → block boundary doesn't bleed
  8. Proof-log and completed:DATE correctly appended to moved entry

Verification

shellcheck .agents/scripts/task-complete-helper.sh  # only pre-existing SC1091 info
shellcheck .agents/scripts/tests/test-task-complete-move.sh  # clean
bash .agents/scripts/tests/test-task-complete-move.sh  # 10/10 pass
awk '/^## Ready$|^## Backlog$/{f=1; next} /^## /{f=0} f && /^- \[x\]/' TODO.md | wc -l  # 0
grep -c '^- \[x\]' TODO.md  # 804 (unchanged)

Resolves #18746

… of in-place marking

Fixes t2060 / Resolves #18746.

Part 1 — Behavior change: replace the sed in-place substitution in
complete_task() (task-complete-helper.sh:353) with a two-pass awk
extract-and-move approach.  The function now:
  - Captures the parent task line + all indented children as a block
  - Transforms the parent line ([ ] -> [x], appends proof_log + completed:DATE)
  - Removes the block from its original location
  - Inserts the block at the top of the ## Done section
  - Verifies the move via post-edit grep + awk checks
  - Errors out clearly when ## Done header is missing
  - Preserves existing subtask guards, backup/restore, and proof-log
    validation logic unchanged

Part 2 — Retroactive cleanup: moved 561 completed [x] entries that had
accumulated in ## Ready (3 entries) and ## Backlog (558 entries) into
## Done via a one-time Python batch operation.
  - Total [x] count before = after = 804 (no entries lost or duplicated)
  - ## Ready and ## Backlog now contain zero [x] entries

Part 3 — Test harness: new tests/test-task-complete-move.sh with 10
assertions covering 7 edge cases:
  - Single-line task (no subtasks)
  - Task with indented subtasks (children move with parent)
  - Task blocked by open subtasks (cannot complete)
  - Task already in ## Done (idempotent)
  - Task in ## In Progress (moves to Done)
  - ## Done header missing (errors out clearly)
  - Multiple consecutive entries (block boundary doesn't bleed)
  - Proof-log + completed:date correctly appended
@alex-solovyev alex-solovyev added the origin:worker Auto-created by pulse labelless backfill (t2112) label Apr 13, 2026
@gemini-code-assist
Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@alex-solovyev
Copy link
Copy Markdown
Collaborator Author

Merge Summary

Task: t2060 — fix(task-complete-helper): move completed entries to ## Done

What was done:

  1. Replaced sed in-place substitution in complete_task() with a two-pass awk extract-and-move approach — task blocks now land at the top of ## Done instead of staying in their original section.
  2. Retroactive cleanup: moved 561 completed [x] entries from ## Ready (3) and ## Backlog (558) to ## Done. Total [x] count before = after = 804 — no entries lost.
  3. New test harness tests/test-task-complete-move.sh with 10 assertions covering 7 edge cases — all pass.

Verification:

  • shellcheck: pre-existing SC1091 info only (no new violations)
  • Tests: 10/10 pass
  • Zero [x] in Ready/Backlog: ✓
  • Total [x] count unchanged (804): ✓

Root cause fixed: task-complete-helper.sh:353 was doing sed -i in place, leaving completed entries in ## Ready/## Backlog indefinitely. The bot-review false premise on PR #18417 (Gemini reasoning about auto-generated sections) was caused by seeing completed entries in ## Ready.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 13, 2026

Warning

Rate limit exceeded

@alex-solovyev has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 41 minutes and 7 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 41 minutes and 7 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 42a54c0c-8b21-48a9-bd0c-ad79ac1d7837

📥 Commits

Reviewing files that changed from the base of the PR and between a228dca and 6d3f343.

📒 Files selected for processing (3)
  • .agents/scripts/task-complete-helper.sh
  • .agents/scripts/tests/test-task-complete-move.sh
  • TODO.md
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/auto-20260414-012652

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.

@github-actions github-actions bot added the bug Auto-created from TODO.md tag label Apr 13, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🔍 Code Quality Report

�[0;35m[MONITOR]�[0m Code Review Monitoring Report

SonarCloud: 0 bugs, 0 vulnerabilities, 226 code smells

Mon Apr 13 23:41:01 UTC 2026: Code review monitoring started
Mon Apr 13 23:41:02 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 226

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 226
  • VULNERABILITIES: 0

Generated on: Mon Apr 13 23:41:04 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

@codacy-production
Copy link
Copy Markdown

codacy-production bot commented Apr 13, 2026

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

TIP This summary will be updated as you push new changes. Give us feedback

…00-line gate

Main branch ratcheted FUNCTION_COMPLEXITY_THRESHOLD to 30 (PR #18755); the
initial complete_task() rewrite was 174 lines, pushing violations to 31.

Extract two helpers:
  _check_task_subtasks_open()  — 45 lines (moved subtask guard logic)
  _move_task_block_to_done()   — 60 lines (awk extract + insert passes)
  complete_task()              — 67 lines (thin orchestrator, was 174)

No behaviour change; all 10 test assertions still pass.
@github-actions
Copy link
Copy Markdown
Contributor

🔍 Code Quality Report

�[0;35m[MONITOR]�[0m Code Review Monitoring Report

SonarCloud: 0 bugs, 0 vulnerabilities, 228 code smells

Mon Apr 13 23:49:15 UTC 2026: Code review monitoring started
Mon Apr 13 23:49:15 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 228

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 228
  • VULNERABILITIES: 0

Generated on: Mon Apr 13 23:49:17 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

@sonarqubecloud
Copy link
Copy Markdown

@milohiss
Copy link
Copy Markdown
Contributor

Closing — this PR has merge conflicts with the base branch. The work for this task (t2060) has already landed on main (via PR #18749), so no re-attempt is needed.

Closed by deterministic merge pass (pulse-wrapper.sh, GH#17574).

1 similar comment
@alex-solovyev
Copy link
Copy Markdown
Collaborator Author

Closing — this PR has merge conflicts with the base branch. The work for this task (t2060) has already landed on main (via PR #18749), so no re-attempt is needed.

Closed by deterministic merge pass (pulse-wrapper.sh, GH#17574).

@marcusquinn
Copy link
Copy Markdown
Owner

Reopened — this PR was closed in error by the deterministic merge pass (pulse-merge.sh:_close_conflicting_pr).

The closer cited PR #18749 as having "already landed on main", but #18749 is a planning-only PR — it added todo/tasks/t2059-brief.md and todo/tasks/t2060-brief.md and made one TODO.md edit. No code change to task-complete-helper.sh was ever merged. Verified:

The branch feature/auto-20260414-012652 still exists on origin, so the implementation, test harness (10 assertions / 7 cases), and TODO.md cleanup are recoverable in full.

Root cause of the false closure: _close_conflicting_pr extracts the task ID from the conflicting PR's title and greps recent main commit subjects for that ID. PR #18749's commit subject was plan(t2059, t2060): file follow-ups... — the regex matched (, t2060) and the heuristic concluded the implementation had landed.

A framework fix for this false positive is being filed and shipped as an urgent patch release. Once the fix is in, this PR can be rebased and re-merged safely.

For #18746

@marcusquinn
Copy link
Copy Markdown
Owner

Closing — this PR has merge conflicts with the base branch. The work for this task (t2060) has already landed on main (via PR #18806), so no re-attempt is needed.

Closed by deterministic merge pass (pulse-wrapper.sh, GH#17574).

marcusquinn added a commit that referenced this pull request Apr 14, 2026
…icting worker PRs

The deterministic merge pass closed PR #18760 with a false 'work has
already landed on main' claim, citing PR #18749 as the merging PR.
PR #18749 was a planning-only PR (added briefs, modified TODO.md) —
it touched zero implementation files. The closing PR's task ID
appeared in #18749's commit subject ('plan(t2059, t2060): file
follow-ups...') and the task-ID grep matched, but no implementation
work had landed.

Fix: require non-planning file overlap between the closing PR and
the matching commit before claiming 'work landed on main'. On
overlap miss OR file-lookup failure, fail CLOSED — leave the PR
open and post a one-time rebase nudge instead of discarding work.

Three new helpers:
- _is_planning_path_for_overlap: classifies TODO.md, README.md,
  CHANGELOG.md, VERSION, todo/**, and simplification-state.json as
  planning paths that cannot satisfy the duplicate-work signal.
- _verify_pr_overlaps_commit: fetches the closing PR's files and
  the matching commit's files, returns 0 only on non-planning
  intersection; returns 1 on lookup failure (fail-CLOSED).
- _post_rebase_nudge_on_worker_conflicting: idempotent rebase nudge
  modelled on _post_rebase_nudge_on_interactive_conflicting,
  posted exactly once per affected worker PR.

Refactored _close_conflicting_pr to fetch (sha, subject) JSON
from gh api commits and use jq for word-boundary matching, so
the matching commit's files can be looked up by SHA.

Test coverage: extends test-close-conflicting-pr-wording.sh from 3
to 7 assertions covering 4 new GH#18815 regressions:
- Planning-only match leaves PR open (the #18760 incident exactly)
- Real implementation overlap still closes PR
- commit-files lookup failure → fail-CLOSED
- PR-files lookup failure → fail-CLOSED
marcusquinn added a commit that referenced this pull request Apr 14, 2026
…icting worker PRs (#18820)

The deterministic merge pass closed PR #18760 with a false 'work has
already landed on main' claim, citing PR #18749 as the merging PR.
PR #18749 was a planning-only PR (added briefs, modified TODO.md) —
it touched zero implementation files. The closing PR's task ID
appeared in #18749's commit subject ('plan(t2059, t2060): file
follow-ups...') and the task-ID grep matched, but no implementation
work had landed.

Fix: require non-planning file overlap between the closing PR and
the matching commit before claiming 'work landed on main'. On
overlap miss OR file-lookup failure, fail CLOSED — leave the PR
open and post a one-time rebase nudge instead of discarding work.

Three new helpers:
- _is_planning_path_for_overlap: classifies TODO.md, README.md,
  CHANGELOG.md, VERSION, todo/**, and simplification-state.json as
  planning paths that cannot satisfy the duplicate-work signal.
- _verify_pr_overlaps_commit: fetches the closing PR's files and
  the matching commit's files, returns 0 only on non-planning
  intersection; returns 1 on lookup failure (fail-CLOSED).
- _post_rebase_nudge_on_worker_conflicting: idempotent rebase nudge
  modelled on _post_rebase_nudge_on_interactive_conflicting,
  posted exactly once per affected worker PR.

Refactored _close_conflicting_pr to fetch (sha, subject) JSON
from gh api commits and use jq for word-boundary matching, so
the matching commit's files can be looked up by SHA.

Test coverage: extends test-close-conflicting-pr-wording.sh from 3
to 7 assertions covering 4 new GH#18815 regressions:
- Planning-only match leaves PR open (the #18760 incident exactly)
- Real implementation overlap still closes PR
- commit-files lookup failure → fail-CLOSED
- PR-files lookup failure → fail-CLOSED
@marcusquinn
Copy link
Copy Markdown
Owner

Final resolution — work is preserved, fix is shipped, system self-validated.

This PR is now legitimately closed because the t2060 implementation actually landed via PR #18806 (a fresh re-implementation by a parallel worker session, merged at 2026-04-14T02:51:03Z). The current closing comment cites #18806, not the original false-positive #18749, because the deterministic merge pass re-ran AFTER the GH#18815 fix landed and correctly verified file overlap this time.

End-to-end timeline:

  1. PR t2060: fix(task-complete-helper): move completed entries to ## Done instead of in-place marking #18760 closed in error citing planning PR plan(t2059, t2060): file follow-ups from GH#18538 worker-is-triager session #18749 (the original false positive that surfaced this bug)
  2. Issue bug: _close_conflicting_pr auto-closes implementation PRs when a planning PR with the same task ID has merged #18815 filed — _close_conflicting_pr false-positive bug
  3. PR GH#18815: fix(pulse-merge): file-overlap verification before auto-closing conflicting worker PRs #18820 merged the fix (file-overlap verification + fail-CLOSED on lookup errors) and shipped in v3.8.19
  4. PR t2060: fix(task-complete-helper): move completed entries from Ready/Backlog to Done #18806 re-implemented t2060 on a fresh branch (parallel worker session) and merged
  5. The deterministic merge pass ran one more cycle on t2060: fix(task-complete-helper): move completed entries to ## Done instead of in-place marking #18760, fetched commit subjects, found t2060 in t2060: fix(task-complete-helper): move completed entries from Ready/Backlog to Done #18806's subject, fetched the matching commit's files (.agents/scripts/task-complete-helper.sh + .agents/scripts/tests/test-task-complete-move.sh), verified overlap with this PR's files, and closed correctly.

The current "Closed by deterministic merge pass" comment is the FIXED behaviour: cites the real implementation PR #18806, not the planning PR. No value lost — t2060 is on main, the framework bug that wrongly closed this PR is fixed in v3.8.19, and the regression test (test-close-conflicting-pr-wording.sh::test_no_close_when_matching_commit_only_touches_planning_files) reproduces this exact incident as a permanent guard.

For #18746


aidevops.sh v3.8.20 plugin for OpenCode v1.4.3 with claude-opus-4-6 spent 30m and 69,534 tokens on this with the user in an interactive session.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Auto-created from TODO.md tag origin:worker Auto-created by pulse labelless backfill (t2112)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

t2060: fix(task-complete-helper): move completed entries from ## Ready to ## Done instead of in-place [x] marking

3 participants