neurastream 0.2.56 → 0.2.57
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 +1 -1
- package/package.json +1 -1
- package/src/adapters/omp/index.ts +10 -0
- package/src/core/config.ts +4 -0
- package/src/core/guards.ts +3 -17
- package/src/core/page-notes.ts +1 -1
- package/src/core/pages.ts +8 -4
- package/src/core/plan-approval.ts +104 -29
- package/templates/AGENTS.md +1 -0
- package/templates/config.yml +2 -0
package/README.md
CHANGED
|
@@ -141,7 +141,7 @@ An answer appends one record to `<queue_state>/owner-inbox.jsonl` (plan, questio
|
|
|
141
141
|
|
|
142
142
|
## Static pages (`neurastream pages`)
|
|
143
143
|
|
|
144
|
-
`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. A published HTML page carries the notes panel `pages publish` injects: `neurastream notes check <page>` exits 1 while any note on it has no answer in `<queue_state>/page-notes/<page>.answers.json`, and `pages publish` refuses that page until the file answers every id; `pages publish <html> <name> --plan <plan.md>` marks the page as a plan's diagram: it then carries an Approve bar that records
|
|
144
|
+
`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. A published HTML page carries the notes panel `pages publish` injects: `neurastream notes check <page>` exits 1 while any note on it has no answer in `<queue_state>/page-notes/<page>.answers.json`, and `pages publish` refuses that page until the file answers every id; `pages publish <html> <name> --plan <plan.md>` marks the page as a plan's diagram: it then carries an Approve bar that records the plan's text hash in `<queue_state>/plan-approvals.json` and never edits the plan (disabled, and refused with 409, while a note on the page has no answer), and `neurastream diagram check <html> <plan.md>` requires that page to show every phase of the plan and every file or command its phase lines name, with 2+ kids behind every drilldown — `pages publish --plan` runs it, and Approve stays disabled (the server answers 409) until it passes. main-guard refuses a spawn on a plan that has such a page and no approval record whose hash matches the plan's current text. The publish that goes through prints each answer beside its note, archives the closed notes and never reuses an id.
|
|
145
145
|
|
|
146
146
|
## Base tab (`/?tab=knowledge`)
|
|
147
147
|
|
package/package.json
CHANGED
|
@@ -21,6 +21,7 @@ import { basename, dirname, extname, join, resolve } from "node:path";
|
|
|
21
21
|
import type { Decision } from "../../core/adapter.ts";
|
|
22
22
|
import { AGENTS_TEMPLATE, renderBlock } from "../../core/agents-md.ts";
|
|
23
23
|
import { chatGo, chatTier, type Tier } from "../../core/autonomy.ts";
|
|
24
|
+
import { chatApprove } from "../../core/plan-approval.ts";
|
|
24
25
|
import { burdenRule, repoRules, rulesChanged } from "../../core/repo-rules.ts";
|
|
25
26
|
import { configFile, loadConfig, reloadingConfig, type Config } from "../../core/config.ts";
|
|
26
27
|
import { checkWrite, deferSteer, type WriteCheckConfig } from "../../core/write-check.ts";
|
|
@@ -1461,6 +1462,15 @@ export function createOmpAdapter(pi: ExtensionHost, initial: Config, freshConfig
|
|
|
1461
1462
|
notifyGo(ctx, g);
|
|
1462
1463
|
return { handled: true };
|
|
1463
1464
|
}
|
|
1465
|
+
const a = chatApprove(text, cfg, "interactive");
|
|
1466
|
+
if (a.applied) {
|
|
1467
|
+
asRolloverCtx(ctx)?.notify(`approved ${basename(a.plan)}`);
|
|
1468
|
+
return { handled: true };
|
|
1469
|
+
}
|
|
1470
|
+
if (a.problem !== undefined) {
|
|
1471
|
+
asRolloverCtx(ctx)?.notify(a.problem);
|
|
1472
|
+
return { handled: true };
|
|
1473
|
+
}
|
|
1464
1474
|
const r = q.chatUnlock(asString(e.text), cfg, "interactive");
|
|
1465
1475
|
if (!r.applied) return undefined;
|
|
1466
1476
|
notifyUnlock(ctx, r);
|
package/src/core/config.ts
CHANGED
|
@@ -172,6 +172,8 @@ export interface Config {
|
|
|
172
172
|
/** Minutes the spawn gate caches a repo's open-MR list in <queue_state>/mr-cache.json; 0 = no cache. */
|
|
173
173
|
mr_cache_minutes: number;
|
|
174
174
|
};
|
|
175
|
+
/** Plan approval hard gate (plan 20261029_1455 P3): a plan stamped at or after `since` needs a page and an approval record. "" = off. */
|
|
176
|
+
approval: { since: string };
|
|
175
177
|
/** Static pages hosted over the tailnet. */
|
|
176
178
|
pages: { enabled: boolean; port: number; dir: string; keep_days: number };
|
|
177
179
|
/** Repo-local HTML explainers under docs/knowledge/ (owner page Knowledge tab). */
|
|
@@ -523,6 +525,8 @@ function check(cfg: Config): void {
|
|
|
523
525
|
throw new ConfigError('review.agents must be a list of agent names allowed to run review spawns (default ["reviewer"])');
|
|
524
526
|
if (!Number.isInteger(cfg.review.mr_cache_minutes) || cfg.review.mr_cache_minutes < 0)
|
|
525
527
|
throw new ConfigError("review.mr_cache_minutes must be an integer >= 0 (minutes the spawn gate caches a repo's open-MR list; 0 = no cache)");
|
|
528
|
+
if (typeof cfg.approval.since !== "string" || (cfg.approval.since !== "" && !/^\d{8}_\d{4}$/.test(cfg.approval.since)))
|
|
529
|
+
throw new ConfigError('approval.since must be "" or a plan stamp YYYYMMDD_HHMM (plans stamped at or after it need a page and an approval record)');
|
|
526
530
|
if (cfg.autonomy.tier !== "strict" && cfg.autonomy.tier !== "opinionated" && cfg.autonomy.tier !== "full")
|
|
527
531
|
throw new ConfigError('autonomy.tier must be "strict", "opinionated" or "full"');
|
|
528
532
|
if (!Number.isInteger(cfg.autonomy.strict_edit_limit) || cfg.autonomy.strict_edit_limit < 1)
|
package/src/core/guards.ts
CHANGED
|
@@ -26,7 +26,8 @@ import { appendFileSync, mkdirSync, readFileSync, statSync, writeFileSync } from
|
|
|
26
26
|
import path from "node:path";
|
|
27
27
|
import type { Decision, InjectEvent, PlanEditEvent, SpawnEvent, StopEvent, ToolEvent } from "./adapter.ts";
|
|
28
28
|
import { currentTier, takeGo } from "./autonomy.ts";
|
|
29
|
-
import { approvalProblem } from "./plan-approval.ts";
|
|
29
|
+
import { approvalProblem, MAIN_ONLY_LINE, reviewHash } from "./plan-approval.ts";
|
|
30
|
+
export { reviewHash };
|
|
30
31
|
import type { Config } from "./config.ts";
|
|
31
32
|
import { addIncident, openIncidents, ownerMessagesFile, ownerSaid, readOwnerMessages, type IncidentView, type OwnerMessage } from "./incidents.ts";
|
|
32
33
|
import { notifyProtectedPaths, notifySecretReadHit } from "./notify.ts";
|
|
@@ -167,18 +168,6 @@ function writePlanReviews(reviews: Record<string, PlanReview>, cfg: Config): voi
|
|
|
167
168
|
}
|
|
168
169
|
}
|
|
169
170
|
|
|
170
|
-
/** What a PASS covers: the plan text outside "## Progress" without the Main-only lines, so progress notes never expire a review. */
|
|
171
|
-
export function reviewHash(text: string): string {
|
|
172
|
-
return q.sha(
|
|
173
|
-
q
|
|
174
|
-
.outsideProgress(text)
|
|
175
|
-
.split("\n")
|
|
176
|
-
.filter(l => !MAIN_ONLY_LINE.test(l))
|
|
177
|
-
.map(l => l.replace(/^(\s*[-*]\s+)\[[xX]\]/, "$1[ ]")) // a ticked phase box hashes as unticked: ticking never expires a PASS
|
|
178
|
-
.join("\n"),
|
|
179
|
-
);
|
|
180
|
-
}
|
|
181
|
-
|
|
182
171
|
/** The progress entry that records a review; only a subagent's edit can carry one. The verdict is the match, never a substring. */
|
|
183
172
|
const REVIEW_LINE = /^- (?:\d{4}-\d{2}-\d{2} \d{2}:\d{2} [^\s:]+: )?PLAN REVIEW: (PASS|FAIL)\b/;
|
|
184
173
|
/** Any entry that opens like a review line; one that REVIEW_LINE does not match is restored, not recorded. */
|
|
@@ -597,7 +586,7 @@ export function planGate(text: string, label: string, cfg?: Config): [string | n
|
|
|
597
586
|
[],
|
|
598
587
|
];
|
|
599
588
|
if (cfg) {
|
|
600
|
-
const approval = approvalProblem(p.text, p.file, cfg.pages.dir);
|
|
589
|
+
const approval = approvalProblem(p.text, p.file, cfg.pages.dir, cfg.approval.since);
|
|
601
590
|
if (approval) return [approval, []];
|
|
602
591
|
}
|
|
603
592
|
const open = unticked(p);
|
|
@@ -1527,9 +1516,6 @@ export function checkInject(e: InjectEvent, cfg: Config): Decision {
|
|
|
1527
1516
|
};
|
|
1528
1517
|
}
|
|
1529
1518
|
|
|
1530
|
-
// Lines only Main may write: the status, owner parking, plan waits, owner cancellation, cancelled-list clearance.
|
|
1531
|
-
const MAIN_ONLY_LINE = /^\s*(?:[-*]\s+)?(Status:|WAITING on owner:|Waits on:|Cancelled by owner:|False positive:)/;
|
|
1532
|
-
|
|
1533
1519
|
function mainOnlyLines(text: string): string {
|
|
1534
1520
|
return text.split("\n").filter(l => MAIN_ONLY_LINE.test(l)).join("\n");
|
|
1535
1521
|
}
|
package/src/core/page-notes.ts
CHANGED
|
@@ -122,7 +122,7 @@ function approveBlock(chrome: ApproveChrome): string {
|
|
|
122
122
|
<script>(function(){var page="${page}",btn=document.getElementById("ns-approve-btn"),status=document.getElementById("ns-approve-status");
|
|
123
123
|
function set(open,problems){var bad=(problems||[]);btn.disabled=open.length>0||bad.length>0;status.textContent=open.length>0?"Answer every note first ("+open.join(", ")+")":bad.length>0?"The diagram is not complete yet ("+bad.length+"): "+bad.slice(0,3).join("; "):"Approve and go \u2014 the plan records it.";}
|
|
124
124
|
fetch("/_approve?page="+page).then(function(r){return r.json();}).then(function(d){set(d.open||[],d.problems);}).catch(function(){set(["?"],[]);});
|
|
125
|
-
btn.addEventListener("click",function(){btn.disabled=true;fetch("/_approve?page="+page,{method:"POST",headers:{"content-type":"application/json"},body:"{}"}).then(function(r){return r.json().then(function(d){return {ok:r.ok,body:d};});}).then(function(res){status.textContent=res.ok?
|
|
125
|
+
btn.addEventListener("click",function(){btn.disabled=true;fetch("/_approve?page="+page,{method:"POST",headers:{"content-type":"application/json"},body:"{}"}).then(function(r){return r.json().then(function(d){return {ok:r.ok,body:d};});}).then(function(res){status.textContent=res.ok?res.body.approved:"Not approved: "+res.body.error;btn.disabled=!res.ok;}).catch(function(){status.textContent="Not approved: the pages server did not answer.";btn.disabled=false;});});
|
|
126
126
|
})();</script>
|
|
127
127
|
</section>`;
|
|
128
128
|
}
|
package/src/core/pages.ts
CHANGED
|
@@ -27,9 +27,9 @@ export function startPagesServer(opts: PagesOptions): PagesServer {
|
|
|
27
27
|
// rows Main delivers. Same origin only, so another site's tab cannot write to the inbox; nothing here
|
|
28
28
|
// touches the page file, and a submit with no note text is refused.
|
|
29
29
|
if (req.method === "POST") {
|
|
30
|
-
// Approve from the plan's own page (plan 20261026 P9): the click records
|
|
31
|
-
// in the
|
|
32
|
-
// note on the page has no answer.
|
|
30
|
+
// Approve from the plan's own page (plan 20261026 P9): the click records a hash of the plan text
|
|
31
|
+
// in the queue state (plan-approvals.json). Only that plan, only from this page's origin, and
|
|
32
|
+
// never while a note on the page has no answer.
|
|
33
33
|
if (url.pathname === "/_approve") {
|
|
34
34
|
if (req.headers.get("origin") !== `http://${req.headers.get("host")}`) return plain("forbidden: origin is not this page", 403);
|
|
35
35
|
const page = url.searchParams.get("page") ?? "";
|
|
@@ -41,7 +41,11 @@ export function startPagesServer(opts: PagesOptions): PagesServer {
|
|
|
41
41
|
if (unproven.length > 0) return Response.json({ error: `the diagram is not complete (${unproven.slice(0, 3).join("; ")})` }, { status: 409 });
|
|
42
42
|
const plan = record.plan;
|
|
43
43
|
if (!existsSync(plan)) return plain("not found: the plan file is gone", 404);
|
|
44
|
-
|
|
44
|
+
try {
|
|
45
|
+
return Response.json({ approved: approvePlanFile(plan, page) });
|
|
46
|
+
} catch (e) {
|
|
47
|
+
return plain(`not approved: ${e instanceof Error ? e.message : String(e)}`, 500);
|
|
48
|
+
}
|
|
45
49
|
}
|
|
46
50
|
if (url.pathname !== "/_notes") return plain("method not allowed", 405);
|
|
47
51
|
if (req.headers.get("origin") !== `http://${req.headers.get("host")}`) return plain("forbidden: origin is not this page", 403);
|
|
@@ -1,13 +1,26 @@
|
|
|
1
1
|
// Plan approval from the plan's own diagram page (plan 20261026_0930 P9). A plan that has a page in
|
|
2
|
-
// Base is approved there
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
2
|
+
// Base is approved there: the Approve bar records a hash of the plan text in the queue state
|
|
3
|
+
// (plan-approvals.json). The plan file is never edited. main-guard refuses a spawn on a plan whose page
|
|
4
|
+
// has no record with the plan's current hash; a plan with no page predates the convention and is left alone, unless it is stamped at or after approval.since (plan 20261029_1455 P3), when it is refused until its page is published.
|
|
5
|
+
import { appendFileSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
|
|
6
|
+
import { basename, join, resolve } from "node:path";
|
|
7
|
+
import * as q from "./queue/lib.ts";
|
|
8
|
+
import type { Config } from "./config.ts";
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
const
|
|
10
|
+
/** Lines only Main may write: the status, owner parking, plan waits, owner cancellation, cancelled-list clearance. */
|
|
11
|
+
export const MAIN_ONLY_LINE = /^\s*(?:[-*]\s+)?(Status:|WAITING on owner:|Waits on:|Cancelled by owner:|False positive:)/;
|
|
12
|
+
|
|
13
|
+
/** What a PASS covers: the plan text outside "## Progress" without the Main-only lines, so progress notes never expire a review. */
|
|
14
|
+
export function reviewHash(text: string): string {
|
|
15
|
+
return q.sha(
|
|
16
|
+
q
|
|
17
|
+
.outsideProgress(text)
|
|
18
|
+
.split("\n")
|
|
19
|
+
.filter(l => !MAIN_ONLY_LINE.test(l))
|
|
20
|
+
.map(l => l.replace(/^(\s*[-*]\s+)\[[xX]\]/, "$1[ ]")) // a ticked phase box hashes as unticked: ticking never expires a PASS
|
|
21
|
+
.join("\n"),
|
|
22
|
+
);
|
|
23
|
+
}
|
|
11
24
|
|
|
12
25
|
/** What publishing recorded for a page: the plan it approves and what its diagram check found. */
|
|
13
26
|
export interface PagePlan {
|
|
@@ -60,36 +73,98 @@ export function pageOfPlan(dir: string, file: string): string | null {
|
|
|
60
73
|
return null;
|
|
61
74
|
}
|
|
62
75
|
|
|
63
|
-
|
|
64
|
-
|
|
76
|
+
// --- Plan approval records (plan 20261026_0930 P9): a hash in the queue state, not a line in the plan ---
|
|
77
|
+
|
|
78
|
+
/** One approval: the plan text it covers, when it was recorded, and how. */
|
|
79
|
+
export interface PlanApproval {
|
|
80
|
+
hash: string;
|
|
81
|
+
at: number;
|
|
82
|
+
via: "page" | "chat";
|
|
83
|
+
page: string;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function planApprovalsFile(): string {
|
|
87
|
+
return join(q.STATE_DIR, "plan-approvals.json");
|
|
65
88
|
}
|
|
66
89
|
|
|
67
|
-
|
|
68
|
-
|
|
90
|
+
function readPlanApprovals(): Record<string, PlanApproval> {
|
|
91
|
+
try {
|
|
92
|
+
const parsed = JSON.parse(readFileSync(planApprovalsFile(), "utf8"));
|
|
93
|
+
if (parsed?.approvals && typeof parsed.approvals === "object") return parsed.approvals as Record<string, PlanApproval>;
|
|
94
|
+
} catch {
|
|
95
|
+
}
|
|
96
|
+
return {};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function writePlanApprovals(approvals: Record<string, PlanApproval>): boolean {
|
|
100
|
+
try {
|
|
101
|
+
mkdirSync(q.STATE_DIR, { recursive: true });
|
|
102
|
+
writeFileSync(planApprovalsFile(), JSON.stringify({ approvals }, null, 1));
|
|
103
|
+
return true;
|
|
104
|
+
} catch {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
69
107
|
}
|
|
70
108
|
|
|
71
|
-
|
|
72
|
-
return
|
|
109
|
+
function readPlanApproval(file: string): PlanApproval | null {
|
|
110
|
+
return readPlanApprovals()[file] ?? null;
|
|
73
111
|
}
|
|
74
112
|
|
|
75
|
-
/**
|
|
76
|
-
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
return at < 0 ? `${text.replace(/\s*$/, "")}\n${line}\n` : `${text.slice(0, at)}${line}\n\n${text.slice(at)}`;
|
|
113
|
+
/** Record one approval. Throws when the queue state cannot be written, so nobody reports "approved" for a record that is not there. */
|
|
114
|
+
function recordApproval(file: string, approval: PlanApproval): void {
|
|
115
|
+
const approvals = readPlanApprovals();
|
|
116
|
+
approvals[file] = approval;
|
|
117
|
+
if (!writePlanApprovals(approvals)) throw new Error(`cannot write ${planApprovalsFile()}`);
|
|
81
118
|
}
|
|
82
119
|
|
|
83
|
-
/**
|
|
120
|
+
/** The owner's click on a plan page: record a hash of the plan text in the queue state and return the page it approved. The plan file itself is never edited. */
|
|
84
121
|
export function approvePlanFile(file: string, page: string, now = new Date()): string {
|
|
85
|
-
|
|
86
|
-
|
|
122
|
+
const text = readFileSync(file, "utf8");
|
|
123
|
+
recordApproval(file, { hash: reviewHash(text), at: now.getTime(), via: "page", page });
|
|
124
|
+
return `approved ${page}`;
|
|
87
125
|
}
|
|
88
126
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
127
|
+
export type ChatApproveResult = { applied: true; plan: string } | { applied: false; problem?: string };
|
|
128
|
+
|
|
129
|
+
const APPROVE_CMD = /^approve (\d{8}_\d{4})$/;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* The owner's own chat `approve <YYYYMMDD_HHMM>` (same trust rules as chatGo): the one open indexed
|
|
133
|
+
* plan whose file stamp matches records a chat approval and is logged to plan_guard_log. Any other
|
|
134
|
+
* text is not an approval. A stamp that matches none, or several, or a record that cannot be saved,
|
|
135
|
+
* is a problem for the owner to read; nothing is approved.
|
|
136
|
+
*/
|
|
137
|
+
export function chatApprove(text: string, cfg: Config, source: string): ChatApproveResult {
|
|
138
|
+
if (!cfg.guards.chat_unlock) return { applied: false };
|
|
139
|
+
const m = APPROVE_CMD.exec(text.trim());
|
|
140
|
+
if (!m) return { applied: false };
|
|
141
|
+
const stamp = m[1];
|
|
142
|
+
const matches = q.activePlans().filter(p => p.status === "open" && basename(p.file).startsWith(`${stamp}_`));
|
|
143
|
+
const [plan, second] = matches;
|
|
144
|
+
if (!plan) return { applied: false, problem: `no open plan ${stamp}` };
|
|
145
|
+
if (second) return { applied: false, problem: `${matches.length} open plans match ${stamp}; nothing approved` };
|
|
146
|
+
try {
|
|
147
|
+
recordApproval(plan.file, { hash: reviewHash(plan.text), at: Date.now(), via: "chat", page: pageOfPlan(cfg.pages.dir, plan.file) ?? "" });
|
|
148
|
+
} catch (e) {
|
|
149
|
+
return { applied: false, problem: `plan ${stamp} not approved: ${e instanceof Error ? e.message : String(e)}` };
|
|
150
|
+
}
|
|
151
|
+
try {
|
|
152
|
+
appendFileSync(cfg.paths.plan_guard_log, `${new Date().toISOString()} APPROVE chat source=${source} plan=${plan.file}\n`);
|
|
153
|
+
} catch {}
|
|
154
|
+
return { applied: true, plan: plan.file };
|
|
95
155
|
}
|
|
156
|
+
|
|
157
|
+
/** Why a spawn may not run on this plan, or null. A plan with a page in Base needs a record with its current hash. A plan stamped at or after `since` (approval.since, "" = off) needs a page too (plan 20261029_1455 P3): with no page it is refused until the page is published. A file with no stamp counts as stamped after `since`. */
|
|
158
|
+
export function approvalProblem(text: string, file: string, pagesDir: string, since: string): string | null {
|
|
159
|
+
const page = pageOfPlan(pagesDir, file);
|
|
160
|
+
const stamp = /^\d{8}_\d{4}/.exec(basename(file))?.[0] ?? null;
|
|
161
|
+
const gated = since !== "" && (stamp === null || stamp >= since);
|
|
162
|
+
if (page === null) {
|
|
163
|
+
if (!gated) return null; // predates the convention
|
|
164
|
+
return `plan ${file} has no page: publish its page with neurastream pages publish <page.html> --plan ${file}`;
|
|
165
|
+
}
|
|
166
|
+
const rec = readPlanApproval(file);
|
|
167
|
+
if (rec !== null && rec.hash === reviewHash(text)) return null;
|
|
168
|
+
const hint = stamp !== null ? `, or types: approve ${stamp}` : "";
|
|
169
|
+
return `plan ${file} has no approval record. The owner approves it from ${page} in Base${hint}.`;
|
|
170
|
+
}
|
package/templates/AGENTS.md
CHANGED
|
@@ -12,6 +12,7 @@ You are Main, the orchestrator. Main plans, delegates, reviews and lands; implem
|
|
|
12
12
|
- Main writes every plan in `<repo>/docs/plans/`, shaped like `{{AGENT_DIR}}/queue/TEMPLATE.md`. Do the research yourself; never base a plan on another agent's findings.
|
|
13
13
|
- Phase 0 of every plan: blocker scripts that stop the implementer from going against the plan. They must exist before any spawn.
|
|
14
14
|
- Every plan has `## Reuse`; no spawn without a current reviewer PASS (`templates/plan-review-brief.md`, recorded only from the reviewer's own Progress edit); a brief names every open MR of its plan with an `MR !N:` line.
|
|
15
|
+
- Plan order: plan → page (`neurastream pages publish <page.html> --plan <plan.md>`) → owner approves (Approve on the page, or types `approve <YYYYMMDD_HHMM>`) → reviewer PASS → implementer. Once `approval.since` is set, a plan stamped at or after it gets no spawn without a page and an approval record for its current text; a body edit voids the approval, a Progress-only edit keeps it.
|
|
15
16
|
- An open plan gets an implementer subagent. When it claims done, verify (another subagent or yourself). Not done → spawn another implementer for the rest. Done → set `Status: complete`; `queue-close` then archives it and cleans the indexes.
|
|
16
17
|
- Owner asks about a past plan → grep FINISHED.md first; open the archived plan only for details.
|
|
17
18
|
- An implementer's new `## Progress` entry ends with a `Findings:` line — `Findings: none`, or one item per finding with `file:line` evidence; plan-guard restores an entry without it, and each item becomes an incident.
|
package/templates/config.yml
CHANGED
|
@@ -151,6 +151,8 @@ autonomy:
|
|
|
151
151
|
review: # plan review gate (plan 20261028_1600): reuse lines now, reviewer PASS from P2 (docs/config.md)
|
|
152
152
|
agents: ["reviewer"] # agents allowed to run a review spawn: one must be in "## Allowed" of notes/subagents.md (doctor and queue-check fail otherwise, e.g. ["glm"]); the PASS exemption needs one plus the brief's `Plan review:` line; an empty list turns both review gates off
|
|
153
153
|
mr_cache_minutes: 10 # minutes the spawn gate caches a repo's open-MR list in <queue_state>/mr-cache.json; 0 = no cache
|
|
154
|
+
approval: # plan approval hard gate (plan 20261029_1455 P3): docs/config.md
|
|
155
|
+
since: "" # a plan stamped at or after this (YYYYMMDD_HHMM) needs a page and an approval record; "" = off
|
|
154
156
|
|
|
155
157
|
ui:
|
|
156
158
|
enabled: false # the owner's phone page (neurastream ui); binds the tailnet address only
|