adaptive

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package adaptive is a pure next-action SDLC loop. A driver resolves each assignment with an enrolled worker and feeds a structured result back.

Index

Constants

View Source
const (
	Planning     = "planning"
	Implementing = "implementing"
	Verifying    = "verifying"
	Assessing    = "assessing"
	Specializing = "specializing"
	Done         = "done"
	Paused       = "paused"
	Draining     = "draining"
)
View Source
const (
	IntegrationStatusPending    = "pending"
	IntegrationStatusApplied    = "applied"
	IntegrationStatusConflict   = "conflict"
	IntegrationStatusRepair     = "repair"
	IntegrationStatusPaused     = "paused-for-human"
	IntegrationStatusRolledBack = "rolled-back"
)

Integration outcome statuses persisted on the supervisor-owned record.

View Source
const (
	ApplyPreserveDirty = "preserve-dirty"
	RollbackExplicit   = "explicit-rollback-of-applied-paths"
)

Apply/rollback policies are explicit so operators can inspect intent.

View Source
const (
	ArtifactPlan     = "plan.md"
	ArtifactChecks   = "checks.json"
	ArtifactSubtasks = "subtasks.json"
)

Artifact names persisted for a successful planned handoff.

View Source
const (
	MaxPlanChecks            = 32
	MaxPlanSubtasks          = 12
	MaxOwnedPathsPerSubtask  = 32
	MaxCheckArgvLen          = 32
	MaxAcceptanceCriteriaLen = 32
	MaxNextStepsLen          = 32
)

Bounds keep planner-proposed fan-out finite and reviewable.

View Source
const (
	SubtaskPending   = "pending"
	SubtaskReserved  = "reserved"
	SubtaskRunning   = "running"
	SubtaskSucceeded = "succeeded"
	SubtaskFailed    = "failed"
	SubtaskTimedOut  = "timed-out"
	SubtaskCancelled = "cancelled"
)

Subtask lifecycle statuses persisted on the durable supervisor schedule.

View Source
const (
	WorkspaceWorktree       = "worktree"
	WorkspaceSharedReadOnly = "shared-readonly"
	WorkspaceSequential     = "sequential"
	WorkspaceUnavailable    = "unavailable"
)

Workspace modes. A Git worktree is a write boundary, not a security sandbox.

View Source
const (
	ArtifactVerification        = "verification/receipts.json"
	ArtifactVerificationSummary = "verification/failure-summary.txt"
	VerificationLogDirRelative  = "logs/verification"
)

Artifact paths for supervisor-owned verification under the run.

View Source
const (
	VerificationStatusPassed       = "passed"
	VerificationStatusFailed       = "failed"
	VerificationStatusInvalidated  = "invalidated"
	VerificationStatusSkipped      = "skipped"
	VerificationStatusUnauthorized = "unauthorized"
)

Verification outcome statuses persisted on the supervisor-owned record.

View Source
const ArtifactIntegration = "integration/decision.json"

ArtifactIntegration is the durable integration decision JSON under the run.

View Source
const OutcomeVerificationEnvironment = "verification-environment-failed"

OutcomeVerificationEnvironment pauses a run whose checks could not execute in the supervisor environment. Retrying returns to verifying, not to the implementer.

Variables

View Source
var TaskKinds = []string{"bugfix", "feature", "release", "review"}

TaskKinds are routing contexts for the adaptive loop, not fixed graphs.

Functions

func AdmitCap

func AdmitCap(budgets AdmitBudgets, effectiveConcurrency, inFlight int) int

AdmitCap returns how many new slots may be reserved right now.

func ApplyIntegratedCandidate

func ApplyIntegratedCandidate(st *State, fingerprint string) error

ApplyIntegratedCandidate updates adaptive state after a successful supervisor integration. Only the supervisor path may set DiffRevision from fan-out.

func ApplyVerificationResult

