# Kernuq — full documentation (en)

> Source: https://kernuq.com. Generated from the official docs; each section below is one page.


---

<!-- https://kernuq.com/en/docs/introduction/ -->

# What is Kernuq

> The universal intelligence rotor and MicroAgent OS kernel for the AI era — single binary, cross-platform, self-evolving.

Kernuq (科努克) is not another chatbot, coding agent or personal assistant. It is infrastructure in the lineage of **Nginx** and the **UNIX VFS microkernel**: one statically linked binary that turns fluid, general-purpose intelligence (LLMs and ACP agents) into steady, controllable, auditable organizational work.

## In one sentence

> One binary. One company.

Once installed, your machine runs a kernel that routes external events to the right agent, schedules ten thousand resident MicroAgents, manages an org of humans and agents, keeps your secrets, and writes every change to an immutable log.

## What it solves

| Problem | How Kernuq answers |
| --- | --- |
| Agents work in silos | `Formation` hypergraphs orchestrate pipes, delegation and mesh negotiation; humans join as isomorphic seats |
| Every event burns tokens | The LLM-free `Ingress Router` dispatches deterministically; unmatched events are dropped and audited |
| Secrets leak into prompts | `vault://` is AES-256-GCM encrypted and blind-injected in Ring 0 — there is no plaintext read API |
| Agents break UI or config | Physically read-only `ui://rom/*` factory views plus atomic batch rollback |
| Deployments need many services | One binary with embedded SQLite and sqlite-vec, zero runtime dependencies |

## Core primitives

- **Provider (Tao)** — intelligence supply over LLM APIs and ACP.
- **Compute (Field)** — execution: local host, SSH, Cloudflare Sandbox.
- **Harness (One)** — the rotor, binding provider, compute, tools and loop.
- **MicroAgent & Human Seat (Two)** — goroutine-grade agents and human seats.
- **Formation (Three)** — hybrid human–agent topologies.
- **Asset (All things)** — outputs with full lineage metadata.

See [the six-layer ontology](/en/docs/ontology/).

## Next

- [Quickstart](/en/docs/quickstart/) — your first rotor in five minutes.
- [Installation](/en/docs/installation/) — installers and options for every platform.
- [AI agent integration](/en/docs/agents/) — let Claude Code, Codex and Cursor operate Kernuq.


---

<!-- https://kernuq.com/en/docs/quickstart/ -->

# Quickstart

> Install Kernuq, import a sample org, start the daemon and console, and run your first rotor over JSON-RPC — in five minutes.

## 1. Install

macOS / Linux:

```bash
curl -fsSL https://kernuq.com/install.sh | sh
```

Windows (PowerShell):

```powershell
irm https://kernuq.com/install.ps1 | iex
```

## 2. Probe

```bash
kernuq version
kernuq probe --json
```

`probe` reports the host OS, architecture, available toolchains (bash, git, ffmpeg, python3, docker…) and storage status.

## 3. Read the built-in manual

The CLI is progressively self-documenting — for humans and agents alike:

```bash
kernuq manual              # topic index (< 2 KB)
kernuq manual quickstart
kernuq schema harness      # print the formal JSON Schema
```

## 4. Dry-run and import seeds

Every write can be previewed with `--dry-run`:

```bash
kernuq validate --config kernuq.yaml --dry-run --json
kernuq import --config kernuq.yaml --db ~/.kernuq/data/kernuq.db --json
```

> Without `--config`, `validate` uses the example config embedded in the binary.

## 5. Start the daemon and console

```bash
kernuq serve --config kernuq.yaml --ui
```

Open `http://127.0.0.1:7680`. The daemon binds to loopback by default and the local owner needs no login.

## 6. Run your first rotor

```bash
curl -s http://127.0.0.1:7680/rpc \
  -H 'Content-Type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"agent.spawn_and_run",
       "params":{"harness_uri":"harness://ops/log-analyzer",
                 "input":"Summarize 5xx errors in the last 24h with root causes"}}'
```

The result includes a session URI and the full trajectory, which you can replay — and fork from any step — in the console's Sessions view.

