pi-fabric 0.91.0 → 0.92.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 (98) hide show
  1. package/README.md +1 -1
  2. package/dist/audit/trace.d.ts +4 -0
  3. package/dist/audit/trace.d.ts.map +1 -1
  4. package/dist/chunks/chunk-3YZUQESG.js +16 -0
  5. package/dist/chunks/{chunk-7363CD5A.js.map → chunk-3YZUQESG.js.map} +1 -1
  6. package/dist/chunks/{chunk-H6FEQL2D.js → chunk-5MDFFHOO.js} +223 -8
  7. package/dist/chunks/chunk-5MDFFHOO.js.map +7 -0
  8. package/dist/chunks/{chunk-IRPPGNUF.js → chunk-6GT4YJT2.js} +4 -4
  9. package/dist/chunks/{chunk-NGAUBL2M.js → chunk-DDVCVE4D.js} +3 -3
  10. package/dist/chunks/{chunk-F64KOMNS.js → chunk-FRONVGLX.js} +2 -2
  11. package/dist/chunks/{chunk-P22OSVIC.js → chunk-JS2THBBG.js} +2 -2
  12. package/dist/chunks/{chunk-TDCMU5L4.js → chunk-KNBPIZF7.js} +2 -2
  13. package/dist/chunks/{chunk-UVUWHPAO.js → chunk-LLJXPPTA.js} +150 -610
  14. package/dist/chunks/chunk-LLJXPPTA.js.map +7 -0
  15. package/dist/chunks/{chunk-TAJUG2Q3.js → chunk-MF46OHNU.js} +2 -2
  16. package/dist/chunks/{chunk-LJ6FJRFH.js → chunk-OJX2V36R.js} +2 -2
  17. package/dist/chunks/{chunk-5JEOABJ7.js → chunk-QJUDWDPL.js} +59 -50
  18. package/dist/chunks/chunk-QJUDWDPL.js.map +7 -0
  19. package/dist/chunks/{chunk-6LLUZUH4.js → chunk-QOHTGSXY.js} +4 -4
  20. package/dist/chunks/{chunk-DBNZVS2S.js → chunk-RRGTKHXZ.js} +2 -2
  21. package/dist/chunks/{chunk-KAWR7MS5.js → chunk-T3UYWHLT.js} +296 -7
  22. package/dist/chunks/chunk-T3UYWHLT.js.map +7 -0
  23. package/dist/chunks/{chunk-77FQHHZD.js → chunk-UKMQK5VP.js} +2 -2
  24. package/dist/chunks/{chunk-MYCDJTSM.js → chunk-VJJFD42F.js} +2 -2
  25. package/dist/chunks/{chunk-UQHXFLST.js → chunk-X45GMLON.js} +2 -2
  26. package/dist/commands/fabric.d.ts.map +1 -1
  27. package/dist/compaction/hook.js +4 -3
  28. package/dist/core/action-arguments.d.ts +2 -0
  29. package/dist/core/action-arguments.d.ts.map +1 -1
  30. package/dist/core/action-registry.d.ts.map +1 -1
  31. package/dist/core/action-registry.js +4 -5
  32. package/dist/core/action-repair.d.ts.map +1 -1
  33. package/dist/entropy/active.d.ts +6 -4
  34. package/dist/entropy/active.d.ts.map +1 -1
  35. package/dist/entropy/compiled-store.d.ts.map +1 -1
  36. package/dist/entropy/compiled-surface.d.ts +11 -6
  37. package/dist/entropy/compiled-surface.d.ts.map +1 -1
  38. package/dist/entropy/compiler.d.ts +0 -1
  39. package/dist/entropy/compiler.d.ts.map +1 -1
  40. package/dist/entropy/corpus.d.ts.map +1 -1
  41. package/dist/entropy/index.d.ts +1 -0
  42. package/dist/entropy/index.d.ts.map +1 -1
  43. package/dist/entropy/index.js +45 -26
  44. package/dist/entropy/meter.d.ts.map +1 -1
  45. package/dist/entropy/normal-form.d.ts +40 -0
  46. package/dist/entropy/normal-form.d.ts.map +1 -0
  47. package/dist/entropy/passes.d.ts +1 -1
  48. package/dist/entropy/passes.d.ts.map +1 -1
  49. package/dist/entropy/presentation.d.ts +1 -0
  50. package/dist/entropy/presentation.d.ts.map +1 -1
  51. package/dist/entropy/surface.d.ts.map +1 -1
  52. package/dist/entropy/trial.d.ts +6 -3
  53. package/dist/entropy/trial.d.ts.map +1 -1
  54. package/dist/entropy/types.d.ts +26 -3
  55. package/dist/entropy/types.d.ts.map +1 -1
  56. package/dist/fabric-runtime-state.d.ts.map +1 -1
  57. package/dist/fabric-runtime-state.js +42 -41
  58. package/dist/fabric-runtime-state.js.map +3 -3
  59. package/dist/index.d.ts.map +1 -1
  60. package/dist/index.js +70 -67
  61. package/dist/index.js.map +2 -2
  62. package/dist/mcp.js +2 -2
  63. package/dist/memory/discovery.js +5 -4
  64. package/dist/memory/normalize.js +4 -3
  65. package/dist/memory/search.js +5 -4
  66. package/dist/memory.js +7 -6
  67. package/dist/memory.js.map +1 -1
  68. package/dist/protocol.js +2 -2
  69. package/dist/providers/memory-provider.js +7 -6
  70. package/dist/repairs/apply.d.ts.map +1 -1
  71. package/dist/residency/host.js +8 -8
  72. package/dist/residency/pi-entry.js +8 -8
  73. package/dist/speculation/python-scanner.js +1 -1
  74. package/dist/speculation/scanner.js +1 -1
  75. package/docs/certification.md +37 -8
  76. package/docs/configuration.md +1 -1
  77. package/docs/entropy.md +206 -420
  78. package/docs/repairs.md +22 -1
  79. package/package.json +1 -1
  80. package/dist/chunks/chunk-5JEOABJ7.js.map +0 -7
  81. package/dist/chunks/chunk-7363CD5A.js +0 -38
  82. package/dist/chunks/chunk-FMLK3ZA7.js +0 -283
  83. package/dist/chunks/chunk-FMLK3ZA7.js.map +0 -7
  84. package/dist/chunks/chunk-H6FEQL2D.js.map +0 -7
  85. package/dist/chunks/chunk-KAWR7MS5.js.map +0 -7
  86. package/dist/chunks/chunk-UVUWHPAO.js.map +0 -7
  87. /package/dist/chunks/{chunk-IRPPGNUF.js.map → chunk-6GT4YJT2.js.map} +0 -0
  88. /package/dist/chunks/{chunk-NGAUBL2M.js.map → chunk-DDVCVE4D.js.map} +0 -0
  89. /package/dist/chunks/{chunk-F64KOMNS.js.map → chunk-FRONVGLX.js.map} +0 -0
  90. /package/dist/chunks/{chunk-P22OSVIC.js.map → chunk-JS2THBBG.js.map} +0 -0
  91. /package/dist/chunks/{chunk-TDCMU5L4.js.map → chunk-KNBPIZF7.js.map} +0 -0
  92. /package/dist/chunks/{chunk-TAJUG2Q3.js.map → chunk-MF46OHNU.js.map} +0 -0
  93. /package/dist/chunks/{chunk-LJ6FJRFH.js.map → chunk-OJX2V36R.js.map} +0 -0
  94. /package/dist/chunks/{chunk-6LLUZUH4.js.map → chunk-QOHTGSXY.js.map} +0 -0
  95. /package/dist/chunks/{chunk-DBNZVS2S.js.map → chunk-RRGTKHXZ.js.map} +0 -0
  96. /package/dist/chunks/{chunk-77FQHHZD.js.map → chunk-UKMQK5VP.js.map} +0 -0
  97. /package/dist/chunks/{chunk-MYCDJTSM.js.map → chunk-VJJFD42F.js.map} +0 -0
  98. /package/dist/chunks/{chunk-UQHXFLST.js.map → chunk-X45GMLON.js.map} +0 -0
package/README.md CHANGED
@@ -147,7 +147,7 @@ See the [interface & commands reference](docs/interface.md) for every view, keyb
147
147
  - [External providers](docs/providers.md): the versioned provider protocol for extensions.
148
148
  - [Architecture & security](docs/architecture.md): the host bridge, sandboxing, tool-call robustness, and limits.
149
149
  - [Catalog repairs](docs/repairs.md): unique extra keys and unknown actions promoted into silent schema maps.
150
- - [Tool entropy](docs/entropy.md): the deterministic entropy meter, on-demand session measurement, reduction proposals, the autonomous compile loop with its ratchet gate, and `certify:entropy`.
150
+ - [Tool entropy](docs/entropy.md): static capability-preserving normal forms, deterministic invocation-friction metrics, bounded repair witnesses, and offline `certify:entropy` proof checks.
151
151
  - [Speculative PTC](docs/speculation.md): pre-launching literal read calls while the program streams, with epoch + freshness guarantees.
152
152
  - [Skills](docs/skills.md): the core-first invocation policy and user-invoked advanced patterns.
153
153
 
@@ -1,3 +1,4 @@
1
+ import { type NormalFormWitness } from "../entropy/normal-form.js";
1
2
  export declare const FABRIC_EXECUTION_TRACE_KIND: "pi-fabric.execution";
2
3
  export declare const FABRIC_EXECUTION_TRACE_VERSION: 1;
