Interface NaruPlanManager
- All Known Implementing Classes:
NaruPlanManagerImpl
Plans persist with the session (as plans.tson) and survive crashes and
reloads. A plan is addressed by its own id, never by the id of the task that
happens to be working on it, so that the architect task, the executor tasks and the
validator tasks can all reference the same plan.
This interface deliberately contains no scheduling policy. Deciding which ready item runs next, how many run at once, and when a plan is activated are all responsibilities of the layer above; the manager only owns the graph, its derived readiness, and the rules that keep a caller from recording unvalidated work as finished.
-
Method Summary
Modifier and TypeMethodDescriptionnet.thevpc.nuts.util.NOptional<NaruPlan>The plan currently marked for execution, if any.net.thevpc.nuts.util.NOptional<NaruPlan>addItems(String planId, List<NaruPlanItemSpec> items) Appends items to an existing plan, resolving dependency keys against existing items and against keys declared in the same batch.net.thevpc.nuts.util.NOptional<NaruPlanItem>completeItem(String planId, String itemId, boolean validationPassed, String notes) Records the outcome of an item's validator.createPlan(String goal, List<NaruPlanItemSpec> items) Creates a plan from declarative item specs and registers it under its generated id.net.thevpc.nuts.util.NOptional<NaruPlanItem>net.thevpc.nuts.util.NOptional<NaruPlan>plans()All plans, in creation order.net.thevpc.nuts.util.NOptional<NaruPlan>recomputeAndFill(String planId) RecomputesNaruPlanItemStatus.READYfor every non-terminal item whose dependencies are allNaruPlanItemStatus.DONE, and demotes items that areREADYbut no longer satisfied.booleanremovePlan(String planId) net.thevpc.nuts.util.NOptional<List<NaruPlanItem>>reopenItem(String planId, String itemId, boolean cascade) Reopens a finished item, demoting it toNaruPlanItemStatus.PENDINGand cascading the demotion to items that transitively depended on it.net.thevpc.nuts.util.NOptional<NaruPlanItem>reportItem(String planId, String itemId, NaruPlanItemStatus status, String notes) Reports progress on an item.voidsetActivePlanId(String planId) Records which plan is activated.
-
Method Details
-
createPlan
Creates a plan from declarative item specs and registers it under its generated id.- Throws:
IllegalArgumentException- if a dependency key is unknown or the graph would contain a cycle
-
findPlan
-
plans
All plans, in creation order. -
findItem
-
addItems
Appends items to an existing plan, resolving dependency keys against existing items and against keys declared in the same batch.- Throws:
IllegalArgumentException- if a key is unknown, duplicated, or the graph would contain a cycle
-
reportItem
net.thevpc.nuts.util.NOptional<NaruPlanItem> reportItem(String planId, String itemId, NaruPlanItemStatus status, String notes) Reports progress on an item.NaruPlanItemStatus.DONEis rejected here on purpose: completion must go throughcompleteItem(String, String, boolean, String)so that a validator verdict always accompanies a finished item. Everything else the caller may set freely. -
completeItem
net.thevpc.nuts.util.NOptional<NaruPlanItem> completeItem(String planId, String itemId, boolean validationPassed, String notes) Records the outcome of an item's validator.A pass moves the item to
NaruPlanItemStatus.DONE; a failure moves it toNaruPlanItemStatus.FAILEDwithnoteskept as the reason. An item with no validator may be completed here too, but must passtrue. -
reopenItem
net.thevpc.nuts.util.NOptional<List<NaruPlanItem>> reopenItem(String planId, String itemId, boolean cascade) Reopens a finished item, demoting it toNaruPlanItemStatus.PENDINGand cascading the demotion to items that transitively depended on it.This is the destructive operation the human confirmation in the directive is for: cascading can undo validated work.
- Parameters:
cascade- whether to demote dependents as well- Returns:
- the demoted items, in demotion order
-
recomputeAndFill
RecomputesNaruPlanItemStatus.READYfor every non-terminal item whose dependencies are allNaruPlanItemStatus.DONE, and demotes items that areREADYbut no longer satisfied.Safe to call as often as you like; it never touches items that are running, validating or terminal.
-
removePlan
-
activePlan
net.thevpc.nuts.util.NOptional<NaruPlan> activePlan()The plan currently marked for execution, if any. Activation is session state and is independent of the prompt mode of any task; only a human directive sets it. -
activePlanId
String activePlanId() -
setActivePlanId
Records which plan is activated. Passingnullor an unknown id deactivates.
-