func ApplyVerificationResult(st *State, rec VerificationRecord, now time.Time) error

ApplyVerificationResult stores receipts on adaptive state during the verifying stage. On failure, timeout, or invalidation it returns to implementation when revision/run budgets remain; exhaustion pauses with a recovery message. Assessors are assigned only after a successful verification for the same candidate (stage becomes assessing).

func BoundPendingDetail

func BoundPendingDetail(s string, max int) string

BoundPendingDetail truncates a detail string for prompt injection.

func BudgetPause

func BudgetPause(reason string) bool

func ChecksAllowCompletion

func ChecksAllowCompletion(receipts []CheckReceipt, candidateFingerprint string) bool

ChecksAllowCompletion reports whether supervisor receipts authorize Done for this candidate. Failed, timed-out, invalidated, or wrong-revision receipts block completion: Jev classification and agent prose cannot override them. Empty receipts are allowed when verification recorded a no-argv skip.

func CombinePatches

func CombinePatches(order []string, byID map[string]SubtaskContribution) []byte

CombinePatches concatenates successful contribution patches in apply order for the single candidate artifact / fingerprint.

func ContributionsByID

func ContributionsByID(contribs []SubtaskContribution) map[string]SubtaskContribution

ContributionsByID indexes contributions by subtask id.

func DigestHex

func DigestHex(data []byte) string

DigestHex returns the lowercase hex SHA-256 of data.

func FormatReceiptsForAssessor

func FormatReceiptsForAssessor(receipts []CheckReceipt, candidateFingerprint string) string

FormatReceiptsForAssessor builds a bounded, exact-revision receipt digest for assessor prompts. It never invents a pass from prose.

func HasArgvChecks

func HasArgvChecks(checks []Check) bool

HasArgvChecks reports whether any check would execute a command.

func InvalidateOnCandidateChange

func InvalidateOnCandidateChange(st *State)

InvalidateOnCandidateChange clears assessments and check receipts when the integrated candidate changes. Subtasks never call this to mark the run done.

func MarshalChecks

func MarshalChecks(checks []Check) ([]byte, error)

MarshalChecks returns checks.json bytes.

func MarshalSubtasks

func MarshalSubtasks(g SubtaskGraph) ([]byte, error)

MarshalSubtasks returns subtasks.json bytes.

func ReceiptsMatchCandidate

func ReceiptsMatchCandidate(receipts []CheckReceipt, worktreeIdentity, candidateFingerprint string) bool

ReceiptsMatchCandidate reports whether existing receipts are still valid for the exact candidate worktree identity (and optional patch fingerprint).

func TaskKindDescription

func TaskKindDescription(kind string) string

func TaskKindSummary

func TaskKindSummary(kind string) string

func ValidateChecks

func ValidateChecks(checks []Check) error

ValidateChecks validates structured checks only. Empty is allowed.

func ValidatePlannedHandoff

func ValidatePlannedHandoff(content string, nextSteps, acceptance []string, checks []Check) error

ValidatePlannedHandoff requires enough structured information for implementation and assessment. It does not invent checks or parse prose.

Types

type AdmitBudgets

type AdmitBudgets struct {
	PolicyMax            int
	RunTreeLimit         int
	EligibleBindings     int
	RemainingAssignments int
	RemainingChildRuns   int
	TimeRemaining        time.Duration
	CostRemainingOK      bool
}

AdmitBudgets are the independent ceilings that bound how many ready subtasks may be reserved. AdmitCap takes the positive minimum.

type Assessment

type Assessment struct {
	InvocationID string `json:"invocationId"`
	AgentID      string `json:"agentId"`
	Binding      string `json:"binding"`
	Revision     string `json:"revision"`
	Approved     bool   `json:"approved"`
}

type Assignment

