@fenglimg/fabric-shared 1.5.2 → 1.7.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.
package/dist/index.js CHANGED
@@ -6,23 +6,40 @@ import {
6
6
  enMessages,
7
7
  normalizeLocale,
8
8
  zhCNMessages
9
- } from "./chunk-KNZIX6IL.js";
9
+ } from "./chunk-5H2PVNB2.js";
10
10
  import "./chunk-LXNCAKJZ.js";
11
11
 
12
12
  // src/schemas/agents-meta.ts
13
13
  import { z } from "zod";
14
14
  var FABRIC_AGENTS_PREFIX = ".fabric/agents/";
15
15
  var AGENTS_META_LAYERS = ["L0", "L1", "L2"];
16
- var AGENTS_META_TOPOLOGY_TYPES = ["mirror", "cross-cutting"];
16
+ var AGENTS_META_TOPOLOGY_TYPES = ["mirror", "cross-cutting", "domain", "local", "global"];
17
17
  var AGENTS_META_IDENTITY_SOURCES = ["declared", "derived"];
18
18
  var agentsLayerSchema = z.enum(AGENTS_META_LAYERS);
19
19
  var agentsTopologyTypeSchema = z.enum(AGENTS_META_TOPOLOGY_TYPES);
20
20
  var agentsIdentitySourceSchema = z.enum(AGENTS_META_IDENTITY_SOURCES);
21
+ var ruleDescriptionSchema = z.object({
22
+ summary: z.string(),
23
+ intent_clues: z.array(z.string()),
24
+ tech_stack: z.array(z.string()),
25
+ impact: z.array(z.string()),
26
+ must_read_if: z.string(),
27
+ entities: z.array(z.string()).optional()
28
+ }).strict();
29
+ var ruleDescriptionIndexItemSchema = z.object({
30
+ stable_id: z.string(),
31
+ level: agentsLayerSchema,
32
+ required: z.boolean(),
33
+ selectable: z.boolean(),
34
+ description: ruleDescriptionSchema
35
+ }).strict();
21
36
  var agentsMetaNodeBaseSchema = z.object({
22
37
  file: z.string(),
38
+ content_ref: z.string().optional(),
23
39
  scope_glob: z.string(),
24
40
  deps: z.array(z.string()),
25
41
  priority: z.enum(["high", "medium", "low"]),
42
+ level: agentsLayerSchema.optional(),
26
43
  layer: agentsLayerSchema,
27
44
  topology_type: agentsTopologyTypeSchema,
28
45
  hash: z.string(),
@@ -31,7 +48,9 @@ var agentsMetaNodeBaseSchema = z.object({
31
48
  activation: z.object({
32
49
  tier: z.enum(["always", "path", "description"]),
33
50
  description: z.string().optional()
34
- }).optional()
51
+ }).optional(),
52
+ description: ruleDescriptionSchema.optional(),
53
+ sections: z.array(z.string()).optional()
35
54
  });
