neurastream 0.2.64 → 0.2.65
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/package.json +1 -1
- package/src/adapters/omp/index.ts +84 -16
- package/src/adapters/omp/launch.ts +105 -52
- package/src/cli/claim.ts +79 -0
- package/src/cli/commands.ts +4 -0
- package/src/cli/dispatch.ts +4 -0
- package/src/core/brief-lint.ts +13 -6
- package/src/core/claims.ts +140 -0
- package/src/core/config.ts +3 -0
- package/src/core/guards.ts +128 -9
- package/src/core/notify.ts +2 -1
- package/src/core/owner-ui.ts +59 -20
- package/src/core/queue/lib.ts +23 -4
- package/src/core/queue-check.ts +5 -2
- package/src/core/queue-close.ts +6 -0
- package/src/core/rollover.ts +3 -3
- package/src/core/trace-actions.ts +9 -0
- package/templates/config.yml +2 -0
package/src/core/queue/lib.ts
CHANGED
|
@@ -6,6 +6,8 @@ import { accessSync, appendFileSync, chmodSync, constants, existsSync, mkdirSync
|
|
|
6
6
|
import os from "node:os";
|
|
7
7
|
import path from "node:path";
|
|
8
8
|
import type { Config } from "../config.ts";
|
|
9
|
+
import type { ClaimStore } from "../claims.ts";
|
|
10
|
+
import { strftime } from "../clock.ts";
|
|
9
11
|
|
|
10
12
|
// --- landing detection (plan 20261031_0911 P4/P5): lives here, not queue-close.ts, because
|
|
11
13
|
// queueProblems' landed lock needs it and lib must not import the closer that imports lib ---
|
|
@@ -927,7 +929,7 @@ const STOP = new Set(
|
|
|
927
929
|
);
|
|
928
930
|
function keyWords(text: string): string[] {
|
|
929
931
|
const words = text.toLowerCase().match(/[a-z0-9][a-z0-9_.-]{3,}/g) ?? [];
|
|
930
|
-
return [...new Set(words.map(w => w.replace(/[._-]+$/, "")).filter(w => w.length >= 4 && !STOP.has(w)))].
|
|
932
|
+
return [...new Set(words.map(w => w.replace(/[._-]+$/, "")).filter(w => w.length >= 4 && !STOP.has(w)))].toSorted();
|
|
931
933
|
}
|
|
932
934
|
export function planWords(text: string): string[] {
|
|
933
935
|
const title = text.match(/^# (.+)$/m)?.[1] ?? "";
|
|
@@ -1142,6 +1144,12 @@ export function queueProblems(index = INDEX, blockersDir = BLOCKERS_DIR, reviewA
|
|
|
1142
1144
|
return probs;
|
|
1143
1145
|
}
|
|
1144
1146
|
|
|
1147
|
+
/** Queue ranks of the open queue plans an open plan waits on (I-20261025-208); empty when it is free to start. */
|
|
1148
|
+
export function openWaits(p: Plan, plans: Plan[], rank: Map<string, number>): number[] {
|
|
1149
|
+
if (p.status !== "open") return [];
|
|
1150
|
+
return p.waitsOn.map(f => rank.get(f)).filter((at): at is number => at !== undefined && plans[at - 1]!.status === "open");
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1145
1153
|
// P4 (plan 20261027_0915): from this day on, a Progress entry claiming a phase done/complete/
|
|
1146
1154
|
// "nothing left"/"finished" must quote that phase's verify command (or the Done check) and its
|
|
1147
1155
|
// result, or queue-check fails the plan; entries without a date or dated before it are grandfathered.
|
|
@@ -1203,17 +1211,24 @@ export function holdWarnings(plans: Plan[]): string[] {
|
|
|
1203
1211
|
// and passes `cap = Infinity`.
|
|
1204
1212
|
export const SUMMARY_CAP = 10;
|
|
1205
1213
|
|
|
1206
|
-
export function queueSummary(index = INDEX, reviewAgents: string[] = [],
|
|
1214
|
+
export function queueSummary(index = INDEX, reviewAgents: string[] = [], staleOrClaims: ReadonlySet<string> | ClaimStore | null = null, cap: number = SUMMARY_CAP): string {
|
|
1207
1215
|
// Index order IS priority (20261025_0215_index_priority): the list is flat and ranked,
|
|
1208
1216
|
// rank 1 = the index's top line; repos only surface through each plan's own path.
|
|
1209
1217
|
const plans = activePlans(index);
|
|
1210
1218
|
const rank = new Map(plans.map((p, i) => [p.file, i + 1] as const));
|
|
1211
1219
|
const repos = [...new Set(plans.map(p => p.repo))];
|
|
1212
1220
|
const lines = [`Queue (${index}): ${plans.length ? `${plans.length} plan(s) in ${repos.length} repo(s)` : "empty, no open work"}`];
|
|
1221
|
+
let claimStore: ClaimStore | null = null;
|
|
1222
|
+
let stale: ReadonlySet<string> = new Set<string>();
|
|
1223
|
+
if (staleOrClaims != null && typeof (staleOrClaims as ClaimStore).holder === 'function') {
|
|
1224
|
+
claimStore = staleOrClaims as ClaimStore;
|
|
1225
|
+
} else {
|
|
1226
|
+
stale = staleOrClaims as ReadonlySet<string> ?? new Set<string>();
|
|
1227
|
+
}
|
|
1213
1228
|
plans.slice(0, cap).forEach((p, i) => {
|
|
1214
1229
|
const status = awaitingMerge(p) ? "complete, awaiting merge" : (p.status ?? "INVALID");
|
|
1215
1230
|
const ask = (p.waitingLine ?? "").slice(0, 80);
|
|
1216
|
-
const hold = p.waiting ? (stale
|
|
1231
|
+
const hold = p.waiting ? (stale?.has(p.file) ? `[STALE?] ${ask}` : `WAITING on owner: ${ask}`) : "";
|
|
1217
1232
|
// I-20261025-208: an open plan waiting on an open plan of the queue shows the target's rank.
|
|
1218
1233
|
const waits: string[] = [];
|
|
1219
1234
|
if (p.status === "open")
|
|
@@ -1223,7 +1238,11 @@ export function queueSummary(index = INDEX, reviewAgents: string[] = [], stale:
|
|
|
1223
1238
|
waits.push(`waits on #${at}`);
|
|
1224
1239
|
}
|
|
1225
1240
|
const done = p.phases.total ? `${p.phases.done}/${p.phases.total} done` : "";
|
|
1226
|
-
|
|
1241
|
+
// P4 multi-main (20261027_1300): with the claim store handed in (guards' inject and
|
|
1242
|
+
// queue-check pass it), every plan shows `held by <id> since HH:MM` or `free`.
|
|
1243
|
+
const holder = claimStore?.holder(p.file) ?? null;
|
|
1244
|
+
const claimFlag = claimStore ? (holder ? `held by ${holder.main} since ${strftime(holder.since, "%H:%M")}` : "free") : "";
|
|
1245
|
+
const flags = [status, done, hold, ...waits, claimFlag, p.priorityId ?? ""].filter(Boolean).join(", ");
|
|
1227
1246
|
const goal = items(sections(p.text).get("goal") ?? "")[0]?.slice(0, 100) ?? "";
|
|
1228
1247
|
lines.push(` ${i + 1}. ${p.file} [${flags}] ${goal}`);
|
|
1229
1248
|
});
|
package/src/core/queue-check.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { Config } from "./config.ts";
|
|
2
|
+
import { fileClaimStore } from "./claims.ts";
|
|
3
|
+
import { nowSec } from "./clock.ts";
|
|
2
4
|
import { applyQueueEnv } from "./queue/env.ts";
|
|
3
5
|
import { activePlans, allowedAgents, holdWarnings, queueProblems, queueSummary, reviewAgentsProblem } from "./queue/lib.ts";
|
|
4
6
|
import { mrSweep } from "./mr-sweep.ts";
|
|
5
|
-
import { recheckHolds,
|
|
7
|
+
import { recheckHolds, staleHoldLines } from "./waiting-check.ts";
|
|
6
8
|
|
|
7
9
|
// One index (20261024_1400_one_index): the main index lists plan files directly, so there are no
|
|
8
10
|
// repo INDEX.md files to git-check and no work_roots scan; the queue problems carry the
|
|
@@ -13,9 +15,10 @@ export function queueCheck(args: string[], cfg: Config): number {
|
|
|
13
15
|
for (const p of activePlans()) if (p.priorityId && !p.waiting && p.status === "open") console.log(p.priorityId);
|
|
14
16
|
return 0;
|
|
15
17
|
}
|
|
18
|
+
const claims = fileClaimStore(cfg.paths.queue_state, nowSec, cfg.queue.claim_ttl_min);
|
|
16
19
|
const plans = activePlans();
|
|
17
20
|
const holds = recheckHolds(cfg, plans);
|
|
18
|
-
console.log(queueSummary(undefined, cfg.review.agents,
|
|
21
|
+
console.log(queueSummary(undefined, cfg.review.agents, claims, Infinity));
|
|
19
22
|
for (const line of staleHoldLines(holds, plans)) console.log(line);
|
|
20
23
|
// main-start prints the sweep itself and passes this so the child bin does not print it twice.
|
|
21
24
|
let fail = queueProblems(undefined, undefined, cfg.review.agents).length > 0;
|
package/src/core/queue-close.ts
CHANGED
|
@@ -2,7 +2,10 @@ import { spawnSync } from "node:child_process";
|
|
|
2
2
|
import { appendFileSync, existsSync, fstatSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
3
3
|
import os from "node:os";
|
|
4
4
|
import path from "node:path";
|
|
5
|
+
import { fileClaimStore } from "./claims.ts";
|
|
6
|
+
import { nowSec } from "./clock.ts";
|
|
5
7
|
import type { Config } from "./config.ts";
|
|
8
|
+
import { mainId } from "./guards.ts";
|
|
6
9
|
import { applyQueueEnv } from "./queue/env.ts";
|
|
7
10
|
import { activePlans, cancelledFile, cancelledLine, closeLog, finishedEntry, finishedPath, gitOut as git, INDEX, landed, prependFinished, sha, STATE_DIR, writeIndex } from "./queue/lib.ts";
|
|
8
11
|
import { fixedIncident } from "./incidents.ts";
|
|
@@ -316,6 +319,9 @@ export function queueClose(args: string[], cfg: Config): number {
|
|
|
316
319
|
}
|
|
317
320
|
if (recorded.length) console.log(`queue-close: recorded fixed for ${recorded.join(", ")}`);
|
|
318
321
|
}
|
|
322
|
+
// Multi-main P3: closing the plan frees this Main's claim; another Main's claim stays
|
|
323
|
+
// (release is keyed by the holder).
|
|
324
|
+
fileClaimStore(cfg.paths.queue_state, nowSec, cfg.queue.claim_ttl_min).release(file, mainId());
|
|
319
325
|
console.log("queue-close: CLOSED");
|
|
320
326
|
return 0;
|
|
321
327
|
}
|
package/src/core/rollover.ts
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
// the jobs and the note mtime, and performs the switch. No harness names here.
|
|
6
6
|
|
|
7
7
|
import { join } from "node:path";
|
|
8
|
+
import { mainStateDir } from "./guards.ts";
|
|
8
9
|
import { strftime } from "./clock.ts";
|
|
9
|
-
import { stateDirPath } from "./queue/lib.ts";
|
|
10
10
|
import type { OwnerAnswer, OwnerMessage } from "./incidents.ts";
|
|
11
11
|
|
|
12
12
|
export type RolloverState = "below" | "need-note" | "wait-jobs" | "ready";
|
|
@@ -167,11 +167,11 @@ export function noteRequest(path: string, reason = ""): string {
|
|
|
167
167
|
}
|
|
168
168
|
|
|
169
169
|
/** Where Main writes the handoff note for one session. */
|
|
170
|
-
export function notePath(sessionId: string, stateDir =
|
|
170
|
+
export function notePath(sessionId: string, stateDir = mainStateDir()): string {
|
|
171
171
|
return join(stateDir, "rollover", `${sessionId}.md`);
|
|
172
172
|
}
|
|
173
173
|
|
|
174
174
|
/** The launcher's relaunch request file: written by the harness just before it exits under `neurastream main`. */
|
|
175
|
-
export function relaunchPath(stateDir =
|
|
175
|
+
export function relaunchPath(stateDir = mainStateDir()): string {
|
|
176
176
|
return join(stateDir, "rollover", "relaunch.json");
|
|
177
177
|
}
|
|
@@ -381,6 +381,12 @@ export interface OwnRun {
|
|
|
381
381
|
* it, so it replaces the final-text check below.
|
|
382
382
|
*/
|
|
383
383
|
claimedNone?: boolean;
|
|
384
|
+
/**
|
|
385
|
+
* Read paths named in the run's brief text (cfg.brief.path_prefixes), extracted the
|
|
386
|
+
* brief-lint way. A read whose target globMatches one is skipped as a D7 finding: the
|
|
387
|
+
* owner deliberately pointed the sub at that path in the brief.
|
|
388
|
+
*/
|
|
389
|
+
allowed?: string[];
|
|
384
390
|
}
|
|
385
391
|
|
|
386
392
|
export interface UnreportedFinding {
|
|
@@ -469,6 +475,9 @@ export function unreportedFindings(events: TraceEvent[], rules: ActionsRules, ow
|
|
|
469
475
|
const t = expandHome(raw, rules.home);
|
|
470
476
|
const repo = ownedRepoOf(t, rules.owned_repos);
|
|
471
477
|
if (repo === null || segKey(repo) === ownKey) continue;
|
|
478
|
+
// P10c: a read whose path matches a path the run's brief text names is not an
|
|
479
|
+
// unreported finding — the owner deliberately pointed the sub at it.
|
|
480
|
+
if (own.allowed?.some((p) => globMatch(p, t, rules.home))) continue;
|
|
472
481
|
const id = `${repo}:${t}`;
|
|
473
482
|
if (seen.has(id)) continue;
|
|
474
483
|
seen.add(id);
|
package/templates/config.yml
CHANGED
|
@@ -111,6 +111,8 @@ queue:
|
|
|
111
111
|
auto_close_min: 15
|
|
112
112
|
repo_index: "INDEX.md"
|
|
113
113
|
cancelled_rel: "docs/plans/CANCELLED.md"
|
|
114
|
+
# Minutes without a heartbeat before a Main's plan claim frees (src/core/claims.ts).
|
|
115
|
+
claim_ttl_min: 30
|
|
114
116
|
waiting_check_ttl_sec: 600 # a hold's `still true if` result is reused this long (key: plan mtime, command, HEAD)
|
|
115
117
|
waiting_check_timeout_sec: 60 # one check may run this long; a timeout is "unknown" (card stays, no incident)
|
|
116
118
|
|