type Assignment struct {
	InvocationID           string   `json:"invocationId"`
	StageID                string   `json:"stageId,omitempty"`
	Objective              string   `json:"objective,omitempty"`
	Reason                 string   `json:"reason,omitempty"`
	AgentID                string   `json:"agentId"`
	Binding                string   `json:"binding"`
	Via                    string   `json:"via,omitempty"`
	Runtime                string   `json:"runtime,omitempty"`
	Role                   string   `json:"role"`
	Revision               string   `json:"revision,omitempty"`
	ReadOnly               bool     `json:"readOnly,omitempty"`
	Isolated               bool     `json:"isolated,omitempty"`
	ProjectWriteScopes     []string `json:"projectWriteScopes,omitempty"`
	AgentWriteScopes       []string `json:"agentWriteScopes,omitempty"`
	ToolPolicyFingerprint  string   `json:"toolPolicyFingerprint,omitempty"`
	RuntimeArgsFingerprint string   `json:"runtimeArgsFingerprint,omitempty"`
}

type Check

type Check struct {
	ID             string   `json:"id"`
	Description    string   `json:"description,omitempty"`
	Argv           []string `json:"argv,omitempty"`
	WorkingDir     string   `json:"workingDir,omitempty"`
	TimeoutSeconds int      `json:"timeoutSeconds,omitempty"`
	Manual         string   `json:"manual,omitempty"`
}

Check is a machine-readable verification gate. Exactly one of Argv or Manual must be set. Commands are never invented or executed during planning.

type CheckReceipt

type CheckReceipt struct {
	CheckID              string   `json:"checkId"`
	CommandIdentity      string   `json:"commandIdentity,omitempty"`
	Argv                 []string `json:"argv,omitempty"`
	Manual               string   `json:"manual,omitempty"`
	PlanDigest           string   `json:"planDigest,omitempty"`
	ChecksDigest         string   `json:"checksDigest,omitempty"`
	CandidateFingerprint string   `json:"candidateFingerprint,omitempty"`
	WorktreeIdentity     string   `json:"worktreeIdentity,omitempty"`
	At                   string   `json:"at,omitempty"`
	ExitCode             int      `json:"exitCode,omitempty"`
	TimedOut             bool     `json:"timedOut,omitempty"`
	OutputPath           string   `json:"outputPath,omitempty"`
	OutputDigest         string   `json:"outputDigest,omitempty"`
	Passed               bool     `json:"passed"`
	Invalidated          bool     `json:"invalidated,omitempty"`
	DurationMS           int64    `json:"durationMs,omitempty"`
	Detail               string   `json:"detail,omitempty"`
}

CheckReceipt is a supervisor verification receipt bound to one candidate. It records the actual worktree identity (tree hash), not only patch.diff's report hash. Any candidate change must clear Adaptive.CheckReceipts.

type ChecksFile

type ChecksFile struct {
	Checks []Check `json:"checks"`
}

ChecksFile is the on-disk checks.json envelope.

type IntegrationDecision

type IntegrationDecision struct {
	At     string   `json:"at,omitempty"`
	Kind   string   `json:"kind"`
	Detail string   `json:"detail,omitempty"`
	Paths  []string `json:"paths,omitempty"`
}

IntegrationDecision is one recorded choice during planning or apply.

type IntegrationRecord

