@neuroverseos/governance 0.2.1 → 0.3.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.
Files changed (67) hide show
  1. package/.well-known/ai-plugin.json +26 -0
  2. package/.well-known/mcp.json +68 -0
  3. package/AGENTS.md +219 -0
  4. package/README.md +64 -4
  5. package/dist/adapters/autoresearch.cjs +196 -0
  6. package/dist/adapters/autoresearch.d.cts +103 -0
  7. package/dist/adapters/autoresearch.d.ts +103 -0
  8. package/dist/adapters/autoresearch.js +7 -0
  9. package/dist/adapters/express.d.cts +1 -1
  10. package/dist/adapters/express.d.ts +1 -1
  11. package/dist/adapters/express.js +3 -3
  12. package/dist/adapters/index.cjs +215 -8
  13. package/dist/adapters/index.d.cts +2 -1
  14. package/dist/adapters/index.d.ts +2 -1
  15. package/dist/adapters/index.js +10 -6
  16. package/dist/adapters/langchain.cjs +34 -4
  17. package/dist/adapters/langchain.d.cts +1 -1
  18. package/dist/adapters/langchain.d.ts +1 -1
  19. package/dist/adapters/langchain.js +3 -3
  20. package/dist/adapters/openai.cjs +34 -4
  21. package/dist/adapters/openai.d.cts +1 -1
  22. package/dist/adapters/openai.d.ts +1 -1
  23. package/dist/adapters/openai.js +3 -3
  24. package/dist/adapters/openclaw.cjs +34 -4
  25. package/dist/adapters/openclaw.d.cts +1 -1
  26. package/dist/adapters/openclaw.d.ts +1 -1
  27. package/dist/adapters/openclaw.js +3 -3
  28. package/dist/{chunk-ZL4AHY4X.js → chunk-2NICNKOM.js} +1 -1
  29. package/dist/{chunk-UPJNTSVM.js → chunk-2PQU3VAN.js} +10 -7
  30. package/dist/{chunk-5EDDNJU6.js → chunk-4A7LISES.js} +10 -7
  31. package/dist/{chunk-PQBJBVSW.js → chunk-4JRYGIO7.js} +1 -1
  32. package/dist/{chunk-P74Y66ZV.js → chunk-4QXB6PEO.js} +29 -2
  33. package/dist/{chunk-37JG24WH.js → chunk-6CZSKEY5.js} +3 -0
  34. package/dist/{chunk-IVPKFJX3.js → chunk-COT5XS4V.js} +10 -7
  35. package/dist/{chunk-TINSRYXQ.js → chunk-ER62HNGF.js} +10 -7
  36. package/dist/{chunk-PAX2P6ZP.js → chunk-OGL7QXZS.js} +15 -8
  37. package/dist/{chunk-ADV7Q2LJ.js → chunk-PDOZHZWL.js} +1 -1
  38. package/dist/{chunk-2JQJ5U5X.js → chunk-QPASI2BR.js} +1 -1
  39. package/dist/chunk-T5EUJQE5.js +172 -0
  40. package/dist/cli/neuroverse.cjs +1245 -208
  41. package/dist/cli/neuroverse.js +20 -8
  42. package/dist/cli/plan.cjs +59 -14
  43. package/dist/cli/plan.js +30 -15
  44. package/dist/cli/run.cjs +34 -4
  45. package/dist/cli/run.js +2 -2
  46. package/dist/{doctor-V72UM2TC.js → doctor-XPDLEYXN.js} +2 -1
  47. package/dist/{guard-WA3FCCIO.js → guard-RV65TT4L.js} +2 -2
  48. package/dist/{guard-contract-D-2LQInm.d.cts → guard-contract-WZx__PmU.d.cts} +39 -1
  49. package/dist/{guard-contract-D-2LQInm.d.ts → guard-contract-WZx__PmU.d.ts} +39 -1
  50. package/dist/{guard-engine-D7X4CVAE.js → guard-engine-JLTUARGU.js} +2 -2
  51. package/dist/{impact-BWULZ5RP.js → impact-XPECYRLH.js} +4 -4
  52. package/dist/index.cjs +47 -7
  53. package/dist/index.d.cts +20 -5
  54. package/dist/index.d.ts +20 -5
  55. package/dist/index.js +32 -32
  56. package/dist/infer-world-7GVZWFX4.js +543 -0
  57. package/dist/init-world-VWMQZQC7.js +223 -0
  58. package/dist/{mcp-server-YUOQP4M5.js → mcp-server-FPVSU32Z.js} +3 -3
  59. package/dist/{playground-CBXMAW2B.js → playground-E664U4T6.js} +2 -2
  60. package/dist/{redteam-SSNABQ7W.js → redteam-Z7WREJ44.js} +2 -2
  61. package/dist/{session-MWRBTCYX.js → session-EKTRSR7C.js} +3 -3
  62. package/dist/{test-3GZSG5FR.js → test-OGXJK4QU.js} +2 -2
  63. package/dist/{trace-TM4Z7G73.js → trace-JVF67VR3.js} +3 -3
  64. package/dist/worlds/autoresearch.nv-world.md +230 -0
  65. package/llms.txt +79 -0
  66. package/openapi.yaml +230 -0
  67. package/package.json +15 -4
