Files
loki/docs/architecture/effective-loop-operations.md
CatoandClaude Fable 5.1 6c20cd4e0a feat(autopilot): the night works from what you said, and no further than you allow (#1123)
* feat(autopilot): the night works from what you said, and no further than you allow

The night used to be `nudge-idle`: wake three idle projects at 04:00 with a
generic "pick the highest-impact action" prompt, with no limit on what that
spent and no record the owner could read in the morning. A run with no brief
is where the queue of things nobody asked for came from.

The night now
- builds from the feedback inbox — one fix per project, the owner's own
  notes first, then what most visitors hit — through the same Implement
  path as the button, so a night's run is a person's run: same prompt,
  same auto-ship rules, same ledger;
- is capped by a per-account budget counted in RUNS (beacon_settings
  .night_runs, default 4, max 20, 0 = file away but build nothing). A run
  is the unit that spends the owner's agent credits, and a run cap holds
  whether or not the runner reports a price;
- reads one site not read this week, when there is budget left, through
  the same review prompt as "AI review this page" (now shared in
  lib/feedback/ai-review-prompt.ts), filing findings into the inbox;
- files away reports nobody started in 21 days, with the reason on the row
  (site_feedback.archive_reason, cleared on reopen);
- hands rows waiting for a shut laptop to the cloud builder;
- writes one row per (user, night) to autopilot_nights and leaves one line
  on /feedback, Telegram and push — nothing when it did nothing.

Decisions are one pure planner (src/config/autopilot-night.ts, tested in
scripts/test/autopilot-night.ts); the lib gathers facts and carries the plan
out; the same dispatch gates as Control refuse a working, blocked or failing
project; a project paused on Control takes nothing. No model is called from
the timer — every night action is an agent run on the owner's builder or a
count — so no-free-background-ai stays green.

Settings → When an agent finishes gains "Overnight: up to N runs a night";
the autopilot copy on Settings and the Control sheet says what On means now.
docs/paths.md path 3 and CHANGELOG record it; effective-loop-operations.md
names the night in place of the idle cron.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011L2dmcydDLYAiNQwK4XcF4

* docs(telegram): register the night's morning note

The registry gate found the one new path that can reach the phone.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011L2dmcydDLYAiNQwK4XcF4

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-10 01:22:23 -07:00

3.6 KiB

created_date, last_modified_date, last_modified_summary
created_date last_modified_date last_modified_summary
2026-07-01 2026-09-23 Updates the execution flow and Terminal wording to the current cloud-builder and Fleet Runner model.

Effective Loop Operations

Loki can run real project loops today when three conditions are true:

  1. The project has an executable user_projects row with a dir_path.
  2. A builder is connected for that user:
    • eligible accounts: the shared Cloud builder can claim cloud commands
    • other accounts or local projects: Fleet Runner on the configured computer must be connected
  3. Fleet/project autopilot is on and the project is not busy, blocked, over the concurrency cap, or already pending.

If any of those are false, the product must say why instead of pretending work started.

Current Loop Entrypoints

  • Control Start building / Build selected: /api/control/fleet-kick -> kickFleet() -> injectPrompt(next_best).
  • Loki "develop all / build fleet": same kickFleet() path.
  • Loki "move forward" with one project: injectPrompt(next_best).
  • Agent finishes and reports ready: Fleet Runner asks /api/control/dispatch; safety gates return queue, nextbest, or off.
  • The night: /api/crons/autopilot-night -> implementFeedback() for the inbox's open reports under the account's run budget, and injectPrompt(customPrompt: review) for one site read — never a bare next_best (retired nudge-idle, 2026-10-10; see src/config/autopilot-night.ts).

injectPrompt() is the SSOT dispatch spine. It assembles project context/RAG, opens run tracking, applies tenant execution policy, and queues the runner's self-healing dispatch command when a project has dir_path.

What Changed

The night (and before it the idle cron) does not insert pending_commands directly. Direct insertion skipped:

  • tenant execution policy
  • project context/RAG assembly parity
  • prompt history
  • run tracking
  • runner self-healing launch behavior

It uses the same injectPrompt / implementFeedback path as Control, Loki and the Implement button.

kickFleet() now skips projects without dir_path with reason no_path. A project profile without a path is still useful strategy context, but it is not an executable loop target.

How To Use It Effectively Now

  1. Open /control.
  2. Make sure the header shows a connected builder.
  3. Register each loop target with a real local/box path:
    • existing repo: import from local or register with dir_path
    • new project: create it, then ensure it has a path before expecting Control to run it
  4. Add project context:
    • mission / brief / goals
    • Git URL when available
    • prompt queue for specific next actions
  5. Press Build all or select projects and press Build selected.
  6. Watch:
    • Control for truth state and activity
    • Terminal → Cloud builder or Your computer for live sessions; this view selector does not change the project's Runs on setting
    • Activity for outcomes and commits

Public Release Boundary

This is ready for founder dogfood and controlled beta users. Eligible accounts can use the shared cloud builder; other execution uses Fleet Runner on the configured computer.

It is not ready for broad public hosted-agent release until Cloud execution is per-tenant sandboxed. The shared box-runner is intentionally private because it owns real filesystem, PTYs, CLI auth, and agent credentials.

Next Reliability Improvements

  • Make no_path visible as a first-class Control chip/CTA.
  • Add a Loop Readiness panel: executable path, builder channel, context fullness, recent outcome, pending command.
  • Build hosted per-tenant sandbox execution before enabling Cloud for arbitrary users.