@neuroverseos/governance 0.4.0 → 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 (105) hide show
  1. package/dist/adapters/autoresearch.d.cts +2 -1
  2. package/dist/adapters/autoresearch.d.ts +2 -1
  3. package/dist/adapters/autoresearch.js +2 -2
  4. package/dist/adapters/deep-agents.d.cts +3 -2
  5. package/dist/adapters/deep-agents.d.ts +3 -2
  6. package/dist/adapters/deep-agents.js +2 -2
  7. package/dist/adapters/express.d.cts +2 -1
  8. package/dist/adapters/express.d.ts +2 -1
  9. package/dist/adapters/express.js +2 -2
  10. package/dist/adapters/index.cjs +66 -1
  11. package/dist/adapters/index.d.cts +4 -278
  12. package/dist/adapters/index.d.ts +4 -278
  13. package/dist/adapters/index.js +33 -33
  14. package/dist/adapters/langchain.d.cts +3 -2
  15. package/dist/adapters/langchain.d.ts +3 -2
  16. package/dist/adapters/langchain.js +2 -2
  17. package/dist/adapters/mentraos.cjs +2181 -0
  18. package/dist/adapters/mentraos.d.cts +319 -0
  19. package/dist/adapters/mentraos.d.ts +319 -0
  20. package/dist/{mentraos-YFS7FMJH.js → adapters/mentraos.js} +6 -6
  21. package/dist/adapters/openai.d.cts +3 -2
  22. package/dist/adapters/openai.d.ts +3 -2
  23. package/dist/adapters/openai.js +2 -2
  24. package/dist/adapters/openclaw.d.cts +3 -2
  25. package/dist/adapters/openclaw.d.ts +3 -2
  26. package/dist/adapters/openclaw.js +2 -2
  27. package/dist/{add-LYHDZ5RL.js → add-XSANI3FK.js} +1 -1
  28. package/dist/bootstrap-contract-DcV6t-8M.d.cts +216 -0
  29. package/dist/bootstrap-contract-DcV6t-8M.d.ts +216 -0
  30. package/dist/{build-THUEYMVT.js → build-EGBGZFIJ.js} +5 -5
  31. package/dist/{chunk-MFKHTE5R.js → chunk-3AYKQHYI.js} +1 -1
  32. package/dist/chunk-3S5AD4AB.js +421 -0
  33. package/dist/{chunk-V4FZHJQX.js → chunk-A7SHG75T.js} +1 -1
  34. package/dist/{chunk-JKGPSFGH.js → chunk-AV7XJJWK.js} +1 -1
  35. package/dist/{chunk-Y6WXAPKY.js → chunk-DA5MHFRR.js} +1 -1
  36. package/dist/{chunk-7D7PZLB7.js → chunk-FS2UUJJO.js} +3 -3
  37. package/dist/{chunk-TD5GKIHP.js → chunk-FVOGUCB6.js} +1 -1
  38. package/dist/{chunk-APU4OZIP.js → chunk-GTPV2XGO.js} +67 -2
  39. package/dist/{chunk-BXLTEUS4.js → chunk-I4RTIMLX.js} +2 -2
  40. package/dist/{chunk-5JUZ4HL7.js → chunk-J2IZBHXJ.js} +3 -3
  41. package/dist/{chunk-YNYCQECH.js → chunk-QMVQ6KPL.js} +1 -1
  42. package/dist/{chunk-25XHSTPT.js → chunk-RDA7ISWC.js} +1 -1
  43. package/dist/{chunk-DWHUZUEY.js → chunk-YJ34R5NB.js} +1 -1
  44. package/dist/{chunk-UTH7OXTM.js → chunk-ZEIT2QLM.js} +3 -3
  45. package/dist/cli/neuroverse.cjs +580 -28
  46. package/dist/cli/neuroverse.js +21 -21
  47. package/dist/cli/plan.js +2 -2
  48. package/dist/cli/run.js +2 -2
  49. package/dist/{demo-66MMJTEH.js → demo-6OQYWRR6.js} +3 -3
  50. package/dist/{derive-5LOMN7GO.js → derive-7Y7YWVLU.js} +4 -4
  51. package/dist/{doctor-WIO4FLA3.js → doctor-NHXI7OQW.js} +3 -2
  52. package/dist/engine/bootstrap-emitter.cjs +241 -0
  53. package/dist/engine/bootstrap-emitter.d.cts +27 -0
  54. package/dist/engine/bootstrap-emitter.d.ts +27 -0
  55. package/dist/{bootstrap-emitter-GIMOJFOC.js → engine/bootstrap-emitter.js} +2 -2
  56. package/dist/engine/bootstrap-parser.cjs +560 -0
  57. package/dist/engine/bootstrap-parser.d.cts +96 -0
  58. package/dist/engine/bootstrap-parser.d.ts +96 -0
  59. package/dist/{bootstrap-parser-LBLGVEMU.js → engine/bootstrap-parser.js} +2 -2
  60. package/dist/engine/guard-engine.cjs +1116 -0
  61. package/dist/engine/guard-engine.d.cts +60 -0
  62. package/dist/engine/guard-engine.d.ts +60 -0
  63. package/dist/{guard-engine-N7TUIUU7.js → engine/guard-engine.js} +3 -3
  64. package/dist/engine/simulate-engine.cjs +390 -0
  65. package/dist/engine/simulate-engine.d.cts +105 -0
  66. package/dist/engine/simulate-engine.d.ts +105 -0
  67. package/dist/engine/simulate-engine.js +9 -0
  68. package/dist/{equity-penalties-WWC7UDQD.js → equity-penalties-NVBAB5WL.js} +2 -2
  69. package/dist/{explain-MUSGDT67.js → explain-HDFN4ION.js} +1 -1
  70. package/dist/github-TIKTWOGU.js +27 -0
  71. package/dist/{guard-W3BMQPBJ.js → guard-6KSCWT2W.js} +2 -2
  72. package/dist/{guard-contract-CLBbTGK_.d.cts → guard-contract-C991HDZp.d.cts} +2 -369
  73. package/dist/{guard-contract-CLBbTGK_.d.ts → guard-contract-hHjTTjtR.d.ts} +2 -369
  74. package/dist/{improve-PJDAWW4Q.js → improve-2PWGGO5B.js} +3 -3
  75. package/dist/index.cjs +452 -0
  76. package/dist/index.d.cts +231 -492
  77. package/dist/index.d.ts +231 -492
  78. package/dist/index.js +76 -55
  79. package/dist/{lens-IP6GIZ2Q.js → lens-MHMUDCMQ.js} +92 -25
  80. package/dist/{mcp-server-OG3PPVD2.js → mcp-server-TNIWZ7B5.js} +2 -2
  81. package/dist/{playground-4BK2XQ47.js → playground-3FLDGBET.js} +2 -2
  82. package/dist/{redteam-BRZALBPP.js → redteam-HV6LMKEH.js} +2 -2
  83. package/dist/{session-SGRUT2UH.js → session-XZP2754M.js} +2 -2
  84. package/dist/{shared-BGzmYP5g.d.cts → shared-DGnn1jiS.d.cts} +1 -1
  85. package/dist/{shared-CwGpPheR.d.ts → shared-U405h52W.d.ts} +1 -1
  86. package/dist/{simulate-FGXKIH7V.js → simulate-VT437EEL.js} +2 -2
  87. package/dist/spatial/index.cjs +682 -0
  88. package/dist/spatial/index.d.cts +517 -0
  89. package/dist/spatial/index.d.ts +517 -0
  90. package/dist/spatial/index.js +633 -0
  91. package/dist/{test-PT44BSYG.js → test-4WTX6RKQ.js} +2 -2
  92. package/dist/types.cjs +18 -0
  93. package/dist/types.d.cts +370 -0
  94. package/dist/types.d.ts +370 -0
  95. package/dist/types.js +0 -0
  96. package/dist/{validate-Q5O5TGLT.js → validate-M52DX22Y.js} +1 -1
  97. package/dist/{world-V52ZMH26.js → world-O4HTQPDP.js} +1 -1
  98. package/dist/{world-loader-C4D3VPP3.js → world-loader-YTYFOP7D.js} +1 -1
  99. package/dist/worlds/mentraos-spatial.nv-world.md +68 -0
  100. package/package.json +46 -3
  101. package/dist/{behavioral-SPWPGYXL.js → behavioral-SLW7ALEK.js} +3 -3
  102. package/dist/{bootstrap-IP5QMC3Q.js → bootstrap-2OW5ZLBL.js} +3 -3
  103. package/dist/{chunk-7QIAF377.js → chunk-CYDMUJVZ.js} +0 -0
  104. package/dist/{chunk-QZ666FCV.js → chunk-FHXXD2TI.js} +6 -6
  105. package/dist/{configure-ai-5MP5DWTT.js → configure-ai-LL3VAPQW.js} +3 -3