type IntegrationRecord struct {
	Status                string                `json:"status"`
	SourceRevision        string                `json:"sourceRevision,omitempty"`
	ProjectHead           string                `json:"projectHead,omitempty"`
	CandidateFingerprint  string                `json:"candidateFingerprint,omitempty"`
	ApplyOrder            []string              `json:"applyOrder,omitempty"`
	AppliedSubtasks       []string              `json:"appliedSubtasks,omitempty"`
	PendingSubtasks       []string              `json:"pendingSubtasks,omitempty"`
	PathPlan              []PathApply           `json:"pathPlan,omitempty"`
	PreservedDirty        []string              `json:"preservedDirty,omitempty"`
	ApplyPolicy           string                `json:"applyPolicy,omitempty"`
	RollbackPolicy        string                `json:"rollbackPolicy,omitempty"`
	Decisions             []IntegrationDecision `json:"decisions,omitempty"`
	Provenance            []SubtaskProvenance   `json:"provenance,omitempty"`
	Repair                *RepairBrief          `json:"repair,omitempty"`
	RepairAssignment      *Assignment           `json:"repairAssignment,omitempty"`
	Summary               string                `json:"summary,omitempty"`
	CombinedPatchArtifact string                `json:"combinedPatchArtifact,omitempty"`
	CheckReceiptsCleared  bool                  `json:"checkReceiptsCleared,omitempty"`
	AssessmentsCleared    bool                  `json:"assessmentsCleared,omitempty"`
	AppliedAt             string                `json:"appliedAt,omitempty"`
	RolledBackAt          string                `json:"rolledBackAt,omitempty"`
}

IntegrationRecord is the durable supervisor-owned integration step. Only this record (not a subtask) may advance the aggregate candidate after fan-out.

func PlanIntegration

func PlanIntegration(s Schedule, contribs []SubtaskContribution, project ProjectSurface, alreadyApplied []string) IntegrationRecord

PlanIntegration is the supervisor-owned step that validates contributions before any write to the user's project. It never marks the aggregate run complete; callers advance adaptive state only after a successful Commit.

func (*IntegrationRecord) CommitApply

func (r *IntegrationRecord) CommitApply(combinedPatch []byte, now time.Time) error

CommitApply records a successful apply of the pending path plan. It recomputes the candidate fingerprint from the combined patch and refuses double-apply.

func (*IntegrationRecord) Rollback

func (r *IntegrationRecord) Rollback(now time.Time) error

Rollback clears applied state explicitly without touching preserved dirty files.

type IsolationDecision

type IsolationDecision struct {
	Mode   string
	Reason string
}

IsolationDecision chooses a workspace mode for the next reservation. Concurrent writable work requires an isolated worktree; without it the scheduler either sequences or pauses — never concurrent live-worktree writes.

func DecideIsolation

func DecideIsolation(wantParallel bool, writable bool, readOnlyEnforced bool, worktreeAvailable bool, writableInFlight bool) IsolationDecision

type LiveLease

type LiveLease struct {
	SubtaskID  string
	LeaseOwner string
	PID        int
	Alive      bool
}

LiveLease is observed process/lease state used during reconcile.

type PathApply

type PathApply struct {
	Path    string `json:"path"`
	Subtask string `json:"subtaskId"`
	Action  string `json:"action"` // apply, preserve-dirty, skip
	Reason  string `json:"reason,omitempty"`
}

PathApply describes one path the supervisor intends to write or skip.

type ProjectSurface

type ProjectSurface struct {
	HeadRevision string   // current HEAD; compared to recorded bases for staleness
	DirtyPaths   []string // pre-existing dirty files that must be preserved
}

ProjectSurface describes the user's live project at integration time.

type RepairBrief

type RepairBrief struct {
	Summary       string   `json:"summary"`
	SubtaskIDs    []string `json:"subtaskIds,omitempty"`
	Artifacts     []string `json:"artifacts,omitempty"`
	ConflictPaths []string `json:"conflictPaths,omitempty"`
	FailedIDs     []string `json:"failedIds,omitempty"`
}

RepairBrief is the exact artifact set and summary for one bounded repair.

type RepairFeedback

type RepairFeedback struct {
	InvocationID string `json:"invocationId"`
	Revision     string `json:"revision"`
	Role         string `json:"role"`
	Summary      string `json:"summary"`
}

RepairFeedback preserves the decisive review across retries and restarts. It is evidence for this candidate only, not an instruction or an approval.

type Result

