Skip to content

fix: keep goals active through permission blockers - #13000

Closed
rubencu wants to merge 2 commits into
kirodotdev:mainfrom
rubencu:fix/goal-permission-blocker-keeps-running
Closed

rubencu wants to merge 2 commits into
kirodotdev:mainfrom
rubencu:fix/goal-permission-blocker-keeps-running

Conversation

@rubencu

@rubencu rubencu commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

An autonomous /goal could identify a fixable missing permission, name the owning configuration change, and then stop its own AutoNudge loop as “blocked.” The same work succeeded when resumed manually, proving the blocker was remediation work rather than a terminal outcome.

Why it matters

Autonomous goals lose continuity exactly when they should investigate and repair dependencies. A person must notice the stopped loop, repeat the instruction, and manually restart work even when the agent is allowed to make a least-privilege fix. Human-only approvals should be reported and rechecked, not silently retire the goal.

What changed (motivation → approach → change)

The root cause was inconsistent contracts across src/kiro_crew/config/prompt.md, src/kiro_crew/dashboard/chat_runner.py, src/kiro_crew/mcp_tools/control.py, and skills/self-nudge-loop/SKILL.md: generic blockers were treated as stop conditions. Those surfaces now classify missing permissions, credentials, configuration, dependencies, and failing commands as remediation work, while preserving completion, explicit user stop, STOP sentinels, unrecoverable host failures, and finite budgets as legitimate endings. They also state that remediation never means granting the agent approvals/permissions, weakening approval policy, or editing governance controls.

The runtime in src/kiro_crew/autonudge.py now makes that contract real. Prompt/goal loops durably consume unanswered-approval evidence before publishing another cycle, retain and retry evidence when persistence fails, and grant gated loops one follow-up tick so a QUIET probe cannot suppress remediation. Typed structured monitors still record an undeliverable accepted action as approval_stall on MonitorState; pre-upgrade outer-loop approval_stalled values remain readable. Approval-path comments in src/kiro_crew/dashboard, src/kiro_crew/messaging, src/kiro_crew/slack, and src/kiro_crew/discord document the split.

skills/self-nudge-loop/scaffold.sh now emits the same remediation-first step as its owning recipe. test/test_autonudge_approval_stall.py, test/test_goal_command.py, test/test_autonudge_stop_auth.py, and test/test_prompt_compact_contract.py pin runtime, prompt, tool, generated-nudge, recipe, and scaffold behavior. .github/black-baseline.txt drops the now-formatted goal test. docs/system-specs/modules/learn-cron-dashboard.md and docs/system-specs/modules/messaging.md describe the lifecycle. This product-shape decision is proposed independently in RFC PR #13013; this implementation remains blocked until maintainers accept and merge that RFC onto main.

Backwards compatibility

Compatible: no accepted input, key, kind, or API is removed or narrowed. Existing stop conditions and structured-monitor approval-stall outcomes remain intact; only legacy prompt/goal loops stop treating a remediable approval timeout as terminal.

Tests

  • 363 AutoNudge, approval-stall, manual-fire, monitor-completion, goal-command, prompt-contract, and stop-tool tests passed.
  • 434 dashboard, shared messaging, Slack, and Discord approval-path tests passed.
  • The final post-rebase focused suite passed 114 tests.
  • Black, isort, Flake8, and mypy passed on changed Python files.
  • Documentation self-test and the full documentation lint passed.
  • Manual mutation proof restored the old blocker deactivation and removed the gated follow-up credit; each corresponding regression failed.
  • The change-scoped local gate ran 35,444 tests: 35,408 passed. Its 36 failures were unrelated local child-interpreter/environment failures; representative failures from each cluster reproduced on pristine current origin/main, while the one order-dependent case passed in isolation on this head.
  • Final local GPT and Opus reviews reported no findings on the exact head.

Manual verification

N/A — no external service or UI flow changed. Runtime transition ordering, persistence failure, gated QUIET behavior, and channel approval paths are covered by focused automated tests and mutation proof.

Screenshots / video

N/A — no user-visible frontend surface changed.

Related Issues

No linked issue: reported directly with a reproducible transcript.

Pattern harvest

Rule candidate: review-prompt
Pattern: a remediable permission, dependency, configuration, build, test, or tool failure is intermediate work to repair and verify, not a terminal goal outcome.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@rubencu
rubencu requested review from a team and buluoray September 23, 2026 04:50
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: action required A blocking check or review needs attention labels Sep 23, 2026
@rubencu

rubencu commented Sep 23, 2026

