@codeledger/types 0.7.3 → 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
@@ -1757,68 +1757,687 @@ export interface ReviewConfig {
1757
1757
  /** Whether the gatekeeper hook is enabled. Default: true */
1758
1758
  gatekeeper_enabled: boolean;
1759
1759
  }
1760
- /** Symbol kinds extracted by the SCE symbol graph */
1761
- export type SymbolKind = 'function' | 'class' | 'interface' | 'type' | 'enum' | 'variable';
1762
- /** 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';
1763
2401
  export interface SymbolNode {
1764
- /** Stable ID: "<file>::<symbolName>" */
1765
2402
  id: string;
1766
- /** Exported symbol name */
1767
2403
  name: string;
1768
2404
  kind: SymbolKind;
1769
- /** Absolute file path */
1770
2405
  file: string;
1771
- /** 1-based source line of the definition */
1772
2406
  line: number;
1773
- /** Symbols this node imports/depends on (by ID) */
1774
2407
  dependencies: string[];
1775
- /** Symbols that depend on this node (by ID, populated after full graph build) */
1776
2408
  dependents: string[];
1777
2409
  }
1778
- /** Symbol-level dependency graph produced by the SCE */
1779
2410
  export interface SymbolGraph {
1780
- /** Map of symbol ID → SymbolNode */
1781
2411
  nodes: Record<string, SymbolNode>;
1782
2412
  file_count: number;
1783
2413
  symbol_count: number;
1784
2414
  }
1785
- /** A single symbol-level slice entry in the MSCS */
1786
2415
  export interface CodeSlice {
1787
2416
  symbol_id: string;
1788
2417
  symbol_name: string;
1789
2418
  symbol_kind: SymbolKind;
1790
2419
  file: string;
1791
2420
  line: number;
1792
- /** Extracted source lines around the symbol definition */
1793
2421
  excerpt: string;
1794
- /** Relevance of this symbol to the task keywords [0,1] */
1795
2422
  relevance_score: number;
1796
- /** IDs of symbols this slice depends on */
1797
2423
  dependency_ids: string[];
1798
2424
  }
1799
- /** Minimal Sufficient Code Slice — output of SCE slice builder */
1800
2425
  export interface MinimalSufficientCodeSlice {
1801
2426
  task_keywords: string[];
1802
- /** Seed symbol IDs that directly matched task keywords */
1803
2427
  seed_symbols: string[];
1804
2428
  slices: CodeSlice[];
1805
2429
  file_count: number;
1806
2430
  symbol_count: number;
1807
- /** Maximum dependency depth traversed to build this slice */
1808
2431
  dependency_depth_reached: number;
1809
2432
  }
1810
- /** Stable task intent signature derived from the task prompt */
1811
2433
  export interface IntentSignature {
1812
- /** SHA-256 truncated to 16 hex chars — stable across sessions for same task */
1813
2434
  hash: string;
1814
2435
  task_normalized: string;
1815
2436
  keywords: string[];
1816
2437
  category: 'bug_fix' | 'feature_add' | 'refactor' | 'test_update' | 'config' | 'unknown';
1817
- derived_at: ISODateTime;
2438
+ derived_at: string;
1818
2439
  }
1819
- /** Kind of execution failure */
1820
- export type FailureKind = 'test_failure' | 'build_error' | 'type_error' | 'runtime_error' | 'unknown';
1821
- /** Structured failure vector parsed from agent execution output */
2440
+ export type FailureKind = 'test_failure' | 'build_error' | 'unknown';
1822
2441
  export interface FailureVector {
1823
2442
  kind: FailureKind;
1824
2443
  failures: Array<{
@@ -1828,164 +2447,73 @@ export interface FailureVector {
1828
2447
  line?: number;
1829
2448
  symbol?: string;
1830
2449
  }>;
1831
- /** Source files implicated by stack traces or test output */
1832
2450
  implicated_files: string[];
1833
- /** Symbol names referenced in error messages */
1834
2451
  implicated_symbols: string[];
1835
- /** FNV-1a hash of raw output (for deduplication) */
1836
2452
  raw_output_hash: string;
1837
- parsed_at: ISODateTime;
2453
+ parsed_at: string;
1838
2454
  }
1839
- /** Context expansion levels — higher levels include more context */
1840
2455
  export type ExpansionLevel = 1 | 2 | 3 | 4;
1841
- /** A single entry in the expansion ladder log */
1842
- export interface ExpansionEscalation {
1843
- from_level: ExpansionLevel;
1844
- to_level: ExpansionLevel;
1845
- at_iteration: number;
1846
- reason: string;
1847
- implicated_files: string[];
1848
- }
1849
- /** Running state of the IOLE expansion ladder */
1850
2456
  export interface ExpansionLadderState {
1851
2457
  intent_hash: string;
1852
2458
  task: string;
1853
2459
  current_level: ExpansionLevel;
1854
- max_level: 4;
2460
+ max_level: number;
1855
2461
  iteration_count: number;
1856
2462
  failure_count: number;
1857
- 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
+ }>;
1858
2470
  resolved: boolean;
1859
2471
  }
1860
- /** Outcome record for a single agent iteration */
1861
2472
  export interface OutcomeRecord {
1862
2473
  task_id: string;
1863
2474
  iteration: number;
1864
2475
  passed: boolean;
1865
- /** Context expansion level used during this iteration */
1866
2476
  context_level: number;
1867
- /** Severity score of failure [0,1] — 0 = no failure, 1 = catastrophic */
1868
2477
  failure_severity: number;
1869
- recorded_at: ISODateTime;
2478
+ recorded_at: string;
1870
2479
  }
