workflow

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: Apache-2.0 Imports: 44 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 workflow implements the deterministic M1 stage graph and the orchestrator that drives it (§6, §11). The orchestrator is constrained by workflow policy: it runs stages in order and may only rank/explain next moves within that policy.

Index

Constants

View Source
const (
	BudgetSourceInitiative = "initiative"
	BudgetSourceProject    = "project"
	BudgetSourceNone       = "none"
)

Budget sources: where an initiative's effective cap comes from.

View Source
const (
	StageFraming           = "framing"
	StageResearch          = "research"
	StageProductDefinition = "product_definition"
	StageReview            = "review"
)

Stage keys for the M1 graph.

View Source
const (
	StageArchitecture        = "architecture"
	StageProductDesign       = "product_design"
	StageVerificationDesign  = "verification_design"
	StageConvergence         = "convergence"
	StageExecutionPlan       = "execution_plan"
	StageExecutionPlanReview = "execution_plan_review"
	StageImplementationBrief = "implementation_brief"
)

Stage keys for the M2 graph (§12).

View Source
const (
	RoleOrchestrator         = "product_orchestrator"
	RoleResearchAnalyst      = "research_analyst"
	RoleProductManager       = "product_manager"
	RoleAdversarialReviewer  = "adversarial_reviewer"
	RoleArchitect            = "architect"
	RoleProductDesigner      = "product_designer"
	RoleVerificationEngineer = "verification_engineer"
	RoleEngineeringLead      = "engineering_lead"
)

