Documentation
¶
Index ¶
- Constants
- Variables
- type AutomationAPI
- type AutomationRunAPI
- type ChainFilter
- type ChainRun
- type Config
- type DeleteChainRunCounts
- type DeleteChainRunResult
- type GitOpsFinalizeInput
- type GitOpsFinalizeResult
- type GitOpsFinalizer
- type ListResult
- type LocalContextReader
- type Options
- type ProjectRunSummary
- type RunSummary
- type RunTree
- type Service
- func (svc *Service) ActivateCompiledWorkPlanForShadow(ctx context.Context, run ChainRun, ...) error
- func (svc *Service) CallWorkflowChainTool(ctx context.Context, name string, arguments json.RawMessage) (any, error)
- func (svc *Service) CancelChain(ctx context.Context, projectID, chainRunID string) (ChainRun, error)
- func (svc *Service) CarryForwardStageOutputTasksForShadow(ctx context.Context, projectID string, run ChainRun, ...) error
- func (svc *Service) CompileStageMetadataForShadow(ctx context.Context, run ChainRun, stage StageConfig) (StageRun, projectworkflow.WorkflowCompileResult, error)
- func (svc *Service) DeleteChainRun(ctx context.Context, projectID, chainRunID string) (DeleteChainRunResult, error)
- func (svc *Service) FinalizeGitOpsForShadow(ctx context.Context, run *ChainRun) error
- func (svc *Service) Get(ctx context.Context, projectID, chainRunID string) (ChainRun, error)
- func (svc *Service) GetProjectRunSummary(ctx context.Context, projectID string) (ProjectRunSummary, error)
- func (svc *Service) GetRunTree(ctx context.Context, projectID, chainRunID string) (RunTree, error)
- func (svc *Service) HandleWorkPlanStatusChanged(ctx context.Context, change projectworkplan.WorkPlanStatusChange) error
- func (svc *Service) List(ctx context.Context, filter ChainFilter) (ListResult, error)
- func (svc *Service) ReconcileStaleStages(ctx context.Context) error
- func (svc *Service) RecordChainRunPullRequestRef(ctx context.Context, projectID, chainRunID, pullRequestRef string) error
- func (svc *Service) ReleaseCompiledTasksForShadow(ctx context.Context, projectID string, ...) error
- func (svc *Service) ResolveContextRefsForShadow(ctx context.Context, projectID, chainRef, inputRef string) ([]string, error)
- func (svc *Service) ResolveStageConfigsForShadow(ctx context.Context, projectID, chainRef string) ([]StageConfig, error)
- func (svc *Service) RetryGitOps(ctx context.Context, projectID, chainRunID string) (ChainRun, error)
- func (svc *Service) RetryStageActivation(ctx context.Context, projectID, chainRunID string) (ChainRun, error)
- func (svc *Service) SetAutomationAPI(automations AutomationAPI)
- func (svc *Service) SetAutomationRunAPI(runs AutomationRunAPI)
- func (svc *Service) SetGitOpsFinalizer(finalizer GitOpsFinalizer)
- func (svc *Service) SetLocalContextReader(reader LocalContextReader)
- func (svc *Service) Start(ctx context.Context, input StartInput) (StartResult, error)
- func (svc *Service) StartGovernedIntake(ctx context.Context, req projectdurable.DurableIntakeRequest, input StartInput) (StartResult, error)
- func (svc *Service) StartReconciler(ctx context.Context)
- type StageConfig
- type StageRecoverySummary
- type StageRun
- type StageTree
- type StartInput
- type StartResult
- type Store
- type TaskCounts
- type WorkPlanAPI
- type WorkflowAPI
Constants ¶
const ( ChainStatusPlanned = "planned" ChainStatusQueued = "queued" ChainStatusActive = "active" ChainStatusCompleted = "completed" ChainStatusPostValidationPassed = "post_validation_passed" ChainStatusBlocked = "blocked" // ChainStatusRepairing is set when a chain's GitOps finalization failed // repairably (GitOpsRecoveryStatus == repairable) and a validation-reviewer // repair task is queued/running to fix it and retry GitOps. It is distinct // from blocked (stuck, needs human): a repairing chain has automated work // in flight. The reconciler recovery branches and operator recovery tools // treat blocked and repairing as the same family (see isChainBlockedOrRepairing); // repairing is NOT collapsed into active because that would disarm the // escalation branches (FM-5/GAP-10 advisory-proceed, GAP-9 plan recovery) // that key off the blocked/repairing bucket. ChainStatusRepairing = "repairing" ChainStatusFailed = "failed" ChainStatusCancelled = "cancelled" ChainStatusSuperseded = "superseded" )
const ( StageStatusPlanned = "planned" StageStatusQueued = "queued" StageStatusCompleted = "completed" StageStatusBlocked = "blocked" StageStatusFailed = "failed" StageStatusCancelled = "cancelled" StageStatusSuperseded = "superseded" )
const ( GitOpsRecoveryStatusRepairable = "repairable" GitOpsRecoveryStatusTerminal = "terminal" GitOpsRecoveryStatusCompleted = "completed" )
const ( InputKindJiraIssueKey = "jira_issue_key" InputKindObjectiveText = "objective_text" InputKindSafeRef = "safe_ref" ContextProviderJira = "jira" ContextProviderConfluence = "confluence" ContextProviderIndexedRepo = "indexed_repo" ContextModeLocalIngested = "local_ingested" ContextModeIndexed = "indexed" TriggerOnChainStart = "on_chain_start" TriggerAfterStageReviewPassed = "after_stage_review_passed" GitOpsModeDraftPRAfterValidation = "draft_pr_after_post_validation" )
const ( BlockedCodeActivationFailed = "activation_failed" BlockedCodeMissingCarriedImplementationTasks = "missing_carried_implementation_tasks" BlockedCodeNonReadyCarriedImplementationTask = "non_ready_carried_implementation_task" )
Variables ¶
var ErrInvalidInput = errors.New("invalid project workflow chain input")
Functions ¶
This section is empty.
Types ¶
type AutomationAPI ¶ added in v0.3.0
type AutomationAPI interface {
CreateAutomation(context.Context, projectautomation.CreateAutomationInput) (projectautomation.Automation, error)
ListAutomations(context.Context, projectautomation.AutomationFilter) ([]projectautomation.Automation, error)
ReconcileReadyAutomationsForPlan(context.Context, string, string) error
// CancelAutomationsForPlan disables all enabled automations for a plan.
// Used by CancelChain (GAP-12) so cancelled chains don't leave stale
// automations that pollute the reconciler's scan.
CancelAutomationsForPlan(context.Context, string, string) error
// DeleteAutomationsForPlanCascade permanently removes every automation for
// a plan together with each automation's runs. Used by the governed
// chain-run delete cascade.
DeleteAutomationsForPlanCascade(context.Context, string, string) (projectautomation.AutomationDeleteCounts, error)
}
type AutomationRunAPI ¶ added in v0.3.0
type AutomationRunAPI interface {
ListRuns(context.Context, projectautomation.RunFilter) ([]projectautomation.AutomationRun, error)
}
AutomationRunAPI exposes the automation-run read surface used by GetRunTree/GetProjectRunSummary to count active (non-terminal) runs for a plan. Kept separate from AutomationAPI because run state lives in a different service object (the run store) in the server wiring.
type ChainFilter ¶
type ChainRun ¶
type ChainRun struct {
ID string `json:"chain_run_id"`
ProjectID string `json:"project_id"`
ChainRef string `json:"chain_ref"`
InputRef string `json:"input_ref"`
Status string `json:"status"`
ContextRefs []string `json:"context_refs,omitempty"`
StageRuns []StageRun `json:"stage_runs,omitempty"`
WorkPlanIDs []string `json:"work_plan_ids,omitempty"`
AutomationIDs []string `json:"automation_ids,omitempty"`
CreatedByRunID string `json:"created_by_run_id,omitempty"`
TraceID string `json:"trace_id,omitempty"`
GitOpsReady bool `json:"gitops_ready,omitempty"`
GitOpsAttemptCount int `json:"gitops_attempt_count,omitempty"`
GitOpsFailureCategory string `json:"gitops_failure_category,omitempty"`
GitOpsFailureEvidenceRefs []string `json:"gitops_failure_evidence_refs,omitempty"`
GitOpsRecoveryStatus string `json:"gitops_recovery_status,omitempty"`
GitOpsResetCount int `json:"gitops_reset_count,omitempty"`
// GitOpsAdvisoryProceed is set true when a verifier failure has persisted
// through the full reconciler reset budget (sustained stagnation), indicating
// the verifier is beyond the repair agent's ability to fix. When true, the
// finalization verifier gate treats a failed verifier ref as an advisory
// warning (via the existing failedVerifierRefHasFinalReadinessDisposition
// escape hatch) and the draft PR proceeds. Per policy, workflow gates are
// advisory by default; the downstream GitHub CI / human review is the real
// gate. This field is NOT cleared by the reconciler auto-reset — it is a
// durable decision once the stagnation threshold is reached.
GitOpsAdvisoryProceed bool `json:"gitops_advisory_proceed,omitempty"`
PullRequestRef string `json:"pull_request_ref,omitempty"`
NextAction string `json:"next_action,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type Config ¶
type Config struct {
ProjectID string `json:"project_id"`
ChainRef string `json:"chain_ref"`
Enabled bool `json:"enabled"`
InputKind string `json:"input_kind,omitempty"`
InputPattern string `json:"input_pattern,omitempty"`
ContextProvider string `json:"context_provider,omitempty"`
ContextMode string `json:"context_mode,omitempty"`
DefaultTitleTemplate string `json:"default_title_template,omitempty"`
GitOpsMode string `json:"gitops_mode,omitempty"`
GitOpsEnabled bool `json:"gitops_enabled,omitempty"`
Stages []StageConfig `json:"stages,omitempty"`
}
type DeleteChainRunCounts ¶ added in v0.3.0
type DeleteChainRunCounts struct {
Plans int `json:"plans"`
Tasks int `json:"tasks"`
Attachments int `json:"attachments"`
Automations int `json:"automations"`
Runs int `json:"runs"`
}
DeleteChainRunCounts tallies what a governed delete cascade removed.
type DeleteChainRunResult ¶ added in v0.3.0
type DeleteChainRunResult struct {
ChainRunID string `json:"chain_run_id"`
ProjectID string `json:"project_id"`
Deleted DeleteChainRunCounts `json:"deleted"`
}
DeleteChainRunResult is the metadata-only summary returned by DeleteChainRun. A deleted chain run has nothing useful to return as an entity, so this counts summary mirrors the purge_cancelled convention.
type GitOpsFinalizeInput ¶
type GitOpsFinalizeInput struct {
ProjectID string
ChainRunID string
ChainRef string
InputRef string
WorkPlan projectworkplan.WorkPlan
StageRuns []StageRun
AutomationIDs []string
AllowedPathspecs []string
ReviewRefs []string
VerifierRefs []string
TestResults []string
CreatedByRunID string
TraceID string
// AdvisoryProceed indicates the chain has exhausted its repair budget and
// the PR should be created with a verifier warning instead of failing on
// verifier errors. When true, the finalizer MUST skip server-side verifier
// re-runs (the verifier ladder already failed and the repair agent cannot
// fix it — the PR is created as a draft with a warning).
AdvisoryProceed bool
}
type GitOpsFinalizeResult ¶
type GitOpsFinalizer ¶
type GitOpsFinalizer interface {
FinalizeWorkflowChain(context.Context, GitOpsFinalizeInput) (GitOpsFinalizeResult, error)
}
type ListResult ¶
type LocalContextReader ¶ added in v0.3.0
type LocalContextReader interface {
ReadLocalContent(context.Context, projectintegrations.LocalReadInput) (projectintegrations.RichContentReadResult, error)
}
type Options ¶ added in v0.3.0
type Options struct {
GitOpsRecoveryMaxAttempts int
ReconcilerInterval time.Duration
// ReconcilerGitOpsResets bounds the number of auto-reset cycles the
// reconciler performs before a terminal GitOps failure escalates to
// advisory-proceed or permanent terminal. Defaults to
// defaultReconcilerGitOpsResets (5). Previously hardcoded; now configurable.
ReconcilerGitOpsResets int
// AdvisoryProceedEnabled controls whether a verifier failure that has
// persisted through the full reconciler reset budget (sustained stagnation)
// converts to advisory proceed (draft PR with a verifier warning) instead of
// permanently terminal-blocking. Defaults to true via NewWithOptions.
AdvisoryProceedEnabled bool
}
type ProjectRunSummary ¶ added in v0.3.0
type ProjectRunSummary struct {
ProjectID string `json:"project_id"`
TotalChains int `json:"total_chains"`
ActiveChains int `json:"active_chains"`
BlockedChains int `json:"blocked_chains"`
TotalPlans int `json:"total_plans"`
ActivePlans int `json:"active_plans"`
BlockedPlans int `json:"blocked_plans"`
TaskCounts TaskCounts `json:"task_counts"`
AutomationRunCounts map[string]int `json:"automation_run_counts,omitempty"`
ActiveRuns []RunSummary `json:"active_runs,omitempty"`
}
ProjectRunSummary is the project-wide overview returned by GET .../run-summary. It replaces the multi-call fan-out that show_stats.py / pipeline-stats.py had to do.
type RunSummary ¶ added in v0.3.0
type RunSummary struct {
ChainRunID string `json:"chain_run_id"`
TraceID string `json:"trace_id,omitempty"`
InputRef string `json:"input_ref,omitempty"`
Status string `json:"status"`
CurrentStage string `json:"current_stage,omitempty"`
StagesCompleted int `json:"stages_completed"`
StagesTotal int `json:"stages_total"`
TaskDone int `json:"task_done"`
TaskTotal int `json:"task_total"`
ActiveAutomationRuns int `json:"active_automation_runs,omitempty"`
PullRequestRef string `json:"pull_request_ref,omitempty"`
UpdatedAt time.Time `json:"updated_at"`
}
RunSummary is the per-active-chain entry inside ProjectRunSummary. It carries just enough for a stats table: identity, status, stage progress, task progress.
type RunTree ¶ added in v0.3.0
type RunTree struct {
ChainRun ChainRun `json:"chain_run"`
Stages []StageTree `json:"stages,omitempty"`
// Recovery is the chain-wide rollup of task-level gitops recovery activity
// (summed across stages). It is computed read-side in GetRunTree from the
// automation-runs fetch each stage already performs — no extra I/O, no new
// persistence. Nil when there is no recovery activity (omitempty hides it).
Recovery *StageRecoverySummary `json:"recovery,omitempty"`
}
RunTree is the aggregate hierarchy for a single chain run: the chain run itself plus, for every stage that has a work plan, the hydrated plan, its tasks, its automations, and any non-terminal automation runs. This is what the GET .../workflow-chain-runs/{id}/tree endpoint returns so operators and stats scripts get the full picture in ONE call instead of N fan-out calls.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func New ¶
func New(store Store, workflows WorkflowAPI, workPlans WorkPlanAPI, configs []Config) *Service
func NewWithOptions ¶ added in v0.3.0
func NewWithOptions(store Store, workflows WorkflowAPI, workPlans WorkPlanAPI, configs []Config, options Options) *Service
func (*Service) ActivateCompiledWorkPlanForShadow ¶ added in v0.3.0
func (svc *Service) ActivateCompiledWorkPlanForShadow(ctx context.Context, run ChainRun, compiled projectworkflow.WorkflowCompileResult) error
ActivateCompiledWorkPlanForShadow exposes only the Work Plan activation part of activateCompiledStage for the durable shadow adapter. Carry-forward and task release remain separate exported calls so the durable trace records the same step order explicitly.
func (*Service) CallWorkflowChainTool ¶
func (*Service) CancelChain ¶ added in v0.3.0
func (*Service) CarryForwardStageOutputTasksForShadow ¶ added in v0.3.0
func (svc *Service) CarryForwardStageOutputTasksForShadow(ctx context.Context, projectID string, run ChainRun, compiled projectworkflow.WorkflowCompileResult) error
CarryForwardStageOutputTasksForShadow exposes the current carry-forward rules to the durable shadow adapter so generated task handoffs are converted through the same concrete Work Task ID path as the current service.
func (*Service) CompileStageMetadataForShadow ¶ added in v0.3.0
func (svc *Service) CompileStageMetadataForShadow(ctx context.Context, run ChainRun, stage StageConfig) (StageRun, projectworkflow.WorkflowCompileResult, error)
CompileStageMetadataForShadow exposes the current compileStageMetadata helper for the durable workflow-chain shadow adapter. It is compile only: no task release, plan activation, or GitOps finalization happens here.
func (*Service) DeleteChainRun ¶ added in v0.3.0
func (svc *Service) DeleteChainRun(ctx context.Context, projectID, chainRunID string) (DeleteChainRunResult, error)
DeleteChainRun permanently removes a workflow chain run together with all of its persisted child data: each stage's work plan, the plan's tasks and their attachments, and the plan's automations and their runs. It is the governed operator surface for cleaning up a cancelled/failed chain's storage.
Guard (inverted from CancelChain): only TERMINAL chain runs (completed/cancelled/superseded/failed) may be deleted. An in-flight chain (planned/active/queued/blocked/repairing) must be cancelled first so live work is never hard-deleted under a runner. Idempotent: re-deleting an already-absent run returns a not-found error (the second call finds nothing).
Cascade order is designed to defeat the reconciler: each plan is flipped to terminal and its automations disabled BEFORE child records are removed, so reconcileMissingCarriedImplementationAutomations cannot resurrect deleted automations for an active plan mid-cascade. Best-effort per stage: a child delete error is returned, but earlier deletes in the same cascade are not rolled back (re-invoking is safe because every child delete is idempotent).
func (*Service) FinalizeGitOpsForShadow ¶ added in v0.3.0
FinalizeGitOpsForShadow exposes the current GitOps finalization helper to durable shadow tests. The helper mutates run; callers must persist the run through the store after a nil error, mirroring the current service callers.
func (*Service) GetProjectRunSummary ¶ added in v0.3.0
func (svc *Service) GetProjectRunSummary(ctx context.Context, projectID string) (ProjectRunSummary, error)
GetProjectRunSummary returns a project-wide overview of all non-terminal chains: aggregate counts (chains/plans/tasks/automation-runs by status) plus a per-active-run summary with stage + task progress. This is the single call that replaces show_stats.py / pipeline-stats.py fan-out (RC-4).
func (*Service) GetRunTree ¶ added in v0.3.0
GetRunTree returns the full hierarchy for a single chain run: the chain run plus, for every stage with a work plan, the hydrated plan + its tasks + automations + a count of active automation runs. This collapses the N-call fan-out that operators and stats scripts previously had to do (RC-1/RC-4).
It reads via the denormalized ID lists on ChainRun (WorkPlanIDs, StageRuns[].WorkPlanID/WorkTaskIDs/AutomationIDs) so there is no N+1: each plan/task/automation is a direct Get, not a scan. See plan §4 TIER 2 and §7 ("Do NOT make aggregate endpoints do N+1").
func (*Service) HandleWorkPlanStatusChanged ¶
func (svc *Service) HandleWorkPlanStatusChanged(ctx context.Context, change projectworkplan.WorkPlanStatusChange) error
func (*Service) List ¶
func (svc *Service) List(ctx context.Context, filter ChainFilter) (ListResult, error)
func (*Service) ReconcileStaleStages ¶ added in v0.3.0
ReconcileStaleStages finds active chain runs with stages whose plans have all tasks done but the plan never transitioned to Done. It synthesizes a WorkPlanStatusDone event so the chain can compile/activate the next stage.
func (*Service) RecordChainRunPullRequestRef ¶ added in v0.3.0
func (svc *Service) RecordChainRunPullRequestRef(ctx context.Context, projectID, chainRunID, pullRequestRef string) error
CancelChain moves a non-terminal chain to Cancelled and fails its open work tasks so the chain stops consuming reconciler attention and its tasks drop out of open-task scans (FM-7). This is the operator recovery path for superseded/stale/duplicate chains that accumulated because there was no cancel surface. Only chains in a non-terminal status (active/queued/blocked/ failed) may be cancelled; completed/cancelled/superseded chains are rejected (idempotent guard).
Scope: this performs state cleanup only — chain status + open task failing. Disabling the chain's automations, removing its worktree, and deleting stale remote compile branches are environment/git operations that remain an explicit operator follow-up (auto-deleting git refs is unsafe from here). RecordChainRunPullRequestRef writes a draft-PR ref produced by a per-task GitOps run back onto the owning chain run's PullRequestRef field. This closes the observability gap where a chain that produced its PR via per-task GitOps (the common governed-workplan-implementation case) reported PR: (none) until chain-level finalize ran — because only finalize used to set the field.
Semantics (bulletproof):
- First-writer-wins: if PullRequestRef is already set (e.g. by chain finalize), this is a no-op. The per-task callback never clobbers a canonical finalize ref.
- Does NOT transition chain status. Only the chain-level finalize owns the active -> completed transition. This callback only fills the field so pipeline-stats.py / dashboard surface the PR as soon as it exists.
- Missing run = silent no-op (a task not belonging to any chain must not error here).
- Blank projectID/chainRunID, or a non-github-pr-N ref, is a programmer error and returns ErrInvalidInput (fail loud, do not silently pollute).
func (*Service) ReleaseCompiledTasksForShadow ¶ added in v0.3.0
func (svc *Service) ReleaseCompiledTasksForShadow(ctx context.Context, projectID string, compiled projectworkflow.WorkflowCompileResult, run ChainRun) error
ReleaseCompiledTasksForShadow exposes the current release helper for the durable shadow adapter. Callers are responsible for invoking it before ActivateCompiledWorkPlanForShadow to preserve the current event order.
func (*Service) ResolveContextRefsForShadow ¶ added in v0.3.0
func (svc *Service) ResolveContextRefsForShadow(ctx context.Context, projectID, chainRef, inputRef string) ([]string, error)
ResolveContextRefsForShadow exposes the current chain context-ref resolver for the durable workflow-chain shadow adapter. It returns safe metadata refs only and preserves local-ingested Jira validation before any stage compile.
func (*Service) ResolveStageConfigsForShadow ¶ added in v0.3.0
func (svc *Service) ResolveStageConfigsForShadow(ctx context.Context, projectID, chainRef string) ([]StageConfig, error)
ResolveStageConfigsForShadow returns the enabled stage configuration for a durable shadow adapter. It deliberately exposes metadata only; callers still drive compile/activate through the narrow exported methods below.
func (*Service) RetryGitOps ¶
func (*Service) RetryStageActivation ¶ added in v0.3.0
func (svc *Service) RetryStageActivation(ctx context.Context, projectID, chainRunID string) (ChainRun, error)
RetryStageActivation recovers a chain blocked by a compile_next_stage_failed or activate_next_stage_failed error. Unlike GitOps blocks (which have their own retry path), these stage-level failures had NO recovery surface — the blocked reason was write-only and no MCP tool could clear it. This method clears the block, resets the stage to Planned, and re-attempts compilation + activation. Per policy line 46: state transitions must be recoverable.
func (*Service) SetAutomationAPI ¶ added in v0.3.0
func (svc *Service) SetAutomationAPI(automations AutomationAPI)
func (*Service) SetAutomationRunAPI ¶ added in v0.3.0
func (svc *Service) SetAutomationRunAPI(runs AutomationRunAPI)
SetAutomationRunAPI wires the automation-run read surface. Optional: when unset, GetRunTree omits active-run counts (the field reports 0). Wired by the server so the tree/summary endpoints can count in-flight runs.
func (*Service) SetGitOpsFinalizer ¶
func (svc *Service) SetGitOpsFinalizer(finalizer GitOpsFinalizer)
func (*Service) SetLocalContextReader ¶ added in v0.3.0
func (svc *Service) SetLocalContextReader(reader LocalContextReader)
func (*Service) Start ¶
func (svc *Service) Start(ctx context.Context, input StartInput) (StartResult, error)
func (*Service) StartGovernedIntake ¶ added in v0.3.0
func (svc *Service) StartGovernedIntake(ctx context.Context, req projectdurable.DurableIntakeRequest, input StartInput) (StartResult, error)
func (*Service) StartReconciler ¶ added in v0.3.0
StartReconciler launches a background goroutine that periodically checks for chain stages whose work plans have all tasks done but never emitted WorkPlanStatusDone (e.g. because the automation closeout path missed them). It synthesizes the Done transition so the chain can advance automatically.
type StageConfig ¶
type StageConfig struct {
StageRef string `json:"stage_ref"`
WorkflowRef string `json:"workflow_ref"`
Trigger string `json:"trigger,omitempty"`
DependsOn []string `json:"depends_on,omitempty"`
AutomationRefTemplate string `json:"automation_ref_template,omitempty"`
RequiredStatusBeforeNext string `json:"required_status_before_next,omitempty"`
}
type StageRecoverySummary ¶ added in v0.3.0
type StageRecoverySummary struct {
// RecoveringRuns counts runs whose SafeSummary is the active recovery
// marker (RunSafeSummaryGitOpsPostTaskRecovery) — i.e. the recovery loop
// has re-armed them and they are in flight again.
RecoveringRuns int `json:"recovering_runs,omitempty"`
// FailedRuns counts runs in RunStatusFailed — candidates the recovery
// loop is evaluating. Distinct from RecoveringRuns (which are already
// re-claimed).
FailedRuns int `json:"failed_runs,omitempty"`
// TotalAttempts sums AttemptCount across recovering + failed runs, so an
// operator sees the cumulative retry pressure (a run on attempt 7 is a
// different signal than 7 runs on attempt 1).
TotalAttempts int `json:"total_attempts,omitempty"`
// FailureCategories lists the distinct failure_category values across
// recovering + failed runs, deduped and capped. These are already-validated
// safe refs (they pass the safe-ref boundary at write time).
FailureCategories []string `json:"failure_categories,omitempty"`
}
StageRecoverySummary tallies the task-level gitops_post_task_recovery activity within one stage's automation runs. The recovery loop (projectautomation.claimGitOpsPostTaskRecovery) operates on AutomationRun records and never writes to ChainRun, so without this aggregate an operator watching a chain (e.g. mid-post-validation) sees no signal that failed runs underneath are being recovered. Every field is omitempty so a healthy stage serializes no recovery object at all.
type StageRun ¶
type StageRun struct {
StageRef string `json:"stage_ref"`
WorkflowRef string `json:"workflow_ref"`
WorkflowID string `json:"workflow_id,omitempty"`
Status string `json:"status"`
WorkPlanID string `json:"work_plan_id,omitempty"`
WorkTaskIDs []string `json:"work_task_ids,omitempty"`
AutomationIDs []string `json:"automation_ids,omitempty"`
StartedAt time.Time `json:"started_at,omitempty"`
CompletedAt time.Time `json:"completed_at,omitempty"`
BlockedCode string `json:"blocked_code,omitempty"`
BlockedReason string `json:"blocked_reason,omitempty"`
}
type StageTree ¶ added in v0.3.0
type StageTree struct {
StageRef string `json:"stage_ref"`
Status string `json:"status"`
Plan *projectworkplan.WorkPlan `json:"plan,omitempty"`
Tasks []projectworkplan.WorkTask `json:"tasks,omitempty"`
Automations []projectautomation.Automation `json:"automations,omitempty"`
ActiveAutomationRuns int `json:"active_automation_runs,omitempty"`
// Recovery tallies this stage's task-level gitops recovery activity. Nil
// when the stage has no recovering or failed runs (omitempty hides it).
Recovery *StageRecoverySummary `json:"recovery,omitempty"`
}
StageTree is one stage's slice of the run tree. Only stages with a non-empty WorkPlanID populate Plan/Tasks/Automations; planned-but-not-yet-compiled stages carry only the stage ref + status.
type StartInput ¶
type StartResult ¶
type StartResult struct {
ProjectID string `json:"project_id"`
ChainRef string `json:"chain_ref"`
InputRef string `json:"input_ref"`
Status string `json:"status"`
ContextRefs []string `json:"context_refs,omitempty"`
ChainRunID string `json:"chain_run_id,omitempty"`
StageRuns []StageRun `json:"stage_runs,omitempty"`
WorkPlanIDs []string `json:"work_plan_ids,omitempty"`
AutomationIDs []string `json:"automation_ids,omitempty"`
DryRun bool `json:"dry_run,omitempty"`
NextAction string `json:"next_action"`
PullRequestRef string `json:"pull_request_ref,omitempty"`
}
type Store ¶
type Store interface {
CreateChainRun(context.Context, ChainRun) (ChainRun, error)
GetChainRun(context.Context, string, string) (ChainRun, error)
ListChainRuns(context.Context, ChainFilter) ([]ChainRun, error)
UpdateChainRun(context.Context, ChainRun) (ChainRun, error)
FindChainRunByWorkPlan(context.Context, string, string) (ChainRun, error)
// DeleteChainRun permanently removes a chain run. Scoped by project;
// idempotent. Used by the governed chain-run delete cascade.
DeleteChainRun(context.Context, string, string) error
}
type TaskCounts ¶ added in v0.3.0
type TaskCounts struct {
Total int `json:"total"`
Done int `json:"done"`
Active int `json:"active"`
Blocked int `json:"blocked"`
Failed int `json:"failed"`
NeedsReview int `json:"needs_review,omitempty"`
}
TaskCounts is the per-status breakdown of work tasks across the project's active chains. Only tasks belonging to non-terminal chains are counted so historical/cancelled chains don't drown out the signal.
type WorkPlanAPI ¶
type WorkPlanAPI interface {
GetWorkPlan(context.Context, string, string) (projectworkplan.WorkPlan, error)
GetWorkPlansByIDs(context.Context, string, []string) ([]projectworkplan.WorkPlan, error)
ListWorkPlans(context.Context, projectworkplan.WorkPlanFilter) ([]projectworkplan.WorkPlan, error)
GetWorkTask(context.Context, string, string) (projectworkplan.WorkTask, error)
ListWorkTasksByPlanIDs(context.Context, string, []string) ([]projectworkplan.WorkTask, error)
ListWorkTasks(context.Context, projectworkplan.WorkTaskFilter) ([]projectworkplan.WorkTask, error)
ListOpenWorkTasks(context.Context, projectworkplan.WorkTaskFilter) ([]projectworkplan.WorkTask, error)
CreateWorkTask(context.Context, projectworkplan.CreateWorkTaskInput) (projectworkplan.WorkTask, error)
AttachReviewResult(context.Context, projectworkplan.AttachInput) (projectworkplan.Attachment, error)
UpdateWorkPlanStatus(context.Context, projectworkplan.UpdateWorkPlanStatusInput) (projectworkplan.WorkPlan, error)
UpdateWorkTaskStatus(context.Context, projectworkplan.UpdateWorkTaskStatusInput) (projectworkplan.WorkTask, error)
// ResetWorkTaskRecovery stamps the operator recovery marker on a blocked/
// failed task, clears the poison TraceID and stale ClaimedByRunID, and
// transitions the task to ready. This is the full recovery path that
// resets the replacement-retry counter so the automation orchestrator can
// queue a fresh run. Used by the chain reconciler's soft-verifier recovery
// to avoid the zombie loop where a reopened task gets immediately re-blocked
// by accumulated terminal failures (MASS-3847).
ResetWorkTaskRecovery(context.Context, projectworkplan.WorkTaskActionInput) (projectworkplan.WorkTask, error)
// DeleteWorkPlanCascade permanently removes a plan, its tasks, and task
// attachments. Used by the governed chain-run delete cascade.
DeleteWorkPlanCascade(context.Context, string, string) (projectworkplan.WorkPlanDeleteCounts, error)
}
type WorkflowAPI ¶
type WorkflowAPI interface {
ListWorkflows(context.Context, projectworkflow.WorkflowFilter) ([]projectworkflow.WorkflowDefinition, error)
CompileWorkflow(context.Context, projectworkflow.WorkflowCompileInput) (projectworkflow.WorkflowCompileResult, error)
}