3
4
  export declare const FABRIC_EXECUTION_TRACE_MAX_BYTES: number;
@@ -17,6 +18,7 @@ export interface FabricExecutionTraceOperationV1 {
17
18
  [key: string]: FabricTraceJsonValue;
18
19
  };
19
20
  outcome: FabricExecutionOutcomeV1;
21
+ normalization?: NormalFormWitness;
20
22
  failureStage?: FabricExecutionFailureStageV1;
21
23
  error?: string;
22
24
  result?: FabricTraceJsonValue;
@@ -61,6 +63,7 @@ interface MutableOperation {
61
63
  [key: string]: FabricTraceJsonValue;
62
64
  }>;
63
65
  outcome?: FabricExecutionOutcomeV1;
66
+ normalization?: NormalFormWitness;
64
67
  failureStage?: FabricExecutionFailureStageV1;
65
68
  error?: Sanitized<string>;
66
69
  result?: Sanitized<FabricTraceJsonValue>;
@@ -77,6 +80,7 @@ export declare class FabricExecutionTraceOperationHandle {
77
80
  constructor(recorder: FabricExecutionTraceRecorder, operation: MutableOperation | undefined);
78
81
  resolved(provider: string, action: string): void;
79
82
  prepared(args: Record<string, unknown>): void;
83
+ normalized(witness: NormalFormWitness): void;
80
84
  succeed(result: unknown, meta?: TraceResultMeta): void;
81
85
  fail(stage: FabricExecutionFailureStageV1, error: unknown, outcome?: FabricExecutionOutcomeV1, result?: unknown, meta?: TraceResultMeta): void;
82
86
  }
@@ -1 +1 @@
1
- {"version":3,"file":"trace.d.ts","sourceRoot":"","sources":["../../src/audit/trace.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,2BAA2B,EAAG,qBAA8B,CAAC;AAC1E,eAAO,MAAM,8BAA8B,EAAG,CAAU,CAAC;AACzD,eAAO,MAAM,gCAAgC,QAAa,CAAC;AAc3D,MAAM,MAAM,wBAAwB,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AACxE,MAAM,MAAM,oBAAoB,GAC5B,wBAAwB,GACxB,oBAAoB,EAAE,GACtB;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,oBAAoB,CAAA;CAAE,CAAC;AAE5C,MAAM,MAAM,wBAAwB,GAAG,WAAW,GAAG,QAAQ,GAAG,SAAS,GAAG,WAAW,CAAC;AACxF,MAAM,MAAM,6BAA6B,GACrC,SAAS,GACT,SAAS,GACT,UAAU,GACV,SAAS,GACT,QAAQ,GACR,OAAO,CAAC;AAEZ,MAAM,WAAW,+BAA+B;IAC9C,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,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B,EACpC,KAAK,EAAE,OAAO,EACd,OAAO,GAAE,wBAAmC,EAC5C,MAAM,CAAC,EAAE,OAAO,EAChB,IAAI,CAAC,EAAE,eAAe,GACrB,IAAI;CAwBR;AAED,qBAAa,4BAA4B;;IAKvC,MAAM,UAAS;IAEf,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,SAAuB,GAAG,MAAM;IAM1E,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,mCAAmC;IAyB1F,IAAI,CACF,OAAO,EAAE,wBAAwB,EACjC,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,SAAS,CAAC,EAAE,MAAM,GACjB,sBAAsB;CA2I1B;AAED,eAAO,MAAM,yBAAyB,GACpC,OAAO,OAAO,EACd,SAAS,WAAW,KACnB,wBAGF,CAAC;AAwCF,eAAO,MAAM,iCAAiC,GAC5C,OAAO,OAAO,KACb,KAAK,IAAI,+BAMX,CAAC;AAmBF,eAAO,MAAM,wBAAwB,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,sBAMlE,CAAC;AAEF,eAAO,MAAM,0BAA0B,GAAI,OAAO,OAAO,KAAG,sBAAsB,GAAG,SAChC,CAAC"}
@@ -0,0 +1,16 @@
1
+ // src/core/stable-hash.ts
2
+ import { createHash } from "node:crypto";
3
+ var stableJsonValue = (value) => {
4
+ if (Array.isArray(value)) return value.map(stableJsonValue);
5
+ if (value instanceof URL) return value.href;
6
+ if (value === null || typeof value !== "object") return value;
7
+ return Object.fromEntries(
8
+ Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([key, nested]) => [key, stableJsonValue(nested)])
9
+ );
10
+ };
11
+ var stableJsonHash = (value) => createHash("sha256").update(JSON.stringify(stableJsonValue(value))).digest("hex");
12
+
13
+ export {
14
+ stableJsonHash
15
+ };
16
+ //# sourceMappingURL=chunk-3YZUQESG.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/core/stable-hash.ts"],
4
4
  "sourcesContent": ["import { createHash } from \"node:crypto\";\n\n// Deterministic JSON shaping for hashing: object keys sort recursively so\n// equivalent values hash identically regardless of key insertion order. URL\n// instances hash by href \u2014 they expose no enumerable own properties, so\n// untreated they would all collapse to \"{}\" (MCP server definitions carry\n// `URL` instances for HTTP transports).\nconst stableJsonValue = (value: unknown): unknown => {\n if (Array.isArray(value)) return value.map(stableJsonValue);\n if (value instanceof URL) return value.href;\n if (value === null || typeof value !== \"object\") return value;\n return Object.fromEntries(\n Object.entries(value as Record<string, unknown>)\n .sort(([left], [right]) => left.localeCompare(right))\n .map(([key, nested]) => [key, stableJsonValue(nested)]),\n );\n};\n\nexport const stableJsonHash = (value: unknown): string =>\n createHash(\"sha256\").update(JSON.stringify(stableJsonValue(value))).digest(\"hex\");\nconst STABLE_HASH_ARRAY_CHUNK = 64;\n\n// Cooperative canonical hashing for large evidence arrays. Each element is\n// normalized by the same pure shaper as stableJsonHash; fixed 64-record chunks\n// keep extension hooks responsive without changing a byte of hash input.\nexport const stableJsonHashArrayAsync = async (\n values: readonly unknown[],\n): Promise<string> => {\n const hash = createHash(\"sha256\");\n hash.update(\"[\");\n let first = true;\n let batch: string[] = [];\n const flush = async (): Promise<void> => {\n if (batch.length === 0) return;\n hash.update(`${first ? \"\" : \",\"}${batch.join(\",\")}`);\n first = false;\n batch = [];\n await new Promise((resolve) => setImmediate(resolve));\n };\n for (const value of values) {\n // JSON.stringify renders undefined array entries as null.\n batch.push(JSON.stringify(stableJsonValue(value)) ?? \"null\");\n if (batch.length >= STABLE_HASH_ARRAY_CHUNK) await flush();\n }\n if (batch.length > 0) hash.update(`${first ? \"\" : \",\"}${batch.join(\",\")}`);\n hash.update(\"]\");\n return hash.digest(\"hex\");\n};\n"],
5
- "mappings": ";AAAA,SAAS,kBAAkB;AAO3B,IAAM,kBAAkB,CAAC,UAA4B;AACnD,MAAI,MAAM,QAAQ,KAAK,EAAG,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AI,MAAM,QAAQ,KAAK,EAAG,QAAO,MAAM,IAAI,eAAe;AAC1D,MAAI,iBAAiB,IAAK,QAAO,MAAM;AACvC,MAAI,UAAU,QAAQ,OAAO,UAAU,SAAU,QAAO;AACxD,SAAO,OAAO;AAAA,IACZ,OAAO,QAAQ,KAAgC,EAC5C,KAAK,CAAC,CAAC,IAAI,GAAG,CAAC,KAAK,MAAM,KAAK,cAAc,KAAK,CAAC,EACnD,IAAI,CAAC,CAAC,KAAK,MAAM,MAAM,CAAC,KAAK,gBAAgB,MAAM,CAAC,CAAC;AAAA,EAC1D;AACF;AAEO,IAAM,iBAAiB,CAAC,UAC7B,WAAW,QAAQ,EAAE,OAAO,KAAK,UAAU,gBAAgB,KAAK,CAAC,CAAC,EAAE,OAAO,KAAK;",
6
6
  "names": []
7
7
  }
@@ -1,11 +1,206 @@
1
- import {
2
- COMPILED_SURFACE_VERSION,
3
- MAX_COMPILED_SURFACE_PROPOSALS
4
- } from "./chunk-FMLK3ZA7.js";
5
1
  import {
6
2
  writeJsonAtomic,
7
3
  writeJsonAtomicAsync
8
4
  } from "./chunk-KAD7UWT2.js";
