Skip to content

feat(ai-autopilot): the loop (#113)#118

Merged
suleimansh merged 1 commit into
mainfrom
feat/the-loop
Jul 2, 2026
Merged

feat(ai-autopilot): the loop (#113)#118
suleimansh merged 1 commit into
mainfrom
feat/the-loop

Conversation

@suleimansh

Copy link
Copy Markdown
Member

Closes #113. Child of the AI-framework epic #110; builds on the decisions ledger (#117).

What

The event-to-prompt-chain policy, the web-app orchestration layer generic harnesses lack. The agent declares a semantic change and the right prompts fire:

  • major-change => review + code-quality + security
  • ui-flow => QA + UX
  • extensible: defineRule your own kind => [prompt ids]

Loop.handle(event) resolves the chain from the rules and runs it; matches(event) is the pure preview; watch(stream) handles a stream fire-and-report. defaultLoopRules() is the built-in policy as data. Prompts (definePrompt) run for their passes with fresh context every pass (Rom's finding), and each gets the decisions ledger on ctx.ledger.

Design calls (the issue's two open questions)

  • What is a "major change"? Agent-declared, not heuristic: the trigger is a LoopEvent { kind } the worker emits. Deterministic, and the agent is what knows intent. A classifier (supervisor-event => LoopEvent) can sit in front later.
  • Sync vs async? Both. handle() awaits the chain; continueOnError: false makes it a blocking gate (a failing prompt stops the chain). Fire-and-report via watch(stream) or launchAutopilot. (v1 gates on execution failure; gating on a review's verdict waits for prompts to return one, Built-in prompts library (review, quality, security, refactor, UX, QA, knowledge base) #111.)

The prompt bodies are #111, registered under the ids defaultLoopRules() references. This wires cleanly to #116 (bootstrap's full-fledged loop reuses the fresh-context passes).

Verification

  • 116 tests pass (17 new: define/loop/policy), typecheck + build clean.
  • Drove it end-to-end: a major-change event fires review (2 fresh passes) => code-quality => security in order, ui-flow fires qa => ux, an unrelated event matches nothing, and every prompt sees the ledger.

The agent declares a semantic LoopEvent (a change kind) and the matching prompt
chain fires: major-change runs review + code-quality + security, ui-flow runs
QA + UX. Loop.handle(event) resolves the chain from LoopRules (defineRule /
defaultLoopRules as the built-in policy) and runs each LoopPrompt (definePrompt)
for its passes with fresh context every pass; matches() is the pure preview,
watch(stream) handles a stream fire-and-report.

Design calls on the open questions: the trigger is agent-declared, not a
heuristic; both modes ship (handle awaits; continueOnError:false is a blocking
gate). Consults the decisions ledger via ctx.ledger; references the prompts
library (#111) by id.

Child #113 of the AI-framework epic (#110).
@suleimansh suleimansh added enhancement New feature or request priority: medium Worth doing, not urgent labels Jul 2, 2026
@suleimansh suleimansh self-assigned this Jul 2, 2026
@suleimansh suleimansh merged commit 481c2f0 into main Jul 2, 2026
2 checks passed
@suleimansh suleimansh deleted the feat/the-loop branch July 2, 2026 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request priority: medium Worth doing, not urgent

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"The loop" — event-triggered prompt chains (major change → review/quality/security; UI flow → QA/UX)

1 participant