Reference implementation for the Phoenix Architecture. Work in progress. aicoding.leaflet.pub/
ai coding crazy
at main 54 lines 1.9 kB view raw
1/** 2 * Negative Knowledge model — what was tried and failed. 3 * 4 * "What failed matters as much as what succeeded, and it disappears first." 5 * Failed generation attempts, rejected approaches, incident-driven constraints. 6 * Preserved across compaction. The system's immune memory. 7 * 8 * (See: Fowler, The Phoenix Architecture, Chapter 14) 9 */ 10 11export type NegativeKnowledgeKind = 12 | 'failed_generation' // generation attempt that didn't pass evaluations 13 | 'rejected_approach' // architectural approach tried and abandoned 14 | 'incident_constraint' // constraint added after a production incident 15 | 'deprecated_behavior' // behavior intentionally removed with reason 16 | 'known_limitation'; // known issue accepted with rationale 17 18export interface NegativeKnowledge { 19 /** Unique ID */ 20 nk_id: string; 21 /** What kind of negative knowledge */ 22 kind: NegativeKnowledgeKind; 23 /** Which IU or canonical node this applies to */ 24 subject_id: string; 25 /** Subject type */ 26 subject_type: 'iu' | 'canonical_node' | 'system'; 27 /** Human-readable description of what was tried */ 28 what_was_tried: string; 29 /** Why it failed or was rejected */ 30 why_it_failed: string; 31 /** What constraint or lesson this implies for future regeneration */ 32 constraint_for_future: string; 33 /** Reference to incident, post-mortem, or decision record */ 34 reference?: string; 35 /** When this knowledge was recorded */ 36 recorded_at: string; 37 /** Who recorded it */ 38 recorded_by?: string; 39 /** Is this still relevant? (can be marked stale) */ 40 active: boolean; 41} 42 43/** 44 * Check if a regeneration should consult negative knowledge before proceeding. 45 */ 46export function hasRelevantNegativeKnowledge( 47 records: NegativeKnowledge[], 48 subjectId: string, 49): NegativeKnowledge[] { 50 return records.filter(nk => 51 nk.active && 52 nk.subject_id === subjectId 53 ); 54}