type Result struct {
	InvocationID string  `json:"invocationId"`
	AgentID      string  `json:"agentId"`
	Outcome      string  `json:"outcome"` // planned, changed, answer, no-change, approved, changes-required, auth-failed, invocation-failed, failed, timed-out, run-time-exhausted
	Revision     string  `json:"revision,omitempty"`
	CostUSD      float64 `json:"costUsd,omitempty"`
	Focus        string  `json:"focus,omitempty"`
	Reason       string  `json:"reason,omitempty"`
}

Result is a worker's structured outcome. A revision is a content digest of the plan or diff, supplied by the driver after it writes the artifact.

type Schedule

type Schedule struct {
	GraphRevision        string                   `json:"graphRevision,omitempty"`
	Mode                 string                   `json:"mode"`
	Parallelize          bool                     `json:"parallelize,omitempty"`
	EffectiveConcurrency int                      `json:"effectiveConcurrency"`
	SourceRevision       string                   `json:"sourceRevision,omitempty"`
	Subtasks             map[string]SubtaskRecord `json:"subtasks,omitempty"`
	PauseReason          string                   `json:"pauseReason,omitempty"`
	IntegrationPending   bool                     `json:"integrationPending,omitempty"`
}

Schedule is the durable supervisor scheduler for an approved fan-out graph.

func NewSchedule

func NewSchedule(g SubtaskGraph, graphRevision, sourceRevision string) Schedule

NewSchedule builds a durable schedule from an approved fan-out graph. Single-mode graphs return a schedule with EffectiveConcurrency 1 and no subtask fan-out records.

func (Schedule) AllTerminal

func (s Schedule) AllTerminal() bool

AllTerminal reports whether every subtask reached a terminal status.

func (*Schedule) Complete

func (s *Schedule) Complete(id, status string, result Result, usage *SubtaskUsage, now time.Time) error

Complete records a terminal result. Attempt budget was already consumed at Reserve.

func (Schedule) HasFailures

func (s Schedule) HasFailures() bool

HasFailures reports whether any subtask ended unsuccessfully.

func (*Schedule) Heartbeat

func (s *Schedule) Heartbeat(id, leaseOwner string, now time.Time) error

Heartbeat refreshes a live lease.

func (Schedule) InFlight

func (s Schedule) InFlight() int

InFlight counts reserved/running subtasks.

func (*Schedule) MarkRunning

func (s *Schedule) MarkRunning(id string, pid int, now time.Time) error

MarkRunning transitions a reserved subtask after the process has started.

func (*Schedule) Pause

func (s *Schedule) Pause(reason string)

Pause stops further reservation with an operator-visible reason.

func (Schedule) ReadyIDs

func (s Schedule) ReadyIDs() []string

ReadyIDs returns pending subtasks whose dependencies have succeeded, sorted by merge order then id for stable admission.

func (*Schedule) Reconcile

func (s *Schedule) Reconcile(live []LiveLease, now time.Time) []string

Reconcile aligns durable leases with observed live processes before the next schedule tick. Dead reserved/running leases become failed attempts.

func (*Schedule) Reserve

func (s *Schedule) Reserve(id string, assignment Assignment, workspace, mode, leaseOwner string, now time.Time) error

Reserve atomically claims one ready subtask. Callers must hold the root run lock. Failed/retried attempts still consume Attempt (budget is charged by the driver when Reserve succeeds).

func (*Schedule) RetryFailed

func (s *Schedule) RetryFailed(id string) error

RetryFailed moves a failed/timed-out/cancelled subtask back to pending so another attempt can be reserved. The prior attempt still consumed budget.

func (Schedule) WritableInFlight

func (s Schedule) WritableInFlight() bool

WritableInFlight reports whether any non-read-only subtask is reserved or running.

type SpecialistCheck

type SpecialistCheck struct {
	Role     string `json:"role"`
	Focus    string `json:"focus"`
	Revision string `json:"revision,omitempty"`
	AgentID  string `json:"agentId,omitempty"`
	Binding  string `json:"binding,omitempty"`
	Approved bool   `json:"approved,omitempty"`
	Overlap  bool   `json:"overlap,omitempty"`
}

