|
| 1 | +# StackMemory Vision — the 24/7 meta-loop |
| 2 | + |
| 3 | +> Your agents run 24/7. A single goal isn't enough to keep them on track — and |
| 4 | +> too loose a goal makes them go haywire. **VISION.md** is the guardrail: a |
| 5 | +> north-star mission, hard limits, and an ordered objective list. The vision |
| 6 | +> loop runs one level above any single task, drawing work from both the |
| 7 | +> objectives *and* a monitored signal source, delegating to the conductor, and |
| 8 | +> recording every conclusion to the shared brain so thinking compounds. |
| 9 | +
|
| 10 | +``` |
| 11 | + VISION.md (mission + guardrails + objectives + limits) |
| 12 | + │ |
| 13 | + signals ──► vision loop ──► consult brain ──► conductor ──► PR |
| 14 | + (bugs, CI, │ guardrails │ (no repeats) (executor) |
| 15 | + issues) │ checked ▼ |
| 16 | + └──────────────► record outcome ──► brain (compounds) |
| 17 | +``` |
| 18 | + |
| 19 | +This is the layer that turns "build a feature" into "build the app" and "fix a |
| 20 | +bug" into "watch the bug stream and fix them as they arrive." |
| 21 | + |
| 22 | +## Quick start |
| 23 | + |
| 24 | +```bash |
| 25 | +stackmemory conductor vision init # scaffold VISION.md |
| 26 | +$EDITOR VISION.md # set the mission, scope, objectives |
| 27 | +stackmemory conductor vision plan # dry-run: what's the next action? |
| 28 | +stackmemory conductor vision run --once --dry-run |
| 29 | + |
| 30 | +# Act for real — provide how to delegate one objective: |
| 31 | +stackmemory conductor vision run --delegate-cmd 'claude -p "{{OBJECTIVE}}"' |
| 32 | +``` |
| 33 | + |
| 34 | +> **Safety:** `run` is **plan-only** unless you pass `--delegate-cmd`. The loop |
| 35 | +> never spawns autonomous agents by accident. |
| 36 | +
|
| 37 | +## VISION.md format |
| 38 | + |
| 39 | +Plain markdown, so it stays human-editable and reviewable: |
| 40 | + |
| 41 | +```markdown |
| 42 | +# Vision |
| 43 | + |
| 44 | +Ship a reliable, self-healing sync layer that any agent can depend on. |
| 45 | + |
| 46 | +## Guardrails |
| 47 | +- Stay within the scope below; never touch secrets or deploy/publish. |
| 48 | +- Open a PR for review; never merge to the default branch autonomously. |
| 49 | +- If an objective is ambiguous or risky, stop and ask a human. |
| 50 | + |
| 51 | +## Scope |
| 52 | +- src/** |
| 53 | +- docs/** |
| 54 | + |
| 55 | +## Objectives |
| 56 | +- [ ] add retry with jitter to the sync client |
| 57 | +- [x] write the protocol types |
| 58 | +- [ ] add a `sync status` command |
| 59 | + |
| 60 | +## Limits |
| 61 | +maxIterations: 10 |
| 62 | +maxIterationsPerDay: 50 |
| 63 | +maxConsecutiveFailures: 3 |
| 64 | +tickIntervalSec: 60 |
| 65 | +requireApproval: false |
| 66 | +stopWhenComplete: true |
| 67 | +``` |
| 68 | + |
| 69 | +The loop reloads VISION.md **every tick**, so editing the file (or checking a |
| 70 | +box) changes its behavior live. |
| 71 | + |
| 72 | +## Two sources of work |
| 73 | + |
| 74 | +Per the design, the loop draws objectives from **both**: |
| 75 | + |
| 76 | +1. **VISION.md objectives** — the planned, ordered backlog (the "build the app" |
| 77 | + direction). Completed objectives get their checkbox ticked automatically. |
| 78 | +2. **A monitored signal inbox** — reactive work that arrives over time (the "fix |
| 79 | + bugs as they show up" direction): |
| 80 | + |
| 81 | + ```bash |
| 82 | + stackmemory conductor vision signal "500s on /sync after deploy" --severity high |
| 83 | + ``` |
| 84 | + |
| 85 | + Anything can feed it — a CI hook, a GitHub-issue poller, a bug-report |
| 86 | + webhook — by appending to `.stackmemory/vision/signals.jsonl` or calling the |
| 87 | + `signal` command. **Pending signals outrank objectives**, so urgent issues |
| 88 | + preempt planned work, bounded by the same guardrails. |
| 89 | + |
| 90 | +## Guardrails (the anti-haywire layer) |
| 91 | + |
| 92 | +Every tick is gated by `## Limits`: |
| 93 | + |
| 94 | +| Limit | Effect | |
| 95 | +|-------|--------| |
| 96 | +| `maxIterations` | objectives handled per `run` | |
| 97 | +| `maxIterationsPerDay` | objectives handled per calendar day (persisted) | |
| 98 | +| `maxConsecutiveFailures` | circuit breaker — stop after N failures in a row | |
| 99 | +| `tickIntervalSec` | delay between ticks | |
| 100 | +| `requireApproval` | when true, the loop only plans + queues, never delegates | |
| 101 | +| `stopWhenComplete` | stop once objectives are done and no signals remain | |
| 102 | + |
| 103 | +Loop state (today's count, consecutive failures) lives in |
| 104 | +`.stackmemory/vision/state.json` and resets daily. |
| 105 | + |
| 106 | +## Brain integration (compounding) |
| 107 | + |
| 108 | +Before delegating, the loop asks the [brain](./BRAIN.md) whether this exact work |
| 109 | +was already concluded — if so it **skips it** (and ticks the objective), so the |
| 110 | +loop never repeats itself across machines or agents. After delegating, the |
| 111 | +outcome is recorded as a brain `experiment` (agent `vision`) with the |
| 112 | +conclusion, tags, and refs — feeding the same compounding memory every other |
| 113 | +agent reads. |
| 114 | + |
| 115 | +## Running it on the portal (24/7) |
| 116 | + |
| 117 | +On your Hetzner + Tailscale [portal](./PORTAL.md) box, run the loop inside the |
| 118 | +tmux session so it survives disconnects: |
| 119 | + |
| 120 | +```bash |
| 121 | +# inside the tmux 'claude' session |
| 122 | +stackmemory conductor vision run \ |
| 123 | + --delegate-cmd 'claude -p "{{OBJECTIVE}}. Stay within VISION.md scope. Open a PR."' |
| 124 | +``` |
| 125 | + |
| 126 | +Check in from any device via the portal; the loop keeps working the vision and |
| 127 | +the signal stream while you experience life. |
| 128 | + |
| 129 | +## CLI |
| 130 | + |
| 131 | +```bash |
| 132 | +stackmemory conductor vision init [--force] |
| 133 | +stackmemory conductor vision status [--json] |
| 134 | +stackmemory conductor vision signal <text> [--severity] [--source] [--refs] |
| 135 | +stackmemory conductor vision plan [--max <n>] |
| 136 | +stackmemory conductor vision run [--once] [--max <n>] [--dry-run] \ |
| 137 | + [--delegate-cmd <tpl>] [--timeout <sec>] |
| 138 | +``` |
| 139 | + |
| 140 | +`--delegate-cmd` substitutes `{{OBJECTIVE}}`, `{{KIND}}`, and `{{REFS}}`. |
| 141 | + |
| 142 | +## Files |
| 143 | + |
| 144 | +| Path | Purpose | |
| 145 | +|------|---------| |
| 146 | +| `src/core/vision/vision-file.ts` | VISION.md parse / scaffold / objective toggle | |
| 147 | +| `src/core/vision/signals.ts` | monitored signal inbox (JSONL) | |
| 148 | +| `src/core/vision/vision-loop.ts` | the guardrailed loop (select → gate → dedupe → delegate → record) | |
| 149 | +| `src/cli/commands/vision.ts` | `stackmemory conductor vision` command | |
0 commit comments