@@ -0,0 +1,103 @@
1
+ import { W as WorldDefinition, G as GuardEvent } from '../guard-contract-WZx__PmU.cjs';
2
+
3
+ /**
4
+ * Autoresearch Adapter — Bridge between NeuroVerse governance and autoresearch loops
5
+ *
6
+ * This adapter translates autoresearch experiment events into GuardEvents
7
+ * that can be evaluated by the NeuroVerse governance engine.
8
+ *
9
+ * Usage:
10
+ * import { AutoresearchGovernor } from '@neuroverseos/governance/adapters';
11
+ *
12
+ * const governor = new AutoresearchGovernor({ worldPath: './world/' });
13
+ * const verdict = await governor.evaluateExperiment(experiment);
14
+ * const state = governor.updateState(experimentResult);
15
+ */
16
+
17
+ interface ExperimentProposal {
18
+ experiment_id: number;
19
+ architecture: string;
20
+ description: string;
21
+ estimated_minutes?: number;
22
+ hyperparameters?: Record<string, unknown>;
23
+ }
24
+ interface ExperimentResult {
25
+ experiment_id: number;
26
+ architecture: string;
27
+ dataset: string;
28
+ metric_name: string;
29
+ metric_value: number;
30
+ training_config: Record<string, unknown>;
31
+ wall_clock_minutes: number;
32
+ timestamp: string;
33
+ success: boolean;
34
+ error?: string;
35
+ }
36
+ interface ResearchState {
37
+ experiments_run: number;
38
+ best_result: ExperimentResult | null;
39
+ architectures_tested: string[];
40
+ experiment_log: ExperimentResult[];
41
+ total_compute_minutes: number;
42
+ keep_count: number;
43
+ }
44
+ interface AutoresearchGovernorConfig {
45
+ world?: WorldDefinition;
46
+ worldPath?: string;
47
+ metric: string;
48
+ optimize: 'minimize' | 'maximize';
49
+ computeBudgetMinutes: number;
50
+ dataset: string;
51
+ context: string;
52
+ constraints?: string[];
53
+ }
54
+ declare class AutoresearchGovernor {
55
+ private config;
56
+ private state;
57
+ constructor(config: AutoresearchGovernorConfig);
58
+ /**
59
+ * Convert an experiment proposal into a GuardEvent for governance evaluation.
60
+ */
61
+ proposalToGuardEvent(proposal: ExperimentProposal): GuardEvent;
62
+ /**
63
+ * Evaluate an experiment proposal against governance rules.
64
+ * Returns a simplified verdict without requiring the full guard engine.
65
+ */
66
+ evaluateProposal(proposal: ExperimentProposal): {
67
+ allowed: boolean;
68
+ reason: string;
69
+ warnings: string[];
70
+ };
71
+ /**
72
+ * Record an experiment result and update research state.
73
+ */
74
+ recordResult(result: ExperimentResult): {
75
+ kept: boolean;
76
+ improvement: number | null;
77
+ state: ResearchState;
78
+ };
79
+ /**
80
+ * Export current state as a state snapshot compatible with the world file.
81
+ */
82
+ toWorldState(): Record<string, number>;
83
+ /**
84
+ * Get a summary of the current research state.
85
+ */
86
+ getSummary(): {
87
+ experiments_run: number;
88
+ best_result: ExperimentResult | null;
89
+ keep_rate: number;
90
+ compute_remaining_minutes: number;
91
+ architectures_tested: string[];
92
+ };
93
+ /**
94
+ * Load state from a persisted research context file.
95
+ */
96
+ loadState(state: ResearchState): void;
97
+ /**
98
+ * Export state for persistence.
99
+ */
100
+ exportState(): ResearchState;
101
+ }
102
+
103
+ export { AutoresearchGovernor, type AutoresearchGovernorConfig, type ExperimentProposal, type ExperimentResult, type ResearchState };
@@ -0,0 +1,103 @@
1
+ import { W as WorldDefinition, G as GuardEvent } from '../guard-contract-WZx__PmU.js';
2
+
3
+ /**
4
+ * Autoresearch Adapter — Bridge between NeuroVerse governance and autoresearch loops
5
+ *
6
+ * This adapter translates autoresearch experiment events into GuardEvents
7
+ * that can be evaluated by the NeuroVerse governance engine.
8
+ *
9
+ * Usage:
10
+ * import { AutoresearchGovernor } from '@neuroverseos/governance/adapters';
11
+ *
12
+ * const governor = new AutoresearchGovernor({ worldPath: './world/' });
13
+ * const verdict = await governor.evaluateExperiment(experiment);
14
+ * const state = governor.updateState(experimentResult);
15
+ */
16
+
17
+ interface ExperimentProposal {
18
+ experiment_id: number;
19
+ architecture: string;
20
+ description: string;
21
+ estimated_minutes?: number;
22
+ hyperparameters?: Record<string, unknown>;
23
+ }
24
+ interface ExperimentResult {
25
+ experiment_id: number;
26
+ architecture: string;
27
+ dataset: string;
28
+ metric_name: string;
29
+ metric_value: number;
30
+ training_config: Record<string, unknown>;
31
+ wall_clock_minutes: number;
32
+ timestamp: string;
33
+ success: boolean;
34
+ error?: string;
35
+ }
36
+ interface ResearchState {
37
+ experiments_run: number;
38
+ best_result: ExperimentResult | null;
39
+ architectures_tested: string[];
40
+ experiment_log: ExperimentResult[];
41
+ total_compute_minutes: number;
42
+ keep_count: number;
43
+ }
44
+ interface AutoresearchGovernorConfig {
45
+ world?: WorldDefinition;
46
+ worldPath?: string;
47
+ metric: string;
48
+ optimize: 'minimize' | 'maximize';
49
+ computeBudgetMinutes: number;
50
+ dataset: string;
51
+ context: string;
52
+ constraints?: string[];
53
+ }
54
+ declare class AutoresearchGovernor {
55
+ private config;
56
+ private state;
57
+ constructor(config: AutoresearchGovernorConfig);
58
+ /**
59
+ * Convert an experiment proposal into a GuardEvent for governance evaluation.
60
+ */
61
+ proposalToGuardEvent(proposal: ExperimentProposal): GuardEvent;
62
+ /**
63
+ * Evaluate an experiment proposal against governance rules.
64
+ * Returns a simplified verdict without requiring the full guard engine.
65
+ */
66
+ evaluateProposal(proposal: ExperimentProposal): {
67
+ allowed: boolean;
68
+ reason: string;
69
+ warnings: string[];
70
+ };
71
+ /**
72
+ * Record an experiment result and update research state.
73
+ */
74
+ recordResult(result: ExperimentResult): {
75
+ kept: boolean;
76
+ improvement: number | null;
77
+ state: ResearchState;
78
+ };
79
+ /**
80
+ * Export current state as a state snapshot compatible with the world file.
81
+ */
82
+ toWorldState(): Record<string, number>;
83
+ /**
84
+ * Get a summary of the current research state.
85
+ */
86
+ getSummary(): {
87
+ experiments_run: number;
88
+ best_result: ExperimentResult | null;
89
+ keep_rate: number;
90
+ compute_remaining_minutes: number;
91
+ architectures_tested: string[];
92
+ };
93
+ /**
94
+ * Load state from a persisted research context file.
95
+ */
96
+ loadState(state: ResearchState): void;
97
+ /**
98
+ * Export state for persistence.
99
+ */
100
+ exportState(): ResearchState;
101
+ }
102
+
103
+ export { AutoresearchGovernor, type AutoresearchGovernorConfig, type ExperimentProposal, type ExperimentResult, type ResearchState };
@@ -0,0 +1,7 @@
1
+ import {
2
+ AutoresearchGovernor
3
+ } from "../chunk-T5EUJQE5.js";
4
+ import "../chunk-YZFATT7X.js";
5
+ export {
6
+ AutoresearchGovernor
7
+ };
@@ -1,4 +1,4 @@
1
- import { G as GuardVerdict, a as GuardEvent, W as WorldDefinition } from '../guard-contract-D-2LQInm.cjs';
1
+ import { a as GuardVerdict, G as GuardEvent, W as WorldDefinition } from '../guard-contract-WZx__PmU.cjs';
2
2
 
