@codeledger/types 0.7.2 → 0.7.5

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.d.ts CHANGED
@@ -790,6 +790,444 @@ export interface SessionRecord {
790
790
  pid: number | null;
791
791
  bundle_files: string[];
792
792
  status: SessionStatus;
793
+ /** Git ref (commit SHA) at the time the bundle was activated.
794
+ * Used by pr-check and staleness detection as the baseline for
795
+ * computing what changed since the session started working. */
796
+ activation_ref?: string;
797
+ }
798
+ /** A single file-system event detected by Pulse */
799
+ export interface PulseFileEvent {
800
+ path: string;
801
+ kind: 'create' | 'modify' | 'delete' | 'rename';
802
+ timestamp: ISODateTime;
803
+ }
804
+ /** A cluster of related file events forming a working set */
805
+ export interface PulseWorkingSet {
806
+ files: string[];
807
+ modules: string[];
808
+ first_change: ISODateTime;
809
+ last_change: ISODateTime;
810
+ }
811
+ /** An inferred session from Pulse analysis */
812
+ export interface PulseSession {
813
+ sessionId: string;
814
+ candidateIntent: string;
815
+ touchedFiles: string[];
816
+ dependencySurface: string[];
817
+ modules: string[];
818
+ timestamp: ISODateTime;
819
+ confidence: number;
820
+ }
821
+ /** Persistent Pulse state stored on disk */
822
+ export interface PulseState {
823
+ schema_version: 'pulse/v1';
824
+ sessions: PulseSession[];
825
+ recentEvents: PulseFileEvent[];
826
+ lastScanTimestamp: ISODateTime;
827
+ }
828
+ /** An exported symbol entry from the public surface of a file */
829
+ export interface PublicSurfaceEntry {
830
+ file: string;
831
+ symbol: string;
832
+ kind: 'function' | 'interface' | 'type' | 'class' | 'const' | 'enum';
833
+ signature: string;
834
+ lineNumber: number;
835
+ }
836
+ /** A session's collected public surface (all exported symbols) */
837
+ export interface SessionPublicSurface {
838
+ sessionId: string;
839
+ entries: PublicSurfaceEntry[];
840
+ extractedAt: string;
841
+ }
842
+ /** A detected change in an exported symbol's signature */
843
+ export interface SignatureChange {
844
+ symbol: string;
845
+ file: string;
846
+ kind: PublicSurfaceEntry['kind'];
847
+ previousSignature: string;
848
+ newSignature: string;
849
+ changeType: 'removal' | 'arity_change' | 'parameter_change' | 'rename' | 'type_change';
850
+ breaking: boolean;
851
+ }
852
+ /** A semantic conflict detected by Layer D */
853
+ export interface LayerDConflict {
854
+ affectedSymbol: string;
855
+ file: string;
856
+ producerSession: string;
857
+ consumerSessions: string[];
858
+ change: SignatureChange;
859
+ severity: number;
860
+ description: string;
861
+ }
862
+ /** Aggregate result of Layer D analysis */
863
+ export interface LayerDAnalysis {
864
+ conflicts: LayerDConflict[];
865
+ surfacesAnalyzed: number;
866
+ timestamp: ISODateTime;
867
+ }
868
+ /** Signal types used in conflict severity scoring */
869
+ export type ConflictSignalType = 'exact_file_overlap' | 'direct_dependency' | 'shared_test_surface' | 'branch_divergence' | 'semantic_signature_overlap';
870
+ /** A single conflict signal with its computed weight */
871
+ export interface ConflictSignal {
872
+ type: ConflictSignalType;
873
+ weight: number;
874
+ details: string;
875
+ }
876
+ /** Severity level classification */
877
+ export type ConflictSeverityLevel = 'HIGH' | 'MEDIUM' | 'LOW';
878
+ /** Full severity assessment for a session pair */
879
+ export interface ConflictSeverityAssessment {
880
+ signals: ConflictSignal[];
881
+ aggregateScore: number;
882
+ level: ConflictSeverityLevel;
883
+ shouldInterrupt: boolean;
884
+ shouldAdvise: boolean;
885
+ sessionPair: [string, string];
886
+ }
887
+ /** Per-signal-type weights for severity scoring */
888
+ export interface SeverityWeights {
889
+ exact_file_overlap: number;
890
+ direct_dependency: number;
891
+ shared_test_surface: number;
892
+ branch_divergence: number;
893
+ semantic_signature_overlap: number;
894
+ }
895
+ /** Thresholds for severity level classification */
896
+ export interface SeverityThresholds {
897
+ high: number;
898
+ medium: number;
899
+ }
900
+ /** Configuration for the severity scoring engine */
901
+ export interface SeverityConfig {
902
+ weights: SeverityWeights;
903
+ thresholds: SeverityThresholds;
904
+ }
905
+ /** A soft claim representing advisory file ownership */
906
+ export interface SoftClaim {
907
+ sessionId: string;
908
+ actorId: string;
909
+ timestamp: ISODateTime;
910
+ touchedFiles: string[];
911
+ dependencySurface: string[];
912
+ intentLabel: string;
913
+ expiresAt: ISODateTime;
914
+ }
915
+ /** Per-file presence information (who is working on what) */
916
+ export interface ClaimPresence {
917
+ file: string;
918
+ actors: Array<{
919
+ actorId: string;
920
+ sessionId: string;
921
+ intentLabel: string;
922
+ timestamp: ISODateTime;
923
+ }>;
924
+ }
925
+ /** Staleness level for context freshness assessment */
926
+ export type StalenessLevel = 'fresh' | 'low' | 'medium' | 'high';
927
+ /** A file that has changed since the session's activation baseline */
928
+ export interface ShadowChangedFile {
929
+ path: string;
930
+ changedBy: string;
931
+ changeKind: 'added' | 'deleted' | 'renamed' | 'modified';
932
+ inBundle: boolean;
933
+ inDependencySurface: boolean;
934
+ description: string;
935
+ }
936
+ /** A staleness update computed for a session */
937
+ export interface ShadowUpdate {
938
+ sessionId: string;
939
+ changedFiles: ShadowChangedFile[];
940
+ summary: string;
941
+ computedAt: ISODateTime;
942
+ stalenessLevel: StalenessLevel;
943
+ }
944
+ /** Warning type for coalescing and dedup */
945
+ export type WarningType = 'file_overlap' | 'severity_assessment' | 'staleness';
946
+ /** A conflict/staleness warning to surface to the user */
947
+ export interface ConflictWarning {
948
+ sessionId: string;
949
+ message: string;
950
+ severity: ConflictSeverityLevel;
951
+ overlappingFiles: string[];
952
+ relatedSessions: string[];
953
+ timestamp: ISODateTime;
954
+ /** Warning type for coalescing (defaults to 'file_overlap' for backwards compat) */
955
+ warningType?: WarningType;
956
+ }
957
+ /** Persistent throttle state for warning deduplication */
958
+ export interface WarningThrottleState {
959
+ schema_version: 'warning-throttle/v1';
960
+ lastWarnings: Array<{
961
+ /** Content hash for dedup */
962
+ hash: string;
963
+ /** Dedup key (type + session pair) for severity tracking */
964
+ dedupKey: string;
965
+ /** Severity when last shown */
966
+ severity: ConflictSeverityLevel;
967
+ timestamp: ISODateTime;
968
+ /** Signal fingerprint for same-signal suppression (v2.5.1+) */
969
+ fingerprint?: string;
970
+ }>;
971
+ }
972
+ /** Overall PR readiness status */
973
+ export type PRCheckStatus = 'CLEAN' | 'REVIEW' | 'STALE' | 'CONFLICTED';
974
+ /** Result of a pre-PR freshness check */
975
+ export interface PRCheckResult {
976
+ status: PRCheckStatus;
977
+ conflictRisk: ConflictSeverityLevel;
978
+ staleness: StalenessLevel;
979
+ /** Human-readable one-line summary */
980
+ summary: string;
981
+ /** Top 2-4 specific, high-signal findings */
982
+ findings: string[];
983
+ changedFilesSinceStart: string[];
984
+ overlappingSessions: string[];
985
+ /** Single best next action (preferred over list) */
986
+ recommendedAction: string;
987
+ /** Additional actions if needed */
988
+ recommendedActions: string[];
989
+ timestamp: ISODateTime;
990
+ }
991
+ /** Lifecycle state of a Command Capsule */
992
+ export type CapsuleState = 'draft' | 'pending_policy' | 'pending_approval' | 'approved' | 'rejected' | 'executing' | 'completed' | 'failed' | 'revoked';
993
+ /** Specification of the action a capsule governs */
994
+ export interface ActionSpec {
995
+ operation: string;
996
+ description: string;
997
+ targetSystem: string;
998
+ targets: string[];
999
+ sideEffects: string[];
1000
+ }
1001
+ /** A state transition in a capsule's lifecycle */
1002
+ export interface CapsuleTransition {
1003
+ from: CapsuleState;
1004
+ to: CapsuleState;
1005
+ trigger: string;
1006
+ actor: string;
1007
+ timestamp: ISODateTime;
1008
+ metadata?: Record<string, unknown>;
1009
+ }
1010
+ /** A pre- or post-condition on execution */
1011
+ export interface ExecutionCondition {
1012
+ name: string;
1013
+ description: string;
1014
+ required: boolean;
1015
+ result?: {
1016
+ passed: boolean;
1017
+ message: string;
1018
+ evaluatedAt: ISODateTime;
1019
+ };
1020
+ }
1021
+ /** Risk assessment for a capsule */
1022
+ export interface CapsuleRiskAssessment {
1023
+ score: number;
1024
+ level: 'low' | 'medium' | 'high' | 'critical';
1025
+ factors: RiskFactor[];
1026
+ assessedAt: ISODateTime;
1027
+ }
1028
+ /** A single risk factor contributing to the overall score */
1029
+ export interface RiskFactor {
1030
+ name: string;
1031
+ weight: number;
1032
+ score: number;
1033
+ description: string;
1034
+ }
1035
+ /** Configuration for risk scoring weights */
1036
+ export interface RiskScoringConfig {
1037
+ scopeWeight: number;
1038
+ failureHistoryWeight: number;
1039
+ sensitivityWeight: number;
1040
+ magnitudeWeight: number;
1041
+ coverageGapWeight: number;
1042
+ }
1043
+ /** File sensitivity map for risk scoring */
1044
+ export interface SensitivityMap {
1045
+ patterns: Array<{
1046
+ glob: string;
1047
+ level: 'low' | 'medium' | 'high' | 'critical';
1048
+ }>;
1049
+ }
1050
+ /** Execution outcome for a completed capsule */
1051
+ export interface CapsuleOutcome {
1052
+ status: 'success' | 'failure';
1053
+ message: string;
1054
+ completedAt: ISODateTime;
1055
+ summary?: string;
1056
+ eclEntryId?: string;
1057
+ testResults?: {
1058
+ passed: number;
1059
+ failed: number;
1060
+ skipped: number;
1061
+ };
1062
+ }
1063
+ /** An approval requirement derived from policy evaluation */
1064
+ export interface ApprovalRequirement {
1065
+ policyId: string;
1066
+ reason: string;
1067
+ approverRole?: string;
1068
+ targets?: string[];
1069
+ ruleName?: string;
1070
+ requiredScope?: string;
1071
+ delegatable?: boolean;
1072
+ }
1073
+ /** A recorded approval, rejection, or delegation decision */
1074
+ export interface ApprovalDecision {
1075
+ policyId: string;
1076
+ decision: 'approved' | 'rejected' | 'delegated';
1077
+ approver: string;
1078
+ reason: string;
1079
+ timestamp: ISODateTime;
1080
+ authorityScope?: string;
1081
+ }
1082
+ /** The first-class Command Capsule domain object */
1083
+ export interface CommandCapsule {
1084
+ id: string;
1085
+ state: CapsuleState;
1086
+ action: ActionSpec;
1087
+ risk: CapsuleRiskAssessment;
1088
+ policyIds: string[];
1089
+ approvalRequirements: ApprovalRequirement[];
1090
+ approvalDecisions: ApprovalDecision[];
1091
+ preconditions: ExecutionCondition[];
1092
+ postconditions: ExecutionCondition[];
1093
+ transitions: CapsuleTransition[];
1094
+ intentSignature?: string;
1095
+ createdBy: string;
1096
+ createdAt: ISODateTime;
1097
+ updatedAt: ISODateTime;
1098
+ outcome?: CapsuleOutcome;
1099
+ }
1100
+ /** An authority who can approve capsules matching file patterns */
1101
+ export interface ApprovalAuthority {
1102
+ id: string;
1103
+ name: string;
1104
+ patterns: string[];
1105
+ role: string;
1106
+ canDelegate: boolean;
1107
+ actorId?: string;
1108
+ scope?: 'any_peer' | 'team_lead' | 'security' | 'owner';
1109
+ }
1110
+ /** Policy configuration for approval workflow */
1111
+ export interface ApprovalPolicyConfig {
1112
+ version: number;
1113
+ enabled: boolean;
1114
+ authorities: ApprovalAuthority[];
1115
+ preventSelfApproval: boolean;
1116
+ maxDelegationDepth: number;
1117
+ approvalThreshold: CapsuleRiskAssessment['level'];
1118
+ }
1119
+ /** Stage kind in the 7-stage execution timeline */
1120
+ export type TimelineStageKind = 'intent' | 'context' | 'policy' | 'approval' | 'execution' | 'outcome' | 'learning';
1121
+ /** A single stage in the execution timeline */
1122
+ export interface TimelineStage {
1123
+ kind: TimelineStageKind;
1124
+ label: string;
1125
+ timestamp: ISODateTime;
1126
+ sourceType: 'authoritative' | 'derived' | 'synthetic';
1127
+ sourceRef: string;
1128
+ data: Record<string, unknown>;
1129
+ }
1130
+ /** A full 7-stage execution timeline assembled from a capsule */
1131
+ export interface ExecutionTimeline {
1132
+ capsuleId: string;
1133
+ stages: TimelineStage[];
1134
+ assembledAt: ISODateTime;
1135
+ complete: boolean;
1136
+ }
1137
+ /** A learning signal derived from execution outcome */
1138
+ export interface LearningSignal {
1139
+ intentSignature: string;
1140
+ capsuleId: string;
1141
+ direction: 'positive' | 'negative';
1142
+ magnitude: number;
1143
+ factors: string[];
1144
+ recordedAt: ISODateTime;
1145
+ }
1146
+ /** A recommended policy adjustment from learning feedback */
1147
+ export interface PolicyAdjustment {
1148
+ type?: 'tighten' | 'relax' | 'add_rule' | 'remove_rule';
1149
+ target?: string;
1150
+ reason: string;
1151
+ confidence: number;
1152
+ basedOnSignals?: number;
1153
+ ruleId?: string;
1154
+ adjustment?: 'tighten' | 'relax';
1155
+ suggestedChange?: Record<string, unknown>;
1156
+ }
1157
+ /** Qualitative health rating */
1158
+ export type HealthRating = 'EXCELLENT' | 'GOOD' | 'FAIR' | 'POOR' | 'CRITICAL';
1159
+ /** Trend direction for a dashboard metric */
1160
+ export type TrendDirection = 'improving' | 'stable' | 'degrading';
1161
+ /** Computed dashboard metrics (5-component health score) */
1162
+ export interface DashboardMetrics {
1163
+ ahs: number;
1164
+ dri: number;
1165
+ eds: number;
1166
+ sts: number;
1167
+ override_frequency: number;
1168
+ overall: number;
1169
+ timestamp: number;
1170
+ }
1171
+ /** A point-in-time snapshot of dashboard metrics */
1172
+ export interface DashboardSnapshot extends DashboardMetrics {
1173
+ snapshot_source: string;
1174
+ }
1175
+ /** Trend analysis across dashboard metric history */
1176
+ export interface DashboardTrends {
1177
+ ahs_trend: TrendDirection;
1178
+ dri_trend: TrendDirection;
1179
+ eds_trend: TrendDirection;
1180
+ sts_trend: TrendDirection;
1181
+ override_trend: TrendDirection;
1182
+ overall_trend: TrendDirection;
1183
+ }
1184
+ /** Policy domain name */
1185
+ export type PolicyDomain = 'discovery' | 'enforcement' | 'source_of_truth' | 'overrides' | 'interventions' | 'dashboard';
1186
+ /** Definition of a policy field */
1187
+ export interface PolicyFieldDefinition {
1188
+ name: string;
1189
+ type: 'boolean' | 'number' | 'string' | 'string[]';
1190
+ description: string;
1191
+ default_value: unknown;
1192
+ resolution: 'strictest' | 'union' | 'loosest' | 'override';
1193
+ }
1194
+ /** Definition of a policy domain */
1195
+ export interface PolicyDomainDefinition {
1196
+ name: PolicyDomain;
1197
+ description: string;
1198
+ fields: PolicyFieldDefinition[];
1199
+ defaults: Record<string, unknown>;
1200
+ }
1201
+ /** A validation error in a policy configuration */
1202
+ export interface PolicyValidationError {
1203
+ domain: PolicyDomain;
1204
+ field: string;
1205
+ message: string;
1206
+ value?: unknown;
1207
+ severity: 'error' | 'warning';
1208
+ }
1209
+ /** Result from a real-time policy check during context selection */
1210
+ export interface PolicyCheckResult {
1211
+ allowed: boolean;
1212
+ violations: PolicyValidationError[];
1213
+ advisory: string[];
1214
+ }
1215
+ /** Context provided to real-time policy checks */
1216
+ export interface RealtimePolicyContext {
1217
+ task?: string;
1218
+ target_files?: string[];
1219
+ discovery_verdict?: DiscoveryVerdict;
1220
+ confidence?: number;
1221
+ drift?: number;
1222
+ }
1223
+ /** A single field-level difference between two policies */
1224
+ export interface PolicyDiffEntry {
1225
+ domain: PolicyDomain;
1226
+ field: string;
1227
+ base_value: unknown;
1228
+ target_value: unknown;
1229
+ effective_value: unknown;
1230
+ resolution_rule: string;
793
1231
  }
