# VERDICT: add-goal-mode **Status: PASS** Task delivers goal-oriented loop extensions: work-source dispatch (`single`/`audit`/`backlog`), verifier prompt token plumbing (`{task_brief}`, `{acceptance_criteria}`, `{next_hint}`), `next_hint` feedback loop closure, `--audit --json` machine-readable mode, and ci-triage template updates. All changes are in `scripts/loop-runner.py`, `scripts/status.py`, `templates/loops/ci-triage/loop.json`, and `tests/test_goal_mode.py`. ## Requirement coverage | Req | Status | Tests | |-----|--------|-------| | R1 find_work dispatch | delivered | TestFindWorkDispatch (3) | | R2 audit work_source | delivered | TestAuditWorkSource (4) | | R3 backlog work_source | delivered | TestBacklogWorkSource (3) | | R4 verifier tokens | delivered | TestVerifierTokens (4) | | R5 _truncate_tokens | delivered | TestTruncateTokens (3) | | R6 next_hint feedback loop | delivered | TestNextHintFeedback (2) | | R7 loop.json schema additions | delivered | TestLoopJsonSchemaAdditions (3) | | R8 --audit --json | delivered | TestAuditJson (3) | | Regression backward compat | delivered | TestRegressionBackwardCompat (1) | Tests: 26 new. Full suite: **354 passed** (was 328 + 26 new). No regressions. ## Goal-mode loop closure - **Work discovery**: `single` (unchanged), `audit` (highest-severity violation), `backlog` (top unchecked BACKLOG.md item). Missing/unknown falls back to `single` with WARNING. - **Goal injection**: `{task_brief}` from RESEARCH/DESIGN/SPEC.md, `{acceptance_criteria}` from loop.json, `{next_hint}` from last verdict -- all truncated and fed to both Implement and Verify roles. - **Feedback loop**: tick N's verifier `next_hint` becomes tick N+1's `{next_hint}` context. First tick / post-approve: empty string (no KeyError). - **Audit integration**: `--audit --json` produces the violation list the `audit` work source consumes. Self-healing: violations without tasks trigger `--create-task`. ## Defense against loop death modes -- unchanged The runner's brake enforcement is unchanged from task 3. Goal-mode additions are purely additive to the work-discovery and token-substitution layers; they do not touch gate logic, state-write atomicity, or halt semantics. The `no_work` skip reason is a clean scheduler exit (exit 0, no state advance) -- same pattern as `no_current_task`. ## Agnosticism preserved - **Harness-agnostic**: new tokens are substitution placeholders in `harness.command`; only active when the operator's command template includes them. Default command unchanged. - **OS-agnostic**: no platform-specific code added. `--audit --json` is pure Python. - **Model-agnostic**: runner still never inspects model size/provider. Goal tokens are text content, not model directives. ## Doc impact landed - `CHANGELOG.md` `[unreleased]` entry for `add-goal-mode` (test counts updated to actual). - `design/loops/technical.md` schema section already documents `work_source` and `acceptance_criteria`. - `design/loops/functional.md` already documents the fields. - `templates/loops/ci-triage/loop.json` updated with explicit fields. No code-doc mismatches. ## Hardening items deferred (tracked in BUG_REPORT + ADVERSARIAL_BUG_REPORT) 1. `work_source.area` path-traversal validation (A3) -> v1.1 defense-in-depth. 2. `current_task` from audit JSON path-traversal validation (A5) -> v1.1 defense-in-depth. 3. `_truncate_tokens` marker edge case with tiny budgets (O5) -> v1.1. All three are explicit follow-ups; none block this task. ## Resolution **PASS -- proceed to `complete`.** Task 4 closes the goal-oriented loop on the runner side. With work-source dispatch, acceptance-criteria injection, and next_hint feedback, the runner can now drive loops that discover their own work (audit/backlog) and improve across ticks. Remaining tasks: 5 (blast-radius-scheduler), 6 (templates-onboarding), 7 (self-improvement-loop), 8 (install-update-flow), 9 (move-completed-tasks).