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 ¶
- func DefaultStateRoot() string
- func Run(addr, stateRoot string, log *slog.Logger) error
- type InitiativeDocInput
- type PreconditionError
- 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) ApprovePlanInitiative(ctx context.Context, projectID, initiativeID string) (string, error)
- func (r *Runtime) CancelOperation(ctx context.Context, opID string) error
- func (r *Runtime) Close() 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) ListProjects(ctx context.Context) ([]store.ProjectRecord, error)
- 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) 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) 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) 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 ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultStateRoot ¶
func DefaultStateRoot() string
DefaultStateRoot returns the global state directory (§30), overridable via IDEA_HARNESS_STATE for tests.
Types ¶
type InitiativeDocInput ¶
InitiativeDocInput is one context doc supplied atomically at initiative creation (idea new --doc).
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.*Initiative precondition checks return this type, never internal/workflow. Fourteen handler call sites pass http.StatusBadRequest for engine errors (ReviewChangeSet and VerifyInitiative among them); 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.
func (*PreconditionError) Error ¶
func (e *PreconditionError) Error() string
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) ApprovePlanInitiative ¶
func (r *Runtime) ApprovePlanInitiative(ctx context.Context, projectID, initiativeID string) (string, error)
ApprovePlanInitiative re-runs the execution-plan review asynchronously.
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) 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).
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) ListProjects ¶
ListProjects returns the registry entries.
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) 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) 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) 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) (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 credential-swept/validated BEFORE the initiative is created, so a rejected doc never leaves a half-created row.