app

package
v0.1.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 21, 2026 License: MIT Imports: 36 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package app is the shared application service behind every devsys 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

View Source
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".

View Source
const (
	MatchTrigger = "trigger"
	MatchSources = "sources"
)

Knowledge match kinds.

View Source
const (
	KnowledgeFresh   = "fresh"
	KnowledgeStale   = "stale"
	KnowledgeMissing = "missing"
)

Status constants for KnowledgeStatusView.Status; the CLI maps them onto the reserved exit codes.

View Source
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.

Variables

This section is empty.

Functions

func Classify

func Classify(err error) error

Classify wraps an arbitrary error as an application error. Errors that are already classified pass through unchanged.

func MCPSnippet

func MCPSnippet(name, devsysBin, projectRoot string) (string, error)

MCPSnippet returns the copy-paste MCP client configuration for one harness.

File-based shapes are marked [UNVERIFIED]: no live client of that kind has been connected from this machine. The stdio command itself is verified: `devsys mcp serve` over IOTransport (smoke-m4 via scripts/m4helper).

Snippets pin `--tier core` (the 19-tool 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

type ApprovalFilter struct {
	WorkItemID string
	Status     string
}

ApprovalFilter narrows an approval listing.

type AttemptSpawner

type AttemptSpawner func(root, runID string, argv []string, logPath string) (int, error)

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

type CommentView struct {
	Event *domain.Event `json:"event"`
}

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

type DecideApprovalRequest struct {
	ID      string
	By      string
	Comment string
	Reason  string
}

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

type Error struct {
	Kind     string
	Message  string
	Problems []config.Problem
}

Error is a classified application failure.

func Internalf

func Internalf(format string, a ...any) *Error

Internalf reports an unexpected failure.

func Invalidf

func Invalidf(kind string, problems []config.Problem, format string, a ...any) *Error

Invalidf reports managed state that exists but cannot be trusted; kind is the display kind (invalid, workflow, gate, quality, workitem, approval).

func Preconditionf

func Preconditionf(format string, a ...any) *Error

Preconditionf reports a state or environment precondition.

func Usagef

func Usagef(format string, a ...any) *Error

Usagef reports invalid input the schema could not express.

func (*Error) Class

func (e *Error) Class() string

Class collapses the display kind onto the four shared classes: usage, precondition, internal or invalid. The CLI maps classes to exit codes (2/3/1/4) and MCP to tool error codes (usage/precondition/internal/invalid).

func (*Error) Error

func (e *Error) Error() string

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

type KnowledgeScanExclusion struct {
	Path   string `json:"path"`
	Reason string `json:"reason"`
}

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 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

type RunListRequest struct {
	WorkItemID string
	Status     string
}

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 RunView

type RunView struct {
	Run     *domain.Run `json:"run"`
	Version string      `json:"version"`
}

RunView is one run record plus its version hash.

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 New

func New(root string) *Service

New returns a service bound to root.

func (*Service) ApprovalApprove

func (s *Service) ApprovalApprove(ctx context.Context, req DecideApprovalRequest) (*domain.Approval, error)

ApprovalApprove records an approval decision.

func (*Service) ApprovalGet

func (s *Service) ApprovalGet(ctx context.Context, id string) (*domain.Approval, error)

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

func (s *Service) ArtifactGet(ctx context.Context, id string) (RecordView, error)

ArtifactGet reads one artifact with its version hash.

func (*Service) ArtifactHistory

func (s *Service) ArtifactHistory(ctx context.Context, id string) ([]*domain.Artifact, error)

ArtifactHistory walks the previous_id chain (newest first).

func (*Service) ArtifactList

func (s *Service) ArtifactList(ctx context.Context) ([]*domain.Artifact, error)

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

func (s *Service) ContextGet(ctx context.Context, limit int) (ContextView, error)

ContextGet assembles the project working context. limit bounds each reference list (0 selects the default of 5).

func (*Service) ContextRefresh

func (s *Service) ContextRefresh(ctx context.Context, limit int) (ContextView, error)

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

func (s *Service) DecisionApprove(ctx context.Context, id, by, expect string) (RecordView, error)

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

func (s *Service) DecisionGet(ctx context.Context, id string) (RecordView, error)

DecisionGet reads one decision with its version hash.

func (*Service) DecisionList

func (s *Service) DecisionList(ctx context.Context) ([]*domain.Decision, error)

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) EventList

func (s *Service) EventList(ctx context.Context, req EventListRequest) ([]*domain.Event, error)

EventList reads events (ascending by time; Limit keeps the newest N).

func (*Service) EventRecord

func (s *Service) EventRecord(ctx context.Context, req RecordEventRequest) (*domain.Event, error)

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

func (s *Service) FindingGet(ctx context.Context, id string) (RecordView, error)

FindingGet reads one finding with its version hash.

func (*Service) FindingList

func (s *Service) FindingList(ctx context.Context) ([]*domain.Finding, error)

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) Next

func (s *Service) Next(ctx context.Context) (next.Report, []*domain.WorkItem, error)

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

func (s *Service) ProjectBlueprint(ctx context.Context) (*domain.Artifact, error)

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

func (s *Service) ProjectCreate(ctx context.Context, path string) (*project.Result, string, error)

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

func (s *Service) ProjectStateGet(ctx context.Context) (StateView, error)

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 `devsys 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

func (s *Service) RunCreate(ctx context.Context, req CreateRunRequest) (RunView, error)

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

func (s *Service) RunFinish(ctx context.Context, req RunFinishRequest) (RunView, error)

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) RunGet

func (s *Service) RunGet(ctx context.Context, id string) (RunView, error)

RunGet reads one run with its version hash.

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) RunList

func (s *Service) RunList(ctx context.Context, req RunListRequest) ([]*domain.Run, error)

RunList lists runs, optionally filtered by work item or status.

func (*Service) RunLog

func (s *Service) RunLog(ctx context.Context, id string, limit int) (RunLogView, error)

RunLog returns the run's own evidence plus the events recorded against it.

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

func (s *Service) RunUpdate(ctx context.Context, req UpdateRunRequest) (RunView, error)

RunUpdate applies a run patch (evidence accumulation; lifecycle authority stays with the executor paths).

func (*Service) RunVerify

func (s *Service) RunVerify(ctx context.Context, runID string) (CompletionCheck, error)

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) SkillStatus

func (s *Service) SkillStatus() (files int, marked int)

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

func (s *Service) Wire(ctx context.Context, dryRun bool) (WireView, error)

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

func (s *Service) WorkflowGet(ctx context.Context, id string) (WorkflowView, error)

WorkflowGet reads one work item's instance and, when the policy resolves, its step candidates.

func (*Service) WorkflowInitTemplate

func (s *Service) WorkflowInitTemplate(ctx context.Context, id string) (WorkflowInitView, error)

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

func (s *Service) WorkflowList(ctx context.Context) ([]PolicySummary, []workflow.Issue, error)

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

func (s *Service) WorkflowStepNext(ctx context.Context, id string) (WorkflowView, error)

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

func (s *Service) WorkitemGet(ctx context.Context, id string) (WorkItemView, error)

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

func (s *Service) WriteSkill() ([]string, error)

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 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 `devsys 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 `devsys wire` did (or would do).

type WorkItemView

type WorkItemView struct {
	Item    *domain.WorkItem `json:"item"`
	Version string           `json:"version"`
}

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

type WorkitemFilter struct {
	Status string
	Type   string
	Parent string
}

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.

Jump to

Keyboard shortcuts

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