Commit graph

246 commits

Author SHA1 Message Date
Parfii-bot
082b4c09e3 Merge feat/stream-e-invoke-wire — kei-runtime subprocess → real atoms 2026-04-23 01:21:12 +08:00
Parfii-bot
8626e23c22 feat(stream-e): invoke wire — kei-runtime subprocess → real atoms
Replace NotImplemented stub with real atom execution per schema
§Runtime invocation contract.

Convention: JSON-in/JSON-out over subprocess. Every refactored crate
exposes `<crate> run-atom <verb>` that reads JSON from stdin (or
--input), dispatches to atoms::<verb>::run, emits Output JSON on
stdout, exits per atom-error class.

Runtime side (kei-runtime):
- InvokeError: +AtomFailed{atom,code,stderr} +SubprocessError
  +OutputParse +BinaryNotFound{crate_name}. NotImplemented kept as
  legacy escape for atoms opting out of run-atom protocol.
- Output: now {atom: String, result: Value} — carries atom's actual
  return value.
- invoke_exit_code: AtomFailed passes through child exit (0..=255),
  Subprocess/OutputParse → 1, BinaryNotFound → 127, NotImplemented → 64.
- Binary resolution: KEI_RUNTIME_BIN_DIR env → PATH fallback.

kei-task side:
- New `pub mod run_atom` in lib.rs
- atoms/mod.rs: VERBS const + DispatchError enum wrapping per-atom errors
- src/run_atom.rs: read_input (stdin/@path/literal), dispatch, exit mapping
- main.rs: Cmd::RunAtom{verb, input} subcommand; collapsed three
  classify_*_error helpers into single classify_dispatch. Legacy
  create/search/add-dependency CLIs preserved.

Tests: 5/5 runtime (+1 invoke_real_atom integration), 9/9 kei-task
(+1 atoms::tests::verbs_list_matches_submodules).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 01:21:00 +08:00
Parfii-bot
9307f8d26e Merge fix/audit-wave-substrate-v1 — security hardening + CLI contract + integration test 2026-04-23 00:56:41 +08:00
Parfii-bot
f7e4725573 fix(substrate): amendment A-1 (input/output required all kinds) + integration test + jsonschema 0.18 relative-$id bug
Three post-E1/E2/E3-merge items:

1. Schema amendment A-1 (architect P0-a, non-breaking clarification):
   input.schema and output.schema are REQUIRED for all atom kinds. The
   shared kei-atom-discovery parses them as Option<PathBuf> only to allow
   tolerant skip-on-missing (stderr warn), not to permit absent schemas.
   Resolves Stream C / Stream D enforcement asymmetry documented in
   critic finding #6.

2. Cross-stream integration test (architect P0-b): tests/substrate_integration.sh
   builds release binaries, scaffolds a test atom corpus, runs
   schema-lint + list-atoms + atoms-discover + invoke; asserts all four
   streams agree on the same atom corpus and exit codes honour the
   locked §Runtime contract. Previously missing — only manual smoke
   checks existed.

3. Fix regression introduced by E1's jsonschema 0.18 upgrade:
   "relative URL without a base" on compile when schema declared a
   relative $id like "kei-task/atoms/schemas/create-input.json".
   validate.rs now synthesises an absolute file:// $id from the
   canonicalised schema path before compile. Internal $refs still
   resolve relative to the schema file; LocalFileResolver still confines
   to the schema's parent dir. Integration test catches this.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 00:56:27 +08:00
Parfii-bot
ca0635e0fa Merge fix/e3-contract-compliance — exit codes + invoke Err + strict lint
# Conflicts:
#	_primitives/_rust/kei-runtime/src/invoke.rs
2026-04-23 00:52:54 +08:00
Parfii-bot
4e9a7dddfb Merge fix/e2-kei-forge-hardening — DNS/CSRF/injection + headers 2026-04-23 00:49:59 +08:00
Parfii-bot
f1a6098aa9 Merge fix/e1-atom-discovery — shared crate + SSRF/traversal/YAML fixes 2026-04-23 00:49:59 +08:00
Parfii-bot
1bc6fbf4e3 fix(substrate): E3 — CLI contract compliance (exit codes + invoke Err)
Four audit findings on CLI contract violations per locked §Runtime schema:

- crit#7: invoke returned Ok with error payload — now returns
  Err(InvokeError::NotImplemented) → exit 64
- crit#5: typed errors collapsed via anyhow::anyhow!("{e}") in kei-task —
  replaced with CliError { code, msg } + classify_*_error helpers;
  validation errors exit 2, storage errors exit 1 (spec-compliant)
- crit#8: lint.rs wikilink parser accepted [[[foo]] — strict parse_wikilink
  from kei-atom-discovery used; emits finding for malformed entries
- crit#15: draft-07 detection was substring match — is_draft07_uri exact
  match against canonical URIs only

Tests: 4/4 kei-runtime (was 2; +2 invoke exit-code tests) + 8/8 kei-task
(was 7; +1 empty-title exit-2 test) = 12/12 green.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 00:49:49 +08:00
Parfii-bot
f7982f0415 fix(substrate): E2 — kei-forge security hardening (DNS rebind + CSRF + injection)
Three HIGH security findings resolved in _primitives/_rust/kei-forge/:

- F-1: DNS rebinding — require_local_host middleware returns 421 on
  non-localhost Host headers
- F-2: CSRF via urlencoded — require_json_content_type middleware
  returns 415 on non-JSON; form HTML now POSTs JSON via fetch()
- crit#1/SA F-7: description sed injection — whitelist validator rejects
  newline/CR/tab/NUL/backtick/$/length>200, blocks the shell-script attack
  at the Rust layer
- crit#11: missing security headers — CSP, X-Frame-Options DENY,
  X-Content-Type-Options nosniff, Referrer-Policy no-referrer on GET /

Zero new deps (axum 0.7 middleware::from_fn + HeaderMap native).
Constructor Pattern compliant — 6 Cube files, largest 231 LOC including tests.

Tests: 29/29 (was 12/12; +17 new). Includes 4 adversarial integration
tests for each defence layer.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 00:49:49 +08:00
Parfii-bot
990f5e3711 fix(substrate): E1 — kei-atom-discovery shared crate + 4 critical security fixes
Extracts authoritative atom discovery + frontmatter parsing into new crate
_primitives/_rust/kei-atom-discovery/. kei-sage and kei-runtime now both
consume the same implementation, eliminating Frontmatter drift.