type SpecialistDecision

type SpecialistDecision struct {
	Role       string  `json:"role"`
	Revision   string  `json:"revision"`
	Choice     string  `json:"choice,omitempty"`
	Confidence float64 `json:"confidence,omitempty"`
	Reason     string  `json:"reason"`
}

SpecialistDecision records why an optional check ran or was skipped.

type State

type State struct {
	TreeBudget             bool                  `json:"treeBudget,omitempty"`
	BudgetPhase            string                `json:"budgetPhase,omitempty"`
	BudgetBlockers         []string              `json:"budgetBlockers,omitempty"`
	RetryPhase             string                `json:"retryPhase,omitempty"`
	TaskKind               string                `json:"taskKind"`
	Profile                string                `json:"profile"`
	Stage                  string                `json:"stage"`
	Outcome                string                `json:"outcome,omitempty"`
	PlanRevision           string                `json:"planRevision,omitempty"`
	ChecksRevision         string                `json:"checksRevision,omitempty"`
	SubtasksRevision       string                `json:"subtasksRevision,omitempty"`
	DiffRevision           string                `json:"diffRevision,omitempty"`
	Quorum                 int                   `json:"quorum"`
	MaxConcurrent          int                   `json:"maxConcurrent"`
	MaxAssignments         int                   `json:"maxAssignments,omitempty"`
	AssignmentCount        int                   `json:"assignmentCount,omitempty"`
	MaxEstimatedCostUSD    float64               `json:"maxEstimatedCostUsd,omitempty"`
	EstimatedCostUSD       float64               `json:"estimatedCostUsd,omitempty"`
	MaxRevisions           int                   `json:"maxRevisions"`
	RevisionCount          int                   `json:"revisionCount"`
	Assignments            map[string]Assignment `json:"assignments,omitempty"`
	Assessments            []Assessment          `json:"assessments,omitempty"`
	CheckReceipts          []CheckReceipt        `json:"checkReceipts,omitempty"`
	Excluded               map[string]bool       `json:"excluded,omitempty"`
	ExcludedBindings       map[string]bool       `json:"excludedBindings,omitempty"`
	HandoffExcluded        map[string]bool       `json:"handoffExcluded,omitempty"`
	ExcludedRuntimes       map[string]bool       `json:"excludedRuntimes,omitempty"`
	HandoffCount           int                   `json:"handoffCount,omitempty"`
	LastHandoffBinding     string                `json:"lastHandoffBinding,omitempty"`
	HandoffFallbackUsed    bool                  `json:"handoffFallbackUsed,omitempty"`
	PendingFocus           string                `json:"pendingFocus,omitempty"`
	PendingReason          string                `json:"pendingReason,omitempty"`
	SpecialistQueue        []SpecialistCheck     `json:"specialistQueue,omitempty"`
	SpecialistReviews      []SpecialistCheck     `json:"specialistReviews,omitempty"`
	SpecialistDecisions    []SpecialistDecision  `json:"specialistDecisions,omitempty"`
	AfterSpecialists       string                `json:"afterSpecialists,omitempty"`
	PendingDecision        string                `json:"pendingDecision,omitempty"`
	PendingPhase           string                `json:"pendingPhase,omitempty"`
	LastImplementerBinding string                `json:"lastImplementerBinding,omitempty"`
	RepairFeedback         *RepairFeedback       `json:"repairFeedback,omitempty"`
	NoProgressCount        int                   `json:"noProgressCount,omitempty"`
}

func New

func New(taskKind, profile string, quorum, maxConcurrent, maxRevisions int) (State, error)

func (*State) Apply

func (s *State) Apply(r Result) error

Apply leaves state untouched when a result is invalid.

func (*State) Assign

func (s *State) Assign(a Assignment) error

Assign accepts a driver-routed worker. The caller must check current eligibility first; this enforces invocation and assessor independence.

