@neuroverseos/governance 0.3.4 → 0.4.1

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 (129) hide show
  1. package/README.md +280 -405
  2. package/dist/adapters/autoresearch.cjs +63 -9
  3. package/dist/adapters/autoresearch.d.cts +2 -1
  4. package/dist/adapters/autoresearch.d.ts +2 -1
  5. package/dist/adapters/autoresearch.js +3 -3
  6. package/dist/adapters/deep-agents.cjs +63 -9
  7. package/dist/adapters/deep-agents.d.cts +3 -2
  8. package/dist/adapters/deep-agents.d.ts +3 -2
  9. package/dist/adapters/deep-agents.js +3 -3
  10. package/dist/adapters/express.cjs +63 -9
  11. package/dist/adapters/express.d.cts +2 -1
  12. package/dist/adapters/express.d.ts +2 -1
  13. package/dist/adapters/express.js +3 -3
  14. package/dist/adapters/index.cjs +961 -9
  15. package/dist/adapters/index.d.cts +4 -2
  16. package/dist/adapters/index.d.ts +4 -2
  17. package/dist/adapters/index.js +54 -17
  18. package/dist/adapters/langchain.cjs +63 -9
  19. package/dist/adapters/langchain.d.cts +3 -2
  20. package/dist/adapters/langchain.d.ts +3 -2
  21. package/dist/adapters/langchain.js +3 -3
  22. package/dist/adapters/mentraos.cjs +2181 -0
  23. package/dist/adapters/mentraos.d.cts +319 -0
  24. package/dist/adapters/mentraos.d.ts +319 -0
  25. package/dist/adapters/mentraos.js +48 -0
  26. package/dist/adapters/openai.cjs +63 -9
  27. package/dist/adapters/openai.d.cts +3 -2
  28. package/dist/adapters/openai.d.ts +3 -2
  29. package/dist/adapters/openai.js +3 -3
  30. package/dist/adapters/openclaw.cjs +63 -9
  31. package/dist/adapters/openclaw.d.cts +3 -2
  32. package/dist/adapters/openclaw.d.ts +3 -2
  33. package/dist/adapters/openclaw.js +3 -3
  34. package/dist/{add-ROOZLU62.js → add-XSANI3FK.js} +1 -1
  35. package/dist/{behavioral-MJO34S6Q.js → behavioral-SLW7ALEK.js} +4 -4
  36. package/dist/{bootstrap-CQRZVOXK.js → bootstrap-2OW5ZLBL.js} +4 -4
  37. package/dist/bootstrap-contract-DcV6t-8M.d.cts +216 -0
  38. package/dist/bootstrap-contract-DcV6t-8M.d.ts +216 -0
  39. package/dist/browser.global.js +149 -5
  40. package/dist/{build-ZHPMX5AZ.js → build-EGBGZFIJ.js} +6 -6
  41. package/dist/{chunk-A7GKPPU7.js → chunk-2VAWP6FI.js} +1 -1
  42. package/dist/{chunk-3WQLXYTP.js → chunk-3AYKQHYI.js} +2 -2
  43. package/dist/{chunk-EMQDLDAF.js → chunk-3NZMMSOW.js} +80 -2
  44. package/dist/chunk-3S5AD4AB.js +421 -0
  45. package/dist/{chunk-VXHSMA3I.js → chunk-6CV4XG3J.js} +1 -1
  46. package/dist/{chunk-BNKJPUPQ.js → chunk-A7SHG75T.js} +2 -2
  47. package/dist/{chunk-U6U7EJZL.js → chunk-AV7XJJWK.js} +2 -2
  48. package/dist/{chunk-ZWI3NIXK.js → chunk-CYDMUJVZ.js} +54 -3
  49. package/dist/{chunk-F66BVUYB.js → chunk-DA5MHFRR.js} +3 -3
  50. package/dist/{chunk-YEKMVDWK.js → chunk-FHXXD2TI.js} +7 -7
  51. package/dist/{chunk-5TPFNWRU.js → chunk-FS2UUJJO.js} +3 -3
  52. package/dist/{chunk-4FLICVVA.js → chunk-FVOGUCB6.js} +2 -2
  53. package/dist/chunk-GTPV2XGO.js +893 -0
  54. package/dist/{chunk-CTZHONLA.js → chunk-I4RTIMLX.js} +2 -2
  55. package/dist/{chunk-B6OXJLJ5.js → chunk-J2IZBHXJ.js} +4 -4
  56. package/dist/{chunk-TG6SEF24.js → chunk-OQU65525.js} +1 -1
  57. package/dist/{chunk-QXBFT7NI.js → chunk-QMVQ6KPL.js} +2 -2
  58. package/dist/{chunk-G7DJ6VOD.js → chunk-RDA7ISWC.js} +2 -2
  59. package/dist/{chunk-O5ABKEA7.js → chunk-YJ34R5NB.js} +2 -2
  60. package/dist/{chunk-PVTQQS3Y.js → chunk-YPCVY4GS.js} +31 -0
  61. package/dist/{chunk-W7LLXRGY.js → chunk-ZAF6JH23.js} +65 -10
  62. package/dist/{chunk-IS4WUH6Y.js → chunk-ZEIT2QLM.js} +4 -4
  63. package/dist/cli/neuroverse.cjs +4436 -1035
  64. package/dist/cli/neuroverse.js +40 -24
  65. package/dist/cli/plan.cjs +176 -12
  66. package/dist/cli/plan.js +2 -2
  67. package/dist/cli/run.cjs +63 -9
  68. package/dist/cli/run.js +2 -2
  69. package/dist/configure-world-XU2COHOZ.js +705 -0
  70. package/dist/{decision-flow-M63D47LO.js → decision-flow-3K4D72G4.js} +2 -2
  71. package/dist/{demo-G43RLCPK.js → demo-6OQYWRR6.js} +4 -4
  72. package/dist/{derive-LMDUTXDD.js → derive-7Y7YWVLU.js} +5 -5
  73. package/dist/{doctor-6BC6X2VO.js → doctor-NHXI7OQW.js} +3 -1
  74. package/dist/engine/bootstrap-emitter.cjs +241 -0
  75. package/dist/engine/bootstrap-emitter.d.cts +27 -0
  76. package/dist/engine/bootstrap-emitter.d.ts +27 -0
  77. package/dist/{bootstrap-emitter-Q7UIJZ2O.js → engine/bootstrap-emitter.js} +2 -2
  78. package/dist/engine/bootstrap-parser.cjs +560 -0
  79. package/dist/engine/bootstrap-parser.d.cts +96 -0
  80. package/dist/engine/bootstrap-parser.d.ts +96 -0
  81. package/dist/{bootstrap-parser-EEF36XDU.js → engine/bootstrap-parser.js} +2 -2
  82. package/dist/engine/guard-engine.cjs +1116 -0
  83. package/dist/engine/guard-engine.d.cts +60 -0
  84. package/dist/engine/guard-engine.d.ts +60 -0
  85. package/dist/engine/guard-engine.js +12 -0
  86. package/dist/engine/simulate-engine.cjs +390 -0
  87. package/dist/engine/simulate-engine.d.cts +105 -0
  88. package/dist/engine/simulate-engine.d.ts +105 -0
  89. package/dist/engine/simulate-engine.js +9 -0
  90. package/dist/{equity-penalties-SG5IZQ7I.js → equity-penalties-NVBAB5WL.js} +4 -4
  91. package/dist/{explain-RHBU2GBR.js → explain-HDFN4ION.js} +1 -1
  92. package/dist/github-TIKTWOGU.js +27 -0
  93. package/dist/{guard-AEEJNWLD.js → guard-6KSCWT2W.js} +4 -4
  94. package/dist/{guard-contract-B7lplwm9.d.cts → guard-contract-C991HDZp.d.cts} +32 -309
  95. package/dist/{guard-contract-B7lplwm9.d.ts → guard-contract-hHjTTjtR.d.ts} +32 -309
  96. package/dist/{impact-3XVDSCBU.js → impact-WIAM66IH.js} +3 -3
  97. package/dist/{improve-TQP4ECSY.js → improve-2PWGGO5B.js} +3 -3
  98. package/dist/index.cjs +682 -14
  99. package/dist/index.d.cts +231 -423
  100. package/dist/index.d.ts +231 -423
  101. package/dist/index.js +81 -58
  102. package/dist/{init-FYPV4SST.js → init-TKIJDR7I.js} +5 -1
  103. package/dist/lens-MHMUDCMQ.js +1084 -0
  104. package/dist/{mcp-server-5Y3ZM7TV.js → mcp-server-TNIWZ7B5.js} +3 -3
  105. package/dist/{playground-VZBNPPBO.js → playground-3FLDGBET.js} +3 -3
  106. package/dist/{redteam-MZPZD3EF.js → redteam-HV6LMKEH.js} +3 -3
  107. package/dist/{session-JYOARW54.js → session-XZP2754M.js} +3 -3
  108. package/dist/{shared-C_zpdvBm.d.cts → shared-DGnn1jiS.d.cts} +1 -1
  109. package/dist/{shared-Cf7yxx4-.d.ts → shared-U405h52W.d.ts} +1 -1
  110. package/dist/{simulate-LJXYBC6M.js → simulate-VT437EEL.js} +17 -4
  111. package/dist/spatial/index.cjs +682 -0
  112. package/dist/spatial/index.d.cts +517 -0
  113. package/dist/spatial/index.d.ts +517 -0
  114. package/dist/spatial/index.js +633 -0
  115. package/dist/{test-BOOR4A5F.js → test-4WTX6RKQ.js} +3 -3
  116. package/dist/{trace-PKV4KX56.js → trace-2YDNAXMK.js} +2 -2
  117. package/dist/types.cjs +18 -0
  118. package/dist/types.d.cts +370 -0
  119. package/dist/types.d.ts +370 -0
  120. package/dist/types.js +0 -0
  121. package/dist/{validate-RALX7CZS.js → validate-M52DX22Y.js} +1 -1
  122. package/dist/{world-BIP4GZBZ.js → world-O4HTQPDP.js} +1 -1
  123. package/dist/{world-loader-Y6HMQH2D.js → world-loader-YTYFOP7D.js} +1 -1
  124. package/dist/worlds/mentraos-smartglasses.nv-world.md +423 -0
  125. package/dist/worlds/mentraos-spatial.nv-world.md +68 -0
  126. package/dist/worlds/user-rules.nv-world.md +328 -0
  127. package/package.json +46 -3
  128. package/dist/guard-engine-PNR6MHCM.js +0 -10
  129. package/dist/{configure-ai-5MP5DWTT.js → configure-ai-LL3VAPQW.js} +3 -3
