clawft

Kernel Phases (K0-K6)

Complete overview of the six kernel development phases, their status, components, test counts, and dependency graph.

WeftOS is built in incremental phases (K0 through K6). Each phase adds a layer of OS capability to the kernel. K0 through K2b are complete with 373+ passing tests. K3 through K6 have types and traits implemented with Phase 1 logic complete.

Phase Summary

PhaseNameStatusTestsKey Deliverables
K0FoundationComplete45+Boot state machine, event logging, config, errors
K1Process and SupervisionComplete80+PID allocation, process table, supervisor, RBAC
K2IPC and CommunicationComplete130+Message envelopes, A2A routing, pub/sub, cron, health, services
K2bHardeningComplete30+Chain-logged lifecycle, signal handling, DashMap fixes
ExoChainCryptographic AuditComplete60+Hash chain, resource tree, gate backends
K3WASM SandboxComplete--Wasmtime runner, fuel metering, 27-tool catalog
K3cECC Cognitive SubstrateComplete83Causal DAG, cognitive tick, HNSW, impulse queue
K4ContainersComplete--Container lifecycle, config, health propagation
K5App FrameworkComplete--Manifest parsing, app lifecycle, agent spawning
K6Mesh NetworkingPhase 1 Complete133Transport traits, discovery, cross-node IPC, replication

Total test count: 560+ (479 baseline + 83 ECC).

K0: Kernel Foundation

Status: COMPLETE (45+ tests)

Establishes the kernel lifecycle with a boot state machine and structured event logging.

ComponentFileTestsDescription
Kernel boot state machineboot.rs14Booting -> Running -> Halted lifecycle
Boot event loggingconsole.rs12BootEvent, BootPhase, KernelEventLog
Configuration extensionconfig.rs8KernelConfigExt trait for config access
Error typeserror.rs11KernelError enum + Display implementations

K0 wraps AppContext<P> in a Kernel<P: Platform> struct with structured startup and shutdown. The KernelState enum (Booting, Running, ShuttingDown, Halted) manages the lifecycle state machine.

K1: Process and Supervision

Status: COMPLETE (80+ tests)

Introduces PID-based agent tracking, lifecycle supervision, and the capability-based security model.

ComponentFileTestsDescription
Process tableprocess.rs22PID allocation, ProcessState state machine
Agent supervisorsupervisor.rs35Spawn/stop/restart with resource limits
Capability modelcapability.rs24RBAC, IpcScope, SandboxPolicy, ResourceLimits

The process table uses DashMap<Pid, ProcessEntry> for lock-free concurrent access. Each process tracks state (Starting, Running, Suspended, Stopping, Exited), capabilities, and resource usage.

K2: IPC and Communication

Status: COMPLETE (130+ tests)

Adds typed inter-process communication with message envelopes, agent-to-agent routing, pub/sub topics, and system services.

ComponentFileTestsDescription
Kernel IPCipc.rs18KernelMessage envelopes, MessageTarget, MessagePayload
A2A routinga2a.rs28Per-agent inboxes with capability checks
Topic pub/subtopic.rs14TopicRouter with subscriptions
Agent work loopagent_loop.rs22Command processing, gate integration
Cron schedulercron.rs12Job registration, tick handling
Health systemhealth.rs10Aggregated health checks
Service registryservice.rs16Named lifecycle management

K2 establishes the internal API surface. The A2ARouter manages per-agent inboxes using DashMap, with capability-based access control on every send.

K2b: Hardening

Status: COMPLETE (30+ tests)

Hardens K0-K2 with chain-logged lifecycle events, signal handling, and concurrency fixes.

ComponentAreaTestsDescription
Chain-logged lifecycleagent_loop.rs8ipc.recv, ipc.ack, agent.spawn events
Signal-based stop/restartdaemon.rs4SIGTERM/SIGHUP handlers
CLI displaycommands/6agent inspect, chain detail output
DashMap deadlock fixa2a.rs3Concurrent access safety
GovernanceGategate.rs7Governance-to-GateBackend adapter
Gate wiringdaemon.rs2GovernanceGate replaces None

K2.1: Symposium Changes

Status: PENDING

Breaking changes and quick wins from the K2 Symposium (22 decisions, 10 approved changes):