36
55
  var agentsMetaNodeSchema = z.preprocess((value) => {
37
56
  if (!isRecord(value) || typeof value.file !== "string") {
@@ -48,7 +67,8 @@ function withDerivedAgentsMetaNodeDefaults(node) {
48
67
  const identitySource = deriveAgentsMetaIdentitySource(node);
49
68
  return {
50
69
  ...node,
51
- layer: node.layer ?? deriveAgentsMetaLayer(node.file),
70
+ layer: node.layer ?? node.level ?? deriveAgentsMetaLayer(node.file),
71
+ level: node.level ?? node.layer ?? deriveAgentsMetaLayer(node.file),
52
72
  topology_type: node.topology_type ?? deriveAgentsMetaTopologyType(node.file),
53
73
  stable_id: stableId,
54
74
  identity_source: identitySource
@@ -106,10 +126,40 @@ function isRecord(value) {
106
126
  return typeof value === "object" && value !== null;
107
127
  }
108
128
 
109
- // src/schemas/api-contracts.ts
129
+ // src/schemas/rule-test-index.ts
110
130
  import { z as z2 } from "zod";
111
- var ledgerSourceSchema = z2.enum(["ai", "human"]);
112
- var timestampFilterSchema = z2.preprocess((value) => {
131
+ var RULE_TEST_INDEX_SCHEMA_VERSION = 1;
132
+ var hashSchema = z2.string().min(1);
133
+ var ruleTestLinkSchema = z2.object({
134
+ rule_stable_id: z2.string().min(1),
135
+ rule_file: z2.string().min(1),
136
+ rule_hash: hashSchema,
137
+ previous_rule_hash: hashSchema.optional(),
138
+ test_file: z2.string().min(1),
139
+ test_hash: hashSchema,
140
+ previous_test_hash: hashSchema.optional(),
141
+ annotation_line: z2.number().int().positive()
142
+ }).strict();
143
+ var ruleTestOrphanAnnotationSchema = z2.object({
144
+ rule_stable_id: z2.string().min(1),
145
+ test_file: z2.string().min(1),
146
+ test_hash: hashSchema,
147
+ previous_test_hash: hashSchema.optional(),
148
+ annotation_line: z2.number().int().positive()
149
+ }).strict();
150
+ var ruleTestIndexSchema = z2.object({
151
+ schema_version: z2.literal(RULE_TEST_INDEX_SCHEMA_VERSION),
152
+ generated_at: z2.string().datetime({ offset: true }),
153
+ revision: z2.string().min(1).optional(),
154
+ previous_revision: z2.string().min(1).optional(),
155
+ links: z2.array(ruleTestLinkSchema),
156
+ orphan_annotations: z2.array(ruleTestOrphanAnnotationSchema)
157
+ }).strict();
158
+
159
+ // src/schemas/api-contracts.ts
160
+ import { z as z3 } from "zod";
161
+ var ledgerSourceSchema = z3.enum(["ai", "human"]);
162
+ var timestampFilterSchema = z3.preprocess((value) => {
113
163
  if (value === void 0 || value === null || value === "") {
114
164
  return void 0;
115
165
  }
@@ -128,61 +178,61 @@ var timestampFilterSchema = z2.preprocess((value) => {
128
178
  return Number.isNaN(parsed) ? value : parsed;
129
179
  }
130
180
  return value;
131
- }, z2.number().int().nonnegative());
132
- var ledgerQuerySchema = z2.object({
181
+ }, z3.number().int().nonnegative());
182
+ var ledgerQuerySchema = z3.object({
133
183
  source: ledgerSourceSchema.optional(),
134
184
  since: timestampFilterSchema.optional()
135
185
  });
136
- var historyStateQuerySchema = z2.object({
137
- ledger_id: z2.string().trim().min(1).optional(),
186
+ var historyStateQuerySchema = z3.object({
187
+ ledger_id: z3.string().trim().min(1).optional(),
138
188
  ts: timestampFilterSchema.optional()
139
189
  }).superRefine((value, ctx) => {
140
190
  const provided = [value.ledger_id, value.ts].filter((entry) => entry !== void 0);
141
191
  if (provided.length !== 1) {
142
192
  ctx.addIssue({
143
- code: z2.ZodIssueCode.custom,
193
+ code: z3.ZodIssueCode.custom,
144
194
  message: "Provide exactly one of ledger_id or ts.",
145
195
  path: ["ledger_id"]
146
196
  });
147
197
  }
148
198
  });
149
- var humanLockApproveRequestSchema = z2.object({
150
- file: z2.string().min(1),
151
- start_line: z2.number().int().positive(),
152
- end_line: z2.number().int().positive(),
153
- new_hash: z2.string().min(1)
199
+ var humanLockApproveRequestSchema = z3.object({
200
+ file: z3.string().min(1),
201
+ start_line: z3.number().int().positive(),
202
+ end_line: z3.number().int().positive(),
203
+ new_hash: z3.string().min(1)
154
204
  });
155
- var humanLockFileParamsSchema = z2.object({
156
- file: z2.string().min(1)
205
+ var humanLockFileParamsSchema = z3.object({
206
+ file: z3.string().min(1)
157
207
  });
158
- var annotateIntentRequestSchema = z2.object({
159
- ledger_entry_id: z2.string().min(1),
160
- annotation: z2.string().trim().min(1)
208
+ var annotateIntentRequestSchema = z3.object({
209
+ ledger_entry_id: z3.string().min(1),
210
+ annotation: z3.string().trim().min(1)
161
211
  });
162
212
 
163
213
  // src/schemas/ledger-entry.ts
164
- import { z as z3 } from "zod";
214
+ import { z as z4 } from "zod";
165
215
  var ledgerEntryBaseSchema = {
166
- id: z3.string().optional(),
167
- ts: z3.number().int().nonnegative(),
168
- intent: z3.string(),
169
- affected_paths: z3.array(z3.string())
216
+ id: z4.string().optional(),
217
+ ts: z4.number().int().nonnegative(),
218
+ intent: z4.string(),
219
+ affected_paths: z4.array(z4.string())
170
220
  };
171
- var aiLedgerEntrySchema = z3.object({
221
+ var aiLedgerEntrySchema = z4.object({
172
222
  ...ledgerEntryBaseSchema,
173
- source: z3.literal("ai"),
174
- commit_sha: z3.string().optional()
223
+ source: z4.literal("ai"),
224
+ commit_sha: z4.string().optional()
175
225
  });
176
- var humanLedgerEntrySchema = z3.object({
226
+ var humanLedgerEntrySchema = z4.object({
177
227
  ...ledgerEntryBaseSchema,
178
- source: z3.literal("human"),
179
- parent_sha: z3.string(),
180
- parent_ledger_entry_id: z3.string().optional(),
181
- diff_stat: z3.string(),
182
- annotation: z3.string().optional()
183
- });
184
- var ledgerEntryUnionSchema = z3.discriminatedUnion("source", [aiLedgerEntrySchema, humanLedgerEntrySchema]);
185
- var ledgerEntrySchema = z3.preprocess((value) => {
228
+ source: z4.literal("human"),
229
+ parent_sha: z4.string(),
230
+ parent_ledger_entry_id: z4.string().optional(),
231
+ diff_stat: z4.string(),
232
+ annotation: z4.string().optional()
233
+ });
234
+ var ledgerEntryUnionSchema = z4.discriminatedUnion("source", [aiLedgerEntrySchema, humanLedgerEntrySchema]);
235
+ var ledgerEntrySchema = z4.preprocess((value) => {
186
236
  if (value && typeof value === "object" && !Array.isArray(value) && (!("source" in value) || value.source === void 0)) {
187
237
  return {
188
238
  ...value,
@@ -193,198 +243,313 @@ var ledgerEntrySchema = z3.preprocess((value) => {
193
243
  }, ledgerEntryUnionSchema);
194
244
 
195
245
  // src/schemas/human-lock.ts
196
- import { z as z4 } from "zod";
197
- var humanLockEntrySchema = z4.object({
198
- file: z4.string(),
199
- start_line: z4.number().int().nonnegative(),
200
- end_line: z4.number().int().nonnegative(),
201
- hash: z4.string()
246
+ import { z as z5 } from "zod";
247
+ var humanLockEntrySchema = z5.object({
248
+ file: z5.string(),
249
+ start_line: z5.number().int().nonnegative(),
250
+ end_line: z5.number().int().nonnegative(),
251
+ hash: z5.string()
202
252
  });
203
- var humanLockFileSchema = z4.object({
204
- locked: z4.array(humanLockEntrySchema).optional()
253
+ var humanLockFileSchema = z5.object({
254
+ locked: z5.array(humanLockEntrySchema).optional()
205
255
  });
206
256
 
207
257
  // src/schemas/fabric-config.ts
208
- import { z as z5 } from "zod";
209
- var auditModeSchema = z5.enum(["strict", "warn", "off"]);
210
- var clientPathsSchema = z5.object({
211
- claudeCodeCLI: z5.string().optional(),
212
- claudeCodeDesktop: z5.string().optional(),
213
- cursor: z5.string().optional(),
214
- windsurf: z5.string().optional(),
215
- rooCode: z5.string().optional(),
216
- geminiCLI: z5.string().optional(),
217
- codexCLI: z5.string().optional()
218
- });
219
- var fabricConfigSchema = z5.object({
258
+ import { z as z6 } from "zod";
259
+ var auditModeSchema = z6.enum(["strict", "warn", "off"]);
260
+ var clientPathsSchema = z6.object({
261
+ claudeCodeCLI: z6.string().optional(),
262
+ claudeCodeDesktop: z6.string().optional(),
263
+ cursor: z6.string().optional(),
264
+ windsurf: z6.string().optional(),
265
+ rooCode: z6.string().optional(),
266
+ geminiCLI: z6.string().optional(),
267
+ codexCLI: z6.string().optional()
268
+ });
269
+ var fabricConfigSchema = z6.object({
220
270
  clientPaths: clientPathsSchema.optional(),
221
- externalFixturePath: z5.string().optional(),
222
- scanIgnores: z5.array(z5.string()).optional(),
271
+ externalFixturePath: z6.string().optional(),
272
+ scanIgnores: z6.array(z6.string()).optional(),
223
273
  auditMode: auditModeSchema.optional(),
224
274
  audit_mode: auditModeSchema.optional()
225
275
  });
226
276
 
227
277
  // src/schemas/forensic-report.ts
228
- import { z as z6 } from "zod";
229
- var forensicCodeSampleSchema = z6.object({
230
- path: z6.string(),
231
- lines: z6.string(),
232
- snippet: z6.string(),
233
- pattern_hint: z6.string()
234
- });
235
- var forensicEvidenceAnchorSchema = z6.object({
236
- file: z6.string(),
237
- line: z6.string(),
238
- snippet: z6.string()
239
- });
240
- var forensicAssertionCoverageSchema = z6.object({
241
- ratio: z6.number().min(0).max(1),
242
- total: z6.number().int().nonnegative(),
243
- matched: z6.number().int().nonnegative(),
244
- co_occurring_patterns: z6.array(z6.string())
245
- });
246
- var forensicAssertionSchema = z6.object({
247
- type: z6.enum(["framework", "pattern", "invariant", "domain"]),
248
- statement: z6.string(),
249
- confidence: z6.enum(["HIGH", "MEDIUM", "LOW"]),
250
- evidence: z6.array(forensicEvidenceAnchorSchema),
278
+ import { z as z7 } from "zod";
279
+ var forensicCodeSampleSchema = z7.object({
280
+ path: z7.string(),
281
+ lines: z7.string(),
282
+ snippet: z7.string(),
283
+ pattern_hint: z7.string()
284
+ });
285
+ var forensicEvidenceAnchorSchema = z7.object({
286
+ file: z7.string(),
287
+ line: z7.string(),
288
+ snippet: z7.string()
289
+ });
290
+ var forensicAssertionCoverageSchema = z7.object({
291
+ ratio: z7.number().min(0).max(1),
292
+ total: z7.number().int().nonnegative(),
293
+ matched: z7.number().int().nonnegative(),
294
+ co_occurring_patterns: z7.array(z7.string())
295
+ });
296
+ var forensicAssertionSchema = z7.object({
297
+ type: z7.enum(["framework", "pattern", "invariant", "domain"]),
298
+ statement: z7.string(),
299
+ confidence: z7.enum(["HIGH", "MEDIUM", "LOW"]),
300
+ evidence: z7.array(forensicEvidenceAnchorSchema),
251
301
  coverage: forensicAssertionCoverageSchema,
252
- proposed_rule: z6.string().optional(),
253
- alternatives: z6.array(z6.string()).optional()
254
- });
255
- var forensicTopologySchema = z6.object({
256
- total_files: z6.number().int().nonnegative(),
257
- by_ext: z6.record(z6.number().int().nonnegative()),
258
- key_dirs: z6.array(z6.string()),
259
- max_depth: z6.number().int().nonnegative()
260
- });
261
- var forensicEntryPointSchema = z6.object({
262
- path: z6.string(),
263
- reason: z6.string(),
264
- size_bytes: z6.number().int().nonnegative().optional()
265
- });
266
- var forensicFrameworkSchema = z6.object({
267
- kind: z6.string(),
268
- version: z6.string(),
269
- subkind: z6.string(),
270
- evidence: z6.array(z6.string())
271
- });
272
- var forensicReadmeSchema = z6.object({
273
- quality: z6.enum(["missing", "stub", "ok"]),
274
- line_count: z6.number().int().nonnegative(),
275
- has_contributing: z6.boolean()
276
- });
277
- var candidateFileEntrySchema = z6.object({
278
- path: z6.string(),
279
- family: z6.enum(["entry", "component", "config", "test", "domain"]),
280
- rationale: z6.string()
281
- });
282
- var forensicSamplingBudgetSchema = z6.object({
283
- max_files: z6.literal(15),
284
- max_lines_per_file: z6.literal(100)
285
- });
286
- var forensicReportSchema = z6.object({
287
- version: z6.string(),
288
- generated_at: z6.string(),
289
- generated_by: z6.string(),
290
- target: z6.string(),
291
- project_name: z6.string(),
302
+ proposed_rule: z7.string().optional(),
303
+ alternatives: z7.array(z7.string()).optional()
304
+ });
305
+ var forensicTopologySchema = z7.object({
306
+ total_files: z7.number().int().nonnegative(),
307
+ by_ext: z7.record(z7.number().int().nonnegative()),
308
+ key_dirs: z7.array(z7.string()),
309
+ max_depth: z7.number().int().nonnegative()
310
+ });
311
+ var forensicEntryPointSchema = z7.object({
312
+ path: z7.string(),
313
+ reason: z7.string(),
314
+ size_bytes: z7.number().int().nonnegative().optional()
315
+ });
316
+ var forensicFrameworkSchema = z7.object({
317
+ kind: z7.string(),
318
+ version: z7.string(),
319
+ subkind: z7.string(),
320
+ evidence: z7.array(z7.string())
321
+ });
322
+ var forensicReadmeSchema = z7.object({
323
+ quality: z7.enum(["missing", "stub", "ok"]),
324
+ line_count: z7.number().int().nonnegative(),
325
+ has_contributing: z7.boolean()
326
+ });
327
+ var candidateFileEntrySchema = z7.object({
328
+ path: z7.string(),
329
+ family: z7.enum(["entry", "component", "config", "test", "domain"]),
330
+ rationale: z7.string()
331
+ });
332
+ var forensicSamplingBudgetSchema = z7.object({
333
+ max_files: z7.literal(15),
334
+ max_lines_per_file: z7.literal(100)
335
+ });
336
+ var forensicReportSchema = z7.object({
337
+ version: z7.string(),
338
+ generated_at: z7.string(),
339
+ generated_by: z7.string(),
340
+ target: z7.string(),
341
+ project_name: z7.string(),
292
342
  framework: forensicFrameworkSchema,
293
343
  topology: forensicTopologySchema,
294
- entry_points: z6.array(forensicEntryPointSchema),
295
- code_samples: z6.array(forensicCodeSampleSchema),
296
- assertions: z6.array(forensicAssertionSchema),
297
- candidate_files: z6.array(candidateFileEntrySchema),
344
+ entry_points: z7.array(forensicEntryPointSchema),
345
+ code_samples: z7.array(forensicCodeSampleSchema),
346
+ assertions: z7.array(forensicAssertionSchema),
347
+ candidate_files: z7.array(candidateFileEntrySchema),
298
348
  sampling_budget: forensicSamplingBudgetSchema,
299
349
  readme: forensicReadmeSchema,
300
- recommendations_for_skill: z6.array(z6.string()).optional()
350
+ recommendations_for_skill: z7.array(z7.string()).optional()
301
351
  });
302
352
 
303
353
  // src/schemas/init-context.ts
304
- import { z as z7 } from "zod";
305
- var initContextFrameworkSchema = z7.object({
306
- kind: z7.string(),
307
- version: z7.string(),
308
- subkind: z7.string()
309
- });
310
- var initContextInvariantConfidenceSnapshotSchema = z7.object({
311
- confidence: z7.enum(["HIGH", "MEDIUM", "LOW"]),
312
- evidence_refs: z7.array(z7.string())
313
- });
314
- var initContextSourceEvidenceSchema = z7.object({
315
- file: z7.string(),
316
- lines: z7.string()
317
- });
318
- var initContextInvariantSchema = z7.object({
319
- type: z7.enum(["ban", "require", "protect"]),
320
- rule: z7.string(),
321
- rationale: z7.string().optional(),
354
+ import { z as z8 } from "zod";
355
+ var initContextFrameworkSchema = z8.object({
356
+ kind: z8.string(),
357
+ version: z8.string(),
358
+ subkind: z8.string()
359
+ });
360
+ var initContextInvariantConfidenceSnapshotSchema = z8.object({
361
+ confidence: z8.enum(["HIGH", "MEDIUM", "LOW"]),
362
+ evidence_refs: z8.array(z8.string())
363
+ });
364
+ var initContextSourceEvidenceSchema = z8.object({
365
+ file: z8.string(),
366
+ lines: z8.string()
367
+ });
368
+ var initContextInvariantSchema = z8.object({
369
+ type: z8.enum(["ban", "require", "protect"]),
370
+ rule: z8.string(),
371
+ rationale: z8.string().optional(),
322
372
  confidence_snapshot: initContextInvariantConfidenceSnapshotSchema.optional(),
323
- source_evidence: z7.array(initContextSourceEvidenceSchema).optional()
324
- });
325
- var initContextDomainGroupSchema = z7.object({
326
- name: z7.string(),
327
- paths: z7.array(z7.string()),
328
- summary: z7.string().optional(),
329
- topology_type: z7.enum(["mirror", "cross-cutting"]).optional(),
330
- target_path: z7.string().optional()
331
- });
332
- var initContextInterviewTrailEntrySchema = z7.object({
333
- phase: z7.string(),
334
- question: z7.string(),
335
- answer: z7.string(),
336
- presentation: z7.string().optional(),
337
- user_corrections: z7.array(z7.string()).optional()
338
- });
339
- var initContextSchema = z7.object({
373
+ source_evidence: z8.array(initContextSourceEvidenceSchema).optional()
374
+ });
375
+ var initContextDomainGroupSchema = z8.object({
376
+ name: z8.string(),
377
+ paths: z8.array(z8.string()),
378
+ summary: z8.string().optional(),
379
+ topology_type: z8.enum(["mirror", "cross-cutting"]).optional(),
380
+ target_path: z8.string().optional()
381
+ });
382
+ var initContextInterviewTrailEntrySchema = z8.object({
383
+ phase: z8.string(),
384
+ question: z8.string(),
385
+ answer: z8.string(),
386
+ presentation: z8.string().optional(),
387
+ user_corrections: z8.array(z8.string()).optional()
388
+ });
389
+ var initContextSchema = z8.object({
340
390
  framework: initContextFrameworkSchema,
341
- architecture_patterns: z7.array(z7.string()),
342
- invariants: z7.array(initContextInvariantSchema),
343
- domain_groups: z7.array(initContextDomainGroupSchema),
344
- interview_trail: z7.array(initContextInterviewTrailEntrySchema),
345
- forensic_ref: z7.string()
391
+ architecture_patterns: z8.array(z8.string()),
392
+ invariants: z8.array(initContextInvariantSchema),
393
+ domain_groups: z8.array(initContextDomainGroupSchema),
394
+ interview_trail: z8.array(initContextInterviewTrailEntrySchema),
395
+ forensic_ref: z8.string()
346
396
  });
347
397
 
348
398
  // src/schemas/events.ts
349
- import { z as z8 } from "zod";
350
- var metaUpdatedEventSchema = z8.object({
351
- type: z8.literal("meta:updated"),
399
+ import { z as z9 } from "zod";
400
+ var metaUpdatedEventSchema = z9.object({
401
+ type: z9.literal("meta:updated"),
352
402
  payload: agentsMetaSchema
353
403
  });
354
- var lockDriftEventSchema = z8.object({
355
- type: z8.literal("lock:drift"),
356
- payload: z8.object({
357
- locked: z8.array(humanLockEntrySchema),
358
- drifted: z8.array(humanLockEntrySchema)
404
+ var lockDriftEventSchema = z9.object({
405
+ type: z9.literal("lock:drift"),
406
+ payload: z9.object({
407
+ locked: z9.array(humanLockEntrySchema),
408
+ drifted: z9.array(humanLockEntrySchema)
359
409
  })
360
410
  });
361
- var lockApprovedEventSchema = z8.object({
362
- type: z8.literal("lock:approved"),
363
- payload: z8.object({
364
- locked: z8.array(humanLockEntrySchema),
365
- approved: z8.array(humanLockEntrySchema)
411
+ var lockApprovedEventSchema = z9.object({
412
+ type: z9.literal("lock:approved"),
413
+ payload: z9.object({
414
+ locked: z9.array(humanLockEntrySchema),
415
+ approved: z9.array(humanLockEntrySchema)
366
416
  })
367
417
  });
368
- var ledgerAppendedEventSchema = z8.object({
369
- type: z8.literal("ledger:appended"),
418
+ var ledgerAppendedEventSchema = z9.object({
419
+ type: z9.literal("ledger:appended"),
370
420
  payload: ledgerEntrySchema
371
421
  });
372
- var driftDetectedEventSchema = z8.object({
373
- type: z8.literal("drift:detected"),
422
+ var driftDetectedEventSchema = z9.object({
423
+ type: z9.literal("drift:detected"),
374
424
  payload: forensicReportSchema
375
425
  });
376
- var fabricEventSchema = z8.discriminatedUnion("type", [
426
+ var fabricEventSchema = z9.discriminatedUnion("type", [
377
427
  metaUpdatedEventSchema,
378
428
  lockDriftEventSchema,
379
429
  lockApprovedEventSchema,
380
430
  ledgerAppendedEventSchema,
381
431
  driftDetectedEventSchema
382
432
  ]);
433
+
434
+ // src/schemas/event-ledger.ts
435
+ import { z as z10 } from "zod";
436
+ var eventLedgerEnvelopeSchema = {
437
+ kind: z10.literal("fabric-event"),
438
+ id: z10.string(),
439
+ ts: z10.number().int().nonnegative(),
440
+ schema_version: z10.literal(1),
441
+ correlation_id: z10.string().optional(),
442
+ session_id: z10.string().optional()
443
+ };
444
+ var stringRecordSchema = z10.record(z10.string());
445
+ var ruleContextPlannedEventSchema = z10.object({
446
+ ...eventLedgerEnvelopeSchema,
447
+ event_type: z10.literal("rule_context_planned"),
448
+ target_paths: z10.array(z10.string()),
449
+ required_stable_ids: z10.array(z10.string()),
450
+ ai_selectable_stable_ids: z10.array(z10.string()),
451
+ final_stable_ids: z10.array(z10.string()),
452
+ selection_token: z10.string().optional(),
453
+ client_hash: z10.string().optional(),
454
+ intent: z10.string().optional(),
455
+ known_tech: z10.array(z10.string()).optional(),
456
+ diagnostics: z10.array(z10.unknown()).optional()
457
+ });
458
+ var ruleSelectionEventSchema = z10.object({
459
+ ...eventLedgerEnvelopeSchema,
460
+ event_type: z10.literal("rule_selection"),
461
+ selection_token: z10.string(),
462
+ target_paths: z10.array(z10.string()),
463
+ required_stable_ids: z10.array(z10.string()),
464
+ ai_selectable_stable_ids: z10.array(z10.string()),
465
+ ai_selected_stable_ids: z10.array(z10.string()),
466
+ final_stable_ids: z10.array(z10.string()),
467
+ ai_selection_reasons: stringRecordSchema,
468
+ rejected_stable_ids: z10.array(z10.string()),
469
+ ignored_stable_ids: z10.array(z10.string())
470
+ });
471
+ var ruleSectionsFetchedEventSchema = z10.object({
472
+ ...eventLedgerEnvelopeSchema,
473
+ event_type: z10.literal("rule_sections_fetched"),
474
+ selection_token: z10.string(),
475
+ target_paths: z10.array(z10.string()).optional(),
476
+ requested_sections: z10.array(z10.string()),
477
+ final_stable_ids: z10.array(z10.string()),
478
+ ai_selected_stable_ids: z10.array(z10.string()),
479
+ diagnostics: z10.array(z10.unknown()).optional()
480
+ });
481
+ var editIntentCheckedEventSchema = z10.object({
482
+ ...eventLedgerEnvelopeSchema,
483
+ event_type: z10.literal("edit_intent_checked"),
484
+ path: z10.string(),
485
+ compliant: z10.boolean(),
486
+ intent: z10.string(),
487
+ ledger_entry_id: z10.string(),
488
+ ledger_source: z10.enum(["ai", "human"]).optional(),
489
+ commit_sha: z10.string().optional(),
490
+ parent_sha: z10.string().optional(),
491
+ parent_ledger_entry_id: z10.string().optional(),
492
+ diff_stat: z10.string().optional(),
493
+ annotation: z10.string().optional(),
494
+ matched_rule_context_ts: z10.number().int().nonnegative().nullable(),
495
+ window_ms: z10.number().int().nonnegative()
496
+ });
497
+ var ruleDriftDetectedEventSchema = z10.object({
498
+ ...eventLedgerEnvelopeSchema,
499
+ event_type: z10.literal("rule_drift_detected"),
500
+ revision: z10.string().optional(),
501
+ drifted_stable_ids: z10.array(z10.string()),
502
+ missing_files: z10.array(z10.string()),
503
+ stale_files: z10.array(z10.string()),
504
+ details: z10.array(
505
+ z10.object({
506
+ file: z10.string(),
507
+ stable_id: z10.string(),
508
+ expected_hash: z10.string(),
509
+ actual_hash: z10.string().nullable()
510
+ })
511
+ ).optional()
512
+ });
513
+ var ruleBaselineAcceptedEventSchema = z10.object({
514
+ ...eventLedgerEnvelopeSchema,
515
+ event_type: z10.literal("rule_baseline_accepted"),
516
+ revision: z10.string(),
517
+ previous_revision: z10.string().optional(),
518
+ accepted_stable_ids: z10.array(z10.string()),
519
+ source: z10.enum(["doctor_fix", "sync_meta"]).optional()
520
+ });
521
+ var baselineSyncedEventSchema = z10.object({
522
+ ...eventLedgerEnvelopeSchema,
523
+ event_type: z10.literal("baseline_synced"),
524
+ revision: z10.string(),
525
+ previous_revision: z10.string().optional(),
526
+ synced_files: z10.array(z10.string()),
527
+ accepted_stable_ids: z10.array(z10.string()),
528
+ source: z10.enum(["doctor_fix", "sync_meta"])
529
+ });
530
+ var mcpEventLedgerEventSchema = z10.object({
531
+ ...eventLedgerEnvelopeSchema,
532
+ event_type: z10.literal("mcp_event"),
533
+ mcp_event_id: z10.string(),
534
+ stream_id: z10.string(),
535
+ message: z10.unknown()
536
+ });
537
+ var eventLedgerEventSchema = z10.discriminatedUnion("event_type", [
538
+ ruleContextPlannedEventSchema,
539
+ ruleSelectionEventSchema,
540
+ ruleSectionsFetchedEventSchema,
541
+ editIntentCheckedEventSchema,
542
+ ruleDriftDetectedEventSchema,
543
+ ruleBaselineAcceptedEventSchema,
544
+ baselineSyncedEventSchema,
545
+ mcpEventLedgerEventSchema
546
+ ]);
383
547
  export {
384
548
  AGENTS_META_IDENTITY_SOURCES,
385
549
  AGENTS_META_LAYERS,
386
550
  AGENTS_META_TOPOLOGY_TYPES,
387
551
  PROTECTED_TOKENS,
552
+ RULE_TEST_INDEX_SCHEMA_VERSION,
388
553
  agentsIdentitySourceSchema,
389
554
  agentsLayerSchema,
390
555
  agentsMetaNodeSchema,
@@ -393,6 +558,7 @@ export {
393
558
  aiLedgerEntrySchema,
394
559
  annotateIntentRequestSchema,
395
560
  auditModeSchema,
561
+ baselineSyncedEventSchema,
396
562
  candidateFileEntrySchema,
397
563
  clientPathsSchema,
398
564
  createTranslator,
@@ -403,7 +569,9 @@ export {
403
569
  deriveAgentsMetaTopologyType,
404
570
  detectNodeLocale,
405
571
  driftDetectedEventSchema,
572
+ editIntentCheckedEventSchema,
406
573
  enMessages,
574
+ eventLedgerEventSchema,
407
575
  fabricConfigSchema,
408
576
  fabricEventSchema,
409
577
  forensicAssertionCoverageSchema,
@@ -435,8 +603,19 @@ export {
435
603
  ledgerSourceSchema,
436
604
  lockApprovedEventSchema,
437
605
  lockDriftEventSchema,
606
+ mcpEventLedgerEventSchema,
438
607
  metaUpdatedEventSchema,
439
608
  normalizeLocale,
609
+ ruleBaselineAcceptedEventSchema,
610
+ ruleContextPlannedEventSchema,
611
+ ruleDescriptionIndexItemSchema,
612
+ ruleDescriptionSchema,
613
+ ruleDriftDetectedEventSchema,
614
+ ruleSectionsFetchedEventSchema,
615
+ ruleSelectionEventSchema,
616
+ ruleTestIndexSchema,
617
+ ruleTestLinkSchema,
618
+ ruleTestOrphanAnnotationSchema,
440
619
  withDerivedAgentsMetaNodeDefaults,
441
620
  zhCNMessages
442
621
  };