package/dist/index.d.cts CHANGED
@@ -1,48 +1,13 @@
1
- import { G as GuardEvent, W as WorldDefinition, b as GuardEngineOptions, a as GuardVerdict, P as PlanDefinition, S as StepEvidence, A as AdvanceResult, d as PlanVerdict, e as PlanCheck, c as PlanProgress, f as AgentBehaviorState, g as GuardStatus, C as Consequence, R as Reward, h as Guard, I as Invariant, i as Rule, V as ViabilityStatus } from './guard-contract-B7lplwm9.cjs';
2
- export { E as EvaluationTrace, j as GUARD_EXIT_CODES, k as GuardCheck, l as GuardExitCode, m as IntentRecord, n as InvariantCheck, K as KernelRuleCheck, L as LevelCheck, o as PLAN_EXIT_CODES, p as PlanCompletionMode, q as PlanConstraint, r as PlanExitCode, s as PlanStatus, t as PlanStep, u as PrecedenceResolution, v as RoleCheck, w as SafetyCheck, x as VerdictEvidence } from './guard-contract-B7lplwm9.cjs';
3
-
4
- /**
5
- * Guard Engine Deterministic Governance Evaluator
6
- *
7
- * Pure function: (event, world, options) → verdict
8
- *
9
- * Evaluates a GuardEvent against a loaded WorldDefinition and produces
10
- * a GuardVerdict with evidence and optional evaluation trace.
11
- *
12
- * Evaluation chain (first-match-wins on BLOCK/PAUSE):
13
- * 1. Safety checks (prompt injection, scope escape) → PAUSE
14
- * 1.5 Plan enforcement (task scope) → BLOCK/PAUSE
15
- * 2. Role-specific rules (cannotDo, requiresApproval) → BLOCK/PAUSE
16
- * 3. Declarative guards (guards.json) → BLOCK/PAUSE/WARN
17
- * 4. Kernel rules (kernel.json forbidden patterns) → BLOCK
18
- * 5. Level constraints (basic/standard/strict) → PAUSE
19
- * 6. Default → ALLOW
20
- *
21
- * Invariant checks run unconditionally and are recorded in evidence
22
- * but do not produce verdicts — they measure world health.
23
- *
24
- * INVARIANTS:
25
- * - Deterministic: same event + same world → same verdict.
26
- * - Zero network calls. Zero LLM calls. Zero async.
27
- * - Every check is recorded in the trace, not just the decider.
28
- * - No hidden logic. Everything is in the world file or declared here.
29
- */
30
-
31
- declare function evaluateGuard(event: GuardEvent, world: WorldDefinition, options?: GuardEngineOptions): GuardVerdict;
32
- /**
33
- * Build a normalized allowlist key from a GuardEvent.
34
- *
35
- * Format: `tool::intent` (both lowercased, intent trimmed).
36
- * Tool defaults to '*' when absent.
37
- *
38
- * Callers use this to:
39
- * 1. Add keys to the allowlist set (on user "allow-always" decision)
40
- * 2. The engine uses it to check membership before evaluation
41
- *
42
- * The key is opaque — callers should always use this function
43
- * rather than constructing keys manually.
44
- */
45
- declare function eventToAllowlistKey(event: GuardEvent): string;
1
+ export { evaluateGuard, eventToAllowlistKey, verdictToEvent } from './engine/guard-engine.cjs';
2
+ import { b as GuardEngineOptions, a as GuardVerdict, G as GuardEvent, P as PlanDefinition, S as StepEvidence, A as AdvanceResult, e as PlanVerdict, f as PlanCheck, c as PlanProgress, g as AgentBehaviorState, d as GuardStatus, C as Consequence, R as Reward } from './guard-contract-C991HDZp.cjs';
3
+ export { E as EvaluationTrace, h as GUARD_EXIT_CODES, i as GuardCheck, j as GuardExitCode, I as IntentRecord, k as InvariantCheck, K as KernelRuleCheck, L as LevelCheck, l as PLAN_EXIT_CODES, m as PlanCompletionMode, n as PlanConstraint, o as PlanExitCode, p as PlanStatus, q as PlanStep, r as PrecedenceResolution, s as RoleCheck, t as SafetyCheck, V as VerdictEvidence } from './guard-contract-C991HDZp.cjs';
4
+ import { WorldDefinition, Guard, Invariant, Rule } from './types.cjs';
5
+ export { GovernanceEvent } from './types.cjs';
6
+ export { parseWorldMarkdown } from './engine/bootstrap-parser.cjs';
7
+ export { emitWorldDefinition } from './engine/bootstrap-emitter.cjs';
8
+ export { B as BOOTSTRAP_EXIT_CODES, b as BootstrapExitCode, c as BootstrapResult, a as ParseIssue, d as ParsedAssumptionProfile, e as ParsedEffect, f as ParsedFrontmatter, g as ParsedGate, h as ParsedInvariant, i as ParsedOutcome, j as ParsedRule, k as ParsedStateVariable, l as ParsedTrigger, P as ParsedWorld } from './bootstrap-contract-DcV6t-8M.cjs';
9
+ export { AppliedEffect, EventApplication, RuleEvaluation, SimulateOptions, SimulationResult, SimulationStep, renderSimulateText, simulateWorld } from './engine/simulate-engine.cjs';
10
+ import { G as GovernanceBlockedError } from './shared-DGnn1jiS.cjs';
46
11
 
