agent-coord-mcp 0.26.21 → 0.26.23
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/dist/capabilities.js +270 -2
- package/dist/capabilities.js.map +1 -1
- package/dist/closing-line.js +83 -0
- package/dist/closing-line.js.map +1 -0
- package/dist/commit-cite.js +55 -0
- package/dist/commit-cite.js.map +1 -0
- package/dist/gated-head.js +67 -20
- package/dist/gated-head.js.map +1 -1
- package/dist/server-spread.js +195 -0
- package/dist/server-spread.js.map +1 -0
- package/dist/server.js +2 -2
- package/dist/server.js.map +1 -1
- package/dist/store.js +32 -0
- package/dist/store.js.map +1 -1
- package/dist/tools/away.js +67 -7
- package/dist/tools/away.js.map +1 -1
- package/dist/tools/board-ref.js +44 -4
- package/dist/tools/board-ref.js.map +1 -1
- package/dist/tools/event-kinds.js +5 -1
- package/dist/tools/event-kinds.js.map +1 -1
- package/dist/tools/events.js +40 -4
- package/dist/tools/events.js.map +1 -1
- package/dist/tools/herdr-delivery.js +99 -0
- package/dist/tools/herdr-delivery.js.map +1 -0
- package/dist/tools/messaging.js +72 -6
- package/dist/tools/messaging.js.map +1 -1
- package/dist/tools/record-events.js +85 -5
- package/dist/tools/record-events.js.map +1 -1
- package/dist/tools/records.js +310 -44
- package/dist/tools/records.js.map +1 -1
- package/dist/tools/registry.js +67 -3
- package/dist/tools/registry.js.map +1 -1
- package/dist/tools/seat-build.js +182 -0
- package/dist/tools/seat-build.js.map +1 -0
- package/dist/tools/shared.js.map +1 -1
- package/dist/tools/stall.js +1095 -18
- package/dist/tools/stall.js.map +1 -1
- package/dist/tools/transport.js +71 -3
- package/dist/tools/transport.js.map +1 -1
- package/dist/tools/worktrees.js +14 -0
- package/dist/tools/worktrees.js.map +1 -1
- package/dist/transports/herdr.js +297 -0
- package/dist/transports/herdr.js.map +1 -0
- package/dist/transports/index.js +10 -4
- package/dist/transports/index.js.map +1 -1
- package/package.json +1 -1
- package/scripts/coord-attention-clock.mjs +2 -0
- package/scripts/coord-stall-clock.mjs +52 -11
- package/src/capabilities.ts +284 -2
- package/src/closing-line.ts +85 -0
- package/src/commit-cite.ts +58 -0
- package/src/gated-head.ts +128 -26
- package/src/server-spread.ts +233 -0
- package/src/server.ts +2 -2
- package/src/store.ts +32 -0
- package/src/tools/away.ts +82 -9
- package/src/tools/board-ref.ts +70 -3
- package/src/tools/event-kinds.ts +19 -2
- package/src/tools/events.ts +42 -4
- package/src/tools/herdr-delivery.ts +87 -0
- package/src/tools/messaging.ts +71 -6
- package/src/tools/record-events.ts +78 -5
- package/src/tools/records.ts +316 -44
- package/src/tools/registry.ts +68 -4
- package/src/tools/seat-build.ts +201 -0
- package/src/tools/shared.ts +22 -0
- package/src/tools/stall.ts +1266 -23
- package/src/tools/transport.ts +69 -2
- package/src/tools/worktrees.ts +13 -0
- package/src/transports/herdr.ts +311 -0
- package/src/transports/index.ts +10 -4
package/src/capabilities.ts
CHANGED
|
@@ -47,6 +47,11 @@ import {
|
|
|
47
47
|
type TransportKind,
|
|
48
48
|
} from "./transports/index.js";
|
|
49
49
|
import { readAllTransportMarkers } from "./tools/registry.js";
|
|
50
|
+
import { queueWriteSchema } from "./tools/queue-write.js";
|
|
51
|
+
import { treeProvenance } from "./tools/tree-provenance.js";
|
|
52
|
+
import { detectSpread } from "./server-spread.js";
|
|
53
|
+
import { HerdrTransport, herdrKeyName } from "./transports/herdr.js";
|
|
54
|
+
import { HERDR } from "./transports/types.js";
|
|
50
55
|
|
|
51
56
|
export type ProbeResult = {
|
|
52
57
|
id: string;
|
|
@@ -59,6 +64,69 @@ export type ProbeResult = {
|
|
|
59
64
|
|
|
60
65
|
type Probe = { id: string; since: string; run: () => { present: boolean; evidence: string } };
|
|
61
66
|
|
|
67
|
+
/**
|
|
68
|
+
* ⛔⛆⛆ THE PROBE DECISIONS ARE EXPORTED AS PURE PREDICATES, AND THE MUTATION
|
|
69
|
+
* MATRIX IS WHY.
|
|
70
|
+
*
|
|
71
|
+
* Their first form computed `present` inline and built an evidence string from
|
|
72
|
+
* the same raw values. Deleting a conjunct from `present` reddened NOTHING: the
|
|
73
|
+
* tests asserted the EVIDENCE TEXT, which the mutation did not touch, and the
|
|
74
|
+
* probe's own fixed input could not produce the rejected case. ⭐⭐ ***A
|
|
75
|
+
* predicate that cannot be handed the input it is supposed to reject is not
|
|
76
|
+
* guarded — it is decorative, which is the defect one row over and the same
|
|
77
|
+
* shape this row is about.***
|
|
78
|
+
*
|
|
79
|
+
* Exported so a control can pass the failing shape directly.
|
|
80
|
+
*/
|
|
81
|
+
export function retagAccepted(parse: (v: string) => boolean): boolean {
|
|
82
|
+
// BOTH halves matter: the new member must parse AND a pre-existing one must
|
|
83
|
+
// still parse. Without the control a schema that accepted ANY string would pass.
|
|
84
|
+
return parse("retag") === true && parse("reprioritise") === true;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* `#283`'s load-bearing property, and it is NOT "it answered": an unfetchable
|
|
89
|
+
* tree must report `"unknown"` and NEVER `0`. A distance of `0` from an
|
|
90
|
+
* unfetched ref and from a fetched one are byte-identical and mean opposite
|
|
91
|
+
* things — so a numeric `behind` on a tree that was never fetched is the exact
|
|
92
|
+
* failure the verb exists to prevent.
|
|
93
|
+
*/
|
|
94
|
+
export function treeProvenanceRefusesZero(r: { behind: number | "unknown"; fetched: boolean; stale: boolean }): boolean {
|
|
95
|
+
return r.behind === "unknown" && r.fetched === false && r.stale === false;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* `#293`'s load-bearing property (0.26.22): a seat that publishes NO module path
|
|
100
|
+
* makes the fleet `CANNOT_COMPARE` — it is never dropped from the population so
|
|
101
|
+
* the readable rest can answer `AGREED`. ⛔ BOTH CONTROLS ARE CONJUNCTS ON
|
|
102
|
+
* PURPOSE: readable seats on one side of the install must still `AGREED` and on
|
|
103
|
+
* two sides must still `DIVERGED`, or a detector that answered
|
|
104
|
+
* `CANNOT_COMPARE` for everything would pass this probe while detecting nothing.
|
|
105
|
+
*
|
|
106
|
+
* ⭐ AND THIS PROBE EXISTS BECAUSE THE GATE ONE ROW OVER FIRED ON ITS OWN PR:
|
|
107
|
+
* `#293` bumped `0.26.22` with behaviour and no probe, `main` moved under
|
|
108
|
+
* `#292`, and qa measured `probedThrough 0.26.21 < running 0.26.22 → ok:false`.
|
|
109
|
+
* The remedy is the probe, not a softer comparison — softening it would turn
|
|
110
|
+
* the verb back into the label read ⟨q-1c8e35f9⟩ exists to end.
|
|
111
|
+
*/
|
|
112
|
+
/**
|
|
113
|
+
* ⟨q-8a3f1c05⟩ / #303 — IN-FLIGHT IS DERIVED FROM THE SEAM, NOT MATCHED ON A GLYPH.
|
|
114
|
+
* A 0.26.21 server read `⛔ Blocked — was 🚧 until the base went red` as IN FLIGHT
|
|
115
|
+
* (the regex `/🚧|🔍/` matched the mention); the seam's `workStateOf` reads the
|
|
116
|
+
* LEADING glyph and answers blocked. All three conjuncts matter: the old answer
|
|
117
|
+
* for the blocked row must be refused AND the two genuine in-flight states must
|
|
118
|
+
* still read in flight, or a predicate that answers false to everything passes.
|
|
119
|
+
* The version label did not move for #303 (still 0.26.22), so `check-probe-coverage`
|
|
120
|
+
* could not see the behaviour arrive — this probe is what sees it.
|
|
121
|
+
*/
|
|
122
|
+
export function inFlightDerivedFromSeam(inFlight: (status: string) => boolean): boolean {
|
|
123
|
+
return inFlight("⛔ Blocked — was 🚧 until the base went red") === false && inFlight("🔍 In Review") === true && inFlight("🚧 In Progress") === true;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export function spreadPoisonedByUnreadableSeat(states: { unreadable: string; agreed: string; diverged: string }): boolean {
|
|
127
|
+
return states.unreadable === "CANNOT_COMPARE" && states.agreed === "AGREED" && states.diverged === "DIVERGED";
|
|
128
|
+
}
|
|
129
|
+
|
|
62
130
|
/**
|
|
63
131
|
* Each probe calls a behaviour that did not exist before its release and
|
|
64
132
|
* reports what it observed. A probe that could pass without the code being
|
|
@@ -124,6 +192,104 @@ const PROBES: Probe[] = [
|
|
|
124
192
|
};
|
|
125
193
|
},
|
|
126
194
|
},
|
|
195
|
+
/**
|
|
196
|
+
* ⛔⛆⛆ THE PROBES BELOW CLOSE THE WINDOW ⟨q-1c8e35f9⟩ MEASURED.
|
|
197
|
+
*
|
|
198
|
+
* Before them the newest `since` was `0.26.15`, so `capabilities` answered
|
|
199
|
+
* `ok · missing: []` identically on every version from `0.26.16` to `0.26.21`
|
|
200
|
+
* — the whole set the fleet was about to install.
|
|
201
|
+
*
|
|
202
|
+
* ⚠ AND THE TRAP THE ROW NAMES IS THE ONE TO AVOID WHILE WRITING THESE:
|
|
203
|
+
* `away-means-david-away` EXISTS, its NAME matches the changed area, and its
|
|
204
|
+
* ASSERTION predates the change — it tests `0.26.13`'s refusal list, not
|
|
205
|
+
* `#216`'s query mode. ⭐⭐ ***A probe whose name matches while its assertion
|
|
206
|
+
* predates reads as coverage and is not. So each probe below asserts a
|
|
207
|
+
* behaviour that DID NOT EXIST before its own `since`, and would throw or
|
|
208
|
+
* return `false` on the release before it.***
|
|
209
|
+
*/
|
|
210
|
+
{
|
|
211
|
+
// #284 — `queue_write` gained `op: "retag"`. On 0.26.20 the enum has three
|
|
212
|
+
// members and parsing `"retag"` throws, which is the probe's whole point.
|
|
213
|
+
id: "queue-write-retag",
|
|
214
|
+
since: "0.26.21",
|
|
215
|
+
run: () => {
|
|
216
|
+
const parse = (v: string) => queueWriteSchema.op.safeParse(v).success === true;
|
|
217
|
+
const present = retagAccepted(parse);
|
|
218
|
+
return {
|
|
219
|
+
present,
|
|
220
|
+
evidence: `queue_write op accepts "retag": ${parse("retag")} (control "reprioritise": ${parse("reprioritise")}) -> present=${present}`,
|
|
221
|
+
};
|
|
222
|
+
},
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
// #283 — every `repo`-taking verb reports the tree it read. The load-bearing
|
|
226
|
+
// property is NOT that it answers, it is that an unfetchable tree yields
|
|
227
|
+
// `"unknown"` and NEVER `0`: a distance of 0 from an unfetched ref and from a
|
|
228
|
+
// fetched one are byte-identical and mean opposite things.
|
|
229
|
+
id: "tree-provenance-unknown-not-zero",
|
|
230
|
+
since: "0.26.21",
|
|
231
|
+
run: () => {
|
|
232
|
+
const r = treeProvenance("/nonexistent-path-for-capability-probe");
|
|
233
|
+
const present = treeProvenanceRefusesZero(r);
|
|
234
|
+
return {
|
|
235
|
+
present,
|
|
236
|
+
evidence: `unreachable tree -> behind=${JSON.stringify(r.behind)} fetched=${r.fetched} stale=${r.stale} -> present=${present}`,
|
|
237
|
+
};
|
|
238
|
+
},
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
// #293 — `detectSpread` did not exist before 0.26.22. The property is not
|
|
242
|
+
// "it answers": an UNREADABLE seat must poison the verdict rather than be
|
|
243
|
+
// dropped, while readable seats still resolve to AGREED / DIVERGED.
|
|
244
|
+
id: "server-spread-unreadable-poisons",
|
|
245
|
+
since: "0.26.22",
|
|
246
|
+
run: () => {
|
|
247
|
+
const installed = { mtime: 1_000, module: "/installed-for-capability-probe" };
|
|
248
|
+
const a = { agentId: "a", serverStartedAt: 2_000, serverModule: installed.module };
|
|
249
|
+
const b = { agentId: "b", serverStartedAt: 3_000, serverModule: installed.module };
|
|
250
|
+
const older = { agentId: "older", serverStartedAt: 500, serverModule: installed.module };
|
|
251
|
+
const mute = { agentId: "mute" };
|
|
252
|
+
const states = {
|
|
253
|
+
unreadable: detectSpread([a, mute], installed).state,
|
|
254
|
+
agreed: detectSpread([a, b], installed).state,
|
|
255
|
+
diverged: detectSpread([a, older], installed).state,
|
|
256
|
+
};
|
|
257
|
+
const present = spreadPoisonedByUnreadableSeat(states);
|
|
258
|
+
return {
|
|
259
|
+
present,
|
|
260
|
+
evidence: `unreadable seat -> ${states.unreadable} · same side -> ${states.agreed} · two sides -> ${states.diverged} -> present=${present}`,
|
|
261
|
+
};
|
|
262
|
+
},
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
// #303 (shipped under 0.26.22, no bump) — `isInFlightStatus` derives from the seam.
|
|
266
|
+
id: "in-flight-derives-from-seam",
|
|
267
|
+
since: "0.26.22",
|
|
268
|
+
run: () => {
|
|
269
|
+
const blocked = isInFlightStatus("⛔ Blocked — was 🚧 until the base went red");
|
|
270
|
+
const review = isInFlightStatus("🔍 In Review");
|
|
271
|
+
const present = inFlightDerivedFromSeam(isInFlightStatus);
|
|
272
|
+
return { present, evidence: `"⛔ Blocked — was 🚧 …" in flight: ${blocked} (0.26.21 said true) · "🔍 In Review": ${review} -> present=${present}` };
|
|
273
|
+
},
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
// Phase 5.4 Task 4 (0.26.23) — the herdr transport exists and refuses by name: a scripted
|
|
277
|
+
// dead pane reads dead from herdr's own reply, and a tmux key name is refused, not typed.
|
|
278
|
+
id: "herdr-transport-registered",
|
|
279
|
+
since: "0.26.23",
|
|
280
|
+
run: () => {
|
|
281
|
+
const scripted = new HerdrTransport({
|
|
282
|
+
run: (a) => (a[0] === "status"
|
|
283
|
+
? { ok: true, status: 0, stdout: "server:\n status: running\n", stderr: "" }
|
|
284
|
+
: { ok: false, status: 0, stdout: "", stderr: "", json: { error: { code: "pane_not_found", message: "pane w0:p0 not found" } }, error: { code: "pane_not_found", message: "pane w0:p0 not found" } }),
|
|
285
|
+
sleep: () => {},
|
|
286
|
+
});
|
|
287
|
+
const key = herdrKeyName("C-u");
|
|
288
|
+
const exists = scripted.paneExists("w0:p0");
|
|
289
|
+
const present = scripted.kind === HERDR && exists === false && key.ok === false;
|
|
290
|
+
return { present, evidence: `HerdrTransport.kind=${scripted.kind} · scripted pane_not_found -> paneExists=${exists} · herdrKeyName("C-u").ok=${key.ok} -> present=${present}` };
|
|
291
|
+
},
|
|
292
|
+
},
|
|
127
293
|
{
|
|
128
294
|
id: "record-authority",
|
|
129
295
|
since: "0.24.0",
|
|
@@ -184,13 +350,82 @@ export type CapabilityReport = {
|
|
|
184
350
|
*/
|
|
185
351
|
answeredBy: { pid: number; startedAtIso: string; module: string; versionLabel: string };
|
|
186
352
|
probes: ProbeResult[];
|
|
353
|
+
/** Whether the probes reach the version this process claims to be. */
|
|
354
|
+
coverage: {
|
|
355
|
+
probedThrough: string | null;
|
|
356
|
+
running: string;
|
|
357
|
+
covered: boolean;
|
|
358
|
+
verdict: string;
|
|
359
|
+
};
|
|
187
360
|
missing: string[];
|
|
361
|
+
/** Every probe passed AND the probes reach the running version. */
|
|
188
362
|
ok: boolean;
|
|
189
363
|
/** Absent only if the probe itself threw — see `probeTransport`. */
|
|
190
364
|
transport?: TransportCapability;
|
|
191
365
|
note: string;
|
|
192
366
|
};
|
|
193
367
|
|
|
368
|
+
/**
|
|
369
|
+
* ⛔⛆⛆ `missing: []` MEANS TWO DIFFERENT THINGS AND THIS SEPARATES THEM.
|
|
370
|
+
*
|
|
371
|
+
* "Nothing is missing" and "nothing was tested" produce the SAME answer today.
|
|
372
|
+
* ⭐⭐ ***Measured 2026-09-14: `capabilities` answered `ok · missing: []`
|
|
373
|
+
* IDENTICALLY on `0.26.20` and `0.26.21` — the probe set stops at `since
|
|
374
|
+
* 0.26.15`, so every version the fleet was about to install was unprobed, and
|
|
375
|
+
* the verb the fleet reaches for to prove a restart took could not see the three
|
|
376
|
+
* changes it would have been asked to certify.***
|
|
377
|
+
*
|
|
378
|
+
* That is `0`-vs-`unknown` inside the instrument the six delivery states END on:
|
|
379
|
+
* while this is blind, `observed` is unmeasurable BY CONSTRUCTION and every
|
|
380
|
+
* "delivered" claim in the fleet rests on a version LABEL.
|
|
381
|
+
*
|
|
382
|
+
* ⚠ THE COMPARISON IS AGAINST THE LABEL, WHICH IS NOT EVIDENCE — and that is
|
|
383
|
+
* deliberate rather than sloppy. The label is the only statement of intent
|
|
384
|
+
* available about what this process is SUPPOSED to be; the probes are the only
|
|
385
|
+
* evidence about what it IS. Comparing them is precisely how a divergence
|
|
386
|
+
* becomes visible, and this function says which side is which rather than
|
|
387
|
+
* blending them.
|
|
388
|
+
*/
|
|
389
|
+
function coverageOf(probes: ProbeResult[], versionLabel: string) {
|
|
390
|
+
const cmp = (a: string, b: string) => {
|
|
391
|
+
const pa = a.split(".").map((n) => Number.parseInt(n, 10));
|
|
392
|
+
const pb = b.split(".").map((n) => Number.parseInt(n, 10));
|
|
393
|
+
for (let i = 0; i < Math.max(pa.length, pb.length); i += 1) {
|
|
394
|
+
const x = Number.isFinite(pa[i]) ? pa[i] : 0;
|
|
395
|
+
const y = Number.isFinite(pb[i]) ? pb[i] : 0;
|
|
396
|
+
if (x !== y) return x < y ? -1 : 1;
|
|
397
|
+
}
|
|
398
|
+
return 0;
|
|
399
|
+
};
|
|
400
|
+
const sinces = probes.map((p) => p.since).filter((v) => /^\d+(\.\d+)*$/.test(v));
|
|
401
|
+
const probedThrough = sinces.length ? sinces.reduce((hi, v) => (cmp(v, hi) > 0 ? v : hi)) : null;
|
|
402
|
+
const labelUsable = /^\d+(\.\d+)*$/.test(versionLabel);
|
|
403
|
+
|
|
404
|
+
if (!probedThrough || !labelUsable) {
|
|
405
|
+
return {
|
|
406
|
+
probedThrough,
|
|
407
|
+
running: versionLabel,
|
|
408
|
+
covered: false as const,
|
|
409
|
+
verdict:
|
|
410
|
+
`COVERAGE UNKNOWN — ${!probedThrough ? "no probe declares a numeric `since`" : "the version label is not numeric"}. ` +
|
|
411
|
+
`Unknown is not covered: this cannot be read as "nothing is missing".`,
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
const covered = cmp(probedThrough, versionLabel) >= 0;
|
|
415
|
+
return {
|
|
416
|
+
probedThrough,
|
|
417
|
+
running: versionLabel,
|
|
418
|
+
covered,
|
|
419
|
+
verdict: covered
|
|
420
|
+
? `PROBES REACH THE RUNNING VERSION — newest probe \`since ${probedThrough}\`, label \`${versionLabel}\`. ` +
|
|
421
|
+
`So \`missing: []\` here means TESTED-AND-PRESENT rather than untested.`
|
|
422
|
+
: `UNPROBED WINDOW \`${probedThrough}\` → \`${versionLabel}\` — every behaviour introduced after ` +
|
|
423
|
+
`\`${probedThrough}\` is UNTESTED by this verb. \`missing: []\` below therefore does NOT mean "nothing is ` +
|
|
424
|
+
`missing"; it means "nothing in that window was looked at". A restart certified on this answer certifies the ` +
|
|
425
|
+
`versions it can see and is silent about the ones it cannot.`,
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
|
|
194
429
|
export function probeCapabilities(context: { module: string; versionLabel: string }): CapabilityReport {
|
|
195
430
|
const probes: ProbeResult[] = PROBES.map((p) => {
|
|
196
431
|
try {
|
|
@@ -205,7 +440,9 @@ export function probeCapabilities(context: { module: string; versionLabel: strin
|
|
|
205
440
|
}
|
|
206
441
|
});
|
|
207
442
|
const missing = probes.filter((p) => !p.present).map((p) => p.id);
|
|
443
|
+
const coverage = coverageOf(probes, context.versionLabel);
|
|
208
444
|
return {
|
|
445
|
+
coverage,
|
|
209
446
|
answeredBy: {
|
|
210
447
|
pid: process.pid,
|
|
211
448
|
startedAtIso: new Date(Date.now() - Math.round(process.uptime() * 1000)).toISOString(),
|
|
@@ -214,7 +451,14 @@ export function probeCapabilities(context: { module: string; versionLabel: strin
|
|
|
214
451
|
},
|
|
215
452
|
probes,
|
|
216
453
|
missing,
|
|
217
|
-
|
|
454
|
+
/**
|
|
455
|
+
* ⛔ `ok` NOW REQUIRES COVERAGE AS WELL AS PRESENCE. It previously meant
|
|
456
|
+
* "no probe failed", which on an unprobed version is "no probe ran" — the
|
|
457
|
+
* reading this row exists to stop. A reader asking "is this server good?"
|
|
458
|
+
* gets `false` when the honest answer is "I cannot tell", and `coverage`
|
|
459
|
+
* says which of the two it is.
|
|
460
|
+
*/
|
|
461
|
+
ok: missing.length === 0 && coverage.covered,
|
|
218
462
|
note:
|
|
219
463
|
"Every line above was produced by CALLING the code in this process. `versionLabel` is a label someone typed " +
|
|
220
464
|
"into package.json and is context, never evidence — a published tarball has already been observed carrying a " +
|
|
@@ -227,6 +471,8 @@ export function probeCapabilities(context: { module: string; versionLabel: strin
|
|
|
227
471
|
/* ── the verb ──────────────────────────────────────────────────────────────── */
|
|
228
472
|
|
|
229
473
|
import { resolveServerIdentity } from "./server-identity.js";
|
|
474
|
+
import { seatBuildOf, installedFrom, psReader, type SeatBuild } from "./tools/seat-build.js";
|
|
475
|
+
import { isInFlightStatus } from "./tools/stall.js";
|
|
230
476
|
|
|
231
477
|
export const capabilitiesSchema = {} as const;
|
|
232
478
|
|
|
@@ -274,11 +520,47 @@ export async function probeTransport(): Promise<TransportCapability> {
|
|
|
274
520
|
};
|
|
275
521
|
}
|
|
276
522
|
|
|
523
|
+
/**
|
|
524
|
+
* ⟨q-8a3f1c05⟩ — EVERY LIVE SEAT'S BUILD STATE, STATED. The restart operation read
|
|
525
|
+
* `capabilities` to certify a stage and it could not see a pusher; this is that verb
|
|
526
|
+
* answering the question it was asked. `seats[]` carries each live seat's PUSHER half
|
|
527
|
+
* (keyed by the `--agent` on its own command line, against the installed hook's mtime);
|
|
528
|
+
* `answering` carries the SERVER half of the one process that can know it — this one.
|
|
529
|
+
* Servers carry no `--agent`, so no other seat's server is observable from here, and
|
|
530
|
+
* each seat entry says so rather than borrowing its marker's attach-time stamp.
|
|
531
|
+
*/
|
|
532
|
+
export async function seatBuilds(): Promise<{ installed: { module: string; hookPath: string; hookMtime: string | null; buildMtime: string | null }; answering: SeatBuild["server"]; seats: SeatBuild[]; note: string }> {
|
|
533
|
+
const id = resolveServerIdentity();
|
|
534
|
+
const installed = installedFrom(id.path);
|
|
535
|
+
const startedAt = Date.now() - Math.round(process.uptime() * 1000);
|
|
536
|
+
const answering = seatBuildOf({ agentId: "(answering process)", marker: undefined, installed, ps: psReader, server: { pid: process.pid, startedAt, buildMtime: installed.buildMtime } }).server;
|
|
537
|
+
const seats: SeatBuild[] = [];
|
|
538
|
+
try {
|
|
539
|
+
for (const { marker, live } of await readAllTransportMarkers()) {
|
|
540
|
+
if (!live) continue;
|
|
541
|
+
seats.push(seatBuildOf({ agentId: marker.agentId, marker, installed, ps: psReader, server: null }));
|
|
542
|
+
}
|
|
543
|
+
} catch {
|
|
544
|
+
/* an unreadable transports dir yields no seats — an empty list, not a healthy fleet */
|
|
545
|
+
}
|
|
546
|
+
const toIso = (ms: number | null) => (ms === null ? null : new Date(ms).toISOString());
|
|
547
|
+
return {
|
|
548
|
+
installed: { module: installed.module, hookPath: installed.hookPath, hookMtime: toIso(installed.hookMtime), buildMtime: toIso(installed.buildMtime) },
|
|
549
|
+
answering,
|
|
550
|
+
seats,
|
|
551
|
+
note:
|
|
552
|
+
"seats[] states each live seat's PUSHER against the installed hook's own mtime (hooks/tmux-pusher.mjs, read directly), " +
|
|
553
|
+
"keyed by the --agent on the pusher's command line. The SERVER half is known only for the answering process " +
|
|
554
|
+
"(`answering`): servers carry no --agent, so another seat's server cannot be keyed from ps — ask that seat's own " +
|
|
555
|
+
"`status`, which states both halves for itself. A seat that reads current here and stale in its own status is half-restarted.",
|
|
556
|
+
};
|
|
557
|
+
}
|
|
558
|
+
|
|
277
559
|
export async function capabilitiesTool() {
|
|
278
560
|
const id = resolveServerIdentity();
|
|
279
561
|
const report = probeCapabilities({ module: id.path, versionLabel: id.version });
|
|
280
562
|
try {
|
|
281
|
-
return { ...report, transport: await probeTransport() };
|
|
563
|
+
return { ...report, transport: await probeTransport(), seats: await seatBuilds() };
|
|
282
564
|
} catch (e) {
|
|
283
565
|
// A THROWN TRANSPORT PROBE IS NOT A BROKEN VERB. An unknown configured value
|
|
284
566
|
// refuses at startup by design, and this verb is exactly what an operator
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* ⟨q-fee7239f⟩ — A CLOSING LINE STATES AN ARTEFACT IT HAS NOT READ.
|
|
3
|
+
*
|
|
4
|
+
* Measured 2026-09-14 in one clock: #318 merged 18:12:42Z · "Remote branch
|
|
5
|
+
* deleted" posted 18:12:53.626Z · head_ref_deleted 18:13:27Z — the claim
|
|
6
|
+
* preceded its artefact by 33.4s; #319 by 61.7s. Then qa re-read
|
|
7
|
+
* `git ls-remote --heads origin` after #321 and withdrew the same line for
|
|
8
|
+
* FIVE merges (#309 #311 #315 #317 #321) where the remote was NEVER deleted:
|
|
9
|
+
* `gh --delete-branch` had not deleted the remote when the local delete
|
|
10
|
+
* errored, and the closing line reported THE FLAG IT PASSED rather than the
|
|
11
|
+
* remote it never read. A closing line already verifies the squash by content;
|
|
12
|
+
* the ref gets the same rule. The grammar admits exactly two forms for a
|
|
13
|
+
* deletion: a post-delete observation — `remote ref read: 0 refs at <ts>` —
|
|
14
|
+
* or the weaker `delete requested`, which claims no state. A closing that
|
|
15
|
+
* asserts deletion in any other wording is refused at the send, by the same
|
|
16
|
+
* check that requires a DONE to cite its PR, naming both forms.
|
|
17
|
+
*
|
|
18
|
+
* Dated adoption floor: qa's 18:36:30.939Z message — "From here every closing
|
|
19
|
+
* line reads the remote before claiming a delete". Closings at or before it
|
|
20
|
+
* are LISTED, never raised.
|
|
21
|
+
*/
|
|
22
|
+
export const CLOSING_GRAMMAR_ADOPTED_MS = 1789410990939; // 2026-09-14T18:36:30.939Z
|
|
23
|
+
|
|
24
|
+
/** A merge-closing line: a `done` whose text says MERGED. */
|
|
25
|
+
export const isMergeClosing = (text: string): boolean => /\bMERGED\b/.test(text);
|
|
26
|
+
/**
|
|
27
|
+
* A deletion CLAIM is a statement, read by POSITION: the wording at the start
|
|
28
|
+
* of a sentence. The same words quoted mid-sentence — qa's own correction says
|
|
29
|
+
* `My "remote branch deleted" lines … were wrong` — are a mention, not a claim.
|
|
30
|
+
*/
|
|
31
|
+
export const DELETE_CLAIM = /(?:^|[.;!]\s+|\n\s*)(?:(?:Remote|Local and remote|Remote and local) (?:branch|ref) deleted|Deleted the remote (?:branch|ref))\b/;
|
|
32
|
+
/** The observation form: what `git ls-remote --heads origin <branch>` returned, and when. */
|
|
33
|
+
export const REMOTE_READ = /remote ref read:\s*(\d+)\s*refs?\s+at\s+(\S+?)(?=[.;,)]?(?:\s|$))/i;
|
|
34
|
+
/** The weaker form: a command was issued; the state is left unclaimed. */
|
|
35
|
+
export const DELETE_REQUESTED = /\bdelete requested\b/i;
|
|
36
|
+
export const ACCEPTED_FORMS = "`remote ref read: 0 refs at <ISO ts>` (an `ls-remote` observation taken AFTER the delete) or `delete requested` (a command issued; state unclaimed)";
|
|
37
|
+
|
|
38
|
+
export type ClosingLine = {
|
|
39
|
+
merged: boolean;
|
|
40
|
+
claimsDelete: boolean;
|
|
41
|
+
form: "read" | "requested" | null;
|
|
42
|
+
read?: { refs: number; at: string };
|
|
43
|
+
};
|
|
44
|
+
export function closingLineOf(text: string): ClosingLine {
|
|
45
|
+
const merged = isMergeClosing(text);
|
|
46
|
+
const claimsDelete = DELETE_CLAIM.test(text);
|
|
47
|
+
const r = REMOTE_READ.exec(text);
|
|
48
|
+
const form: ClosingLine["form"] = r ? "read" : DELETE_REQUESTED.test(text) ? "requested" : null;
|
|
49
|
+
return { merged, claimsDelete, form, ...(r ? { read: { refs: Number(r[1]), at: r[2]! } } : {}) };
|
|
50
|
+
}
|
|
51
|
+
/** The refusal: a merge closing that asserts deletion without either accepted form. */
|
|
52
|
+
export function checkClosingLine(text: string): { ok: true; closing: ClosingLine } | { ok: false; error: string; closing: ClosingLine } {
|
|
53
|
+
const closing = closingLineOf(text);
|
|
54
|
+
if (closing.merged && closing.claimsDelete && closing.form === null) {
|
|
55
|
+
return {
|
|
56
|
+
ok: false,
|
|
57
|
+
closing,
|
|
58
|
+
error:
|
|
59
|
+
`a merge-closing line asserts a branch deletion it has not shown it read — "Remote branch deleted" reports a flag passed, not a remote observed (2 of 2 measured were premature, 5 of 7 were false). ` +
|
|
60
|
+
`State the deletion in one of the two accepted forms: ${ACCEPTED_FORMS}.`,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
return { ok: true, closing };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export type Closing = { pr: number | null; from: string; ts: number; claimsDelete: boolean; form: ClosingLine["form"]; beforeAdoption: boolean };
|
|
67
|
+
/** Every merge closing in a log, judged; `beforeAdoption` for those at or before the floor. */
|
|
68
|
+
export function closingsIn(logText: string, floorMs: number = CLOSING_GRAMMAR_ADOPTED_MS): Closing[] {
|
|
69
|
+
const out: Closing[] = [];
|
|
70
|
+
for (const l of logText.split("\n")) {
|
|
71
|
+
if (!l.trim()) continue;
|
|
72
|
+
let o: { ts?: number; from?: string; text?: string; record?: { type?: string; cites?: { ref?: string }[] } };
|
|
73
|
+
try { o = JSON.parse(l); } catch { continue; }
|
|
74
|
+
if (o.record?.type !== "done") continue;
|
|
75
|
+
const text = String(o.text ?? "");
|
|
76
|
+
const c = closingLineOf(text);
|
|
77
|
+
if (!c.merged) continue;
|
|
78
|
+
const cited = (o.record.cites ?? []).map((x) => (String(x?.ref ?? "").match(/#(\d+)/) ?? [])[1]).find(Boolean);
|
|
79
|
+
const inText = (text.match(/MERGED[^\n]*?#(\d+)/) ?? [])[1];
|
|
80
|
+
const pr = cited ?? inText;
|
|
81
|
+
const ts = Number(o.ts ?? 0);
|
|
82
|
+
out.push({ pr: pr ? Number(pr) : null, from: String(o.from ?? ""), ts, claimsDelete: c.claimsDelete, form: c.form, beforeAdoption: ts <= floorMs });
|
|
83
|
+
}
|
|
84
|
+
return out.sort((a, b) => a.ts - b.ts);
|
|
85
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ⟨q-cc0819dc⟩ — A `done` MAY CITE A COMMIT WHEN THE WORK HAS NO PR BY RULE.
|
|
3
|
+
*
|
|
4
|
+
* Docs-direct work (queue curation, canon, board moves) is pushed straight to the shared
|
|
5
|
+
* branch by policy; the `done` gate demanded a `{kind:'pr'}` cite, so the compliant path did
|
|
6
|
+
* not exist and the aide downgraded to `fyi` (2026-09-12 15:50). The fix accepts a commit
|
|
7
|
+
* cite — and only a commit that is REAL: a fabricated sha must not become a citable DONE.
|
|
8
|
+
*
|
|
9
|
+
* What "real" means here, stated so the ancestry call below is not mistaken for a merge test:
|
|
10
|
+
* is this exact commit object reachable from origin/main in `repo`? A docs-direct push puts
|
|
11
|
+
* THE COMMIT ITSELF on the shared branch, so reachability is the right question for it — this
|
|
12
|
+
* is not "was this branch's work squashed in", which `--is-ancestor` cannot answer
|
|
13
|
+
* (docs/LANDEDNESS.md); a squash-merged PR is cited by its PR, never by its branch sha.
|
|
14
|
+
*
|
|
15
|
+
* Full 40-hex only, REFUSED rather than normalised: a prefix is a claim about a sha the
|
|
16
|
+
* joiners (verdict/landing/closure readers) compare in full; normalising here would write a
|
|
17
|
+
* sha the sender never saw. No network: one local `git` in `repo`, which the caller passes
|
|
18
|
+
* because the send path has no repository of its own.
|
|
19
|
+
*/
|
|
20
|
+
import { execFileSync } from "node:child_process";
|
|
21
|
+
|
|
22
|
+
export const FULL_SHA = /^[0-9a-f]{40}$/;
|
|
23
|
+
export const SHARED_BRANCH_CANDIDATES = ["origin/main", "origin/master"];
|
|
24
|
+
|
|
25
|
+
export type CommitCiteVerdict =
|
|
26
|
+
| { ok: true; sha: string; branch: string }
|
|
27
|
+
| { ok: false; why: string };
|
|
28
|
+
|
|
29
|
+
function git(repo: string, args: string[]): { status: number; out: string } {
|
|
30
|
+
try {
|
|
31
|
+
const out = execFileSync("git", ["-C", repo, ...args], { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] });
|
|
32
|
+
return { status: 0, out: out.trim() };
|
|
33
|
+
} catch (e) {
|
|
34
|
+
return { status: Number((e as { status?: number }).status ?? 1), out: "" };
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** Verify one commit cite against the shared branch of `repo`. */
|
|
39
|
+
export function verifyCommitCite(ref: string, repo: string | undefined): CommitCiteVerdict {
|
|
40
|
+
const sha = String(ref ?? "").trim();
|
|
41
|
+
if (!FULL_SHA.test(sha)) {
|
|
42
|
+
return { ok: false, why: `commit cite '${sha}' is not a full 40-hex sha — refused, not normalised: a prefix is a claim the joiners compare in full` };
|
|
43
|
+
}
|
|
44
|
+
if (!repo) {
|
|
45
|
+
return { ok: false, why: `commit cite ${sha.slice(0, 7)} cannot be verified without \`repo\` — pass the repository whose origin/main carries it (no network is used)` };
|
|
46
|
+
}
|
|
47
|
+
if (git(repo, ["rev-parse", "--verify", "--quiet", `${sha}^{commit}`]).status !== 0) {
|
|
48
|
+
return { ok: false, why: `commit ${sha.slice(0, 7)} does not exist in ${repo} — a sha the repository has never seen cannot be a citable DONE` };
|
|
49
|
+
}
|
|
50
|
+
for (const branch of SHARED_BRANCH_CANDIDATES) {
|
|
51
|
+
if (git(repo, ["rev-parse", "--verify", "--quiet", branch]).status !== 0) continue;
|
|
52
|
+
// Is the cited commit reachable from the shared branch? (the reachability question,
|
|
53
|
+
// asked of the commit object itself — see the header for why that is the right one here)
|
|
54
|
+
if (git(repo, ["merge-base", "--is-ancestor", sha, branch]).status === 0) return { ok: true, sha, branch };
|
|
55
|
+
return { ok: false, why: `commit ${sha.slice(0, 7)} exists but is not reachable from ${branch} — work that is done is on the shared branch; a commit that is not is not done` };
|
|
56
|
+
}
|
|
57
|
+
return { ok: false, why: `${repo} has no origin/main or origin/master to verify commit ${sha.slice(0, 7)} against — fetch the shared branch first` };
|
|
58
|
+
}
|