Kraftverk

Docs / Architecture

Architecture

Kraftverk is a Cargo workspace of first-party crates with a hard ceiling (≤10) to discourage artificial micro-crates. The product framing is the evidence loop; the implementation is a session that inspects, measures, searches, and persists.

Evidence loop

Measure → Experiment → Validate → Improve

Measure → Experiment → Validate → Improve, then learn and repeat.

Crate layout

CrateRole
kraftverk-coreDomain models, errors, stats, Kraft Index, goals/constraints
kraftverk-systemPlatform trait, Native/Mock, recovery journal, hardware eligibility, telemetry
kraftverk-benchKraftBench workloads + suite runner
kraftverk-optimizerSearch strategies + profile catalog
kraftverk-dataSQLite experiment store + reports + sessions
kraftverk-agentPrivileged agent IPC types (scaffold in 0.2)
kraftverk-sdkProgrammatic facade
kraftverk-cliUser-facing binary / optimize orchestration
kraftverk-desktopLocal engineering instrument UI

Control flow

CLI → open_session (inspect fingerprint, open DB, recover journal)
    → baseline/benchmark: KraftBench samples → Kraft Index → SQLite
    → optimize: SearchStrategy proposes Candidate
         → ApplyGuard (journal + apply/verify)
         → KraftBench samples → compare vs baseline
         → rollback (search) or commit (validated accept)
flowchart TB
  CLI[kraftverk-cli] --> SYS[kraftverk-system]
  CLI --> OPT[kraftverk-optimizer]
  OPT --> BENCH[kraftverk-bench]
  OPT --> SYS
  BENCH --> CORE[kraftverk-core]
  CLI --> DATA[kraftverk-data]
  DESK[kraftverk-desktop] --> DATA
  AGENT[kraftverk-agent] -.->|scaffold IPC| SYS

Platform boundary

Callers never branch on OS. Platform (in kraftverk-system) exposes capabilities/topology, read/apply/verify/rollback, and a mock-only score multiplier. MockPlatform simulates deltas, noise, failed applies, throttling, and unsupported keys for tests.

Persistence

SQLite stores fingerprint, versions, OS info, candidate JSON, parent id, samples, stats, telemetry, stability, score, accept/reject reason, and timestamps.

Privilege separation

Safe opts run in-process today. kraftverk-agent defines request/response types for a future authenticated local IPC channel. Privileged agent execution remains a scaffold in 0.2 — treated as experimental, not a finished security boundary.

Related

Optimizer · Safety · security.md