rerun

package
v0.1.20 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package rerun starts immutable child runs that replay a verified source attempt.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidRequest identifies an invalid rerun request.
	ErrInvalidRequest = errors.New("invalid rerun request")
	// ErrSourceCorrupt identifies a source whose immutable replay material is not intact.
	ErrSourceCorrupt = errors.New("corrupt rerun source")
	// ErrSourceMutated identifies a source changed while its child was started.
	ErrSourceMutated = errors.New("rerun source mutated")
	// ErrInvalidChild identifies a replay executor result that violates child invariants.
	ErrInvalidChild = errors.New("invalid rerun child")
)

Functions

func SourceAttemptSHA256

func SourceAttemptSHA256(source SourceAttempt) string

SourceAttemptSHA256 returns the domain-separated digest adapters must bind to verified immutable source-attempt material. ImmutableSHA256 itself is excluded.

Types

type ChildPublicationContext

type ChildPublicationContext struct {
	SessionID                    domain.SessionID
	ParentRunID                  domain.RunID
	SourceRunID                  domain.RunID
	SourceReviewID               domain.ReviewID
	SourceRecoveryManifestSHA256 string
	SourceAttemptID              domain.AttemptID
	SourceManifestURI            string
	SourceManifestSHA256         string
	ReplayMode                   ReplayMode
}

ChildPublicationContext binds a new child publication to the immutable source authority. The executor must preserve every field in its result.

type ChildReplay

type ChildReplay struct {
	SessionID                    domain.SessionID
	ParentRunID                  domain.RunID
	SourceRunID                  domain.RunID
	SourceReviewID               domain.ReviewID
	SourceRecoveryManifestSHA256 string
	SourceAttemptID              domain.AttemptID
	Mode                         ReplayMode
	Target                       Target
	Scope                        string
	Role                         string
	Publication                  ChildPublicationContext
	Run                          domain.Run
	Assignments                  []review.Assignment

	// Exact is populated only for exact replay. It deliberately includes the
	// original adapter profile and parameters, plus source prompt authority.
	Exact *ExactInput
}

ChildReplay contains defensive copies of verified source authority and a freshly constructed lineage/publication context for one child execution.

type ChildReplayExecutor

type ChildReplayExecutor interface {
	ExecuteChildReplay(context.Context, ChildReplay) (ChildReplayResult, error)
}

ChildReplayExecutor creates and executes a child replay. A successful result must contain a new run and execution identity in the source session.

type ChildReplayResult

type ChildReplayResult struct {
	SessionID                    domain.SessionID
	RunID                        domain.RunID
	ParentRunID                  domain.RunID
	SourceRunID                  domain.RunID
	SourceReviewID               domain.ReviewID
	SourceRecoveryManifestSHA256 string
	SourceAttemptID              domain.AttemptID
	ExecutionInvocationID        string
	PromptIdentity               string
	PromptManifestURI            string
	PromptManifestSHA256         string
	ReplayMode                   ReplayMode
	ExactReplay                  bool
	RoleReportURIs               []RoleReportURI
	// contains filtered or unexported fields
}

ChildReplayResult is the child identity, persisted prompt-manifest view, verified committed role-report URIs, and verified P2 terminal exit decision.

func NewChildReplayResult

func NewChildReplayResult(sessionID domain.SessionID, runID, parentRunID, sourceRunID domain.RunID, sourceReviewID domain.ReviewID, sourceAttemptID domain.AttemptID, executionInvocationID, promptIdentity, promptManifestURI, promptManifestSHA256 string, replayMode ReplayMode, exactReplay bool, roleReportURIs []RoleReportURI, terminalExit domain.OperationalExitDecision) (ChildReplayResult, error)

NewChildReplayResult validates and binds the verified P2 terminal exit to one published rerun child.

func (ChildReplayResult) TerminalExit

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

TerminalExit returns the immutable, verified P2 terminal exit decision.

func (ChildReplayResult) ValidateTerminalExit

func (result ChildReplayResult) ValidateTerminalExit() error

ValidateTerminalExit rejects results without a verified committed terminal exit.

type ChildRunIssuer

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