1871
- /** Aggregate outcome score computed from multiple outcome records */
1872
2480
  export interface OutcomeScore {
1873
2481
  pass_rate: number;
1874
2482
  total_iterations: number;
1875
2483
  first_pass_rate: number;
1876
2484
  stability_signal: 'stable' | 'oscillating' | 'degrading' | 'improving' | 'unknown';
1877
2485
  improvement_trend: 'improving' | 'flat' | 'degrading';
1878
- /** Distribution of retry counts: { retries: count } */
1879
2486
  retry_distribution: Record<number, number>;
1880
- last_updated: ISODateTime;
1881
- }
1882
- /** A layer in the architectural graph */
1883
- export type ArchitectureLayer = 'types' | 'models' | 'services' | 'routes' | 'tests' | 'config' | 'infra' | 'unknown';
1884
- /** A Mermaid diagram produced by the AIL */
1885
- export interface MermaidGraph {
1886
- /** Diagram type: flowchart, graph, etc. */
1887
- diagram_type: 'flowchart' | 'graph';
1888
- /** Complete Mermaid markup ready for rendering */
1889
- markup: string;
1890
- /** Files included as nodes in the diagram */
1891
- included_files: string[];
1892
- generated_at: ISODateTime;
1893
- }
1894
- /** Context diff between two bundle iterations */
1895
- export interface ContextDiff {
1896
- from_bundle_id: string;
1897
- to_bundle_id: string;
1898
- /** Files added to the context in this iteration */
1899
- added: string[];
1900
- /** Files removed from the context */
1901
- removed: string[];
1902
- /** Files that stayed in context but changed relevance score */
1903
- score_changed: Array<{
1904
- path: string;
1905
- from_score: number;
1906
- to_score: number;
1907
- }>;
1908
- token_delta: number;
1909
- generated_at: ISODateTime;
1910
- }
1911
- /** Severity level of a validation issue */
1912
- export type ValidationSeverity = 'error' | 'warning' | 'info';
1913
- /** A single execution-aware validation issue */
1914
- export interface ValidationIssue {
1915
- code: string;
1916
- severity: ValidationSeverity;
1917
- message: string;
1918
- file?: string;
1919
- symbol?: string;
1920
- }
1921
- /** Result of execution-aware context validation */
1922
- export interface ValidationResult {
1923
- passed: boolean;
1924
- issues: ValidationIssue[];
1925
- /** Files that have missing or unresolvable type imports */
1926
- missing_dependencies: string[];
1927
- /** Files with no linked test coverage */
1928
- uncovered_files: string[];
1929
- /** Architecture boundary violations (importing across disallowed layers) */
1930
- boundary_violations: Array<{
1931
- from: string;
1932
- to: string;
1933
- reason: string;
1934
- }>;
1935
- validated_at: ISODateTime;
2487
+ last_updated: string;
1936
2488
  }
1937
- /** A single execution cycle recorded in the ECL-lite ledger */
1938
2489
  export interface EclLiteEntry {
1939
- /** Stable intent hash from IntentSignature */
1940
2490
  intentSignature: string;
1941
- /** Unix timestamp (ms) */
1942
2491
  timestamp: number;
1943
- /** Files included in the context bundle */
1944
2492
  files: string[];
1945
- /** Symbol names included in any MSCS slice */
1946
2493
  symbols: string[];
1947
- /** Expansion ladder level used (1–4) */
1948
2494
  expansionLevel: number;
1949
2495
  outcome: 'success' | 'failure';
1950
- /** Condensed failure vector (kind + implicated files) */
1951
2496
  failureVector?: {
1952
2497
  kind: string;
1953
2498
  implicated_files: string[];
1954
2499
  };
1955
- /** SHA-256 hash of the bundle file list (for dedup) */
1956
2500
  contextHash: string;
1957
- /** CCS score at time of execution (0–1) */
1958
2501
  confidenceScore: number;
1959
- /**
1960
- * Deterministic category from IntentObject: "{domain}_{operation}" or "general_task".
1961
- * Optional for backward compatibility with pre-v2.1.1 ledger entries.
1962
- */
1963
2502
  intentCategory?: string;
1964
2503
  }
1965
- /** Deterministic integer weight entry for the success/failure index */
1966
2504
  export interface EclWeightEntry {
1967
- /** Intent signature this entry tracks */
1968
2505
  intentSignature: string;
1969
- /** Cumulative successes (each success increments by 1) */
1970
2506
  successWeight: number;
1971
- /** Cumulative failures (each failure increments by 1) */
1972
2507
  failureWeight: number;
1973
2508
  lastUpdated: number;
1974
2509
  }
1975
- /** A file that frequently appears in failure vectors — a failure hotspot */
1976
2510
  export interface FailureHotspot {
1977
2511
  file: string;
1978
2512
  failureCount: number;
1979
2513
  successCount: number;
1980
- /** failureCount / (failureCount + successCount) */
1981
2514
  implicationRate: number;
1982
- /**
1983
- * Unix timestamp (ms) of the most recent failure implicating this file.
1984
- * Used for recency decay: recent failures have higher boost than stale ones.
1985
- */
1986
2515
  lastFailureTimestamp: number;
1987
2516
  }