5
+ import {
6
+ MAX_NORMAL_FORM_PLANS,
7
+ isNormalFormPlan,
8
+ provesNormalFormPlan
9
+ } from "./chunk-T3UYWHLT.js";
10
+ import {
11
+ stableJsonHash
12
+ } from "./chunk-3YZUQESG.js";
13
+
14
+ // src/entropy/types.ts
15
+ var ENTROPY_METRIC_VERSION = 3;
16
+ var ENTROPY_WEIGHTS = {
17
+ shape: 1,
18
+ failureStage: 1,
19
+ churn: 4,
20
+ navigation: 4,
21
+ flow: 1,
22
+ lexicon: 2,
23
+ staticFreedom: 0.25
24
+ };
25
+ var ENTROPY_INVOCATION_STAGES = ["resolve", "prepare", "validate"];
26
+
27
+ // src/entropy/compiled-surface.ts
28
+ import { Value } from "typebox/value";
29
+ var COMPILED_SURFACE_VERSION = 2;
30
+ var MAX_COMPILED_SURFACE_PROPOSALS = 256;
31
+ var emptyCompiledSurface = () => ({
32
+ version: COMPILED_SURFACE_VERSION,
33
+ metricVersion: ENTROPY_METRIC_VERSION,
34
+ actions: [],
35
+ quarantined: [],
36
+ normalizations: [],
37
+ applied: [],
38
+ gate: { passed: true, beforeScore: 0, afterScore: 0, reasons: [] },
39
+ evidenceDigest: stableJsonHash([])
40
+ });
41
+ var compiledSurfaceEffectChanged = (before, after) => stableJsonHash(before?.version === COMPILED_SURFACE_VERSION ? before.normalizations ?? [] : []) !== stableJsonHash(after.version === COMPILED_SURFACE_VERSION ? after.normalizations ?? [] : []);
42
+ var isPlainRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
43
+ var schemaDigest = (schema) => stableJsonHash(schema);
44
+ var effectiveSchemaFor = (_ref, liveSchema, _file) => liveSchema;
45
+ var applyCompiledSurface = (live, _file) => live;
46
+ var quarantinedRefNames = (_file) => /* @__PURE__ */ new Set();
47
+ var isQuarantinedRef = (_ref, _liveSchema, _file) => false;
48
+ var mergeCompiledSurfaces = (local, incoming, live) => {
49
+ const schemas = new Map(live.actions.map((action) => [action.ref, action.inputSchema]));
50
+ const plans = /* @__PURE__ */ new Map();
51
+ let droppedNormalizations = 0;
52
+ for (const file of [local, incoming]) {
53
+ if (!file || file.version !== COMPILED_SURFACE_VERSION) continue;
54
+ for (const plan of file.normalizations ?? []) {
55
+ if (!provesNormalFormPlan(plan, schemas.get(plan.ref))) {
56
+ droppedNormalizations++;
57
+ continue;
58
+ }
59
+ if (plans.size >= MAX_NORMAL_FORM_PLANS || plans.has(plan.ref)) continue;
60
+ plans.set(plan.ref, plan);
61
+ }
62
+ }
63
+ const normalizations = [...plans.values()].sort((a, b) => a.ref < b.ref ? -1 : a.ref > b.ref ? 1 : 0);
64
+ return {
65
+ file: {
66
+ ...emptyCompiledSurface(),
67
+ normalizations,
68
+ applied: normalizations.slice(0, MAX_COMPILED_SURFACE_PROPOSALS).map((plan) => ({ kind: "normal-form", ref: plan.ref, detail: `${plan.rules.length} proven rules` })),
69
+ evidenceDigest: stableJsonHash(normalizations)
70
+ },
71
+ droppedOverlays: (local?.actions.length ?? 0) + incoming.actions.length,
72
+ droppedQuarantines: (local?.quarantined.length ?? 0) + incoming.quarantined.length,
73
+ droppedNormalizations
74
+ };
75
+ };
76
+ var replaySuccessfulCalls = (surface, before, traces, touchedRefs, auditCalls) => {
77
+ const schemaByRef = new Map(surface.actions.map((action) => [action.ref, action.inputSchema]));
78
+ const beforeByRef = new Map(before.actions.map((action) => [action.ref, action.inputSchema]));
79
+ const accepts = (schema, args) => {
80
+ try {
81
+ return isPlainRecord(schema) && Value.Check(schema, args);
82
+ } catch {
83
+ return false;
84
+ }
85
+ };
86
+ const violations = [];
87
+ const auditedRefs = /* @__PURE__ */ new Set();
88
+ if (auditCalls) {
89
+ const auditArgsByRef = /* @__PURE__ */ new Map();
90
+ for (const call of auditCalls) {
91
+ if (!touchedRefs.has(call.ref)) continue;
92
+ const bucket = auditArgsByRef.get(call.ref) ?? [];
93
+ bucket.push(call.args);
94
+ auditArgsByRef.set(call.ref, bucket);
95
+ }
96
+ for (const [ref, argsList] of auditArgsByRef) {
97
+ auditedRefs.add(ref);
98
+ const schema = schemaByRef.get(ref);
99
+ if (schema === void 0) {
100
+ violations.push({ ref, reason: "absent from the candidate surface" });
101
+ continue;
102
+ }
103
+ const declared = beforeByRef.get(ref);
104
+ for (const args of argsList) {
105
+ if (declared !== void 0 && !accepts(declared, args)) continue;
106
+ if (!accepts(schema, args)) {
107
+ violations.push({
108
+ ref,
109
+ reason: "recorded arguments no longer validate against the compiled schema"
110
+ });
111
+ }
112
+ }
113
+ }
114
+ }
115
+ for (const sourceTrace of traces) {
116
+ for (const operation of sourceTrace.operations) {
117
+ if (operation.outcome !== "succeeded") continue;
118
+ if (operation.ref.startsWith("fabric.")) continue;
119
+ if (!touchedRefs.has(operation.ref)) continue;
120
+ if (auditedRefs.has(operation.ref)) continue;
121
+ const schema = schemaByRef.get(operation.ref);
122
+ if (schema === void 0) {
123
+ violations.push({ ref: operation.ref, reason: "absent from the candidate surface" });
124
+ continue;
125
+ }
126
+ if (!accepts(schema, operation.args)) {
127
+ violations.push({
128
+ ref: operation.ref,
129
+ reason: "recorded arguments no longer validate against the compiled schema"
130
+ });
131
+ }
132
+ }
133
+ }
134
+ return violations;
135
+ };
136
+ var COOPERATIVE_REPLAY_CHUNK = 64;
137
+ var replayYield = () => new Promise((resolve) => setImmediate(resolve));
138
+ var replaySuccessfulCallsAsync = async (surface, before, traces, touchedRefs, auditCalls) => {
139
+ const schemaByRef = new Map(surface.actions.map((action) => [action.ref, action.inputSchema]));
140
+ const beforeByRef = new Map(before.actions.map((action) => [action.ref, action.inputSchema]));
141
+ const accepts = (schema, args) => {
142
+ try {
143
+ return isPlainRecord(schema) && Value.Check(schema, args);
144
+ } catch {
145
+ return false;
146
+ }
147
+ };
148
+ const violations = [];
149
+ const auditedRefs = /* @__PURE__ */ new Set();
150
+ let processed = 0;
151
+ await replayYield();
152
+ if (auditCalls) {
153
+ const auditArgsByRef = /* @__PURE__ */ new Map();
154
+ for (const call of auditCalls) {
155
+ if (touchedRefs.has(call.ref)) {
156
+ const bucket = auditArgsByRef.get(call.ref) ?? [];
157
+ bucket.push(call.args);
158
+ auditArgsByRef.set(call.ref, bucket);
159
+ }
160
+ processed += 1;
161
+ if (processed % COOPERATIVE_REPLAY_CHUNK === 0) await replayYield();
162
+ }
163
+ for (const [ref, argsList] of auditArgsByRef) {
164
+ auditedRefs.add(ref);
165
+ const schema = schemaByRef.get(ref);
166
+ if (schema === void 0) {
167
+ violations.push({ ref, reason: "absent from the candidate surface" });
168
+ continue;
169
+ }
170
+ const declared = beforeByRef.get(ref);
171
+ for (const args of argsList) {
172
+ if (declared === void 0 || accepts(declared, args)) {
173
+ if (!accepts(schema, args)) {
174
+ violations.push({
175
+ ref,
176
+ reason: "recorded arguments no longer validate against the compiled schema"
177
+ });
178
+ }
179
+ }
180
+ processed += 1;
181
+ if (processed % COOPERATIVE_REPLAY_CHUNK === 0) await replayYield();
182
+ }
183
+ }
184
+ }
185
+ for (const sourceTrace of traces) {
186
+ for (const operation of sourceTrace.operations) {
187
+ if (operation.outcome === "succeeded" && !operation.ref.startsWith("fabric.") && touchedRefs.has(operation.ref) && !auditedRefs.has(operation.ref)) {
188
+ const schema = schemaByRef.get(operation.ref);
189
+ if (schema === void 0) {
190
+ violations.push({ ref: operation.ref, reason: "absent from the candidate surface" });
191
+ } else if (!accepts(schema, operation.args)) {
192
+ violations.push({
193
+ ref: operation.ref,
194
+ reason: "recorded arguments no longer validate against the compiled schema"
195
+ });
196
+ }
197
+ }
198
+ processed += 1;
199
+ if (processed % COOPERATIVE_REPLAY_CHUNK === 0) await replayYield();
200
+ }
201
+ }
202
+ return violations;
203
+ };
9
204
 
10
205
  // src/entropy/compiled-store.ts
11
206
  import fs2 from "node:fs";
@@ -277,7 +472,7 @@ var parseAppliedProposal = (value) => {
277
472
  };