## Next

- [Harness rotors](/en/docs/harness/) — write your own rotor.
- [Formation topologies](/en/docs/formation/) — turn agents and people into a team.
- [MCP server](/en/docs/mcp/) — let Claude Code build it for you.


---

<!-- https://kernuq.com/en/docs/installation/ -->

# Installation

> One-line installers for every platform, installer options, direct downloads, verification and building from source.

Kernuq ships as a single fully static binary with embedded SQLite (WAL) and SIMD-accelerated `sqlite-vec`. There are no runtime dependencies.

## One-line install

| Platform | Command |
| --- | --- |
| macOS / Linux | `curl -fsSL https://kernuq.com/install.sh \| sh` |
| Windows | `irm https://kernuq.com/install.ps1 \| iex` |

The installer detects OS and architecture (preferring native arm64 under Rosetta), downloads the matching binary, verifies it against `SHA256SUMS` when the release provides one, and adds the install directory to `PATH`.

## Installer options

| Variable | Effect |
| --- | --- |
| `KERNUQ_VERSION` | Pin a version such as `v1.0.0` (default `latest`) |
| `KERNUQ_INSTALL_DIR` | Install directory (default `~/.kernuq/bin`) |
| `KERNUQ_NO_MODIFY_PATH` | Set to `1` to leave shell profiles / user PATH untouched |
| `KERNUQ_JSON` | Set to `1` for a silent install that prints one JSON line |
| `KERNUQ_DOWNLOAD_BASE` | Custom download base (mirrors, air-gapped networks) |

Non-interactive install for agents:

```bash
curl -fsSL https://kernuq.com/install.sh | KERNUQ_JSON=1 sh
# {"ok":true,"binary":"/Users/me/.kernuq/bin/kernuq","version":"…","target":"darwin/arm64",…}
```

## Targets

| File | Platform |
| --- | --- |
| `kernuq-darwin-arm64` / `kernuq-darwin-amd64` | macOS Apple Silicon / Intel |
| `kernuq-linux-amd64` / `-arm64` / `-riscv64` | Linux (static musl, incl. embedded Linux) |
| `kernuq-windows-amd64.exe` / `-arm64.exe` | Windows x64 / ARM64 |

For MMU-less RTOS targets such as FreeRTOS and Zephyr there is **Kernuq-Nano**, a C99 edge-protocol subset (`edge/kernuq-nano`).

## Build from source

```bash
git clone https://github.com/Payhon/Kernuq.git && cd Kernuq
corepack pnpm --dir apps/console-prototype build   # embedded console
./scripts/build-matrix.sh host                     # → dist/kernuq-<os>-<arch>
./scripts/build-matrix.sh all                      # all 7 targets, requires zig
```

## Uninstall

Delete the binary and the data directory:

```bash
rm -f ~/.kernuq/bin/kernuq
rm -rf ~/.kernuq          # warning: removes all local data
```


---

<!-- https://kernuq.com/en/docs/ontology/ -->

# The six-layer ontology

> Tao, Field, One, Two, Three and All Things — how Kernuq maps Eastern generative philosophy, industrial motors and UNIX primitives onto six core primitives.

> The Tao begets One; One begets Two; Two begets Three; Three begets all things. — Tao Te Ching, Chapter 42

Every object in Kernuq belongs to one of six layers, each with an industrial-motor analogy and a URI scheme.

| Philosophy | Industrial analogy | Primitive | URI |
| --- | --- | --- | --- |
| Tao | Power grid / voltage | Provider | `provider://` |
| Field | Motor housing / load bench | Compute | `compute://` |
| One | Rotor / stator winding | Harness | `harness://` |
| Two | Motor assembly / operator | MicroAgent & Human Seat | `agent://` `human://` |
| Three | Production line / enterprise | Formation & Org | `org://` |
| All things | Finished goods | Asset | `vfs://` |

## Tao · Provider

Fluid, general-purpose intelligence. One abstraction over direct LLM APIs (OpenAI-compatible, Anthropic Messages…) and the **ACP protocol**, which can drive external Claude Code, Codex or another Kernuq node.

