feat: Task Close Gate + HEUREKA Completion Sequence for state-hub projects

workplan-spec.md:
- Task Close Gate: when marking a task done in the file, also call
  update_task_status(state_hub_task_id, "done") in the State Hub
- HEUREKA Completion Sequence: before HEUREKA, for hub-integrated workplans:
  update all tasks, update_workstream_status → done, add_progress_event
  milestone, then set status: done and output HEUREKA

plugin/ralph-workplan.md:
- Added State-Hub Integration Notes section injected via stop-hook prompt
  so the worker follows Task Close Gate and HEUREKA Completion Sequence

Resolves: state-hub progress event 1e73441e (2026-03-16)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-16 08:06:11 +00:00
parent 2fb2bb5cb8
commit 9d57ce430f
2 changed files with 63 additions and 0 deletions

View File

@@ -74,3 +74,27 @@ Then report:
> "🔄 Ralph loop active. The loop will feed the workplan prompt back on every
> iteration. It retires when all tasks are done and the workplan status is
> updated to 'done' in the file."
## State-Hub Integration Notes
These notes are injected into the stop-hook prompt so the worker follows the
correct conventions when working on state-hub-integrated workplans.
**Task Close Gate** — When marking a task `done` in the workplan file, if the
task block has a `state_hub_task_id` field, also call `update_task_status` on
that ID in the State Hub. Do this at the same time as editing the file, not
in a batch at the end.
**HEUREKA Completion Sequence** — Before outputting `<promise>HEUREKA</promise>`,
if the workplan frontmatter has `state_hub_workstream_id`:
1. Ensure all `state_hub_task_id` tasks are marked `done` in the hub
(`update_task_status` — idempotent)
2. Call `update_workstream_status(state_hub_workstream_id, "done")`
3. Call `add_progress_event(summary="<what was delivered>", event_type="milestone",
topic_id="<from CLAUDE.md>", workstream_id="<state_hub_workstream_id>")`
4. Set workplan frontmatter `status: done`
5. Output `<promise>HEUREKA</promise>`
If the workplan has no `state_hub_workstream_id`, skip all hub calls and go
straight to steps 45.