Documentation
¶
Overview ¶
Package daemon implements the localhost control-plane HTTP server (§28–§29): token-authenticated, project-scoped REST + SSE over one user-level daemon.
Index ¶
- Constants
- func DaemonConfigPath(stateRoot string) string
- func DefaultStateRoot() string
- func Run(addr, stateRoot string, log *slog.Logger, onReady func()) error
- func RunWith(addr, stateRoot string, log *slog.Logger, onReady func(), ...) error
- func SetEvalRunner(fn EvalRunner)
- func WriteDaemonConfig(stateRoot string, c DaemonConfig) error
- type AutomationView
- type ConfirmResult
- type ConfirmSkipped
- type DaemonConfig
- type Duration
- type EvalRequest
- type EvalResult
- type EvalRunner
- type ExecutorCompat
- type ExecutorConfigView
- type InitiativeDocInput
- type IntegrationStatus
- type ListenPlan
- type PreconditionError
- type ProjectBudgetRow
- type RunStats
- type Runtime
- func (r *Runtime) AdvanceInitiative(ctx context.Context, projectID, initiativeID string) (string, error)
- func (r *Runtime) ApplyChangeSetInitiative(ctx context.Context, projectID, initiativeID, changeSetID string) (string, error)
- func (r *Runtime) ApproveInitiative(ctx context.Context, projectID, initiativeID string) (domain.InitiativeStatus, error)
- func (r *Runtime) ApprovePlanInitiative(ctx context.Context, projectID, initiativeID string) (string, error)
- func (r *Runtime) CancelOperation(ctx context.Context, opID string) error
- func (r *Runtime) CaptureInitiative(ctx context.Context, token, brief string) (string, error)
- func (r *Runtime) Close() error
- func (r *Runtime) CreatePRForInitiative(ctx context.Context, projectID, initiativeID string) (string, error)
- func (r *Runtime) CreateProject(ctx context.Context, rootPath string) (string, error)
- func (r *Runtime) EnsureProject(ctx context.Context, projectID string) (*projectRuntime, error)
- func (r *Runtime) ExecuteInitiative(ctx context.Context, projectID, initiativeID string) (string, error)
- func (r *Runtime) ExecuteInitiativeFresh(ctx context.Context, projectID, initiativeID string, fresh bool) (string, error)
- func (r *Runtime) ExecuteInitiativeFreshWithNote(ctx context.Context, projectID, initiativeID string, fresh bool, note string) (string, error)
- func (r *Runtime) InitiativeRunStats(ctx context.Context, projectID, initiativeID string) (RunStats, []domain.ReviewTelemetry, error)
- func (r *Runtime) ListCaptureTokens(ctx context.Context, projectID string) ([]store.CaptureToken, error)
- func (r *Runtime) ListProjects(ctx context.Context) ([]store.ProjectRecord, error)
- func (r *Runtime) MeasureQualityInitiative(ctx context.Context, projectID, initiativeID string) (string, error)
- func (r *Runtime) MintCaptureToken(ctx context.Context, projectID, label string) (string, error)
- func (r *Runtime) PRChecksForChangeSet(ctx context.Context, projectID, changeSetID string) (git.PRChecksResult, error)
- func (r *Runtime) RegisterProvider(name string, p model.Provider)
- func (r *Runtime) ReloadProject(ctx context.Context, projectID string) (*projectRuntime, error)
- func (r *Runtime) ReopenPhaseInitiative(ctx context.Context, projectID, initiativeID, phase string) (string, error)
- func (r *Runtime) RerunChangeSetReviewInitiative(ctx context.Context, projectID, initiativeID, changeSetID string) (string, error)
- func (r *Runtime) ResumeInitiative(ctx context.Context, projectID, initiativeID string) (domain.InitiativeStatus, error)
- func (r *Runtime) RetryConflictedApply(ctx context.Context, projectID, initiativeID, changeSetID string) (string, error)
- func (r *Runtime) RetryInitiative(ctx context.Context, projectID, initiativeID, model string) (string, error)
- func (r *Runtime) RetryInitiativeWithNote(ctx context.Context, projectID, initiativeID, model, note string) (string, error)
- func (r *Runtime) RevertChangeSetInitiative(ctx context.Context, projectID, initiativeID, changeSetID string) (string, error)
- func (r *Runtime) ReviseInitiative(ctx context.Context, projectID, initiativeID string) (string, error)
- func (r *Runtime) RevisePlanInitiative(ctx context.Context, projectID, initiativeID string) (string, error)
- func (r *Runtime) RevisePlanInitiativeWithNote(ctx context.Context, projectID, initiativeID, note string) (string, error)
- func (r *Runtime) RunVerificationGate(ctx context.Context, projectID, initiativeID, requirement string, ...) (domain.InitiativeStatus, []workflow.Coverage, error)
- func (r *Runtime) RunVerificationGateConfirmingTests(ctx context.Context, projectID, initiativeID, requirement string, ...) (domain.InitiativeStatus, []workflow.Coverage, *ConfirmResult, error)
- func (r *Runtime) Shutdown(ctx context.Context) error
- func (r *Runtime) StartDraftInitiative(ctx context.Context, projectID, initiativeID string) (string, error)
- func (r *Runtime) StartInitiative(ctx context.Context, projectID, title, description string) (string, string, error)
- func (r *Runtime) StartInitiativeWithDocs(ctx context.Context, projectID, title, description string, ...) (string, string, error)
- func (r *Runtime) StateRoot() string
- func (r *Runtime) SuggestAnswersInitiative(ctx context.Context, projectID, initiativeID string) (string, error)
- func (r *Runtime) Token() string
- type Server
Constants ¶
const ( AutomationLinearInbound = "linear_inbound" AutomationMetricMeasurement = "metric_measurement" AutomationEval = "eval" )
Automation names.
Variables ¶
This section is empty.
Functions ¶
func DaemonConfigPath ¶ added in v0.7.0
DaemonConfigPath is where the daemon config lives under a state root.
func DefaultStateRoot ¶
func DefaultStateRoot() string
DefaultStateRoot returns the global state directory (§30), overridable via IDEA_HARNESS_STATE for tests.
func Run ¶
Run starts the daemon HTTP server on addr (loopback) and blocks until the server exits. onReady, if set, runs once this process owns the address and the state directory -- the point at which it is THE daemon -- and is where the caller records its pid.
func RunWith ¶ added in v0.7.0
func RunWith(addr, stateRoot string, log *slog.Logger, onReady func(), override func(*DaemonConfig)) error
RunWith is Run with the daemon config (<stateRoot>/config.yaml) adjusted by override first -- `idea daemon --listen ...` flags win over the file.
func SetEvalRunner ¶ added in v0.7.0
func SetEvalRunner(fn EvalRunner)
SetEvalRunner registers the eval implementation the scheduled eval job uses. Without one (a test binary, an embedder) the job reports itself unavailable rather than pretending to run.
func WriteDaemonConfig ¶ added in v0.7.0
func WriteDaemonConfig(stateRoot string, c DaemonConfig) error
WriteDaemonConfig writes <stateRoot>/config.yaml with the `daemon:` section. It is the single write path for the daemon-wide config, mirroring LoadDaemonConfig: the same file, the same shape, 0600.
Types ¶
type AutomationView ¶ added in v0.7.0
type AutomationView struct {
Name string `json:"name"`
Label string `json:"label"`
Description string `json:"description"`
Enabled bool `json:"enabled"`
// Available is false when the job cannot run at all right now, with
// Unavailable saying why (Linear not configured, no eval model, ...).
Available bool `json:"available"`
// Schedule is the cadence in words.
Schedule string `json:"schedule"`
Running bool `json:"running"`
LastRun *store.AutomationRun `json:"last_run"`
NextRunAt *time.Time `json:"next_run_at"`
// Settings are the job's own harness.yaml fields (eval only).
Settings *config.EvalAutomationConfig `json:"settings,omitempty"`
// Targets are the metrics the measurement job covers.
Targets []metricTarget `json:"targets,omitempty"`
History []store.AutomationRun `json:"history"`
Note string `json:"note,omitempty"`
}
AutomationView is one job in GET .../automations.
type ConfirmResult ¶ added in v0.6.0
type ConfirmResult struct {
Confirmed []string `json:"confirmed"`
Skipped []ConfirmSkipped `json:"skipped"`
}
ConfirmResult reports what confirmPassingTests did (C3/H2, review fix): which requirement codes it actually confirmed, and which candidates it looked at but skipped, and why -- so a bad requirement never aborts the whole loop silently, and the caller (the HTTP handler, in turn the UI's confirm dialog) can show exactly what happened instead of a bare status.
type ConfirmSkipped ¶ added in v0.6.0
type ConfirmSkipped struct {
Requirement string `json:"requirement"`
Reason string `json:"reason"`
}
ConfirmSkipped names one requirement confirmPassingTests looked at but did not confirm, and why.
type DaemonConfig ¶ added in v0.7.0
type DaemonConfig struct {
// Listen is an extra, non-loopback address to serve on ("100.101.1.2:8787").
// Empty: loopback only.
Listen string `yaml:"listen"`
// TLSCert/TLSKey serve Listen over HTTPS. Both or neither.
TLSCert string `yaml:"tls_cert"`
TLSKey string `yaml:"tls_key"`
// AllowedHosts are extra hostnames the Host/Origin guard accepts -- the
// name a browser uses to reach this daemon through a proxy
// (`laptop.tailnet-1234.ts.net` under `tailscale serve`).
AllowedHosts []string `yaml:"allowed_hosts"`
// SessionTTL bounds a browser session's absolute lifetime. Default 30 days.
SessionTTL Duration `yaml:"session_ttl"`
// PushContact is the VAPID `sub` claim push services may use to reach
// whoever runs this daemon (mailto: or https:). Default: the project page.
PushContact string `yaml:"push_contact"`
}
DaemonConfig is the daemon-wide configuration: <state root>/config.yaml, section `daemon:`. Daemon-wide rather than per project because there is one daemon, one listener and one token for every project it serves -- harness.yaml is the wrong home for any of them.
func LoadDaemonConfig ¶ added in v0.7.0
func LoadDaemonConfig(stateRoot string) (DaemonConfig, error)
LoadDaemonConfig reads <stateRoot>/config.yaml. A missing file is the default config (loopback only); a malformed one is an error, because a typo in `listen` silently meaning "loopback only" would be confusing and a typo in `allowed_hosts` silently widening nothing is fine -- but neither should be guessed at.
type Duration ¶ added in v0.7.0
Duration is a time.Duration that unmarshals from "720h"-style YAML.
func (Duration) MarshalYAML ¶ added in v0.7.0
MarshalYAML writes the duration in its Go string form ("720h"), the form UnmarshalYAML reads back, so a config round-trip is lossless.
type EvalRequest ¶ added in v0.7.0
type EvalRequest struct {
ProjectRoot string
Model string
// Suite is a path relative to ProjectRoot; empty is the built-in suite.
Suite string
Cases []string
// MaxCostUSD caps the run; always > 0.
MaxCostUSD float64
// Baseline is a report to compare with (absolute path), or "".
Baseline string
// ReportDir is where the runner writes <stamp>.json and <stamp>.md.
ReportDir string
Stamp string
}
EvalRequest is one scheduled (or "Run now") eval run, as the daemon hands it to the registered EvalRunner.
type EvalResult ¶ added in v0.7.0
type EvalResult struct {
CostUSD float64
Summary string
Regressions []string
ReportPath string
StoppedAtCap bool
}
EvalResult is what an eval run found.
type EvalRunner ¶ added in v0.7.0
type EvalRunner func(ctx context.Context, req EvalRequest) (EvalResult, error)
EvalRunner runs one eval. internal/eval implements it; it is injected because that package drives a daemon in-process and so imports this one.
type ExecutorCompat ¶ added in v0.7.0
type ExecutorCompat struct {
Kind string `json:"kind"`
Model string `json:"model"`
Blocked bool `json:"blocked"`
Message string `json:"message"`
}
ExecutorCompat is one compatibility advisory.
type ExecutorConfigView ¶ added in v0.7.0
type ExecutorConfigView struct {
Config config.ExecutorConfig `json:"config"`
// MaxParallel is execute.max_parallel as it is enforced (<=0 -> 1), for the
// Settings editor alongside the executor block.
MaxParallel int `json:"max_parallel"`
// Compat is the executor/model compatibility advisory for the kind and
// model asked about (?kind=&model=, defaulting to the saved ones):
// blocked (known to fail every run, refused at execute) or untested.
// Null when the combination is verified or there is nothing to say.
Compat *ExecutorCompat `json:"compat"`
// Env maps every environment variable the executor block names -- the
// OpenHands session key, each MCP value_env -- to whether it is set in
// the daemon's environment or the project's .env. Never a value.
Env map[string]bool `json:"env"`
// Problems are the configuration findings about the executor block.
Problems []config.Problem `json:"problems"`
}
ExecutorConfigView is GET .../executors/config: the whole executor block as harness.yaml holds it, for the Settings editor -- GET .../executors lists kinds and readiness but only the kind/image/model fields of the config.
type InitiativeDocInput ¶
type InitiativeDocInput struct {
Content string
Kind string
Title string
Data []byte
Filename string
}
InitiativeDocInput is one context doc supplied atomically at initiative creation (idea new --doc). Exactly one of Content (extracted text) or Data (raw image bytes) is set: text/extractable docs carry Content, image docs carry Data + Filename.
type IntegrationStatus ¶ added in v0.7.0
type IntegrationStatus struct {
Name string `json:"name"`
Configured bool `json:"configured"`
// Active is true when the integration is running: configured, and the
// token it cannot work without is present.
Active bool `json:"active"`
// Tokens maps each environment variable the integration reads to
// whether it is set. Never the value.
Tokens map[string]bool `json:"tokens,omitempty"`
Problems []string `json:"problems"`
Outbox *store.OutboxStats `json:"outbox,omitempty"`
IngestError string `json:"ingest_error,omitempty"`
Socket *slack.SocketState `json:"socket,omitempty"`
Poll *linear.PollState `json:"poll,omitempty"`
// LinkedIssues counts Linear issues linked to initiatives and tasks.
LinkedIssues int `json:"linked_issues,omitempty"`
// Config is the integration's harness.yaml section as written (null when
// not configured), for the Settings editor. It holds environment
// variable NAMES only; Tokens says whether each is set.
Config any `json:"config"`
// TokenEnvs names the variables the integration reads (defaults
// applied), so an unconfigured integration's editor can say which ones
// it will need.
TokenEnvs []string `json:"token_envs"`
}
IntegrationStatus is one integration's health (GET .../integrations).
type ListenPlan ¶ added in v0.7.0
type ListenPlan struct {
Addr string
TLS *tls.Config
// Warning is logged, loudly, at startup.
Warning string
// contains filtered or unexported fields
}
ListenPlan is a validated daemon.listen.
type PreconditionError ¶
type PreconditionError struct {
Reason string
}
PreconditionError marks an error as the caller asking for something the current state does not allow -- "initiative is already running", "advance requires an approved PRD". It exists so writeErr can answer 409 without each handler remembering to.
The audit found handleAdvance and handleRevise mapping every error to 500, including those two, while their four siblings -- retry, approve-plan, reopen-phase, revise-plan -- returned 409 for the identical class. Hand-mapping a sixth handler would have left the seventh to get it wrong; this makes the classification travel with the error instead.
Deliberately narrow. Only Runtime.* precondition checks return this type, never internal/workflow. Handler call sites pass http.StatusBadRequest for engine errors; retyping an error those paths can surface would silently flip a 400 into a 409, so the type is applied to an enumerated set and TestPrecondition pins both halves.
Runtime.RunVerificationGate joined that set when `idea verify` stopped being able to complete a failed initiative. Note what did and did not change: Engine.VerifyInitiative's own errors still reach writeErr as plain errors and still answer 400. What carries this type is the Runtime's own read of the status, and the translation of store.ErrInitiativeNotClaimable, both of which are preconditions on the request rather than failures inside the gate.
func (*PreconditionError) Error ¶
func (e *PreconditionError) Error() string
type ProjectBudgetRow ¶ added in v0.7.0
type ProjectBudgetRow struct {
InitiativeID string `json:"initiative_id"`
Title string `json:"title"`
Status string `json:"status"`
Budget workflow.BudgetStatus `json:"budget"`
}
ProjectBudgetRow is one initiative on the project budget overview.
type RunStats ¶ added in v0.7.0
type RunStats struct {
Calls int `json:"calls"`
InputTokens int64 `json:"input_tokens"`
OutputTokens int64 `json:"output_tokens"`
CostUSD float64 `json:"cost_usd"`
}
RunStats is an initiative's model usage, summed over every run manifest.
type Runtime ¶
type Runtime struct {
// contains filtered or unexported fields
}
Runtime owns the global registry, the per-install token, and lazily-opened per-project runtimes.
func NewRuntime ¶
NewRuntime opens (creating if needed) the global state and token.
func (*Runtime) AdvanceInitiative ¶
func (r *Runtime) AdvanceInitiative(ctx context.Context, projectID, initiativeID string) (string, error)
AdvanceInitiative runs the M2 slice (Design → Execution Plan → plan review) asynchronously. Returns the operation id.
func (*Runtime) ApplyChangeSetInitiative ¶
func (r *Runtime) ApplyChangeSetInitiative(ctx context.Context, projectID, initiativeID, changeSetID string) (string, error)
ApplyChangeSetInitiative applies an approved change set asynchronously.
func (*Runtime) ApproveInitiative ¶ added in v0.4.0
func (r *Runtime) ApproveInitiative(ctx context.Context, projectID, initiativeID string) (domain.InitiativeStatus, error)
ApproveInitiative records human approval of the reviewed PRD.
A Runtime wrapper rather than a direct engine call from the handler, and that is deliberate: preconditionf is what writeErr turns into a 409, and it is also what `make api-check`'s conflict axis scans for. Calling the engine straight from the handler and mapping the error to 409 there would have produced the right status code and a spec that silently never declared it -- the checker only sees preconditionf inside Runtime methods.
func (*Runtime) ApprovePlanInitiative ¶
func (r *Runtime) ApprovePlanInitiative(ctx context.Context, projectID, initiativeID string) (string, error)
ApprovePlanInitiative accepts the execution plan, findings and all.
func (*Runtime) CancelOperation ¶
CancelOperation interrupts a running asynchronous operation (M3, §16): it cancels the operation's context so the in-flight model/command call unwinds, and marks the operation cancelled so callers observe the terminal state immediately. Returns an error when no live handle exists (already settled or orphaned after a daemon restart).
func (*Runtime) CaptureInitiative ¶ added in v0.7.0
CaptureInitiative creates a draft initiative from a brief, authorised by the capture token alone (the unauthenticated route). The pipeline does NOT start: the draft waits for a human to open it and press Start.
func (*Runtime) CreatePRForInitiative ¶ added in v0.6.0
func (r *Runtime) CreatePRForInitiative(ctx context.Context, projectID, initiativeID string) (string, error)
CreatePRForInitiative pushes the initiative's dedicated branch and opens a pull request via `gh pr create` (review C4 piece 3), synchronously: unlike apply/execute/revert it neither claims the initiative nor mutates the workspace tree, only git/GitHub state, so there is no long-running pipeline to run as a background operation. The three ways this can be refused -- no dedicated branch yet, `gh` not installed, or (PRChecksForChangeSet only) no PR yet -- are classified here as preconditions, never inside internal/workflow (see PreconditionError's doc comment), so a caller answers 409 with a message naming exactly which of the three it hit.
func (*Runtime) CreateProject ¶
CreateProject initializes .idea-harness/ in rootPath and registers it.
func (*Runtime) EnsureProject ¶
EnsureProject returns (opening if needed) the runtime for a project id. Construction is single-flight: r.mu is held across the whole build so two concurrent first-opens cannot open two *store.DB handles for one project (full-platform review: project-runtime race).
Every HTTP handler resolves its project through here (Server.project), so this is also the single choke point for maybeAutoReload: a cached project whose harness.yaml has changed on disk since it was last loaded -- a hand edit, e.g. to test_cmd -- is reloaded before its (possibly stale) runtime is handed back (review defect #4).
func (*Runtime) ExecuteInitiative ¶
func (r *Runtime) ExecuteInitiative(ctx context.Context, projectID, initiativeID string) (string, error)
ExecuteInitiative runs the M3 execute pipeline for the next ready task asynchronously, producing a change set. Returns the operation id.
func (*Runtime) ExecuteInitiativeFresh ¶ added in v0.5.1
func (r *Runtime) ExecuteInitiativeFresh(ctx context.Context, projectID, initiativeID string, fresh bool) (string, error)
ExecuteInitiativeFresh is ExecuteInitiative; with fresh, a stopped run's kept files are discarded once the run is accepted, so it starts from the workspace ("Start over").
func (*Runtime) ExecuteInitiativeFreshWithNote ¶ added in v0.6.0
func (r *Runtime) ExecuteInitiativeFreshWithNote(ctx context.Context, projectID, initiativeID string, fresh bool, note string) (string, error)
ExecuteInitiativeFreshWithNote is ExecuteInitiativeFresh, with an optional human note (D-a, wave 3 contract) that steers this one execute: appended to the implementer's brief and recorded on the agent run. Set on the engine BEFORE launching, and cleared by Execute itself once that run finishes, so it can never bleed into a later, unrelated execute of this initiative.
func (*Runtime) InitiativeRunStats ¶ added in v0.7.0
func (r *Runtime) InitiativeRunStats(ctx context.Context, projectID, initiativeID string) (RunStats, []domain.ReviewTelemetry, error)
InitiativeRunStats returns an initiative's summed model usage and its review convergence telemetry, oldest cycle first.
func (*Runtime) ListCaptureTokens ¶ added in v0.7.0
func (r *Runtime) ListCaptureTokens(ctx context.Context, projectID string) ([]store.CaptureToken, error)
ListCaptureTokens returns a project's capture tokens as metadata (id, label, created/last-used) — never the secret or its hash.
func (*Runtime) ListProjects ¶
ListProjects returns the registry entries.
func (*Runtime) MeasureQualityInitiative ¶ added in v0.7.0
func (r *Runtime) MeasureQualityInitiative(ctx context.Context, projectID, initiativeID string) (string, error)
MeasureQualityInitiative launches a measure_quality operation. It does not claim the initiative: measuring only reads the workspace (under the engine's own lock for the snapshot) and appends results, so it may run beside anything -- including on a complete or failed initiative, where the scorecard is still worth having.
func (*Runtime) MintCaptureToken ¶ added in v0.7.0
MintCaptureToken mints a capture token for a project: generates the secret, stores its SHA-256 in global.db, and returns the secret exactly once. The caller is the one who shows it (CLI/Settings), never a read path.
func (*Runtime) PRChecksForChangeSet ¶ added in v0.6.0
func (r *Runtime) PRChecksForChangeSet(ctx context.Context, projectID, changeSetID string) (git.PRChecksResult, error)
PRChecksForChangeSet reports the latest CI status of changeSetID's initiative's pull request via `gh pr checks`. See CreatePRForInitiative's doc comment for why "no PR yet" and "no gh" are classified here.
func (*Runtime) RegisterProvider ¶ added in v0.7.0
RegisterProvider adds a model provider, under name, to the registry of every project this runtime opens or reloads from now on. A project selects it the ordinary way, with `default_model: <name>/<model>` in harness.yaml.
It exists for the eval's deterministic scenarios: a reviewer that keeps re-raising rephrased findings, or one that holds a genuine blocker, is a scripted model.Provider, and the only way it can sit behind the real daemon's real registry is to be registered into it. A name a project also configures is overridden, so it cannot be mistaken for a real provider.
func (*Runtime) ReloadProject ¶
ReloadProject drops the cached runtime so the next EnsureProject re-reads config and rebuilds the provider registry (§40). It rebuilds the and rebuilds the provider registry (§40). It builds a NEW *projectRuntime reusing the same *store.DB (no second DB handle) and swaps the pointer under r.mu, so a reload never mutates fields that a concurrent reader/operation is using (review: project-runtime / field-swap race). Reconciliation does not re-run (reconciled flag stays set).
func (*Runtime) ReopenPhaseInitiative ¶
func (r *Runtime) ReopenPhaseInitiative(ctx context.Context, projectID, initiativeID, phase string) (string, error)
ReopenPhaseInitiative re-runs a design phase and everything downstream (cascade) asynchronously. Returns the operation id.
func (*Runtime) RerunChangeSetReviewInitiative ¶ added in v0.6.0
func (r *Runtime) RerunChangeSetReviewInitiative(ctx context.Context, projectID, initiativeID, changeSetID string) (string, error)
RerunChangeSetReviewInitiative runs the adversarial reviewer again for a change set whose review never completed, as an async operation (ICP re-run D2). The review itself is a real model call -- observed 1m12s-1m38s across four founder-journey runs -- which used to run SYNCHRONOUSLY inside the HTTP handler (detached from the request's own cancellation, but not from the CLI's 60s http.Client timeout): the daemon always finished the work, but the CLI reported a timeout error on every single invocation of a brand-new command, because it was still blocked waiting for the response when its own client gave up. It now returns an operation id immediately, the same shape `idea apply`/`idea execute` use, so `idea review <id> rerun` can be waited on/watched/cancelled like any other long-running action instead of racing a fixed client timeout against a model call.
The two precondition checks that used to fail fast, synchronously, inside Engine.RerunChangeSetReview are duplicated here (read-only, no model call) so a wrong-state rerun still refuses immediately with a normal 4xx rather than an operation the caller must poll to learn failed instantly. Engine.RerunChangeSetReview re-checks both under its own lock regardless, which is the correctness boundary; this is purely for a fast, synchronous answer on the common misuse.
func (*Runtime) ResumeInitiative ¶ added in v0.4.0
func (r *Runtime) ResumeInitiative(ctx context.Context, projectID, initiativeID string) (domain.InitiativeStatus, error)
ResumeInitiative re-runs the review loop for an initiative parked on a human. It stays synchronous (unlike Advance/RevisePlan/ReopenPhase below): callers get the final status directly, as before.
review H4: Resume used to run Engine.Resume with no operation row at all -- the only claiming entry point that didn't create one. That made it invisible to ListUnfinishedOperations, which both ReloadProject's "refuse to swap config while an operation is running" guard and reconcileStaleOperations key off: a reload could swap in a new redactor/registry/cfg mid-review-loop (a secret just added to harness.yaml would not be swept from the second half of the run), and a daemon crash mid-Resume stranded Engine.Resume's own ClaimInitiativeRunning claim with nothing for the sweep to find -- exactly what that claim's own comment already flagged. The operation row here is bookkeeping only: Resume still runs synchronously in this goroutine and still self-claims/self-releases inside Engine.Resume exactly as before (its own defer already restores needs_human_judgment on error); only ops visibility changes, so this operation's own status is recorded here rather than via failOperation (which would also fail the initiative -- Engine.Resume already decided that outcome).
func (*Runtime) RetryConflictedApply ¶
func (r *Runtime) RetryConflictedApply(ctx context.Context, projectID, initiativeID, changeSetID string) (string, error)
RetryConflictedApply resets a conflicted change set to approved and re-runs the existing async apply path. Returns the operation id.
func (*Runtime) RetryInitiative ¶
func (r *Runtime) RetryInitiative(ctx context.Context, projectID, initiativeID, model string) (string, error)
RetryInitiative re-runs a failed initiative's workflow under a chosen model (retry-with-a-different-model). Returns the operation id.
func (*Runtime) RetryInitiativeWithNote ¶ added in v0.6.0
func (r *Runtime) RetryInitiativeWithNote(ctx context.Context, projectID, initiativeID, model, note string) (string, error)
RetryInitiativeWithNote is RetryInitiative, with an optional human note (D-a, wave 3 contract) that steers this one retry. Retry re-runs the framing→research→PRD→review pipeline rather than the implementer, so the note joins the framing prompt (see Engine.runFraming) instead of "the implementer's brief" the wave 3 contract names -- there is no implementer brief at this stage of the pipeline for it to join.
func (*Runtime) RevertChangeSetInitiative ¶
func (r *Runtime) RevertChangeSetInitiative(ctx context.Context, projectID, initiativeID, changeSetID string) (string, error)
RevertChangeSetInitiative records a rolled-back journal entry for a change set asynchronously.
func (*Runtime) ReviseInitiative ¶
func (r *Runtime) ReviseInitiative(ctx context.Context, projectID, initiativeID string) (string, error)
ReviseInitiative applies the human's decisions by re-running product definition + review asynchronously (§8, §11).
func (*Runtime) RevisePlanInitiative ¶
func (r *Runtime) RevisePlanInitiative(ctx context.Context, projectID, initiativeID string) (string, error)
RevisePlanInitiative regenerates the execution plan (and its review) asynchronously, keeping the PRD/design artifacts. Returns the operation id.
func (*Runtime) RevisePlanInitiativeWithNote ¶ added in v0.7.0
func (r *Runtime) RevisePlanInitiativeWithNote(ctx context.Context, projectID, initiativeID, note string) (string, error)
RevisePlanInitiativeWithNote is RevisePlanInitiative with the human's note on what to change. "Ask for a revision" used to take no input, so the planner regenerated from exactly the inputs that produced the plan being revised. The note joins the planner's inputs for this one revision and is recorded on its run, the same contract as execute's and retry's notes.
func (*Runtime) RunVerificationGate ¶ added in v0.4.0
func (r *Runtime) RunVerificationGate(ctx context.Context, projectID, initiativeID, requirement string, disposition domain.VerificationStatus, note string) (domain.InitiativeStatus, []workflow.Coverage, error)
RunVerificationGate records any human evidence in the request and then runs the verification gate, refusing an initiative that has already failed.
Verify was the one state-writing path that never went through the Runtime: handleVerify called the engine directly, with no running check, no claim and no state precondition -- which is why `verifyInitiative` declared no 409 and the conflict axis correctly agreed there was nothing to declare.
`failed` only. `running` is deliberately NOT refused: `idea apply` does not wait for its operation, and the initiative reads `running` until the release that follows the change set being marked applied -- so the documented apply-then-verify sequence (docs/demo-greenfield.md, and scripts/smoke.sh, which polls the change set and then verifies) runs inside that window. Refusing it there would break the flow this fix is not about.
The residual that leaves: a `complete` written during an in-flight apply can be reverted by that apply's release, which writes priorStatus unconditionally. Pre-existing, recorded in docs/plans/deferred.md, and not closed here.
func (*Runtime) RunVerificationGateConfirmingTests ¶ added in v0.6.0
func (r *Runtime) RunVerificationGateConfirmingTests(ctx context.Context, projectID, initiativeID, requirement string, disposition domain.VerificationStatus, note string, confirmPassingTests bool) (domain.InitiativeStatus, []workflow.Coverage, *ConfirmResult, error)
RunVerificationGateConfirmingTests is RunVerificationGate, with confirmPassingTests (C2, wire contract: `POST .../verify {"confirm_passing_tests": true}`) additionally confirming, through the same human-evidence path (actor "human"), every requirement whose mapped tests all passed. Never runs without this explicit request -- nothing here is invoked from any other path. The returned *ConfirmResult is nil unless confirmPassingTests was requested.
func (*Runtime) Shutdown ¶ added in v0.5.0
Shutdown cancels every running operation and waits, until ctx expires, for them to finish.
Go exits at once on SIGTERM, which is what `idea daemon stop` sends, so no deferred cleanup ran: an agent container kept running with the provider key, network access and auto-approve, writing into the work root, until something happened to load the project again. Cancelling an operation's context is what makes the engine remove its container.
func (*Runtime) StartDraftInitiative ¶ added in v0.7.0
func (r *Runtime) StartDraftInitiative(ctx context.Context, projectID, initiativeID string) (string, error)
StartDraftInitiative runs the pipeline on a captured draft: it claims the initiative running from `draft` and launches the M1 workflow, exactly as `idea new` does for a freshly created initiative. A non-draft status is a conflict.
func (*Runtime) StartInitiative ¶
func (r *Runtime) StartInitiative(ctx context.Context, projectID, title, description string) (string, string, error)
StartInitiative creates an initiative + operation and runs the workflow asynchronously (§34). Returns the initiative and operation ids.
func (*Runtime) StartInitiativeWithDocs ¶
func (r *Runtime) StartInitiativeWithDocs(ctx context.Context, projectID, title, description string, docs []InitiativeDocInput, sourceInitiativeID string) (string, string, error)
StartInitiativeWithDocs creates an initiative, ingests its context docs, and only THEN launches the M1 run — so `idea new --doc` grounds framing/research/ PRD in the supplied material. Docs are size-checked, credential-swept and validated BEFORE the initiative is created, so a rejected doc never leaves a half-created row; anything that fails after creation marks the initiative failed rather than stranding it in `running`.
When sourceInitiativeID is non-empty (brownfield `idea new --from`), the source's live requirements are seeded into the new initiative (preserving codes) before the run, so the PRD stage emits added/modified/removed deltas against them rather than authoring from scratch.
Source Files
¶
- apidocs.go
- automations.go
- budget.go
- capture.go
- channels.go
- decode.go
- errors.go
- eval_hooks.go
- executor_status.go
- gaps.go
- graph_views.go
- handlers.go
- integrations.go
- lock_unix.go
- loginlimit.go
- logredact.go
- modelcache.go
- outcomes.go
- precondition.go
- providers.go
- push.go
- quality.go
- remote.go
- remoteruns.go
- routes.go
- run_handlers.go
- runevents.go
- runtime.go
- secret_allowlist_handlers.go
- server.go
- settings_executor.go
- settings_integrations.go
- sse.go
- uisession.go