@graphrefly/graphrefly 0.13.0 → 0.15.0
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/dist/{chunk-HA6QMDKQ.js → chunk-2ZICUAUJ.js} +4 -4
- package/dist/{chunk-H4UFM6WD.js → chunk-4APC3AFN.js} +3 -3
- package/dist/{chunk-UQI4GAHD.js → chunk-CRACCCJY.js} +3 -3
- package/dist/{chunk-UPC5OEB5.js → chunk-GKRKDYNT.js} +3 -3
- package/dist/{chunk-6B2ZCCNN.js → chunk-H243FWYP.js} +12 -13
- package/dist/chunk-H243FWYP.js.map +1 -0
- package/dist/{chunk-KNGOJEYP.js → chunk-QVYZD65U.js} +2 -2
- package/dist/{chunk-PFMXKG4Y.js → chunk-XQ4UMAU7.js} +2 -2
- package/dist/{chunk-5RN7NBNG.js → chunk-YW6LFCFS.js} +3 -3
- package/dist/{chunk-QOGWU5K7.js → chunk-ZHTHUX5D.js} +3 -3
- package/dist/compat/nestjs/index.cjs +11 -12
- package/dist/compat/nestjs/index.cjs.map +1 -1
- package/dist/compat/nestjs/index.js +7 -7
- package/dist/core/index.cjs +11 -12
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.js +3 -3
- package/dist/extra/index.cjs +11 -12
- package/dist/extra/index.cjs.map +1 -1
- package/dist/extra/index.js +3 -3
- package/dist/graph/index.cjs +3 -0
- package/dist/graph/index.cjs.map +1 -1
- package/dist/graph/index.js +4 -4
- package/dist/index.cjs +425 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +368 -56
- package/dist/index.d.ts +368 -56
- package/dist/index.js +426 -13
- package/dist/index.js.map +1 -1
- package/dist/patterns/reactive-layout/index.cjs +3 -0
- package/dist/patterns/reactive-layout/index.cjs.map +1 -1
- package/dist/patterns/reactive-layout/index.js +4 -4
- package/package.json +5 -2
- package/dist/chunk-6B2ZCCNN.js.map +0 -1
- /package/dist/{chunk-HA6QMDKQ.js.map → chunk-2ZICUAUJ.js.map} +0 -0
- /package/dist/{chunk-H4UFM6WD.js.map → chunk-4APC3AFN.js.map} +0 -0
- /package/dist/{chunk-UQI4GAHD.js.map → chunk-CRACCCJY.js.map} +0 -0
- /package/dist/{chunk-UPC5OEB5.js.map → chunk-GKRKDYNT.js.map} +0 -0
- /package/dist/{chunk-KNGOJEYP.js.map → chunk-QVYZD65U.js.map} +0 -0
- /package/dist/{chunk-PFMXKG4Y.js.map → chunk-XQ4UMAU7.js.map} +0 -0
- /package/dist/{chunk-5RN7NBNG.js.map → chunk-YW6LFCFS.js.map} +0 -0
- /package/dist/{chunk-QOGWU5K7.js.map → chunk-ZHTHUX5D.js.map} +0 -0
package/dist/graph/index.js
CHANGED
|
@@ -4,14 +4,14 @@ import {
|
|
|
4
4
|
createDagCborZstdCodec,
|
|
5
5
|
negotiateCodec,
|
|
6
6
|
replayWAL
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-ZHTHUX5D.js";
|
|
8
8
|
import {
|
|
9
9
|
GRAPH_META_SEGMENT,
|
|
10
10
|
Graph,
|
|
11
11
|
reachable
|
|
12
|
-
} from "../chunk-
|
|
13
|
-
import "../chunk-
|
|
14
|
-
import "../chunk-
|
|
12
|
+
} from "../chunk-CRACCCJY.js";
|
|
13
|
+
import "../chunk-XQ4UMAU7.js";
|
|
14
|
+
import "../chunk-H243FWYP.js";
|
|
15
15
|
export {
|
|
16
16
|
GRAPH_META_SEGMENT,
|
|
17
17
|
Graph,
|
package/dist/index.cjs
CHANGED
|
@@ -185,6 +185,7 @@ __export(index_exports, {
|
|
|
185
185
|
globToRegExp: () => globToRegExp,
|
|
186
186
|
graph: () => graph_exports,
|
|
187
187
|
graphspec: () => graphspec_exports,
|
|
188
|
+
harness: () => harness_exports,
|
|
188
189
|
interval: () => interval,
|
|
189
190
|
isBatching: () => isBatching,
|
|
190
191
|
isKnownMessageType: () => isKnownMessageType,
|
|
@@ -427,8 +428,7 @@ function drainPending() {
|
|
|
427
428
|
if (ownsFlush) {
|
|
428
429
|
flushInProgress = true;
|
|
429
430
|
}
|
|
430
|
-
|
|
431
|
-
let hasError = false;
|
|
431
|
+
const errors = [];
|
|
432
432
|
try {
|
|
433
433
|
let iterations = 0;
|
|
434
434
|
while (pendingPhase2.length > 0 || pendingPhase3.length > 0) {
|
|
@@ -446,10 +446,7 @@ function drainPending() {
|
|
|
446
446
|
try {
|
|
447
447
|
run();
|
|
448
448
|
} catch (e) {
|
|
449
|
-
|
|
450
|
-
firstError = e;
|
|
451
|
-
hasError = true;
|
|
452
|
-
}
|
|
449
|
+
errors.push(e);
|
|
453
450
|
}
|
|
454
451
|
}
|
|
455
452
|
}
|
|
@@ -467,10 +464,7 @@ function drainPending() {
|
|
|
467
464
|
try {
|
|
468
465
|
run();
|
|
469
466
|
} catch (e) {
|
|
470
|
-
|
|
471
|
-
firstError = e;
|
|
472
|
-
hasError = true;
|
|
473
|
-
}
|
|
467
|
+
errors.push(e);
|
|
474
468
|
}
|
|
475
469
|
}
|
|
476
470
|
}
|
|
@@ -480,8 +474,11 @@ function drainPending() {
|
|
|
480
474
|
flushInProgress = false;
|
|
481
475
|
}
|
|
482
476
|
}
|
|
483
|
-
if (
|
|
484
|
-
throw
|
|
477
|
+
if (errors.length === 1) {
|
|
478
|
+
throw errors[0];
|
|
479
|
+
}
|
|
480
|
+
if (errors.length > 1) {
|
|
481
|
+
throw new AggregateError(errors, "batch drain: multiple callbacks threw");
|
|
485
482
|
}
|
|
486
483
|
}
|
|
487
484
|
function partitionForBatch(messages) {
|
|
@@ -1122,6 +1119,9 @@ var NodeImpl = class {
|
|
|
1122
1119
|
for (const m of messages) {
|
|
1123
1120
|
const t = m[0];
|
|
1124
1121
|
if (t === DATA) {
|
|
1122
|
+
if (m.length < 2) {
|
|
1123
|
+
continue;
|
|
1124
|
+
}
|
|
1125
1125
|
this._cached = m[1];
|
|
1126
1126
|
if (this._versioning != null) {
|
|
1127
1127
|
advanceVersion(this._versioning, m[1], this._hashFn);
|
|
@@ -12967,6 +12967,7 @@ __export(patterns_exports, {
|
|
|
12967
12967
|
demoShell: () => demo_shell_exports,
|
|
12968
12968
|
domainTemplates: () => domain_templates_exports,
|
|
12969
12969
|
graphspec: () => graphspec_exports,
|
|
12970
|
+
harness: () => harness_exports,
|
|
12970
12971
|
layout: () => reactive_layout_exports,
|
|
12971
12972
|
memory: () => memory_exports,
|
|
12972
12973
|
messaging: () => messaging_exports,
|
|
@@ -13522,7 +13523,9 @@ function promptNode(adapter, deps, prompt, opts) {
|
|
|
13522
13523
|
const messagesNode = derived(
|
|
13523
13524
|
deps,
|
|
13524
13525
|
(values) => {
|
|
13526
|
+
if (values.some((v) => v == null)) return [];
|
|
13525
13527
|
const text = typeof prompt === "string" ? prompt : prompt(...values);
|
|
13528
|
+
if (!text) return [];
|
|
13526
13529
|
const msgs = [];
|
|
13527
13530
|
if (opts?.systemPrompt) msgs.push({ role: "system", content: opts.systemPrompt });
|
|
13528
13531
|
msgs.push({ role: "user", content: text });
|
|
@@ -17383,6 +17386,59 @@ ${validation.errors.join("\n")}`);
|
|
|
17383
17386
|
return parsed;
|
|
17384
17387
|
}
|
|
17385
17388
|
|
|
17389
|
+
// src/patterns/harness/index.ts
|
|
17390
|
+
var harness_exports = {};
|
|
17391
|
+
__export(harness_exports, {
|
|
17392
|
+
DEFAULT_DECAY_RATE: () => DEFAULT_DECAY_RATE2,
|
|
17393
|
+
DEFAULT_QUEUE_CONFIGS: () => DEFAULT_QUEUE_CONFIGS,
|
|
17394
|
+
DEFAULT_SEVERITY_WEIGHTS: () => DEFAULT_SEVERITY_WEIGHTS,
|
|
17395
|
+
HarnessGraph: () => HarnessGraph,
|
|
17396
|
+
defaultErrorClassifier: () => defaultErrorClassifier,
|
|
17397
|
+
evalIntakeBridge: () => evalIntakeBridge,
|
|
17398
|
+
harnessLoop: () => harnessLoop,
|
|
17399
|
+
priorityScore: () => priorityScore,
|
|
17400
|
+
strategyKey: () => strategyKey,
|
|
17401
|
+
strategyModel: () => strategyModel
|
|
17402
|
+
});
|
|
17403
|
+
|
|
17404
|
+
// src/patterns/harness/bridge.ts
|
|
17405
|
+
function evalIntakeBridge(evalSource, intakeTopic, opts) {
|
|
17406
|
+
const defaultSeverity = opts?.defaultSeverity ?? "medium";
|
|
17407
|
+
return effect([evalSource], ([results]) => {
|
|
17408
|
+
if (results == null) return;
|
|
17409
|
+
const runs = Array.isArray(results) ? results : [results];
|
|
17410
|
+
for (const run of runs) {
|
|
17411
|
+
for (const task2 of run.tasks) {
|
|
17412
|
+
if (task2.valid && task2.judge_scores?.every((s) => s.pass)) continue;
|
|
17413
|
+
if (!task2.valid && (!task2.judge_scores || task2.judge_scores.length === 0)) {
|
|
17414
|
+
intakeTopic.publish({
|
|
17415
|
+
source: "eval",
|
|
17416
|
+
summary: `Task ${task2.task_id} invalid (model: ${run.model})`,
|
|
17417
|
+
evidence: `Run ${run.run_id}: task produced invalid output`,
|
|
17418
|
+
affectsAreas: ["graphspec"],
|
|
17419
|
+
affectsEvalTasks: [task2.task_id],
|
|
17420
|
+
severity: defaultSeverity
|
|
17421
|
+
});
|
|
17422
|
+
continue;
|
|
17423
|
+
}
|
|
17424
|
+
if (task2.judge_scores) {
|
|
17425
|
+
for (const score of task2.judge_scores) {
|
|
17426
|
+
if (score.pass) continue;
|
|
17427
|
+
intakeTopic.publish({
|
|
17428
|
+
source: "eval",
|
|
17429
|
+
summary: `${task2.task_id}: ${score.claim} (model: ${run.model})`,
|
|
17430
|
+
evidence: score.reasoning,
|
|
17431
|
+
affectsAreas: ["graphspec"],
|
|
17432
|
+
affectsEvalTasks: [task2.task_id],
|
|
17433
|
+
severity: defaultSeverity
|
|
17434
|
+
});
|
|
17435
|
+
}
|
|
17436
|
+
}
|
|
17437
|
+
}
|
|
17438
|
+
}
|
|
17439
|
+
});
|
|
17440
|
+
}
|
|
17441
|
+
|
|
17386
17442
|
// src/patterns/messaging.ts
|
|
17387
17443
|
var messaging_exports = {};
|
|
17388
17444
|
__export(messaging_exports, {
|
|
@@ -18276,6 +18332,362 @@ function onFailure(graph, name, source, recover, opts) {
|
|
|
18276
18332
|
return step;
|
|
18277
18333
|
}
|
|
18278
18334
|
|
|
18335
|
+
// src/patterns/harness/types.ts
|
|
18336
|
+
function strategyKey(rootCause, intervention) {
|
|
18337
|
+
return `${rootCause}\u2192${intervention}`;
|
|
18338
|
+
}
|
|
18339
|
+
function defaultErrorClassifier(result) {
|
|
18340
|
+
const d = result.detail.toLowerCase();
|
|
18341
|
+
if (d.includes("parse") || d.includes("json") || d.includes("config") || d.includes("validation") || d.includes("syntax")) {
|
|
18342
|
+
return "self-correctable";
|
|
18343
|
+
}
|
|
18344
|
+
return "structural";
|
|
18345
|
+
}
|
|
18346
|
+
var DEFAULT_SEVERITY_WEIGHTS = {
|
|
18347
|
+
critical: 100,
|
|
18348
|
+
high: 70,
|
|
18349
|
+
medium: 40,
|
|
18350
|
+
low: 10
|
|
18351
|
+
};
|
|
18352
|
+
var DEFAULT_DECAY_RATE2 = Math.LN2 / (7 * 24 * 3600);
|
|
18353
|
+
var DEFAULT_QUEUE_CONFIGS = {
|
|
18354
|
+
"auto-fix": { gated: false },
|
|
18355
|
+
"needs-decision": { gated: true },
|
|
18356
|
+
investigation: { gated: true },
|
|
18357
|
+
backlog: { gated: false, startOpen: false }
|
|
18358
|
+
};
|
|
18359
|
+
|
|
18360
|
+
// src/patterns/harness/strategy.ts
|
|
18361
|
+
function strategyModel() {
|
|
18362
|
+
const _map = reactiveMap({ name: "strategy-entries" });
|
|
18363
|
+
const snapshot = derived(
|
|
18364
|
+
[_map.node],
|
|
18365
|
+
([mapSnap]) => {
|
|
18366
|
+
const raw = mapSnap.value.map;
|
|
18367
|
+
return new Map(raw);
|
|
18368
|
+
},
|
|
18369
|
+
{
|
|
18370
|
+
name: "strategy-model",
|
|
18371
|
+
equals: (a, b) => {
|
|
18372
|
+
const am = a;
|
|
18373
|
+
const bm = b;
|
|
18374
|
+
if (am.size !== bm.size) return false;
|
|
18375
|
+
for (const [k, v] of am) {
|
|
18376
|
+
const bv = bm.get(k);
|
|
18377
|
+
if (!bv || v.attempts !== bv.attempts || v.successes !== bv.successes) return false;
|
|
18378
|
+
}
|
|
18379
|
+
return true;
|
|
18380
|
+
}
|
|
18381
|
+
}
|
|
18382
|
+
);
|
|
18383
|
+
function record(rootCause, intervention, success) {
|
|
18384
|
+
const key = strategyKey(rootCause, intervention);
|
|
18385
|
+
const existing = _map.get(key);
|
|
18386
|
+
const attempts = (existing?.attempts ?? 0) + 1;
|
|
18387
|
+
const successes = (existing?.successes ?? 0) + (success ? 1 : 0);
|
|
18388
|
+
_map.set(key, {
|
|
18389
|
+
rootCause,
|
|
18390
|
+
intervention,
|
|
18391
|
+
attempts,
|
|
18392
|
+
successes,
|
|
18393
|
+
successRate: successes / attempts
|
|
18394
|
+
});
|
|
18395
|
+
}
|
|
18396
|
+
function lookup(rootCause, intervention) {
|
|
18397
|
+
return _map.get(strategyKey(rootCause, intervention));
|
|
18398
|
+
}
|
|
18399
|
+
const _unsub = snapshot.subscribe(() => {
|
|
18400
|
+
});
|
|
18401
|
+
return { node: snapshot, record, lookup };
|
|
18402
|
+
}
|
|
18403
|
+
function priorityScore(item, strategy, lastInteractionNs, urgency, signals) {
|
|
18404
|
+
const severityWeights = { ...DEFAULT_SEVERITY_WEIGHTS, ...signals?.severityWeights };
|
|
18405
|
+
const decayRate = signals?.decayRate ?? DEFAULT_DECAY_RATE2;
|
|
18406
|
+
const effectivenessThreshold = signals?.effectivenessThreshold ?? 0.7;
|
|
18407
|
+
const effectivenessBoost = signals?.effectivenessBoost ?? 15;
|
|
18408
|
+
const deps = [item, strategy, lastInteractionNs];
|
|
18409
|
+
if (urgency) deps.push(urgency);
|
|
18410
|
+
return derived(
|
|
18411
|
+
deps,
|
|
18412
|
+
(values) => {
|
|
18413
|
+
const itm = values[0];
|
|
18414
|
+
const strat = values[1];
|
|
18415
|
+
const lastNs = values[2];
|
|
18416
|
+
const urg = urgency ? values[3] : 0;
|
|
18417
|
+
const baseWeight = severityWeights[itm.severity ?? "medium"];
|
|
18418
|
+
const ageSeconds = (monotonicNs() - lastNs) / 1e9;
|
|
18419
|
+
let score = decay(baseWeight, ageSeconds, decayRate, 0);
|
|
18420
|
+
const key = strategyKey(itm.rootCause, itm.intervention);
|
|
18421
|
+
const entry = strat.get(key);
|
|
18422
|
+
if (entry && entry.successRate >= effectivenessThreshold) {
|
|
18423
|
+
score += effectivenessBoost;
|
|
18424
|
+
}
|
|
18425
|
+
score += urg * 20;
|
|
18426
|
+
return score;
|
|
18427
|
+
},
|
|
18428
|
+
{ name: "priority-score" }
|
|
18429
|
+
);
|
|
18430
|
+
}
|
|
18431
|
+
|
|
18432
|
+
// src/patterns/harness/loop.ts
|
|
18433
|
+
function baseSummary(summary) {
|
|
18434
|
+
return summary.replace(/^\[RETRY \d+\/\d+\]\s*/, "");
|
|
18435
|
+
}
|
|
18436
|
+
var DEFAULT_TRIAGE_PROMPT = `You are a triage classifier for a reactive collaboration harness.
|
|
18437
|
+
|
|
18438
|
+
Given an intake item, classify it and output JSON:
|
|
18439
|
+
{
|
|
18440
|
+
"rootCause": "composition" | "missing-fn" | "bad-docs" | "schema-gap" | "regression" | "unknown",
|
|
18441
|
+
"intervention": "template" | "catalog-fn" | "docs" | "wrapper" | "schema-change" | "investigate",
|
|
18442
|
+
"route": "auto-fix" | "needs-decision" | "investigation" | "backlog",
|
|
18443
|
+
"priority": <number 0-100>,
|
|
18444
|
+
"triageReasoning": "<one sentence>"
|
|
18445
|
+
}
|
|
18446
|
+
|
|
18447
|
+
Strategy model (past effectiveness):
|
|
18448
|
+
{{strategy}}
|
|
18449
|
+
|
|
18450
|
+
Intake item:
|
|
18451
|
+
{{item}}`;
|
|
18452
|
+
var DEFAULT_EXECUTE_PROMPT = `You are an implementation agent.
|
|
18453
|
+
|
|
18454
|
+
Given a triaged issue with root cause and intervention type, produce a fix.
|
|
18455
|
+
|
|
18456
|
+
Issue:
|
|
18457
|
+
{{item}}
|
|
18458
|
+
|
|
18459
|
+
Output JSON:
|
|
18460
|
+
{
|
|
18461
|
+
"outcome": "success" | "failure" | "partial",
|
|
18462
|
+
"detail": "<description of what was done or what failed>"
|
|
18463
|
+
}`;
|
|
18464
|
+
var DEFAULT_VERIFY_PROMPT = `You are a QA reviewer.
|
|
18465
|
+
|
|
18466
|
+
Given an execution result, verify whether the fix is correct.
|
|
18467
|
+
|
|
18468
|
+
Execution:
|
|
18469
|
+
{{execution}}
|
|
18470
|
+
|
|
18471
|
+
Original issue:
|
|
18472
|
+
{{item}}
|
|
18473
|
+
|
|
18474
|
+
Output JSON:
|
|
18475
|
+
{
|
|
18476
|
+
"verified": true/false,
|
|
18477
|
+
"findings": ["<finding1>", ...],
|
|
18478
|
+
"errorClass": "self-correctable" | "structural" // only if verified=false
|
|
18479
|
+
}`;
|
|
18480
|
+
var QUEUE_NAMES = [
|
|
18481
|
+
"auto-fix",
|
|
18482
|
+
"needs-decision",
|
|
18483
|
+
"investigation",
|
|
18484
|
+
"backlog"
|
|
18485
|
+
];
|
|
18486
|
+
var HarnessGraph = class extends Graph {
|
|
18487
|
+
/** Intake topic — publish items here to enter the loop. */
|
|
18488
|
+
intake;
|
|
18489
|
+
/** Per-route queue topics. */
|
|
18490
|
+
queues;
|
|
18491
|
+
/** Per-route gate controllers (only for gated queues). */
|
|
18492
|
+
gates;
|
|
18493
|
+
/** Strategy model bundle — record outcomes, lookup effectiveness. */
|
|
18494
|
+
strategy;
|
|
18495
|
+
/** Verify results topic — subscribe to see verification outcomes. */
|
|
18496
|
+
verifyResults;
|
|
18497
|
+
/** Per-item fast-retry counts (keyed by base summary). */
|
|
18498
|
+
retryTracker;
|
|
18499
|
+
/** Per-item reingestion counts (keyed by base summary). */
|
|
18500
|
+
reingestionTracker;
|
|
18501
|
+
constructor(name, intake, queues, gates, strategy, verifyResults, retryTracker, reingestionTracker) {
|
|
18502
|
+
super(name);
|
|
18503
|
+
this.intake = intake;
|
|
18504
|
+
this.queues = queues;
|
|
18505
|
+
this.gates = gates;
|
|
18506
|
+
this.strategy = strategy;
|
|
18507
|
+
this.verifyResults = verifyResults;
|
|
18508
|
+
this.retryTracker = retryTracker;
|
|
18509
|
+
this.reingestionTracker = reingestionTracker;
|
|
18510
|
+
}
|
|
18511
|
+
};
|
|
18512
|
+
function harnessLoop(name, opts) {
|
|
18513
|
+
const adapter = opts.adapter;
|
|
18514
|
+
const maxRetries = opts.maxRetries ?? 2;
|
|
18515
|
+
const retainedLimit = opts.retainedLimit ?? 1e3;
|
|
18516
|
+
const errorClassifier = opts.errorClassifier ?? defaultErrorClassifier;
|
|
18517
|
+
const queueConfigs = /* @__PURE__ */ new Map();
|
|
18518
|
+
for (const route of QUEUE_NAMES) {
|
|
18519
|
+
queueConfigs.set(route, {
|
|
18520
|
+
...DEFAULT_QUEUE_CONFIGS[route],
|
|
18521
|
+
...opts.queues?.[route]
|
|
18522
|
+
});
|
|
18523
|
+
}
|
|
18524
|
+
const intake = new TopicGraph("intake", { retainedLimit });
|
|
18525
|
+
const strategy = strategyModel();
|
|
18526
|
+
const triageInput = withLatestFrom(
|
|
18527
|
+
intake.latest,
|
|
18528
|
+
strategy.node
|
|
18529
|
+
);
|
|
18530
|
+
const triageNode = promptNode(
|
|
18531
|
+
adapter,
|
|
18532
|
+
[triageInput],
|
|
18533
|
+
opts.triagePrompt ?? ((pair) => {
|
|
18534
|
+
const [item, strat] = pair;
|
|
18535
|
+
if (!item) return "";
|
|
18536
|
+
return DEFAULT_TRIAGE_PROMPT.replace(
|
|
18537
|
+
"{{strategy}}",
|
|
18538
|
+
JSON.stringify(Array.from(strat.entries()))
|
|
18539
|
+
).replace("{{item}}", JSON.stringify(item));
|
|
18540
|
+
}),
|
|
18541
|
+
{
|
|
18542
|
+
name: "triage",
|
|
18543
|
+
format: "json",
|
|
18544
|
+
retries: 1
|
|
18545
|
+
}
|
|
18546
|
+
);
|
|
18547
|
+
const queueTopics = /* @__PURE__ */ new Map();
|
|
18548
|
+
for (const route of QUEUE_NAMES) {
|
|
18549
|
+
queueTopics.set(route, new TopicGraph(`queue/${route}`, { retainedLimit }));
|
|
18550
|
+
}
|
|
18551
|
+
const router = effect([triageNode], ([triaged]) => {
|
|
18552
|
+
const item = triaged;
|
|
18553
|
+
if (!item || !item.route) return;
|
|
18554
|
+
const topic2 = queueTopics.get(item.route);
|
|
18555
|
+
if (topic2) topic2.publish(item);
|
|
18556
|
+
});
|
|
18557
|
+
router.subscribe(() => {
|
|
18558
|
+
});
|
|
18559
|
+
const gateGraph = new Graph("gates");
|
|
18560
|
+
const gateControllers = /* @__PURE__ */ new Map();
|
|
18561
|
+
for (const route of QUEUE_NAMES) {
|
|
18562
|
+
const config = queueConfigs.get(route);
|
|
18563
|
+
const topic2 = queueTopics.get(route);
|
|
18564
|
+
if (config.gated) {
|
|
18565
|
+
gateGraph.add(`${route}/source`, topic2.latest);
|
|
18566
|
+
const ctrl = gate(gateGraph, `${route}/gate`, `${route}/source`, {
|
|
18567
|
+
maxPending: config.maxPending,
|
|
18568
|
+
startOpen: config.startOpen
|
|
18569
|
+
});
|
|
18570
|
+
gateControllers.set(route, ctrl);
|
|
18571
|
+
}
|
|
18572
|
+
}
|
|
18573
|
+
const retryTopic = new TopicGraph("retry-input", { retainedLimit });
|
|
18574
|
+
const queueOutputs = [];
|
|
18575
|
+
for (const route of QUEUE_NAMES) {
|
|
18576
|
+
const config = queueConfigs.get(route);
|
|
18577
|
+
if (config.gated && gateControllers.has(route)) {
|
|
18578
|
+
queueOutputs.push(gateControllers.get(route).node);
|
|
18579
|
+
} else {
|
|
18580
|
+
queueOutputs.push(queueTopics.get(route).latest);
|
|
18581
|
+
}
|
|
18582
|
+
}
|
|
18583
|
+
queueOutputs.push(retryTopic.latest);
|
|
18584
|
+
const executeInput = merge(...queueOutputs);
|
|
18585
|
+
const executeNode = promptNode(
|
|
18586
|
+
adapter,
|
|
18587
|
+
[executeInput],
|
|
18588
|
+
opts.executePrompt ?? ((item) => DEFAULT_EXECUTE_PROMPT.replace("{{item}}", JSON.stringify(item))),
|
|
18589
|
+
{
|
|
18590
|
+
name: "execute",
|
|
18591
|
+
format: "json",
|
|
18592
|
+
retries: 1
|
|
18593
|
+
}
|
|
18594
|
+
);
|
|
18595
|
+
const verifyResults = new TopicGraph("verify-results", { retainedLimit });
|
|
18596
|
+
const verifyNode = promptNode(
|
|
18597
|
+
adapter,
|
|
18598
|
+
[executeNode, executeInput],
|
|
18599
|
+
opts.verifyPrompt ?? ((execution, item) => DEFAULT_VERIFY_PROMPT.replace("{{execution}}", JSON.stringify(execution)).replace(
|
|
18600
|
+
"{{item}}",
|
|
18601
|
+
JSON.stringify(item)
|
|
18602
|
+
)),
|
|
18603
|
+
{
|
|
18604
|
+
name: "verify",
|
|
18605
|
+
format: "json",
|
|
18606
|
+
retries: 1
|
|
18607
|
+
}
|
|
18608
|
+
);
|
|
18609
|
+
const verifyWithExec = withLatestFrom(verifyNode, executeNode);
|
|
18610
|
+
const verifyContext = withLatestFrom(
|
|
18611
|
+
verifyWithExec,
|
|
18612
|
+
executeInput
|
|
18613
|
+
);
|
|
18614
|
+
const maxReingestions = opts.maxReingestions ?? 1;
|
|
18615
|
+
const retryTracker = /* @__PURE__ */ new Map();
|
|
18616
|
+
const reingestionTracker = /* @__PURE__ */ new Map();
|
|
18617
|
+
const fastRetry = effect([verifyContext], ([ctx]) => {
|
|
18618
|
+
const [[vo, execRaw], item] = ctx;
|
|
18619
|
+
if (!vo || !item) return;
|
|
18620
|
+
const exec = {
|
|
18621
|
+
item,
|
|
18622
|
+
outcome: execRaw?.outcome ?? "failure",
|
|
18623
|
+
detail: execRaw?.detail ?? "unknown"
|
|
18624
|
+
};
|
|
18625
|
+
const vr = {
|
|
18626
|
+
item,
|
|
18627
|
+
execution: exec,
|
|
18628
|
+
verified: vo.verified,
|
|
18629
|
+
findings: vo.findings ?? [],
|
|
18630
|
+
errorClass: vo.errorClass
|
|
18631
|
+
};
|
|
18632
|
+
if (vr.verified) {
|
|
18633
|
+
strategy.record(item.rootCause, item.intervention, true);
|
|
18634
|
+
verifyResults.publish(vr);
|
|
18635
|
+
return;
|
|
18636
|
+
}
|
|
18637
|
+
const errClass = vr.errorClass ?? errorClassifier({
|
|
18638
|
+
item,
|
|
18639
|
+
outcome: "failure",
|
|
18640
|
+
detail: vr.findings.join("; ")
|
|
18641
|
+
});
|
|
18642
|
+
const key = baseSummary(item.summary);
|
|
18643
|
+
const retryCount = retryTracker.get(key) ?? 0;
|
|
18644
|
+
if (errClass === "self-correctable" && retryCount < maxRetries) {
|
|
18645
|
+
retryTracker.set(key, retryCount + 1);
|
|
18646
|
+
const retryItem = {
|
|
18647
|
+
...item,
|
|
18648
|
+
summary: `[RETRY ${retryCount + 1}/${maxRetries}] ${baseSummary(item.summary)} \u2014 Previous attempt failed: ${vr.findings.join("; ")}`
|
|
18649
|
+
};
|
|
18650
|
+
retryTopic.publish(retryItem);
|
|
18651
|
+
} else {
|
|
18652
|
+
strategy.record(item.rootCause, item.intervention, false);
|
|
18653
|
+
verifyResults.publish(vr);
|
|
18654
|
+
const itemReingestions = reingestionTracker.get(key) ?? 0;
|
|
18655
|
+
if (itemReingestions < maxReingestions) {
|
|
18656
|
+
reingestionTracker.set(key, itemReingestions + 1);
|
|
18657
|
+
intake.publish({
|
|
18658
|
+
source: "eval",
|
|
18659
|
+
summary: `Verification failed for: ${baseSummary(item.summary)}`,
|
|
18660
|
+
evidence: vr.findings.join("\n"),
|
|
18661
|
+
affectsAreas: item.affectsAreas,
|
|
18662
|
+
affectsEvalTasks: item.affectsEvalTasks,
|
|
18663
|
+
severity: "high",
|
|
18664
|
+
relatedTo: [baseSummary(item.summary)]
|
|
18665
|
+
});
|
|
18666
|
+
}
|
|
18667
|
+
}
|
|
18668
|
+
});
|
|
18669
|
+
fastRetry.subscribe(() => {
|
|
18670
|
+
});
|
|
18671
|
+
const harness = new HarnessGraph(
|
|
18672
|
+
name,
|
|
18673
|
+
intake,
|
|
18674
|
+
queueTopics,
|
|
18675
|
+
gateControllers,
|
|
18676
|
+
strategy,
|
|
18677
|
+
verifyResults,
|
|
18678
|
+
retryTracker,
|
|
18679
|
+
reingestionTracker
|
|
18680
|
+
);
|
|
18681
|
+
harness.mount("intake", intake);
|
|
18682
|
+
for (const [route, topic2] of queueTopics) {
|
|
18683
|
+
harness.mount(`queue/${route}`, topic2);
|
|
18684
|
+
}
|
|
18685
|
+
harness.mount("gates", gateGraph);
|
|
18686
|
+
harness.mount("retry-input", retryTopic);
|
|
18687
|
+
harness.mount("verify-results", verifyResults);
|
|
18688
|
+
return harness;
|
|
18689
|
+
}
|
|
18690
|
+
|
|
18279
18691
|
// src/patterns/reactive-layout/index.ts
|
|
18280
18692
|
var reactive_layout_exports = {};
|
|
18281
18693
|
__export(reactive_layout_exports, {
|
|
@@ -18890,6 +19302,7 @@ var version = "0.0.0";
|
|
|
18890
19302
|
globToRegExp,
|
|
18891
19303
|
graph,
|
|
18892
19304
|
graphspec,
|
|
19305
|
+
harness,
|
|
18893
19306
|
interval,
|
|
18894
19307
|
isBatching,
|
|
18895
19308
|
isKnownMessageType,
|