Role names (must match contracts/*.yaml).

View Source
const (
	LiveIdle     = "idle"     // no run in progress
	LiveStarting = "starting" // a run is preparing: planning, copying the workspace
	LiveRunning  = "running"  // the agent is running
	LiveFinished = "finished" // the agent is done; the run is in its checks
)

Live output states, as reported to clients.

View Source
const ChangeSetReviewSchemaName = "change_set_review"

ChangeSetReviewSchemaName is the fake provider's queue key for the change-set adversarial review. Exported so demoProvider can prime it and tests can steer it; it never reaches a real provider.

View Source
const DeterministicPlanCheckRun = "deterministic-plan-check"

DeterministicPlanCheckRun is the ReviewRunID stamped on every finding deterministicPlanChecks produced, distinguishing them from the adversarial reviewer's, whose run id runModel supplies. The daemon reads it to refuse `approve-plan` over a structural defect a human cannot meaningfully accept. The PRD loop's equivalent literal is "deterministic-check", deliberately different, so the two sets cannot be confused.

View Source
const PlanFindingTarget = "execution_plan"

PlanFindingTarget is the target type of every finding raised against the execution plan. The UI shows these on the Plan page, where approval happens.

View Source
const QualityReviewSchemaName = "quality_review"

QualityReviewSchemaName is the structured-output name of the verification_engineer's quality review (schema.QualityReview). Its own key, so a scripted test can drive it without disturbing any other review.

View Source
const RigorCapCategory = "review_rigor"

RigorCapNote is the category stamped on the synthetic observation finding capFindings adds when it drops findings, so the UI and tests can find it without string-matching the whole findings list.

View Source
const ToolCallCancelled = "cancelled"

ToolCallCancelled is the status closeOpenToolCalls gives a tool call the run ended without finishing.

Variables

View Source
var ErrBudgetExceeded = errors.New("workflow: budget exceeded")

ErrBudgetExceeded is matched (errors.Is) by every BudgetExceededError.

View Source
var ErrNoInitiativeBranch = errors.New("workflow: this initiative has no dedicated branch yet; " +
	"enable git.branch_per_initiative and apply a change set first")

ErrNoInitiativeBranch is returned by CreatePR when the initiative has no dedicated branch yet AND git.branch_per_initiative is off -- the message names the actual fix in that case: turn the setting on, then apply a change set. It must not be returned verbatim when the setting is already on (see noInitiativeBranchError): a real founder-journey run hit `idea pr` with git.branch_per_initiative already enabled and no change set applied yet, and got told to "enable git.branch_per_initiative" -- advice for a state the initiative was not in.

View Source
var ErrNoLiveRun = errors.New("workflow: that run is not running")

ErrNoLiveRun is returned when a note is sent to a run that is not running.

View Source
var ErrNoPR = errors.New("workflow: this initiative has no pull request yet; run `idea pr` first")

ErrNoPR is returned by PRChecks when the initiative has no pull request yet.

View Source
var ErrNoReadyTask = errors.New("workflow: no ready tasks")

ErrNoReadyTask is what nextReadyTask returns when the initiative has nothing runnable. A sentinel rather than a bare error so callers can tell it from the storage failures the same function can return -- NextAction has to make exactly that distinction.

View Source
var GraphNodeTypes = []string{
	"task", "requirement", "decision", "question", "artifact", "context_doc", "run", "quality_result",
	"objective", "metric", "assertion", "change_set",
}

GraphNodeTypes is the closed set of node types the product graph addresses. Exported so the daemon can reject an unknown one at the edge rather than answering an empty traversal.

Functions

func ImplementerModelSpec added in v0.5.0

func ImplementerModelSpec(cfg config.HarnessConfig, registry *model.Registry) string

ImplementerModelSpec is the model the coding agent runs: models.implementer, then executor.model, then the implementer role's usual resolution. Exported so the daemon's "can a run start" check resolves exactly what Execute will; it checked executor.model alone and so blocked runs Execute would accept, and passed ones it would refuse.

func ImplementerProvider added in v0.5.0

func ImplementerProvider(cfg config.HarnessConfig, registry *model.Registry) (executor.AgentProvider, error)

ImplementerProvider resolves the provider the coding agent will use, as Execute does.

func NormalizeRequirementRef added in v0.6.0

func NormalizeRequirementRef(raw string) string

NormalizeRequirementRef normalizes a model- or human-supplied requirement reference for tolerant matching against a Requirement.Code (review A4 #4): trimmed, upper-cased, and a "REQ-3: title" form reduced to the code prefix before the colon. Exported so the daemon's task-editing handlers (`add task` / `update task`) apply the identical tolerance.

func PlanNotReadyForExecution added in v0.5.0

func PlanNotReadyForExecution(ini domain.Initiative) string

PlanNotReadyForExecution returns why an initiative waiting on a human cannot have its tasks run yet, or "".

needs_human_judgment covers parks before the plan is approved (the PRD or the plan under review) as well as after (verification). Execution was allowed from all of them, so from a plan-review park it ran tasks from an unapproved plan -- and left the initiative where approve-plan and revise-plan were both refused. The Build page then offered that one click away.

func SetAutoDockerProbeForTest added in v0.7.0

func SetAutoDockerProbeForTest(probe func(context.Context) bool) (restore func())

SetAutoDockerProbeForTest replaces the Docker probe auto resolution uses, returning a restore func. It panics outside a test binary, for the reason executor.TestOnlySetKnownIncompatible does.

func ValidNodeType added in v0.4.0

func ValidNodeType(typ string) bool

ValidNodeType reports whether typ names a node the graph can hold.

Nothing validated it, so `idea why requirements REQ-1` -- a plural typo -- answered "No provenance edges found." and exited 0. A bad *id* was caught and a bad *type* was not, which turns a provenance question into a confident false negative on the product's headline claim.

Types

type BudgetExceededError added in v0.7.0

type BudgetExceededError struct {
	InitiativeID string
	SpentUSD     float64
	CapUSD       float64
	// Before names the call that was refused ("the plan_review model call",
	// "the hermes agent run").
	Before string
}

BudgetExceededError says an initiative reached its cap before a call.

func (*BudgetExceededError) Detail added in v0.7.0

func (e *BudgetExceededError) Detail() string

Detail is the short "$x of $y" form the budget_exceeded event carries.

func (*BudgetExceededError) Error added in v0.7.0

func (e *BudgetExceededError) Error() string

func (*BudgetExceededError) Is added in v0.7.0

func (e *BudgetExceededError) Is(target error) bool

Is makes errors.Is(err, ErrBudgetExceeded) match.

type BudgetStatus added in v0.7.0

type BudgetStatus struct {
	// CapUSD is the effective cap; nil when there is none.
	CapUSD *float64 `json:"cap_usd"`
	// Source is initiative, project or none.
	Source string `json:"source"`
	// InitiativeCapUSD is the initiative's own cap, when it set one.
	InitiativeCapUSD *float64 `json:"initiative_cap_usd"`
	// ProjectDefaultUSD is budget.default_initiative_usd (0: none).
	ProjectDefaultUSD float64 `json:"project_default_usd"`
	// SpentUSD is what counts against the cap: ModelUSD plus AgentUSD when
	// the agent's spend was measured.
	SpentUSD float64 `json:"spent_usd"`
	ModelUSD float64 `json:"model_usd"`
	// AgentUSD is the coding agent's measured spend; nil when not measured.
	AgentUSD  *float64 `json:"agent_usd"`
	AgentRuns int      `json:"agent_runs"`
	// AgentNotCounted is true when the agent ran but its spend could not be
	// measured (hermes and omp print no reliable cost), so the meter
	// understates the real spend by that much.
	AgentNotCounted bool `json:"agent_not_counted"`
	// RemainingUSD is CapUSD - SpentUSD, floored at 0; nil without a cap.
	RemainingUSD *float64 `json:"remaining_usd"`
	// Exceeded is true when the next model or agent call would be refused.
	Exceeded bool `json:"exceeded"`
	// Parked is true while the initiative is stopped on budget_exceeded.
	Parked bool `json:"parked"`
	// Note explains what the meter does and does not count.
	Note string `json:"note"`
}

BudgetStatus is an initiative's cap and spend (GET .../budget).

type Coverage

type Coverage struct {
	Code        string `json:"code"`
	Pass        int    `json:"pass"`
	Total       int    `json:"total"`
	NeedsManual int    `json:"needs_manual"`
	Status      string `json:"status"`
}

Coverage is a per-requirement verification-coverage summary (§70).

type DiffDecision

type DiffDecision struct {
	Code       string `json:"code"`
	Question   string `json:"question"`
	Resolution string `json:"resolution,omitempty"`
}

DiffDecision is one decision in the semantic diff.

type DiffRequirement

type DiffRequirement struct {
	Code      string `json:"code"`
	Statement string `json:"statement"`
	Priority  string `json:"priority"`
}

DiffRequirement is one requirement in the semantic diff.

type Engine

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

Engine drives the M1 workflow.

func New

func New(db *store.DB, blobs *blob.Store, registry *model.Registry, cfg config.HarnessConfig, log *slog.Logger) *Engine

New builds an engine.

func (*Engine) Advance

func (e *Engine) Advance(ctx context.Context, initiativeID string) (domain.InitiativeStatus, error)

func (*Engine) AgentOutput added in v0.5.1

func (e *Engine) AgentOutput(ctx context.Context, initiativeID string) (state string, output string)

AgentOutput returns the end of a running agent's output for an initiative, redacted and sanitized, and whether the agent is still running. It never takes e.mu.

func (*Engine) ApplyChangeSet

func (e *Engine) ApplyChangeSet(ctx context.Context, initiativeID, changeSetID string) error

ApplyChangeSet applies an approved change set: approved→applying→applied. It writes the orchestrator-computed diff into the canonical workspace via atomic per-file temp+rename, capturing the pre-image into the journal so revert can restore it byte-for-byte (§39, review B1).

func (*Engine) Approve

func (e *Engine) Approve(ctx context.Context, initiativeID string) error

Approve records explicit human approval of the initiative (§11): the reviewed PRD is accepted as it stands, findings and all, and the initiative moves on to design.

Compare-and-swap, not a read-then-write. This was an unconditional SetInitiativeStatus with no check whatsoever, so it overwrote whatever the initiative was doing -- including releasing the claim a running `advance` was holding, after which a second advance was accepted and two ran concurrently on one initiative. Reading the status first would have narrowed that window without closing it, which is the same check-then-act ClaimInitiativeRunning exists to avoid.

`approved` is a legal source so a repeated approve is a no-op rather than an error. Every other status is refused: `running` because work is in flight, `plan_approved` and `complete` because approving there walks the state machine backwards, and `failed` because the recovery for that is `idea retry`.

func (*Engine) ApprovePlan

func (e *Engine) ApprovePlan(ctx context.Context, initiativeID string) (domain.InitiativeStatus, error)

ApprovePlan accepts a plan whose review raised findings: it records the human's acceptance of them and moves the initiative to plan_approved. It does not regenerate tasks, and it is terminal -- there is no re-evaluation and no path back to needs_human_judgment, which is what makes it an accept rather than a retry.

Gated on the reason, exactly as Approve is, and for the same defect. All four JudgmentReasons share one status, so a status-only gate let this accept a plan parked on `plan_dependencies` -- where the undisposed `plan_dependency` finding IS the guard that keeps a dependency graph known to be incomplete out of `complete`, something advance.go relies on in three places and the CHANGELOG states outright. Approving there shipped the incomplete graph.

The change-set guard matches RevisePlan and ReopenPhase. Without it, an initiative already building could have its change set's findings swept by a plan-level command -- and a blocking change-set finding is the one this repository repeatedly calls unclearable by any CLI command.

The disposition lives here and not in runExecutionPlanReview, which Advance, RevisePlan and ReopenPhase also call: on those paths the plan was regenerated and nobody accepted anything, so attributing an acceptance to a human would be a lie. accepted_risk by HumanActor, the same pair Approve records, because that is what happened -- nothing was fixed.

func (*Engine) BackfillNoOpChangeSets added in v0.6.0

func (e *Engine) BackfillNoOpChangeSets(ctx context.Context) (int, error)

BackfillNoOpChangeSets recomputes no_op for every change set migration 34 left at its conservative default of false (review MEDIUM #1). The migration's comment argued file counts "aren't recomputable" -- they are: the patch manifest was persisted unconditionally before no_op existed, so len(loadPatch(cs).Files) == 0 is one blob read per row. The recompute doesn't happen IN the migration because a migration is plain SQL text (store.migrations) with no access to the blob store; this runs once, at daemon start, after both the DB and the raw blob store exist (see runtime.go's EnsureProject), gated by store.ClaimNoOpBackfill's persisted marker so it costs one query per project on every later start rather than a full table scan.

A change set whose patch can no longer be read (a blob evicted or corrupted independently of this fix) is left at no_op=false -- exactly migration 34's own fallback for a row it cannot recompute -- rather than failing the whole backfill.

func (*Engine) BudgetStatus added in v0.7.0

func (e *Engine) BudgetStatus(ctx context.Context, initiativeID string) (BudgetStatus, error)

BudgetStatus reports an initiative's effective cap and its spend so far.

func (*Engine) BuildRunReport added in v0.7.0

func (e *Engine) BuildRunReport(ctx context.Context, runID string) (RunReport, error)

BuildRunReport assembles the report for an agent run.

func (*Engine) ConvergeDecisions

func (e *Engine) ConvergeDecisions(ctx context.Context, initiativeID string) error

ConvergeDecisions runs the orchestrator synthesis across every open decision that has preserved dissents (§M2 tail). For each such decision the product orchestrator reconciles the dissenting positions into a single synthesized recommendation, which is stored back on the decision (and surfaced as its synthesis in the projection). Dissents themselves are never erased (§8).

func (*Engine) Coverage

func (e *Engine) Coverage(ctx context.Context, initiativeID string) ([]Coverage, error)

Coverage computes the verification coverage for each requirement of an initiative (pass criteria / total criteria, plus how many still need a human). The requirement's status is surfaced so consumers can distinguish waived and failed (neither of which is "needs manual sign-off") from genuinely pending.

func (*Engine) CreatePR added in v0.6.0

func (e *Engine) CreatePR(ctx context.Context, initiativeID string) (string, error)

CreatePR pushes an initiative's dedicated branch and opens a pull request via `gh pr create` (review C4 piece 3), with a body built from the initiative's title, description, change sets and verification progress. Idempotent: a repeat call returns the already-recorded PR URL rather than opening a second PR for the same branch.

func (*Engine) DescribeImages

func (e *Engine) DescribeImages(ctx context.Context, initiativeID string) error

DescribeImages describes every image context doc that lacks a description, using a vision-capable model. Each description is stored (redacted) and its digest recorded so contextDocs can inject it. Failures are logged per-doc and do not block the remaining docs.

func (*Engine) DetachRemoteRuns added in v0.7.0

func (e *Engine) DetachRemoteRuns()

DetachRemoteRuns stops following remote runs without stopping them: the daemon is shutting down, and the next one re-attaches.

func (*Engine) DiscardPartial added in v0.5.1

func (e *Engine) DiscardPartial(initiativeID string) error

DiscardPartial throws the initiative's kept partials away — every task's, not one. It is called by "Start over", and by reopening a phase or revising the plan, which can change the task a partial belongs to.

func (*Engine) DiscussDecision

func (e *Engine) DiscussDecision(ctx context.Context, decisionID, message string) (string, error)

DiscussDecision runs one human→AI discussion turn on a decision (§8): the human asks for elaboration or proposes an alternative, and the product manager replies. Both messages are persisted to the decision's thread.

func (*Engine) Execute

func (e *Engine) Execute(ctx context.Context, initiativeID string) (domain.ChangeSet, error)

Execute runs the multi-role pipeline for the next ready task — planner (engineering_lead brief) → implementer (executor writes files) → deterministic checks → review_required/rejected. The adversarial reviewer runs at review time (§50).

func (*Engine) ExecutePrecondition added in v0.6.0

func (e *Engine) ExecutePrecondition(ctx context.Context, initiativeID string) error

ExecutePrecondition runs Execute's own fast, read-only guards -- task selection, another open change set, executor resolution, the trust-tier gate, and a prior change set of the SAME task left mid-review or as an unresolved no-op -- without doing any of Execute's actual work. It exists so Runtime.ExecuteInitiativeFreshWithNote can call it SYNCHRONOUSLY, before ever creating an operation (ICP re-run D5).

Execute is asynchronous: before this existed, every one of these guards ran only inside the launchOperation goroutine, strictly after the daemon had already answered 202 and the CLI had already printed "✓ execute started". A guard that refuses in under a millisecond, at zero model cost -- the ordinary case, since none of them call a model -- then landed a moment later as an operation failure: a success line immediately followed by a failure, for a run that in fact never started at all.

This mirrors, but does not replace, the identical checks inlined in Execute below: they remain the backstop for the genuine race window between this call returning and the task actually being claimed, the same reasoning ExecuteInitiativeFreshWithNote's own NextReadyTask precheck already documents. Deliberately excluded: the changes_requested -> superseded transition Execute performs over the same prior-change-set loop is a WRITE, not a read -- calling it here too would supersede a change set during the precondition check and then find it no longer changes_requested when Execute runs for real a moment later.

No engine mutex: like the exported NextReadyTask, every read here is a plain table scan with no dependency on state e.mu protects, so it is safe to call from outside Execute's own locked section.

func (*Engine) ExecuteWave added in v0.7.0

func (e *Engine) ExecuteWave(ctx context.Context, initiativeID string, maxParallel int) ([]domain.ChangeSet, error)

ExecuteWave runs up to maxParallel ready tasks concurrently, each through the per-task pipeline, returning the change sets produced (in task order) and the first error. It is the dependency-aware parallel execution primitive: independent tasks whose depends_on predecessors are applied run in one wave; a dependent becomes ready only in a later wave after its predecessor is applied. Overlapping edits by independent peers are caught at apply by fsdiff.StaleBase (the clean, existing conflict path).

func (*Engine) Impact

func (e *Engine) Impact(ctx context.Context, initiativeID, nodeType, nodeID string) ([]ImpactItem, error)

Impact returns the dependents of a node: it follows incoming edges (from nodes that point to this node) with a staleness classification.

An incoming invalidates edge is not followed: the assertion that invalidates a node undercuts it, it does not depend on it. A dependent that something invalidates is classed "obsolete" instead -- so `impact assertion ASM-3` on a retracted assertion reads the requirements and decisions resting on it as obsolete, not merely to revalidate.

A task's change sets are not wired as graph edges (review A4 #4: a change set is linked to its task via ChangeSet.TaskID, not an edge), so when the frontier reaches a task node, its change sets are pulled in by query and added as synthetic dependents -- otherwise `impact requirement REQ-n` (or `impact decision DEC-n`) could reach the task and stop there, never reaching the CHG built from it (review A4 #4/#5: "impact is true").

func (*Engine) ImpactCounts

func (e *Engine) ImpactCounts(ctx context.Context, initiativeID string, nodes []NodeRef) (map[string]int, error)

ImpactCounts returns, for each node, the number of unique transitive dependents (nodes that directly or indirectly depend on it). Used to render "blocks N" without an Impact call per node.

Unlike Impact — which returns one item per edge and can repeat a node that is reachable via multiple paths — these counts are DEDUPED by node, so a count is the number of distinct blocked nodes, not the number of edges. In a cycle the queried node itself may appear among its dependents (mirroring Impact's frontier semantics).

func (*Engine) LiveRun added in v0.7.0

func (e *Engine) LiveRun(initiativeID string) (LiveRunInfo, bool)

LiveRun returns the initiative's running agent run, if one is past the point of having a run id.

func (*Engine) MeasureMetrics added in v0.7.0

func (e *Engine) MeasureMetrics(ctx context.Context, initiativeID, ref, actor string) ([]MeasureResult, error)

MeasureMetrics measures one metric (ref is its code or id) or, with ref empty, every live metric with a command or url source. Manual metrics are reported as skipped when measured in bulk and refused when named. Each successful measurement is recorded as an observation (with attribution and drift, see store.RecordObservation); one source failing does not stop the rest.

func (*Engine) MeasureQuality added in v0.7.0

func (e *Engine) MeasureQuality(ctx context.Context, initiativeID string) (QualityScorecard, error)

MeasureQuality measures every enabled quality dimension against the initiative's applied work and records the results as evidence, then returns the updated scorecard. Dimensions whose mode is off are not measured and not recorded.

The workspace is read under mu -- the lock execute/apply/revert hold -- so a measurement never sees half an apply; the sandbox runs and the model review happen after it is released, against a private copy, so a minutes-long reproducibility run does not hold every other mutation up.

func (*Engine) NextAction

func (e *Engine) NextAction(ctx context.Context, initiativeID string) (string, error)

NextAction returns the deterministic next step for an initiative (§52, Track C). It stops at human judgment points (review / apply / resolve / done) and otherwise names the next automatable step (advance / execute / verify). `failed` and `wait` are terminal-for-now answers rather than steps: the first is an error the caller must surface, the second means an operation is in flight.

func (*Engine) NextReadyTask added in v0.5.0

func (e *Engine) NextReadyTask(ctx context.Context, initiativeID string) (*NextTask, error)

NextReadyTask reports the task Execute would run next for initiativeID, or nil when there is none.

Deliberately lock-free, unlike Execute itself: a poll-driven UI (the Build page) calling this on every refresh must not block for the whole duration of an in-flight Execute, which holds e.mu for as long as the agent container runs. A slightly stale answer is an acceptable cost for a read-only hint; Execute's own claim is still what actually enforces correctness when the button is clicked.

func (*Engine) PRChecks added in v0.6.0

func (e *Engine) PRChecks(ctx context.Context, changeSetID string) (git.PRChecksResult, error)

PRChecks reports the latest CI status of changeSetID's initiative's pull request via `gh pr checks` (review C4 piece 3). Every change set of an initiative shares the same PR, so this is the same result whichever of the initiative's change sets it is asked through.

func (*Engine) PartialWork added in v0.5.1

func (e *Engine) PartialWork(initiativeID string) *PartialWorkInfo

PartialWork describes the next ready task's kept partial, or nil — the one a re-run would carry, mirroring nextReadyTask.

func (*Engine) PendingNotes added in v0.7.0

func (e *Engine) PendingNotes(ctx context.Context, initiativeID string) []string

PendingNotes returns steering notes held for the initiative's next run, oldest first (nil when none, or when they cannot be read).

func (*Engine) PromoteDocComment

func (e *Engine) PromoteDocComment(ctx context.Context, commentID string) (*domain.Question, error)

PromoteDocComment turns a document comment into an open Question for the initiative's judgment flow, and links the comment to the new question (so it is not promotable twice). The section, when present, is prefixed to the question so the question names where in the document it came from.

func (*Engine) QualityScorecard added in v0.7.0

func (e *Engine) QualityScorecard(ctx context.Context, initiativeID string) (QualityScorecard, error)

QualityScorecard reads the current scorecard without measuring anything.

func (*Engine) ReconcileRemoteRuns added in v0.7.0

func (e *Engine) ReconcileRemoteRuns(ctx context.Context) (int, error)

ReconcileRemoteRuns re-attaches to every remote run not yet over: each is caught up from its event cursor and followed until it finishes (its task's next execute collects the result), fails, or turns out to have vanished from the server. It returns once the watchers are started.

func (*Engine) RecordHumanEvidence

func (e *Engine) RecordHumanEvidence(ctx context.Context, initiativeID, requirementRef string, status domain.VerificationStatus, note, actor string) error

RecordHumanEvidence records a human judgment (pass/fail/waived) for every acceptance criterion of a requirement (§70, review B10), then applies the requirement-level disposition: pass leaves the status for VerifyInitiative to mark verified; fail marks it failed; waived marks it waived. This is the human sign-off path — UX/security criteria that the deterministic verifier marks needs_manual are cleared here by a human actor, never by a model.

func (*Engine) RecordHumanPass

func (e *Engine) RecordHumanPass(ctx context.Context, initiativeID, requirementRef, note, actor string) error

RecordHumanPass records a human "pass" evidence for every acceptance criterion of a requirement (§70, review B10).

func (*Engine) RecordMetric added in v0.7.0

func (e *Engine) RecordMetric(ctx context.Context, initiativeID, ref string, value float64, note, actor string, observedAt time.Time) (*domain.MetricObservation, domain.MetricStatus, error)

RecordMetric records a human-supplied value for a metric (`idea metric record`, the MCP record_metric tool): the store computes attribution and drift. observedAt zero means now.

func (*Engine) RejectConflicted

func (e *Engine) RejectConflicted(ctx context.Context, initiativeID, changeSetID string) error

RejectConflicted resolves a conflicted change set by rejecting it and re-opening its task (mirrors the existing rejected recovery path).

func (*Engine) Reload

func (e *Engine) Reload(cfg config.HarnessConfig, registry *model.Registry, redactor *security.Redactor, blobs *blob.Store, dotEnv map[string]string)

Reload swaps the config-derived components in place on the SAME engine, so the engine's mutex continues to serialize execute/apply/revert across a reload. e.mu excludes Execute/ApplyChangeSet/RevertChangeSet, which hold it for their whole duration; cfgMu (review H4) is what actually guards the field writes below against every OTHER entry point (Run, Advance, Retry, RevisePlan, Resume, Revise, ReopenPhase, ...), none of which hold e.mu -- the doc comment this replaces claimed "ALL entry points now hold [e.mu]", which was false, and go test -race proved it.

func (*Engine) RemoteSupervisor added in v0.7.0

func (e *Engine) RemoteSupervisor() *executor.RemoteSupervisor

RemoteSupervisor returns the engine's supervisor, creating it on first use.

func (*Engine) RenderPatch

func (e *Engine) RenderPatch(cs *domain.ChangeSet) string

RenderPatch renders a change set's patch as a readable diff (path + content per file) for the adversarial reviewer and the diff endpoint. RenderPatch renders a change set's patch as a readable diff (path + content per file) for the adversarial reviewer and the diff endpoint. It is REDACTED at this display surface so raw file content never reaches a network-egress model (review SRE regression); the raw store stays redaction-free for byte-for-byte apply/revert.

func (*Engine) RenderPatchPage added in v0.6.0

func (e *Engine) RenderPatchPage(cs *domain.ChangeSet) (rendered string, total int)

RenderPatchPage is RenderPatch bounded to at most maxDiffEndpointFiles files (the diff endpoint's variant; see maxDiffEndpointFiles). total is the change set's true file count, so a truncated response can say so.

func (*Engine) ReopenPhase

func (e *Engine) ReopenPhase(ctx context.Context, initiativeID, phase string) (domain.InitiativeStatus, error)

ReopenPhase re-runs the design pipeline from the given design stage through plan review (downstream cascade), regenerating artifacts as new versions and the plan from scratch. It is a pre-execution action: once any change set exists the reopen is refused, since re-planning would orphan applied work. phase must be one of architecture, product_design, verification_design.

func (*Engine) RerunChangeSetReview added in v0.6.0

func (e *Engine) RerunChangeSetReview(ctx context.Context, initiativeID, changeSetID string) error

RerunChangeSetReview runs the adversarial reviewer for a change set whose review never completed (ICP re-run defect #1): Execute's own call to it errored -- most often the operation was cancelled mid-review -- after the change set had already left checks_running for review_required, so it sits there carrying only mechanical-check observations, with the task never marked done and `idea execute` free to re-pick it and duplicate the work.

This is an explicit, paid, user-initiated action (a real model call), never triggered implicitly by approve: the round-3 fix that made a plain approve free of model calls is unconditional, and this is the one, named escape hatch for the one case that needs a review to actually happen. It refuses outright once a review has already completed for this change set -- nothing to rerun, and rerunning would reintroduce exactly the "a rejected finding comes back reworded" non-convergence problem that fix removed.

func (*Engine) ResetConflictedForRetry

func (e *Engine) ResetConflictedForRetry(ctx context.Context, initiativeID, changeSetID string) error

ResetConflictedForRetry resets a conflicted change set back to approved so the existing apply path can be re-run unchanged (approved→applying→applied).

func (*Engine) ResolveExecutor added in v0.7.0

func (e *Engine) ResolveExecutor(ctx context.Context) ExecutorResolution

ResolveExecutor is the package function applied to this engine's current configuration and key lookup.

func (*Engine) RestoreWorkspace

func (e *Engine) RestoreWorkspace(ctx context.Context, changeSetID, manifestDigest string) error

RestoreWorkspace restores the canonical workspace from a persisted pre-image manifest digest, for a change set stuck mid-apply. Used by startup reconciliation to unwind an interrupted apply.

H3: RevertChangeSet refuses to restore a pre-image over an edit made to the workspace AFTER the mutation it is unwinding (fsdiff.StalePost) -- without the same guard here, a crash-recovery restore could silently overwrite whatever the user (or a later, successful operation) wrote to one of these same paths between the crash and the next daemon startup. changeSetID identifies the change set whose patch describes exactly the paths (and post-image digests) this restore would otherwise blindly overwrite.

func (*Engine) Resume

func (e *Engine) Resume(ctx context.Context, initiativeID string) (status domain.InitiativeStatus, err error)

Resume re-runs the review loop after a human has resolved decisions/findings in needs_human_judgment (§11).

The claim is what makes that comment true. Resume took no claim and checked no status, so it re-ran the review loop from any state and wrote the result over it: called on a `plan_approved` initiative it discarded the approved plan and left `approved`, silently undoing M2. Claiming from needs_human_judgment is both the guard and the exclusion -- runReviewLoop's terminal transition releases it.

func (*Engine) Retry

func (e *Engine) Retry(ctx context.Context, initiativeID string) (domain.InitiativeStatus, error)

Retry resumes a failed initiative's vertical slice after the last phase that actually completed, under the currently-set per-initiative model override (retry-with-a-different-model). Prior requirements and assertions are superseded immediately before product definition re-runs, so that re-run does not duplicate them; artifacts are immutable-versioned and decisions/questions are de-duplicated. The override is cleared when the run finishes.

It used to re-run framing→research→PRD unconditionally, "from scratch", every time (ICP walkthrough finding: a 503 mid-PRD-authoring, followed by `idea retry`, re-asked framing's clarifying questions and re-ran research that had already succeeded). Framing does not consult existing decisions/questions at all, so redoing it after the human had already answered some of them looked, from the outside, like their answers were discarded -- even though the rows survive (SupersedeRequirements/ SupersedeAssertions never touch decisions or questions, and runProductDefinition always feeds current decisions/questions back to the model). The real defect was doing the redundant work and re-asking at all. Resuming after the last completed phase, keyed off artifacts (a durable domain fact -- see the operation `stage` column's own doc comment for why that is NOT used here: it is a cosmetic progress hint, cleared on terminal status) fixes both: no wasted cost, and no re-asked framing questions.

func (*Engine) RevertBlockedReason added in v0.6.0

func (e *Engine) RevertBlockedReason(ctx context.Context, initiativeID, changeSetID string) (string, error)

RevertBlockedReason reports why RevertChangeSet would refuse to revert changeSetID right now, or "" when it would not. It mirrors RevertChangeSet's own stale-workspace guard read-only and lock-free (see RunBlockedReason), so Runtime can answer a synchronous 409 instead of starting an operation that can only fail in the background, and so a client can grey out "Revert" and say why before the click.

A race between this read and RevertChangeSet's own authoritative recheck (taken under the engine lock, immediately before any byte is restored) is still safe: a file edited in that narrow window is caught there instead, and nothing is written either way.

func (*Engine) RevertChangeSet

func (e *Engine) RevertChangeSet(ctx context.Context, initiativeID, changeSetID string) error

RevertChangeSet rolls back an applied change set: it restores the pre-image snapshot recorded at apply time (byte-for-byte), then advances applied→reverted plus a rolled_back journal entry atomically (§39, review B1).

func (*Engine) ReviewChangeSet

func (e *Engine) ReviewChangeSet(ctx context.Context, initiativeID, changeSetID, verdict string) error

ReviewChangeSet with acceptFindings=true is the human accept: it signs off the reviewer's open findings on this change set and approves, without running a fresh review.

That last clause is the whole point, and it is the third time this project has needed it. `idea approve` had to stop re-running the PRD review; `idea approve-plan` had to stop re-running the plan review; and this had to stop re-running the change-set review. A model reviewer is not a fixed point, so "disposition, then review again" is a retry, not an accept -- and here it was worse than a coin flip: the first attempt persists its findings, and every later attempt fails denyReviewOpenBlocking on them before the review even runs. The keyed magic path hit this every run and had no way out.

func (*Engine) ReviewChangeSetAccepting added in v0.4.0

func (e *Engine) ReviewChangeSetAccepting(ctx context.Context, initiativeID, changeSetID, verdict string) error

ReviewChangeSetAccepting is ReviewChangeSet with the human accept.

func (*Engine) ReviewChangeSetWithNote added in v0.7.0

func (e *Engine) ReviewChangeSetWithNote(ctx context.Context, initiativeID, changeSetID, verdict string, acceptFindings bool, note string) error

ReviewChangeSetWithNote is ReviewChangeSet carrying the human's note: what they want changed. It is recorded on the change set with a changes_requested or rejected verdict -- both reopen the task -- and the task's next Execute appends it to the implementer's brief (priorReviewNote). Any other verdict refuses a note rather than dropping it: there is no next run for it to steer.

func (*Engine) Revise

func (e *Engine) Revise(ctx context.Context, initiativeID string) (domain.InitiativeStatus, error)

Revise applies the human's decisions/answers by re-running product definition (with the resolved decisions + answered questions in context), then re-runs review. This is the "apply my judgment → updated PRD" loop (§8, §11).

func (*Engine) RevisePlan

func (e *Engine) RevisePlan(ctx context.Context, initiativeID string) (domain.InitiativeStatus, error)

RevisePlan regenerates the execution plan (and its review) in place after the human edited or rejected the prior plan. It deletes the prior tasks and their edges and disposes prior plan-review findings first, so no duplicate tasks or stale blocking findings survive the regeneration (full-platform review: plan revision must not leave orphans or wedge the verify gate).

func (*Engine) Run

func (e *Engine) Run(ctx context.Context, initiativeID, idea string) (domain.InitiativeStatus, error)

Run executes the full vertical slice for an initiative and returns the final initiative status.

func (*Engine) RunBlockedReason added in v0.5.0

func (e *Engine) RunBlockedReason(ctx context.Context, initiativeID string) (string, error)

RunBlockedReason reports why Execute would refuse to run right now for initiativeID, or "" when it would not (the Build contract's `run_blocked_reason`).

It mirrors Execute's own guards read-only and lock-free (see NextReadyTask) so the Build page can grey out "Run next task" and say why, instead of letting the click land on a 409/400 it has to parse. It does NOT check executor readiness (image/key) -- that lives in the daemon package, which alone knows about Docker and the project's .env; the caller composes both.

func (*Engine) RunUIURL added in v0.7.0

func (e *Engine) RunUIURL(ctx context.Context, runID string) string

RunUIURL is the run's "Open in OpenHands" link: its conversation in the configured OpenHands UI, or "" (not an openhands run, or no ui_url).

func (*Engine) SemanticDiff

func (e *Engine) SemanticDiff(ctx context.Context, initiativeID string) (*SemanticDiff, error)

SemanticDiff computes the structured diff for an initiative.

func (*Engine) SetDotEnv added in v0.5.0

func (e *Engine) SetDotEnv(dotEnv map[string]string)

SetDotEnv supplies the project's .env, which the daemon's model registry already falls back to for provider keys. The coding agent reads its key the same way; with only the process environment it launched keyless for anyone whose key lived in .env.

func (*Engine) SetMetricSandbox added in v0.7.0

func (e *Engine) SetMetricSandbox(fn MetricSandboxFunc)

SetMetricSandbox replaces the container sandbox command sources run in.

func (*Engine) SetModelOverride

func (e *Engine) SetModelOverride(initiativeID, spec string)

SetModelOverride forces every role to the given "provider/model" spec for the given initiative's next workflow run (retry-with-a-different-model). The engine clears it once that run finishes.

func (*Engine) SetNoteOverride added in v0.6.0

func (e *Engine) SetNoteOverride(initiativeID, note string)

SetNoteOverride records a human note to steer the given initiative's next Execute or Retry (D-a, wave 3 contract). Cleared once that run finishes.

func (*Engine) SetQualitySandbox added in v0.7.0

func (e *Engine) SetQualitySandbox(s QualitySandbox)

SetQualitySandbox replaces the Docker sandbox verify's quality dimensions run commands in (tests).

func (*Engine) SetRawBlobs

func (e *Engine) SetRawBlobs(b *blob.Store)

SetRawBlobs sets the redaction-free content store used by the diff/apply/revert path (review C1/C2). File content must round-trip byte-for-byte, so it is never redacted; the redacted `blobs` store is reserved for model artifacts.

func (*Engine) SetRedactor

func (e *Engine) SetRedactor(r *security.Redactor)

SetRedactor sets the redactor applied at the DISPLAY/model surface (the adversarial review context and the diff endpoint), so raw file content never reaches a network-egress model unredacted (review SRE regression).

func (*Engine) SetWorkRoot

func (e *Engine) SetWorkRoot(dir string)

SetWorkRoot sets the directory that Execute derives per-initiative isolated work roots from. The daemon points this at its per-project state directory so the executor's WorkRoot mirrors "<state-root>/work/<initiative>".

func (*Engine) SetWorkspaceRoot

func (e *Engine) SetWorkspaceRoot(dir string)

SetWorkspaceRoot sets the canonical workspace that ApplyChangeSet writes into and RevertChangeSet restores. The daemon points this at the project root.

func (*Engine) SteerRun added in v0.7.0

func (e *Engine) SteerRun(ctx context.Context, initiativeID, runID, note string, interrupt bool) (SteerResult, error)

SteerRun sends a human's note to the initiative's running agent run. runID, when set, must name that run (a stale UI must not steer a newer run it never saw). How the note travels depends on the executor:

  • an executor.Steerer (acp, openhands): Steer -- delivered or queued as the agent's next turn;
  • any other executor (internal, container, hermes, omp): the agent cannot be reached mid-run, so the note is held and appended to the task's next run's brief -- next_run.

Every note is recorded as a message event (source user) on the run, and on the run manifest's executor provenance.

func (*Engine) StructuredDiff

func (e *Engine) StructuredDiff(cs *domain.ChangeSet) []StructuredFile

StructuredDiff renders a change set as a per-file list (path + kind + redacted content). Deleted files carry no content. A change set rejected by the secret sweep never had its raw bytes persisted (persistDiff is skipped), but carries a MASKED version instead (RedactedDigest, persistRedactedDiff) -- that is served here with Redacted=true rather than leaving Content empty, so the human can see what was blocked. Content is genuinely absent (Size 0, Redacted false) only when neither the raw nor the masked bytes could be found -- e.g. a patch persisted before this fix, or a masking failure. A patch-manifest read/decode failure yields an empty (non-nil) list so the `files` wire field is always a JSON array; the read error is surfaced via RenderPatch's "(patch unreadable: …)" in the sibling `patch` field.

func (*Engine) StructuredDiffPage added in v0.6.0

func (e *Engine) StructuredDiffPage(cs *domain.ChangeSet) (files []StructuredFile, total int)

StructuredDiffPage is StructuredDiff bounded to at most maxDiffEndpointFiles files, returning the change set's true total file count alongside the (possibly truncated) list so a caller can report "showing 500 of 14300".

func (*Engine) SuggestAnswers

func (e *Engine) SuggestAnswers(ctx context.Context, initiativeID string, emit func([]domain.SuggestedAnswer)) error

SuggestAnswers asks the product manager to propose a concise answer for every open question, grounded in the project's intent and purpose. Questions are answered in bounded chunks, and each chunk's answers are emitted via `emit` as they complete (so callers can persist progress incrementally).

func (*Engine) VerifyInitiative

func (e *Engine) VerifyInitiative(ctx context.Context, initiativeID string) error

VerifyInitiative computes coverage across all approved requirements, marks a requirement verified when every mandatory criterion has a pass evidence, and completes the initiative when every requirement is verified and there are no open blocking findings (§70, review B4). It is idempotent and deterministic.

review H7: takes mu, the same mutex Execute/ApplyChangeSet/RevertChangeSet hold for their whole duration, so this cannot run concurrently with any of them actually mutating files or the task/change-set graph. Before this, verify ran with no synchronization of its own; store.CompleteInitiative's CAS only excludes `failed`, not `running` (deliberately -- the documented apply-then-verify sequence verifies while the row still reads `running` after apply's own operation goroutine has not yet released its claim, and that must keep working), so nothing stopped this from reaching CompleteInitiative WHILE one of those three was still actively writing. Proven: an apply mid-file-write let a concurrent verify complete the initiative, after which a third request (revise) claimed `running` FROM the `complete` verify had just manufactured and started superseding requirements while apply's files were still landing -- two pipelines on one initiative. Taking mu here makes verify wait for the real work to finish (mu already excludes the other three from each other and from itself); it does not need to wait for `running` to clear back to a resting status, which is a separate, much narrower race ReleaseInitiativeClaim's own CAS closes.

func (*Engine) Why

func (e *Engine) Why(ctx context.Context, initiativeID, nodeType, nodeID string) ([]TraceItem, error)

Why returns the provenance chain for a node: it follows outgoing edges (implements / derived_from / produced_by / depends_on) from the node to its sources, bounded.

invalidates is the exception both ways. An assertion's outgoing invalidates edge is not provenance and is not followed; a node's incoming one is listed (A --invalidates--> node, not walked further), so the chain for a requirement resting on a retracted assertion says the basis was refuted.

type ErrReviewUnavailable added in v0.6.0

type ErrReviewUnavailable struct {
	// RunID is the (failed) run that made the final, exhausted attempt --
	// attributable for `idea logs` / cost accounting even though it never
	// produced findings.
	RunID string
	// Cause is the underlying error from runModel (wrapping model.ErrTruncated).
	Cause error
}

ErrReviewUnavailable is returned by runChangeSetAdversarialReview when the adversarial reviewer was genuinely ATTEMPTED for a change set but could not complete: every attempt (including runModel's own reduced-ask retry on model.ErrTruncated) was cut off at the model's output-token ceiling.

This is the "no wedge" half of the change-set review truncation defect. An ordinary error here used to propagate straight out of Execute/ RerunChangeSetReview: the change set was left in review_required with ReviewCompletedAt nil and no record of WHY, indistinguishable from a cancelled operation, and the task was never marked done -- so `idea execute` kept re-offering it, hit the same "never finished its adversarial review" guard every time, and the ONLY documented escape, --accept-findings, refused too (it requires ReviewCompleted()). A caller that receives this instead calls store.SetChangeSetReviewUnavailable, which records the cause explicitly (never silently) and lets that one, narrowly-scoped escape apply -- see domain.ChangeSet.ReviewUnavailable.

func (*ErrReviewUnavailable) Error added in v0.6.0

func (e *ErrReviewUnavailable) Error() string

func (*ErrReviewUnavailable) Unwrap added in v0.6.0

func (e *ErrReviewUnavailable) Unwrap() error

type ExecutorResolution added in v0.7.0

type ExecutorResolution struct {
	// Requested is harness.yaml's executor.kind ("auto" when unset).
	Requested string `json:"requested"`
	// Resolved is the kind that runs.
	Resolved string `json:"resolved"`
	// Image is the agent image for an agent kind.
	Image string `json:"image,omitempty"`
	// Server is the Agent Server URL for kind openhands: where the work root
	// goes.
	Server string `json:"server,omitempty"`
	// Warning is the loud one: auto fell back to the placeholder executor.
	// It says why, and how to fix it.
	Warning string `json:"warning,omitempty"`
	// Note is the quiet one: executor.kind is explicitly internal, which is a
	// legitimate demo setup, so it is mentioned rather than shouted.
	Note string `json:"note,omitempty"`
}

ExecutorResolution is which executor a run uses, and why.

An unset executor.kind is "auto": hermes on its pinned image when Docker is reachable and the coding model's provider key is set, internal otherwise. Internal writes a placeholder file, not code, so falling back to it is never silent: Warning is set, and every surface that starts or inspects a run -- `idea execute`, the run manifest, `idea doctor`, the Build page's guidance -- shows it. Before auto existed an unset kind simply meant internal, and a user who never found docs/agents.md got placeholder change sets with nothing saying a real agent had never been tried.

func ResolveExecutor added in v0.7.0

func ResolveExecutor(ctx context.Context, h config.HarnessConfig, registry *model.Registry, lookupKey func(string) string) ExecutorResolution

ResolveExecutor decides which executor a run with this configuration uses. lookupKey reads a provider key the way the run will (the daemon's environment, then the project's .env).

func (ExecutorResolution) Placeholder added in v0.7.0

func (r ExecutorResolution) Placeholder() bool

Placeholder reports whether this run writes a placeholder, not code.

type ImpactItem

type ImpactItem struct {
	TraceItem
	Staleness string `json:"staleness"`
}

ImpactItem is a TraceItem with a staleness classification.

type LiveRunInfo added in v0.7.0

type LiveRunInfo struct {
	RunID    string `json:"run_id"`
	Executor string `json:"executor,omitempty"`
	// Steerable reports whether a note reaches the running agent itself;
	// false means it is held for the task's next run.
	Steerable bool `json:"steerable"`
}

LiveRunInfo describes an initiative's running agent run for clients.

type MeasureResult added in v0.7.0

type MeasureResult struct {
	MetricID    string                    `json:"metric_id"`
	MetricCode  string                    `json:"metric_code"`
	Observation *domain.MetricObservation `json:"observation,omitempty"`
	Status      *domain.MetricStatus      `json:"status,omitempty"`
	Skipped     string                    `json:"skipped,omitempty"`
	Error       string                    `json:"error,omitempty"`
}

MeasureResult is one metric's measurement outcome. Exactly one of Observation, Skipped and Error is set.

type MetricSandboxFunc added in v0.7.0

type MetricSandboxFunc func(ctx context.Context, opts executor.RunOptions) (stdout, stderr string, exitCode int, err error)

MetricSandboxFunc runs a command source in place of the container sandbox. It exists for tests outside this package -- the daemon's scheduled-measurement tests -- which have no Docker.

func (MetricSandboxFunc) Run added in v0.7.0

Run implements the measurement sandbox.

type NextTask added in v0.5.0

type NextTask struct {
	ID      string `json:"id"`
	HumanID string `json:"human_id"`
	Title   string `json:"title"`
}

NextTask is the task Execute would run next, projected for an API response without exposing the full domain.Task shape (the Build contract's `next_task`).

type NodeRef

type NodeRef struct {
	Type string `json:"type"`
	ID   string `json:"id"`
}

NodeRef addresses a graph node by type + id.

type PartialWorkInfo added in v0.5.1

type PartialWorkInfo struct {
	TaskID string `json:"task_id"`
	Files  int    `json:"files"`
	// Note is set when the stopped run's files were not kept, and why.
	Note string `json:"note,omitempty"`
}

PartialWorkInfo describes a kept partial for clients.

type QualityDimensionView added in v0.7.0

type QualityDimensionView struct {
	Dimension domain.QualityDimension `json:"dimension"`
	Mode      domain.QualityMode      `json:"mode"`
	Result    *domain.QualityResult   `json:"result"`
	Stale     bool                    `json:"stale"`
}

QualityDimensionView is one row of the scorecard: the dimension, its mode under the current policy, its latest result (nil when it was never measured), and whether that result is stale -- measured against different applied work or a different policy than the initiative has now.

type QualitySandbox added in v0.7.0

type QualitySandbox interface {
	Available(ctx context.Context) bool
	Run(ctx context.Context, image string, opts executor.RunOptions) (output string, exitCode int, err error)
}

QualitySandbox runs one command for a quality dimension in an isolated container. The real implementation is executor.ContainerSandbox; tests script it. Available reports whether it can run anything at all -- a dimension that needs it and finds it unavailable reports not_measured.

type QualityScorecard added in v0.7.0

type QualityScorecard struct {
	// Rigor is the effective review rigor the default modes came from.
	Rigor string `json:"rigor"`
	// Overridden lists the dimensions verify.dimensions set explicitly.
	Overridden []domain.QualityDimension `json:"overridden"`
	Dimensions []QualityDimensionView    `json:"dimensions"`
	// InputDigest is what a fresh measurement would be recorded against now.
	InputDigest string `json:"input_digest"`
	// NeedsMeasurement is true when any enabled dimension has no result for
	// the current input digest -- what `idea verify` checks before deciding
	// to measure.
	NeedsMeasurement bool `json:"needs_measurement"`
	// GateUnmet names every gated dimension that does not satisfy the gate
	// (failed, not measured, or stale). Empty means the quality half of the
	// verification gate is met; advisory dimensions never appear here.
	GateUnmet []string `json:"gate_unmet"`
}

QualityScorecard is verify's quality-dimension scorecard for an initiative.

type RigorLevel added in v0.6.0

type RigorLevel string

RigorLevel is review.rigor's calibrated value once "auto" is resolved (review B1). Only critical/high findings ever block approval (§11, Severity.Blocking); rigor governs how MUCH review a change gets, not whether a system-deny check (secret sweep, host exec, blob digest mismatch) can be skipped -- those are absolute and never rigor-gated.

const (
	RigorAuto     RigorLevel = "auto"
	RigorQuick    RigorLevel = "quick"
	RigorStandard RigorLevel = "standard"
	RigorThorough RigorLevel = "thorough"
)

func (RigorLevel) Valid added in v0.6.0

func (r RigorLevel) Valid() bool

Valid reports whether r is one of the four configured values (§B1). Auto is a valid CONFIGURED value (it is what calibrateRigor resolves away), but is never itself an "effective" level a reviewer runs at.

type RunReport added in v0.7.0

type RunReport struct {
	GeneratedAt time.Time             `json:"generated_at"`
	Run         RunReportRun          `json:"run"`
	Manifest    *domain.RunManifest   `json:"manifest,omitempty"`
	ChangeSet   *RunReportChangeSet   `json:"change_set,omitempty"`
	Files       []RunReportFile       `json:"files"`
	Findings    []RunReportFinding    `json:"findings"`
	Cost        domain.RunUsage       `json:"cost"`
	Steering    []domain.SteeringNote `json:"steering"`
	Events      []domain.RunEvent     `json:"events"`
	// EventsDropped is how many of the run's earliest events the per-run cap
	// removed (store.RunEventsPerRunMax).
	EventsDropped int64 `json:"events_dropped,omitempty"`
	// OpenHandsURL links the run's conversation in an OpenHands UI, when one
	// is configured (executor.openhands.ui_url).
	OpenHandsURL string `json:"openhands_url,omitempty"`
}

RunReport is one agent run, written down: what ran, what it did (its events), what it changed (the file list with line counts), what review found, and what it cost. GET .../runs/{runId}/report serves it as JSON, Markdown, or both in a zip. Everything in it is already redacted: events on the way in, findings at creation.

func (RunReport) Markdown added in v0.7.0

func (r RunReport) Markdown() string

Markdown renders the report for a person: summary, files, findings, steering, then the event log. Event text is already redacted; it is rendered inside code spans/blocks so an agent's message cannot inject Markdown structure (links, headings) into the report.

type RunReportChangeSet added in v0.7.0

type RunReportChangeSet struct {
	ID      string `json:"id"`
	HumanID string `json:"human_id"`
	Status  string `json:"status"`
	NoOp    bool   `json:"no_op,omitempty"`
}

RunReportChangeSet is the change set the run produced.

type RunReportFile added in v0.7.0

type RunReportFile struct {
	Path    string `json:"path"`
	Change  string `json:"change,omitempty"`
	Added   int    `json:"added"`
	Removed int    `json:"removed"`
}

RunReportFile is one file the run changed, with line counts when known.

type RunReportFinding added in v0.7.0

type RunReportFinding struct {
	Severity    string `json:"severity"`
	Category    string `json:"category"`
	Finding     string `json:"finding"`
	Disposition string `json:"disposition,omitempty"`
}

RunReportFinding is one finding on the run's change set.

type RunReportRun added in v0.7.0

type RunReportRun struct {
	ID           string     `json:"id"`
	Status       string     `json:"status"`
	InitiativeID string     `json:"initiative_id,omitempty"`
	TaskID       string     `json:"task_id,omitempty"`
	TaskCode     string     `json:"task_code,omitempty"`
	TaskTitle    string     `json:"task_title,omitempty"`
	Executor     string     `json:"executor,omitempty"`
	Note         string     `json:"note,omitempty"`
	StartedAt    time.Time  `json:"started_at"`
	FinishedAt   *time.Time `json:"finished_at,omitempty"`
}

RunReportRun is the run itself.

type SemanticDiff

type SemanticDiff struct {
	Requirements struct {
		Added   []DiffRequirement `json:"added"`
		Removed []DiffRequirement `json:"removed"`
	} `json:"requirements"`
	Decisions struct {
		Open       []DiffDecision `json:"open"`
		Decided    []DiffDecision `json:"decided"`
		Superseded []DiffDecision `json:"superseded"`
	} `json:"decisions"`
}

SemanticDiff reports structured requirement/decision changes (added vs removed; open vs decided vs superseded) rather than raw markdown (§25).

type SteerResult added in v0.7.0

type SteerResult struct {
	RunID    string `json:"run_id"`
	Executor string `json:"executor,omitempty"`
	// Delivery is delivered | queued | next_run (domain.Steering*).
	Delivery string `json:"delivery"`
	// Message is a sentence for the person who sent it.
	Message string `json:"message"`
}

SteerResult is what became of a steering note.

type StructuredFile

type StructuredFile struct {
	Path       string `json:"path"`
	ChangeType string `json:"change_type"`
	Size       int    `json:"size"`
	Content    string `json:"content"`
	// Patch is a unified diff of the file against its base (B6): an added file
	// is all '+', a deleted file is all '-', a modified file is base vs new.
	// Omitted when there is nothing to diff (both sides empty). This is what
	// lets the diff view render a change instead of a full-file dump for a
	// whole-file rewrite of an existing file.
	Patch string `json:"patch,omitempty"`
	// PatchNote says why Patch is empty when there was a change to show: the
	// file is binary, too large to diff, its content was never kept, or its
	// base can no longer be recovered. The UI shows it and falls back to
	// Content.
	PatchNote string `json:"patch_note,omitempty"`
	// Redacted is true when Content holds MASKED content instead of the file's
	// real post-image bytes, because the secret sweep denied this change set
	// and the raw bytes were never persisted -- only their masked form was.
	// The UI shows a distinct, honest note instead of treating this like an
	// ordinary (or missing) diff. Review: secret-sweep diff visibility.
	Redacted bool `json:"redacted,omitempty"`
	// contains filtered or unexported fields
}

StructuredFile is one file of a change set for per-file display: its path, add/modify/delete kind, byte size, and REDACTED content. Content is redacted at this display surface exactly like RenderPatch, so raw bytes never reach a network-egress model (review SRE regression); the raw store stays redaction-free for byte-for-byte apply/revert. The post-image digest is deliberately NOT exposed here — a digest is not needed for display and would be pure hash-confirmation surface.

type SystemDenyError added in v0.7.0

type SystemDenyError struct {
	Code   domain.DenyCode
	Detail string
}

SystemDenyError is a fail-closed refusal that carries its machine-readable DenyCode, for the denies that stop an action before there is a change set (or a finding) to attach the code to. Callers that want the code use errors.As; the message names it as "system deny <code>" like every other deny error in this package.

func (*SystemDenyError) Error added in v0.7.0

func (e *SystemDenyError) Error() string

type TraceItem

type TraceItem struct {
	EdgeType  string `json:"edge_type"`
	FromType  string `json:"from_type"`
	FromID    string `json:"from_id"`
	FromLabel string `json:"from_label,omitempty"`
	ToType    string `json:"to_type"`
	ToID      string `json:"to_id"`
	ToLabel   string `json:"to_label,omitempty"`
}

TraceItem is one graph edge with resolved endpoint labels.

Jump to

Keyboard shortcuts

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