47
12
  /**
48
13
  * Derive Contract — AI-Assisted World Synthesis Types
@@ -1414,300 +1379,6 @@ type ValidateExitCode = (typeof VALIDATE_EXIT_CODES)[keyof typeof VALIDATE_EXIT_
1414
1379
  */
1415
1380
  declare function validateWorld(world: WorldDefinition, mode?: ValidationMode): ValidateReport;
1416
1381
 
1417
- /**
1418
- * Bootstrap Contract — Markdown → WorldDefinition Compilation Types
1419
- *
1420
- * Defines the input/output contract for `neuroverse bootstrap`.
1421
- *
1422
- * Input: .nv-world.md file (structured markdown)
1423
- * Output: WorldDefinition (passed to validate, guard, or compileWorldToZip)
1424
- *
1425
- * The markdown format is:
1426
- * - YAML frontmatter for world identity and metadata
1427
- * - H1 sections for each block (Thesis, Invariants, State, etc.)
1428
- * - Structured sub-sections within each block
1429
- * - Deterministically parseable — no LLM, no heuristics
1430
- *
1431
- * Exit codes:
1432
- * 0 = SUCCESS (compiled cleanly)
1433
- * 1 = FAIL (parse errors, missing required sections)
1434
- * 3 = ERROR (file not found, invalid input)
1435
- */
1436
- type ParseSeverity = 'error' | 'warning' | 'info';
1437
- /**
1438
- * A single parse issue found during markdown compilation.
1439
- */
1440
- interface ParseIssue {
1441
- /** Line number in the source markdown (1-based) */
1442
- line: number;
1443
- /** Which section the issue was found in */
1444
- section: string;
1445
- /** Human-readable message */
1446
- message: string;
1447
- /** Severity */
1448
- severity: ParseSeverity;
1449
- }
1450
- /**
1451
- * The result of parsing a .nv-world.md file.
1452
- */
1453
- interface BootstrapResult {
1454
- /** Whether compilation succeeded (no errors) */
1455
- success: boolean;
1456
- /** Source file path */
1457
- sourcePath: string;
1458
- /** All parse issues */
1459
- issues: ParseIssue[];
1460
- /** Parsed sections (for debugging) */
1461
- parsedSections: string[];
1462
- /** Duration */
1463
- durationMs: number;
1464
- }
1465
- /**
1466
- * YAML frontmatter parsed from the markdown header.
1467
- */
1468
- interface ParsedFrontmatter {
1469
- world_id: string;
1470
- name: string;
1471
- version?: string;
1472
- runtime_mode?: string;
1473
- default_profile?: string;
1474
- alternative_profile?: string;
1475
- }
1476
- /**
1477
- * A parsed invariant from the Invariants section.
1478
- */
1479
- interface ParsedInvariant {
1480
- id: string;
1481
- label: string;
1482
- enforcement: string;
1483
- mutable: boolean;
1484
- line: number;
1485
- }
1486
- /**
1487
- * A parsed state variable from the State section.
1488
- */
1489
- interface ParsedStateVariable {
1490
- id: string;
1491
- type: 'number' | 'enum' | 'boolean';
1492
- default: string | number | boolean;
1493
- label: string;
1494
- description: string;
1495
- min?: number;
1496
- max?: number;
1497
- step?: number;
1498
- options?: string[];
1499
- line: number;
1500
- }
1501
- /**
1502
- * A parsed assumption profile from the Assumptions section.
1503
- */
1504
- interface ParsedAssumptionProfile {
1505
- id: string;
1506
- name: string;
1507
- description: string;
1508
- parameters: Record<string, string | number | boolean>;
1509
- line: number;
1510
- }
1511
- /**
1512
- * A parsed trigger from a rule.
1513
- */
1514
- interface ParsedTrigger {
1515
- field: string;
1516
- operator: string;
1517
- value: string | number | boolean;
1518
- source: 'state' | 'assumption';
1519
- }
1520
- /**
1521
- * A parsed effect from a rule.
1522
- */
1523
- interface ParsedEffect {
1524
- target: string;
1525
- operation: string;
1526
- value: number | boolean | string;
1527
- }
1528
- /**
1529
- * A parsed rule from the Rules section.
1530
- */
1531
- interface ParsedRule {
1532
- id: string;
1533
- label: string;
1534
- severity: string;
1535
- description?: string;
1536
- order: number;
1537
- triggers: ParsedTrigger[];
1538
- effects: ParsedEffect[];
1539
- collapse_check?: {
1540
- field: string;
1541
- operator: string;
1542
- value: number;
1543
- };
1544
- causal_translation?: {
1545
- trigger_text: string;
1546
- rule_text: string;
1547
- shift_text: string;
1548
- effect_text: string;
1549
- };
1550
- line: number;
1551
- }
1552
- /**
1553
- * A parsed gate from the Gates section.
1554
- */
1555
- interface ParsedGate {
1556
- status: string;
1557
- field: string;
1558
- operator: string;
1559
- value: number;
1560
- line: number;
1561
- }
1562
- /**
1563
- * A parsed outcome from the Outcomes section.
1564
- */
1565
- interface ParsedOutcome {
1566
- id: string;
1567
- type: string;
1568
- range?: [number, number];
1569
- display?: string;
1570
- label: string;
1571
- primary?: boolean;
1572
- assignment?: string;
1573
- line: number;
1574
- }
1575
- /**
1576
- * The full parsed intermediate representation.
1577
- */
1578
- interface ParsedWorld {
1579
- frontmatter: ParsedFrontmatter;
1580
- thesis: string;
1581
- invariants: ParsedInvariant[];
1582
- stateVariables: ParsedStateVariable[];
1583
- assumptions: ParsedAssumptionProfile[];
1584
- rules: ParsedRule[];
1585
- gates: ParsedGate[];
1586
- outcomes: ParsedOutcome[];
1587
- }
1588
- declare const BOOTSTRAP_EXIT_CODES: {
1589
- readonly SUCCESS: 0;
1590
- readonly FAIL: 1;
1591
- readonly ERROR: 3;
1592
- };
1593
- type BootstrapExitCode = (typeof BOOTSTRAP_EXIT_CODES)[keyof typeof BOOTSTRAP_EXIT_CODES];
1594
-
1595
- /**
1596
- * Bootstrap Parser — .nv-world.md → ParsedWorld
1597
- *
1598
- * Deterministic markdown parser for the NeuroVerse world authoring format.
1599
- * No LLM calls. No heuristics. Pattern matching on structured markdown.
1600
- *
1601
- * ## Markdown Format (.nv-world.md)
1602
- *
1603
- * ```markdown
1604
- * ---
1605
- * world_id: my-world
1606
- * name: My World
1607
- * version: 1.0.0
1608
- * default_profile: baseline
1609
- * alternative_profile: alternative
1610
- * ---
1611
- *
1612
- * # Thesis
1613
- * The structural claim this world tests...
1614
- *
1615
- * # Invariants
1616
- * - `invariant_id` — Label text (structural, immutable)
1617
- * - `another_id` — Another label (structural, immutable)
1618
- *
1619
- * # State
1620
- * ## variable_name
1621
- * - type: number
1622
- * - min: 0
1623
- * - max: 100
1624
- * - step: 5
1625
- * - default: 50
1626
- * - label: Human Label
1627
- * - description: What this variable represents
1628
- *
1629
- * ## another_variable
1630
- * - type: enum
1631
- * - options: option_a, option_b, option_c
1632
- * - default: option_a
1633
- * - label: Another Variable
1634
- * - description: Description here
1635
- *
1636
- * # Assumptions
1637
- * ## baseline
1638
- * - name: Baseline Scenario
1639
- * - description: The default conditions
1640
- * - param_key: param_value
1641
- *
1642
- * ## alternative
1643
- * - name: Alternative Scenario
1644
- * - description: What changes
1645
- * - param_key: different_value
1646
- *
1647
- * # Rules
1648
- * ## rule-001: Rule Label (structural)
1649
- * Description of what this rule does.
1650
- *
1651
- * When field == "value" [state] AND other_field > 50 [assumption]
1652
- * Then target *= 0.30, other_target = false
1653
- * Collapse: field < 0.03
1654
- *
1655
- * > trigger: Trigger text here
1656
- * > rule: Rule text here
1657
- * > shift: Shift text here
1658
- * > effect: Effect text here
1659
- *
1660
- * # Gates
1661
- * - THRIVING: effective_margin >= 40
1662
- * - STABLE: effective_margin >= 20
1663
- * - COMPRESSED: effective_margin >= 10
1664
- * - CRITICAL: effective_margin > 3
1665
- * - MODEL_COLLAPSES: effective_margin <= 3
1666
- *
1667
- * # Outcomes
1668
- * ## outcome_id
1669
- * - type: number
1670
- * - range: 0-100
1671
- * - display: percentage
1672
- * - label: Outcome Label
1673
- * - primary: true
1674
- * ```
1675
- */
1676
-
1677
- /**
1678
- * Parse a .nv-world.md string into a ParsedWorld.
1679
- *
1680
- * Returns the parsed world and a list of issues.
1681
- * Callers should check issues for severity === 'error' before proceeding.
1682
- */
1683
- declare function parseWorldMarkdown(markdown: string): {
1684
- world: ParsedWorld | null;
1685
- issues: ParseIssue[];
1686
- };
1687
-
1688
- /**
1689
- * Bootstrap Emitter — ParsedWorld → WorldDefinition
1690
- *
1691
- * Converts the intermediate representation from the parser
1692
- * into a proper WorldDefinition that the guard engine, validate engine,
1693
- * and compileWorldToZip() all consume.
1694
- *
1695
- * Fills in sensible defaults for optional fields.
1696
- * Reports issues when the parsed data can't cleanly map to the target type.
1697
- *
1698
- * Deterministic. Same parsed input → same WorldDefinition output.
1699
- */
1700
-
1701
- /**
1702
- * Convert a ParsedWorld into a WorldDefinition.
1703
- *
1704
- * Returns the world definition and any issues encountered during emission.
1705
- */
1706
- declare function emitWorldDefinition(parsed: ParsedWorld): {
1707
- world: WorldDefinition;
1708
- issues: ParseIssue[];
1709
- };
1710
-
1711
1382
  /**
1712
1383
  * Add Engine — Incremental Governance Authoring
1713
1384
  *
@@ -1957,89 +1628,6 @@ interface WorldStats {
1957
1628
  declare function explainWorld(world: WorldDefinition): ExplainOutput;
1958
1629
  declare function renderExplainText(output: ExplainOutput): string;
1959
1630
 
1960
- /**
1961
- * Simulate Engine — Deterministic State Evolution (Reference Simulator)
1962
- *
1963
- * Pure function: (world, options) → SimulationResult
1964
- *
1965
- * This is NeuroVerse's REFERENCE SIMULATOR — one way to model how a world
1966
- * evolves over time. It is NOT the governance engine.
1967
- *
1968
- * simulateWorld() ≠ evaluateGuard()
1969
- *
1970
- * evaluateGuard() — Runtime enforcement. Decides if an action is allowed.
1971
- * Includes safety layer, role checks, plan enforcement,
1972
- * kernel rules, level constraints. Use for governance.
1973
- *
1974
- * simulateWorld() — State evolution modeling. Evaluates rule triggers,
1975
- * applies effects, tracks viability over N steps.
1976
- * Use for scenario planning and what-if analysis.
1977
- *
1978
- * World files (.nv-world.md) are portable — they define rules, roles, and
1979
- * constraints that can be consumed by any simulator or governance engine.
1980
- * This simulator is a reference implementation, not the only interpreter.
1981
- *
1982
- * Supports:
1983
- * - Single-step evaluation (default)
1984
- * - Multi-step iteration (--steps N)
1985
- * - State overrides (start from non-default values)
1986
- * - Assumption profile selection
1987
- * - Collapse detection (early termination)
1988
- *
1989
- * INVARIANTS:
1990
- * - Deterministic: same world + same options → same result.
1991
- * - Zero network calls. Zero LLM calls. Zero async.
1992
- * - Every rule evaluation is recorded in the trace.
1993
- * - World definition is REQUIRED — no world, no simulation.
1994
- */
1995
-
1996
- interface SimulateOptions {
1997
- /** Number of simulation steps (default: 1) */
1998
- steps?: number;
1999
- /** State variable overrides (start values) */
2000
- stateOverrides?: Record<string, string | number | boolean>;
2001
- /** Assumption profile to use (default: world default) */
2002
- profile?: string;
2003
- }
2004
- interface SimulationResult {
2005
- worldId: string;
2006
- worldName: string;
2007
- profile: string;
2008
- initialState: Record<string, string | number | boolean>;
2009
- steps: SimulationStep[];
2010
- finalState: Record<string, string | number | boolean>;
2011
- finalViability: ViabilityStatus;
2012
- collapsed: boolean;
2013
- collapseStep?: number;
2014
- collapseRule?: string;
2015
- }
2016
- interface SimulationStep {
2017
- step: number;
2018
- rulesEvaluated: RuleEvaluation[];
2019
- rulesFired: number;
2020
- stateAfter: Record<string, string | number | boolean>;
2021
- viability: ViabilityStatus;
2022
- collapsed: boolean;
2023
- }
2024
- interface RuleEvaluation {
2025
- ruleId: string;
2026
- label: string;
2027
- triggered: boolean;
2028
- excluded: boolean;
2029
- effects: AppliedEffect[];
2030
- collapsed: boolean;
2031
- collapseField?: string;
2032
- }
2033
- interface AppliedEffect {
2034
- target: string;
2035
- operation: string;
2036
- value: number | boolean | string;
2037
- before: string | number | boolean;
2038
- after: string | number | boolean;
2039
- }
2040
- declare function simulateWorld(world: WorldDefinition, options?: SimulateOptions): SimulationResult;
2041
- declare function renderSimulateText(result: SimulationResult): string;
2042
-
2043
1631
  /**
2044
1632
  * Improve Engine — Actionable Suggestions from World Analysis
2045
1633
  *
@@ -2292,6 +1880,226 @@ declare function detectBehavioralPatterns(adaptations: Adaptation[], totalAgents
2292
1880
  */