Resolved findings:
- F-3/crit#3: path traversal via md_dir.join() — safe_join helper rejects
  absolute paths + .. components + post-canonicalise escapes (4 sites)
- crit#6/architect P0-a: Frontmatter drift — single AtomMeta struct
- SA supply-chain: serde_yaml archived — migrated to serde_yaml_ng 0.10
- crit#2: JSON Schema $ref SSRF — jsonschema 0.17→0.18 with resolve-file
  feature only, custom LocalFileResolver denies non-file:// schemes
- F-4: symlink traversal — walkdir follow_links(false) explicit everywhere
- F-5: YAML billion-laughs — 64 KiB pre-parse cap

Tests: 9/9 new crate + 23/23 sage + 2/2 runtime + 7/7 kei-task = 41/41 green.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 00:49:49 +08:00
Parfii-bot
42fe08232e Merge feat/stream-d-kei-runtime — invoke/list-atoms/schema-lint MVP
# Conflicts:
#	_primitives/_rust/Cargo.lock
#	_primitives/_rust/Cargo.toml
2026-04-23 00:13:16 +08:00
Parfii-bot
2361a21d15 Merge feat/stream-c-kei-sage-substrate — kei-sage walks atoms/*.md 2026-04-23 00:10:44 +08:00
Parfii-bot
ef48c9993b Merge feat/stream-b-atoms-kei-task — 3 pilot atoms per locked schema 2026-04-23 00:10:44 +08:00
Parfii-bot
9858662b72 Merge feat/stream-a-kei-forge — local web wizard scaffolding atoms 2026-04-23 00:10:44 +08:00
Parfii-bot
d68fddb59a feat(stream-d): kei-runtime — discover + validate + lint (invoke stub)
New crate _primitives/_rust/kei-runtime/ implementing §Runtime invocation
contract from locked substrate schema.

CLI (clap-derive):
- list-atoms [--root] [--crate] [--kind]   → walk + print
- invoke <atom-id> --input <json|@file>    → discover + validate input (stub exec)
- schema-lint [--root] [--crate]           → 6-check validator
- pipe <dag.toml>                          → "not yet implemented" stub

Modules (≤ 200 LOC each, largest lint.rs @ 171):
- src/discover.rs — walk_atoms walks <root>/*/atoms/*.md, parses frontmatter
- src/validate.rs — JSONSchema draft-07 via jsonschema 0.17.1
- src/invoke.rs — MVP stub: discover → parse → validate_input → boundary ack
- src/lint.rs — 6 checks: required fields, kind enum, side_effects shape,
  schema path existence + draft-07 declaration, wikilink resolution
- src/main.rs — clap CLI, exit 0|1|2 per §Runtime contract

Intentional stub boundary: invoke returns structured JSON ack (exit 0),
wire-up to concrete atom impls deferred to integration pass (needs
Stream B atoms landed first).

Registered kei-runtime in workspace members.

Tests: 2/2 integration smoke (lint_smoke, discover_smoke) green.

Stream D of substrate v1 parallel build.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 00:09:58 +08:00
Parfii-bot
57b9475e50 feat(stream-c): kei-sage substrate — walk atoms/*.md + wikilink graph
Extends kei-sage with substrate-atom indexing layer per locked schema
§Graph / discovery contract.

New modules (all ≤ 200 LOC, Constructor Pattern):
- src/atom_parse.rs — frontmatter splitter, wikilink parser, id splitter
- src/atoms.rs — AtomKind + FromStr, AtomRecord, discover_atoms, resolve_wikilinks
- src/atom_index.rs — persists atoms as Units + atom_related edges into existing Store
- src/atom_cli.rs — 4 subcommand handlers

New CLI subcommands (default root ~/.claude/agents/_primitives/_rust):
- atoms-discover — walks atoms/*.md, prints table
- atoms-rank — PageRank over wikilink edges (composes w/ existing vault)
- atoms-related <atom-id> — BFS from atom
- atoms-search <query> — FTS over frontmatter + body

Tolerant scan: invalid frontmatter → stderr warn + continue (never abort).
[[rules/...]] wikilinks filtered at edge resolution per scope (rules
integration deferred to follow-up).

Tests: 9 unit + 6 integration smoke + 8 pre-existing = 23/23 green.
Zero regression. Single new dep: serde_yaml 0.9.

Stream C of substrate v1 parallel build.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 00:09:57 +08:00
Parfii-bot
ae82bc6242 feat(stream-b): kei-task pilot — 3 atoms (create/search/add-dependency)
Pilot refactor per locked substrate schema. kei-task migrated to atom
layout:

- atoms/<verb>.md — YAML frontmatter + human body for 3 verbs
- atoms/schemas/<verb>-{input,output}.json — JSON Schema draft-07
- src/atoms/<verb>.rs — typed Input/Output/Error + pub fn run()
- src/atoms/mod.rs — module registry
- Cargo.toml [package.metadata.keisei] — crate-level substrate data
- src/main.rs — dispatcher for 3 pilot commands via atoms::

Zero behaviour change: 7/7 integration tests pass before and after
(create_and_get, update_persists, cycle_detected, milestone_linking,
dependency_chain_traversal, task_graph_edges, search_finds_task).

main.rs still has 5 non-migrated subcommands (update, graph,
dependency-chain, milestone, link-milestone) — scope discipline, they
migrate in later passes. main.rs 120 → 132 LOC.

Stream B pilot reference — other crates follow this pattern in v0.24+.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 00:09:55 +08:00
Parfii-bot
fd25c3af60 feat(stream-a): kei-forge MVP — local web wizard scaffolding atoms
New crate _primitives/_rust/kei-forge/ exposing POST /forge over axum
on 127.0.0.1:8747. Shell-outs to scripts/new-atom.sh for generation.
5-input inline HTML form, no JS required. 9 unit + 3 integration tests
green via `cargo test --features mock-generate`.

Registered kei-forge in workspace members.

Stream A of substrate v1 parallel build — see docs/SUBSTRATE-SCHEMA.md.
Spec pre-locked; schema immutable until 2026-06-03 or revocation.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 00:09:53 +08:00
Parfii-bot
9f6ba0cbfc Merge feat/substrate-schema-v1 — substrate schema v1 locked + template + generator 2026-04-23 00:00:33 +08:00
Parfii-bot
ae4f5b9813 feat(substrate): LOCK schema — 6-week parallel Stream A/B/C/D window opens
Schema at SUBSTRATE-SCHEMA.md (revised 2026-04-22) is immutable until
~2026-06-03 or explicit user revocation. 4 parallel streams may now
proceed independently against this contract.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 00:00:33 +08:00
Parfii-bot
559db303e1 feat(substrate): apply user decisions + ship atom template + generator
Schema revisions per user review 2026-04-22 (all 6 open questions resolved
— see §Decision log in SUBSTRATE-SCHEMA.md):

- #3 side_effects: string tags → structured { op, domain } objects (user:
  "лучше сразу с запасом")
- #4 capabilities.toml: DROPPED entirely (user: "почему не мд?"). SSoT is
  atoms/*.md. Crate-level metadata moves to Cargo.toml
  [package.metadata.keisei] — Cargo-native, no drift, no build.rs, no
  generated files to commit. kei-sage + kei-runtime walk atoms/*.md
  directly.
- #5 atom template: shipped in this PR (user: "ui же параллельно! создавай
  все!") so Streams B/C/D can scaffold atoms from day 0 without waiting
  for Stream A (kei-forge UI).
- #1/#2/#6 confirmed as drafted (draft-07, `::` separator, per-atom errors).

New files:

- _templates/atom/ — 5-file template set with placeholder substitution
  (__CRATE__, __VERB__, __KIND__, __DESCRIPTION__ etc). Covers
  atoms/<verb>.md, schemas/<verb>-{input,output}.json, src/atoms/<verb>.rs,
  tests/<verb>_smoke.rs. Each file is a minimal working skeleton.
- scripts/new-atom.sh — POSIX bash generator (bash for $'\n' / readonly /
  trap). Validates verb is lowercase kebab-case, kind is one of
  command|query|stream|transform. Refuses to overwrite existing files.
  Rolls back on any failure (trap ERR deletes all generated files so no
  half-scaffolded state). Tested: produces 5 files, placeholder
  substitution correct on smoke-test crate.

Stream B (atoms refactor) updated to drop the "generates capabilities.toml
via build.rs" wording — now just "writes atoms/*.md + updates Cargo.toml
[package.metadata.keisei]". Stream D reads atoms/*.md + Cargo.toml, not
capabilities.toml.

Schema status: revisions applied, decision log complete. Ready for
SCHEMA-LOCKED.md marker commit once user signs off on revised doc.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 23:53:26 +08:00
Parfii-bot
58944e15bd docs(substrate): v1 atom/capability/graph SSoT schema — DRAFT for review
Substrate thesis requires a single source of truth before parallel work
streams (UI/Atoms/Graph/Runtime) can proceed independently without drift.
This document is that SSoT.

Key decisions baked in (open to revision before lock):

- Atom = one verb on a primitive, not one crate. Target ~150 atoms
  across current 25 crates. Crate = physical container, atom = unit of
  composition.

- File layout: src/atoms/<verb>.rs (code) + atoms/<verb>.md (docs with
  machine-parseable YAML frontmatter) + atoms/schemas/*.json (JSON
  Schema draft-07 for input/output) + capabilities.toml (auto-generated
  aggregator, committed to repo).

- Atom kinds: command / query / stream / transform. Combined with
  side_effects[] and idempotent flag, runtime decides retry safety,
  parallelism, caching.

- Naming: <crate>::<verb> globally unique. Rust :: separator keeps it
  native-feeling.

- Versioning: atoms inherit crate SemVer. Breaking change to an atom =
  new atom (create-v2), old marked deprecated.

- Runtime contract: `kei-runtime invoke <atom-id> --input <json>` with
  schema validation at entry + exit, ledger row per invocation.

- Graph contract: kei-sage auto-walks atoms/*.md, resolves [[atom-id]]
  wikilinks, exposes rank / related / search / graph over atom corpus.

- UI contract: kei-forge web wizard generates .md + .json + .rs + test
  from form input; postcondition cargo check + kei-schema-lint pass.

Document declares 4 stream interfaces explicitly — each stream knows
what it reads from this schema, what it writes, what it does NOT depend
on from other streams. Enables true parallel work.

6 open questions flagged for user review at bottom:
1) JSON Schema draft-07 vs 2020-12
2) Atom ID separator :: vs /
3) side_effects strings vs structured
4) capabilities.toml committed vs gitignored
5) kei-atom-template in this PR or defer to Stream A
6) Error model per-atom vs shared registry

STATUS: DRAFT — awaits user approval + SCHEMA-LOCKED.md marker before
parallel streams start. Once locked, breaking changes require explicit
revocation + all-streams sync.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 23:39:24 +08:00
Parfii-bot
71cb04525b fix(release): v0.22.3 — native arm64-linux + gh-CLI Publish (no race, no draft)
Two production-readiness fixes motivated by the v0.22.2 post-mortem.

1. aarch64-linux: native ARM runner instead of cross-compile

   v0.22.2 consistently failed `Install aarch64 cross-linker` (apt
   gcc-aarch64-linux-gnu) on the ubuntu-latest x86_64 runner. Was
   carried as `experimental: true` so non-blocking, but meant no
   aarch64-linux Rust tarball ever shipped.

   Fix: move to ubuntu-24.04-arm (native ARM64 runner). Rust builds
   aarch64-unknown-linux-gnu HOST-NATIVELY — no cross-linker, no
   `.cargo/config.toml` linker override. `experimental: false` now —
   native path is reliable.

2. Publish step: softprops/action-gh-release → `gh release create` CLI

   v0.22.2 softprops/action-gh-release v2.6.2 uploaded all 15 assets
   successfully but exited with `failure` due to a metadata-update
   race: asset uploaded to GitHub's blob store, then the subsequent
   PATCH to set the asset's `name` returned 404 because the Releases
   metadata API hadn't caught up yet (eventual consistency). Workflow
   failure → Release left in Draft. We had to promote it manually
   (`gh release edit --draft=false`) and re-upload one missing sha256.

   Fix: replace the action with `gh release create` + `gh release
   upload --clobber` in a bash step.
   - Idempotent: existing release gets updated in place.
   - No metadata PATCH race: CLI never patches, it creates fresh.
   - Retry loop: up to 3 tries per asset on transient network errors.
   - `--clobber` means re-runs replace cleanly.
   - GitHub CLI is pre-installed on every runner, zero new deps.

Verified post-polish on v0.22.2: 16/16 assets present, Release
Published, `kei-mcp-server-darwin-arm64` + `keisei` both execute on
this MacBook (arm64) — adapter list shows Claude Code detected at
project+user scope. SHA256 of `keisei-aarch64-apple-darwin.tar.gz`
verified OK.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 23:22:50 +08:00
Parfii-bot
42d964b14f Merge docs/readme-split — 89 KB → 7.8 KB hero + 6 docs/ files + release.yml fix 2026-04-22 22:43:54 +08:00
Parfii-bot
8eadb12d00 Merge docs/readme-missing-sections — About + nightly-cycle + Security 2026-04-22 22:43:54 +08:00
Parfii-bot
f070ada841 fix(release): consolidate bun builds to ubuntu-latest (macos-13 deprecated)
Root cause: macos-13 Intel Mac runners were deprecated by GitHub. The
darwin-x64 bun matrix job was sitting queued for 1.5-2.5 hours on every
tag push (v0.21.1, v0.22.0, v0.22.1) and never picked up a runner. The
release job has `needs: [build-release, build-mcp-binary]` so it waited
forever — NO GitHub Releases were created for any v0.22 tag.

Fix: bun cross-compiles to every target (Linux / macOS / Windows,
x64 / arm64) from any host via `--target=<bun-target>`. Consolidate the
entire build-mcp-binary matrix onto ubuntu-latest. Binaries remain
native per-target (correct Mach-O / ELF / PE format preserved by bun
--target flag).

Side effects:
- Faster: Linux runners provision in seconds vs macOS in minutes
- No macOS quota cost (free tier: 2000 min/month, macOS = 10x multiplier)
- No runner starvation on tag push
- `continue-on-error` arm64-linux carve-out removed (no longer needed —
  all jobs now on the same runner pool with equal reliability)

Verified locally: bun 1.1+ supports all 5 target triples from Linux host.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 22:42:55 +08:00
Parfii-bot
ce9ba61ee0 docs(readme): split 89 KB monolith into hero-pitch + 6 docs/ files
README down from 89 KB to 7.8 KB (11x reduction, target was 10-15 KB).
Visitor-facing README now loads in one screen — hero + 3 killer features
+ what-it-solves + quick install + docs index.

Extracted 6 new files under docs/:

- INSTALL.md (15 KB) — prerequisites, profiles, interactive install,
  MCP binary, keisei CLI intro, runtime hook controls, what-you-get table
- REFERENCE.md (35 KB) — every one of 25 Rust primitives + 13 shell
  primitives + 10 hooks + 39 skills with actual CLI surface (clap flags,
  exit codes, env vars, state paths), keisei CLI deep-dive, 12 pipelines
- ARCHITECTURE.md (11 KB) — build pipeline, creating-a-new-agent,
  adding custom blocks/manifests, agents overview, cross-tool bridges,
  meta-composer, regen counts, workflow-file editing protocol
- SLEEP-LAYER.md (11 KB) — three-phase nightly cycle diagram,
  session self-audit (RULE 0.14), Cloud REM sync, sleep-on-it incubation,
  deep-sleep NREM consolidation with 4-primitive pipeline + example
- SECURITY.md (7.6 KB) — threat surface table + 8 mitigations in detail
  (memory-repo privacy, secrets-guard patterns, supply-chain SHA pinning,
  S3 SSRF, brain path/name validation, exFAT warning, battle matrix)
- WHY.md (3.6 KB) — full 'From the author' manifesto restored from
  git history (pre-1f3aaca product pivot). Medium/dev.to-friendly for
  virality, separate from the product README

New docs cross-link each other + README has docs index in tail.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 22:20:22 +08:00
Parfii-bot
b55c3d6ef3 docs(readme): restore About section + nightly-cycle overview + security model
Adds 6 missing pieces flagged by readme review:

1. ## About — author attribution + "not a product" positioning + "Why
   Rust, not Python" (was removed in 1f3aaca, but load-bearing context
   for new users). Keeps the product-oriented greeting intact above it.

2. ## Install — plugin vs classic two-path table up front; links to
   PLUGIN.md (v0.16+ Anthropic plugin format was previously un-linked).

3. ## The nightly cycle at a glance — unified ASCII overview of the
   three-phase sleep cycle (A incubation → B REM → C NREM), biological
   analog, phase-interaction rules (marathon owns night, Phase C cadence,
   morning report is human-only).

4. ### Deep-sleep NREM consolidation — 4-primitive pipeline diagram
   (conflict-scan → refactor-engine → graph-check via kei-store) plus a
   concrete example of a detected conflict.

5. ## Security model — 7 bullets covering memory-repo privacy, RULE 0.1,
   secrets-guard, GitHub Actions SHA pinning, S3 SSRF guard, marker
   0o600, exFAT/FAT32 warning. Plus battle-matrix mention.

6. ## Docs — link index to CHANGELOG / PLUGIN / USB-BRAIN guide / battle
   tests (none of those four files were referenced from README before).

README.md: +83 lines (1221 → 1304).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 21:46:06 +08:00
Parfii-bot
5ec90ca241 fix(tests): repair 2 missing closing braces from v0.22 Track-A↔Track-C merge
Merge of feat/v0.22-keisei-schema-v4 into main (which already had
Track C's fs_type tests) elided '); }' at 2 seams. Tests compiled
once I added them back, but the edit missed the git-add step.

No behaviour change — both tests already passed after the fix;
commit just closes out the working tree.
2026-04-22 21:16:22 +08:00
Parfii-bot
4f6cbfd305 Merge docs/v0.22-reference-section — README Reference section (conflict resolved)
CHANGELOG: Reference entry folded into Track A's block.
README: auto-merged cleanly (agent appended the 670-LOC Reference
section after 'What you get' table, untouched by Track A/B/C).

wc -l README.md: 1233 (was 563 pre-session — 2.2x growth from product
rewrite + USB guide + exobrain CLI docs + Reference section).
2026-04-22 21:11:21 +08:00
Parfii-bot
ca8d980ac6 docs(readme): comprehensive Reference section — every primitive/skill/hook/CLI with real behaviour
+670 LOC to README.md. Source-of-truth extraction from each primitive's
actual src/main.rs (clap subcommands) + hook header comments + skill
SKILL.md frontmatter.

Covers:
  - Rust primitives (25) with real subcommands, flags, state paths,
    exit codes. Extracted from src/main.rs.
  - Shell primitives (13) with usage signature + env-var contract.
  - Hooks (10) tabular + per-hook detail (event/severity/bypass).
  - Skills (39) grouped into 6 collapsible <details> sections.
  - keisei CLI deep-dive — real flag matrix, exit codes, env vars,
    SSoT location, v0.19 hardening invariants.

Agent flagged 4 discrepancies vs prior task-description drafts
(agent refused to fabricate: no --client / --force / --dry-run on
keisei, exit codes 0/1 not 0/1/2, kei-curator --db required).
These were never in the code — docs now describe reality.

bash scripts/regen-counts.sh --check: no drift
wc -l README.md: 1233

Closes user request 'сделай подробное описание каждой функции'.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 21:10:11 +08:00
Parfii-bot
4ccb1548a2 Merge refactor/v0.22-kei-store-async-backend — AsyncBackend trait + shared runtime 2026-04-22 21:06:50 +08:00
Parfii-bot
bc7e099697 refactor(v0.22): kei-store AsyncBackend trait + shared tokio runtime (Track B)
Extracts an AsyncBackend trait in kei-store so future GCS/Azure/Bunny
backends implement 5 async fns, not re-invent the sync-over-tokio
bridge. Closes architect P1 + P2 findings.

NEW src/async_backend.rs (189 LOC):
  - trait AsyncBackend with get/put/list/list_recursive/delete/exists
  - AsyncBackendStore<B: AsyncBackend> — generic MemoryStore impl
    (sync-over-async via shared runtime)
  - shared_runtime() -> &'static Runtime via OnceLock
    (multi-thread, 2 workers, enable_io+enable_time)
  - path helpers (validate_rel, short_hash, is_manifest_key) moved
    here as single source of truth

NEW src/s3_cloud/backend.rs (120 LOC):
  - S3AsyncBackend impl of AsyncBackend — 5 async fns using the
    existing aws-sdk-s3::Client

MODIFIED src/s3_cloud/mod.rs (200 → 43 LOC):
  pub type S3CloudStore = AsyncBackendStore<S3AsyncBackend>;
  Thin re-export + inherent new(cfg) constructor.
  Doc-header documents the extension seam: 'adding GCS = impl 5 async fns'.

MODIFIED src/s3_cloud/keys.rs (66 → 40 LOC): compat shim — re-exports
  validate_rel / short_hash / is_manifest_key from async_backend.
  Old call-sites + 4 unit tests unchanged.

Deps: async-trait = 0.1 added under s3 feature; tokio now has
  rt-multi-thread feature too.

FIXES N=2 Store footgun: prior impl created a current_thread Runtime
  per instance — 2 instances in one process = 2 runtimes, block_on
  panic if caller is on another runtime. Shared multi-thread runtime
  via OnceLock means N instances all share 2 workers.

REAL VERIFICATION (agent-pasted):
  cargo check -p kei-store: clean
  cargo check -p kei-store --features s3: clean
  cargo test -p kei-store --release: 10+9+0 = 19 passed
  cargo test -p kei-store --features s3 --release: 38+9+6 = 53 passed
    (+7 vs baseline 46)

Tests added (7):
  async_backend::tests::shared_runtime_is_singleton
  async_backend::tests::validate_rel_rejects_absolute
  async_backend::tests::validate_rel_rejects_parent
  async_backend::tests::short_hash_deterministic
  async_backend::tests::is_manifest_key_matches_format
  s3_cloud::tests::async_backend_shared_runtime_handles_two_store_instances
  s3_cloud::tests::async_backend_runtime_is_multi_thread

Public API preserved: S3CloudStore::new / .branch / .current_branch /
  .key / .backend_name. Factory + integration tests untouched.

Pre-existing: list_inner 38 LOC (moved verbatim from mod.rs, not
  refactored per Core Rule 3).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 21:06:50 +08:00
Parfii-bot
27c153cefb Merge feat/v0.22-keisei-schema-v4 — schema v4 + Scope::Auto + registry (conflicts resolved)
CHANGELOG: merged Track A (schema v4 + Auto + registry + time.rs split) and Track C (fs_type.rs + battle-matrix + USB guide split) Added entries side-by-side. Kept Track A's Removed block.

integration.rs: 2 conflict blocks merged by concatenation — Track C's
fs_type detection tests (2) and Track A's schema v4 / multi-brain /
Scope::Auto / templated hint / registry tests (16). Total 48 tests pass
(46 Track A + 2 Track C).

Missing closing braces on both merge boundaries repaired
(auto-merge dropped '); }' at 2 seams).
2026-04-22 21:06:23 +08:00
Parfii-bot
4bbc95fd7c feat(v0.22): keisei schema v4 + Scope::Auto + templated hint + registry (Track A)
BREAKING schema bump v3 → v4. Backward-compat via untagged serde
for v1/v2/v3 read-paths — no user-visible regression.

1. Schema v4 — multi-brain marker
   AttachRecord inverted: each Attachment carries its own brain_path
   + brain_name + scope + attached_at. Enables brain-A to Claude-
   Code (user scope) + brain-B to Cursor (project scope) in ONE
   marker. v1/v2/v3 auto-migrate via config_migrate.rs (NEW, 114
   LOC) — silent stderr notice on first v0.22 read.

2. Scope::Auto — default CLI behaviour
   'keisei attach <brain>' no longer defaults User scope blindly.
   New Scope::Auto resolves per-adapter via auto_scope():
     claude-code: CWD/.claude/ present → Project else User
     cursor:      CWD/.cursor/ present → Project else User
     continue:    User (no project concept)
     zed:         User (global settings only)
   'keisei mount' stays host-wide (always User fan-out).

3. Templated post_attach_hint
   fn post_attach_hint(&self, brain: &Brain, scope: Scope) -> String
   Each adapter interpolates brain name + scope. Example for
   claude-code: 'run /help in Claude Code (user scope) — verify
   '<brain-name>' is in mcpServers'.

4. Adapter registry
   adapters/_registry.rs (NEW, 32 LOC) — single canonical list
   of 4 adapters. adapter::all() delegates. 5th adapter = one
   line change, one place.

5. Dead code cleanup
   Error::NotAttached + Error::AdapterFailed removed. Grep-verified
   zero references.

6. config.rs decomposition (200 LOC rule)
   config.rs 224 → 197 LOC.
   time.rs (NEW, 90 LOC) — now_utc_string + format_epoch_utc +
     civil_from_days Howard Hinnant + 5 unit tests
     (epoch-0, leap day 2020-02-29, century-non-leap 2100-03-01,
      arbitrary 2026-04-22, RFC3339 shape).
   config_migrate.rs (NEW, 114 LOC) — WireRecord migration.

REAL VERIFICATION:
  cargo test -p keisei --release: 46 passed 0 failed
    (5 time::tests + 41 integration — 30 existing adjusted to v4 + 11 new)

Tests added:
  marker_v3_migrates_to_v4
  two_brains_can_be_attached_simultaneously
  detach_removes_single_brain_preserves_others
  scope_auto_resolves_to_{project,user}_*
  cursor_auto_scope_respects_cwd_dot_cursor
  post_attach_hint_interpolates_brain_name
  adapter_registry_lists_all_four
  dead_error_variants_removed
  time_now_utc_string_has_rfc3339_shape
  fresh_marker_has_schema_version_4

Agent corrected 3 of the spec's epoch anchor timestamps
(1583020800 → 1582977600 for 2020-02-29T12:00:00Z, 1776870000 →
1776877200 for 2026-04-22T17:00:00Z); century-non-leap anchor
4107542400 → 2100-03-01 was already correct.

Known pre-existing: continue_adapter.rs 206 LOC (was 204; +2 for
signature widening). Out-of-scope for this track.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 21:00:13 +08:00
Parfii-bot
1f3aaca58c docs(readme): remove 'From the author' + rewrite greeting product-oriented
User feedback: 'поменяй ридми и привествие, убери от автора'.

Replaced 18-paragraph personal preface with a 3-paragraph product
summary:
  1. One-line pitch: structural layer over Claude Code + Cursor +
     Continue + Zed that catches LLM failure modes at commit time
  2. Drop-in toolkit capabilities in one sentence
  3. Why-it-exists: LLMs are wired for plausible-but-wrong output;
     structure around the prompt is the fix, not better prompts
  4. Rust-first constraint: compile-time hallucination elimination

'Why Rust, not Python' collapsed into one paragraph.
'It is not a product' / 'forks and PRs welcome' / 'hope it is a
small Kei' — all removed.

Detailed per-function Reference section coming in separate commit
(agent in flight).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 20:59:25 +08:00
Parfii-bot
5c3f2a57cc Merge feat/v0.22-fs-warn-battle-matrix — FS warn + battle-test matrix + USB docs split 2026-04-22 20:56:42 +08:00
Parfii-bot
5993f32146 feat(v0.22): FS warn + battle-test matrix + USB docs platform split (Track C)
1. Filesystem type detection (architect P2 finding)
   _primitives/_rust/keisei/src/fs_type.rs (NEW, 103 LOC)
     - statfs(2)-based detection on unix (libc = '0.2' under
       [target.'cfg(unix)'.dependencies])
     - Recognizes exfat / msdos (FAT32) via f_fstypename on macOS,
       via f_type magic numbers on Linux (0x4d44, 0x2011bab0)
     - Windows stub returns Unknown (GetVolumeInformationW TBD)
     - warn_on_unsafe_fs(root) emits stderr warning on ExFat/Fat32
   brain.rs::load calls warn_on_unsafe_fs after canonicalize+symlink
     checks. Warning NOT fatal — user can opt into single-client use.

2. Battle-test matrix (architect P3 finding)
   tests/battle/Dockerfile.install-test-alpine (NEW)
     - alpine:3.19 + apk rust/cargo/pandoc
     - Exposes musl-vs-glibc issues in aws-sdk-s3, rusqlite, git2
   tests/battle/Dockerfile.install-test-debian (NEW)
     - debian:12 + rustup stable + pandoc
     - Default server distro, different apt structure from Ubuntu
   tests/battle/README.md rewritten — 3-distro matrix with run script

3. USB-BRAIN-GUIDE platform split
   docs/USB-BRAIN-GUIDE.md — restructured as TOC + platform-agnostic
     preamble + exFAT warning + cross-platform troubleshooting
   docs/USB-BRAIN-GUIDE-macos.md (NEW, 97 LOC) — Gatekeeper, diskutil,
     /Volumes, xattr -d com.apple.quarantine
   docs/USB-BRAIN-GUIDE-linux.md (NEW, 98 LOC) — /media/$USER,
     umount, ext4 recommended, systemd-udev auto-mount note
   docs/USB-BRAIN-GUIDE-windows.md (NEW, 115 LOC) — PowerShell
     Dismount-Volume, NTFS, FS-advisory Unknown caveat

REAL VERIFICATION (paste from agent):
  cargo check -p keisei: Finished (clean)
  cargo test -p keisei --release: 32 passed 0 failed (30 existing + 2 new)
  docker buildx outline: both new Dockerfiles parse

Constructor Pattern:
  fs_type.rs 103 LOC, brain.rs 198 LOC (at limit 200, held the line)
  All fns <30 LOC. Each USB guide sub-doc 97-115 LOC.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 20:56:42 +08:00
Parfii-bot
f33408f0d6 fix(v0.21.2): pin actionlint v1.7.12 sha256 constants (was SKIP placeholders)
Closes the one outstanding item from v0.21.1 wave-audit: SEC-H1 agent
left SHA256_* vars as 'SKIP' because no WebFetch available this session.

Sources verified via live curl:
  https://github.com/rhysd/actionlint/releases/download/v1.7.12/actionlint_1.7.12_checksums.txt

Pinned hashes (4 platforms):
  darwin_amd64: 5b44c3bc...c644
  darwin_arm64: aba9ced2...953f
  linux_amd64:  8aca8db9...a3d8
  linux_arm64:  325e971b...f0c6

End-to-end verified locally (darwin_arm64):
  HOME=/tmp/aln-test bash scripts/install-actionlint.sh
  → SHA-256 verified: aba9ced2...
  → actionlint -version: 1.7.12 installed by downloading from release page

Header comment updated: [UNVERIFIED] → [VERIFIED 2026-04-22 via curl ...].

ACTIONLINT_SHA256_OVERRIDE env var still works (for CI with different pins).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 20:42:58 +08:00
Parfii-bot
64aa34afe6 Merge fix/v0.21.1-audit-wave — 5 critic HIGH + 2 security HIGH + 3 polish 2026-04-22 20:03:17 +08:00
Parfii-bot
f12eb9f83c fix(v0.21.1): wave-audit consolidated — 5 critic HIGH + 2 security HIGH + 3 polish
Closes 10 audit findings from 4-agent wave (critic + security +
architect + validator) on v0.21.0.

CRITIC HIGH (5):
  H1 s3_cloud::commit() was listing with delimiter='/' — nested
     writes silently dropped from manifest hash. Added
     list_recursive() (no delimiter), filter manifest-*.json from
     hash input.
  H2 S3Cfg access_key_env + secret_key_env were advertised in TOML
     but never read. Wired via resolve_explicit_creds() with
     aws-credential-types. Partial-set or empty-resolve → error.
  H3 display::sanitize_display missing in detach.rs + mount.rs
     (regression of v0.19.2 L9 ANSI injection fix). Applied at 8
     print sites. 2 new integration tests.
  H4 adapters/jsonmcp.rs RESTORED (was lost in earlier merge).
     107 LOC shared module: load_json_or_empty / upsert_under_key /
     remove_under_key / persist. claude_code 163→105, cursor 165→106,
     zed 178→114. Unified error handling via ConfigParseError.
  H5 ENV_LOCK shared across kei-store tests. New test_env.rs (24 LOC)
     exposed under cfg(any(test, feature='s3')). github.rs +
     s3_cloud/tests.rs + s3_smoke.rs all use shared mutex. Fixes
     parallel-test race on KEI_STORE_S3_ENDPOINT.

SECURITY HIGH (2):
  SEC-H1 scripts/install-actionlint.sh — added sha256 verify
     (shasum/sha256sum) before extract. ACTIONLINT_SHA256_OVERRIDE
     env var for CI injection. Per-platform constants marked
     [UNVERIFIED: SKIP] pending live checksums.txt fetch (agent had
     no WebFetch this session — user follow-up: paste from
     https://github.com/rhysd/actionlint/releases/download/v1.7.12/checksums.txt).
  SEC-H2 S3 SSRF/IMDS guard. validate_endpoint() rejects:
     loopback (127/8, ::1, localhost), link-local (169.254/16,
     fe80::/10), metadata hostnames (google/azure). Override via
     KEI_STORE_S3_ALLOW_INTERNAL=1. HTTP rejected unless
     KEI_STORE_S3_ALLOW_INSECURE=1. Custom endpoint now REQUIRES
     explicit creds (no IMDS chain leak via third-party endpoint).
     4 reject + 3 accept tests pass.

POLISH (3):
  D1 docs/USB-BRAIN-GUIDE.md — ⚠️ WARNING block under Prerequisites:
     exFAT/FAT32 NOT safe for multi-client attach (SQLite WAL needs
     shared-mem mmap). Use ONE client at a time on those FSes.
     New Troubleshooting entry 'SQLite corruption on mount-attach'.
  D2 '~5 MB release binary growth' now labelled [estimate, E5 —
     not yet measured] in CHANGELOG.md + s3_cloud/mod.rs header.
  D3 scripts/validate-workflow-shas.sh exits 2 (not 0) when
     UNVERIFIED_COUNT > 0 and GITHUB_TOKEN absent. Distinguishes
     'network denied' from 'all good'.

REAL VERIFICATION (pasted by agent):
  cargo check -p keisei -p kei-store: Finished (clean)
  cargo test -p keisei --release: 30 passed 0 failed
  cargo test -p kei-store --release: 10 + 9 passed (default features)
  cargo test -p kei-store --features s3 --release:
    31 + 9 + 6 = 46 passed (with s3)
  bash -n scripts/*.sh: OK
  regen-counts.sh --check: no drift

Constructor Pattern: largest new src 200 LOC (s3_cloud/mod.rs, at
limit). jsonmcp.rs 107 LOC. test_env.rs 24 LOC.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 20:03:17 +08:00
Parfii-bot
2b3ba50ccb docs(v0.21): .dockerignore + USB brain step-by-step guide
.dockerignore — trim Docker build context (was trying to pack
2.6 GB target/ + 6 GB .claude/worktrees/ + 212 MB node_modules/
on 2026-04-22, causing daemon I/O error). Excludes Rust target,
TS node_modules/dist/.turbo, agent worktrees, .git, IDE files,
logs. Essential before any tests/battle/* docker build.

docs/USB-BRAIN-GUIDE.md — 11-step recipe for the physical-USB
exobrain workflow:
  1-4. Prepare + download 5 platform binaries + verify sha256
  5-6. keisei attach --scope=user → verify in Claude Code
  7.   keisei mount for multi-client fan-out
  8.   --scope=project for per-repo brains
  9-10. status + detach cleanup
  11.  safe eject
Plus Troubleshooting section (7 common errors with fixes),
plus What-this-tests-end-to-end checklist (6 v0.21 features
exercised).

Target audience: first-time user of v0.21 exobrain feature on
macOS (Linux adaptation notes inline).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 18:47:12 +08:00
Parfii-bot
340de0e2f6 fix(install): copy sibling data dirs (schemas/ assets/ templates/ fixtures/ migrations/) in copy_rust_primitive
Ship-blocker found by Docker battle-test: install.sh --profile=full
only built 6/25 Rust binaries on fresh ubuntu:24.04 because
kei-artifact has sibling schemas/*.json files that src/schemas.rs
include_str!s at compile time. Prior copy_rust_primitive only copied
Cargo.toml + src/ + tests/ — schemas dir missing → 5 compile errors.

Fix: whitelist 5 common sibling data directories (schemas, assets,
templates, fixtures, migrations) — copy each if present. Keeps
target/, .git/, and other build artifacts out.

Battle-test (pre-fix):
  full profile: 6/25 Rust binaries built (kei-artifact + cascade fails)
  install exit 0 (soft-fail design), silent partial-install

Expected post-fix:
  full profile: 25/25 binaries (pending re-verification on Docker)

Affects: any future crate that uses include_str!('../<dir>/*') on
a sibling data folder. 5-item whitelist covers the patterns we know;
extend as needed.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 18:39:28 +08:00
Parfii-bot
82689d108b Merge test/v0.21-battle-docker — Docker install.sh battle-test (CHANGELOG conflict resolved) 2026-04-22 18:38:58 +08:00
Parfii-bot
b1c5fd00d2 test(v0.21): Docker battle-test infra for install.sh on fresh ubuntu:24.04
tests/battle/Dockerfile.install-test — ubuntu:24.04 + deps
  (git, curl, ca-certificates, build-essential, jq, pandoc, rustup)
tests/battle/battle-entry.sh — ENTRYPOINT: runs install.sh with
  $PROFILE (default minimal), then verify.sh
tests/battle/verify.sh — POSIX sh gate: blocks >= 79, skills >= 39,
  top hooks >= 10, _lib hooks >= 2, test-gate.sh exits 0,
  settings.json valid JSON
tests/battle/README.md — build + run docs

SHIP-BLOCKER FOUND (for follow-up fix commit):
  kei-artifact crate fails to compile on fresh install because
  install/lib-primitives.sh::copy_rust_primitive copies only
  Cargo.toml + src/ + tests/. Crate has sibling schemas/ dir with
  5 JSON files that src/schemas.rs include_str!s at compile time.
  Missing → cargo build error, install exits 0 (soft-fail design)
  but full profile only produces 6/25 binaries instead of 25/25.

Real stdout verified:
  minimal: 80 blocks, 39 skills, 10 hooks, 3 _lib — exit 0 ✓
  dev:     same counts — exit 0 ✓ BUT 3/8 binaries (kei-artifact fail)
  full:    same counts — exit 0 ✓ BUT 6/25 binaries

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 18:37:55 +08:00
Parfii-bot
969ddf34cd Merge feat/v0.21-kei-store-s3 — real S3 backend (CHANGELOG conflict resolved)
Kept both Added blocks: v0.21 SSoT/Scope (from earlier merge) and
v0.21 kei-store S3. Both are part of the v0.21 ship.
2026-04-22 17:59:56 +08:00
Parfii-bot
e5cd0d6790 feat(v0.21): kei-store real S3 backend behind opt-in 's3' feature flag
Promotes S3 from MVP stub to functional via aws-sdk-s3. Default builds
unchanged (zero new deps). Feature flag ensures users who don't need
S3 don't pay the ~5MB binary / C-toolchain cost.

Cargo.toml: new [features] s3 = [...] gating 4 optional deps:
  aws-sdk-s3 = 1.130.0
  aws-config = 1.8.16 (with behavior-version-latest)
  tokio = 1.52.1 (current-thread runtime, no multi-threaded bloat)
  bytes = 1 (S3 body passthrough)

s3_cloud/ module (4 files, Constructor Pattern):
  mod.rs (190 LOC) — S3CloudStore + MemoryStore trait impl
  client.rs (81 LOC) — aws-config builder, KEI_STORE_S3_ENDPOINT
    override for R2 / Wasabi / MinIO / any S3-compat
  keys.rs (60 LOC) — path-traversal guard + DJB2 hash helper
  tests.rs (63 LOC) — builder + prefix + key-guard unit tests

Factory routing (factory.rs):
  with 's3' feature + bucket URL → S3CloudStore (real network)
  without 's3' feature → S3Store stub (existing MVP, preserved)

Security posture:
  - Branch-prefix isolation rejects  traversal at keys.rs layer
  - aws-config default credential chain (env → ~/.aws → IMDS);
    no bespoke credential handling
  - rustls, not OpenSSL (matches existing crate tree)

Tests: 22 existing + 11 new (4 keys + 3 client + 5 mod + 5 smoke)
  cargo test -p kei-store (default features): 9 passed
  cargo test -p kei-store --features s3: 22 + 9 + 5 = 36 passed
  cargo clippy -p kei-store --features s3: clean

Real stdout verified for all verify criteria. No fabrication.

MANIFEST.toml [primitive.kei-store] deps updated to reflect feature
opt-in model.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 17:59:11 +08:00
Parfii-bot
766ced792a Merge feat/v0.21-keisei-ssot-scope — SSoT ~/.keisei + Scope enum (user/project) 2026-04-22 17:56:10 +08:00
Parfii-bot
81e3b58533 feat(v0.21): keisei SSoT relocation + Scope enum (user/project)
Two architect-audit P1/P2 findings closed.

PART A — SSoT relocation
  Before: ~/.claude/keisei-attached.toml (baked Claude-Code subpath)
  After: ~/.keisei/attached.toml (client-neutral)
  config::migrate_from_legacy() runs inside config::read() — first
  call after v0.21 install reads legacy path, writes new path,
  deletes legacy, emits stderr notice.
  claude_code adapter's .claude/ subpath UNCHANGED — that's Claude
  Code's real config dir, not keisei's marker namespace.

PART B — Scope enum (architect P1)
  ClientAdapter trait gains:
    fn supported_scopes(&self) -> &[Scope] { &[Scope::User] }  // default
    fn config_path(&self, scope: Scope) -> PathBuf
    fn attach(&self, brain: &Brain, scope: Scope) -> Result<()>
    fn detach(&self, brain_name: &str, scope: Scope) -> Result<()>

  Per-adapter scope support:
    claude_code — [User, Project]  (~/.claude vs ./.claude)
    cursor      — [User, Project]  (~/.cursor vs ./.cursor)
    continue    — [User] only (Continue has no project concept)
    zed         — [User] only (Zed uses global settings)

  CLI: keisei attach <brain> --scope={user|project} (default user).
  keisei mount → always Scope::User (host-wide fan-out).
  Marker Attachment gains scope field with #[serde(default)] so
  v0.20 markers read as Scope::User (backward-compat).

  New Error::ScopeUnsupported { client, scope, supported } — blocks
  invalid combos (e.g. zed --scope=project) with clear message.

New module scope.rs (49 LOC) — Scope enum + serde + Display + FromStr.
paths.rs gains keisei_state_dir() returning $HOME/.keisei.

5 new integration tests:
  - legacy_marker_migrates_on_first_read
  - attach_with_project_scope_writes_local_config
  - attach_user_scope_still_default
  - scope_unsupported_by_adapter_errors
  - detach_respects_scope_from_marker

REAL VERIFIED cargo test -p keisei output: 28 passed; 0 failed.
cargo check -p keisei: clean.
grep /Users/denisparfionovich/ in edits: zero hits.

Constructor Pattern: scope.rs 49 LOC, paths.rs 34 LOC, largest fn
migrate_from_legacy() 22 LOC.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 17:56:10 +08:00
Parfii-bot
c7355ed77e Merge feat/v0.20.1-workflow-validation — actionlint + SHA validate + pre-commit hook 2026-04-22 17:53:57 +08:00