sage: file row 65 follow-ups as P19 376 and 377 (mos-0842 item 4, #1558)

This commit is contained in:
jason.woltje committed 2026-10-19 11:41:36 -05:00
1 parent 73bbbee81b
commit 894ce3f370
2 files changed
+97

No files matched your search

@@ -0,0 +1,70 @@
// Sage, 2026-10-19: decision 110, mos-0842 item 4. Files row 65's follow-ups (follow-up 5 from Darkwing 29144
// and Dewey 29145, and Dewey's REQ-LIMIT-4 regex notes from 29136) in project 19 with Sage's own key (bot user
// 13). Refuses if a title already exists. The sync key reads each back. No labels, no assignees, no bucket
// moves. Rollback is marking a task done; deletion is Jason's or ops-01's. Prints no secret.
// Usage: node file-r65-followups.mjs https://tasks.woltje.com SAGE_TOKEN_FILE SYNC_TOKEN_FILE OUT_JSON
import { readFileSync, writeFileSync, existsSync } from "node:fs";
const [ORIGIN, KEY, SYNC, OUT] = process.argv.slice(2);
if (!/^https:\/\/tasks\.woltje\.com$/.test(ORIGIN)) throw new Error("tasks.woltje.com only");
if (!OUT || existsSync(OUT)) throw new Error("OUT_JSON missing or exists; refusing");
const PROJECT = 19;
const SIG = "Created by Sage (T3 1ef1e4f8) with Sage's own key (bot user 13).";
const esc = (s) => s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
const p = (...xs) => xs.map((x) => `<p>${esc(x)}</p>`).join("") + `<p>${esc(SIG)}</p>`;
const TASKS = [
{ title: "Chief of staff's partial fallback through assistants: refuse with organization-partial-fallback, not invalid-request (row 65 follow-up, #1558)",
description: p("Follow-up 5 on row 65 (Gitea #1558), raised by Darkwing (comment 29144) and Dewey (comment 29145) in round 2. Landed as c216f47db.",
"When the chief of staff writes an assistant's vars through organization.set assistants (Q169, ruling b) with only part of a fallback (fallback.harness and fallback.model without fallback.thinking, say), the write is refused, but with invalid-request. The human route write (routes.set) gives organization-partial-fallback for the same shape (packages/bus/tests/routes-verb.test.mjs:135-136), from packages/business/src/launch-settings.mjs:258.",
"The refusal holds and nothing is written, so this is about the code only. Fix: make the assistants path give organization-partial-fallback, and add a case to packages/bus/tests/chief-of-staff.test.mjs that asserts the code.",
"Bus and business only. Needs a queue row and a brief.") },
{ title: "REQ-LIMIT-4 source checks: regexes miss an aliased load, a variable modules(kind) and snapshot( (row 65 note, #1558)",
description: p("Dewey's REQ-LIMIT-4 notes on row 65 (Gitea #1558, round 1 comment 29136, still standing in round 2 comment 29145). Not blocking.",
"launch-limit-checks.test.mjs:77-78 pins the launcher's only .load( to { harness: [m.harness] } and refuses modules(\"<kind>\") for any other kind. The loader imports only packages/plugins/<kind>/<name>/index.mjs after a name check and a realpath check, so a harness-only load can't bring in a limit-check module, and the requirement holds.",
"The source regexes don't catch three shapes: an aliased or destructured load, modules(kind) with a variable, and snapshot(. They only matter if someone writes around the rule on purpose.",
"Fix: tighten the checks for those three shapes, or replace the source match with a runtime check of which kinds the launcher loads. Add a mutant for each. Test-only.") },
];
const key = readFileSync(KEY, "utf8").trim(), sync = readFileSync(SYNC, "utf8").trim();
async function api(method, path, body, auth) {
const r = await fetch(ORIGIN + path, { method, headers: { Authorization: `Bearer ${auth}`, "Content-Type": "application/json" }, body: body === undefined ? undefined : JSON.stringify(body), redirect: "error" });
const t = await r.text(); let json = null; try { json = JSON.parse(t); } catch {}
return { status: r.status, json };
}
const list = (j) => j?.items ?? (Array.isArray(j) ? j : []);
async function existing() {
const out = [];
for (let page = 1; page < 20; page++) {
const r = await api("GET", `/api/v2/projects/${PROJECT}/tasks?per_page=50&page=${page}`, undefined, sync);
if (r.status !== 200) throw new Error(`list tasks: ${r.status}`);
out.push(...list(r.json));
if (list(r.json).length < 50) return out;
}
throw new Error("more than 19 pages");
}
const rec = { at: new Date().toISOString(), project: PROJECT, created: [], problems: [] };
const save = () => {
const out = JSON.stringify(rec, null, 1) + "\n";
if (out.includes(key) || out.includes(sync)) throw new Error("secret in the record; not written");
writeFileSync(OUT, out);
};
const before = await existing();
const clash = before.filter((t) => TASKS.some((x) => x.title === t.title));
if (clash.length) throw new Error(`exists: ${clash.map((t) => `#${t.id} ${t.title}`).join("; ")}; refusing`);
writeFileSync(OUT, "", { flag: "wx" });
for (const t of TASKS) {
rec.created.push({ title: t.title });
save();
const body = { title: t.title, description: t.description, ...(t.due ? { due_date: t.due } : {}) };
const r = await api("PUT", `/api/v1/projects/${PROJECT}/tasks`, body, key);
if (r.status >= 300 || !Number.isSafeInteger(r.json?.id)) {
rec.problems.push(`create ${t.title}: ${r.status} ${r.json?.code ?? ""} ${r.json?.message ?? ""}`);
break;
}
Object.assign(rec.created.at(-1), { id: r.json.id, index: r.json.index, inverse: `mark done: POST /api/v1/tasks/${r.json.id} done true (pm); delete is Jason's or ops-01's` });
const back = await api("GET", `/api/v2/tasks/${r.json.id}`, undefined, sync);
Object.assign(rec.created.at(-1), { readBack: back.status, project_back: back.json?.project_id, due_back: back.json?.due_date, done: back.json?.done });
if (back.status !== 200 || back.json?.title !== t.title || back.json?.project_id !== PROJECT || back.json?.done) rec.problems.push(`${t.title} read-back differs`);
}
save();
process.stdout.write(JSON.stringify(rec, null, 1) + "\n");
if (rec.problems.length) process.exit(2);
@@ -0,0 +1,27 @@
{
"at": "2026-10-19T16:41:26.707Z",
"project": 19,
"created": [
{
"title": "Chief of staff's partial fallback through assistants: refuse with organization-partial-fallback, not invalid-request (row 65 follow-up, #1558)",
"id": 376,
"index": 216,
"inverse": "mark done: POST /api/v1/tasks/376 done true (pm); delete is Jason's or ops-01's",
"readBack": 200,
"project_back": 19,
"due_back": "0001-01-01T00:00:00Z",
"done": false
},
{
"title": "REQ-LIMIT-4 source checks: regexes miss an aliased load, a variable modules(kind) and snapshot( (row 65 note, #1558)",
"id": 377,
"index": 217,
"inverse": "mark done: POST /api/v1/tasks/377 done true (pm); delete is Jason's or ops-01's",
"readBack": 200,
"project_back": 19,
"due_back": "0001-01-01T00:00:00Z",
"done": false
}
],
"problems": []
}