1988
- /** Summary of the ECL-lite ledger state */
1989
2517
  export interface EclLiteStatus {
1990
2518
  entry_count: number;
1991
2519
  success_count: number;
@@ -1996,166 +2524,135 @@ export interface EclLiteStatus {
1996
2524
  ledger_path: string;
1997
2525
  last_entry_at: ISODateTime | null;
1998
2526
  }
1999
- /** Recommendation from the CCS assessment */
2000
- export type CcsRecommendation = 'proceed' | 'expand' | 'block';
2001
- /** Per-factor breakdown of the Context Confidence Score */
2002
2527
  export interface CcsFactors {
2003
- /** Fraction of imported deps present in the bundle [0,1] */
2004
2528
  dependencyCoverage: number;
2005
- /** Fraction of bundle source files with mapped tests [0,1] */
2006
2529
  testCoverageMapping: number;
2007
- /** Historical pass rate for this intent type from ECL-lite [0,1] */
2008
2530
  historicalSuccessRate: number;
2009
- /** Fraction of task keywords matched by bundle symbols [0,1] */
2010
2531
  symbolCompleteness: number;
2011
- /** Penalty applied based on current expansion level (L1=0, L4=0.3) */
2012
2532
  expansionLevelPenalty: number;
2013
- /**
2014
- * Number of ledger entries used to compute historicalSuccessRate.
2015
- * Low sample sizes reduce the weight of the historical factor to avoid
2016
- * early-data instability (< 5 → weight 0, 5–19 → scaled, ≥ 20 → full).
2017
- */
2018
2533
  historySampleSize: number;
2019
- /**
2020
- * Effective weight applied to the historical success factor after maturity scaling.
2021
- * Between 0 (empty/tiny ledger) and the configured W_HISTORICAL_SUCCESS (0.20).
2022
- */
2023
2534
  adjustedHistoricalWeight: number;
2024
2535
  }
2025
- /** Full Context Confidence Score assessment */
2536
+ export type CcsRecommendation = 'proceed' | 'expand' | 'block';
2026
2537
  export interface ContextConfidenceScore {
2027
- /** Weighted composite score [0,1] */
2028
2538
  score: number;
2029
2539
  level: 'high' | 'medium' | 'low';
2030
2540
  factors: CcsFactors;
2031
2541
  recommendation: CcsRecommendation;
2032
- /** Suggested expansion level when recommendation = 'expand' */
2033
2542
  suggestedExpansionLevel?: number;
2034
- /** Human-readable issues explaining score deductions */
2035
2543
  issues: string[];
2036
- computed_at: ISODateTime;
2544
+ computed_at: string;
2037
2545
  }
2038
- /** Structured decomposition of a task prompt — no embeddings, pure keyword parsing */
2039
- export interface IntentObject {
2040
- /** Primary domain inferred from task (e.g., "auth", "api", "database", "ui") */
2041
- domain: string;
2042
- /** Operation type */
2043
- operation: 'bugfix' | 'feature' | 'refactor' | 'test_update' | 'config' | 'unknown';
2044
- /** Architectural layer the task targets */
2045
- layer: ArchitectureLayer;
2046
- /** Specific entities extracted: function names, module names, type names */
2047
- entities: string[];
2048
- /** Inferred constraints: "no breaking changes", "must keep backward compat", etc. */
2049
- constraints: string[];
2050
- /**
2051
- * Deterministic category: "{domain}_{operation}" (e.g., "auth_bugfix", "api_feature").
2052
- * Falls back to "general_task" when domain or operation is unknown.
2053
- * Used for aggregated historical success lookups and hotspot grouping.
2054
- */
2055
- category: string;
2056
- /**
2057
- * Extraction confidence [0,1]. Low values (< 0.4) indicate ambiguous input
2058
- * where domain/operation fell back to defaults. Used by CCS to apply a small
2059
- * confidence penalty when intent structure is unclear.
2060
- */
2061
- intentConfidence: number;
2062
- /** Raw task string this was decomposed from */
2063
- raw_task: string;
2064
- decomposed_at: ISODateTime;
2065
- }
2066
- /**
2067
- * Per-factor breakdown for an Intent Sufficiency Check.
2068
- * Each score is [0,1]; the weighted composite produces IntentSufficiencyCheck.score.
2069
- */
2070
2546
  export interface IntentSufficiencyFactors {
2071
- /**
2072
- * Token signal score [0,1].
2073
- * Penalizes ultra-short prompts (< 3 tokens) and rewards richer descriptions.
2074
- * Weight: 0.20
2075
- */
2076
2547
  tokenSignalScore: number;
2077
- /**
2078
- * Operation clarity score [0,1].
2079
- * 1.0 when a clear action verb (fix, add, refactor, …) is detected; 0.0 otherwise.
2080
- * Weight: 0.30
2081
- */
2082
2548
  operationClarityScore: number;
2083
- /**
2084
- * Domain clarity score [0,1].
2085
- * 1.0 when a recognisable domain keyword (auth, api, database, …) is present.
2086
- * Weight: 0.25
2087
- */
2088
2549
  domainClarityScore: number;
2089
- /**
2090
- * Target specificity score [0,1].
2091
- * Rewards naming concrete targets: file paths, module names, function names, quoted
2092
- * identifiers, or camelCase/snake_case tokens.
2093
- * Weight: 0.15
2094
- */
2095
2550
  targetSpecificityScore: number;
2096
- /**
2097
- * Constraint presence score [0,1].
2098
- * 1.0 when scope or quality constraints are present (e.g., "without breaking …",
2099
- * "must keep backward compat", "in packages/…").
2100
- * Weight: 0.10
2101
- */
2102
2551
  constraintPresenceScore: number;
2103
2552
  }
2104
- /**
2105
- * Result of an Intent Sufficiency Check.
2106
- *
2107
- * ISC is the PRE-CONTEXT certification layer — it answers:
2108
- * "Is this task prompt specific enough to justify context construction?"
2109
- *
2110
- * Decision thresholds:
2111
- * SUFFICIENT ≥ 0.75 — proceed normally
2112
- * WEAK 0.50–0.74 — proceed with -0.05 CCS penalty
2113
- * INSUFFICIENT < 0.50 — block context construction; surface recommendations
2114
- */
2115
2553
  export interface IntentSufficiencyCheck {
2116
- /** Weighted composite score [0,1] */
2117
2554
  score: number;
2118
- /** Gate decision */
2119
2555
  decision: 'SUFFICIENT' | 'WEAK' | 'INSUFFICIENT';
2120
- /** Per-factor breakdown */
2121
2556
  factors: IntentSufficiencyFactors;
2122
- /** Human-readable issues explaining score deductions */
2123
2557
  issues: string[];
2124
- /** Actionable suggestions to improve the prompt */
2125
2558
  recommendations: string[];
2126
- /** The operation keyword detected, if any */
2127
2559
  detectedOperation?: string;
2128
- /** The domain keyword detected, if any */
2129
2560
  detectedDomain?: string;
2130
- /** Specific target tokens detected (file paths, identifiers, module names) */
2131
2561
  detectedTargets?: string[];
2132
2562
  }
2133
- /** 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
+ }
2134
2643
  export interface TeamLedgerEntry {
2135
- /** Intent category (e.g. 'bug_fix', 'feature_add', 'refactor') */
2136
2644
  intentCategory: string;
2137
- /** SHA-256 hash of sorted context files */
2138
2645
  contextHash: string;
2139
- /** Execution outcome */
2140
2646
  outcome: 'success' | 'failure';
2141
- /** Context confidence score at execution time */
2142
2647
  confidenceScore: number;
2143
- /** Files included in the context bundle */
2144
2648
  files: string[];
2145
- /** Symbols included in the context bundle */
2146
2649
  symbols: string[];
2147
- /** Epoch ms */
2148
2650
  timestamp: number;
2149
- /** Developer identifier (redactable) */
2150
2651
  actor?: string;
2151
- /** Expansion level used (0-3) */
2152
2652
  expansionLevel: number;
2153
- /** Success weight (incremented on merge dedup) */
2154
2653
  successWeight: number;
2155
- /** Failure weight (incremented on merge dedup) */
2156
2654
  failureWeight: number;
2157
2655
  }
