The kernel is the deterministic control center of rx.
It owns the autonomous loop and nothing else.
If the kernel grows complex, boundaries are being violated.
The kernel is responsible for:
- Accepting a goal
- Maintaining execution state
- Running the iteration loop
- Invoking tools via registry
- Persisting structured events
- Evaluating termination conditions
The kernel does NOT:
- Execute shell commands directly
- Read or write files directly
- Access the network
- Implement storage logic
- Contain transport logic
Each iteration follows this sequence:
- Load current state
- Generate next action (LLM)
- Validate action
- Invoke tool
- Capture tool result
- Append event
- Evaluate termination
- Increment iteration counter
Repeat until termination.
Each iteration must produce:
- Step number
- Model decision
- Tool invocation (if any)
- Tool input
- Tool output
- Error (if any)
- State summary
Every iteration must be persisted.
Execution must stop when:
donetool is invoked- Maximum iterations exceeded
- Fatal tool error
- No progress detected
- Explicit cancellation
Termination must be logged with reason.
The kernel must:
- Enforce max iteration cap
- Prevent infinite loops
- Handle tool failures gracefully
- Never panic on recoverable errors
- Emit structured events
Iteration cap must be enforced in code, not prompt.
Kernel state must minimally track:
- Goal
- Iteration count
- Event history reference
- Last tool result
- Termination status
The kernel must not depend on storage implementation.
The model produces structured action output.
The kernel must:
- Parse structured output
- Reject malformed responses
- Retry if necessary
- Never execute free-form text blindly
All tool calls must be explicit.
When a tool fails:
- Log failure
- Provide failure context to model
- Allow model to retry or choose alternative
- Abort if repeated failure exceeds threshold
Kernel must avoid silent failure loops.
The kernel must support:
- Reconstructing state from event log
- Resuming from last completed iteration
- Replaying events deterministically
Kernel logic must be replay-safe.
Every kernel action must be:
- Logged (human-readable)
- Persisted (machine-readable)
- Traceable by goal ID
The system must allow:
- Step inspection
- Tool trace inspection
- Termination audit
If removing a component makes:
- The system unable to decide next action → it belongs in kernel.
- The system unable to perform side effects → it belongs in tools.
- The system unable to persist history → it belongs in state backend.
Everything else is not kernel.
The kernel implementation should be small.
If Phase 1 kernel exceeds a few hundred lines, responsibilities are likely leaking.
The goal is clarity over feature richness.