ChildRunIssuer issues only fresh child run identities.

type Config

type Config struct {
	Clock       ports.Clock
	IDs         ChildRunIssuer
	Assignments []review.Assignment
}

Config is the required authority used to construct rerun children.

type ExactInput

type ExactInput struct {
	ComposedStdin               []byte
	ComposedStdinSHA256         string
	CompleteStdinSHA256         string
	SourceInvocationID          string
	SourceExecutionInvocationID string
	TemplateID                  string
	TemplateVersion             string
	TemplateSHA256              string
	AdapterProfile              string
	SourceProviderInstance      string
	Parameters                  []Parameter
	SourceManifestURI           string
	SourceManifestSHA256        string
}

ExactInput is the exact replay-only provider wire contract.

type Parameter

type Parameter struct {
	Name  string
	Value string
}

Parameter is one immutable adapter parameter captured with an attempt.

type PromptManifest

type PromptManifest struct {
	URI                   string
	SHA256                string
	ComposedStdin         []byte
	ComposedStdinSHA256   string
	CompleteStdinSHA256   string
	SourceInvocationID    string
	ExecutionInvocationID string
	TemplateID            string
	TemplateVersion       string
	TemplateSHA256        string
	AdapterProfile        string
	Parameters            []Parameter
	Scope                 string
	Role                  string
}

PromptManifest is the verified source prompt material needed for exact replay. Source manifest identity binds the child prompt to its authority.

type ReplayMode

type ReplayMode string

ReplayMode controls whether source provider wire bytes are replayed or a new prompt is composed from current trusted configuration.

const (
	ExactReplay     ReplayMode = "exact"
	RecomposeReplay ReplayMode = "recompose"
)

func (ReplayMode) Valid

func (mode ReplayMode) Valid() bool

type Request

type Request struct {
	SourceRunID     domain.RunID
	SourceAttemptID domain.AttemptID
	ReplayMode      ReplayMode
}

Request identifies the immutable source attempt to rerun.

type Result

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

Result is the bounded application result exposed to command wiring, including verified committed role-report URIs and the verified P2 terminal exit.

func NewResult

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

NewResult validates and binds the verified P2 terminal exit to the bounded rerun 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 starts child replay runs from verified, immutable attempt material.

func NewService

func NewService(sources SourceReader, executor ChildReplayExecutor, config Config) (*Service, error)

NewService constructs a rerun service with the authority to read verified sources and execute fresh child runs.

func (*Service) StartRerun

func (service *Service) StartRerun(ctx context.Context, request Request) (Result, error)

StartRerun reads one immutable source attempt and executes it as a distinct child run. Once a valid child result is returned, the committed effect is never retried; source re-observation continues without caller cancellation so late cancellation cannot hide that effect.

type SourceAttempt

type SourceAttempt struct {
	SessionID              domain.SessionID
	RunID                  domain.RunID
	ReviewID               domain.ReviewID
	RecoveryManifestSHA256 string
	AttemptID              domain.AttemptID
	ProviderInstance       string
	Target                 Target
	Prompt                 PromptManifest
	ImmutableSHA256        string
}

SourceAttempt is a verified immutable source attempt. ImmutableSHA256 must change whenever any source bytes or replay-relevant identity changes.

func SourceFromRecovery added in v0.1.20

func SourceFromRecovery(snapshot recovery.Snapshot, attemptID domain.AttemptID) (SourceAttempt, error)

func (SourceAttempt) Reference added in v0.1.20

func (source SourceAttempt) Reference() (domain.SourceReference, error)

type SourceReader

type SourceReader interface {
	ReadRerunSource(context.Context, domain.RunID, domain.AttemptID) (SourceAttempt, error)
}

SourceReader is the narrow authority for verified source attempt, target, and prompt-manifest reads. Implementations must require P2 or a verified failed-run recovery manifest.

type Target

type Target struct {
	Identity        domain.TargetIdentity
	Bytes           []byte
	SHA256          string
	CapturedArchive []byte
}

Target is a captured immutable target. Identity and bytes are copied at package boundaries so neither readers nor executors can modify source material.

Jump to

Keyboard shortcuts

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