3
3
  /**
4
4
  * NeuroVerse Adapter — Express / Fastify
@@ -1,4 +1,4 @@
1
- import { G as GuardVerdict, a as GuardEvent, W as WorldDefinition } from '../guard-contract-D-2LQInm.js';
1
+ import { a as GuardVerdict, G as GuardEvent, W as WorldDefinition } from '../guard-contract-WZx__PmU.js';
2
2
 
3
3
  /**
4
4
  * NeuroVerse Adapter — Express / Fastify
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  createGovernanceMiddleware,
3
3
  createGovernanceMiddlewareFromWorld
4
- } from "../chunk-ZL4AHY4X.js";
5
- import "../chunk-PQBJBVSW.js";
4
+ } from "../chunk-2NICNKOM.js";
5
+ import "../chunk-4JRYGIO7.js";
6
+ import "../chunk-4QXB6PEO.js";
6
7
  import "../chunk-JZPQGIKR.js";
7
- import "../chunk-P74Y66ZV.js";
8
8
  import "../chunk-YZFATT7X.js";
9
9
  export {
10
10
  createGovernanceMiddleware,
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/adapters/index.ts
31
31
  var adapters_exports = {};
32
32
  __export(adapters_exports, {
33
+ AutoresearchGovernor: () => AutoresearchGovernor,
33
34
  GovernedToolExecutor: () => GovernedToolExecutor,
34
35
  LangChainGovernanceBlockedError: () => GovernanceBlockedError,
35
36
  NeuroVerseCallbackHandler: () => NeuroVerseCallbackHandler,
@@ -154,13 +155,40 @@ function getPlanProgress(plan) {
154
155
  percentage: total > 0 ? Math.round(completed / total * 100) : 0
155
156
  };
156
157
  }
157
- function advancePlan(plan, stepId) {
158
- return {
158
+ function advancePlan(plan, stepId, evidence) {
159
+ const step = plan.steps.find((s) => s.id === stepId);
160
+ if (!step) {
161
+ return { success: false, reason: `Step "${stepId}" not found in plan.` };
162
+ }
163
+ if (step.status === "completed") {
164
+ return { success: false, reason: `Step "${stepId}" is already completed.` };
165
+ }
166
+ const mode = plan.completion ?? "trust";
167
+ if (mode === "verified" && step.verify) {
168
+ if (!evidence) {
169
+ return {
170
+ success: false,
171
+ reason: `Step "${step.label}" requires evidence (verify: ${step.verify}). Provide evidence to advance.`
172
+ };
173
+ }
174
+ if (evidence.type !== step.verify) {
175
+ return {
176
+ success: false,
177
+ reason: `Evidence type "${evidence.type}" does not match required verification "${step.verify}".`
178
+ };
179
+ }
180
+ }
181
+ const updatedPlan = {
159
182
  ...plan,
160
183
  steps: plan.steps.map(
161
184
  (s) => s.id === stepId ? { ...s, status: "completed" } : s
162
185
  )
163
186
  };
187
+ return {
188
+ success: true,
189
+ plan: updatedPlan,
190
+ evidence: evidence ?? void 0
191
+ };
164
192
  }
165
193
  function evaluatePlan(event, plan) {
166
194
  const progress = getPlanProgress(plan);
@@ -1108,8 +1136,11 @@ var NeuroVerseCallbackHandler = class {
1108
1136
  if (verdict.status === "ALLOW" && this.activePlan) {
1109
1137
  const planVerdict = evaluatePlan(event, this.activePlan);
1110
1138
  if (planVerdict.matchedStep) {
1111
- this.activePlan = advancePlan(this.activePlan, planVerdict.matchedStep);
1112
- this.engineOptions.plan = this.activePlan;
1139
+ const advResult = advancePlan(this.activePlan, planVerdict.matchedStep);
1140
+ if (advResult.success && advResult.plan) {
1141
+ this.activePlan = advResult.plan;
1142
+ this.engineOptions.plan = this.activePlan;
1143
+ }
1113
1144
  const progress = getPlanProgress(this.activePlan);
1114
1145
  this.options.onPlanProgress?.(progress);
1115
1146
  if (progress.completed === progress.total) {
@@ -1187,8 +1218,11 @@ var GovernedToolExecutor = class {
1187
1218
  if (verdict.status === "ALLOW" && this.activePlan) {
1188
1219
  const planVerdict = evaluatePlan(event, this.activePlan);
1189
1220
  if (planVerdict.matchedStep) {
1190
- this.activePlan = advancePlan(this.activePlan, planVerdict.matchedStep);
1191
- this.engineOptions.plan = this.activePlan;
1221
+ const advResult = advancePlan(this.activePlan, planVerdict.matchedStep);
1222
+ if (advResult.success && advResult.plan) {
1223
+ this.activePlan = advResult.plan;
1224
+ this.engineOptions.plan = this.activePlan;
1225
+ }
1192
1226
  const progress = getPlanProgress(this.activePlan);
1193
1227
  this.options.onPlanProgress?.(progress);
1194
1228
  if (progress.completed === progress.total) {
@@ -1305,8 +1339,11 @@ var NeuroVersePlugin = class {
1305
1339
  if (verdict.status === "ALLOW" && this.activePlan) {
1306
1340
  const planVerdict = evaluatePlan(event, this.activePlan);
1307
1341
  if (planVerdict.matchedStep) {
1308
- this.activePlan = advancePlan(this.activePlan, planVerdict.matchedStep);
1309
- this.engineOptions.plan = this.activePlan;
1342
+ const advResult = advancePlan(this.activePlan, planVerdict.matchedStep);
1343
+ if (advResult.success && advResult.plan) {
1344
+ this.activePlan = advResult.plan;
1345
+ this.engineOptions.plan = this.activePlan;
1346
+ }
1310
1347
  const progress = getPlanProgress(this.activePlan);
1311
1348
  this.options.onPlanProgress?.(progress);
1312
1349
  if (progress.completed === progress.total) {
@@ -1443,8 +1480,178 @@ function createGovernanceMiddlewareFromWorld(world, options = {}) {
1443
1480
  }
1444
1481
  };
1445
1482
  }
1483
+
1484
+ // src/adapters/autoresearch.ts
1485
+ var AutoresearchGovernor = class {
1486
+ config;
1487
+ state;
1488
+ constructor(config) {
1489
+ this.config = config;
1490
+ this.state = {
1491
+ experiments_run: 0,
1492
+ best_result: null,
1493
+ architectures_tested: [],
1494
+ experiment_log: [],
1495
+ total_compute_minutes: 0,
1496
+ keep_count: 0
1497
+ };
1498
+ }
1499
+ /**
1500
+ * Convert an experiment proposal into a GuardEvent for governance evaluation.
1501
+ */
1502
+ proposalToGuardEvent(proposal) {
1503
+ return {
1504
+ intent: `run experiment: ${proposal.description}`,
1505
+ tool: "experiment_runner",
1506
+ scope: "experiment",
1507
+ roleId: "experiment_runner",
1508
+ direction: "output",
1509
+ actionCategory: "shell",
1510
+ args: {
1511
+ experiment_id: String(proposal.experiment_id),
1512
+ architecture: proposal.architecture,
1513
+ estimated_minutes: String(proposal.estimated_minutes || 5)
1514
+ }
1515
+ };
1516
+ }
1517
+ /**
1518
+ * Evaluate an experiment proposal against governance rules.
1519
+ * Returns a simplified verdict without requiring the full guard engine.
1520
+ */
1521
+ evaluateProposal(proposal) {
1522
+ const warnings = [];
1523
+ const estimatedMinutes = proposal.estimated_minutes || 5;
1524
+ if (this.state.total_compute_minutes + estimatedMinutes > this.config.computeBudgetMinutes) {
1525
+ return {
1526
+ allowed: false,
1527
+ reason: `Compute budget exhausted: ${this.state.total_compute_minutes}/${this.config.computeBudgetMinutes} minutes used`,
1528
+ warnings
1529
+ };
1530
+ }
1531
+ if (this.config.constraints) {
1532
+ for (const constraint of this.config.constraints) {
1533
+ const lower = constraint.toLowerCase();
1534
+ const archLower = proposal.architecture.toLowerCase();
1535
+ const descLower = proposal.description.toLowerCase();
1536
+ if (lower.startsWith("no ")) {
1537
+ const forbidden = lower.slice(3).trim();
1538
+ if (archLower.includes(forbidden) || descLower.includes(forbidden)) {
1539
+ return {
1540
+ allowed: false,
1541
+ reason: `Architecture constraint violated: ${constraint}`,
1542
+ warnings
1543
+ };
1544
+ }
1545
+ }
1546
+ }
1547
+ }
1548
+ const failureCount = this.state.experiment_log.filter((e) => !e.success).length;
1549
+ if (failureCount > 5) {
1550
+ warnings.push(`High failure rate: ${failureCount} failed experiments. Consider investigating root cause.`);
1551
+ }
1552
+ const recentArchitectures = this.state.experiment_log.slice(-5).map((e) => e.architecture);
1553
+ const uniqueRecent = new Set(recentArchitectures).size;
1554
+ if (recentArchitectures.length >= 5 && uniqueRecent === 1) {
1555
+ warnings.push("Research may be stuck: last 5 experiments used the same architecture.");
1556
+ }
1557
+ return { allowed: true, reason: "Experiment approved", warnings };
1558
+ }
1559
+ /**
1560
+ * Record an experiment result and update research state.
1561
+ */
1562
+ recordResult(result) {
1563
+ this.state.experiments_run++;
1564
+ this.state.total_compute_minutes += result.wall_clock_minutes;
1565
+ this.state.experiment_log.push(result);
1566
+ if (!this.state.architectures_tested.includes(result.architecture)) {
1567
+ this.state.architectures_tested.push(result.architecture);
1568
+ }
1569
+ if (!result.success) {
1570
+ return { kept: false, improvement: null, state: { ...this.state } };
1571
+ }
1572
+ let kept = false;
1573
+ let improvement = null;
1574
+ if (this.state.best_result === null) {
1575
+ kept = true;
1576
+ this.state.best_result = result;
1577
+ this.state.keep_count++;
1578
+ } else {
1579
+ const prev = this.state.best_result.metric_value;
1580
+ const curr = result.metric_value;
1581
+ if (this.config.optimize === "minimize") {
1582
+ kept = curr < prev;
1583
+ improvement = kept ? prev - curr : null;
1584
+ } else {
1585
+ kept = curr > prev;
1586
+ improvement = kept ? curr - prev : null;
1587
+ }
1588
+ if (kept) {
1589
+ this.state.best_result = result;
1590
+ this.state.keep_count++;
1591
+ }
1592
+ }
1593
+ return { kept, improvement, state: { ...this.state } };
1594
+ }
1595
+ /**
1596
+ * Export current state as a state snapshot compatible with the world file.
1597
+ */
1598
+ toWorldState() {
1599
+ const successfulExperiments = this.state.experiment_log.filter((e) => e.success);
1600
+ const failedCount = this.state.experiment_log.filter((e) => !e.success).length;
1601
+ const keepRate = this.state.experiments_run > 0 ? Math.round(this.state.keep_count / this.state.experiments_run * 100) : 0;
1602
+ let improvementRate = 0;
1603
+ if (successfulExperiments.length >= 2) {
1604
+ const recent = successfulExperiments.slice(-10);
1605
+ let improvements = 0;
1606
+ for (let i = 1; i < recent.length; i++) {
1607
+ const prev = recent[i - 1].metric_value;
1608
+ const curr = recent[i].metric_value;
1609
+ if (this.config.optimize === "minimize" ? curr < prev : curr > prev) {
1610
+ improvements++;
1611
+ }
1612
+ }
1613
+ improvementRate = Math.round(improvements / (recent.length - 1) * 100);
1614
+ }
1615
+ return {
1616
+ experiments_run: this.state.experiments_run,
1617
+ best_metric_value: this.state.best_result?.metric_value ?? (this.config.optimize === "minimize" ? 100 : -1e3),
1618
+ keep_rate: keepRate,
1619
+ compute_used_minutes: Math.round(this.state.total_compute_minutes),
1620
+ compute_budget_minutes: this.config.computeBudgetMinutes,
1621
+ failed_experiments: failedCount,
1622
+ metric_improvement_rate: improvementRate,
1623
+ research_context_drift: 0
1624
+ // would need NLP to compute properly
1625
+ };
1626
+ }
1627
+ /**
1628
+ * Get a summary of the current research state.
1629
+ */
1630
+ getSummary() {
1631
+ return {
1632
+ experiments_run: this.state.experiments_run,
1633
+ best_result: this.state.best_result,
1634
+ keep_rate: this.state.experiments_run > 0 ? Math.round(this.state.keep_count / this.state.experiments_run * 100) : 0,
1635
+ compute_remaining_minutes: this.config.computeBudgetMinutes - this.state.total_compute_minutes,
1636
+ architectures_tested: [...this.state.architectures_tested]
1637
+ };
1638
+ }
1639
+ /**
1640
+ * Load state from a persisted research context file.
1641
+ */
1642
+ loadState(state) {
1643
+ this.state = { ...state };
1644
+ }
1645
+ /**
1646
+ * Export state for persistence.
1647
+ */
1648
+ exportState() {
1649
+ return { ...this.state };
1650
+ }
1651
+ };
1446
1652
  // Annotate the CommonJS export names for ESM import in node:
