@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/{chunk-KNZIX6IL.js → chunk-5H2PVNB2.js} +93 -107
- package/dist/i18n/index.d.ts +1 -1
- package/dist/i18n/index.js +1 -1
- package/dist/index.d.ts +1339 -53
- package/dist/index.js +366 -187
- package/dist/types/index.d.ts +21 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6,23 +6,40 @@ import {
|
|
|
6
6
|
enMessages,
|
|
7
7
|
normalizeLocale,
|
|
8
8
|
zhCNMessages
|
|
9
|
-
} from "./chunk-
|
|
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/
|
|
129
|
+
// src/schemas/rule-test-index.ts
|
|
110
130
|
import { z as z2 } from "zod";
|
|
111
|
-
var
|
|
112
|
-
var
|
|
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
|
-
},
|
|
132
|
-
var ledgerQuerySchema =
|
|
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 =
|
|
137
|
-
ledger_id:
|
|
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:
|
|
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 =
|
|
150
|
-
file:
|
|
151
|
-
start_line:
|
|
152
|
-
end_line:
|
|
153
|
-
new_hash:
|
|
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 =
|
|
156
|
-
file:
|
|
205
|
+
var humanLockFileParamsSchema = z3.object({
|
|
206
|
+
file: z3.string().min(1)
|
|
157
207
|
});
|
|
158
|
-
var annotateIntentRequestSchema =
|
|
159
|
-
ledger_entry_id:
|
|
160
|
-
annotation:
|
|
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
|
|
214
|
+
import { z as z4 } from "zod";
|
|
165
215
|
var ledgerEntryBaseSchema = {
|
|
166
|
-
id:
|
|
167
|
-
ts:
|
|
168
|
-
intent:
|
|
169
|
-
affected_paths:
|
|
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 =
|
|
221
|
+
var aiLedgerEntrySchema = z4.object({
|
|
172
222
|
...ledgerEntryBaseSchema,
|
|
173
|
-
source:
|
|
174
|
-
commit_sha:
|
|
223
|
+
source: z4.literal("ai"),
|
|
224
|
+
commit_sha: z4.string().optional()
|
|
175
225
|
});
|
|
176
|
-
var humanLedgerEntrySchema =
|
|
226
|
+
var humanLedgerEntrySchema = z4.object({
|
|
177
227
|
...ledgerEntryBaseSchema,
|
|
178
|
-
source:
|
|
179
|
-
parent_sha:
|
|
180
|
-
parent_ledger_entry_id:
|
|
181
|
-
diff_stat:
|
|
182
|
-
annotation:
|
|
183
|
-
});
|
|
184
|
-
var ledgerEntryUnionSchema =
|
|
185
|
-
var ledgerEntrySchema =
|
|
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
|
|
197
|
-
var humanLockEntrySchema =
|
|
198
|
-
file:
|
|
199
|
-
start_line:
|
|
200
|
-
end_line:
|
|
201
|
-
hash:
|
|
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 =
|
|
204
|
-
locked:
|
|
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
|
|
209
|
-
var auditModeSchema =
|
|
210
|
-
var clientPathsSchema =
|
|
211
|
-
claudeCodeCLI:
|
|
212
|
-
claudeCodeDesktop:
|
|
213
|
-
cursor:
|
|
214
|
-
windsurf:
|
|
215
|
-
rooCode:
|
|
216
|
-
geminiCLI:
|
|
217
|
-
codexCLI:
|
|
218
|
-
});
|
|
219
|
-
var fabricConfigSchema =
|
|
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:
|
|
222
|
-
scanIgnores:
|
|
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
|
|
229
|
-
var forensicCodeSampleSchema =
|
|
230
|
-
path:
|
|
231
|
-
lines:
|
|
232
|
-
snippet:
|
|
233
|
-
pattern_hint:
|
|
234
|
-
});
|
|
235
|
-
var forensicEvidenceAnchorSchema =
|
|
236
|
-
file:
|
|
237
|
-
line:
|
|
238
|
-
snippet:
|
|
239
|
-
});
|
|
240
|
-
var forensicAssertionCoverageSchema =
|
|
241
|
-
ratio:
|
|
242
|
-
total:
|
|
243
|
-
matched:
|
|
244
|
-
co_occurring_patterns:
|
|
245
|
-
});
|
|
246
|
-
var forensicAssertionSchema =
|
|
247
|
-
type:
|
|
248
|
-
statement:
|
|
249
|
-
confidence:
|
|
250
|
-
evidence:
|
|
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:
|
|
253
|
-
alternatives:
|
|
254
|
-
});
|
|
255
|
-
var forensicTopologySchema =
|
|
256
|
-
total_files:
|
|
257
|
-
by_ext:
|
|
258
|
-
key_dirs:
|
|
259
|
-
max_depth:
|
|
260
|
-
});
|
|
261
|
-
var forensicEntryPointSchema =
|
|
262
|
-
path:
|
|
263
|
-
reason:
|
|
264
|
-
size_bytes:
|
|
265
|
-
});
|
|
266
|
-
var forensicFrameworkSchema =
|
|
267
|
-
kind:
|
|
268
|
-
version:
|
|
269
|
-
subkind:
|
|
270
|
-
evidence:
|
|
271
|
-
});
|
|
272
|
-
var forensicReadmeSchema =
|
|
273
|
-
quality:
|
|
274
|
-
line_count:
|
|
275
|
-
has_contributing:
|
|
276
|
-
});
|
|
277
|
-
var candidateFileEntrySchema =
|
|
278
|
-
path:
|
|
279
|
-
family:
|
|
280
|
-
rationale:
|
|
281
|
-
});
|
|
282
|
-
var forensicSamplingBudgetSchema =
|
|
283
|
-
max_files:
|
|
284
|
-
max_lines_per_file:
|
|
285
|
-
});
|
|
286
|
-
var forensicReportSchema =
|
|
287
|
-
version:
|
|
288
|
-
generated_at:
|
|
289
|
-
generated_by:
|
|
290
|
-
target:
|
|
291
|
-
project_name:
|
|
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:
|
|
295
|
-
code_samples:
|
|
296
|
-
assertions:
|
|
297
|
-
candidate_files:
|
|
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:
|
|
350
|
+
recommendations_for_skill: z7.array(z7.string()).optional()
|
|
301
351
|
});
|
|
302
352
|
|
|
303
353
|
// src/schemas/init-context.ts
|
|
304
|
-
import { z as
|
|
305
|
-
var initContextFrameworkSchema =
|
|
306
|
-
kind:
|
|
307
|
-
version:
|
|
308
|
-
subkind:
|
|
309
|
-
});
|
|
310
|
-
var initContextInvariantConfidenceSnapshotSchema =
|
|
311
|
-
confidence:
|
|
312
|
-
evidence_refs:
|
|
313
|
-
});
|
|
314
|
-
var initContextSourceEvidenceSchema =
|
|
315
|
-
file:
|
|
316
|
-
lines:
|
|
317
|
-
});
|
|
318
|
-
var initContextInvariantSchema =
|
|
319
|
-
type:
|
|
320
|
-
rule:
|
|
321
|
-
rationale:
|
|
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:
|
|
324
|
-
});
|
|
325
|
-
var initContextDomainGroupSchema =
|
|
326
|
-
name:
|
|
327
|
-
paths:
|
|
328
|
-
summary:
|
|
329
|
-
topology_type:
|
|
330
|
-
target_path:
|
|
331
|
-
});
|
|
332
|
-
var initContextInterviewTrailEntrySchema =
|
|
333
|
-
phase:
|
|
334
|
-
question:
|
|
335
|
-
answer:
|
|
336
|
-
presentation:
|
|
337
|
-
user_corrections:
|
|
338
|
-
});
|
|
339
|
-
var initContextSchema =
|
|
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:
|
|
342
|
-
invariants:
|
|
343
|
-
domain_groups:
|
|
344
|
-
interview_trail:
|
|
345
|
-
forensic_ref:
|
|
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
|
|
350
|
-
var metaUpdatedEventSchema =
|
|
351
|
-
type:
|
|
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 =
|
|
355
|
-
type:
|
|
356
|
-
payload:
|
|
357
|
-
locked:
|
|
358
|
-
drifted:
|
|
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 =
|
|
362
|
-
type:
|
|
363
|
-
payload:
|
|
364
|
-
locked:
|
|
365
|
-
approved:
|
|
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 =
|
|
369
|
-
type:
|
|
418
|
+
var ledgerAppendedEventSchema = z9.object({
|
|
419
|
+
type: z9.literal("ledger:appended"),
|
|
370
420
|
payload: ledgerEntrySchema
|
|
371
421
|
});
|
|
372
|
-
var driftDetectedEventSchema =
|
|
373
|
-
type:
|
|
422
|
+
var driftDetectedEventSchema = z9.object({
|
|
423
|
+
type: z9.literal("drift:detected"),
|
|
374
424
|
payload: forensicReportSchema
|
|
375
425
|
});
|
|
376
|
-
var fabricEventSchema =
|
|
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
|
};
|