bootstrap

package
v0.14.1 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: MIT Imports: 21 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package bootstrap executes PRD §18 steps 10-15: given the answers an interview (internal/interview, internal/question) collected, it re-derives the terminal question.Complete document itself and composes internal/config, internal/instructions, internal/gitops, and internal/ghops into the one mechanical act that turns an approved interview into an open bootstrap pull request — a mechanical in-binary executor, no model subagent (decision 30).

Execute is the package's only exported entry point and the whole policy home for `orch init --bootstrap`; cli/init.go stays thin dispatch (decode stdin into an AnswerSet, call Execute, encode the result). Two design choices Stage 0 exists to enforce:

  • Anti-forgery (spec pass 2026-07-11, contract call 4): Execute never trusts a caller-supplied Complete document — there is no such parameter. It re-runs interview.Detect and interview.Next itself from the raw answers in Deps.Answers and requires the result to be a DocComplete with BootstrapReady, so every byte it goes on to write is recomputed from validated answers, never injected by an adapter. Approval is itself an answer Next validates, and Blockers make approval an error, so a caller cannot skip either check by hand-crafting a document.
  • No Delivery lock (contract call 1): bootstrap never creates .orchestrator/ in the primary checkout and never writes to internal/state or internal/lockfile (ExecuteConfigure, PR B's `orch configure` counterpart, does read both — its own Stage 0 refuses to start while a Delivery run is active — but neither entry point ever creates or mutates either). Mutual exclusion against a concurrent or crashed bootstrap comes entirely from fail-closed preflights against a fixed branch name, orch/bootstrap — not the per-issue orch/issue-<n>- scheme internal/run uses, because the issue number this branch will eventually close does not exist until Stage 1 creates it. A fixed name is what makes a crashed re-run collide with its own leftovers instead of sidestepping them under a fresh number (contract call 3).

Stage 0 (preflights, see preflight.go) performs zero mutations: any failure there changes nothing on disk or on GitHub. Stage 1 (mutations, see below) advances in a fixed order — label taxonomy, issue, worktree, files, §18.13 validation, commit, push, PR, status — and every failure after the issue is created is reported with the exact artifacts it left behind and the shell commands that undo them (contract call 3: re-running bootstrap from the same answers is the recovery path, not `orch abort`, which this package never calls — it never touches Delivery state to begin with).

Index

Constants

View Source
const BootstrapBranch = "orch/bootstrap"

BootstrapBranch is the fixed branch name Stage 0's orphan preflights guard and Stage 1 creates (see the package doc's "no Delivery lock" note): deliberately not the Delivery orch/issue-<n>- scheme.

View Source
const ConfigureBranch = "orch/configure"

ConfigureBranch is the fixed branch name `orch configure`'s Stage 0 orphan preflights guard and Stage 1 creates — the same crash-collision rationale as BootstrapBranch (package doc), and deliberately distinct from both it and internal/run's per-issue orch/issue-<n>- scheme (drift-pinned in bootstrap_test.go).

View Source
const ReportSchemaVersion = 1

ReportSchemaVersion is the Report schema this build emits.

Variables

View Source
var (
	// ErrNotComplete reports that Next did not re-derive a terminal
	// DocComplete document from deps.Answers: either the interview is
	// not finished (still questions/summary) or it was aborted.
	ErrNotComplete = errors.New("interview has not reached the terminal complete document")
	// ErrNotBootstrapReady reports a re-derived Complete document whose
	// BootstrapReady is false (git or gh was not detected).
	ErrNotBootstrapReady = errors.New("bootstrap readiness requirements are not met")
	// ErrAlreadyInitialized reports a committed configuration already
	// present at the git root.
	ErrAlreadyInitialized = errors.New("already initialized: " + config.Path + " exists")
	// ErrBranchExists reports the fixed bootstrap branch already
	// resolving locally (contract call 3: an orphan preflight).
	ErrBranchExists = errors.New("bootstrap branch already exists locally")
	// ErrRemoteBranchExists reports the fixed bootstrap branch already
	// present on the remote (contract call 3).
	ErrRemoteBranchExists = errors.New("bootstrap branch already exists on the remote")
	// ErrOpenPRExists reports an open PR already carrying the fixed
	// bootstrap branch as its head (contract call 3).
	ErrOpenPRExists = errors.New("an open bootstrap pull request already exists")
	// ErrValidationFailed reports a §18.13 mechanical check that did
	// not pass inside the freshly written worktree.
	ErrValidationFailed = errors.New("bootstrap installation validation failed")
)