Copy link
Copy Markdown
Contributor Author

Intent: Keep autonomous goals active through remediable permission, configuration, dependency, tool, build, and test blockers, with durable approval-stall recovery and verified least-privilege repair.
Not a goal: Remove finite safety budgets, user/STOP-sentinel controls, unrecoverable-host stop conditions, or structured monitors' terminal delivery-failure semantics.

@github-actions

Copy link
Copy Markdown
Contributor

GPT 5.6 Review (fork) — ✅ no blocking findings

Reviewed 0768a4a75b05d9a0b1743276c0549694acee279b via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 0768a4a

@github-actions

Copy link
Copy Markdown
Contributor

Design Review (Fable 5, fork) — 🔴 BLOCK (blocking)

Design-level review of 0768a4a75b05d9a0b1743276c0549694acee279b via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: BLOCK

Reverses the pinned "a loop proved unable to act must not burn another cycle" decision, unbounded, with no maintainer decision on record.

Blockers

Prompt-loop approval-stall terminal removed with no replacement bound, treating a named pin as a gap.
The rewritten test's own message pinned the forbidden behavior ("a loop proved unable to act must not burn another cycle"), and messaging.md recorded why ("deactivates instead of burning its cycle budget being denied"). The diff makes the stall marker consumable every wake, so an unattended loop whose grant lapsed — the exact scenario the control shipped for — again fires cycle after cycle, each spending a model turn plus a full approval window, until the caps the description itself calls only "safety backstops". The description frames the old terminal as "inconsistent contracts" (root cause), and the doc hunk rewrites the original rationale's history from "a loop whose grant lapsed" to "a monitor whose grant lapsed" — retroactively narrowing a decision rather than acknowledging its reversal; no linked issue or maintainer decision exists. The reported incident (the agent volunteering autonudge_stop(reason="blocked")) is fully fixed by the prompt/tool/skill changes alone; the runtime reversal targets the one blocker class — an unanswered human approval — the agent provably cannot remediate. The proportionate middle already exists in the same dataclass: consecutive_start_failures (autonudge.py:754) consumes evidence, backs off after N, stands down after M.
Fix: keep the prompt/skill/tool-description changes; give the runtime a consecutive-stall stand-down (mirroring consecutive_start_failures) instead of unbounded consumption, or split the reversal into its own PR.
Clears when: a maintainer explicitly approves retiring the pin as-is, or the runtime bounds consecutive stall-consumed cycles with a stand-down before the cycle cap.

Watch

The new instruction "a missing permission… is remediation work: inspect the owning code/config, make the least-privileged allowed fix" invites an unattended agent to edit permission/approval configuration it can reach (the OS fence covers only the governance keystone files); the "only the user can grant" carve-out relies on the model classifying correctly — the same model whose misclassification motivated this PR.
Clears when: the prompt text (prompt.md, chat_runner goal message, autonudge_stop descriptor) explicitly excludes granting itself approvals/permissions from "remediation work".

Suggestions

  • Model the stall bound on consecutive_start_failures: clear the counter on a delivered non-stalled turn, stand down after N consecutive stalls — continuity for mixed-work goals, restored protection for loops that can never act.

[DESIGN-REVIEWED] 0768a4a

@github-actions

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5, fork) — 🔴 BLOCK

Premise-level review of 0768a4a75b05d9a0b1743276c0549694acee279b via the fork AI-review pipeline — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: BLOCK

Reverses the pinned stall-stop — "a loop proved unable to act must not burn another cycle" — and rewires every stop default, with no non-draft RFC covering that shape.

Not justified as shipped

  • Item 1 — product-shape, reversed pin: the description calls the recorded stall-stop "inconsistent contracts", but the transcript it cites (unlinked) shows the agent calling autonudge_stop — item 2's defect — not the service stop this reverses; no evidence the pin was wrong.
    Clears when: an RFC covering the goal-loop blocker lifecycle merges non-draft on base (then push or rebase), or a maintainer pushes this branch to kirodotdev/KiroCrew and records /ai-review override first-principles 0768a4a75b05d9a0b1743276c0549694acee279b: <decision>.
  • Item 2 — product-shape: changes what /goal, the global prompt, autonudge_stop, and the self-nudge skill do by default; the cited implemented RFC contains "remediat" 0 times and its stated goal is "Preserve legacy AutoNudge behavior during migration".
    Clears when: the same record as item 1 — a covering non-draft RFC on base (push or rebase after), or the maintainer-pushed override on this head.

What this change ships

Inventory (8 items) — 3 justified