DecisionChangeDescription
D3C1SpawnBackend enum added to SpawnRequest
D11C6Post-quantum dual signing (Ed25519 + ML-DSA-65)
D14C8SpawnBackend::Tee variant (returns BackendNotAvailable)
D1--ServiceEntry as first-class registry concept
D19--Breaking IPC changes: MessageTarget::Service(name) routing

ExoChain Subsystem

Status: COMPLETE (60+ tests)

Provides an append-only hash-linked event log with SHAKE-256 integrity, Ed25519 signing, and a resource tree facade.

ComponentFileTestsDescription
Hash chain managerchain.rs28SHAKE-256, Ed25519, witness chains
Resource tree facadetree_manager.rs18Atomic tree+chain+mutation ops
Gate backendsgate.rs14CapabilityGate, GovernanceGate

K3: WASM Sandbox

Status: COMPLETE (types, Wasmtime runner, fuel metering, sandbox tests pass)

File: wasm_runner.rs (~1,639 lines)

Key deliverables:

  • 27-tool catalog with builtin_tool_catalog()
  • WasmToolRunner with fuel metering, memory limits, timeout config
  • WasmSandboxConfig with configurable limits
  • Tool lifecycle: Build -> Deploy -> Execute -> Version -> Revoke
  • ExoChain audit logging for all lifecycle events

K3 Symposium scorecard: 8.1/10 overall, rated "Ready for K4".

K3c: ECC Cognitive Substrate

Status: COMPLETE (83 tests)

Adds the Ephemeral Causal Cognition (ECC) substrate behind the ecc feature flag.

ComponentFileTestsDescription
Causal DAGcausal.rs22Typed/weighted edges, BFS traversal
Cognitive tickcognitive_tick.rs20Adaptive interval, drift detection
Cross-referencescrossref.rs12UniversalNodeId (BLAKE3), bidirectional store
Calibrationcalibration.rs10Boot-time benchmarking, p50/p95
HNSW servicehnsw_service.rs11Thread-safe HnswStore wrapper
Impulse queueimpulse.rs8HLC-sorted ephemeral causal events

See ECC for the full deep dive.

K4: Containers

Status: COMPLETE (config validation, lifecycle management, health propagation)

File: container.rs (~600 lines)

Key components:

  • ContainerManager with start/stop/health lifecycle
  • ContainerConfig with image, ports, volumes, env, restart policy
  • ContainerState state machine: Created -> Running -> Stopped -> Failed
  • Health check integration with HealthSystem

K5: App Framework

Status: COMPLETE (manifest parsing, install/start/stop lifecycle, agent spawning)

File: app.rs (~980 lines)

Key components:

  • AppManager with install/start/stop/uninstall methods
  • AppManifest parsed from weftapp.toml
  • AgentSpec, ServiceSpec, ToolSpec for component definitions
  • AppState machine: Installed -> Starting -> Running -> Stopping -> Stopped -> Failed

K6: Mesh Networking

Status: Phase 1 COMPLETE (types, traits, TCP/WS transport, 136 tests)

3,543 lines across 14 new files implementing all types, traits, protocol messages, and in-process logic. See Mesh Networking for the full deep dive.

Phase Dependency Graph

K0 (Foundation)
 |
 v
K1 (Process + Supervision)
 |
 v
K2 (IPC + Communication) -----> ExoChain (chain, tree, gate)
 |                                    |
 v                                    v
K2b (Hardening) <----- chain logging integration
 |
 v
K3 (WASM Sandbox) + K3c (ECC)
 |
 v
K4 (Containers)
 |
 v
K5 (App Framework + Clustering)
 |
 v
K6 (Mesh Networking + Replication)

Integration Checklist

Every new K-phase must satisfy these requirements:

  • Chain logging for all state changes
  • Tree registration in standard namespace
  • Gate check before privileged operations
  • Tests with chain verification
  • CLI commands in clawft-weave
  • Feature flag if external dependency
  • Documentation in docs/weftos/

Implementation Priority

Ordering per K2 Symposium decision D21: K3 -> K4 -> K5 -> K6, with iteration. K3-K6 are a development cycle, not a strict waterfall.

PriorityPhaseEstimated EffortKey Dependency
1K3 WASM sandbox + ServiceApi~25hwasmtime crate
2K4 Containers + ChainAnchor~20hDocker/Podman on host
3K5 App framework + Clustering~35hK3/K4 complete
4K6 Deep Networking + Replication~40hSPARC spec, transport design

On this page