## Field · Compute

The physical hands of an agent. A controlled local host (`local_host`) by default; switch per rotor to a remote SSH server or an isolated Cloudflare Sandbox computer. See [Compute](/en/docs/compute/).

## One · Harness

The declarative atomic unit. It binds **provider + compute + a tool subset + an L0–L3 loop**, takes voltage in and emits a stream that honours a contract. See [Harness rotors](/en/docs/harness/).

## Two · MicroAgent & Human Seat

- **MicroAgent** — runs as a goroutine (default) or a bootstrapped isolated process and mounts 1–N harnesses. Ten thousand can stay resident on one node; a hot/cold state machine swaps idle context into SQLite.
- **Human Seat** — real people join as isomorphic seats. An `active_account` collaborates live in the console; a `contact_seat` registers only an email or phone, and the Presence Dispatcher handles approvals and follow-ups by email.

## Three · Formation

Recursively nested hypergraphs: `pipe`, `delegate` and `mesh`. An org grows smoothly from a one-person studio to a multi-subsidiary group. See [Formation topologies](/en/docs/formation/).

## All things · Asset

Documents, code, designs, finished films, reports — each with full lineage metadata and a `vfs://` address, delivered proactively via `asset_ready` events.


---

<!-- https://kernuq.com/en/docs/uri-schemes/ -->

# URI schemes & VFS

> Eleven orthogonal URI schemes and six VFS syscalls address every unit of intelligence, machine, person and asset.

Kernuq takes UNIX's "everything is a file" one step further: **everything is a URI**.

## Eleven schemes

| Scheme | Meaning |
| --- | --- |
| `provider://` | Intelligence supply: LLM and ACP |
| `compute://` | Execution: local host / SSH / Cloudflare Sandbox |
| `vault://` | Vault: AES-256-GCM credentials, blind-injected |
| `channel://` | Channels: webhook, email, IM |
| `vfs://` | Virtual file system: asset addressing |
| `tool://` | Tools: built-in, MCP, WASM, IPC drivers |
| `harness://` | Rotors |
| `agent://` | MicroAgents |
| `human://` | Human seats |
| `org://` | Org units, business lines and formations |
| `ui://` | Interface: SDUI views, widgets and ROM |

## Six syscalls

Every resource shares one set of primitives: `Stat`, `OpenRead`, `OpenWrite`, `Invoke`, `Watch`, `Control`.

## Invariants

- **Pass by reference** — payloads over 16 KB or binary media must live in `vfs://`; contexts carry only the URI.
- **Path traversal is blocked in Ring 0** — any path containing `..` is rejected.
- **`ui://rom/*` is physically immutable.**

## Hypertext capsules (KHLP)

Paste a `scheme://` address into the omnibar and it collapses into a clickable capsule with a type icon and a short name. Underneath is a lossless hypertext format:

```text
Ask @[Drama Studio](org://unit/drama) to rewrite @[Script v3](vfs://drama/script-v3.md) with @[DeepSeek](provider://llm/deepseek/reasoner)
```

See `kernuq schema hypertext-input` for the full contract.


---

<!-- https://kernuq.com/en/docs/harness/ -->

# Harness rotors

> The declarative atomic unit — binds provider, compute, a tool subset and an L0–L3 loop, and emits a stable contract stream.

A Harness is Kernuq's "One": a rotor that takes intelligence voltage and produces steady torque. It is declarative configuration stored in the resource layer — not code.

## Minimal example

```yaml
uri: "harness://ops/log-analyzer"
owner_unit_uri: "org://unit/group_hq"
title: "Log Analyzer Rotor"
provider_binding:
  primary_uri: "provider://llm/deepseek/reasoner"
compute_binding:
  compute_uri: "compute://builtin/local-host"
  lifecycle: "session_scoped"
io_contract:
  output_mode: "text_stream"
loop_spec:
  level: "L1_STEP"
  max_steps: 8
```

## Key fields

