domain

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: 7 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 domain defines the typed entities and controlled vocabularies of the idea-harness product graph (Milestone 1 subset). It contains no I/O and no LLM logic: it is the single source of truth for enums and invariants that other packages enforce.

Index

Constants

View Source
const (
	RunEventSourceAgent   = "agent"
	RunEventSourceHarness = "harness"
	RunEventSourceUser    = "user"
)

Event sources.

View Source
const (
	RunEventTitleMax  = 240
	RunEventDetailMax = 4096
	RunEventPathMax   = 1024
)

Bounds on one stored event's text. The run view is a live summary, not an archive of the agent's transcript: a 2 MB file write or a pasted log would otherwise land in the database and in every client's memory.

View Source
const (
	SteeringDelivered = "delivered"
	SteeringQueued    = "queued"
	SteeringNextRun   = "next_run"
)

Steering note deliveries.

View Source
const SignalWorksButFailsObjective = "works_but_fails_objective"

SignalWorksButFailsObjective is RequirementOutcomeDrift.Signal's one value.

Variables

GapKinds is every kind in report order: the order human output groups them in, and the order --kind's error lists them in.

QualityDimensions is every dimension, in scorecard order. The order is the order a reader meets them in -- "does it build from a clean checkout" first, the judgment calls last -- not alphabetical.

Functions

func CriterionKey

func CriterionKey(requirementID string, i int) string

CriterionKey returns the stable key for the i-th acceptance criterion of a requirement. The thin slice treats every criterion as mandatory and keys evidence by requirement + index (§70, review B4).

func FormatMetricValue added in v0.7.0

func FormatMetricValue(v float64) string

FormatMetricValue is fmtNum for callers outside the package (CLI, guidance).

func GenerateShortTitle added in v0.6.0

func GenerateShortTitle(idea string) string

GenerateShortTitle deterministically derives a short, human title (<=60 characters) from an idea's full text (C1, wave 3 contract): the first sentence or clause, with a common lead-in phrase dropped, trimmed at a word boundary. Title/Description keep the full text; this is only ever a display label. Same input always produces the same output, so it can be generated once on create and backfilled identically for older initiatives.

func NewerChangeSetInScanOrder added in v0.6.0

func NewerChangeSetInScanOrder(cs, cur ChangeSet) bool

NewerChangeSetInScanOrder reports whether cs should replace cur as "the latest" when a caller reduces a slice of change sets to one per key (per task, or across an initiative) by scanning it in ascending CreatedAt order -- store.ListChangeSets' own order, with no secondary sort key.

MEDIUM fix: two change sets created in the same millisecond tie on CreatedAt alone, and this codebase had two different answers for who wins that tie -- evidence eligibility and /queue used "not before" (the later one in scan order, i.e. the actual later attempt, wins), while /guidance's LatestChangeSetsPerActiveTask and PR's mostRecentGitCommitWarning used strict "after" (the FIRST one scanned wins instead). Two change sets a millisecond apart could make /queue and /guidance name different "latest" change sets for the same task. Every such reducer must call this one function instead of comparing CreatedAt itself, so they can never disagree again.

func ParseCadence added in v0.7.0

func ParseCadence(s string) (time.Duration, error)

ParseCadence turns a cadence into a duration. "" is 0 (no expectation).

func SeverityRank added in v0.7.0

func SeverityRank(s Severity) int

SeverityRank orders severities most severe first (critical = 0). An unknown severity ranks last.

func TrimToWordBoundary added in v0.6.0

func TrimToWordBoundary(s string, n int) string