package/dist/index.d.cts CHANGED
@@ -1,61 +1,13 @@
1
- import { G as GuardEvent, W as WorldDefinition, b as GuardEngineOptions, a as GuardVerdict, d as GuardStatus, e as GovernanceEvent, P as PlanDefinition, S as StepEvidence, A as AdvanceResult, f as PlanVerdict, g as PlanCheck, c as PlanProgress, h as AgentBehaviorState, C as Consequence, R as Reward, i as Guard, I as Invariant, j as Rule, V as ViabilityStatus } from './guard-contract-CLBbTGK_.cjs';
2
- export { E as EvaluationTrace, k as GUARD_EXIT_CODES, l as GuardCheck, m as GuardExitCode, n as IntentRecord, o as InvariantCheck, K as KernelRuleCheck, L as LevelCheck, p as PLAN_EXIT_CODES, q as PlanCompletionMode, r as PlanConstraint, s as PlanExitCode, t as PlanStatus, u as PlanStep, v as PrecedenceResolution, w as RoleCheck, x as SafetyCheck, y as VerdictEvidence } from './guard-contract-CLBbTGK_.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;
46
- /**
47
- * Convert a guard verdict into a GovernanceEvent.
48
- *
49
- * The guard evaluation log IS the event stream.
50
- * No Kafka, no queues — just data flowing from Guard → Simulate.
51
- *
52
- * Mapping:
53
- * ALLOW → "action_allowed"
54
- * BLOCK → "action_blocked"
55
- * PAUSE → "action_paused"
56
- * + semantic type from intent when available
57
- */
58
- declare function verdictToEvent(status: GuardStatus, intent?: string): GovernanceEvent;
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';
59
11
 