func (State) BudgetExhausted

func (s State) BudgetExhausted() bool

func (State) ParallelReviews

func (s State) ParallelReviews() bool

ParallelReviews reports whether the stage admits concurrent read-only reviewer invocations (assessors and optional specialists).

func (*State) Pause

func (s *State) Pause(reason string)

func (State) Pending

func (s State) Pending() []Assignment

func (State) ReviewSlotsNeeded

func (s State) ReviewSlotsNeeded() int

ReviewSlotsNeeded is how many additional independent reviewers the stage still requires before a quorum or specialist-queue decision can complete.

func (State) Role

func (s State) Role() string

type Subtask

type Subtask struct {
	ID                 string   `json:"id"`
	Objective          string   `json:"objective"`
	DependsOn          []string `json:"dependsOn,omitempty"`
	ExpectedOutput     string   `json:"expectedOutput"`
	OwnedPaths         []string `json:"ownedPaths"`
	MergeOrder         int      `json:"mergeOrder"`
	AcceptanceCriteria []string `json:"acceptanceCriteria"`
}

Subtask is one scoped unit in an optional planner fan-out graph.

type SubtaskContribution

type SubtaskContribution struct {
	SubtaskID    string
	BaseRevision string
	Patch        []byte
	Handoff      string
	ChangedPaths []string
	OwnedPaths   []string
	MergeOrder   int
	DependsOn    []string
	Status       string // SubtaskSucceeded / Failed / TimedOut / Cancelled
	Artifact     string // relative run artifact path for provenance
	InvocationID string
	AgentID      string
	Workspace    string
}

SubtaskContribution is one subtask's patch and handoff collected against its recorded base revision. ChangedPaths must be supplied by the driver (from the worktree diff or change report); the integrator does not invent them.

func CollectContributions

func CollectContributions(s Schedule, patches map[string][]byte, handoffs map[string]string, changed map[string][]string, artifactFor func(id string) string) []SubtaskContribution

CollectContributions builds contributions from a durable schedule plus driver- supplied patch bodies keyed by subtask id. Missing successful patches are treated as empty contributions (still ordered).

func (SubtaskContribution) ID

func (c SubtaskContribution) ID() string

type SubtaskGraph

type SubtaskGraph struct {
	Mode                 string    `json:"mode"`
	FallbackReason       string    `json:"fallbackReason,omitempty"`
	IndependenceReason   string    `json:"independenceReason,omitempty"`
	IntegrationOwner     string    `json:"integrationOwner,omitempty"`
	SharedPaths          []string  `json:"sharedPaths,omitempty"`
	LatencyBenefit       string    `json:"latencyBenefit,omitempty"`
	Parallelize          bool      `json:"parallelize,omitempty"`
	EffectiveConcurrency int       `json:"effectiveConcurrency,omitempty"`
	Subtasks             []Subtask `json:"subtasks,omitempty"`
}

SubtaskGraph is an optional bounded dependency graph. Mode is "fan-out" when the validated graph is kept, or "single" when Jevkit falls back to one implementer (including when the planner omitted subtasks).

func BoundGraphConcurrency

func BoundGraphConcurrency(g SubtaskGraph, maxConcurrent, remainingAssignments int) SubtaskGraph

BoundGraphConcurrency caps an otherwise eligible fan-out graph to the enrolled policy and remaining run budgets. EffectiveConcurrency is always set.

func NormalizeSubtaskGraph

func NormalizeSubtaskGraph(g *SubtaskGraph) SubtaskGraph

NormalizeSubtaskGraph validates an optional graph. Invalid or non-beneficial fan-out falls back to one implementer; a nil/empty proposal is single mode. Call BoundGraphConcurrency with enrolled policy and run budgets before persisting under --auto or when displaying the effective concurrency limit.

func SingleImplementerGraph

func SingleImplementerGraph(reason string) SubtaskGraph

