[MACHINE-SPIRIT 2/8] Pure symbolic task state machine + finite step protocol #331

Open
opened 2026-09-08 02:03:33 +00:00 by nsaspy · 0 comments
Owner

Parent epic: #636
Depends on: #637

Goal

Define MACHINE-SPIRIT's generic task executive as a pure finite symbolic state machine before giving it any side-effect authority.

The core should be independently extractable to Prolog-RLM later. Zara's existing TaskStore remains host persistence; this issue defines the generic symbolic semantics that a host may persist/restore.

Proposed core contract

Expose a small closed API in the spirit of:

machine_spirit_initial_state(+Spec, +Budget, -State).
machine_spirit_step(+State0, +Observation, -Decision, -State1).
machine_spirit_terminal(+State, -Outcome).
machine_spirit_snapshot(+State, -Snapshot).
machine_spirit_restore(+Snapshot, -State).

Names may change, semantics may not: machine_spirit_step/4 is pure. It chooses a typed next decision; it does not execute tools, call models, touch files, mutate Zara DB state, or invoke unrestricted goals.

Closed state / decision vocabulary

State must carry only bounded, serializable data needed by the generic executive, for example:

  • opaque task/run identity supplied by host;
  • immutable task/spec reference;
  • status;
  • current step index;
  • finite budget counters/deadlines;
  • validated plan/graph reference;
  • checkpoint/evidence references;
  • bounded selected result/error metadata.

Decisions must be a closed tagged vocabulary such as:

  • plan(...)
  • execute_effect(...)
  • observe(...)
  • checkpoint(...)
  • complete(...)
  • fail(...)
  • wait(...) only where host semantics explicitly allow it.

No decision may contain executable Prolog supplied by a model.

Finite budget contract

Define hard monotonic limits for at least:

  • executive steps;
  • plan/graph depth;
  • model calls;
  • tool calls;
  • context operations;
  • retries;
  • output/evidence bytes;
  • wall-clock deadline supplied/checked by host.

Budget consumption must never reset merely because a task retries, resumes, recurses, or enters a subgraph. Child authority/budget cannot exceed parent authority/budget.

TDD/adversarial requirements

RED first. Deterministically test:

  • illegal state transition;
  • terminal-state resurrection attempt;
  • negative/zero/NaN/oversized budgets;
  • retry resetting budget;
  • recursion/depth overrun;
  • cyclic/cyclic-looking input terms;
  • malformed observation/decision terms;
  • unknown tags;
  • snapshot tampering/version mismatch;
  • replay of an already-consumed decision;
  • huge state/result values;
  • model-shaped text that contains Prolog code remains data.

Use PLUnit plus property/generative tests where practical. No skipped/xfail acceptance.

Acceptance

  • Pure generic state/transition modules load standalone with Prolog-RLM.
  • Every transition is closed, typed/validated, and deterministic for the same state+observation.
  • Terminal states are immutable.
  • Budgets are finite, monotonic, and narrowing-only through nested work.
  • Snapshot/restore is versioned and contains no executable closures.
  • No side effects occur from the transition layer.
  • Adversarial transition suite is green.
  • Extraction test proves no Zara-specific dependency in generic modules.

Non-goals

No real tool invocation, no TaskStore integration, no LLM/provider call, no UI, no autonomous self-modification.

Parent epic: #636 Depends on: #637 ## Goal Define MACHINE-SPIRIT's generic task executive as a **pure finite symbolic state machine** before giving it any side-effect authority. The core should be independently extractable to Prolog-RLM later. Zara's existing TaskStore remains host persistence; this issue defines the generic symbolic semantics that a host may persist/restore. ## Proposed core contract Expose a small closed API in the spirit of: ```prolog machine_spirit_initial_state(+Spec, +Budget, -State). machine_spirit_step(+State0, +Observation, -Decision, -State1). machine_spirit_terminal(+State, -Outcome). machine_spirit_snapshot(+State, -Snapshot). machine_spirit_restore(+Snapshot, -State). ``` Names may change, semantics may not: `machine_spirit_step/4` is pure. It chooses a typed next decision; it does not execute tools, call models, touch files, mutate Zara DB state, or invoke unrestricted goals. ## Closed state / decision vocabulary State must carry only bounded, serializable data needed by the generic executive, for example: - opaque task/run identity supplied by host; - immutable task/spec reference; - status; - current step index; - finite budget counters/deadlines; - validated plan/graph reference; - checkpoint/evidence references; - bounded selected result/error metadata. Decisions must be a closed tagged vocabulary such as: - `plan(...)` - `execute_effect(...)` - `observe(...)` - `checkpoint(...)` - `complete(...)` - `fail(...)` - `wait(...)` only where host semantics explicitly allow it. No decision may contain executable Prolog supplied by a model. ## Finite budget contract Define hard monotonic limits for at least: - executive steps; - plan/graph depth; - model calls; - tool calls; - context operations; - retries; - output/evidence bytes; - wall-clock deadline supplied/checked by host. Budget consumption must never reset merely because a task retries, resumes, recurses, or enters a subgraph. Child authority/budget cannot exceed parent authority/budget. ## TDD/adversarial requirements RED first. Deterministically test: - illegal state transition; - terminal-state resurrection attempt; - negative/zero/NaN/oversized budgets; - retry resetting budget; - recursion/depth overrun; - cyclic/cyclic-looking input terms; - malformed observation/decision terms; - unknown tags; - snapshot tampering/version mismatch; - replay of an already-consumed decision; - huge state/result values; - model-shaped text that contains Prolog code remains data. Use PLUnit plus property/generative tests where practical. No skipped/xfail acceptance. ## Acceptance - [ ] Pure generic state/transition modules load standalone with Prolog-RLM. - [ ] Every transition is closed, typed/validated, and deterministic for the same state+observation. - [ ] Terminal states are immutable. - [ ] Budgets are finite, monotonic, and narrowing-only through nested work. - [ ] Snapshot/restore is versioned and contains no executable closures. - [ ] No side effects occur from the transition layer. - [ ] Adversarial transition suite is green. - [ ] Extraction test proves no Zara-specific dependency in generic modules. ## Non-goals No real tool invocation, no TaskStore integration, no LLM/provider call, no UI, no autonomous self-modification.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
nsaspy/zara#331
No description provided.