fix(home): manual autonomy fires on receipt — Dispatch button wasn't bootstrappable

Bug: a fresh project (zero outcome history) has confidence 0.5, but the
Dispatch button posted autonomy="auto" which gates on confidence >= 0.55.
Result: clicking Dispatch on a fresh project returned a proposal, not a
fire. With no fires, no outcomes accrued, confidence never moved, and
the brain stayed stuck at 0.5 forever. The system could not bootstrap.

Root cause was a wrong mental model in AUTONOMY_THRESHOLD: 'manual' was
set to Infinity (never auto-execute) with a comment saying "UI shows
the proposal, user clicks" — but the user clicking IS what makes it
manual. There's no second click step. Manual conflated with confirm.

Sharpened the meanings:

  manual  → 0       human clicked Dispatch — fire on receipt, the
                    human IS the gate. Confidence still flows for
                    display but never blocks.
  confirm → Infinity   show the proposal so the human can review or
                       click Dispatch (manual) to fire.
  auto    → 0.55    autonomous scheduler (cron, queue drain) — moderate
                    confidence gate.
  sleep   → 0.75    autonomous while-away — high confidence gate.

Health-critical still blocks manual via shouldAutoExecute's hard gate,
so an unhealthy project can't be force-dispatched past recovery.

Wired the UI Dispatch button to send autonomy="manual" instead of
"auto". Propose stays on "confirm".

home/decide.ts self-tests: 11/11 (was 10/10) — flipped the now-wrong
"manual never auto-executes" case to assert it ALWAYS fires, and added
the health-critical-still-blocks-manual regression. state 13/13 and
worker 12/12 still green. tsc clean.
This commit is contained in:
g-but committed 2026-05-20 05:10:54 +02:00
1 parent e81d9ee1d7
commit 4237260e1c
2 files changed
+23 -7

No files matched your search

+22 -6
View File
@@ -87,10 +87,13 @@ export function computeConfidence(outcomes: Outcome[]): number {
// Threshold per mode: below this, hold and ask. At/above, fire.
const AUTONOMY_THRESHOLD: Record<Autonomy, number> = {
manual: Infinity, // never auto-execute — UI shows the proposal, user clicks
confirm: Infinity, // never auto-execute — UI runs a countdown then re-POSTs
// with autonomy="auto" to fire, OR user clicks now
auto: 0.55, // moderate confidence — fires immediately when in this mode
manual: 0, // human clicked Dispatch — fire on receipt, no gate. The
// confidence value still flows through for display, but
// it never blocks; the user is the gate.
confirm: Infinity, // never auto-execute — UI shows the proposal so the
// human can override or click Dispatch (manual) to fire
auto: 0.55, // moderate confidence — autonomous scheduler (cron,
// queue drain) fires when the gate clears
sleep: 0.75, // high confidence — fires while user away IF healthy
};
@@ -242,9 +245,22 @@ function selfTest() {
expect: (d) => d.action.kind === "dispatch" && d.action.intent === "next_best",
},
{
name: "manual autonomy never auto-executes",
name: "manual autonomy ALWAYS auto-executes (human clicked, no gate)",
input: {
project: { ...baseProject, recentOutcomes: ["success", "success", "success", "success", "success"] },
// Fresh project, zero history. The UI Dispatch button hits this path —
// it must fire even when computeConfidence is still neutral 0.5.
project: { ...baseProject, lastHandoff: { done: "", next: "", tests: "", todos: "", health: "good" } },
autonomy: "manual",
},
expect: (d) => d.autoExecute,
},
{
name: "manual autonomy still blocks when health is critical (recovery first)",
input: {
project: {
...baseProject,
lastHandoff: { done: "x", next: "", tests: "", todos: "", health: "critical — auth broken" },
},
autonomy: "manual",
},
expect: (d) => !d.autoExecute,
+1 -1
View File
@@ -238,7 +238,7 @@ async function refresh() {
'</div>'
: '<div class="actions">' +
'<button data-action="dispatch" data-project="' + projAttr + '" data-autonomy="confirm">Propose</button>' +
'<button class="primary" data-action="dispatch" data-project="' + projAttr + '" data-autonomy="auto">Dispatch</button>' +
'<button class="primary" data-action="dispatch" data-project="' + projAttr + '" data-autonomy="manual">Dispatch</button>' +
'</div>';
return \`
<div class="project\${cr ? ' running' : ''}">