2158
- /** Aggregated weight entry in team-ledger/weights.json */
2159
2656
  export interface TeamWeightEntry {
2160
2657
  intentCategory: string;
2161
2658
  contextHash: string;
@@ -2163,17 +2660,14 @@ export interface TeamWeightEntry {
2163
2660
  failureWeight: number;
2164
2661
  lastUpdated: number;
2165
2662
  }
2166
- /** Team-level failure hotspot (team-ledger/hotspots.json) */
2167
2663
  export interface TeamHotspot {
2168
2664
  file: string;
2169
2665
  failureCount: number;
2170
2666
  successCount: number;
2171
2667
  implicationRate: number;
2172
2668
  lastFailureTimestamp: number;
2173
- /** Number of distinct developers who hit this hotspot */
2174
2669
  actorCount: number;
2175
2670
  }
2176
- /** Status summary for the team ledger */
2177
2671
  export interface TeamLedgerStatus {
2178
2672
  entryCount: number;
2179
2673
  successCount: number;
@@ -2185,517 +2679,84 @@ export interface TeamLedgerStatus {
2185
2679
  lastEntryAt: ISODateTime | null;
2186
2680
  ledgerPath: string;
2187
2681
  }
2188
- /** A single required-context rule in team policy */
2189
- export interface TeamPolicyRule {
2190
- /** Human-readable rule name (e.g. 'auth', 'payments', 'api-routes') */
2191
- name: string;
2192
- /** Files that MUST be included when this rule's keywords match the task */
2193
- requiredFiles: string[];
2194
- /** Whether matching tests must also be included */
2195
- requiredTests: boolean;
2196
- /** Keywords that trigger this rule (matched against task description) */
2197
- triggerKeywords: string[];
2198
- /** Action when required files are missing: 'boost' scores or 'block' validation */
2199
- enforcement: 'boost' | 'block';
2200
- }
2201
- /** Team context policy config (codeledger.team-policy.json) */
2202
- export interface TeamPolicyConfig {
2203
- /** Schema version */
2204
- version: 1;
2205
- /** Whether team policy enforcement is enabled */
2206
- enabled: boolean;
2207
- /** Policy rules keyed by domain name */
2208
- rules: TeamPolicyRule[];
2209
- }
2210
- /** Result of evaluating team policy against a bundle */
2211
- export interface TeamPolicyEvaluation {
2212
- /** Whether all required files are present */
2213
- passed: boolean;
2214
- /** Rules that were triggered by the task */
2215
- triggeredRules: string[];
2216
- /** Rules that passed (all required files present) */
2217
- satisfiedRules: string[];
2218
- /** Rules that failed (missing required files) */
2219
- violatedRules: Array<{
2220
- rule: string;
2221
- missingFiles: string[];
2222
- enforcement: 'boost' | 'block';
2223
- }>;
2682
+ export interface TeamWeakArea {
2683
+ area: 'recall' | 'precision' | 'drift' | 'context_confidence' | 'intent_sufficiency';
2684
+ description: string;
2685
+ score: number;
2224
2686
  }
2225
- /** Aggregated team-level quality metrics */
2226
2687
  export interface TeamMetrics {
2227
- /** Composite team context quality score [0, 1] */
2228
2688
  score: number;
2229
- /** Number of sessions aggregated */
2230
2689
  sessionCount: number;
2231
- /** Average bundle recall across sessions */
2232
2690
  avgRecall: number;
2233
- /** Average bundle precision across sessions */
2234
2691
  avgPrecision: number;
2235
- /** Average intent drift score [0, 1] (0 = no drift) */
2236
2692
  avgDrift: number;
2237
- /** Average CCS across sessions */
2238
2693
  avgCcs: number;
2239
- /** Average ISC across sessions */
2240
2694
  avgIsc: number;
2241
- /** Trend: change in score over last 7 days */
2242
2695
  trend: number;
2243
- /** Weak areas identified */
2244
2696
  weakAreas: TeamWeakArea[];
2245
- /** Timestamp of computation */
2246
2697
  computedAt: ISODateTime;
2247
- /** Time range: start epoch ms */
2248
2698
  rangeStartMs: number;
2249
- /** Time range: end epoch ms */
2250
2699
  rangeEndMs: number;
2251
2700
  }
2252
- /** A weak area identified in team metrics */
2253
- export interface TeamWeakArea {
2254
- area: string;
2255
- description: string;
2256
- score: number;
2257
- }
2258
- /** Composite metrics for architecture health monitoring */
2259
- export interface DashboardMetrics {
2260
- ahs: number;
2261
- dri: number;
2262
- eds: number;
2263
- sts: number;
2264
- override_frequency: number;
2265
- overall: number;
2266
- timestamp: number;
2267
- }
2268
- /** A dashboard metrics snapshot with provenance */
2269
- export interface DashboardSnapshot extends DashboardMetrics {
2270
- snapshot_source: string;
2271
- }
2272
- /** Trend direction for each dashboard metric */
2273
- export interface DashboardTrends {
2274
- ahs_trend: 'improving' | 'stable' | 'degrading';
2275
- dri_trend: 'improving' | 'stable' | 'degrading';
2276
- eds_trend: 'improving' | 'stable' | 'degrading';
2277
- sts_trend: 'improving' | 'stable' | 'degrading';
2278
- override_trend: 'improving' | 'stable' | 'degrading';
2279
- overall_trend: 'improving' | 'stable' | 'degrading';
2280
- }
2281
- /** Node types in the provenance graph */
2282
- export type ProvenanceNodeKind = 'task' | 'intent' | 'bundle' | 'file' | 'edit' | 'commit' | 'outcome';
2283
- /** A node in the provenance graph */
2284
- export interface ProvenanceNode {
2285
- /** Unique node ID (e.g. 'task:abc123', 'file:src/auth.ts') */
2286
- id: string;
2287
- /** Node kind */
2288
- kind: ProvenanceNodeKind;
2289
- /** Human-readable label */
2290
- label: string;
2291
- /** Epoch ms of creation */
2292
- timestamp: number;
2293
- /** Arbitrary metadata */
2294
- metadata: Record<string, unknown>;
2295
- }
2296
- /** Edge types in the provenance graph */
2297
- export type ProvenanceEdgeKind = 'GENERATED_CONTEXT' | 'INCLUDED_FILE' | 'MODIFIED_FILE' | 'PRODUCED_OUTCOME' | 'DERIVED_INTENT' | 'COMMITTED_CHANGE';
2298
- /** An edge in the provenance graph */
2299
- export interface ProvenanceEdge {
2300
- /** Source node ID */
2301
- source: string;
2302
- /** Target node ID */
2303
- target: string;
2304
- /** Edge kind */
2305
- kind: ProvenanceEdgeKind;
2306
- /** Epoch ms */
2307
- timestamp: number;
2308
- /** Arbitrary metadata */
2309
- metadata: Record<string, unknown>;
2701
+ export interface TeamPolicyRule {
2702
+ name: string;
2703
+ triggerKeywords: string[];
2704
+ requiredFiles: string[];
2705
+ enforcement: 'block' | 'warn';
2310
2706
  }
2311
- /** Full provenance graph (in-memory representation) */
2312
- export interface ProvenanceGraph {
2313
- nodes: ProvenanceNode[];
2314
- edges: ProvenanceEdge[];
2707
+ export interface TeamPolicyConfig {
2708
+ version: number;
2709
+ enabled: boolean;
2710
+ rules: TeamPolicyRule[];
2315
2711
  }
2316
- /** A causal trace from task to outcome */
2317
- export interface ProvenanceTrace {
2318
- /** The task that started this trace */
2319
- taskId: string;
2320
- /** Human-readable task description */
2321
- taskLabel: string;
2322
- /** Ordered chain of provenance nodes */
2323
- chain: ProvenanceNode[];
2324
- /** Edges connecting the chain */
2325
- chainEdges: ProvenanceEdge[];
2326
- /** Final outcome (if reached) */
2327
- 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
+ }>;
2328
2721
  }
2329
- /** Result of a policy simulation run */
2330
2722
  export interface PolicySimulationResult {
2331
- /** Total historical entries evaluated */
2332
2723
  totalEntries: number;
2333
- /** Entries that would be blocked */
2334
- blockedCount: number;
2335
- /** Entries that would receive warnings */
2336
- warnedCount: number;
2337
- /** Block rate as a fraction [0, 1] */
2338
- blockRate: number;
2339
- /** Top violation reasons sorted by frequency */
2340
- topViolations: Array<{
2341
- reason: string;
2342
- count: number;
2343
- percentage: number;
2344
- }>;
2345
- /** Simulation scope: 'team' or 'org' */
2346
- scope: 'team' | 'org';
2347
- /** Timestamp of simulation */
2348
- simulatedAt: ISODateTime;
2349
- }
2350
- /** A file reservation claimed by an agent */
2351
- export interface FileReservation {
2352
- /** Path to the reserved file (relative to repo root) */
2353
- file: string;
2354
- /** Agent or session ID that holds the reservation */
2355
- agentId: string;
2356
- /** Epoch ms when reservation was created */
2357
- claimedAt: number;
2358
- /** Epoch ms when reservation expires (0 = no expiry) */
2359
- expiresAt: number;
2360
- /** Whether the agent is actively editing this file */
2361
- active: boolean;
2362
- }
2363
- /** A task partition assigning files to agents */
2364
- export interface TaskPartition {
2365
- /** Agent or session ID */
2366
- agentId: string;
2367
- /** Files assigned to this agent */
2368
- files: string[];
2369
- /** Dependencies this agent's files have on other partitions */
2370
- dependsOn: string[];
2371
- }
2372
- /** Result of attempting to claim a file reservation */
2373
- export interface ReservationResult {
2374
- /** Whether the reservation was granted */
2375
- granted: boolean;
2376
- /** If denied, the agent that holds the current reservation */
2377
- heldBy?: string;
2378
- /** If denied, when the current reservation was claimed */
2379
- heldSince?: number;
2380
- /** The reservation record (if granted) */
2381
- reservation?: FileReservation;
2382
- }
2383
- /** Orchestration state for multi-agent coordination */
2384
- export interface OrchestrationState {
2385
- /** All active file reservations */
2386
- reservations: FileReservation[];
2387
- /** Current task partitions (if partitioned) */
2388
- partitions: TaskPartition[];
2389
- /** Dependency ordering constraints */
2390
- dependencyOrder: Array<{
2391
- before: string;
2392
- after: string;
2393
- }>;
2394
- /** Last updated timestamp */
2395
- updatedAt: number;
2396
- }
2397
- /** Overlap classification for a discovery result */
2398
- export type OverlapClassification = 'NO_MATERIAL_OVERLAP' | 'PARTIAL_OVERLAP' | 'STRONG_OVERLAP' | 'FEATURE_ALREADY_EXISTS';
2399
- /** Recommended implementation posture */
2400
- export type ImplementationPosture = 'EXTEND_EXISTING_SYSTEM' | 'WRAP_EXISTING_SYSTEM' | 'ADD_ADAPTER_LAYER' | 'BUILD_NEW_CAPABILITY';
2401
- /** Go/No-Go verdict for a discovery gate */
2402
- export type DiscoveryVerdict = 'GO_GENUINELY_NEW' | 'GO_EXTENSION_ONLY' | 'NO_GO_ALREADY_EXISTS';
2403
- /** Kind of file in the architecture */
2404
- export type DiscoveryFileKind = 'route' | 'service' | 'model' | 'schema' | 'type' | 'migration' | 'test' | 'doc' | 'config' | 'util' | 'ui' | 'unknown';
2405
- /** A system found during discovery that relates to the requested capability */
2406
- export interface DiscoveryMatch {
2407
- /** File path (relative to repo root) */
2408
- file: string;
2409
- /** System or module name */
2410
- system: string;
2411
- /** Short description of what it does */
2412
- description: string;
2413
- /** Similarity score 0–1 (combined keyword + centrality + structural signals) */
2414
- similarity: number;
2415
- /** Type of overlap */
2416
- overlap: 'direct' | 'indirect';
2417
- /** Exported symbols that matched */
2418
- matched_symbols: string[];
2419
- /** Architectural kind of this file */
2420
- kind: DiscoveryFileKind;
2421
- /** Why this file is relevant */
2422
- why_relevant: string;
2423
- /** Centrality score (dependents-based) [0-1] */
2424
- centrality: number;
2425
- }
2426
- /** Source-of-truth for a discovered system */
2427
- export interface DiscoverySourceOfTruth {
2428
- /** Canonical system name */
2429
- system: string;
2430
- /** Primary file path (highest centrality in cluster) */
2431
- path: string;
2432
- /** Confidence in this being the true owner [0-1] */
2433
- confidence: number;
2434
- /** Why this was selected as source of truth */
2435
- justification: string;
2436
- /** Competing systems that implement similar capability */
2437
- competitors: Array<{
2438
- system: string;
2439
- path: string;
2440
- similarity: number;
2441
- }>;
2442
- /** Whether fragmentation was detected (same concept across 3+ unrelated dirs) */
2443
- fragmented: boolean;
2444
- }
2445
- /** Blast radius for a discovered system */
2446
- export interface DiscoveryBlastRadius {
2447
- /** System name */
2448
- system: string;
2449
- /** Primary file path */
2450
- path: string;
2451
- /** Direct dependents (files that import it) */
2452
- direct_dependents: string[];
2453
- /** Transitive dependents (full chain) */
2454
- transitive_dependents: string[];
2455
- /** Shared modules/types this system uses */
2456
- shared_modules: string[];
2457
- /** Impacted tests */
2458
- impacted_tests: string[];
2459
- /** Risk classification */
2460
- risk: 'low' | 'medium' | 'high';
2461
- }
2462
- /** Gap analysis for a discovery result */
2463
- export interface DiscoveryGapAnalysis {
2464
- /** Estimated coverage: what % of requested capability exists [0-1] */
2465
- coverage_estimate: number;
2466
- /** Specific missing capabilities (entities/concepts not found in SoT) */
2467
- missing_capabilities: string[];
2468
- /** Recommended extensions with target file/module */
2469
- recommended_extensions: Array<{
2470
- target: string;
2471
- description: string;
2472
- }>;
2473
- /** Exact files/modules to extend */
2474
- extension_targets: string[];
2475
- /** Warning when coverage is high (>70%) — "DO NOT BUILD NEW — EXTEND" */
2476
- warning: string | null;
2477
- /** Source-of-truth exports that align with the task */
2478
- existing_exports: string[];
2479
- }
2480
- /** Full discovery artifact (versioned, persisted to .codeledger/discovery/) */
2481
- export interface DiscoveryArtifactV1 {
2482
- /** Schema version */
2483
- schema_version: 'discovery/v1';
2484
- /** Task description */
2485
- task: string;
2486
- /** Normalized task (lowercased, stopwords removed) */
2487
- normalized_task: string;
2488
- /** Search evidence */
2489
- search_evidence: {
2490
- keywords: string[];
2491
- expanded_terms: string[];
2492
- semantic_neighbors: Array<{
2493
- term: string;
2494
- reason: string;
2495
- }>;
2496
- files_scanned: number;
2497
- };
2498
- /** Intent decomposition */
2499
- intent: IntentObject;
2500
- /** Top similarity matches (grouped by system) */
2501
- matches: DiscoveryMatch[];
2502
- /** Source of truth detection */
2503
- source_of_truth: DiscoverySourceOfTruth | null;
2504
- /** Blast radius for top systems */
2505
- blast_radius: DiscoveryBlastRadius[];
2506
- /** Gap analysis */
2507
- gap_analysis: DiscoveryGapAnalysis;
2508
- /** Overlap classification */
2509
- overlap_classification: OverlapClassification;
2510
- /** Duplication risk description */
2511
- duplication_risk: string;
2512
- /** Recommended implementation posture */
2513
- recommended_posture: ImplementationPosture;
2514
- /** Proposed insertion points (file paths to extend) */
2515
- proposed_insertion_points: string[];
2516
- /** Prohibited files (paths where parallel systems MUST NOT be created) */
2517
- prohibited_files: string[];
2518
- /** Things that must NOT be created */
2519
- must_not_create: string[];
2520
- /** Things that MUST be reused */
2521
- must_reuse: string[];
2522
- /** Go/No-Go verdict */
2523
- verdict: DiscoveryVerdict;
2524
- /** Related repo standards */
2525
- related_standards: Array<{
2526
- helper_name: string;
2527
- example_paths: string[];
2528
- usage_count: number;
2529
- }>;
2530
- /** Duration in milliseconds */
2531
- duration_ms: number;
2532
- /** Timestamp */
2533
- generated_at: ISODateTime;
2534
- }
2535
- /** Result of running the discovery gate (backward-compatible + enhanced) */
2536
- export interface DiscoveryResult {
2537
- /** The requested capability (task description) */
2538
- requested_capability: string;
2539
- /** Intent decomposition of the task */
2540
- intent: IntentObject;
2541
- /** Keywords and synonyms searched */
2542
- keywords_searched: string[];
2543
- /** Files scanned (count) */
2544
- files_scanned: number;
2545
- /** Top similarity matches */
2546
- matches: DiscoveryMatch[];
2547
- /** Existing repo standards that relate */
2548
- related_standards: Array<{
2549
- helper_name: string;
2550
- example_paths: string[];
2551
- usage_count: number;
2552
- }>;
2553
- /** Overlap classification */
2554
- overlap: OverlapClassification;
2555
- /** Duplication risk explanation */
2556
- duplication_risk: string;
2557
- /** Recommended implementation posture */
2558
- posture: ImplementationPosture;
2559
- /** Go/No-Go verdict */
2560
- verdict: DiscoveryVerdict;
2561
- /** Guardrails: what must be reused */
2562
- must_reuse: string[];
2563
- /** Guardrails: what must NOT be created */
2564
- must_not_create: string[];
2565
- /** Proposed insertion points (file paths) */
2566
- insertion_points: string[];
2567
- /** Prohibited files (paths where parallel systems must NOT be created) */
2568
- prohibited_files: string[];
2569
- /** Source-of-truth detection result */
2570
- source_of_truth: DiscoverySourceOfTruth | null;
2571
- /** Blast radius for top systems */
2572
- blast_radius: DiscoveryBlastRadius[];
2573
- /** Gap analysis */
2574
- gap_analysis: DiscoveryGapAnalysis | null;
2575
- /** Duration in milliseconds */
2576
- duration_ms: number;
2577
- }
2578
- /** Result from the discovery hook (run automatically on implementation tasks) */
2579
- export interface DiscoveryHookResult {
2580
- verdict: DiscoveryVerdict;
2581
- taskHash: string;
2582
- cached: boolean;
2583
- guardrails: {
2584
- must_reuse: string[];
2585
- must_not_create: string[];
2586
- insertion_points: string[];
2587
- prohibited_files: string[];
2588
- };
2589
- guidance: string;
2590
- }
2591
- /** Cache entry for a discovery result (keyed by task hash) */
2592
- export interface DiscoveryCacheEntry {
2593
- taskHash: string;
2594
- task: string;
2595
- verdict: DiscoveryVerdict;
2596
- overlap: OverlapClassification;
2597
- posture: ImplementationPosture;
2598
- guardrails: {
2599
- must_reuse: string[];
2600
- must_not_create: string[];
2601
- insertion_points: string[];
2602
- prohibited_files: string[];
2603
- };
2604
- timestamp: number;
2605
- ttl_seconds: number;
2606
- }
2607
- /** Result from the discovery enforcement check on Edit/Write operations */
2608
- export interface DiscoveryEnforcementResult {
2609
- blocked: boolean;
2610
- reason: string;
2611
- guidance: string;
2612
- verdict: DiscoveryVerdict | null;
2613
- }
2614
- /** A single insertion-point or ghost-file violation */
2615
- export interface InsertionPointViolation {
2616
- file: string;
2617
- violation_type: 'ghost_file' | 'outside_insertion_point' | 'prohibited_path';
2618
- severity: 'P1' | 'P2';
2619
- reason: string;
2620
- similar_to?: string;
2621
- shared_symbols?: string[];
2622
- }
2623
- /** Aggregate symbol growth report for a PR */
2624
- export interface SymbolGrowthReport {
2625
- total_symbols_added: number;
2626
- total_symbols_removed: number;
2627
- total_symbols_modified: number;
2628
- net_growth: number;
2629
- scope_creep_detected: boolean;
2630
- threshold: number;
2631
- per_file: SymbolGrowthEntry[];
2632
- api_surface_explosions: string[];
2633
- }
2634
- /** Per-file symbol growth entry */
2635
- export interface SymbolGrowthEntry {
2636
- file: string;
2637
- added: string[];
2638
- removed: string[];
2639
- modified: string[];
2640
- net: number;
2641
- }
2642
- export interface AggregatedSignal {
2643
- id: string;
2644
- source: 'drift' | 'discovery' | 'review_intelligence' | 'layer_d' | 'policy' | 'verify';
2645
- severity: 'critical' | 'high' | 'medium' | 'low';
2646
- category: InterventionCategory;
2647
- description: string;
2648
- affected_files: string[];
2649
- timestamp: number;
2650
- metadata?: Record<string, unknown>;
2651
- }
2652
- export type InterventionCategory = 'drift_spike' | 'duplication_pressure' | 'governance_breakdown' | 'architectural_violation' | 'test_gap' | 'scope_creep' | 'sot_instability' | 'coverage_gap' | 'extension_failure';
2653
- export interface EscalationResult {
2654
- level: 'none' | 'advisory' | 'warning' | 'blocking';
2655
- reason: string;
2656
- compound_escalation: boolean;
2657
- signal_summary: Record<InterventionCategory, number>;
2658
- }
2659
- export interface Intervention {
2660
- id: string;
2661
- priority: InterventionPriority;
2662
- title: string;
2663
- description: string;
2664
- action_type: 'refactor' | 'extend_existing' | 'add_test' | 'fix_violation' | 'consolidate_duplicates' | 'update_policy';
2665
- category: InterventionCategory;
2666
- affected_files: string[];
2667
- affected_systems: string[];
2668
- suggested_fix: string;
2669
- suggested_actions: string[];
2670
- apply_command?: string;
2671
- estimated_impact: number;
2672
- agent_template?: string;
2724
+ blockedCount: number;
2725
+ warnedCount: number;
2726
+ blockRate: number;
2727
+ topViolations: Array<{
2728
+ reason: string;
2729
+ count: number;
2730
+ percentage: number;
2731
+ }>;
2732
+ scope: 'team' | 'org';
2733
+ simulatedAt: ISODateTime;
2673
2734
  }
2674
- /** Scope levels for architecture policies (strictest wins) */
2735
+ /** Scope level for architecture policies */
2675
2736
  export type PolicyScope = 'global' | 'repo' | 'zone' | 'system';
2676
2737
  /** Lifecycle status of a policy document */
2677
2738
  export type PolicyStatus = 'draft' | 'active' | 'deprecated';
2678
- /** A single architecture policy rule */
2739
+ /** A single rule within an architecture policy document */
2679
2740
  export interface ArchitecturePolicyRule {
2680
2741
  id: string;
2681
2742
  name?: string;
2682
- description?: string;
2743
+ domain: PolicyDomain;
2683
2744
  scope: PolicyScope;
2684
- domain: 'discovery' | 'enforcement' | 'source_of_truth' | 'overrides' | 'interventions' | 'dashboard';
2685
2745
  condition: string;
2686
2746
  action: 'block' | 'warn' | 'allow';
2687
2747
  enabled: boolean;
2748
+ description?: string;
2688
2749
  }
2689
- /** A policy document containing rules */
2750
+ /** A full architecture policy document */
2690
2751
  export interface ArchitecturePolicyDocument {
2691
2752
  schema_version: 'codeledger/arch-policy/v1';
2692
2753
  name: string;
2693
2754
  description?: string;
2694
2755
  scope: PolicyScope;
2695
2756
  status?: PolicyStatus;
2696
- rules: ArchitecturePolicyRule[];
2697
2757
  created_at?: string;
2698
2758
  updated_at?: string;
2759
+ rules: ArchitecturePolicyRule[];
2699
2760
  }
2700
2761
  /** A conflict between two rules at different scopes */
2701
2762
  export interface PolicyConflict {
@@ -2704,7 +2765,7 @@ export interface PolicyConflict {
2704
2765
  losing_scope: PolicyScope;
2705
2766
  resolution: string;
2706
2767
  }
2707
- /** Resolved policy after cascade resolution */
2768
+ /** Result of resolving all architecture policies with strictest-wins */
2708
2769
  export interface ResolvedArchitecturePolicy {
2709
2770
  rules: ArchitecturePolicyRule[];
2710
2771
  sources: Array<{
@@ -2720,7 +2781,7 @@ export interface ResolvedArchitecturePolicy {
2720
2781
  reason: string;
2721
2782
  }>;
2722
2783
  }
2723
- /** Result of simulating a policy against historical data */
2784
+ /** Result of simulating architecture policy against historical discoveries */
2724
2785
  export interface ArchPolicySimulationResult {
2725
2786
  rules_evaluated: number;
2726
2787
  would_block: number;
@@ -2728,133 +2789,98 @@ export interface ArchPolicySimulationResult {
2728
2789
  would_allow: number;
2729
2790
  affected_discoveries: Array<{
2730
2791
  task: string;
2731
- verdict: string;
2792
+ verdict: DiscoveryVerdict;
2732
2793
  triggered_rules: string[];
2733
2794
  action: 'block' | 'warn' | 'allow';
2734
2795
  }>;
2735
2796
  summary: string;
2736
2797
  }
2737
- /** Architecture Health Score (5-component, 0-100 scale) */
2738
- export interface ArchitectureHealthScore {
2739
- overall: number;
2740
- components: {
2741
- dri: number;
2742
- eds: number;
2743
- sts: number;
2744
- ofs: number;
2745
- dcs: number;
2746
- };
2747
- grade: 'A' | 'B' | 'C' | 'D' | 'F';
2748
- trend: 'improving' | 'stable' | 'declining';
2749
- }
2750
- /** A hotspot detected in the architecture */
2751
- export interface HealthHotspot {
2752
- system: string;
2753
- path: string;
2754
- duplication_pressure: number;
2755
- recent_violations: number;
2756
- risk: 'low' | 'medium' | 'high' | 'critical';
2757
- }
2758
- /** A change in source-of-truth assignment */
2759
- export interface SoTChange {
2760
- system: string;
2761
- previous_path: string | null;
2762
- current_path: string;
2763
- confidence_delta: number;
2764
- timestamp: string;
2765
- }
2766
- /** An entry in the override log */
2767
- export interface OverrideLogEntry {
2768
- task: string;
2769
- approved_by: string;
2770
- verdict_overridden: DiscoveryVerdict;
2771
- timestamp: string;
2772
- reason: string;
2773
- }
2774
- /** A health alert triggered by threshold breach */
2775
- export interface HealthAlert {
2776
- severity: 'critical' | 'warning';
2777
- message: string;
2778
- system: string | null;
2779
- metric: string;
2780
- value: number;
2781
- threshold: number;
2782
- }
2783
- /** A point-in-time health snapshot */
2784
- export interface HealthSnapshot {
2785
- timestamp: string;
2786
- commit_sha: string | null;
2787
- score: ArchitectureHealthScore;
2788
- hotspots: HealthHotspot[];
2789
- sot_changes: SoTChange[];
2790
- override_log: OverrideLogEntry[];
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;
2791
2811
  }
2792
- /** Full health dashboard with current state, history, and alerts */
2793
- export interface HealthDashboard {
2794
- current: HealthSnapshot;
2795
- history: HealthSnapshot[];
2796
- alerts: HealthAlert[];
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;
2797
2818
  }
2798
- /** An advisor recommendation for architecture improvements */
2799
- export interface AdvisorRecommendation {
2800
- rule_id: string;
2801
- name: string;
2802
- severity: 'critical' | 'warning' | 'info';
2819
+ /** A single validation issue in a context bundle */
2820
+ export interface ValidationIssue {
2821
+ code: string;
2822
+ severity: 'error' | 'warning' | 'info';
2803
2823
  message: string;
2804
- affected_systems: string[];
2805
- suggested_actions: string[];
2824
+ file?: string;
2825
+ symbol?: string;
2806
2826
  }
2807
- /** Drift velocity rate of architectural change */
2808
- export type DriftVelocityLevel = 'LOW' | 'RISING' | 'HIGH' | 'CRITICAL';
2809
- export interface DriftVelocity {
2810
- level: DriftVelocityLevel;
2811
- unique_tasks_1h: number;
2812
- unique_tasks_24h: number;
2813
- acceleration: number;
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;
2814
2839
  }
2815
- /** Priority level for interventions */
2816
- export type InterventionPriority = 'critical' | 'high' | 'medium' | 'low';
2817
- /** Result of running the intervention engine */
2818
- export interface InterventionResult {
2819
- interventions: Intervention[];
2820
- total_count: number;
2821
- critical_count: number;
2822
- high_count: number;
2823
- estimated_ahs_improvement: number;
2824
- generated_at: string;
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;
2825
2855
  }
2826
- /** Policy configuration for discovery enforcement */
2827
- export interface DiscoveryPolicyConfig {
2828
- block_on_strong_overlap: boolean;
2829
- enforce_symbol_growth: boolean;
2830
- max_new_exports: number;
2831
- duplicate_similarity_threshold: number;
2832
- require_human_override: boolean;
2833
- insertion_point_strictness: 'block' | 'warn';
2856
+ /** Result from enforcing discovery guardrails */
2857
+ export interface DiscoveryEnforcementResult {
2858
+ blocked: boolean;
2859
+ reason: string;
2860
+ guidance: string;
2861
+ verdict: DiscoveryVerdict | null;
2834
2862
  }
2835
- /** Sensible defaults for discovery policy */
2836
- export declare const DEFAULT_DISCOVERY_POLICY: DiscoveryPolicyConfig;
2837
- /** A diff compliance violation */
2863
+ /** A single diff compliance violation */
2838
2864
  export interface DiffComplianceViolation {
2839
2865
  type: 'prohibited_file' | 'outside_insertion_points' | 'parallel_directory';
2840
2866
  file: string;
2841
2867
  message: string;
2842
2868
  severity: 'error' | 'warn';
2843
2869
  }
2844
- /** Result of diff compliance check */
2870
+ /** Result of checking PR diff against discovery constraints */
2845
2871
  export interface DiffComplianceResult {
2846
2872
  status: 'pass' | 'warn' | 'fail';
2847
2873
  violations: DiffComplianceViolation[];
2848
2874
  files_checked: number;
2849
2875
  }
2850
- /** A detected duplicate file */
2876
+ /** A single duplicate detection match */
2851
2877
  export interface DuplicateEntry {
2852
2878
  new_file: string;
2853
2879
  existing_file: string;
2854
2880
  similarity: number;
2855
2881
  message: string;
2856
2882
  }
2857
- /** Result of duplicate detection */
2883
+ /** Result of content-based duplicate detection */
2858
2884
  export interface DuplicateDetectionResult {
2859
2885
  duplicates: DuplicateEntry[];
2860
2886
  files_checked: number;
@@ -2866,35 +2892,220 @@ export interface DiscoveryOverride {
2866
2892
  approved_by: string;
2867
2893
  timestamp: string;
2868
2894
  }
2869
- /** Validation result for a discovery override */
2895
+ /** Result of validating a discovery override */
2870
2896
  export interface DiscoveryOverrideValidation {
2871
2897
  valid: boolean;
2872
2898
  reason: string;
2873
2899
  approved_by: string | null;
2874
2900
  }
2875
- /** Result of the discovery check command */
2876
- export interface DiscoveryCheckResult {
2877
- verdict: DiscoveryVerdict;
2878
- overlap: OverlapClassification;
2879
- diff_compliance: DiffComplianceResult | null;
2880
- symbol_growth: SymbolGrowthResult | null;
2881
- duplicate_detection: DuplicateDetectionResult | null;
2882
- override: DiscoveryOverrideValidation | null;
2883
- policy: DiscoveryPolicyConfig | null;
2884
- passed: boolean;
2885
- summary: string;
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';
2886
2909
  }
2887
- /** Result of symbol growth analysis */
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 */
2888
2915
  export interface SymbolGrowthResult {
2889
2916
  status: 'pass' | 'warn' | 'fail';
2890
- files_analyzed: number;
2917
+ total_new_exports: number;
2918
+ unrelated_count: number;
2891
2919
  new_symbols: Array<{
2892
2920
  file: string;
2893
2921
  symbol: string;
2894
2922
  classification: 'expected' | 'suspicious' | 'unrelated';
2895
2923
  reason: string;
2896
2924
  }>;
2897
- total_new_exports: number;
2898
- unrelated_count: 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;
2899
3110
  }
2900
3111
  //# sourceMappingURL=index.d.ts.map