feat(agent): add outcome-aware unit dependencies Extend the unit manager for declarative script ordering without changing existing status dependencies or `coder exp sync` behavior. - Add a separate conditional dependency graph with `success` and `completion` requirements, outcome tracking, and runnable, skipped, or waiting decisions. - Failed, timed-out, or skipped prerequisites skip `success` dependents but satisfy `completion`. Canceled or unregistered prerequisites keep dependents waiting. - Add context-cancelable waiting with no built-in timeout and sorted unmet prerequisites for logging. Callers remain responsible for recording skips. - Enforce immutable final outcomes, reject cycles and conflicting edge requirements, and accept identical duplicate edges. - Add race-tested coverage for outcome semantics, validation, graph isolation, cancellation, and concurrent waiters. No callers yet; script-runner integration follows in PLAT-549. Refs PLAT-546.
18 lines
935 B
Go
18 lines
935 B
Go
// Package unit tracks named units of work and the dependencies between them.
|
|
//
|
|
// A Manager holds two independent kinds of dependency. Status dependencies
|
|
// (AddDependency, IsReady) wait for a prerequisite to reach one exact Status
|
|
// and back coder exp sync. Conditional dependencies (AddConditionalDependency,
|
|
// Evaluate, WaitForDecision) wait for a prerequisite's Outcome to satisfy a
|
|
// Requirement and back declarative script ordering. "Conditional dependency"
|
|
// is the same thing the script ordering RFC calls an "outcome-aware
|
|
// dependency".
|
|
//
|
|
// A Manager instance is the isolation boundary between callers. Unit IDs are
|
|
// not namespaced, so callers that must not see each other's units, such as
|
|
// the agent socket API and a script execution, use separate instances.
|
|
//
|
|
// Cycle detection is per graph. A status edge in one direction and a
|
|
// conditional edge in the other form a loop neither check sees.
|
|
package unit
|