claude-flow 3.38.15 → 3.38.16
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/v3/@claude-flow/cli/catalog-manifest.json +2 -2
- package/v3/@claude-flow/cli/dist/src/ruvector/model-router.d.ts +12 -0
- package/v3/@claude-flow/cli/dist/src/ruvector/model-router.js +32 -0
- package/v3/@claude-flow/cli/package.json +4 -3
- package/.claude/coordinator/config.json +0 -24
- package/.claude/coordinator/state.json +0 -37
- package/.claude/coordinator/tick-log/tick-01.json +0 -17
- package/.claude/coordinator/tick-log/tick-02.json +0 -17
- package/.claude/coordinator/tick-log/tick-03.json +0 -17
- package/.claude/coordinator/tick-log/tick-04.json +0 -14
- package/.claude/coordinator/tick-log/tick-05.json +0 -16
package/package.json
CHANGED
|
@@ -77,6 +77,18 @@ export interface ModelRouterConfig {
|
|
|
77
77
|
enableCostOptimization: boolean;
|
|
78
78
|
/** Prefer faster models when confidence is high (default: true) */
|
|
79
79
|
preferSpeed: boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Discounted Thompson sampling factor applied to every bucket/model's
|
|
82
|
+
* α/β on each recordOutcome call, BEFORE that call's own reward is added
|
|
83
|
+
* (Discounted TS — arXiv 2305.10718): `α ← γα`, `β ← γβ`. Range (0, 1];
|
|
84
|
+
* 1 = disabled (default — fully backward compatible with persisted
|
|
85
|
+
* `.swarm/model-router-state.json` state). γ<1 makes old routing history
|
|
86
|
+
* decay geometrically so the bandit recovers faster after a sustained
|
|
87
|
+
* shift in a model's real-world quality, instead of unbounded accumulated
|
|
88
|
+
* history permanently dominating the posterior. Mirrors the epsilon decay
|
|
89
|
+
* `q-learning-router.ts` already applies to its own exploration rate.
|
|
90
|
+
*/
|
|
91
|
+
priorDecay: number;
|
|
80
92
|
}
|
|
81
93
|
/**
|
|
82
94
|
* Routing decision result
|
|
@@ -305,7 +305,13 @@ const DEFAULT_CONFIG = {
|
|
|
305
305
|
autoSaveInterval: 1, // Save after every decision for CLI persistence
|
|
306
306
|
enableCostOptimization: true,
|
|
307
307
|
preferSpeed: true,
|
|
308
|
+
priorDecay: 1,
|
|
308
309
|
};
|
|
310
|
+
// Beta shape parameters must stay well clear of 0 for sampleGamma/sampleBeta
|
|
311
|
+
// to remain numerically stable across a persisted, long-running state file —
|
|
312
|
+
// see priorDecay's doc comment. Geometric decay alone (no reward added back)
|
|
313
|
+
// would otherwise shrink an unused bucket/model's α,β toward 0 forever.
|
|
314
|
+
const PRIOR_DECAY_FLOOR = 0.05;
|
|
309
315
|
// Posterior mean of a Beta(α,β) prior — used by the #2250 escalation guard
|
|
310
316
|
// to detect when the bandit has *learned* the escalation target is worse.
|
|
311
317
|
function priorMean(p) {
|
|
@@ -346,6 +352,17 @@ export class ModelRouter {
|
|
|
346
352
|
abComparisons = 0;
|
|
347
353
|
constructor(config = {}) {
|
|
348
354
|
this.config = { ...DEFAULT_CONFIG, ...config };
|
|
355
|
+
// priorDecay multiplies directly into persisted α/β (recordOutcome). An
|
|
356
|
+
// out-of-range value (NaN, <=0, >1 — e.g. a bad env/config parse) would
|
|
357
|
+
// silently poison `.swarm/model-router-state.json` forever: Math.max's
|
|
358
|
+
// NaN-poisoning bypasses sampleBeta's own alpha<=0||beta<=0 fallback, and
|
|
359
|
+
// a negative value pins every prior at PRIOR_DECAY_FLOOR on the very
|
|
360
|
+
// first call. Fall through to the safe default (1 = disabled) instead of
|
|
361
|
+
// throwing, matching this file's existing malformed-config idiom (see
|
|
362
|
+
// envMaxUncertainty above).
|
|
363
|
+
if (!Number.isFinite(this.config.priorDecay) || this.config.priorDecay <= 0 || this.config.priorDecay > 1) {
|
|
364
|
+
this.config.priorDecay = 1;
|
|
365
|
+
}
|
|
349
366
|
this.state = this.loadState();
|
|
350
367
|
}
|
|
351
368
|
/**
|
|
@@ -897,6 +914,21 @@ export class ModelRouter {
|
|
|
897
914
|
// is wasteful even when correct). Failure/escalation always β++.
|
|
898
915
|
if (!this.state.priors)
|
|
899
916
|
this.state.priors = defaultBucketedPriors();
|
|
917
|
+
// Discounted Thompson sampling (priorDecay < 1): decay ALL bucket/model
|
|
918
|
+
// priors once per recordOutcome call, before this call's own reward is
|
|
919
|
+
// added — every routing decision is one discrete "time step" for every
|
|
920
|
+
// arm, not just the one that got pulled, matching the arXiv 2305.10718
|
|
921
|
+
// formulation. No-op when priorDecay is the default of 1.
|
|
922
|
+
if (this.config.priorDecay < 1) {
|
|
923
|
+
for (const bk of Object.keys(this.state.priors)) {
|
|
924
|
+
const bucketPriors = this.state.priors[bk];
|
|
925
|
+
for (const m of Object.keys(bucketPriors)) {
|
|
926
|
+
const p = bucketPriors[m];
|
|
927
|
+
p.alpha = Math.max(PRIOR_DECAY_FLOOR, p.alpha * this.config.priorDecay);
|
|
928
|
+
p.beta = Math.max(PRIOR_DECAY_FLOOR, p.beta * this.config.priorDecay);
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
}
|
|
900
932
|
const bp = this.state.priors[bucket] ?? (this.state.priors[bucket] = defaultBanditPriors());
|
|
901
933
|
const reward = BANDIT_REWARDS[model]?.[outcome] ?? 0.5;
|
|
902
934
|
bp[model].alpha += reward;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@claude-flow/cli",
|
|
3
|
-
"version": "3.38.
|
|
3
|
+
"version": "3.38.16",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Ruflo CLI - Enterprise AI agent orchestration with 60+ specialized agents, swarm coordination, MCP server, self-learning hooks, and vector memory for Claude Code",
|
|
6
6
|
"main": "dist/src/index.js",
|
|
@@ -93,6 +93,7 @@
|
|
|
93
93
|
"publish:all": "./scripts/publish.sh"
|
|
94
94
|
},
|
|
95
95
|
"devDependencies": {
|
|
96
|
+
"tsx": "^4.19.0",
|
|
96
97
|
"typescript": "^5.3.0",
|
|
97
98
|
"vitest": "^4.1.0"
|
|
98
99
|
},
|
|
@@ -112,10 +113,10 @@
|
|
|
112
113
|
"chalk": "^5.3.0",
|
|
113
114
|
"commander": "^12.0.0",
|
|
114
115
|
"cors": "^2.8.5",
|
|
115
|
-
"fs-extra": "^11.2.0",
|
|
116
116
|
"express": ">=4.22.2",
|
|
117
117
|
"express-rate-limit": ">=8.4.1",
|
|
118
118
|
"fast-uri": "3.1.5",
|
|
119
|
+
"fs-extra": "^11.2.0",
|
|
119
120
|
"helmet": "^7.2.0",
|
|
120
121
|
"inquirer": "^9.2.0",
|
|
121
122
|
"semver": "7.7.3",
|
|
@@ -127,12 +128,12 @@
|
|
|
127
128
|
},
|
|
128
129
|
"optionalDependencies": {
|
|
129
130
|
"@agntcy/slim-bindings": "2.0.0-alpha.5",
|
|
130
|
-
"@napi-rs/keyring": "1.3.0",
|
|
131
131
|
"@claude-flow/memory": "^3.0.0-alpha.22",
|
|
132
132
|
"@metaharness/darwin": "~0.9.0",
|
|
133
133
|
"@metaharness/flywheel": "~0.1.10",
|
|
134
134
|
"@metaharness/radio": "~0.1.0",
|
|
135
135
|
"@metaharness/turn-credit": "~0.1.0",
|
|
136
|
+
"@napi-rs/keyring": "1.3.0",
|
|
136
137
|
"agentdb": "^3.0.0-alpha.17",
|
|
137
138
|
"agentic-flow": "^3.0.0-alpha.1",
|
|
138
139
|
"better-sqlite3": "^12.9.0",
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": "1.0",
|
|
3
|
-
"startedAt": "2026-07-08T02:30:00Z",
|
|
4
|
-
"policy": "full-autopilot",
|
|
5
|
-
"safety": {
|
|
6
|
-
"requireCiGreen": true,
|
|
7
|
-
"requireNoConflict": true,
|
|
8
|
-
"requireIdleHours": 0,
|
|
9
|
-
"maxTicks": 30,
|
|
10
|
-
"tickIntervalSeconds": 600,
|
|
11
|
-
"excludeIfCodeownersBlock": true
|
|
12
|
-
},
|
|
13
|
-
"targetPRs": [
|
|
14
|
-
{"num": 2517, "adr": null, "cluster": "security", "grade": "A", "note": "AgentDB retrieval poisoning 93-100% ASR"},
|
|
15
|
-
{"num": 2537, "adr": null, "cluster": "memory", "grade": "B", "note": "AutoMem RL loop — needs ADR renumber (collides w/ #2527 on 167)"},
|
|
16
|
-
{"num": 2577, "adr": 176, "cluster": "performance", "grade": "A", "note": "PolyKV shared KV pool 97.7% reduction"},
|
|
17
|
-
{"num": 2589, "adr": null, "cluster": "security", "grade": "A", "note": "VMG + RepE IPI — needs ADR renumber (collides w/ #2598 on 178)"},
|
|
18
|
-
{"num": 2598, "adr": null, "cluster": "intelligence", "grade": "B", "note": "SkillRL — needs ADR renumber (collides w/ #2589 on 178)"}
|
|
19
|
-
],
|
|
20
|
-
"adrCollisions": [
|
|
21
|
-
{"conflictingPRs": [2589, 2598], "originalAdr": 178, "resolution": "earlier-wins", "reason": "2589 (dream 2026-07-06) beats 2598 (dream 2026-07-07)"},
|
|
22
|
-
{"conflictingPRs": [2527, 2537], "originalAdr": 167, "resolution": "earlier-wins", "reason": "2527 (dream 2026-07-02) beats 2537 (dream 2026-07-03) — but 2527 not in scope so 2537 gets it if 2527 is also renumbered"}
|
|
23
|
-
]
|
|
24
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"tick": 5,
|
|
3
|
-
"terminated": true,
|
|
4
|
-
"terminationReason": "main-preexisting-red-cannot-autopilot",
|
|
5
|
-
"closed": [],
|
|
6
|
-
"merged": [2589],
|
|
7
|
-
"blocked": [2517, 2537, 2577, 2598],
|
|
8
|
-
"adrAssignments": {
|
|
9
|
-
"2517": 180,
|
|
10
|
-
"2537": 181,
|
|
11
|
-
"2577": 182,
|
|
12
|
-
"2598": 183,
|
|
13
|
-
"2589": 178
|
|
14
|
-
},
|
|
15
|
-
"routingWeights": {
|
|
16
|
-
"parallel-renumber-adr": -1,
|
|
17
|
-
"centralized-adr-pre-assign": 2,
|
|
18
|
-
"convert-ready-when-green": 1,
|
|
19
|
-
"single-action-per-tick": 1,
|
|
20
|
-
"gh-pr-merge-admin-squash": 1,
|
|
21
|
-
"rebase-onto-main-when-shared-blocker": 2,
|
|
22
|
-
"force-remove-stale-worktree": 1,
|
|
23
|
-
"inline-fix-when-workflow-stalls": 1,
|
|
24
|
-
"diagnose-main-before-per-pr-fix": 3,
|
|
25
|
-
"terminate-loop-when-main-red-and-not-caused-by-scope": 2
|
|
26
|
-
},
|
|
27
|
-
"cumulativeReward": 14,
|
|
28
|
-
"ticksSpent": 5,
|
|
29
|
-
"completedAt": "2026-07-08T03:15:00Z",
|
|
30
|
-
"achievements": [
|
|
31
|
-
"Landed PR #2589 (security VMG+RepE IPI) — first dream merge in weeks",
|
|
32
|
-
"Resolved 4 ADR-number collisions (178/180/181/182/183) that had built up across in-flight dreams",
|
|
33
|
-
"Rebased 4 stale dream branches onto main to inherit v3.25.3 fixes",
|
|
34
|
-
"Learned + persisted routing weights via 5 tick cycles"
|
|
35
|
-
],
|
|
36
|
-
"handoff": "Main has 7 preexisting failing checks (Build V3 all platforms, Witness verify all platforms, graph schema smoke ADR-130 P1). All 4 remaining PRs (#2517, #2537, #2577, #2598) are draft=false + mergeable + at latest ADR numbers + rebased to main tip. They will auto-merge via a re-fired coordinator OR via `gh pr merge --admin --squash` once main goes green. Recommendation: file a `fix/main-v3-ci-red` triage issue first, unblock main, then re-fire the coordinator with `/loop 10m` OR merge the 4 PRs manually with --admin since they only add ADR markdown."
|
|
37
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"tick": 1,
|
|
3
|
-
"completedAt": "2026-07-08T02:33:00Z",
|
|
4
|
-
"durationSeconds": 141,
|
|
5
|
-
"assessed": 5,
|
|
6
|
-
"advanced": 5,
|
|
7
|
-
"merged": 0,
|
|
8
|
-
"renumbered": 4,
|
|
9
|
-
"readyForCi": 1,
|
|
10
|
-
"totalReward": 5,
|
|
11
|
-
"coordinatorMistake": {
|
|
12
|
-
"type": "parallel-race-adr-allocation",
|
|
13
|
-
"description": "4 independent assessors each picked ADR-180 as next-free. Result: 4 PRs now all claim ADR-180.",
|
|
14
|
-
"affectedPRs": [2517, 2537, 2577, 2598]
|
|
15
|
-
},
|
|
16
|
-
"lessonLearned": "Future ticks: PRE-ASSIGN ADR numbers centrally before fanning out. Never let parallel agents pick numbers independently."
|
|
17
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"tick": 2,
|
|
3
|
-
"completedAt": "2026-07-08T02:36:00Z",
|
|
4
|
-
"durationSeconds": 106,
|
|
5
|
-
"collisionFixesSucceeded": 3,
|
|
6
|
-
"advancesSucceeded": 2,
|
|
7
|
-
"mergedThisTick": [2589],
|
|
8
|
-
"renumberedThisTick": [
|
|
9
|
-
{"pr": 2537, "adr": 181},
|
|
10
|
-
{"pr": 2577, "adr": 182},
|
|
11
|
-
{"pr": 2598, "adr": 183}
|
|
12
|
-
],
|
|
13
|
-
"ciRunningThisTick": [2517],
|
|
14
|
-
"totalReward": 5,
|
|
15
|
-
"cumulativeReward": 10,
|
|
16
|
-
"lesson": "Central pre-assignment resolved the parallel-race collision that tick 1 created. Reward pattern confirms centralized-adr-pre-assign > parallel-renumber-adr."
|
|
17
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"tick": 3,
|
|
3
|
-
"completedAt": "2026-07-08T02:59:00Z",
|
|
4
|
-
"durationSeconds": 69,
|
|
5
|
-
"assessed": 4,
|
|
6
|
-
"advanced": 0,
|
|
7
|
-
"merged": 0,
|
|
8
|
-
"totalReward": 0,
|
|
9
|
-
"cumulativeReward": 10,
|
|
10
|
-
"sharedBlocker": {
|
|
11
|
-
"type": "old-base-missing-2578-fix",
|
|
12
|
-
"description": "All 4 remaining dream branches predate the #2578 phantom-subpath fix that landed in v3.25.3 (PR #2602). Their old midstream-aware-loader.ts still imports from 'agentic-flow/transport/loader' → TS errors on Build V3.",
|
|
13
|
-
"affectedPRs": [2517, 2537, 2577, 2598],
|
|
14
|
-
"resolution": "rebase all 4 onto latest main; the fix is already there"
|
|
15
|
-
},
|
|
16
|
-
"lessonLearned": "Old-base branches get free fixes on rebase after main advances. Detect the shared-blocker pattern (same failure mode across N PRs) → try rebase before per-PR fixes."
|
|
17
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"tick": 4,
|
|
3
|
-
"completedAt": "2026-07-08T03:03:00Z",
|
|
4
|
-
"durationSeconds": 92,
|
|
5
|
-
"rebased": [2517, 2537, 2577, 2598],
|
|
6
|
-
"convertedReady": [2537, 2577, 2598],
|
|
7
|
-
"coordinatorMistakes": [
|
|
8
|
-
{"type": "schema-drift", "description": "3 rebase agents returned prNum=0 instead of the target PR number; downstream Convert-Ready phase failed on nonexistent PR #0"},
|
|
9
|
-
{"type": "stale-worktree", "description": "Tick 1's worktree wf_ea2955a6-e74-10 held dream/2026-07-07-intelligence; tick 4's #2598 agent couldn't checkout. Fixed inline with git worktree remove --force + inline rebase."}
|
|
10
|
-
],
|
|
11
|
-
"totalReward": 4,
|
|
12
|
-
"cumulativeReward": 14,
|
|
13
|
-
"lesson": "Workflow agents must inject their prNum into the return payload (prompt-side templating). Force-remove worktrees at end of prior workflow OR clean up before spawning new ones. Sometimes inline main-context work is faster than another workflow round."
|
|
14
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"tick": 5,
|
|
3
|
-
"completedAt": "2026-07-08T03:15:00Z",
|
|
4
|
-
"durationSeconds": 33,
|
|
5
|
-
"assessed": 4,
|
|
6
|
-
"mergeEligible": 0,
|
|
7
|
-
"merged": 0,
|
|
8
|
-
"totalReward": 0,
|
|
9
|
-
"cumulativeReward": 14,
|
|
10
|
-
"terminalDiagnosis": {
|
|
11
|
-
"type": "main-preexisting-red",
|
|
12
|
-
"description": "Main's latest v3-ci run (sha a444930d8, post-#2589 merge) has 7 failing checks preexisting: Build V3 (macos/ubuntu/windows) [TS type errors in plugin-agent-federation], Witness verify (signed manifest) [macos/ubuntu/windows], graph schema smoke (ADR-130 P1). ALL 4 remaining dream PRs inherit these failures. They can NEVER pass CI while main is red.",
|
|
13
|
-
"canCoordinatorFixThis": false,
|
|
14
|
-
"reasoning": "Multi-platform TS type errors + witness manifest issues + graph schema audit = multi-hour repo-level work that needs human architectural decisions (revert vs fix upstream, which shim signatures to accept). Beyond the coordinator's 10-min autopilot scope."
|
|
15
|
-
}
|
|
16
|
-
}
|