2293
1881
  declare function generateAdaptationNarrative(patterns: BehavioralPattern[], context?: NetworkContext): string;
2294
1882
 
1883
+ /**
1884
+ * NeuroVerse Adapter — GitHub
1885
+ *
1886
+ * Governance middleware for GitHub-driven workflows. Evaluates GitHub events
1887
+ * (PRs, issues, comments, pushes, releases, workflow runs) against world rules
1888
+ * before allowing actions to proceed.
1889
+ *
1890
+ * Two modes:
1891
+ * 1. Webhook mode — receives GitHub webhook payloads, evaluates, returns verdict
1892
+ * 2. Action mode — wraps Octokit/GitHub API calls with governance checks
1893
+ *
1894
+ * Usage (Webhook):
1895
+ * import { createGitHubWebhookHandler } from 'neuroverse-governance/adapters/github';
1896
+ *
1897
+ * const handler = await createGitHubWebhookHandler('./world/');
1898
+ * app.post('/webhook', async (req, res) => {
1899
+ * const verdict = handler.evaluate(req.headers['x-github-event'], req.body);
1900
+ * if (verdict.status === 'BLOCK') return res.status(403).json({ blocked: true });
1901
+ * // proceed with webhook processing...
1902
+ * });
1903
+ *
1904
+ * Usage (Action):
1905
+ * import { createGitHubGovernor } from 'neuroverse-governance/adapters/github';
1906
+ *
1907
+ * const gov = await createGitHubGovernor('./world/');
1908
+ *
1909
+ * // Before merging a PR:
1910
+ * const verdict = gov.evaluate({
1911
+ * action: 'merge_pull_request',
1912
+ * repository: 'myorg/myrepo',
1913
+ * ref: 'refs/heads/main',
1914
+ * actor: 'dependabot[bot]',
1915
+ * metadata: { pr_number: 42, labels: ['auto-merge'] },
1916
+ * });
1917
+ *
1918
+ * if (verdict.status === 'ALLOW') await octokit.pulls.merge(...);
1919
+ */
1920
+
1921
+ /** GitHub webhook event names the adapter understands. */
1922
+ type GitHubWebhookEvent = 'push' | 'pull_request' | 'pull_request_review' | 'issues' | 'issue_comment' | 'release' | 'workflow_run' | 'workflow_dispatch' | 'check_run' | 'check_suite' | 'deployment' | 'deployment_status' | 'create' | 'delete' | 'fork' | 'member' | 'repository' | 'status' | string;
1923
+ /** A structured GitHub action to evaluate against governance. */
1924
+ interface GitHubAction {
1925
+ /** What the actor wants to do (e.g., 'merge_pull_request', 'push_to_main', 'create_release'). */
1926
+ action: string;
1927
+ /** Full repository name (e.g., 'myorg/myrepo'). */
1928
+ repository: string;
1929
+ /** Git ref involved (e.g., 'refs/heads/main', 'refs/tags/v1.0.0'). */
1930
+ ref?: string;
1931
+ /** GitHub username or bot performing the action. */
1932
+ actor?: string;
1933
+ /** Branch being targeted (extracted from ref or PR base). */
1934
+ branch?: string;
1935
+ /** Additional context for guard evaluation. */
1936
+ metadata?: Record<string, unknown>;
1937
+ }
1938
+ /** Result of evaluating a GitHub action. */
1939
+ interface GitHubGovernanceResult {
1940
+ /** The guard verdict. */
1941
+ verdict: GuardVerdict;
1942
+ /** The GuardEvent that was evaluated (for audit/logging). */
1943
+ event: GuardEvent;
1944
+ /** The original action that triggered evaluation. */
1945
+ action: GitHubAction;
1946
+ }
1947
+ /** Result of evaluating a webhook payload. */
1948
+ interface WebhookGovernanceResult {
1949
+ /** The guard verdict. */
1950
+ verdict: GuardVerdict;
1951
+ /** The GuardEvent that was evaluated. */
1952
+ event: GuardEvent;
1953
+ /** The webhook event type. */
1954
+ webhookEvent: string;
1955
+ /** The webhook action (e.g., 'opened', 'closed', 'merged'). */
1956
+ webhookAction?: string;
1957
+ }
1958
+ interface GitHubGovernorOptions {
1959
+ /** Include full evaluation trace in verdicts. Default: false. */
1960
+ trace?: boolean;
1961
+ /** Enforcement level override. */
1962
+ level?: 'basic' | 'standard' | 'strict';
1963
+ /** Called for every evaluation (logging/audit hook). */
1964
+ onEvaluate?: (verdict: GuardVerdict, event: GuardEvent, action: GitHubAction) => void;
1965
+ /** Custom mapping from GitHubAction to GuardEvent. */
1966
+ mapAction?: (action: GitHubAction) => GuardEvent;
1967
+ /** Active plan overlay for task-scoped governance. */
1968
+ plan?: PlanDefinition;
1969
+ /** Called when plan progress changes. */
1970
+ onPlanProgress?: (progress: PlanProgress) => void;
1971
+ /** Called when all plan steps are completed. */
1972
+ onPlanComplete?: () => void;
1973
+ /** Protected branches that require strict governance. Default: ['main', 'master', 'production']. */
1974
+ protectedBranches?: string[];
1975
+ /** Actors (bots, users) with restricted permissions. */
1976
+ restrictedActors?: string[];
1977
+ }
1978
+ interface WebhookHandlerOptions extends GitHubGovernorOptions {
1979
+ /** Webhook secret for signature verification (HMAC-SHA256). */
1980
+ webhookSecret?: string;
1981
+ /** Custom mapping from webhook payload to GitHubAction. */
1982
+ mapWebhook?: (eventType: string, payload: Record<string, unknown>) => GitHubAction;
1983
+ }
1984
+ declare class GitHubGovernanceBlockedError extends GovernanceBlockedError {
1985
+ readonly action: GitHubAction;
1986
+ constructor(verdict: GuardVerdict, action: GitHubAction);
1987
+ }
1988
+ /**
1989
+ * Evaluates GitHub actions against a NeuroVerse world.
1990
+ * Use this when you're making GitHub API calls and want governance
1991
+ * to approve/block them before execution.
1992
+ */
1993
+ declare class GitHubGovernor {
1994
+ private world;
1995
+ private options;
1996
+ engineOptions: GuardEngineOptions;
1997
+ activePlan?: PlanDefinition;
1998
+ private protectedBranches;
1999
+ private restrictedActors;
2000
+ private mapFn;
2001
+ constructor(world: WorldDefinition, options?: GitHubGovernorOptions);
2002
+ /**
2003
+ * Evaluate a GitHub action against governance rules.
2004
+ * Returns a full result with verdict, event, and the original action.
2005
+ */
2006
+ evaluate(action: GitHubAction): GitHubGovernanceResult;
2007
+ /**
2008
+ * Evaluate and enforce — throws GitHubGovernanceBlockedError on BLOCK/PAUSE.
2009
+ * Use this as a gate before executing GitHub API calls.
2010
+ */
2011
+ enforce(action: GitHubAction): GitHubGovernanceResult;
2012
+ /**
2013
+ * Check if pushing to a branch is allowed.
2014
+ * Convenience method for the most common governance check.
2015
+ */
2016
+ canPush(repository: string, branch: string, actor?: string): GuardVerdict;
2017
+ /**
2018
+ * Check if merging a PR is allowed.
2019
+ */
2020
+ canMerge(repository: string, targetBranch: string, prNumber: number, actor?: string, labels?: string[]): GuardVerdict;
2021
+ /**
2022
+ * Check if creating a release is allowed.
2023
+ */
2024
+ canRelease(repository: string, tag: string, actor?: string, prerelease?: boolean): GuardVerdict;
2025
+ /**
2026
+ * Check if deploying to an environment is allowed.
2027
+ */
2028
+ canDeploy(repository: string, environment: string, ref?: string, actor?: string): GuardVerdict;
2029
+ }
2030
+ /**
2031
+ * Evaluates incoming GitHub webhook payloads against a NeuroVerse world.
2032
+ * Use this in your webhook endpoint to govern repository events.
2033
+ */
2034
+ declare class GitHubWebhookHandler {
2035
+ private governor;
2036
+ private mapWebhookFn;
2037
+ private webhookSecret?;
2038
+ constructor(world: WorldDefinition, options?: WebhookHandlerOptions);
2039
+ /**
2040
+ * Evaluate a webhook payload.
2041
+ *
2042
+ * @param eventType - The X-GitHub-Event header value
2043
+ * @param payload - The parsed webhook body
2044
+ */
2045
+ evaluate(eventType: string, payload: Record<string, unknown>): WebhookGovernanceResult;
2046
+ /**
2047
+ * Evaluate and enforce — throws on BLOCK/PAUSE.
2048
+ */
2049
+ enforce(eventType: string, payload: Record<string, unknown>): WebhookGovernanceResult;
2050
+ /** Access the underlying governor for direct action evaluation. */
2051
+ getGovernor(): GitHubGovernor;
2052
+ /** Get the configured webhook secret (for signature verification in your server). */
2053
+ getWebhookSecret(): string | undefined;
2054
+ }
2055
+ /**
2056
+ * Guard evaluation result formatted for GitHub Actions output.
2057
+ * Set step outputs and write to $GITHUB_OUTPUT.
2058
+ */
2059
+ interface ActionsOutput {
2060
+ /** 'allowed' or 'blocked' or 'paused' — for use in step conditions */
2061
+ governance_status: string;
2062
+ /** The full verdict status */
2063
+ verdict_status: string;
2064
+ /** Reason for block/pause (empty string if allowed) */
2065
+ reason: string;
2066
+ /** Matched rule ID (empty string if none) */
2067
+ rule_id: string;
2068
+ /** Formatted as GITHUB_OUTPUT lines */
2069
+ outputLines: string;
2070
+ }
2071
+ /**
2072
+ * Format a verdict for GitHub Actions step outputs.
2073
+ * Write the .outputLines to $GITHUB_OUTPUT in your action.
2074
+ *
2075
+ * Usage in a GitHub Action:
2076
+ * const result = governor.evaluate(action);
2077
+ * const output = formatForActions(result.verdict);
2078
+ * fs.appendFileSync(process.env.GITHUB_OUTPUT!, output.outputLines);
2079
+ */
2080
+ declare function formatForActions(verdict: GuardVerdict): ActionsOutput;
2081
+ /**
2082
+ * Create a PR comment body from a governance verdict.
2083
+ * Useful for posting governance status as a PR comment.
2084
+ */
2085
+ declare function formatPRComment(verdict: GuardVerdict, action: GitHubAction): string;
2086
+ /**
2087
+ * Create a GitHub Governor from a world path.
2088
+ */
2089
+ declare function createGitHubGovernor(worldPath: string, options?: GitHubGovernorOptions): Promise<GitHubGovernor>;
2090
+ /**
2091
+ * Create a GitHub Governor from a pre-loaded world.
2092
+ */
2093
+ declare function createGitHubGovernorFromWorld(world: WorldDefinition, options?: GitHubGovernorOptions): GitHubGovernor;
2094
+ /**
2095
+ * Create a GitHub Webhook Handler from a world path.
2096
+ */
2097
+ declare function createGitHubWebhookHandler(worldPath: string, options?: WebhookHandlerOptions): Promise<GitHubWebhookHandler>;
2098
+ /**
2099
+ * Create a GitHub Webhook Handler from a pre-loaded world.
2100
+ */
2101
+ declare function createGitHubWebhookHandlerFromWorld(world: WorldDefinition, options?: WebhookHandlerOptions): GitHubWebhookHandler;
2102
+
2295
2103
  /**
2296
2104
  * API Handlers — Server-side request handlers for the demo server.
2297
2105
  *
@@ -2347,4 +2155,4 @@ declare function handleCreateCapsule(body: {
2347
2155
  createdAt: string;
2348
2156
  };
2349
2157
 
2350
- export { type AIGuardOptions, type AIGuardVerdict, type AIProvider, type AIProviderConfig, type ActionCategory, type Adaptation, type AddGuardInput, type AddInvariantInput, type AddResult, type AddRuleInput, AdvanceResult, type AgentAction, AgentBehaviorState, type AppliedEffect, type AuditEvent, type AuditLogger, type AuditSummary, BOOTSTRAP_EXIT_CODES, type BehavioralPattern, type BootstrapExitCode, type BootstrapResult, CONFIGURE_AI_EXIT_CODES, type ChatMessage, type ClassifiedIntent, type CollectedSource, CompositeAuditLogger, type Condition, type ConditionOperator, type ConditionResult, Consequence, ConsoleAuditLogger, type ConstructType, type ContentFields, DERIVE_EXIT_CODES, type DecisionFlow, type DecisionFlowMetrics, type DeriveExitCode, type DeriveFinding, type DeriveResult, type ExplainOutput, FileAuditLogger, type FindingCategory, type FindingSeverity, type FlowPath, type FormatVerdictOptions, type GovernanceEngineOptions, type GovernanceHealth, type Governor, type GovernorConfig, GuardEngineOptions, GuardEvent, GuardStatus, GuardVerdict, type ImpactReport, type ImprovementReport, type IntentClassifierOptions, type IntentCluster, type IntentSource, McpGovernanceServer, type McpServerConfig, ModelAdapter, type ModelConfig, type ModelResponse, type NetworkContext, type NormalizationSummary, type OutcomeCluster, PROVIDERS, type ParseIssue, type ParsedAssumptionProfile, type ParsedEffect, type ParsedFrontmatter, type ParsedGate, type ParsedInvariant, type ParsedOutcome, type ParsedRule, type ParsedStateVariable, type ParsedTrigger, type ParsedWorld, PlanCheck, PlanDefinition, type PlanParseResult, PlanProgress, PlanVerdict, type PreventionCategory, type ProviderPreset, Reward, type RuleEvaluation, type RuleObstacle, type SessionConfig, SessionManager, type SessionState, type SimulateOptions, type SimulationResult, type SimulationStep, StepEvidence, type Suggestion, type SuggestionCategory, type SuggestionPriority, type ToolCall, type ToolDefinition, VALIDATE_EXIT_CODES, type ValidateExitCode, type ValidateFinding, type ValidateReport, type ValidateSummary, type ValidationMode, type WorldInfo, type WorldState, actionToGuardEvent, adaptationFromVerdict, addGuard, addInvariant, addRule, advancePlan, applyConsequence, applyReward, buildPlanCheck, classifyAdaptation, classifyIntent, classifyIntentWithAI, createAgentState, createGovernanceEngine, createGovernor, deriveWorld, describeActiveWorld, detectBehavioralPatterns, emitWorldDefinition, evaluateCondition, evaluateGuard, evaluateGuardWithAI, evaluatePlan, eventToAllowlistKey, explainWorld, extractContentFields, extractWorldMarkdown, formatVerdict, formatVerdictOneLine, generateAdaptationNarrative, generateDecisionFlow, generateImpactReport, generateImpactReportFromFile, getActiveWorldName, getPlanProgress, govern, handleCreateCapsule, handleHealthCheck, handleListPresets, handleReasonRequest, improveWorld, listWorlds, loadWorld, loadWorldFromDirectory, normalizeWorldMarkdown, parseGuardDescription, parsePlanMarkdown, parseWorldMarkdown, readAuditLog, renderDecisionFlow, renderExplainText, renderImpactReport, renderImproveText, renderSimulateText, resolveProvider, resolveWorldPath, runInteractiveMode, runPipeMode, setActiveWorld, simulateWorld, summarizeAuditEvents, tickAgentStates, validateWorld, verdictToAuditEvent, writeTempWorld };
2158
+ export { type AIGuardOptions, type AIGuardVerdict, type AIProvider, type AIProviderConfig, type ActionCategory, type ActionsOutput, type Adaptation, type AddGuardInput, type AddInvariantInput, type AddResult, type AddRuleInput, AdvanceResult, type AgentAction, AgentBehaviorState, type AuditEvent, type AuditLogger, type AuditSummary, type BehavioralPattern, CONFIGURE_AI_EXIT_CODES, type ChatMessage, type ClassifiedIntent, type CollectedSource, CompositeAuditLogger, type Condition, type ConditionOperator, type ConditionResult, Consequence, ConsoleAuditLogger, type ConstructType, type ContentFields, DERIVE_EXIT_CODES, type DecisionFlow, type DecisionFlowMetrics, type DeriveExitCode, type DeriveFinding, type DeriveResult, type ExplainOutput, FileAuditLogger, type FindingCategory, type FindingSeverity, type FlowPath, type FormatVerdictOptions, type GitHubAction, GitHubGovernanceBlockedError, type GitHubGovernanceResult, GitHubGovernor, type GitHubGovernorOptions, type GitHubWebhookEvent, GitHubWebhookHandler, type GovernanceEngineOptions, type GovernanceHealth, type Governor, type GovernorConfig, GuardEngineOptions, GuardEvent, GuardStatus, GuardVerdict, type ImpactReport, type ImprovementReport, type IntentClassifierOptions, type IntentCluster, type IntentSource, McpGovernanceServer, type McpServerConfig, ModelAdapter, type ModelConfig, type ModelResponse, type NetworkContext, type NormalizationSummary, type OutcomeCluster, PROVIDERS, PlanCheck, PlanDefinition, type PlanParseResult, PlanProgress, PlanVerdict, type PreventionCategory, type ProviderPreset, Reward, type RuleObstacle, type SessionConfig, SessionManager, type SessionState, StepEvidence, type Suggestion, type SuggestionCategory, type SuggestionPriority, type ToolCall, type ToolDefinition, VALIDATE_EXIT_CODES, type ValidateExitCode, type ValidateFinding, type ValidateReport, type ValidateSummary, type ValidationMode, type WebhookGovernanceResult, type WebhookHandlerOptions, type WorldInfo, type WorldState, actionToGuardEvent, adaptationFromVerdict, addGuard, addInvariant, addRule, advancePlan, applyConsequence, applyReward, buildPlanCheck, classifyAdaptation, classifyIntent, classifyIntentWithAI, createAgentState, createGitHubGovernor, createGitHubGovernorFromWorld, createGitHubWebhookHandler, createGitHubWebhookHandlerFromWorld, createGovernanceEngine, createGovernor, deriveWorld, describeActiveWorld, detectBehavioralPatterns, evaluateCondition, evaluateGuardWithAI, evaluatePlan, explainWorld, extractContentFields, extractWorldMarkdown, formatForActions, formatPRComment, formatVerdict, formatVerdictOneLine, generateAdaptationNarrative, generateDecisionFlow, generateImpactReport, generateImpactReportFromFile, getActiveWorldName, getPlanProgress, govern, handleCreateCapsule, handleHealthCheck, handleListPresets, handleReasonRequest, improveWorld, listWorlds, loadWorld, loadWorldFromDirectory, normalizeWorldMarkdown, parseGuardDescription, parsePlanMarkdown, readAuditLog, renderDecisionFlow, renderExplainText, renderImpactReport, renderImproveText, resolveProvider, resolveWorldPath, runInteractiveMode, runPipeMode, setActiveWorld, summarizeAuditEvents, tickAgentStates, validateWorld, verdictToAuditEvent, writeTempWorld };