Skip to main content

exocortex_pack_dev_v1/
lib.rs

1//! The v1 developer-domain pack (§7.1, §7.2, §7.3, §7.18).
2//!
3//! 13 memory types × 12 entity types × 48 relationship kinds across 8 buckets.
4//! This crate is the sole pack v1 links; adding a second pack in v2 is purely
5//! additive.
6
7use exocortex_kernel::pack;
8
9/// Link anchor consumed by production entrypoints through the pack-agnostic
10/// kernel contract. Removing this crate from the link leaves the symbol
11/// unresolved, so a packless binary cannot be produced accidentally.
12#[no_mangle]
13pub extern "C" fn exocortex_required_ontology_pack_anchor() {}
14
15pack! {
16    name: "exocortex-pack-dev-v1",
17    version: "1.0.0",
18    kernel_min: "1.0.0",
19
20    memory_types! {
21        Task, CodePattern, Problem, Solution, Project, Technology,
22        Error, Fix, Command, FileContext, Workflow, General, Conversation,
23    }
24
25    entity_types! {
26        File, Function, Class, Error, Technology, Concept,
27        Person, Project, Command, Package, Url, Variable,
28    }
29
30    // W6 (audit): R-T14's computed-only kinds — Dreams is the only
31    // legitimate producer; the ingest boundary reads THIS marker, not a
32    // string literal.
33    computed_only_kinds! {
34        SimilarTo,
35    }
36
37    kinds! {
38        // Solution bucket (5) — kernel-const SOLVES is bound to `Solves`.
39        Solves        => bucket: Solution,   inverse: SolvedBy,     bi: false, default_strength: 0.85, kernel_const: SOLVES,
40        Addresses     => bucket: Solution,   inverse: AddressedBy,  bi: false, default_strength: 0.70,
41        AlternativeTo => bucket: Solution,   inverse: Self,         bi: true,  default_strength: 0.60,
42        Improves      => bucket: Solution,   inverse: ImprovedBy,   bi: false, default_strength: 0.70,
43        Replaces      => bucket: Solution,   inverse: ReplacedBy,   bi: false, default_strength: 0.90,
44
45        // Causal bucket (7) — kernel-const FIXES/CAUSES bound below.
46        Causes        => bucket: Causal,     inverse: CausedBy,     bi: false, default_strength: 0.85, kernel_const: CAUSES,
47        Prevents      => bucket: Causal,     inverse: PreventedBy,  bi: false, default_strength: 0.80,
48        Triggers      => bucket: Causal,     inverse: TriggeredBy,  bi: false, default_strength: 0.75,
49        LeadsTo       => bucket: Causal,     inverse: FollowsFrom,  bi: false, default_strength: 0.70,
50        Enables       => bucket: Causal,     inverse: EnabledBy,    bi: false, default_strength: 0.65,
51        Blocks        => bucket: Causal,     inverse: BlockedBy,    bi: false, default_strength: 0.75,
52        Fixes         => bucket: Causal,     inverse: FixedBy,      bi: false, default_strength: 0.90, kernel_const: FIXES,
53
54        // Context bucket (9)
55        Uses          => bucket: Context,    inverse: UsedBy,       bi: false, default_strength: 0.70,
56        Requires      => bucket: Context,    inverse: RequiredBy,   bi: false, default_strength: 0.85,
57        DependsOn     => bucket: Context,    inverse: DependedBy,   bi: false, default_strength: 0.75,
58        Contains      => bucket: Context,    inverse: ContainedBy,  bi: false, default_strength: 0.70,
59        PartOf        => bucket: Context,    inverse: HasPart,      bi: false, default_strength: 0.70,
60        InSession     => bucket: Context,    inverse: HasMember,    bi: false, default_strength: 0.80, kernel_const: IN_SESSION,
61        InProject     => bucket: Context,    inverse: ProjectHas,   bi: false, default_strength: 0.80,
62        WrittenIn     => bucket: Context,    inverse: Powers,       bi: false, default_strength: 0.65,
63        Modifies      => bucket: Context,    inverse: ModifiedBy,   bi: false, default_strength: 0.65,
64
65        // Learning bucket (6)
66        Teaches       => bucket: Learning,   inverse: LearnedFrom,  bi: false, default_strength: 0.70,
67        Demonstrates  => bucket: Learning,   inverse: Self,         bi: true,  default_strength: 0.65,
68        Contradicts   => bucket: Learning,   inverse: Self,         bi: true,  default_strength: 0.80,
69        Confirms      => bucket: Learning,   inverse: ConfirmedBy,  bi: false, default_strength: 0.75,
70        BuildsOn      => bucket: Learning,   inverse: BuiltOnBy,    bi: false, default_strength: 0.75,
71        Specializes   => bucket: Learning,   inverse: Generalizes,  bi: false, default_strength: 0.70,
72
73        // Similarity bucket (4)
74        SimilarTo     => bucket: Similarity, inverse: Self,         bi: true,  default_strength: 0.60,
75        DifferentFrom => bucket: Similarity, inverse: Self,         bi: true,  default_strength: 0.55,
76        AnalogousTo   => bucket: Similarity, inverse: Self,         bi: true,  default_strength: 0.55,
77        RelatedTo     => bucket: Similarity, inverse: Self,         bi: true,  default_strength: 0.30,
78
79        // Workflow bucket (6)
80        Precedes      => bucket: Workflow,   inverse: Follows,      bi: false, default_strength: 0.70,
81        ParallelTo    => bucket: Workflow,   inverse: Self,         bi: true,  default_strength: 0.50,
82        Executes      => bucket: Workflow,   inverse: ExecutedBy,   bi: false, default_strength: 0.75,
83        Creates       => bucket: Workflow,   inverse: CreatedBy,    bi: false, default_strength: 0.75,
84        Configures    => bucket: Workflow,   inverse: ConfiguredBy, bi: false, default_strength: 0.65,
85        Automates     => bucket: Workflow,   inverse: AutomatedBy,  bi: false, default_strength: 0.75,
86
87        // Quality bucket (5)
88        Validates     => bucket: Quality,    inverse: ValidatedBy,  bi: false, default_strength: 0.75,
89        Tests         => bucket: Quality,    inverse: TestedBy,     bi: false, default_strength: 0.75,
90        Measures      => bucket: Quality,    inverse: MeasuredBy,   bi: false, default_strength: 0.65,
91        Documents     => bucket: Quality,    inverse: DocumentedBy, bi: false, default_strength: 0.65,
92        Verifies      => bucket: Quality,    inverse: VerifiedBy,   bi: false, default_strength: 0.75,
93
94        // Integration bucket (6)
95        IntegratesWith=> bucket: Integration,inverse: Self,         bi: true,  default_strength: 0.70,
96        Consumes      => bucket: Integration,inverse: ConsumedBy,   bi: false, default_strength: 0.70,
97        Produces      => bucket: Integration,inverse: ProducedBy,   bi: false, default_strength: 0.70,
98        Exposes       => bucket: Integration,inverse: ExposedBy,    bi: false, default_strength: 0.65,
99        Wraps         => bucket: Integration,inverse: WrappedBy,    bi: false, default_strength: 0.70,
100        Bridges       => bucket: Integration,inverse: BridgedBy,    bi: false, default_strength: 0.70,
101    }
102
103    type_triples! {
104        // Solution
105        Solves        => (Solution | Fix, Problem | Error),
106        Addresses     => (Solution | Fix, Problem | Error),
107        AlternativeTo => (Solution | Fix, Solution | Fix),
108        Improves      => (Solution | Fix | CodePattern, Solution | Fix | CodePattern | Task),
109        Replaces      => (_, _),
110        // Causal
111        Causes        => (_, Error | Problem),
112        Prevents      => (Solution | Fix | CodePattern, Error | Problem),
113        Fixes         => (Fix, Error | Problem),
114        Triggers      => (_, _), LeadsTo => (_, _), Enables => (_, _), Blocks => (_, _),
115        // Context
116        // NOTE (PRD §7.18 conflict): `Package` is an EntityType, not a
117        // MemoryType; it is dropped from both `Uses` and `Requires` to-sides.
118        // Recorded in the M1 report.
119        Uses          => (_, Technology | Command),
120        Requires      => (_, Technology),
121        DependsOn     => (_, _),
122        Contains      => (_, _),
123        PartOf        => (_, _),
124        InSession     => (_, Conversation),
125        InProject     => (_, Project),
126        WrittenIn     => (CodePattern | FileContext, Technology),
127        Modifies      => (Task | Command | Fix, FileContext),
128        // Learning
129        Teaches       => (_, _), Demonstrates => (_, _), Contradicts => (_, _),
130        Confirms      => (_, _), BuildsOn => (_, _), Specializes => (_, _),
131        // Similarity
132        SimilarTo     => (_, _), DifferentFrom => (_, _), AnalogousTo => (_, _), RelatedTo => (_, _),
133        // Workflow
134        Precedes      => (_, _), ParallelTo => (_, _), Executes => (Command, _),
135        Creates       => (Task | Command | Fix, FileContext),
136        Configures    => (_, _), Automates => (Workflow | Command, _),
137        // Quality
138        Validates     => (_, _), Tests => (_, _), Measures => (_, _),
139        Documents     => (_, _), Verifies => (_, _),
140        // Integration
141        IntegratesWith=> (_, _), Consumes => (_, _), Produces => (_, _),
142        Exposes       => (_, _), Wraps => (_, _), Bridges => (_, _),
143    }
144
145    // Rules R1-R9 live in the kernel (§10.2). Pack-local rules are D1-D6 and
146    // only fire on pack-owned kinds. They MUST NOT bind kernel-const kinds
147    // directly by numeric id; they reference them by name so the kernel can
148    // inject the interned RelKindId at compile time (see kernel::rules::pack_scope!).
149    crepe_rules! {
150        // D1: `Fix Fixes Problem` implies `Fix Solves Problem` (subsumption).
151        implied_solves(a, b) <- edge(a, b, Fixes), memory(a, MemoryType::Fix, _);
152        // D2: `A BuildsOn B` and `B BuildsOn C` implies `A BuildsOn C` (transitivity, k=3 bounded).
153        transitive_builds_on(a, c) <- edge(a, b, BuildsOn), edge(b, c, BuildsOn);
154        // D3: `A Blocks B` and `B Requires C` implies `A Blocks C` (indirect blocker).
155        indirect_blocker(a, c) <- edge(a, b, Blocks), edge(b, c, Requires);
156        // D4: contradiction cluster - if A Contradicts B and B Confirms C then A Contradicts C.
157        contradiction_propagates(a, c) <- edge(a, b, Contradicts), edge(b, c, Confirms);
158        // D5: file-lineage propagation - if a Task Modifies F, and Fix Modifies F later, they share a target.
159        shared_target(a, b, f) <- edge(a, f, Modifies), edge(b, f, Modifies), memory(a, _, _), memory(b, _, _), a != b;
160        // D6: session cohesion - all memories `InSession S` are candidates for MCR2 grouping.
161        session_cohort(m, s) <- edge(m, s, InSession);
162    }
163}