1447
1653
  0 && (module.exports = {
1654
+ AutoresearchGovernor,
1448
1655
  GovernedToolExecutor,
1449
1656
  LangChainGovernanceBlockedError,
1450
1657
  NeuroVerseCallbackHandler,
@@ -2,4 +2,5 @@ export { GovernanceBlockedError as LangChainGovernanceBlockedError, NeuroVerseCa
2
2
  export { GovernedExecutorOptions, GovernedToolExecutor, GovernedToolResult, GovernanceBlockedError as OpenAIGovernanceBlockedError, OpenAIToolCall, createGovernedToolExecutor, createGovernedToolExecutorFromWorld } from './openai.cjs';
3
3
  export { AgentAction, HookResult, NeuroVersePlugin, NeuroVersePluginOptions, GovernanceBlockedError as OpenClawGovernanceBlockedError, createNeuroVersePlugin, createNeuroVersePluginFromWorld } from './openclaw.cjs';
4
4
  export { GovernanceMiddlewareOptions, GovernanceRequest, GovernanceResponse, createGovernanceMiddleware, createGovernanceMiddlewareFromWorld } from './express.cjs';
5
- import '../guard-contract-D-2LQInm.cjs';
5
+ export { AutoresearchGovernor, AutoresearchGovernorConfig, ExperimentProposal, ExperimentResult, ResearchState } from './autoresearch.cjs';
6
+ import '../guard-contract-WZx__PmU.cjs';
@@ -2,4 +2,5 @@ export { GovernanceBlockedError as LangChainGovernanceBlockedError, NeuroVerseCa
2
2
  export { GovernedExecutorOptions, GovernedToolExecutor, GovernedToolResult, GovernanceBlockedError as OpenAIGovernanceBlockedError, OpenAIToolCall, createGovernedToolExecutor, createGovernedToolExecutorFromWorld } from './openai.js';
3
3
  export { AgentAction, HookResult, NeuroVersePlugin, NeuroVersePluginOptions, GovernanceBlockedError as OpenClawGovernanceBlockedError, createNeuroVersePlugin, createNeuroVersePluginFromWorld } from './openclaw.js';
4
4
  export { GovernanceMiddlewareOptions, GovernanceRequest, GovernanceResponse, createGovernanceMiddleware, createGovernanceMiddlewareFromWorld } from './express.js';
5
- import '../guard-contract-D-2LQInm.js';
5
+ export { AutoresearchGovernor, AutoresearchGovernorConfig, ExperimentProposal, ExperimentResult, ResearchState } from './autoresearch.js';
6
+ import '../guard-contract-WZx__PmU.js';
@@ -1,30 +1,34 @@
1
+ import {
2
+ AutoresearchGovernor
3
+ } from "../chunk-T5EUJQE5.js";
1
4
  import {
2
5
  createGovernanceMiddleware,
3
6
  createGovernanceMiddlewareFromWorld
4
- } from "../chunk-ZL4AHY4X.js";
7
+ } from "../chunk-2NICNKOM.js";
5
8
  import {
6
9
  GovernanceBlockedError,
7
10
  NeuroVerseCallbackHandler,
8
11
  createNeuroVerseCallbackHandler,
9
12
  createNeuroVerseCallbackHandlerFromWorld
10
- } from "../chunk-IVPKFJX3.js";
13
+ } from "../chunk-COT5XS4V.js";
11
14
  import {
12
15
  GovernanceBlockedError as GovernanceBlockedError2,
13
16
  GovernedToolExecutor,
14
17
  createGovernedToolExecutor,
15
18
  createGovernedToolExecutorFromWorld
16
- } from "../chunk-TINSRYXQ.js";
19
+ } from "../chunk-ER62HNGF.js";
17
20
  import {
18
21
  GovernanceBlockedError as GovernanceBlockedError3,
19
22
  NeuroVersePlugin,
20
23
  createNeuroVersePlugin,
21
24
  createNeuroVersePluginFromWorld
22
- } from "../chunk-UPJNTSVM.js";
23
- import "../chunk-PQBJBVSW.js";
25
+ } from "../chunk-2PQU3VAN.js";
26
+ import "../chunk-4JRYGIO7.js";
27
+ import "../chunk-4QXB6PEO.js";
24
28
  import "../chunk-JZPQGIKR.js";
