neurastream 0.2.80 → 0.2.82
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 +13 -0
- package/package.json +1 -1
- package/src/adapters/index.ts +6 -0
- package/src/adapters/omp/adapter.ts +4 -1
- package/src/adapters/omp/doctor.ts +15 -0
- package/src/adapters/omp/index.ts +2 -1
- package/src/adapters/omp/launch.ts +3 -1
- package/src/adapters/omp/providers.ts +217 -0
- package/src/adapters/omp/traces.ts +12 -1
- package/src/cli/commands.ts +3 -1
- package/src/cli/diff-check.ts +30 -0
- package/src/cli/dispatch.ts +17 -0
- package/src/cli/labels.ts +110 -0
- package/src/core/agent-score.ts +26 -10
- package/src/core/config.ts +17 -0
- package/src/core/diff-check.ts +96 -0
- package/src/core/episodes.ts +54 -0
- package/src/core/guards.ts +23 -1
- package/src/core/label-import.ts +97 -0
- package/src/core/label-update.ts +114 -0
- package/src/core/labels.ts +253 -0
- package/src/core/main-start.ts +61 -2
- package/src/core/provider-state.ts +196 -2
- package/src/core/report.ts +85 -0
- package/src/core/watch.ts +30 -9
- package/src/core/wip-roots.ts +6 -1
- package/templates/AGENTS.md +1 -0
- package/templates/config.yml +11 -0
package/src/core/watch.ts
CHANGED
|
@@ -311,6 +311,10 @@ export interface ReleaseVerdict {
|
|
|
311
311
|
/** An after-window runs from the tag to the next tag or 24 h, whichever is first (the heartbeat
|
|
312
312
|
* is one overwritten file, so longer outages are not provable). */
|
|
313
313
|
const VERDICT_CAP_SEC = 86400;
|
|
314
|
+
/** At most the newest two judgable tags per pass — a first run after an outage or install must not dump a week of back catalogue (2026-11-03). */
|
|
315
|
+
const VERDICT_MAX_PER_RUN = 2;
|
|
316
|
+
/** Raw events per side a metric needs before its change is read at all — one question or one phase tick is noise (2026-11-03). */
|
|
317
|
+
const VERDICT_MIN_SIGNAL = 3;
|
|
314
318
|
|
|
315
319
|
/** The value per 100 Main tool calls in the window, so a busy night is not read as a worse version. */
|
|
316
320
|
const rate = (v: number | null, calls: number): number | null => (v === null ? null : (v * 100) / calls);
|
|
@@ -355,7 +359,7 @@ const fmtNum = (v: number): string => String(Number(v.toFixed(1)));
|
|
|
355
359
|
/** One judged number: the same value in both windows. Rates are per 100 Main tool calls. */
|
|
356
360
|
interface VerdictNum {
|
|
357
361
|
name: string;
|
|
358
|
-
/** 1 = owner pain (
|
|
362
|
+
/** 1 = owner pain (a floor-passing rise is one vote; WORSE needs two), 2-4 = worse when higher, 5 = output (worse when lower). */
|
|
359
363
|
group: 1 | 2 | 3 | 4 | 5;
|
|
360
364
|
before: number | null;
|
|
361
365
|
after: number | null;
|
|
@@ -371,15 +375,23 @@ interface VerdictNum {
|
|
|
371
375
|
export function releaseVerdicts(cfg: Config, deps: ReleaseVerdictDeps): ReleaseVerdict[] {
|
|
372
376
|
const done = new Set(readMetricEvents(cfg).filter(e => e.type === "release-verdict").map(e => String(e.tag)));
|
|
373
377
|
const tags = deps.tags.toSorted((a, b) => a.ts - b.ts);
|
|
374
|
-
const
|
|
378
|
+
const eligible: { name: string; before: Window; after: Window }[] = [];
|
|
375
379
|
for (let i = 0; i < tags.length; i++) {
|
|
376
380
|
const tag = tags[i]!;
|
|
377
381
|
if (done.has(tag.name)) continue;
|
|
378
382
|
const end = Math.min(tag.ts + VERDICT_CAP_SEC, tags[i + 1]?.ts ?? tag.ts + VERDICT_CAP_SEC);
|
|
379
383
|
if (deps.now < end) continue;
|
|
380
|
-
|
|
384
|
+
// Never judge a tag older than the cap; the last tag in a >24 h gap is then never judged.
|
|
385
|
+
if (deps.now > tag.ts + VERDICT_CAP_SEC) continue;
|
|
386
|
+
// Before window [tag.ts-(end-tag.ts), tag.ts) must hold no other release (inWindow is half-open).
|
|
387
|
+
if (i > 0 && tags[i - 1]!.ts >= tag.ts - (end - tag.ts)) continue;
|
|
388
|
+
eligible.push({ name: tag.name, before: { from: tag.ts - (end - tag.ts), to: tag.ts }, after: { from: tag.ts, to: end } });
|
|
389
|
+
}
|
|
390
|
+
const out: ReleaseVerdict[] = [];
|
|
391
|
+
for (const item of eligible.slice(-VERDICT_MAX_PER_RUN)) {
|
|
392
|
+
const verdict = judgeRelease(cfg, item.name, item.before, item.after, deps);
|
|
381
393
|
if (verdict === null) continue; // not enough data yet: no verdict, nothing recorded, nothing posted
|
|
382
|
-
appendMetric(cfg, { type: "release-verdict", tag:
|
|
394
|
+
appendMetric(cfg, { type: "release-verdict", tag: item.name, verdict: verdict.verdict, ts: deps.now });
|
|
383
395
|
if (verdict.post !== null) deps.notify(verdict.post);
|
|
384
396
|
out.push(verdict);
|
|
385
397
|
}
|
|
@@ -411,7 +423,7 @@ function judgeRelease(cfg: Config, tag: string, before: Window, after: Window, d
|
|
|
411
423
|
const kindIn = (kind: string, w: Window) => incidents.filter(i => i.kind === kind && inWindow(i.ts, w)).length;
|
|
412
424
|
const merges = (w: Window) => inCount("ci", w);
|
|
413
425
|
const nums: VerdictNum[] = [
|
|
414
|
-
// 1 owner pain (
|
|
426
|
+
// 1 owner pain (a floor-passing rise is one vote; WORSE needs two, or a downgrade)
|
|
415
427
|
{ name: "corrections", group: 1, before: rate(row("m4_corrections").prev, bc), after: rate(row("m4_corrections").cur, ac), beforeCount: row("m4_corrections").prev ?? 0, afterCount: row("m4_corrections").cur ?? 0, dailyKey: "m4_corrections" },
|
|
416
428
|
{ name: "questions", group: 1, before: rate(row("m4_questions").prev, bc), after: rate(row("m4_questions").cur, ac), beforeCount: row("m4_questions").prev ?? 0, afterCount: row("m4_questions").cur ?? 0, dailyKey: "m4_questions" },
|
|
417
429
|
{ name: "m8 waits", group: 1, before: rate(inCount("m8", before), bc), after: rate(inCount("m8", after), ac), beforeCount: inCount("m8", before), afterCount: inCount("m8", after) },
|
|
@@ -452,12 +464,20 @@ function judgeRelease(cfg: Config, tag: string, before: Window, after: Window, d
|
|
|
452
464
|
.filter(e => e.type === "version-change" && inWindow(Number(e.ts), after))
|
|
453
465
|
.map(e => ({ from: String(e.from ?? ""), to: String(e.to ?? "") }))
|
|
454
466
|
.find(v => verCompare(v.to, v.from) < 0) ?? null;
|
|
455
|
-
const
|
|
467
|
+
const comparable = nums.map(n => ({ n, pct: pctOf(n) })).filter((jd): jd is { n: VerdictNum; pct: number } => jd.pct !== null);
|
|
468
|
+
const judged: { n: VerdictNum; pct: number }[] = [];
|
|
469
|
+
const thin: string[] = [];
|
|
470
|
+
for (const jd of comparable) {
|
|
471
|
+
const n = jd.n;
|
|
472
|
+
const passes = (n.beforeCount >= VERDICT_MIN_SIGNAL && n.afterCount >= VERDICT_MIN_SIGNAL) || (n.group === 1 && n.beforeCount === 0 && n.afterCount >= VERDICT_MIN_SIGNAL);
|
|
473
|
+
if (passes) judged.push(jd);
|
|
474
|
+
else thin.push(n.name);
|
|
475
|
+
}
|
|
456
476
|
const worseOnes = judged.filter(jd => isWorse(jd.n, jd.pct));
|
|
457
477
|
const improved24 = judged.some(jd => jd.n.group >= 2 && jd.n.group <= 4 && isBetter(jd.n, jd.pct));
|
|
458
478
|
let verdict: "BETTER" | "WORSE" | "MIXED";
|
|
459
|
-
if (downgrade !== null || worseOnes.length
|
|
460
|
-
else if (judged.filter(jd => jd.n.group >= 2).every(jd => !isWorse(jd.n, jd.pct)) && improved24) verdict = "BETTER";
|
|
479
|
+
if (downgrade !== null || worseOnes.length >= 2) verdict = "WORSE";
|
|
480
|
+
else if (worseOnes.length === 0 && judged.filter(jd => jd.n.group >= 2).every(jd => !isWorse(jd.n, jd.pct)) && improved24) verdict = "BETTER";
|
|
461
481
|
else verdict = "MIXED";
|
|
462
482
|
|
|
463
483
|
const parts: string[] = [];
|
|
@@ -469,7 +489,8 @@ function judgeRelease(cfg: Config, tag: string, before: Window, after: Window, d
|
|
|
469
489
|
}
|
|
470
490
|
const fresh = nums.filter(n => n.beforeCount === 0 && pctOf(n) === null).map(n => n.name);
|
|
471
491
|
const freshLine = fresh.length === 0 ? "" : `${(fresh.length > 4 ? [...fresh.slice(0, 4), `+${fresh.length - 4} more`] : fresh).join(", ")} new, not compared`;
|
|
472
|
-
const
|
|
492
|
+
const thinLine = thin.length === 0 ? "" : `${thin.join(", ")} thin, not compared`;
|
|
493
|
+
const post = `${tag}: ${verdict} — ${[...parts, freshLine, thinLine].filter(p => p !== "").join(", ")}`;
|
|
473
494
|
|
|
474
495
|
if (verdict === "WORSE") {
|
|
475
496
|
const top = worseOnes.toSorted((p, q) => Math.abs(q.pct) - Math.abs(p.pct))[0];
|
package/src/core/wip-roots.ts
CHANGED
|
@@ -16,10 +16,15 @@ export function deadGitfile(dir: string): boolean {
|
|
|
16
16
|
return !existsSync(resolve(dir, first.slice("gitdir: ".length).trim()));
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
/** The worktree's ref key: one valid git ref component, also for paths outside home (`../`) or dot dirs. */
|
|
19
20
|
export function keyOf(path: string, home: string): string {
|
|
20
21
|
const realHome = existsSync(home) ? realpathSync(home) : home;
|
|
21
22
|
const realPath = existsSync(path) ? realpathSync(path) : path;
|
|
22
|
-
return relative(realHome, realPath)
|
|
23
|
+
return relative(realHome, realPath)
|
|
24
|
+
.replace(/[^A-Za-z0-9._-]+/g, "_")
|
|
25
|
+
.replace(/\.{2,}/g, "_")
|
|
26
|
+
.replace(/^[._]+|_+$/g, "")
|
|
27
|
+
.replace(/\.lock$/, "_lock");
|
|
23
28
|
}
|
|
24
29
|
|
|
25
30
|
function walkFolder(dir: string, currentDepth: number, maxDepth: number, out: string[]): void {
|
package/templates/AGENTS.md
CHANGED
|
@@ -31,6 +31,7 @@ You are Main, the orchestrator. Main plans, delegates, reviews and lands; implem
|
|
|
31
31
|
|`brief-lint <plan.md>`|when writing or reworking a plan (the spawn guard lints the named plans itself)|
|
|
32
32
|
|`wip-check`|session start, before new work|
|
|
33
33
|
|`neurastream metrics ci <repo> <mr>`|after every merge|
|
|
34
|
+
|`neurastream labels update --repo <dir>`|after every merge, next to `metrics ci`|
|
|
34
35
|
|`neurastream metrics report`|weekly when main-start says due; propose ONE rule change to the owner|
|
|
35
36
|
|`neurastream incident list --open`|session start, before status reports, when a spawn or stop is blocked|
|
|
36
37
|
|`machine-guard`, `heavy-run`|machine-guard at session start and before launches; every test run goes through heavy-run|
|
package/templates/config.yml
CHANGED
|
@@ -298,6 +298,17 @@ snapshot:
|
|
|
298
298
|
- "snap-private-tmp"
|
|
299
299
|
- "*.sock"
|
|
300
300
|
|
|
301
|
+
|
|
302
|
+
labels:
|
|
303
|
+
episode_days: 30 # how far back episodes are built for labels
|
|
304
|
+
flip_weight: 1.0 # share of an episode's accept points a flip removes (1 = all)
|
|
305
|
+
repos: [] # repo dirs the main-start daily `labels update` runs over; empty = only the after-merge moment
|
|
306
|
+
# Removal check (src/core/diff-check.ts, plan 20261024_1915): `neurastream diff-check` and the
|
|
307
|
+
# plan-guard commit gate flag added comment lines matching removal_comment_patterns; a commit
|
|
308
|
+
# subject matching removal_subjects flags every added non-blank line. Pure deletions pass. A
|
|
309
|
+
# regex that does not compile is skipped (fail-open), never refused.
|
|
310
|
+
removal_comment_patterns: ['\bremoved\b', '\bno longer\b', '\bpreviously\b', '\bused to\b', '\bwas deleted\b'] # added comment lines a removal must not add
|
|
311
|
+
removal_subjects: ['^(remove|drop|delete)\b', '^chore: remove'] # commit subjects that flag every added non-blank line
|
|
301
312
|
traces:
|
|
302
313
|
provider:
|
|
303
314
|
# Provider-honesty rules (src/core/trace-provider.ts). The maps below are open: an empty
|