feat(task-loop): new skill for in-session board draining v0.1.0

Interactive claim -> work -> close -> repeat loop in the current session;
no daemon, no spawned claude, no busy-poll. Coordinates with using-tasks
(.tasks/.lock, session_break gate, 10-min claim TTL -> tasks_heartbeat) and
project-discipline (push Rule 4, sensitive artifacts).

TDD (writing-skills RED-GREEN-REFACTOR):
- RED: 2 clean-context subagents revealed gaps A-E (claim scope, missed
  session_break + .lock, consult-gate boundary, paused-vs-blocked).
- GREEN: SKILL.md addresses all five; compliance subagent B clean.
- REFACTOR: closed CronCreate loophole in long-watch (separate session =
  daemon); mandate ScheduleWakeup on this session. Re-test passed.

Semver: 0.1.0 (initial).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-11 17:33:35 +03:00
parent 9168a14ab7
commit 0016c458d1
2 changed files with 162 additions and 0 deletions

45
.tasks/task-loop-skill.md Normal file
View File

@@ -0,0 +1,45 @@
# task-loop-skill
## Goal
Write a new skill `task-loop` for interactive Claude Code sessions: the agent in an open
session claims tasks from the board and works them one-by-one **in that same session**
no separate daemon, no spawned claude processes. Empty queue → stop and report (never
busy-poll). The skill must coordinate with `using-tasks` v1.4.0 (session `.tasks/.lock`,
`session_break` gate, 10-min claim TTL → `tasks_heartbeat`) and `project-discipline`
(push-gate Rule 4, sensitive artifacts).
## Key files
- `skills/task-loop/SKILL.md` — the deliverable (to be created)
- `skills/using-tasks/SKILL.md:120-179` — session-lock guard + session-break + completion gates the loop must honor
- `skills/project-discipline/SKILL.md` — push Rule 4, sensitive-artifact gates
- `skills/delegate-task/SKILL.md` — sibling task-system skill (style reference)
- projects-meta tools: `tasks_claim_next` (returns slug/weight/claim_token/consult_policy), `tasks_close`, `tasks_update`, `tasks_heartbeat`
## Decisions log
Reverse-chronological. Append-only.
- 2026-06-11: **RED baseline run** (2 clean-context subagents, dry-run, no live tools). Finding: ecosystem already produces mostly-correct behavior (no busy-wait on empty, pointed heartbeat, parks blocked tasks, push only on grant). Real gaps the skill must close: (A) **claim scope diverged** — agent-1 used `filter={}` cross-federation, agent-2 `{project:current}`; (B) **both missed session-break gate** between tasks; (C) **both ignored `.tasks/.lock`**; (D) **autonomy vs sensitive-gate boundary unclear** — agent-1 injected an unasked confirmation stop on a CI task; (E) **paused vs blocked** — spec said paused, agent-2 chose `blocked` for an external blocker (more correct).
- 2026-06-11: Design resolutions (recommend-don't-menu, no user objection to proposal):
- Scope default = **current project** (`filter={project:<current>}`); multi-project only via explicit arg / POLLER_PROJECTS.
- Autonomy gate via **`consult_policy`** from claim: `auto`→full autopilot; `human-only`/`strict-human`→do the work but STOP before the irreversible step (commit/close) to consult. `weight:needs-human` never reaches the loop (server excludes from autonomous claim). Push never automatic (project-discipline Rule 4).
- Failed task: external/unresolvable blocker → `tasks_update status=blocked` + blocker note (frees claim, don't leave hanging, don't `close`, roll back partial work); interrupted/resumable-by-me → `status=paused`. (Refines acceptance #3 literal "paused".)
- Empty queue → STOP + report. `ScheduleWakeup` ONLY on explicit "работай пока не скажу стоп", interval ≥1200s.
- session-break: after each close, BEFORE next claim, honor `using-tasks` session_break marker → STOP. Loop delegates this gate, doesn't reimplement.
- Heartbeat: single task expected >~8 min → `tasks_heartbeat(slug, claim_token)`.
## Open questions
- [x] Sensitive-task confirmation driven by `consult_policy` (the contract) + project-discipline push-gate for the riskiest step — NO blanket overlay. Resolved: compliance test B confirmed the `human-only` gate stops before close/commit correctly; push stays ask-mode regardless. consult_policy=auto means autopilot through close (push still needs a grant).
## Completed steps
- [x] Claimed task (meta status=active, commit 9168a14), synced local
- [x] Read mandatory skills: writing-skills, test-driven-development
- [x] Recon: skills/ layout, heartbeat refs, using-tasks session-lock section, claim/close tool schemas
- [x] RED baseline: 2 subagents, gaps AE documented above
- [x] GREEN: wrote skills/task-loop/SKILL.md v0.1.0 (desc trimmed of workflow summary per CSO rule)
- [x] GREEN compliance: 2 subagents. B (blocked/consult/break) PERFECT — all gaps AE fixed (scope=current, human-only→stop-before-close, session_break halts drain, external→blocked not close, empty→stop). A (scope/empty/watch) clean EXCEPT chose CronCreate for long-watch → loophole.
- [x] REFACTOR: long-watch carve-out reworded to mandate ScheduleWakeup (same session) and forbid CronCreate (separate session=daemon) always; core/What-NOT/red-flags aligned. Re-test PASSED — agent picks ScheduleWakeup 1800s, rejects CronCreate with correct reasoning.
- [x] Acceptance 1-6 all met (see commit). TDD cycle RED→GREEN→REFACTOR complete.
## Notes
- `heartbeat-side-channel` skill referenced in acceptance #4 does NOT exist — resolved by documenting `tasks_heartbeat` usage directly.
- Installed `~/.claude/skills/using-tasks` appears older than repo source (no session-lock) — deployment gap, not this task's concern. Write the skill against the repo source (v1.4.0).
- Notify target on close: OpeItcLoc03/workshop.