Intent: keep autonomous goal loops working through remediable blockers instead of retiring; framed as a FIX, but items 1–2 redesign pinned defaults.

  1. A goal/prompt loop with an unanswered approval now stays active and fires again — product-shape, reversed pin
  2. Agent stop guidance on four surfaces now forbids stopping on remediable blockers — product-shape, no recorded decision
  3. A gated loop gets one follow-up turn bypassing a QUIET probe after a stall — rides along
  4. A failed evidence write keeps the marker and retries on bounded backoff — rides along
  5. Structured monitors keep the terminal stall treatment — justified
  6. Approval-path comments across channels document the monitor/prompt split — justified
  7. Owning spec docs updated in the same commit — justified
  8. Goal test reformatted and dropped from the black baseline — rides along

Blockers

product-shape change without accepted RFC — the default blocker/approval-stall lifecycle of first-class goal loops.
The diff rewrites test_stall_stops_loop_before_the_next_cycle, whose assertion read "a loop proved unable to act must not burn another cycle", and deletes _timer's rationale "Without this the loop keeps waking, dispatching, being declined and spending its cap on cycles that were never able to work" — the exact behavior the change reinstates for prompt loops. The description recasts that decision as "inconsistent contracts" and grounds coverage in the token-efficient-monitors RFC, where I counted 0 matches for remediat and whose goals include "Preserve legacy AutoNudge behavior during migration". Base RFC list carries no other non-draft document covering this lifecycle (rfc-perpetual-agent.md is draft).
Clears when: an RFC covering the goal-loop blocker/stall lifecycle is merged non-draft on the base branch and the author pushes or rebases so the run reads a base that carries it, or a maintainer pushes this branch to kirodotdev/KiroCrew and records /ai-review override first-principles 0768a4a75b05d9a0b1743276c0549694acee279b: <decision>.

[FIRST-PRINCIPLES-REVIEWED] 0768a4a

@github-actions

Copy link
Copy Markdown
Contributor

Opus 5 Review (fork) — ✅ no blocking findings

Reviewed 0768a4a75b05d9a0b1743276c0549694acee279b via the fork AI-review pipeline; updated in place on each push.

Review details

Two advisory gaps: the same skill's generated nudge still carries the retired "all blocked" stop, and the rewritten spec/field comment still name a stopped_reason producer this commit deletes.

FINDING — skills/self-nudge-loop/scaffold.sh:124 — the generator for this skill's own arming template still emits 6. If everything blocked AND you already posted a blocker this arming: autonudge_stop(reason="all blocked"), stop. inside the "Ready-to-paste nudge" it writes into LOOP.md (the path SKILL.md:240 tells the user to run), so a scaffold-armed loop keeps retiring on a blocked board while SKILL.md:215 now says the opposite → Fix: apply the same step-6 rewrite to the heredoc at scaffold.sh:124.

FINDING — src/kiro_crew/autonudge.py:725 — the rewritten field comment attributes "approval_stalled" to retained legacy/structured stop evidence, but the structured path writes staged_state.stopped_reason = MONITOR_STOP_APPROVAL_STALL ("approval_stall", on MonitorState, autonudge.py:4122) and never loop.stopped_reason, while learn-cron-dashboard.md's rewritten paragraph still lists "approval_stalled" among loop stopped_reason values that "_timer's terminal bounds tag themselves" — the one _timer writer being deleted at autonudge.py:5480 → Fix: say plainly that loop.stopped_reason == "approval_stalled" is only pre-upgrade store evidence and that the structured stop is recorded as approval_stall on MonitorState.stopped_reason.

[OPUS-REVIEWED] 0768a4a

@rubencu rubencu mentioned this pull request Sep 23, 2026
5 tasks done
Treat missing permissions, credentials, configuration, dependencies, and failing tools as remediation work instead of terminal goal outcomes. Align the base prompt, stop-tool descriptor, slash goal nudge, self-nudge recipe, docs, and regression contracts.
@rubencu
rubencu force-pushed the fix/goal-permission-blocker-keeps-running branch from 0768a4a to 2a505fa Compare September 23, 2026 06:13
@rubencu

rubencu commented Sep 23, 2026

Copy link
Copy Markdown
Contributor Author

Outcome: needs-a-decision
Question for maintainers: Should the lifecycle in RFC PR #13013 be accepted: finite cycle/runtime budgets remain the terminal bound, while an unanswered human approval does not add a second approval-specific stand-down? The implementation will not be called review-ready until that RFC is merged onto its base.

@rubencu

rubencu commented Sep 23, 2026

Copy link
Copy Markdown
Contributor Author

