neurastream 0.2.23 → 0.2.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -109,6 +109,10 @@ A plan parked for the owner has one line: `WAITING on owner: <what>`. That line
109
109
 
110
110
  `INDEX.md` order is priority: the top line is rank 1. The queue summary lists plans in that order (`N. <file> [flags] <goal>`). Before a spawn, the guard checks every plan above each plan the brief names. A higher plan that is idle — open, no `WAITING on owner:`, not awaiting merge, still has an unticked phase, and not itself waiting on another open indexed plan via a `Waits on: <plan>` line — and not staffed by a running job blocks the spawn unless the brief quotes the owner: `Priority skip: <plan> — owner: "<his words>"`, at least four words that appear in an owner message of the last 24 h (`<queue_state>/owner-messages.jsonl`, recorded from Main's prompts); any other skip line is refused. `Waits on:` lines are Main-only, like `WAITING on owner:`. Staffing is `<queue_state>/staffing.json` (each plan's newest spawn's task names) matched against omp's running job labels. The owner reorders the queue by dragging cards on the phone page.
111
111
 
112
+ ## Autonomy tiers
113
+
114
+ One setting decides how much Main does without asking: `autonomy.tier` in the config (default `opinionated`), moved any time by the owner's whole chat message `tier strict|opinionated|full` (when `guards.chat_unlock` is on) or the tier buttons on the phone page — the setting lives in `<queue_state>/autonomy-tier`, a guard-protected path no agent can write. `strict` caps Main's project-file changes at `autonomy.strict_edit_limit` per `guards.main_window_min` minutes and refuses `git push` / `glab mr merge` / `gh pr merge` until the owner types `go` (one landing, valid `autonomy.go_minutes` minutes); `opinionated` keeps today's limits (`guards.main_edit_limit`); `full` drops the cap and lets Main skip an idle higher plan with `Priority skip: <plan> — Main: "<reason>"` (reason ≥ 4 words). No tier loosens the owner-only moves: guard-file edits without the unlock, starting the phone page, reading notify secrets, local `npm publish` and the tier setting itself.
115
+
112
116
  ## Owner page (`neurastream ui`)
113
117
 
114
118
  `neurastream ui on --login <tailscale login> [--port N]` does the whole setup in one sentence: it writes `ui.enabled: true` and `ui.owner_login` (plus `ui.port` with `--port`) into `~/.config/neurastream/config.yml` — every other line of the file is kept byte-for-byte — copies `templates/systemd/neurastream-ui.service` to `~/.config/systemd/user/neurastream-ui.service`, runs `systemctl --user daemon-reload`, `enable` and `restart`, then prints the phone link `http://<MagicDNS name>:<port>`. The login must be one the tailnet knows (`tailscale status --json`); when tailscale cannot answer, the check is skipped with a printed warning, never a refusal. `neurastream ui off` stops and disables the unit and sets `ui.enabled: false`, keeping `ui.owner_login` for the next `on`.
@@ -121,7 +125,7 @@ An answer appends one record to `<queue_state>/owner-inbox.jsonl` (plan, questio
121
125
 
122
126
  ## Static pages (`neurastream pages`)
123
127
 
124
- `neurastream pages on [--port N] [--dir D]` installs the systemd user unit and serves regular files in the configured pages directory on the tailnet; `pages publish <file> [name] [--force]` publishes an artifact and prints its MagicDNS URL. `pages list` lists published files and `pages off` stops the service. Requests are limited to the configured owner's tailnet login or loopback; hidden files, symlinks and paths outside the directory are not served.
128
+ `neurastream pages on [--port N] [--dir D]` installs the systemd user unit and serves regular files in the configured pages directory on the tailnet; `pages publish <file> [name] [--force] [--keep]` publishes an artifact and prints its MagicDNS URL, then `expires YYYY-MM-DD` or `kept`. A page without `--keep` is deleted `pages.keep_days` days after publishing (default 15). `pages list` prints each file as `<name> expires YYYY-MM-DD` or `<name> kept`, and `pages off` stops the service. Publish, list, and serve remove expired files first; serve repeats that sweep every hour. Requests are limited to the configured owner's tailnet login or loopback; hidden files, symlinks and paths outside the directory are not served.
125
129
 
126
130
  ## Session rollover
127
131
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neurastream",
3
- "version": "0.2.23",
3
+ "version": "0.2.25",
4
4
  "description": "Guardrails for running many AI coding agents at once: plan queue, blockers, call budgets, provider caps, scoring, merge-verified close.",
5
5
  "keywords": [
6
6
  "ai-agents",
@@ -19,6 +19,7 @@ import { execFileSync, spawn } from "node:child_process";
19
19
  import { appendFileSync, mkdirSync, openSync, readFileSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
20
20
  import { basename, dirname, join } from "node:path";
21
21
  import type { Decision } from "../../core/adapter.ts";
22
+ import { chatGo, chatTier, type Tier } from "../../core/autonomy.ts";
22
23
  import { loadConfig, type Config } from "../../core/config.ts";
23
24
  import { nowSec, strftime } from "../../core/clock.ts";
24
25
  import { runDetectors, runDetectorsGated, type DetectorInput } from "../../core/incident-detectors.ts";
@@ -1092,8 +1093,10 @@ export function createOmpAdapter(pi: ExtensionHost, cfg: Config): void {
1092
1093
  return null;
1093
1094
  };
1094
1095
 
1095
- // Chat unlock (guards.chat_unlock): the owner's whole message "unlock"/"unlock N"/"lock" moves
1096
- // the guard unlock file (src/core/queue/lib.ts chatUnlock). Only prompts the owner really typed
1096
+ // Chat unlock + autonomy tiers (guards.chat_unlock): the owner's whole message "unlock"/
1097
+ // "unlock N"/"lock" moves the guard unlock file, "tier <name>" sets the autonomy tier and
1098
+ // "go" approves one strict landing (src/core/queue/lib.ts chatUnlock, src/core/autonomy.ts
1099
+ // chatTier/chatGo). Only prompts the owner really typed
1097
1100
  // count: the local terminal (input event, source "interactive") and collab guest prompts from
1098
1101
  // write peers. This handler is registered BEFORE the rollover input handler below, so the unlock
1099
1102
  // wins while a rollover is ready or in flight (emitInput short-circuits on { handled: true }).
@@ -1107,10 +1110,32 @@ export function createOmpAdapter(pi: ExtensionHost, cfg: Config): void {
1107
1110
  c.notify("guard locked again");
1108
1111
  }
1109
1112
  };
1113
+ // The tier switch and the one-shot `go` travel the same two owner paths and answer the same way.
1114
+ const notifyTier = (ctx: unknown, r: { tier?: Tier }): void => {
1115
+ const c = asRolloverCtx(ctx);
1116
+ if (!c || r.tier === undefined) return;
1117
+ c.notify(`tier now ${r.tier}`);
1118
+ };
1119
+ const notifyGo = (ctx: unknown, r: { minutes?: number }): void => {
1120
+ const c = asRolloverCtx(ctx);
1121
+ if (!c || r.minutes === undefined) return;
1122
+ c.notify(`go: one push/merge approved for ${r.minutes} min`);
1123
+ };
1110
1124
  pi.on("input", (event, ctx) => {
1111
1125
  if (!cfg.guards.chat_unlock || !isMain(ctx)) return undefined;
1112
1126
  const e = asRecord(event);
1113
1127
  if (asString(e.source) !== "interactive") return undefined;
1128
+ const text = asString(e.text);
1129
+ const t = chatTier(text, cfg, "interactive");
1130
+ if (t.applied) {
1131
+ notifyTier(ctx, t);
1132
+ return { handled: true };
1133
+ }
1134
+ const g = chatGo(text, cfg, "interactive");
1135
+ if (g.applied) {
1136
+ notifyGo(ctx, g);
1137
+ return { handled: true };
1138
+ }
1114
1139
  const r = q.chatUnlock(asString(e.text), cfg, "interactive");
1115
1140
  if (!r.applied) return undefined;
1116
1141
  notifyUnlock(ctx, r);
@@ -1146,7 +1171,17 @@ export function createOmpAdapter(pi: ExtensionHost, cfg: Config): void {
1146
1171
  if (seenChatPrompts.has(key)) continue;
1147
1172
  seenChatPrompts.add(key);
1148
1173
  const r = q.chatUnlock(text, cfg, `collab:${from}`);
1149
- if (r.applied) notifyUnlock(ctx, r);
1174
+ if (r.applied) {
1175
+ notifyUnlock(ctx, r);
1176
+ continue;
1177
+ }
1178
+ const t = chatTier(text, cfg, `collab:${from}`);
1179
+ if (t.applied) {
1180
+ notifyTier(ctx, t);
1181
+ continue;
1182
+ }
1183
+ const g = chatGo(text, cfg, `collab:${from}`);
1184
+ if (g.applied) notifyGo(ctx, g);
1150
1185
  }
1151
1186
  }
1152
1187
  const rule = { pattern: cfg.quota.reset_pattern, zone: cfg.quota.reset_tz };
package/src/cli/pages.ts CHANGED
@@ -2,20 +2,49 @@ import { readdirSync } from "node:fs";
2
2
  import { homedir } from "node:os";
3
3
  import { defaultRunSource } from "../adapters/omp/sessions.ts";
4
4
  import { loadConfig } from "../core/config.ts";
5
+ import { readExpiry, sweepPages } from "../core/pages-expiry.ts";
5
6
  import { startPagesServer } from "../core/pages.ts";
6
7
  import { pagesOff, pagesOn, publishPage, type Runner } from "../core/pages-setup.ts";
7
8
  import { realTailscale, type Tailscale } from "../core/tailscale.ts";
8
9
 
9
- export interface PagesDeps { home?: string; runner?: Runner; tailscale?: Tailscale }
10
+ export interface PagesDeps { home?: string; runner?: Runner; tailscale?: Tailscale; clock?: () => Date }
11
+ const HOUR_MS = 60 * 60 * 1000;
10
12
  export async function runPages(args: string[] = [], deps: PagesDeps = {}): Promise<number> {
11
- const home=deps.home ?? homedir();
13
+ const home = deps.home ?? homedir();
14
+ const clock = deps.clock ?? (() => new Date());
12
15
  try {
13
- if(args[0]==="on") { let port:number|undefined,dir:string|undefined; for(let i=1;i<args.length;i++){if(args[i]==="--port")port=Number(args[++i]);else if(args[i]==="--dir")dir=args[++i];else return 2;} return pagesOn({home,runner:deps.runner,tailscale:deps.tailscale,port,dir}); }
14
- if(args[0]==="off"&&args.length===1)return pagesOff({home,runner:deps.runner});
15
- const cfg=loadConfig({home});
16
- if(args[0]==="serve"&&args.length===1){if(!cfg.pages.enabled)throw new Error("pages.enabled is false");startPagesServer({cfg,tailscale:deps.tailscale ?? realTailscale,source:defaultRunSource(cfg)});return new Promise<number>(()=>{});}
17
- if(args[0]==="publish"&&args[1]){let force=false,name:string|undefined;for(const arg of args.slice(2)){if(arg==="--force")force=true;else if(!name)name=arg;else return 2;}const n=publishPage(args[1],name,force,cfg.pages.dir);const host=(deps.tailscale ?? realTailscale).dnsName() ?? "tailnet";console.log(`http://${host}:${cfg.pages.port}/${encodeURIComponent(n)}`);return 0;}
18
- if(args[0]==="list"&&args.length===1){for(const f of readdirSync(cfg.pages.dir,{withFileTypes:true}).filter(e=>e.isFile()&&!e.name.startsWith(".")))console.log(f.name);return 0;}
19
- } catch(e){console.error(e instanceof Error?e.message:String(e));return 1;}
20
- console.error("usage: neurastream pages on [--port N] [--dir D] | off | serve | publish <file> [<name>] [--force] | list");return 2;
16
+ if (args[0] === "on") { let port: number | undefined, dir: string | undefined; for (let i = 1; i < args.length; i++) { if (args[i] === "--port") port = Number(args[++i]); else if (args[i] === "--dir") dir = args[++i]; else return 2; } return pagesOn({ home, runner: deps.runner, tailscale: deps.tailscale, port, dir }); }
17
+ if (args[0] === "off" && args.length === 1) return pagesOff({ home, runner: deps.runner });
18
+ const cfg = loadConfig({ home });
19
+ if (args[0] === "serve" && args.length === 1) {
20
+ if (!cfg.pages.enabled) throw new Error("pages.enabled is false");
21
+ sweepPages(cfg.pages.dir, cfg.pages.keep_days, clock());
22
+ startPagesServer({ cfg, tailscale: deps.tailscale ?? realTailscale, source: defaultRunSource(cfg) });
23
+ setInterval(() => { try { sweepPages(cfg.pages.dir, cfg.pages.keep_days, clock()); } catch (e) { console.error(e instanceof Error ? e.message : String(e)); } }, HOUR_MS);
24
+ return new Promise<number>(() => {});
25
+ }
26
+ if (args[0] === "publish" && args[1]) {
27
+ let force = false, keep = false, name: string | undefined;
28
+ for (const arg of args.slice(2)) { if (arg === "--force") force = true; else if (arg === "--keep") keep = true; else if (!name) name = arg; else return 2; }
29
+ const now = clock();
30
+ sweepPages(cfg.pages.dir, cfg.pages.keep_days, now);
31
+ const n = publishPage(args[1], name, force, cfg.pages.dir, keep, cfg.pages.keep_days, now);
32
+ const host = (deps.tailscale ?? realTailscale).dnsName() ?? "tailnet";
33
+ console.log(`http://${host}:${cfg.pages.port}/${encodeURIComponent(n)}`);
34
+ const expires = readExpiry(cfg.pages.dir)[n]?.expires;
35
+ console.log(expires ? `expires ${expires.slice(0, 10)}` : "kept");
36
+ return 0;
37
+ }
38
+ if (args[0] === "list" && args.length === 1) {
39
+ sweepPages(cfg.pages.dir, cfg.pages.keep_days, clock());
40
+ const map = readExpiry(cfg.pages.dir);
41
+ for (const f of readdirSync(cfg.pages.dir, { withFileTypes: true }).filter(e => e.isFile() && !e.name.startsWith("."))) {
42
+ const expires = map[f.name]?.expires;
43
+ console.log(`${f.name} ${expires ? `expires ${expires.slice(0, 10)}` : "kept"}`);
44
+ }
45
+ return 0;
46
+ }
47
+ } catch (e) { console.error(e instanceof Error ? e.message : String(e)); return 1; }
48
+ console.error("usage: neurastream pages on [--port N] [--dir D] | off | serve | publish <file> [<name>] [--force] [--keep] | list");
49
+ return 2;
21
50
  }
@@ -0,0 +1,97 @@
1
+ // Autonomy tiers (I-20261025-177): one owner setting — strict / opinionated / full — that the
2
+ // guards follow. The tier and a one-shot `go` are written only by the owner's own words (the same
3
+ // paths as chatUnlock: the terminal input event and collab write-peer messages) or the
4
+ // authenticated phone page; never by a tool call (the state dir is protected) and never from
5
+ // model text. Every tier keeps the owner-only moves owner-only; no tier loosens them.
6
+
7
+ import { appendFileSync, mkdirSync, readFileSync, rmSync, statSync, writeFileSync } from "node:fs";
8
+ import path from "node:path";
9
+ import type { Config } from "./config.ts";
10
+ import { stateDirPath } from "./queue/lib.ts";
11
+
12
+ export type Tier = "strict" | "opinionated" | "full";
13
+ const TIERS: readonly Tier[] = ["strict", "opinionated", "full"];
14
+
15
+ export function tierFile(): string {
16
+ return path.join(stateDirPath(), "autonomy-tier");
17
+ }
18
+
19
+ export function goFile(): string {
20
+ return path.join(stateDirPath(), "autonomy-go");
21
+ }
22
+
23
+ /** The tier the guards follow: `<state dir>/autonomy-tier` when it names one of the three (one word), else the config value. */
24
+ export function currentTier(cfg: Config): Tier {
25
+ try {
26
+ const word = readFileSync(tierFile(), "utf8").trim().toLowerCase();
27
+ if ((TIERS as readonly string[]).includes(word)) return word as Tier;
28
+ } catch {}
29
+ return cfg.autonomy.tier;
30
+ }
31
+
32
+ export interface ChatTierResult {
33
+ /** True when the text was a whole-message `tier <name>` command that took effect. */
34
+ applied: boolean;
35
+ /** The tier now in force. */
36
+ tier?: Tier;
37
+ }
38
+
39
+ const TIER_CMD = /^tier\s+(strict|opinionated|full)$/i;
40
+
41
+ /**
42
+ * Owner tier switch by chat (guards.chat_unlock, the same flag as chatUnlock): the whole trimmed
43
+ * message — "tier strict", "tier opinionated" or "tier full", case-insensitive — writes
44
+ * `<state dir>/autonomy-tier`. Only the adapter and the owner page call this, with text the owner
45
+ * really typed or tapped; a model, a tool result or a machine prompt must never reach it. Every
46
+ * applied switch is logged to the plan-guard log with `word` naming the entry point ("chat" or "ui").
47
+ */
48
+ export function chatTier(text: string, cfg: Config, source: string, word: "chat" | "ui" = "chat"): ChatTierResult {
49
+ if (!cfg.guards.chat_unlock) return { applied: false };
50
+ const m = TIER_CMD.exec(text.trim());
51
+ if (!m) return { applied: false };
52
+ const tier = (m[1] ?? "").toLowerCase() as Tier;
53
+ mkdirSync(stateDirPath(), { recursive: true });
54
+ writeFileSync(tierFile(), `${tier}\n`);
55
+ try {
56
+ appendFileSync(cfg.paths.plan_guard_log, `${new Date().toISOString()} TIER ${tier} ${word} source=${source}\n`);
57
+ } catch {}
58
+ return { applied: true, tier };
59
+ }
60
+
61
+ export interface ChatGoResult {
62
+ /** True when the text was a whole-message `go` command that took effect. */
63
+ applied: boolean;
64
+ /** The minutes this `go` stays valid (autonomy.go_minutes), for the owner notice. */
65
+ minutes?: number;
66
+ }
67
+
68
+ /**
69
+ * The strict tier's one-shot landing approval by chat (guards.chat_unlock): the whole trimmed
70
+ * message "go" touches `<state dir>/autonomy-go`; the next strict push/merge consumes it
71
+ * (takeGo). Same trust rules as chatTier.
72
+ */
73
+ export function chatGo(text: string, cfg: Config, source: string, word: "chat" | "ui" = "chat"): ChatGoResult {
74
+ if (!cfg.guards.chat_unlock) return { applied: false };
75
+ if (text.trim().toLowerCase() !== "go") return { applied: false };
76
+ mkdirSync(stateDirPath(), { recursive: true });
77
+ writeFileSync(goFile(), "");
78
+ try {
79
+ appendFileSync(cfg.paths.plan_guard_log, `${new Date().toISOString()} GO ${word} source=${source} minutes=${cfg.autonomy.go_minutes}\n`);
80
+ } catch {}
81
+ return { applied: true, minutes: cfg.autonomy.go_minutes };
82
+ }
83
+
84
+ /**
85
+ * Consume a standing `go`: true once — the file is deleted — when it is younger than
86
+ * autonomy.go_minutes; a stale or missing file is false (a stale one is removed).
87
+ */
88
+ export function takeGo(cfg: Config, now = Date.now()): boolean {
89
+ let mtimeMs: number;
90
+ try {
91
+ mtimeMs = statSync(goFile()).mtimeMs;
92
+ } catch {
93
+ return false;
94
+ }
95
+ rmSync(goFile(), { force: true });
96
+ return now - mtimeMs < cfg.autonomy.go_minutes * 60_000;
97
+ }
@@ -133,10 +133,20 @@ export interface Config {
133
133
  protected: string[];
134
134
  ledger_command: string;
135
135
  };
136
+ /** Autonomy tiers (I-20261025-177): how much Main may do without asking. The owner moves the
137
+ * tier (chat `tier <name>`, or the phone page); the guards follow it. */
138
+ autonomy: {
139
+ /** Tier in force when `<state dir>/autonomy-tier` does not name one (src/core/autonomy.ts). */
140
+ tier: "strict" | "opinionated" | "full";
141
+ /** Main's project-file changes per guards.main_window_min window in tier strict. */
142
+ strict_edit_limit: number;
143
+ /** Minutes one owner `go` approves exactly one push/merge in tier strict. */
144
+ go_minutes: number;
145
+ };
136
146
  /** The owner's phone page (`neurastream ui`): binds the tailnet address only. */
137
147
  ui: { enabled: boolean; port: number; owner_login: string };
138
148
  /** Static pages hosted over the tailnet. */
139
- pages: { enabled: boolean; port: number; dir: string };
149
+ pages: { enabled: boolean; port: number; dir: string; keep_days: number };
140
150
  rollover: { enabled: boolean; max_session_mb: number; exit_grace_s: number };
141
151
  metrics: { report_days: number; correction_patterns: string[]; ci_pipelines_cmd: string };
142
152
  /** Incident detectors (src/core/incident-detectors.ts): when a sighting becomes an incident. */
@@ -398,6 +408,12 @@ function check(cfg: Config): void {
398
408
  throw new ConfigError("guards.sub_max_calls_cap must be >= guards.sub_max_calls");
399
409
  }
400
410
  if (!(cfg.rollover.max_session_mb > 0)) throw new ConfigError("rollover.max_session_mb must be > 0");
411
+ if (cfg.autonomy.tier !== "strict" && cfg.autonomy.tier !== "opinionated" && cfg.autonomy.tier !== "full")
412
+ throw new ConfigError('autonomy.tier must be "strict", "opinionated" or "full"');
413
+ if (!Number.isInteger(cfg.autonomy.strict_edit_limit) || cfg.autonomy.strict_edit_limit < 1)
414
+ throw new ConfigError("autonomy.strict_edit_limit must be an integer >= 1");
415
+ if (!Number.isInteger(cfg.autonomy.go_minutes) || cfg.autonomy.go_minutes < 1)
416
+ throw new ConfigError("autonomy.go_minutes must be an integer >= 1");
401
417
  if (!Array.isArray(cfg.guards.rate_limit.patterns) || cfg.guards.rate_limit.patterns.some(p => typeof p !== "string" || p === "")) {
402
418
  throw new ConfigError("guards.rate_limit.patterns must be a list of non-empty strings");
403
419
  }
@@ -409,6 +425,7 @@ function check(cfg: Config): void {
409
425
  if (!(cfg.ui.port >= 1 && cfg.ui.port <= 65535)) throw new ConfigError("ui.port must be between 1 and 65535");
410
426
  if (!Number.isInteger(cfg.pages.port) || cfg.pages.port < 1 || cfg.pages.port > 65535) throw new ConfigError("pages.port must be an integer between 1 and 65535");
411
427
  if (typeof cfg.pages.dir !== "string" || cfg.pages.dir.length === 0) throw new ConfigError("pages.dir must be a non-empty path");
428
+ if (!Number.isInteger(cfg.pages.keep_days) || cfg.pages.keep_days < 1) throw new ConfigError("pages.keep_days must be an integer >= 1");
412
429
  for (const p of cfg.metrics.correction_patterns) {
413
430
  try {
414
431
  new RegExp(p, "i");
@@ -10,9 +10,13 @@
10
10
  // - protected guard files, unlockable by the owner for `guards.unlock_minutes`
11
11
  // - subs: no queue-close/queue-cancel, call budget 90/100, plan edits only inside "## Progress",
12
12
  // blocker execution, invalid plans refuse
13
- // - main: 5 project-file changes per `main_window_min` window (owner message resets), spawn
13
+ // - main: project-file changes per `main_window_min` window capped by the autonomy tier
14
+ // (strict: `autonomy.strict_edit_limit`, opinionated: 5, full: none), spawn
14
15
  // gate (allow-list, task-only, open plan, new Progress since last run), bypass launches go
15
- // through the same plan gate, cancel-pending blocks spawns and stops, keep-working stop rule
16
+ // through the same plan gate, cancel-pending blocks spawns and stops, keep-working stop rule;
17
+ // tier strict additionally refuses `git push` / `glab mr merge` / `gh pr merge` until the
18
+ // owner's one-shot `go`, and tier full lets a `Priority skip: <plan> — Main: "<reason>"` line
19
+ // past the priority gate
16
20
  // - incidents: while an incident is open (src/core/incidents.ts: no plan/dismiss/fixed record)
17
21
  // every Main prompt lists it, a spawn must be fix work (its plan cites `INCIDENT <id>`), and
18
22
  // the stop is refused; an incident with a plan no longer blocks
@@ -21,6 +25,7 @@ import { execFileSync } from "node:child_process";
21
25
  import { appendFileSync, mkdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
22
26
  import path from "node:path";
23
27
  import type { Decision, InjectEvent, PlanEditEvent, SpawnEvent, StopEvent, ToolEvent } from "./adapter.ts";
28
+ import { currentTier, takeGo, type Tier } from "./autonomy.ts";
24
29
  import type { Config } from "./config.ts";
25
30
  import { addIncident, openIncidents, type IncidentView } from "./incidents.ts";
26
31
  import { notifyProtectedPaths, notifySecretReadHit } from "./notify.ts";
@@ -390,15 +395,18 @@ function priorityIdle(p: Plan, plans: Plan[]): boolean {
390
395
  * Proof is either the higher plan's own `Waits on: <plan>` line for a plan still open in the index
391
396
  * (then it is not idle at all) or a `Priority skip: <path> — owner: "<words>"` line whose quoted
392
397
  * words (≥ 4, normalised) appear in one of `messages` (the owner's recorded words of the last
393
- * 24 h; `now` is the current unix seconds). Any other skip line is refused.
398
+ * 24 h; `now` is the current unix seconds). In tier full (`cfg`) a `Priority skip: <path> —
399
+ * Main: "<reason>"` line with ≥ 4 words is proof too; without `cfg` the refusal behaviour is the
400
+ * pre-tier one. Any other skip line is refused.
394
401
  * `staffed === undefined` means the caller had no running-job info (CLI spawn without it): never
395
402
  * refuse. Plans already named by this call never block it.
396
403
  */
397
- export function priorityProblem(plans: Plan[], named: string[], staffed: string[] | undefined, brief: string, messages: OwnerMessage[] = [], now: number = nowSec()): PriorityOutcome | null {
404
+ export function priorityProblem(plans: Plan[], named: string[], staffed: string[] | undefined, brief: string, messages: OwnerMessage[] = [], now: number = nowSec(), cfg?: Config): PriorityOutcome | null {
398
405
  if (staffed === undefined) return { unknown: true };
399
406
  const namedRanks = named.map(f => plans.findIndex(p => p.file === f)).filter(n => n >= 0);
400
407
  if (!namedRanks.length) return null;
401
408
  const higher = plans.slice(0, Math.min(...namedRanks));
409
+ const tier = cfg ? currentTier(cfg) : "opinionated";
402
410
  const skipLines: Record<string, string> = {};
403
411
  for (const m of brief.matchAll(SKIP_LINE)) {
404
412
  const plan = (m[1] ?? "").trim();
@@ -410,6 +418,13 @@ export function priorityProblem(plans: Plan[], named: string[], staffed: string[
410
418
  const p = higher[i]!;
411
419
  if (!priorityIdle(p, plans) || staffed.includes(p.file)) continue;
412
420
  const why = skipLines[p.file];
421
+ // Tier full (20261025_1940 P2): Main's own >= 4-word reason is proof enough; every other
422
+ // tier refuses it exactly as before — only the owner's recorded words let a skip through.
423
+ const mainWhy = tier === "full" ? why?.match(/^Main:\s*"(.+)"\s*$/) : undefined;
424
+ if (why && mainWhy && mainWhy[1]!.trim().split(/\s+/).length >= 4) {
425
+ skips.push({ plan: p.file, why });
426
+ continue;
427
+ }
413
428
  const quote = why?.match(/^owner:\s*"(.+)"\s*$/);
414
429
  if (why && quote && ownerSaid(quote[1]!, messages, now)) {
415
430
  skips.push({ plan: p.file, why });
@@ -422,7 +437,7 @@ export function priorityProblem(plans: Plan[], named: string[], staffed: string[
422
437
 
423
438
  /** Load staffing and the owner's recorded words, run the pure priority gate and log its outcome; the refusal comes back with the caller's label, or null. */
424
439
  function priorityGate(named: string[], runningJobs: string[] | undefined, brief: string, cfg: Config, label: string): string | null {
425
- const outcome = priorityProblem(q.activePlans(), named, runningJobs === undefined ? undefined : staffedPlans(readStaffing(), runningJobs), brief, readOwnerMessages(), nowSec());
440
+ const outcome = priorityProblem(q.activePlans(), named, runningJobs === undefined ? undefined : staffedPlans(readStaffing(), runningJobs), brief, readOwnerMessages(), nowSec(), cfg);
426
441
  if (outcome?.unknown) log(cfg.paths.guard_log, "PRIORITY unknown jobs");
427
442
  for (const s of outcome?.skips ?? []) log(cfg.paths.guard_log, `PRIORITY skip ${s.plan}: ${s.why}`);
428
443
  return outcome?.problem ? `${label}: ${outcome.problem}` : null;
@@ -531,6 +546,23 @@ function startsOwnerUi(input: Record<string, unknown>): boolean {
531
546
  });
532
547
  }
533
548
 
549
+ // True when a command segment lands work on a remote (plan 20261025_1940 P2): `git push`,
550
+ // `glab mr merge`, `gh pr merge`. Segment splitting and launcher skipping match startsOwnerUi,
551
+ // so `sh -c "git push"`, `sudo git push` and chained pushes are seen too.
552
+ function landingCommand(input: Record<string, unknown>): boolean {
553
+ const text = Object.values(input).filter((v): v is string => typeof v === "string").join("\n");
554
+ return text.split(/&&|\|\||;|\||\n|\$\(|`/).some(seg => {
555
+ const words = seg.trim().split(/\s+/).filter(Boolean).map(w => w.replace(/^["'(]+|["')]+$/g, ""));
556
+ let i = 0;
557
+ while (i < words.length && (LAUNCHERS[words[i] ?? ""] === true || /^\w+=/.test(words[i] ?? "") || /(^|\/)main\.ts$/.test(words[i] ?? ""))) i++;
558
+ const cmd = (words[i] ?? "").split("/").pop() ?? "";
559
+ if (cmd === "git" && words[i + 1] === "push") return true;
560
+ if (cmd === "glab" && words[i + 1] === "mr" && words[i + 2] === "merge") return true;
561
+ if (cmd === "gh" && words[i + 1] === "pr" && words[i + 2] === "merge") return true;
562
+ return false;
563
+ });
564
+ }
565
+
534
566
  // Subagent half of a tool call (the original plan-guard checkCall without the main return).
535
567
  // `cap` is the sub's hard call cap: its recorded per-spawn budget, else the global sub_max_calls.
536
568
  function subRules(e: ToolEvent, input: Record<string, unknown>, paths: string[], writes: string[], cfg: Config, cap: number): string | null {
@@ -565,33 +597,39 @@ function subRules(e: ToolEvent, input: Record<string, unknown>, paths: string[],
565
597
  return null;
566
598
  }
567
599
 
568
- // Main's edit limit: window starts at the first counted change, resets after main_window_min
569
- // minutes and at every owner message. State lives in the queue state dir so one-shot CLI
570
- // processes share the window (the original kept it in extension memory for one session).
600
+ // Main's edit limit (20261025_1940 P2): the cap follows the autonomy tier — autonomy.strict_edit_limit
601
+ // in strict, guards.main_edit_limit in opinionated, none in full. Window starts at the first counted
602
+ // change, resets after main_window_min minutes and at every owner message. State lives in the queue
603
+ // state dir so one-shot CLI processes share the window (the original kept it in extension memory for
604
+ // one session).
571
605
  function editWindow(e: ToolEvent, input: Record<string, unknown>, cfg: Config): Decision {
572
606
  const files = changedProjectFiles(e.tool, input, e.cwd, cfg);
573
607
  if (!files.length) return ALLOW;
608
+ const tier = currentTier(cfg);
609
+ if (tier === "full") return ALLOW; // no cap: Main works unattended
610
+ const limit = tier === "strict" ? cfg.autonomy.strict_edit_limit : cfg.guards.main_edit_limit;
611
+ const limitName = tier === "strict" ? "autonomy.strict_edit_limit" : "owner limit";
574
612
  const now = Date.now();
575
613
  const w = readWindow();
576
614
  if (w.used.length && now - w.windowStart >= cfg.guards.main_window_min * 60_000) w.used = [];
577
- if (w.used.length >= cfg.guards.main_edit_limit) {
615
+ if (w.used.length >= limit) {
578
616
  const mins = Math.ceil((w.windowStart + cfg.guards.main_window_min * 60_000 - now) / 60_000);
579
- log(cfg.paths.guard_log, `BLOCK tool=${e.tool} after ${w.used.length} edits: ${files.join(",")}`);
617
+ log(cfg.paths.guard_log, `BLOCK tool=${e.tool} after ${w.used.length} edits (tier ${tier}): ${files.join(",")}`);
580
618
  return deny(
581
- `main-guard: Main already changed project files ${w.used.length} times in this ${cfg.guards.main_window_min}-minute window ` +
582
- `(owner limit ${cfg.guards.main_edit_limit}; resets in ${mins} min). Main writes plans, not code: put the work in a plan ` +
619
+ `main-guard: tier ${tier} — Main already changed project files ${w.used.length} times in this ${cfg.guards.main_window_min}-minute window ` +
620
+ `(${limitName} ${limit}; resets in ${mins} min). Main writes plans, not code: put the work in a plan ` +
583
621
  `(listed in ${q.INDEX}, phase-0 blockers first) and spawn an implementer. Changes so far: ${w.used.join(", ")}`,
584
622
  );
585
623
  }
586
624
  if (!w.used.length) w.windowStart = now;
587
625
  w.used.push(`${e.tool}:${files[0]!}`);
588
626
  writeWindow(w);
589
- const left = cfg.guards.main_edit_limit - w.used.length;
627
+ const left = limit - w.used.length;
590
628
  if (left <= 2)
591
629
  return {
592
630
  allow: true,
593
631
  reason: "",
594
- inject: `main-guard: ${left} project-file change(s) left in this ${cfg.guards.main_window_min}-minute window; then delegate.`,
632
+ inject: `main-guard: tier ${tier} — ${left} project-file change(s) left in this ${cfg.guards.main_window_min}-minute window; then delegate.`,
595
633
  };
596
634
  return ALLOW;
597
635
  }
@@ -662,6 +700,13 @@ function mainTool(e: ToolEvent, input: Record<string, unknown>, cfg: Config): De
662
700
  return ALLOW;
663
701
  }
664
702
  if (cfg.guards.shell_tools.includes(e.tool)) {
703
+ // Strict landing gate (20261025_1940 P2): in tier strict every push/merge waits for the
704
+ // owner's one-shot `go` (autonomy.go_minutes); the landing that consumes it goes through.
705
+ // Opinionated and full keep today's allowance. Owner-only rules above are untouched.
706
+ if (landingCommand(input) && currentTier(cfg) === "strict" && !takeGo(cfg)) {
707
+ log(cfg.paths.guard_log, "BLOCK landing: tier strict, no go");
708
+ return deny('main-guard: tier strict — type "go" to approve one push/merge');
709
+ }
665
710
  const command = String(input?.command ?? input?.code ?? "");
666
711
  for (const entry of cfg.guards.bypass_spawn) {
667
712
  if (!bypassRegExp(entry).test(command)) continue;
@@ -888,7 +933,15 @@ export function checkInject(e: InjectEvent, cfg: Config): Decision {
888
933
  const cancel = continuation ? "" : flagCancel(e.inject, cfg);
889
934
  const incidents = openIncidentList(cfg);
890
935
  const incidentText = incidents.length ? `\n${incidents.map(incidentLine).join("\n")}` : "";
891
- const editLimit = continuation ? "" : `\nmain-guard: Main may change project files at most ${cfg.guards.main_edit_limit} times per ${cfg.guards.main_window_min}-minute window; then delegate.`;
936
+ // 20261025_1940 P2: the injected line names the autonomy tier and what Main does without asking in it.
937
+ const tier = currentTier(cfg);
938
+ const tierNote =
939
+ tier === "strict"
940
+ ? `Main changes at most ${cfg.autonomy.strict_edit_limit} project files per ${cfg.guards.main_window_min} min, and every git push / glab mr merge / gh pr merge waits for your "go" (one landing, valid ${cfg.autonomy.go_minutes} min).`
941
+ : tier === "full"
942
+ ? `Main works unattended: no edit cap, its own "Priority skip: <plan> — Main: \\"<reason>\\"" skips pass, pushes and merges go through. Owner-only moves (guard files, the phone page, notify secrets, the unlock) stay locked.`
943
+ : `Main changes at most ${cfg.guards.main_edit_limit} project files per ${cfg.guards.main_window_min} min; pushes and merges go through.`;
944
+ const editLimit = continuation ? "" : `\nautonomy: ${tier} — ${tierNote}`;
892
945
  return {
893
946
  allow: true,
894
947
  reason: "",
@@ -12,6 +12,7 @@ import { randomUUID } from "node:crypto";
12
12
  import os from "node:os";
13
13
  import { basename, resolve } from "node:path";
14
14
  import type { RunSource } from "./adapter.ts";
15
+ import { chatTier, currentTier, type Tier } from "./autonomy.ts";
15
16
  import type { Config } from "./config.ts";
16
17
  import { nowSec, strftime } from "./clock.ts";
17
18
  import { cpuCount } from "./host.ts";
@@ -435,19 +436,21 @@ function tilesHtml(data: PageData): string {
435
436
  return [needsTile, spendTileHtml(data), runs, plans].join("\n");
436
437
  }
437
438
 
438
- /** The sticky mockup top bar: logo, pill tabs, and the lock pill that posts the unlock/lock forms. */
439
+ /** The sticky mockup top bar: logo, pill tabs, and the lock pill that posts the unlock/lock and tier forms. */
439
440
  function topBarHtml(tab: string, lockMinutesLeft: number | null, cfg: Config): string {
440
441
  const tabs: [string, string][] = [["now", "Now"], ["queue", "Queue"], ["agents", "Agents"], ["spend", "Spend"]];
441
442
  const pills = tabs.map(([id, label]) => `<a href="/?tab=${id}"${tab === id ? ` class="on"` : ""}>${label}</a>`).join("");
442
443
  const lockLabel = lockMinutesLeft === null ? "🔒 Off" : `🔓 ${lockMinutesLeft} min`;
443
444
  const unlockForm = (minutes: number) =>
444
445
  `<form method="post" action="/unlock"><input type="hidden" name="minutes" value="${minutes}"><button class="btn" type="submit">Unlock ${minutes} min</button></form>`;
446
+ const tierForm = (name: Tier, label: string) =>
447
+ `<form method="post" action="/tier"><input type="hidden" name="tier" value="${name}"><button class="btn${currentTier(cfg) === name ? " on" : ""}" type="submit">${label}</button></form>`;
445
448
  const off = cfg.guards.chat_unlock
446
449
  ? ""
447
450
  : `<p class="offnote">Unlocking from the page is switched off in the config. To turn it on, set:</p><code class="offcfg">guards: chat_unlock: true</code>`;
448
451
  return `<div class="top"><span class="logo">ns</span>
449
452
  <nav class="pills" aria-label="Sections">${pills}</nav>
450
- <details class="lock" id="lock-pill"><summary>${lockLabel}</summary><div class="lockmenu">${unlockForm(15)}${unlockForm(30)}<form method="post" action="/lock"><button class="btn" type="submit">Lock now</button></form>${off}</div></details>
453
+ <details class="lock" id="lock-pill"><summary>${lockLabel}</summary><div class="lockmenu">${unlockForm(15)}${unlockForm(30)}<form method="post" action="/lock"><button class="btn" type="submit">Lock now</button></form><hr>${tierForm("strict", "Tier: strict")}${tierForm("opinionated", "Tier: opinionated")}${tierForm("full", "Tier: full")}${off}</div></details>
451
454
  </div>`;
452
455
  }
453
456
 
@@ -836,6 +839,21 @@ function handleLock(cfg: Config, login: string): Response {
836
839
  return redirect("/?sent=lock");
837
840
  }
838
841
 
842
+ const TIERS: readonly Tier[] = ["strict", "opinionated", "full"];
843
+
844
+ // Autonomy tier from the phone page (plan 20261025_1940 P3): behind the same auth as every other
845
+ // route, written by the core chatTier with the owner's tapped name; a bad name is a 400 before
846
+ // the core is called, and the chat gate off redirects to the plain-words note like unlock/lock.
847
+ function handleTier(cfg: Config, fields: Record<string, string>, login: string): Response {
848
+ const name = (fields.tier ?? "").trim().toLowerCase();
849
+ if (!(TIERS as readonly string[]).includes(name)) return textRes("tier must be strict, opinionated or full", 400);
850
+ const result = chatTier(`tier ${name}`, cfg, `ui:${login}`, "ui");
851
+ if (!result.applied) return redirect("/?sent=unlock-off");
852
+ mkdirSync(stateDirPath(), { recursive: true });
853
+ appendFileSync(inboxPath(), `${JSON.stringify({ ts: nowSec(), kind: "tier", tier: result.tier, login })}\n`);
854
+ return redirect(`/?sent=tier&tier=${result.tier}`);
855
+ }
856
+
839
857
  // ---- queue reorder (plan P4): the owner drags a card; INDEX.md is rewritten atomically ----
840
858
 
841
859
  /**
@@ -996,6 +1014,9 @@ export function startOwnerUi(opts: OwnerUiOptions): OwnerUiServer {
996
1014
  } else if (req.method === "POST" && url.pathname === "/lock") {
997
1015
  res = handleLock(cfg, login);
998
1016
  code = res.status;
1017
+ } else if (req.method === "POST" && url.pathname === "/tier") {
1018
+ res = handleTier(cfg, await fieldsOf(req), login);
1019
+ code = res.status;
999
1020
  } else if (req.method === "POST" && url.pathname === "/reorder") {
1000
1021
  res = handleReorder(cfg, await fieldsOf(req), login);
1001
1022
  code = res.status;
@@ -0,0 +1,79 @@
1
+ import { lstatSync, readdirSync, readFileSync, renameSync, unlinkSync, writeFileSync } from "node:fs";
2
+ import { join } from "node:path";
3
+
4
+ export interface ExpiryRecord { published: string; expires: string | null }
5
+ export type ExpiryMap = Record<string, ExpiryRecord>;
6
+
7
+ const RECORD = ".expiry.json";
8
+ const DAY_MS = 86_400_000;
9
+
10
+ function expiryRecord(value: unknown): ExpiryRecord | null {
11
+ if (!value || typeof value !== "object" || Array.isArray(value)) return null;
12
+ const published = "published" in value ? value.published : undefined;
13
+ const expires = "expires" in value ? value.expires : undefined;
14
+ if (typeof published !== "string") return null;
15
+ if (expires !== null && typeof expires !== "string") return null;
16
+ return { published, expires };
17
+ }
18
+
19
+ export function readExpiry(dir: string): ExpiryMap {
20
+ const path = join(dir, RECORD);
21
+ let st;
22
+ try { st = lstatSync(path); } catch { return {}; }
23
+ if (!st.isFile()) return {};
24
+ try {
25
+ const parsed: unknown = JSON.parse(readFileSync(path, "utf8"));
26
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return {};
27
+ const out: ExpiryMap = {};
28
+ for (const [name, value] of Object.entries(parsed)) {
29
+ const rec = expiryRecord(value);
30
+ if (rec) out[name] = rec;
31
+ }
32
+ return out;
33
+ } catch { return {}; }
34
+ }
35
+
36
+ function writeExpiry(dir: string, map: ExpiryMap): void {
37
+ const tmp = join(dir, `.expiry.${process.pid}.${Date.now()}.tmp`);
38
+ writeFileSync(tmp, `${JSON.stringify(map)}\n`);
39
+ renameSync(tmp, join(dir, RECORD));
40
+ }
41
+
42
+ export function recordPublish(dir: string, name: string, keep: boolean, keepDays: number, now: Date): ExpiryRecord {
43
+ const map = readExpiry(dir);
44
+ const existing = map[name];
45
+ const rec: ExpiryRecord = {
46
+ published: now.toISOString(),
47
+ expires: keep || existing?.expires === null ? null : new Date(now.getTime() + keepDays * DAY_MS).toISOString(),
48
+ };
49
+ map[name] = rec;
50
+ writeExpiry(dir, map);
51
+ return rec;
52
+ }
53
+
54
+ export function sweepPages(dir: string, keepDays: number, now: Date): { removed: string[] } {
55
+ let dirStat;
56
+ try { dirStat = lstatSync(dir); } catch { return { removed: [] }; }
57
+ if (!dirStat.isDirectory()) return { removed: [] };
58
+ const map = readExpiry(dir);
59
+ const next: ExpiryMap = {};
60
+ const removed: string[] = [];
61
+ for (const entry of readdirSync(dir, { withFileTypes: true })) {
62
+ if (entry.name.startsWith(".") || !entry.isFile()) continue;
63
+ const path = join(dir, entry.name);
64
+ let st;
65
+ try { st = lstatSync(path); } catch { continue; }
66
+ if (!st.isFile()) continue;
67
+ const rec = map[entry.name];
68
+ const expiresAt = rec?.expires == null ? null : Date.parse(rec.expires);
69
+ if (typeof expiresAt === "number" && Number.isFinite(expiresAt) && expiresAt < now.getTime()) {
70
+ unlinkSync(path);
71
+ removed.push(entry.name);
72
+ continue;
73
+ }
74
+ if (rec && (rec.expires === null || (typeof expiresAt === "number" && Number.isFinite(expiresAt)))) next[entry.name] = rec;
75
+ else next[entry.name] = { published: now.toISOString(), expires: new Date(now.getTime() + keepDays * DAY_MS).toISOString() };
76
+ }
77
+ writeExpiry(dir, next);
78
+ return { removed };
79
+ }
@@ -4,6 +4,7 @@ import { homedir } from "node:os";
4
4
  import { dirname, join, basename, extname } from "node:path";
5
5
  import { fileURLToPath } from "node:url";
6
6
  import { configFile, loadConfig } from "./config.ts";
7
+ import { recordPublish } from "./pages-expiry.ts";
7
8
  import { realTailscale, type Tailscale } from "./tailscale.ts";
8
9
  const HERE = dirname(fileURLToPath(import.meta.url));
9
10
  export const PAGES_UNIT_TEMPLATE = join(HERE, "../../templates/systemd/neurastream-pages.service");
@@ -45,9 +46,9 @@ export function pagesOff(opts: Setup = {}): number {
45
46
  const cfg=loadConfig({home}); writeFileSync(file,editBlock(old,{enabled:false,port:cfg.pages.port,dir:cfg.pages.dir}));
46
47
  const r=runner(["--user","stop","neurastream-pages"]); if(r.status!==0){console.error(r.stderr);return 1;} return 0;
47
48
  }
48
- export function publishPage(file: string, name: string | undefined, force: boolean, dir: string): string {
49
+ export function publishPage(file: string, name: string | undefined, force: boolean, dir: string, keep = false, keepDays = 15, now = new Date()): string {
49
50
  const source=basename(file), base=(name ?? source.slice(0,source.length-extname(source).length)).toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"");
50
51
  const targetName=base+extname(source).toLowerCase(), target=join(dir,targetName); mkdirSync(dir,{recursive:true});
51
- if(existsSync(target)){const a=readFileSync(file),b=readFileSync(target); if(a.equals(b)) return targetName; if(!force) throw new Error(`pages: ${targetName} exists with different content (use --force)`);}
52
- copyFileSync(file,target); return targetName;
52
+ if(existsSync(target)){const a=readFileSync(file),b=readFileSync(target); if(a.equals(b)){recordPublish(dir,targetName,keep,keepDays,now);return targetName;} if(!force) throw new Error(`pages: ${targetName} exists with different content (use --force)`);}
53
+ copyFileSync(file,target); recordPublish(dir,targetName,keep,keepDays,now); return targetName;
53
54
  }
@@ -27,3 +27,5 @@ You are Main, the orchestrator. Main plans, delegates, reviews and lands; implem
27
27
  |`machine-guard`, `heavy-run`|machine-guard at session start and before launches; every test run goes through heavy-run|
28
28
 
29
29
  Guard files are locked for every agent; the owner unlocks with `touch {{AGENT_DIR}}/.guard-unlock` (30 min), or — when `guards.chat_unlock` is on in the config — by typing `unlock 30` in chat (`lock` closes it again).
30
+
31
+ Autonomy tiers: the owner sets how much Main does unattended with one word — `tier strict` (edit cap `autonomy.strict_edit_limit`; every `git push`, `glab mr merge` or `gh pr merge` also waits until the owner types `go`, which approves exactly one landing for `autonomy.go_minutes` minutes), `tier opinionated` (the limits above), or `tier full` (no edit cap, and a `Priority skip: <plan> — Main: "<reason>"` line with a reason of at least four words may skip an idle higher plan). Pushes stay owner-ruled in strict and opinionated as above; whatever the tier, guard files, the phone page, notify secrets and the unlock stay owner-only.
@@ -125,6 +125,11 @@ guards:
125
125
  protected: []
126
126
  ledger_command: "agent-ledger --hours 12"
127
127
 
128
+ autonomy:
129
+ tier: opinionated # strict | opinionated | full: how much Main does without asking; the owner moves it with `tier <name>` in chat or a button on the phone page
130
+ strict_edit_limit: 2 # Main's project-file changes per main_window_min in tier strict
131
+ go_minutes: 10 # minutes one owner `go` approves exactly one push/merge in tier strict
132
+
128
133
  ui:
129
134
  enabled: false # the owner's phone page (neurastream ui); binds the tailnet address only
130
135
  port: 7787
@@ -135,6 +140,7 @@ pages:
135
140
  enabled: false
136
141
  port: 7788
137
142
  dir: "~/.local/share/neurastream/pages"
143
+ keep_days: 15 # delete a published page this many days later; publish --keep is permanent
138
144
  rollover:
139
145
  enabled: true
140
146
  max_session_mb: 5
@@ -53,4 +53,4 @@ Open the file at two widths and check the root plus one drilled level:
53
53
 
54
54
  ## Host
55
55
 
56
- Single file: open it from disk, or serve the folder with any static server. Share the file as-is.
56
+ Build the HTML in a scratch directory (`mktemp -d`), not in a repo. Publish it with `neurastream pages publish <file>`. The page is deleted after 15 days. Add `--keep` only when the owner's prompt says to keep it permanently. Never commit the HTML into a repo unless the owner asks.