Sentinel errors callers test with errors.Is. Specifics wrap these with %w and detail (config/run house style) rather than replace them.

View Source
var ErrDeliveryActive = errors.New("a delivery run is active")

ErrDeliveryActive reports a running or crashed Delivery run detected through state.Load/lockfile.Inspect: `orch configure` refuses to start while one is active (contract call 1) — a mid-run committed configuration edit would change the routing inputs the active run already computed against.

Functions

This section is empty.

Types

type Deps

type Deps struct {
	// RepoRoot is the directory `orch init --bootstrap` was invoked
	// from — the primary checkout. Detect probes git from here; the
	// resulting Facts.GitRoot (not RepoRoot) is what every subsequent
	// gitops/ghops/config/instructions call uses once Stage 0 confirms
	// git is present (BootstrapReady already requires it).
	RepoRoot string
	// Answers is the adapter's raw AnswerSet.Answers — never a
	// pre-built Complete document (see the package doc's anti-forgery
	// note). A nil map is treated as empty, mirroring
	// question.DecodeAnswers' own normalization.
	Answers map[string]string
	// Runner executes git and gh.
	Runner execx.Runner
	// LookPath resolves an executable name; a nil LookPath makes every
	// host/git/gh/memhub fact false (interview.Deps precedent).
	LookPath func(string) (string, error)
	// Now returns the current time; nil defaults to time.Now
	// (run.Env precedent). Stamps every §18.13 validation entry.
	Now func() time.Time
}

Deps carries Execute's injectable surface.

type Report

type Report struct {
	SchemaVersion int               `json:"schema_version"`
	Issue         ReportRef         `json:"issue"`
	PR            ReportRef         `json:"pr"`
	Branch        string            `json:"branch"`
	Validations   []ValidationEntry `json:"validations"`
	NextSteps     []string          `json:"next_steps"`
}

Report is Execute's success output, emitted by `orch init --bootstrap` as schema-versioned JSON on stdout.

func Execute

func Execute(ctx context.Context, deps Deps) (Report, error)

Execute runs the full bootstrap: Stage 0 re-derives and validates the interview's terminal document from deps.Answers (zero mutations; see preflight.go), then Stage 1 performs the ordered mutation sequence PRD §18 steps 10-15 describe.

func ExecuteConfigure

func ExecuteConfigure(ctx context.Context, deps Deps) (Report, error)

ExecuteConfigure runs the full `orch configure` PR flow (PRD §17): Stage 0 re-derives and validates interview.NextConfigure's terminal document from deps.Answers (zero mutations; see stage0Configure), then Stage 1 performs the same ordered mutation sequence Execute's own bootstrap flow does (EnsureLabelTaxonomy, issue, worktree, files, validation, commit, push, PR, status), parameterized by configureJob instead of initJob.

type ReportRef

type ReportRef struct {
	Number int    `json:"number"`
	URL    string `json:"url"`
}

ReportRef names a created issue or PR.

type ValidationEntry

type ValidationEntry struct {
	Name   string `json:"name"`
	Result string `json:"result"`
	Detail string `json:"detail,omitempty"`
	At     string `json:"at,omitempty"`
}

ValidationEntry is one §18.13 mechanical check's outcome, in the shape manifest.Verification/run.VerificationInput already establish for audit-record evidence: Name identifies the check, Result is a short free-text verdict ("pass"/"fail"), Detail explains a failure, and At is the RFC3339 UTC stamp from Deps.Now.

Jump to

Keyboard shortcuts

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