pi-straw-boss 0.76.0 → 0.77.2
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/README.zh-TW.md +1 -4
- package/dist/gui/assets/{allyasks-Czxu9N0_.js → allyasks-B157BVSK.js} +1 -1
- package/dist/gui/assets/{allyunits-Cu820tRD.js → allyunits-D49tC5yS.js} +1 -1
- package/dist/gui/assets/{answer-D3Fc6DBr.js → answer-B_eEaZuu.js} +1 -1
- package/dist/gui/assets/{ask-DK8Sf6Pa.js → ask-Cf4u8awy.js} +1 -1
- package/dist/gui/assets/{asks-DqkFBBS7.js → asks-BP9fh8zE.js} +1 -1
- package/dist/gui/assets/{askview-gHx_Hk2d.js → askview-BzFy3A9l.js} +1 -1
- package/dist/gui/assets/{autoback-CZkFJtdj.js → autoback-mQmgZrYL.js} +1 -1
- package/dist/gui/assets/{blockschunk-DUknCMor.js → blockschunk-Bcf8T3l_.js} +1 -1
- package/dist/gui/assets/{box-BUf9E97Z.js → box-CdTJxlY3.js} +1 -1
- package/dist/gui/assets/{chat-CraWb-vz.js → chat-pwXYtfIJ.js} +1 -1
- package/dist/gui/assets/{drawer-DyN2PbF3.js → drawer-C4b67hAK.js} +1 -1
- package/dist/gui/assets/index-Dvw58cHb.js +4 -0
- package/dist/gui/assets/{lanwait-y3ZgXxvk.js → lanwait-D8XQhI49.js} +1 -1
- package/dist/gui/assets/{layer-BMeWKQ6w.js → layer-CcPpb9oC.js} +1 -1
- package/dist/gui/assets/{lightbox-BtmIeJYB.js → lightbox-cGNtXXLf.js} +1 -1
- package/dist/gui/assets/{link-_ku8_F1J.js → link-CfF8WoKX.js} +1 -1
- package/dist/gui/assets/{linkdialogs-BHiWLB73.js → linkdialogs-BtrIR5oZ.js} +1 -1
- package/dist/gui/assets/{mdbody-DmC2OoJ3.js → mdbody-CM0vyeve.js} +1 -1
- package/dist/gui/assets/{pair-6RKgnkV8.js → pair-BdBNEx-I.js} +1 -1
- package/dist/gui/assets/{picker-C9mN-2Ml.js → picker-CBlvQLT5.js} +1 -1
- package/dist/gui/assets/{server-D8Peiga1.js → server-CSZVUOSr.js} +1 -1
- package/dist/gui/assets/{sessionfacts-C-3Lh2Gu.js → sessionfacts-R0PNxQ07.js} +1 -1
- package/dist/gui/assets/{settings-C5nXwYtK.js → settings-Bqjz9KP-.js} +1 -1
- package/dist/gui/assets/{spawn-DmP1vT7z.js → spawn-DlKByPlr.js} +1 -1
- package/dist/gui/assets/{termcard-BWctoI4H.js → termcard-acLQMoog.js} +1 -1
- package/dist/gui/assets/{towerturns-Cd9alhqa.js → towerturns-Cldgw4hX.js} +1 -1
- package/dist/gui/assets/{trains-GY_I0p6W.js → trains-CY_wPPrG.js} +1 -1
- package/dist/gui/assets/{trust-D-_wrdAz.js → trust-DYlVFo7K.js} +1 -1
- package/dist/gui/assets/{views-SvadD2NQ.js → views-BxBhtxB1.js} +1 -1
- package/dist/gui/assets/{waitcard-Xgi9yQRE.js → waitcard-BF4toG4g.js} +1 -1
- package/dist/gui/assets/{yard-C6xyMp5L.js → yard-Bqrbq1yf.js} +1 -1
- package/dist/gui/index.html +2 -2
- package/dist/gui/themes/raven/{raven-DGx4eH2o.js → raven-Dr7te0ib.js} +2 -2
- package/dist/gui/themes/zen/{zen-BQrgqRoA.js → zen-C2J8hYV2.js} +1 -1
- package/dist/gui/themes.json +2 -2
- package/dist/server/{chunk-7HXSLT4U.mjs → chunk-ENYILM47.mjs} +4 -0
- package/dist/server/cli.mjs +1 -1
- package/dist/server/main.mjs +208 -42
- package/package.json +1 -1
- package/prompts/apps-config.md +1 -1
- package/prompts/integrator.md +1 -1
- package/prompts/main.md +1 -1
- package/prompts/planning.md +1 -1
- package/prompts/tower-run.md +1 -1
- package/prompts/train.md +1 -1
- package/src/carwait.ts +105 -0
- package/src/index.ts +1 -1
- package/src/server/carbook.ts +186 -33
- package/src/server/carnotices.ts +14 -8
- package/src/server/carops.ts +3 -1
- package/src/train/cars.ts +12 -2
- package/src/train/contract-legacy.ts +19 -0
- package/src/train/contract.ts +51 -0
- package/src/traincar.ts +32 -6
- package/src/trainguard.ts +11 -12
- package/dist/gui/assets/index-LCc1BzpW.js +0 -4
- package/src/train/anchorloop.ts +0 -78
package/dist/gui/themes.json
CHANGED
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
},
|
|
7
7
|
"zen": {
|
|
8
8
|
"css": "themes/zen/zen-CyPgPbzb.css",
|
|
9
|
-
"module": "themes/zen/zen-
|
|
9
|
+
"module": "themes/zen/zen-C2J8hYV2.js",
|
|
10
10
|
"icon": "themes/zen/favicon-zen-Drb9eAC0.svg"
|
|
11
11
|
},
|
|
12
12
|
"raven": {
|
|
13
13
|
"css": "themes/raven/raven-xbq3LIC7.css",
|
|
14
|
-
"module": "themes/raven/raven-
|
|
14
|
+
"module": "themes/raven/raven-Dr7te0ib.js",
|
|
15
15
|
"icon": "themes/raven/favicon-raven-OQEWezoq.svg"
|
|
16
16
|
}
|
|
17
17
|
}
|
|
@@ -4854,6 +4854,7 @@ function validateStateFields(state, fields) {
|
|
|
4854
4854
|
for (const key2 of Object.keys(fields)) if (present4(fields[key2]) && !spec.some((f) => f.name === key2)) out.push(`sb: ${state}.${key2} is not a field`);
|
|
4855
4855
|
return out;
|
|
4856
4856
|
}
|
|
4857
|
+
var endOf = (file) => file.states.find((s) => isTerminal(s.state));
|
|
4857
4858
|
function emptyCar(car) {
|
|
4858
4859
|
return { v: 1, project: car.project, app: car.app, car: { tickets: [...car.tickets], branch: car.branch, head: car.head }, coordinator: car.coordinator, states: [] };
|
|
4859
4860
|
}
|
|
@@ -4981,6 +4982,7 @@ function noticeStatus(record, state) {
|
|
|
4981
4982
|
const last = attempts.at(-1);
|
|
4982
4983
|
return last ? { kind: "pending", attempts: attempts.length, last: last.answer ?? last.outcome } : { kind: "pending", attempts: 0 };
|
|
4983
4984
|
}
|
|
4985
|
+
var landedWord = (ticket, head, how) => `sb: car ${ticket} (${head.slice(0, 12)}) ${how}, so it takes no train again: a car lands once. Return it with this word (train_car returned), which tells its coordinator`;
|
|
4984
4986
|
var headsIn = (text4) => [...new Set([...text4.matchAll(/(?:^|[\s|])head:\s*([0-9a-f]{40})(?![0-9a-f])/gim)].map((m) => m[1]))];
|
|
4985
4987
|
function slipsInText(body) {
|
|
4986
4988
|
const lines = body.replace(/(\S)[ \t]+(car:[ \t]*[A-Za-z0-9._-]+[ \t]*\|[ \t]*tickets:)/gi, "$1\n$2");
|
|
@@ -6786,11 +6788,13 @@ export {
|
|
|
6786
6788
|
factsOf,
|
|
6787
6789
|
RETRY_MS,
|
|
6788
6790
|
validateStateFields,
|
|
6791
|
+
endOf,
|
|
6789
6792
|
emptyCar,
|
|
6790
6793
|
carFileName,
|
|
6791
6794
|
addState,
|
|
6792
6795
|
stateLine,
|
|
6793
6796
|
noticeStatus,
|
|
6797
|
+
landedWord,
|
|
6794
6798
|
headsIn,
|
|
6795
6799
|
slipsInText,
|
|
6796
6800
|
coordinatorWord,
|
package/dist/server/cli.mjs
CHANGED
package/dist/server/main.mjs
CHANGED
|
@@ -67,6 +67,7 @@ import {
|
|
|
67
67
|
dmtfUtcPs,
|
|
68
68
|
dutyOfAgent,
|
|
69
69
|
emptyCar,
|
|
70
|
+
endOf,
|
|
70
71
|
endpointFor,
|
|
71
72
|
ensureTowerVia,
|
|
72
73
|
execFailure,
|
|
@@ -110,6 +111,7 @@ import {
|
|
|
110
111
|
joinLocal,
|
|
111
112
|
lanAppCookieFor,
|
|
112
113
|
lanCookieFor,
|
|
114
|
+
landedWord,
|
|
113
115
|
listenControl,
|
|
114
116
|
listening,
|
|
115
117
|
localEndpoint,
|
|
@@ -131,6 +133,7 @@ import {
|
|
|
131
133
|
prepareSlot,
|
|
132
134
|
purge,
|
|
133
135
|
qr,
|
|
136
|
+
readApps,
|
|
134
137
|
readCar,
|
|
135
138
|
readCwds,
|
|
136
139
|
readEntries,
|
|
@@ -208,7 +211,7 @@ import {
|
|
|
208
211
|
writeStartError,
|
|
209
212
|
writerAlive,
|
|
210
213
|
yardPath
|
|
211
|
-
} from "./chunk-
|
|
214
|
+
} from "./chunk-ENYILM47.mjs";
|
|
212
215
|
|
|
213
216
|
// src/server/main.ts
|
|
214
217
|
import { homedir as homedir14 } from "node:os";
|
|
@@ -17185,7 +17188,16 @@ var refusal3 = (text11) => new Error(text11);
|
|
|
17185
17188
|
var text7 = (v, max) => typeof v === "string" && v.trim() !== "" && v.length <= max;
|
|
17186
17189
|
var iso = (ms3) => new Date(ms3).toISOString();
|
|
17187
17190
|
var noticeName = (name2) => name2.replace(/\.json$/, ".notice.json");
|
|
17191
|
+
var PAST = "#";
|
|
17192
|
+
var changedAt = (held) => held.file.states.at(-1)?.at ?? "";
|
|
17188
17193
|
var firstLine = (error) => String(error.stderr || error.message).trim().split("\n")[0].slice(0, 200);
|
|
17194
|
+
function reachClass(line3) {
|
|
17195
|
+
if (/could not read (?:Username|Password)|terminal prompts disabled|Authentication failed|Access denied|Permission denied \(publickey|returned error: 40[13]|Host key verification failed/i.test(line3)) return "auth";
|
|
17196
|
+
if (/Repository not found|does not appear to be a git repository|returned error: 404|not found/i.test(line3)) return "repository-not-found";
|
|
17197
|
+
if (/Could not resolve host|Connection refused|Connection timed out|timed out|Failed to connect|Network is unreachable|Could not read from remote repository|unable to access|Connection reset|Connection closed/i.test(line3)) return "connection";
|
|
17198
|
+
return void 0;
|
|
17199
|
+
}
|
|
17200
|
+
var unreached = (text11, line3) => Object.assign(refusal3(text11), { reach: reachClass(line3) });
|
|
17189
17201
|
var same3 = (a, b) => a.length === b.length && a.every((x, i) => x === b[i]);
|
|
17190
17202
|
var MIRROR_FLAGS = ["-c", "core.commitGraph=false", "-c", "fetch.writeCommitGraph=false", "-c", "gc.auto=0", "-c", "maintenance.auto=false", "-c", "core.multiPackIndex=false"];
|
|
17191
17203
|
var FETCH_FLAGS = ["-c", "transfer.fsckObjects=true", "-c", "fetch.fsckObjects=true", "-c", "fetch.unpackLimit=1", "-c", "transfer.unpackLimit=1"];
|
|
@@ -17289,6 +17301,7 @@ var CarBook = class {
|
|
|
17289
17301
|
}
|
|
17290
17302
|
// ---- the display journal: written here, read by the yard, never read back (CR-F003)
|
|
17291
17303
|
writeCar(project, name2, held) {
|
|
17304
|
+
if (name2.includes(PAST)) return;
|
|
17292
17305
|
const dir = carsDir(this.d.stateDir, project), root = trainboardDir(this.d.stateDir);
|
|
17293
17306
|
try {
|
|
17294
17307
|
writePrivate(join38(dir, name2), `${JSON.stringify(held.file)}
|
|
@@ -17381,7 +17394,7 @@ var CarBook = class {
|
|
|
17381
17394
|
if (!role) throw refusal3(`sb: session ${look3.name} is neither a train nor a main (its role is ${look3.role ?? "none"})`);
|
|
17382
17395
|
if (role === "train" && !look3.train) throw refusal3(`sb: session ${look3.name} is a train with no train token`);
|
|
17383
17396
|
if (role === "train" && this.trainOf(look3.train.project, look3.train.code)?.session !== reg.session) throw refusal3(`sb: this server did not open train ${look3.train.code} of project ${look3.train.project} for session ${reg.session}`);
|
|
17384
|
-
return { reg, setter: { role, name: look3.name, session: reg.session, ...look3.workspace ? { workspace: look3.workspace } : {} }, ...look3.train ? { train: look3.train } : {} };
|
|
17397
|
+
return { reg, setter: { role, name: look3.name, session: reg.session, ...look3.workspace ? { workspace: look3.workspace } : {} }, look: look3, ...look3.train ? { train: look3.train } : {} };
|
|
17385
17398
|
}
|
|
17386
17399
|
// ---- reading
|
|
17387
17400
|
/** Every car file of a project with its notice record, unbounded: for the sender's own bookkeeping and the tests. A caller over the socket gets `readFor`. */
|
|
@@ -17400,19 +17413,31 @@ var CarBook = class {
|
|
|
17400
17413
|
return held && held.file.app === app && held.file.car.head === head ? { file: held.file, ...held.notice ? { notice: held.notice } : {} } : void 0;
|
|
17401
17414
|
}
|
|
17402
17415
|
/**
|
|
17403
|
-
* The cars a registered session may see (`cars-read`): a train sees, in its own project, the cars of its manifest; the integrator sees the cars a tower forwarded to it and the ones it set
|
|
17416
|
+
* The cars a registered session may see (`cars-read`): a train sees, in its own project, the cars of its manifest, each in the life it acts on (`lifeFor`); the integrator sees the cars a tower forwarded to it and the ones it set, every life of each,
|
|
17417
|
+
* the newest `MAX_FILES` of them. The guard asks for nothing else.
|
|
17404
17418
|
*/
|
|
17405
17419
|
async readFor(req) {
|
|
17406
17420
|
const { setter, train } = await this.who(req.secret);
|
|
17407
17421
|
if (!isName(req.project)) throw refusal3("sb: cars-read needs a project (a path-safe name)");
|
|
17408
|
-
const project = req.project;
|
|
17409
|
-
let visible;
|
|
17422
|
+
const project = req.project, view = (h) => ({ file: structuredClone(h.file), ...h.notice ? { notice: structuredClone(h.notice) } : {} });
|
|
17410
17423
|
if (setter.role === "train") {
|
|
17411
17424
|
if (project !== train.project) throw refusal3(`sb: this train works for project ${train.project}, not ${project}`);
|
|
17412
|
-
|
|
17413
|
-
|
|
17414
|
-
|
|
17415
|
-
|
|
17425
|
+
return [...new Set(this.trainOf(project, train.code)?.heads ?? [])].flatMap((head) => {
|
|
17426
|
+
const life = this.lifeFor(project, head, train.code);
|
|
17427
|
+
return life ? [view(life[1])] : [];
|
|
17428
|
+
});
|
|
17429
|
+
}
|
|
17430
|
+
const mine = (h) => h.file.states.some((s2) => s2.by.session === setter.session) || this.forwardOf(h.file.car.head, setter.session) !== void 0;
|
|
17431
|
+
return [...this.cars.get(project)?.values() ?? []].filter(mine).slice(-MAX_FILES).map(view);
|
|
17432
|
+
}
|
|
17433
|
+
/**
|
|
17434
|
+
* The life of a car (by its head) a train acts on and reads: the newest one the integrator received for this train, else the life the car lives now. A car that was dropped and then sent again rides another train in a new life (#14),
|
|
17435
|
+
* and the train that dropped it still reads, and waits for, the state it set.
|
|
17436
|
+
*/
|
|
17437
|
+
lifeFor(project, head, code) {
|
|
17438
|
+
const lives2 = [...this.cars.get(project)?.entries() ?? []].filter(([, h]) => h.file.car.head === head);
|
|
17439
|
+
const newest = (list2) => list2.reduce((top, life) => top && changedAt(top[1]) >= changedAt(life[1]) ? top : life, void 0);
|
|
17440
|
+
return newest(lives2.filter(([, h]) => h.file.states.some((s2) => s2.state === "received" && s2.train === code))) ?? newest(lives2);
|
|
17416
17441
|
}
|
|
17417
17442
|
/** Every state whose notice is not yet told, oldest first, for the sender. */
|
|
17418
17443
|
pending() {
|
|
@@ -17428,29 +17453,66 @@ var CarBook = class {
|
|
|
17428
17453
|
}
|
|
17429
17454
|
return out.sort((a, b) => a.entry.at.localeCompare(b.entry.at));
|
|
17430
17455
|
}
|
|
17431
|
-
/**
|
|
17432
|
-
|
|
17433
|
-
|
|
17456
|
+
/**
|
|
17457
|
+
* The life a state entry belongs to, wherever the book keeps it now: a new life of the car moves the one before to `<name>#<n>` (#14), maybe while the sender awaits a send of that earlier life (car-forward-F001). A life's later states keep the entries of its
|
|
17458
|
+
* earlier ones (`addState` copies the list, not the entries), so the entry names its life and no other.
|
|
17459
|
+
*/
|
|
17460
|
+
lifeOf(project, name2, entry) {
|
|
17461
|
+
for (const [key2, held] of this.cars.get(project) ?? []) if ((key2 === name2 || key2.startsWith(`${name2}${PAST}`)) && held.file.states.includes(entry)) return [key2, held];
|
|
17462
|
+
return void 0;
|
|
17463
|
+
}
|
|
17464
|
+
/** The notice record of one state of the life `entry` was set in, as it is now. */
|
|
17465
|
+
noticeOf(project, name2, entry) {
|
|
17466
|
+
return this.lifeOf(project, name2, entry)?.[1].notice?.states[entry.state];
|
|
17434
17467
|
}
|
|
17435
|
-
/** Changes
|
|
17436
|
-
updateNotice(project, name2,
|
|
17437
|
-
const
|
|
17438
|
-
if (!
|
|
17468
|
+
/** Changes the notice record of one state of the life `entry` was set in (the sender is the only caller) and writes it. */
|
|
17469
|
+
updateNotice(project, name2, entry, change) {
|
|
17470
|
+
const life = this.lifeOf(project, name2, entry);
|
|
17471
|
+
if (!life) return;
|
|
17472
|
+
const [key2, held] = life, state = entry.state;
|
|
17439
17473
|
const notice = held.notice ?? { v: 1, states: {} };
|
|
17440
17474
|
const record2 = notice.states[state] ?? { attempts: [] };
|
|
17441
17475
|
change(record2);
|
|
17442
17476
|
notice.states[state] = record2;
|
|
17443
17477
|
held.notice = notice;
|
|
17444
|
-
this.writeCar(project,
|
|
17478
|
+
this.writeCar(project, key2, held);
|
|
17445
17479
|
}
|
|
17446
17480
|
// ---- setting a state
|
|
17481
|
+
/**
|
|
17482
|
+
* Sets are taken one at a time. The git check at `received` (`unlanded`, a fetch of the base) runs before the request joins that queue, since it reads nothing the book holds: a train's `landed` behind a few receipts is not held up by their fetches
|
|
17483
|
+
* (car-forward-F002). Inside the queue the check runs again only when the book changed in between so that the receipt needs it and it was not run.
|
|
17484
|
+
*/
|
|
17447
17485
|
set(req) {
|
|
17448
|
-
const run3 = this.
|
|
17449
|
-
|
|
17486
|
+
const run3 = this.precheck(req).then((checked) => {
|
|
17487
|
+
const next2 = this.chain.then(() => this.setNow(req, checked));
|
|
17488
|
+
this.chain = next2.catch(() => void 0);
|
|
17489
|
+
return next2;
|
|
17490
|
+
});
|
|
17450
17491
|
return run3;
|
|
17451
17492
|
}
|
|
17452
|
-
|
|
17453
|
-
|
|
17493
|
+
/** The check at `received` of a receipt that would start a car or a life, run outside the queue. Anything other than the check's own refusal is left for `setNow` to say. */
|
|
17494
|
+
async precheck(req) {
|
|
17495
|
+
if (req.state !== "received" || !isObject(req.car) || !SHA_RE.test(String(req.car.head))) return void 0;
|
|
17496
|
+
const head = String(req.car.head);
|
|
17497
|
+
let found;
|
|
17498
|
+
try {
|
|
17499
|
+
found = await this.who(req.secret);
|
|
17500
|
+
} catch {
|
|
17501
|
+
return void 0;
|
|
17502
|
+
}
|
|
17503
|
+
const project = req.car.project, sent = this.forwardOf(head, found.setter.session);
|
|
17504
|
+
if (found.setter.role !== "main" || !isName(project) || !sent || sent.slip.over) return void 0;
|
|
17505
|
+
const name2 = carFileName(sent.slip.app, head);
|
|
17506
|
+
if (!this.startsLife(project, name2, sent.at)) return void 0;
|
|
17507
|
+
return { head, app: sent.slip.app, ...await this.unlanded(project, sent.slip.app, head, sent.slip.tickets[0] ?? name2, found.look) };
|
|
17508
|
+
}
|
|
17509
|
+
/** Whether a receipt now would start the car or a new life of it (no car under `name`, or one that ended before the forward). */
|
|
17510
|
+
startsLife(project, name2, sentAt) {
|
|
17511
|
+
const file2 = this.cars.get(project)?.get(name2)?.file, ended = file2 ? endOf(file2) : void 0;
|
|
17512
|
+
return !file2 || ended !== void 0 && sentAt > Date.parse(ended.at);
|
|
17513
|
+
}
|
|
17514
|
+
async setNow(req, checked) {
|
|
17515
|
+
const { setter, train, look: look3 } = await this.who(req.secret);
|
|
17454
17516
|
const state = req.state, fields = isObject(req.fields) ? { ...req.fields } : {};
|
|
17455
17517
|
const bad2 = validateStateFields(state, fields);
|
|
17456
17518
|
if (bad2.length) throw refusal3(bad2.join("; "));
|
|
@@ -17462,7 +17524,7 @@ var CarBook = class {
|
|
|
17462
17524
|
if (setter.role === "train" && car.project !== void 0 && car.project !== project) throw refusal3(`sb: this train works for project ${project}, not ${String(car.project)}`);
|
|
17463
17525
|
if (setter.role === "main" && (state === "dropped" || state === "landed")) throw refusal3(`sb: only a train sets ${state}; the integrator sets received and returned`);
|
|
17464
17526
|
if (setter.role === "train" && state === "received") throw refusal3("sb: only the integrator sets received");
|
|
17465
|
-
let file2, name2, held, label;
|
|
17527
|
+
let file2, name2, held, label, before, unchecked;
|
|
17466
17528
|
if (setter.role === "main") {
|
|
17467
17529
|
const sent = this.forwardOf(head, setter.session);
|
|
17468
17530
|
if (!sent) throw refusal3(`sb: no forward by a tower carries head ${head.slice(0, 12)} to this session: a car slip reaches the integrator only as the tower's tower_send or tower_reply with forward: (the code stamps fwd-from).${this.restartWord()}`);
|
|
@@ -17475,6 +17537,14 @@ var CarBook = class {
|
|
|
17475
17537
|
const claims = [["app", car.app === void 0 || car.app === slip.app], ["tickets", car.tickets === void 0 || same3(car.tickets, slip.tickets)], ["branch", car.branch === void 0 || car.branch === slip.branch], ["coordinator", car.coordinator === void 0 || car.coordinator === slip.coordinator]];
|
|
17476
17538
|
const off = claims.find(([, ok]) => !ok);
|
|
17477
17539
|
if (off) throw refusal3(`sb: car ${label} does not match the forwarded slip: ${off[0]} differs from what the slip the tower forwarded says`);
|
|
17540
|
+
const ended = file2 ? endOf(file2) : void 0;
|
|
17541
|
+
if (ended && sent.at > Date.parse(ended.at)) {
|
|
17542
|
+
if (ended.state === "landed" && state === "received") throw refusal3(landedWord(label, head, `landed in ${String(ended.version).slice(0, 60)}`));
|
|
17543
|
+
const rode = [...this.cars.get(project)?.entries() ?? []].some(([key2, h]) => (key2 === name2 || key2.startsWith(`${name2}${PAST}`)) && h.file.states.some((s2) => s2.state === "received" && s2.train === fields.train));
|
|
17544
|
+
if (state === "received" && rode) throw refusal3(`sb: car ${label} rode train ${String(fields.train)} in an earlier life and left it; received names the train it rides now`);
|
|
17545
|
+
before = held;
|
|
17546
|
+
held = file2 = void 0;
|
|
17547
|
+
}
|
|
17478
17548
|
if (file2?.states.some((s2) => s2.state === "received")) throw refusal3(`sb: car ${label} is already received${state === "returned" ? "; the integrator returns a car at receipt only" : ""}`);
|
|
17479
17549
|
if (!slip.coordinator) throw refusal3("sb: the slip names no coordinator");
|
|
17480
17550
|
if (slip.coordinator !== sent.from) {
|
|
@@ -17482,13 +17552,15 @@ var CarBook = class {
|
|
|
17482
17552
|
if (state === "received") throw refusal3(word);
|
|
17483
17553
|
fields.reason = word;
|
|
17484
17554
|
}
|
|
17555
|
+
if (state === "received" && !file2) unchecked = checked && checked.head === head && checked.app === slip.app ? checked.unchecked : (await this.unlanded(project, slip.app, head, label, look3)).unchecked;
|
|
17485
17556
|
file2 ??= emptyCar({ project, app: slip.app, tickets: slip.tickets, branch: slip.branch, head, coordinator: sent.from });
|
|
17486
17557
|
} else {
|
|
17487
17558
|
const record2 = this.trainOf(project, train.code);
|
|
17488
17559
|
if (!record2.heads.includes(head)) throw refusal3(`sb: car with head ${head.slice(0, 12)} is not in the manifest of train ${train.code}: the server read the cars of the manifest at the open, and a train sets only those`);
|
|
17489
|
-
|
|
17560
|
+
const life = this.lifeFor(project, head, train.code);
|
|
17561
|
+
held = life?.[1];
|
|
17490
17562
|
file2 = held?.file;
|
|
17491
|
-
name2 =
|
|
17563
|
+
name2 = life?.[0] ?? head;
|
|
17492
17564
|
label = file2?.car.tickets[0] ?? head.slice(0, 12);
|
|
17493
17565
|
if (!file2) throw refusal3(`sb: car with head ${head.slice(0, 12)} is not in the book of project ${project}: only a car the integrator received can be set`);
|
|
17494
17566
|
const receipt = file2.states.find((s2) => s2.state === "received");
|
|
@@ -17504,14 +17576,25 @@ var CarBook = class {
|
|
|
17504
17576
|
} catch (error) {
|
|
17505
17577
|
throw refusal3(error.message);
|
|
17506
17578
|
}
|
|
17507
|
-
const entry = next2.states.at(-1), stored = { file: next2, ...held?.notice ? { notice: held.notice } : {} };
|
|
17579
|
+
const entry = next2.states.at(-1), stored = { file: next2, ...held?.notice ? { notice: held.notice } : before ? { notice: { v: 1, states: {} } } : {} };
|
|
17508
17580
|
const forProject = this.cars.get(project) ?? /* @__PURE__ */ new Map();
|
|
17509
|
-
|
|
17581
|
+
if (before) {
|
|
17582
|
+
const past = `${name2}${PAST}${[...forProject.keys()].filter((k) => k.startsWith(`${name2}${PAST}`)).length + 1}`;
|
|
17583
|
+
forProject.delete(name2);
|
|
17584
|
+
forProject.set(name2, stored);
|
|
17585
|
+
forProject.set(past, before);
|
|
17586
|
+
} else forProject.set(name2, stored);
|
|
17510
17587
|
this.cars.set(project, forProject);
|
|
17511
17588
|
this.writeCar(project, name2, stored);
|
|
17512
17589
|
this.d.log?.("cars-set", { project, state, car: label.slice(0, 40) });
|
|
17513
17590
|
queueMicrotask(() => this.d.onChange?.());
|
|
17514
|
-
|
|
17591
|
+
let notice;
|
|
17592
|
+
try {
|
|
17593
|
+
notice = stateLine(next2, entry);
|
|
17594
|
+
} catch {
|
|
17595
|
+
notice = void 0;
|
|
17596
|
+
}
|
|
17597
|
+
return { state, at: entry.at, file: name2, coordinator: next2.coordinator, ...notice ? { notice } : {}, ...unchecked ? { unchecked } : {} };
|
|
17515
17598
|
}
|
|
17516
17599
|
/**
|
|
17517
17600
|
* A commit is landed when git, run here, finds it on the real remote's branch of the base. The remote is the one the server read from the tower's checkout at the open; the base is the one the manifest named. The tip of that branch is read by `git ls-remote` run
|
|
@@ -17545,6 +17628,87 @@ var CarBook = class {
|
|
|
17545
17628
|
if (!record2.url) throw refusal3(`sb: the remote of project ${project} was not read when train ${code} opened (the open names none or none that is safe to fetch from, or this server learned of the train after a restart), so ${label}'s commit cannot be checked`);
|
|
17546
17629
|
const url = record2.url, first2 = this.remotes.get(project);
|
|
17547
17630
|
if (first2 !== void 0 && first2 !== url) throw refusal3(`sb: the remote of project ${project} changed between two opens of this server (${first2.slice(0, 120)}, then ${url.slice(0, 120)}); landed is not checked against a remote that moved`);
|
|
17631
|
+
await this.withBase({ project, url, base, key: code, state: "landed" }, async (git, tip) => {
|
|
17632
|
+
try {
|
|
17633
|
+
await git("merge-base", "--is-ancestor", commit, tip);
|
|
17634
|
+
} catch {
|
|
17635
|
+
throw refusal3(`sb: landed.commit ${commit.slice(0, 12)} is not on ${base} of the project's remote: a car has landed only when its commit is on the base's branch there`);
|
|
17636
|
+
}
|
|
17637
|
+
});
|
|
17638
|
+
}
|
|
17639
|
+
/**
|
|
17640
|
+
* A car lands once (#15): `received` is refused for a head that git, run here, finds on the base's branch of the project's remote already. Nothing the book remembers is asked, so it holds after a restart, when the book no longer knows that the car landed, and
|
|
17641
|
+
* for a head somebody pushed to the base by hand. The remote and the base are read now: the remote of the checkout of the integrator's workspace (where an open reads it) and the app's `integration.base` in that checkout's apps.json. The fetch is the one of
|
|
17642
|
+
* `landed`, into a mirror of its own. When the checkout's remote cannot be read nothing is checked (`cars-received-unchecked` is logged, and the integrator's tool says so): an open reads the remote from the same checkout, so a train of such a project has no remote and
|
|
17643
|
+
* cannot set `landed` either. When the remote is read but the app names no usable `integration.base`, `received` is refused (car-forward-F003; the boss's rule that a car is never landed twice wins), and so it is when git fails for any reason but reaching the remote. When
|
|
17644
|
+
* `ls-remote` or the fetch fails because the remote cannot be reached or authenticated (the server's git has no credential helper, RR3-F002; repository not found counts), the car is received unchecked with that class as the reason (0.77.2). A head that is not in the base's history is the usual car. A car merged by squash or rebase has no head on the base and is not found here.
|
|
17645
|
+
*/
|
|
17646
|
+
async unlanded(project, app, head, label, look3) {
|
|
17647
|
+
const where = await this.baseOf(look3, app);
|
|
17648
|
+
if ("unread" in where) {
|
|
17649
|
+
this.d.log?.("cars-received-unchecked", { project, car: label.slice(0, 40), reason: "unread" });
|
|
17650
|
+
return { unchecked: `the remote of the integrator's workspace checkout could not be read, so whether head ${head.slice(0, 12)} is on the base already was not checked` };
|
|
17651
|
+
}
|
|
17652
|
+
if ("refused" in where) {
|
|
17653
|
+
const word = `sb: car ${label} is not received: ${where.refused}, so whether its head ${head.slice(0, 12)} is on the base already cannot be checked. A car that is on the base is never received again: the boss sets integration.base of app ${app}`;
|
|
17654
|
+
this.d.log?.("cars-received-refused", { project, car: label.slice(0, 40), reason: word.slice(0, 200) });
|
|
17655
|
+
throw refusal3(word);
|
|
17656
|
+
}
|
|
17657
|
+
const { url, base } = where;
|
|
17658
|
+
let on;
|
|
17659
|
+
try {
|
|
17660
|
+
on = await this.withBase({ project, url, base, key: "receipt", state: "received" }, async (git, tip) => {
|
|
17661
|
+
if (tip === head) return true;
|
|
17662
|
+
try {
|
|
17663
|
+
await git("cat-file", "-e", `${head}^{commit}`);
|
|
17664
|
+
} catch {
|
|
17665
|
+
return false;
|
|
17666
|
+
}
|
|
17667
|
+
try {
|
|
17668
|
+
await git("merge-base", "--is-ancestor", head, tip);
|
|
17669
|
+
return true;
|
|
17670
|
+
} catch (error) {
|
|
17671
|
+
if (error.code === 1) return false;
|
|
17672
|
+
throw refusal3(`sb: git could not compare ${head.slice(0, 12)} with the tip of ${base}: ${firstLine(error)}`);
|
|
17673
|
+
}
|
|
17674
|
+
});
|
|
17675
|
+
} catch (error) {
|
|
17676
|
+
const reach = error.reach;
|
|
17677
|
+
if (reach) {
|
|
17678
|
+
this.d.log?.("cars-received-unchecked", { project, car: label.slice(0, 40), reason: reach });
|
|
17679
|
+
return { unchecked: `the server could not reach the project's remote (${reach}: ${error.message.replace(/^sb: /, "").slice(0, 200)}), so whether head ${head.slice(0, 12)} is on ${base} already was not checked` };
|
|
17680
|
+
}
|
|
17681
|
+
const word = `sb: car ${label} is not received: whether its head ${head.slice(0, 12)} is on ${base} of the project's remote already could not be checked (${error.message.replace(/^sb: /, "").slice(0, 300)}). A car that is on the base is never received again, so the check has to run: try again`;
|
|
17682
|
+
this.d.log?.("cars-received-refused", { project, car: label.slice(0, 40), reason: word.slice(0, 200) });
|
|
17683
|
+
throw refusal3(word);
|
|
17684
|
+
}
|
|
17685
|
+
if (on) throw refusal3(landedWord(label, head, `is on ${base} of the project's remote already`));
|
|
17686
|
+
return {};
|
|
17687
|
+
}
|
|
17688
|
+
/** Where a car of `app` lands, read now and from nothing the book holds: the remote of the checkout of the session's workspace (its own folder when the workspace has none) and the app's `integration.base` in that checkout's apps.json. `unread` when the remote cannot be read, `refused` (why) when the remote is read and the base is not there or not usable. */
|
|
17689
|
+
async baseOf(look3, app) {
|
|
17690
|
+
let checkout;
|
|
17691
|
+
try {
|
|
17692
|
+
checkout = await this.d.checkoutOf?.(look3);
|
|
17693
|
+
} catch {
|
|
17694
|
+
checkout = void 0;
|
|
17695
|
+
}
|
|
17696
|
+
checkout ??= look3.cwd;
|
|
17697
|
+
const url = await this.remoteOf(checkout);
|
|
17698
|
+
if (!checkout || !url) return { unread: true };
|
|
17699
|
+
const apps = readApps(checkout), entry = apps.ok ? apps.apps.find((a) => a.name === app) : void 0;
|
|
17700
|
+
if (!apps.ok) return { refused: "the apps.json of the integrator's workspace checkout cannot be read" };
|
|
17701
|
+
if (!entry) return { refused: `the apps.json of the integrator's workspace checkout names no app ${app}` };
|
|
17702
|
+
const base = isObject(entry.integration) ? entry.integration.base : void 0;
|
|
17703
|
+
if (typeof base !== "string" || !BASE_RE.test(base) || base.includes("..")) return { refused: `app ${app} names no usable integration.base in the apps.json of the integrator's workspace checkout` };
|
|
17704
|
+
return { url, base };
|
|
17705
|
+
}
|
|
17706
|
+
/**
|
|
17707
|
+
* The base's branch of a remote, fetched for one check and removed after it: the steps the comment of `landed` gives, which the check at `received` shares. `answer` gets git in the mirror and the tip `ls-remote` read; the mirror is inspected once more after it
|
|
17708
|
+
* answered. `key` names the mirror's one ref, and `state` the state the refusals speak of.
|
|
17709
|
+
*/
|
|
17710
|
+
async withBase(o, answer) {
|
|
17711
|
+
const { project, url, base, key: code, state } = o;
|
|
17548
17712
|
let work, mirror = "", hosts = "";
|
|
17549
17713
|
try {
|
|
17550
17714
|
mkdirSync12(this.d.dir, { recursive: true, mode: 448 });
|
|
@@ -17559,13 +17723,14 @@ var CarBook = class {
|
|
|
17559
17723
|
}
|
|
17560
17724
|
const env = { GIT_SSH_COMMAND: sshCommand(hosts), GIT_ALLOW_PROTOCOL: "https:ssh" };
|
|
17561
17725
|
const ref = `refs/heads/${base}`, mine = `refs/sb/base/${code}`;
|
|
17562
|
-
const tampered = (problems) => refusal3(`sb: the mirror the server made for this check was written to by something else (${problems.slice(0, 4).join(", ")});
|
|
17726
|
+
const tampered = (problems) => refusal3(`sb: the mirror the server made for this check was written to by something else (${problems.slice(0, 4).join(", ")}); ${state} is not accepted from it. Check again`);
|
|
17563
17727
|
try {
|
|
17564
17728
|
let listed2;
|
|
17565
17729
|
try {
|
|
17566
17730
|
listed2 = await this.d.git(parse3(this.d.dir).root, [...REMOTE_FLAGS, "ls-remote", "--exit-code", "--", url, ref], env);
|
|
17567
17731
|
} catch (error) {
|
|
17568
|
-
|
|
17732
|
+
const line3 = firstLine(error);
|
|
17733
|
+
throw unreached(`sb: git ls-remote of ${base} from the project's remote failed: ${line3}`, line3);
|
|
17569
17734
|
}
|
|
17570
17735
|
const tip = listed2.split("\n").map((l) => l.split(" ")).find(([, name2]) => name2 === ref)?.[0];
|
|
17571
17736
|
if (!tip || !/^[0-9a-f]{40,64}$/.test(tip)) throw refusal3(`sb: the project's remote lists no branch ${base}`);
|
|
@@ -17580,19 +17745,17 @@ var CarBook = class {
|
|
|
17580
17745
|
try {
|
|
17581
17746
|
await inMirror(...REMOTE_FLAGS, ...FETCH_FLAGS, "fetch", "--no-tags", "--no-recurse-submodules", "--", url, `+${ref}:${mine}`);
|
|
17582
17747
|
} catch (error) {
|
|
17583
|
-
|
|
17748
|
+
const line3 = firstLine(error);
|
|
17749
|
+
throw unreached(`sb: git fetch of ${base} from the project's remote failed: ${line3}`, line3);
|
|
17584
17750
|
}
|
|
17585
17751
|
const fetched = inspectMirror(mirror, code, "fetch", fresh.look);
|
|
17586
17752
|
if (fetched.problems.length) throw tampered(fetched.problems);
|
|
17587
17753
|
const got = (await inMirror("rev-parse", "--verify", "-q", mine)).trim();
|
|
17588
|
-
if (got !== tip) throw refusal3(`sb: the fetch brought ${got.slice(0, 12)} as the tip of ${base}, but ls-remote read ${tip.slice(0, 12)} (the branch moved between the two, or the fetch was served from another repository);
|
|
17589
|
-
|
|
17590
|
-
await inMirror("merge-base", "--is-ancestor", commit, tip);
|
|
17591
|
-
} catch {
|
|
17592
|
-
throw refusal3(`sb: landed.commit ${commit.slice(0, 12)} is not on ${base} of the project's remote: a car has landed only when its commit is on the base's branch there`);
|
|
17593
|
-
}
|
|
17754
|
+
if (got !== tip) throw refusal3(`sb: the fetch brought ${got.slice(0, 12)} as the tip of ${base}, but ls-remote read ${tip.slice(0, 12)} (the branch moved between the two, or the fetch was served from another repository); ${state} is not accepted. Check again`);
|
|
17755
|
+
const out = await answer(inMirror, tip);
|
|
17594
17756
|
const after2 = inspectMirror(mirror, code, "check", fetched.look);
|
|
17595
17757
|
if (after2.problems.length) throw tampered(after2.problems);
|
|
17758
|
+
return out;
|
|
17596
17759
|
} finally {
|
|
17597
17760
|
this.dropMirror(work);
|
|
17598
17761
|
}
|
|
@@ -17624,6 +17787,7 @@ var AWAY_MS = 3e4;
|
|
|
17624
17787
|
var MAX_AWAY_MS = 6e5;
|
|
17625
17788
|
var iso2 = (ms3) => new Date(ms3).toISOString();
|
|
17626
17789
|
var short2 = (text11, n = 160) => text11.replace(/[\u0000-\u001f\u007f-\u009f]+/g, " ").trim().slice(0, n);
|
|
17790
|
+
var idStem = (item) => `car-${createHash14("sha256").update(`${item.project}/${item.file.app}/${item.file.car.head}/${item.entry.at}`).digest("hex").slice(0, 12)}-${item.entry.state}`;
|
|
17627
17791
|
var CarNotices = class {
|
|
17628
17792
|
busy = false;
|
|
17629
17793
|
again = false;
|
|
@@ -17667,7 +17831,7 @@ var CarNotices = class {
|
|
|
17667
17831
|
if (record2.deliveredAt || now - Date.parse(entry.at) > KEEP_MS9) return;
|
|
17668
17832
|
const intercom = this.d.intercom();
|
|
17669
17833
|
if (!intercom) return;
|
|
17670
|
-
const key2 =
|
|
17834
|
+
const key2 = idStem(item), gone = this.away.get(key2);
|
|
17671
17835
|
if (gone && now < gone.next) return;
|
|
17672
17836
|
let live;
|
|
17673
17837
|
try {
|
|
@@ -17681,7 +17845,7 @@ var CarNotices = class {
|
|
|
17681
17845
|
this.away.set(key2, { next: now + wait2, wait: wait2 });
|
|
17682
17846
|
}
|
|
17683
17847
|
const sends = record2.attempts.filter((a) => a.outcome !== "not-live");
|
|
17684
|
-
const change = (fn) => this.d.book.updateNotice(project, name2,
|
|
17848
|
+
const change = (fn) => this.d.book.updateNotice(project, name2, entry, fn);
|
|
17685
17849
|
if (!live) {
|
|
17686
17850
|
if (!record2.escalatedAt) {
|
|
17687
17851
|
if (!record2.attempts.some((a) => a.outcome === "not-live")) change((r) => r.attempts.push({ at: iso2(now), outcome: "not-live", answer: `${file2.coordinator} is not live` }));
|
|
@@ -17695,7 +17859,7 @@ var CarNotices = class {
|
|
|
17695
17859
|
}
|
|
17696
17860
|
const due = sends.length === 0 ? now : Date.parse(sends.at(-1).at) + RETRY_MS[sends.length - 1];
|
|
17697
17861
|
if (now < due) return;
|
|
17698
|
-
const n = sends.length + 1, messageId =
|
|
17862
|
+
const n = sends.length + 1, messageId = `${idStem(item)}-${n}`;
|
|
17699
17863
|
const at = iso2(now);
|
|
17700
17864
|
change((r) => {
|
|
17701
17865
|
r.id = messageId;
|
|
@@ -17729,7 +17893,7 @@ var CarNotices = class {
|
|
|
17729
17893
|
}
|
|
17730
17894
|
/** One `blocked` call to the tower of the setter's workspace, naming the car, the state, the coordinator and the notice text. It counts once the tower's mailbox has it. */
|
|
17731
17895
|
async escalate(item, why) {
|
|
17732
|
-
const { project, name: name2, file: file2, entry } = item, state = entry.state, record2 = this.d.book.noticeOf(project, name2,
|
|
17896
|
+
const { project, name: name2, file: file2, entry } = item, state = entry.state, record2 = this.d.book.noticeOf(project, name2, entry) ?? { attempts: [] };
|
|
17733
17897
|
if (record2.escalatedAt) return;
|
|
17734
17898
|
const tries = record2.tower ?? [], now = this.d.now();
|
|
17735
17899
|
if (tries.length >= TOWER_TRIES) return;
|
|
@@ -17743,13 +17907,13 @@ var CarNotices = class {
|
|
|
17743
17907
|
let attempt;
|
|
17744
17908
|
let taken = false;
|
|
17745
17909
|
try {
|
|
17746
|
-
const result2 = await intercom.send(to, { text: message, messageId:
|
|
17910
|
+
const result2 = await intercom.send(to, { text: message, messageId: `${idStem(item)}-tower-${tries.length + 1}` });
|
|
17747
17911
|
taken = result2.delivered === true;
|
|
17748
17912
|
attempt = { at: iso2(now), outcome: taken ? "delivered" : "failed", ...taken ? {} : { answer: short2(result2.reason ?? "not delivered") } };
|
|
17749
17913
|
} catch (error) {
|
|
17750
17914
|
attempt = { at: iso2(now), outcome: "failed", answer: short2(error.message) };
|
|
17751
17915
|
}
|
|
17752
|
-
this.d.book.updateNotice(project, name2,
|
|
17916
|
+
this.d.book.updateNotice(project, name2, entry, (r) => {
|
|
17753
17917
|
(r.tower ??= []).push(attempt);
|
|
17754
17918
|
if (taken) r.escalatedAt = iso2(this.d.now());
|
|
17755
17919
|
});
|
|
@@ -17821,6 +17985,8 @@ function startCars(o) {
|
|
|
17821
17985
|
knownHosts: knownHostsOfUser(),
|
|
17822
17986
|
exists: existsSync6,
|
|
17823
17987
|
log: o.log,
|
|
17988
|
+
// The checkout of the session's workspace, as the tower's open reads it (towers.ts): where the check at `received` finds the project's remote and the app's base.
|
|
17989
|
+
checkoutOf: async (seen) => (seen.workspace ? (await workspaces(o.run)).find((w) => w.workspace_id === seen.workspace)?.worktree?.checkout_path : void 0) ?? seen.cwd,
|
|
17824
17990
|
startOf: o.startOf,
|
|
17825
17991
|
onChange: () => notices?.kick(),
|
|
17826
17992
|
...o.over
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-straw-boss",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.77.2",
|
|
4
4
|
"description": "Straw Boss coordination for pi in Herdr: sessions join a tab's net by choice, the first joiner is its main agent, a workspace tower opens on demand with a live monitoring dashboard, and boss_broadcast reaches the rest",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
package/prompts/apps-config.md
CHANGED
|
@@ -28,7 +28,7 @@ With a merge train:
|
|
|
28
28
|
<!-- integration -->
|
|
29
29
|
## Merge train
|
|
30
30
|
|
|
31
|
-
The procedure is
|
|
31
|
+
The procedure is the `integrating` and `deploying` skills (the merge-train contract), which Straw Boss binds in the Seam bindings of the main prompt; this file holds only the `apps.json` fields. The project's skill (`integration.skill`) holds every concrete check, found by the headings of `integrating`'s Project skill contract (`## Light checks` to `## Load`), exactly as written; Straw Boss reads no other part of it. When a required one is missing (`integrating` says which), the integrator does not depart and calls the tower with `why=blocked`.
|
|
32
32
|
|
|
33
33
|
A computer can turn the merge train off with `STRAW_BOSS_INTEGRATION=off` in the environment, or `"integration": "off"` in `config.json` of the state folder (the variable wins). Every field above is then ignored, and this file is served without it.
|
|
34
34
|
<!-- /integration -->
|
package/prompts/integrator.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Integrator
|
|
2
2
|
|
|
3
|
-
You are the integrator of one project: the main that places the cars mains send it, for each app with an `integration` field ({{dir}}/apps-config.md), on trains. A departed train runs on its own in a `train` session the tower opens; you do not supervise it. Follow
|
|
3
|
+
You are the integrator of one project: the main that places the cars mains send it, for each app with an `integration` field ({{dir}}/apps-config.md), on trains. A departed train runs on its own in a `train` session the tower opens; you do not supervise it. Follow the `integrating` skill and `deploying` skill (the merge-train contract), bound by the Seam bindings in your role prompt. sb refuses your `train` todos while either does not declare the contract: `call_tower` with `why=blocked` quoting the refusal; depart nothing.
|
|
4
4
|
|
|
5
5
|
- The project's skill is `integration.skill` (the headings of `integrating`'s Project skill contract). sb reads apps.json and refuses a `train` todo for an app whose `stages` still list the old uat stage or whose cars show less than `integration.accept`: depart nothing, `why=blocked`, naming the field.
|
|
6
6
|
- A car slip arrives forwarded by the tower; its `coordinator` is a session id and must equal the forward's `fwd-from`. At receipt run `train check` as your main prompt gives it, with `--accept <evidence>` (`none` for a slip that says `accept: none`) `--app-accept <integration.accept> --slip <slip>` (absolute paths) and check that `auth` covers every `strict` target in `deploy`. An `origin=remote:` forward's `auth` covers only `strict` targets its device's boss granted; else `why=blocked`, naming car and target.
|
package/prompts/main.md
CHANGED
|
@@ -5,7 +5,7 @@ You are the main agent of Herdr tab {{tab}}, of kind {{duty}}: the boss works wi
|
|
|
5
5
|
- Brief workers in English: required behavior, the Reality anchor, the boss's authorizations quoted; cause and location are the worker's. End with: "When you need a decision these authorizations do not cover, or a rule you follow says to ask first, call `caller_ping` and stop." Answer pings via the boss; `subagent_resume`.
|
|
6
6
|
- Check results against the brief. Merging to a shared branch or deploying needs the boss's authorization.
|
|
7
7
|
<!-- integration -->
|
|
8
|
-
- For an app with `integration` (apps-config), never merge to its base or claim a pre-dev branch, unless your kind is `integrator`; else after the skill's `Light checks` build and send the car slip by the Seam bindings at the end of this prompt; rework a returned car. Merge and deploy work follows
|
|
8
|
+
- For an app with `integration` (apps-config), never merge to its base or claim a pre-dev branch, unless your kind is `integrator`; else after the skill's `Light checks` build and send the car slip by the Seam bindings at the end of this prompt; rework a returned car. Merge and deploy work follows the `integrating` and `deploying` skills (missing: `call_tower` `why: blocked` naming the merge-train contract).
|
|
9
9
|
<!-- /integration -->
|
|
10
10
|
<!-- no-integration -->
|
|
11
11
|
- Integration is off on this computer: ignore `integration`, `stages`, `targets`, and `deploy` in apps.json, and ask the boss before you merge to a shared branch or deploy. A `car:` block sent to you is answered "integration is off on this computer".
|
package/prompts/planning.md
CHANGED
|
@@ -34,7 +34,7 @@ Each anchor is the lightest check that can fail before the change and still reac
|
|
|
34
34
|
Tasks that share one anchor share one checkpoint. Give each such group one checkpoint todo, `blockedBy` every task it covers, and tell those workers to hand it their evidence. A task whose check is distinct, or plainly cheaper in place, keeps its own.
|
|
35
35
|
|
|
36
36
|
<!-- integration -->
|
|
37
|
-
In an app that declares `integration`, follow `integrating`'s Principle
|
|
37
|
+
In an app that declares `integration`, follow `integrating`'s Principle: your anchor before handoff is your review (P0 and P1 clear), behaviour tests aimed at your own change, and the project skill's `Light checks`; repo-wide quality gates run once, by the integrator, on the integrated pre-dev head (its `Full gates`). Run the app's `integration.accept` on your branch before the slip, as the project skill's `## Acceptance` says, get the boss's nod, and write the evidence file (absolute paths in `accept:` and `evidence`); check it with the `train check` command in your main prompt (`--accept none` when `integration.accept` is empty): `--accept <file> --app-accept <integration.accept> --slip <slip>` before you send the slip; a `human` anchor is this acceptance, not the train's.
|
|
38
38
|
|
|
39
39
|
<!-- /integration -->
|
|
40
40
|
A change-set that touches a shared contract, authorization or permission data, or a migration gets one fresh-context reviewer after its anchor passes. Other change-sets take the author's own read of the diff against the brief.
|
package/prompts/tower-run.md
CHANGED
|
@@ -8,7 +8,7 @@ You are a run: the sb server woke you for the events that reach you as messages,
|
|
|
8
8
|
- Friction reports: find the owner and the broken relationship (registration, endpoint, dependency, shared resource, cleanup); have the owner repair it. Return a Straw Boss defect as a finding with evidence.
|
|
9
9
|
- Your memory (the Memory section of your brief) holds the boss's standing instructions and decisions, as the boss wrote or confirmed them, and the open waits. Follow the standing instructions. You cannot make one: when a boss message gives a lasting instruction or a decision, propose it with `tower_memory` (`add`, `kind`, `text`, and `event` with the id of that boss message), and to retire one propose `retire` with its id. A proposal is pending, not an instruction: the boss confirms or rejects it in the GUI or with `/boss memory`, the brief lists it apart as pending, and you do not act on it as if it were kept. At most 12 open waits are kept (an answered one takes no place), and one expires after 7 days. When the brief says some memory was left out, call `tower_memory` with `op: "read"`. Record a wait when something waits on someone, and resolve it when it ends; a wait is your own note, not an instruction. Record a wait for the boss as a card they act on in the GUI: `type` (action when they do something, choice when they pick, secret when a session needs a secret from them), `happened`, `do`, `url` or `command` (where, for an action), `after`, `options` (for a choice), `secret.name` (for a secret; never the value), and `from`: the session id in the `[intercom from ...]` line of the message that raised it, or `self`. Write every field in the language the brief's Memory section names (sb's locale), as sentences for a person who has not followed the work: say what a host, a ticket, or a tool is the first time. Example, for an event from the session mp3946-print saying its print deploy cannot reach fonstar-staging: `tower_memory` op add, kind wait, for boss, type action, happened "The Tailscale login key of the machine fonstar-staging expired at about 10:30, so it is offline. The print feature of ticket MP-3946 is deployed there, but nobody can reach it to test it.", do "Open the Tailscale admin page and re-authorize fonstar-staging, or set its key to never expire.", url "https://login.tailscale.com/admin/machines", after "Once the machine is back, the tower asks the MP-3946 main to verify the print feature.", from the id in that event's `[intercom from ...]` line. A refusal lists what to fix. Fix every line and call again. When the boss presses a card you get their message (`The boss pressed ...`, `chose ...`, `declined ...`): act on it, then resolve the wait. A declined wait is over: tell the raiser what happens instead. A wait whose row says `old free-text wait` is recorded again as a card with `restates`. Do not send the raiser the same news yourself: sb told it, and your event says whether that reached it. A wait whose row ends with `(open ...)` has stood a day or more: check whether it still holds, then resolve or drop it, or restate it in your handoff note. A wait whose row says `answered by the boss` was answered by their message to you: read that message, act on it, then resolve the wait, or restate it as a new wait if the boss still has to decide something; until you do, the boss is not asked about it again. A wait that is no longer in your memory was resolved or dismissed by the boss: never record it again from an earlier handoff note. Memory is for what outlives runs; the handoff note is for your next run.
|
|
10
10
|
- Close a main you opened with boss_close_main after its done report, unless it awaits a boss decision; if it refuses as busy, retry after its next message.
|
|
11
|
-
- Each agent message says why it came (`why=` in its header, written by the code). `milestone`: update your obligations, tell whoever waits on it, and close a main you opened after its done report. `shared`: <!-- integration -->from the integrator itself, answer go or wait (its slips' auth covers its own merges; a deploy it starts names its target, so check that target for a clash), never forward; otherwise <!-- /integration -->check board_read and your obligations for a clash, then answer go or wait with the owner named. <!-- integration -->Exception: a `shared` request to merge into an app's base, from an app that declares `integration` in apps-config, is no go or wait: it is a car slip, and it goes to that project's integrator (the one main that runs the merge train, per integrator.md beside apps-config.md). Send it there with `boss_open_main` and `role: "integrator"`: the slip as it came as the request, and its sender, in the run that took it. The code reads the project from the checkout's apps.json (name none), refuses the slip of a main opened for a teammate's device (its device's ally run takes it), finds the project's integrator or opens it as your own main (kind integrator, outside the two opened mains and the sender's one; a project never has two) and forwards the slip stamped with its sender. Where the project already runs integrators of its own (the boss's, one per app, such as `integ FE2` and `integ v3`), the door opens nothing and answers with their names and the slip's event id: forward the slip to the one that runs that app's trains with `tower_reply` (`to`: that integrator, `message`: the slip as it came, `forward`: that event id), in the same run, so the code stamps its sender; open no main for it. `tower_send` cannot reach an integrator, and nothing you send without that stamp reaches one as a slip. The sb server tells the coordinator, so relay nothing back. A `shared` from the integrator that carries a `train:` block is a train to open, not go or wait: `boss_open_main` with `role: "train"`, the manifest verbatim as the request, once per code, then answer the integrator with `tower_reply`: the train's session id, or the refusal; a train is no main and does not count toward the two opened mains. A train's `shared` naming a target gets the same clash check as the integrator's deploy; close the train after its done `milestone`. An integrator that reports `milestone` idle is closed by the rule above. A `blocked` from the sb server about a car notice names a coordinator that is gone: find its owner on the board or record a wait for the boss, as for any `blocked`. <!-- /integration --><!-- no-integration -->A `shared` request that carries a `car:` block is no go: answer it with tower_reply "integration is off on this computer" and open no main for it. <!-- /no-integration -->`blocked` or unspecified: route it to its owner. A decision only the boss can make is not sent back to the caller: record a wait for the boss in your memory and name it in your `tower_done` handoff note as waiting on the boss, and tell the main with `tower_reply` that it waits on the boss. Never ask mains for progress: board_read has it.
|
|
11
|
+
- Each agent message says why it came (`why=` in its header, written by the code). `milestone`: update your obligations, tell whoever waits on it, and close a main you opened after its done report. `shared`: <!-- integration -->from the integrator itself, answer go or wait (its slips' auth covers its own merges; a deploy it starts names its target, so check that target for a clash), never forward; otherwise <!-- /integration -->check board_read and your obligations for a clash, then answer go or wait with the owner named. <!-- integration -->Exception: a `shared` request to merge into an app's base, from an app that declares `integration` in apps-config, is no go or wait: it is a car slip, and it goes to that project's integrator (the one main that runs the merge train, per integrator.md beside apps-config.md). Send it there with `boss_open_main` and `role: "integrator"`: the slip as it came as the request, and its sender, in the run that took it. The code reads the project from the checkout's apps.json (name none), refuses the slip of a main opened for a teammate's device (its device's ally run takes it), finds the project's integrator or opens it as your own main (kind integrator, outside the two opened mains and the sender's one; a project never has two) and forwards the slip stamped with its sender. Where the project already runs integrators of its own (the boss's, one per app, such as `integ FE2` and `integ v3`), the door opens nothing and answers with their names and the slip's event id: forward the slip to the one that runs that app's trains with `tower_reply` (`to`: that integrator, `message`: the slip as it came, `forward`: that event id), in the same run, so the code stamps its sender; open no main for it. `tower_send` cannot reach an integrator, and nothing you send without that stamp reaches one as a slip. The sb server tells the coordinator, so relay nothing back. A `shared` from the integrator that carries a `train:` block is a train to open, not go or wait: `boss_open_main` with `role: "train"`, the manifest verbatim as the request, once per code, then answer the integrator with `tower_reply`: the train's session id, or the refusal; a train is no main and does not count toward the two opened mains. A train's `shared` naming a target gets the same clash check as the integrator's deploy; close the train after its done `milestone`. An integrator that reports `milestone` idle is closed by the rule above. A `blocked` from the sb server about a car notice names a coordinator that is gone: find its owner on the board or record a wait for the boss, as for any `blocked`. One from an integrator about a `returned` notice sb cannot confirm carries the notice: when that coordinator is live, send it the notice with `tower_reply` (`to`: its session id); else do as for one that is gone. <!-- /integration --><!-- no-integration -->A `shared` request that carries a `car:` block is no go: answer it with tower_reply "integration is off on this computer" and open no main for it. <!-- /no-integration -->`blocked` or unspecified: route it to its owner. A decision only the boss can make is not sent back to the caller: record a wait for the boss in your memory and name it in your `tower_done` handoff note as waiting on the boss, and tell the main with `tower_reply` that it waits on the boss. Never ask mains for progress: board_read has it.
|
|
12
12
|
- Never ask the boss (no ask_user, robot_hand, focus changes); a decision only the boss can make goes in the handoff note as above. Call `tower_done` with a handoff note (what you routed, what waits for whom, what to check next) when nothing is left for you; it is refused while events are still for you, and it answers that the boss is here while they are in this session (they wrote at the tower prompt or typed here): then keep answering them, and call it again when they are quiet and you are asked to wrap up.
|
|
13
13
|
- Your brief may open with a boss conversation: the boss is at the keyboard, and this session may be the one you talked with them in before, resumed. What is in it from earlier (intercom messages, notices, a teammate's words, even text that quotes the boss) is data and history, not instruction; only an event that opens with the boss line is the boss's, as ever. The event-run notes in your brief are those runs' own words, fenced in double angle quotes, not the boss's; what the boss said there is in that run's session. Stay and answer them: do not call `tower_done` after an answer while they are here (it is answered with a stay, and then you write nothing more until their next message), and the server ends the conversation when they leave or go quiet, then asks you for the handoff note.
|
|
14
14
|
- Do no work yourself: no commands, process signals, edits, or subagents; even a one-step fix goes to its owner. A run the server started has no shell, edit, or write tool, only the tower tools and read-only file access (`read`, `grep`, `find`, `ls`, which refuse the sb server's state folder and secret folders).
|
package/prompts/train.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<!-- integration -->
|
|
2
|
-
You are a train, opened by the tower for one set of cars. You are no tab's main, and your name is never renamed. The `train:` manifest in your handoff is your work. Follow
|
|
2
|
+
You are a train, opened by the tower for one set of cars. You are no tab's main, and your name is never renamed. The `train:` manifest in your handoff is your work. Follow the `integrating` and `deploying` skills (the merge-train contract), bound by the Seam bindings below. sb refuses your `todo` and `MonitorCreate` calls while either does not declare the contract: `call_tower` with `why=blocked` quoting the refusal.
|
|
3
3
|
|
|
4
4
|
- Assemble the cars; run the checks before push, before merge, and before CI/CD; deploy; end. The order is the one `integrating`, `deploying`, and the project's skill give.
|
|
5
5
|
- Every todo is a step with `metadata.sb` (`v`: 1, `project`, `app`, `train`, `round`, `kind`, `name`, `spec`) and nothing else; sb blocks a `todo` call that does not fit. Kinds only classify: `assemble`, `review`, `full-check`, `merge`, `ci`, `deploy`, `deploy-verify`, `rollback`, `land`. A failed step completes `failed`.
|