Phase Contracts¶
Documentation of the input/output contracts and interfaces for each pipeline phase.
Common Interfaces¶
PhaseRunner¶
Base interface implemented by all pipeline phases.
Bases: ABC, Generic[InputT]
Base for every pipeline phase. Each phase accepts a typed input contract and returns an artifact collection. Phases may still project to the graph incrementally for crash resilience, but artifact collections are the runtime handoff.
The Pipeline class composes PhaseRunner instances into a DAG and exposes .run(), .run_phase(n), and .run_from_phase(n).
Dispatch contract (O-09)¶
The orchestrator needs three things from a phase that name cannot
safely supply: which config block to fingerprint, whether to persist its
artifacts, and which artifact view to feed it. Those used to be recovered
by string-matching name (name.startswith("Phase 3b")), which made a
display string load-bearing — renaming a phase silently changed its
behaviour, and the match order mattered ("Phase 3b" had to be tested before
"Phase 3"). They are now explicit class attributes.
Source code in packages/episteme-pipeline/episteme_pipeline/protocols/phase_runner.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | |
PipelineInput¶
Standard input structure for pipeline execution.
Bases: BaseModel
Entry point for the full pipeline.
Parameters¶
source_paths : list[str] File paths to the source documents to ingest and process. bib_paths : list[str | Path], optional Optional file paths to bibliography references (.bib), by default empty list. metadata : dict[str, str], optional Arbitrary execution metadata strings, by default empty dict. structural_anchor : GlobalStructuralAnchor | None, optional Global structural anchor coordinate system (ToC outline, document summary, and/or global thesis) for the target document or pipeline run, by default None.
Source code in packages/episteme-pipeline/episteme_pipeline/contracts/phase_contracts.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | |
Phase 1: Data Foundation¶
Handles document parsing and chunking operations.
Input Contract¶
Accepts raw document paths and bibliographic information.
Output Contract¶
Produces chunked text representations with provenance metadata.
Bases: BaseModel
Source code in packages/episteme-pipeline/episteme_pipeline/contracts/domain.py
56 57 58 59 60 61 62 63 64 | |
Bases: BaseModel
Source code in packages/episteme-pipeline/episteme_pipeline/contracts/domain.py
67 68 69 70 71 72 73 74 75 | |
Phase 2: Entity Discovery¶
Extracts and types entities from chunked text.
Domain Objects¶
Bases: BaseModel
Layer 2 (global/logical) entity representation.
Attributes¶
id : str The unique identifier for the entity (typically a UUID or stable hash). label : str The entity category or class label (e.g., 'CONCEPT', 'PERSON', 'WORK'). name : str The canonical name of the entity. description : str, optional A synthesized textual description of what the entity represents. textual_envelope : str, optional The original text context where this entity was first discovered. is_mature : bool, default False Flag indicating if the entity's description has gone through the Stage 2 maturation protocol. If True, the description is stable, centroid-fused, and protected against further epistemic drift. source_chunk_ids : list of str, default [] Identifiers of all the source chunks where this entity has been mentioned.
Source code in packages/episteme-pipeline/episteme_pipeline/contracts/domain.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | |
Phase 3: Relation Extraction¶
Identifies relationships between entities.
Domain Objects¶
Bases: BaseModel
Source code in packages/episteme-pipeline/episteme_pipeline/contracts/domain.py
109 110 111 112 113 114 115 116 117 118 | |
Phase 3b: Latent Graph Consolidation¶
Performs a fast mathematical sweep over dense vectors and 1-hop relation edge Jaccard similarity to merge duplicate Layer 2 entity nodes before Phase 4.
Phase Runner¶
Bases: PhaseRunner[Phase3ArtifactsView]
Runner for Phase 3b: Latent Graph Consolidation.
A fast mathematical sweep over dense vectors to merge duplicate nodes caused by parallel processing collisions. Runs without LLM calls.
Source code in packages/episteme-pipeline/episteme_pipeline/phases/phase3b_consolidation/__init__.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
__init__(config, *, embedding_model, graph_store, instance_fusion=None)
¶
Initialize the Phase 3b runner.
Parameters¶
config : Phase3bConfig Configuration settings for Phase 3b. embedding_model : object The embedding model used to project textual envelopes into vector space. graph_store : FusionGraph The graph database store to interact with the constructed graph. instance_fusion : InstanceFusion, optional An optional custom InstanceFusion implementation. Defaults to LatentGraphConsolidation.
Source code in packages/episteme-pipeline/episteme_pipeline/phases/phase3b_consolidation/__init__.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | |
run(input, context)
async
¶
Run the Latent Graph Consolidation phase.
Sweeps the graph L2 nodes, finds duplicates using vector similarity and 1-hop relation overlap, and generates Canonicalization artifacts representing the duplicate-to-canonical mapping.
Parameters¶
input : Phase3ArtifactsView View of the artifacts generated up to Phase 3. context : ArtifactExecutionContext The context of the current pipeline execution.
Returns¶
ArtifactCollection A collection of canonicalization artifacts.
Source code in packages/episteme-pipeline/episteme_pipeline/phases/phase3b_consolidation/__init__.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
Phase 4: Entity Maturation¶
Synthesizes canonical descriptions and resolves entity-level epistemic drift.
Phase Runner¶
Bases: PhaseRunner[Phase3ArtifactsView]
Runner for Phase 4: Entity Maturation (Batch Epistemic Synthesis).
This phase addresses the 'epistemic drift' problem in knowledge graph construction.
Instead of using a naive 'first-mention-wins' approach to name and describe entities,
this phase runs after Phase 3 to mature and stabilize entities before fusion:
1. Fetches all mention context envelopes (from EXTRACTED_FROM relations).
2. Encodes envelopes using the Phase 2 Bi-Encoder.
3. Calculates the geometric centroid of the vectors to find the core meaning.
4. Ranks envelopes and selects the top-K closest to the centroid.
5. Calls the LLM to synthesize a canonical description from these top-K envelopes.
6. Persists the matured entity and marks it as mature (is_mature = True).
Parameters¶
config : Phase4EntityMaturationConfig Configuration options for maturation (e.g. top-K envelopes to select). llm : LiteLLM LLM instance used for structured description synthesis. graph_store : ProcessingGraph The underlying Neo4j/graph database client.
Source code in packages/episteme-pipeline/episteme_pipeline/phases/phase4_entity_maturation/__init__.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 | |
Phase 4: Argument Mining¶
Constructs argumentative structures from text components.
Domain Objects¶
Bases: BaseModel
Source code in packages/episteme-pipeline/episteme_pipeline/contracts/domain.py
187 188 189 190 191 192 193 194 195 196 197 198 199 | |
Phase 5b: Theory Fusion & Argument Clustering¶
Groups semantically equivalent argument components and performs theory-level graph clustering.
Phase Runner¶
Bases: PhaseRunner[Phase4ArtifactsView]
Source code in packages/episteme-pipeline/episteme_pipeline/phases/phase5_fusion/argument_web.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | |
Artifact Views¶
Standardized views of phase outputs for downstream consumption.
Phase 1 Artifacts¶
Source code in packages/episteme-pipeline/episteme_pipeline/artifacts/execution.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | |
Phase 2 Artifacts¶
Source code in packages/episteme-pipeline/episteme_pipeline/artifacts/execution.py
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | |
Phase 3 Artifacts¶
Source code in packages/episteme-pipeline/episteme_pipeline/artifacts/execution.py
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | |
Phase 4 Artifacts¶
Source code in packages/episteme-pipeline/episteme_pipeline/artifacts/execution.py
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 | |