100%

Walking skeleton — engine drives one work_item off-path

Goal

Prove the depth-zero base case: create one sandbox RootClosure with one root InvocationFrame, enter through reconcile over sandbox plan state, emit one ContextAssembly, and flip one work item. The state machine selects the action; the simulated LLM returns only the bounded result.

Self-hosting constraint

Run the skeleton in a sandbox plan directory. Keep live route_walk.py/review_phase.py untouched until reversible cutover.

Implementation sketch

  • Scaffold scripts/workflow_engine/ with engine.py (load JSON, run SM), a stub registry.py, and a tests/ dir.
  • Author a 4-state work_item.json (reconcile -> validate -> flip -> reconcile -> completed) + one stub proof_satisfied gate + flip_status action that resolve by name. state_authority=domain_artifact; reconcile reads the sandbox plan API; flip_status settles back to reconcile; no free-standing frame state selects validate, flip, or completed.
  • Wire a smoke test that drives the engine over a sandbox plan dir and asserts the item flips complete, with the old orchestrator never invoked.
  • Have the script generate a bounded task prompt from the sandbox plan state, active-execution RuleUnit, root/frame Reminders, exact next action, and root/frame digests; reject a model-authored or paraphrased control prompt by provenance digest.

Spec references

  • plans/workflow-engine-rework/spec/workflow-state-machines.md sec 10 (migration step 2 — thin engine first); sec 10.2 (folder layout).

Work items

  • Scaffold scripts/workflow_engine/{engine,registry}.py + tests/ (off-path)
  • Author the 4-state workflows/work_item.json skeleton with domain-artifact authority, fixed plan-derived reconcile entry, stub proof_satisfied, flip_status -> reconcile, and terminal selection only from the post-write plan projection
  • Smoke test: engine flips a sandbox work_item complete; assert live orchestrator untouched
  • Emit minimal ContextAssembly with sandbox root/frame identity, script-generated digest-pinned bounded prompt, execution RuleUnit, root/frame Reminders, and exact next action; reject LLM/client prompt substitution

Test strategy / acceptance

Smoke pins: live orchestrator unused; every ordinary entry starts at reconcile; a bypassed/unreachable reconcile rejects; flip_status returns to reconcile before terminal selection; the sandbox plan API is the workflow/domain-state authority; no unbound frame cursor is accepted; exact sandbox identity appears in ContextAssembly; a mismatched plan target rejects; prompt bytes/provenance come from the script; the simulated LLM cannot choose the next state.

Fresh intel (regenerated)

This section is pure greenfield (scripts/workflow_engine/ does not exist on disk; a graph scan for workflow_engine / RootClosure / InvocationFrame / ContextAssembly symbols returns 0 rows). Its entire value in the graph is by CONTRAST: the skeleton is a depth-zero MINIATURE of the live orchestration surface it will eventually replace, and the graph makes both the shadowed surface and the fragmentation it collapses precisely visible.

The three moving parts the section builds each map to an EXACT live-engine function, and the semantic-similar surface proves the mapping the section prose only implies:

Skeleton primitive (new, greenfield)Live engine function it miniaturizessimilar corroboration
state machine SELECTS next actionroute_walk.serve_next_v7 / next_action / _next_action_v7serve_next_v7 ~ next_action 0.864; next_action ~ _next_action_v7 0.914
flip_status Action + proof_satisfied gatereview_phase.complete_work_item_v7 / verify_and_complete_v7verify_and_complete_v7 ~ complete_work_item_v7 0.810
reconcile entry reads the sandbox plan APIplan_corpus/read.py (summary_dict / load_plan)WorkflowContext wraps this READ-ONLY (spec 10.2)

[JOIN] the skeleton IS serve_next_v7 + complete_work_item_v7 shrunk to depth zero, re-expressed as JSON wiring over named Python primitives — this is spec sec 10 “Migration step 2 (thin engine first)” applied to the smallest closed loop. The section is not inventing a shape; it is proving the JSON-wires/Python-computes contract on one work item before engine-core (s-e585be74) generalizes it.

[JOIN] The scatter the whole plan collapses is quantified in the graph: 19 distinct scripts/*_runtime/next_action.schema.json files, 7 state-machine / next-action-emitter modules (commit_push/state_machine.py, plan_orchestrator/state_machine.py, impl_hygiene_review_runtime/rails_compose.py+rails_advance.py, tpr_review_runtime/next_action_emit.py, two dispatch.py), and 5+ independent orchestrate() entry points (fix_bug, fix_next_bug, review_plan/driver, triage_bugs, roadmap). The skeleton’s registry.py name->component resolver is the seed of the ONE convergence point those parallel emitters fold into — it must NOT become a 20th parallel envelope.

Decisions this package forces before any code is written:

  1. Touch NOTHING on the live serve/flip path. The plan executes THROUGH route_walk.serve_next_v7 + review_phase.verify_and_complete_v7; editing either mid-plan mutates the run’s own substrate (mission self-hosting corollary; section “Self-hosting constraint”). scripts/workflow_engine/ imports nothing from — and is imported by nothing on — the live path. These live functions are the do-not-touch surface until reversible-cutover (s-d343a923).
  2. registry.py resolves names by scanning folders — mirror REGISTERED_HALT_STATES, do not fork it. The GitHub-Actions uses:-by-name pattern (spec 10.2) is the shape; a second registry mechanism is LEAK:scattered-knowledge. (The sibling engine-core dossier constrains REGISTERED_HALT_STATES for the same reason.)
  3. The reconcile node WRAPS the sandbox plan API read-only — never re-implements plan state. read.py (summary_dict / load_plan) is the sole authority; state_authority=domain_artifact requires it (spec 10.2). Snapshot once into WorkflowContext; never reconstruct state from the frame / prompt / transcript.
  4. The provenance-digest rejection IS a validator — it must FAIL on an LLM-authored prompt. The smoke test’s negative pins (LLM cannot choose the next state; a model-authored/paraphrased control prompt is rejected by digest; an unbound frame cursor rejects; a mismatched plan target rejects) are the deliverable’s teeth — INVERTED-TDD if gated or weakened to pass.
  5. Every design VERDICT inherits the tooling-scope hygiene families (§3H): STRUCTURE:script-first-violation + STRUCTURE:claude-driving-workflow (the engine IS the script-drives contract), SCHEMA:unvalidated-config (work_item.json must be schema-validated at load), LEAK:algorithmic-duplication (the 19+7+5 scatter), LEAK:scattered-knowledge (the status vocabulary), DESIGN:low-cohesion (engine.py god-object risk). The deep compiler matrix (dual-exec / L5–L10 backends) is N/A — this is scripts/** Python.
["serve_next_v7", "next_action", "_next_action_v7", "peek_next_v7", "_v7_walk", "verify_and_complete_v7", "complete_work_item_v7", "_route_dispatch", "run_state_machine", "route_walk", "review_phase", "REGISTERED_HALT_STATES"]

DIG DEEPER

python -m scripts.plan_corpus.read --summary plans/workflow-engine-rework
sed -n '1,27p' plans/workflow-engine-rework/content/walking-skeleton--s-951de451.md
# prove the deliverable is greenfield (0 rows):
scripts/intel-query.sh cypher "MATCH (s:Symbol {repo:'ori-platform'}) WHERE toLower(s.qualified_name) CONTAINS 'workflow_engine' OR toLower(s.qualified_name) CONTAINS 'rootclosure' OR toLower(s.qualified_name) CONTAINS 'invocationframe' RETURN s.qualified_name LIMIT 20" --human

(full dossier: walking-skeleton—s-951de451.intel.md)