salvage 2026-11-06: uncommitted work from scratch/sage-r143/wt (disk cleanup #824)
This commit is contained in:
1 parent
80a2e442bf
commit
67060e3490
9 files changed
+144
-4
No files matched your search
+4
-1
@@ -407,7 +407,10 @@ spec/north-star.md or docs/NAME.md of a project: one local commit authored by th
|
||||
business's human, refused `stale-base` if the file changed since the editor opened it.
|
||||
It is the human bus verb `project.file.save` through the human transport; an agent
|
||||
refuses it. Nothing is pushed. Without `--send` the page reads and previews only. See
|
||||
`packages/webui/README.md` ("Spec and docs editor").
|
||||
`packages/webui/README.md` ("Spec and docs editor"). A save of spec/north-star.md also
|
||||
sends the business's pm and cto one notice naming the commit (row 143); a BLOCK from
|
||||
either goes to the chief of staff and on to the assistant. See `packages/bus/README.md`
|
||||
("Spec review notices").
|
||||
|
||||
The unit runs a pinned copy, not the working checkout (row 77, #1571).
|
||||
`copy COMMIT` resolves COMMIT to its full id, refuses one not reachable
|
||||
|
||||
+27
-1
@@ -314,9 +314,19 @@ message stranded for a role nobody holds shows once a run claims the role.
|
||||
Unknown keys, roles, references, actions and verbs refuse. If writing refusal
|
||||
evidence fails, the caller receives the static `storage-unavailable` code. `human` is the reserved
|
||||
recipient. Message classes are REQUEST, ASSIGNMENT, REVIEW-REQUEST, REVIEW-RESULT,
|
||||
RESULT, INFO, DECISION and REACTION. `staff.request` also writes STAFF-REQUEST (row 140);
|
||||
RESULT, INFO, DECISION, REACTION and BLOCK (row 143). `staff.request` also writes STAFF-REQUEST (row 140);
|
||||
`message.send` and `thread.send` refuse that class. References cannot cross businesses.
|
||||
|
||||
A BLOCK answers a spec notice (Spec review notices, below). `message.send` accepts it only from a
|
||||
pm or cto instance (`block-sender`), only to the chief-of-staff instance (`block-recipient`; the
|
||||
assistant may hear only from the user and the chief of staff, REQ-ASSIST-2), and only with
|
||||
`in_reply_to` naming a notice the bus sent that sender (`block-reply-required`). The BLOCK sits in no
|
||||
thread, because a message may join only a thread whose instance sent or received it. When the chief of
|
||||
staff relays to the assistant in reply to the BLOCK (or to anything on a chain back to the notice), the
|
||||
reply chain reaches the notice, and the relay is filed in the user's most recently opened thread of the
|
||||
notice's project whose instance is the assistant. With no such thread the relay is refused
|
||||
(`thread-required-reply-to-thread-message`). `thread.send` refuses the class.
|
||||
|
||||
Routing is immutable at raise: within-role closes atomically with `choice`,
|
||||
cross-role routes to the configured delivery arbiter (or technical arbiter with
|
||||
`domain:'technical'`). A gated raise that cites the project's current spec commit routes the same way,
|
||||
@@ -760,6 +770,22 @@ Every refusal is recorded as the others are. The save verb alone may carry a req
|
||||
up to 1 MiB + 64 KiB (the client and the server both check it); every other verb
|
||||
keeps the 64 KiB envelope. Tests: `packages/bus/tests/project-files.test.mjs`.
|
||||
|
||||
### Spec review notices
|
||||
|
||||
Row 143 (#1637, REQ-PROJ-4): a successful `project.file.save` of `spec/north-star.md` sends one
|
||||
notice to every instance whose definition is `pm` or `cto`. It comes from `_bus` (run `bus`), class
|
||||
RESULT, in no thread. The body begins `The human saved spec/north-star.md in project <key>: commit
|
||||
<sha>, from the editor's base <sha>.` and asks the role to read the change with `read_spec`, check it
|
||||
against settled decisions and work in flight, and answer the chief of staff once, in reply to the
|
||||
notice: an INFO beginning "Accept", or a BLOCK naming each conflict. A BLOCK does not revert the commit.
|
||||
|
||||
Only that verb sends a notice. A save of a docs file, a refused or stale save, an agent's
|
||||
`record.write` commit and a git commit made outside the Console send none. The notice is stored after
|
||||
the commit; if storing it fails the save answers `outcome-unknown` and the commit stands. A notice to a
|
||||
role no run holds waits and is delivered at the next claim. The broker launches nothing and does not
|
||||
tell `launch.by`; the chief of staff's `launch` is how a pm or cto session starts. A business with
|
||||
no pm or cto instance sends nothing. Tests: `packages/bus/tests/spec-review.test.mjs`.
|
||||
|
||||
The 3e→3f offline step adds nullable spec_path/spec_commit columns to decisions,
|
||||
with nulls on existing rows. It changes no event or resolution and creates no
|
||||
spec/confirmation tables. The 3e fixture is pinned from 26a0b0fab's tree; no live
|
||||
|
||||
@@ -156,6 +156,13 @@ const THREAD_DEFINITION = 'assistant';
|
||||
// business ID_PATTERN, which starts with [a-z0-9], so no instance can be named this.
|
||||
const NOTICE_ROLE = '_bus';
|
||||
const NOTICE_RUN = 'bus';
|
||||
// Row 143 (#1637, REQ-PROJ-4): a human save of this file through project.file.save sends one notice to each
|
||||
// instance of these definitions. Their answer goes to the instance of SPEC_ANSWER_TO, the chief of staff,
|
||||
// because only the user and the chief of staff may send to the assistant (REQ-ASSIST-2).
|
||||
const SPEC_PATH = 'spec/north-star.md';
|
||||
const SPEC_REVIEWERS = ['pm', 'cto'];
|
||||
const SPEC_ANSWER_TO = 'chief-of-staff';
|
||||
const SPEC_NOTICE = `The human saved ${SPEC_PATH} `;
|
||||
// How many messages `thread.messages` returns by default and at most, oldest first.
|
||||
export const THREAD_PAGE = 50;
|
||||
export const THREAD_PAGE_MAX = 200;
|
||||
@@ -283,7 +290,7 @@ export class Broker {
|
||||
for (let at = inReplyTo ?? null; at !== null && !seen.has(at); ) {
|
||||
seen.add(at);
|
||||
const m = this.#store.get(
|
||||
'SELECT m.in_reply_to, t.thread FROM messages m LEFT JOIN message_threads t ON t.message=m.id WHERE m.id=? AND m.business=?',
|
||||
'SELECT m.in_reply_to, m.from_role, m.body, t.thread FROM messages m LEFT JOIN message_threads t ON t.message=m.id WHERE m.id=? AND m.business=?',
|
||||
at,
|
||||
s.business,
|
||||
);
|
||||
@@ -291,6 +298,11 @@ export class Broker {
|
||||
if (this.#store.get('SELECT instance FROM threads WHERE id=?', m.thread).instance !== to) fail('thread-instance-mismatch');
|
||||
return m.thread;
|
||||
}
|
||||
// Row 143: a chain that reaches a spec notice belongs to the user's thread in that notice's project.
|
||||
if (m?.from_role === NOTICE_ROLE && m.body.startsWith(SPEC_NOTICE)) {
|
||||
const spec = this.#specThread(s, to, m.body);
|
||||
if (spec) return spec;
|
||||
}
|
||||
at = m?.in_reply_to ?? null;
|
||||
}
|
||||
// The code is the whole message a run sees (runner.mjs forwards codes only), so it says what to do.
|
||||
@@ -1235,6 +1247,12 @@ export class Broker {
|
||||
keys(args, ['project', 'path', 'base', 'content'], ['project', 'path', 'base', 'content']);
|
||||
const saved = await writeFile({ ...context, path: args.path, base: args.base, content: args.content });
|
||||
result = { path: saved.path, commit: saved.commit };
|
||||
// The commit stands whatever happens next, so a notice that fails to store answers outcome-unknown
|
||||
// and the Console reloads to the new commit, as record.write does after its commit.
|
||||
if (saved.path === SPEC_PATH) {
|
||||
try { this.#store.transaction(() => this.#specNotice(s.business, args.project, saved.commit, args.base)); }
|
||||
catch { fail('outcome-unknown'); }
|
||||
}
|
||||
}
|
||||
this.#secretCheck(result);
|
||||
return result;
|
||||
@@ -1642,6 +1660,7 @@ export class Broker {
|
||||
'INFO',
|
||||
'DECISION',
|
||||
'REACTION',
|
||||
'BLOCK',
|
||||
].includes(a.class)
|
||||
)
|
||||
fail('invalid-class');
|
||||
@@ -1652,6 +1671,7 @@ export class Broker {
|
||||
fail('message-not-found');
|
||||
}
|
||||
}
|
||||
if (a.class === 'BLOCK') this.#checkBlock(s, to, a.in_reply_to);
|
||||
if (a.decision) this.#decision(s, a.decision);
|
||||
const thread = this.#threadFor(s, to, a.in_reply_to);
|
||||
const mid = randomUUID();
|
||||
@@ -2306,6 +2326,67 @@ export class Broker {
|
||||
);
|
||||
this.#route(business, nid, by, null);
|
||||
}
|
||||
// Row 143 (#1637, REQ-PROJ-4): one notice per spec commit to each pm and cto instance, from the bus,
|
||||
// class RESULT like #notice. The runner takes a turn on it and sends no automatic reply, so the body
|
||||
// names where the answer goes. Written once, in the transaction that follows the save's commit; no
|
||||
// other path calls it, so a record commit by an agent and a git commit outside the Console send none.
|
||||
// The notice sits in no thread, so the user's thread view shows none of this traffic. Nothing is
|
||||
// launched here: a notice to a role no run holds waits for a claim and does not tell launch.by.
|
||||
#specNotice(business, project, commit, base) {
|
||||
const b = this.#business(business);
|
||||
const roles = Object.keys(b.roles).filter((r) => SPEC_REVIEWERS.includes(b.roles[r].definition));
|
||||
if (!roles.length) return;
|
||||
const chief = Object.keys(b.roles).find((r) => b.roles[r].definition === SPEC_ANSWER_TO) ?? SPEC_ANSWER_TO;
|
||||
for (const to of roles) {
|
||||
const nid = randomUUID();
|
||||
this.#store.run(
|
||||
'INSERT INTO messages(id,at,business,from_role,from_run,to_role,class,in_reply_to,decision,corrects,body) VALUES(?,?,?,?,?,?,?,?,?,?,?)',
|
||||
nid,
|
||||
this.#now(),
|
||||
business,
|
||||
NOTICE_ROLE,
|
||||
NOTICE_RUN,
|
||||
to,
|
||||
'RESULT',
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
`${SPEC_NOTICE}in project ${project}: commit ${commit}, from the editor's base ${base}. ` +
|
||||
`Read the change with read_spec (commit ${commit}, and commit ${base} for the text before it) and check it against ` +
|
||||
`settled decisions and work in flight. Answer once, to ${chief} with send_message in_reply_to ${nid}: ` +
|
||||
`class BLOCK naming the conflict, or class INFO that begins "Accept". A BLOCK does not revert the commit. ` +
|
||||
`Don't reply to _bus; it receives nothing.`,
|
||||
);
|
||||
this.#route(business, nid, to, null);
|
||||
}
|
||||
}
|
||||
// Row 143: a BLOCK answers a spec notice. Only a pm or cto instance sends one, only to the chief of
|
||||
// staff, and only in reply to a notice the bus sent that sender. The BLOCK itself sits in no thread: the
|
||||
// schema lets a message join only a thread whose instance sent or received it. The chief's relay to the
|
||||
// assistant replies to the BLOCK, and #specThread finds the user's thread from the notice at the end of
|
||||
// that chain, which is the only way a result reaches the assistant (REQ-ASSIST-2).
|
||||
#checkBlock(s, to, inReplyTo) {
|
||||
const b = this.#business(s.business);
|
||||
if (s.human || s.tester || !SPEC_REVIEWERS.includes(b.roles[s.role]?.definition)) fail('block-sender');
|
||||
if (b.roles[to]?.definition !== SPEC_ANSWER_TO) fail('block-recipient');
|
||||
const n = inReplyTo === undefined ? null : this.#store.get('SELECT from_role, to_role, body FROM messages WHERE id=? AND business=?', inReplyTo, s.business);
|
||||
if (!n || n.from_role !== NOTICE_ROLE || n.to_role !== s.role || !n.body.startsWith(SPEC_NOTICE)) fail('block-reply-required');
|
||||
}
|
||||
// The thread a reply chain reaches through a spec notice: the user's most recently opened thread in the
|
||||
// notice's project whose instance is the recipient, or null when there is none.
|
||||
#specThread(s, to, body) {
|
||||
const project = /^in project ([^ :]+):/.exec(body.slice(SPEC_NOTICE.length))?.[1];
|
||||
return (
|
||||
this.#store.get(
|
||||
`SELECT t.id FROM threads t JOIN projects p ON p.id=t.project WHERE t.business=? AND t.owner=? AND t.instance=? AND p.repo=?
|
||||
ORDER BY coalesce((SELECT max(o.seq) FROM thread_opens o WHERE o.thread=t.id), 0) DESC, t.seq DESC LIMIT 1`,
|
||||
s.business,
|
||||
this.#business(s.business).human,
|
||||
to,
|
||||
project,
|
||||
)?.id ?? null
|
||||
);
|
||||
}
|
||||
#delivery(mid, op, h, transport = null) {
|
||||
this.#store.run(
|
||||
'INSERT INTO deliveries(message,at,op,holder_run,transport,address) VALUES(?,?,?,?,?,?)',
|
||||
|
||||
@@ -75,7 +75,7 @@ const TASK_TOOLS = {
|
||||
"task.close": ["task_close", "Close a task after its review verdict. A task with pushed work closes only on an approve verdict for its latest push.", { ...COMMON, verdict: str("The review verdict id review_verdict returned, as the REVIEW-RESULT message names it") }, ["task_ref", "verdict"]],
|
||||
};
|
||||
|
||||
const MESSAGE_CLASSES = ["REQUEST", "ASSIGNMENT", "REVIEW-REQUEST", "REVIEW-RESULT", "RESULT", "INFO", "DECISION", "REACTION"];
|
||||
const MESSAGE_CLASSES = ["REQUEST", "ASSIGNMENT", "REVIEW-REQUEST", "REVIEW-RESULT", "RESULT", "INFO", "DECISION", "REACTION", "BLOCK"];
|
||||
|
||||
// typedTools({ resolved, arbiter, tracker, projects, land }) -> [{ name, verb, action, description, parameters }]
|
||||
// resolved resolveInstance(...) output for the session's instance
|
||||
|
||||
@@ -29,6 +29,12 @@ test("the PM gets its task verbs and the reads, and no launch", (t) => {
|
||||
}
|
||||
});
|
||||
|
||||
// Row 143 (#1637): send_message offers the BLOCK class a pm or cto answers a spec notice with.
|
||||
test("send_message offers the BLOCK class, beside the classes it already had", (t) => {
|
||||
const send = typedTools({ resolved: resolvedFor(t, "pm"), arbiter: true, tracker: true }).find((x) => x.name === "send_message");
|
||||
assert.deepEqual(send.parameters.properties.class.enum, ["REQUEST", "ASSIGNMENT", "REVIEW-REQUEST", "REVIEW-RESULT", "RESULT", "INFO", "DECISION", "REACTION", "BLOCK"]);
|
||||
});
|
||||
|
||||
// Row 119 (#1613): the chief of staff holds launch and message.send; row 123 adds role.end and organization.change, which row 132 gives tools.
|
||||
test("the chief of staff gets launch, send_message, end_run and change_organization, and no task verbs", (t) => {
|
||||
const chief = resolvedFor(t, "chief");
|
||||
|
||||
@@ -18,6 +18,12 @@ sessions.
|
||||
it, paraphrase it or add to it. Don't send it to that role yourself.
|
||||
- Report to the user what the chief of staff answers, and every refusal
|
||||
with its exact text.
|
||||
- When the chief of staff passes you the result of a review of the user's
|
||||
saved spec change, summarize it for the user in your own words. Say
|
||||
whether the product manager and the CTO accepted, and for each BLOCK
|
||||
say what conflicts with what and what the user can do about it. Don't
|
||||
repeat the chief of staff's text or quote it back. A BLOCK doesn't
|
||||
undo the user's commit, so say that the change stands.
|
||||
|
||||
## Authority
|
||||
|
||||
|
||||
@@ -35,6 +35,10 @@ product's code, you don't review it and you don't create tasks yourself.
|
||||
may do, raise a `policy.change` decision.
|
||||
- Report to the assistant what the roles answer, and every refusal with
|
||||
its exact text.
|
||||
- When the pm or the cto answers the bus's notice of a saved spec with a
|
||||
BLOCK or an accept, relay it to the assistant with `send_message`
|
||||
`in_reply_to` the message that carried it. The bus refuses a relay
|
||||
without that link. A BLOCK doesn't revert the commit.
|
||||
|
||||
## Authority
|
||||
|
||||
|
||||
@@ -13,6 +13,13 @@ assigned engineering work yourself.
|
||||
question, the decision comes to you, and you resolve it with a reason.
|
||||
- Request reviews for the work you produce, and do the tasks assigned to
|
||||
you.
|
||||
- When the bus tells you the human saved `spec/north-star.md`, read the
|
||||
change with `read_spec` and check it against the decisions already
|
||||
settled and the work in flight. Answer the chief of staff once, in
|
||||
reply to the bus's notice: with `send_message` class `BLOCK` naming each
|
||||
conflict, or class `INFO` that begins "Accept". A BLOCK doesn't revert
|
||||
the commit. The chief of staff tells the assistant, and the assistant
|
||||
tells the user.
|
||||
|
||||
## Authority
|
||||
|
||||
|
||||
@@ -33,6 +33,13 @@ order. You don't write the product's code and you don't review it.
|
||||
many sessions it needs. The chief of staff answers by message with the
|
||||
instances it launched, or with a refusal and its reason. The limits
|
||||
are the chief of staff's to apply, not yours.
|
||||
- When the bus tells you the human saved `spec/north-star.md`, read the
|
||||
change with `read_spec` and check it against the decisions already
|
||||
settled and the tasks in flight. Answer the chief of staff once, in
|
||||
reply to the bus's notice: with `send_message` class `BLOCK` naming each
|
||||
conflict, or class `INFO` that begins "Accept". A BLOCK doesn't revert
|
||||
the commit. The chief of staff tells the assistant, and the assistant
|
||||
tells the user.
|
||||
|
||||
## Authority
|
||||
|
||||
|
||||
Reference in new issue
Block a user