794
1232
  /** A checkpoint snapshot saved during a session for resume-after-interruption */
795
1233
  export interface CheckpointRecord {
@@ -894,6 +1332,39 @@ export interface MustangPolicyV1 {
894
1332
  block_post_hoc_reads?: boolean;
895
1333
  /** Review Intelligence configuration (optional, additive) */
896
1334
  review_intelligence?: ReviewIntelligencePolicyConfig;
1335
+ /** Discovery gate domain settings */
1336
+ discovery?: {
1337
+ auto_run?: boolean;
1338
+ block_on_no_go?: boolean;
1339
+ cache_ttl_seconds?: number;
1340
+ };
1341
+ /** Source-of-truth domain settings */
1342
+ source_of_truth?: {
1343
+ require_stability?: boolean;
1344
+ min_confidence?: number;
1345
+ alert_on_fragmentation?: boolean;
1346
+ };
1347
+ /** Override governance domain settings */
1348
+ overrides?: {
1349
+ require_approval?: boolean;
1350
+ max_depth?: number;
1351
+ audit?: boolean;
1352
+ };
1353
+ /** Intervention engine domain settings */
1354
+ interventions?: {
1355
+ auto_generate?: boolean;
1356
+ min_severity?: string;
1357
+ escalation_enabled?: boolean;
1358
+ };
1359
+ /** Architecture health dashboard domain settings */
1360
+ dashboard?: {
1361
+ collection_enabled?: boolean;
1362
+ snapshot_interval_minutes?: number;
1363
+ alert_thresholds?: {
1364
+ ahs_min?: number;
1365
+ dri_max?: number;
1366
+ };
1367
+ };
897
1368
  }
898
1369
  /** Review Intelligence policy configuration (nested under MustangPolicyV1) */
899
1370
  export interface ReviewIntelligencePolicyConfig {
@@ -916,7 +1387,7 @@ export interface ResolvedPolicyV1 extends MustangPolicyV1 {
916
1387
  resolved_from: 'hardcoded-defaults' | 'org-default' | 'repo-override';
917
1388
  }
918
1389
  /** Stable violation codes — do not invent new ones without spec basis */
919
- export type ViolationCode = 'LOW_CONFIDENCE' | 'HIGH_DRIFT' | 'DENY_PATH_MATCH' | 'MISSING_TESTS' | 'BUNDLE_TOO_LARGE' | 'INSUFFICIENT_COVERAGE' | 'POST_HOC_READS';
1390
+ export type ViolationCode = 'LOW_CONFIDENCE' | 'HIGH_DRIFT' | 'DENY_PATH_MATCH' | 'MISSING_TESTS' | 'BUNDLE_TOO_LARGE' | 'INSUFFICIENT_COVERAGE' | 'POST_HOC_READS' | 'DISCOVERY_STRONG_OVERLAP' | 'DISCOVERY_PROHIBITED_FILE' | 'DISCOVERY_INSERTION_VIOLATION' | 'DISCOVERY_DUPLICATE_DETECTED' | 'DISCOVERY_SYMBOL_GROWTH';
920
1391
  /** A single policy violation */
921
1392
  export interface ViolationV1 {
922
1393
  code: ViolationCode;
@@ -960,6 +1431,10 @@ export interface VerifyReportV1 {
960
1431
  violations: ViolationV1[];
961
1432
  /** Review Intelligence results (present when review intelligence is enabled) */
962
1433
  review_intelligence?: VerifyReviewIntelligenceV1;
1434
+ /** Insertion-point lock violations (present when discovery result is available) */
1435
+ insertion_point_violations?: InsertionPointViolation[];
1436
+ /** Symbol growth report (present when base branch comparison is available) */
1437
+ symbol_growth?: SymbolGrowthReport;
963
1438
  }
964
1439
  /** Review Intelligence section of the verify report */
965
1440
  export interface VerifyReviewIntelligenceV1 {
@@ -1282,68 +1757,687 @@ export interface ReviewConfig {
1282
1757
  /** Whether the gatekeeper hook is enabled. Default: true */
1283
1758
  gatekeeper_enabled: boolean;
1284
1759
  }
1285
- /** Symbol kinds extracted by the SCE symbol graph */
1286
- export type SymbolKind = 'function' | 'class' | 'interface' | 'type' | 'enum' | 'variable';
1287
- /** A single named symbol node in the SCE symbol graph */
1760
+ /** Confidence tier for evidence gate findings */
1761
+ export type EvidenceTier = 'observed' | 'likely' | 'possible';
1762
+ /** Finding type for evidence gate rules */
1763
+ export type FindingType = 'unused_code' | 'untested_surface' | 'broken_wiring' | 'dead_dependency' | 'missing_guard' | 'architectural_violation';
1764
+ /** Type of required check for evidence gates */
1765
+ export type RequiredCheckType = 'grep' | 'ast_reference_check' | 'import_graph_check' | 'test_presence_check' | 'contract_check' | 'routing_check' | 'store_context_check' | 'policy_check';
1766
+ /** A single executable check required before surfacing a finding */
1767
+ export interface RequiredCheck {
1768
+ id: string;
1769
+ description: string;
1770
+ type: RequiredCheckType;
1771
+ /** Shell command to run; use {target} as a placeholder for the file/scope */
1772
+ command?: string;
1773
+ }
1774
+ /** An evidence gate rule that must be satisfied before surfacing a finding type */
1775
+ export interface EvidenceRule {
1776
+ findingType: FindingType;
1777
+ minimumTier: EvidenceTier;
1778
+ requiredChecks: RequiredCheck[];
1779
+ /** Suppress findings below this tier from output */
1780
+ suppressBelowTier?: EvidenceTier;
1781
+ /** Only surface reviewer-visible findings at or above this tier */
1782
+ reviewerVisibleFromTier?: EvidenceTier;
1783
+ }
1784
+ /** The full evidence gate ledger */
1785
+ export interface EvidenceGateLedger {
1786
+ rules: EvidenceRule[];
1787
+ }
1788
+ /** How structural invalidation ripples through the dependency graph */
1789
+ export interface BlastRadius {
1790
+ dependencyDepth: number;
1791
+ invalidatesScopes?: string[];
1792
+ severity: 'narrow' | 'moderate' | 'wide';
1793
+ }
1794
+ /** Rule that triggers invalidation of a clean surface */
1795
+ export interface InvalidationRule {
1796
+ type: 'file_changed' | 'dependency_changed' | 'test_surface_changed' | 'policy_changed';
1797
+ /** File or module that triggers this invalidation when it changes */
1798
+ target?: string;
1799
+ }
1800
+ /** Reason a surface was invalidated */
1801
+ export interface ValidationInvalidationReason {
1802
+ type: 'file_changed' | 'dependency_changed' | 'test_surface_changed' | 'manual_override';
1803
+ detail: string;
1804
+ detectedAt: string;
1805
+ }
1806
+ /** A scope that has been validated and is known-clean */
1807
+ export interface CleanSurfaceRecord {
1808
+ id: string;
1809
+ scopeType: 'file' | 'module' | 'subsystem';
1810
+ scopeId: string;
1811
+ /** sha256 hex hashes keyed by file path */
1812
+ fileHashes: Record<string, string>;
1813
+ dependencyHash?: string;
1814
+ testSurfaceHash?: string;
1815
+ blastRadius?: BlastRadius;
1816
+ lastValidatedAt: string;
1817
+ validationLevel: 'lint' | 'unit' | 'integration' | 'e2e' | 'mixed';
1818
+ status: 'clean' | 'stale' | 'invalidated';
1819
+ invalidationRules: InvalidationRule[];
1820
+ invalidatedBy?: ValidationInvalidationReason[];
1821
+ }
1822
+ /** A round of validation that was run */
1823
+ export interface ValidationRoundRecord {
1824
+ id: string;
1825
+ timestamp: string;
1826
+ scope: {
1827
+ files?: string[];
1828
+ modules?: string[];
1829
+ subsystems?: string[];
1830
+ };
1831
+ validationLevel: 'lint' | 'unit' | 'integration' | 'e2e' | 'mixed';
1832
+ result: 'pass' | 'fail' | 'partial';
1833
+ outputs?: {
1834
+ testsRun?: string[];
1835
+ failures?: string[];
1836
+ notes?: string[];
1837
+ };
1838
+ }
1839
+ /** Tracks which surfaces are clean and recent validation rounds */
1840
+ export interface DeltaValidationLedger {
1841
+ cleanSurfaces: CleanSurfaceRecord[];
1842
+ validationRounds: ValidationRoundRecord[];
1843
+ }
1844
+ /** A single meaning for an ontology concept (handles polysemy) */
1845
+ export interface OntologyMeaning {
1846
+ id: string;
1847
+ label: string;
1848
+ description: string;
1849
+ relatedConcepts: string[];
1850
+ fileHints: string[];
1851
+ confidenceBase?: number;
1852
+ }
1853
+ /** An alias that maps a term to a canonical concept id */
1854
+ export interface OntologyAlias {
1855
+ term: string;
1856
+ conceptId: string;
1857
+ }
1858
+ /** A concept in the product ontology */
1859
+ export interface OntologyConcept {
1860
+ id: string;
1861
+ displayName: string;
1862
+ description: string;
1863
+ meanings: OntologyMeaning[];
1864
+ relatedConceptIds?: string[];
1865
+ fileHints: string[];
1866
+ moduleHints?: string[];
1867
+ docHints?: string[];
1868
+ /** Prompt the agent should surface when the concept is ambiguous */
1869
+ disambiguationPrompt?: string;
1870
+ recencyBoost?: {
1871
+ lastTouchedAt?: string;
1872
+ boostReason?: string;
1873
+ };
1874
+ }
1875
+ /** Full product ontology ledger */
1876
+ export interface ProductOntologyLedger {
1877
+ concepts: OntologyConcept[];
1878
+ aliases: OntologyAlias[];
1879
+ }
1880
+ /** A wiring neighborhood describing structural connections around an anchor */
1881
+ export interface WiringNeighborhood {
1882
+ id: string;
1883
+ anchor: {
1884
+ type: 'file' | 'module' | 'component' | 'service';
1885
+ id: string;
1886
+ };
1887
+ upstream: string[];
1888
+ downstream: string[];
1889
+ sharedContracts?: string[];
1890
+ relatedStores?: string[];
1891
+ relatedContexts?: string[];
1892
+ relatedTests?: string[];
1893
+ /**
1894
+ * Connections that must not be bypassed or casually rewired.
1895
+ * Changing local logic is fine; these structural links are immutable.
1896
+ */
1897
+ immutableWires?: string[];
1898
+ trustLevel: 'low' | 'medium' | 'high';
1899
+ trustReason?: string;
1900
+ notes?: string[];
1901
+ }
1902
+ /** Structural trust ledger: wiring neighborhoods for the repo */
1903
+ export interface StructuralTrustLedger {
1904
+ neighborhoods: WiringNeighborhood[];
1905
+ }
1906
+ /** An accepted change that is part of recent repo truth */
1907
+ export interface AcceptedChangeRecord {
1908
+ id: string;
1909
+ timestamp: string;
1910
+ title: string;
1911
+ summary: string;
1912
+ concepts: string[];
1913
+ files: string[];
1914
+ modules?: string[];
1915
+ status: 'accepted' | 'shipped' | 'validated';
1916
+ source?: 'commit' | 'pr' | 'manual' | 'session';
1917
+ /** 0..1 — higher = more relevant right now */
1918
+ relevanceScore?: number;
1919
+ ttlDays?: number;
1920
+ evidence?: {
1921
+ commitShas?: string[];
1922
+ prNumbers?: string[];
1923
+ testRounds?: string[];
1924
+ };
1925
+ }
1926
+ /** An architecture decision record */
1927
+ export interface ArchitectureDecisionRecord {
1928
+ id: string;
1929
+ timestamp: string;
1930
+ title: string;
1931
+ decision: string;
1932
+ relatedConcepts: string[];
1933
+ affectedAreas: string[];
1934
+ constraints?: string[];
1935
+ supersedes?: string[];
1936
+ relevanceScore?: number;
1937
+ ttlDays?: number;
1938
+ }
1939
+ /** A recently introduced feature */
1940
+ export interface RecentFeatureRecord {
1941
+ id: string;
1942
+ name: string;
1943
+ introducedAt: string;
1944
+ concepts: string[];
1945
+ fileHints: string[];
1946
+ maturity: 'new' | 'stabilizing' | 'stable';
1947
+ relevanceScore?: number;
1948
+ ttlDays?: number;
1949
+ }
1950
+ /** Recent accepted truth ledger */
1951
+ export interface RecentTruthLedger {
1952
+ acceptedChanges: AcceptedChangeRecord[];
1953
+ architectureDecisions: ArchitectureDecisionRecord[];
1954
+ recentFeatures: RecentFeatureRecord[];
1955
+ }
1956
+ /** Top-level CodeLedger memory model */
1957
+ export interface CodeLedgerMemory {
1958
+ version: '1.0';
1959
+ repoId: string;
1960
+ updatedAt: string;
1961
+ recentTruth: RecentTruthLedger;
1962
+ validation: DeltaValidationLedger;
1963
+ ontology: ProductOntologyLedger;
1964
+ structure: StructuralTrustLedger;
1965
+ evidence: EvidenceGateLedger;
1966
+ lessons?: LessonsLedger;
1967
+ metadata?: {
1968
+ generatorVersion?: string;
1969
+ notes?: string;
1970
+ };
1971
+ }
1972
+ /** Ontology expansion section in a broker response */
1973
+ export interface BrokerOntologyExpansion {
1974
+ concepts: string[];
1975
+ meanings?: string[];
1976
+ disambiguationPrompt?: string;
1977
+ }
1978
+ /** Recent truth section in a broker response */
1979
+ export interface BrokerRecentTruth {
1980
+ highlights: string[];
1981
+ acceptedChangeIds?: string[];
1982
+ }
1983
+ /** Safe zone section in a broker response */
1984
+ export interface BrokerSafeZones {
1985
+ scopes: string[];
1986
+ reason?: string;
1987
+ }
1988
+ /** Top-level broker response for task context resolution */
1989
+ export interface BrokerTaskContextResponse {
1990
+ version: '1.0';
1991
+ taskText: string;
1992
+ normalizedIntent?: {
1993
+ operation?: string;
1994
+ entities?: string[];
1995
+ };
1996
+ ontologyExpansion: BrokerOntologyExpansion;
1997
+ recentTruth: BrokerRecentTruth;
1998
+ safeZones: BrokerSafeZones;
1999
+ relevantFiles: string[];
2000
+ relevantDocs?: string[];
2001
+ preamble: string;
2002
+ }
2003
+ /** Broker response for validation status of a target */
2004
+ export interface BrokerValidationResponse {
2005
+ target: string;
2006
+ status: 'clean' | 'stale' | 'invalidated' | 'unknown';
2007
+ validationLevel?: string;
2008
+ lastValidatedAt?: string;
2009
+ invalidatedBy?: string[];
2010
+ blastRadius?: {
2011
+ dependencyDepth: number;
2012
+ invalidatesScopes?: string[];
2013
+ severity: 'narrow' | 'moderate' | 'wide';
2014
+ };
2015
+ }
2016
+ /** Broker response for structural neighborhood lookup */
2017
+ export interface BrokerNeighborhoodResponse {
2018
+ target: string;
2019
+ upstream: string[];
2020
+ downstream: string[];
2021
+ immutableWires?: string[];
2022
+ relatedContracts?: string[];
2023
+ relatedTests?: string[];
2024
+ trustLevel?: 'low' | 'medium' | 'high';
2025
+ summary?: string;
2026
+ }
2027
+ /** Broker response for evidence requirements */
2028
+ export interface BrokerEvidenceResponse {
2029
+ findingType: string;
2030
+ requiredChecks: Array<{
2031
+ id: string;
2032
+ description: string;
2033
+ type: string;
2034
+ command?: string;
2035
+ }>;
2036
+ minimumTier?: string;
2037
+ reviewerVisibleFromTier?: string;
2038
+ }
2039
+ /** Broker response for completion state */
2040
+ export interface BrokerCompletionResponse {
2041
+ taskId?: string;
2042
+ completionState?: string;
2043
+ verifiedClaims?: string[];
2044
+ remainingUnchecked?: string[];
2045
+ blockers?: string[];
2046
+ summary?: string;
2047
+ }
2048
+ /** Architecture layer classification for intent decomposition */
2049
+ export type ArchitectureLayer = 'types' | 'routes' | 'services' | 'tests' | 'config' | 'infra' | 'models' | 'unknown';
2050
+ /** Structured intent object produced by IOLE intent decomposition */
2051
+ export interface IntentObject {
2052
+ domain: string;
2053
+ operation: 'bugfix' | 'feature' | 'refactor' | 'test_update' | 'config' | 'unknown';
2054
+ layer: ArchitectureLayer;
2055
+ entities: string[];
2056
+ constraints: string[];
2057
+ category: string;
2058
+ intentConfidence: number;
2059
+ raw_task: string;
2060
+ decomposed_at: string;
2061
+ }
2062
+ /** Overlap classification from discovery gate */
2063
+ export type OverlapClassification = 'FEATURE_ALREADY_EXISTS' | 'STRONG_OVERLAP' | 'PARTIAL_OVERLAP' | 'NO_MATERIAL_OVERLAP';
2064
+ /** Implementation posture recommendation from discovery gate */
2065
+ export type ImplementationPosture = 'WRAP_EXISTING_SYSTEM' | 'EXTEND_EXISTING_SYSTEM' | 'ADD_ADAPTER_LAYER' | 'BUILD_NEW_CAPABILITY';
2066
+ /** Go/no-go verdict from discovery gate */
2067
+ export type DiscoveryVerdict = 'NO_GO_ALREADY_EXISTS' | 'GO_EXTENSION_ONLY' | 'GO_GENUINELY_NEW';
2068
+ /** A file match found during discovery scanning */
2069
+ export interface DiscoveryMatch {
2070
+ file: string;
2071
+ system: string;
2072
+ description: string;
2073
+ similarity: number;
2074
+ overlap: 'direct' | 'indirect';
2075
+ matched_symbols: string[];
2076
+ kind: string;
2077
+ why_relevant: string;
2078
+ centrality: number;
2079
+ }
2080
+ /** Source of truth identification from discovery */
2081
+ export interface DiscoverySourceOfTruth {
2082
+ system: string;
2083
+ path: string;
2084
+ confidence: number;
2085
+ justification: string;
2086
+ competitors: Array<{
2087
+ system: string;
2088
+ path: string;
2089
+ similarity: number;
2090
+ }>;
2091
+ fragmented: boolean;
2092
+ }
2093
+ /** Blast radius analysis for a discovery target */
2094
+ export interface DiscoveryBlastRadius {
2095
+ system: string;
2096
+ path: string;
2097
+ direct_dependents: string[];
2098
+ transitive_dependents: string[];
2099
+ shared_modules: string[];
2100
+ impacted_tests: string[];
2101
+ risk: 'low' | 'medium' | 'high';
2102
+ }
2103
+ /** Gap analysis from discovery gate */
2104
+ export interface DiscoveryGapAnalysis {
2105
+ coverage_estimate: number;
2106
+ missing_capabilities: string[];
2107
+ recommended_extensions: Array<{
2108
+ target: string;
2109
+ description: string;
2110
+ }>;
2111
+ extension_targets: string[];
2112
+ warning: string | null;
2113
+ existing_exports: string[];
2114
+ }
2115
+ /** Full result from a discovery gate run */
2116
+ export interface DiscoveryResult {
2117
+ requested_capability: string;
2118
+ intent: IntentObject;
2119
+ keywords_searched: string[];
2120
+ files_scanned: number;
2121
+ matches: DiscoveryMatch[];
2122
+ related_standards: Array<{
2123
+ helper_name: string;
2124
+ example_paths: string[];
2125
+ usage_count: number;
2126
+ }>;
2127
+ overlap: OverlapClassification;
2128
+ duplication_risk: string;
2129
+ posture: ImplementationPosture;
2130
+ verdict: DiscoveryVerdict;
2131
+ must_reuse: string[];
2132
+ must_not_create: string[];
2133
+ insertion_points: string[];
2134
+ prohibited_files: string[];
2135
+ source_of_truth: DiscoverySourceOfTruth | null;
2136
+ blast_radius: DiscoveryBlastRadius[];
2137
+ gap_analysis: DiscoveryGapAnalysis;
2138
+ duration_ms: number;
2139
+ }
2140
+ /** An insertion-point lock violation detected during PR verification */
2141
+ export interface InsertionPointViolation {
2142
+ file: string;
2143
+ violation_type: 'ghost_file' | 'outside_insertion_point' | 'prohibited_path';
2144
+ severity: 'P1' | 'P2';
2145
+ reason: string;
2146
+ similar_to?: string;
2147
+ shared_symbols?: string[];
2148
+ }
2149
+ /** Per-file symbol growth entry */
2150
+ export interface SymbolGrowthEntry {
2151
+ file: string;
2152
+ added: string[];
2153
+ removed: string[];
2154
+ modified: string[];
2155
+ net: number;
2156
+ }
2157
+ /** Symbol growth analysis report from PR verification */
2158
+ export interface SymbolGrowthReport {
2159
+ total_symbols_added: number;
2160
+ total_symbols_removed: number;
2161
+ total_symbols_modified: number;
2162
+ net_growth: number;
2163
+ scope_creep_detected: boolean;
2164
+ threshold: number;
2165
+ per_file: SymbolGrowthEntry[];
2166
+ api_surface_explosions: string[];
2167
+ }
2168
+ /** Task type classification for CIC neighborhood selection */
2169
+ export type CICTaskType = 'release_pipeline' | 'wizard_ux' | 'ci_change' | 'feature' | 'bugfix' | 'refactor' | 'docs' | 'unknown';
2170
+ /** Completion state in the CIC promotion ladder */
2171
+ export type CompletionState = 'incomplete' | 'edited' | 'implemented' | 'wired' | 'verified' | 'audited' | 'release_safe';
2172
+ /** Type of evidence collected during a CIC run (distinct from EvidenceTier) */
2173
+ export type EvidenceType = 'test_result' | 'execution_log' | 'validation_output' | 'ci_pass' | 'build_success' | 'lint_pass';
2174
+ /** A single claim made by the agent about what it completed */
2175
+ export interface CompletionClaim {
2176
+ id: string;
2177
+ description: string;
2178
+ files: string[];
2179
+ verified: boolean;
2180
+ evidence?: CompletionEvidence[];
2181
+ }
2182
+ /** Evidence collected to support a completion claim */
2183
+ export interface CompletionEvidence {
2184
+ type: EvidenceType;
2185
+ content: string;
2186
+ collected_at: ISODateTime;
2187
+ }
2188
+ /** A mismatch between what the agent claimed and what exists in the repo */
2189
+ export interface RealityMismatch {
2190
+ claim: string;
2191
+ expectedTarget: string;
2192
+ actualDiffPresence: boolean;
2193
+ severity: 'critical' | 'major' | 'minor';
2194
+ }
2195
+ /** A warning that the agent's summary terms drift from the actual edits */
2196
+ export interface SemanticDriftWarning {
2197
+ term: string;
2198
+ expectedConcept: string;
2199
+ actualFiles: string[];
2200
+ detail: string;
2201
+ }
2202
+ /** An intentional omission declared by the agent */
2203
+ export interface IntentionalOmission {
2204
+ id: string;
2205
+ description: string;
2206
+ scope: string[];
2207
+ reason: string;
2208
+ }
2209
+ /** Result of a self-audit check */
2210
+ export interface SelfAuditResult {
2211
+ type: 'claim_vs_repo' | 'doc_consistency' | 'cross_reference' | 'semantic_drift' | 'release_readiness';
2212
+ outcome: 'pass' | 'warn' | 'fail';
2213
+ detail: string;
2214
+ }
2215
+ /** A surface checked during CIC neighborhood analysis */
2216
+ export interface NeighborhoodSurface {
2217
+ name: string;
2218
+ paths: string[];
2219
+ required: boolean;
2220
+ status: 'changed' | 'checked' | 'not_checked' | 'stale' | 'intentionally_skipped';
2221
+ omission_reason?: string;
2222
+ }
2223
+ /** Assessment of confidence level vs evidence strength */
2224
+ export interface ConfidenceAssessment {
2225
+ claimConfidence: 'low' | 'medium' | 'high';
2226
+ evidenceStrength: 'weak' | 'moderate' | 'strong';
2227
+ mismatch: boolean;
2228
+ note?: string;
2229
+ }
2230
+ /** Full completion record produced by a CIC run */
2231
+ export interface CompletionRecord {
2232
+ run_id: string;
2233
+ checked_at: ISODateTime;
2234
+ task: string;
2235
+ taskType: CICTaskType;
2236
+ completionState: CompletionState;
2237
+ claims: CompletionClaim[];
2238
+ diffFiles: string[];
2239
+ neighborhood: NeighborhoodSurface[];
2240
+ audits: SelfAuditResult[];
2241
+ remainingUnchecked: string[];
2242
+ completed: string[];
2243
+ intentionalOmissions?: IntentionalOmission[];
2244
+ confidenceAssessment: ConfidenceAssessment;
2245
+ semanticDriftWarnings?: SemanticDriftWarning[];
2246
+ realityMismatches?: RealityMismatch[];
2247
+ guards?: GuardrailResult[];
2248
+ triggeredLessons?: Array<{
2249
+ lessonId: string;
2250
+ title: string;
2251
+ severity: string;
2252
+ detail: string;
2253
+ }>;
2254
+ }
2255
+ /** A summary entry appended to the completion history ledger */
2256
+ export interface CompletionHistoryEntry {
2257
+ run_id: string;
2258
+ checked_at: ISODateTime;
2259
+ task: string;
2260
+ taskType: CICTaskType;
2261
+ completionState: CompletionState;
2262
+ claim_count: number;
2263
+ verified_claim_count: number;
2264
+ mismatch_count: number;
2265
+ drift_warning_count: number;
2266
+ audit_pass_count: number;
2267
+ audit_fail_count: number;
2268
+ }
2269
+ /** Category of engineering guardrail */
2270
+ export type GuardrailCategory = 'rename_integrity' | 'export_collision' | 'workspace_validation' | 'stale_artifact' | 'release_tag' | 'unused_parameter' | 'adversarial_trigger';
2271
+ /** Result of a single guardrail check */
2272
+ export interface GuardrailResult {
2273
+ id: string;
2274
+ category: GuardrailCategory;
2275
+ outcome: 'pass' | 'warn' | 'fail';
2276
+ detail: string;
2277
+ remediation?: string;
2278
+ files?: string[];
2279
+ }
2280
+ /** Input context for guardrail evaluation */
2281
+ export interface GuardrailInput {
2282
+ cwd: string;
2283
+ task: string;
2284
+ taskType: CICTaskType;
2285
+ diffFiles: string[];
2286
+ claims: CompletionClaim[];
2287
+ }
2288
+ /** Aggregated guardrails report */
2289
+ export interface GuardrailsReport {
2290
+ guards: GuardrailResult[];
2291
+ /** Number of guards that passed */
2292
+ pass_count: number;
2293
+ /** Number of guards that warned */
2294
+ warn_count: number;
2295
+ /** Number of guards that failed */
2296
+ fail_count: number;
2297
+ /** Whether any guard failed (blocks promotion) */
2298
+ blocks_promotion: boolean;
2299
+ }
2300
+ /** Lesson category classifying the engineering failure pattern */
2301
+ export type LessonCategory = 'rename_safety' | 'export_surface' | 'workspace_scope' | 'artifact_freshness' | 'typing_contract' | 'tsconfig_boundary' | 'branch_delivery' | 'release_integrity' | 'audit_trigger' | 'parameter_safety' | 'golden_path' | 'other';
2302
+ /** Lesson verification status — only 'verified' lessons influence CIC blocking */
2303
+ export type LessonStatus = 'proposed' | 'verified' | 'deprecated';
2304
+ /** Source that originated the lesson */
2305
+ export type LessonSource = 'manual' | 'audit' | 'completion' | 'guardrail' | 'session' | 'ci';
2306
+ /** Criteria that trigger a lesson when matched against a change set */
2307
+ export interface LessonTriggerCriteria {
2308
+ files_changed?: string[];
2309
+ content_contains?: string[];
2310
+ content_not_contains?: string[];
2311
+ file_types?: string[];
2312
+ task_patterns?: string[];
2313
+ tsconfig_conditions?: {
2314
+ cross_package_includes?: boolean;
2315
+ missing_references?: boolean;
2316
+ };
2317
+ }
2318
+ /** A repo lesson — an encoded engineering failure/success pattern */
2319
+ export interface RepoLesson {
2320
+ id: string;
2321
+ title: string;
2322
+ summary: string;
2323
+ category: LessonCategory;
2324
+ severity: 'low' | 'medium' | 'high';
2325
+ status: LessonStatus;
2326
+ source: LessonSource;
2327
+ triggerCriteria: LessonTriggerCriteria;
2328
+ concepts?: string[];
2329
+ taskTypes?: string[];
2330
+ fileHints?: string[];
2331
+ packageHints?: string[];
2332
+ recommendedChecks?: string[];
2333
+ recommendedCommands?: string[];
2334
+ rationale: string;
2335
+ createdAt: string;
2336
+ updatedAt?: string;
2337
+ active: boolean;
2338
+ }
2339
+ /** Event type for lesson lifecycle tracking */
2340
+ export type LessonEventType = 'created' | 'updated' | 'triggered' | 'ignored' | 'escalated' | 'resolved';
2341
+ /** A lesson event recording a trigger, escalation, or resolution */
2342
+ export interface LessonEvent {
2343
+ id: string;
2344
+ lessonId: string;
2345
+ timestamp: string;
2346
+ eventType: LessonEventType;
2347
+ riskMultiplier: number;
2348
+ detail: string;
2349
+ relatedFiles?: string[];
2350
+ }
2351
+ /** Full lessons ledger */
2352
+ export interface LessonsLedger {
2353
+ lessons: RepoLesson[];
2354
+ events: LessonEvent[];
2355
+ }
2356
+ /** Release readiness state */
2357
+ export type ReleaseState = 'not_ready' | 'ready_conditional' | 'ready' | 'ready_hardened';
2358
+ /** Severity of a release finding */
2359
+ export type ReleaseFindingSeverity = 'critical' | 'high' | 'medium' | 'low' | 'info';
2360
+ /** Category of a release finding */
2361
+ export type ReleaseFindingCategory = 'git_integrity' | 'core_tests' | 'full_suite' | 'binary_parity' | 'cli_wiring' | 'docs_alignment' | 'open_loop' | 'workspace_alignment' | 'lesson_stress';
2362
+ /** A single finding from a release check */
2363
+ export interface ReleaseFinding {
2364
+ id: string;
2365
+ category: ReleaseFindingCategory;
2366
+ severity: ReleaseFindingSeverity;
2367
+ title: string;
2368
+ detail: string;
2369
+ remediation?: string;
2370
+ files?: string[];
2371
+ isBaseline?: boolean;
2372
+ }
2373
+ /** Per-category confidence scores (0-1) */
2374
+ export interface ReleaseCategoryScores {
2375
+ gitIntegrity: number;
2376
+ coreTests: number;
2377
+ fullSuite: number;
2378
+ binaryParity: number;
2379
+ cliWiring: number;
2380
+ docsAlignment: number;
2381
+ openLoopRisk: number;
2382
+ workspaceAlignment: number;
2383
+ }
2384
+ /** Full release check result */
2385
+ export interface ReleaseCheckResult {
2386
+ releaseState: ReleaseState;
2387
+ confidenceScore: number;
2388
+ categoryScores: ReleaseCategoryScores;
2389
+ findings: ReleaseFinding[];
2390
+ verified: string[];
2391
+ remainingUnchecked: string[];
2392
+ blockers: string[];
2393
+ recommendations: string[];
2394
+ knownDebt: ReleaseFinding[];
2395
+ regressions: ReleaseFinding[];
2396
+ shouldBlockCI: boolean;
2397
+ checkedAt: string;
2398
+ version: string;
2399
+ }
2400
+ export type SymbolKind = 'function' | 'class' | 'interface' | 'type' | 'enum';
1288
2401
  export interface SymbolNode {
1289
- /** Stable ID: "<file>::<symbolName>" */
1290
2402
  id: string;
1291
- /** Exported symbol name */
1292
2403
  name: string;
1293
2404
  kind: SymbolKind;
1294
- /** Absolute file path */
1295
2405
  file: string;
1296
- /** 1-based source line of the definition */
1297
2406
  line: number;
1298
- /** Symbols this node imports/depends on (by ID) */
1299
2407
  dependencies: string[];
1300
- /** Symbols that depend on this node (by ID, populated after full graph build) */
1301
2408
  dependents: string[];
1302
2409
  }
1303
- /** Symbol-level dependency graph produced by the SCE */
1304
2410
  export interface SymbolGraph {
1305
- /** Map of symbol ID → SymbolNode */
1306
2411
  nodes: Record<string, SymbolNode>;
1307
2412
  file_count: number;
1308
2413
  symbol_count: number;
1309
2414
  }
1310
- /** A single symbol-level slice entry in the MSCS */
1311
2415
  export interface CodeSlice {
1312
2416
  symbol_id: string;
1313
2417
  symbol_name: string;
1314
2418
  symbol_kind: SymbolKind;
1315
2419
  file: string;
1316
2420
  line: number;
1317
- /** Extracted source lines around the symbol definition */
1318
2421
  excerpt: string;
1319
- /** Relevance of this symbol to the task keywords [0,1] */
1320
2422
  relevance_score: number;
1321
- /** IDs of symbols this slice depends on */
1322
2423
  dependency_ids: string[];
1323
2424
  }
1324
- /** Minimal Sufficient Code Slice — output of SCE slice builder */
1325
2425
  export interface MinimalSufficientCodeSlice {
1326
2426
  task_keywords: string[];
1327
- /** Seed symbol IDs that directly matched task keywords */
1328
2427
  seed_symbols: string[];
1329
2428
  slices: CodeSlice[];
1330
2429
  file_count: number;
1331
2430
  symbol_count: number;
1332
- /** Maximum dependency depth traversed to build this slice */
1333
2431
  dependency_depth_reached: number;
1334
2432
  }
1335
- /** Stable task intent signature derived from the task prompt */
1336
2433
  export interface IntentSignature {
1337
- /** SHA-256 truncated to 16 hex chars — stable across sessions for same task */
1338
2434
  hash: string;
1339
2435
  task_normalized: string;
1340
2436
  keywords: string[];
1341
2437
  category: 'bug_fix' | 'feature_add' | 'refactor' | 'test_update' | 'config' | 'unknown';
1342
- derived_at: ISODateTime;
2438
+ derived_at: string;
1343
2439
  }
1344
- /** Kind of execution failure */
1345
- export type FailureKind = 'test_failure' | 'build_error' | 'type_error' | 'runtime_error' | 'unknown';
1346
- /** Structured failure vector parsed from agent execution output */
2440
+ export type FailureKind = 'test_failure' | 'build_error' | 'unknown';
1347
2441
  export interface FailureVector {
1348
2442
  kind: FailureKind;
1349
2443
  failures: Array<{
@@ -1353,164 +2447,73 @@ export interface FailureVector {
1353
2447
  line?: number;
1354
2448
  symbol?: string;
1355
2449
  }>;
1356
- /** Source files implicated by stack traces or test output */
1357
2450
  implicated_files: string[];
1358
- /** Symbol names referenced in error messages */
1359
2451
  implicated_symbols: string[];
1360
- /** FNV-1a hash of raw output (for deduplication) */
1361
2452
  raw_output_hash: string;
1362
- parsed_at: ISODateTime;
2453
+ parsed_at: string;
1363
2454
  }
1364
- /** Context expansion levels — higher levels include more context */
1365
2455
  export type ExpansionLevel = 1 | 2 | 3 | 4;
1366
- /** A single entry in the expansion ladder log */
1367
- export interface ExpansionEscalation {
1368
- from_level: ExpansionLevel;
1369
- to_level: ExpansionLevel;
1370
- at_iteration: number;
1371
- reason: string;
1372
- implicated_files: string[];
1373
- }
1374
- /** Running state of the IOLE expansion ladder */
1375
2456
  export interface ExpansionLadderState {
1376
2457
  intent_hash: string;
1377
2458
  task: string;
1378
2459
  current_level: ExpansionLevel;
1379
- max_level: 4;
2460
+ max_level: number;
1380
2461
  iteration_count: number;
1381
2462
  failure_count: number;
1382
- escalation_log: ExpansionEscalation[];
2463
+ escalation_log: Array<{
2464
+ from_level: number;
2465
+ to_level: ExpansionLevel;
2466
+ at_iteration: number;
2467
+ reason: string;
2468
+ implicated_files: string[];
2469
+ }>;
1383
2470
  resolved: boolean;
1384
2471
  }
1385
- /** Outcome record for a single agent iteration */
1386
2472
  export interface OutcomeRecord {
1387
2473
  task_id: string;
1388
2474
  iteration: number;
1389
2475
  passed: boolean;
1390
- /** Context expansion level used during this iteration */
1391
2476
  context_level: number;
1392
- /** Severity score of failure [0,1] — 0 = no failure, 1 = catastrophic */
1393
2477
  failure_severity: number;
1394
- recorded_at: ISODateTime;
2478
+ recorded_at: string;
1395
2479
  }
1396
- /** Aggregate outcome score computed from multiple outcome records */
1397
2480
  export interface OutcomeScore {
1398
2481
  pass_rate: number;
1399
2482
  total_iterations: number;
1400
2483
  first_pass_rate: number;
1401
2484
  stability_signal: 'stable' | 'oscillating' | 'degrading' | 'improving' | 'unknown';
1402
2485
  improvement_trend: 'improving' | 'flat' | 'degrading';
1403
- /** Distribution of retry counts: { retries: count } */
1404
2486
  retry_distribution: Record<number, number>;
1405
- last_updated: ISODateTime;
1406
- }
1407
- /** A layer in the architectural graph */
1408
- export type ArchitectureLayer = 'types' | 'models' | 'services' | 'routes' | 'tests' | 'config' | 'infra' | 'unknown';
1409
- /** A Mermaid diagram produced by the AIL */
1410
- export interface MermaidGraph {
1411
- /** Diagram type: flowchart, graph, etc. */
1412
- diagram_type: 'flowchart' | 'graph';
1413
- /** Complete Mermaid markup ready for rendering */
1414
- markup: string;
1415
- /** Files included as nodes in the diagram */
1416
- included_files: string[];
1417
- generated_at: ISODateTime;
1418
- }
1419
- /** Context diff between two bundle iterations */
1420
- export interface ContextDiff {
1421
- from_bundle_id: string;
1422
- to_bundle_id: string;
1423
- /** Files added to the context in this iteration */
1424
- added: string[];
1425
- /** Files removed from the context */
1426
- removed: string[];
1427
- /** Files that stayed in context but changed relevance score */
1428
- score_changed: Array<{
1429
- path: string;
1430
- from_score: number;
1431
- to_score: number;
1432
- }>;
1433
- token_delta: number;
1434
- generated_at: ISODateTime;
1435
- }
1436
- /** Severity level of a validation issue */
1437
- export type ValidationSeverity = 'error' | 'warning' | 'info';
1438
- /** A single execution-aware validation issue */
1439
- export interface ValidationIssue {
1440
- code: string;
1441
- severity: ValidationSeverity;
1442
- message: string;
1443
- file?: string;
1444
- symbol?: string;
1445
- }
1446
- /** Result of execution-aware context validation */
1447
- export interface ValidationResult {
1448
- passed: boolean;
1449
- issues: ValidationIssue[];
1450
- /** Files that have missing or unresolvable type imports */
1451
- missing_dependencies: string[];
1452
- /** Files with no linked test coverage */
1453
- uncovered_files: string[];
1454
- /** Architecture boundary violations (importing across disallowed layers) */
1455
- boundary_violations: Array<{
1456
- from: string;
1457
- to: string;
1458
- reason: string;
1459
- }>;
1460
- validated_at: ISODateTime;
2487
+ last_updated: string;
1461
2488
  }
1462
- /** A single execution cycle recorded in the ECL-lite ledger */
1463
2489
  export interface EclLiteEntry {
1464
- /** Stable intent hash from IntentSignature */
1465
2490
  intentSignature: string;
1466
- /** Unix timestamp (ms) */
1467
2491
  timestamp: number;
1468
- /** Files included in the context bundle */
1469
2492
  files: string[];
1470
- /** Symbol names included in any MSCS slice */
1471
2493
  symbols: string[];
1472
- /** Expansion ladder level used (1–4) */
1473
2494
  expansionLevel: number;
1474
2495
  outcome: 'success' | 'failure';
1475
- /** Condensed failure vector (kind + implicated files) */
1476
2496
  failureVector?: {
1477
2497
  kind: string;
1478
2498
  implicated_files: string[];
1479
2499
  };
1480
- /** SHA-256 hash of the bundle file list (for dedup) */
1481
2500
  contextHash: string;
1482
- /** CCS score at time of execution (0–1) */
1483
2501
  confidenceScore: number;
1484
- /**
1485
- * Deterministic category from IntentObject: "{domain}_{operation}" or "general_task".
1486
- * Optional for backward compatibility with pre-v2.1.1 ledger entries.
1487
- */
1488
2502
  intentCategory?: string;
1489
2503
  }
1490
- /** Deterministic integer weight entry for the success/failure index */
1491
2504
  export interface EclWeightEntry {
1492
- /** Intent signature this entry tracks */
1493
2505
  intentSignature: string;
1494
- /** Cumulative successes (each success increments by 1) */
1495
2506
  successWeight: number;
1496
- /** Cumulative failures (each failure increments by 1) */
1497
2507
  failureWeight: number;
1498
2508
  lastUpdated: number;
1499
2509
  }
1500
- /** A file that frequently appears in failure vectors — a failure hotspot */
1501
2510
  export interface FailureHotspot {
1502
2511
  file: string;
1503
2512
  failureCount: number;
1504
2513
  successCount: number;
1505
- /** failureCount / (failureCount + successCount) */
1506
2514
  implicationRate: number;
1507
- /**
1508
- * Unix timestamp (ms) of the most recent failure implicating this file.
1509
- * Used for recency decay: recent failures have higher boost than stale ones.
1510
- */
1511
2515
  lastFailureTimestamp: number;
1512
2516
  }
1513
- /** Summary of the ECL-lite ledger state */
1514
2517
  export interface EclLiteStatus {
1515
2518
  entry_count: number;
1516
2519
  success_count: number;
@@ -1521,166 +2524,135 @@ export interface EclLiteStatus {
1521
2524
  ledger_path: string;
1522
2525
  last_entry_at: ISODateTime | null;
1523
2526
  }
1524
- /** Recommendation from the CCS assessment */
1525
- export type CcsRecommendation = 'proceed' | 'expand' | 'block';
1526
- /** Per-factor breakdown of the Context Confidence Score */
1527
2527
  export interface CcsFactors {
1528
- /** Fraction of imported deps present in the bundle [0,1] */
1529
2528
  dependencyCoverage: number;
1530
- /** Fraction of bundle source files with mapped tests [0,1] */
1531
2529
  testCoverageMapping: number;
1532
- /** Historical pass rate for this intent type from ECL-lite [0,1] */
1533
2530
  historicalSuccessRate: number;
1534
- /** Fraction of task keywords matched by bundle symbols [0,1] */
1535
2531
  symbolCompleteness: number;
1536
- /** Penalty applied based on current expansion level (L1=0, L4=0.3) */
1537
2532
  expansionLevelPenalty: number;
1538
- /**
1539
- * Number of ledger entries used to compute historicalSuccessRate.
1540
- * Low sample sizes reduce the weight of the historical factor to avoid
1541
- * early-data instability (< 5 → weight 0, 5–19 → scaled, ≥ 20 → full).
1542
- */
1543
2533
  historySampleSize: number;
1544
- /**
1545
- * Effective weight applied to the historical success factor after maturity scaling.
1546
- * Between 0 (empty/tiny ledger) and the configured W_HISTORICAL_SUCCESS (0.20).
1547
- */
1548
2534
  adjustedHistoricalWeight: number;
1549
2535
  }
1550
- /** Full Context Confidence Score assessment */
2536
+ export type CcsRecommendation = 'proceed' | 'expand' | 'block';
1551
2537
  export interface ContextConfidenceScore {
1552
- /** Weighted composite score [0,1] */
1553
2538
  score: number;
1554
2539
  level: 'high' | 'medium' | 'low';
1555
2540
  factors: CcsFactors;
1556
2541
  recommendation: CcsRecommendation;
1557
- /** Suggested expansion level when recommendation = 'expand' */
1558
2542
  suggestedExpansionLevel?: number;
1559
- /** Human-readable issues explaining score deductions */
1560
2543
  issues: string[];
1561
- computed_at: ISODateTime;
1562
- }
1563
- /** Structured decomposition of a task prompt — no embeddings, pure keyword parsing */
1564
- export interface IntentObject {
1565
- /** Primary domain inferred from task (e.g., "auth", "api", "database", "ui") */
1566
- domain: string;
1567
- /** Operation type */
1568
- operation: 'bugfix' | 'feature' | 'refactor' | 'test_update' | 'config' | 'unknown';
1569
- /** Architectural layer the task targets */
1570
- layer: ArchitectureLayer;
1571
- /** Specific entities extracted: function names, module names, type names */
1572
- entities: string[];
1573
- /** Inferred constraints: "no breaking changes", "must keep backward compat", etc. */
1574
- constraints: string[];
1575
- /**
1576
- * Deterministic category: "{domain}_{operation}" (e.g., "auth_bugfix", "api_feature").
1577
- * Falls back to "general_task" when domain or operation is unknown.
1578
- * Used for aggregated historical success lookups and hotspot grouping.
1579
- */
1580
- category: string;
1581
- /**
1582
- * Extraction confidence [0,1]. Low values (< 0.4) indicate ambiguous input
1583
- * where domain/operation fell back to defaults. Used by CCS to apply a small
1584
- * confidence penalty when intent structure is unclear.
1585
- */
1586
- intentConfidence: number;
1587
- /** Raw task string this was decomposed from */
1588
- raw_task: string;
1589
- decomposed_at: ISODateTime;
2544
+ computed_at: string;
1590
2545
  }
1591
- /**
1592
- * Per-factor breakdown for an Intent Sufficiency Check.
1593
- * Each score is [0,1]; the weighted composite produces IntentSufficiencyCheck.score.
1594
- */
1595
2546
  export interface IntentSufficiencyFactors {
1596
- /**
1597
- * Token signal score [0,1].
1598
- * Penalizes ultra-short prompts (< 3 tokens) and rewards richer descriptions.
1599
- * Weight: 0.20
1600
- */
1601
2547
  tokenSignalScore: number;
1602
- /**
1603
- * Operation clarity score [0,1].
1604
- * 1.0 when a clear action verb (fix, add, refactor, …) is detected; 0.0 otherwise.
1605
- * Weight: 0.30
1606
- */
1607
2548
  operationClarityScore: number;
1608
- /**
1609
- * Domain clarity score [0,1].
1610
- * 1.0 when a recognisable domain keyword (auth, api, database, …) is present.
1611
- * Weight: 0.25
1612
- */
1613
2549
  domainClarityScore: number;
1614
- /**
1615
- * Target specificity score [0,1].
1616
- * Rewards naming concrete targets: file paths, module names, function names, quoted
1617
- * identifiers, or camelCase/snake_case tokens.
1618
- * Weight: 0.15
1619
- */
1620
2550
  targetSpecificityScore: number;
1621
- /**
1622
- * Constraint presence score [0,1].
1623
- * 1.0 when scope or quality constraints are present (e.g., "without breaking …",
1624
- * "must keep backward compat", "in packages/…").
1625
- * Weight: 0.10
1626
- */
1627
2551
  constraintPresenceScore: number;
1628
2552
  }
1629
- /**
1630
- * Result of an Intent Sufficiency Check.
1631
- *
1632
- * ISC is the PRE-CONTEXT certification layer — it answers:
1633
- * "Is this task prompt specific enough to justify context construction?"
1634
- *
1635
- * Decision thresholds:
1636
- * SUFFICIENT ≥ 0.75 — proceed normally
1637
- * WEAK 0.50–0.74 — proceed with -0.05 CCS penalty
1638
- * INSUFFICIENT < 0.50 — block context construction; surface recommendations
1639
- */
1640
2553
  export interface IntentSufficiencyCheck {
1641
- /** Weighted composite score [0,1] */
1642
2554
  score: number;
1643
- /** Gate decision */
1644
2555
  decision: 'SUFFICIENT' | 'WEAK' | 'INSUFFICIENT';
1645
- /** Per-factor breakdown */
1646
2556
  factors: IntentSufficiencyFactors;
1647
- /** Human-readable issues explaining score deductions */
1648
2557
  issues: string[];
1649
- /** Actionable suggestions to improve the prompt */
1650
2558
  recommendations: string[];
1651
- /** The operation keyword detected, if any */
1652
2559
  detectedOperation?: string;
1653
- /** The domain keyword detected, if any */
1654
2560
  detectedDomain?: string;
1655
- /** Specific target tokens detected (file paths, identifiers, module names) */
1656
2561
  detectedTargets?: string[];
1657
2562
  }
1658
- /** An entry in the team-shared context ledger (team-ledger/entries.jsonl). */
2563
+ export type InterventionCategory = 'drift_spike' | 'duplication_pressure' | 'governance_breakdown' | 'architectural_violation' | 'test_gap' | 'scope_creep' | 'sot_instability' | 'coverage_gap' | 'extension_failure';
2564
+ export interface AggregatedSignal {
2565
+ id: string;
2566
+ source: 'drift' | 'review_intelligence' | 'discovery' | 'layer_d' | 'policy';
2567
+ severity: 'critical' | 'high' | 'medium' | 'low';
2568
+ category: InterventionCategory;
2569
+ description: string;
2570
+ affected_files: string[];
2571
+ timestamp: number;
2572
+ metadata?: Record<string, unknown>;
2573
+ }
2574
+ export interface EscalationResult {
2575
+ level: 'none' | 'advisory' | 'warning' | 'blocking';
2576
+ reason: string;
2577
+ compound_escalation: boolean;
2578
+ signal_summary: Record<string, number>;
2579
+ }
2580
+ export type InterventionPriority = 'critical' | 'high' | 'medium' | 'low';
2581
+ export interface Intervention {
2582
+ id: string;
2583
+ priority: InterventionPriority;
2584
+ title: string;
2585
+ description: string;
2586
+ action_type: 'refactor' | 'consolidate_duplicates' | 'update_policy' | 'fix_violation' | 'add_test' | 'extend_existing';
2587
+ category: InterventionCategory;
2588
+ affected_files: string[];
2589
+ affected_systems: string[];
2590
+ suggested_fix: string;
2591
+ suggested_actions: string[];
2592
+ estimated_impact: number;
2593
+ agent_template?: string;
2594
+ apply_command?: string;
2595
+ }
2596
+ export interface FileReservation {
2597
+ file: string;
2598
+ agentId: string;
2599
+ claimedAt: number;
2600
+ expiresAt: number;
2601
+ active: boolean;
2602
+ }
2603
+ export interface TaskPartition {
2604
+ agentId: string;
2605
+ files: string[];
2606
+ dependsOn: string[];
2607
+ }
2608
+ export interface ReservationResult {
2609
+ granted: boolean;
2610
+ reservation?: FileReservation;
2611
+ heldBy?: string;
2612
+ heldSince?: number;
2613
+ }
2614
+ export interface OrchestrationState {
2615
+ reservations: FileReservation[];
2616
+ partitions: TaskPartition[];
2617
+ dependencyOrder: string[];
2618
+ updatedAt: number;
2619
+ }
2620
+ export interface ProvenanceNode {
2621
+ id: string;
2622
+ kind: 'task' | 'intent' | 'bundle' | 'file' | 'edit' | 'commit' | 'outcome';
2623
+ label: string;
2624
+ timestamp: number;
2625
+ metadata: Record<string, unknown>;
2626
+ }
2627
+ export interface ProvenanceEdge {
2628
+ source: string;
2629
+ target: string;
2630
+ kind: 'GENERATED_CONTEXT' | 'INCLUDED_FILE' | 'MODIFIED_FILE' | 'PRODUCED_OUTCOME' | 'DERIVED_INTENT' | 'COMMITTED_CHANGE';
2631
+ }
2632
+ export interface ProvenanceGraph {
2633
+ nodes: ProvenanceNode[];
2634
+ edges: ProvenanceEdge[];
2635
+ }
2636
+ export interface ProvenanceTrace {
2637
+ taskId: string;
2638
+ taskLabel: string;
2639
+ chain: ProvenanceNode[];
2640
+ chainEdges: ProvenanceEdge[];
2641
+ outcome: 'success' | 'failure' | 'pending';
2642
+ }
1659
2643
  export interface TeamLedgerEntry {
1660
- /** Intent category (e.g. 'bug_fix', 'feature_add', 'refactor') */
1661
2644
  intentCategory: string;
1662
- /** SHA-256 hash of sorted context files */
1663
2645
  contextHash: string;
1664
- /** Execution outcome */
1665
2646
  outcome: 'success' | 'failure';
1666
- /** Context confidence score at execution time */
1667
2647
  confidenceScore: number;
1668
- /** Files included in the context bundle */
1669
2648
  files: string[];
1670
- /** Symbols included in the context bundle */
1671
2649
  symbols: string[];
1672
- /** Epoch ms */
1673
2650
  timestamp: number;
1674
- /** Developer identifier (redactable) */
1675
2651
  actor?: string;
1676
- /** Expansion level used (0-3) */
1677
2652
  expansionLevel: number;
1678
- /** Success weight (incremented on merge dedup) */
1679
2653
  successWeight: number;
1680
- /** Failure weight (incremented on merge dedup) */
1681
2654
  failureWeight: number;
1682
2655
  }
1683
- /** Aggregated weight entry in team-ledger/weights.json */
1684
2656
  export interface TeamWeightEntry {
1685
2657
  intentCategory: string;
1686
2658
  contextHash: string;
@@ -1688,17 +2660,14 @@ export interface TeamWeightEntry {
1688
2660
  failureWeight: number;
1689
2661
  lastUpdated: number;
1690
2662
  }
1691
- /** Team-level failure hotspot (team-ledger/hotspots.json) */
1692
2663
  export interface TeamHotspot {
1693
2664
  file: string;
1694
2665
  failureCount: number;
1695
2666
  successCount: number;
1696
2667
  implicationRate: number;
1697
2668
  lastFailureTimestamp: number;
1698
- /** Number of distinct developers who hit this hotspot */
1699
2669
  actorCount: number;
1700
2670
  }
1701
- /** Status summary for the team ledger */
1702
2671
  export interface TeamLedgerStatus {
1703
2672
  entryCount: number;
1704
2673
  successCount: number;
@@ -1710,190 +2679,433 @@ export interface TeamLedgerStatus {
1710
2679
  lastEntryAt: ISODateTime | null;
1711
2680
  ledgerPath: string;
1712
2681
  }
1713
- /** A single required-context rule in team policy */
1714
- export interface TeamPolicyRule {
1715
- /** Human-readable rule name (e.g. 'auth', 'payments', 'api-routes') */
1716
- name: string;
1717
- /** Files that MUST be included when this rule's keywords match the task */
1718
- requiredFiles: string[];
1719
- /** Whether matching tests must also be included */
1720
- requiredTests: boolean;
1721
- /** Keywords that trigger this rule (matched against task description) */
1722
- triggerKeywords: string[];
1723
- /** Action when required files are missing: 'boost' scores or 'block' validation */
1724
- enforcement: 'boost' | 'block';
1725
- }
1726
- /** Team context policy config (codeledger.team-policy.json) */
1727
- export interface TeamPolicyConfig {
1728
- /** Schema version */
1729
- version: 1;
1730
- /** Whether team policy enforcement is enabled */
1731
- enabled: boolean;
1732
- /** Policy rules keyed by domain name */
1733
- rules: TeamPolicyRule[];
1734
- }
1735
- /** Result of evaluating team policy against a bundle */
1736
- export interface TeamPolicyEvaluation {
1737
- /** Whether all required files are present */
1738
- passed: boolean;
1739
- /** Rules that were triggered by the task */
1740
- triggeredRules: string[];
1741
- /** Rules that passed (all required files present) */
1742
- satisfiedRules: string[];
1743
- /** Rules that failed (missing required files) */
1744
- violatedRules: Array<{
1745
- rule: string;
1746
- missingFiles: string[];
1747
- enforcement: 'boost' | 'block';
1748
- }>;
2682
+ export interface TeamWeakArea {
2683
+ area: 'recall' | 'precision' | 'drift' | 'context_confidence' | 'intent_sufficiency';
2684
+ description: string;
2685
+ score: number;
1749
2686
  }
1750
- /** Aggregated team-level quality metrics */
1751
2687
  export interface TeamMetrics {
1752
- /** Composite team context quality score [0, 1] */
1753
2688
  score: number;
1754
- /** Number of sessions aggregated */
1755
2689
  sessionCount: number;
1756
- /** Average bundle recall across sessions */
1757
2690
  avgRecall: number;
1758
- /** Average bundle precision across sessions */
1759
2691
  avgPrecision: number;
1760
- /** Average intent drift score [0, 1] (0 = no drift) */
1761
2692
  avgDrift: number;
1762
- /** Average CCS across sessions */
1763
2693
  avgCcs: number;
1764
- /** Average ISC across sessions */
1765
2694
  avgIsc: number;
1766
- /** Trend: change in score over last 7 days */
1767
2695
  trend: number;
1768
- /** Weak areas identified */
1769
2696
  weakAreas: TeamWeakArea[];
1770
- /** Timestamp of computation */
1771
2697
  computedAt: ISODateTime;
1772
- /** Time range: start epoch ms */
1773
2698
  rangeStartMs: number;
1774
- /** Time range: end epoch ms */
1775
2699
  rangeEndMs: number;
1776
2700
  }
1777
- /** A weak area identified in team metrics */
1778
- export interface TeamWeakArea {
1779
- area: string;
1780
- description: string;
1781
- score: number;
1782
- }
1783
- /** Node types in the provenance graph */
1784
- export type ProvenanceNodeKind = 'task' | 'intent' | 'bundle' | 'file' | 'edit' | 'commit' | 'outcome';
1785
- /** A node in the provenance graph */
1786
- export interface ProvenanceNode {
1787
- /** Unique node ID (e.g. 'task:abc123', 'file:src/auth.ts') */
1788
- id: string;
1789
- /** Node kind */
1790
- kind: ProvenanceNodeKind;
1791
- /** Human-readable label */
1792
- label: string;
1793
- /** Epoch ms of creation */
1794
- timestamp: number;
1795
- /** Arbitrary metadata */
1796
- metadata: Record<string, unknown>;
1797
- }
1798
- /** Edge types in the provenance graph */
1799
- export type ProvenanceEdgeKind = 'GENERATED_CONTEXT' | 'INCLUDED_FILE' | 'MODIFIED_FILE' | 'PRODUCED_OUTCOME' | 'DERIVED_INTENT' | 'COMMITTED_CHANGE';
1800
- /** An edge in the provenance graph */
1801
- export interface ProvenanceEdge {
1802
- /** Source node ID */
1803
- source: string;
1804
- /** Target node ID */
1805
- target: string;
1806
- /** Edge kind */
1807
- kind: ProvenanceEdgeKind;
1808
- /** Epoch ms */
1809
- timestamp: number;
1810
- /** Arbitrary metadata */
1811
- metadata: Record<string, unknown>;
2701
+ export interface TeamPolicyRule {
2702
+ name: string;
2703
+ triggerKeywords: string[];
2704
+ requiredFiles: string[];
2705
+ enforcement: 'block' | 'warn';
1812
2706
  }
1813
- /** Full provenance graph (in-memory representation) */
1814
- export interface ProvenanceGraph {
1815
- nodes: ProvenanceNode[];
1816
- edges: ProvenanceEdge[];
2707
+ export interface TeamPolicyConfig {
2708
+ version: number;
2709
+ enabled: boolean;
2710
+ rules: TeamPolicyRule[];
1817
2711
  }
1818
- /** A causal trace from task to outcome */
1819
- export interface ProvenanceTrace {
1820
- /** The task that started this trace */
1821
- taskId: string;
1822
- /** Human-readable task description */
1823
- taskLabel: string;
1824
- /** Ordered chain of provenance nodes */
1825
- chain: ProvenanceNode[];
1826
- /** Edges connecting the chain */
1827
- chainEdges: ProvenanceEdge[];
1828
- /** Final outcome (if reached) */
1829
- outcome?: 'success' | 'failure' | 'pending';
2712
+ export interface TeamPolicyEvaluation {
2713
+ passed: boolean;
2714
+ triggeredRules: string[];
2715
+ satisfiedRules: string[];
2716
+ violatedRules: Array<{
2717
+ rule: string;
2718
+ missingFiles: string[];
2719
+ enforcement: 'block' | 'warn';
2720
+ }>;
1830
2721
  }
1831
- /** Result of a policy simulation run */
1832
2722
  export interface PolicySimulationResult {
1833
- /** Total historical entries evaluated */
1834
2723
  totalEntries: number;
1835
- /** Entries that would be blocked */
1836
2724
  blockedCount: number;
1837
- /** Entries that would receive warnings */
1838
2725
  warnedCount: number;
1839
- /** Block rate as a fraction [0, 1] */
1840
2726
  blockRate: number;
1841
- /** Top violation reasons sorted by frequency */
1842
2727
  topViolations: Array<{
1843
2728
  reason: string;
1844
2729
  count: number;
1845
2730
  percentage: number;
1846
2731
  }>;
1847
- /** Simulation scope: 'team' or 'org' */
1848
2732
  scope: 'team' | 'org';
1849
- /** Timestamp of simulation */
1850
2733
  simulatedAt: ISODateTime;
1851
2734
  }
1852
- /** A file reservation claimed by an agent */
1853
- export interface FileReservation {
1854
- /** Path to the reserved file (relative to repo root) */
2735
+ /** Scope level for architecture policies */
2736
+ export type PolicyScope = 'global' | 'repo' | 'zone' | 'system';
2737
+ /** Lifecycle status of a policy document */
2738
+ export type PolicyStatus = 'draft' | 'active' | 'deprecated';
2739
+ /** A single rule within an architecture policy document */
2740
+ export interface ArchitecturePolicyRule {
2741
+ id: string;
2742
+ name?: string;
2743
+ domain: PolicyDomain;
2744
+ scope: PolicyScope;
2745
+ condition: string;
2746
+ action: 'block' | 'warn' | 'allow';
2747
+ enabled: boolean;
2748
+ description?: string;
2749
+ }
2750
+ /** A full architecture policy document */
2751
+ export interface ArchitecturePolicyDocument {
2752
+ schema_version: 'codeledger/arch-policy/v1';
2753
+ name: string;
2754
+ description?: string;
2755
+ scope: PolicyScope;
2756
+ status?: PolicyStatus;
2757
+ created_at?: string;
2758
+ updated_at?: string;
2759
+ rules: ArchitecturePolicyRule[];
2760
+ }
2761
+ /** A conflict between two rules at different scopes */
2762
+ export interface PolicyConflict {
2763
+ rule_id: string;
2764
+ winning_scope: PolicyScope;
2765
+ losing_scope: PolicyScope;
2766
+ resolution: string;
2767
+ }
2768
+ /** Result of resolving all architecture policies with strictest-wins */
2769
+ export interface ResolvedArchitecturePolicy {
2770
+ rules: ArchitecturePolicyRule[];
2771
+ sources: Array<{
2772
+ path: string;
2773
+ scope: PolicyScope;
2774
+ rule_count: number;
2775
+ }>;
2776
+ conflicts: PolicyConflict[];
2777
+ skipped_policies: Array<{
2778
+ path: string;
2779
+ name: string;
2780
+ status: PolicyStatus;
2781
+ reason: string;
2782
+ }>;
2783
+ }
2784
+ /** Result of simulating architecture policy against historical discoveries */
2785
+ export interface ArchPolicySimulationResult {
2786
+ rules_evaluated: number;
2787
+ would_block: number;
2788
+ would_warn: number;
2789
+ would_allow: number;
2790
+ affected_discoveries: Array<{
2791
+ task: string;
2792
+ verdict: DiscoveryVerdict;
2793
+ triggered_rules: string[];
2794
+ action: 'block' | 'warn' | 'allow';
2795
+ }>;
2796
+ summary: string;
2797
+ }
2798
+ /** Diff between two context bundles */
2799
+ export interface ContextDiff {
2800
+ from_bundle_id: string;
2801
+ to_bundle_id: string;
2802
+ added: string[];
2803
+ removed: string[];
2804
+ score_changed: Array<{
2805
+ path: string;
2806
+ from_score: number;
2807
+ to_score: number;
2808
+ }>;
2809
+ token_delta: number;
2810
+ generated_at: string;
2811
+ }
2812
+ /** Mermaid dependency diagram from a context bundle */
2813
+ export interface MermaidGraph {
2814
+ diagram_type: string;
2815
+ markup: string;
2816
+ included_files: string[];
2817
+ generated_at: string;
2818
+ }
2819
+ /** A single validation issue in a context bundle */
2820
+ export interface ValidationIssue {
2821
+ code: string;
2822
+ severity: 'error' | 'warning' | 'info';
2823
+ message: string;
2824
+ file?: string;
2825
+ symbol?: string;
2826
+ }
2827
+ /** Result of validating a context bundle */
2828
+ export interface ValidationResult {
2829
+ passed: boolean;
2830
+ issues: ValidationIssue[];
2831
+ missing_dependencies: string[];
2832
+ uncovered_files: string[];
2833
+ boundary_violations: Array<{
2834
+ from: string;
2835
+ to: string;
2836
+ reason: string;
2837
+ }>;
2838
+ validated_at: string;
2839
+ }
2840
+ /** A cached discovery result entry */
2841
+ export interface DiscoveryCacheEntry {
2842
+ taskHash: string;
2843
+ task: string;
2844
+ verdict: DiscoveryVerdict;
2845
+ overlap: OverlapClassification;
2846
+ posture: ImplementationPosture;
2847
+ guardrails: {
2848
+ must_reuse: string[];
2849
+ must_not_create: string[];
2850
+ insertion_points: string[];
2851
+ prohibited_files: string[];
2852
+ };
2853
+ timestamp: number;
2854
+ ttl_seconds: number;
2855
+ }
2856
+ /** Result from enforcing discovery guardrails */
2857
+ export interface DiscoveryEnforcementResult {
2858
+ blocked: boolean;
2859
+ reason: string;
2860
+ guidance: string;
2861
+ verdict: DiscoveryVerdict | null;
2862
+ }
2863
+ /** A single diff compliance violation */
2864
+ export interface DiffComplianceViolation {
2865
+ type: 'prohibited_file' | 'outside_insertion_points' | 'parallel_directory';
1855
2866
  file: string;
1856
- /** Agent or session ID that holds the reservation */
1857
- agentId: string;
1858
- /** Epoch ms when reservation was created */
1859
- claimedAt: number;
1860
- /** Epoch ms when reservation expires (0 = no expiry) */
1861
- expiresAt: number;
1862
- /** Whether the agent is actively editing this file */
1863
- active: boolean;
2867
+ message: string;
2868
+ severity: 'error' | 'warn';
2869
+ }
2870
+ /** Result of checking PR diff against discovery constraints */
2871
+ export interface DiffComplianceResult {
2872
+ status: 'pass' | 'warn' | 'fail';
2873
+ violations: DiffComplianceViolation[];
2874
+ files_checked: number;
2875
+ }
2876
+ /** A single duplicate detection match */
2877
+ export interface DuplicateEntry {
2878
+ new_file: string;
2879
+ existing_file: string;
2880
+ similarity: number;
2881
+ message: string;
1864
2882
  }
1865
- /** A task partition assigning files to agents */
1866
- export interface TaskPartition {
1867
- /** Agent or session ID */
1868
- agentId: string;
1869
- /** Files assigned to this agent */
1870
- files: string[];
1871
- /** Dependencies this agent's files have on other partitions */
1872
- dependsOn: string[];
2883
+ /** Result of content-based duplicate detection */
2884
+ export interface DuplicateDetectionResult {
2885
+ duplicates: DuplicateEntry[];
2886
+ files_checked: number;
1873
2887
  }
1874
- /** Result of attempting to claim a file reservation */
1875
- export interface ReservationResult {
1876
- /** Whether the reservation was granted */
1877
- granted: boolean;
1878
- /** If denied, the agent that holds the current reservation */
1879
- heldBy?: string;
1880
- /** If denied, when the current reservation was claimed */
1881
- heldSince?: number;
1882
- /** The reservation record (if granted) */
1883
- reservation?: FileReservation;
2888
+ /** A discovery override artifact */
2889
+ export interface DiscoveryOverride {
2890
+ task: string;
2891
+ reason: string;
2892
+ approved_by: string;
2893
+ timestamp: string;
1884
2894
  }
1885
- /** Orchestration state for multi-agent coordination */
1886
- export interface OrchestrationState {
1887
- /** All active file reservations */
1888
- reservations: FileReservation[];
1889
- /** Current task partitions (if partitioned) */
1890
- partitions: TaskPartition[];
1891
- /** Dependency ordering constraints */
1892
- dependencyOrder: Array<{
1893
- before: string;
1894
- after: string;
2895
+ /** Result of validating a discovery override */
2896
+ export interface DiscoveryOverrideValidation {
2897
+ valid: boolean;
2898
+ reason: string;
2899
+ approved_by: string | null;
2900
+ }
2901
+ /** Configuration for discovery enforcement policy */
2902
+ export interface DiscoveryPolicyConfig {
2903
+ block_on_strong_overlap: boolean;
2904
+ enforce_symbol_growth: boolean;
2905
+ max_new_exports: number;
2906
+ duplicate_similarity_threshold: number;
2907
+ require_human_override: boolean;
2908
+ insertion_point_strictness: 'block' | 'warn';
2909
+ }
2910
+ /** Default discovery enforcement policy */
2911
+ export declare const DEFAULT_DISCOVERY_POLICY: DiscoveryPolicyConfig;
2912
+ /** Architectural file kind classification for discovery scoring */
2913
+ export type DiscoveryFileKind = 'route' | 'service' | 'model' | 'schema' | 'type' | 'test' | 'doc' | 'config' | 'ui' | 'util' | 'migration' | 'unknown';
2914
+ /** Symbol growth analysis result from discover-check */
2915
+ export interface SymbolGrowthResult {
2916
+ status: 'pass' | 'warn' | 'fail';
2917
+ total_new_exports: number;
2918
+ unrelated_count: number;
2919
+ new_symbols: Array<{
2920
+ file: string;
2921
+ symbol: string;
2922
+ classification: 'expected' | 'suspicious' | 'unrelated';
2923
+ reason: string;
1895
2924
  }>;
1896
- /** Last updated timestamp */
1897
- updatedAt: number;
2925
+ files_analyzed: number;
2926
+ }
2927
+ /** Full result from discover-check */
2928
+ export interface DiscoveryCheckResult {
2929
+ verdict: DiscoveryVerdict;
2930
+ overlap: OverlapClassification;
2931
+ diff_compliance: DiffComplianceResult;
2932
+ symbol_growth: SymbolGrowthResult;
2933
+ duplicate_detection: DuplicateDetectionResult;
2934
+ override: DiscoveryOverrideValidation | null;
2935
+ policy: DiscoveryPolicyConfig;
2936
+ passed: boolean;
2937
+ summary: string;
2938
+ }
2939
+ /** A recommendation from the architecture health advisor */
2940
+ export interface AdvisorRecommendation {
2941
+ rule_id: string;
2942
+ name: string;
2943
+ severity: 'critical' | 'warning' | 'info';
2944
+ message: string;
2945
+ affected_systems: string[];
2946
+ suggested_actions: string[];
2947
+ }
2948
+ /** Result from discovery hook evaluation */
2949
+ export interface DiscoveryHookResult {
2950
+ verdict: string;
2951
+ taskHash: string;
2952
+ cached: boolean;
2953
+ guardrails: {
2954
+ must_reuse: string[];
2955
+ must_not_create: string[];
2956
+ insertion_points: string[];
2957
+ prohibited_files: string[];
2958
+ };
2959
+ guidance: string;
2960
+ }
2961
+ /** Composite architecture health score with 5 components */
2962
+ export interface ArchitectureHealthScore {
2963
+ overall: number;
2964
+ components: {
2965
+ dri: number;
2966
+ eds: number;
2967
+ sts: number;
2968
+ ofs: number;
2969
+ dcs: number;
2970
+ };
2971
+ grade: 'A' | 'B' | 'C' | 'D' | 'F';
2972
+ trend: 'improving' | 'stable' | 'declining';
2973
+ }
2974
+ /** Override log entry for health tracking */
2975
+ export interface OverrideLogEntry {
2976
+ task: string;
2977
+ approved_by: string;
2978
+ verdict_overridden: DiscoveryVerdict;
2979
+ timestamp: string;
2980
+ reason: string;
2981
+ }
2982
+ /** Source-of-truth path change across discovery runs */
2983
+ export interface SoTChange {
2984
+ system: string;
2985
+ previous_path: string;
2986
+ current_path: string;
2987
+ confidence_delta: number;
2988
+ timestamp: string;
2989
+ }
2990
+ /** Hotspot from duplication pressure */
2991
+ export interface HealthHotspot {
2992
+ system: string;
2993
+ path: string;
2994
+ duplication_pressure: number;
2995
+ recent_violations: number;
2996
+ risk: 'low' | 'medium' | 'high' | 'critical';
2997
+ }
2998
+ /** Point-in-time health snapshot */
2999
+ export interface HealthSnapshot {
3000
+ timestamp: string;
3001
+ commit_sha: string | null;
3002
+ score: ArchitectureHealthScore;
3003
+ hotspots: HealthHotspot[];
3004
+ sot_changes: SoTChange[];
3005
+ override_log: OverrideLogEntry[];
3006
+ }
3007
+ /** Alert from health metric thresholds */
3008
+ export interface HealthAlert {
3009
+ severity: 'warning' | 'critical';
3010
+ message: string;
3011
+ system: string | null;
3012
+ metric: string;
3013
+ value: number;
3014
+ threshold: number;
3015
+ }
3016
+ /** Full health dashboard output */
3017
+ export interface HealthDashboard {
3018
+ current: HealthSnapshot;
3019
+ history: HealthSnapshot[];
3020
+ alerts: HealthAlert[];
3021
+ }
3022
+ /** Drift velocity classification level */
3023
+ export type DriftVelocityLevel = 'LOW' | 'RISING' | 'HIGH' | 'CRITICAL';
3024
+ /** Drift velocity measurement from task history */
3025
+ export interface DriftVelocity {
3026
+ level: DriftVelocityLevel;
3027
+ unique_tasks_1h: number;
3028
+ unique_tasks_24h: number;
3029
+ acceleration: number;
3030
+ }
3031
+ /** Overall pre-PR verdict */
3032
+ export type PrePRVerdict = 'PASS' | 'WARN' | 'FAIL';
3033
+ /** Severity of a pre-PR finding */
3034
+ export type PrePRSeverity = 'critical' | 'high' | 'medium' | 'low';
3035
+ /** Category of a pre-PR check */
3036
+ export type PrePRCategory = 'completion' | 'type_contract' | 'cross_package' | 'staleness' | 'structural_trust' | 'build_test' | 'neighborhood' | 'release' | 'review_complexity' | 'adversarial';
3037
+ /** Individual pre-PR finding */
3038
+ export interface PrePRFinding {
3039
+ category: PrePRCategory;
3040
+ severity: PrePRSeverity;
3041
+ title: string;
3042
+ detail: string;
3043
+ remediation?: string;
3044
+ files?: string[];
3045
+ }
3046
+ /** Result of a single pre-PR check */
3047
+ export interface PrePRCheckResult {
3048
+ category: PrePRCategory;
3049
+ verdict: PrePRVerdict;
3050
+ findings: PrePRFinding[];
3051
+ durationMs: number;
3052
+ }
3053
+ /** Aggregated pre-PR report */
3054
+ export interface PrePRReport {
3055
+ verdict: PrePRVerdict;
3056
+ checks: PrePRCheckResult[];
3057
+ blockers: PrePRFinding[];
3058
+ warnings: PrePRFinding[];
3059
+ nextAction: string;
3060
+ timestamp: string;
3061
+ durationMs: number;
3062
+ }
3063
+ /** A single prevented issue with verifiable provenance */
3064
+ export interface InsightPreventedIssue {
3065
+ id: string;
3066
+ description: string;
3067
+ severity: 'critical' | 'high' | 'medium';
3068
+ source: 'guardrail' | 'pre_pr' | 'release_check' | 'cic';
3069
+ recursiveImpact?: string;
3070
+ }
3071
+ /** Work avoided metrics */
3072
+ export interface InsightWorkAvoided {
3073
+ surfaces: number;
3074
+ tests: number;
3075
+ contextScansAvoided: number;
3076
+ estimatedTimeSavedSec?: number;
3077
+ }
3078
+ /** Truth established via state promotions */
3079
+ export interface InsightTruthEstablished {
3080
+ completionState?: CompletionState;
3081
+ releaseState?: ReleaseState;
3082
+ }
3083
+ /** A state transition record */
3084
+ export interface InsightStateTransition {
3085
+ from: string;
3086
+ to: string;
3087
+ label: string;
3088
+ delta: number;
3089
+ }
3090
+ /** Full insight result — the value dashboard output */
3091
+ export interface InsightResult {
3092
+ preventedIssues: number;
3093
+ preventedDetails: InsightPreventedIssue[];
3094
+ workAvoided: InsightWorkAvoided;
3095
+ truthEstablished: InsightTruthEstablished;
3096
+ confidenceDelta: number;
3097
+ stateTransitions: InsightStateTransition[];
3098
+ recommendedAction?: string;
3099
+ silent: boolean;
3100
+ healthPulse: boolean;
3101
+ timestamp: string;
3102
+ sessionId?: string;
3103
+ }
3104
+ /** Session insight storage entry */
3105
+ export interface InsightSessionEntry {
3106
+ sessionId: string;
3107
+ command: string;
3108
+ result: InsightResult;
3109
+ timestamp: string;
1898
3110
  }
1899
3111
  //# sourceMappingURL=index.d.ts.map