Outcome: fixed
Rationale: Head 2a505fa explicitly forbids self-granting approvals or permissions, weakening/bypassing approval policy, and editing governance controls across the base prompt, /goal nudge, stop descriptor, recipe, and scaffold. Contract tests pin every agent-facing surface.

@rubencu

rubencu commented Sep 23, 2026

Copy link
Copy Markdown
Contributor Author

Outcome: needs-a-decision
Question for maintainers: RFC PR #13013 explicitly rejects a terminal consecutive-stall stand-down because it would retire a goal before its declared budget; it permits a future non-terminal adaptive-backoff RFC. Should that finite-budget lifecycle be accepted?

@rubencu

rubencu commented Sep 23, 2026

Copy link
Copy Markdown
Contributor Author

Outcome: needs-a-decision
Question for maintainers: Standalone RFC PR #13013 now records the prompt-loop approval-stall decision independently of this implementation. Please accept and merge that RFC, or decline the lifecycle; this implementation remains blocked meanwhile.

@rubencu

rubencu commented Sep 23, 2026

Copy link
Copy Markdown
Contributor Author

Outcome: needs-a-decision
Question for maintainers: RFC PR #13013 covers the default behavior of /goal, the global prompt, autonudge_stop, and self-nudge templates, including the no-self-grant authority ceiling. This PR will wait for that decision to land on main.

@rubencu

rubencu commented Sep 23, 2026

Copy link
Copy Markdown
Contributor Author

Outcome: needs-a-decision
Question for maintainers: The required product-shape record is RFC PR #13013, opened separately and marked accepted upon maintainer merge. Implementation readiness remains blocked until the base contains it.

@rubencu

rubencu commented Sep 23, 2026

Copy link
Copy Markdown
Contributor Author

Outcome: fixed
Rationale: Head 2a505fa rewrites the scaffold heredoc to match the remediation-first recipe. A platform-neutral test parses the emitted LOOP_MD template unconditionally and permits only DoD-met and sentinel stop reasons.

@rubencu

rubencu commented Sep 23, 2026

Copy link
Copy Markdown
Contributor Author

Outcome: fixed
Rationale: Head 2a505fa documents outer approval_stalled as pre-upgrade evidence only and identifies approval_stall on MonitorState.stopped_reason as the current structured-monitor record; runtime behavior is unchanged by this documentation repair.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 23, 2026
@rubencu
rubencu requested a review from a team September 24, 2026 20:12
@github-actions github-actions Bot added readiness: checking Automated validation is still running merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: action required A blocking check or review needs attention labels Sep 24, 2026

@bolichen97 bolichen97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes: unbounded prompt loops lose the approval-stall stop that RFC PR #13013 says they keep

The Design Review BLOCK above covers the reversal in general. This point is narrower and is not on the thread yet. The reply to that review says finite cycle/runtime budgets remain the terminal bound. A loop with max_cycles=0 and max_runtime_secs=0 has no such budget, and this head does not treat it differently.

What breaks. At src/kiro_crew/autonudge.py:5519:

if loop.approval_stalled:
    ...
    consumed = await self._consume_prompt_approval_stall(loop)
    ...
    if not consumed:
        return

After this, the code falls through to the fire. Neither this branch nor _consume_prompt_approval_stall (:4257) checks whether the loop is bounded. The earlier checks do nothing at 0: if loop.max_cycles and ... (:5478) is skipped, and runtime_budget_exceeded (:933) returns False when max_runtime_secs is 0. On main, this spot deactivates the loop instead (autonudge.py:6113-6122: update(active=False, stopped_reason=APPROVAL_STALL_REASON), _emit("expired"), return).

Scenario. An unbounded prompt loop has an approval that nobody answers. Examples: an Issue Radar crew (src/kiro_crew/apps/builtins/issue_radar/backend/crew_runtime.py:785, max_cycles=0, no runtime budget), a ctx.nudge loop (src/kiro_crew/workflows/runner.py:566, default max_cycles=0), a popover goal set to 0 explicitly, or any goal stored with 0 before this change. On main, the next wake stops the loop with approval_stalled and emits expired. On this head, the loop consumes the marker and fires another model turn on every wake, and nothing on the service side ever ends it. Whether each cycle also waits out an approval window depends on the model calling the gated tool again, and the new "recheck it on later cycles" wording encourages it to.

