Documentation
¶
Overview ¶
This file holds the shared infrastructure for the per-issue Delivery lifecycle verbs (PRD §12 steps 8-22), each in its own file:
dispatch worktree-ready → dispatched pr-open dispatched → pr-open review pr-open/in-review → in-review escalate dispatched/pr-open/in-review → reroute (same) or blocked ci pr-open/in-review/awaiting-merge → same (manifest only) merge-report in-review → awaiting-merge merge awaiting-merge → merged block any non-terminal → blocked abandon any non-terminal → abandoned cleanup merged/abandoned → cleaned complete run-level; requires every issue cleaned
Failure semantics are pure (PRD §15, resolved 2026-07-11): no verb mutates phase, state, GitHub, or git as a side effect of failing. State advances only on the success path, persisted after each sub-step; a post-mutation error is wrapped (wrapAfterMutation) with the `orch abort`/resume remediation, exactly as activation wraps errors after EnterDelivery. Every mutating verb runs the shared preconditions in loadVerb before touching anything.
resume.go reconciles an interrupted Delivery run against GitHub and git, then advances, adopts, blocks, or unblocks each issue by state alone (PRD §23). It is the recovery path a crashed lifecycle verb, an out-of-band GitHub action, or a secret-stopped run returns through.
Three strictly separated stages keep the decision auditable and the failure semantics pure:
- observe: every gh/git read is batched up front (one ListWorktrees call total; per-issue reads scoped by phase). Any transport error aborts before a single write.
- classify: reconcileIssue is a pure function over the observations — the whole decision table lives there, with no I/O.
- apply: outcomes mutate a deep working copy, persisted with ONE state.Save at the end (skipped entirely when nothing changed, so a converged resume is a byte-level no-op).
Resume performs zero external mutations: it never pushes, merges, closes, or edits labels or bodies. It only rewrites state.json to match what GitHub already proves. Labels self-heal when the next lifecycle verb runs.
Package run is the Delivery run engine: the policy home that composes internal/paths, internal/execx, internal/gitops, internal/ghops, internal/manifest, internal/routing, and internal/state+internal/lockfile (all policy-free) into the adapter-facing plumbing surface PRD §22 calls for. There is no manual delivery command — host adapters shell out to `orch run <verb>` after their own native dialogs, exchanging JSON documents on stdin/stdout:
orch run plan # plan JSON on stdin → gate document JSON on stdout orch run activate # activation request JSON on stdin → activation result JSON on stdout orch run status --json # run-state JSON on stdout
The per-issue lifecycle verbs (see lifecycle.go) extend the surface — dispatch, pr-open, review, escalate, ci, merge-report, merge, block, abandon, cleanup — plus the run-level complete. Each reads a schema-versioned request document on stdin and writes a schema-versioned result on stdout.
Concurrency invariant: plan and status are read-only. Every mutating verb acquires or re-verifies the cross-host Delivery lock: activate enters Delivery via state.EnterDelivery, and each lifecycle verb runs the shared preconditions in loadVerb (state.Load + lockfile.Inspect + state.CheckConsistent with st.Run.ID == owner.RunID, plus config-drift and stopped-run gates) before touching anything. Within one invocation writes are sequential, so PRD §14's serialization requirement holds trivially. Failure semantics are pure: a verb never mutates phase, state, GitHub, or git as a side effect of failing.
All documents this package accepts are schema-versioned (exact-match, fail closed) and decoded with DisallowUnknownFields: an adapter sending a field this build does not recognize is a bug to surface immediately, not silently drop.
Index ¶
- Constants
- Variables
- type AbandonRequest
- type AbandonResult
- type ActivationRequest
- type ActivationResult
- type ActivationResultIssue
- type Approval
- type BlockRequest
- type BlockResult
- type CICheck
- type CIReport
- type CIRequest
- type CIResult
- type CleanupRequest
- type CleanupResult
- type CompleteRequest
- type CompleteResult
- type DispatchRequest
- type DispatchResult
- type Env
- type EscalateRequest
- type EscalateResult
- type GateDoc
- type GateIssue
- type IssueResume
- type MemhubReport
- type MergeApproval
- type MergeReportCI
- type MergeReportRequest
- type MergeReportResult
- type MergeRequest
- type MergeResult
- type PROpenRequest
- type PROpenResult
- type PlanDoc
- type PlanDowngrade
- type PlanFacts
- type PlanIssue
- type Prober
- type ResumeAction
- type ResumeDoc
- type ResumeObserved
- type ResumeRequest
- type ReviewRequest
- type ReviewResult
- type RunView
- type StatusDoc
- type VerificationInput
Constants ¶
const ( VerdictApprove = "approve" VerdictRequestChanges = "request-changes" )
The two review verdicts (PRD §12 step 11).
const AbandonSchemaVersion = 1
AbandonSchemaVersion is the abandon request/result schema this build accepts and emits.
const AbandonStatement = "abandon-issue"
AbandonStatement is the exact confirmation abandonment requires: closing a PR and issue without merging is destructive bookkeeping and carries its own explicit approval (PRD §15).
const ActivationSchemaVersion = 1
ActivationSchemaVersion is the activation-request/result schema this build accepts and emits.
const ApprovalStatement = "approve-and-enter-delivery"
ApprovalStatement is the exact assertion an adapter's human approval must carry (PRD §8): the engine cannot verify a human, so this string is the recorded proof that one saw the gate and approved it, tied to a specific plan digest.
const BlockSchemaVersion = 1
BlockSchemaVersion is the block request/result schema this build accepts and emits.
const CISchemaVersion = 1
CISchemaVersion is the ci request/result schema this build accepts and emits.
const CleanupSchemaVersion = 1
CleanupSchemaVersion is the cleanup request/result schema this build accepts and emits.
const CleanupStatement = "cleanup-issue"
CleanupStatement is the exact confirmation cleanup requires: one statement covers the verb's three deletions — remote branch, worktree, and local branch — because they are one act (PRD §15).
const CompleteSchemaVersion = 1
CompleteSchemaVersion is the complete request/result schema this build accepts and emits.
const DispatchSchemaVersion = 1
DispatchSchemaVersion is the dispatch request/result schema this build accepts and emits.
const EscalateSchemaVersion = 1
EscalateSchemaVersion is the escalate request/result schema this build accepts and emits.
const GateSchemaVersion = 1
GateSchemaVersion is the gate-document schema this build emits.
const MergeApprovalStatement = "approve-merge"
MergeApprovalStatement is the exact assertion a human merge approval must carry (PRD §8): a fresh approval per PR, pinned to the head OID the human saw. The engine cannot verify a human, so this recorded string is the proof one approved this specific merge.
const MergeReportSchemaVersion = 1
MergeReportSchemaVersion is the merge-report request/result schema this build accepts and emits.
const MergeSchemaVersion = 1
MergeSchemaVersion is the merge request/result schema this build accepts and emits.
const PROpenSchemaVersion = 1
PROpenSchemaVersion is the pr-open request/result schema this build accepts and emits.
const PlanSchemaVersion = 1
PlanSchemaVersion is the plan-document schema this build accepts.
const ResumeSchemaVersion = 1
ResumeSchemaVersion is the resume-document schema this build emits.
const ResumeStoppedRunStatement = "resume-stopped-run"
ResumeStoppedRunStatement is the exact statement that authorizes resume to clear a secret-stopped run's StoppedReason. A stopped run is fully observed, classified, and reported without it, but nothing is written.
const ReviewSchemaVersion = 1
ReviewSchemaVersion is the review request/result schema this build accepts and emits.
const StatusSchemaVersion = 1
StatusSchemaVersion is the status-document schema this build emits.
const WorktreeContainer = ".orchestrator/worktrees"
WorktreeContainer is the repo-relative directory activation creates per-issue worktrees under. It must be listed in .gitignore (F1): gitops.RequireIgnored enforces that before activation touches git.
Variables ¶
var ( // ErrPlanInvalid reports a plan document that fails validation: // unsupported schema, a host not enabled, malformed or duplicate // issue ids, unresolved/self-referencing/non-acyclic dependencies, // invalid risk domains, read-only work (rejected — F3), labels that // fail the PRD §13 taxonomy or the model denylist, an unrecognized // usage class, or any empty required text field. ErrPlanInvalid = errors.New("plan document is invalid") // ErrBadApproval reports a malformed activation request envelope or // an approval assertion that does not match the plan it approves: // unsupported schema, unparsable/unknown-field JSON, a statement // other than ApprovalStatement, or a plan_digest that does not // equal the recomputed digest (the "adjust = resubmit" loop). ErrBadApproval = errors.New("activation approval is invalid") // ErrAreaLabelMissing reports plan-declared area labels absent from // the repository at activation preflight: area labels are // repository-defined (PRD §13), so activation never creates them — // it fails closed before any mutation instead. ErrAreaLabelMissing = errors.New("plan-declared area labels do not exist in the repository") // ErrMemhubRequired reports that config.Memhub.Mode is "required" // and the memhub probe failed or could not run (PRD §20: fail // closed rather than proceed without memory). ErrMemhubRequired = errors.New("memhub is required but unavailable") // ErrDeliveryActive reports that a Delivery run is already active // (or the state/lock pair is inconsistent) when a verb requires // Assist with no lock held. ErrDeliveryActive = errors.New("a delivery run is already active") // ErrNoDeliveryRun reports that a lifecycle verb ran without an // active Delivery run to act on (the repository is in Assist). ErrNoDeliveryRun = errors.New("no delivery run is active") // ErrConfigDrift reports that the committed configuration changed // mid-run (its revision no longer matches the run's): config changes // ship via their own Delivery run, so drift fails closed. ErrConfigDrift = errors.New("configuration changed mid-run") // ErrRunStopped reports that the run was stopped by a secret block // (PRD §16); every mutating verb but block itself is denied until // `orch abort` or `orch resume`. ErrRunStopped = errors.New("delivery run is stopped") // ErrUnknownIssue reports an issue_number that matches no run issue. ErrUnknownIssue = errors.New("issue number does not match any run issue") // ErrWrongPhase reports an issue whose phase is not in the verb's // allowed set. ErrWrongPhase = errors.New("issue is not in a phase this verb accepts") // ErrBadRequest reports a malformed verb request document: an // unsupported schema, unparsable or unknown-field JSON, a wrong // confirmation statement, or a value outside a closed set. ErrBadRequest = errors.New("verb request document is invalid") // ErrDependencyUnmet reports a dispatch blocked by a dependency issue // that is not yet merged or cleaned (PRD §11 wave ordering). ErrDependencyUnmet = errors.New("a dependency issue is not yet merged") // ErrDependencyAbandoned reports a dispatch blocked by an abandoned // dependency: the plan's scope changed materially and must go back // through the plan gate (PRD §8/§16). ErrDependencyAbandoned = errors.New("a dependency issue was abandoned") // ErrPRExists reports an open pull request already present for a // branch at pr-open — an orphan from a crashed run (PRD §23). ErrPRExists = errors.New("an open pull request already exists for the branch") // ErrReviewStale reports a review whose reviewed head OID no longer // matches the PR's live head: the PR changed under the reviewer. ErrReviewStale = errors.New("review does not match the pull request head") // ErrReviewerMismatch reports a review performed by a selection other // than the issue's routed reviewer (PRD §13: the audit record's // reviewer is the one that reviewed). ErrReviewerMismatch = errors.New("reviewer is not the routed reviewer") // ErrCINotReady reports required CI that is pending or failing where // a mergeable state (passing or no-checks) is required (PRD §16). ErrCINotReady = errors.New("required CI is not in a mergeable state") // ErrMergeApproval reports a merge approval that does not authorize // the merge: a wrong statement, a PR/head mismatch, or drift after // approval (PRD §8: approval pins one PR state). ErrMergeApproval = errors.New("merge approval does not authorize this merge") // ErrBodyTooLarge reports an audit body that cannot be brought under // GitHub's 65,536-character limit even after dropping detail text. ErrBodyTooLarge = errors.New("audit body exceeds GitHub's size limit") // ErrNotAllCleaned reports a complete attempted before every issue // reached the cleaned phase (PRD §7). ErrNotAllCleaned = errors.New("not every issue is cleaned") )
Sentinel errors callers test with errors.Is. Specifics wrap these with %w and detail (state.go / manifest.go house style) rather than replace them.
Functions ¶
This section is empty.
Types ¶
type AbandonRequest ¶
type AbandonRequest struct {
SchemaVersion int `json:"schema_version"`
IssueNumber int `json:"issue_number"`
Reason string `json:"reason"`
Statement string `json:"statement"`
}
AbandonRequest abandons an in-flight issue without merging.
type AbandonResult ¶
type AbandonResult struct {
SchemaVersion int `json:"schema_version"`
IssueNumber int `json:"issue_number"`
Phase state.Phase `json:"phase"`
}
AbandonResult reports the abandonment.
func Abandon ¶
Abandon closes an issue's PR and the issue without merging (PRD §15), recording the reason in the durable issue audit record. The branch and worktree are preserved until cleanup. Each GitHub mutation is guarded by a state read so a re-run after a partial failure converges; the only state write is the final Save, so a failure before it leaves the run unchanged.
type ActivationRequest ¶
type ActivationRequest struct {
SchemaVersion int `json:"schema_version"`
Plan PlanDoc `json:"plan"`
Approval Approval `json:"approval"`
}
ActivationRequest is the input to Activate: the full plan plus the adapter's record of the human's approval of it.
func DecodeActivation ¶
func DecodeActivation(data []byte) (*ActivationRequest, error)
DecodeActivation decodes data into an ActivationRequest, rejecting any field this build does not recognize at any level (including the embedded plan) and any unsupported schema_version.
type ActivationResult ¶
type ActivationResult struct {
SchemaVersion int `json:"schema_version"`
RunID string `json:"run_id"`
Issues []ActivationResultIssue `json:"issues"`
}
ActivationResult is the output of a successful Activate.
func Activate ¶
Activate validates a plan and its approval, runs the read-only Delivery preflights, enters Delivery, and creates one GitHub issue plus one branch/worktree per plan issue in wave order. See the package doc and internal/run's design notes for the exact phase/step ordering and abort-safety invariant; a summary:
- Phase 1 (pure validation): decode/validate the plan and its approval, derive routing and labels for every issue.
- Phase 2 (read-only preflights): Assist+no-lock, clean primary checkout, authenticated GitHub remote, primary on the default branch (F4), every plan-declared area label existing in the repository (area labels are repository-defined per PRD §13, so activation never creates them), the memhub gate, and the worktree container git-ignored (F1).
- Phase 3 (idempotent GitHub prep): EnsureLabelTaxonomy — the only mutation before the lock is held (F6).
- Phase 4: state.EnterDelivery acquires the lock and records the run.
- Phase 5 (per issue, wave order): create the GitHub issue with the PRD §13 audit record, persist state, add the branch/worktree, persist state again.
- Phase 6: a final state.Save, then return the result. The run stays in Delivery — dispatching issues onward is PR B.
type ActivationResultIssue ¶
type ActivationResultIssue struct {
ID string `json:"id"`
Number int `json:"number"`
URL string `json:"url"`
Branch string `json:"branch"`
Worktree string `json:"worktree"`
}
ActivationResultIssue is one activated issue's created artifacts.
type Approval ¶
type Approval struct {
PlanDigest string `json:"plan_digest"`
ApprovedBy string `json:"approved_by"`
ApprovedAt time.Time `json:"approved_at"`
Statement string `json:"statement"`
}
Approval is the adapter's assertion that a human approved plan (identified by digest) for entry into Delivery.
type BlockRequest ¶
type BlockRequest struct {
SchemaVersion int `json:"schema_version"`
IssueNumber int `json:"issue_number"`
Class string `json:"class"`
Detail string `json:"detail"`
}
BlockRequest blocks an in-flight issue for human attention.
type BlockResult ¶
type BlockResult struct {
SchemaVersion int `json:"schema_version"`
IssueNumber int `json:"issue_number"`
Phase state.Phase `json:"phase"`
RunStopped bool `json:"run_stopped"`
}
BlockResult reports the block and whether it stopped the run.
func Block ¶
Block blocks an issue for human action (PRD §15), preserving its branch and worktree. It is the only mutating verb allowed on a stopped run, and it accepts any non-terminal phase including blocked (re-block updates the reason). A secret block also stops the whole run (PRD §16), after which every other mutating verb fails closed until the human recovers. Unaffected issues continue unless the run stopped.
type CICheck ¶
type CICheck struct {
Name string `json:"name"`
State string `json:"state"`
Bucket string `json:"bucket"`
Link string `json:"link,omitempty"`
}
CICheck is one required check in the CI result.
type CIReport ¶
type CIReport struct {
WorkflowsPresent bool `json:"workflows_present"`
Statement string `json:"statement"`
}
CIReport is the plan gate's honest PRD §16 statement about CI. It is a pre-PR heuristic only (F8): before a PR exists, required-check configuration is unobservable — the real signal is ghops.RequiredCI, available once a PR is open (PR B).
type CIRequest ¶
type CIRequest struct {
SchemaVersion int `json:"schema_version"`
IssueNumber int `json:"issue_number"`
}
CIRequest asks for the current required-CI state of an issue's PR.
type CIResult ¶
type CIResult struct {
SchemaVersion int `json:"schema_version"`
IssueNumber int `json:"issue_number"`
State string `json:"state"`
Required []CICheck `json:"required"`
Total int `json:"total"`
}
CIResult is the honest tri-state required-CI report (PRD §16); a no-checks state is explicit, never conflated with passing.
func CI ¶
CI reads the required-CI state of an issue's PR and folds it into the audit record under the singleton verification "required-ci", replacing the previous entry by name so polling never grows the body. It makes no phase change; the only mutations are the two body writes, so a failure leaves the run unchanged and a re-run converges.
type CleanupRequest ¶
type CleanupRequest struct {
SchemaVersion int `json:"schema_version"`
IssueNumber int `json:"issue_number"`
Statement string `json:"statement"`
}
CleanupRequest removes a merged or abandoned issue's git artifacts.
type CleanupResult ¶
type CleanupResult struct {
SchemaVersion int `json:"schema_version"`
IssueNumber int `json:"issue_number"`
Phase state.Phase `json:"phase"`
}
CleanupResult reports the completed cleanup.
func Cleanup ¶
Cleanup deletes a merged or abandoned issue's remote branch, worktree, and local branch (PRD §12 steps 18-19), then marks the issue cleaned (terminal). Each deletion is pre-checked so a crashed cleanup re-runs cleanly; the only state write is the final Save. A failure mid-cleanup leaves the run incomplete (PRD §16) — the phase stays put and cleanup re-runs.
type CompleteRequest ¶
type CompleteRequest struct {
SchemaVersion int `json:"schema_version"`
}
CompleteRequest finishes a Delivery run. It carries no issue — complete is run-level.
type CompleteResult ¶
type CompleteResult struct {
SchemaVersion int `json:"schema_version"`
RunID string `json:"run_id"`
Merged int `json:"merged"`
Abandoned int `json:"abandoned"`
ReturnedTo string `json:"returned_to"`
MemhubWrapupDue bool `json:"memhub_wrapup_due"`
}
CompleteResult reports the finished run and hands the adapter the memhub wrap-up cue (PRD §20: only the Architect initiates memory writes, so the engine never runs them itself).
func Complete ¶
Complete finishes a Delivery run once every issue is cleaned (PRD §7 auto-return): it fast-forwards the primary checkout to origin/<default> (PRD §12 step 20) and returns the repository to Assist with the lock released. It never runs memhub itself — it only signals that a wrap-up is due. The git preflights run before any state change, so a failure leaves the run in Delivery.
type DispatchRequest ¶
type DispatchRequest struct {
SchemaVersion int `json:"schema_version"`
IssueNumber int `json:"issue_number"`
}
DispatchRequest asks to hand one worktree-ready issue to its executor.
type DispatchResult ¶
type DispatchResult struct {
SchemaVersion int `json:"schema_version"`
IssueNumber int `json:"issue_number"`
Branch string `json:"branch"`
Worktree string `json:"worktree"`
Executor manifest.Selection `json:"executor"`
Reviewer manifest.Selection `json:"reviewer"`
Rationale string `json:"rationale"`
}
DispatchResult carries what the adapter needs to spawn the executor into the issue's worktree (PRD §12 step 8): the branch, the repo-relative worktree, and the routing selection.
func Dispatch ¶
Dispatch moves a worktree-ready issue to dispatched: it enforces the issue's dependencies (every DependsOn issue merged or cleaned; an abandoned dependency returns the plan to the gate), fetches origin and fast-forwards the issue branch to origin/<default> inside its worktree (closing the activation and inter-wave staleness windows), sets the issue status to in-progress, and records the phase. The only state write is the final Save, so any failure before it leaves the run unchanged.
type Env ¶
type Env struct {
// RepoRoot is the directory containing .orchestrator/.
RepoRoot string
// Runner executes external commands (git, gh, memhub).
Runner execx.Runner
// Now returns the current time; nil defaults to time.Now. Declared
// for every verb's determinism (tests inject a fixed clock); no PR
// A document currently carries a timestamp field, so no verb reads
// it yet — PR B's lifecycle verbs will.
Now func() time.Time
}
Env carries the invocation context for every run verb, mirroring cli.Env's shape but scoped to what this package needs.
type EscalateRequest ¶
type EscalateRequest struct {
SchemaVersion int `json:"schema_version"`
IssueNumber int `json:"issue_number"`
Trigger string `json:"trigger"`
Detail string `json:"detail"`
}
EscalateRequest raises a PRD §11 escalation on an in-flight issue. Trigger is the closed routing.Trigger set; the engine passes it through and lets routing reject a mismatch.
type EscalateResult ¶
type EscalateResult struct {
SchemaVersion int `json:"schema_version"`
IssueNumber int `json:"issue_number"`
Kind string `json:"kind"`
Executor *manifest.Selection `json:"executor,omitempty"`
Reviewer *manifest.Selection `json:"reviewer,omitempty"`
Rationale string `json:"rationale,omitempty"`
Reason string `json:"reason"`
}
EscalateResult reports the escalation outcome: a reroute (with the new executor/reviewer for the adapter to spawn into the same worktree) or a return-to-architect (the issue is blocked for human design work).
func Escalate ¶
Escalate applies a PRD §11 escalation to an in-flight issue. It builds the routing profile and history from config and the issue's persisted state and runs routing.Escalate (an unknown or mismatched trigger is an error). A reroute updates the routing decision, attempts, role label, and audit records, transferring the work to a stronger executor in place (PRD §11). A return-to-architect blocks the issue for human design work.
type GateDoc ¶
type GateDoc struct {
SchemaVersion int `json:"schema_version"`
PlanDigest string `json:"plan_digest"`
PlanTitle string `json:"plan_title"`
Host string `json:"host"`
ConfigRevision string `json:"config_revision"`
ConfigOverrides []string `json:"config_overrides,omitempty"`
MergeStrategy string `json:"merge_strategy"`
Memhub MemhubReport `json:"memhub"`
CI CIReport `json:"ci"`
Issues []GateIssue `json:"issues"`
}
GateDoc is the human decision gate for a plan (PRD §8, covering every §8 bullet): the adapter renders it natively and owns the four §8 choices (approve and enter Delivery, adjust agent routing, revise scope, or cancel and remain read-only).
type GateIssue ¶
type GateIssue struct {
ID string `json:"id"`
Title string `json:"title"`
Objective string `json:"objective"`
AcceptanceCriteria []string `json:"acceptance_criteria"`
Role manifest.Role `json:"role"`
Executor manifest.Selection `json:"executor"`
Reviewer manifest.Selection `json:"reviewer"`
ReviewerDowngraded bool `json:"reviewer_downgraded"`
RoutingRationale string `json:"routing_rationale"`
DependsOn []string `json:"depends_on,omitempty"`
Wave int `json:"wave"`
RequiredTests []string `json:"required_tests"`
Risk string `json:"risk"`
UsageClass string `json:"usage_class"`
Labels []string `json:"labels"`
}
GateIssue is one plan issue's gate view: what it will do plus the routing the engine derived for it. Executor and Reviewer reuse manifest.Selection — the same exact model/effort pairing the audit record carries.
type IssueResume ¶
type IssueResume struct {
PlanID string `json:"plan_id"`
Number int `json:"number,omitempty"`
Title string `json:"title"`
PhaseBefore state.Phase `json:"phase_before"`
PhaseAfter state.Phase `json:"phase_after"`
Action ResumeAction `json:"action"`
Reason string `json:"reason,omitempty"`
Observed ResumeObserved `json:"observed"`
}
IssueResume is the per-issue line of the resume report.
type MemhubReport ¶
type MemhubReport struct {
Mode string `json:"mode"`
Probe string `json:"probe"` // "healthy" | "unhealthy" | "skipped"
Recall string `json:"recall"` // "healthy" | "unhealthy" | "skipped"
Detail string `json:"detail,omitempty"`
}
MemhubReport records a plan/gate document's memhub probe outcome.
type MergeApproval ¶
type MergeApproval struct {
PRNumber int `json:"pr_number"`
HeadOID string `json:"head_oid"`
ApprovedBy string `json:"approved_by"`
ApprovedAt time.Time `json:"approved_at"`
Statement string `json:"statement"`
}
MergeApproval is the adapter's record of the human's merge approval, pinned to one PR at one head commit.
type MergeReportCI ¶
type MergeReportCI struct {
State string `json:"state"`
Required []CICheck `json:"required"`
Total int `json:"total"`
}
MergeReportCI is the CI evidence carried in the ready-to-merge report.
type MergeReportRequest ¶
type MergeReportRequest struct {
SchemaVersion int `json:"schema_version"`
IssueNumber int `json:"issue_number"`
}
MergeReportRequest asks to pin an approved PR at the merge gate.
type MergeReportResult ¶
type MergeReportResult struct {
SchemaVersion int `json:"schema_version"`
IssueNumber int `json:"issue_number"`
PRNumber int `json:"pr_number"`
PRURL string `json:"pr_url"`
HeadOID string `json:"head_oid"`
MergeStrategy string `json:"merge_strategy"`
CI MergeReportCI `json:"ci"`
ReviewCycles int `json:"review_cycles"`
ConfigRevision string `json:"config_revision"`
NoCIStatement string `json:"no_ci_statement,omitempty"`
}
MergeReportResult is the ready-to-merge report the adapter shows at the human merge gate (PRD §8, §16).
func MergeReport ¶
MergeReport moves an approved, mergeable issue to awaiting-merge and pins the PR's live head OID as the approved head (PRD §8: approval pins one PR state). It requires the last review to have approved, the PR to be open, and required CI to be passing or absent — a pending or failing state fails closed. No-checks is allowed but stated explicitly in the report (PRD §16).
type MergeRequest ¶
type MergeRequest struct {
SchemaVersion int `json:"schema_version"`
IssueNumber int `json:"issue_number"`
Approval MergeApproval `json:"approval"`
}
MergeRequest asks to merge an approved, awaiting-merge issue.
type MergeResult ¶
type MergeResult struct {
SchemaVersion int `json:"schema_version"`
IssueNumber int `json:"issue_number"`
PRNumber int `json:"pr_number"`
Merged bool `json:"merged"`
}
MergeResult reports the completed merge.
func Merge ¶
Merge merges an approved PR at the human merge gate (PRD §12 steps 16-17). The approval must carry the exact statement and pin the PR and head OID the engine recorded at merge-report, which must still equal the PR's live head — any drift fails closed. The verb is re-runnable after a crash: if the PR already reads MERGED it skips the merge and proceeds to closure confirmation and the phase transition.
type PROpenRequest ¶
type PROpenRequest struct {
SchemaVersion int `json:"schema_version"`
IssueNumber int `json:"issue_number"`
Verifications []VerificationInput `json:"verifications"`
// Usage is adapter-reported model usage for this PR-open call
// (PRD §21 "where available"); optional and best-effort.
Usage *metrics.Usage `json:"usage,omitempty"`
}
PROpenRequest opens the PR for a dispatched issue, carrying the executor's verification evidence.
type PROpenResult ¶
type PROpenResult struct {
SchemaVersion int `json:"schema_version"`
IssueNumber int `json:"issue_number"`
PRNumber int `json:"pr_number"`
PRURL string `json:"pr_url"`
}
PROpenResult reports the opened PR.
func PROpen ¶
PROpen opens a pull request for a dispatched issue (PRD §12 step 9). Preconditions: the worktree is clean, the branch is strictly ahead of origin/<default> (no empty PRs), and no open PR already exists for the branch (an orphan from a crashed run fails closed naming resume/abort). It pushes the branch, records the verification evidence in the issue and PR audit records, creates the PR, and moves the issue to pr-open / awaiting-review. The verification set is written (not appended) so a pre-CreatePR crash re-runs cleanly.
type PlanDoc ¶
type PlanDoc struct {
SchemaVersion int `json:"schema_version"`
Host string `json:"host"`
Title string `json:"title"`
Summary string `json:"summary,omitempty"`
Issues []PlanIssue `json:"issues"`
}
PlanDoc is the adapter-submitted plan: a set of issues, grouped into dependency-respecting waves, that `orch run plan` gates and `orch run activate` turns into a Delivery run.
func DecodePlan ¶
DecodePlan decodes data into a PlanDoc, rejecting any field this build does not recognize at any level (schema-versioned documents fail closed on drift rather than silently ignore it).
func (*PlanDoc) Digest ¶
Digest returns the plan's stable content hash: "sha256:" followed by the hex SHA-256 of the re-marshaled struct. Marshaling the decoded struct (rather than hashing the raw input bytes) makes the digest agree regardless of the adapter's original whitespace or key order, so plan and activate compute the same value for the same content.
func (*PlanDoc) Validate ¶
Validate checks the plan against cfg, collecting every violation into one error wrapping ErrPlanInvalid rather than stopping at the first problem (config-package house style). It never mutates p.
Strictly increasing waves across a dependency edge (dep.wave < issue.wave) prove the dependency graph acyclic without a separate topological sort. Risk is not independently checked here beyond domain membership: it is derived from facts.risk_domains (see deriveRisk), never declared, so it cannot contradict them.
type PlanDowngrade ¶
type PlanDowngrade struct {
Mechanical bool `json:"mechanical"`
LowRisk bool `json:"low_risk"`
FullySpecified bool `json:"fully_specified"`
Unsurprising bool `json:"unsurprising"`
}
PlanDowngrade mirrors routing.DowngradeFacts on the wire.
type PlanFacts ¶
type PlanFacts struct {
ReadOnly bool `json:"read_only"`
UnusuallyDifficult bool `json:"unusually_difficult"`
RiskDomains []string `json:"risk_domains,omitempty"`
Downgrade PlanDowngrade `json:"downgrade"`
}
PlanFacts carries the routing-relevant facts about one issue (PRD §9–§11). Routing is derived from these, never independently declared: "adjust routing" means revise facts and resubmit.
type PlanIssue ¶
type PlanIssue struct {
ID string `json:"id"`
Title string `json:"title"`
Objective string `json:"objective"`
AcceptanceCriteria []string `json:"acceptance_criteria"`
Type string `json:"type"` // ghops.Type
AreaLabels []string `json:"area_labels,omitempty"`
Facts PlanFacts `json:"facts"`
DependsOn []string `json:"depends_on,omitempty"`
Wave int `json:"wave"`
RequiredTests []string `json:"required_tests"`
UsageClass string `json:"usage_class"` // light|medium|heavy
}
PlanIssue is one unit of work in the plan.
type Prober ¶
Prober checks memhub reachability and the live recall path. internal/memhub's Client is the production implementation; tests inject a fake so they never spawn a real memhub process.
type ResumeAction ¶
type ResumeAction string
ResumeAction names what resume did to one issue.
const ( // ActionKept leaves the issue's phase unchanged. ActionKept ResumeAction = "kept" // ActionAdvanced moves an issue forward across a crash window GitHub // proves complete (activation's AddWorktree→Save gap). ActionAdvanced ResumeAction = "advanced" // ActionAdoptedPR adopts an orphan PR a crashed pr-open left, moving // the issue to pr-open. ActionAdoptedPR ResumeAction = "adopted-pr" // ActionDemoted returns an awaiting-merge issue to in-review after its // PR head moved past the recorded approval. ActionDemoted ResumeAction = "demoted" // ActionBlocked routes an issue to the blocked phase for human action. ActionBlocked ResumeAction = "blocked" // ActionUnblocked recovers a blocked issue to a re-derived phase. ActionUnblocked ResumeAction = "unblocked" )
type ResumeDoc ¶
type ResumeDoc struct {
SchemaVersion int `json:"schema_version"`
Mode state.Mode `json:"mode"`
RunID string `json:"run_id,omitempty"`
DryRun bool `json:"dry_run"`
Applied bool `json:"applied"`
StoppedReasonBefore string `json:"stopped_reason_before,omitempty"`
StoppedReasonAfter string `json:"stopped_reason_after,omitempty"`
Issues []IssueResume `json:"issues,omitempty"`
Warnings []string `json:"warnings,omitempty"`
}
ResumeDoc is the report resume returns and the CLI renders. Applied is false whenever resume declined to write: on a dry run, or on a stopped run reached without the statement.
type ResumeObserved ¶
type ResumeObserved struct {
IssueState string `json:"issue_state,omitempty"` // OPEN/CLOSED
PRNumber int `json:"pr_number,omitempty"`
PRState string `json:"pr_state,omitempty"` // OPEN/CLOSED/MERGED
PRHeadOID string `json:"pr_head_oid,omitempty"`
CIState string `json:"ci_state,omitempty"` // no-checks|pending|failing|passing
LocalBranch *bool `json:"local_branch,omitempty"` // nil = not checked
Worktree *bool `json:"worktree,omitempty"`
RemoteBranch *bool `json:"remote_branch,omitempty"`
ManifestOK *bool `json:"manifest_ok,omitempty"`
}
ResumeObserved records the GitHub/git facts resume read for one issue. Pointer fields are nil when the fact was not checked for that phase, so the report never conflates "absent" with "not observed".
type ResumeRequest ¶
type ResumeRequest struct {
// Statement must be "" or ResumeStoppedRunStatement.
Statement string
// DryRun observes, classifies, and reports without writing.
DryRun bool
}
ResumeRequest is built by the CLI from flags; it never crosses a process boundary, so it carries no schema_version and is never JSON decoded.
type ReviewRequest ¶
type ReviewRequest struct {
SchemaVersion int `json:"schema_version"`
IssueNumber int `json:"issue_number"`
ReviewedHeadOID string `json:"reviewed_head_oid"`
Verdict string `json:"verdict"`
Summary string `json:"summary"`
Reviewer manifest.Selection `json:"reviewer"`
// Usage is adapter-reported model usage for this review cycle
// (PRD §21 "where available"); optional and best-effort.
Usage *metrics.Usage `json:"usage,omitempty"`
}
ReviewRequest records one consolidated review cycle for an open PR. Reviewer is the selection that actually performed the review; it must equal the issue's routed reviewer, so a review run on the wrong model fails closed instead of polluting the audit record.
type ReviewResult ¶
type ReviewResult struct {
SchemaVersion int `json:"schema_version"`
IssueNumber int `json:"issue_number"`
ReviewCycles int `json:"review_cycles"`
Verdict string `json:"verdict"`
}
ReviewResult reports the recorded review cycle.
func Review ¶
Review records one consolidated review cycle (PRD §12 step 11). It requires the reporting reviewer to be the issue's routed reviewer (PRD §13: the audit record's reviewer is the one that reviewed), and enforces PRD §14's "review begins only after the PR stops changing" by requiring the reviewed head OID to equal the PR's live head — a stale review is rejected so the reviewer re-reads. It advances the issue to in-review, appends the cycle to the issue and PR audit records, and, on request-changes, sets the status back to in-progress.
type RunView ¶
type RunView struct {
ID string `json:"id"`
Host string `json:"host"`
StartedAt time.Time `json:"started_at"`
Plan state.PlanRef `json:"plan"`
Issues []state.Issue `json:"issues"`
// StoppedReason is non-empty when a secret block stopped the run.
StoppedReason string `json:"stopped_reason,omitempty"`
}
RunView is the active Delivery run's status view. Issues carry the full state.Issue shape, so the PR B per-issue lifecycle fields (phase, PR number, decision, review cycles, ...) are reported as-is.
type StatusDoc ¶
type StatusDoc struct {
SchemaVersion int `json:"schema_version"`
Mode state.Mode `json:"mode"`
Consistent bool `json:"consistent"`
Warning string `json:"warning,omitempty"`
Lock *lockfile.Owner `json:"lock,omitempty"`
Run *RunView `json:"run,omitempty"`
}
StatusDoc is the run-state document `orch run status --json` reports. It never loads config, and it never fails on an inconsistent state/lock pair — a second host must be able to see broken state to report it (PRD §14), so any CheckConsistent problem goes into Warning, never the returned error.
type VerificationInput ¶
type VerificationInput struct {
Name string `json:"name"`
Command string `json:"command,omitempty"`
Result string `json:"result"`
Detail string `json:"detail,omitempty"`
At string `json:"at,omitempty"`
}
VerificationInput is one required-test evidence entry the executor supplies (PRD §15: completion requires targeted-test evidence). A missing At is stamped by the engine.