| Field | Meaning |
| --- | --- |
| `provider_binding` | Intelligence source; `primary_uri` points at a `provider://` |
| `compute_binding` | Execution field and lifecycle (e.g. `session_scoped`) |
| `io_contract` | Output contract: text stream, JSON Schema, asset… |
| `loop_spec` | Loop level (L0–L3) and step limit |

## Loop levels L0–L3

From a single call (L0) and a step-wise tool loop (L1) to plan–execute (L2) and reflect–revise (L3). Higher levels mean more autonomy — and stricter budgets and TTLs.

## Validation and revisions

```bash
kernuq schema harness                                  # the formal contract
kernuq validate --config kernuq.yaml --dry-run --json  # preview
```

Each change creates a new revision: list with `harness.revisions`, revert with `harness.rollback`; Cortex can propose changes via `harness.evolve`.


---

<!-- https://kernuq.com/en/docs/formation/ -->

# Formation topologies

> Orchestrate MicroAgents, human seats and sub-orgs as pipes, delegation pyramids and mesh negotiation with recursively nested hypergraphs.

A Formation is Kernuq's "Three": it turns agents and people into a team.

## Nodes

- `micro_agent` — a MicroAgent mounting one or more harnesses, with a `carrier` (e.g. `in_process`) and a `lifecycle` (`resident` / `ephemeral`).
- `human_seat` — a person, with an interaction kind (e.g. `approval`), delivery mode and timeout.
- `nested_formation` — a sub-formation, for group-scale orgs.

## Edges

| Kind | Semantics |
| --- | --- |
| `pipe` | Serial / parallel pipes with `fan_out.split_json_path` and `fan_in.strategy` (`barrier_all` / `first_success` / `quorum_majority`) |
| `delegate` | Supervisor → worker delegation with upward escalation |
| `mesh` | Negotiation on a shared blackboard topic with `max_rounds`, `member_timeout_ms`, `quorum_min_responders` |

## Example: a short-drama studio

```yaml
uri: "org://formation/ancient-mystery-drama"
owner_unit_uri: "org://unit/group_hq/branch_sh"
entry_node_id: "chief_director"
run_limits:
  max_total_steps: 160
  max_tokens_per_run: 500000
nodes:
  - id: "chief_director"
    node_kind: "micro_agent"
    lifecycle: "resident"
    harnesses: [{ role: "execute", uri: "harness://drama/chief-director" }]
  - id: "script_writer"
    node_kind: "micro_agent"
    lifecycle: "ephemeral"
    harnesses: [{ role: "execute", uri: "harness://drama/script-writer" }]
  - id: "storyboard_painters"
    node_kind: "micro_agent"
    pool_max_parallel: 8
    harnesses: [{ role: "execute", uri: "harness://drama/storyboard-painter" }]
  - id: "producer_final_review"
    node_kind: "human_seat"
    human_seat_spec:
      assignee_uri: "human://branch_sh/seat_producer_lin"
      interaction_kind: "approval"
      timeout_sec: 7200
edges:
  - { from: "chief_director", to: "script_writer", kind: "delegate" }
  - from: "script_writer"
    to: "storyboard_painters"
    kind: "pipe"
    fan_out: { split_json_path: "$.scenes[*]", max_concurrency: 8 }
    fan_in: { strategy: "barrier_all" }
  - { from: "storyboard_painters", to: "producer_final_review", kind: "pipe" }
```

## Deploy

```bash
kernuq schema formation
```

Deploy at runtime with `formation.deploy`, or let Cortex staff a team from one sentence (`cortex.interact` → `cortex.confirm_team`).


---

<!-- https://kernuq.com/en/docs/compute/ -->

# Compute

> The physical hands of an agent — local host, remote SSH and isolated Cloudflare Sandbox computers, mounted per rotor.

Compute is Kernuq's "Field": it abstracts physical execution environments as `compute://` resources and binds them into harnesses.

## Three substrates

### Local host — `local_host`

```yaml
uri: "compute://builtin/local-host"
substrate_kind: "local_host"
declared_capabilities: ["exec", "fs_rw", "pty"]
local_host_config:
  workspace_root: "~/.kernuq/workspaces"
  isolate_subprocess: true
```