25
- import "../chunk-P74Y66ZV.js";
26
29
  import "../chunk-YZFATT7X.js";
27
30
  export {
31
+ AutoresearchGovernor,
28
32
  GovernedToolExecutor,
29
33
  GovernanceBlockedError as LangChainGovernanceBlockedError,
30
34
  NeuroVerseCallbackHandler,
@@ -144,13 +144,40 @@ function getPlanProgress(plan) {
144
144
  percentage: total > 0 ? Math.round(completed / total * 100) : 0
145
145
  };
146
146
  }
147
- function advancePlan(plan, stepId) {
148
- return {
147
+ function advancePlan(plan, stepId, evidence) {
148
+ const step = plan.steps.find((s) => s.id === stepId);
149
+ if (!step) {
150
+ return { success: false, reason: `Step "${stepId}" not found in plan.` };
151
+ }
152
+ if (step.status === "completed") {
153
+ return { success: false, reason: `Step "${stepId}" is already completed.` };
154
+ }
155
+ const mode = plan.completion ?? "trust";
156
+ if (mode === "verified" && step.verify) {
157
+ if (!evidence) {
158
+ return {
159
+ success: false,
160
+ reason: `Step "${step.label}" requires evidence (verify: ${step.verify}). Provide evidence to advance.`
161
+ };
162
+ }
163
+ if (evidence.type !== step.verify) {
164
+ return {
165
+ success: false,
166
+ reason: `Evidence type "${evidence.type}" does not match required verification "${step.verify}".`
167
+ };
168
+ }
169
+ }
170
+ const updatedPlan = {
149
171
  ...plan,
150
172
  steps: plan.steps.map(
151
173
  (s) => s.id === stepId ? { ...s, status: "completed" } : s
152
174
  )
153
175
  };
176
+ return {
177
+ success: true,
178
+ plan: updatedPlan,
179
+ evidence: evidence ?? void 0
180
+ };
154
181
  }
155
182
  function evaluatePlan(event, plan) {
156
183
  const progress = getPlanProgress(plan);
@@ -1098,8 +1125,11 @@ var NeuroVerseCallbackHandler = class {
1098
1125
  if (verdict.status === "ALLOW" && this.activePlan) {
1099
1126
  const planVerdict = evaluatePlan(event, this.activePlan);
1100
1127
  if (planVerdict.matchedStep) {
1101
- this.activePlan = advancePlan(this.activePlan, planVerdict.matchedStep);
1102
- this.engineOptions.plan = this.activePlan;
1128
+ const advResult = advancePlan(this.activePlan, planVerdict.matchedStep);
1129
+ if (advResult.success && advResult.plan) {
1130
+ this.activePlan = advResult.plan;
1131
+ this.engineOptions.plan = this.activePlan;
1132
+ }
1103
1133
  const progress = getPlanProgress(this.activePlan);
1104
1134
  this.options.onPlanProgress?.(progress);
1105
1135
  if (progress.completed === progress.total) {
@@ -1,4 +1,4 @@
1
- import { G as GuardVerdict, a as GuardEvent, W as WorldDefinition, P as PlanDefinition, b as PlanProgress } from '../guard-contract-D-2LQInm.cjs';
1
+ import { a as GuardVerdict, G as GuardEvent, W as WorldDefinition, P as PlanDefinition, b as PlanProgress } from '../guard-contract-WZx__PmU.cjs';
2
2
 
3
3
  /**
4
4
  * NeuroVerse Adapter — LangChain
@@ -1,4 +1,4 @@
1
- import { G as GuardVerdict, a as GuardEvent, W as WorldDefinition, P as PlanDefinition, b as PlanProgress } from '../guard-contract-D-2LQInm.js';
1
+ import { a as GuardVerdict, G as GuardEvent, W as WorldDefinition, P as PlanDefinition, b as PlanProgress } from '../guard-contract-WZx__PmU.js';
2
2
 
3
3
  /**
4
4
  * NeuroVerse Adapter — LangChain
@@ -3,10 +3,10 @@ import {
3
3
  NeuroVerseCallbackHandler,
4
4
  createNeuroVerseCallbackHandler,
5
5
  createNeuroVerseCallbackHandlerFromWorld
6
- } from "../chunk-IVPKFJX3.js";
7
- import "../chunk-PQBJBVSW.js";
6
+ } from "../chunk-COT5XS4V.js";
7
+ import "../chunk-4JRYGIO7.js";
8
+ import "../chunk-4QXB6PEO.js";
8
9
  import "../chunk-JZPQGIKR.js";
9
- import "../chunk-P74Y66ZV.js";
10
10
  import "../chunk-YZFATT7X.js";
11
11
  export {
12
12
  GovernanceBlockedError,