Documentation
¶
Overview ¶
Package app is the shared application service behind every workloom surface (CLI, MCP, file protocol): one implementation of input validation, gates, approvals, version guards and transactions, so no entry point can bypass a constraint the others enforce (方案 §8.1, 实施计划 M4.2).
Errors carry the taxonomy both surfaces render: Kind is the display kind the CLI already used (usage, precondition, invalid, workflow, gate, quality, workitem, approval), and Class collapses it onto the four classes that map to exit codes and MCP tool error codes.
Index ¶
- Constants
- func Classify(err error) error
- func MCPSnippet(name string, cmd MCPCommand, projectRoot string) (string, error)
- func SkillMainBody() string
- func WorkflowTemplates() []string
- type ApprovalFilter
- type AttemptSpawner
- type ClaimView
- type CommentView
- type CompletionCheck
- type ContextView
- type CreateDecisionRequest
- type CreateFindingRequest
- type CreateRunRequest
- type CreateWorkitemRequest
- type DecideApprovalRequest
- type DispatchReport
- type DispatchRequest
- type DispatchedAttempt
- type Error
- type EventListRequest
- type EventRef
- type HeartbeatView
- type KnowledgeContext
- type KnowledgePageRef
- type KnowledgePageView
- type KnowledgeRefreshRequest
- type KnowledgeRefreshView
- type KnowledgeScanExclusion
- type KnowledgeScanView
- type KnowledgeStatusView
- type KnowledgeValidateView
- type MCPCommand
- type MCPInstallRequest
- type MCPInstallResult
- type MCPInstallView
- type MCPProbeResult
- type PolicySummary
- type ProjectEntry
- type ProjectStatusView
- type ProjectView
- type RecordEventRequest
- type RecordRef
- type RecordView
- type RegisterArtifactRequest
- type RequestApprovalRequest
- type RunExecRequest
- type RunExecView
- type RunFinishRequest
- type RunListRequest
- type RunLogView
- type RunPromptRequest
- type RunPromptView
- type RunView
- type Service
- func (s *Service) ApprovalApprove(ctx context.Context, req DecideApprovalRequest) (*domain.Approval, error)
- func (s *Service) ApprovalGet(ctx context.Context, id string) (*domain.Approval, error)
- func (s *Service) ApprovalList(ctx context.Context, filter ApprovalFilter) ([]*domain.Approval, error)
- func (s *Service) ApprovalReject(ctx context.Context, req DecideApprovalRequest) (*domain.Approval, string, error)
- func (s *Service) ApprovalRequest(ctx context.Context, req RequestApprovalRequest) (*domain.Approval, string, error)
- func (s *Service) ArtifactGet(ctx context.Context, id string) (RecordView, error)
- func (s *Service) ArtifactHistory(ctx context.Context, id string) ([]*domain.Artifact, error)
- func (s *Service) ArtifactList(ctx context.Context) ([]*domain.Artifact, error)
- func (s *Service) ArtifactRegister(ctx context.Context, req RegisterArtifactRequest) (RecordView, error)
- func (s *Service) ArtifactUpdate(ctx context.Context, req UpdateArtifactRequest) (RecordView, error)
- func (s *Service) ContextCompact(ctx context.Context) (ContextView, error)
- func (s *Service) ContextForWorkitem(ctx context.Context, id string, paths []string) (WorkitemContextView, error)
- func (s *Service) ContextGet(ctx context.Context, limit int) (ContextView, error)
- func (s *Service) ContextRefresh(ctx context.Context, limit int) (ContextView, error)
- func (s *Service) DecisionApprove(ctx context.Context, id, by, expect string) (RecordView, error)
- func (s *Service) DecisionCreate(ctx context.Context, req CreateDecisionRequest) (RecordView, error)
- func (s *Service) DecisionGet(ctx context.Context, id string) (RecordView, error)
- func (s *Service) DecisionList(ctx context.Context) ([]*domain.Decision, error)
- func (s *Service) Dispatch(ctx context.Context, req DispatchRequest) (DispatchReport, error)
- func (s *Service) EventList(ctx context.Context, req EventListRequest) ([]*domain.Event, error)
- func (s *Service) EventRecord(ctx context.Context, req RecordEventRequest) (*domain.Event, error)
- func (s *Service) FindingCreate(ctx context.Context, req CreateFindingRequest) (RecordView, error)
- func (s *Service) FindingGet(ctx context.Context, id string) (RecordView, error)
- func (s *Service) FindingList(ctx context.Context) ([]*domain.Finding, error)
- func (s *Service) FindingResolve(ctx context.Context, id, resolution, expect string) (RecordView, error)
- func (s *Service) KnowledgeRefresh(ctx context.Context, req KnowledgeRefreshRequest) (KnowledgeRefreshView, error)
- func (s *Service) KnowledgeScan(ctx context.Context) (KnowledgeScanView, error)
- func (s *Service) KnowledgeStatus(ctx context.Context) (KnowledgeStatusView, error)
- func (s *Service) KnowledgeValidate(ctx context.Context, roots []string) (KnowledgeValidateView, error)
- func (s *Service) MCPInstall(ctx context.Context, req MCPInstallRequest) (*MCPInstallView, error)
- func (s *Service) Next(ctx context.Context) (next.Report, []*domain.WorkItem, error)
- func (s *Service) ProjectBlueprint(ctx context.Context) (*domain.Artifact, error)
- func (s *Service) ProjectCreate(ctx context.Context, path string) (*project.Result, string, error)
- func (s *Service) ProjectGet(ctx context.Context) (ProjectView, error)
- func (s *Service) ProjectList(ctx context.Context) ([]ProjectEntry, error)
- func (s *Service) ProjectStateGet(ctx context.Context) (StateView, error)
- func (s *Service) ProjectStateUpdate(ctx context.Context, req UpdateStateRequest) (StateView, error)
- func (s *Service) ProjectStatus(ctx context.Context) (ProjectStatusView, error)
- func (s *Service) ProjectUpdate(ctx context.Context, req UpdateProjectRequest) (ProjectView, error)
- func (s *Service) RunCreate(ctx context.Context, req CreateRunRequest) (RunView, error)
- func (s *Service) RunExec(ctx context.Context, req RunExecRequest) (RunExecView, error)
- func (s *Service) RunFinish(ctx context.Context, req RunFinishRequest) (RunView, error)
- func (s *Service) RunGet(ctx context.Context, id string) (RunView, error)
- func (s *Service) RunHeartbeat(ctx context.Context, runID, owner, token, actor, reason string, ...) (HeartbeatView, error)
- func (s *Service) RunList(ctx context.Context, req RunListRequest) ([]*domain.Run, error)
- func (s *Service) RunLog(ctx context.Context, id string, limit int) (RunLogView, error)
- func (s *Service) RunPrompt(ctx context.Context, req RunPromptRequest) (RunPromptView, error)
- func (s *Service) RunUpdate(ctx context.Context, req UpdateRunRequest) (RunView, error)
- func (s *Service) RunVerify(ctx context.Context, runID string) (CompletionCheck, error)
- func (s *Service) SessionStart(ctx context.Context, req SessionRequest) (SessionView, error)
- func (s *Service) Setup(ctx context.Context, template string) (SetupView, error)
- func (s *Service) SkillStatus() (files int, marked int)
- func (s *Service) TaskContext(ctx context.Context, id string, paths []string, limit int, refresh bool) (TaskContext, error)
- func (s *Service) Wire(ctx context.Context, dryRun bool) (WireView, error)
- func (s *Service) WireCheck() WireCheckView
- func (s *Service) WorkflowGet(ctx context.Context, id string) (WorkflowView, error)
- func (s *Service) WorkflowInitTemplate(ctx context.Context, id string) (WorkflowInitView, error)
- func (s *Service) WorkflowList(ctx context.Context) ([]PolicySummary, []workflow.Issue, error)
- func (s *Service) WorkflowSignal(ctx context.Context, action, id, actor, reason, owner, token, expect string) (WorkflowView, error)
- func (s *Service) WorkflowStart(ctx context.Context, id, policyID, actor, reason, owner, token, expect string) (WorkflowView, error)
- func (s *Service) WorkflowStepComplete(ctx context.Context, id, to, actor, reason, owner, token, expect string) (WorkflowView, error)
- func (s *Service) WorkflowStepNext(ctx context.Context, id string) (WorkflowView, error)
- func (s *Service) WorkitemAddDependency(ctx context.Context, id, dependsOn, expect string) (WorkItemView, error)
- func (s *Service) WorkitemClaim(ctx context.Context, id, owner, reason, expect string) (ClaimView, error)
- func (s *Service) WorkitemComment(ctx context.Context, id, text, actor, replyTo string) (CommentView, error)
- func (s *Service) WorkitemCreate(ctx context.Context, req CreateWorkitemRequest) (WorkItemView, error)
- func (s *Service) WorkitemGet(ctx context.Context, id string) (WorkItemView, error)
- func (s *Service) WorkitemList(ctx context.Context, filter WorkitemFilter) ([]*domain.WorkItem, error)
- func (s *Service) WorkitemRelease(ctx context.Context, id, owner, token, actor, reason, expect string) (WorkItemView, error)
- func (s *Service) WorkitemRemoveDependency(ctx context.Context, id, dependsOn, expect string) (WorkItemView, error)
- func (s *Service) WorkitemStart(ctx context.Context, id, owner, token, actor, reason, expect string) (ClaimView, error)
- func (s *Service) WorkitemTransition(ctx context.Context, id, to, actor, reason, expect string) (WorkItemView, string, error)
- func (s *Service) WorkitemUpdate(ctx context.Context, id string, req UpdateWorkitemRequest) (WorkItemView, error)
- func (s *Service) WorkspaceList(ctx context.Context, workItemID string) ([]workspace.Listing, error)
- func (s *Service) WorkspacePrepare(ctx context.Context, req WorkspacePrepareRequest) (WorkspaceView, error)
- func (s *Service) WorkspaceRemove(ctx context.Context, req WorkspaceRemoveRequest) (workspace.RemoveReport, error)
- func (s *Service) WriteSkill() ([]string, error)
- type SessionAction
- type SessionContext
- type SessionIdentity
- type SessionProject
- type SessionRequest
- type SessionView
- type SessionWorkitem
- type SetupStep
- type SetupView
- type StateView
- type SweptAttempt
- type TaskContext
- type UpdateArtifactRequest
- type UpdateProjectRequest
- type UpdateRunRequest
- type UpdateStateRequest
- type UpdateWorkitemRequest
- type WireCheckLine
- type WireCheckView
- type WireView
- type WorkItemView
- type WorkflowInitView
- type WorkflowView
- type WorkitemContextView
- type WorkitemFilter
- type WorkspacePrepareRequest
- type WorkspaceRemoveRequest
- type WorkspaceView
Constants ¶
const ( KindUsage = "usage" KindPrecondition = "precondition" KindInternal = "internal" KindInvalid = "invalid" KindWorkflow = "workflow" KindGate = "gate" KindQuality = "quality" KindWorkitem = "workitem" KindApproval = "approval" KindKnowledge = "knowledge" )
Error kinds. The first four are the shared classes; the rest are display kinds that all collapse onto "invalid".
const ( MatchTrigger = "trigger" MatchSources = "sources" )
Knowledge match kinds.
const ( KnowledgeFresh = "fresh" KnowledgeStale = "stale" KnowledgeMissing = "missing" )
Status constants for KnowledgeStatusView.Status; the CLI maps them onto the reserved exit codes.
const ( // RunRunning is the status of an attempt that is executing. RunRunning = "running" RunSucceeded = "succeeded" RunFailed = "failed" RunTimedOut = "timed_out" RunStalled = "stalled" RunCanceled = "canceled" )
Terminal run statuses are the §4.8 vocabulary: an attempt either succeeded, failed, ran out of time, stalled or was canceled. The lifecycle commands speak exactly these words; the generic RunUpdate stays free-form for evidence accumulation.
const DefaultSetupTemplate = "quick-fix"
DefaultSetupTemplate is the starter policy `workloom setup` installs when the caller does not name one. An existing file is never overwritten.
const MCPProbeTimeout = 10 * time.Second
MCPProbeTimeout bounds the startup probe. A client that connects to a registered server must see an answer inside this window, otherwise the registration is reported as not working.
Variables ¶
This section is empty.
Functions ¶
func Classify ¶
Classify wraps an arbitrary error as an application error. Errors that are already classified pass through unchanged.
func MCPSnippet ¶
func MCPSnippet(name string, cmd MCPCommand, projectRoot string) (string, error)
MCPSnippet returns the copy-paste MCP client configuration for one harness.
File shapes written by `mcp install` were checked against the vendor docs (Codex command+args, Claude mcpServers command+args, OpenCode type local + command array, cwd not directory). JSONC and an inline Codex mcp_servers table are still refused, not rewritten. The snippet may include cwd; the installer does not write cwd.
Snippets pin `--tier core` (the daily subset). Progress / failure / block tools (`run_update`, `run_fail`, `workitem_block`) live at `--tier standard` or the CLI — core stays an explicit opt-in surface.
func SkillMainBody ¶
func SkillMainBody() string
SkillMainBody exposes the managed SKILL.md body for tests.
func WorkflowTemplates ¶
func WorkflowTemplates() []string
WorkflowTemplates lists the example workflow template ids available to `workflow init --template`, sorted for stable display.
Types ¶
type ApprovalFilter ¶
ApprovalFilter narrows an approval listing.
type AttemptSpawner ¶
AttemptSpawner starts one attempt: argv is the devsys command to run (run exec …) and logPath receives the attempt's stdout/stderr.
type ClaimView ¶
type ClaimView struct {
WorkitemID string `json:"workitem_id"`
RunID string `json:"run_id"`
Token string `json:"token"`
Status string `json:"status"`
// Notice carries a non-fatal warning for the caller to surface: today the
// "no workflow policy governs this work item" gap (gates not enforced).
Notice string `json:"notice,omitempty"`
}
ClaimView reports the claim's fresh run and lease credentials.
type CommentView ¶
CommentView reports one recorded comment event.
type CompletionCheck ¶
type CompletionCheck struct {
RunID string `json:"run_id"`
Workspace string `json:"workspace,omitempty"`
Branch string `json:"branch,omitempty"`
ClaimHead string `json:"claim_head,omitempty"`
CurrentHead string `json:"current_head,omitempty"`
Advanced bool `json:"advanced"`
Skipped bool `json:"skipped,omitempty"`
Reason string `json:"reason,omitempty"`
}
CompletionCheck is the evidence behind a completion: the head the attempt started from and the head its branch points at now (方案 §4.8). Skipped is set when git evidence does not apply (non-git project or directory workspace); Advanced stays false — skip is not a verified advance.
type ContextView ¶
type ContextView struct {
Project *domain.Project `json:"project"`
State domain.CurrentState `json:"state"`
Counts map[string]int `json:"counts"`
Verdict string `json:"verdict"`
Next any `json:"next"`
Risks any `json:"risks,omitempty"`
RecentDecisions []RecordRef `json:"recent_decisions"`
RecentFindings []RecordRef `json:"recent_findings"`
RecentArtifacts []RecordRef `json:"recent_artifacts"`
RecentEvents []EventRef `json:"recent_events"`
Notices []string `json:"notices,omitempty"`
}
ContextView is the working context an agent needs to orient without reading source: project facts, progress, the recommended action and the most recent records (as references — read the bodies on demand).
type CreateDecisionRequest ¶
type CreateDecisionRequest struct {
Title string
Context string
Decision string
Reasoning string
Options []string
Consequences []string
RelatedWorkItems []string
CreatedBy string
}
CreateDecisionRequest is the input to DecisionCreate.
type CreateFindingRequest ¶
type CreateFindingRequest struct {
Type string
Title string
Description string
Evidence []string
Severity string
RelatedWorkItems []string
RecommendedActions []string
DiscoveredByRunID string
}
CreateFindingRequest is the input to FindingCreate.
type CreateRunRequest ¶
type CreateRunRequest struct {
WorkItemID string
WorkflowID string
Phase string
Actor string
Reason string
Agent domain.RunAgent
Workspace domain.Workspace
}
CreateRunRequest is the input to RunCreate.
type CreateWorkitemRequest ¶
type CreateWorkitemRequest struct {
Title string
Description string
Type string
Prefix string
ParentID string
Priority int
Actor string
Reason string
AcceptanceCriteria []string
}
CreateWorkitemRequest is the input to WorkitemCreate.
type DecideApprovalRequest ¶
DecideApprovalRequest is the input to ApprovalApprove / ApprovalReject.
type DispatchReport ¶
type DispatchReport struct {
DryRun bool `json:"dry_run"`
Recover *reconcile.RecoverReport `json:"recover,omitempty"`
Plan dispatch.Report `json:"plan"`
Started []DispatchedAttempt `json:"started"`
// Swept lists the failed or stalled attempts the tick ended and requeued.
Swept []SweptAttempt `json:"swept,omitempty"`
Notices []string `json:"notices,omitempty"`
}
DispatchReport is what a tick did — or, under DryRun, what it would do.
type DispatchRequest ¶
type DispatchRequest struct {
Actor string
Reason string
// Max bounds how many attempts this tick starts (0 = the caps decide).
Max int
// DryRun plans and reports without recovering, claiming, preparing a
// workspace or starting anything.
DryRun bool
// Spawn starts one attempt and reports its process id. Nil uses this
// devsys binary as a child process; tests inject a recorder.
Spawn AttemptSpawner
}
DispatchRequest is one scheduling tick (方案 §4.8): recover, reconcile, then start the attempts the plan allows. Nothing here is a background service — a tick runs, reports, and returns.
type DispatchedAttempt ¶
type DispatchedAttempt struct {
WorkitemID string `json:"workitem_id"`
RunID string `json:"run_id"`
Workspace string `json:"workspace,omitempty"`
Command string `json:"command"`
PID int `json:"pid,omitempty"`
Log string `json:"log"`
}
DispatchedAttempt is one attempt a tick started.
type Error ¶
Error is a classified application failure.
func Invalidf ¶
Invalidf reports managed state that exists but cannot be trusted; kind is the display kind (invalid, workflow, gate, quality, workitem, approval).
func Preconditionf ¶
Preconditionf reports a state or environment precondition.
type EventListRequest ¶
type EventListRequest struct {
SubjectType string
SubjectID string
Type string
Since time.Time
Until time.Time
Limit int
}
EventListRequest filters the event stream.
type EventRef ¶
type EventRef struct {
ID string `json:"id"`
Type string `json:"type"`
Subject string `json:"subject"`
Actor string `json:"actor"`
Time time.Time `json:"time"`
}
EventRef is a pointer to one event.
type HeartbeatView ¶
type HeartbeatView struct {
WorkitemID string `json:"workitem_id"`
RunID string `json:"run_id"`
LeaseUntil time.Time `json:"lease_until"`
HeartbeatAt time.Time `json:"heartbeat_at"`
}
HeartbeatView reports the lease the heartbeat extended.
type KnowledgeContext ¶
type KnowledgeContext struct {
Baseline string `json:"baseline,omitempty"`
Pages []KnowledgePageRef `json:"pages"`
Degraded bool `json:"degraded,omitempty"`
Notice string `json:"notice,omitempty"`
}
KnowledgeContext is the knowledge layer's contribution to a task's context: references, not bodies. The pages stay one read away, and a project without a page layer degrades to an empty list with a notice (方案 §12.6).
type KnowledgePageRef ¶
type KnowledgePageRef struct {
Path string `json:"path"`
Description string `json:"description,omitempty"`
Type string `json:"type,omitempty"`
Status string `json:"status,omitempty"`
Match string `json:"match"`
Reason string `json:"reason,omitempty"`
Stale bool `json:"stale,omitempty"`
}
KnowledgePageRef is one page a task touches, with why it matched.
type KnowledgePageView ¶
type KnowledgePageView struct {
Path string `json:"path"`
Status string `json:"status,omitempty"`
Type string `json:"type,omitempty"`
Triggers int `json:"triggers"`
Sources int `json:"sources"`
SourceCommit string `json:"source_commit,omitempty"`
Protected bool `json:"protected,omitempty"`
Issues int `json:"issues,omitempty"`
}
KnowledgePageView summarizes one page for the validate report.
type KnowledgeRefreshRequest ¶
type KnowledgeRefreshRequest struct {
// Full regenerates every page; otherwise only the affected ones.
Full bool
// Force overrides the two protections the layer enforces: `protected: true`
// and hand-edited pages. Overridden pages are still reported (M5.4).
Force bool
}
KnowledgeRefreshRequest selects what a refresh asks the generator to rebuild.
type KnowledgeRefreshView ¶
type KnowledgeRefreshView struct {
Scope string `json:"scope"`
Pages []string `json:"pages"`
// Resumed is true when this run continued an interrupted one: its page list
// is the interrupted run's remainder, with the pages that had already been
// written left out.
Resumed bool `json:"resumed,omitempty"`
// Checkpoint is the run file this refresh wrote (.devsys/knowledge/run.json).
Checkpoint string `json:"checkpoint,omitempty"`
Generator string `json:"generator,omitempty"`
ScopeFile string `json:"scope_file,omitempty"`
Ran bool `json:"ran"`
Reason string `json:"reason,omitempty"`
Output string `json:"output,omitempty"`
// Missing is true when there is nothing here to regenerate: no page layer,
// or no generator configured. The CLI reports it with the `missing` exit
// code instead of pretending a refresh happened (方案 §12.6).
Missing bool `json:"missing,omitempty"`
// Skipped lists the pages the layer refused to regenerate and why (M5.4):
// `protected: true` locks, a hand-edited page's content is not the
// generator's to replace. With Force they were regenerated anyway and each
// entry says so.
Skipped []knowledge.Skip `json:"skipped,omitempty"`
// Finalized reports that the generator recorded a new baseline.
Finalized bool `json:"finalized,omitempty"`
// AwaitingGeneration lists the pages the generator cannot write by itself:
// RepoWiki writes pages through its skill, so its CLI alone leaves them for
// an agent (方案 §12.6).
AwaitingGeneration []string `json:"awaiting_generation,omitempty"`
// Failed reports a generator that ran and did not finish cleanly.
Failed bool `json:"failed,omitempty"`
// Error is the generator failure, when Failed.
Error string `json:"error,omitempty"`
// Status is the freshness report taken after a successful run.
Status *KnowledgeStatusView `json:"status,omitempty"`
}
KnowledgeRefreshView reports one refresh attempt.
type KnowledgeScanExclusion ¶
KnowledgeScanExclusion is one path the index left out, with its reason.
type KnowledgeScanView ¶
type KnowledgeScanView struct {
File string `json:"file"`
GeneratedAt time.Time `json:"generated_at"`
Files int `json:"files"`
TotalSize int64 `json:"total_size"`
Languages map[string]int `json:"languages"`
Excluded []KnowledgeScanExclusion `json:"excluded"`
ExcludedDirectories []string `json:"excluded_directories"`
IgnoreFiles []string `json:"ignore_files,omitempty"`
Rules []string `json:"rules"`
}
KnowledgeScanView reports one index scan (M5.2). The exclusion list travels with the result: an index that is smaller than the tree must say why.
type KnowledgeStatusView ¶
type KnowledgeStatusView struct {
Status string `json:"status"`
Layer string `json:"layer"`
Reason string `json:"reason,omitempty"`
// Baseline is the layer baseline from the generator's state. It is empty
// until a generator writes state.json: the layer has no baseline of its own,
// and the per-page `source_commit` values are what a verdict then rests on.
Baseline string `json:"baseline,omitempty"`
Head string `json:"head,omitempty"`
Branch string `json:"branch,omitempty"`
// IndexReady reports whether the file index has been built (M5.2).
IndexReady bool `json:"index_ready"`
// IndexFiles is the index's file count when it has been built.
IndexFiles int `json:"index_files,omitempty"`
// Pages is the page-layer size; zero means the layer has not been generated.
Pages int `json:"pages"`
// Generator is the configured generator, if any.
Generator string `json:"generator,omitempty"`
// Adapter is the built-in adapter backing that generator, when it names one
// (方案 §12.6); AdapterInstalled reports whether the tool it drives is on
// PATH.
Adapter string `json:"adapter,omitempty"`
AdapterInstalled bool `json:"adapter_installed,omitempty"`
AdapterDetail string `json:"adapter_detail,omitempty"`
ChangedFiles int `json:"changed_files"`
Affected []string `json:"affected_pages"`
Unverifiable []string `json:"unverifiable_pages,omitempty"`
// FreshPages counts pages with a verdict of fresh.
FreshPages int `json:"fresh_pages"`
}
KnowledgeStatusView is the layer's freshness report (M5.3, 方案 §12.5). The status field is the contract CI reads through the exit code: fresh (0), stale (10) or missing (11).
type KnowledgeValidateView ¶
type KnowledgeValidateView struct {
Roots []string `json:"roots"`
Missing bool `json:"missing,omitempty"`
Pages []KnowledgePageView `json:"pages"`
Errors int `json:"errors"`
Warnings int `json:"warnings"`
Issues []config.Problem `json:"issues,omitempty"`
}
KnowledgeValidateView is the page layer's validation result. Errors are located problems that make a page unusable; warnings are advisories.
type MCPCommand ¶ added in v0.1.12
MCPCommand is the executable form written into MCP client configuration. Args precede the serve arguments (Codex and Claude spawn Command with Args; OpenCode uses one command array).
func MCPCommandFor ¶ added in v0.1.12
func MCPCommandFor(exe string) MCPCommand
MCPCommandFor resolves the running executable (os.Args[0] in the CLI).
func ResolveMCPCommand ¶ added in v0.1.12
func ResolveMCPCommand(exe string, lookPath func(string) (string, error)) MCPCommand
ResolveMCPCommand maps an executable path onto the form written into client configs. Paths outside node_modules are returned unchanged; an npm-managed path is replaced by node + the wrapper script when the wrapper package is found next to it and node is available.
Two npm layouts have to be covered: the platform package nested inside the wrapper (what a global install produces today) and hoisted next to it under the same node_modules (what a project-local install produces).
func (MCPCommand) ServeArgs ¶ added in v0.1.12
func (c MCPCommand) ServeArgs(serve []string) []string
ServeArgs returns the full argv handed to the MCP client.
type MCPInstallRequest ¶ added in v0.1.9
type MCPInstallRequest struct {
Scope string
Clients []string
Apply bool
Force bool
DryRun bool
Bin string
HomeDir string
Announce func(client, path string)
// contains filtered or unexported fields
}
MCPInstallRequest describes one `workloom mcp install` run. Clients empty means every known client; Bin and HomeDir are test hooks (empty = the running devsys binary / the operator's home directory).
Writing happens only when Apply is set and DryRun is not. The default (neither flag) is a dry-run. Force replaces an existing devsys entry; without it an existing entry is left untouched. Announce, when set, is called with the target path before any write.
type MCPInstallResult ¶ added in v0.1.9
type MCPInstallResult struct {
Client string `json:"client"`
Status string `json:"status"`
Detail string `json:"detail"`
Path string `json:"path"`
}
MCPInstallResult is one client's outcome. Status is one of installed, planned (dry-run), skipped (already registered), failed, not-detected.
type MCPInstallView ¶ added in v0.1.9
type MCPInstallView struct {
Scope string `json:"scope"`
Results []MCPInstallResult `json:"results"`
Probe *MCPProbeResult `json:"probe,omitempty"`
}
MCPInstallView is the `workloom mcp install` report. Probe is the result of starting the registered command once: writing a config is not evidence that the server runs, so both are reported.
type MCPProbeResult ¶ added in v0.1.12
type MCPProbeResult struct {
OK bool `json:"ok"`
Skipped bool `json:"skipped,omitempty"`
Tools int `json:"tools"`
DurationMS int64 `json:"duration_ms"`
Detail string `json:"detail,omitempty"`
}
MCPProbeResult is the outcome of one `mcp serve` startup probe. It is data, not an error: the caller decides whether a failed probe fails the command. Skipped marks a probe that was not run (DEVSYS_MCP_PROBE=0) — that is "not checked", not "working".
func ProbeMCPServer ¶ added in v0.1.12
func ProbeMCPServer(ctx context.Context, cmd MCPCommand, serve []string, cwd string) MCPProbeResult
ProbeMCPServer starts the registered command, completes the MCP initialize handshake and lists the tool surface — the same three steps the first client to connect will take. Writing a config file is not evidence that the server starts, so the caller reports both.
type PolicySummary ¶
type PolicySummary struct {
File string `json:"file"`
ID string `json:"id"`
Name string `json:"name"`
Version int `json:"version"`
}
PolicySummary is the JSON view of one valid policy file.
type ProjectEntry ¶
type ProjectEntry struct {
ID string `json:"id"`
Path string `json:"path"`
LastSeenAt string `json:"last_seen_at"`
Exists bool `json:"exists"`
Current bool `json:"current"`
}
ProjectEntry is one registry entry annotated with existence.
type ProjectStatusView ¶
type ProjectStatusView struct {
Project *domain.Project `json:"project"`
Counts map[string]int `json:"counts"`
Verdict string `json:"verdict"`
Risks []next.Risk `json:"risks"`
Next next.Recommendation `json:"next"`
}
ProjectStatusView aggregates the project facts an agent needs to orient.
type ProjectView ¶
type ProjectView struct {
Project *domain.Project `json:"project"`
Version string `json:"version"`
}
ProjectView is the project metadata plus the version hash of its file.
type RecordEventRequest ¶
type RecordEventRequest struct {
Type string
Subject domain.Reference
Actor string
Content string
Related []domain.Reference
ReplyTo string
}
RecordEventRequest is the input to EventRecord.
type RecordRef ¶
type RecordRef struct {
Ref string `json:"ref"`
Title string `json:"title"`
Status string `json:"status"`
UpdatedAt time.Time `json:"updated_at,omitempty"`
}
RecordRef is a pointer to a record: identity, title, status and when it changed. The body stays one read away (`decision_get`, `finding_get`, …).
type RecordView ¶
type RecordView struct {
Decision *domain.Decision `json:"decision,omitempty"`
Finding *domain.Finding `json:"finding,omitempty"`
Artifact *domain.Artifact `json:"artifact,omitempty"`
Version string `json:"version,omitempty"`
}
RecordView is one record plus the version hash the surfaces report and the update guards consume.
type RegisterArtifactRequest ¶
type RegisterArtifactRequest struct {
Type string
Name string
Path string
Source string
CreatedByRunID string
Status string
RelatedWorkItems []string
// Actor and Reason are the mandatory audit trail for the write.
Actor string
Reason string
}
RegisterArtifactRequest is the input to ArtifactRegister.
type RequestApprovalRequest ¶
type RequestApprovalRequest struct {
WorkItemID string
Stage string
Scope string
RunID string
Actor string
Reason string
}
RequestApprovalRequest is the input to ApprovalRequest.
type RunExecRequest ¶
type RunExecRequest struct {
RunID string
Argv []string
Timeout time.Duration
// Round selects the session round; 0 continues the session (round 1 when
// nothing ran yet). The first round carries the full prompt, later rounds
// the delta only (方案 §4.8).
Round int
// Harness names the harness adapter to drive (方案 §9.3). When set, the
// adapter builds the command from the assembled prompt and Argv must be
// empty; when empty, Argv is run as given (the shell path).
Harness string
Model string
Actor string
Reason string
Sink func(harness.Line)
}
RunExecRequest is one attempt driven through a harness adapter (实施计划 M6.1/M6.3). Sink receives every streamed line as it is persisted; nil means nobody is watching (dispatch, background execution).
type RunExecView ¶
type RunExecView struct {
RunID string `json:"run_id"`
Adapter string `json:"adapter"`
Command string `json:"command"`
Dir string `json:"dir"`
Round int `json:"round"`
Mode string `json:"prompt_mode"`
PromptHash string `json:"prompt_hash"`
PromptFile string `json:"prompt_file,omitempty"`
Phase string `json:"phase"`
// Status is how this round ended; RunStatus is where the run stands after
// it. A clean round leaves the run running — the session may continue
// (§4.8 schedules a continuation check), and only completion, failure,
// timeout, stall or cancellation ends the attempt.
Status string `json:"status"`
RunStatus string `json:"run_status"`
ExitCode int `json:"exit_code"`
TimedOut bool `json:"timed_out"`
Canceled bool `json:"canceled"`
DurationMS int64 `json:"duration_ms"`
Lines int `json:"lines"`
Log string `json:"log"`
Warnings []string `json:"warnings,omitempty"`
}
RunExecView is the outcome of one attempt. ExitCode is the command's own exit code (-1 when it has none: killed by a signal, or never started) — devsys's own exit code stays reserved for devsys operations (0 ran and recorded, 2 usage, 3 precondition, 4 untrusted state, 1 internal).
type RunFinishRequest ¶
type RunFinishRequest struct {
RunID string
Expect string
Outcome string
Actor string
Reason string
// Note is optional detail kept with the run's result evidence.
Note string
// Force lets a reviewer record an outcome the completion check refused.
// It requires By: an exception to "no evidence, no verified" has to be
// traceable to a person (方案 §4.8).
Force bool
By string
}
RunFinishRequest records how an attempt ended when the outcome is decided by a caller rather than by a command's exit status: an operator, the dispatch tick (M6.4) or a harness reporting through the tool surface.
type RunListRequest ¶
RunListRequest filters the run listing.
type RunLogView ¶
type RunLogView struct {
RunID string `json:"run_id"`
Status string `json:"status"`
Phase string `json:"phase"`
Logs []string `json:"logs"`
Commands []string `json:"commands"`
Tests []string `json:"tests"`
ChangedFiles []string `json:"changed_files"`
Result domain.RunResult `json:"result"`
Events []*domain.Event `json:"events,omitempty"`
}
RunLogView is the evidence trail a run accumulated.
type RunPromptRequest ¶
type RunPromptRequest struct {
RunID string
// Round selects the round; 0 assembles the next one.
Round int
// Write materializes the text under .devsys/local/runs/<run-id>/ (not
// committed, regenerable) and reports the path.
Write bool
}
RunPromptRequest assembles one round's prompt for a run.
type RunPromptView ¶
type RunPromptView struct {
RunID string `json:"run_id"`
Round int `json:"round"`
Mode string `json:"mode"`
Hash string `json:"hash"`
Path string `json:"path,omitempty"`
Refs []string `json:"refs"`
Text string `json:"text"`
Notices []string `json:"notices,omitempty"`
// Snapshot is what this round's context was assembled from; it is recorded
// with the round so the attempt's evidence says what the agent saw (方案 §11.3).
Snapshot prompt.Snapshot `json:"snapshot"`
}
RunPromptView is one assembled round: the text the harness receives, its hash (the only proof of what was handed over) and the pointers it refers to.
type Service ¶
type Service struct {
Root string
// Now is the clock; nil means time.Now().UTC().
Now func() time.Time
}
Service is the application service bound to one project root.
func (*Service) ApprovalApprove ¶
func (s *Service) ApprovalApprove(ctx context.Context, req DecideApprovalRequest) (*domain.Approval, error)
ApprovalApprove records an approval decision.
func (*Service) ApprovalGet ¶
ApprovalGet reads one approval.
func (*Service) ApprovalList ¶
func (s *Service) ApprovalList(ctx context.Context, filter ApprovalFilter) ([]*domain.Approval, error)
ApprovalList lists approvals (newest last, store order).
func (*Service) ApprovalReject ¶
func (s *Service) ApprovalReject(ctx context.Context, req DecideApprovalRequest) (*domain.Approval, string, error)
ApprovalReject rejects an approval. A stage-gate rejection commits the decision and the work item disposition in ONE transaction (the decision rides the transition's Guard), so a failed disposition leaves the approval pending instead of half-applying (方案 §4.9). The returned disposition is the status the work item moved to ("" for action-scope approvals).
func (*Service) ApprovalRequest ¶
func (s *Service) ApprovalRequest(ctx context.Context, req RequestApprovalRequest) (*domain.Approval, string, error)
ApprovalRequest records a pending approval. The returned warning (if any) names a stage-gate request no policy will ever consume.
func (*Service) ArtifactGet ¶
ArtifactGet reads one artifact with its version hash.
func (*Service) ArtifactHistory ¶
ArtifactHistory walks the previous_id chain (newest first).
func (*Service) ArtifactList ¶
ArtifactList lists every artifact in ascending ID order.
func (*Service) ArtifactRegister ¶
func (s *Service) ArtifactRegister(ctx context.Context, req RegisterArtifactRequest) (RecordView, error)
ArtifactRegister stores a new artifact record (version 1).
func (*Service) ArtifactUpdate ¶
func (s *Service) ArtifactUpdate(ctx context.Context, req UpdateArtifactRequest) (RecordView, error)
ArtifactUpdate appends a new version linked to the previous one (records are immutable: the old file is never rewritten).
func (*Service) ContextCompact ¶
func (s *Service) ContextCompact(ctx context.Context) (ContextView, error)
ContextCompact returns the smallest useful context: project identity, progress counts and the recommended action, without record references.
func (*Service) ContextForWorkitem ¶
func (s *Service) ContextForWorkitem(ctx context.Context, id string, paths []string) (WorkitemContextView, error)
ContextForWorkitem assembles everything an executor needs about one work item: the item itself, its workflow candidates, and the records that reference it. ContextForWorkitem assembles the task's context. paths are the files the caller expects to touch: pages whose `sources` cover them join the page list even when no trigger matches, which is what makes the third layer useful before any code has been read.
func (*Service) ContextGet ¶
ContextGet assembles the project working context. limit bounds each reference list (0 selects the default of 5).
func (*Service) ContextRefresh ¶
ContextRefresh is ContextGet with the policy and readiness notices spelled out: the caller asked for a fresh evaluation, so fallbacks are surfaced rather than summarized away.
func (*Service) DecisionApprove ¶
DecisionApprove marks a decision approved by the given decider, under the version guard.
func (*Service) DecisionCreate ¶
func (s *Service) DecisionCreate(ctx context.Context, req CreateDecisionRequest) (RecordView, error)
DecisionCreate stores a decision (一记录一文件, ID assigned by the store).
func (*Service) DecisionGet ¶
DecisionGet reads one decision with its version hash.
func (*Service) DecisionList ¶
DecisionList lists every decision in ascending ID order.
func (*Service) Dispatch ¶
func (s *Service) Dispatch(ctx context.Context, req DispatchRequest) (DispatchReport, error)
Dispatch runs one scheduling tick: it recovers interrupted state, releases expired and orphaned claims, plans the dispatchable work items (ordering, concurrency gates and the blocked_by precondition — §7.4), and starts the attempts the plan allows. Starting means: claim, prepare the workspace, spawn the attempt, mark the work item running — each attempt gets its own run, workspace and prompt (M6.2/M6.3).
A candidate that cannot start for a precondition reason (invalid policy, quality gate, workspace failure) is reported in Notices and does not stop the tick: one broken item must not hold the queue.
func (*Service) EventRecord ¶
EventRecord appends one event (append-only; no version guard).
func (*Service) FindingCreate ¶
func (s *Service) FindingCreate(ctx context.Context, req CreateFindingRequest) (RecordView, error)
FindingCreate stores a finding.
func (*Service) FindingGet ¶
FindingGet reads one finding with its version hash.
func (*Service) FindingList ¶
FindingList lists every finding in ascending ID order.
func (*Service) FindingResolve ¶
func (s *Service) FindingResolve(ctx context.Context, id, resolution, expect string) (RecordView, error)
FindingResolve closes a finding under the version guard.
func (*Service) KnowledgeRefresh ¶
func (s *Service) KnowledgeRefresh(ctx context.Context, req KnowledgeRefreshRequest) (KnowledgeRefreshView, error)
KnowledgeRefresh hands the generator the pages that need regenerating (方案 §12.5/§12.6). Without a generator there is nothing to run: the answer is the documented degradation, and the caller reports it with the `missing` exit code instead of pretending the work happened.
func (*Service) KnowledgeScan ¶
func (s *Service) KnowledgeScan(ctx context.Context) (KnowledgeScanView, error)
KnowledgeScan builds the index layer's snapshot of the working tree and writes it to .devsys/knowledge/snapshot.json (M5.2, 方案 §12.2). It reads the tree and git only; nothing else in .devsys/ is touched.
func (*Service) KnowledgeStatus ¶
func (s *Service) KnowledgeStatus(ctx context.Context) (KnowledgeStatusView, error)
KnowledgeStatus reports whether the page layer still describes the working tree (M5.3). A project without pages is `missing`, not an error: not having a generator is a supported degradation (方案 §12.6). Git failures are errors — §12.5 forbids answering "fresh" when the baseline is unknown.
func (*Service) KnowledgeValidate ¶
func (s *Service) KnowledgeValidate(ctx context.Context, roots []string) (KnowledgeValidateView, error)
KnowledgeValidate checks the page layer's front matter contract (方案 §12.5, M5.1). Explicit roots — from the command line or `knowledge_pages` — must exist; the built-in candidates that do not exist are skipped, and no page layer at all is reported as `missing` rather than as a failure: not having a generator is a supported degradation (方案 §12.6). Errors refuse the call (exit code 4) with every located problem, warnings included.
func (*Service) MCPInstall ¶ added in v0.1.9
func (s *Service) MCPInstall(ctx context.Context, req MCPInstallRequest) (*MCPInstallView, error)
MCPInstall registers the devsys MCP server with Codex / Claude Code / OpenCode config files. Existing files are preserved byte-for-byte outside the inserted entry; anything unreadable or non-strict is refused (fail closed) with a `wire --print-mcp` pointer instead of a guessed rewrite.
func (*Service) Next ¶
Next evaluates the readiness verdict and the single recommended next action (方案 §7.4, 实施计划 M3.4). Like doctor it never writes, recovers or creates the local lock; while pending transactions exist — or no writer ever ran — it reports without rendering business facts (方案 §15.4).
The returned work items are the facts the evaluation consumed; they are empty whenever the inspection is not trustworthy.
func (*Service) ProjectBlueprint ¶
ProjectBlueprint returns the artifact the project declares as its blueprint. A project that declares none is a normal state, not a failure: the caller gets (nil, nil) and reports "no blueprint declared" as a result, so a read-only query exits 0 the way `project status` and `next` do.
func (*Service) ProjectCreate ¶
ProjectCreate initializes a project at path (default: the service root) and registers it in the user-level registry (方案 §14.4).
func (*Service) ProjectGet ¶
func (s *Service) ProjectGet(ctx context.Context) (ProjectView, error)
ProjectGet reads the project metadata (validated, read-only).
func (*Service) ProjectList ¶
func (s *Service) ProjectList(ctx context.Context) ([]ProjectEntry, error)
ProjectList lists the user-level registry (方案 §14.4): paths and identity only, never project state.
func (*Service) ProjectStateGet ¶
ProjectStateGet reads state/current.yaml.
func (*Service) ProjectStateUpdate ¶
func (s *Service) ProjectStateUpdate(ctx context.Context, req UpdateStateRequest) (StateView, error)
ProjectStateUpdate applies a current-state patch under the version guard.
func (*Service) ProjectStatus ¶
func (s *Service) ProjectStatus(ctx context.Context) (ProjectStatusView, error)
ProjectStatus reports the project metadata, work item counts by status and the readiness verdict (same evaluation `workloom next` renders).
func (*Service) ProjectUpdate ¶
func (s *Service) ProjectUpdate(ctx context.Context, req UpdateProjectRequest) (ProjectView, error)
ProjectUpdate applies a metadata patch under the version guard.
func (*Service) RunCreate ¶
RunCreate records a standalone run for a work item. Claim-created runs (the normal path) carry lease credentials; a standalone run carries none, so it must not be treated as an active claim.
func (*Service) RunExec ¶
func (s *Service) RunExec(ctx context.Context, req RunExecRequest) (RunExecView, error)
RunExec runs one attempt round for a run: it enforces the workspace invariants and the before_run hook (§4.8), assembles the round's prompt, streams both output streams into the run's event stream (.devsys/runs/<id>.jsonl, §14.2) while forwarding them to the sink, then records the evidence on the run and in the event log — including the §4.8 phase progression and the terminal status.
func (*Service) RunFinish ¶
RunFinish writes the terminal status, the finish time and a run_finished event under the version guard. Ending a run that already ended is refused rather than silently repeated, so two actors cannot both claim the outcome.
func (*Service) RunHeartbeat ¶
func (s *Service) RunHeartbeat(ctx context.Context, runID, owner, token, actor, reason string, extendBy time.Duration) (HeartbeatView, error)
RunHeartbeat extends the lease of the run's work item (owner and token must match the active lease — the same contract claim/release use).
func (*Service) RunPrompt ¶
func (s *Service) RunPrompt(ctx context.Context, req RunPromptRequest) (RunPromptView, error)
RunPrompt assembles a round's prompt from the run's own facts: the first round carries the task brief, the rendered policy body, the readiness state, the context pointers and the reporting protocol; later rounds carry only what changed and what is left (方案 §4.8). Assembly is deterministic, so the same round can be replayed and compared by hash.
func (*Service) RunUpdate ¶
RunUpdate applies a run patch (evidence accumulation; lifecycle authority stays with the executor paths).
func (*Service) RunVerify ¶
RunVerify reports whether an attempt's work advanced its branch, without changing anything: the read-only half of the completion check.
func (*Service) SessionStart ¶
func (s *Service) SessionStart(ctx context.Context, req SessionRequest) (SessionView, error)
SessionStart assembles the first call of a session (方案 §8.3, 实施计划 M4.4). It is read-only: the harness's own agent identity is reported back, never recorded, so starting a session cannot change project state.
func (*Service) Setup ¶ added in v0.1.9
Setup runs the project onboarding sequence and stops at the first hard failure. It composes the existing service methods; it does not add a second write path. Re-running is idempotent: an existing policy file is left in place.
func (*Service) SkillStatus ¶
SkillStatus reports whether the skill files exist and carry our marker.
func (*Service) TaskContext ¶
func (s *Service) TaskContext(ctx context.Context, id string, paths []string, limit int, refresh bool) (TaskContext, error)
TaskContext assembles the layers around one work item. paths are the files the caller expects to touch; refresh asks for a fresh policy evaluation instead of a summarized one.
func (*Service) Wire ¶
Wire injects the managed block into the repository's AGENTS.md, idempotently: running it three times leaves the file byte-identical, and content outside the block is never touched. With dryRun it reports the diff instead of writing.
func (*Service) WireCheck ¶
func (s *Service) WireCheck() WireCheckView
WireCheck inspects the operator environment without writing anything: no lock, no recovery, no file creation.
func (*Service) WorkflowGet ¶
WorkflowGet reads one work item's instance and, when the policy resolves, its step candidates.
func (*Service) WorkflowInitTemplate ¶
WorkflowInitTemplate installs one embedded example policy as .devsys/workflows/<id>.md, the directory workflow.Load reads. An existing file is never overwritten: the operator's edits win, and re-running init says so instead of silently resetting the policy.
func (*Service) WorkflowList ¶
WorkflowList scans the policy files (the data behind `workflow check`): valid policies plus every located issue, errors and warnings apart.
func (*Service) WorkflowSignal ¶
func (s *Service) WorkflowSignal(ctx context.Context, action, id, actor, reason, owner, token, expect string) (WorkflowView, error)
WorkflowSignal pauses, resumes or cancels an instance.
func (*Service) WorkflowStart ¶
func (s *Service) WorkflowStart(ctx context.Context, id, policyID, actor, reason, owner, token, expect string) (WorkflowView, error)
WorkflowStart attaches and starts a workflow instance (dispatch-like: the policy must be currently valid).
func (*Service) WorkflowStepComplete ¶
func (s *Service) WorkflowStepComplete(ctx context.Context, id, to, actor, reason, owner, token, expect string) (WorkflowView, error)
WorkflowStepComplete advances the instance (declaration order unless a target step is named); refusals carry the allowed candidates.
func (*Service) WorkflowStepNext ¶
WorkflowStepNext evaluates the step candidates without writing anything.
func (*Service) WorkitemAddDependency ¶
func (s *Service) WorkitemAddDependency(ctx context.Context, id, dependsOn, expect string) (WorkItemView, error)
WorkitemAddDependency records that id depends on dependsOn.
func (*Service) WorkitemClaim ¶
func (s *Service) WorkitemClaim(ctx context.Context, id, owner, reason, expect string) (ClaimView, error)
WorkitemClaim claims a ready work item after the claim quality gate, and returns the fresh run credentials.
func (*Service) WorkitemComment ¶
func (s *Service) WorkitemComment(ctx context.Context, id, text, actor, replyTo string) (CommentView, error)
WorkitemComment appends a comment event on a work item (方案 §4.6).
func (*Service) WorkitemCreate ¶
func (s *Service) WorkitemCreate(ctx context.Context, req CreateWorkitemRequest) (WorkItemView, error)
WorkitemCreate creates a draft work item (ID assignment is CAS-guarded).
func (*Service) WorkitemGet ¶
WorkitemGet reads one work item with its version hash.
func (*Service) WorkitemList ¶
func (s *Service) WorkitemList(ctx context.Context, filter WorkitemFilter) ([]*domain.WorkItem, error)
WorkitemList returns the work items matching the filter, in store order.
func (*Service) WorkitemRelease ¶
func (s *Service) WorkitemRelease(ctx context.Context, id, owner, token, actor, reason, expect string) (WorkItemView, error)
WorkitemRelease releases an active lease (owner and token must match).
func (*Service) WorkitemRemoveDependency ¶
func (s *Service) WorkitemRemoveDependency(ctx context.Context, id, dependsOn, expect string) (WorkItemView, error)
WorkitemRemoveDependency drops a recorded dependency.
func (*Service) WorkitemStart ¶
func (s *Service) WorkitemStart(ctx context.Context, id, owner, token, actor, reason, expect string) (ClaimView, error)
WorkitemStart moves a claimed work item into its run (owner and token must match the active lease).
func (*Service) WorkitemTransition ¶
func (s *Service) WorkitemTransition(ctx context.Context, id, to, actor, reason, expect string) (WorkItemView, string, error)
WorkitemTransition advances the state machine through the stage gate (and consumes the matching approval in the same transaction). The returned notice carries a last-known-good fallback note for the caller to surface.
func (*Service) WorkitemUpdate ¶
func (s *Service) WorkitemUpdate(ctx context.Context, id string, req UpdateWorkitemRequest) (WorkItemView, error)
WorkitemUpdate applies a patch under the version guard. Actor and reason are mandatory: every write carries an audit trail (手册「凡写命令都要 actor+reason」), recorded as a workitem_updated event.
func (*Service) WorkspaceList ¶
func (s *Service) WorkspaceList(ctx context.Context, workItemID string) ([]workspace.Listing, error)
WorkspaceList reports the workspaces below the root (read-only).
func (*Service) WorkspacePrepare ¶
func (s *Service) WorkspacePrepare(ctx context.Context, req WorkspacePrepareRequest) (WorkspaceView, error)
WorkspacePrepare ensures the work item's workspace exists and, when a run is named, binds it to that run under the version guard. A workspace that exists is reused without running after_create again; a broken policy blocks the dispatch (the same fail-closed rule claim uses), while a non-fatal hook failure is reported as a warning.
func (*Service) WorkspaceRemove ¶
func (s *Service) WorkspaceRemove(ctx context.Context, req WorkspaceRemoveRequest) (workspace.RemoveReport, error)
WorkspaceRemove takes the workspace down: the before_remove hook first (its failure is recorded, never fatal), then the worktree registration and the directory. The branch is kept — it may hold the run's commits.
func (*Service) WriteSkill ¶
WriteSkill writes the skill files idempotently: existing files carrying our marker are refreshed to the current body, files without the marker are left untouched (hand-written skill wins), missing files are created. It returns the paths it created or refreshed.
type SessionAction ¶
type SessionAction struct {
Type string `json:"type"`
ID string `json:"id,omitempty"`
Reason string `json:"reason"`
Command string `json:"command,omitempty"`
}
SessionAction is the recommended next action, with the command that performs it.
type SessionContext ¶
type SessionContext struct {
ProjectSummary string `json:"project_summary"`
RelevantDecisions []RecordRef `json:"relevant_decisions"`
RecentFindings []RecordRef `json:"recent_findings"`
RelevantArtifacts []RecordRef `json:"relevant_artifacts"`
// RecentEvents is omitted in compact mode by design (the key is absent
// rather than empty).
RecentEvents []EventRef `json:"recent_events,omitempty"`
}
SessionContext is the background a session should have: the project summary plus references to the decisions, findings and artifacts that matter. Bodies stay one read away.
type SessionIdentity ¶
type SessionIdentity struct {
Harness string `json:"harness,omitempty"`
AgentID string `json:"agent_id,omitempty"`
Workspace string `json:"workspace,omitempty"`
Intent string `json:"intent,omitempty"`
}
SessionIdentity echoes what the caller declared. It is never persisted and does not steer the recommendation (a session start must not change state); M6 may use the workspace when it scopes runs.
type SessionProject ¶
type SessionProject struct {
ID string `json:"id"`
Name string `json:"name"`
CurrentPhase string `json:"current_phase"`
}
SessionProject is the project identity a session reports.
type SessionRequest ¶
type SessionRequest struct {
Harness string
AgentID string
Workspace string
Intent string
// Compact trims the context payload for small windows: fewer references
// and no per-item detail beyond the essentials.
Compact bool
}
SessionRequest is the input to SessionStart (方案 §8.3): who is starting, where, and with what intent.
type SessionView ¶
type SessionView struct {
Session SessionIdentity `json:"session"`
Project SessionProject `json:"project"`
State domain.CurrentState `json:"state"`
CurrentWorkitems []SessionWorkitem `json:"current_workitems"`
RecommendedNextAction SessionAction `json:"recommended_next_action"`
Context SessionContext `json:"context"`
Notices []string `json:"notices,omitempty"`
}
SessionView is the one-shot orientation a new session needs: project facts, current state, work in flight, the single recommended next action, and the context behind it. One call, no follow-up queries required.
type SessionWorkitem ¶
type SessionWorkitem struct {
ID string `json:"id"`
Status string `json:"status"`
Title string `json:"title"`
Priority int `json:"priority"`
UpdatedAt time.Time `json:"updated_at"`
}
SessionWorkitem is one in-flight work item.
type SetupStep ¶ added in v0.1.9
type SetupStep struct {
Name string `json:"name"`
OK bool `json:"ok"`
Skipped bool `json:"skipped,omitempty"`
Detail string `json:"detail"`
}
SetupStep is one line of the setup report. OK false on blueprint or mcp is a report, not a failure: those steps do not write and do not gate Ready.
type SetupView ¶ added in v0.1.9
type SetupView struct {
Ready bool `json:"ready"`
Template string `json:"template"`
Steps []SetupStep `json:"steps"`
Next string `json:"next,omitempty"`
}
SetupView is the product onboarding report. Ready means init, the starter workflow, wire, config, and doctor succeeded. A missing blueprint or MCP client config is reported in Steps and Next; setup does not invent either.
type StateView ¶
type StateView struct {
State *domain.CurrentStateFile `json:"state"`
Version string `json:"version"`
}
StateView is the current-state document plus its version hash.
type SweptAttempt ¶
type SweptAttempt struct {
WorkitemID string `json:"workitem_id"`
RunID string `json:"run_id"`
Action string `json:"action"` // retry_queued | released
Reason string `json:"reason"`
Attempts int `json:"attempts"`
NextAttemptAt *time.Time `json:"next_attempt_at,omitempty"`
}
SweptAttempt is one failed or stalled attempt the tick acted on.
type TaskContext ¶
type TaskContext struct {
Summary ContextView `json:"summary"`
Task WorkitemContextView `json:"task"`
}
TaskContext is the layered assembly for one task (方案 §11.1): the project summary, the task's own context and records, and the knowledge pages the task touches. Two assemblies of the same task are identical field for field — an agent that re-reads its context must not see a different world.
type UpdateArtifactRequest ¶
type UpdateArtifactRequest struct {
ID string
Expect string
Status string
Path string
Source string
RelatedWorkItems []string
}
UpdateArtifactRequest appends a new artifact version.
type UpdateProjectRequest ¶
type UpdateProjectRequest struct {
Name *string
Description *string
Status *string
CurrentPhase *string
BlueprintArtifactID *string
Expect string
}
UpdateProjectRequest patches project metadata. Nil fields stay untouched; a pointer to an empty string clears the field; Expect is the version hash from ProjectGet.
type UpdateRunRequest ¶
type UpdateRunRequest struct {
ID string
Expect string
Status *string
Phase *string
AddLogs []string
AddCommands []string
AddTests []string
ChangedFiles []string
Result *domain.RunResult
}
UpdateRunRequest patches a run under the version guard. Add* fields append.
type UpdateStateRequest ¶
type UpdateStateRequest struct {
Summary *string
Risks []string
Blockers []string
NextFocus []string
Expect string
}
UpdateStateRequest patches state/current.yaml. Nil/empty collections stay untouched; Expect is the version hash from ProjectStateGet.
type UpdateWorkitemRequest ¶
type UpdateWorkitemRequest struct {
Title *string
Description *string
Priority *int
AcceptanceCriteria []string
Dependencies []string
Constraints []string
// AssignedAgent and AssignedHarness say who should work the item; the
// harness is what dispatch resolves an adapter from (方案 §9.3).
AssignedAgent *string
AssignedHarness *string
Expect string
// Actor and Reason are the mandatory audit trail for the write.
Actor string
Reason string
}
UpdateWorkitemRequest patches mutable work item fields. Nil fields are left untouched; Expect is the version hash from WorkitemGet.
type WireCheckLine ¶
type WireCheckLine struct {
Name string `json:"name"`
OK bool `json:"ok"`
Detail string `json:"detail"`
}
WireCheckLine is one environment line of `workloom wire --check`.
type WireCheckView ¶
type WireCheckView struct {
Lines []WireCheckLine `json:"lines"`
}
WireCheckView is the read-only environment report: toolchain, project, registry, AGENTS.md block and skill files. Inspecting never writes.
type WireView ¶
type WireView struct {
Path string `json:"path"`
Changed bool `json:"changed"`
Created bool `json:"created"`
Diff string `json:"diff,omitempty"`
}
WireView reports what `workloom wire` did (or would do).
type WorkItemView ¶
WorkItemView is one work item plus the version hash every mutation consumes (方案 §15.2 乐观并发).
type WorkflowInitView ¶
type WorkflowInitView struct {
Template string `json:"template"`
Path string `json:"path"` // project-relative, e.g. .devsys/workflows/quick-fix.md
}
WorkflowInitView reports what `workflow init --template` wrote.
type WorkflowView ¶
type WorkflowView struct {
WorkitemID string `json:"workitem_id"`
Workflow *domain.WorkflowInstance `json:"workflow"`
Candidates []workflow.StepCandidate `json:"candidates,omitempty"`
Notice string `json:"notice,omitempty"`
}
WorkflowView is one work item's workflow instance plus, for read operations, the evaluated step candidates.
type WorkitemContextView ¶
type WorkitemContextView struct {
WorkItem *domain.WorkItem `json:"workitem"`
Version string `json:"version"`
Workflow *WorkflowView `json:"workflow,omitempty"`
Decisions []RecordRef `json:"decisions"`
Findings []RecordRef `json:"findings"`
Artifacts []RecordRef `json:"artifacts"`
Comments []EventRef `json:"comments"`
Knowledge KnowledgeContext `json:"knowledge"`
Notices []string `json:"notices,omitempty"`
}
WorkitemContextView is the context assembled around one work item: the second layer of 方案 §11.1 (the task itself and the records that reference it), plus the third layer — the knowledge pages the task touches.
type WorkitemFilter ¶
WorkitemFilter narrows a work item listing. Zero values mean no filter.
type WorkspacePrepareRequest ¶
type WorkspacePrepareRequest struct {
WorkItemID string
RunID string
Branch string
Actor string
Reason string
}
WorkspacePrepareRequest asks for the execution workspace of a work item (方案 §4.8): create it if missing, reuse it if it exists, and bind it to a run when one is named.
type WorkspaceRemoveRequest ¶
type WorkspaceRemoveRequest struct {
WorkItemID string
Path string
Force bool
Actor string
Reason string
}
WorkspaceRemoveRequest takes a workspace down.
type WorkspaceView ¶
type WorkspaceView struct {
WorkItemID string `json:"workitem_id"`
RunID string `json:"run_id,omitempty"`
Key string `json:"key"`
Path string `json:"path"`
Branch string `json:"branch"`
Created bool `json:"created"`
Hook *workspace.HookReport `json:"hook,omitempty"`
Warnings []string `json:"warnings,omitempty"`
}
WorkspaceView is what preparation produced.