### Remote SSH — `remote_ssh`

The private key lives in the vault and is blind-injected at execution time:

```yaml
uri: "compute://ssh/prod-order-01"
substrate_kind: "remote_ssh"
remote_ssh_config:
  ssh_vault_uri: "vault://infra/ssh/prod-order-01"
  remote_workdir: "/var/kernuq-ops"
  read_only_guard: true
```

### Cloudflare Sandbox — `cloudflare_sandbox`

Isolated Linux computers on Cloudflare Containers in milliseconds, with process streams, `/workspace` snapshot hydration, PTY, live port previews and GUI / CDP browser control:

```yaml
uri: "compute://cloudflare/desktop-computer-01"
substrate_kind: "cloudflare_sandbox"
declared_capabilities: ["exec", "fs_rw", "pty", "code_interpreter", "computer_gui", "port_preview"]
cloudflare_sandbox_config:
  gateway_url: "https://kernuq-sandbox-gw.example.workers.dev"
  auth_vault_uri: "vault://secret/cf-sandbox-gateway"
  gateway_contract_version: "kcg_v1"
  image_profile: "desktop-computer"
  idle_sleep_sec: 300
```

## Binding to a rotor

Pick the field with `compute_binding.compute_uri` in a harness. Different rotors of the same agent can run on different machines.

```bash
kernuq schema compute
```


---

<!-- https://kernuq.com/en/docs/cli/ -->

# CLI reference

> Every kernuq subcommand and flag, plus the agent-first conventions — --json, --dry-run and the progressive manual.

Every subcommand speaks `--json`; every write supports `--dry-run`. Errors are written to stderr as structured JSON: `{"error":{"code":…,"message":…}}`.

## Introspection

| Command | Purpose |
| --- | --- |
| `kernuq version` | Print the version |
| `kernuq manual [topic]` | Progressive manual; without a topic prints a < 2 KB index |
| `kernuq schema <kind>` | Print a formal JSON Schema |
| `kernuq skill-export [--dir <path>] [--json]` | Generate an Agent Skills `SKILL.md` |
| `kernuq probe [--json]` | Host and kernel probe |

Manual topics: `quickstart`, `uri-vfs`, `harness`, `formation`, `sdui-lowcode`, `widget-sandbox`, `admin-crud`, `security-boundaries`.

Schema kinds: `harness`, `formation`, `compute`, `resource-catalog`, `event`, `hypertext-input`, `sdui`, `ui-widget`.

## Config and data

```bash
kernuq validate --config <file> [--conf-dir <dir>] [--dry-run=true] [--json]
kernuq import   --config <file> [--conf-dir <dir>] [--db <path>] [--dry-run] [--json]
kernuq export   [--db ~/.kernuq/data/kernuq.db] [--dir ./exported-bundle] [--json]
```

YAML is the seed; SQLite is the runtime single source of truth. `export` writes the current state as a GitOps bundle.

## Run

```bash
kernuq serve --config <file> [--db <path>] [--bind 127.0.0.1:7680] [--ui]
```

`--ui` mounts the embedded SDUI console.

## Agent interop

```bash
kernuq mcp-serve [--db <path>] [--profile builder] [--batch-id <id>]
```

Runs a stdio MCP server. `--profile` is one of `observer`, `ui_co_designer`, `builder`, `operator`; every write in the process shares `--batch-id` for atomic rollback.

```bash
kernuq agent-host --node-id <id> --owner-unit <org-uri> --master-ws <ws-url> \
  --wrap claude --workspace ./workspace [--token $KERNUQ_ACP_HOST_TOKEN]
```

Wraps a local CLI agent as an ACP node that reverse-registers with the master; `--workspace` is the directory jail it may access.


---

<!-- https://kernuq.com/en/docs/json-rpc/ -->

# JSON-RPC guide

> The unified JSON-RPC 2.0 gateway — address, authentication, request shape, batching, event streams and error handling.

Kernuq exposes its whole control plane through one JSON-RPC 2.0 gateway: `POST /rpc`. It shares one transactional domain service with MCP tools, the CLI and the console (100% UI–Tool parity).