TrimToWordBoundary trims s to at most n runes without splitting a word, falling back to a hard cut only when no earlier space exists. Exported (review LOW #11) so it is the one place this algorithm lives: projection's truncateWords used to carry an independent, near-identical copy that had already drifted on when it measures length (before vs. after trimming surrounding whitespace) before either callers noticed -- two implementations of the same word-boundary cut, each free to diverge further the next time one of them was touched.

Types

type ACPPermission added in v0.7.0

type ACPPermission struct {
	ToolCallID string    `json:"tool_call_id,omitempty"`
	Title      string    `json:"title,omitempty"`
	ToolKind   string    `json:"tool_kind,omitempty"`
	OptionID   string    `json:"option_id,omitempty"`
	Decision   string    `json:"decision"` // allow_once|allow_always|reject_once|reject_always|cancelled
	At         time.Time `json:"at"`
}

ACPPermission is one permission request an ACP agent made and its answer.

type AcceptanceCriterion

type AcceptanceCriterion struct {
	Metric    string `json:"metric"`
	Target    string `json:"target"`
	Condition string `json:"condition"`
}

AcceptanceCriterion is a structurally verifiable acceptance criterion: a measurable predicate with a metric, a target, and a condition (§11, §18).

func (AcceptanceCriterion) Verifiable

func (c AcceptanceCriterion) Verifiable() bool

Verifiable reports whether the criterion has a quantified target, not a bare evaluative adjective. This is the deterministic structural check (§11).

type AgentCost added in v0.6.0

type AgentCost struct {
	Runs    int      `json:"runs"`
	Seconds float64  `json:"seconds"`
	USD     *float64 `json:"usd"`
	Note    string   `json:"note,omitempty"`
}

AgentCost is the coding-agent run summary (C3, wave 3 contract). USD is nil ("agent spend not measured") unless every counted run's cost could be parsed from the agent's own output.

type ApplyJournalEntry

type ApplyJournalEntry struct {
	ID                      string     `json:"id"`
	ChangeSetID             string     `json:"change_set_id"`
	State                   ApplyState `json:"state"`
	WorkspaceSnapshotDigest string     `json:"workspace_snapshot_digest,omitempty"`
	AppliedAt               *time.Time `json:"applied_at,omitempty"`
	CreatedAt               time.Time  `json:"created_at"`
}

ApplyJournalEntry is one durable apply-journal record (§39).

type ApplyState

type ApplyState string

ApplyState is the durable apply-journal state (§39).

const (
	ApplyPrepared         ApplyState = "prepared"
	ApplyWorkspaceMutated ApplyState = "workspace_mutated"
	ApplyCommitted        ApplyState = "committed"
	ApplyRolledBack       ApplyState = "rolled_back"
	ApplyRecoveryRequired ApplyState = "recovery_required"
)

func (ApplyState) Valid

func (s ApplyState) Valid() bool

type Artifact

type Artifact struct {
	ID           string       `json:"id"`
	InitiativeID string       `json:"initiative_id"`
	Kind         ArtifactKind `json:"kind"`
	CreatedAt    time.Time    `json:"created_at"`
}

Artifact is an immutable-versioned artifact family (§20).

type ArtifactKind

type ArtifactKind string

ArtifactKind enumerates the core artifacts (§20).

const (
	ArtifactIdeaBrief            ArtifactKind = "idea_brief"
	ArtifactResearchBrief        ArtifactKind = "research_brief"
	ArtifactPRD                  ArtifactKind = "prd"
	ArtifactTechnicalDesign      ArtifactKind = "technical_design"
	ArtifactDesignSpec           ArtifactKind = "design_spec"
	ArtifactVerificationPlan     ArtifactKind = "verification_plan"
	ArtifactThreatModel          ArtifactKind = "threat_model"
	ArtifactExecutionPlan        ArtifactKind = "execution_plan"
	ArtifactOperationalReadiness ArtifactKind = "operational_readiness"
	ArtifactVerificationReport   ArtifactKind = "verification_report"
)

func (ArtifactKind) Valid

func (k ArtifactKind) Valid() bool

type ArtifactVersion

type ArtifactVersion struct {
	ID            string    `json:"id"`
	ArtifactID    string    `json:"artifact_id"`
	Version       int       `json:"version"`
	Status        string    `json:"status"`
	BodyDigest    string    `json:"body_digest"`
	ProducedByRun string    `json:"produced_by_run,omitempty"`
	SupersededBy  string    `json:"superseded_by,omitempty"`
	CreatedAt     time.Time `json:"created_at"`
}

ArtifactVersion is one immutable version of an Artifact.

type Assertion

type Assertion struct {
	ID             string          `json:"id"`
	InitiativeID   string          `json:"initiative_id"`
	Code           string          `json:"code"`
	Type           AssertionType   `json:"type"`
	Status         AssertionStatus `json:"status"`
	Statement      string          `json:"statement"`
	EvidenceDigest string          `json:"evidence_digest,omitempty"`
	Confidence     Confidence      `json:"confidence"`
	Source         string          `json:"source"`
	Provenance     []ProvenanceRef `json:"provenance"`
	ProducedByRun  string          `json:"produced_by_run,omitempty"`
	SupersededBy   string          `json:"superseded_by,omitempty"`
	CreatedAt      time.Time       `json:"created_at"`
}

Assertion is a structured Fact/Assumption/Hypothesis (§18). Code is its initiative-scoped human code (ASM-n): what a PRD cites in a requirement's or decision's based_on, and what `idea assumption` accepts.

type AssertionStatus

type AssertionStatus string

AssertionStatus is the lifecycle state of an Assertion (§18).

const (
	AssertionCandidate  AssertionStatus = "candidate"
	AssertionAccepted   AssertionStatus = "accepted"
	AssertionDisputed   AssertionStatus = "disputed"
	AssertionRetracted  AssertionStatus = "retracted"
	AssertionSuperseded AssertionStatus = "superseded"
)

func (AssertionStatus) Valid

func (s AssertionStatus) Valid() bool

type AssertionType

type AssertionType string

AssertionType discriminates Facts from Assumptions from Hypotheses (constitution §18).

const (
	AssertionFact       AssertionType = "fact"
	AssertionAssumption AssertionType = "assumption"
	AssertionHypothesis AssertionType = "hypothesis"
)

func (AssertionType) Valid

func (t AssertionType) Valid() bool

type ChangeSet

type ChangeSet struct {
	ID             string          `json:"id"`
	HumanID        string          `json:"human_id"`
	InitiativeID   string          `json:"initiative_id"`
	TaskID         string          `json:"task_id"`
	BaseSnapshotID string          `json:"base_snapshot_id,omitempty"`
	Status         ChangeSetStatus `json:"status"`
	PatchDigest    string          `json:"patch_digest"`
	ReviewID       string          `json:"review_id,omitempty"`
	GitCommitSHA   string          `json:"git_commit_sha,omitempty"`
	// GitCommitWarning explains why an applied change set was NOT committed
	// even though git_commit is on: a detached HEAD, a rebase/merge/
	// cherry-pick in progress, or the repository's default branch without
	// git.allow_default_branch (review C4, adopted #2). Empty whenever
	// git_commit is off, the change set was committed (GitCommitSHA is set),
	// or the workspace is not a git repository.
	GitCommitWarning string `json:"git_commit_warning,omitempty"`
	CreatedByRunID   string `json:"created_by_run_id,omitempty"`
	// Model is the actual model spec that produced this change set (e.g.
	// "openai/gpt-5"), or "demo" when no real provider was configured. The UI
	// keys model=="demo" to label the change "Shipped (demo)" / "Placeholder
	// change" rather than real agent output.
	Model string `json:"model,omitempty"`
	// Executor is the executor kind that produced the change set ("internal"
	// output is a placeholder whatever the model).
	Executor string `json:"executor,omitempty"`
	// AgentOutput is the end of the coding agent's own output for the run
	// that produced this change set: redacted, sanitized, at most 100 lines.
	AgentOutput string    `json:"agent_output,omitempty"`
	CreatedAt   time.Time `json:"created_at"`
	// NoOp is true when the change set touched zero files (fsdiff.Diff found
	// nothing to persist) — the agent decided the task was already done, or
	// its model call failed and it wrote nothing (ICP re-run defect #2). An
	// applied NoOp change set must never count as "this task is implemented"
	// anywhere: task completion, evidence eligibility, staleness propagation,
	// or the "every task has an applied change set" guidance — see
	// ImplementsTask. It can still be approved/applied/reverted like any
	// other change set; only what it is COUNTED as changes.
	NoOp bool `json:"no_op,omitempty"`
	// ReviewCompletedAt is set the one time the adversarial reviewer actually
	// finishes for this change set (store.SetChangeSetReview), never merely
	// attempted (ICP re-run defect #1). A change set can reach
	// review_required with this nil when Execute's call to the reviewer
	// itself errored (e.g. the operation was cancelled mid-review) after the
	// checks-running -> review_required transition already happened: it then
	// carries only mechanical-check observations, no adversarial findings,
	// and reviewChangeSet's "approved" verdict must refuse it rather than
	// let it through as if a real review had converged.
	ReviewCompletedAt *time.Time `json:"review_completed_at,omitempty"`
	// PredatesReviewTracking is true when cs was created before migration 33
	// added review_completed_at at all (review MEDIUM #2: its store, not the
	// wire, is the source of truth -- computed by comparing CreatedAt against
	// that migration's own applied_at, per store.applyPredatesReviewTracking).
	// It is only meaningful when ReviewCompletedAt is nil, and it exists
	// purely to keep the four "never finished its adversarial review"
	// messages (Execute's re-pick refusal, the approve refusal, guidance, and
	// applyStateMessage) from calling a pre-upgrade row "cancelled": before
	// the upgrade, a change set's review ran (or was skipped) at approve
	// time and nothing ever recorded whether it "completed" -- NULL is the
	// expected, permanent state for that row, not evidence of a cancellation.
	// Never serialized: it is a message-selection detail, not API surface.
	PredatesReviewTracking bool `json:"-"`
	// ReviewUnavailableReason records why the adversarial reviewer was
	// genuinely ATTEMPTED for cs but could not complete -- e.g. every
	// attempt (including runModel's own reduced-ask retry) was cut off at
	// the model's output-token ceiling (model.ErrTruncated) on a change set
	// too large for it. Set once, by store.SetChangeSetReviewUnavailable,
	// from Execute's own review call or RerunChangeSetReview -- never
	// guessed. Empty means either the review completed (ReviewCompleted()
	// is true) or it was never attempted at all (see
	// ReviewNeverCompletedCause, which falls back to "likely cancelled
	// mid-review" in that case). See ReviewUnavailable.
	ReviewUnavailableReason string `json:"review_unavailable_reason,omitempty"`
	// ReviewNote is what the human asked for when they requested changes on,
	// or rejected, this change set (`idea review <id> changes_requested
	// --note`, POST .../review {"note"}). The task's next run carries it in the
	// implementer's brief, so "request changes" says what to change. Empty for
	// a verdict given without one.
	ReviewNote string `json:"review_note,omitempty"`
}

ChangeSet is the source mutation primitive (§36).

func (ChangeSet) ImplementsTask added in v0.6.0

func (cs ChangeSet) ImplementsTask() bool

ImplementsTask reports whether this change set is applied AND actually changed something. An applied change set with zero file changes (NoOp) must never count as "the task is implemented" (ICP re-run defect #2): not for task completion, not for verification-evidence eligibility, not for staleness propagation, and not for "every task has an applied change set" guidance.

func (ChangeSet) ReviewCompleted added in v0.6.0

func (cs ChangeSet) ReviewCompleted() bool

ReviewCompleted reports whether the adversarial reviewer actually finished for this change set at least once (ICP re-run defect #1). False for a change set still in review_required after Execute's own review call errored (e.g. cancelled mid-review) — it holds only mechanical-check observations, never a real adversarial pass.

func (ChangeSet) ReviewNeverCompletedCause added in v0.6.0

func (cs ChangeSet) ReviewNeverCompletedCause() string

ReviewNeverCompletedCause names, in a short clause meant to be embedded in a sentence, why cs has no completed adversarial review (ICP re-run defect #1) -- the shared wording for every surface that explains this to a human: workflow.Execute's re-pick refusal, reviewChangeSet's approve refusal, projection.BuildGuidance, and daemon.applyStateMessage (review MEDIUM #2). Only meaningful when !cs.ReviewCompleted().

func (ChangeSet) ReviewUnavailable added in v0.6.0

func (cs ChangeSet) ReviewUnavailable() bool

ReviewUnavailable reports whether the adversarial reviewer was genuinely ATTEMPTED for cs but explicitly could not complete (as opposed to never having run at all -- ordinary cancellation, or predating review tracking). Only meaningful when !cs.ReviewCompleted().

This is the one case reviewChangeSet's "approved" verdict may let through with --accept-findings even though ReviewCompleted() is false: the human asked for a review, one genuinely ran, and it explicitly could not finish (recorded by store.SetChangeSetReviewUnavailable, never guessed) -- as opposed to a change set that was simply cancelled mid-review and has no review attempt to point to at all, which must still refuse either way (the round-4 guarantee: an unreviewed change set cannot be silently approved).

type ChangeSetStatus

type ChangeSetStatus string

ChangeSetStatus is the lifecycle of a ChangeSet (§38).

const (
	ChangeSetDraft            ChangeSetStatus = "draft"
	ChangeSetChecksRunning    ChangeSetStatus = "checks_running"
	ChangeSetReviewRequired   ChangeSetStatus = "review_required"
	ChangeSetRejected         ChangeSetStatus = "rejected"
	ChangeSetChangesRequested ChangeSetStatus = "changes_requested"
	ChangeSetSuperseded       ChangeSetStatus = "superseded"
	ChangeSetApproved         ChangeSetStatus = "approved"
	ChangeSetApplying         ChangeSetStatus = "applying"
	ChangeSetApplied          ChangeSetStatus = "applied"
	ChangeSetReverted         ChangeSetStatus = "reverted"
	ChangeSetConflicted       ChangeSetStatus = "conflicted"
)

func (ChangeSetStatus) HoldsWork added in v0.4.0

func (s ChangeSetStatus) HoldsWork() bool

HoldsWork reports whether a change set in this state is work a plan-level command must not disturb.

`rejected` and `superseded` are absorbing states minted on ordinary paths -- every credential-sweep reject leaves one behind and reopens the task, and a re-execution supersedes its predecessor -- so a plan carrying only those has no work in flight and is legitimately revisable. Counting them made `revise-plan`, `approve-plan` and `reopen-phase` refuse forever, and the refusal named `idea review` and `idea apply`, both of which are closed for a rejected change set.

This is the same distinction that got audit 5's A2 rejected: it proposed gating completion on `{applied, reverted}` and review pointed out that the absorbing states are minted on ordinary paths, so the predicate would wedge any initiative that ever tripped the sweep. Here it is stated once and read by every site rather than re-derived at each.

func (ChangeSetStatus) Valid

func (s ChangeSetStatus) Valid() bool

type Confidence

type Confidence string

Confidence is the review-finding confidence (§15).

const (
	ConfidenceHigh   Confidence = "high"
	ConfidenceMedium Confidence = "medium"
	ConfidenceLow    Confidence = "low"
)

func (Confidence) Valid

func (c Confidence) Valid() bool

type ContextDoc

type ContextDoc struct {
	ID                string    `json:"id"`
	InitiativeID      string    `json:"initiative_id"`
	Kind              string    `json:"kind"`
	Title             string    `json:"title"`
	Digest            string    `json:"digest"`
	Preview           string    `json:"preview"`
	Format            string    `json:"format"`
	DescriptionDigest string    `json:"description_digest,omitempty"`
	CreatedAt         time.Time `json:"created_at"`
}

ContextDoc is one source document attached to an initiative: a PRD, design note, technical spec, market research, a wireframe/mockup image, or other free-form labeled context. The body is stored as a content-addressed blob; this row records its digest plus a short redacted text preview. Image docs (Format=="image") carry the raw image in Digest and, once described by a vision model, the description text digest in DescriptionDigest.

type ContextEntry

type ContextEntry struct {
	Priority        int        `json:"priority"`
	Source          string     `json:"source"`
	Digest          string     `json:"digest,omitempty"`
	Trust           TrustLevel `json:"trust"`
	InclusionReason string     `json:"inclusion_reason"`
	Selector        string     `json:"selector"`
	Transformation  string     `json:"transformation"`
	Size            int64      `json:"size"`
}

ContextEntry is one compiled context entry (§37).

type Decision

type Decision struct {
	ID             string          `json:"id"`
	InitiativeID   string          `json:"initiative_id"`
	Code           string          `json:"code"`
	Type           DecisionType    `json:"type"`
	Question       string          `json:"question"`
	Options        []string        `json:"options"`
	Recommendation string          `json:"recommendation"`
	Status         DecisionStatus  `json:"status"`
	Resolution     string          `json:"resolution,omitempty"`
	ResolvedBy     string          `json:"resolved_by,omitempty"`
	Provenance     []ProvenanceRef `json:"provenance"`
	SupersededBy   string          `json:"superseded_by,omitempty"`
	CreatedAt      time.Time       `json:"created_at"`
}

Decision is a structured decision with a recommendation (§8, §19).

type DecisionDiscussion

type DecisionDiscussion struct {
	ID         string    `json:"id"`
	DecisionID string    `json:"decision_id"`
	Author     string    `json:"author"`
	Message    string    `json:"message"`
	CreatedAt  time.Time `json:"created_at"`
}

DecisionDiscussion is one message in a human↔AI discussion thread attached to a decision (§8): the human asks for context or proposes an alternative, and the model replies.

type DecisionDissent

type DecisionDissent struct {
	ID              string    `json:"id"`
	DecisionID      string    `json:"decision_id"`
	ProponentRole   string    `json:"proponent_role"`
	Position        string    `json:"position"`
	ReasoningDigest string    `json:"reasoning_digest,omitempty"`
	CreatedAt       time.Time `json:"created_at"`
}

DecisionDissent preserves a dissenting view so it is never erased (§8).

type DecisionStatus

type DecisionStatus string

DecisionStatus is the lifecycle of a Decision (§19).

const (
	DecisionOpen       DecisionStatus = "open"
	DecisionDecided    DecisionStatus = "decided"
	DecisionSuperseded DecisionStatus = "superseded"
)

func (DecisionStatus) Valid

func (s DecisionStatus) Valid() bool

type DecisionType

type DecisionType string

DecisionType categorizes a Decision (§19).

const (
	DecisionProduct      DecisionType = "product"
	DecisionArchitecture DecisionType = "architecture"
	DecisionDesign       DecisionType = "design"
	DecisionSecurity     DecisionType = "security"
	DecisionOperations   DecisionType = "operations"
)

func (DecisionType) Valid

func (t DecisionType) Valid() bool

type DenyCode

type DenyCode string

DenyCode is a machine-readable system-deny reason (security model, §system deny). It is set on a Finding.Code when a deterministic, non-overridable boundary rejects or blocks an action — independent of executor trust or human approval ("system deny beats human approve").

const (
	DenyCodeSecretSweep        DenyCode = "secret_sweep"
	DenyCodePII                DenyCode = "pii"
	DenyCodePathEscape         DenyCode = "path_escape"
	DenyCodeHostExec           DenyCode = "host_exec"
	DenyCodeBlobDigestMismatch DenyCode = "blob_digest_mismatch"
	DenyCodeTrustDeny          DenyCode = "trust_deny"
	DenyCodeReviewOpenBlocking DenyCode = "review_open_blocking"
	// DenyCodeBlastRadius marks a change set refused for touching more files
	// than execute.max_files allows (review C, the blast-radius guard) —
	// refused before the adversarial review ever runs, so there is never a
	// finding to override: the way past it is splitting the task or raising
	// the configured limit, not a human disposition.
	DenyCodeBlastRadius DenyCode = "blast_radius"
)

func (DenyCode) Valid

func (d DenyCode) Valid() bool

type Disposition

type Disposition string

Disposition is the review-finding disposition (§15 seven-value enum, plus not_a_secret -- review changes #1 -- which is valid only on a secret_sweep finding; store.SetFindingDisposition enforces that scoping, not this type).

const (
	DispositionFixed         Disposition = "fixed"
	DispositionAcceptedRisk  Disposition = "accepted_risk"
	DispositionNotApplicable Disposition = "not_applicable"
	DispositionDuplicate     Disposition = "duplicate"
	DispositionDeferred      Disposition = "deferred"
	DispositionRejected      Disposition = "rejected"
	DispositionMitigate      Disposition = "mitigate"
	// DispositionNotASecret marks a secret_sweep finding's detected value as a
	// false positive. Recording it also allowlists the value's fingerprint
	// (never the value) for the project, so future sweeps ignore it (§ D2).
	DispositionNotASecret Disposition = "not_a_secret"
)

func (Disposition) Valid

func (d Disposition) Valid() bool

type DocComment

type DocComment struct {
	ID                 string    `json:"id"`
	InitiativeID       string    `json:"initiative_id"`
	ArtifactVersionID  string    `json:"artifact_version_id"`
	Section            string    `json:"section,omitempty"`
	Text               string    `json:"text"`
	Author             string    `json:"author"`
	PromotedQuestionID string    `json:"promoted_question_id,omitempty"`
	CreatedAt          time.Time `json:"created_at"`
}

DocComment is a human comment anchored to a section of an artifact version. It can be promoted into an open Question for the initiative's judgment flow.

type EdgeType

type EdgeType string

EdgeType is a Product Graph edge kind (§25). M2 wires the five traceability edges; the rest are declared now and written in later milestones.

const (
	EdgeSupports    EdgeType = "supports"
	EdgeContradicts EdgeType = "contradicts"
	EdgeDerivedFrom EdgeType = "derived_from"
	EdgeDependsOn   EdgeType = "depends_on"
	EdgeImplements  EdgeType = "implements"
	EdgeAddresses   EdgeType = "addresses"
	EdgeTests       EdgeType = "tests"
	EdgeVerifies    EdgeType = "verifies"
	EdgeReviews     EdgeType = "reviews"
	EdgeSupersedes  EdgeType = "supersedes"
	EdgeInvalidates EdgeType = "invalidates"
	EdgeProducedBy  EdgeType = "produced_by"
	EdgeConsumes    EdgeType = "consumes"
	// The outcome chain (Objective -> Hypothesis -> Requirement -> ... ->
	// Evidence -> outcome). Each points from the dependent node to the node it
	// exists for, like implements and derived_from, so `why` walks toward the
	// objective and `impact` walks away from it:
	//
	//   requirement --serves--> objective        (N:M, the PRD or a human links it)
	//   metric      --measures--> objective      (a metric belongs to one objective)
	//   assertion   --predicts--> metric         ("we believe X will move MET-2")
	//   metric      --attributed_to--> change_set (CHG-n landed between two observations)
	//
	// attributed_to points from the metric to the change set so that `impact
	// requirement REQ-1` -- which already reaches a task's change sets --
	// continues on to the outcome metrics those change sets moved.
	EdgeServes       EdgeType = "serves"
	EdgeMeasures     EdgeType = "measures"
	EdgePredicts     EdgeType = "predicts"
	EdgeAttributedTo EdgeType = "attributed_to"
)

func (EdgeType) Valid

func (e EdgeType) Valid() bool

type Event

type Event struct {
	Seq           int64     `json:"seq"`
	AggregateType string    `json:"aggregate_type"`
	AggregateID   string    `json:"aggregate_id"`
	Actor         string    `json:"actor"`
	CorrelationID string    `json:"correlation_id"`
	CausationID   string    `json:"causation_id"`
	Operation     string    `json:"operation"`
	EventType     string    `json:"event_type"`
	PayloadDigest string    `json:"payload_digest"`
	CreatedAt     time.Time `json:"created_at"`
}

Event is an append-only event record (§32).

type EvidenceTest added in v0.6.0

type EvidenceTest struct {
	Name      string `json:"name"`
	Status    string `json:"status"`
	ChangeSet string `json:"change_set"`
}

EvidenceTest is one test-run result mapped to a requirement (C2, wave 3 contract). Status is the test's own outcome ("passed"|"failed"), not a domain.VerificationStatus -- it is evidence a human still has to confirm, not a verification judgment.

type ExecutorProvenance added in v0.7.0

type ExecutorProvenance struct {
	Requested string `json:"requested"`
	Resolved  string `json:"resolved"`
	// Image is the container image the agent ran in, as configured (a pinned
	// repo@sha256 reference for the default Hermes image). Empty for internal.
	Image string `json:"image,omitempty"`
	// Server is the remote Agent Server the run executed on (kind
	// openhands): where the work root was sent.
	Server string `json:"server,omitempty"`
	// Warning is non-empty when the run fell back to the placeholder executor.
	Warning string `json:"warning,omitempty"`
	// Permissions is every session/request_permission an ACP agent made, with
	// the answer the harness gave. The container is the sandbox boundary, so
	// each is auto-answered (allow_once when offered) -- and logged here, so
	// what was approved on the operator's behalf is never invisible.
	Permissions []ACPPermission `json:"permissions,omitempty"`
	// Steering is every note a human sent the agent while it ran, and what
	// became of each (delivered, queued as its next turn, or held for the
	// next run when the executor cannot be steered).
	Steering []SteeringNote `json:"steering,omitempty"`
}

ExecutorProvenance records which coding executor a run actually used, and why, on the run manifest.

Requested is what harness.yaml asked for ("auto" when executor.kind is unset); Resolved is what ran. They differ only for auto, and the pair is the whole point: "requested: auto, resolved: internal" is a run that wrote a placeholder instead of code, and Warning says why and how to fix it. Before this existed an unset kind silently meant internal and nothing recorded that a real agent had never been tried.

type ExecutorTrust

type ExecutorTrust string

ExecutorTrust is the executor trust tier (§49).

const (
	ExecutorInternal       ExecutorTrust = "internal"
	ExecutorLocalExternal  ExecutorTrust = "local_external"
	ExecutorRemoteExternal ExecutorTrust = "remote_external"
)

func (ExecutorTrust) Valid

func (t ExecutorTrust) Valid() bool

type FileChange

type FileChange struct {
	Path       string         `json:"path"`
	Digest     string         `json:"digest"`
	Mode       string         `json:"mode,omitempty"`
	ChangeType FileChangeKind `json:"change_type,omitempty"`
	// BaseDigest is the digest of the file this change was made against, for a
	// modified or deleted file. Apply refuses when the workspace file no longer
	// matches it, rather than overwriting an edit made after the agent ran.
	BaseDigest string `json:"base_digest,omitempty"`
	// RedactedDigest is the digest of this file's post-image content with every
	// detected secret span masked, persisted INSTEAD of the raw bytes when the
	// secret sweep denied the change set (Digest above still names the real
	// content's hash, but that hash is never resolvable in the blob store for a
	// denied change set -- only the masked bytes were ever written, so the raw
	// value never reaches the raw store). Empty whenever the raw content was
	// persisted normally. Review: secret-sweep diff visibility.
	RedactedDigest string `json:"redacted_digest,omitempty"`
}

FileChange is one file-level change in a source diff (§36). Path is relative to the workspace root. A non-empty Digest is the SHA-256 of the file's post-image content; an empty Digest denotes deletion. Mode is "file" for the M4 thin slice (the internal implementer produces only regular files). ChangeType records whether the file was added, modified, or deleted (computed by the orchestrator's Diff); it is empty for patches persisted before the field existed, in which case callers fall back to IsDelete.

func (FileChange) IsDelete

func (f FileChange) IsDelete() bool

IsDelete reports whether this change removes the file at Path.

type FileChangeKind

type FileChangeKind string

FileChangeKind classifies a single FileChange for display (add/modify/delete).

const (
	FileAdded    FileChangeKind = "add"
	FileModified FileChangeKind = "modify"
	FileDeleted  FileChangeKind = "delete"
)

type Finding

type Finding struct {
	ID               string      `json:"id"`
	InitiativeID     string      `json:"initiative_id,omitempty"`
	ReviewRunID      string      `json:"review_run_id"`
	TargetType       string      `json:"target_type"`
	TargetID         string      `json:"target_id"`
	Severity         Severity    `json:"severity"`
	Confidence       Confidence  `json:"confidence"`
	Category         string      `json:"category"`
	Code             DenyCode    `json:"code,omitempty"`
	Finding          string      `json:"finding"`
	Evidence         string      `json:"evidence"`
	Impact           string      `json:"impact"`
	Recommendation   string      `json:"recommendation"`
	Disposition      Disposition `json:"disposition,omitempty"`
	DispositionActor string      `json:"disposition_actor,omitempty"`
	Note             string      `json:"note,omitempty"`
	// SecretFingerprint, SecretKind and SecretPath are set only on a
	// secret_sweep finding raised from a per-file credential match (§ D2,
	// review changes #1, review H3). SecretFingerprint is a per-project HMAC
	// of the matched value's capture group, never the value itself, and never
	// a bare sha256 (which anyone could precompute and correlate across
	// installations); disposing the finding not_a_secret allowlists it by
	// this fingerprint scoped to SecretPath.
	SecretFingerprint string `json:"secret_fingerprint,omitempty"`
	SecretKind        string `json:"secret_kind,omitempty"`
	SecretPath        string `json:"secret_path,omitempty"`
	// SecretOverridable reports whether a human may disposition this finding
	// not_a_secret at all (review H3): true for an ordinary pattern-shaped
	// match (might be a false positive), false for a match drawn from the
	// project's own configured secret values -- a real credential by
	// construction, never eligible for the override regardless of who asks.
	// Defaults to true (the zero value of the underlying column) so older
	// rows written before this field existed are not retroactively treated
	// as configured-secret matches.
	SecretOverridable bool `json:"secret_overridable"`
	// SecretPreview is a masked preview of the matched value (review LOW):
	// nothing at all for a value under 16 characters (masked entirely), at
	// most 1 character on each side for a 16-23 character value, and at most
	// the first/last 4 characters (e.g. "sk-p…Xy9z") only from 24 characters
	// up -- shown so a human dispositioning this finding can see enough to
	// recognize what they are allowlisting without the raw value ever being
	// persisted or returned in full. See security.maskValue.
	SecretPreview string `json:"secret_preview,omitempty"`
	// Path is the file the finding is about, self-reported by the reviewer
	// (change-set review only, review B2, adopted #5). Optional: a finding
	// with no specific file leaves it empty.
	Path string `json:"path,omitempty"`
	// InDiff is the reviewer's own claim that Path (or, if Path is empty, the
	// finding as a whole) is about code the change set actually touches
	// (review B2, adopted #5). Only consulted when Path is empty -- when Path
	// is set, whether it is one of the change set's files is checked
	// deterministically instead of trusting this self-report.
	InDiff bool `json:"in_diff,omitempty"`
	// Advisory marks a finding that does not block approval regardless of
	// severity: "about code this change set did not touch" (review B2), a
	// rigor cap's own dropped-count note (review B1), and a generic
	// "credential assignment" secret-sweep match found in a test/fixture path
	// (ICP re-run defect #1) all set it. Kept as its own bool rather than
	// folded into Severity or Disposition -- review.EvaluateApproval and
	// denyReviewOpenBlocking both skip an advisory finding outright, and a UI
	// backlog view is exactly the findings with this set and no disposition
	// yet.
	Advisory  bool      `json:"advisory,omitempty"`
	CreatedAt time.Time `json:"created_at"`

	// Cites, ReRaises and Justification are the adversarial reviewer's own
	// convergence fields (schema.Review: "requirement", "reraises",
	// "justification"), read by review.ParseFindings and consumed by the PRD
	// review loop's convergence rules before the finding is persisted. They
	// are parse-time only -- no column stores them, so a finding read back
	// from the store always has them empty, and json:"-" keeps the API from
	// advertising fields it could never fill. What they decided is persisted
	// where a human can see it: the cited requirement as TargetType/TargetID,
	// and the justification (or the reason a finding was made advisory) in
	// Note.
	Cites         string `json:"-"`
	ReRaises      string `json:"-"`
	Justification string `json:"-"`
}

Finding is a structured review finding (§15).

func (Finding) ResolvesBlocking added in v0.6.0

func (f Finding) ResolvesBlocking() bool

ResolvesBlocking reports whether f's current disposition clears it from the approval bar (§11, §15) -- review.EvaluateApproval and denyReviewOpenBlocking both call this instead of comparing Disposition directly, so the two stay in lockstep (ICP re-run defect #2).

fixed and accepted_risk always resolve a blocking finding. rejected also does, but ONLY when a HUMAN set it (DispositionActor == "human" -- store.HumanActor's value; domain cannot import store, which imports domain) on a finding that carries NO system deny code (Code == ""): a human dispositioning the adversarial reviewer's own judgment call "rejected" is "the human judged this finding wrong," semantically no different from overruling it with accepted_risk, and the ICP re-run found this permanently deadlocked approval instead (rejected recorded 200, AllDispositioned true, but nothing ever cleared the block; the error even recommended --accept-findings, which had no effect on an ALREADY dispositioned finding).

A SYSTEM-set rejected must keep blocking regardless of who looks at it afterward ("system deny beats human approve"): a failing build/test check (Code == "", Disposition == rejected, set by the check runner itself, never a human), a secret_sweep/host_exec/etc. finding (Code != "", self-rejected at creation), and a rejected change set's own findings closed via Disposition = rejected (review M5) all fail the Code == "" and/or DispositionActor == "human" tests above and so are excluded here exactly as before this method existed.

type Gap added in v0.7.0

type Gap struct {
	Kind       GapKind   `json:"kind"`
	State      GapState  `json:"state"`
	Severity   Severity  `json:"severity"`
	Nodes      []GapNode `json:"nodes"`
	Why        string    `json:"why"`
	Next       string    `json:"next"`
	Dependents int       `json:"dependents"`
	// InitiativeID is set on every gap, so a project-wide report stays
	// attributable after a client flattens it.
	InitiativeID string `json:"initiative_id"`
}

Gap is one hole `idea gaps` found in the Product Graph: what kind, how bad, which nodes, why in one line, and the command that closes it.

Nodes[0] is always the node the gap is *about* (the requirement that is not implemented, the decision whose basis moved); any further nodes are the evidence for it (the stale dependents, the criteria with no evidence). Dependents counts the live nodes that rest on Nodes[0] -- the ranking key within a severity, so the assumption half the plan depends on sorts above one nothing cites.

type GapKind added in v0.7.0

type GapKind string

GapKind names one class of hole `idea gaps` finds in the Product Graph. The values are a public contract (the `kind` field of every gap, the --kind filter, the MCP `gaps` tool): add new ones, never rename one.

The set is deliberately open-ended. Each kind is one analyzer in projection.BuildGaps' table; a new kind is a new constant here, its spec enum entry, and one more analyzer -- nothing that renders or filters gaps switches on the kind.

const (
	GapUnimplementedRequirement    GapKind = "unimplemented_requirement"
	GapUnverifiedRequirement       GapKind = "unverified_requirement"
	GapUntestedAcceptanceCriterion GapKind = "untested_acceptance_criterion"
	GapUnvalidatedAssumption       GapKind = "unvalidated_assumption"
	GapInvalidatedDecision         GapKind = "invalidated_decision"
	GapOrphanTask                  GapKind = "orphan_task"
	GapOrphanChangeSet             GapKind = "orphan_change_set"
	GapStaleArtifact               GapKind = "stale_artifact"
	// The outcome chain (domain.AnalyzeOutcomeChain): work with no stated
	// outcome, outcomes nobody measures or aims at, metrics drifting, and
	// verified work whose objective is failing.
	GapOrphanRequirement      GapKind = "orphan_requirement"
	GapUnmeasuredObjective    GapKind = "unmeasured_objective"
	GapUnservedObjective      GapKind = "unserved_objective"
	GapDriftingMetric         GapKind = "drifting_metric"
	GapIneffectiveRequirement GapKind = "ineffective_requirement"
)

func (GapKind) Valid added in v0.7.0

func (k GapKind) Valid() bool

type GapNode added in v0.7.0

type GapNode struct {
	Type  string `json:"type"`
	ID    string `json:"id"`
	Code  string `json:"code"`
	Label string `json:"label,omitempty"`
}

GapNode is one Product Graph node a gap is about. Code is the human handle (REQ-3, TASK-2, CHG-4, DEC-1, an artifact kind, an acceptance criterion as REQ-3/AC-2, an assertion's short id) -- what a person types; ID is the stable id a client links with.

type GapReport added in v0.7.0

type GapReport struct {
	InitiativeID string     `json:"initiative_id,omitempty"`
	Gaps         []Gap      `json:"gaps"`
	Summary      GapSummary `json:"summary"`
}

GapReport is the GET …/gaps response body.

type GapState added in v0.7.0

type GapState string

GapState says which trigger of a kind fired, so a client can tell "no evidence" from "evidence failed" from "evidence stale" without parsing the sentence. Each kind uses a fixed subset; docs/architecture.md ("Asking the graph: gaps") lists which and exactly what fires each.

const (
	// unimplemented_requirement
	GapStateNoTask     GapState = "no_task"
	GapStateNotApplied GapState = "not_applied"
	// unverified_requirement / untested_acceptance_criterion
	GapStateNoCriteria     GapState = "no_criteria"
	GapStateNoEvidence     GapState = "no_evidence"
	GapStateEvidenceFailed GapState = "evidence_failed"
	GapStateEvidenceStale  GapState = "evidence_stale"
	// unvalidated_assumption
	GapStateUnvalidated GapState = "unvalidated"
	GapStateDisputed    GapState = "disputed"
	GapStateRefuted     GapState = "refuted"
	// invalidated_decision
	GapStateDependentsStale     GapState = "dependents_stale"
	GapStateRequirementRevised  GapState = "requirement_revised"
	GapStateRequirementsRemoved GapState = "requirements_removed"
	GapStateBasisRefuted        GapState = "basis_refuted"
	// orphan_task / orphan_change_set
	GapStateNoRequirement GapState = "no_requirement"
	GapStateTaskMissing   GapState = "task_missing"
	GapStateTaskOrphaned  GapState = "task_orphaned"
	// stale_artifact
	GapStateUpstreamNewer GapState = "upstream_newer"
	// orphan_requirement
	GapStateNoObjective       GapState = "no_objective"
	GapStateObjectivesMissing GapState = "objectives_missing"
	// unmeasured_objective (unserved_objective reuses no_requirement)
	GapStateNoMetric GapState = "no_metric"
	// drifting_metric (the MetricDrift values that count as drifting)
	GapStateOffTrack  GapState = "off_track"
	GapStateRegressed GapState = "regressed"
	GapStateStale     GapState = "stale"
	// ineffective_requirement
	GapStateWorksButFailsObjective GapState = "works_but_fails_objective"
)

func (GapState) Valid added in v0.7.0

func (s GapState) Valid() bool

type GapSummary added in v0.7.0

type GapSummary struct {
	Total      int            `json:"total"`
	BySeverity map[string]int `json:"by_severity"`
	ByKind     map[string]int `json:"by_kind"`
}

GapSummary is the at-a-glance count the guidance projection and the Health page show: totals by severity and by kind. Every known kind and severity appears, zero included, so a client never has to tell "absent" from "zero".

func Summarize added in v0.7.0

func Summarize(gaps []Gap) GapSummary

Summarize counts gaps by severity and kind.

type GraphEdge

type GraphEdge struct {
	ID           string         `json:"id"`
	InitiativeID string         `json:"initiative_id,omitempty"`
	FromType     string         `json:"from_type"`
	FromID       string         `json:"from_id"`
	EdgeType     EdgeType       `json:"edge_type"`
	ToType       string         `json:"to_type"`
	ToID         string         `json:"to_id"`
	Metadata     map[string]any `json:"metadata,omitempty"`
	CreatedAt    time.Time      `json:"created_at"`
}

GraphEdge is a Product Graph edge linking two typed nodes (§25).

type Initiative

type Initiative struct {
	ID          string `json:"id"`
	ProjectID   string `json:"project_id,omitempty"`
	Title       string `json:"title"`
	Description string `json:"description"`
	// ShortTitle is a deterministically generated short label (<=60 chars,
	// C1 wave 3 contract): the idea's first sentence or clause, trimmed at a
	// word boundary, with a common lead-in ("I want to", "Build") dropped.
	// Title/Description keep the full prompt; the UI shows ShortTitle||Title.
	// Generated on create, and backfilled lazily for older initiatives by
	// GetInitiative/ListInitiatives when empty.
	ShortTitle    string           `json:"short_title,omitempty"`
	Status        InitiativeStatus `json:"status"`
	FailureReason string           `json:"failure_reason,omitempty"`
	// JudgmentReason is set only while Status is needs_human_judgment. It is
	// not cleared when the status moves on -- nothing reads it in any other
	// status, and clearing it on every transition would mean touching the claim
	// path, which failure_reason already showed to be the wrong place.
	JudgmentReason JudgmentReason `json:"judgment_reason,omitempty"`
	// GitBranch is the dedicated branch (`idea/<slug>`) this initiative's
	// change sets commit to when git.branch_per_initiative is on. Set on the
	// initiative's first apply and reused by every later one, so all of its
	// change sets land on the same branch. Empty when the setting is off, or
	// before a first apply has created it.
	GitBranch string `json:"git_branch,omitempty"`
	// PRURL is the pull request `idea pr` opened for GitBranch (review C4
	// piece 3). Empty until a PR exists; a repeat `idea pr` is idempotent and
	// returns this URL rather than opening a second PR.
	PRURL     string    `json:"pr_url,omitempty"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

Initiative is the user-facing idea under development.

type InitiativeCosts added in v0.6.0

type InitiativeCosts struct {
	TotalUSD float64     `json:"total_usd"`
	ByPhase  []PhaseCost `json:"by_phase"`
	Agent    AgentCost   `json:"agent"`
}

InitiativeCosts is the GET .../costs response body (C3, wave 3 contract).

type InitiativeStatus

type InitiativeStatus string

InitiativeStatus is the initiative/workflow lifecycle (§11).

const (
	InitiativeRunning            InitiativeStatus = "running"
	InitiativeNeedsHumanJudgment InitiativeStatus = "needs_human_judgment"
	InitiativeApproved           InitiativeStatus = "approved"
	InitiativePlanApproved       InitiativeStatus = "plan_approved"
	InitiativeFailed             InitiativeStatus = "failed"
	InitiativeComplete           InitiativeStatus = "complete"
	// InitiativeDraft is a captured idea that has not started the pipeline:
	// created by `idea capture`/a channel, opened and started later from the UI.
	InitiativeDraft InitiativeStatus = "draft"
)

func (InitiativeStatus) Valid

func (s InitiativeStatus) Valid() bool

type JudgmentReason added in v0.4.0

type JudgmentReason string

JudgmentReason says why an initiative is in `needs_human_judgment`.

The status has six producers and they need different answers from the user: a stalled PRD review is approved or revised, a plan whose dependency graph did not resolve can only be regenerated, and a requirement failed after completion is re-verified. Recording the reason is what lets `idea next` name a command instead of guessing. It was guessed before, from the presence of the execution-plan artifact, which is written *before* the unresolved- dependency check that produces two of the six -- so the guess named `approve-plan` for a plan known to be incomplete.

const (
	// JudgmentPRDReview: the adversarial PRD review did not converge within
	// max_cycles. Resolve by accepting the PRD or regenerating it.
	JudgmentPRDReview JudgmentReason = "prd_review"
	// JudgmentPlanDependencies: the execution plan has tasks whose dependencies
	// were never satisfied. Only regenerating the plan resolves this -- approving
	// it would set plan_approved over a known-incomplete graph and leave an
	// undisposed blocking finding that wedges completion.
	JudgmentPlanDependencies JudgmentReason = "plan_dependencies"
	// JudgmentPlanReview: the adversarial plan review raised blocking findings.
	JudgmentPlanReview JudgmentReason = "plan_review"
	// JudgmentVerification: a requirement was failed after the initiative had
	// already completed, so it dropped back out of `complete`. Resolve by
	// recording verification evidence, not by touching the plan.
	JudgmentVerification JudgmentReason = "verification"
	// JudgmentBudget: the initiative reached its spending cap (`budget`) and
	// the engine stopped before the next model or agent call. Resolve by
	// raising the cap (`idea budget <initiative> --set <usd>`), which returns
	// the initiative to where it was, and running the step again.
	JudgmentBudget JudgmentReason = "budget_exceeded"
)

func (JudgmentReason) Valid added in v0.4.0

func (r JudgmentReason) Valid() bool

Valid reports whether r is a known judgment reason. The empty string is valid and means "not recorded": initiatives written before this was introduced, and any producer that has not been taught to set it.

type MetricDirection added in v0.7.0

type MetricDirection string

MetricDirection is which way an OutcomeMetric is supposed to move. maintain means "hold it at the target": the value should not move away from it.

const (
	DirectionIncrease MetricDirection = "increase"
	DirectionDecrease MetricDirection = "decrease"
	DirectionMaintain MetricDirection = "maintain"
)

func (MetricDirection) Valid added in v0.7.0

func (d MetricDirection) Valid() bool

type MetricDrift added in v0.7.0

type MetricDrift string

MetricDrift is the deterministic outcome status of a metric (EvaluateMetricDrift). One primary value is reported, by precedence regressed > off_track > stale > no_data > on_track; the individual signals are carried alongside it on MetricStatus, so a metric that is both stale and off track says so.

const (
	DriftOnTrack   MetricDrift = "on_track"
	DriftOffTrack  MetricDrift = "off_track"
	DriftStale     MetricDrift = "stale"
	DriftRegressed MetricDrift = "regressed"
	DriftNoData    MetricDrift = "no_data"
)

func (MetricDrift) Drifting added in v0.7.0

func (d MetricDrift) Drifting() bool

Drifting reports whether d is a status a human should hear about: the metric is going the wrong way, or nobody has looked at it in time.

func (MetricDrift) Valid added in v0.7.0

func (d MetricDrift) Valid() bool

type MetricObservation added in v0.7.0

type MetricObservation struct {
	ID           string           `json:"id"`
	InitiativeID string           `json:"initiative_id"`
	MetricID     string           `json:"metric_id"`
	Value        float64          `json:"value"`
	ObservedAt   time.Time        `json:"observed_at"`
	Source       MetricSourceKind `json:"source"`
	Note         string           `json:"note,omitempty"`
	RecordedBy   string           `json:"recorded_by"`
	// Provenance is what produced the value: the human who typed it, or the
	// digest of the command output / fetched document it was read from.
	Provenance []ProvenanceRef `json:"provenance"`
	// ChangeSetIDs are the change sets that were applied (and are still
	// applied, and changed something) between the previous observation and
	// this one -- the outcome attribution. Each is also a metric
	// --attributed_to--> change_set graph edge.
	ChangeSetIDs []string  `json:"change_set_ids"`
	CreatedAt    time.Time `json:"created_at"`
}

MetricObservation is one measured value of a metric.

type MetricSource added in v0.7.0

type MetricSource struct {
	Kind MetricSourceKind `json:"kind"`
	// Command is a shell command run with `sh -c` in the no-network check
	// sandbox, with the workspace mounted read-only at /repo. Its stdout must
	// contain a number; the last number printed is the observation.
	Command string `json:"command,omitempty"`
	// URL is fetched through the SSRF-guarded fetcher (public http(s)
	// addresses only) and must return JSON; Pointer is the RFC 6901 JSON
	// pointer to the number in it ("" means the document itself is a number).
	URL     string `json:"url,omitempty"`
	Pointer string `json:"pointer,omitempty"`
}

MetricSource says how an OutcomeMetric is measured. Command and URL run on request (`idea metric measure`), and on the metric's cadence only once a person enables the scheduled measurement (automations.metric_measurement).

func (MetricSource) Validate added in v0.7.0

func (s MetricSource) Validate() error

Validate reports why a source cannot be measured, or nil.

type MetricSourceKind added in v0.7.0

type MetricSourceKind string

MetricSourceKind is where an OutcomeMetric's observations come from. manual is recorded by a human (`idea metric record`); command runs a shell command in the no-network check sandbox and reads the number it prints; url fetches a JSON document through the SSRF-guarded fetcher and reads the number at a JSON pointer. Neither command nor url runs on its own: a human (or an MCP client) asks for `idea metric measure`, or a person has enabled automations.metric_measurement, which measures each on its cadence.

const (
	MetricSourceManual  MetricSourceKind = "manual"
	MetricSourceCommand MetricSourceKind = "command"
	MetricSourceURL     MetricSourceKind = "url"
)

func (MetricSourceKind) Valid added in v0.7.0

func (k MetricSourceKind) Valid() bool

type MetricStatus added in v0.7.0

type MetricStatus struct {
	Drift             MetricDrift `json:"drift"`
	OffTrack          bool        `json:"off_track"`
	Stale             bool        `json:"stale"`
	Regressed         bool        `json:"regressed"`
	GuardrailBreached bool        `json:"guardrail_breached"`
	Achieved          bool        `json:"achieved"`
	Observations      int         `json:"observations"`
	Latest            *float64    `json:"latest,omitempty"`
	LatestAt          *time.Time  `json:"latest_at,omitempty"`
	Previous          *float64    `json:"previous,omitempty"`
	// EffectiveBaseline is what off_track compares against, and
	// BaselineSource where it came from: "declared" (the metric's own
	// baseline) or "first_observation" (none declared). Both empty with no
	// observations and no declared baseline.
	EffectiveBaseline *float64 `json:"effective_baseline,omitempty"`
	BaselineSource    string   `json:"baseline_source,omitempty"`
	// RegressedBy is the change sets attributed to the observation that moved
	// the metric the wrong way (empty unless Regressed).
	RegressedBy []string   `json:"regressed_by"`
	NextDueAt   *time.Time `json:"next_due_at,omitempty"`
	Reasons     []string   `json:"reasons"`
}

MetricStatus is the deterministic drift evaluation of one metric.

func EvaluateMetricDrift added in v0.7.0

func EvaluateMetricDrift(m OutcomeMetric, obs []MetricObservation, now time.Time) MetricStatus

EvaluateMetricDrift is the deterministic drift rule for one metric. obs may be in any order; now is the evaluation time (staleness is relative to it).

The rules, exactly:

  • no_data: the metric has never been observed. It is additionally stale when it has a cadence and more than one cadence has passed since the metric was defined.
  • off_track: the latest observation is worse than the effective baseline (lower for increase, higher for decrease, farther from the target for maintain) -- i.e. on the wrong side of the baseline->target trajectory -- or it breaches the guardrail. The effective baseline is the declared one, or, when none was declared, the first observation; so a metric with no baseline and a single observation cannot be off track except by its guardrail.
  • stale: a cadence is set and more than one cadence has passed since the latest observation (strictly more: exactly one cadence is still due, not late).
  • regressed: the latest observation is worse than the one before it, by the same direction rule, AND at least one change set landed between the two (MetricObservation.ChangeSetIDs). A drop with no change set in between is noise or the world, not this work; it can still be off_track.

Drift is the most urgent that holds: regressed > off_track > stale > no_data > on_track. Each signal is also reported on its own.

type Objective added in v0.7.0

type Objective struct {
	ID           string          `json:"id"`
	InitiativeID string          `json:"initiative_id"`
	Code         string          `json:"code"`
	Statement    string          `json:"statement"`
	Rationale    string          `json:"rationale,omitempty"`
	Status       ObjectiveStatus `json:"status"`
	Owner        string          `json:"owner,omitempty"`
	// ProducedByRun is the PRD run that authored this objective, empty for one
	// a human added. Only a model-authored objective is ever superseded by a
	// later PRD revision; a human's objective is the human's to change.
	ProducedByRun string `json:"produced_by_run,omitempty"`
	SupersededBy  string `json:"superseded_by,omitempty"`
	// RequirementIDs are the active requirements serving this objective, and
	// MetricIDs its active metrics. Computed at read time from graph edges and
	// the metric table -- never nil on the wire.
	RequirementIDs []string  `json:"requirement_ids"`
	MetricIDs      []string  `json:"metric_ids"`
	CreatedAt      time.Time `json:"created_at"`
	UpdatedAt      time.Time `json:"updated_at"`
}

Objective is a product objective an initiative exists to move (OBJ-n).

func (Objective) Active added in v0.7.0

func (o Objective) Active() bool

Active reports whether o is a live objective: not superseded by a PRD revision, and still being pursued.

type ObjectiveStatus added in v0.7.0

type ObjectiveStatus string

ObjectiveStatus is the lifecycle of a product Objective. Only an active objective is checked for drift or required to have a metric: an achieved or abandoned one is kept as a record, not as a live promise.

const (
	ObjectiveActive    ObjectiveStatus = "active"
	ObjectiveAchieved  ObjectiveStatus = "achieved"
	ObjectiveAbandoned ObjectiveStatus = "abandoned"
)

func (ObjectiveStatus) Valid added in v0.7.0

func (s ObjectiveStatus) Valid() bool

type Operation

type Operation struct {
	ID           string          `json:"id"`
	ProjectID    string          `json:"project_id"`
	InitiativeID string          `json:"initiative_id,omitempty"`
	Type         string          `json:"type"`
	Status       OperationStatus `json:"status"`
	ResultRef    string          `json:"result_ref,omitempty"`
	// Error is the reason a failed or cancelled operation ended that way,
	// redacted and length-capped before it is persisted (B2). Before this
	// field existed, a failed execute left the initiative at plan_approved,
	// the Build page's running card simply vanished, and the only record of
	// why was a line in daemon.log — invisible to anyone not tailing it.
	Error string `json:"error,omitempty"`
	// Stage is the current step the engine reports while this operation runs
	// (C3, wave 3 contract), e.g. "Writing the PRD", "Reviewing the plan
	// (cycle 2)", "Agent running TASK-2", "Running checks". Set by a small
	// callback the engine calls as it moves between steps and cleared by
	// nothing -- it simply stops changing once the operation reaches a
	// terminal status. The CLI's wait loop prints it in place of a bare
	// "still working…".
	Stage      string     `json:"stage,omitempty"`
	CreatedAt  time.Time  `json:"created_at"`
	FinishedAt *time.Time `json:"finished_at,omitempty"`
}

Operation is a durable long-running operation (§34).

type OperationStatus

type OperationStatus string

OperationStatus is the lifecycle of a durable Operation (§34).

const (
	OperationPending   OperationStatus = "pending"
	OperationRunning   OperationStatus = "running"
	OperationSucceeded OperationStatus = "succeeded"
	OperationFailed    OperationStatus = "failed"
	OperationCancelled OperationStatus = "cancelled"
)

func (OperationStatus) Valid

func (s OperationStatus) Valid() bool

type OutcomeChainGaps added in v0.7.0

type OutcomeChainGaps struct {
	// ObjectivesMissing: there is at least one live requirement and no active
	// objective at all -- the whole chain is absent, reported once rather than
	// once per requirement.
	ObjectivesMissing bool
	// ObjectivesWithoutMetrics are the active objectives with no live,
	// measurable metric (OutcomeMetric.Measurable).
	ObjectivesWithoutMetrics []Objective
	// ObjectivesWithoutRequirements are the active objectives no live
	// requirement serves.
	ObjectivesWithoutRequirements []Objective
	// RequirementsWithoutObjectives are the live requirements that serve no
	// active objective. Empty when ObjectivesMissing (or when there are no
	// active objectives at all).
	RequirementsWithoutObjectives []Requirement
	// DriftingMetrics are the live metrics whose drift is off_track,
	// regressed or stale (MetricDrift.Drifting). no_data is not drifting.
	DriftingMetrics []OutcomeMetric
	// RequirementDrift is the "works but fails its objective" signal.
	RequirementDrift []RequirementOutcomeDrift
}

OutcomeChainGaps is where the outcome end of the Product Graph is missing a link or failing: the one definition the outcome report (GET …/outcomes, the Health page), `idea gaps` and the PRD review's outcome checks all read, so "which requirement serves nothing" or "which objective is unmeasured" has exactly one answer. AnalyzeOutcomeChain computes it.

func AnalyzeOutcomeChain added in v0.7.0

func AnalyzeOutcomeChain(reqs []Requirement, objectives []Objective, metrics []OutcomeMetric) OutcomeChainGaps

AnalyzeOutcomeChain is the deterministic outcome-chain gap rule. Inputs may include dead nodes; it applies the liveness filters itself:

  • a live requirement is not removed and not superseded;
  • an active objective is Objective.Active (not superseded, status active);
  • a live metric is not superseded, and metrics carry their drift Status (store.ListMetrics evaluates it); one with no Status is not drifting.

"Serves" is a requirement's ObjectiveIDs (its serves edges) naming an active objective; serving only an achieved or abandoned objective is serving none -- the same rule the PRD review applies.

Output order follows input order (requirements and objectives as the store lists them; RequirementDrift by requirement, then by its objectives).

type OutcomeMetric added in v0.7.0

type OutcomeMetric struct {
	ID           string          `json:"id"`
	InitiativeID string          `json:"initiative_id"`
	ObjectiveID  string          `json:"objective_id"`
	Code         string          `json:"code"`
	Name         string          `json:"name"`
	Definition   string          `json:"definition,omitempty"`
	Unit         string          `json:"unit,omitempty"`
	Direction    MetricDirection `json:"direction"`
	// Baseline is the value before the work, when known. Without one, the
	// first observation stands in for it (see EvaluateMetricDrift).
	Baseline *float64 `json:"baseline,omitempty"`
	Target   float64  `json:"target"`
	// Guardrail is a hard limit on the bad side of the metric: a floor for
	// increase, a ceiling for decrease, and the largest allowed distance from
	// the target for maintain. Crossing it is off_track whatever the baseline.
	Guardrail *float64     `json:"guardrail,omitempty"`
	Source    MetricSource `json:"source"`
	// Cadence is how often the metric is expected to be observed: hourly,
	// daily, weekly, monthly, quarterly, a Go duration ("36h"), or "<n>d" /
	// "<n>w". Empty means no expectation, so the metric is never stale.
	Cadence       string    `json:"cadence,omitempty"`
	ProducedByRun string    `json:"produced_by_run,omitempty"`
	SupersededBy  string    `json:"superseded_by,omitempty"`
	CreatedAt     time.Time `json:"created_at"`
	UpdatedAt     time.Time `json:"updated_at"`
	// ObjectiveCode and Status are computed at read time (the objective's
	// OBJ-n, and this metric's drift evaluation). Status is nil only on a
	// write response, before there is anything to evaluate.
	ObjectiveCode string        `json:"objective_code,omitempty"`
	Status        *MetricStatus `json:"status,omitempty"`
}

OutcomeMetric is how an Objective is measured (MET-n).

func (OutcomeMetric) Measurable added in v0.7.0

func (m OutcomeMetric) Measurable() bool

Measurable reports whether m can be judged at all: a name, a direction and a valid, parseable cadence. Target is a number by construction.

type PhaseCost added in v0.6.0

type PhaseCost struct {
	Phase   string  `json:"phase"`
	USD     float64 `json:"usd"`
	Seconds float64 `json:"seconds"`
	Calls   int     `json:"calls"`
}

PhaseCost is one phase's spend and time (C3, wave 3 contract): a "phase" is a workflow stage that made a model call (PRD, review, design, plan, ...). Agent (coding) runs are reported separately under InitiativeCosts.Agent, since their spend is not always measurable the same way.

type ProjectMemory added in v0.7.0

type ProjectMemory struct {
	ID        string    `json:"id"`
	Kind      string    `json:"kind"`
	Body      string    `json:"body"`
	CreatedAt time.Time `json:"created_at"`
}

ProjectMemory is one accumulated, cross-initiative entry in a project's standing memory: a human-resolved decision (DEC-x: question → resolution) that later initiatives read as authoritative context. The per-project DB is the project, so no initiative_id is stored.

type ProvenanceRef

type ProvenanceRef struct {
	Kind   string     `json:"kind"`
	ID     string     `json:"id"`
	Digest string     `json:"digest,omitempty"`
	Trust  TrustLevel `json:"trust"`
}

ProvenanceRef is a structured reference to the object that produced or supports a statement (§5, §6). It is a typed reference, never free text.

type QualityCheck added in v0.7.0

type QualityCheck struct {
	Name      string            `json:"name"`
	Status    QualityStatus     `json:"status"`
	Method    QualityMethod     `json:"method"`
	Detail    string            `json:"detail,omitempty"`
	Citations []QualityCitation `json:"citations,omitempty"`
}

QualityCheck is one check inside a quality dimension: what was checked, how (deterministic or model-reviewed), the outcome, and where the evidence is.

type QualityCitation added in v0.7.0

type QualityCitation struct {
	Path        string `json:"path,omitempty"`
	Line        int    `json:"line,omitempty"`
	Requirement string `json:"requirement,omitempty"`
}

QualityCitation points a quality check at the evidence behind it: a file and line in the workspace, and/or the requirement it bears on.

type QualityDimension added in v0.7.0

type QualityDimension string

QualityDimension is one quality dimension `idea verify` measures beyond the acceptance tests (verify.dimensions in harness.yaml). Each produces a QualityResult with pass/warn/fail -- or an explicit not_measured -- and file/requirement citations, recorded as evidence in the Product Graph.

const (
	QualitySetupReproducibility QualityDimension = "setup_reproducibility"
	QualityDocsCompleteness     QualityDimension = "docs_completeness"
	QualityAPICompatibility     QualityDimension = "api_compatibility"
	QualityAPIErgonomics        QualityDimension = "api_ergonomics"
	QualitySecurity             QualityDimension = "security"
	QualityPerformance          QualityDimension = "performance"
	QualityOperationalReadiness QualityDimension = "operational_readiness"
)

func (QualityDimension) Valid added in v0.7.0

func (d QualityDimension) Valid() bool

type QualityMethod added in v0.7.0

type QualityMethod string

QualityMethod says how a quality check reached its result: a deterministic check (a parser, a heuristic, a command run in the sandbox) or a model review (the verification_engineer role, whose findings must cite lines).

const (
	QualityMethodDeterministic QualityMethod = "deterministic"
	QualityMethodModel         QualityMethod = "model"
)

func (QualityMethod) Valid added in v0.7.0

func (m QualityMethod) Valid() bool

type QualityMode added in v0.7.0

type QualityMode string

QualityMode is a dimension's policy: off (not measured at all), advisory (measured and reported, never blocks) or gate (a fail or not_measured result keeps the verification gate from passing).

const (
	QualityModeOff      QualityMode = "off"
	QualityModeAdvisory QualityMode = "advisory"
	QualityModeGate     QualityMode = "gate"
)

func (QualityMode) Valid added in v0.7.0

func (m QualityMode) Valid() bool

type QualityResult added in v0.7.0

type QualityResult struct {
	ID            string           `json:"id"`
	InitiativeID  string           `json:"initiative_id"`
	MeasurementID string           `json:"measurement_id"`
	Dimension     QualityDimension `json:"dimension"`
	Mode          QualityMode      `json:"mode"`
	Status        QualityStatus    `json:"status"`
	Summary       string           `json:"summary"`
	Checks        []QualityCheck   `json:"checks"`
	// Metrics are named numeric measurements (performance budgets record
	// theirs here; they are the next measurement's baseline).
	Metrics map[string]float64 `json:"metrics,omitempty"`
	// InputDigest names what was measured: the applied change sets and the
	// verify policy. A result whose digest no longer matches the initiative's
	// current one is stale and counts as not measured at the gate.
	InputDigest string `json:"input_digest"`
	// Requirements are the codes of the requirements this result is linked
	// to in the Product Graph.
	Requirements []string  `json:"requirements"`
	CreatedAt    time.Time `json:"created_at"`
}

QualityResult is one dimension's measured outcome for an initiative's applied work (verify.dimensions). Results are append-only: every measurement writes a new row per dimension, the scorecard is the latest of each, and the previous one is the performance baseline. Each result is linked to the requirements it bears on with a `verifies` edge, so `idea why quality_result <id>` and `idea impact requirement REQ-n` show it.

type QualityStatus added in v0.7.0

type QualityStatus string

QualityStatus is a dimension's (or one of its checks') outcome.

not_measured is not a softer pass: it is what a dimension reports when the harness could not look -- no Docker, no toolchain image, a vulnerability database that needs the network, a demo model that cannot review -- and a gated dimension that was not measured does not satisfy the gate. not_applicable is the opposite case: the harness looked and there was nothing for the dimension to judge (no OpenAPI spec and no Go package changed, say), which does satisfy it.

const (
	QualityPass          QualityStatus = "pass"
	QualityWarn          QualityStatus = "warn"
	QualityFail          QualityStatus = "fail"
	QualityNotMeasured   QualityStatus = "not_measured"
	QualityNotApplicable QualityStatus = "not_applicable"
)

func (QualityStatus) SatisfiesGate added in v0.7.0

func (s QualityStatus) SatisfiesGate() bool

SatisfiesGate reports whether a gated dimension with this status lets the verification gate pass. warn does (it is a note, not a failure); fail and not_measured do not.

func (QualityStatus) Valid added in v0.7.0

func (s QualityStatus) Valid() bool

type Question

type Question struct {
	ID           string         `json:"id"`
	InitiativeID string         `json:"initiative_id"`
	Question     string         `json:"question"`
	Status       QuestionStatus `json:"status"`
	// NeedsClarification marks a question the model flagged [NEEDS
	// CLARIFICATION] rather than guessing at a missing input. Approving the PRD
	// refuses while any such question is still open, so an unresolved unknown
	// cannot silently become an invented requirement.
	NeedsClarification bool   `json:"needs_clarification,omitempty"`
	AnswerDigest       string `json:"answer_digest,omitempty"`
	// Answer is the answer's text, filled at read time by the questions list
	// (never stored on the row: the text lives in the blob store under
	// AnswerDigest). The UI's Resolved section shows it; without it an
	// answered question simply vanished from Define.
	Answer     string     `json:"answer,omitempty"`
	AnsweredBy string     `json:"answered_by,omitempty"`
	CreatedAt  time.Time  `json:"created_at"`
	ResolvedAt *time.Time `json:"resolved_at,omitempty"`
}

Question is an open question (§4, §9).

type QuestionStatus

type QuestionStatus string

QuestionStatus is the lifecycle of an Open Question.

const (
	QuestionOpen     QuestionStatus = "open"
	QuestionResolved QuestionStatus = "resolved"
)

func (QuestionStatus) Valid

func (s QuestionStatus) Valid() bool

type QueueItem added in v0.6.0

type QueueItem struct {
	InitiativeID string `json:"initiative_id"`
	ShortTitle   string `json:"short_title"`
	Kind         string `json:"kind"`
	Label        string `json:"label"`
	Rank         int64  `json:"rank"`
	Href         string `json:"href"`
}

QueueItem is one cross-initiative "needs you" row (D-b, wave 3 contract). Rank is a sort key, ascending: lower ranks more urgent, blocking items first and then by age within a category.

type RemoteRun added in v0.7.0

type RemoteRun struct {
	ID       string `json:"id"`
	Executor string `json:"executor"`
	// IdempotencyKey is deterministic per (task, attempt): a retry after a
	// crash computes the same key and re-attaches.
	IdempotencyKey string `json:"idempotency_key"`
	InitiativeID   string `json:"initiative_id"`
	TaskID         string `json:"task_id"`
	Attempt        int    `json:"attempt"`
	ServerURL      string `json:"server_url"`
	// ConversationID is the remote server's id for the run.
	ConversationID string `json:"conversation_id,omitempty"`
	// RemoteDir is the remote workspace directory the work root was
	// uploaded to.
	RemoteDir string `json:"remote_dir,omitempty"`
	// BaseDigest is the snapshot digest of the work root as uploaded. A
	// finished run is only collected into a work root with the same digest:
	// its files were written against that base, not whatever the workspace
	// holds now.
	BaseDigest string          `json:"base_digest,omitempty"`
	Status     RemoteRunStatus `json:"status"`
	// RemoteStatus is the server's own last-reported status, verbatim.
	RemoteStatus string `json:"remote_status,omitempty"`
	// LastEventID is the event-ingestion cursor: the id of the newest remote
	// event already folded into Progress.
	LastEventID string `json:"last_event_id,omitempty"`
	EventCount  int    `json:"event_count"`
	// Progress is a compact, redacted log of the remote events (the last few
	// hundred lines), for the live view and for a run watched after a
	// restart.
	Progress   string     `json:"progress,omitempty"`
	Error      string     `json:"error,omitempty"`
	CreatedAt  time.Time  `json:"created_at"`
	UpdatedAt  time.Time  `json:"updated_at"`
	FinishedAt *time.Time `json:"finished_at,omitempty"`
	// RunID is the agent run (runs.id) whose event stream this run feeds.
	// Set by the Execute that dispatches or re-attaches to it, so the
	// watcher -- which outlives that Execute -- knows where events go.
	RunID string `json:"run_id,omitempty"`
}

RemoteRun is the durable record of one agent run delegated to a remote execution plane (executor kind openhands). It is what lets a daemon restart re-attach to a run that kept going on the server instead of starting it a second time, and what reconciliation drives to a terminal state.

type RemoteRunStatus added in v0.7.0

type RemoteRunStatus string

RemoteRunStatus is where a run delegated to a remote execution plane (the openhands executor's Agent Server) stands, as the harness last recorded it. The harness stays authoritative: the remote server's own status is an input to this, never a substitute for it.

const (
	// RemoteRunDispatching: the record exists, the remote conversation may or
	// may not. A crash here is resolved by re-dispatching under the same
	// idempotency key, which finds the conversation if it was created.
	RemoteRunDispatching RemoteRunStatus = "dispatching"
	// RemoteRunRunning: the remote conversation exists and has not finished.
	RemoteRunRunning RemoteRunStatus = "running"
	// RemoteRunFinished: the remote agent finished successfully, and its
	// files have not been brought back yet (the daemon restarted, or
	// reconciliation saw it finish). The next execute of the same task
	// collects it instead of starting again.
	RemoteRunFinished RemoteRunStatus = "finished"
	// RemoteRunCollected: the files were brought back into the local work
	// root and the change-set pipeline took over. Terminal.
	RemoteRunCollected RemoteRunStatus = "collected"
	// RemoteRunFailed: the remote agent errored, the conversation vanished,
	// or the result could not be used. Terminal; Error says why.
	RemoteRunFailed RemoteRunStatus = "failed"
	// RemoteRunCancelled: stopped by the operator (idea cancel / Stop).
	// Terminal.
	RemoteRunCancelled RemoteRunStatus = "cancelled"
)

func (RemoteRunStatus) Terminal added in v0.7.0

func (s RemoteRunStatus) Terminal() bool

Terminal reports whether nothing further will happen to the run: a new attempt of the same task starts a new remote run rather than re-attaching.

func (RemoteRunStatus) Valid added in v0.7.0

func (s RemoteRunStatus) Valid() bool

type Requirement

type Requirement struct {
	ID                 string                `json:"id"`
	InitiativeID       string                `json:"initiative_id"`
	Code               string                `json:"code"`
	Statement          string                `json:"statement"`
	AcceptanceCriteria []AcceptanceCriterion `json:"acceptance_criteria"`
	Priority           RequirementPriority   `json:"priority"`
	Status             RequirementStatus     `json:"status"`
	SourceAssertionID  string                `json:"source_assertion_id,omitempty"`
	Provenance         []ProvenanceRef       `json:"provenance"`
	ProducedByRun      string                `json:"produced_by_run,omitempty"`
	SupersededBy       string                `json:"superseded_by,omitempty"`
	// RevisedAt is set (once) when a revision changes the requirement's
	// statement or acceptance criteria in place (store.UpdateRequirement).
	RevisedAt *time.Time `json:"revised_at,omitempty"`
	// ChangeKind is the derived delta (added/modified/removed), populated at
	// read time by DeriveChangeKind — never a stored column.
	ChangeKind RequirementChangeKind `json:"change_kind,omitempty"`
	VerifiedAt *time.Time            `json:"verified_at,omitempty"`
	// EvidenceTests is the test-run evidence mapped to this requirement (C2,
	// wave 3 contract): every test the verification plan (or a name match on
	// this requirement's code) associates with it, and whether it last passed
	// or failed. Computed at read time by internal/projection from the most
	// recent "tests" check output per change set -- never persisted, so it is
	// always as fresh as the last check run. Nil/empty means no test is known
	// to cover this requirement yet, not that it failed.
	EvidenceTests []EvidenceTest `json:"evidence_tests,omitempty"`
	// ObjectiveIDs are the live objectives this requirement serves
	// (requirement --serves--> objective, N:M). Computed at read time from
	// graph edges by store.ListRequirements -- never nil there, so a
	// requirement serving nothing is `[]`, which is exactly the gap the
	// PRD's deterministic outcome check reports.
	ObjectiveIDs []string  `json:"objective_ids"`
	CreatedAt    time.Time `json:"created_at"`
}

func (Requirement) DeriveChangeKind added in v0.7.0

func (r Requirement) DeriveChangeKind() RequirementChangeKind

DeriveChangeKind reports the requirement's delta relative to a prior revision, derived from its own lifecycle fields: removed wins, then modified (revised in place), else added.

type RequirementChangeKind added in v0.7.0

type RequirementChangeKind string

Requirement is a first-class structured requirement (§17). RequirementChangeKind is the derived delta a requirement represents relative to a prior revision: added (new), modified (revised in place), or removed (superseded/removed). It is computed at read time from the row's own lifecycle, never stored, so it cannot drift from status/SupersededBy.

const (
	RequirementChangeAdded    RequirementChangeKind = "added"
	RequirementChangeModified RequirementChangeKind = "modified"
	RequirementChangeRemoved  RequirementChangeKind = "removed"
)

type RequirementOutcomeDrift added in v0.7.0

type RequirementOutcomeDrift struct {
	RequirementID   string   `json:"requirement_id"`
	RequirementCode string   `json:"requirement_code"`
	ObjectiveID     string   `json:"objective_id"`
	ObjectiveCode   string   `json:"objective_code"`
	MetricCodes     []string `json:"metric_codes"`
	Signal          string   `json:"signal"`
	Detail          string   `json:"detail"`
}

RequirementOutcomeDrift is the "works but fails its objective" signal: a requirement that is verified, serving an active objective whose metrics are off track or regressed.

type RequirementPriority

type RequirementPriority string

RequirementPriority is the requirement priority level.

const (
	PriorityMust   RequirementPriority = "must"
	PriorityShould RequirementPriority = "should"
	PriorityCould  RequirementPriority = "could"
)

func (RequirementPriority) Valid

func (p RequirementPriority) Valid() bool

type RequirementStatus

type RequirementStatus string

RequirementStatus is the lifecycle of a Requirement (§17).

const (
	RequirementDraft    RequirementStatus = "draft"
	RequirementApproved RequirementStatus = "approved"
	RequirementVerified RequirementStatus = "verified"
	// RequirementFailed records a human "fail" judgment: the requirement stays in
	// the active set and blocks completion until re-verified (a human pass).
	RequirementFailed RequirementStatus = "failed"
	// RequirementWaived records a human "waive" judgment: the requirement is out
	// of scope and is excluded from the completion gate (like removed), but is
	// retained as a visible, recorded judgment rather than deleted.
	RequirementWaived  RequirementStatus = "waived"
	RequirementRemoved RequirementStatus = "removed"
)

func (RequirementStatus) Valid

func (s RequirementStatus) Valid() bool

type ReviewTelemetry added in v0.7.0

type ReviewTelemetry struct {
	// Review is which review loop this is: "prd" or "execution_plan".
	Review string `json:"review"`
	Cycle  int    `json:"cycle"`
	// Mode is review.convergence.mode as it ran: "guarded" or "legacy".
	Mode  string `json:"mode"`
	Rigor string `json:"rigor,omitempty"`

	Raised   map[Severity]int `json:"raised,omitempty"`
	New      map[Severity]int `json:"new,omitempty"`
	ReRaised map[Severity]int `json:"reraised,omitempty"`
	Resolved map[Severity]int `json:"resolved,omitempty"`
	Demoted  map[string]int   `json:"demoted,omitempty"`

	// Deterministic is the number of gating deterministic-check findings
	// (duplicate code, missing/vague criterion, plan structure) this cycle.
	Deterministic int `json:"deterministic"`
	// OpenBlocking is every finding still gating approval after this cycle's
	// rules ran, deterministic ones included. PrevOpenBlocking is the same
	// figure for the previous cycle of the same loop, -1 on a loop's first
	// cycle -- the pair is what the stall detector compares.
	OpenBlocking     int `json:"open_blocking"`
	PrevOpenBlocking int `json:"prev_open_blocking"`
	// Outcome is what the loop did next: "converged", "revise", "stalled"
	// (the open blocking count stopped decreasing), "max_cycles", or
	// "blocked" (a single-pass review, e.g. the plan's, that parked).
	Outcome string `json:"outcome"`
}

ReviewTelemetry is one review cycle's convergence record, persisted on the adversarial reviewer's run manifest (RunManifest.Review). It exists because the PRD review loop used to be a black box: "did not converge" was the only output, and nothing distinguished a reviewer that kept finding genuinely new problems from one that kept rephrasing the same three -- which is the difference between a loop that needs a human and one that needs a fix.

Counts are per severity (critical/high/medium/low/observation). Raised is every adversarial finding this cycle produced; New and ReRaised partition it against the previous cycle's gating findings; Resolved counts previous-cycle gating findings this cycle did NOT re-raise. Demoted counts findings made advisory by a convergence rule, keyed by the rule.

type RiskProfile

type RiskProfile struct {
	ID           string       `json:"id"`
	InitiativeID string       `json:"initiative_id"`
	Tier         RiskTier     `json:"tier"`
	Signals      []RiskSignal `json:"signals"`
	Reason       []string     `json:"reason,omitempty"`
	CreatedAt    time.Time    `json:"created_at"`
}

RiskProfile is a coarse risk tiering for an initiative (§31).

type RiskSignal

type RiskSignal struct {
	Name     string `json:"name"`
	Detected bool   `json:"detected"`
	Detail   string `json:"detail,omitempty"`
}

RiskSignal is one deterministic security signal (§31).

type RiskTier

type RiskTier string

RiskTier is a coarse risk tier (§31); no numeric scores.

const (
	RiskLow      RiskTier = "low"
	RiskMedium   RiskTier = "medium"
	RiskHigh     RiskTier = "high"
	RiskCritical RiskTier = "critical"
)

func (RiskTier) Valid

func (t RiskTier) Valid() bool

type RunEvent added in v0.7.0

type RunEvent struct {
	Seq          int64        `json:"seq"`
	RunID        string       `json:"run_id"`
	OperationID  string       `json:"operation_id,omitempty"`
	InitiativeID string       `json:"initiative_id,omitempty"`
	TaskID       string       `json:"task_id,omitempty"`
	Executor     string       `json:"executor,omitempty"`
	At           time.Time    `json:"at"`
	Kind         RunEventKind `json:"kind"`
	// Source is who the event came from: "agent" (the coding agent itself),
	// "harness" (the executor or engine: phases, file scans, the final
	// diff) or "user" (a steering note).
	Source string `json:"source,omitempty"`
	// Title is the one-line summary the run view shows ("Edit src/x.ts",
	// "npm test exited 1").
	Title string `json:"title"`
	// Detail is the longer text, when there is any: an agent message, a
	// command, an error. Bounded to RunEventDetailMax.
	Detail string `json:"detail,omitempty"`
	// Path is the work-root-relative file the event is about, when it is
	// about one.
	Path string `json:"path,omitempty"`
	// ToolCallID ties a tool_call to its tool_result(s) and permissions.
	ToolCallID string `json:"tool_call_id,omitempty"`
	// ToolKind is the tool's category as the agent reported it (ACP's
	// read|edit|delete|move|search|execute|think|fetch|other, or an
	// OpenHands tool name).
	ToolKind string `json:"tool_kind,omitempty"`
	// Status is the tool call's state (pending|in_progress|completed|
	// failed), a permission's decision, a steering note's delivery, or a
	// status event's lifecycle state.
	Status string `json:"status,omitempty"`
	// Added/Removed are line counts on an authoritative file_change.
	Added   int `json:"added,omitempty"`
	Removed int `json:"removed,omitempty"`
	// Token and cost DELTAS on a cost event (not running totals).
	InputTokens  int64   `json:"input_tokens,omitempty"`
	OutputTokens int64   `json:"output_tokens,omitempty"`
	CostUSD      float64 `json:"cost_usd,omitempty"`
	// ChangeSetID is set on the status event that ends a run which produced
	// a change set: the run's result, for the run view and report to link.
	ChangeSetID string `json:"change_set_id,omitempty"`
	Truncated   bool   `json:"truncated,omitempty"`
}

RunEvent is one normalized step of a running coding agent, whichever executor ran it: an ACP session/update, an OpenHands Agent Server event, a line of a CLI agent's output, a file the agent wrote. Every executor maps its own vocabulary onto this one so the run view, the report and any client read one shape.

Seq is monotonic per run (1, 2, 3, ...) and is the resume cursor: a client that has seen seq N asks for the events after N and gets only those. Text fields are redacted before an event is stored, and bounded (see RunEventTitleMax/RunEventDetailMax); Truncated says a field was cut.

func (RunEvent) Bounded added in v0.7.0

func (e RunEvent) Bounded() RunEvent

Bounded returns the event with its text fields cut to the limits above (on a rune boundary), Truncated set when anything was cut, and an invalid kind coerced to action so a mapping bug cannot store an event no client knows.

func (RunEvent) Redacted added in v0.7.0

func (e RunEvent) Redacted(redact func(string) string) RunEvent

Redacted returns the event with every free-text field passed through redact. Kind, ids, counts and the timestamp are structural and kept.

type RunEventKind added in v0.7.0

type RunEventKind string

RunEventKind is the vocabulary of a normalized run event (RunEvent): what one step of a running coding agent was, independent of which executor produced it. Clients switch on it to group tool calls, list files, show the current action and surface errors.

const (
	// RunEventAction is a coarse step with no finer structure: a line of a
	// CLI agent's output, an executor phase.
	RunEventAction RunEventKind = "action"
	// RunEventToolCall is the agent starting a tool call (ACP tool_call, an
	// OpenHands ActionEvent). Its ToolCallID groups the later results.
	RunEventToolCall RunEventKind = "tool_call"
	// RunEventToolResult is a tool call's progress or outcome (ACP
	// tool_call_update, an OpenHands ObservationEvent).
	RunEventToolResult RunEventKind = "tool_result"
	// RunEventFileChange is a file the agent wrote: live from an fs write, a
	// file-editing tool or a work-root scan, and authoritative (with line
	// counts) from the orchestrator's own diff once the agent has finished.
	RunEventFileChange RunEventKind = "file_change"
	// RunEventPermission is a permission request an ACP agent made and the
	// answer the harness gave on the operator's behalf.
	RunEventPermission RunEventKind = "permission"
	// RunEventMessage is text: the agent's own message, or a steering note
	// from the human (Source "user").
	RunEventMessage RunEventKind = "message"
	// RunEventThought marks that the agent is reasoning. The content is never
	// kept (§50: chain-of-thought is not exposed) -- only the fact.
	RunEventThought RunEventKind = "thought"
	// RunEventCost is a token/cost delta the agent or server reported.
	RunEventCost RunEventKind = "cost"
	// RunEventStatus is a lifecycle change: started, a phase, finished.
	RunEventStatus RunEventKind = "status"
	// RunEventError is a failure the agent or the executor reported.
	RunEventError RunEventKind = "error"
)

func (RunEventKind) Valid added in v0.7.0

func (k RunEventKind) Valid() bool

type RunKind

type RunKind string

RunKind discriminates the generic Run model (§35).

const (
	RunModel  RunKind = "model"
	RunReview RunKind = "review"
	RunCheck  RunKind = "check"
	RunTool   RunKind = "tool"
	RunAgent  RunKind = "agent"
)

func (RunKind) Valid

func (k RunKind) Valid() bool

type RunManifest

type RunManifest struct {
	ID             string            `json:"id"`
	RunID          string            `json:"run_id"`
	SnapshotDigest string            `json:"snapshot_digest,omitempty"`
	ConfigDigest   string            `json:"config_digest,omitempty"`
	WorkflowDigest string            `json:"workflow_digest,omitempty"`
	RoleVersion    string            `json:"role_version,omitempty"`
	RequestedModel string            `json:"requested_model"`
	ActualModel    string            `json:"actual_model"`
	ContextDigest  string            `json:"context_digest,omitempty"`
	SkillDigests   []string          `json:"skill_digests,omitempty"`
	ToolVersions   map[string]string `json:"tool_versions,omitempty"`
	Usage          RunUsage          `json:"usage"`
	ResultDigest   string            `json:"result_digest,omitempty"`
	StartedAt      time.Time         `json:"started_at"`
	FinishedAt     time.Time         `json:"finished_at"`
	// Executor is set on coding-agent (implementer) runs only.
	Executor *ExecutorProvenance `json:"executor,omitempty"`
	// Review is the convergence record of the review cycle this run was the
	// adversarial reviewer for (nil on every other run). Written after the
	// manifest itself, once the cycle's rules have run -- see
	// store.SetRunManifestReview.
	Review *ReviewTelemetry `json:"review,omitempty"`
}

RunManifest records immutable provenance for a Run (§36).

type RunStatus

type RunStatus string

RunStatus is the lifecycle of a Run.

const (
	RunPending   RunStatus = "pending"
	RunRunning   RunStatus = "running"
	RunSucceeded RunStatus = "succeeded"
	RunFailed    RunStatus = "failed"
)

func (RunStatus) Valid

func (s RunStatus) Valid() bool

type RunUsage

type RunUsage struct {
	InputTokens  int64   `json:"input_tokens,omitempty"`
	OutputTokens int64   `json:"output_tokens,omitempty"`
	CostUSD      float64 `json:"cost_usd,omitempty"`
	DurationMS   int64   `json:"duration_ms,omitempty"`
}

RunUsage records token/cost/duration for a run (§17, §36).

type SandboxMode

type SandboxMode string

SandboxMode is the OS-level sandbox mode (§52).

const (
	SandboxContainer       SandboxMode = "container"
	SandboxLocalRestricted SandboxMode = "local_restricted"
	SandboxHostApproved    SandboxMode = "host_approved"
	// SandboxRemote: the agent runs on another machine (the openhands kind's
	// Agent Server), inside whatever sandbox that server provides. The
	// harness cannot inspect or enforce it, so it does not claim "container"
	// for it -- what it does enforce is on the way back: the returned files
	// go through the same snapshot, diff, secret sweep and review as any
	// local agent's (docs/security-model.md).
	SandboxRemote SandboxMode = "remote"
)

func (SandboxMode) Valid

func (m SandboxMode) Valid() bool

type SecretAllowlistEntry added in v0.6.0

type SecretAllowlistEntry struct {
	ID          string    `json:"id"`
	Fingerprint string    `json:"fingerprint"`
	Kind        string    `json:"kind"`
	Path        string    `json:"path"`
	Actor       string    `json:"actor"`
	CreatedAt   time.Time `json:"created_at"`
}

SecretAllowlistEntry is a human "not a secret" disposition on a detected credential pattern match, scoped to one project (review changes #1). The fingerprint is the sha256 of the matched value's capture group -- never the raw value -- so the sweep can recognise the same false positive again without ever having stored the secret it decided wasn't one.

type Severity

type Severity string

Severity is the review-finding severity (§15).

const (
	SeverityCritical    Severity = "critical"
	SeverityHigh        Severity = "high"
	SeverityMedium      Severity = "medium"
	SeverityLow         Severity = "low"
	SeverityObservation Severity = "observation"
)

func (Severity) AtLeast added in v0.7.0

func (s Severity) AtLeast(min Severity) bool

AtLeast reports whether s is at least as severe as min.

func (Severity) Blocking

func (s Severity) Blocking() bool

Blocking reports whether an open finding of this severity blocks approval (§11).

func (Severity) Valid

func (s Severity) Valid() bool

type StaleItem added in v0.6.0

type StaleItem struct {
	ID           string     `json:"id"`
	InitiativeID string     `json:"initiative_id"`
	TargetType   string     `json:"target_type"`
	TargetID     string     `json:"target_id"`
	Reason       string     `json:"reason"`
	DecisionID   string     `json:"decision_id,omitempty"`
	CreatedAt    time.Time  `json:"created_at"`
	ClearedAt    *time.Time `json:"cleared_at,omitempty"`
	ClearedBy    string     `json:"cleared_by,omitempty"`
}

StaleItem marks a graph node whose validity is in question because a decided decision it (transitively) depends on stopped being decided after the node was produced or applied (§26, review A4 #5: "impact is true"). TargetType is one of "requirement", "task" or "change_set". Cleared either by re-planning (which re-derives the plan from the live decision state) or by an explicit human acknowledgement.

type SteeringNote added in v0.7.0

type SteeringNote struct {
	At       time.Time `json:"at"`
	Note     string    `json:"note"`
	Delivery string    `json:"delivery"`
}

SteeringNote is a note a human sent to a running agent, recorded on the run manifest (ExecutorProvenance.Steering) and as a message event. Delivery says what became of it: "delivered" (the agent received it now), "queued" (it is sent as the agent's next prompt turn when the current one ends) or "next_run" (the executor cannot be steered; it rides on the task's next run, like the rerun note on execute).

type SuggestedAnswer

type SuggestedAnswer struct {
	QuestionID string `json:"question_id"`
	Question   string `json:"question"`
	Answer     string `json:"answer"`
}

SuggestedAnswer is one AI-proposed answer to an open question.

type Task

type Task struct {
	ID            string              `json:"id"`
	InitiativeID  string              `json:"initiative_id"`
	Code          string              `json:"code"`
	Title         string              `json:"title"`
	Statement     string              `json:"statement"`
	Status        TaskStatus          `json:"status"`
	Priority      RequirementPriority `json:"priority"`
	Estimate      string              `json:"estimate,omitempty"`
	ProducedByRun string              `json:"produced_by_run,omitempty"`
	SupersededBy  string              `json:"superseded_by,omitempty"`
	// RequirementIDs is the requirement graph edges this task implements
	// (N:M, review A4 #3/#4) and DependsOn the task ids it depends on.
	// Computed at read time from graph_edges, not a stored column -- always
	// populated by the handler before the response is written, never nil
	// (an empty task has both as `[]`, not `null`).
	RequirementIDs []string  `json:"requirement_ids"`
	DependsOn      []string  `json:"depends_on"`
	CreatedAt      time.Time `json:"created_at"`
}

Task is one unit of the execution plan (§12, M2).

type TaskStatus

type TaskStatus string

TaskStatus is the lifecycle of an execution-plan Task.

const (
	TaskProposed  TaskStatus = "proposed"
	TaskReady     TaskStatus = "ready"
	TaskBlocked   TaskStatus = "blocked"
	TaskDone      TaskStatus = "done"
	TaskCancelled TaskStatus = "cancelled"
)

func (TaskStatus) Valid

func (s TaskStatus) Valid() bool

type TimelineEntry added in v0.6.0

type TimelineEntry struct {
	At     time.Time   `json:"at"`
	Kind   string      `json:"kind"`
	Title  string      `json:"title"`
	Detail string      `json:"detail,omitempty"`
	Ref    TimelineRef `json:"ref"`
}

TimelineEntry is one human-language line of an initiative's "what changed" timeline (C1, wave 3 contract), newest first. Kind is one of change_set_applied, change_set_rejected, change_set_denied, change_set_reverted, run_failed, run_stopped, decision_changed, stale, phase_completed.

type TimelineRef added in v0.6.0

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

TimelineRef points a TimelineEntry at the entity it is about, so a client can link to it without parsing the human title.

type TrustLevel

type TrustLevel string

TrustLevel is the context trust level (§38). It is assigned by deterministic code, never by model output.

const (
	TrustSystem                TrustLevel = "system"
	TrustPolicy                TrustLevel = "policy"
	TrustHumanApproved         TrustLevel = "human_approved"
	TrustReviewedAgentOutput   TrustLevel = "reviewed_agent_output"
	TrustUnreviewedAgentOutput TrustLevel = "unreviewed_agent_output"
	TrustExternalUntrusted     TrustLevel = "external_untrusted"
)

func (TrustLevel) Valid

func (t TrustLevel) Valid() bool

type VerificationEvidence

type VerificationEvidence struct {
	ID             string             `json:"id"`
	InitiativeID   string             `json:"initiative_id"`
	RequirementID  string             `json:"requirement_id"`
	CriterionKey   string             `json:"criterion_key"`
	Kind           VerificationKind   `json:"kind"`
	Status         VerificationStatus `json:"status"`
	EvidenceDigest string             `json:"evidence_digest,omitempty"`
	RunID          string             `json:"run_id,omitempty"`
	VerifiedBy     string             `json:"verified_by,omitempty"` // role name or "human:<actor>"
	Note           string             `json:"note,omitempty"`
	CreatedAt      time.Time          `json:"created_at"`
}

VerificationEvidence is one piece of evidence for an acceptance criterion (§70). CriterionKey is a stable per-criterion key (see CriterionKey). A requirement is verified only when every mandatory criterion has a pass evidence — never merely because tests exist.

type VerificationKind

type VerificationKind string

VerificationKind is the evidence category for a verification (§70).

const (
	VerificationAcceptance VerificationKind = "acceptance"
	VerificationSecurity   VerificationKind = "security"
	VerificationUX         VerificationKind = "ux"
)

func (VerificationKind) Valid

func (k VerificationKind) Valid() bool

type VerificationStatus

type VerificationStatus string

VerificationStatus is the outcome of one piece of evidence (§70).

const (
	VerificationPass        VerificationStatus = "pass"
	VerificationFail        VerificationStatus = "fail"
	VerificationBlocked     VerificationStatus = "blocked"
	VerificationNeedsManual VerificationStatus = "needs_manual"
	// VerificationWaived records a human waiver judgment at evidence level (the
	// corresponding requirement is marked waived, not verified).
	VerificationWaived VerificationStatus = "waived"
)

func (VerificationStatus) Valid

func (s VerificationStatus) Valid() bool

Jump to

Keyboard shortcuts

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