delta

package
v0.1.15 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 16, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package delta starts immutable A-to-B child review runs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChildExecutor

type ChildExecutor interface {
	ExecuteDelta(context.Context, ChildRequest) (ExecutionResult, error)
}

ChildExecutor executes and publishes a child run. It owns provider execution and P2 publication, while this service owns the child/source invariants.

type ChildRequest

type ChildRequest struct {
	Run            domain.Run
	SourceReviewID domain.ReviewID
	SourceTarget   ImmutableTarget
	CurrentTarget  ImmutableTarget
	Delta          Delta
}

ChildRequest is the fully trusted input supplied to child execution.

type Comparator

type Comparator interface {
	Compare(context.Context, ImmutableTarget, ImmutableTarget) (Delta, error)
}

Comparator compares exactly the two materialized snapshots. Delta may be empty; a nil error always denotes a comparable result.

type Delta

type Delta struct {
	Bytes []byte
}

Delta is comparator-owned opaque A-to-B material. Empty is valid.

type ExecutionResult

type ExecutionResult struct {
	SessionID         domain.SessionID
	RunID             domain.RunID
	ReviewArtifactURI string
	RoleReportURIs    []RoleReportURI
	// contains filtered or unexported fields
}

ExecutionResult binds the published artifact to the child run identity, verified committed role-report URIs, and the verified P2 terminal exit.

func NewExecutionResult

func NewExecutionResult(sessionID domain.SessionID, runID domain.RunID, reviewArtifactURI string, roleReportURIs []RoleReportURI, terminalExit domain.OperationalExitDecision) (ExecutionResult, error)

NewExecutionResult validates and binds the verified P2 terminal exit to one published delta child run.

func (ExecutionResult) TerminalExit

func (result ExecutionResult) TerminalExit() (domain.OperationalExitDecision, bool)

TerminalExit returns the immutable, verified P2 terminal exit decision.

func (ExecutionResult) ValidateTerminalExit

func (result ExecutionResult) ValidateTerminalExit() error

ValidateTerminalExit rejects results without a verified committed terminal exit.

type IdentityGenerator

type IdentityGenerator interface {
	NewRunID(time.Time) (domain.RunID, error)
}

IdentityGenerator supplies the fresh child run identity.

type ImmutableTarget

type ImmutableTarget struct {
	// contains filtered or unexported fields
}

ImmutableTarget preserves the request kind, exact bounded captured bytes, and canonical domain identity. Git metadata is retained only for a diff capture.

func NewByteImmutableTarget

func NewByteImmutableTarget(kind TargetKind, value string, targetBytes []byte) (ImmutableTarget, error)

NewByteImmutableTarget materializes a patch or stdin request without assigning Git object identities to non-Git input.

func NewGitImmutableTarget

func NewGitImmutableTarget(value string, captured ports.CapturedGitTarget) (ImmutableTarget, error)

NewGitImmutableTarget materializes a diff request from a resolved Git capture.

func NewGitImmutableTargetForKind

func NewGitImmutableTargetForKind(kind TargetKind, value string, captured ports.CapturedGitTarget) (ImmutableTarget, error)

func NewP2ImmutableTarget

func NewP2ImmutableTarget(identity domain.TargetIdentity, targetBytes []byte) (ImmutableTarget, error)

NewP2ImmutableTarget reconstructs an immutable target from P2-bound bytes and identity. Persisted targets intentionally have no mutable input selector.

func (ImmutableTarget) Bytes

func (target ImmutableTarget) Bytes() []byte

func (ImmutableTarget) CapturedArchive

func (target ImmutableTarget) CapturedArchive() []byte

func (ImmutableTarget) Identity

func (target ImmutableTarget) Identity() domain.TargetIdentity

func (ImmutableTarget) Kind

func (target ImmutableTarget) Kind() TargetKind

func (ImmutableTarget) SHA256

func (target ImmutableTarget) SHA256() string

func (ImmutableTarget) Value

