Repository navigation
feat: Implement pending_corrections: heartbeat comment poll + finalize gate (item #269's proposal) - #756
Merged
Conversation
Implemented the mechanism from `docs/superpowers/plans/2026-09-17-mid-flight-item-correction-detection.md` (item #269) in `src/work_item_pipeline.rs`: 1. **`WorkItemData::pending_corrections: Vec<String>`** and **`last_seen_comment_at: i64`** — new persisted fields (both `#[serde(default)]` for backward-compat deserialization of older runs). 2. **Heartbeat-tick poll** (`poll_pending_corrections`) — piggybacks on the existing 300s heartbeat in `run_or_resume_with_sender`'s outer loop. Lists item comments via `comment_impl(action="list")`, keeps ones newer than the cursor and not authored by the run's own `owner` identity, and writes them via `StateStore::update` (the same load-mutate-write-under-lock primitive the engine itself uses), so it races safely against an in-flight step — worst case a write is lost to a step's completion overwrite and gets re-detected on the next tick (an explicitly accepted tradeoff in the plan doc). 3. **Per-task-turn consumption** in `build_sdd_loop_step` — prepends any pending corrections to the next role prompt as a labeled note, then clears them. 4. **Finalize gate** in `build_finalize_step` — if a correction is still pending right before `item_done`, it's treated like `hold_reason`: release the claim, post an on-hold comment quoting the correction, skip `item_done`/PR-open. Seeded `last_seen_comment_at` to run-start time on fresh dispatch (resumed runs keep their persisted cursor). **Tests added** (4 new, all passing): prompt-prepend + clear behavior, no-op when nothing pending, finalize hold-gate (verifies `pr_url` stays `None` and the hold comment quotes the correction), and `poll_pending_corrections`'s author/cursor filtering against a real SQLite-backed engine + comment DB. **Verification**: `cargo build` clean; `cargo test -p agentflare --bin agentflare work_item_pipeline` → 104 passed, 0 failed, 2 pre-existing ignores (unrelated); `cargo clippy --tests` clean (zero warnings touching `work_item_pipeline`); `rustfmt --edition 2024` applied to all changed files (plain `cargo fmt -- <paths>` misdetects edition when given explicit file args — pre-existing repo quirk, not a regression). **Concerns**: The plan's two "open questions" (handoff-onto-claimed-item not surfacing through this channel, and whether a correction should force-reopen an already-approved judge decision) are explicitly left as follow-ups in the doc and are out of scope here — not implemented. Agentflare-Branch: task/270-implement-pending-corrections-heartbeat Agentflare-Item: 270
|
Warning Review limit reachedNext included review available in 10 minutes. View limit detailsLimit details: You’ve used all 3 included reviews currently available. Your 47 included PR review attempts over the past 7 days set your current allowance at 3 reviews per hour. Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. Review configuration: ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Essentials Run ID: 📒 Files selected for processing (3)
Comment |
getappz
deleted the
task/270-implement-pending-corrections-heartbeat
branch
September 17, 2026 08:02
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implemented the mechanism from
docs/superpowers/plans/2026-09-17-mid-flight-item-correction-detection.md(item #269) insrc/work_item_pipeline.rs:WorkItemData::pending_corrections: Vec<String>andlast_seen_comment_at: i64— new persisted fields (both#[serde(default)]for backward-compat deserialization of older runs).poll_pending_corrections) — piggybacks on the existing 300s heartbeat inrun_or_resume_with_sender's outer loop. Lists item comments viacomment_impl(action="list"), keeps ones newer than the cursor and not authored by the run's ownowneridentity, and writes them viaStateStore::update(the same load-mutate-write-under-lock primitive the engine itself uses), so it races safely against an in-flight step — worst case a write is lost to a step's completion overwrite and gets re-detected on the next tick (an explicitly accepted tradeoff in the plan doc).build_sdd_loop_step— prepends any pending corrections to the next role prompt as a labeled note, then clears them.build_finalize_step— if a correction is still pending right beforeitem_done, it's treated likehold_reason: release the claim, post an on-hold comment quoting the correction, skipitem_done/PR-open.Seeded
last_seen_comment_atto run-start time on fresh dispatch (resumed runs keep their persisted cursor).Tests added (4 new, all passing): prompt-prepend + clear behavior, no-op when nothing pending, finalize hold-gate (verifies
pr_urlstaysNoneand the hold comment quotes the correction), andpoll_pending_corrections's author/cursor filtering against a real SQLite-backed engine + comment DB.Verification:
cargo buildclean;cargo test -p agentflare --bin agentflare work_item_pipeline→ 104 passed, 0 failed, 2 pre-existing ignores (unrelated);cargo clippy --testsclean (zero warnings touchingwork_item_pipeline);rustfmt --edition 2024applied to all changed files (plaincargo fmt -- <paths>misdetects edition when given explicit file args — pre-existing repo quirk, not a regression).Concerns: The plan's two "open questions" (handoff-onto-claimed-item not surfacing through this channel, and whether a correction should force-reopen an already-approved judge decision) are explicitly left as follow-ups in the doc and are out of scope here — not implemented.
Opened by
claude-codeon flared:51bb8de6c33b for item #270 via agentflare.