278
473
  var parseGateRecord = (value) => {
279
474
  if (!isRecord(value) || typeof value.passed !== "boolean") return void 0;
280
- if (typeof value.beforeScore !== "number" || typeof value.afterScore !== "number") {
475
+ if (typeof value.beforeScore !== "number" || typeof value.afterScore !== "number" || !Number.isFinite(value.beforeScore) || !Number.isFinite(value.afterScore)) {
281
476
  return void 0;
282
477
  }
283
478
  if (!Array.isArray(value.reasons) || !value.reasons.every((r) => typeof r === "string")) {
@@ -291,7 +486,11 @@ var parseGateRecord = (value) => {
291
486
  };
292
487
  };
293
488
  var parseCompiledSurfaceFile = (value) => {
294
- if (!isRecord(value) || value.version !== COMPILED_SURFACE_VERSION) return void 0;
489
+ if (!isRecord(value) || value.version !== 1 && value.version !== COMPILED_SURFACE_VERSION) return void 0;
490
+ if (value.version === COMPILED_SURFACE_VERSION) {
491
+ if (!Array.isArray(value.normalizations) || value.normalizations.length > MAX_NORMAL_FORM_PLANS || !value.normalizations.every(isNormalFormPlan) || new Set(value.normalizations.map((plan) => plan.ref)).size !== value.normalizations.length) return void 0;
492
+ if (!Array.isArray(value.actions) || value.actions.length !== 0 || !Array.isArray(value.quarantined) || value.quarantined.length !== 0) return void 0;
493
+ }
295
494
  if (!Number.isSafeInteger(value.metricVersion) || value.metricVersion < 1) {
296
495
  return void 0;
297
496
  }
@@ -313,7 +512,8 @@ var parseCompiledSurfaceFile = (value) => {
313
512
  overlaySeen.add(parsed.ref);
314
513
  }
315
514
  return {
316
- version: COMPILED_SURFACE_VERSION,
515
+ version: value.version,
516
+ ...value.version === COMPILED_SURFACE_VERSION ? { normalizations: value.normalizations } : {},
317
517
  metricVersion: value.metricVersion,
318
518
  actions: value.actions.map((entry) => parseOverlayEntry(entry)),
319
519
  quarantined: value.quarantined.map((entry) => parseQuarantineEntry(entry)),
@@ -415,6 +615,21 @@ var saveCompiledSurfaceAsync = async (agentDir, file) => withExclusiveFileLockAs
415
615
  );
416
616
 
417
617
  export {
618
+ ENTROPY_METRIC_VERSION,
619
+ ENTROPY_WEIGHTS,
620
+ ENTROPY_INVOCATION_STAGES,
621
+ COMPILED_SURFACE_VERSION,
622
+ MAX_COMPILED_SURFACE_PROPOSALS,
623
+ emptyCompiledSurface,
624
+ compiledSurfaceEffectChanged,
625
+ schemaDigest,
626
+ effectiveSchemaFor,
627
+ applyCompiledSurface,
628
+ quarantinedRefNames,
629
+ isQuarantinedRef,
630
+ mergeCompiledSurfaces,
631
+ replaySuccessfulCalls,
632
+ replaySuccessfulCallsAsync,
418
633
  withExclusiveFileLockAsync,
419
634
  withExclusiveFileLock,
420
635
  compiledSurfaceDirectory,
@@ -424,4 +639,4 @@ export {
424
639
  saveCompiledSurface,
425
640
  saveCompiledSurfaceAsync
426
641
  };
427
- //# sourceMappingURL=chunk-H6FEQL2D.js.map
642
+ //# sourceMappingURL=chunk-5MDFFHOO.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/entropy/types.ts", "../../src/entropy/compiled-surface.ts", "../../src/entropy/compiled-store.ts", "../../src/core/file-lock.ts"],
4
+ "sourcesContent": ["// Deterministic tool-entropy measurement for the Fabric tool surface.\n//\n// The operational score is an invocation rejection fraction, not bits.\n// Shape, failure-stage, flow, churn, navigation, lexicon, and schema freedom\n// remain separate diagnostics from typed traces, repairs, and live schemas.\n// No model judges anything; identical inputs and metric version give the\n// same report. Derived metrics are rounded to six decimal places.\n\nexport const ENTROPY_METRIC_VERSION = 3 as const;\n\n// Legacy diagnostic weights retained for export compatibility. In v3 only\n// staticFreedom scales staticScore; none contribute to the operational score.\n// Changes to metric formulas require an ENTROPY_METRIC_VERSION bump.\nexport const ENTROPY_WEIGHTS = {\n shape: 1,\n failureStage: 1,\n churn: 4,\n navigation: 4,\n flow: 1,\n lexicon: 2,\n staticFreedom: 0.25,\n} as const;\n\n// Failure stages that mean \"the surface rejected the call before it could\n// take effect\" \u2014 the offline residue class behind repair fingerprints.\nexport const ENTROPY_INVOCATION_STAGES: readonly string[] = [\"resolve\", \"prepare\", \"validate\"];\n\nexport type EntropyOutcome = \"succeeded\" | \"failed\" | \"aborted\" | \"timed_out\";\n\nexport interface EntropySurfaceAction {\n ref: string;\n inputSchema: unknown;\n}\n\nexport interface EntropySurfaceSnapshot {\n version: 1;\n actions: EntropySurfaceAction[];\n}\n\nexport interface EntropyOperationInput {\n ref: string;\n args: Record<string, unknown>;\n outcome: EntropyOutcome;\n failureStage?: string;\n normalization?: import(\"./normal-form.js\").NormalFormWitness;\n}\n\nexport interface EntropyTraceInput {\n operations: EntropyOperationInput[];\n taskKey?: string;\n /** Producing model, stamped from the session scan as `provider/modelId`. */\n model?: string;\n}\n\n// Normalized compatibility alias: `ref` is the canonical target the row\n// repairs toward.\nexport interface EntropyRepairRowInput {\n kind: \"keyAlias\" | \"actionAlias\";\n ref: string;\n from: string;\n to: string;\n}\n\n// One verbatim argument value observed in persisted audits: the value-level\n// corpus for enum-tighten. Trace V1 projects values away per ref; audits\n// carry every argument the call actually used. Pooled observations carry\n// `count` multiplicity instead of one entry per call.\nexport interface EntropyValueObservation {\n ref: string;\n key: string;\n value: string | number | boolean;\n /** Observation multiplicity; window scans emit one entry per call, pools emit one per distinct value. */\n count?: number;\n}\n\n// One verbatim call per persisted audit: the authoritative record of the\n// arguments a call actually used. Trace V1 projects values away per ref, so\n// replay validation consults these, never the projected trace args.\nexport interface EntropyAuditCall {\n ref: string;\n args: Record<string, unknown>;\n}\n\nexport interface EntropyShapeSignature {\n signature: string;\n count: number;\n}\n\nexport interface EntropyRefReport {\n ref: string;\n calls: number;\n succeeded: number;\n failed: number;\n shapeSignatures: EntropyShapeSignature[];\n /** Shannon entropy of argument shapes, in bits. */\n shapeEntropyBits: number;\n /** Shannon entropy of failed-call stages, in bits. */\n failureStageEntropyBits: number;\n /** Mean normalized shape distance between a failure and the next same-ref call. */\n churnRate: number;\n /** Count of repair rows targeting this ref. */\n lexiconRows: number;\n /** Heuristic schema-freedom units; zero for an unknown schema. */\n staticFreedom: number;\n /** Invocation rejections / calls, a fraction in [0, 1]. */\n score: number;\n}\n\nexport interface EntropyTotals {\n traces: number;\n operations: number;\n actionOperations: number;\n discoveryOperations: number;\n workflowOperations: number;\n succeeded: number;\n failed: number;\n aborted: number;\n timedOut: number;\n invocationRejections: number;\n invocationRejectionsPer1k: number;\n}\n\n// Per-model behavioral attribution over stamped traces only.\nexport interface EntropyModelReport {\n model: string;\n operations: number;\n actionOperations: number;\n succeeded: number;\n invocationRejections: number;\n invocationRejectionsPer1k: number;\n /** Invocation rejections / action operations for this model, in [0, 1]; zero if none. */\n behavioralScore: number;\n}\n\nexport interface EntropyReport {\n metricVersion: typeof ENTROPY_METRIC_VERSION;\n catalogDigest: string;\n totals: EntropyTotals;\n /** Call-weighted mean per-ref shape entropy, in bits. */\n shapeEntropyBits: number;\n /** Failed-call-weighted mean per-ref failure-stage entropy, in bits. */\n failureStageEntropyBits: number;\n /** Mean normalized failure-to-next-same-ref shape distance within traces. */\n churnRate: number;\n /** Discovery operations / action operations; zero without action operations. */\n navigationRatio: number;\n /** Trace-weighted mean per-task action-sequence entropy, in bits. */\n flowEntropyBits: number;\n /** Total count of supplied repair rows. */\n lexiconRows: number;\n /** Sum of heuristic schema-freedom units over distinct called refs. */\n staticFreedom: number;\n /** 0.25 \u00D7 call-weighted mean schema freedom; unknown schemas contribute zero.\n * Diagnostic only, zero without action calls; never added to score. */\n staticScore: number;\n /** Identical to score: invocation rejection fraction, not entropy bits. */\n behavioralScore: number;\n /** Failed resolve/prepare/validate calls / all action operations, in [0, 1].\n * Zero without action operations. Discovery/workflow operations are excluded. */\n score: number;\n refs: EntropyRefReport[];\n /** Behavioral attribution per producing model; empty when no trace carries one. */\n byModel: EntropyModelReport[];\n}\n\nexport type EntropyProposal =\n | {\n kind: \"normal-form\";\n ref: string;\n baseSchemaDigest: string;\n rules: import(\"./normal-form.js\").NormalFormRule[];\n }\n | {\n kind: \"enum-tighten\";\n ref: string;\n key: string;\n values: (string | number | boolean)[];\n calls: number;\n distinct: number;\n topShare: number;\n }\n | {\n kind: \"declare-enum\";\n ref: string;\n key: string;\n values: (string | number | boolean)[];\n calls: number;\n distinct: number;\n topShare: number;\n }\n | {\n kind: \"overload-split\";\n ref: string;\n shapeEntropyBits: number;\n clusters: { keys: string[]; calls: number }[];\n }\n | {\n kind: \"sequence-fuse\";\n sequence: string[];\n occurrences: number;\n }\n | {\n kind: \"noise-quarantine\";\n ref: string;\n calls: number;\n succeeded: number;\n failed: number;\n failureStageEntropyBits: number;\n };\n\nexport interface EntropyGateResult {\n passed: boolean;\n beforeScore: number;\n afterScore: number;\n delta: number;\n reasons: string[];\n}\n\n// Trend of a score sequence, oldest to newest: the ratchet's line. A\n// negative slopePerStep means the surface is compiling down.\nexport interface EntropyTrend {\n count: number;\n first?: number;\n last?: number;\n slopePerStep: number;\n}\n", "// Version 2 compiles compatibility normal forms, never schema restrictions.\n// Version 1 restriction artifacts remain readable for migration but are inert.\nimport { Value } from \"typebox/value\";\nimport { stableJsonHash } from \"../core/stable-hash.js\";\nimport { ENTROPY_METRIC_VERSION } from \"./types.js\";\nimport { MAX_NORMAL_FORM_PLANS, provesNormalFormPlan, type NormalFormPlan } from \"./normal-form.js\";\nimport type { EntropyAuditCall, EntropyProposal, EntropySurfaceSnapshot, EntropyTraceInput } from \"./types.js\";\n\nexport const COMPILED_SURFACE_VERSION = 2 as const;\nexport const MAX_COMPILED_SURFACE_PROPOSALS = 256;\nexport interface CompiledSurfaceOverlayEntry {\n ref: string;\n inputSchema: Record<string, unknown>;\n baseSchemaDigest: string;\n}\nexport interface CompiledSurfaceQuarantineEntry { ref: string; baseSchemaDigest: string }\nexport interface CompiledSurfaceAppliedProposal { kind: EntropyProposal[\"kind\"]; ref: string; detail: string }\nexport interface CompiledSurfaceGateRecord { passed: boolean; beforeScore: number; afterScore: number; reasons: string[] }\nexport interface CompiledSurfaceFile {\n version: 1 | typeof COMPILED_SURFACE_VERSION;\n metricVersion: number;\n /** Legacy restrictions are retained only when reading version 1. Never enforced. */\n actions: CompiledSurfaceOverlayEntry[];\n quarantined: CompiledSurfaceQuarantineEntry[];\n normalizations?: NormalFormPlan[];\n applied: CompiledSurfaceAppliedProposal[];\n gate: CompiledSurfaceGateRecord;\n evidenceDigest: string;\n}\n\nexport const emptyCompiledSurface = (): CompiledSurfaceFile => ({\n version: COMPILED_SURFACE_VERSION, metricVersion: ENTROPY_METRIC_VERSION,\n actions: [], quarantined: [], normalizations: [], applied: [],\n gate: { passed: true, beforeScore: 0, afterScore: 0, reasons: [] },\n evidenceDigest: stableJsonHash([]),\n});\nexport const compiledSurfaceEffectChanged = (before: CompiledSurfaceFile | undefined, after: CompiledSurfaceFile): boolean =>\n stableJsonHash(before?.version === COMPILED_SURFACE_VERSION ? before.normalizations ?? [] : []) !==\n stableJsonHash(after.version === COMPILED_SURFACE_VERSION ? after.normalizations ?? [] : []);\nconst isPlainRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\nexport const schemaDigest = (schema: unknown): string => stableJsonHash(schema);\n\n// These compatibility APIs deliberately preserve the entire declaration.\n// Neither a legacy artifact nor an imported schema may remove capabilities.\nexport const effectiveSchemaFor = (_ref: string, liveSchema: unknown, _file?: CompiledSurfaceFile): unknown => liveSchema;\nexport const applyCompiledSurface = (live: EntropySurfaceSnapshot, _file?: CompiledSurfaceFile): EntropySurfaceSnapshot => live;\nexport const quarantinedRefNames = (_file?: CompiledSurfaceFile): ReadonlySet<string> => new Set();\nexport const isQuarantinedRef = (_ref: string, _liveSchema: unknown, _file?: CompiledSurfaceFile): boolean => false;\n\nexport interface MergedCompiledSurface {\n file: CompiledSurfaceFile;\n droppedOverlays: number;\n droppedQuarantines: number;\n droppedNormalizations: number;\n}\n\n// Import proves the complete rule plan by re-derivation, not merely a base\n// digest. Forged rule kinds/targets, drift, and every legacy restriction drop.\nexport const mergeCompiledSurfaces = (\n local: CompiledSurfaceFile | undefined,\n incoming: CompiledSurfaceFile,\n live: EntropySurfaceSnapshot,\n): MergedCompiledSurface => {\n const schemas = new Map(live.actions.map((action) => [action.ref, action.inputSchema]));\n const plans = new Map<string, NormalFormPlan>();\n let droppedNormalizations = 0;\n for (const file of [local, incoming]) {\n if (!file || file.version !== COMPILED_SURFACE_VERSION) continue;\n for (const plan of file.normalizations ?? []) {\n if (!provesNormalFormPlan(plan, schemas.get(plan.ref))) { droppedNormalizations++; continue; }\n if (plans.size >= MAX_NORMAL_FORM_PLANS || plans.has(plan.ref)) continue;\n plans.set(plan.ref, plan);\n }\n }\n const normalizations = [...plans.values()].sort((a, b) => a.ref < b.ref ? -1 : a.ref > b.ref ? 1 : 0);\n return {\n file: {\n ...emptyCompiledSurface(), normalizations,\n applied: normalizations.slice(0, MAX_COMPILED_SURFACE_PROPOSALS).map((plan) => ({ kind: \"normal-form\", ref: plan.ref, detail: `${plan.rules.length} proven rules` })),\n evidenceDigest: stableJsonHash(normalizations),\n },\n droppedOverlays: (local?.actions.length ?? 0) + incoming.actions.length,\n droppedQuarantines: (local?.quarantined.length ?? 0) + incoming.quarantined.length,\n droppedNormalizations,\n };\n};\n\nexport interface ReplayViolation {\n ref: string;\n reason: string;\n}\n\n// Replay preservation: every successful call to a ref the compile touched\n// must still parse against the candidate surface \u2014 resolution plus the same\n// TypeBox check the registry's validate stage uses. Untouched refs keep\n// their schema by identity, so replay stays scoped to the touched set.\n// When a touched ref has verbatim audit calls, they are the replay corpus:\n// trace V1 projects values away per ref, so validating the projected trace\n// args would phantom-reject calls that actually parsed. Audits the declared\n// surface already rejected are not protected \u2014 those calls never executed,\n// so no compile can invalidate them.\nexport const replaySuccessfulCalls = (\n surface: EntropySurfaceSnapshot,\n before: EntropySurfaceSnapshot,\n traces: readonly EntropyTraceInput[],\n touchedRefs: ReadonlySet<string>,\n auditCalls?: readonly EntropyAuditCall[],\n): ReplayViolation[] => {\n const schemaByRef = new Map(surface.actions.map((action) => [action.ref, action.inputSchema]));\n const beforeByRef = new Map(before.actions.map((action) => [action.ref, action.inputSchema]));\n const accepts = (schema: unknown, args: Record<string, unknown>): boolean => {\n try {\n return isPlainRecord(schema) && Value.Check(schema, args);\n } catch {\n return false;\n }\n };\n const violations: ReplayViolation[] = [];\n const auditedRefs = new Set<string>();\n if (auditCalls) {\n const auditArgsByRef = new Map<string, Record<string, unknown>[]>();\n for (const call of auditCalls) {\n if (!touchedRefs.has(call.ref)) continue;\n const bucket = auditArgsByRef.get(call.ref) ?? [];\n bucket.push(call.args);\n auditArgsByRef.set(call.ref, bucket);\n }\n for (const [ref, argsList] of auditArgsByRef) {\n auditedRefs.add(ref);\n const schema = schemaByRef.get(ref);\n if (schema === undefined) {\n violations.push({ ref, reason: \"absent from the candidate surface\" });\n continue;\n }\n const declared = beforeByRef.get(ref);\n for (const args of argsList) {\n if (declared !== undefined && !accepts(declared, args)) continue;\n if (!accepts(schema, args)) {\n violations.push({\n ref,\n reason: \"recorded arguments no longer validate against the compiled schema\",\n });\n }\n }\n }\n }\n for (const sourceTrace of traces) {\n for (const operation of sourceTrace.operations) {\n if (operation.outcome !== \"succeeded\") continue;\n if (operation.ref.startsWith(\"fabric.\")) continue;\n if (!touchedRefs.has(operation.ref)) continue;\n if (auditedRefs.has(operation.ref)) continue;\n const schema = schemaByRef.get(operation.ref);\n if (schema === undefined) {\n violations.push({ ref: operation.ref, reason: \"absent from the candidate surface\" });\n continue;\n }\n if (!accepts(schema, operation.args)) {\n violations.push({\n ref: operation.ref,\n reason: \"recorded arguments no longer validate against the compiled schema\",\n });\n }\n }\n }\n return violations;\n};\n\nconst COOPERATIVE_REPLAY_CHUNK = 64;\n\nconst replayYield = (): Promise<void> =>\n new Promise((resolve) => setImmediate(resolve));\n\n// Hook-safe replay gate. The ordering and validation rules match the pure\n// certification path exactly, with fixed operation chunks between TUI turns.\nexport const replaySuccessfulCallsAsync = async (\n surface: EntropySurfaceSnapshot,\n before: EntropySurfaceSnapshot,\n traces: readonly EntropyTraceInput[],\n touchedRefs: ReadonlySet<string>,\n auditCalls?: readonly EntropyAuditCall[],\n): Promise<ReplayViolation[]> => {\n const schemaByRef = new Map(surface.actions.map((action) => [action.ref, action.inputSchema]));\n const beforeByRef = new Map(before.actions.map((action) => [action.ref, action.inputSchema]));\n const accepts = (schema: unknown, args: Record<string, unknown>): boolean => {\n try {\n return isPlainRecord(schema) && Value.Check(schema, args);\n } catch {\n return false;\n }\n };\n const violations: ReplayViolation[] = [];\n const auditedRefs = new Set<string>();\n let processed = 0;\n await replayYield();\n if (auditCalls) {\n const auditArgsByRef = new Map<string, Record<string, unknown>[]>();\n for (const call of auditCalls) {\n if (touchedRefs.has(call.ref)) {\n const bucket = auditArgsByRef.get(call.ref) ?? [];\n bucket.push(call.args);\n auditArgsByRef.set(call.ref, bucket);\n }\n processed += 1;\n if (processed % COOPERATIVE_REPLAY_CHUNK === 0) await replayYield();\n }\n for (const [ref, argsList] of auditArgsByRef) {\n auditedRefs.add(ref);\n const schema = schemaByRef.get(ref);\n if (schema === undefined) {\n violations.push({ ref, reason: \"absent from the candidate surface\" });\n continue;\n }\n const declared = beforeByRef.get(ref);\n for (const args of argsList) {\n if (declared === undefined || accepts(declared, args)) {\n if (!accepts(schema, args)) {\n violations.push({\n ref,\n reason: \"recorded arguments no longer validate against the compiled schema\",\n });\n }\n }\n processed += 1;\n if (processed % COOPERATIVE_REPLAY_CHUNK === 0) await replayYield();\n }\n }\n }\n for (const sourceTrace of traces) {\n for (const operation of sourceTrace.operations) {\n if (\n operation.outcome === \"succeeded\" &&\n !operation.ref.startsWith(\"fabric.\") &&\n touchedRefs.has(operation.ref) &&\n !auditedRefs.has(operation.ref)\n ) {\n const schema = schemaByRef.get(operation.ref);\n if (schema === undefined) {\n violations.push({ ref: operation.ref, reason: \"absent from the candidate surface\" });\n } else if (!accepts(schema, operation.args)) {\n violations.push({\n ref: operation.ref,\n reason: \"recorded arguments no longer validate against the compiled schema\",\n });\n }\n }\n processed += 1;\n if (processed % COOPERATIVE_REPLAY_CHUNK === 0) await replayYield();\n }\n }\n return violations;\n};\n", "// Persistence for the compiled entropy surface: <agent dir>/fabric/entropy/\n// compiled.json, locked across Pi processes sharing the agent directory.\n// A damaged artifact surfaces as an error and blocks compiles from\n// overwriting it \u2014 the same discipline as the repair table. The artifact is\n// clock-free, so saving byte-identical content is a no-op.\n\nimport fs from \"node:fs\";\nimport { isNormalFormPlan, MAX_NORMAL_FORM_PLANS } from \"./normal-form.js\";\nimport path from \"node:path\";\nimport { writeJsonAtomic, writeJsonAtomicAsync } from \"../core/atomic-write.js\";\nimport { withExclusiveFileLock, withExclusiveFileLockAsync } from \"../core/file-lock.js\";\nimport {\n COMPILED_SURFACE_VERSION,\n MAX_COMPILED_SURFACE_PROPOSALS,\n type CompiledSurfaceAppliedProposal,\n type CompiledSurfaceFile,\n type CompiledSurfaceGateRecord,\n type CompiledSurfaceOverlayEntry,\n type CompiledSurfaceQuarantineEntry,\n} from \"./compiled-surface.js\";\n\nconst COMPILED_LOCK_ATTEMPTS = 50;\nconst COMPILED_LOCK_DELAY_MS = 5;\nconst COMPILED_STALE_LOCK_MS = 30_000;\n\nexport const compiledSurfaceDirectory = (agentDir: string): string =>\n path.join(agentDir, \"fabric\", \"entropy\");\n\nconst compiledPath = (directory: string): string => path.join(directory, \"compiled.json\");\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nconst errorCode = (error: unknown): string | undefined =>\n isRecord(error) && typeof error.code === \"string\" ? error.code : undefined;\n\nconst errorText = (error: unknown): string =>\n (error instanceof Error ? error.message : String(error)).slice(0, 200);\n\nconst parseOverlayEntry = (value: unknown): CompiledSurfaceOverlayEntry | undefined => {\n if (!isRecord(value) || typeof value.ref !== \"string\" || !value.ref.trim()) return undefined;\n if (!isRecord(value.inputSchema)) return undefined;\n if (typeof value.baseSchemaDigest !== \"string\" || !value.baseSchemaDigest.trim()) {\n return undefined;\n }\n return {\n ref: value.ref.trim(),\n inputSchema: value.inputSchema,\n baseSchemaDigest: value.baseSchemaDigest.trim(),\n };\n};\n\nconst parseQuarantineEntry = (value: unknown): CompiledSurfaceQuarantineEntry | undefined => {\n if (!isRecord(value) || typeof value.ref !== \"string\" || !value.ref.trim()) return undefined;\n if (typeof value.baseSchemaDigest !== \"string\" || !value.baseSchemaDigest.trim()) {\n return undefined;\n }\n return { ref: value.ref.trim(), baseSchemaDigest: value.baseSchemaDigest.trim() };\n};\n\nconst parseAppliedProposal = (value: unknown): CompiledSurfaceAppliedProposal | undefined => {\n if (!isRecord(value)) return undefined;\n if (typeof value.kind !== \"string\" || !value.kind.trim()) return undefined;\n if (typeof value.ref !== \"string\" || !value.ref.trim()) return undefined;\n if (typeof value.detail !== \"string\" || !value.detail.trim()) return undefined;\n return {\n kind: value.kind.trim() as CompiledSurfaceAppliedProposal[\"kind\"],\n ref: value.ref.trim(),\n detail: value.detail.trim(),\n };\n};\n\nconst parseGateRecord = (value: unknown): CompiledSurfaceGateRecord | undefined => {\n if (!isRecord(value) || typeof value.passed !== \"boolean\") return undefined;\n if (typeof value.beforeScore !== \"number\" || typeof value.afterScore !== \"number\" ||\n !Number.isFinite(value.beforeScore) || !Number.isFinite(value.afterScore)) {\n return undefined;\n }\n if (!Array.isArray(value.reasons) || !value.reasons.every((r) => typeof r === \"string\")) {\n return undefined;\n }\n return {\n passed: value.passed,\n beforeScore: value.beforeScore,\n afterScore: value.afterScore,\n reasons: value.reasons,\n };\n};\n\n// Version 1 is accepted only as inert migration data. Version 2 cannot carry\n// restrictions. Its bounded plans are re-proved against live schemas at use;\n// a persisted gate flag or metric version never grants execution authority.\nconst parseCompiledSurfaceFile = (value: unknown): CompiledSurfaceFile | undefined => {\n if (!isRecord(value) || (value.version !== 1 && value.version !== COMPILED_SURFACE_VERSION)) return undefined;\n if (value.version === COMPILED_SURFACE_VERSION) {\n if (!Array.isArray(value.normalizations) || value.normalizations.length > MAX_NORMAL_FORM_PLANS ||\n !value.normalizations.every(isNormalFormPlan) ||\n new Set(value.normalizations.map((plan) => plan.ref)).size !== value.normalizations.length) return undefined;\n if (!Array.isArray(value.actions) || value.actions.length !== 0 ||\n !Array.isArray(value.quarantined) || value.quarantined.length !== 0) return undefined;\n }\n if (!Number.isSafeInteger(value.metricVersion) || (value.metricVersion as number) < 1) {\n return undefined;\n }\n if (!Array.isArray(value.actions) || !value.actions.every((entry) => parseOverlayEntry(entry))) {\n return undefined;\n }\n if (\n !Array.isArray(value.quarantined) ||\n !value.quarantined.every((entry) => parseQuarantineEntry(entry))\n ) {\n return undefined;\n }\n if (\n !Array.isArray(value.applied) ||\n value.applied.length > MAX_COMPILED_SURFACE_PROPOSALS ||\n !value.applied.every((entry) => parseAppliedProposal(entry))\n ) {\n return undefined;\n }\n if (!parseGateRecord(value.gate)) return undefined;\n if (typeof value.evidenceDigest !== \"string\" || !value.evidenceDigest.trim()) return undefined;\n const overlaySeen = new Set<string>();\n for (const entry of value.actions) {\n const parsed = parseOverlayEntry(entry)!;\n if (overlaySeen.has(parsed.ref)) return undefined;\n overlaySeen.add(parsed.ref);\n }\n return {\n version: value.version,\n ...(value.version === COMPILED_SURFACE_VERSION ? { normalizations: value.normalizations as import(\"./normal-form.js\").NormalFormPlan[] } : {}),\n metricVersion: value.metricVersion as number,\n actions: value.actions.map((entry) => parseOverlayEntry(entry)!),\n quarantined: value.quarantined.map((entry) => parseQuarantineEntry(entry)!),\n applied: value.applied.map((entry) => parseAppliedProposal(entry)!),\n gate: parseGateRecord(value.gate)!,\n evidenceDigest: value.evidenceDigest.trim(),\n };\n};\n\n// Public guarded parse for artifact files that did not come from this\n// agent dir: exported artifacts being imported, or certification fixtures.\n// The same validation the store applies to its own file, so nothing trusts\n// an artifact shape the store would refuse to load.\nexport const parseCompiledSurfaceArtifact = (\n value: unknown,\n): CompiledSurfaceFile | undefined => parseCompiledSurfaceFile(value);\n\nexport interface LoadedCompiledSurface {\n file?: CompiledSurfaceFile;\n error?: string;\n}\n\nexport const loadCompiledSurface = (agentDir: string): LoadedCompiledSurface => {\n const file = compiledPath(compiledSurfaceDirectory(agentDir));\n let raw: string;\n try {\n raw = fs.readFileSync(file, \"utf8\");\n } catch (error) {\n // A missing artifact means the surface was never compiled; anything\n // else is damage that callers must surface, not silently rebuild.\n if (errorCode(error) === \"ENOENT\") return {};\n return { error: `compiled surface is unreadable: ${errorText(error)}` };\n }\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw);\n } catch {\n return { error: \"compiled surface is malformed JSON\" };\n }\n const parsedFile = parseCompiledSurfaceFile(parsed);\n if (!parsedFile) return { error: \"compiled surface is invalid\" };\n return { file: parsedFile };\n};\n\nexport const loadCompiledSurfaceAsync = async (\n agentDir: string,\n): Promise<LoadedCompiledSurface> => {\n const file = compiledPath(compiledSurfaceDirectory(agentDir));\n let raw: string;\n try {\n raw = await fs.promises.readFile(file, \"utf8\");\n } catch (error) {\n if (errorCode(error) === \"ENOENT\") return {};\n return { error: `compiled surface is unreadable: ${errorText(error)}` };\n }\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw);\n } catch {\n return { error: \"compiled surface is malformed JSON\" };\n }\n const parsedFile = parseCompiledSurfaceFile(parsed);\n return parsedFile ? { file: parsedFile } : { error: \"compiled surface is invalid\" };\n};\n\nexport interface SavedCompiledSurface {\n file: CompiledSurfaceFile;\n written: boolean;\n}\n\nexport const saveCompiledSurface = (\n agentDir: string,\n file: CompiledSurfaceFile,\n): SavedCompiledSurface =>\n withExclusiveFileLock(\n {\n directory: compiledSurfaceDirectory(agentDir),\n lockName: \"compiled.lock\",\n timeoutMessage: \"Timed out waiting for the compiled entropy surface lock\",\n attempts: COMPILED_LOCK_ATTEMPTS,\n delayMs: COMPILED_LOCK_DELAY_MS,\n staleMs: COMPILED_STALE_LOCK_MS,\n },\n () => {\n // A damaged artifact must never be silently rebuilt; fail so the\n // compile records the rejection and leaves the file for recovery.\n const loaded = loadCompiledSurface(agentDir);\n if (loaded.error) throw new Error(loaded.error);\n const target = compiledPath(compiledSurfaceDirectory(agentDir));\n const serialized = `${JSON.stringify(file, null, 2)}\\n`;\n try {\n if (fs.readFileSync(target, \"utf8\") === serialized) return { file, written: false };\n } catch {\n // Missing file: proceed to write.\n }\n writeJsonAtomic(target, file, { space: 2, newline: true, mode: 0o600, dirMode: 0o700 });\n return { file, written: true };\n },\n );\n\nexport const saveCompiledSurfaceAsync = async (\n agentDir: string,\n file: CompiledSurfaceFile,\n): Promise<SavedCompiledSurface> =>\n withExclusiveFileLockAsync(\n {\n directory: compiledSurfaceDirectory(agentDir),\n lockName: \"compiled.lock\",\n timeoutMessage: \"Timed out waiting for the compiled entropy surface lock\",\n attempts: COMPILED_LOCK_ATTEMPTS,\n delayMs: COMPILED_LOCK_DELAY_MS,\n staleMs: COMPILED_STALE_LOCK_MS,\n },\n async () => {\n const loaded = await loadCompiledSurfaceAsync(agentDir);\n if (loaded.error) throw new Error(loaded.error);\n const target = compiledPath(compiledSurfaceDirectory(agentDir));\n const serialized = `${JSON.stringify(file, null, 2)}\\n`;\n try {\n if (await fs.promises.readFile(target, \"utf8\") === serialized) {\n return { file, written: false };\n }\n } catch {\n // Missing file: proceed to write.\n }\n await writeJsonAtomicAsync(target, file, {\n space: 2,\n newline: true,\n mode: 0o600,\n dirMode: 0o700,\n });\n return { file, written: true };\n },\n );\n", "// Cross-process exclusive lock for Fabric's durable stores (the repair\n// table, the compiled entropy surface). Acquisition is a bounded retry over\n// mkdir; stale-lock recovery is an exclusive rename claim, so racing\n// reapers can never delete a lock a fresh writer owns.\n\nimport { randomUUID } from \"node:crypto\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\n\nconst DEFAULT_LOCK_ATTEMPTS = 50;\nconst DEFAULT_LOCK_DELAY_MS = 5;\nconst DEFAULT_STALE_LOCK_MS = 30_000;\n\nexport interface ExclusiveLockOptions {\n directory: string;\n lockName: string;\n /** Error message when acquisition times out. */\n timeoutMessage: string;\n staleMs?: number;\n attempts?: number;\n delayMs?: number;\n}\n\nconst errorCode = (error: unknown): string | undefined =>\n typeof error === \"object\" && error !== null && \"code\" in error\n ? String((error as { code?: unknown }).code)\n : undefined;\n\nconst sleepSync = (() => {\n try {\n const buffer = new Int32Array(new SharedArrayBuffer(4));\n return (ms: number): void => {\n Atomics.wait(buffer, 0, 0, ms);\n };\n } catch {\n return (): void => undefined;\n }\n})();\n\nconst processAlive = (pid: number): boolean => {\n if (!Number.isSafeInteger(pid) || pid <= 0) return false;\n try {\n process.kill(pid, 0);\n return true;\n } catch {\n return false;\n }\n};\n\nconst sleepAsync = (ms: number): Promise<void> =>\n new Promise((resolve) => setTimeout(resolve, ms));\n\nconst reapStaleLockAsync = async (\n lock: string,\n verify: (claimed: string) => Promise<boolean>,\n): Promise<boolean> => {\n const claim = `${lock}.reap-${process.pid}-${randomUUID()}`;\n try {\n await fs.promises.rename(lock, claim);\n } catch {\n return false;\n }\n if (!(await verify(claim))) {\n try {\n await fs.promises.rename(claim, lock);\n } catch {\n if (await verify(claim)) {\n await fs.promises.rm(claim, { recursive: true, force: true });\n }\n }\n return false;\n }\n await fs.promises.rm(claim, { recursive: true, force: true });\n return true;\n};\n\nexport const withExclusiveFileLockAsync = async <T>(\n options: ExclusiveLockOptions,\n operation: () => T | Promise<T>,\n): Promise<T> => {\n const attempts = options.attempts ?? DEFAULT_LOCK_ATTEMPTS;\n const delayMs = options.delayMs ?? DEFAULT_LOCK_DELAY_MS;\n const staleMs = options.staleMs ?? DEFAULT_STALE_LOCK_MS;\n await fs.promises.mkdir(options.directory, { recursive: true, mode: 0o700 });\n const lock = path.join(options.directory, options.lockName);\n const ownerPath = path.join(lock, \"owner\");\n const token = randomUUID();\n let acquired = false;\n for (let attempt = 0; attempt < attempts; attempt++) {\n try {\n await fs.promises.mkdir(lock, { mode: 0o700 });\n try {\n await fs.promises.writeFile(ownerPath, `${token}\\n${process.pid}\\n${Date.now()}\\n`, {\n encoding: \"utf-8\",\n mode: 0o600,\n });\n } catch (error) {\n await fs.promises.rm(lock, { recursive: true, force: true });\n throw error;\n }\n acquired = true;\n break;\n } catch (error) {\n if (errorCode(error) !== \"EEXIST\") throw error;\n try {\n const firstOwner = await fs.promises.readFile(ownerPath, \"utf8\");\n const [, pidText, createdText] = firstOwner.trim().split(\"\\n\");\n const stale = Date.now() - Number(createdText) > staleMs;\n if (stale && !processAlive(Number(pidText))) {\n const secondOwner = await fs.promises.readFile(ownerPath, \"utf8\");\n if (\n secondOwner === firstOwner &&\n await reapStaleLockAsync(lock, async (claimed) => {\n try {\n const owner = await fs.promises.readFile(path.join(claimed, \"owner\"), \"utf8\");\n const [, pid, created] = owner.trim().split(\"\\n\");\n return Date.now() - Number(created) > staleMs && !processAlive(Number(pid));\n } catch {\n return false;\n }\n })\n ) {\n continue;\n }\n }\n } catch {\n try {\n const first = await fs.promises.stat(lock);\n if (\n Date.now() - first.mtimeMs > staleMs &&\n await reapStaleLockAsync(lock, async (claimed) => {\n try {\n return Date.now() - (await fs.promises.stat(claimed)).mtimeMs > staleMs;\n } catch {\n return false;\n }\n })\n ) {\n continue;\n }\n } catch {\n // Lock creation or stale recovery raced; retry the bounded acquisition.\n }\n }\n if (attempt === attempts - 1) break;\n await sleepAsync(delayMs);\n }\n }\n if (!acquired) throw new Error(options.timeoutMessage);\n try {\n return await operation();\n } finally {\n try {\n const owner = await fs.promises.readFile(ownerPath, \"utf8\");\n if (owner.startsWith(`${token}\\n`)) {\n await fs.promises.rm(lock, { recursive: true, force: true });\n }\n } catch {\n // A recovering process already removed this lock.\n }\n }\n};\n\n// Stale-lock recovery must be an exclusive claim. Stat-then-delete is\n// TOCTOU: two reapers (or a reaper and a fresh writer that recreated the\n// lock in between) can both pass their checks, and the slower rm then\n// deletes a lock the faster one already replaced. rename() is the claim \u2014\n// only one process can move the directory, and removal targets the claimed\n// path, never the live lock path. A claim that turns out to hold a live\n// lock is renamed back before any destructive step; a live lock is never\n// deleted, even if the rename-back races a fresh writer.\nconst reapStaleLock = (lock: string, verify: (claimed: string) => boolean): boolean => {\n const claim = `${lock}.reap-${process.pid}-${randomUUID()}`;\n try {\n fs.renameSync(lock, claim);\n } catch {\n return false;\n }\n if (!verify(claim)) {\n try {\n fs.renameSync(claim, lock);\n } catch {\n // `lock` was recreated after the claim. Re-verify before any\n // destructive step so a claimed live lock is only ever abandoned as\n // garbage, never deleted.\n if (verify(claim)) fs.rmSync(claim, { recursive: true, force: true });\n }\n return false;\n }\n fs.rmSync(claim, { recursive: true, force: true });\n return true;\n};\n\nexport const withExclusiveFileLock = <T>(\n options: ExclusiveLockOptions,\n operation: () => T,\n): T => {\n const attempts = options.attempts ?? DEFAULT_LOCK_ATTEMPTS;\n const delayMs = options.delayMs ?? DEFAULT_LOCK_DELAY_MS;\n const staleMs = options.staleMs ?? DEFAULT_STALE_LOCK_MS;\n fs.mkdirSync(options.directory, { recursive: true, mode: 0o700 });\n const lock = path.join(options.directory, options.lockName);\n const ownerPath = path.join(lock, \"owner\");\n const token = randomUUID();\n let acquired = false;\n for (let attempt = 0; attempt < attempts; attempt++) {\n try {\n fs.mkdirSync(lock, { mode: 0o700 });\n try {\n fs.writeFileSync(ownerPath, `${token}\\n${process.pid}\\n${Date.now()}\\n`, {\n encoding: \"utf-8\",\n mode: 0o600,\n });\n } catch (error) {\n fs.rmSync(lock, { recursive: true, force: true });\n throw error;\n }\n acquired = true;\n break;\n } catch (error) {\n if (errorCode(error) !== \"EEXIST\") throw error;\n try {\n const firstOwner = fs.readFileSync(ownerPath, \"utf8\");\n const [, pidText, createdText] = firstOwner.trim().split(\"\\n\");\n const stale = Date.now() - Number(createdText) > staleMs;\n if (stale && !processAlive(Number(pidText))) {\n const secondOwner = fs.readFileSync(ownerPath, \"utf8\");\n if (\n secondOwner === firstOwner &&\n reapStaleLock(lock, (claimed) => {\n try {\n const owner = fs.readFileSync(path.join(claimed, \"owner\"), \"utf8\");\n const [, pid, created] = owner.trim().split(\"\\n\");\n return Date.now() - Number(created) > staleMs && !processAlive(Number(pid));\n } catch {\n return false;\n }\n })\n ) {\n continue;\n }\n }\n } catch {\n try {\n // Ownerless lock (crash between mkdir and the owner write): age is\n // the only signal, and the claim re-verifies it after the rename.\n const first = fs.statSync(lock);\n if (\n Date.now() - first.mtimeMs > staleMs &&\n reapStaleLock(lock, (claimed) => {\n try {\n return Date.now() - fs.statSync(claimed).mtimeMs > staleMs;\n } catch {\n return false;\n }\n })\n ) {\n continue;\n }\n } catch {\n // Lock creation or stale recovery raced; retry the bounded acquisition.\n }\n }\n if (attempt === attempts - 1) break;\n sleepSync(delayMs);\n }\n }\n if (!acquired) throw new Error(options.timeoutMessage);\n try {\n return operation();\n } finally {\n try {\n const owner = fs.readFileSync(ownerPath, \"utf8\");\n if (owner.startsWith(`${token}\\n`)) {\n fs.rmSync(lock, { recursive: true, force: true });\n }\n } catch {\n // A recovering process already removed this lock.\n }\n }\n};"],
5
+ "mappings": ";;;;;;;;;;;;;;AAQO,IAAM,yBAAyB;AAK/B,IAAM,kBAAkB;AAAA,EAC7B,OAAO;AAAA,EACP,cAAc;AAAA,EACd,OAAO;AAAA,EACP,YAAY;AAAA,EACZ,MAAM;AAAA,EACN,SAAS;AAAA,EACT,eAAe;AACjB;AAIO,IAAM,4BAA+C,CAA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AAAA,EAC/B;AACF;",
6
+ "names": ["fs", "path", "path", "errorCode", "fs"]
7
+ }
@@ -14,7 +14,7 @@ import {
14
14
  reconstructSessionLineage,
15
15
  searchMemoryIndex,
16
16
  shardPolicy
17
- } from "./chunk-F64KOMNS.js";
17
+ } from "./chunk-FRONVGLX.js";
18
18
  import {
19
19
  compareLexical,
20
20
  foldSessionDigest,
@@ -26,12 +26,12 @@ import {
26
26
  enumerateAllSessions,
27
27
  resolveScope,
28
28
  resolveSessionTarget
29
- } from "./chunk-TDCMU5L4.js";
29
+ } from "./chunk-KNBPIZF7.js";
30
30
  import {
31
31
  expandSessionEntriesChecked,
32
32
  normalizeRecords,
33
33
  normalizeSession
34
- } from "./chunk-MYCDJTSM.js";
34
+ } from "./chunk-VJJFD42F.js";
35
35
  import {
36
36
  actionArgNormalizer
37
37
  } from "./chunk-NQOEHX62.js";
@@ -2178,4 +2178,4 @@ export {
2178
2178
  memoryActionSchemas,
2179
2179
  MemoryProvider
2180
2180
  };
2181
- //# sourceMappingURL=chunk-IRPPGNUF.js.map
2181
+ //# sourceMappingURL=chunk-6GT4YJT2.js.map
@@ -9,7 +9,7 @@ import {
9
9
  agentParticipantRecords,
10
10
  loadModelUsage,
11
11
  useBudgetLedger
12
- } from "./chunk-LJ6FJRFH.js";
12
+ } from "./chunk-OJX2V36R.js";
13
13
  import {
14
14
  RESIDENT_HOST_FORMAT,
15
15
  residentDeliveryPrefix,
@@ -28,7 +28,7 @@ import {
28
28
  import {
29
29
  parseFabricOwnedModelGuidance,
30
30
  resolveFabricModelGuidance
31
- } from "./chunk-77FQHHZD.js";
31
+ } from "./chunk-UKMQK5VP.js";
32
32
 
33
33
  // src/residency/host.ts
34
34
  import { randomUUID } from "node:crypto";
@@ -689,4 +689,4 @@ if (isMain) {
689
689
  export {
690
690
  runResidentHostFromConfigPath
691
691
  };
692
- //# sourceMappingURL=chunk-NGAUBL2M.js.map
692
+ //# sourceMappingURL=chunk-DDVCVE4D.js.map
@@ -9,7 +9,7 @@ import {
9
9
  import {
10
10
  DEFAULT_MEMORY_INDEX_PRIVACY,
11
11
  normalizeSession
12
- } from "./chunk-MYCDJTSM.js";
12
+ } from "./chunk-VJJFD42F.js";
13
13
 
14
14
  // src/memory/index.ts
15
15
  import crypto2 from "node:crypto";
@@ -1239,4 +1239,4 @@ export {
1239
1239
  searchMemoryIndex,
1240
1240
  searchShards
1241
1241
  };
1242
- //# sourceMappingURL=chunk-F64KOMNS.js.map
1242
+ //# sourceMappingURL=chunk-FRONVGLX.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  compileFabricSummary,
3
3
  rawContextTokens
4
- } from "./chunk-TAJUG2Q3.js";
4
+ } from "./chunk-MF46OHNU.js";
5
5
  import {
6
6
  compactionRequestBoundsError,
7
7
  encodeCompactionRequest
@@ -444,4 +444,4 @@ export {
444
444
  buildPeerCards,
445
445
  awaitPeerSettle
446
446
  };
447
- //# sourceMappingURL=chunk-P22OSVIC.js.map
447
+ //# sourceMappingURL=chunk-JS2THBBG.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  readSessionHeader
3
- } from "./chunk-MYCDJTSM.js";
3
+ } from "./chunk-VJJFD42F.js";
4
4
 
5
5
  // src/memory/discovery.ts
6
6
  import fs from "node:fs";
@@ -109,4 +109,4 @@ export {
109
109
  resolveSessionTarget,
110
110
  resolveScope
111
111
  };
112
- //# sourceMappingURL=chunk-TDCMU5L4.js.map
112
+ //# sourceMappingURL=chunk-KNBPIZF7.js.map