@neuroverseos/governance 0.10.0 → 0.12.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 (95) hide show
  1. package/dist/adapters/autoresearch.cjs +19 -1
  2. package/dist/adapters/autoresearch.d.cts +1 -1
  3. package/dist/adapters/autoresearch.d.ts +1 -1
  4. package/dist/adapters/autoresearch.js +2 -2
  5. package/dist/adapters/deep-agents.cjs +19 -1
  6. package/dist/adapters/deep-agents.d.cts +2 -2
  7. package/dist/adapters/deep-agents.d.ts +2 -2
  8. package/dist/adapters/deep-agents.js +2 -2
  9. package/dist/adapters/express.cjs +19 -1
  10. package/dist/adapters/express.d.cts +1 -1
  11. package/dist/adapters/express.d.ts +1 -1
  12. package/dist/adapters/express.js +2 -2
  13. package/dist/adapters/github.cjs +19 -1
  14. package/dist/adapters/github.d.cts +2 -2
  15. package/dist/adapters/github.d.ts +2 -2
  16. package/dist/adapters/github.js +2 -2
  17. package/dist/adapters/index.cjs +19 -1
  18. package/dist/adapters/index.d.cts +2 -2
  19. package/dist/adapters/index.d.ts +2 -2
  20. package/dist/adapters/index.js +8 -8
  21. package/dist/adapters/langchain.cjs +19 -1
  22. package/dist/adapters/langchain.d.cts +2 -2
  23. package/dist/adapters/langchain.d.ts +2 -2
  24. package/dist/adapters/langchain.js +2 -2
  25. package/dist/adapters/mentraos.cjs +19 -1
  26. package/dist/adapters/mentraos.d.cts +2 -2
  27. package/dist/adapters/mentraos.d.ts +2 -2
  28. package/dist/adapters/mentraos.js +2 -2
  29. package/dist/adapters/openai.cjs +19 -1
  30. package/dist/adapters/openai.d.cts +2 -2
  31. package/dist/adapters/openai.d.ts +2 -2
  32. package/dist/adapters/openai.js +2 -2
  33. package/dist/adapters/openclaw.cjs +19 -1
  34. package/dist/adapters/openclaw.d.cts +2 -2
  35. package/dist/adapters/openclaw.d.ts +2 -2
  36. package/dist/adapters/openclaw.js +2 -2
  37. package/dist/admin/index.cjs +19 -1
  38. package/dist/admin/index.js +1 -1
  39. package/dist/audit-JYNN3MOQ.js +98 -0
  40. package/dist/audit-behavior-C62FdRAC.d.cts +100 -0
  41. package/dist/audit-behavior-DFy7LeYv.d.ts +100 -0
  42. package/dist/{behavioral-SPWPGYXL.js → behavioral-4TKMHZQZ.js} +2 -2
  43. package/dist/{chunk-OQU65525.js → chunk-24YW7BHC.js} +1 -1
  44. package/dist/{chunk-BZYQHJDM.js → chunk-2KTPIE57.js} +25 -5
  45. package/dist/{chunk-TJ5L2UTE.js → chunk-5K3LATTM.js} +1 -1
  46. package/dist/{chunk-HDNDL6D5.js → chunk-5LDBYOSJ.js} +1 -1
  47. package/dist/{chunk-FDPPZLSQ.js → chunk-5ZWKM7MO.js} +1 -1
  48. package/dist/{chunk-B3IIPTY3.js → chunk-6MB6TMAG.js} +1 -1
  49. package/dist/{chunk-IOVXB6QN.js → chunk-GXTAHCND.js} +1 -1
  50. package/dist/{chunk-FKQCPRKI.js → chunk-MAOIHKFO.js} +1 -1
  51. package/dist/{chunk-ZAF6JH23.js → chunk-MBOW6YXN.js} +19 -1
  52. package/dist/{chunk-A2UZTLRV.js → chunk-MLXKSX3L.js} +1 -1
  53. package/dist/{chunk-7FL3U7Z5.js → chunk-MWGEXHOD.js} +1 -1
  54. package/dist/{chunk-6CV4XG3J.js → chunk-QFDFAWZ6.js} +1 -1
  55. package/dist/{chunk-2VAWP6FI.js → chunk-RAS62JXV.js} +1 -1
  56. package/dist/{chunk-OTZU76DH.js → chunk-XAF3CYCW.js} +1 -1
  57. package/dist/{chunk-T6GMRZWC.js → chunk-XTYQCTDD.js} +1 -1
  58. package/dist/{chunk-TIXVEPS2.js → chunk-YN7OI5ZV.js} +1 -1
  59. package/dist/cli/neuroverse.cjs +229 -93
  60. package/dist/cli/neuroverse.js +16 -12
  61. package/dist/cli/plan.cjs +18 -0
  62. package/dist/cli/radiant.cjs +42 -4
  63. package/dist/cli/radiant.js +3 -3
  64. package/dist/cli/run.cjs +18 -0
  65. package/dist/cli/run.js +4 -4
  66. package/dist/{decision-flow-IJPNMVQK.js → decision-flow-5VI5YG6A.js} +2 -2
  67. package/dist/{demo-6W3YXLAX.js → demo-GYX6CYHC.js} +2 -2
  68. package/dist/engine/guard-engine.cjs +19 -1
  69. package/dist/engine/guard-engine.d.cts +21 -1
  70. package/dist/engine/guard-engine.d.ts +21 -1
  71. package/dist/engine/guard-engine.js +1 -1
  72. package/dist/{equity-penalties-CCO3GVHS.js → equity-penalties-NOM46NEO.js} +2 -2
  73. package/dist/{guard-IHJEKHL2.js → guard-PQ3SYV4Y.js} +3 -3
  74. package/dist/{guard-contract-ddiIPlOg.d.cts → guard-contract-Oznf-Kgq.d.cts} +32 -0
  75. package/dist/{guard-contract-q6HJAq3Q.d.ts → guard-contract-w_i_6gh-.d.ts} +32 -0
  76. package/dist/{impact-WIAM66IH.js → impact-LDJLTVRU.js} +3 -3
  77. package/dist/index.cjs +62 -1
  78. package/dist/index.d.cts +4 -3
  79. package/dist/index.d.ts +4 -3
  80. package/dist/index.js +49 -8
  81. package/dist/{mcp-server-CKYBHXWK.js → mcp-server-W3MWSKD7.js} +2 -2
  82. package/dist/{playground-3TTBN7XD.js → playground-SSZRNUAF.js} +1 -1
  83. package/dist/radiant/index.cjs +450 -5
  84. package/dist/radiant/index.d.cts +151 -1
  85. package/dist/radiant/index.d.ts +151 -1
  86. package/dist/radiant/index.js +405 -2
  87. package/dist/{redteam-W644UMWN.js → redteam-KCULS7EW.js} +1 -1
  88. package/dist/{server-EI5JCIBU.js → server-EGRGGSM2.js} +2 -2
  89. package/dist/{session-FMAROEIE.js → session-PZLTL22G.js} +2 -2
  90. package/dist/{shared-PpalGKxc.d.cts → shared-BC8mOpt0.d.cts} +1 -1
  91. package/dist/{shared-DAzdfWtU.d.ts → shared-CP63gNNW.d.ts} +1 -1
  92. package/dist/{test-XDB2DH3L.js → test-LIHGWHBA.js} +1 -1
  93. package/dist/{trace-2YDNAXMK.js → trace-DC3D7XPD.js} +2 -2
  94. package/package.json +1 -1
  95. /package/dist/{doctor-XEMLO6UA.js → doctor-SIWQGTAO.js} +0 -0
