@fenglimg/fabric-shared 1.7.0 → 1.8.0-rc.2
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/chunk-3SZRB42B.js +90 -0
- package/dist/{chunk-5H2PVNB2.js → chunk-BLXHC5HA.js} +30 -10
- package/dist/chunk-GI6L6VTT.js +176 -0
- package/dist/chunk-KV27CZH3.js +223 -0
- package/dist/errors/index.d.ts +65 -0
- package/dist/errors/index.js +30 -0
- package/dist/i18n/index.js +1 -1
- package/dist/index.d.ts +718 -254
- package/dist/index.js +354 -309
- package/dist/node/atomic-write.d.ts +14 -0
- package/dist/node/atomic-write.js +60 -0
- package/dist/node/bootstrap-guide.d.ts +12 -0
- package/dist/node/bootstrap-guide.js +52 -0
- package/dist/node/mcp-payload-guard.d.ts +16 -0
- package/dist/node/mcp-payload-guard.js +40 -0
- package/dist/node.js +3 -172
- package/dist/schemas/api-contracts.d.ts +883 -0
- package/dist/schemas/api-contracts.js +36 -0
- package/dist/types/index.d.ts +6 -4
- package/package.json +28 -4
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import "./chunk-LXNCAKJZ.js";
|
|
1
2
|
import {
|
|
2
3
|
PROTECTED_TOKENS,
|
|
3
4
|
createTranslator,
|
|
@@ -6,8 +7,25 @@ import {
|
|
|
6
7
|
enMessages,
|
|
7
8
|
normalizeLocale,
|
|
8
9
|
zhCNMessages
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import
|
|
10
|
+
} from "./chunk-BLXHC5HA.js";
|
|
11
|
+
import {
|
|
12
|
+
annotateIntentRequestSchema,
|
|
13
|
+
getRulesAnnotations,
|
|
14
|
+
getRulesInputSchema,
|
|
15
|
+
getRulesOutputSchema,
|
|
16
|
+
historyStateQuerySchema,
|
|
17
|
+
humanLockApproveRequestSchema,
|
|
18
|
+
humanLockFileParamsSchema,
|
|
19
|
+
ledgerQuerySchema,
|
|
20
|
+
ledgerSourceSchema,
|
|
21
|
+
planContextAnnotations,
|
|
22
|
+
planContextInputSchema,
|
|
23
|
+
planContextOutputSchema,
|
|
24
|
+
ruleSectionsAnnotations,
|
|
25
|
+
ruleSectionsInputSchema,
|
|
26
|
+
ruleSectionsOutputSchema,
|
|
27
|
+
structuredWarningSchema
|
|
28
|
+
} from "./chunk-KV27CZH3.js";
|
|
11
29
|
|
|
12
30
|
// src/schemas/agents-meta.ts
|
|
13
31
|
import { z } from "zod";
|
|
@@ -156,83 +174,29 @@ var ruleTestIndexSchema = z2.object({
|
|
|
156
174
|
orphan_annotations: z2.array(ruleTestOrphanAnnotationSchema)
|
|
157
175
|
}).strict();
|
|
158
176
|
|
|
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) => {
|
|
163
|
-
if (value === void 0 || value === null || value === "") {
|
|
164
|
-
return void 0;
|
|
165
|
-
}
|
|
166
|
-
if (typeof value === "number") {
|
|
167
|
-
return value;
|
|
168
|
-
}
|
|
169
|
-
if (typeof value === "string") {
|
|
170
|
-
const trimmed = value.trim();
|
|
171
|
-
if (trimmed.length === 0) {
|
|
172
|
-
return void 0;
|
|
173
|
-
}
|
|
174
|
-
if (/^\d+$/.test(trimmed)) {
|
|
175
|
-
return Number.parseInt(trimmed, 10);
|
|
176
|
-
}
|
|
177
|
-
const parsed = Date.parse(trimmed);
|
|
178
|
-
return Number.isNaN(parsed) ? value : parsed;
|
|
179
|
-
}
|
|
180
|
-
return value;
|
|
181
|
-
}, z3.number().int().nonnegative());
|
|
182
|
-
var ledgerQuerySchema = z3.object({
|
|
183
|
-
source: ledgerSourceSchema.optional(),
|
|
184
|
-
since: timestampFilterSchema.optional()
|
|
185
|
-
});
|
|
186
|
-
var historyStateQuerySchema = z3.object({
|
|
187
|
-
ledger_id: z3.string().trim().min(1).optional(),
|
|
188
|
-
ts: timestampFilterSchema.optional()
|
|
189
|
-
}).superRefine((value, ctx) => {
|
|
190
|
-
const provided = [value.ledger_id, value.ts].filter((entry) => entry !== void 0);
|
|
191
|
-
if (provided.length !== 1) {
|
|
192
|
-
ctx.addIssue({
|
|
193
|
-
code: z3.ZodIssueCode.custom,
|
|
194
|
-
message: "Provide exactly one of ledger_id or ts.",
|
|
195
|
-
path: ["ledger_id"]
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
});
|
|
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)
|
|
204
|
-
});
|
|
205
|
-
var humanLockFileParamsSchema = z3.object({
|
|
206
|
-
file: z3.string().min(1)
|
|
207
|
-
});
|
|
208
|
-
var annotateIntentRequestSchema = z3.object({
|
|
209
|
-
ledger_entry_id: z3.string().min(1),
|
|
210
|
-
annotation: z3.string().trim().min(1)
|
|
211
|
-
});
|
|
212
|
-
|
|
213
177
|
// src/schemas/ledger-entry.ts
|
|
214
|
-
import { z as
|
|
178
|
+
import { z as z3 } from "zod";
|
|
215
179
|
var ledgerEntryBaseSchema = {
|
|
216
|
-
id:
|
|
217
|
-
ts:
|
|
218
|
-
intent:
|
|
219
|
-
affected_paths:
|
|
180
|
+
id: z3.string().optional(),
|
|
181
|
+
ts: z3.number().int().nonnegative(),
|
|
182
|
+
intent: z3.string(),
|
|
183
|
+
affected_paths: z3.array(z3.string())
|
|
220
184
|
};
|
|
221
|
-
var aiLedgerEntrySchema =
|
|
185
|
+
var aiLedgerEntrySchema = z3.object({
|
|
222
186
|
...ledgerEntryBaseSchema,
|
|
223
|
-
source:
|
|
224
|
-
commit_sha:
|
|
187
|
+
source: z3.literal("ai"),
|
|
188
|
+
commit_sha: z3.string().optional()
|
|
225
189
|
});
|
|
226
|
-
var humanLedgerEntrySchema =
|
|
190
|
+
var humanLedgerEntrySchema = z3.object({
|
|
227
191
|
...ledgerEntryBaseSchema,
|
|
228
|
-
source:
|
|
229
|
-
parent_sha:
|
|
230
|
-
parent_ledger_entry_id:
|
|
231
|
-
diff_stat:
|
|
232
|
-
annotation:
|
|
233
|
-
});
|
|
234
|
-
var ledgerEntryUnionSchema =
|
|
235
|
-
var ledgerEntrySchema =
|
|
192
|
+
source: z3.literal("human"),
|
|
193
|
+
parent_sha: z3.string(),
|
|
194
|
+
parent_ledger_entry_id: z3.string().optional(),
|
|
195
|
+
diff_stat: z3.string(),
|
|
196
|
+
annotation: z3.string().optional()
|
|
197
|
+
});
|
|
198
|
+
var ledgerEntryUnionSchema = z3.discriminatedUnion("source", [aiLedgerEntrySchema, humanLedgerEntrySchema]);
|
|
199
|
+
var ledgerEntrySchema = z3.preprocess((value) => {
|
|
236
200
|
if (value && typeof value === "object" && !Array.isArray(value) && (!("source" in value) || value.source === void 0)) {
|
|
237
201
|
return {
|
|
238
202
|
...value,
|
|
@@ -243,187 +207,189 @@ var ledgerEntrySchema = z4.preprocess((value) => {
|
|
|
243
207
|
}, ledgerEntryUnionSchema);
|
|
244
208
|
|
|
245
209
|
// src/schemas/human-lock.ts
|
|
246
|
-
import { z as
|
|
247
|
-
var humanLockEntrySchema =
|
|
248
|
-
file:
|
|
249
|
-
start_line:
|
|
250
|
-
end_line:
|
|
251
|
-
hash:
|
|
210
|
+
import { z as z4 } from "zod";
|
|
211
|
+
var humanLockEntrySchema = z4.object({
|
|
212
|
+
file: z4.string(),
|
|
213
|
+
start_line: z4.number().int().nonnegative(),
|
|
214
|
+
end_line: z4.number().int().nonnegative(),
|
|
215
|
+
hash: z4.string()
|
|
252
216
|
});
|
|
253
|
-
var humanLockFileSchema =
|
|
254
|
-
locked:
|
|
217
|
+
var humanLockFileSchema = z4.object({
|
|
218
|
+
locked: z4.array(humanLockEntrySchema).optional()
|
|
255
219
|
});
|
|
256
220
|
|
|
257
221
|
// src/schemas/fabric-config.ts
|
|
258
|
-
import { z as
|
|
259
|
-
var auditModeSchema =
|
|
260
|
-
var clientPathsSchema =
|
|
261
|
-
claudeCodeCLI:
|
|
262
|
-
claudeCodeDesktop:
|
|
263
|
-
cursor:
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
222
|
+
import { z as z5 } from "zod";
|
|
223
|
+
var auditModeSchema = z5.enum(["strict", "warn", "off"]);
|
|
224
|
+
var clientPathsSchema = z5.object({
|
|
225
|
+
claudeCodeCLI: z5.string().optional(),
|
|
226
|
+
claudeCodeDesktop: z5.string().optional(),
|
|
227
|
+
cursor: z5.string().optional(),
|
|
228
|
+
codexCLI: z5.string().optional()
|
|
229
|
+
}).passthrough();
|
|
230
|
+
var mcpPayloadLimitsSchema = z5.object({
|
|
231
|
+
warnBytes: z5.number().int().positive().optional(),
|
|
232
|
+
hardBytes: z5.number().int().positive().optional()
|
|
233
|
+
}).optional();
|
|
234
|
+
var fabricConfigSchema = z5.object({
|
|
270
235
|
clientPaths: clientPathsSchema.optional(),
|
|
271
|
-
externalFixturePath:
|
|
272
|
-
scanIgnores:
|
|
236
|
+
externalFixturePath: z5.string().optional(),
|
|
237
|
+
scanIgnores: z5.array(z5.string()).optional(),
|
|
273
238
|
auditMode: auditModeSchema.optional(),
|
|
274
|
-
audit_mode: auditModeSchema.optional()
|
|
239
|
+
audit_mode: auditModeSchema.optional(),
|
|
240
|
+
mcpPayloadLimits: mcpPayloadLimitsSchema
|
|
275
241
|
});
|
|
276
242
|
|
|
277
243
|
// src/schemas/forensic-report.ts
|
|
278
|
-
import { z as
|
|
279
|
-
var forensicCodeSampleSchema =
|
|
280
|
-
path:
|
|
281
|
-
lines:
|
|
282
|
-
snippet:
|
|
283
|
-
pattern_hint:
|
|
284
|
-
});
|
|
285
|
-
var forensicEvidenceAnchorSchema =
|
|
286
|
-
file:
|
|
287
|
-
line:
|
|
288
|
-
snippet:
|
|
289
|
-
});
|
|
290
|
-
var forensicAssertionCoverageSchema =
|
|
291
|
-
ratio:
|
|
292
|
-
total:
|
|
293
|
-
matched:
|
|
294
|
-
co_occurring_patterns:
|
|
295
|
-
});
|
|
296
|
-
var forensicAssertionSchema =
|
|
297
|
-
type:
|
|
298
|
-
statement:
|
|
299
|
-
confidence:
|
|
300
|
-
evidence:
|
|
244
|
+
import { z as z6 } from "zod";
|
|
245
|
+
var forensicCodeSampleSchema = z6.object({
|
|
246
|
+
path: z6.string(),
|
|
247
|
+
lines: z6.string(),
|
|
248
|
+
snippet: z6.string(),
|
|
249
|
+
pattern_hint: z6.string()
|
|
250
|
+
});
|
|
251
|
+
var forensicEvidenceAnchorSchema = z6.object({
|
|
252
|
+
file: z6.string(),
|
|
253
|
+
line: z6.string(),
|
|
254
|
+
snippet: z6.string()
|
|
255
|
+
});
|
|
256
|
+
var forensicAssertionCoverageSchema = z6.object({
|
|
257
|
+
ratio: z6.number().min(0).max(1),
|
|
258
|
+
total: z6.number().int().nonnegative(),
|
|
259
|
+
matched: z6.number().int().nonnegative(),
|
|
260
|
+
co_occurring_patterns: z6.array(z6.string())
|
|
261
|
+
});
|
|
262
|
+
var forensicAssertionSchema = z6.object({
|
|
263
|
+
type: z6.enum(["framework", "pattern", "invariant", "domain"]),
|
|
264
|
+
statement: z6.string(),
|
|
265
|
+
confidence: z6.enum(["HIGH", "MEDIUM", "LOW"]),
|
|
266
|
+
evidence: z6.array(forensicEvidenceAnchorSchema),
|
|
301
267
|
coverage: forensicAssertionCoverageSchema,
|
|
302
|
-
proposed_rule:
|
|
303
|
-
alternatives:
|
|
304
|
-
});
|
|
305
|
-
var forensicTopologySchema =
|
|
306
|
-
total_files:
|
|
307
|
-
by_ext:
|
|
308
|
-
key_dirs:
|
|
309
|
-
max_depth:
|
|
310
|
-
});
|
|
311
|
-
var forensicEntryPointSchema =
|
|
312
|
-
path:
|
|
313
|
-
reason:
|
|
314
|
-
size_bytes:
|
|
315
|
-
});
|
|
316
|
-
var forensicFrameworkSchema =
|
|
317
|
-
kind:
|
|
318
|
-
version:
|
|
319
|
-
subkind:
|
|
320
|
-
evidence:
|
|
321
|
-
});
|
|
322
|
-
var forensicReadmeSchema =
|
|
323
|
-
quality:
|
|
324
|
-
line_count:
|
|
325
|
-
has_contributing:
|
|
326
|
-
});
|
|
327
|
-
var candidateFileEntrySchema =
|
|
328
|
-
path:
|
|
329
|
-
family:
|
|
330
|
-
rationale:
|
|
331
|
-
});
|
|
332
|
-
var forensicSamplingBudgetSchema =
|
|
333
|
-
max_files:
|
|
334
|
-
max_lines_per_file:
|
|
335
|
-
});
|
|
336
|
-
var forensicReportSchema =
|
|
337
|
-
version:
|
|
338
|
-
generated_at:
|
|
339
|
-
generated_by:
|
|
340
|
-
target:
|
|
341
|
-
project_name:
|
|
268
|
+
proposed_rule: z6.string().optional(),
|
|
269
|
+
alternatives: z6.array(z6.string()).optional()
|
|
270
|
+
});
|
|
271
|
+
var forensicTopologySchema = z6.object({
|
|
272
|
+
total_files: z6.number().int().nonnegative(),
|
|
273
|
+
by_ext: z6.record(z6.number().int().nonnegative()),
|
|
274
|
+
key_dirs: z6.array(z6.string()),
|
|
275
|
+
max_depth: z6.number().int().nonnegative()
|
|
276
|
+
});
|
|
277
|
+
var forensicEntryPointSchema = z6.object({
|
|
278
|
+
path: z6.string(),
|
|
279
|
+
reason: z6.string(),
|
|
280
|
+
size_bytes: z6.number().int().nonnegative().optional()
|
|
281
|
+
});
|
|
282
|
+
var forensicFrameworkSchema = z6.object({
|
|
283
|
+
kind: z6.string(),
|
|
284
|
+
version: z6.string(),
|
|
285
|
+
subkind: z6.string(),
|
|
286
|
+
evidence: z6.array(z6.string())
|
|
287
|
+
});
|
|
288
|
+
var forensicReadmeSchema = z6.object({
|
|
289
|
+
quality: z6.enum(["missing", "stub", "ok"]),
|
|
290
|
+
line_count: z6.number().int().nonnegative(),
|
|
291
|
+
has_contributing: z6.boolean()
|
|
292
|
+
});
|
|
293
|
+
var candidateFileEntrySchema = z6.object({
|
|
294
|
+
path: z6.string(),
|
|
295
|
+
family: z6.enum(["entry", "component", "config", "test", "domain"]),
|
|
296
|
+
rationale: z6.string()
|
|
297
|
+
});
|
|
298
|
+
var forensicSamplingBudgetSchema = z6.object({
|
|
299
|
+
max_files: z6.literal(15),
|
|
300
|
+
max_lines_per_file: z6.literal(100)
|
|
301
|
+
});
|
|
302
|
+
var forensicReportSchema = z6.object({
|
|
303
|
+
version: z6.string(),
|
|
304
|
+
generated_at: z6.string(),
|
|
305
|
+
generated_by: z6.string(),
|
|
306
|
+
target: z6.string(),
|
|
307
|
+
project_name: z6.string(),
|
|
342
308
|
framework: forensicFrameworkSchema,
|
|
343
309
|
topology: forensicTopologySchema,
|
|
344
|
-
entry_points:
|
|
345
|
-
code_samples:
|
|
346
|
-
assertions:
|
|
347
|
-
candidate_files:
|
|
310
|
+
entry_points: z6.array(forensicEntryPointSchema),
|
|
311
|
+
code_samples: z6.array(forensicCodeSampleSchema),
|
|
312
|
+
assertions: z6.array(forensicAssertionSchema),
|
|
313
|
+
candidate_files: z6.array(candidateFileEntrySchema),
|
|
348
314
|
sampling_budget: forensicSamplingBudgetSchema,
|
|
349
315
|
readme: forensicReadmeSchema,
|
|
350
|
-
recommendations_for_skill:
|
|
316
|
+
recommendations_for_skill: z6.array(z6.string()).optional()
|
|
351
317
|
});
|
|
352
318
|
|
|
353
319
|
// src/schemas/init-context.ts
|
|
354
|
-
import { z as
|
|
355
|
-
var initContextFrameworkSchema =
|
|
356
|
-
kind:
|
|
357
|
-
version:
|
|
358
|
-
subkind:
|
|
359
|
-
});
|
|
360
|
-
var initContextInvariantConfidenceSnapshotSchema =
|
|
361
|
-
confidence:
|
|
362
|
-
evidence_refs:
|
|
363
|
-
});
|
|
364
|
-
var initContextSourceEvidenceSchema =
|
|
365
|
-
file:
|
|
366
|
-
lines:
|
|
367
|
-
});
|
|
368
|
-
var initContextInvariantSchema =
|
|
369
|
-
type:
|
|
370
|
-
rule:
|
|
371
|
-
rationale:
|
|
320
|
+
import { z as z7 } from "zod";
|
|
321
|
+
var initContextFrameworkSchema = z7.object({
|
|
322
|
+
kind: z7.string(),
|
|
323
|
+
version: z7.string(),
|
|
324
|
+
subkind: z7.string()
|
|
325
|
+
});
|
|
326
|
+
var initContextInvariantConfidenceSnapshotSchema = z7.object({
|
|
327
|
+
confidence: z7.enum(["HIGH", "MEDIUM", "LOW"]),
|
|
328
|
+
evidence_refs: z7.array(z7.string())
|
|
329
|
+
});
|
|
330
|
+
var initContextSourceEvidenceSchema = z7.object({
|
|
331
|
+
file: z7.string(),
|
|
332
|
+
lines: z7.string()
|
|
333
|
+
});
|
|
334
|
+
var initContextInvariantSchema = z7.object({
|
|
335
|
+
type: z7.enum(["ban", "require", "protect"]),
|
|
336
|
+
rule: z7.string(),
|
|
337
|
+
rationale: z7.string().optional(),
|
|
372
338
|
confidence_snapshot: initContextInvariantConfidenceSnapshotSchema.optional(),
|
|
373
|
-
source_evidence:
|
|
374
|
-
});
|
|
375
|
-
var initContextDomainGroupSchema =
|
|
376
|
-
name:
|
|
377
|
-
paths:
|
|
378
|
-
summary:
|
|
379
|
-
topology_type:
|
|
380
|
-
target_path:
|
|
381
|
-
});
|
|
382
|
-
var initContextInterviewTrailEntrySchema =
|
|
383
|
-
phase:
|
|
384
|
-
question:
|
|
385
|
-
answer:
|
|
386
|
-
presentation:
|
|
387
|
-
user_corrections:
|
|
388
|
-
});
|
|
389
|
-
var initContextSchema =
|
|
339
|
+
source_evidence: z7.array(initContextSourceEvidenceSchema).optional()
|
|
340
|
+
});
|
|
341
|
+
var initContextDomainGroupSchema = z7.object({
|
|
342
|
+
name: z7.string(),
|
|
343
|
+
paths: z7.array(z7.string()),
|
|
344
|
+
summary: z7.string().optional(),
|
|
345
|
+
topology_type: z7.enum(["mirror", "cross-cutting"]).optional(),
|
|
346
|
+
target_path: z7.string().optional()
|
|
347
|
+
});
|
|
348
|
+
var initContextInterviewTrailEntrySchema = z7.object({
|
|
349
|
+
phase: z7.string(),
|
|
350
|
+
question: z7.string(),
|
|
351
|
+
answer: z7.string(),
|
|
352
|
+
presentation: z7.string().optional(),
|
|
353
|
+
user_corrections: z7.array(z7.string()).optional()
|
|
354
|
+
});
|
|
355
|
+
var initContextSchema = z7.object({
|
|
390
356
|
framework: initContextFrameworkSchema,
|
|
391
|
-
architecture_patterns:
|
|
392
|
-
invariants:
|
|
393
|
-
domain_groups:
|
|
394
|
-
interview_trail:
|
|
395
|
-
forensic_ref:
|
|
357
|
+
architecture_patterns: z7.array(z7.string()),
|
|
358
|
+
invariants: z7.array(initContextInvariantSchema),
|
|
359
|
+
domain_groups: z7.array(initContextDomainGroupSchema),
|
|
360
|
+
interview_trail: z7.array(initContextInterviewTrailEntrySchema),
|
|
361
|
+
forensic_ref: z7.string()
|
|
396
362
|
});
|
|
397
363
|
|
|
398
364
|
// src/schemas/events.ts
|
|
399
|
-
import { z as
|
|
400
|
-
var metaUpdatedEventSchema =
|
|
401
|
-
type:
|
|
365
|
+
import { z as z8 } from "zod";
|
|
366
|
+
var metaUpdatedEventSchema = z8.object({
|
|
367
|
+
type: z8.literal("meta:updated"),
|
|
402
368
|
payload: agentsMetaSchema
|
|
403
369
|
});
|
|
404
|
-
var lockDriftEventSchema =
|
|
405
|
-
type:
|
|
406
|
-
payload:
|
|
407
|
-
locked:
|
|
408
|
-
drifted:
|
|
370
|
+
var lockDriftEventSchema = z8.object({
|
|
371
|
+
type: z8.literal("lock:drift"),
|
|
372
|
+
payload: z8.object({
|
|
373
|
+
locked: z8.array(humanLockEntrySchema),
|
|
374
|
+
drifted: z8.array(humanLockEntrySchema)
|
|
409
375
|
})
|
|
410
376
|
});
|
|
411
|
-
var lockApprovedEventSchema =
|
|
412
|
-
type:
|
|
413
|
-
payload:
|
|
414
|
-
locked:
|
|
415
|
-
approved:
|
|
377
|
+
var lockApprovedEventSchema = z8.object({
|
|
378
|
+
type: z8.literal("lock:approved"),
|
|
379
|
+
payload: z8.object({
|
|
380
|
+
locked: z8.array(humanLockEntrySchema),
|
|
381
|
+
approved: z8.array(humanLockEntrySchema)
|
|
416
382
|
})
|
|
417
383
|
});
|
|
418
|
-
var ledgerAppendedEventSchema =
|
|
419
|
-
type:
|
|
384
|
+
var ledgerAppendedEventSchema = z8.object({
|
|
385
|
+
type: z8.literal("ledger:appended"),
|
|
420
386
|
payload: ledgerEntrySchema
|
|
421
387
|
});
|
|
422
|
-
var driftDetectedEventSchema =
|
|
423
|
-
type:
|
|
388
|
+
var driftDetectedEventSchema = z8.object({
|
|
389
|
+
type: z8.literal("drift:detected"),
|
|
424
390
|
payload: forensicReportSchema
|
|
425
391
|
});
|
|
426
|
-
var fabricEventSchema =
|
|
392
|
+
var fabricEventSchema = z8.discriminatedUnion("type", [
|
|
427
393
|
metaUpdatedEventSchema,
|
|
428
394
|
lockDriftEventSchema,
|
|
429
395
|
lockApprovedEventSchema,
|
|
@@ -432,109 +398,161 @@ var fabricEventSchema = z9.discriminatedUnion("type", [
|
|
|
432
398
|
]);
|
|
433
399
|
|
|
434
400
|
// src/schemas/event-ledger.ts
|
|
435
|
-
import { z as
|
|
401
|
+
import { z as z9 } from "zod";
|
|
436
402
|
var eventLedgerEnvelopeSchema = {
|
|
437
|
-
kind:
|
|
438
|
-
id:
|
|
439
|
-
ts:
|
|
440
|
-
schema_version:
|
|
441
|
-
correlation_id:
|
|
442
|
-
session_id:
|
|
403
|
+
kind: z9.literal("fabric-event"),
|
|
404
|
+
id: z9.string(),
|
|
405
|
+
ts: z9.number().int().nonnegative(),
|
|
406
|
+
schema_version: z9.literal(1),
|
|
407
|
+
correlation_id: z9.string().optional(),
|
|
408
|
+
session_id: z9.string().optional()
|
|
443
409
|
};
|
|
444
|
-
var stringRecordSchema =
|
|
445
|
-
var ruleContextPlannedEventSchema =
|
|
410
|
+
var stringRecordSchema = z9.record(z9.string());
|
|
411
|
+
var ruleContextPlannedEventSchema = z9.object({
|
|
446
412
|
...eventLedgerEnvelopeSchema,
|
|
447
|
-
event_type:
|
|
448
|
-
target_paths:
|
|
449
|
-
required_stable_ids:
|
|
450
|
-
ai_selectable_stable_ids:
|
|
451
|
-
final_stable_ids:
|
|
452
|
-
selection_token:
|
|
453
|
-
client_hash:
|
|
454
|
-
intent:
|
|
455
|
-
known_tech:
|
|
456
|
-
diagnostics:
|
|
457
|
-
});
|
|
458
|
-
var ruleSelectionEventSchema =
|
|
413
|
+
event_type: z9.literal("rule_context_planned"),
|
|
414
|
+
target_paths: z9.array(z9.string()),
|
|
415
|
+
required_stable_ids: z9.array(z9.string()),
|
|
416
|
+
ai_selectable_stable_ids: z9.array(z9.string()),
|
|
417
|
+
final_stable_ids: z9.array(z9.string()),
|
|
418
|
+
selection_token: z9.string().optional(),
|
|
419
|
+
client_hash: z9.string().optional(),
|
|
420
|
+
intent: z9.string().optional(),
|
|
421
|
+
known_tech: z9.array(z9.string()).optional(),
|
|
422
|
+
diagnostics: z9.array(z9.unknown()).optional()
|
|
423
|
+
});
|
|
424
|
+
var ruleSelectionEventSchema = z9.object({
|
|
459
425
|
...eventLedgerEnvelopeSchema,
|
|
460
|
-
event_type:
|
|
461
|
-
selection_token:
|
|
462
|
-
target_paths:
|
|
463
|
-
required_stable_ids:
|
|
464
|
-
ai_selectable_stable_ids:
|
|
465
|
-
ai_selected_stable_ids:
|
|
466
|
-
final_stable_ids:
|
|
426
|
+
event_type: z9.literal("rule_selection"),
|
|
427
|
+
selection_token: z9.string(),
|
|
428
|
+
target_paths: z9.array(z9.string()),
|
|
429
|
+
required_stable_ids: z9.array(z9.string()),
|
|
430
|
+
ai_selectable_stable_ids: z9.array(z9.string()),
|
|
431
|
+
ai_selected_stable_ids: z9.array(z9.string()),
|
|
432
|
+
final_stable_ids: z9.array(z9.string()),
|
|
467
433
|
ai_selection_reasons: stringRecordSchema,
|
|
468
|
-
rejected_stable_ids:
|
|
469
|
-
ignored_stable_ids:
|
|
434
|
+
rejected_stable_ids: z9.array(z9.string()),
|
|
435
|
+
ignored_stable_ids: z9.array(z9.string())
|
|
470
436
|
});
|
|
471
|
-
var ruleSectionsFetchedEventSchema =
|
|
437
|
+
var ruleSectionsFetchedEventSchema = z9.object({
|
|
472
438
|
...eventLedgerEnvelopeSchema,
|
|
473
|
-
event_type:
|
|
474
|
-
selection_token:
|
|
475
|
-
target_paths:
|
|
476
|
-
requested_sections:
|
|
477
|
-
final_stable_ids:
|
|
478
|
-
ai_selected_stable_ids:
|
|
479
|
-
diagnostics:
|
|
480
|
-
});
|
|
481
|
-
var editIntentCheckedEventSchema =
|
|
439
|
+
event_type: z9.literal("rule_sections_fetched"),
|
|
440
|
+
selection_token: z9.string(),
|
|
441
|
+
target_paths: z9.array(z9.string()).optional(),
|
|
442
|
+
requested_sections: z9.array(z9.string()),
|
|
443
|
+
final_stable_ids: z9.array(z9.string()),
|
|
444
|
+
ai_selected_stable_ids: z9.array(z9.string()),
|
|
445
|
+
diagnostics: z9.array(z9.unknown()).optional()
|
|
446
|
+
});
|
|
447
|
+
var editIntentCheckedEventSchema = z9.object({
|
|
482
448
|
...eventLedgerEnvelopeSchema,
|
|
483
|
-
event_type:
|
|
484
|
-
path:
|
|
485
|
-
compliant:
|
|
486
|
-
intent:
|
|
487
|
-
ledger_entry_id:
|
|
488
|
-
ledger_source:
|
|
489
|
-
commit_sha:
|
|
490
|
-
parent_sha:
|
|
491
|
-
parent_ledger_entry_id:
|
|
492
|
-
diff_stat:
|
|
493
|
-
annotation:
|
|
494
|
-
matched_rule_context_ts:
|
|
495
|
-
window_ms:
|
|
496
|
-
});
|
|
497
|
-
var ruleDriftDetectedEventSchema =
|
|
449
|
+
event_type: z9.literal("edit_intent_checked"),
|
|
450
|
+
path: z9.string(),
|
|
451
|
+
compliant: z9.boolean(),
|
|
452
|
+
intent: z9.string(),
|
|
453
|
+
ledger_entry_id: z9.string(),
|
|
454
|
+
ledger_source: z9.enum(["ai", "human"]).optional(),
|
|
455
|
+
commit_sha: z9.string().optional(),
|
|
456
|
+
parent_sha: z9.string().optional(),
|
|
457
|
+
parent_ledger_entry_id: z9.string().optional(),
|
|
458
|
+
diff_stat: z9.string().optional(),
|
|
459
|
+
annotation: z9.string().optional(),
|
|
460
|
+
matched_rule_context_ts: z9.number().int().nonnegative().nullable(),
|
|
461
|
+
window_ms: z9.number().int().nonnegative()
|
|
462
|
+
});
|
|
463
|
+
var ruleDriftDetectedEventSchema = z9.object({
|
|
498
464
|
...eventLedgerEnvelopeSchema,
|
|
499
|
-
event_type:
|
|
500
|
-
revision:
|
|
501
|
-
drifted_stable_ids:
|
|
502
|
-
missing_files:
|
|
503
|
-
stale_files:
|
|
504
|
-
details:
|
|
505
|
-
|
|
506
|
-
file:
|
|
507
|
-
stable_id:
|
|
508
|
-
expected_hash:
|
|
509
|
-
actual_hash:
|
|
465
|
+
event_type: z9.literal("rule_drift_detected"),
|
|
466
|
+
revision: z9.string().optional(),
|
|
467
|
+
drifted_stable_ids: z9.array(z9.string()),
|
|
468
|
+
missing_files: z9.array(z9.string()),
|
|
469
|
+
stale_files: z9.array(z9.string()),
|
|
470
|
+
details: z9.array(
|
|
471
|
+
z9.object({
|
|
472
|
+
file: z9.string(),
|
|
473
|
+
stable_id: z9.string(),
|
|
474
|
+
expected_hash: z9.string(),
|
|
475
|
+
actual_hash: z9.string().nullable()
|
|
510
476
|
})
|
|
511
477
|
).optional()
|
|
512
478
|
});
|
|
513
|
-
var ruleBaselineAcceptedEventSchema =
|
|
479
|
+
var ruleBaselineAcceptedEventSchema = z9.object({
|
|
514
480
|
...eventLedgerEnvelopeSchema,
|
|
515
|
-
event_type:
|
|
516
|
-
revision:
|
|
517
|
-
previous_revision:
|
|
518
|
-
accepted_stable_ids:
|
|
519
|
-
source:
|
|
481
|
+
event_type: z9.literal("rule_baseline_accepted"),
|
|
482
|
+
revision: z9.string(),
|
|
483
|
+
previous_revision: z9.string().optional(),
|
|
484
|
+
accepted_stable_ids: z9.array(z9.string()),
|
|
485
|
+
source: z9.enum(["doctor_fix", "sync_meta"]).optional()
|
|
520
486
|
});
|
|
521
|
-
var baselineSyncedEventSchema =
|
|
487
|
+
var baselineSyncedEventSchema = z9.object({
|
|
522
488
|
...eventLedgerEnvelopeSchema,
|
|
523
|
-
event_type:
|
|
524
|
-
revision:
|
|
525
|
-
previous_revision:
|
|
526
|
-
synced_files:
|
|
527
|
-
accepted_stable_ids:
|
|
528
|
-
source:
|
|
529
|
-
});
|
|
530
|
-
var mcpEventLedgerEventSchema =
|
|
489
|
+
event_type: z9.literal("baseline_synced"),
|
|
490
|
+
revision: z9.string(),
|
|
491
|
+
previous_revision: z9.string().optional(),
|
|
492
|
+
synced_files: z9.array(z9.string()),
|
|
493
|
+
accepted_stable_ids: z9.array(z9.string()),
|
|
494
|
+
source: z9.enum(["doctor_fix", "sync_meta"])
|
|
495
|
+
});
|
|
496
|
+
var mcpEventLedgerEventSchema = z9.object({
|
|
531
497
|
...eventLedgerEnvelopeSchema,
|
|
532
|
-
event_type:
|
|
533
|
-
mcp_event_id:
|
|
534
|
-
stream_id:
|
|
535
|
-
message:
|
|
498
|
+
event_type: z9.literal("mcp_event"),
|
|
499
|
+
mcp_event_id: z9.string(),
|
|
500
|
+
stream_id: z9.string(),
|
|
501
|
+
message: z9.unknown()
|
|
536
502
|
});
|
|
537
|
-
var
|
|
503
|
+
var reapplyCompletedEventSchema = z9.object({
|
|
504
|
+
...eventLedgerEnvelopeSchema,
|
|
505
|
+
event_type: z9.literal("reapply_completed"),
|
|
506
|
+
preserved_ledger: z9.boolean(),
|
|
507
|
+
preserved_meta: z9.boolean(),
|
|
508
|
+
rules_count: z9.number().int().nonnegative()
|
|
509
|
+
});
|
|
510
|
+
var eventLedgerTruncatedEventSchema = z9.object({
|
|
511
|
+
...eventLedgerEnvelopeSchema,
|
|
512
|
+
event_type: z9.literal("event_ledger_truncated"),
|
|
513
|
+
byte_offset: z9.number().int().nonnegative(),
|
|
514
|
+
byte_length: z9.number().int().nonnegative(),
|
|
515
|
+
corrupted_path: z9.string()
|
|
516
|
+
});
|
|
517
|
+
var mcpConfigMigratedEventSchema = z9.object({
|
|
518
|
+
...eventLedgerEnvelopeSchema,
|
|
519
|
+
event_type: z9.literal("mcp_config_migrated"),
|
|
520
|
+
source: z9.literal("doctor_fix"),
|
|
521
|
+
removed_from: z9.string()
|
|
522
|
+
});
|
|
523
|
+
var metaReconciledOnStartupEventSchema = z9.object({
|
|
524
|
+
...eventLedgerEnvelopeSchema,
|
|
525
|
+
event_type: z9.literal("meta_reconciled_on_startup"),
|
|
526
|
+
reconciled_files: z9.array(z9.string()),
|
|
527
|
+
duration_ms: z9.number().int().nonnegative(),
|
|
528
|
+
source: z9.literal("reconcileRules")
|
|
529
|
+
});
|
|
530
|
+
var metaReconciledEventSchema = z9.object({
|
|
531
|
+
...eventLedgerEnvelopeSchema,
|
|
532
|
+
event_type: z9.literal("meta_reconciled"),
|
|
533
|
+
reconciled_files: z9.array(z9.string()),
|
|
534
|
+
duration_ms: z9.number().int().nonnegative(),
|
|
535
|
+
trigger: z9.enum(["doctor", "manual"]),
|
|
536
|
+
source: z9.literal("reconcileRules")
|
|
537
|
+
});
|
|
538
|
+
var claudeSkillPathMigratedEventSchema = z9.object({
|
|
539
|
+
...eventLedgerEnvelopeSchema,
|
|
540
|
+
event_type: z9.literal("claude_skill_path_migrated"),
|
|
541
|
+
from: z9.string(),
|
|
542
|
+
to: z9.string()
|
|
543
|
+
});
|
|
544
|
+
var claudeHookPathMigratedEventSchema = z9.object({
|
|
545
|
+
...eventLedgerEnvelopeSchema,
|
|
546
|
+
event_type: z9.literal("claude_hook_path_migrated"),
|
|
547
|
+
from: z9.string(),
|
|
548
|
+
to: z9.string()
|
|
549
|
+
});
|
|
550
|
+
var legacyClientPathPresentEventSchema = z9.object({
|
|
551
|
+
...eventLedgerEnvelopeSchema,
|
|
552
|
+
event_type: z9.literal("legacy_client_path_present"),
|
|
553
|
+
removed: z9.array(z9.string())
|
|
554
|
+
});
|
|
555
|
+
var eventLedgerEventSchema = z9.discriminatedUnion("event_type", [
|
|
538
556
|
ruleContextPlannedEventSchema,
|
|
539
557
|
ruleSelectionEventSchema,
|
|
540
558
|
ruleSectionsFetchedEventSchema,
|
|
@@ -542,7 +560,15 @@ var eventLedgerEventSchema = z10.discriminatedUnion("event_type", [
|
|
|
542
560
|
ruleDriftDetectedEventSchema,
|
|
543
561
|
ruleBaselineAcceptedEventSchema,
|
|
544
562
|
baselineSyncedEventSchema,
|
|
545
|
-
mcpEventLedgerEventSchema
|
|
563
|
+
mcpEventLedgerEventSchema,
|
|
564
|
+
reapplyCompletedEventSchema,
|
|
565
|
+
eventLedgerTruncatedEventSchema,
|
|
566
|
+
mcpConfigMigratedEventSchema,
|
|
567
|
+
metaReconciledOnStartupEventSchema,
|
|
568
|
+
metaReconciledEventSchema,
|
|
569
|
+
claudeSkillPathMigratedEventSchema,
|
|
570
|
+
claudeHookPathMigratedEventSchema,
|
|
571
|
+
legacyClientPathPresentEventSchema
|
|
546
572
|
]);
|
|
547
573
|
export {
|
|
548
574
|
AGENTS_META_IDENTITY_SOURCES,
|
|
@@ -560,6 +586,8 @@ export {
|
|
|
560
586
|
auditModeSchema,
|
|
561
587
|
baselineSyncedEventSchema,
|
|
562
588
|
candidateFileEntrySchema,
|
|
589
|
+
claudeHookPathMigratedEventSchema,
|
|
590
|
+
claudeSkillPathMigratedEventSchema,
|
|
563
591
|
clientPathsSchema,
|
|
564
592
|
createTranslator,
|
|
565
593
|
defaultMessages,
|
|
@@ -572,6 +600,7 @@ export {
|
|
|
572
600
|
editIntentCheckedEventSchema,
|
|
573
601
|
enMessages,
|
|
574
602
|
eventLedgerEventSchema,
|
|
603
|
+
eventLedgerTruncatedEventSchema,
|
|
575
604
|
fabricConfigSchema,
|
|
576
605
|
fabricEventSchema,
|
|
577
606
|
forensicAssertionCoverageSchema,
|
|
@@ -584,6 +613,9 @@ export {
|
|
|
584
613
|
forensicReportSchema,
|
|
585
614
|
forensicSamplingBudgetSchema,
|
|
586
615
|
forensicTopologySchema,
|
|
616
|
+
getRulesAnnotations,
|
|
617
|
+
getRulesInputSchema,
|
|
618
|
+
getRulesOutputSchema,
|
|
587
619
|
historyStateQuerySchema,
|
|
588
620
|
humanLedgerEntrySchema,
|
|
589
621
|
humanLockApproveRequestSchema,
|
|
@@ -601,21 +633,34 @@ export {
|
|
|
601
633
|
ledgerEntrySchema,
|
|
602
634
|
ledgerQuerySchema,
|
|
603
635
|
ledgerSourceSchema,
|
|
636
|
+
legacyClientPathPresentEventSchema,
|
|
604
637
|
lockApprovedEventSchema,
|
|
605
638
|
lockDriftEventSchema,
|
|
639
|
+
mcpConfigMigratedEventSchema,
|
|
606
640
|
mcpEventLedgerEventSchema,
|
|
641
|
+
mcpPayloadLimitsSchema,
|
|
642
|
+
metaReconciledEventSchema,
|
|
643
|
+
metaReconciledOnStartupEventSchema,
|
|
607
644
|
metaUpdatedEventSchema,
|
|
608
645
|
normalizeLocale,
|
|
646
|
+
planContextAnnotations,
|
|
647
|
+
planContextInputSchema,
|
|
648
|
+
planContextOutputSchema,
|
|
649
|
+
reapplyCompletedEventSchema,
|
|
609
650
|
ruleBaselineAcceptedEventSchema,
|
|
610
651
|
ruleContextPlannedEventSchema,
|
|
611
652
|
ruleDescriptionIndexItemSchema,
|
|
612
653
|
ruleDescriptionSchema,
|
|
613
654
|
ruleDriftDetectedEventSchema,
|
|
655
|
+
ruleSectionsAnnotations,
|
|
614
656
|
ruleSectionsFetchedEventSchema,
|
|
657
|
+
ruleSectionsInputSchema,
|
|
658
|
+
ruleSectionsOutputSchema,
|
|
615
659
|
ruleSelectionEventSchema,
|
|
616
660
|
ruleTestIndexSchema,
|
|
617
661
|
ruleTestLinkSchema,
|
|
618
662
|
ruleTestOrphanAnnotationSchema,
|
|
663
|
+
structuredWarningSchema,
|
|
619
664
|
withDerivedAgentsMetaNodeDefaults,
|
|
620
665
|
zhCNMessages
|
|
621
666
|
};
|