Class NaruPlan
NaruPlanItems.
Plans are owned by the session, not by a task. A plan is keyed by its own UUID and referenced explicitly, because the tasks that build it, execute it and validate it are all different tasks; keying by task id (as an earlier revision did) made the plan vanish the moment execution moved to a spawned child.
The plan knows nothing about activation, scheduling or spawning. It is a pure
data structure plus the derived status(); deciding which plan runs and when
belongs to NaruPlanManager.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intBumped when the persisted shape changes incompatibly. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddDependency(String itemId, String dependsOnItemId) Adds a dependency edge.addItems(List<NaruPlanItemSpec> specs) Appends items, resolvingNaruPlanItemSpec.dependsOn()keys against the keys declared in this same batch and against the keys of items added by earlier batches.voidDepth-first cycle check over the whole graph.findItemByPrefix(String prefix) Resolves an item by full id or by unique id prefix.goal()id()booleanWhether every item is finished.items()Items with no unsatisfied dependency, in declaration order.The declaration key of an item, or null when it was declared without one.booleanremoveItem(String itemId) Removes an item and every dependency edge pointing at it.net.thevpc.nuts.text.NTextrender()Compact rendering for prompt injection and/plan show.status()Aggregate state, derived from the items on every call.net.thevpc.nuts.elem.NElementtouch()
-
Field Details
-
SCHEMA_VERSION
public static final int SCHEMA_VERSIONBumped when the persisted shape changes incompatibly. Plans written by an older build are skipped on load rather than misread.- See Also:
-
-
Constructor Details
-
NaruPlan
-
NaruPlan
-
NaruPlan
public NaruPlan(net.thevpc.nuts.elem.NElement element)
-
-
Method Details
-
keyOf
The declaration key of an item, or null when it was declared without one. -
id
-
goal
-
setGoal
-
creationInstant
-
modificationInstant
-
items
-
item
-
findItemByPrefix
Resolves an item by full id or by unique id prefix.render()prints 8-character prefixes because full UUIDs in a system prompt are unreadable, so a model quoting the plan back at us will hand us a prefix. An ambiguous prefix resolves to nothing rather than to an arbitrary item: silently picking one of several matches would corrupt the wrong item. -
addItems
Appends items, resolvingNaruPlanItemSpec.dependsOn()keys against the keys declared in this same batch and against the keys of items added by earlier batches. A dependency may also name an item id directly.- Throws:
IllegalArgumentException- if a key is unknown or duplicated, or if the resulting graph would contain a cycle
-
removeItem
Removes an item and every dependency edge pointing at it. Items that depended on the removed item become unblocked only if they had no other unsatisfied edge;NaruPlanManager.recomputeAndFill(String)decides that. -
addDependency
Adds a dependency edge. The target must already exist and the edge must not create a cycle.- Throws:
IllegalArgumentException- if the target is unknown or would create a cycle
-
assertAcyclic
public void assertAcyclic()Depth-first cycle check over the whole graph. Cheap enough to run on every structural edit, which is the point: a cycle would otherwise strand the plan with no runnable item and no obvious cause. -
itemsWithSatisfiedDependencies
Items with no unsatisfied dependency, in declaration order. This is the candidate set a selector draws from; it does not consider status, activation or concurrency. -
isComplete
public boolean isComplete()Whether every item is finished. An empty plan is not complete. -
status
Aggregate state, derived from the items on every call. -
touch
-
render
public net.thevpc.nuts.text.NText render()Compact rendering for prompt injection and/plan show.Dependency ids are rendered as short prefixes because full UUIDs in a system prompt are both unreadable and easy for a model to mistype back.
-
toElement
public net.thevpc.nuts.elem.NElement toElement()
-