Mismatch with the RFC. The current revision of docs/request-for-change/rfc-goal-blocker-lifecycle.md in RFC PR #13013 says:

  • §3 step 2: "if neither bound is set, deactivates the loop with the terminal approval_stalled outcome exactly as today".
  • §5: "An unbounded loop keeps the terminal approval-stall stop unchanged".
  • Phase 1 exit criteria: "a test pins both branches".

This head has neither the branch nor that test. test_prompt_stall_keeps_loop_active_for_remediation (test/test_autonudge_approval_stall.py:134) arms through _armed(svc) with the 0/0 defaults and asserts that the loop stays active and fires. That test pins the unbounded case to keep running.

Fix direction. In the _timer stall branch, keep main's deactivate-and-expired path when not loop.max_cycles and not loop.max_runtime_secs, and consume the marker only for bounded loops. Arm the existing test with a finite max_cycles, and add a test that pins the 0/0 stop.

From a full open-PR audit against origin/main c66f95b (2026-09-25); findings were checked by independent reviewers reading the code. Reply here if this is wrong.

@cruisercohen cruisercohen added the needs-pr-triage PR scanner: awaiting automated triage label Sep 30, 2026
@NicholasRBowers NicholasRBowers added needs-author-decision PR blocked on author input and removed needs-pr-triage PR scanner: awaiting automated triage labels Sep 30, 2026
@NicholasRBowers

Copy link
Copy Markdown
Contributor

🤖 Kiro Crew [operator: NicholasRBowers#a942f9ca]: This PR has been inactive for 7+ days. I reviewed the blockers but they require your input:

  • Merge is gated on RFC docs: decide goal blocker lifecycle #13013, which is open and unreviewed. You have said this PR waits for it, and both Design Review and First Principles BLOCK for that reason: the change reverses the pinned rule that a loop proved unable to act must not burn another cycle, and it is a product-shape change with no accepted RFC. Either the RFC lands on main or a maintainer records an override — nothing an automated pass can substitute for.
  • bolichen97's CHANGES_REQUESTED is mechanical but unaddressed on the current head (cd9e2b1f): at the _timer stall branch, keep main's stop-and-emit-"expired" path when max_cycles == 0 and max_runtime_secs == 0, so only bounded loops consume the marker; arm test_prompt_stall_keeps_loop_active_for_remediation (test/test_autonudge_approval_stall.py:134) with a finite max_cycles; and add a test pinning the 0/0 stop. I confirmed the head's branch has no unbounded check. This matches RFC docs: decide goal blocker lifecycle #13013 §3 step 2 and §5, which the head currently contradicts.
  • Design Review names an alternative you declined, so it is worth a decision rather than silence: a consecutive-stall stand-down modeled on consecutive_start_failures would clear the block without the RFC. You chose the RFC route instead; a maintainer should confirm that is the plan.
  • Fork workflows need approval. PR Readiness is pending and 11 checks never started on cd9e2b1f — CI, Fast Gate and Build have not run at all, so there is no evidence either way on this head, and every bot verdict on the PR reviewed 0768a4a7, two heads back.

One thing to know before the next push: main's #14994 cut autonudge.py by 6,777 lines into the new src/kiro_crew/autonudge_service/ package on 09-30. Your stall branch now lives in autonudge_service/firing.py:155-162, notify_approval_stalled moved to timers.py, and the constant and dataclass comments to model.py. The branch is 1018 commits behind, with heavy churn in chat_runner.py, slack/gateway.py and the docs.

When you've addressed these, the pipeline will re-assess on its next cycle.

@rubencu

rubencu commented Oct 10, 2026

Copy link
Copy Markdown
Contributor Author

Status note. This PR's product path, keeping a goal loop firing through a permission blocker, was superseded by #16993 (merged 2026-10-07), which pauses the loop on an unanswered approval and keeps open ledgers running instead. The lifecycle RFC in #13013 was slimmed against that decision on 2026-10-10 and no longer depends on or references this PR (its stall path names #16993 as the implementation).

The head cd9e2b1f is 47 files conflicting with main and the CHANGES_REQUESTED review is still on record. No further work is planned here. Recommendation for a maintainer: close this PR as superseded by #16993.

@iamwhatever

Copy link
Copy Markdown
Contributor

Thank you @rubencu for this work, and for the status note.

Closing this as superseded, as you suggested. #16993 (2bedbb2c2) is merged on main: it pauses the loop on an unanswered approval and keeps an open work-ledger watch running.

Your branch is kept. If a gap remains, please reopen this or open a follow-up.

@github-actions github-actions Bot removed the readiness: checking Automated validation is still running label Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor) merge conflict Branch has merge conflicts with its base — author must resolve before merge needs-author-decision PR blocked on author input

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants