No description
Find a file
Parfii-bot 5f7a5b2639 fix(wave18): 8 HIGH audit findings closed + three-role pipeline actually built
47 crates, 801 tests green (up from 771 at v0.34.0). Wave 18 audit
found 8 HIGH findings across architect/critic/security/validator. All
closed. Three-role pipeline REBUILT after validator discovered Wave 16
commit was a half-commit (files claimed but never tracked).

## A. Three-role pipeline (REBUILD — was missing from v0.33.0 despite
      CHANGELOG claim)

Files validator flagged absent: _roles/auditor.toml + merger.toml,
4 _capabilities/{policy/git-ops-scope,output/verdict,output/merge-result,
verify/fork-audit}/text.md, kei-spawn/src/{pipeline,precedent}.rs,
pipeline_smoke.rs + pipeline_unit.rs tests. ALL NOW REAL (verified by
git log --all and `ls`).

- auditor role: claude-subagent-type=critic, handoff=[merger]
- merger role: git-ops scope, claude-subagent-type=infra-implementer,
  leaf (empty handoff)
- 5 capability text.md (+ capability.toml for each) defining contracts
- kei-spawn pipeline.rs (171 LOC): pipeline_from_role, derive_steps,
  emit_pipeline_json, scaffold_downstream_tasks
- kei-spawn precedent.rs (118 LOC): env-gated advisory shell-out
- --pipeline flag on spawn subcommand
- +11 tests (pipeline_smoke + pipeline_unit)

## B. kei-fork — 4 HIGH fixes (Critic F1+F7a, Security #3+#4)

- `git add -A` → explicit path list from ls-untracked + ls-modified,
  with exclusion filter for .DONE / .KEI_FORK_META.toml / _archive/ /
  _forks/. No more merge bleed. +1 regression test.
- create() rollback: on write_meta or ledger_fork failure, worktree
  + branch cleaned. +1 test via KEI_FORK_FORCE_LEDGER_FAIL=1.
- worktree_add arg injection: added `--` sentinel + is_safe_refname()
  validator (refuses dash-leading, NUL, ..). +3 tests.
- PATH hijack: KEI_FORK_GIT_BIN env override for all Command::new(git).
  +1 test.

## C. kei-spawn — 2 HIGH fixes (Security #1+#2)

- HTTP body unbounded DoS: MAX_BODY_BYTES=10MiB + content-length
  pre-check + streamed cap (io::Read::take) for chunked encoding.
  +2 feature-gated tests.
- PATH hijack: KEI_LEDGER_BIN env override already existed at
  ledger_sh.rs:15; documented precedence + added 4 regression tests
  locking the 3-tier lookup order.

## D. kei-ledger-sign — 1 HIGH fix (Security #2)

- save_keypair atomic POSIX open(2) O_CREAT|O_EXCL + mode 0o600 +
  rename(2) into place. No race window where key is world-readable.
  +2 tests.

## E. spawn_from_task rollback (Critic F7b)

- register_in_ledger helper: on ledger fork failure, rollback_task_dir
  before error propagation. +1 test spawn_rolls_back_task_dir_on_ledger_fail.

## Audit summary

- architect: GO conditional (taxonomy 19% — defer)
- critic: HIGH closed, MEDIUM debt logged
- security: 4 HIGH closed; MEDIUM (tar symlink, watcher symlink) tracked
- validator: CHANGELOG no longer lies — three-role pipeline is real
- patent-compliance: GO / LOW risk unchanged

All 8 HIGH blockers from Wave 18 consolidated audit → GREEN.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 20:54:59 +08:00
.claude-plugin feat(v0.16): Anthropic plugin format + own marketplace 2026-04-22 15:10:15 +08:00
.github ci: cost optimisation — concurrency + paths-ignore + ubuntu-only PRs (v0.31.1) 2026-04-23 17:49:43 +08:00
_assembler feat(w10c): migrate remaining 7 non-core agents to substrate_role 2026-04-23 13:59:06 +08:00
_blocks sanitize: remove patent-metadata from main tree (Tier 1+2+3) 2026-04-23 19:20:16 +08:00
_bridges sanitize: remove patent-metadata from main tree (Tier 1+2+3) 2026-04-23 19:20:16 +08:00
_capabilities fix(wave18): 8 HIGH audit findings closed + three-role pipeline actually built 2026-04-23 20:54:59 +08:00
_manifests sanitize: remove patent-metadata from main tree (Tier 1+2+3) 2026-04-23 19:20:16 +08:00
_primitives fix(wave18): 8 HIGH audit findings closed + three-role pipeline actually built 2026-04-23 20:54:59 +08:00
_roles fix(wave18): 8 HIGH audit findings closed + three-role pipeline actually built 2026-04-23 20:54:59 +08:00
_schemas/fragments feat(convergence/p1): kei-entity-store engine + schema fragments + kei-task pilot 2026-04-23 04:46:47 +08:00
_templates feat(agent-substrate/phase-5): migrate 5 kit agents to role+task-spec — substrate v1 FULL 2026-04-23 03:07:18 +08:00
_ts_packages chore(v0.19.1): replace placeholder bun.lock with real lockfile + fix workspace path 2026-04-22 17:16:57 +08:00
docs refactor(wave17): cleanup — kei-shared SSoT + MEDIUM audit residuals + docs drift 2026-04-23 20:34:43 +08:00
hooks feat(agent-substrate/phase-4): hook wiring — 3-line glue for kei-capability 2026-04-23 02:51:10 +08:00
install fix(install): copy sibling data dirs (schemas/ assets/ templates/ fixtures/ migrations/) in copy_rust_primitive 2026-04-22 18:39:28 +08:00
scripts feat(substrate): apply user decisions + ship atom template + generator 2026-04-22 23:53:26 +08:00
skills sanitize: remove patent-metadata from main tree (Tier 1+2+3) 2026-04-23 19:20:16 +08:00
tasks/kei-prune-scaffold-w14 feat(wave14): 5 bio-inspired primitives + phase2 cleanup + substrate dogfood 2026-04-23 17:19:25 +08:00
tests feat(w10c): migrate remaining 7 non-core agents to substrate_role 2026-04-23 13:59:06 +08:00
.dockerignore docs(v0.21): .dockerignore + USB brain step-by-step guide 2026-04-22 18:47:12 +08:00
.gitignore feat(wave15): kei-dna-index + kei-fork Option-D path convention fix 2026-04-23 18:15:44 +08:00
CHANGELOG.md refactor(wave17): cleanup — kei-shared SSoT + MEDIUM audit residuals + docs drift 2026-04-23 20:34:43 +08:00
install.sh refactor(v0.16): split install.sh monolith (1238 LOC) into 17 cubes 2026-04-22 15:09:35 +08:00
kei-architect.md feat(agent-substrate/phase-5): migrate 5 kit agents to role+task-spec — substrate v1 FULL 2026-04-23 03:07:18 +08:00
kei-code-implementer.md feat(agent-substrate/phase-5): migrate 5 kit agents to role+task-spec — substrate v1 FULL 2026-04-23 03:07:18 +08:00
kei-cost-guardian.md feat(w10c): migrate remaining 7 non-core agents to substrate_role 2026-04-23 13:59:06 +08:00
kei-critic.md feat(agent-substrate/phase-5): migrate 5 kit agents to role+task-spec — substrate v1 FULL 2026-04-23 03:07:18 +08:00
kei-fal-ai-runner.md feat(w10c): migrate remaining 7 non-core agents to substrate_role 2026-04-23 13:59:06 +08:00
kei-infra-implementer.md sanitize: remove patent-metadata from main tree (Tier 1+2+3) 2026-04-23 19:20:16 +08:00
kei-ml-implementer.md sanitize: remove patent-metadata from main tree (Tier 1+2+3) 2026-04-23 19:20:16 +08:00
kei-ml-researcher.md feat(w10c): migrate remaining 7 non-core agents to substrate_role 2026-04-23 13:59:06 +08:00
kei-modal-runner.md sanitize: remove patent-metadata from main tree (Tier 1+2+3) 2026-04-23 19:20:16 +08:00
kei-researcher.md feat(w10c): migrate remaining 7 non-core agents to substrate_role 2026-04-23 13:59:06 +08:00
kei-security-auditor.md feat(agent-substrate/phase-5): migrate 5 kit agents to role+task-spec — substrate v1 FULL 2026-04-23 03:07:18 +08:00
kei-validator.md feat(agent-substrate/phase-5): migrate 5 kit agents to role+task-spec — substrate v1 FULL 2026-04-23 03:07:18 +08:00
LICENSE feat: KeiSeiKit v0.1.0 — initial public release 2026-04-20 23:58:34 +08:00
PLUGIN.md refactor(wave17): cleanup — kei-shared SSoT + MEDIUM audit residuals + docs drift 2026-04-23 20:34:43 +08:00
README.md refactor(wave17): cleanup — kei-shared SSoT + MEDIUM audit residuals + docs drift 2026-04-23 20:34:43 +08:00
settings-snippet.json feat(agent-substrate/phase-4): hook wiring — 3-line glue for kei-capability 2026-04-23 02:51:10 +08:00

KeiSeiKit

Tester notice (2026-04-23): git history was rewritten to sanitise commit subjects before public launch. If you have an existing clone, run git fetch --all && git reset --hard origin/main to resync. Working tree content is unchanged; only historical commit subjects differ.

A living neural structure you install next to your AI assistant. A mini-universe where any user, from any domain, can discover a new primitive or grow a new class of agent.

KeiSeiKit is not a toolkit. It is a substrate for cognitive growth — an opinionated neural structure of Kei that a developer installs, shapes, and extends. It sleeps when you sleep, remembers what you decided yesterday, heals mistakes it notices in itself, and runs from a directory you can put on a USB stick and carry between machines.

Install in one line

/plugin marketplace add KeiSei84/KeiSeiKit
/plugin install keisei@keisei-marketplace

Twelve agents appear in Claude Code, forty-three skills become callable as /self-audit, /sleep-on-it, /compose-solution, /new-project, /spawn-agent — and the nightly consolidation cycle is wired. Other install paths: docs/INSTALL.md.

The five biological principles

KeiSeiKit is organised around five properties a living neural system has, and most software doesn't. Each principle maps to concrete code shipped in this repo.

  • DNA and taxonomy. Every agent invocation gets a 80-character deterministic identifier composed from role, capability bitmap, scope hash, task-body hash, and per-spawn nonce. Every primitive and agent is tagged along seven orthogonal facets — kingdom, mechanism, domain, layer, stage, stability, language — so the graph is queryable along any axis. See _primitives/_rust/kei-agent-runtime/src/dna.rs and docs/TAXONOMY.md.

  • Creator lineage. Every row in the agent ledger carries creator_id and fork_parent_id. Who spawned what, from which parent, under which DNA — traceable. No orphan artefacts, no "where did this come from". See _primitives/_rust/kei-ledger/src/schema.rs migration v4.

  • Sleep. Three phases, every night. Phase A is incubation: during the day you drop tasks into /sleep-on-it; at 03:00 a remote Claude agent works on them. Phase B is REM: the same agent reads the day's JSONL traces, extracts cross-session patterns, and writes a report. Phase C is NREM (every seven days by default): a conflict-scan plus refactor-engine propose a clean-up branch. Nothing auto-injects into the next session — you git pull, read, decide. See docs/SLEEP-LAYER.md.

  • Self-healing. Three passive hooks (session-end-dump, milestone-commit-hook, error-spike-detector) feed a session retrospective. When the same mistake reappears twice, /escalate-recurrence offers to codify it as rule plus wiki entry plus hook — at the severity you pick. Silent-first: the first ten sessions log without prompting, so the baseline is real.

  • Growth by composition. /new-project scaffolds a project across four phases with branch + ledger + artefact bundle per fork. /spawn-agent emits a new agent manifest. /compose-solution decomposes a free-text problem, greps existing atoms for prior art, and proposes the smallest artefact — agent, skill, hook, rule, block, or pipeline — that closes the gap. Every session leaves the substrate slightly larger than it found it.

The deeper theory — why these five and not others, and the analogy with hippocampal / cortical dynamics — is in docs/PHILOSOPHY.md.

Four layers

4. Portability    USB stick / iCloud / S3 — keisei mount, any machine
3. Sleep          Phase A (incubation) → Phase B (REM) → Phase C (NREM)
2. Cognition      DNA + ledger + taxonomy + memory + self-audit
1. Substrate      atoms, agents, skills, hooks, blocks, bridges

Layer 1 is the body — the reusable parts. Layer 2 is identity and memory. Layer 3 is overnight learning. Layer 4 is the ability to pick up and move.

What ships (verified counts)

  • 47 Rust primitives — pure Rust workspace crates, release-stripped, each ≤2 MB, no Python runtime. Covers the ledger, memory, router, migrate, agent runtime, forge, spawn/replay, fork lifecycle, DNA adjacency/cluster index, pruning + discovery + brain-view, sleep infrastructure, and the keisei CLI.
  • 12 agents (kei-* namespaced) — code-implementer, infra-implementer, ml-implementer, critic, validator, security-auditor, architect, researcher, ml-researcher, cost-guardian, modal-runner, fal-ai-runner. All carry a substrate_role facet.
  • 43 skills — one-command pipelines including /new-project, /spawn-agent, /self-audit, /sleep-on-it, /sleep-setup, /compose-solution, /schema-design, /api-design, /auth-setup, /observability-setup, /ci-scaffold, /pr-review, /debug-deep.
  • 12 hooks — pre-commit safety net, always on: assembler, validator, no-hand-edit-agents, tomd-preread, agent-fork-logger, orchestrator-dirty-check, site-wysiwyd-check, session-end-dump, milestone-commit-hook, error-spike-detector, and two capability gates.
  • 82 behavioural blocks — tested patterns composable into your own agents via blocks = [...] in a manifest.
  • 11 capabilities / 5 roles — the capability-graph that agents resolve at spawn time.
  • 11 cross-tool bridges — one source of truth emits .cursorrules, Cursor MDC, AGENTS.md, Copilot, Windsurf, Junie, Continue, Gemini, Aider, Replit. Switch AI tools without rewriting your setup.
  • 800+ tests across the Rust workspace, green on cargo test --workspace on every supported OS.

Every number is regenerated from source by scripts/regen-counts.sh — no manual drift.

Domain-agnostic by construction

KeiSeiKit has no hardcoded domain. The same substrate ships unchanged for biology, finance, law, medicine, music, research, game dev, ops. What's domain-aware lives in the blocks — reusable markdown cubes you compose into an agent manifest — and the assembler rebuilds the affected agents when a block changes. If you work in a domain the kit doesn't yet cover, the path to first-class support is a manifest plus a handful of blocks, not a fork.

How to start

Install: the two-line plugin command above. Other paths — full profile, dev profile, MCP-only, manual, Nix, Docker — are in docs/INSTALL.md.

Discover a new primitive:

/compose-solution "I want a hook that blocks rm -rf ~/ in any Bash call"

The skill greps existing atoms, proposes the smallest intervention, drafts a block if nothing matches, and hands off to /escalate-recurrence to persist it.

Grow a new agent:

/spawn-agent

Four phases: role, task, scope, emit. The wizard writes the manifest, composes its DNA, forks a ledger row, and the assembler generates the agent markdown Claude Code will pick up.

Start a new project:

/new-project

Four phases: intake, fork skeleton, parallel execution (orchestrator owns git per RULE 0.13), merge ceremony with per-branch AskUserQuestion.

Portability

Every primitive is a pure Rust binary ≤2 MB. Every hook is POSIX shell. Every skill is markdown. Every manifest is TOML. The keisei CLI mounts a brain-directory into Claude Code + Cursor + Continue + Zed simultaneously; the directory can live on a USB stick, iCloud, S3, or any filesystem. Move it to another machine and the same agents, the same memory, the same artefact bundles are there. docs/USB-BRAIN-GUIDE.md.

Under the hood

Constructor Pattern: one file, one concern. TOML manifests are the source of truth. A Rust assembler compiles them to the Markdown Claude Code expects. When a block changes, a PostToolUse hook rebuilds every affected agent. Rust is the backbone because the type system catches the class of mistakes LLMs most often introduce — None vs [], missing .await, unhandled Result — at compile time, so they cannot ship. Python is reserved for the places where Python is genuinely better.

Build pipeline, cross-tool bridge mechanics, meta-composer internals, sleep-layer details → docs/ARCHITECTURE.md.

Docs

PHILOSOPHY.md The biological principles, in depth
INSTALL.md All install paths, profiles, keisei CLI, hook controls
ARCHITECTURE.md Build pipeline, bridges, meta-composer
REFERENCE.md Every primitive, hook, skill with flags and exit codes
SLEEP-LAYER.md Phase A / B / C nightly cycle + self-audit
TAXONOMY.md The seven-facet vocabulary
SUBSTRATE-SCHEMA.md Atom contract
SECURITY.md Threat model + mitigations
USB-BRAIN-GUIDE.md Portable brain — macOS / Linux / Windows
WHY.md The full story of why this exists
CHANGELOG.md What changed, version by version
PLUGIN.md Anthropic plugin-format details

Authorship

Built by Denis Parfionovich (parfionovich@keilab.io) at KeiLab, while running 48 parallel Claude Code terminals every day. What you are looking at is the scaffolding that makes that possible — shared now so you don't have to build your own. Forks and pull requests welcome.

License

MIT. See LICENSE.