SingleImplementerGraph is the persisted form when fan-out is not used.

type SubtaskProvenance

type SubtaskProvenance struct {
	SubtaskID    string   `json:"subtaskId"`
	BaseRevision string   `json:"baseRevision,omitempty"`
	Artifact     string   `json:"artifact,omitempty"`
	InvocationID string   `json:"invocationId,omitempty"`
	AgentID      string   `json:"agentId,omitempty"`
	Workspace    string   `json:"workspace,omitempty"`
	ChangedPaths []string `json:"changedPaths,omitempty"`
	MergeOrder   int      `json:"mergeOrder"`
	Status       string   `json:"status"`
}

SubtaskProvenance records where a contribution came from for inspect/delete.

type SubtaskRecord

type SubtaskRecord struct {
	ID             string        `json:"id"`
	Status         string        `json:"status"`
	DependsOn      []string      `json:"dependsOn,omitempty"`
	OwnedPaths     []string      `json:"ownedPaths,omitempty"`
	Objective      string        `json:"objective,omitempty"`
	ExpectedOutput string        `json:"expectedOutput,omitempty"`
	MergeOrder     int           `json:"mergeOrder"`
	ReadOnly       bool          `json:"readOnly,omitempty"`
	Assignment     *Assignment   `json:"assignment,omitempty"`
	Workspace      string        `json:"workspace,omitempty"`
	WorkspaceMode  string        `json:"workspaceMode,omitempty"`
	BaseRevision   string        `json:"baseRevision,omitempty"`
	HeartbeatAt    string        `json:"heartbeatAt,omitempty"`
	LeaseOwner     string        `json:"leaseOwner,omitempty"`
	PID            int           `json:"pid,omitempty"`
	Result         *Result       `json:"result,omitempty"`
	Usage          *SubtaskUsage `json:"usage,omitempty"`
	Attempt        int           `json:"attempt,omitempty"`
	PauseReason    string        `json:"pauseReason,omitempty"`
	StartedAt      string        `json:"startedAt,omitempty"`
	FinishedAt     string        `json:"finishedAt,omitempty"`
}

SubtaskRecord is the durable per-subtask supervisor record.

type SubtaskUsage

type SubtaskUsage struct {
	InputTokens  *int64   `json:"inputTokens,omitempty"`
	OutputTokens *int64   `json:"outputTokens,omitempty"`
	ToolCalls    *int64   `json:"toolCalls,omitempty"`
	CostUSD      *float64 `json:"costUsd,omitempty"`
}

SubtaskUsage is the measured usage charged for one subtask attempt.

type VerificationRecord

type VerificationRecord struct {
	Status               string         `json:"status"`
	PlanDigest           string         `json:"planDigest,omitempty"`
	ChecksDigest         string         `json:"checksDigest,omitempty"`
	CandidateFingerprint string         `json:"candidateFingerprint,omitempty"`
	WorktreeIdentity     string         `json:"worktreeIdentity,omitempty"`
	Receipts             []CheckReceipt `json:"receipts,omitempty"`
	FailureSummaryPath   string         `json:"failureSummaryPath,omitempty"`
	AllPassed            bool           `json:"allPassed,omitempty"`
	Invalidated          bool           `json:"invalidated,omitempty"`
	At                   string         `json:"at,omitempty"`
	Summary              string         `json:"summary,omitempty"`
	// EnvironmentFailure is set when every failed check failed for a reason the
	// implementer cannot fix from the candidate (missing command, wrong
	// toolchain on the supervisor's PATH). Such runs escalate to the operator
	// instead of spending a revision.
	EnvironmentFailure string `json:"environmentFailure,omitempty"`
}

VerificationRecord is the durable supervisor-owned verification step for one candidate. Stored with the parent run so users can inspect or delete it together; diagnostic logs under logs/verification are separately prunable.

Jump to

Keyboard shortcuts

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