marrow-core Refactor Blueprint¶
Direction¶
marrow-core becomes the stable service/runtime kernel.
It owns: - service lifecycle - scheduling - sync and self-check - IPC status/control - immediate trigger with optional one-shot prompt - service installation/rendering
It does not own: - task queueing - work-item contracts - human workflow state machines - external workflow orchestration policy
Those move to external repos.
New Product Shape¶
One public CLI sits on top of the runtime core.
- root commands are the normal user-facing interface
serviceremains only as an internal/logical grouping for runtime mechanics- no separate
agentcommand surface
Current command shape:
marrow runmarrow run-oncemarrow dry-runmarrow sync-oncemarrow setupmarrow validatemarrow doctormarrow scaffoldmarrow install-servicemarrow statusmarrow wake --reason ... --prompt ...
Runtime Boundary¶
Keep these modules as the active core boundary:
marrow_core/config.pymarrow_core/runtime.pymarrow_core/heartbeat.pymarrow_core/ipc.pymarrow_core/worker.pymarrow_core/services.pymarrow_core/health.pymarrow_core/sync.pymarrow_core/triggers.py
Keep CLI assembly under:
marrow_core/cli/service.pymarrow_core/cli/ops.pymarrow_core/cli/__main__.py
Trigger Model¶
Replace task submission with trigger-only control.
Trigger payload:
Semantics:
- wake the selected agent immediately
- attach prompt only to the next run
- do not persist into
context.d - consume after one run
This is represented in-memory for single-user mode and via worker request files in supervisor mode.
CLI Contract¶
Public root commands¶
runrun-oncedry-runsync-oncesetupvalidatedoctorscaffoldinstall-servicestatuswake --reason ... --prompt ...
Rules:
- one normal command surface
- human-readable by default
- stable enough for scripts, but no separate machine persona
Internal service commands¶
Still exist for implementation structure:
service worker-runservice workspace-sync
These are not the main public interface.
Config Evolution¶
Current config still uses [[agents]] as the scheduling inventory. That is acceptable for the transition.
Next cleanup step:
- rename agent runtime fields to service-oriented names
- reduce config to service-owned concerns only
- keep external workflow/task repos responsible for their own state and schemas
Potential future shape:
[service]
mode = "supervisor"
runtime_root = "/var/lib/marrow"
[control]
socket_path = "/var/lib/marrow/state/marrow.sock"
[[service.agents]]
name = "orchestrator"
command = "opencode run --agent orchestrator"
workspace = "/Users/marrow"
interval_seconds = 10800
timeout_seconds = 7200
Migration Rules¶
Removed from active core¶
- filesystem task queue
- IPC
/tasks marrow task addmarrow task list- active
work_itemsmodel inmarrow_core/ - separate
agentCLI surface
Backed up only¶
legacy/task_queue.pylegacy/work_items.py
Nothing in active runtime code should import from legacy/.
Suggested Next Refactor Passes¶
Pass 1: stabilize the unified CLI¶
- finish test updates for the unified root command tree
- update README/examples/docs to remove task ownership and
agentwording - keep only hidden internal runtime commands where needed
Pass 2: simplify service core¶
- move more runtime orchestration out of CLI modules into pure service modules
- make CLI wrappers thinner
- reduce overlap between
service.pyandops.py
Pass 3: harden control plane¶
- define explicit JSON schema for
/statusand/wake - add structured trigger request persistence rules for supervisor mode
- decide whether filtered
statusviews are needed
Pass 4: shrink internal command leakage¶
- keep
worker-runandworkspace-syncinternal-only - keep service manager output and docs aligned with public root commands
Design Principles¶
- service core stays small and boring
- one public CLI is easier to remember and maintain
- tasks belong outside the runtime kernel
- one-shot prompts are triggers, not queue items