Package net.thevpc.naru.ext.tools.plan
Class NaruPlanManagerImpl
java.lang.Object
net.thevpc.naru.ext.tools.plan.NaruPlanManagerImpl
- All Implemented Interfaces:
NaruPlanManager
Default
NaruPlanManager. Plans live in memory, in creation order, and are
persisted as a single TSON file inside the session folder (written by
NaruSessionImpl).-
Constructor Summary
Constructors -
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.voidclear()Drops every plan and the active-plan pointer.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>voidloadFrom(net.thevpc.nuts.io.NPath file) Replaces the in-memory state with whatever the file holds.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.net.thevpc.nuts.elem.NElementSerialises every plan plus the active-plan pointer.
-
Constructor Details
-
NaruPlanManagerImpl
public NaruPlanManagerImpl()
-
-
Method Details
-
createPlan
Description copied from interface:NaruPlanManagerCreates a plan from declarative item specs and registers it under its generated id.- Specified by:
createPlanin interfaceNaruPlanManager
-
findPlan
- Specified by:
findPlanin interfaceNaruPlanManager
-
plans
Description copied from interface:NaruPlanManagerAll plans, in creation order.- Specified by:
plansin interfaceNaruPlanManager
-
findItem
- Specified by:
findItemin interfaceNaruPlanManager
-
addItems
public net.thevpc.nuts.util.NOptional<NaruPlan> addItems(String planId, List<NaruPlanItemSpec> items) Description copied from interface:NaruPlanManagerAppends items to an existing plan, resolving dependency keys against existing items and against keys declared in the same batch.- Specified by:
addItemsin interfaceNaruPlanManager
-
reportItem
public net.thevpc.nuts.util.NOptional<NaruPlanItem> reportItem(String planId, String itemId, NaruPlanItemStatus status, String notes) Description copied from interface:NaruPlanManagerReports progress on an item.NaruPlanItemStatus.DONEis rejected here on purpose: completion must go throughNaruPlanManager.completeItem(String, String, boolean, String)so that a validator verdict always accompanies a finished item. Everything else the caller may set freely.- Specified by:
reportItemin interfaceNaruPlanManager
-
completeItem
public net.thevpc.nuts.util.NOptional<NaruPlanItem> completeItem(String planId, String itemId, boolean validationPassed, String notes) Description copied from interface:NaruPlanManagerRecords 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.- Specified by:
completeItemin interfaceNaruPlanManager
-
reopenItem
public net.thevpc.nuts.util.NOptional<List<NaruPlanItem>> reopenItem(String planId, String itemId, boolean cascade) Description copied from interface:NaruPlanManagerReopens 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.
- Specified by:
reopenItemin interfaceNaruPlanManagercascade- whether to demote dependents as well- Returns:
- the demoted items, in demotion order
-
recomputeAndFill
Description copied from interface:NaruPlanManagerRecomputesNaruPlanItemStatus.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.
- Specified by:
recomputeAndFillin interfaceNaruPlanManager
-
removePlan
- Specified by:
removePlanin interfaceNaruPlanManager
-
activePlan
Description copied from interface:NaruPlanManagerThe 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.- Specified by:
activePlanin interfaceNaruPlanManager
-
activePlanId
- Specified by:
activePlanIdin interfaceNaruPlanManager
-
setActivePlanId
Description copied from interface:NaruPlanManagerRecords which plan is activated. Passingnullor an unknown id deactivates.- Specified by:
setActivePlanIdin interfaceNaruPlanManager
-
clear
public void clear()Drops every plan and the active-plan pointer. Used when a session ends. -
toElement
public net.thevpc.nuts.elem.NElement toElement()Serialises every plan plus the active-plan pointer. Returns null when there is nothing worth persisting, which tells the core to remove any stale state file. -
loadFrom
public void loadFrom(net.thevpc.nuts.io.NPath file) Replaces the in-memory state with whatever the file holds. A missing file is not an error: it just means this session has no plans yet.
-