@@ -97,27 +97,31 @@ async function main() {
97
97
  return validateMain(subArgs);
98
98
  }
99
99
  case "guard": {
100
- const { main: guardMain } = await import("../guard-IHJEKHL2.js");
100
+ const { main: guardMain } = await import("../guard-PQ3SYV4Y.js");
101
101
  return guardMain(subArgs);
102
102
  }
103
+ case "audit": {
104
+ const { main: auditMain } = await import("../audit-JYNN3MOQ.js");
105
+ return auditMain(subArgs);
106
+ }
103
107
  case "test": {
104
- const { main: testMain } = await import("../test-XDB2DH3L.js");
108
+ const { main: testMain } = await import("../test-LIHGWHBA.js");
105
109
  return testMain(subArgs);
106
110
  }
107
111
  case "redteam": {
108
- const { main: redteamMain } = await import("../redteam-W644UMWN.js");
112
+ const { main: redteamMain } = await import("../redteam-KCULS7EW.js");
109
113
  return redteamMain(subArgs);
110
114
  }
111
115
  case "demo": {
112
- const { main: demoMain } = await import("../demo-6W3YXLAX.js");
116
+ const { main: demoMain } = await import("../demo-GYX6CYHC.js");
113
117
  return demoMain(subArgs);
114
118
  }
115
119
  case "doctor": {
116
- const { main: doctorMain } = await import("../doctor-XEMLO6UA.js");
120
+ const { main: doctorMain } = await import("../doctor-SIWQGTAO.js");
117
121
  return doctorMain(subArgs);
118
122
  }
119
123
  case "playground": {
120
- const { main: playgroundMain } = await import("../playground-3TTBN7XD.js");
124
+ const { main: playgroundMain } = await import("../playground-SSZRNUAF.js");
121
125
  return playgroundMain(subArgs);
122
126
  }
