Documentation
¶
Overview ¶
Package next evaluates a project's readiness verdict and the single recommended next action (方案 §7.4, 实施计划 M3.4). Evaluation is a pure function over observed state so it stays deterministic and testable; the CLI collects the inputs read-only.
The output never carries time estimates: risks and recommendations are observations and orders, not durations.
Index ¶
Constants ¶
const ( VerdictPass = "PASS" VerdictConcerns = "CONCERNS" VerdictFail = "FAIL" )
Verdicts (方案 §7.4): only these three outcomes exist.
const ( ActionRecoverClaim = "recover_claim" ActionReview = "review" ActionStart = "start" ActionStartBacklog = "start_backlog" ActionMilestoneReview = "milestone_review" ActionReportDone = "report_done" )
Recommendation actions, in the fixed §7.4 priority order.
const ( RiskExpiredLease = "expired_lease" RiskOrphanClaim = "orphan_claim" RiskUnreadableLease = "unreadable_lease" RiskStaleReview = "stale_review" RiskBlocked = "blocked" RiskQualityBlocked = "quality_blocked" RiskRetryPending = "retry_pending" RiskInvalidMetadata = "invalid_metadata" RiskInvalidPolicy = "invalid_policy" RiskPendingApproval = "pending_approval" RiskInspectionLimited = "inspection_limited" RiskEmptyProject = "empty_project" RiskDeadAttempt = "dead_attempt" RiskInFlight = "in_flight" )
Risk kinds.
const CreateWorkitemCommand = `devsys workitem create --title "…" --actor <you> --reason "first task"`
CreateWorkitemCommand is the empty-project remediation `next` and `init` name, so the first-use path does not invent a second create recipe.
const ReviewStaleAfter = 24 * time.Hour
ReviewStaleAfter is how long a work item may wait in review/verification before it is reported as stale.
const SpawnGrace = 15 * time.Second
SpawnGrace is how long a just-dispatched attempt may exist without a run stream before `next` treats it as dead. Dispatch does not wait for the child, so a healthy spawn is expected to open its stream inside this window.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AttemptRef ¶
type AttemptRef struct {
WorkitemID string `json:"workitem_id"`
RunID string `json:"run_id"`
Detail string `json:"detail"`
}
AttemptRef names one in-progress attempt `next` judged.
func ClassifyAttempts ¶
func ClassifyAttempts(now time.Time, items []*domain.WorkItem, latest map[string]*domain.Run, streamLines map[string]int) (dead, inflight []AttemptRef)
ClassifyAttempts splits in-progress claims into dead (failed or no evidence) and healthy in-flight. latest is the newest run per work item; streamLines is that run's jsonl record count (0 when the stream does not exist).
type Fix ¶
type Fix struct {
Reason string `json:"reason"`
Command string `json:"command"`
Workflow string `json:"workflow,omitempty"`
}
Fix is one FAIL remediation, ordered by severity.
type Input ¶
type Input struct {
Now time.Time
WorkItems []*domain.WorkItem
Milestones []domain.Milestone
PendingTxns []storage.PendingTxn
ExpiredLeases []reconcile.LeaseProbe
OrphanLeases []reconcile.LeaseProbe
UnreadableLeases []reconcile.LeaseProbe
InspectionOK bool
InspectionNote string
MetadataProblems []string
PolicyProblems []string
// PendingApprovals are approvals waiting for a decision; the work items
// behind them join the "waiting for review" priority class (§7.4 优先级 2).
PendingApprovals []PendingApproval
// QualityBlocks are the ready work items whose claim the effective policy's
// quality gate would refuse (§4.7 领取质量门). The application layer derives
// them with the same judgement claim applies, so a PASS verdict never
// recommends a claim that is certain to fail.
QualityBlocks []QualityBlock
// DefaultPolicy is the project-level policy (.devsys/config.yaml) governing
// work items that declare no instance; PolicyIDs are the policies the
// project declares. Together they tell whether a recommended work item
// would run with no gate at all.
DefaultPolicy string
PolicyIDs []string
RecoverCommand string
// HasBlueprint is true when the project declares a blueprint artifact.
// It is only consulted for the empty-project risk, so a project with
// work and no blueprint can still PASS.
HasBlueprint bool
// DeadAttempts are in-progress claims whose latest run has already
// failed or produced no evidence; they occupy §7.4 rung 1 (recover_claim).
DeadAttempts []AttemptRef
// InFlight are healthy attempts still executing. They are a CONCERNS
// signal, not a new ladder rung: recommend may still land on report_done.
InFlight []AttemptRef
}
Input is the observed project stateEvaluate consumes.
type PendingApproval ¶
PendingApproval names one approval waiting for a decision.
type PolicySource ¶
PolicySource reports the policy governing one work item: its id ("" when no policy governs the item), the file it was read from, and the parsed policy (nil when the file could not be parsed).
type QualityBlock ¶
type QualityBlock struct {
WorkitemID string `json:"workitem_id"`
PolicyID string `json:"policy_id"`
PolicyFile string `json:"policy_file"`
Score int `json:"score"`
MinScore int `json:"min_score"`
// Improvements are the scored-zero components the caller must fix; they
// mirror the claim rejection's problem list.
Improvements []string `json:"improvements,omitempty"`
}
QualityBlock is a ready work item whose claim the quality gate would refuse.
func QualityBlocks ¶
func QualityBlocks(items []*domain.WorkItem, source PolicySource) []QualityBlock
QualityBlocks returns the ready work items whose claim the quality gate would refuse, scored with the same deterministic judgement `workitem claim` applies (§4.7 领取质量门). Callers pass the effective policy per item, so an item guarded by the project default_policy is judged exactly like one with its own instance.
type Recommendation ¶
type Recommendation struct {
Action string `json:"action"`
WorkitemID string `json:"workitem_id,omitempty"`
MilestoneID string `json:"milestone_id,omitempty"`
Reason string `json:"reason"`
}
Recommendation is the single next action.