60
12
  /**
61
13
  * Derive Contract — AI-Assisted World Synthesis Types
@@ -1427,337 +1379,6 @@ type ValidateExitCode = (typeof VALIDATE_EXIT_CODES)[keyof typeof VALIDATE_EXIT_
1427
1379
  */
1428
1380
  declare function validateWorld(world: WorldDefinition, mode?: ValidationMode): ValidateReport;
1429
1381
 
1430
- /**
1431
- * Bootstrap Contract — Markdown → WorldDefinition Compilation Types
1432
- *
1433
- * Defines the input/output contract for `neuroverse bootstrap`.
1434
- *
1435
- * Input: .nv-world.md file (structured markdown)
1436
- * Output: WorldDefinition (passed to validate, guard, or compileWorldToZip)
1437
- *
1438
- * The markdown format is:
1439
- * - YAML frontmatter for world identity and metadata
1440
- * - H1 sections for each block (Thesis, Invariants, State, etc.)
1441
- * - Structured sub-sections within each block
1442
- * - Deterministically parseable — no LLM, no heuristics
1443
- *
1444
- * Exit codes:
1445
- * 0 = SUCCESS (compiled cleanly)
1446
- * 1 = FAIL (parse errors, missing required sections)
1447
- * 3 = ERROR (file not found, invalid input)
1448
- */
1449
- type ParseSeverity = 'error' | 'warning' | 'info';
1450
- /**
1451
- * A single parse issue found during markdown compilation.
1452
- */
1453
- interface ParseIssue {
1454
- /** Line number in the source markdown (1-based) */
1455
- line: number;
1456
- /** Which section the issue was found in */
1457
- section: string;
1458
- /** Human-readable message */
1459
- message: string;
1460
- /** Severity */
1461
- severity: ParseSeverity;
1462
- }
1463
- /**
1464
- * The result of parsing a .nv-world.md file.
1465
- */
1466
- interface BootstrapResult {
1467
- /** Whether compilation succeeded (no errors) */
1468
- success: boolean;
1469
- /** Source file path */
1470
- sourcePath: string;
1471
- /** All parse issues */
1472
- issues: ParseIssue[];
1473
- /** Parsed sections (for debugging) */
1474
- parsedSections: string[];
1475
- /** Duration */
1476
- durationMs: number;
1477
- }
1478
- /**
1479
- * YAML frontmatter parsed from the markdown header.
1480
- */
1481
- interface ParsedFrontmatter {
1482
- world_id: string;
1483
- name: string;
1484
- version?: string;
1485
- runtime_mode?: string;
1486
- default_profile?: string;
1487
- alternative_profile?: string;
1488
- }
1489
- /**
1490
- * A parsed invariant from the Invariants section.
1491
- */
1492
- interface ParsedInvariant {
1493
- id: string;
1494
- label: string;
1495
- enforcement: string;
1496
- mutable: boolean;
1497
- line: number;
1498
- }
1499
- /**
1500
- * A parsed state variable from the State section.
1501
- */
1502
- interface ParsedStateVariable {
1503
- id: string;
1504
- type: 'number' | 'enum' | 'boolean';
1505
- default: string | number | boolean;
1506
- label: string;
1507
- description: string;
1508
- min?: number;
1509
- max?: number;
1510
- step?: number;
1511
- options?: string[];
1512
- line: number;
1513
- }
1514
- /**
1515
- * A parsed assumption profile from the Assumptions section.
1516
- */
1517
- interface ParsedAssumptionProfile {
1518
- id: string;
1519
- name: string;
1520
- description: string;
1521
- parameters: Record<string, string | number | boolean>;
1522
- line: number;
1523
- }
1524
- /**
1525
- * A parsed trigger from a rule.
1526
- */
1527
- interface ParsedTrigger {
1528
- field: string;
1529
- operator: string;
1530
- value: string | number | boolean;
1531
- source: 'state' | 'assumption';
1532
- }
1533
- /**
1534
- * A parsed effect from a rule.
1535
- */
1536
- interface ParsedEffect {
1537
- target: string;
1538
- operation: string;
1539
- value: number | boolean | string;
1540
- }
1541
- /**
1542
- * A parsed rule from the Rules section.
1543
- */
1544
- interface ParsedRule {
1545
- id: string;
1546
- label: string;
1547
- severity: string;
1548
- description?: string;
1549
- order: number;
1550
- triggers: ParsedTrigger[];
1551
- effects: ParsedEffect[];
1552
- collapse_check?: {
1553
- field: string;
1554
- operator: string;
1555
- value: number;
1556
- };
1557
- causal_translation?: {
1558
- trigger_text: string;
1559
- rule_text: string;
1560
- shift_text: string;
1561
- effect_text: string;
1562
- };
1563
- line: number;
1564
- }
1565
- /**
1566
- * A parsed gate from the Gates section.
1567
- */
1568
- interface ParsedGate {
1569
- status: string;
1570
- field: string;
1571
- operator: string;
1572
- value: number;
1573
- line: number;
1574
- }
1575
- /**
1576
- * A parsed outcome from the Outcomes section.
1577
- */
1578
- interface ParsedOutcome {
1579
- id: string;
1580
- type: string;
1581
- range?: [number, number];
1582
- display?: string;
1583
- label: string;
1584
- primary?: boolean;
1585
- assignment?: string;
1586
- line: number;
1587
- }
1588
- /**
1589
- * A parsed lens directive from the Lenses section.
1590
- */
1591
- interface ParsedLensDirective {
1592
- id: string;
1593
- scope: string;
1594
- instruction: string;
1595
- line: number;
1596
- }
1597
- /**
1598
- * A parsed lens from the Lenses section.
1599
- * Each lens is an H2 subsection with key-value properties and directives.
1600
- */
1601
- interface ParsedLens {
1602
- id: string;
1603
- name: string;
1604
- tagline: string;
1605
- description: string;
1606
- tags: string[];
1607
- /** Tone: formality, verbosity, emotion, confidence */
1608
- formality: string;
1609
- verbosity: string;
1610
- emotion: string;
1611
- confidence: string;
1612
- /** Which roles this lens is the default for */
1613
- defaultForRoles: string[];
1614
- /** Behavioral directives */
1615
- directives: ParsedLensDirective[];
1616
- /** Priority when stacking (higher = applied later) */
1617
- priority: number;
1618
- /** Whether it can be stacked with other lenses */
1619
- stackable: boolean;
1620
- line: number;
1621
- }
1622
- /**
1623
- * The full parsed intermediate representation.
1624
- */
1625
- interface ParsedWorld {
1626
- frontmatter: ParsedFrontmatter;
1627
- thesis: string;
1628
- invariants: ParsedInvariant[];
1629
- stateVariables: ParsedStateVariable[];
1630
- assumptions: ParsedAssumptionProfile[];
1631
- rules: ParsedRule[];
1632
- gates: ParsedGate[];
1633
- outcomes: ParsedOutcome[];
1634
- lenses: ParsedLens[];
1635
- lensPolicy?: 'locked' | 'role_default' | 'user_choice';
1636
- lensLockPin?: string;
1637
- }
1638
- declare const BOOTSTRAP_EXIT_CODES: {
1639
- readonly SUCCESS: 0;
1640
- readonly FAIL: 1;
1641
- readonly ERROR: 3;
1642
- };
1643
- type BootstrapExitCode = (typeof BOOTSTRAP_EXIT_CODES)[keyof typeof BOOTSTRAP_EXIT_CODES];
1644
-
1645
- /**
1646
- * Bootstrap Parser — .nv-world.md → ParsedWorld
1647
- *
1648
- * Deterministic markdown parser for the NeuroVerse world authoring format.
1649
- * No LLM calls. No heuristics. Pattern matching on structured markdown.
1650
- *
1651
- * ## Markdown Format (.nv-world.md)
1652
- *
1653
- * ```markdown
1654
- * ---
1655
- * world_id: my-world
1656
- * name: My World
1657
- * version: 1.0.0
1658
- * default_profile: baseline
1659
- * alternative_profile: alternative
1660
- * ---
1661
- *
1662
- * # Thesis
1663
- * The structural claim this world tests...
1664
- *
1665
- * # Invariants
1666
- * - `invariant_id` — Label text (structural, immutable)
1667
- * - `another_id` — Another label (structural, immutable)
1668
- *
1669
- * # State
1670
- * ## variable_name
1671
- * - type: number
1672
- * - min: 0
1673
- * - max: 100
1674
- * - step: 5
1675
- * - default: 50
1676
- * - label: Human Label
1677
- * - description: What this variable represents
1678
- *
1679
- * ## another_variable
1680
- * - type: enum
1681
- * - options: option_a, option_b, option_c
1682
- * - default: option_a
1683
- * - label: Another Variable
1684
- * - description: Description here
1685
- *
1686
- * # Assumptions
1687
- * ## baseline
1688
- * - name: Baseline Scenario
1689
- * - description: The default conditions
1690
- * - param_key: param_value
1691
- *
1692
- * ## alternative
1693
- * - name: Alternative Scenario
1694
- * - description: What changes
1695
- * - param_key: different_value
1696
- *
1697
- * # Rules
1698
- * ## rule-001: Rule Label (structural)
1699
- * Description of what this rule does.
1700
- *
1701
- * When field == "value" [state] AND other_field > 50 [assumption]
1702
- * Then target *= 0.30, other_target = false
1703
- * Collapse: field < 0.03
1704
- *
1705
- * > trigger: Trigger text here
1706
- * > rule: Rule text here
1707
- * > shift: Shift text here
1708
- * > effect: Effect text here
1709
- *
1710
- * # Gates
1711
- * - THRIVING: effective_margin >= 40
1712
- * - STABLE: effective_margin >= 20
1713
- * - COMPRESSED: effective_margin >= 10
1714
- * - CRITICAL: effective_margin > 3
1715
- * - MODEL_COLLAPSES: effective_margin <= 3
1716
- *
1717
- * # Outcomes
1718
- * ## outcome_id
1719
- * - type: number
1720
- * - range: 0-100
1721
- * - display: percentage
1722
- * - label: Outcome Label
1723
- * - primary: true
1724
- * ```
1725
- */
1726
-
1727
- /**
1728
- * Parse a .nv-world.md string into a ParsedWorld.
1729
- *
1730
- * Returns the parsed world and a list of issues.
1731
- * Callers should check issues for severity === 'error' before proceeding.
1732
- */
1733
- declare function parseWorldMarkdown(markdown: string): {
1734
- world: ParsedWorld | null;
1735
- issues: ParseIssue[];
1736
- };
1737
-
1738
- /**
1739
- * Bootstrap Emitter — ParsedWorld → WorldDefinition
1740
- *
1741
- * Converts the intermediate representation from the parser
1742
- * into a proper WorldDefinition that the guard engine, validate engine,
1743
- * and compileWorldToZip() all consume.
1744
- *
1745
- * Fills in sensible defaults for optional fields.
1746
- * Reports issues when the parsed data can't cleanly map to the target type.
1747
- *
1748
- * Deterministic. Same parsed input → same WorldDefinition output.
1749
- */
1750
-
1751
- /**
1752
- * Convert a ParsedWorld into a WorldDefinition.
1753
- *
1754
- * Returns the world definition and any issues encountered during emission.
1755
- */
1756
- declare function emitWorldDefinition(parsed: ParsedWorld): {
1757
- world: WorldDefinition;
1758
- issues: ParseIssue[];
1759
- };
1760
-
1761
1382
  /**
1762
1383
  * Add Engine — Incremental Governance Authoring
1763
1384
  *
@@ -2007,108 +1628,6 @@ interface WorldStats {
2007
1628
  declare function explainWorld(world: WorldDefinition): ExplainOutput;
2008
1629
  declare function renderExplainText(output: ExplainOutput): string;
2009
1630
 
2010
- /**
2011
- * Simulate Engine — Deterministic State Evolution (Reference Simulator)
2012
- *
2013
- * Pure function: (world, options) → SimulationResult
2014
- *
2015
- * This is NeuroVerse's REFERENCE SIMULATOR — one way to model how a world
2016
- * evolves over time. It is NOT the governance engine.
2017
- *
2018
- * simulateWorld() ≠ evaluateGuard()
2019
- *
2020
- * evaluateGuard() — Runtime enforcement. Decides if an action is allowed.
2021
- * Includes safety layer, role checks, plan enforcement,
2022
- * kernel rules, level constraints. Use for governance.
2023
- *
2024
- * simulateWorld() — State evolution modeling. Evaluates rule triggers,
2025
- * applies effects, tracks viability over N steps.
2026
- * Use for scenario planning and what-if analysis.
2027
- *
2028
- * World files (.nv-world.md) are portable — they define rules, roles, and
2029
- * constraints that can be consumed by any simulator or governance engine.
2030
- * This simulator is a reference implementation, not the only interpreter.
2031
- *
2032
- * Supports:
2033
- * - Single-step evaluation (default)
2034
- * - Multi-step iteration (--steps N)
2035
- * - State overrides (start from non-default values)
2036
- * - Assumption profile selection
2037
- * - Collapse detection (early termination)
2038
- *
2039
- * INVARIANTS:
2040
- * - Deterministic: same world + same options → same result.
2041
- * - Zero network calls. Zero LLM calls. Zero async.
2042
- * - Every rule evaluation is recorded in the trace.
2043
- * - World definition is REQUIRED — no world, no simulation.
2044
- */
2045
-
2046
- interface SimulateOptions {
2047
- /** Number of simulation steps (default: 1) */
2048
- steps?: number;
2049
- /** State variable overrides (start values) */
2050
- stateOverrides?: Record<string, string | number | boolean>;
2051
- /** Assumption profile to use (default: world default) */
2052
- profile?: string;
2053
- /**
2054
- * Governance events to inject into the simulation.
2055
- * Events are applied before state-driven rules each step.
2056
- * This is the bridge: Guard → Events → Simulate → State Evolution.
2057
- *
2058
- * Events are distributed across steps (round-robin) or all applied to step 1
2059
- * if there are fewer steps than events.
2060
- */
2061
- events?: GovernanceEvent[];
2062
- }
2063
- interface SimulationResult {
2064
- worldId: string;
2065
- worldName: string;
2066
- profile: string;
2067
- initialState: Record<string, string | number | boolean>;
2068
- steps: SimulationStep[];
2069
- finalState: Record<string, string | number | boolean>;
2070
- finalViability: ViabilityStatus;
2071
- collapsed: boolean;
2072
- collapseStep?: number;
2073
- collapseRule?: string;
2074
- /** Total events consumed during simulation */
2075
- eventsConsumed: number;
2076
- }
2077
- interface SimulationStep {
2078
- step: number;
2079
- /** Events applied during this step (before rules) */
2080
- eventsApplied: EventApplication[];
2081
- rulesEvaluated: RuleEvaluation[];
2082
- rulesFired: number;
2083
- stateAfter: Record<string, string | number | boolean>;
2084
- viability: ViabilityStatus;
2085
- collapsed: boolean;
2086
- }
2087
- /** Record of an event applied during simulation */
2088
- interface EventApplication {
2089
- eventType: string;
2090
- rulesTriggered: string[];
2091
- effects: AppliedEffect[];
2092
- }
2093
- interface RuleEvaluation {
2094
- ruleId: string;
2095
- label: string;
2096
- triggered: boolean;
2097
- excluded: boolean;
2098
- effects: AppliedEffect[];
2099
- collapsed: boolean;
2100
- collapseField?: string;
2101
- }
2102
- interface AppliedEffect {
2103
- target: string;
2104
- operation: string;
2105
- value: number | boolean | string;
2106
- before: string | number | boolean;
2107
- after: string | number | boolean;
2108
- }
2109
- declare function simulateWorld(world: WorldDefinition, options?: SimulateOptions): SimulationResult;
2110
- declare function renderSimulateText(result: SimulationResult): string;
2111
-
2112
1631
  /**
2113
1632
  * Improve Engine — Actionable Suggestions from World Analysis
2114
1633
  *
@@ -2361,6 +1880,226 @@ declare function detectBehavioralPatterns(adaptations: Adaptation[], totalAgents
2361
1880
  */
2362
1881
  declare function generateAdaptationNarrative(patterns: BehavioralPattern[], context?: NetworkContext): string;
2363
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
+
2364
2103
  /**
2365
2104
  * API Handlers — Server-side request handlers for the demo server.
2366
2105
  *
@@ -2416,4 +2155,4 @@ declare function handleCreateCapsule(body: {
2416
2155
  createdAt: string;
2417
2156
  };
2418
2157
 
2419
- 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 EventApplication, type ExplainOutput, FileAuditLogger, type FindingCategory, type FindingSeverity, type FlowPath, type FormatVerdictOptions, type GovernanceEngineOptions, GovernanceEvent, 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, verdictToEvent, 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 };