@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/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-BKTCBFXZ.js";
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-NNDFOOBO.js";
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" || normalized === ".fabric/bootstrap/README.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" || normalized === ".fabric/bootstrap/README.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
- externalFixturePath: z5.string().optional(),
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/forensic-report.ts
469
+ // src/schemas/fabric-config-introspect.ts
442
470
  import { z as z6 } from "zod";
443
- var forensicCodeSampleSchema = z6.object({
444
- path: z6.string(),
445
- lines: z6.string(),
446
- snippet: z6.string(),
447
- pattern_hint: z6.string()
448
- });
449
- var forensicEvidenceAnchorSchema = z6.object({
450
- file: z6.string(),
451
- line: z6.string(),
452
- snippet: z6.string()
453
- });
454
- var forensicAssertionCoverageSchema = z6.object({
455
- ratio: z6.number().min(0).max(1),
456
- total: z6.number().int().nonnegative(),
457
- matched: z6.number().int().nonnegative(),
458
- co_occurring_patterns: z6.array(z6.string())
459
- });
460
- var forensicAssertionSchema = z6.object({
461
- type: z6.enum(["framework", "pattern", "invariant", "domain"]),
462
- statement: z6.string(),
463
- confidence: z6.enum(["HIGH", "MEDIUM", "LOW"]),
464
- evidence: z6.array(forensicEvidenceAnchorSchema),
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: z6.string().optional(),
467
- alternatives: z6.array(z6.string()).optional()
468
- });
469
- var forensicTopologySchema = z6.object({
470
- total_files: z6.number().int().nonnegative(),
471
- by_ext: z6.record(z6.number().int().nonnegative()),
472
- key_dirs: z6.array(z6.string()),
473
- max_depth: z6.number().int().nonnegative()
474
- });
475
- var forensicEntryPointSchema = z6.object({
476
- path: z6.string(),
477
- reason: z6.string(),
478
- size_bytes: z6.number().int().nonnegative().optional()
479
- });
480
- var forensicFrameworkSchema = z6.object({
481
- kind: z6.string(),
482
- version: z6.string(),
483
- subkind: z6.string(),
484
- evidence: z6.array(z6.string())
485
- });
486
- var forensicReadmeSchema = z6.object({
487
- quality: z6.enum(["missing", "stub", "ok"]),
488
- line_count: z6.number().int().nonnegative(),
489
- has_contributing: z6.boolean()
490
- });
491
- var candidateFileEntrySchema = z6.object({
492
- path: z6.string(),
493
- family: z6.enum(["entry", "component", "config", "test", "domain"]),
494
- rationale: z6.string()
495
- });
496
- var forensicSamplingBudgetSchema = z6.object({
497
- max_files: z6.literal(15),
498
- max_lines_per_file: z6.literal(100)
499
- });
500
- var forensicReportSchema = z6.object({
501
- version: z6.string(),
502
- generated_at: z6.string(),
503
- generated_by: z6.string(),
504
- target: z6.string(),
505
- project_name: z6.string(),
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: z6.array(forensicEntryPointSchema),
509
- code_samples: z6.array(forensicCodeSampleSchema),
510
- assertions: z6.array(forensicAssertionSchema),
511
- candidate_files: z6.array(candidateFileEntrySchema),
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: z6.array(z6.string()).optional()
680
+ recommendations_for_skill: z7.array(z7.string()).optional()
515
681
  });
516
682
 
517
683
  // src/schemas/init-context.ts
