ingest blueprint phase

This commit is contained in:
2026-05-25 01:19:10 -06:00
parent af3e18758b
commit 44d9d2065c
3 changed files with 157 additions and 7 deletions
@@ -0,0 +1,90 @@
module IngestSnapshot.DeterministicBundleIngest
open IngestSnapshot.SharedModel
// 1. Primitives
type TaintedBundleInput = TaintedBundleInput of BundleSource
type DerivedRunIdentity = DerivedRunIdentity of RunIdentity
type BoundaryProof = BoundaryProof of string
type RequiredArtifact =
| RunManifestArtifact
| SegmentRecordsArtifact
| CanonicalProjectionArtifact
type IngestFailureReason =
| BundleNotParseable
| RunIdentityCouldNotBeDerived
| NoDeterministicBoundaryProven
| RequiredArtifactMissing of RequiredArtifact
// 2. Commands (Inputs)
type IngestUpstreamSnapshot =
{ SnapshotIdentity: SnapshotIdentity
BundleInput: TaintedBundleInput
SnapshotMetadata: SnapshotMetadata option
PreviousRunManifest: RunManifest option }
// 3. Events (Facts)
type UpstreamSnapshotIngested =
{ RunManifest: RunManifest
SegmentRecords: SegmentRecord list
CanonicalProjectionPath: CanonicalProjectionPath
SummaryPath: SummaryPath option }
type SnapshotIngestHardStopped =
{ SnapshotIdentity: SnapshotIdentity
Reason: IngestFailureReason }
type Event =
| UpstreamSnapshotIngested of UpstreamSnapshotIngested
// 4. Errors
type Error =
| SnapshotIngestHardStopped of SnapshotIngestHardStopped
// 5. State (Aggregates)
type AwaitingSnapshotSelection =
{ RunIdentityRulesDescription: string
BoundaryRulesDescription: string
RequiredArtifacts: RequiredArtifact list }
type SnapshotReady =
{ SelectedSnapshot: SelectedSnapshot
PreviousRunManifest: RunManifest option
RequiredArtifacts: RequiredArtifact list }
type DeterministicSegmentsReady =
{ RunIdentity: RunIdentity
SelectedSnapshot: SelectedSnapshot
PreviousRunManifest: RunManifest option
SegmentRecords: SegmentRecord list
BoundaryProofs: BoundaryProof list
RequiredArtifacts: RequiredArtifact list }
type State =
| AwaitingSnapshotSelection of AwaitingSnapshotSelection
| SnapshotReady of SnapshotReady
| DeterministicSegmentsReady of DeterministicSegmentsReady
| SnapshotIngested of UpstreamSnapshotIngested
// 6. Contract Signatures
val deriveRunIdentity : SelectedSnapshot -> Result<DerivedRunIdentity, Error>
val validateSnapshotSelection : State -> IngestUpstreamSnapshot -> Result<SnapshotReady, Error>
val decideSegmentRecords : SnapshotReady -> Result<DeterministicSegmentsReady, Error>
val decide : State -> IngestUpstreamSnapshot -> Result<Event, Error>
val apply : State -> Event -> State
val workflow : IngestUpstreamSnapshot -> Effect.Effect<Result<Event, Error>>
@@ -0,0 +1,60 @@
module IngestSnapshot.SharedModel
// 1. Shared primitives
type SnapshotIdentity = SnapshotIdentity of string
type BundleSource = BundleSource of string
type RunIdentity = RunIdentity of string
type SourceSpan =
{ StartOffset: int
EndOffset: int }
type AstNodeKind = AstNodeKind of string
type RawHash = RawHash of string
type NormalizedHash = NormalizedHash of string
type ShapeHash = ShapeHash of string
type ManifestPath = ManifestPath of string
type SegmentsPath = SegmentsPath of string
type CanonicalProjectionPath = CanonicalProjectionPath of string
type SummaryPath = SummaryPath of string
// 2. Shared compounds
type SnapshotMetadata =
{ ReleaseNotesSource: string option
CollectedAt: string option }
type SelectedSnapshot =
{ SnapshotIdentity: SnapshotIdentity
BundleSource: BundleSource
SnapshotMetadata: SnapshotMetadata option }
type SegmentHashes =
{ RawHash: RawHash
NormalizedHash: NormalizedHash
ShapeHash: ShapeHash }
type SegmentRecord =
{ SegmentId: string
SourceSpan: SourceSpan
AstNodeKind: AstNodeKind
CanonicalSource: string
Hashes: SegmentHashes }
type RunManifest =
{ RunIdentity: RunIdentity
SnapshotIdentity: SnapshotIdentity
ManifestPath: ManifestPath
SegmentsPath: SegmentsPath
CanonicalProjectionPath: CanonicalProjectionPath
SummaryPath: SummaryPath option }