## Address and auth

- Default: `http://127.0.0.1:7680/rpc` (loopback only)
- The local owner needs no login; other callers send `Authorization: Bearer <token>`, issued by `iam.create_token` and revocable with `iam.revoke_token`.

## Request

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "harness.get",
  "params": { "uri": "harness://ops/log-analyzer" }
}
```

Methods are named `namespace.verb` across 18 namespaces: `system`, `cortex`, `agent`, `session`, `harness`, `formation`, `resource`, `provider`, `vfs`, `asset`, `sdui`, `event`, `bus`, `iam`, `org`, `vault`, `compute`, `prompt`. See the [API reference](/en/api/#rpc) for every method.

## Batching

Per JSON-RPC 2.0, send an array to batch calls; responses are matched by `id`.

## Event stream

`GET /events/sse` pushes KIEP interaction events (`notice`, `asset_ready`, `approval`, `choice`, `form_input`) and `kernel.entity.mutated`:

```js
const es = new EventSource('http://127.0.0.1:7680/events/sse')
es.addEventListener('kiep', (e) => console.log(JSON.parse(e.data)))
```

Reply to approvals, choices and forms with `event.respond`; mark as read with `event.ack_read`.

## Other HTTP endpoints

| Endpoint | Purpose |
| --- | --- |
| `GET /healthz` | Health, version, RSS |
| `GET /cortex/stream` | Cortex conversation stream |
| `ANY /mcp/v1` | MCP Streamable HTTP |
| `WS /acp/reverse` | ACP host reverse registration |
| `POST /webhooks/*` | Ingress webhook channel |
| `GET /vfs/raw` · `POST /vfs/upload` | Raw VFS streams and uploads |

## Errors

| code | Meaning |
| --- | --- |
| `-32700` | Parse error |
| `-32600` | Invalid request |
| `-32601` | Method not found |
| `-32602` | Invalid params |
| `-32603` | Internal error |

KSP extension errors (not found, permission denied, approval required…) use negative codes and carry hints in `error.data` that agents can act on.

## Try it live

The [API reference](/en/api/#sandbox) includes a read-only sandbox on the Cloudflare edge you can call directly.


---

<!-- https://kernuq.com/en/docs/schemas/ -->

# JSON Schemas

> The eight formal KSP v1.0 contracts and how to fetch them locally or from the edge.

Every configurable object in Kernuq is defined by a language-agnostic JSON Schema (KSP v1.0), so YAML seeds and runtime APIs never disagree.

| kind | Defines |
| --- | --- |
| `harness` | Rotors: provider / compute bindings, IO contract, loop |
| `formation` | Hybrid topologies: nodes, edges, fan-in/out, run limits |
| `compute` | Execution fields: local host / SSH / Cloudflare Sandbox |
| `resource-catalog` | Ten resource libraries: servers, platform accounts, databases, proxy pools, OpenAPI contracts… |
| `event` | KIEP interaction events |
| `hypertext-input` | KHLP hypertext capsule input |
| `sdui` | Server-driven UI: views, widgets and data bindings |
| `ui-widget` | Agent-built widgets: composite macros and sandboxed ESM bundles |

## Getting them

Locally:

```bash
kernuq schema formation > formation.schema.json
```

From the edge API (no install, CORS enabled):

```bash
curl -s https://kernuq.com/api/v1/schemas            # list
curl -s https://kernuq.com/api/v1/schemas/harness    # raw schema
```

## Editor completion

Declare the schema at the top of a YAML file for completion and validation in VS Code (YAML extension):

```yaml
# yaml-language-server: $schema=https://kernuq.com/api/v1/schemas/harness
uri: "harness://ops/log-analyzer"
```


---

<!-- https://kernuq.com/en/docs/mcp/ -->

# MCP server

> Use the built-in MCP server so Claude Code, Codex, Cursor and other agents can create resources, customize the UI and staff teams.

Kernuq has a built-in MCP server with two transports:

- **stdio** — `kernuq mcp-serve`
- **Streamable HTTP** — the daemon's `/mcp/v1`

## Connect

Claude Code:

```bash
claude mcp add kernuq -- kernuq mcp-serve --profile builder
```

Codex (`~/.codex/config.toml`):

```toml
[mcp_servers.kernuq]
command = "kernuq"
args = ["mcp-serve", "--profile", "builder"]
```

Cursor (`.cursor/mcp.json`) or any client that reads `mcpServers`:

```json
{
  "mcpServers": {
    "kernuq": { "command": "kernuq", "args": ["mcp-serve", "--profile", "builder"] }
  }
}
```

## Profiles

| profile | Capability |
| --- | --- |
| `observer` | Read-only introspection |
| `ui_co_designer` | UI co-design: evolve views, publish widgets |
| `builder` | Build resources, rotors and topologies |
| `operator` | Runtime control: sessions, rollback |

No profile can read `vault://` plaintext.

## Tools

Twelve cohesive domain tools: `kernuq_inspect`, `kernuq_org_admin`, `kernuq_resource_admin`, `kernuq_compute_admin`, `kernuq_harness_upsert`, `kernuq_formation_deploy`, `kernuq_ui_widget_publish`, `kernuq_sdui_view_evolve`, `kernuq_ui_reset_to_rom`, `kernuq_session_control`, `kernuq_audit_rollback_batch`, `kernuq_cortex_delegate`.

## Batches and rollback

All writes in one `mcp-serve` process share a `batch_session_id` (set it with `--batch-id`). Every change lands in `kernel_mutation_logs` with redacted before/after diffs; a human can review it in the console or roll the whole batch back atomically with `kernuq_audit_rollback_batch`.


---

<!-- https://kernuq.com/en/docs/agents/ -->

# AI agent integration

> llms.txt, agent.json, Agent Skill export and the ACP host bridge — how agents install, understand and operate Kernuq.

Kernuq is **agent-first**: every UI action has a tool twin, every command has `--json` and `--dry-run`, and this website is written for humans and machines alike.

## One-sentence install

Send this to your agent:

```text
Read https://kernuq.com/llms.txt, install Kernuq on this machine non-interactively with KERNUQ_JSON=1, verify with `kernuq probe --json`, then register `kernuq mcp-serve --profile builder` as your MCP server.
```

## Machine-readable entry points

| Address | Contents |
| --- | --- |
| `/llms.txt` | Site index (llms.txt standard) |
| `/llms-full.txt` | All English docs in one file |
| `/agent.json` | Install commands, MCP launch args, profiles, tools and endpoints |
| `/en/docs/<slug>.md` | Raw Markdown for any docs page |
| `/api/v1/schemas/<kind>` | Raw JSON Schemas |

## Agent Skill

```bash
kernuq skill-export --dir .claude/skills/kernuq-operator
```

The generated `SKILL.md` teaches the right workflow: learn contracts progressively with `kernuq manual` and `kernuq schema`, preview with `--dry-run --json`, and respect the four redlines.

## ACP host bridge

The other way round, Kernuq can dispatch your agent. `agent-host` wraps Claude Code / Codex on any machine as an ACP node:

```bash
kernuq agent-host --node-id mac-studio-01 \
  --owner-unit org://unit/group_hq \
  --master-ws wss://kernuq.example.com/acp/reverse \
  --wrap claude --workspace ./workspace
```

In `delegated_to_provider` mode Kernuq sends only the prompt and attachments; the external agent works in its own environment and its outputs are archived automatically.

## Rules for agents

1. Always `--dry-run --json` first and show the diff to a human.
2. Never put plaintext secrets in prompts or schemas — reference `vault://` handles.
3. Never mutate `ui://rom/*`; override `ui://builtin/*` with a `fallback_rom_uri`.
4. Use one `batch_session_id` per cohesive change set.


---

<!-- https://kernuq.com/en/docs/security/ -->

# Security model

> Ring 0–3 capabilities, four physical redlines, the blind-injection vault, human approval and mutation audit.

Security in Kernuq is not a sentence in a prompt; it is a physical boundary in kernel space.

## Four Ring 0 redlines

1. **`ui://rom/*` and `kernel_mutation_logs` are physically read-only.** No agent can tamper with the factory views or the audit trail.
2. **Zero plaintext vault reads.** `vault://` uses AES-256-GCM envelope encryption and is blind-injected into execution only in Ring 0.
3. **Sandboxed widgets are offline by default.** Agent-built ESM widgets run in isolated iframes with `connect_allowlist: []`; the RPC allowlist never includes `vault.*` or `system.*`.
4. **Humans approve the dangerous.** Destructive deletes, production writes and privilege escalation require a HITL `approval` event.

## Capabilities only narrow

Ring 0–3 capabilities can only shrink along a delegation chain — a child agent never gets more than its parent. `governance.limits` also caps spawn depth and fan-out to stop fork bombs:

```yaml
governance:
  limits:
    default_ttl: 16
    max_spawn_depth: 5
    max_fan_out_concurrency: 32
  hitl_approval:
    require_approval_for:
      - "tool://builtin/bash:write_or_network"
      - "budget_exceed_usd:10.0"
```

## Master key

The vault KEK lives in the OS keychain by default, with an environment-variable fallback:

```yaml
governance:
  vault_kek:
    provider: "os_keychain_with_env_fallback"
    env_var: "KERNUQ_MASTER_KEK_B64"
```

## Audit and rollback

Every write from the UI, API or MCP lands in `kernel_mutation_logs` with its `batch_session_id` and redacted before/after diffs, and broadcasts `kernel.entity.mutated`. Any batch can be rolled back atomically with `audit.rollback_batch`.

## Network exposure

The daemon listens only on loopback and OS-protected local pipes by default. LAN (mDNS) and internet (outbound-tunnel Magic Links) access must be enabled explicitly — see [Deployment](/en/docs/deployment/).


---

<!-- https://kernuq.com/en/docs/deployment/ -->

# Deployment & operations

> Listener tiers, LAN multi-user, outbound Magic Link tunnels, hot-reloaded prompts, GitOps export and backups.

## Three listener tiers

```yaml
listeners:
  unix_socket: "~/.kernuq/run/kernuq.sock"   # L1: local pipe bound to the real OS user (0600)
  http:
    bind: "127.0.0.1:7680"                   # loopback only by default
    lan_mdns:
      enabled: false                         # L2: advertise kernuq-studio.local for LAN sign-in
  outbound_scoped_tunnel:
    enabled: false                           # L3: project scoped approval / form Magic Links on demand
    magic_link_ttl_minutes: 120
```

- **L1 local** — the owner needs no login.
- **L2 LAN** — multi-user office sign-in; enable mDNS and bind to a LAN address.
- **L3 internet** — no inbound ports; an outbound tunnel projects read-only / scoped Magic Links with the control plane hard-isolated.

When serving the console over HTTPS, set `KERNUQ_CONSOLE_ORIGIN` to the full public origin (passkeys depend on it).

## Prompts are resources

Kernel prompts live in `prompts/system/*.prompt.md` and are embedded at compile time as a fallback. At runtime they load by priority — SQLite tuned version → config override → embedded — with `fsnotify` hot reload:

```yaml
prompts:
  hot_reload: true
  keep_last_known_good_on_error: true
  override_dir: "~/.kernuq/prompts"
```

## GitOps

```bash
kernuq export --db ~/.kernuq/data/kernuq.db --dir ./exported-bundle
git -C ./exported-bundle add -A && git -C ./exported-bundle commit -m "snapshot"
kernuq import --config ./exported-bundle/kernuq.yaml --dry-run --json
```

## Storage and backup

Data lives in `~/.kernuq/data/kernuq.db` (SQLite WAL). The authoritative track uses `synchronous=FULL` for zero loss on power failure. Back up with SQLite's online backup, or stop the daemon before copying the file.

## Proxy

Outbound traffic can be routed through SOCKS5 with bypass rules:

```yaml
network:
  socks5_proxy:
    enabled: true
    url: "socks5h://127.0.0.1:1080"
    bypass: ["127.0.0.0/8", "10.0.0.0/8", "192.168.0.0/16"]
```