518
- import { z as z7 } from "zod";
519
- var initContextFrameworkSchema = z7.object({
520
- kind: z7.string(),
521
- version: z7.string(),
522
- subkind: z7.string()
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 = z7.object({
525
- confidence: z7.enum(["HIGH", "MEDIUM", "LOW"]),
526
- evidence_refs: z7.array(z7.string())
690
+ var initContextInvariantConfidenceSnapshotSchema = z8.object({
691
+ confidence: z8.enum(["HIGH", "MEDIUM", "LOW"]),
692
+ evidence_refs: z8.array(z8.string())
527
693
  });
528
- var initContextSourceEvidenceSchema = z7.object({
529
- file: z7.string(),
530
- lines: z7.string()
694
+ var initContextSourceEvidenceSchema = z8.object({
695
+ file: z8.string(),
696
+ lines: z8.string()
531
697
  });
532
- var initContextInvariantSchema = z7.object({
533
- type: z7.enum(["ban", "require", "protect"]),
534
- rule: z7.string(),
535
- rationale: z7.string().optional(),
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: z7.array(initContextSourceEvidenceSchema).optional()
538
- });
539
- var initContextDomainGroupSchema = z7.object({
540
- name: z7.string(),
541
- paths: z7.array(z7.string()),
542
- summary: z7.string().optional(),
543
- topology_type: z7.enum(["mirror", "cross-cutting"]).optional(),
544
- target_path: z7.string().optional()
545
- });
546
- var initContextInterviewTrailEntrySchema = z7.object({
547
- phase: z7.string(),
548
- question: z7.string(),
549
- answer: z7.string(),
550
- presentation: z7.string().optional(),
551
- user_corrections: z7.array(z7.string()).optional()
552
- });
553
- var initContextSchema = z7.object({
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: z7.array(z7.string()),
556
- invariants: z7.array(initContextInvariantSchema),
557
- domain_groups: z7.array(initContextDomainGroupSchema),
558
- interview_trail: z7.array(initContextInterviewTrailEntrySchema),
559
- forensic_ref: z7.string()
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 z8 } from "zod";
564
- var metaUpdatedEventSchema = z8.object({
565
- type: z8.literal("meta:updated"),
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 = z8.object({
569
- type: z8.literal("lock:drift"),
570
- payload: z8.object({
571
- locked: z8.array(humanLockEntrySchema),
572
- drifted: z8.array(humanLockEntrySchema)
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 = z8.object({
576
- type: z8.literal("lock:approved"),
577
- payload: z8.object({
578
- locked: z8.array(humanLockEntrySchema),
579
- approved: z8.array(humanLockEntrySchema)
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 = z8.object({
583
- type: z8.literal("ledger:appended"),
748
+ var ledgerAppendedEventSchema = z9.object({
749
+ type: z9.literal("ledger:appended"),
584
750
  payload: ledgerEntrySchema
585
751
  });
586
- var driftDetectedEventSchema = z8.object({
587
- type: z8.literal("drift:detected"),
752
+ var driftDetectedEventSchema = z9.object({
753
+ type: z9.literal("drift:detected"),
588
754
  payload: forensicReportSchema
589
755
  });
590
- var fabricEventSchema = z8.discriminatedUnion("type", [
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 z9 } from "zod";
765
+ import { z as z10 } from "zod";
600
766
  var eventLedgerEnvelopeSchema = {
601
- kind: z9.literal("fabric-event"),
602
- id: z9.string(),
603
- ts: z9.number().int().nonnegative(),
604
- schema_version: z9.literal(1),
605
- correlation_id: z9.string().optional(),
606
- session_id: z9.string().optional()
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 = z9.record(z9.string());
609
- var knowledgeContextPlannedEventSchema = z9.object({
774
+ var stringRecordSchema = z10.record(z10.string());
775
+ var knowledgeContextPlannedEventSchema = z10.object({
610
776
  ...eventLedgerEnvelopeSchema,
611
- event_type: z9.literal("knowledge_context_planned"),
612
- target_paths: z9.array(z9.string()),
613
- required_stable_ids: z9.array(z9.string()),
614
- ai_selectable_stable_ids: z9.array(z9.string()),
615
- final_stable_ids: z9.array(z9.string()),
616
- selection_token: z9.string().optional(),
617
- client_hash: z9.string().optional(),
618
- intent: z9.string().optional(),
619
- known_tech: z9.array(z9.string()).optional(),
620
- diagnostics: z9.array(z9.unknown()).optional()
621
- });
622
- var knowledgeSelectionEventSchema = z9.object({
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: z9.literal("knowledge_selection"),
625
- selection_token: z9.string(),
626
- target_paths: z9.array(z9.string()),
627
- required_stable_ids: z9.array(z9.string()),
628
- ai_selectable_stable_ids: z9.array(z9.string()),
629
- ai_selected_stable_ids: z9.array(z9.string()),
630
- final_stable_ids: z9.array(z9.string()),
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: z9.array(z9.string()),
633
- ignored_stable_ids: z9.array(z9.string())
798
+ rejected_stable_ids: z10.array(z10.string()),
799
+ ignored_stable_ids: z10.array(z10.string())
634
800
  });
635
- var knowledgeSectionsFetchedEventSchema = z9.object({
801
+ var knowledgeSectionsFetchedEventSchema = z10.object({
636
802
  ...eventLedgerEnvelopeSchema,
637
- event_type: z9.literal("knowledge_sections_fetched"),
638
- selection_token: z9.string(),
639
- target_paths: z9.array(z9.string()).optional(),
640
- requested_sections: z9.array(z9.string()),
641
- final_stable_ids: z9.array(z9.string()),
642
- ai_selected_stable_ids: z9.array(z9.string()),
643
- diagnostics: z9.array(z9.unknown()).optional()
644
- });
645
- var editIntentCheckedEventSchema = z9.object({
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: z9.literal("edit_intent_checked"),
648
- path: z9.string(),
649
- compliant: z9.boolean(),
650
- intent: z9.string(),
651
- ledger_entry_id: z9.string(),
652
- ledger_source: z9.enum(["ai", "human"]).optional(),
653
- commit_sha: z9.string().optional(),
654
- parent_sha: z9.string().optional(),
655
- parent_ledger_entry_id: z9.string().optional(),
656
- diff_stat: z9.string().optional(),
657
- annotation: z9.string().optional(),
658
- matched_rule_context_ts: z9.number().int().nonnegative().nullable(),
659
- window_ms: z9.number().int().nonnegative()
660
- });
661
- var knowledgeDriftDetectedEventSchema = z9.object({
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: z9.literal("knowledge_drift_detected"),
664
- revision: z9.string().optional(),
665
- drifted_stable_ids: z9.array(z9.string()),
666
- missing_files: z9.array(z9.string()),
667
- stale_files: z9.array(z9.string()),
668
- details: z9.array(
669
- z9.object({
670
- file: z9.string(),
671
- stable_id: z9.string(),
672
- expected_hash: z9.string(),
673
- actual_hash: z9.string().nullable()
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 = z9.object({
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: z9.literal("mcp_event"),
680
- mcp_event_id: z9.string(),
681
- stream_id: z9.string(),
682
- message: z9.unknown()
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 reapplyCompletedEventSchema = z9.object({
864
+ var mcpConfigMigratedEventSchema = z10.object({
685
865
  ...eventLedgerEnvelopeSchema,
686
- event_type: z9.literal("reapply_completed"),
687
- preserved_ledger: z9.boolean(),
688
- preserved_meta: z9.boolean(),
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 eventLedgerTruncatedEventSchema = z9.object({
870
+ var bootstrapMarkerMigratedEventSchema = z10.object({
692
871
  ...eventLedgerEnvelopeSchema,
693
- event_type: z9.literal("event_ledger_truncated"),
694
- byte_offset: z9.number().int().nonnegative(),
695
- byte_length: z9.number().int().nonnegative(),
696
- corrupted_path: z9.string()
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 mcpConfigMigratedEventSchema = z9.object({
879
+ var metaReconciledOnStartupEventSchema = z10.object({
699
880
  ...eventLedgerEnvelopeSchema,
700
- event_type: z9.literal("mcp_config_migrated"),
701
- source: z9.literal("doctor_fix"),
702
- removed_from: z9.string()
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 metaReconciledOnStartupEventSchema = z9.object({
886
+ var metaReconciledEventSchema = z10.object({
705
887
  ...eventLedgerEnvelopeSchema,
706
- event_type: z9.literal("meta_reconciled_on_startup"),
707
- reconciled_files: z9.array(z9.string()),
708
- duration_ms: z9.number().int().nonnegative(),
709
- source: z9.literal("reconcileKnowledge")
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 metaReconciledEventSchema = z9.object({
899
+ var claudeSkillPathMigratedEventSchema = z10.object({
712
900
  ...eventLedgerEnvelopeSchema,
713
- event_type: z9.literal("meta_reconciled"),
714
- reconciled_files: z9.array(z9.string()),
715
- duration_ms: z9.number().int().nonnegative(),
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 claudeSkillPathMigratedEventSchema = z9.object({
905
+ var claudeHookPathMigratedEventSchema = z10.object({
720
906
  ...eventLedgerEnvelopeSchema,
721
- event_type: z9.literal("claude_skill_path_migrated"),
722
- from: z9.string(),
723
- to: z9.string()
907
+ event_type: z10.literal("claude_hook_path_migrated"),
908
+ from: z10.string(),
909
+ to: z10.string()
724
910
  });
725
- var claudeHookPathMigratedEventSchema = z9.object({
911
+ var codexSkillPathMigratedEventSchema = z10.object({
726
912
  ...eventLedgerEnvelopeSchema,
727
- event_type: z9.literal("claude_hook_path_migrated"),
728
- from: z9.string(),
729
- to: z9.string()
913
+ event_type: z10.literal("codex_skill_path_migrated"),
914
+ from: z10.string(),
915
+ to: z10.string()
730
916
  });
731
- var codexSkillPathMigratedEventSchema = z9.object({
917
+ var initScanCompletedEventSchema = z10.object({
732
918
  ...eventLedgerEnvelopeSchema,
733
- event_type: z9.literal("codex_skill_path_migrated"),
734
- from: z9.string(),
735
- to: z9.string()
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 initScanCompletedEventSchema = z9.object({
924
+ var knowledgeProposedEventSchema = z10.object({
738
925
  ...eventLedgerEnvelopeSchema,
739
- event_type: z9.literal("init_scan_completed"),
740
- written_stable_ids: z9.array(z9.string()),
741
- duration_ms: z9.number().int().nonnegative(),
742
- source: z9.enum(["init", "scan", "doctor_fix", "doctor-rescan"]).optional()
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 knowledgeProposedEventSchema = z9.object({
931
+ var knowledgePromoteStartedEventSchema = z10.object({
745
932
  ...eventLedgerEnvelopeSchema,
746
- event_type: z9.literal("knowledge_proposed"),
747
- stable_id: z9.string().optional(),
748
- timestamp: z9.string().datetime(),
749
- reason: z9.string().optional()
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 knowledgePromoteStartedEventSchema = z9.object({
938
+ var knowledgePromotedEventSchema = z10.object({
752
939
  ...eventLedgerEnvelopeSchema,
753
- event_type: z9.literal("knowledge_promote_started"),
754
- stable_id: z9.string().optional(),
755
- timestamp: z9.string().datetime(),
756
- reason: z9.string().optional()
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 knowledgePromotedEventSchema = z9.object({
945
+ var knowledgePromoteFailedEventSchema = z10.object({
759
946
  ...eventLedgerEnvelopeSchema,
760
- event_type: z9.literal("knowledge_promoted"),
761
- stable_id: z9.string().optional(),
762
- timestamp: z9.string().datetime(),
763
- reason: z9.string().optional()
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 knowledgePromoteFailedEventSchema = z9.object({
952
+ var knowledgeLayerChangedEventSchema = z10.object({
766
953
  ...eventLedgerEnvelopeSchema,
767
- event_type: z9.literal("knowledge_promote_failed"),
768
- stable_id: z9.string().optional(),
769
- timestamp: z9.string().datetime(),
770
- reason: z9.string()
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 knowledgeLayerChangedEventSchema = z9.object({
961
+ var knowledgeSlugRenamedEventSchema = z10.object({
773
962
  ...eventLedgerEnvelopeSchema,
774
- event_type: z9.literal("knowledge_layer_changed"),
775
- stable_id: z9.string().optional(),
776
- timestamp: z9.string().datetime(),
777
- reason: z9.string().optional(),
778
- from_layer: z9.enum(["team", "personal"]),
779
- to_layer: z9.enum(["team", "personal"])
780
- });
781
- var knowledgeSlugRenamedEventSchema = z9.object({
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: z9.literal("knowledge_slug_renamed"),
784
- stable_id: z9.string().optional(),
785
- timestamp: z9.string().datetime(),
786
- reason: z9.string().optional(),
787
- from_slug: z9.string(),
788
- to_slug: z9.string()
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: z9.literal("knowledge_demoted"),
793
- stable_id: z9.string().optional(),
794
- timestamp: z9.string().datetime(),
795
- reason: z9.string().optional()
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 knowledgeArchivedEventSchema = z9.object({
984
+ var knowledgeArchiveAttemptedEventSchema = z10.object({
798
985
  ...eventLedgerEnvelopeSchema,
799
- event_type: z9.literal("knowledge_archived"),
800
- stable_id: z9.string().optional(),
801
- timestamp: z9.string().datetime(),
802
- reason: z9.string().optional()
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 knowledgeArchiveAttemptedEventSchema = z9.object({
991
+ var knowledgeDeferredEventSchema = z10.object({
805
992
  ...eventLedgerEnvelopeSchema,
806
- event_type: z9.literal("knowledge_archive_attempted"),
807
- stable_id: z9.string().optional(),
808
- timestamp: z9.string().datetime(),
809
- reason: z9.string().optional()
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 knowledgeDeferredEventSchema = z9.object({
999
+ var knowledgeRejectedEventSchema = z10.object({
812
1000
  ...eventLedgerEnvelopeSchema,
813
- event_type: z9.literal("knowledge_deferred"),
814
- stable_id: z9.string().optional(),
815
- timestamp: z9.string().datetime(),
816
- reason: z9.string().optional(),
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 knowledgeRejectedEventSchema = z9.object({
1006
+ var knowledgeConsumedEventSchema = z10.object({
820
1007
  ...eventLedgerEnvelopeSchema,
821
- event_type: z9.literal("knowledge_rejected"),
822
- stable_id: z9.string().optional(),
823
- timestamp: z9.string().datetime(),
824
- reason: z9.string()
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 knowledgeConsumedEventSchema = z9.object({
1013
+ var knowledgeScopeDegradedEventSchema = z10.object({
827
1014
  ...eventLedgerEnvelopeSchema,
828
- event_type: z9.literal("knowledge_consumed"),
829
- stable_id: z9.string(),
830
- consumed_at: z9.string().datetime(),
831
- client_hash: z9.string()
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 knowledgeScopeDegradedEventSchema = z9.object({
1022
+ var doctorRunEventSchema = z10.object({
834
1023
  ...eventLedgerEnvelopeSchema,
835
- event_type: z9.literal("knowledge_scope_degraded"),
836
- stable_id: z9.string(),
837
- timestamp: z9.string().datetime(),
838
- from_scope: z9.enum(["narrow", "broad"]),
839
- to_scope: z9.enum(["narrow", "broad"]),
840
- reason: z9.string()
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: z9.literal("doctor_run"),
845
- mode: z9.enum(["lint", "fix-knowledge"]),
846
- issues: z9.number().int().nonnegative(),
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 knowledgePathDangledEventSchema = z9.object({
1036
+ var relevanceMigrationRunEventSchema = z10.object({
851
1037
  ...eventLedgerEnvelopeSchema,
852
- event_type: z9.literal("knowledge_path_dangled"),
853
- stable_id: z9.string(),
854
- removed_glob: z9.string()
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 relevanceMigrationRunEventSchema = z9.object({
1043
+ var pendingAutoArchivedEventSchema = z10.object({
857
1044
  ...eventLedgerEnvelopeSchema,
858
- event_type: z9.literal("relevance_migration_run"),
859
- timestamp: z9.string().datetime(),
860
- scanned_count: z9.number().int().nonnegative(),
861
- touched_count: z9.number().int().nonnegative()
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 pendingAutoArchivedEventSchema = z9.object({
1050
+ var assistantTurnObservedEventSchema = z10.object({
864
1051
  ...eventLedgerEnvelopeSchema,
865
- event_type: z9.literal("pending_auto_archived"),
866
- pending_path: z9.string(),
867
- archived_to: z9.string(),
868
- reason: z9.string()
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 eventLedgerEventSchema = z9.discriminatedUnion("event_type", [
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,