123
127
  case "plan": {
@@ -129,7 +133,7 @@ async function main() {
129
133
  return runMain(subArgs);
130
134
  }
131
135
  case "mcp": {
132
- const { startMcpServer } = await import("../mcp-server-CKYBHXWK.js");
136
+ const { startMcpServer } = await import("../mcp-server-W3MWSKD7.js");
133
137
  return startMcpServer(subArgs);
134
138
  }
135
139
  case "worlds": {
@@ -137,15 +141,15 @@ async function main() {
137
141
  return worldMain(["list", ...subArgs]);
138
142
  }
139
143
  case "trace": {
140
- const { main: traceMain } = await import("../trace-2YDNAXMK.js");
144
+ const { main: traceMain } = await import("../trace-DC3D7XPD.js");
141
145
  return traceMain(subArgs);
142
146
  }
143
147
  case "impact": {
144
- const { main: impactMain } = await import("../impact-WIAM66IH.js");
148
+ const { main: impactMain } = await import("../impact-LDJLTVRU.js");
145
149
  return impactMain(subArgs);
146
150
  }
147
151
  case "behavioral": {
148
- const { main: behavioralMain } = await import("../behavioral-SPWPGYXL.js");
152
+ const { main: behavioralMain } = await import("../behavioral-4TKMHZQZ.js");
149
153
  return behavioralMain(subArgs);
150
154
  }
151
155
  case "world": {
@@ -158,11 +162,11 @@ async function main() {
158
162
  return deriveMain(subArgs);
159
163
  }
160
164
  case "decision-flow": {
161
- const { main: decisionFlowMain } = await import("../decision-flow-IJPNMVQK.js");
165
+ const { main: decisionFlowMain } = await import("../decision-flow-5VI5YG6A.js");
162
166
  return decisionFlowMain(subArgs);
163
167
  }
164
168
  case "equity-penalties": {
165
- const { main: equityPenaltiesMain } = await import("../equity-penalties-CCO3GVHS.js");
169
+ const { main: equityPenaltiesMain } = await import("../equity-penalties-NOM46NEO.js");
166
170
  return equityPenaltiesMain(subArgs);
167
171
  }
168
172
  case "keygen": {
package/dist/cli/plan.cjs CHANGED
@@ -1223,6 +1223,24 @@ function isExternalScope(scope) {
1223
1223
  return !internalPatterns.some((p) => p.test(scope));
1224
1224
  }
1225
1225
  function evaluateGuard(event, world, options = {}) {
1226
+ const verdict = evaluateGuardCore(event, world, options);
1227
+ return options.mode === "observe" ? toShadowVerdict(verdict) : verdict;
1228
+ }
1229
+ function toShadowVerdict(verdict) {
1230
+ if (verdict.status === "ALLOW") return verdict;
1231
+ return {
1232
+ ...verdict,
1233
+ status: "ALLOW",
1234
+ shadowStatus: verdict.status,
1235
+ shadowReason: verdict.reason,
1236
+ // Preserve the original reason as shadowReason and wipe the
1237
+ // top-level reason so callers that display `reason` for BLOCK/PAUSE
1238
+ // don't accidentally surface an enforcement message.
1239
+ reason: void 0,
1240
+ warning: verdict.reason ? `Observe mode: would have ${verdict.status.toLowerCase()} \u2014 ${verdict.reason}` : `Observe mode: would have ${verdict.status.toLowerCase()}`
1241
+ };
1242
+ }
1243
+ function evaluateGuardCore(event, world, options = {}) {
1226
1244
  const startTime = performance.now();
1227
1245
  const level = options.level ?? "standard";
1228
1246
  const includeTrace = options.trace ?? false;
@@ -2813,6 +2813,24 @@ function isExternalScope(scope) {
2813
2813
  return !internalPatterns.some((p) => p.test(scope));
2814
2814
  }
2815
2815
  function evaluateGuard(event, world, options = {}) {
2816
+ const verdict = evaluateGuardCore(event, world, options);
2817
+ return options.mode === "observe" ? toShadowVerdict(verdict) : verdict;
2818
+ }
2819
+ function toShadowVerdict(verdict) {
2820
+ if (verdict.status === "ALLOW") return verdict;
2821
+ return {
2822
+ ...verdict,
2823
+ status: "ALLOW",
2824
+ shadowStatus: verdict.status,
2825
+ shadowReason: verdict.reason,
2826
+ // Preserve the original reason as shadowReason and wipe the
2827
+ // top-level reason so callers that display `reason` for BLOCK/PAUSE
2828
+ // don't accidentally surface an enforcement message.
2829
+ reason: void 0,
2830
+ warning: verdict.reason ? `Observe mode: would have ${verdict.status.toLowerCase()} \u2014 ${verdict.reason}` : `Observe mode: would have ${verdict.status.toLowerCase()}`
2831
+ };
2832
+ }
2833
+ function evaluateGuardCore(event, world, options = {}) {
2816
2834
  const startTime = performance.now();
2817
2835
  const level = options.level ?? "standard";
2818
2836
  const includeTrace = options.trace ?? false;
@@ -3779,6 +3797,7 @@ async function auditGovernance(events, worldPath) {
3779
3797
  return emptyAudit(events.length, "Could not load compiled worldmodel for governance audit.");
3780
3798
  }
3781
3799
  const verdicts = [];
3800
+ const crossings = [];
3782
3801
  for (const ce of events) {
3783
3802
  const intent = ce.event.content?.slice(0, 500) || ce.event.kind || "activity";
3784
3803
  const scope = ce.event.metadata?.scope || void 0;
@@ -3789,16 +3808,32 @@ async function auditGovernance(events, worldPath) {
3789
3808
  scope,
3790
3809
  actionCategory: mapKindToCategory(ce.event.kind)
3791
3810
  },
3792
- world
3811
+ world,
3812
+ { mode: "observe" }
3793
3813
  );
3814
+ const shadow = result.shadowStatus ?? "ALLOW";
3794
3815
  verdicts.push({
3795
3816
  eventId: ce.event.id,
3796
3817
  domain: ce.domain,
3797
- status: result.status,
3798
- reason: result.reason,
3818
+ status: shadow,
3819
+ reason: result.shadowReason,
3799
3820
  ruleId: result.ruleId,
3800
3821
  warning: result.warning
3801
3822
  });
3823
+ if (shadow !== "ALLOW") {
3824
+ crossings.push({
3825
+ eventId: ce.event.id,
3826
+ timestamp: ce.event.timestamp,
3827
+ kind: ce.event.kind,
3828
+ actorId: ce.event.actor.id,
3829
+ shadowStatus: shadow,
3830
+ shadowReason: result.shadowReason,
3831
+ ruleId: result.ruleId,
3832
+ excerpt: intent.length > 280 ? intent.slice(0, 279) + "\u2026" : intent,
3833
+ wouldHaveBlocked: true,
3834
+ verdict: result
3835
+ });
3836
+ }
3802
3837
  } catch {
3803
3838
  verdicts.push({
3804
3839
  eventId: ce.event.id,
@@ -3817,6 +3852,7 @@ async function auditGovernance(events, worldPath) {
3817
3852
  human,
3818
3853
  cyber,
3819
3854
  joint,
3855
+ crossings,
3820
3856
  summary
3821
3857
  };
3822
3858
  }
@@ -3872,6 +3908,7 @@ function emptyAudit(total, reason) {
3872
3908
  human: { allow: 0, modify: 0, block: 0, details: [] },
3873
3909
  cyber: { allow: 0, modify: 0, block: 0, details: [] },
3874
3910
  joint: { allow: 0, modify: 0, block: 0, details: [] },
3911
+ crossings: [],
3875
3912
  summary: reason
3876
3913
  };
3877
3914
  }
@@ -4896,7 +4933,8 @@ Compare stated intent against actual GitHub activity. Gaps = drift.`;
4896
4933
  scores,
4897
4934
  eventCount: events.length,
4898
4935
  activeAdapters,
4899
- worldStack
4936
+ worldStack,
4937
+ governance
4900
4938
  };
4901
4939
  }
4902
4940
  function filterEventsByUser(events, username) {
@@ -7,12 +7,12 @@ import {
7
7
  readExocortex,
8
8
  summarizeExocortex,
9
9
  think
10
- } from "../chunk-BZYQHJDM.js";
10
+ } from "../chunk-2KTPIE57.js";
11
11
  import {
12
12
  listLenses
13
13
  } from "../chunk-TCGGED4G.js";
14
14
  import "../chunk-I4RTIMLX.js";
15
- import "../chunk-ZAF6JH23.js";
15
+ import "../chunk-MBOW6YXN.js";
16
16
  import "../chunk-QLPTHTVB.js";
17
17
  import "../chunk-QWGCMQQD.js";
18
18
 
@@ -743,7 +743,7 @@ async function main(argv) {
743
743
  case "emergent":
744
744
  return cmdEmergent(args);
745
745
  case "mcp": {
746
- const { startRadiantMcp } = await import("../server-EI5JCIBU.js");
746
+ const { startRadiantMcp } = await import("../server-EGRGGSM2.js");
747
747
  return startRadiantMcp(argv);
748
748
  }
749
749
  case "decision":
package/dist/cli/run.cjs CHANGED
@@ -308,6 +308,24 @@ function isExternalScope(scope) {
308
308
  return !internalPatterns.some((p) => p.test(scope));
309
309
  }
310
310
  function evaluateGuard(event, world, options = {}) {
311
+ const verdict = evaluateGuardCore(event, world, options);
312
+ return options.mode === "observe" ? toShadowVerdict(verdict) : verdict;
313
+ }
314
+ function toShadowVerdict(verdict) {
315
+ if (verdict.status === "ALLOW") return verdict;
316
+ return {
317
+ ...verdict,
318
+ status: "ALLOW",
319
+ shadowStatus: verdict.status,
320
+ shadowReason: verdict.reason,
321
+ // Preserve the original reason as shadowReason and wipe the
322
+ // top-level reason so callers that display `reason` for BLOCK/PAUSE
323
+ // don't accidentally surface an enforcement message.
324
+ reason: void 0,
325
+ warning: verdict.reason ? `Observe mode: would have ${verdict.status.toLowerCase()} \u2014 ${verdict.reason}` : `Observe mode: would have ${verdict.status.toLowerCase()}`
326
+ };
327
+ }
328
+ function evaluateGuardCore(event, world, options = {}) {
311
329
  const startTime = performance.now();
312
330
  const level = options.level ?? "standard";
313
331
  const includeTrace = options.trace ?? false;
package/dist/cli/run.js CHANGED
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  FileAuditLogger,
3
3
  verdictToAuditEvent
4
- } from "../chunk-2VAWP6FI.js";
4
+ } from "../chunk-RAS62JXV.js";
5
5
  import {
6
6
  describeActiveWorld,
7
7
  resolveWorldPath
8
8
  } from "../chunk-AKW5YVCE.js";
9
- import "../chunk-ZAF6JH23.js";
9
+ import "../chunk-MBOW6YXN.js";
10
10
  import "../chunk-QLPTHTVB.js";
11
11
  import "../chunk-QWGCMQQD.js";
12
12
 
@@ -105,7 +105,7 @@ async function main(args) {
105
105
  return;
106
106
  }
107
107
  const { resolveProvider, ModelAdapter } = await import("../model-adapter-VXEKB4LS.js");
108
- const { runInteractiveMode } = await import("../session-FMAROEIE.js");
108
+ const { runInteractiveMode } = await import("../session-PZLTL22G.js");
109
109
  const modelConfig = resolveProvider(providerName, {
110
110
  model: parseArg(args, "--model"),
111
111
  apiKey: parseArg(args, "--api-key")
@@ -142,7 +142,7 @@ async function main(args) {
142
142
  model
143
143
  );
144
144
  } else if (isPipeMode) {
145
- const { runPipeMode } = await import("../session-FMAROEIE.js");
145
+ const { runPipeMode } = await import("../session-PZLTL22G.js");
146
146
  await runPipeMode({
147
147
  worldPath,
148
148
  plan,
@@ -4,8 +4,8 @@ import {
4
4
  } from "./chunk-D2UCV5AK.js";
5
5
  import {
6
6
  readAuditLog
7
- } from "./chunk-2VAWP6FI.js";
8
- import "./chunk-ZAF6JH23.js";
7
+ } from "./chunk-RAS62JXV.js";
8
+ import "./chunk-MBOW6YXN.js";
9
9
  import "./chunk-QLPTHTVB.js";
10
10
  import "./chunk-QWGCMQQD.js";
11
11
 
@@ -6,7 +6,7 @@ import {
6
6
  handleListPresets,
7
7
  handleReasonRequest,
8
8
  writeTempWorld
9
- } from "./chunk-7FL3U7Z5.js";
9
+ } from "./chunk-MWGEXHOD.js";
10
10
  import {
11
11
  adaptationFromVerdict,
12
12
  detectBehavioralPatterns,
@@ -20,7 +20,7 @@ import {
20
20
  loadBundledWorld,
21
21
  loadWorld
22
22
  } from "./chunk-I4RTIMLX.js";
23
- import "./chunk-ZAF6JH23.js";
23
+ import "./chunk-MBOW6YXN.js";
24
24
  import "./chunk-QLPTHTVB.js";
25
25
  import {
26
26
  __require
@@ -320,8 +320,26 @@ function isExternalScope(scope) {
320
320
  ];
321
321
  return !internalPatterns.some((p) => p.test(scope));
322
322
  }
323
- var MAX_INPUT_LENGTH = 1e5;
324
323
  function evaluateGuard(event, world, options = {}) {
324
+ const verdict = evaluateGuardCore(event, world, options);
325
+ return options.mode === "observe" ? toShadowVerdict(verdict) : verdict;
326
+ }
327
+ function toShadowVerdict(verdict) {
328
+ if (verdict.status === "ALLOW") return verdict;
329
+ return {
330
+ ...verdict,
331
+ status: "ALLOW",
332
+ shadowStatus: verdict.status,
333
+ shadowReason: verdict.reason,
334
+ // Preserve the original reason as shadowReason and wipe the
335
+ // top-level reason so callers that display `reason` for BLOCK/PAUSE
336
+ // don't accidentally surface an enforcement message.
337
+ reason: void 0,
338
+ warning: verdict.reason ? `Observe mode: would have ${verdict.status.toLowerCase()} \u2014 ${verdict.reason}` : `Observe mode: would have ${verdict.status.toLowerCase()}`
339
+ };
340
+ }
341
+ var MAX_INPUT_LENGTH = 1e5;
342
+ function evaluateGuardCore(event, world, options = {}) {
325
343
  const startTime = performance.now();
326
344
  const level = options.level ?? "standard";
327
345
  const includeTrace = options.trace ?? false;
@@ -1,5 +1,5 @@
1
1
  import { WorldDefinition, GovernanceEvent } from '../types.cjs';
2
- import { a as GuardEvent, b as GuardEngineOptions, G as GuardVerdict, d as GuardStatus } from '../guard-contract-ddiIPlOg.cjs';
2
+ import { a as GuardEvent, b as GuardEngineOptions, G as GuardVerdict, d as GuardStatus } from '../guard-contract-Oznf-Kgq.cjs';
3
3
 
4
4
  /**
5
5
  * Guard Engine — Deterministic Governance Evaluator
@@ -28,6 +28,26 @@ import { a as GuardEvent, b as GuardEngineOptions, G as GuardVerdict, d as Guard
28
28
  * - No hidden logic. Everything is in the world file or declared here.
29
29
  */
30
30
 
31
+ /**
32
+ * Evaluate a guard event against a world definition.
33
+ *
34
+ * This is the entire guard engine. One function. Deterministic.
35
+ * No class instantiation, no state, no side effects.
36
+ *
37
+ * Two modes, same evaluation logic:
38
+ *
39
+ * mode: 'enforce' (default)
40
+ * Returns the real verdict — BLOCK blocks, PAUSE pauses, MODIFY
41
+ * modifies, PENALIZE penalizes.
42
+ *
43
+ * mode: 'observe'
44
+ * Runs every layer identically, then coerces any non-ALLOW verdict
45
+ * to ALLOW before returning — preserving the original status on
46
+ * `shadowStatus`. The caller passes the action through; Radiant /
47
+ * Bevia / audit logs read `shadowStatus` to see what WOULD have
48
+ * happened. This is how teams roll out governance without the
49
+ * political cost of enforcement.
50
+ */
31
51
  declare function evaluateGuard(event: GuardEvent, world: WorldDefinition, options?: GuardEngineOptions): GuardVerdict;
32
52
  /**
33
53
  * Build a normalized allowlist key from a GuardEvent.
@@ -1,5 +1,5 @@
1
1
  import { WorldDefinition, GovernanceEvent } from '../types.js';
2
- import { a as GuardEvent, b as GuardEngineOptions, G as GuardVerdict, d as GuardStatus } from '../guard-contract-q6HJAq3Q.js';
2
+ import { a as GuardEvent, b as GuardEngineOptions, G as GuardVerdict, d as GuardStatus } from '../guard-contract-w_i_6gh-.js';
3
3
 
4
4
  /**
5
5
  * Guard Engine — Deterministic Governance Evaluator
@@ -28,6 +28,26 @@ import { a as GuardEvent, b as GuardEngineOptions, G as GuardVerdict, d as Guard
28
28
  * - No hidden logic. Everything is in the world file or declared here.
29
29
  */
30
30
 
31
+ /**
32
+ * Evaluate a guard event against a world definition.
33
+ *
34
+ * This is the entire guard engine. One function. Deterministic.
35
+ * No class instantiation, no state, no side effects.
36
+ *
37
+ * Two modes, same evaluation logic:
38
+ *
39
+ * mode: 'enforce' (default)
40
+ * Returns the real verdict — BLOCK blocks, PAUSE pauses, MODIFY
41
+ * modifies, PENALIZE penalizes.
42
+ *
43
+ * mode: 'observe'
44
+ * Runs every layer identically, then coerces any non-ALLOW verdict
45
+ * to ALLOW before returning — preserving the original status on
46
+ * `shadowStatus`. The caller passes the action through; Radiant /
47
+ * Bevia / audit logs read `shadowStatus` to see what WOULD have
48
+ * happened. This is how teams roll out governance without the
49
+ * political cost of enforcement.
50
+ */
31
51
  declare function evaluateGuard(event: GuardEvent, world: WorldDefinition, options?: GuardEngineOptions): GuardVerdict;
32
52
  /**
33
53
  * Build a normalized allowlist key from a GuardEvent.
@@ -2,7 +2,7 @@ import {
2
2
  evaluateGuard,
3
3
  eventToAllowlistKey,
4
4
  verdictToEvent
5
- } from "../chunk-ZAF6JH23.js";
5
+ } from "../chunk-MBOW6YXN.js";
6
6
  import "../chunk-QLPTHTVB.js";
7
7
  import "../chunk-QWGCMQQD.js";
8
8
  export {
@@ -8,13 +8,13 @@ import {
8
8
  } from "./chunk-D2UCV5AK.js";
9
9
  import {
10
10
  verdictToAuditEvent
11
- } from "./chunk-2VAWP6FI.js";
11
+ } from "./chunk-RAS62JXV.js";
12
12
  import {
13
13
  loadWorld
14
14
  } from "./chunk-I4RTIMLX.js";
15
15
  import {
16
16
  evaluateGuard
17
- } from "./chunk-ZAF6JH23.js";
17
+ } from "./chunk-MBOW6YXN.js";
18
18
  import "./chunk-QLPTHTVB.js";
19
19
  import "./chunk-QWGCMQQD.js";
20
20
 
@@ -4,12 +4,12 @@ import {
4
4
  import {
5
5
  GUARD_EXIT_CODES,
6
6
  evaluateGuardWithAI
7
- } from "./chunk-6CV4XG3J.js";
7
+ } from "./chunk-QFDFAWZ6.js";
8
8
  import "./chunk-INWQHLPS.js";
9
9
  import {
10
10
  FileAuditLogger,
11
11
  verdictToAuditEvent
12
- } from "./chunk-2VAWP6FI.js";
12
+ } from "./chunk-RAS62JXV.js";
13
13
  import {
14
14
  describeActiveWorld,
15
15
  resolveWorldPath
@@ -19,7 +19,7 @@ import {
19
19
  } from "./chunk-I4RTIMLX.js";
20
20
  import {
21
21
  evaluateGuard
22
- } from "./chunk-ZAF6JH23.js";
22
+ } from "./chunk-MBOW6YXN.js";
23
23
  import "./chunk-QLPTHTVB.js";
24
24
  import "./chunk-QWGCMQQD.js";
25
25
 
@@ -364,6 +364,20 @@ interface GuardVerdict {
364
364
  reason?: string;
365
365
  /** ID of the rule/guard that produced this verdict */
366
366
  ruleId?: string;
367
+ /**
368
+ * Shadow verdict — populated when the engine ran in `mode: 'observe'`.
369
+ * If the real enforcement decision would have been BLOCK/PAUSE/MODIFY/
370
+ * PENALIZE, that original status is captured here while `status` is
371
+ * coerced to ALLOW so the caller passes the action through.
372
+ *
373
+ * Use this for observe/shadow/mirror-mode governance: the engine
374
+ * records every crossing of a rule without stopping anything. Lets
375
+ * teams adopt governance without the political cost of enforcement,
376
+ * and lets tools like Radiant surface which invariants got bumped.
377
+ */
378
+ shadowStatus?: GuardStatus;
379
+ /** Reason the shadow verdict fired (empty when shadowStatus is absent) */
380
+ shadowReason?: string;
367
381
  /** Advisory warning (for ALLOW with warn-mode guards) */
368
382
  warning?: string;
369
383
  /** Consequence applied (for PENALIZE verdicts) */
@@ -494,6 +508,24 @@ interface GuardEngineOptions {
494
508
  trace?: boolean;
495
509
  /** Enforcement level override. If not set, uses world default or 'standard'. */
496
510
  level?: 'basic' | 'standard' | 'strict';
511
+ /**
512
+ * Enforcement mode.
513
+ *
514
+ * - `'enforce'` (default) — the engine returns its real verdict. BLOCK
515
+ * blocks, PAUSE pauses, PENALIZE penalizes, MODIFY modifies.
516
+ *
517
+ * - `'observe'` — the engine evaluates every rule exactly the same way,
518
+ * but coerces non-ALLOW verdicts to ALLOW before returning. The
519
+ * original status is preserved on `shadowStatus` so the caller can
520
+ * record the crossing without blocking the action. Used by Radiant
521
+ * + Bevia to show leaders where their worldmodel is being touched
522
+ * without imposing enforcement, and by teams who want to roll out
523
+ * governance gradually rule-by-rule.
524
+ *
525
+ * Observe mode does NOT alter the evaluation — all layers still run.
526
+ * It only changes how the final verdict is packaged for the caller.
527
+ */
528
+ mode?: 'enforce' | 'observe';
497
529
  /**
498
530
  * Session allowlist — set of pre-approved event keys.
499
531
  * Use `eventToAllowlistKey(event)` to build keys.
@@ -364,6 +364,20 @@ interface GuardVerdict {
364
364
  reason?: string;
365
365
  /** ID of the rule/guard that produced this verdict */
366
366
  ruleId?: string;
367
+ /**
368
+ * Shadow verdict — populated when the engine ran in `mode: 'observe'`.
369
+ * If the real enforcement decision would have been BLOCK/PAUSE/MODIFY/
370
+ * PENALIZE, that original status is captured here while `status` is
371
+ * coerced to ALLOW so the caller passes the action through.
372
+ *
373
+ * Use this for observe/shadow/mirror-mode governance: the engine
374
+ * records every crossing of a rule without stopping anything. Lets
375
+ * teams adopt governance without the political cost of enforcement,
376
+ * and lets tools like Radiant surface which invariants got bumped.
377
+ */
378
+ shadowStatus?: GuardStatus;
379
+ /** Reason the shadow verdict fired (empty when shadowStatus is absent) */
380
+ shadowReason?: string;
367
381
  /** Advisory warning (for ALLOW with warn-mode guards) */
368
382
  warning?: string;
369
383
  /** Consequence applied (for PENALIZE verdicts) */
@@ -494,6 +508,24 @@ interface GuardEngineOptions {
494
508
  trace?: boolean;
495
509
  /** Enforcement level override. If not set, uses world default or 'standard'. */
496
510
  level?: 'basic' | 'standard' | 'strict';
511
+ /**
512
+ * Enforcement mode.
513
+ *
514
+ * - `'enforce'` (default) — the engine returns its real verdict. BLOCK
515
+ * blocks, PAUSE pauses, PENALIZE penalizes, MODIFY modifies.
516
+ *
517
+ * - `'observe'` — the engine evaluates every rule exactly the same way,
518
+ * but coerces non-ALLOW verdicts to ALLOW before returning. The
519
+ * original status is preserved on `shadowStatus` so the caller can
520
+ * record the crossing without blocking the action. Used by Radiant
521
+ * + Bevia to show leaders where their worldmodel is being touched
522
+ * without imposing enforcement, and by teams who want to roll out
523
+ * governance gradually rule-by-rule.
524
+ *
525
+ * Observe mode does NOT alter the evaluation — all layers still run.
526
+ * It only changes how the final verdict is packaged for the caller.
527
+ */
528
+ mode?: 'enforce' | 'observe';
497
529
  /**
498
530
  * Session allowlist — set of pre-approved event keys.
499
531
  * Use `eventToAllowlistKey(event)` to build keys.
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  generateImpactReport,
3
3
  renderImpactReport
4
- } from "./chunk-OQU65525.js";
4
+ } from "./chunk-24YW7BHC.js";
5
5
  import {
6
6
  readAuditLog
7
- } from "./chunk-2VAWP6FI.js";
8
- import "./chunk-ZAF6JH23.js";
7
+ } from "./chunk-RAS62JXV.js";
8
+ import "./chunk-MBOW6YXN.js";
9
9
  import "./chunk-QLPTHTVB.js";
10
10
  import "./chunk-QWGCMQQD.js";
11
11
 
package/dist/index.cjs CHANGED
@@ -966,6 +966,8 @@ __export(index_exports, {
966
966
  advancePlan: () => advancePlan,
967
967
  applyConsequence: () => applyConsequence,
968
968
  applyReward: () => applyReward,
969
+ auditBehavior: () => auditBehavior,
970
+ auditBehaviors: () => auditBehaviors,
969
971
  buildPlanCheck: () => buildPlanCheck,
970
972
  classifyAdaptation: () => classifyAdaptation,
971
973
  classifyIntent: () => classifyIntent,
@@ -1362,8 +1364,26 @@ function isExternalScope(scope) {
1362
1364
  ];
1363
1365
  return !internalPatterns.some((p) => p.test(scope));
1364
1366
  }
1365
- var MAX_INPUT_LENGTH = 1e5;
1366
1367
  function evaluateGuard(event, world, options = {}) {
1368
+ const verdict = evaluateGuardCore(event, world, options);
1369
+ return options.mode === "observe" ? toShadowVerdict(verdict) : verdict;
1370
+ }
1371
+ function toShadowVerdict(verdict) {
1372
+ if (verdict.status === "ALLOW") return verdict;
1373
+ return {
1374
+ ...verdict,
1375
+ status: "ALLOW",
1376
+ shadowStatus: verdict.status,
1377
+ shadowReason: verdict.reason,
1378
+ // Preserve the original reason as shadowReason and wipe the
1379
+ // top-level reason so callers that display `reason` for BLOCK/PAUSE
1380
+ // don't accidentally surface an enforcement message.
1381
+ reason: void 0,
1382
+ warning: verdict.reason ? `Observe mode: would have ${verdict.status.toLowerCase()} \u2014 ${verdict.reason}` : `Observe mode: would have ${verdict.status.toLowerCase()}`
1383
+ };
1384
+ }
1385
+ var MAX_INPUT_LENGTH = 1e5;
1386
+ function evaluateGuardCore(event, world, options = {}) {
1367
1387
  const startTime = performance.now();
1368
1388
  const level = options.level ?? "standard";
1369
1389
  const includeTrace = options.trace ?? false;
@@ -2151,6 +2171,45 @@ function verdictToEvent(status, intent) {
2151
2171
  };
2152
2172
  }
2153
2173
 
2174
+ // src/engine/audit-behavior.ts
2175
+ function auditBehavior(event, world) {
2176
+ const guardEvent = toGuardEvent(event);
2177
+ const verdict = evaluateGuard(guardEvent, world, { mode: "observe" });
2178
+ const wouldHaveBlocked = verdict.shadowStatus !== void 0 && verdict.shadowStatus !== "ALLOW";
2179
+ return {
2180
+ eventId: event.id,
2181
+ timestamp: event.timestamp,
2182
+ kind: event.kind,
2183
+ actorId: event.actorId,
2184
+ shadowStatus: verdict.shadowStatus ?? "ALLOW",
2185
+ shadowReason: verdict.shadowReason,
2186
+ ruleId: verdict.ruleId,
2187
+ excerpt: event.content ? excerptContent(event.content) : void 0,
2188
+ wouldHaveBlocked,
2189
+ verdict
2190
+ };
2191
+ }
2192
+ function auditBehaviors(events, world) {
2193
+ return events.map((e) => auditBehavior(e, world));
2194
+ }
2195
+ function toGuardEvent(event) {
2196
+ return {
2197
+ intent: event.content ?? event.kind ?? "unspecified",
2198
+ tool: event.kind,
2199
+ scope: event.scope,
2200
+ payload: {
2201
+ actorId: event.actorId,
2202
+ actorKind: event.actorKind,
2203
+ timestamp: event.timestamp,
2204
+ sourceEventId: event.id
2205
+ }
2206
+ };
2207
+ }
2208
+ function excerptContent(content, max = 280) {
2209
+ if (content.length <= max) return content;
2210
+ return content.slice(0, max - 1).trimEnd() + "\u2026";
2211
+ }
2212
+
2154
2213
  // src/providers/ai-provider.ts
2155
2214
  var ChatCompletionsProvider = class {
2156
2215
  model;
@@ -8357,6 +8416,8 @@ function handleCreateCapsule(body) {
8357
8416
  advancePlan,
8358
8417
  applyConsequence,
8359
8418
  applyReward,
8419
+ auditBehavior,
8420
+ auditBehaviors,
8360
8421
  buildPlanCheck,
8361
8422
  classifyAdaptation,
8362
8423
  classifyIntent,