@fenglimg/fabric-shared 2.0.0-rc.15 → 2.0.0-rc.22
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-BEABJYVL.js +39 -0
- package/dist/{chunk-BKTCBFXZ.js → chunk-VKCXD6CI.js} +178 -36
- package/dist/{chunk-NNDFOOBO.js → chunk-WK4WINAZ.js} +8 -1
- package/dist/i18n/index.js +1 -1
- package/dist/index.d.ts +434 -5
- package/dist/index.js +582 -339
- package/dist/node/atomic-write.d.ts +16 -0
- package/dist/node/atomic-write.js +19 -10
- package/dist/schemas/api-contracts.d.ts +6 -0
- package/dist/schemas/api-contracts.js +1 -1
- package/dist/templates/bootstrap-canonical.d.ts +56 -0
- package/dist/templates/bootstrap-canonical.js +18 -0
- package/dist/types/index.d.ts +0 -1
- package/package.json +7 -3
package/dist/index.js
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BOOTSTRAP_CANONICAL,
|
|
3
|
+
BOOTSTRAP_MARKER_BEGIN,
|
|
4
|
+
BOOTSTRAP_MARKER_END,
|
|
5
|
+
BOOTSTRAP_REGEX,
|
|
6
|
+
LEGACY_KB_MARKER_BEGIN,
|
|
7
|
+
LEGACY_KB_MARKER_END,
|
|
8
|
+
LEGACY_KB_REGEX
|
|
9
|
+
} from "./chunk-BEABJYVL.js";
|
|
1
10
|
import {
|
|
2
11
|
PROTECTED_TOKENS,
|
|
3
12
|
createTranslator,
|
|
@@ -6,7 +15,7 @@ import {
|
|
|
6
15
|
enMessages,
|
|
7
16
|
normalizeLocale,
|
|
8
17
|
zhCNMessages
|
|
9
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-VKCXD6CI.js";
|
|
10
19
|
import {
|
|
11
20
|
FabExtractKnowledgeInputSchema,
|
|
12
21
|
FabExtractKnowledgeInputShape,
|
|
@@ -45,7 +54,7 @@ import {
|
|
|
45
54
|
planContextInputSchema,
|
|
46
55
|
planContextOutputSchema,
|
|
47
56
|
structuredWarningSchema
|
|
48
|
-
} from "./chunk-
|
|
57
|
+
} from "./chunk-WK4WINAZ.js";
|
|
49
58
|
import "./chunk-LXNCAKJZ.js";
|
|
50
59
|
|
|
51
60
|
// src/schemas/agents-meta.ts
|
|
@@ -166,7 +175,7 @@ function defaultAgentsMetaCounters() {
|
|
|
166
175
|
}
|
|
167
176
|
function deriveAgentsMetaStableId(file) {
|
|
168
177
|
const normalized = normalizePath(file);
|
|
169
|
-
if (normalized === "AGENTS.md"
|
|
178
|
+
if (normalized === "AGENTS.md") {
|
|
170
179
|
return "bootstrap";
|
|
171
180
|
}
|
|
172
181
|
return getDepthSource(normalized).replace(/\.md$/u, "");
|
|
@@ -183,7 +192,7 @@ function deriveAgentsMetaIdentitySource(node) {
|
|
|
183
192
|
}
|
|
184
193
|
function deriveAgentsMetaLayer(file) {
|
|
185
194
|
const normalized = normalizePath(file);
|
|
186
|
-
if (normalized === "AGENTS.md"
|
|
195
|
+
if (normalized === "AGENTS.md") {
|
|
187
196
|
return "L0";
|
|
188
197
|
}
|
|
189
198
|
if (hasCrossCuttingSegment(normalized)) {
|
|
@@ -315,7 +324,13 @@ var fabricLanguageSchema = z5.enum([
|
|
|
315
324
|
var defaultLayerFilterSchema = z5.enum(["team", "personal", "both"]);
|
|
316
325
|
var fabricConfigSchema = z5.object({
|
|
317
326
|
clientPaths: clientPathsSchema.optional(),
|
|
318
|
-
|
|
327
|
+
// rc.17 (R-cut): the dev/test fixture-path config field was removed
|
|
328
|
+
// end-to-end. The `EXTERNAL_FIXTURE_PATH` env var is now the sole source
|
|
329
|
+
// consumed by `resolveDevMode()`. No z.preprocess alias — pre-rc.17
|
|
330
|
+
// fabric-config.json files carrying the field will be silently dropped by
|
|
331
|
+
// the lenient root parser (no .strict() at root). Pre-user clean-slate per
|
|
332
|
+
// memory/feedback_clean_slate.md; mirrors the rc.12 hard-rename precedent
|
|
333
|
+
// documented above.
|
|
319
334
|
scanIgnores: z5.array(z5.string()).optional(),
|
|
320
335
|
audit_mode: auditModeSchema.optional(),
|
|
321
336
|
mcpPayloadLimits: mcpPayloadLimitsSchema,
|
|
@@ -435,159 +450,310 @@ var fabricConfigSchema = z5.object({
|
|
|
435
450
|
// for explicit resolve-or-drop decision. Default 14; tighter than the
|
|
436
451
|
// 7d Signal-B trigger because review specifically targets the long
|
|
437
452
|
// tail. Large repos with slower cadence can raise to 30.
|
|
438
|
-
review_stale_pending_days: z5.number().int().positive().optional().default(14)
|
|
453
|
+
review_stale_pending_days: z5.number().int().positive().optional().default(14),
|
|
454
|
+
// v2.0.0-rc.22 Scope A T3: sliding-window retention (in days) for the
|
|
455
|
+
// event ledger rotation primitive (`rotateEventLedgerIfNeeded`). Lines
|
|
456
|
+
// whose `ts` is older than `now - fabric_event_retention_days * 86_400_000`
|
|
457
|
+
// are partitioned into `.fabric/events.archive/events-rotated-YYYY-MM-DD.jsonl`.
|
|
458
|
+
// Locked to 7/30/90 — three operator-friendly preset windows. Default 30
|
|
459
|
+
// is applied at the consumer site (rotateEventLedgerIfNeeded), so this
|
|
460
|
+
// field stays `.optional()` without a `.default()` to keep the schema
|
|
461
|
+
// surface honest: absence means "use the library default", not "schema
|
|
462
|
+
// default of 30 was injected." 7 = ~tight, 30 = balanced, 90 = forensic.
|
|
463
|
+
// Mirrors cite-policy precedent of locking enum-style numeric tunables
|
|
464
|
+
// to a small literal set (vs free `.positive()`) to prevent fat-finger
|
|
465
|
+
// misconfig.
|
|
466
|
+
fabric_event_retention_days: z5.union([z5.literal(7), z5.literal(30), z5.literal(90)]).optional()
|
|
439
467
|
});
|
|
440
468
|
|
|
441
|
-
// src/schemas/
|
|
469
|
+
// src/schemas/fabric-config-introspect.ts
|
|
442
470
|
import { z as z6 } from "zod";
|
|
443
|
-
var
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
471
|
+
var positiveIntSchema = z6.coerce.number().int().positive();
|
|
472
|
+
function makePositiveIntField(key, defaultValue) {
|
|
473
|
+
return {
|
|
474
|
+
key,
|
|
475
|
+
group: "B_hint_threshold",
|
|
476
|
+
widget: "text",
|
|
477
|
+
label_i18n_key: `cli.config.fields.${key}.label`,
|
|
478
|
+
description_i18n_key: `cli.config.fields.${key}.description`,
|
|
479
|
+
default: defaultValue,
|
|
480
|
+
validate(raw) {
|
|
481
|
+
const trimmed = raw.trim();
|
|
482
|
+
if (trimmed === "") {
|
|
483
|
+
return { ok: false, error: "Value is required (positive integer)." };
|
|
484
|
+
}
|
|
485
|
+
const parsed = positiveIntSchema.safeParse(trimmed);
|
|
486
|
+
if (!parsed.success) {
|
|
487
|
+
return {
|
|
488
|
+
ok: false,
|
|
489
|
+
error: "Must be a positive integer (e.g. 1, 12, 24)."
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
return { ok: true, value: parsed.data };
|
|
493
|
+
},
|
|
494
|
+
format_for_display(value) {
|
|
495
|
+
if (typeof value === "number") return String(value);
|
|
496
|
+
if (value === void 0 || value === null) return String(defaultValue);
|
|
497
|
+
return String(value);
|
|
498
|
+
}
|
|
499
|
+
};
|
|
500
|
+
}
|
|
501
|
+
function makeEnumField(key, group, enumValues, defaultValue) {
|
|
502
|
+
return {
|
|
503
|
+
key,
|
|
504
|
+
group,
|
|
505
|
+
widget: "select",
|
|
506
|
+
label_i18n_key: `cli.config.fields.${key}.label`,
|
|
507
|
+
description_i18n_key: `cli.config.fields.${key}.description`,
|
|
508
|
+
default: defaultValue,
|
|
509
|
+
enum_values: enumValues,
|
|
510
|
+
validate(raw) {
|
|
511
|
+
const trimmed = raw.trim();
|
|
512
|
+
if (!enumValues.includes(trimmed)) {
|
|
513
|
+
return {
|
|
514
|
+
ok: false,
|
|
515
|
+
error: `Must be one of: ${enumValues.join(", ")}.`
|
|
516
|
+
};
|
|
517
|
+
}
|
|
518
|
+
return { ok: true, value: trimmed };
|
|
519
|
+
},
|
|
520
|
+
format_for_display(value) {
|
|
521
|
+
if (typeof value === "string" && enumValues.includes(value)) return value;
|
|
522
|
+
if (value === void 0 || value === null) return defaultValue;
|
|
523
|
+
return String(value);
|
|
524
|
+
}
|
|
525
|
+
};
|
|
526
|
+
}
|
|
527
|
+
var SCHEMA_DEFAULTS = fabricConfigSchema.parse({});
|
|
528
|
+
function pickNumberDefault(key) {
|
|
529
|
+
const v = SCHEMA_DEFAULTS[key];
|
|
530
|
+
if (typeof v !== "number") {
|
|
531
|
+
throw new Error(
|
|
532
|
+
`fabric-config-introspect: expected numeric default for ${String(key)}, got ${typeof v}`
|
|
533
|
+
);
|
|
534
|
+
}
|
|
535
|
+
return v;
|
|
536
|
+
}
|
|
537
|
+
function pickStringDefault(key) {
|
|
538
|
+
const v = SCHEMA_DEFAULTS[key];
|
|
539
|
+
if (typeof v !== "string") {
|
|
540
|
+
throw new Error(
|
|
541
|
+
`fabric-config-introspect: expected string default for ${String(key)}, got ${typeof v}`
|
|
542
|
+
);
|
|
543
|
+
}
|
|
544
|
+
return v;
|
|
545
|
+
}
|
|
546
|
+
var AUDIT_MODE_PANEL_DEFAULT = "warn";
|
|
547
|
+
function getPanelFields() {
|
|
548
|
+
return PANEL_FIELDS;
|
|
549
|
+
}
|
|
550
|
+
function getPanelFieldByKey(key) {
|
|
551
|
+
return PANEL_FIELDS.find((f) => f.key === key);
|
|
552
|
+
}
|
|
553
|
+
var PANEL_FIELDS = [
|
|
554
|
+
// --- Group A: Locale (2) ---
|
|
555
|
+
makeEnumField(
|
|
556
|
+
"fabric_language",
|
|
557
|
+
"A_locale",
|
|
558
|
+
fabricLanguageSchema.options,
|
|
559
|
+
pickStringDefault("fabric_language")
|
|
560
|
+
),
|
|
561
|
+
makeEnumField(
|
|
562
|
+
"default_layer_filter",
|
|
563
|
+
"A_locale",
|
|
564
|
+
defaultLayerFilterSchema.options,
|
|
565
|
+
pickStringDefault("default_layer_filter")
|
|
566
|
+
),
|
|
567
|
+
// --- Group B: Hint thresholds (8 — see leading docstring for the
|
|
568
|
+
// 7-vs-8 reconciliation; archive_edit_threshold is the 8th key) ---
|
|
569
|
+
makePositiveIntField("archive_hint_hours", pickNumberDefault("archive_hint_hours")),
|
|
570
|
+
makePositiveIntField(
|
|
571
|
+
"archive_hint_cooldown_hours",
|
|
572
|
+
pickNumberDefault("archive_hint_cooldown_hours")
|
|
573
|
+
),
|
|
574
|
+
makePositiveIntField(
|
|
575
|
+
"archive_edit_threshold",
|
|
576
|
+
pickNumberDefault("archive_edit_threshold")
|
|
577
|
+
),
|
|
578
|
+
makePositiveIntField(
|
|
579
|
+
"underseed_node_threshold",
|
|
580
|
+
pickNumberDefault("underseed_node_threshold")
|
|
581
|
+
),
|
|
582
|
+
makePositiveIntField(
|
|
583
|
+
"review_hint_pending_count",
|
|
584
|
+
pickNumberDefault("review_hint_pending_count")
|
|
585
|
+
),
|
|
586
|
+
makePositiveIntField(
|
|
587
|
+
"review_hint_pending_age_days",
|
|
588
|
+
pickNumberDefault("review_hint_pending_age_days")
|
|
589
|
+
),
|
|
590
|
+
makePositiveIntField(
|
|
591
|
+
"maintenance_hint_days",
|
|
592
|
+
pickNumberDefault("maintenance_hint_days")
|
|
593
|
+
),
|
|
594
|
+
makePositiveIntField(
|
|
595
|
+
"maintenance_hint_cooldown_days",
|
|
596
|
+
pickNumberDefault("maintenance_hint_cooldown_days")
|
|
597
|
+
),
|
|
598
|
+
// --- Group C: Audit (1) ---
|
|
599
|
+
makeEnumField(
|
|
600
|
+
"audit_mode",
|
|
601
|
+
"C_audit",
|
|
602
|
+
auditModeSchema.options,
|
|
603
|
+
AUDIT_MODE_PANEL_DEFAULT
|
|
604
|
+
)
|
|
605
|
+
];
|
|
606
|
+
|
|
607
|
+
// src/schemas/forensic-report.ts
|
|
608
|
+
import { z as z7 } from "zod";
|
|
609
|
+
var forensicCodeSampleSchema = z7.object({
|
|
610
|
+
path: z7.string(),
|
|
611
|
+
lines: z7.string(),
|
|
612
|
+
snippet: z7.string(),
|
|
613
|
+
pattern_hint: z7.string()
|
|
614
|
+
});
|
|
615
|
+
var forensicEvidenceAnchorSchema = z7.object({
|
|
616
|
+
file: z7.string(),
|
|
617
|
+
line: z7.string(),
|
|
618
|
+
snippet: z7.string()
|
|
619
|
+
});
|
|
620
|
+
var forensicAssertionCoverageSchema = z7.object({
|
|
621
|
+
ratio: z7.number().min(0).max(1),
|
|
622
|
+
total: z7.number().int().nonnegative(),
|
|
623
|
+
matched: z7.number().int().nonnegative(),
|
|
624
|
+
co_occurring_patterns: z7.array(z7.string())
|
|
625
|
+
});
|
|
626
|
+
var forensicAssertionSchema = z7.object({
|
|
627
|
+
type: z7.enum(["framework", "pattern", "invariant", "domain"]),
|
|
628
|
+
statement: z7.string(),
|
|
629
|
+
confidence: z7.enum(["HIGH", "MEDIUM", "LOW"]),
|
|
630
|
+
evidence: z7.array(forensicEvidenceAnchorSchema),
|
|
465
631
|
coverage: forensicAssertionCoverageSchema,
|
|
466
|
-
proposed_rule:
|
|
467
|
-
alternatives:
|
|
468
|
-
});
|
|
469
|
-
var forensicTopologySchema =
|
|
470
|
-
total_files:
|
|
471
|
-
by_ext:
|
|
472
|
-
key_dirs:
|
|
473
|
-
max_depth:
|
|
474
|
-
});
|
|
475
|
-
var forensicEntryPointSchema =
|
|
476
|
-
path:
|
|
477
|
-
reason:
|
|
478
|
-
size_bytes:
|
|
479
|
-
});
|
|
480
|
-
var forensicFrameworkSchema =
|
|
481
|
-
kind:
|
|
482
|
-
version:
|
|
483
|
-
subkind:
|
|
484
|
-
evidence:
|
|
485
|
-
});
|
|
486
|
-
var forensicReadmeSchema =
|
|
487
|
-
quality:
|
|
488
|
-
line_count:
|
|
489
|
-
has_contributing:
|
|
490
|
-
});
|
|
491
|
-
var candidateFileEntrySchema =
|
|
492
|
-
path:
|
|
493
|
-
family:
|
|
494
|
-
rationale:
|
|
495
|
-
});
|
|
496
|
-
var forensicSamplingBudgetSchema =
|
|
497
|
-
max_files:
|
|
498
|
-
max_lines_per_file:
|
|
499
|
-
});
|
|
500
|
-
var forensicReportSchema =
|
|
501
|
-
version:
|
|
502
|
-
generated_at:
|
|
503
|
-
generated_by:
|
|
504
|
-
target:
|
|
505
|
-
project_name:
|
|
632
|
+
proposed_rule: z7.string().optional(),
|
|
633
|
+
alternatives: z7.array(z7.string()).optional()
|
|
634
|
+
});
|
|
635
|
+
var forensicTopologySchema = z7.object({
|
|
636
|
+
total_files: z7.number().int().nonnegative(),
|
|
637
|
+
by_ext: z7.record(z7.number().int().nonnegative()),
|
|
638
|
+
key_dirs: z7.array(z7.string()),
|
|
639
|
+
max_depth: z7.number().int().nonnegative()
|
|
640
|
+
});
|
|
641
|
+
var forensicEntryPointSchema = z7.object({
|
|
642
|
+
path: z7.string(),
|
|
643
|
+
reason: z7.string(),
|
|
644
|
+
size_bytes: z7.number().int().nonnegative().optional()
|
|
645
|
+
});
|
|
646
|
+
var forensicFrameworkSchema = z7.object({
|
|
647
|
+
kind: z7.string(),
|
|
648
|
+
version: z7.string(),
|
|
649
|
+
subkind: z7.string(),
|
|
650
|
+
evidence: z7.array(z7.string())
|
|
651
|
+
});
|
|
652
|
+
var forensicReadmeSchema = z7.object({
|
|
653
|
+
quality: z7.enum(["missing", "stub", "ok"]),
|
|
654
|
+
line_count: z7.number().int().nonnegative(),
|
|
655
|
+
has_contributing: z7.boolean()
|
|
656
|
+
});
|
|
657
|
+
var candidateFileEntrySchema = z7.object({
|
|
658
|
+
path: z7.string(),
|
|
659
|
+
family: z7.enum(["entry", "component", "config", "test", "domain"]),
|
|
660
|
+
rationale: z7.string()
|
|
661
|
+
});
|
|
662
|
+
var forensicSamplingBudgetSchema = z7.object({
|
|
663
|
+
max_files: z7.literal(15),
|
|
664
|
+
max_lines_per_file: z7.literal(100)
|
|
665
|
+
});
|
|
666
|
+
var forensicReportSchema = z7.object({
|
|
667
|
+
version: z7.string(),
|
|
668
|
+
generated_at: z7.string(),
|
|
669
|
+
generated_by: z7.string(),
|
|
670
|
+
target: z7.string(),
|
|
671
|
+
project_name: z7.string(),
|
|
506
672
|
framework: forensicFrameworkSchema,
|
|
507
673
|
topology: forensicTopologySchema,
|
|
508
|
-
entry_points:
|
|
509
|
-
code_samples:
|
|
510
|
-
assertions:
|
|
511
|
-
candidate_files:
|
|
674
|
+
entry_points: z7.array(forensicEntryPointSchema),
|
|
675
|
+
code_samples: z7.array(forensicCodeSampleSchema),
|
|
676
|
+
assertions: z7.array(forensicAssertionSchema),
|
|
677
|
+
candidate_files: z7.array(candidateFileEntrySchema),
|
|
512
678
|
sampling_budget: forensicSamplingBudgetSchema,
|
|
513
679
|
readme: forensicReadmeSchema,
|
|
514
|
-
recommendations_for_skill:
|
|
680
|
+
recommendations_for_skill: z7.array(z7.string()).optional()
|
|
515
681
|
});
|
|
516
682
|
|
|
517
683
|
// src/schemas/init-context.ts
|
|
518
|
-
import { z as
|
|
519
|
-
var initContextFrameworkSchema =
|
|
520
|
-
kind:
|
|
521
|
-
version:
|
|
522
|
-
subkind:
|
|
684
|
+
import { z as z8 } from "zod";
|
|
685
|
+
var initContextFrameworkSchema = z8.object({
|
|
686
|
+
kind: z8.string(),
|
|
687
|
+
version: z8.string(),
|
|
688
|
+
subkind: z8.string()
|
|
523
689
|
});
|
|
524
|
-
var initContextInvariantConfidenceSnapshotSchema =
|
|
525
|
-
confidence:
|
|
526
|
-
evidence_refs:
|
|
690
|
+
var initContextInvariantConfidenceSnapshotSchema = z8.object({
|
|
691
|
+
confidence: z8.enum(["HIGH", "MEDIUM", "LOW"]),
|
|
692
|
+
evidence_refs: z8.array(z8.string())
|
|
527
693
|
});
|
|
528
|
-
var initContextSourceEvidenceSchema =
|
|
529
|
-
file:
|
|
530
|
-
lines:
|
|
694
|
+
var initContextSourceEvidenceSchema = z8.object({
|
|
695
|
+
file: z8.string(),
|
|
696
|
+
lines: z8.string()
|
|
531
697
|
});
|
|
532
|
-
var initContextInvariantSchema =
|
|
533
|
-
type:
|
|
534
|
-
rule:
|
|
535
|
-
rationale:
|
|
698
|
+
var initContextInvariantSchema = z8.object({
|
|
699
|
+
type: z8.enum(["ban", "require", "protect"]),
|
|
700
|
+
rule: z8.string(),
|
|
701
|
+
rationale: z8.string().optional(),
|
|
536
702
|
confidence_snapshot: initContextInvariantConfidenceSnapshotSchema.optional(),
|
|
537
|
-
source_evidence:
|
|
538
|
-
});
|
|
539
|
-
var initContextDomainGroupSchema =
|
|
540
|
-
name:
|
|
541
|
-
paths:
|
|
542
|
-
summary:
|
|
543
|
-
topology_type:
|
|
544
|
-
target_path:
|
|
545
|
-
});
|
|
546
|
-
var initContextInterviewTrailEntrySchema =
|
|
547
|
-
phase:
|
|
548
|
-
question:
|
|
549
|
-
answer:
|
|
550
|
-
presentation:
|
|
551
|
-
user_corrections:
|
|
552
|
-
});
|
|
553
|
-
var initContextSchema =
|
|
703
|
+
source_evidence: z8.array(initContextSourceEvidenceSchema).optional()
|
|
704
|
+
});
|
|
705
|
+
var initContextDomainGroupSchema = z8.object({
|
|
706
|
+
name: z8.string(),
|
|
707
|
+
paths: z8.array(z8.string()),
|
|
708
|
+
summary: z8.string().optional(),
|
|
709
|
+
topology_type: z8.enum(["mirror", "cross-cutting"]).optional(),
|
|
710
|
+
target_path: z8.string().optional()
|
|
711
|
+
});
|
|
712
|
+
var initContextInterviewTrailEntrySchema = z8.object({
|
|
713
|
+
phase: z8.string(),
|
|
714
|
+
question: z8.string(),
|
|
715
|
+
answer: z8.string(),
|
|
716
|
+
presentation: z8.string().optional(),
|
|
717
|
+
user_corrections: z8.array(z8.string()).optional()
|
|
718
|
+
});
|
|
719
|
+
var initContextSchema = z8.object({
|
|
554
720
|
framework: initContextFrameworkSchema,
|
|
555
|
-
architecture_patterns:
|
|
556
|
-
invariants:
|
|
557
|
-
domain_groups:
|
|
558
|
-
interview_trail:
|
|
559
|
-
forensic_ref:
|
|
721
|
+
architecture_patterns: z8.array(z8.string()),
|
|
722
|
+
invariants: z8.array(initContextInvariantSchema),
|
|
723
|
+
domain_groups: z8.array(initContextDomainGroupSchema),
|
|
724
|
+
interview_trail: z8.array(initContextInterviewTrailEntrySchema),
|
|
725
|
+
forensic_ref: z8.string()
|
|
560
726
|
});
|
|
561
727
|
|
|
562
728
|
// src/schemas/events.ts
|
|
563
|
-
import { z as
|
|
564
|
-
var metaUpdatedEventSchema =
|
|
565
|
-
type:
|
|
729
|
+
import { z as z9 } from "zod";
|
|
730
|
+
var metaUpdatedEventSchema = z9.object({
|
|
731
|
+
type: z9.literal("meta:updated"),
|
|
566
732
|
payload: agentsMetaSchema
|
|
567
733
|
});
|
|
568
|
-
var lockDriftEventSchema =
|
|
569
|
-
type:
|
|
570
|
-
payload:
|
|
571
|
-
locked:
|
|
572
|
-
drifted:
|
|
734
|
+
var lockDriftEventSchema = z9.object({
|
|
735
|
+
type: z9.literal("lock:drift"),
|
|
736
|
+
payload: z9.object({
|
|
737
|
+
locked: z9.array(humanLockEntrySchema),
|
|
738
|
+
drifted: z9.array(humanLockEntrySchema)
|
|
573
739
|
})
|
|
574
740
|
});
|
|
575
|
-
var lockApprovedEventSchema =
|
|
576
|
-
type:
|
|
577
|
-
payload:
|
|
578
|
-
locked:
|
|
579
|
-
approved:
|
|
741
|
+
var lockApprovedEventSchema = z9.object({
|
|
742
|
+
type: z9.literal("lock:approved"),
|
|
743
|
+
payload: z9.object({
|
|
744
|
+
locked: z9.array(humanLockEntrySchema),
|
|
745
|
+
approved: z9.array(humanLockEntrySchema)
|
|
580
746
|
})
|
|
581
747
|
});
|
|
582
|
-
var ledgerAppendedEventSchema =
|
|
583
|
-
type:
|
|
748
|
+
var ledgerAppendedEventSchema = z9.object({
|
|
749
|
+
type: z9.literal("ledger:appended"),
|
|
584
750
|
payload: ledgerEntrySchema
|
|
585
751
|
});
|
|
586
|
-
var driftDetectedEventSchema =
|
|
587
|
-
type:
|
|
752
|
+
var driftDetectedEventSchema = z9.object({
|
|
753
|
+
type: z9.literal("drift:detected"),
|
|
588
754
|
payload: forensicReportSchema
|
|
589
755
|
});
|
|
590
|
-
var fabricEventSchema =
|
|
756
|
+
var fabricEventSchema = z9.discriminatedUnion("type", [
|
|
591
757
|
metaUpdatedEventSchema,
|
|
592
758
|
lockDriftEventSchema,
|
|
593
759
|
lockApprovedEventSchema,
|
|
@@ -596,278 +762,325 @@ var fabricEventSchema = z8.discriminatedUnion("type", [
|
|
|
596
762
|
]);
|
|
597
763
|
|
|
598
764
|
// src/schemas/event-ledger.ts
|
|
599
|
-
import { z as
|
|
765
|
+
import { z as z10 } from "zod";
|
|
600
766
|
var eventLedgerEnvelopeSchema = {
|
|
601
|
-
kind:
|
|
602
|
-
id:
|
|
603
|
-
ts:
|
|
604
|
-
schema_version:
|
|
605
|
-
correlation_id:
|
|
606
|
-
session_id:
|
|
767
|
+
kind: z10.literal("fabric-event"),
|
|
768
|
+
id: z10.string(),
|
|
769
|
+
ts: z10.number().int().nonnegative(),
|
|
770
|
+
schema_version: z10.literal(1),
|
|
771
|
+
correlation_id: z10.string().optional(),
|
|
772
|
+
session_id: z10.string().optional()
|
|
607
773
|
};
|
|
608
|
-
var stringRecordSchema =
|
|
609
|
-
var knowledgeContextPlannedEventSchema =
|
|
774
|
+
var stringRecordSchema = z10.record(z10.string());
|
|
775
|
+
var knowledgeContextPlannedEventSchema = z10.object({
|
|
610
776
|
...eventLedgerEnvelopeSchema,
|
|
611
|
-
event_type:
|
|
612
|
-
target_paths:
|
|
613
|
-
required_stable_ids:
|
|
614
|
-
ai_selectable_stable_ids:
|
|
615
|
-
final_stable_ids:
|
|
616
|
-
selection_token:
|
|
617
|
-
client_hash:
|
|
618
|
-
intent:
|
|
619
|
-
known_tech:
|
|
620
|
-
diagnostics:
|
|
621
|
-
});
|
|
622
|
-
var knowledgeSelectionEventSchema =
|
|
777
|
+
event_type: z10.literal("knowledge_context_planned"),
|
|
778
|
+
target_paths: z10.array(z10.string()),
|
|
779
|
+
required_stable_ids: z10.array(z10.string()),
|
|
780
|
+
ai_selectable_stable_ids: z10.array(z10.string()),
|
|
781
|
+
final_stable_ids: z10.array(z10.string()),
|
|
782
|
+
selection_token: z10.string().optional(),
|
|
783
|
+
client_hash: z10.string().optional(),
|
|
784
|
+
intent: z10.string().optional(),
|
|
785
|
+
known_tech: z10.array(z10.string()).optional(),
|
|
786
|
+
diagnostics: z10.array(z10.unknown()).optional()
|
|
787
|
+
});
|
|
788
|
+
var knowledgeSelectionEventSchema = z10.object({
|
|
623
789
|
...eventLedgerEnvelopeSchema,
|
|
624
|
-
event_type:
|
|
625
|
-
selection_token:
|
|
626
|
-
target_paths:
|
|
627
|
-
required_stable_ids:
|
|
628
|
-
ai_selectable_stable_ids:
|
|
629
|
-
ai_selected_stable_ids:
|
|
630
|
-
final_stable_ids:
|
|
790
|
+
event_type: z10.literal("knowledge_selection"),
|
|
791
|
+
selection_token: z10.string(),
|
|
792
|
+
target_paths: z10.array(z10.string()),
|
|
793
|
+
required_stable_ids: z10.array(z10.string()),
|
|
794
|
+
ai_selectable_stable_ids: z10.array(z10.string()),
|
|
795
|
+
ai_selected_stable_ids: z10.array(z10.string()),
|
|
796
|
+
final_stable_ids: z10.array(z10.string()),
|
|
631
797
|
ai_selection_reasons: stringRecordSchema,
|
|
632
|
-
rejected_stable_ids:
|
|
633
|
-
ignored_stable_ids:
|
|
798
|
+
rejected_stable_ids: z10.array(z10.string()),
|
|
799
|
+
ignored_stable_ids: z10.array(z10.string())
|
|
634
800
|
});
|
|
635
|
-
var knowledgeSectionsFetchedEventSchema =
|
|
801
|
+
var knowledgeSectionsFetchedEventSchema = z10.object({
|
|
636
802
|
...eventLedgerEnvelopeSchema,
|
|
637
|
-
event_type:
|
|
638
|
-
selection_token:
|
|
639
|
-
target_paths:
|
|
640
|
-
requested_sections:
|
|
641
|
-
final_stable_ids:
|
|
642
|
-
ai_selected_stable_ids:
|
|
643
|
-
diagnostics:
|
|
644
|
-
});
|
|
645
|
-
var editIntentCheckedEventSchema =
|
|
803
|
+
event_type: z10.literal("knowledge_sections_fetched"),
|
|
804
|
+
selection_token: z10.string(),
|
|
805
|
+
target_paths: z10.array(z10.string()).optional(),
|
|
806
|
+
requested_sections: z10.array(z10.string()),
|
|
807
|
+
final_stable_ids: z10.array(z10.string()),
|
|
808
|
+
ai_selected_stable_ids: z10.array(z10.string()),
|
|
809
|
+
diagnostics: z10.array(z10.unknown()).optional()
|
|
810
|
+
});
|
|
811
|
+
var editIntentCheckedEventSchema = z10.object({
|
|
646
812
|
...eventLedgerEnvelopeSchema,
|
|
647
|
-
event_type:
|
|
648
|
-
path:
|
|
649
|
-
compliant:
|
|
650
|
-
intent:
|
|
651
|
-
ledger_entry_id:
|
|
652
|
-
ledger_source:
|
|
653
|
-
commit_sha:
|
|
654
|
-
parent_sha:
|
|
655
|
-
parent_ledger_entry_id:
|
|
656
|
-
diff_stat:
|
|
657
|
-
annotation:
|
|
658
|
-
matched_rule_context_ts:
|
|
659
|
-
window_ms:
|
|
660
|
-
});
|
|
661
|
-
var knowledgeDriftDetectedEventSchema =
|
|
813
|
+
event_type: z10.literal("edit_intent_checked"),
|
|
814
|
+
path: z10.string(),
|
|
815
|
+
compliant: z10.boolean(),
|
|
816
|
+
intent: z10.string(),
|
|
817
|
+
ledger_entry_id: z10.string(),
|
|
818
|
+
ledger_source: z10.enum(["ai", "human"]).optional(),
|
|
819
|
+
commit_sha: z10.string().optional(),
|
|
820
|
+
parent_sha: z10.string().optional(),
|
|
821
|
+
parent_ledger_entry_id: z10.string().optional(),
|
|
822
|
+
diff_stat: z10.string().optional(),
|
|
823
|
+
annotation: z10.string().optional(),
|
|
824
|
+
matched_rule_context_ts: z10.number().int().nonnegative().nullable(),
|
|
825
|
+
window_ms: z10.number().int().nonnegative()
|
|
826
|
+
});
|
|
827
|
+
var knowledgeDriftDetectedEventSchema = z10.object({
|
|
662
828
|
...eventLedgerEnvelopeSchema,
|
|
663
|
-
event_type:
|
|
664
|
-
revision:
|
|
665
|
-
drifted_stable_ids:
|
|
666
|
-
missing_files:
|
|
667
|
-
stale_files:
|
|
668
|
-
details:
|
|
669
|
-
|
|
670
|
-
file:
|
|
671
|
-
stable_id:
|
|
672
|
-
expected_hash:
|
|
673
|
-
actual_hash:
|
|
829
|
+
event_type: z10.literal("knowledge_drift_detected"),
|
|
830
|
+
revision: z10.string().optional(),
|
|
831
|
+
drifted_stable_ids: z10.array(z10.string()),
|
|
832
|
+
missing_files: z10.array(z10.string()),
|
|
833
|
+
stale_files: z10.array(z10.string()),
|
|
834
|
+
details: z10.array(
|
|
835
|
+
z10.object({
|
|
836
|
+
file: z10.string(),
|
|
837
|
+
stable_id: z10.string(),
|
|
838
|
+
expected_hash: z10.string(),
|
|
839
|
+
actual_hash: z10.string().nullable()
|
|
674
840
|
})
|
|
675
841
|
).optional()
|
|
676
842
|
});
|
|
677
|
-
var mcpEventLedgerEventSchema =
|
|
843
|
+
var mcpEventLedgerEventSchema = z10.object({
|
|
844
|
+
...eventLedgerEnvelopeSchema,
|
|
845
|
+
event_type: z10.literal("mcp_event"),
|
|
846
|
+
mcp_event_id: z10.string(),
|
|
847
|
+
stream_id: z10.string(),
|
|
848
|
+
message: z10.unknown()
|
|
849
|
+
});
|
|
850
|
+
var reapplyCompletedEventSchema = z10.object({
|
|
851
|
+
...eventLedgerEnvelopeSchema,
|
|
852
|
+
event_type: z10.literal("reapply_completed"),
|
|
853
|
+
preserved_ledger: z10.boolean(),
|
|
854
|
+
preserved_meta: z10.boolean(),
|
|
855
|
+
rules_count: z10.number().int().nonnegative()
|
|
856
|
+
});
|
|
857
|
+
var eventLedgerTruncatedEventSchema = z10.object({
|
|
678
858
|
...eventLedgerEnvelopeSchema,
|
|
679
|
-
event_type:
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
859
|
+
event_type: z10.literal("event_ledger_truncated"),
|
|
860
|
+
byte_offset: z10.number().int().nonnegative(),
|
|
861
|
+
byte_length: z10.number().int().nonnegative(),
|
|
862
|
+
corrupted_path: z10.string()
|
|
683
863
|
});
|
|
684
|
-
var
|
|
864
|
+
var mcpConfigMigratedEventSchema = z10.object({
|
|
685
865
|
...eventLedgerEnvelopeSchema,
|
|
686
|
-
event_type:
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
rules_count: z9.number().int().nonnegative()
|
|
866
|
+
event_type: z10.literal("mcp_config_migrated"),
|
|
867
|
+
source: z10.literal("doctor_fix"),
|
|
868
|
+
removed_from: z10.string()
|
|
690
869
|
});
|
|
691
|
-
var
|
|
870
|
+
var bootstrapMarkerMigratedEventSchema = z10.object({
|
|
692
871
|
...eventLedgerEnvelopeSchema,
|
|
693
|
-
event_type:
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
872
|
+
event_type: z10.literal("bootstrap_marker_migrated"),
|
|
873
|
+
path: z10.string(),
|
|
874
|
+
migrated_count: z10.number().int().nonnegative(),
|
|
875
|
+
legacy_marker: z10.literal("fabric:knowledge-base"),
|
|
876
|
+
new_marker: z10.literal("fabric:bootstrap"),
|
|
877
|
+
timestamp: z10.string()
|
|
697
878
|
});
|
|
698
|
-
var
|
|
879
|
+
var metaReconciledOnStartupEventSchema = z10.object({
|
|
699
880
|
...eventLedgerEnvelopeSchema,
|
|
700
|
-
event_type:
|
|
701
|
-
|
|
702
|
-
|
|
881
|
+
event_type: z10.literal("meta_reconciled_on_startup"),
|
|
882
|
+
reconciled_files: z10.array(z10.string()),
|
|
883
|
+
duration_ms: z10.number().int().nonnegative(),
|
|
884
|
+
source: z10.literal("reconcileKnowledge")
|
|
703
885
|
});
|
|
704
|
-
var
|
|
886
|
+
var metaReconciledEventSchema = z10.object({
|
|
705
887
|
...eventLedgerEnvelopeSchema,
|
|
706
|
-
event_type:
|
|
707
|
-
reconciled_files:
|
|
708
|
-
duration_ms:
|
|
709
|
-
|
|
888
|
+
event_type: z10.literal("meta_reconciled"),
|
|
889
|
+
reconciled_files: z10.array(z10.string()),
|
|
890
|
+
duration_ms: z10.number().int().nonnegative(),
|
|
891
|
+
trigger: z10.enum(["doctor", "manual"]),
|
|
892
|
+
source: z10.literal("reconcileKnowledge"),
|
|
893
|
+
// v2.0.0-rc.22 TASK-014 (Scope E): set when reconcileKnowledge forced a
|
|
894
|
+
// writeKnowledgeMeta on revision drift alone (no per-file content drift).
|
|
895
|
+
// Distinguishes top-level schema/revision repair from the standard per-file
|
|
896
|
+
// drift path. Optional so existing emitters stay unchanged.
|
|
897
|
+
force_write_reason: z10.enum(["revision_drift"]).optional()
|
|
710
898
|
});
|
|
711
|
-
var
|
|
899
|
+
var claudeSkillPathMigratedEventSchema = z10.object({
|
|
712
900
|
...eventLedgerEnvelopeSchema,
|
|
713
|
-
event_type:
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
trigger: z9.enum(["doctor", "manual"]),
|
|
717
|
-
source: z9.literal("reconcileKnowledge")
|
|
901
|
+
event_type: z10.literal("claude_skill_path_migrated"),
|
|
902
|
+
from: z10.string(),
|
|
903
|
+
to: z10.string()
|
|
718
904
|
});
|
|
719
|
-
var
|
|
905
|
+
var claudeHookPathMigratedEventSchema = z10.object({
|
|
720
906
|
...eventLedgerEnvelopeSchema,
|
|
721
|
-
event_type:
|
|
722
|
-
from:
|
|
723
|
-
to:
|
|
907
|
+
event_type: z10.literal("claude_hook_path_migrated"),
|
|
908
|
+
from: z10.string(),
|
|
909
|
+
to: z10.string()
|
|
724
910
|
});
|
|
725
|
-
var
|
|
911
|
+
var codexSkillPathMigratedEventSchema = z10.object({
|
|
726
912
|
...eventLedgerEnvelopeSchema,
|
|
727
|
-
event_type:
|
|
728
|
-
from:
|
|
729
|
-
to:
|
|
913
|
+
event_type: z10.literal("codex_skill_path_migrated"),
|
|
914
|
+
from: z10.string(),
|
|
915
|
+
to: z10.string()
|
|
730
916
|
});
|
|
731
|
-
var
|
|
917
|
+
var initScanCompletedEventSchema = z10.object({
|
|
732
918
|
...eventLedgerEnvelopeSchema,
|
|
733
|
-
event_type:
|
|
734
|
-
|
|
735
|
-
|
|
919
|
+
event_type: z10.literal("init_scan_completed"),
|
|
920
|
+
written_stable_ids: z10.array(z10.string()),
|
|
921
|
+
duration_ms: z10.number().int().nonnegative(),
|
|
922
|
+
source: z10.enum(["init", "scan", "doctor_fix", "doctor-rescan"]).optional()
|
|
736
923
|
});
|
|
737
|
-
var
|
|
924
|
+
var knowledgeProposedEventSchema = z10.object({
|
|
738
925
|
...eventLedgerEnvelopeSchema,
|
|
739
|
-
event_type:
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
926
|
+
event_type: z10.literal("knowledge_proposed"),
|
|
927
|
+
stable_id: z10.string().optional(),
|
|
928
|
+
timestamp: z10.string().datetime(),
|
|
929
|
+
reason: z10.string().optional()
|
|
743
930
|
});
|
|
744
|
-
var
|
|
931
|
+
var knowledgePromoteStartedEventSchema = z10.object({
|
|
745
932
|
...eventLedgerEnvelopeSchema,
|
|
746
|
-
event_type:
|
|
747
|
-
stable_id:
|
|
748
|
-
timestamp:
|
|
749
|
-
reason:
|
|
933
|
+
event_type: z10.literal("knowledge_promote_started"),
|
|
934
|
+
stable_id: z10.string().optional(),
|
|
935
|
+
timestamp: z10.string().datetime(),
|
|
936
|
+
reason: z10.string().optional()
|
|
750
937
|
});
|
|
751
|
-
var
|
|
938
|
+
var knowledgePromotedEventSchema = z10.object({
|
|
752
939
|
...eventLedgerEnvelopeSchema,
|
|
753
|
-
event_type:
|
|
754
|
-
stable_id:
|
|
755
|
-
timestamp:
|
|
756
|
-
reason:
|
|
940
|
+
event_type: z10.literal("knowledge_promoted"),
|
|
941
|
+
stable_id: z10.string().optional(),
|
|
942
|
+
timestamp: z10.string().datetime(),
|
|
943
|
+
reason: z10.string().optional()
|
|
757
944
|
});
|
|
758
|
-
var
|
|
945
|
+
var knowledgePromoteFailedEventSchema = z10.object({
|
|
759
946
|
...eventLedgerEnvelopeSchema,
|
|
760
|
-
event_type:
|
|
761
|
-
stable_id:
|
|
762
|
-
timestamp:
|
|
763
|
-
reason:
|
|
947
|
+
event_type: z10.literal("knowledge_promote_failed"),
|
|
948
|
+
stable_id: z10.string().optional(),
|
|
949
|
+
timestamp: z10.string().datetime(),
|
|
950
|
+
reason: z10.string()
|
|
764
951
|
});
|
|
765
|
-
var
|
|
952
|
+
var knowledgeLayerChangedEventSchema = z10.object({
|
|
766
953
|
...eventLedgerEnvelopeSchema,
|
|
767
|
-
event_type:
|
|
768
|
-
stable_id:
|
|
769
|
-
timestamp:
|
|
770
|
-
reason:
|
|
954
|
+
event_type: z10.literal("knowledge_layer_changed"),
|
|
955
|
+
stable_id: z10.string().optional(),
|
|
956
|
+
timestamp: z10.string().datetime(),
|
|
957
|
+
reason: z10.string().optional(),
|
|
958
|
+
from_layer: z10.enum(["team", "personal"]),
|
|
959
|
+
to_layer: z10.enum(["team", "personal"])
|
|
771
960
|
});
|
|
772
|
-
var
|
|
961
|
+
var knowledgeSlugRenamedEventSchema = z10.object({
|
|
773
962
|
...eventLedgerEnvelopeSchema,
|
|
774
|
-
event_type:
|
|
775
|
-
stable_id:
|
|
776
|
-
timestamp:
|
|
777
|
-
reason:
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
});
|
|
781
|
-
var
|
|
963
|
+
event_type: z10.literal("knowledge_slug_renamed"),
|
|
964
|
+
stable_id: z10.string().optional(),
|
|
965
|
+
timestamp: z10.string().datetime(),
|
|
966
|
+
reason: z10.string().optional(),
|
|
967
|
+
from_slug: z10.string(),
|
|
968
|
+
to_slug: z10.string()
|
|
969
|
+
});
|
|
970
|
+
var knowledgeDemotedEventSchema = z10.object({
|
|
782
971
|
...eventLedgerEnvelopeSchema,
|
|
783
|
-
event_type:
|
|
784
|
-
stable_id:
|
|
785
|
-
timestamp:
|
|
786
|
-
reason:
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
});
|
|
790
|
-
var knowledgeDemotedEventSchema = z9.object({
|
|
972
|
+
event_type: z10.literal("knowledge_demoted"),
|
|
973
|
+
stable_id: z10.string().optional(),
|
|
974
|
+
timestamp: z10.string().datetime(),
|
|
975
|
+
reason: z10.string().optional()
|
|
976
|
+
});
|
|
977
|
+
var knowledgeArchivedEventSchema = z10.object({
|
|
791
978
|
...eventLedgerEnvelopeSchema,
|
|
792
|
-
event_type:
|
|
793
|
-
stable_id:
|
|
794
|
-
timestamp:
|
|
795
|
-
reason:
|
|
979
|
+
event_type: z10.literal("knowledge_archived"),
|
|
980
|
+
stable_id: z10.string().optional(),
|
|
981
|
+
timestamp: z10.string().datetime(),
|
|
982
|
+
reason: z10.string().optional()
|
|
796
983
|
});
|
|
797
|
-
var
|
|
984
|
+
var knowledgeArchiveAttemptedEventSchema = z10.object({
|
|
798
985
|
...eventLedgerEnvelopeSchema,
|
|
799
|
-
event_type:
|
|
800
|
-
stable_id:
|
|
801
|
-
timestamp:
|
|
802
|
-
reason:
|
|
986
|
+
event_type: z10.literal("knowledge_archive_attempted"),
|
|
987
|
+
stable_id: z10.string().optional(),
|
|
988
|
+
timestamp: z10.string().datetime(),
|
|
989
|
+
reason: z10.string().optional()
|
|
803
990
|
});
|
|
804
|
-
var
|
|
991
|
+
var knowledgeDeferredEventSchema = z10.object({
|
|
805
992
|
...eventLedgerEnvelopeSchema,
|
|
806
|
-
event_type:
|
|
807
|
-
stable_id:
|
|
808
|
-
timestamp:
|
|
809
|
-
reason:
|
|
993
|
+
event_type: z10.literal("knowledge_deferred"),
|
|
994
|
+
stable_id: z10.string().optional(),
|
|
995
|
+
timestamp: z10.string().datetime(),
|
|
996
|
+
reason: z10.string().optional(),
|
|
997
|
+
until: z10.string().datetime().optional()
|
|
810
998
|
});
|
|
811
|
-
var
|
|
999
|
+
var knowledgeRejectedEventSchema = z10.object({
|
|
812
1000
|
...eventLedgerEnvelopeSchema,
|
|
813
|
-
event_type:
|
|
814
|
-
stable_id:
|
|
815
|
-
timestamp:
|
|
816
|
-
reason:
|
|
817
|
-
until: z9.string().datetime().optional()
|
|
1001
|
+
event_type: z10.literal("knowledge_rejected"),
|
|
1002
|
+
stable_id: z10.string().optional(),
|
|
1003
|
+
timestamp: z10.string().datetime(),
|
|
1004
|
+
reason: z10.string()
|
|
818
1005
|
});
|
|
819
|
-
var
|
|
1006
|
+
var knowledgeConsumedEventSchema = z10.object({
|
|
820
1007
|
...eventLedgerEnvelopeSchema,
|
|
821
|
-
event_type:
|
|
822
|
-
stable_id:
|
|
823
|
-
|
|
824
|
-
|
|
1008
|
+
event_type: z10.literal("knowledge_consumed"),
|
|
1009
|
+
stable_id: z10.string(),
|
|
1010
|
+
consumed_at: z10.string().datetime(),
|
|
1011
|
+
client_hash: z10.string()
|
|
825
1012
|
});
|
|
826
|
-
var
|
|
1013
|
+
var knowledgeScopeDegradedEventSchema = z10.object({
|
|
827
1014
|
...eventLedgerEnvelopeSchema,
|
|
828
|
-
event_type:
|
|
829
|
-
stable_id:
|
|
830
|
-
|
|
831
|
-
|
|
1015
|
+
event_type: z10.literal("knowledge_scope_degraded"),
|
|
1016
|
+
stable_id: z10.string(),
|
|
1017
|
+
timestamp: z10.string().datetime(),
|
|
1018
|
+
from_scope: z10.enum(["narrow", "broad"]),
|
|
1019
|
+
to_scope: z10.enum(["narrow", "broad"]),
|
|
1020
|
+
reason: z10.string()
|
|
832
1021
|
});
|
|
833
|
-
var
|
|
1022
|
+
var doctorRunEventSchema = z10.object({
|
|
834
1023
|
...eventLedgerEnvelopeSchema,
|
|
835
|
-
event_type:
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
var doctorRunEventSchema = z9.object({
|
|
1024
|
+
event_type: z10.literal("doctor_run"),
|
|
1025
|
+
mode: z10.enum(["lint", "fix-knowledge"]),
|
|
1026
|
+
issues: z10.number().int().nonnegative(),
|
|
1027
|
+
mutations: z10.number().int().nonnegative().optional(),
|
|
1028
|
+
timestamp: z10.string().datetime()
|
|
1029
|
+
});
|
|
1030
|
+
var knowledgePathDangledEventSchema = z10.object({
|
|
843
1031
|
...eventLedgerEnvelopeSchema,
|
|
844
|
-
event_type:
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
mutations: z9.number().int().nonnegative().optional(),
|
|
848
|
-
timestamp: z9.string().datetime()
|
|
1032
|
+
event_type: z10.literal("knowledge_path_dangled"),
|
|
1033
|
+
stable_id: z10.string(),
|
|
1034
|
+
removed_glob: z10.string()
|
|
849
1035
|
});
|
|
850
|
-
var
|
|
1036
|
+
var relevanceMigrationRunEventSchema = z10.object({
|
|
851
1037
|
...eventLedgerEnvelopeSchema,
|
|
852
|
-
event_type:
|
|
853
|
-
|
|
854
|
-
|
|
1038
|
+
event_type: z10.literal("relevance_migration_run"),
|
|
1039
|
+
timestamp: z10.string().datetime(),
|
|
1040
|
+
scanned_count: z10.number().int().nonnegative(),
|
|
1041
|
+
touched_count: z10.number().int().nonnegative()
|
|
855
1042
|
});
|
|
856
|
-
var
|
|
1043
|
+
var pendingAutoArchivedEventSchema = z10.object({
|
|
857
1044
|
...eventLedgerEnvelopeSchema,
|
|
858
|
-
event_type:
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
1045
|
+
event_type: z10.literal("pending_auto_archived"),
|
|
1046
|
+
pending_path: z10.string(),
|
|
1047
|
+
archived_to: z10.string(),
|
|
1048
|
+
reason: z10.string()
|
|
862
1049
|
});
|
|
863
|
-
var
|
|
1050
|
+
var assistantTurnObservedEventSchema = z10.object({
|
|
864
1051
|
...eventLedgerEnvelopeSchema,
|
|
865
|
-
event_type:
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
1052
|
+
event_type: z10.literal("assistant_turn_observed"),
|
|
1053
|
+
kb_line_raw: z10.string().nullable(),
|
|
1054
|
+
cite_ids: z10.array(z10.string()).default([]),
|
|
1055
|
+
cite_tags: z10.array(z10.enum(["planned", "recalled", "chained-from", "dismissed", "none"])).default([]),
|
|
1056
|
+
client: z10.enum(["cc", "codex", "cursor"]).optional(),
|
|
1057
|
+
turn_id: z10.string(),
|
|
1058
|
+
envelope_index: z10.number().int().nonnegative().optional(),
|
|
1059
|
+
timestamp: z10.string().datetime()
|
|
869
1060
|
});
|
|
870
|
-
var
|
|
1061
|
+
var citePolicyActivatedEventSchema = z10.object({
|
|
1062
|
+
...eventLedgerEnvelopeSchema,
|
|
1063
|
+
event_type: z10.literal("cite_policy_activated"),
|
|
1064
|
+
policy_version: z10.string(),
|
|
1065
|
+
timestamp: z10.string().datetime()
|
|
1066
|
+
});
|
|
1067
|
+
var eventsRotatedEventSchema = z10.object({
|
|
1068
|
+
...eventLedgerEnvelopeSchema,
|
|
1069
|
+
event_type: z10.literal("events_rotated"),
|
|
1070
|
+
cutoff_ts: z10.string().datetime(),
|
|
1071
|
+
archived_count: z10.number().int().nonnegative(),
|
|
1072
|
+
kept_count: z10.number().int().nonnegative(),
|
|
1073
|
+
archive_path: z10.string()
|
|
1074
|
+
});
|
|
1075
|
+
var knowledgeMetaAutoHealedEventSchema = z10.object({
|
|
1076
|
+
...eventLedgerEnvelopeSchema,
|
|
1077
|
+
event_type: z10.literal("knowledge_meta_auto_healed"),
|
|
1078
|
+
previous_revision_hash: z10.string(),
|
|
1079
|
+
revision_hash: z10.string(),
|
|
1080
|
+
trigger: z10.literal("read"),
|
|
1081
|
+
caller: z10.enum(["planContext", "getKnowledgeSections", "getKnowledge", "extractKnowledge"]).optional()
|
|
1082
|
+
});
|
|
1083
|
+
var eventLedgerEventSchema = z10.discriminatedUnion("event_type", [
|
|
871
1084
|
knowledgeContextPlannedEventSchema,
|
|
872
1085
|
knowledgeSelectionEventSchema,
|
|
873
1086
|
knowledgeSectionsFetchedEventSchema,
|
|
@@ -877,6 +1090,9 @@ var eventLedgerEventSchema = z9.discriminatedUnion("event_type", [
|
|
|
877
1090
|
reapplyCompletedEventSchema,
|
|
878
1091
|
eventLedgerTruncatedEventSchema,
|
|
879
1092
|
mcpConfigMigratedEventSchema,
|
|
1093
|
+
// v2.0.0-rc.19 TASK-004: bootstrap_marker_migrated — one-time fabric:knowledge-base
|
|
1094
|
+
// → fabric:bootstrap marker rewrite emitted per file by `fab doctor --fix`.
|
|
1095
|
+
bootstrapMarkerMigratedEventSchema,
|
|
880
1096
|
metaReconciledOnStartupEventSchema,
|
|
881
1097
|
metaReconciledEventSchema,
|
|
882
1098
|
claudeSkillPathMigratedEventSchema,
|
|
@@ -909,13 +1125,30 @@ var eventLedgerEventSchema = z9.discriminatedUnion("event_type", [
|
|
|
909
1125
|
doctorRunEventSchema,
|
|
910
1126
|
// v2.0.0-rc.9 TASK-003 (A3): relevance_migration_run — emitted by
|
|
911
1127
|
// `doctor --apply-lint` after the lint #26 frontmatter back-fill pass.
|
|
912
|
-
relevanceMigrationRunEventSchema
|
|
1128
|
+
relevanceMigrationRunEventSchema,
|
|
1129
|
+
// v2.0.0-rc.20 TASK-02: assistant_turn_observed — per-turn cite-policy
|
|
1130
|
+
// observation (raw KB: line text + parsed cite_ids/cite_tags + client).
|
|
1131
|
+
assistantTurnObservedEventSchema,
|
|
1132
|
+
// v2.0.0-rc.20 TASK-02: cite_policy_activated — session/policy-bump
|
|
1133
|
+
// marker recording when a given policy_version became active.
|
|
1134
|
+
citePolicyActivatedEventSchema,
|
|
1135
|
+
// v2.0.0-rc.22 Scope D T-D1: knowledge_meta_auto_healed — emitted by
|
|
1136
|
+
// loadActiveMeta when read-path drift triggers an in-place meta rebuild.
|
|
1137
|
+
knowledgeMetaAutoHealedEventSchema,
|
|
1138
|
+
// v2.0.0-rc.22 Scope A T3: events_rotated — emitted as the first line of
|
|
1139
|
+
// the post-rotation events.jsonl when sliding-window-by-age rotation moves
|
|
1140
|
+
// stale entries to events.archive/events-rotated-YYYY-MM-DD.jsonl.
|
|
1141
|
+
eventsRotatedEventSchema
|
|
913
1142
|
]);
|
|
914
1143
|
export {
|
|
915
1144
|
AGENTS_META_IDENTITY_SOURCES,
|
|
916
1145
|
AGENTS_META_LAYERS,
|
|
917
1146
|
AGENTS_META_TOPOLOGY_TYPES,
|
|
918
1147
|
AgentsMetaCountersSchema,
|
|
1148
|
+
BOOTSTRAP_CANONICAL,
|
|
1149
|
+
BOOTSTRAP_MARKER_BEGIN,
|
|
1150
|
+
BOOTSTRAP_MARKER_END,
|
|
1151
|
+
BOOTSTRAP_REGEX,
|
|
919
1152
|
FabExtractKnowledgeInputSchema,
|
|
920
1153
|
FabExtractKnowledgeInputShape,
|
|
921
1154
|
FabExtractKnowledgeOutputSchema,
|
|
@@ -927,6 +1160,9 @@ export {
|
|
|
927
1160
|
KNOWLEDGE_TYPE_CODES,
|
|
928
1161
|
KnowledgeEntryFrontmatterSchema,
|
|
929
1162
|
KnowledgeTypeSchema,
|
|
1163
|
+
LEGACY_KB_MARKER_BEGIN,
|
|
1164
|
+
LEGACY_KB_MARKER_END,
|
|
1165
|
+
LEGACY_KB_REGEX,
|
|
930
1166
|
LayerSchema,
|
|
931
1167
|
MaturitySchema,
|
|
932
1168
|
PROPOSED_REASON_DESCRIPTIONS,
|
|
@@ -941,8 +1177,11 @@ export {
|
|
|
941
1177
|
aiLedgerEntrySchema,
|
|
942
1178
|
allocateKnowledgeId,
|
|
943
1179
|
annotateIntentRequestSchema,
|
|
1180
|
+
assistantTurnObservedEventSchema,
|
|
944
1181
|
auditModeSchema,
|
|
1182
|
+
bootstrapMarkerMigratedEventSchema,
|
|
945
1183
|
candidateFileEntrySchema,
|
|
1184
|
+
citePolicyActivatedEventSchema,
|
|
946
1185
|
claudeHookPathMigratedEventSchema,
|
|
947
1186
|
claudeSkillPathMigratedEventSchema,
|
|
948
1187
|
clientPathsSchema,
|
|
@@ -962,6 +1201,7 @@ export {
|
|
|
962
1201
|
enMessages,
|
|
963
1202
|
eventLedgerEventSchema,
|
|
964
1203
|
eventLedgerTruncatedEventSchema,
|
|
1204
|
+
eventsRotatedEventSchema,
|
|
965
1205
|
fabExtractKnowledgeAnnotations,
|
|
966
1206
|
fabReviewAnnotations,
|
|
967
1207
|
fabricConfigSchema,
|
|
@@ -981,6 +1221,8 @@ export {
|
|
|
981
1221
|
getKnowledgeAnnotations,
|
|
982
1222
|
getKnowledgeInputSchema,
|
|
983
1223
|
getKnowledgeOutputSchema,
|
|
1224
|
+
getPanelFieldByKey,
|
|
1225
|
+
getPanelFields,
|
|
984
1226
|
historyStateQuerySchema,
|
|
985
1227
|
humanLedgerEntrySchema,
|
|
986
1228
|
humanLockApproveRequestSchema,
|
|
@@ -1004,6 +1246,7 @@ export {
|
|
|
1004
1246
|
knowledgeDemotedEventSchema,
|
|
1005
1247
|
knowledgeDriftDetectedEventSchema,
|
|
1006
1248
|
knowledgeLayerChangedEventSchema,
|
|
1249
|
+
knowledgeMetaAutoHealedEventSchema,
|
|
1007
1250
|
knowledgePathDangledEventSchema,
|
|
1008
1251
|
knowledgePromoteFailedEventSchema,
|
|
1009
1252
|
knowledgePromoteStartedEventSchema,
|