func (target ImmutableTarget) Value() string

func (ImmutableTarget) WithCapturedArchive

func (target ImmutableTarget) WithCapturedArchive(archive []byte) (ImmutableTarget, error)

WithCapturedArchive binds the complete capture used to produce this target.

type Result

type Result struct {
	SessionID         domain.SessionID
	RunID             domain.RunID
	ReviewArtifactURI string
	RoleReportURIs    []RoleReportURI
	// contains filtered or unexported fields
}

Result is the exact child identity, published review artifact, verified committed role-report URIs, and verified P2 terminal exit decision.

func NewResult

func NewResult(sessionID domain.SessionID, runID domain.RunID, reviewArtifactURI string, roleReportURIs []RoleReportURI, terminalExit domain.OperationalExitDecision) (Result, error)

NewResult validates and binds the verified P2 terminal exit to the bounded delta application result.

func (Result) TerminalExit

func (result Result) TerminalExit() (domain.OperationalExitDecision, bool)

TerminalExit returns the immutable, verified P2 terminal exit decision.

func (Result) ValidateTerminalExit

func (result Result) ValidateTerminalExit() error

ValidateTerminalExit rejects results without a verified committed terminal exit.

type RoleReportURI added in v0.1.4

type RoleReportURI struct {
	Role string
	URI  string
}

RoleReportURI is one trusted project-relative role-report identity projected from a committed PublicationResult support inventory by childrun.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service coordinates the immutable delta child workflow. It owns source identity, role, and lineage checks; the executor owns child execution and publication.

func NewService

func NewService(clock ports.Clock, ids IdentityGenerator, sources SourceReader, capturer TargetCapturer, comparator Comparator, executor ChildExecutor) (*Service, error)

NewService constructs a delta service with the narrow capabilities needed to create a child run. Every dependency is required because omissions would weaken a fail-closed source or child invariant.

func (*Service) StartDeltaRun

func (service *Service) StartDeltaRun(ctx context.Context, request StartRequest) (Result, error)

StartDeltaRun captures the current target, compares it with the verified source snapshot, and delegates a fresh, lineage-bound child to the executor. It returns only after re-reading the source receipt to prove source invariance.

type SourceReader

type SourceReader interface {
	ReadSource(context.Context, domain.RunID) (SourceSnapshot, error)
}

SourceReader reads only a semantically verified P2 source snapshot. It must not derive authority from artifact filenames or mutable references.

type SourceSnapshot

type SourceSnapshot struct {
	SessionID      domain.SessionID
	RunID          domain.RunID
	ReviewID       domain.ReviewID
	Roles          []domain.RoleTask
	Target         ImmutableTarget
	FinalSHA256    string
	ManifestSHA256 string
	Receipt        string
}

SourceSnapshot is the verified P2 source authority used by delta. Every identity and artifact operand is read explicitly from the persisted source; no in-memory run is accepted as substitute authority.

type StartRequest

type StartRequest struct {
	SourceRunID domain.RunID
	Target      TargetRequest
	Roles       []domain.Role
}

StartRequest is the bounded delta workflow request.

type TargetCapturer

type TargetCapturer interface {
	CaptureTarget(context.Context, TargetRequest) (ImmutableTarget, error)
}

TargetCapturer captures the requested current target to immutable bytes and a kind-appropriate domain identity.

type TargetKind

type TargetKind string

TargetKind identifies the canonical input selected for the current target capture. Diff is a Git-backed capture; patch and stdin are byte captures.

const (
	TargetWorkspace TargetKind = "workspace"
	TargetStage     TargetKind = "stage"
	TargetDirty     TargetKind = "dirty"
	TargetDiff      TargetKind = "diff"
	TargetPatch     TargetKind = "patch"
	TargetStdin     TargetKind = "stdin"
)

type TargetRequest

type TargetRequest struct {
	Kind  TargetKind
	Value string
}

TargetRequest contains only an untrusted selector. Capturers must resolve it to a materialized immutable target before returning.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL