Task — engineering-spec@1

"Idle-time autonomous evolution - the dream loop under the AWH gate"

doneTASK-CUO-204
module cuo · class product · priority p2 · created · shipped null
depends on TASK-CUO-200, TASK-CUO-201, TASK-CUO-202, TASK-CUO-203 · blocks none

Task

Turn Your Will Into Real.

Summary

CyberOS should keep improving itself while no one is using it, without ever risking an unsafe self-modification. This adds an idle-time loop - the "dream loop" - that runs the existing self-evolution cycle (TASK-CUO-201/202/203) on its own when no human is active. The loop proposes refinements to skill prompts, workflow step ordering, and thresholds, runs them through the AWH gate (author, test, gate), and applies a change only if it passes the gate, falls inside an explicit evolution envelope, and is classified low-risk. Anything that touches a security invariant halts and waits for a human. Every applied change is reversible, lands on a dedicated branch for review, and the whole loop has a kill switch.

Problem

The self-evolution harness (TASK-CUO-200 through 203) can already spot that a skill fails too often or that a workflow's shape causes repeat route-backs, and it can propose and apply low-risk fixes. But today a human triggers each run and approves each apply. Stephen wants the system to improve while he is offline - to use idle time productively - while being certain it cannot quietly change something that matters for safety (cross-tenant isolation, the audit chain, auth, PII recall, cost math).

Without a bounded autonomous loop, idle time is wasted and every improvement waits on Stephen's attention. Without a hard envelope and a human checkpoint, an autonomous loop is unsafe. The two needs have to be met together: autonomy inside a fence, never outside it.

Proposed Solution

A scheduled idle-time loop that reuses the TASK-CUO-201/202/203 machinery, bounded by an explicit envelope and a human checkpoint. User-visible behaviour: when the machine has been idle for a set period, the loop wakes, proposes and tests refinements against the golden sets, applies the ones that pass and are in-envelope and low-risk, and leaves a branch plus an audit trail for Stephen to review in the morning. Anything risky is left as a halted proposal, not applied.

Section 1 - normative requirements (BCP-14)

  1. The loop MUST start only when an idle detector reports no human input and no active session for at least the configured window (default 30 minutes), and MUST stop the moment activity resumes.
  1. The loop MUST reuse the TASK-CUO-201/202/203 propose cycle and MUST run it against the golden sets only. It MUST NOT read or touch production tenant data.
  1. A proposed change MUST be applied only if all three hold: (a) it passes the AWH gate (author then test then gate, green); (b) it falls inside the evolution envelope of clause 4; (c) TASK-CUO-202 classifies it low-risk. If any condition fails, the change MUST NOT be applied.
  1. The system MUST define an explicit evolution envelope in config/dream.yaml with an allowlist of self-modifiable artifacts (skill prompt bodies, workflow step ordering, numeric thresholds, retry counts) and a denylist of security invariants that the loop MUST NEVER auto-modify: cross-tenant isolation logic, audit-chain definitions, auth and RBAC, PII recall gates, cost-ledger math, and anything under a path marked protected.
  1. Any proposed change that touches a denylist invariant MUST halt the loop and emit a human-in-the-loop proposal. It MUST NOT be applied autonomously under any circumstance.
  1. Every applied change MUST be reversible: the loop MUST record the pre-change content hash and a rollback ref, and MUST auto-revert a change if a follow-up gate run regresses.
  1. The loop MUST be bounded: a maximum number of applied changes per idle window, a maximum wall-clock per window, and a kill switch (env var plus a flag in config/dream.yaml) that disables dreaming entirely. The kill switch MUST take effect without a redeploy.
  1. The loop MUST emit memory audit kinds through the TASK-CUO-201 audit path: cuo.dream_started, cuo.dream_proposal, cuo.dream_applied, cuo.dream_halted_hitl, cuo.dream_reverted, each carrying the run id, the target artifact, and the outcome.
  1. Applied changes MUST land as commits on a dedicated auto/dream branch, never on main and never deployed. A human reviews and merges.
  1. The loop MUST NOT touch secrets, MUST NOT call external networks beyond what the gate already allows, and MUST NOT deploy or push to any remote.

Alternatives Considered

Continuous online learning or weight-level fine-tuning of a model while idle. Rejected: CyberOS has no training infrastructure, weight updates are opaque and hard to gate or revert, and an autonomously retrained model is exactly the unsafe self-modification Stephen wants to avoid. The dream loop edits prompts, workflow shape, and thresholds - all human-readable, gate-testable, and revertible - not weights.

Keep evolution human-triggered only (the TASK-CUO-200..203 status quo). Rejected: it does not meet the "improve while offline" ask. Idle time stays unused and every refinement waits on attention.

Let the loop apply any gate-passing change, trusting the gate alone. Rejected: a green gate proves tests pass, not that the change is safe to make autonomously. A prompt edit could pass tests yet weaken a security posture the tests do not cover. The envelope plus the denylist halt is the second fence the gate cannot provide.

Success Metrics

Primary metric - net safe refinements per idle window.

Guardrail metric - denylist auto-applies.

Scope

In scope: the idle detector, the dream loop driving the existing propose cycle against the golden sets, the evolution envelope (allowlist plus denylist) and its enforcement, the low-risk-only auto-apply gate, reversibility and auto-revert, the bounded-run limits and kill switch, the five audit kinds, and the dedicated-branch landing.

Out of scope

Dependencies

AI Risk Assessment

Data sources

The loop reads only the golden sets and the harness's own outcome distributions. It does not read production tenant data, secrets, or PII. Proposed edits are to human-readable artifacts (prompts, workflow YAML, thresholds), so every change is inspectable. No model weights are trained or altered.

Human oversight

The denylist halts any security-invariant change for a human decision (EU AI Act Article 14). Every applied change lands on a review branch that a human merges; nothing reaches main or production autonomously. A kill switch disables the loop without a redeploy. Stephen reviews the morning audit trail of what the loop did overnight, and can revert any change from its recorded rollback ref.

Failure modes

A bad proposal that passes tests but is wrong is caught when the follow-up gate regresses, and is auto-reverted (clause 6). A change that tries to touch a denylist invariant is halted before apply (clause 5). A runaway loop is bounded by the per-window change and time limits and the kill switch (clause 7). A loop that wakes during human activity is prevented by the idle detector (clause 1). In every case the safe state is "no change applied", reached by halting, not by guessing.

AI Authorship Disclosure