Commit graph

366 commits

Author SHA1 Message Date
Parfii-bot
11a14680c5 Merge feat/wave13-cleanup — HttpDriver + agent_id + safe_join + entity-store MEDIUM 2026-04-23 16:16:28 +08:00
Parfii-bot
c1556f505a fix: Wave 13 cleanup — HttpDriver + agent_id validator + safe_join + 4 MEDIUM
Closes the remaining v0.29.0 follow-ups + post-audit MEDIUMs.

## HttpDriver (kei-spawn http-driver feature)
- Real reqwest::blocking POST to api.anthropic.com/v1/messages
- Feature flag `http-driver = ["dep:reqwest"]` (default off, zero breaking)
- KEI_ANTHROPIC_KEY read at invoke time (rotation-friendly)
- 5 httpmock tests (missing key, 200, 4xx, 5xx, malformed json)
- Endpoint override via KEI_ANTHROPIC_ENDPOINT env for tests
- Files: drive.rs, drive_http.rs (new), drive_http_parse.rs (new), tests/http_driver.rs

## agent_id path-traversal validator (HIGH)
- New validate.rs with validate_agent_id() — whitelist grammar, 64-char cap,
  rejects /, \, .., leading dot/dash, NUL, :, whitespace, non-ASCII,
  Windows-reserved (CON/PRN/AUX/NUL/COM1-9/LPT1-9)
- Wired into all 5 agent_id→path sinks: load_task, resolve_agent_id,
  prepare, simulated_merge, verify_task
- autogen_agent_id moved to validate.rs with slugify_role helper —
  output passes validator by construction (100-draw property test)
- 33 new tests in agent_id_validator.rs

## safe_join symlink escape (MEDIUM)
- Base must canonicalize (nonexistent → Canonicalize error)
- Joined must start_with base_canon OR joined.parent() must start_with base_canon
- Blocks symlink-to-outside-base with non-existent tail file
- walk.rs refactored into 5 ≤17-LOC helpers
- 7 new tests in safe_join_hardening.rs

## entity-store 4 MEDIUM fixes
- ddl.rs: panic on unsupported FieldKind → typed DdlError::UnsupportedExtraColumn
  propagated through Store::open as VerbError::InvalidInput (exit 2).
  Extracted ddl_edge.rs + ddl_error.rs modules. Backward-compat shim preserved.
- search.rs: FTS5 empty-tokenization → typed InvalidInput on queries with
  no alphanumeric tokens (was opaque rusqlite error). Unicode-aware via
  char::is_alphanumeric.
- engine.rs: WAL pragma failure now logged to stderr with path + rusqlite
  source; fallback to rollback journal preserved (exit-code contract intact).
- bug_fixes_smoke: added fts5_phrase_quoting_preserves_legitimate_queries —
  catches over-broad sanitizer that passes injection test alone.

## Verified
- cargo check --workspace clean (both with and without http-driver feature)
- cargo test --workspace: 668 tests green (up from 620)
- substrate_integration.sh ✓, hook_wiring_integration.sh ✓

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 16:16:24 +08:00
Parfii-bot
47317ab708 docs: refresh HANDOFF-WAKE for v0.29.0 (Wave 13 shipped)
- Real crate count: 39 (was claimed 18 pre-audit; README agent caught it)
- 620 tests green (up from 538 at v0.28)
- Wave 13 entry added with 3 primitives + 2 HIGH fixes

Known follow-ups for v0.29.1:
- HttpDriver re-run (worktree lost mid-session)
- agent_id path-traversal validator re-run (worktree lost mid-session)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 15:56:31 +08:00
Parfii-bot
d521e7d89a feat(wave13): kei-diff + kei-scheduler + kei-watch primitives
3 new primitives, registered in workspace members (39 crates total):

- kei-diff (9 files, 27 tests): Structural JSON diff RFC 6902 subset
  (add/remove/replace). Pure computation. Index-based array diff
  (not LCS) matches drift-detection semantics. Round-trip property
  verified on 15+ fixtures. Zero sibling deps — pure utility.

- kei-scheduler (12 files, 16 tests): Durable task scheduler (cron /
  at / interval) primitive. Engine-native (SCHEDULER_SCHEMA on
  kei-entity-store). Name-unique via custom migration. compute_next
  pure fn + CLI tick for external executor.

- kei-watch (12 files, 30 tests): Filesystem watcher thin wrapper
  around notify 8.x. Sync API (no tokio). 50ms debounce. Cross-platform
  rename handling (macOS Modify(Name(Both)) vs Linux From/To pair).

All crate-local [workspace] tables removed. Registered in
_primitives/_rust/Cargo.toml. cargo check --workspace clean.

Constructor Pattern: all source files <=200 LOC, all functions <=30 LOC.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 15:51:42 +08:00
Parfii-bot
770402ac7a Merge feat/wave13-dna-unique — DNA UNIQUE constraint 2026-04-23 15:45:46 +08:00
Parfii-bot
3cc4279a54 fix(ledger): DNA UNIQUE constraint + v5 migration (HIGH audit)
1 HIGH audit fix: agents.dna had no UNIQUE constraint → duplicate
DNAs accepted silently → kei-replay ambiguous.

- schema.rs: v5 migration adds CREATE UNIQUE INDEX idx_agents_dna_unique
  with pre-check. If existing DB has dna duplicates, migration surfaces
  typed LedgerError::DnaMigrationBlocked { duplicates: Vec<(String, usize)> }
  instead of silently dropping rows.

- error.rs: +DnaCollision { dna } (runtime insert violation at fork).
  Caller regenerates nonce and retries.
  +DnaMigrationBlocked (migration-time precheck failure) with
  resolution hint in doc-comment.

- ledger.rs: classify_insert_error distinguishes DNA-violation vs
  duplicate-id vs generic SQL error.

- NULL handling: multiple NULL dnas allowed (SQLite default UNIQUE
  semantics), preserves v2 "dna optional" contract.

+5 tests, 23/23 kei-ledger green.

Constructor Pattern: source files <=192 LOC, all functions <=25 LOC.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 15:45:43 +08:00
Parfii-bot
fc0f85a947 Merge feat/wave13-fts-fix — HIGH audit fixes 2026-04-23 15:45:27 +08:00
Parfii-bot
0706733abf fix(entity-store): FTS delete-tx + archive FTS desync (HIGH audit)
2 HIGH security/correctness fixes from post-v0.28 audit:

- delete.rs: hard-delete now wraps FTS DELETE + table DELETE in
  unchecked_transaction. Prior: two separate execute calls could
  leave FTS orphan on second-stmt failure. Same pattern as C2 fix.

- archive.rs: archive-UPDATE + FTS DELETE now atomic in one tx.
  Prior: archived rows remained searchable (UX/privacy leak).
  Semantics documented: archive = hidden from FTS; unarchive must
  re-insert (caller responsibility).

+4 regression tests: delete_rollback_on_fts_sabotage,
archive_removes_from_fts, archive_rollback_on_sabotage,
delete_succeeds_when_no_fts_configured. All green (49/49 kes tests).

Constructor Pattern: all files <200 LOC, all functions <30 LOC.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 15:45:23 +08:00
Parfii-bot
f2358397c9 docs: README bio-framing + PHILOSOPHY + security hardening
- README rewritten with bioinspired framing: KeiSeiKit as living
  neural structure of Kei (DNA / REM / Deep Sleep / creator lineage).
  All counts verified against source: 36 crates, 12 agents, 43 skills,
  12 hooks, 82 blocks.

- docs/PHILOSOPHY.md new 11.4 KB deep-dive on the substrate
  thesis, the 4-layer architecture, and roadmap (federation / signing
  / marketplace / visualization as Wave 14+).

- .gitignore hardened: .env, secrets/, *.pem, *.key, id_rsa*,
  id_ed25519*, .claude/secrets/ — public-repo safe. .env.example
  and .env.template re-included.

- docs/SECURITY.md: secret hygiene section with revoke-and-rotate
  protocol + canonical ~/.claude/secrets/.env reference (RULE 0.8).

Verified clean: defensive grep for sk-ant-, ghp_, private keys,
token/key assignments = zero hits across tree.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 15:44:52 +08:00
Parfii-bot
700d8143ea docs: refresh HANDOFF-WAKE for v0.28.0 (wave 12 shipped)
- 6 tags summary (v0.23 → v0.28)
- 538 tests, 18 crates, 12/12 agents substrate-native
- Wave 11 + Wave 12 closure noted
- 2 open follow-ups: HttpDriver + Wave 13 scaffolds
- Security note on mid-session API key leak

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 15:16:39 +08:00
Parfii-bot
7f3ca9137b Merge W12B — docs count refresh 2026-04-23 14:44:31 +08:00
Parfii-bot
0f586f0143 Merge W12A — sister re-migration (campaigns promoted) 2026-04-23 14:44:31 +08:00
Parfii-bot
5113c35914 docs(w12b): refresh counts across README / INSTALL / REFERENCE after v0.23-v0.27
9 stale count references updated:
- README.md: 12 agents / 43 skills / 12 hooks / 82 blocks / 36 primitives
- docs/INSTALL.md: 33→36 (full profile), new crates enumerated
- docs/REFERENCE.md: 25→36 crates, 10→12 hooks, 39→43 skills; v0.27
  note on 11 crates awaiting full per-crate REFERENCE entries
- docs/ARCHITECTURE.md: 10→12 hooks (added capability hooks)
- docs/SUBSTRATE-SCHEMA.md: 25→36 crates (count-only refresh, locked)
- docs/SECURITY.md: battle matrix floors 79/39/10 → 82/43/12
- PLUGIN.md: 24→36 Rust primitives

NOT modified (intentional):
- CHANGELOG.md (auto-generated by kei-changelog)
- docs/WHY.md (stable philosophy)
- docs/TAXONOMY.md (vocab stable)
- docs/HANDOFF-WAKE.md (historical snapshot, frozen by design)
- docs/CONVERGENCE-PLAN.md (strategy analysis, frozen)
- docs/AGENT-SUBSTRATE-SCHEMA.md (phase plan counts are plan-of-record,
  not current state)
- SCHEMA-LOCKED.md / SCHEMA-UNLOCKED.md / AGENT-ROLES.md (registry)
- USB-BRAIN-GUIDE-* (platform guides, no counts)

Follow-up flagged: REFERENCE.md needs per-crate expansion for 11 new
crates (kei-agent-runtime, kei-capability, kei-provision, etc). That's
doc rewrite not audit — separate PR.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 14:44:31 +08:00
Parfii-bot
5bd4a6166f feat(w12a): sister re-migration — content-store campaigns promoted to engine
content-store: CAMPAIGNS_SCHEMA added (INTEGER PK, plain CRUD).
create_campaign now delegates to engine v_create::run.

Stayed bespoke (documented):
- prompts (INSERT OR IGNORE + hash-dedup semantics)
- campaign_assets (composite PK not supported by engine)
- organizations in social-store (UNIQUE name upsert)
- interactions in social-store (FK CASCADE + graph aggregate)

Coverage: content-store 45%→67%, social-store unchanged 50%.

Tests: 4/4 content-store, 5/5 social-store preserved.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 14:44:31 +08:00
Parfii-bot
7e2e5c642c Merge P-pipe-cache — kei-cache wired into kei-pipe DAG executor 2026-04-23 14:27:15 +08:00
Parfii-bot
60647ffd1c Merge P-install — MANIFEST.toml + 8 new crates registered 2026-04-23 14:27:15 +08:00
Parfii-bot
64888d5748 Merge A — Store::open multi-schema; kei-chat-store sessions engine-owned 2026-04-23 14:27:15 +08:00
Parfii-bot
c439a01961 feat(a): Store::open multi-schema — kei-chat-store sessions fully engine-owned
Breaking API change: Store::open(path, schemas: &[&EntitySchema])
replaces single-schema variant. All 6 callers migrated in same commit.

Engine changes:
- engine::run_migrations wraps ALL schemas in one unchecked_transaction
- Cross-schema atomicity: failing migration in schema[N] rolls back
  schema[0..N-1] too. Verified via new failing_migration_rolls_back_
  prior_schemas test.

Sister crates (5): trivial slice wrap in store.rs — 6 sites each,
~2 LOC delta.

kei-chat-store MAJOR change:
- Split CHAT_SCHEMA → MESSAGES_SCHEMA (INTEGER PK, FTS) + SESSIONS_SCHEMA
  (TextPk UUID, TextArchiveEnum status 'active'|'archived', status_at +
  message_count/total_tokens/total_cost aggregate cols)
- Drop chat_sessions DDL from custom_migrations (engine owns now)
- start_session → v_create::run(&SESSIONS_SCHEMA)
- archive_session → v_archive::run (writes 'archived' sentinel +
  stamps status_at via TextArchiveEnum mode)
- get_session → v_get::run
- bump_session_totals stays bespoke (per-message aggregate UPDATE not
  a generic CRUD op)

Substrate coverage kei-chat-store: ~60% → 100% (messages + sessions
both engine-owned).

Tests: 45 entity-store (was 42, +3 multi_schema_smoke: two-schema
creates, verbs dispatch per schema, rollback atomicity).
All sister crates preserved: task 9, chat 6, content 4, social 5,
crossdomain 5, sage 36.

Closes HANDOFF-WAKE's final architectural gap.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 14:27:15 +08:00
Parfii-bot
4a9dd98fde feat(p-pipe-cache): wire kei-cache into kei-pipe DAG executor
Optional per-step and DAG-level cache config in dag.toml:
  [[steps]]
  cache = { enabled = true, ttl_sec = 3600 }
OR
  [pipe]
  cache = { enabled = true, ttl_sec = 3600 }

Cache gated by AtomKind — only query/transform cacheable; command/stream
always re-invoke even with cache.enabled=true.

StepReport.source: Some('cache'|'fresh') | None shows cache outcome.

Constructor Pattern: extracted src/config.rs (CacheConfig + StepKind
+ TOML raw types + split_pipe_cache parser) + src/topo.rs (topo-sort)
to keep dag.rs under 200 LOC.

Tests: 8/8 (was 5, +3: cache-hit reuse, cache-disabled always invokes,
command-kind not cached even if enabled).

kei-cache 22/22 preserved.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 14:26:11 +08:00
Parfii-bot
ca8833b582 feat(p-install): register 8 new crates in MANIFEST.toml + profile selection
Added [primitive.*] entries for kei-agent-runtime, kei-capability,
kei-provision, kei-entity-store, kei-pipe, kei-cache, kei-spawn,
kei-replay. Profile memberships:
- ops: +kei-provision (total 9)
- dev: +7 substrate+automation primitives (total 17)
- full: +8 (total 46)

docs/INSTALL.md + README.md updated with new counts.

Not registered (lib-only, no main.rs): kei-atom-discovery.
Flag for follow-up: kei-forge + kei-runtime are in workspace but not
in MANIFEST (were before my scope). regen-counts.sh will soft-warn.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 14:26:11 +08:00
Parfii-bot
ddea993385 docs: final HANDOFF-WAKE for v0.26.0 — 4 tags overnight, 1 remaining architectural decision
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 14:09:26 +08:00
Parfii-bot
d92d1c0b1f Merge W10C — 7 remaining agents migrated to substrate_role 2026-04-23 13:59:18 +08:00
Parfii-bot
3cfefa7dfc Merge W10B — kei-sage facet-query includes _roles/ 2026-04-23 13:59:18 +08:00
Parfii-bot
c10f17c202 Merge W10A — engine TextPairWithMetadata extras + kei-crossdomain re-migrated 2026-04-23 13:59:18 +08:00
Parfii-bot
c212da8fe7 feat(w10c): migrate remaining 7 non-core agents to substrate_role
All 12 kit-shipped agents now declare substrate_role:
- 7 read-only: kei-cost-guardian, kei-ml-researcher, kei-researcher,
  kei-critic, kei-architect, kei-security-auditor, kei-validator
- 5 edit-local: kei-modal-runner, kei-fal-ai-runner, kei-infra-implementer,
  kei-ml-implementer, kei-code-implementer

Assembler regenerated 7 new .md files with # AGENT SUBSTRATE — role header.
docs/AGENT-ROLES.md: 12-row table + maintenance note.
substrate_integration.sh: migrated floor 5 → 12.
assembler tests (non_migrated) adjusted to strip substrate_role from
temp kit copy since all shipped manifests are now migrated.

cargo test agent-assembler: 47/47 (was 40, +7 regenerate tests).
cargo check --workspace: PASS.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 13:59:06 +08:00
Parfii-bot
ec205d5ee5 feat(w10a): engine TextPairWithMetadata extra_columns + kei-crossdomain re-migrated
EdgeKeyKind::TextPairWithMetadata extended with:
- from_col / to_col (custom column names, default src_path/dst_path)
- extra_columns: &[(name, FieldKind)] for domain-specific edge metadata

kei-crossdomain fully re-migrated via engine:
- edge_table: Some('cross_edges') + TextPairWithMetadata variant with
  from_col='from_uri', to_col='to_uri', has_id/has_weight/has_created_at,
  extra_columns=[evidence, metadata]
- Custom edges DDL dropped from custom_migrations (engine owns it now)
- edges.rs query_edges SELECT uses edge_id (engine-emitted PK)

Tests: 42/42 kei-entity-store (+2), 5/5 kei-crossdomain preserved.
Sister crates (task/chat/content/social/sage) no regression.

Closes HANDOFF-WAKE deferred item #2.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 13:59:06 +08:00
Parfii-bot
cd7dc94512 feat(w10b): kei-sage facet-query walker includes _roles/
Extended discover_primitives to optionally walk _roles/ root (with
backward-compat thin wrapper preserving 3 existing facet tests).

RoleDoc parser handles [role] name= shape (distinct from [capability]
+ flat manifests). Role IDs namespaced as role::<name>.

CLI: default_roles_root() = ~/.claude/_roles; FacetQuery.roles_root
flag optional.

Tests: 36/36 (was 34, +2 role-taxonomy + backward-compat).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 13:57:50 +08:00
Parfii-bot
78f241dbfc docs: update HANDOFF-WAKE for v0.25.0 landing
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 13:48:44 +08:00
Parfii-bot
4f08832b61 Merge W9E — kei-replay NEW crate 2026-04-23 13:37:02 +08:00
Parfii-bot
7dd5c0796d Merge W9D — kei-spawn drive stub 2026-04-23 13:37:02 +08:00
Parfii-bot
4fdb1ec1e3 Merge W9C — /spawn-agent skill 2026-04-23 13:37:02 +08:00
Parfii-bot
9fe780b7ac Merge W9B — kei-chat-store cost Real reinstated 2026-04-23 13:37:02 +08:00
Parfii-bot
b381db2dfc Merge W9A — bulk taxonomy tags 2026-04-23 13:37:02 +08:00
Parfii-bot
38ceab0913 feat(w9e): NEW kei-replay crate — reconstruct spawn from DNA
kei-replay <dna> parses DNA, looks up ledger row, loads task.toml
from worktree, re-runs compose_prompt, recomputes body hash, reports
match/drift.

kei-replay diff <dna-1> <dna-2> flags every changed facet between
two DNAs.

6 cubes (main/lib/replay/diff/ledger_lookup), all ≤114 LOC.

Direct SQLite access in ledger_lookup.rs (kei-ledger has no lib.rs).
v4 schema-compatible (reads id/dna/worktree_path/spec_sha).

Tests: 6/6 (≥4 required): happy path, missing DNA, drift detection,
diff differing bodies, diff identical, explicit --task override.

Workspace Cargo.toml: +kei-replay member.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 13:34:16 +08:00
Parfii-bot
6562b581f7 feat(w9d): kei-spawn drive subcommand + AnthropicDriver trait stub
kei-spawn drive <task.toml> internally calls spawn pipeline, emits
SpawnOutput JSON to stdout, returns exit 64 (NotImplemented) from
ManualDriver with stderr instruction to use manual Agent-tool path.

AnthropicDriver trait: ManualDriver (current) + HttpDriver (future
reqwest+tokio+KEI_ANTHROPIC_KEY). Extensibility preserved without
breaking-change deps.

Tests: 10/10 (was 6, +4: 2 drive unit + 2 drive_smoke binary integration).

Exit code contract: 0 success, 1 spawn-fail, 2 verify-fail, 64
NotImplemented (matches kei-runtime::invoke NotImplemented convention).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 13:34:16 +08:00
Parfii-bot
b57c022ea1 feat(w9b): kei-chat-store cost REAL reinstated via FieldKind::RealDefault
E1 unblocked: cost column added back to chat_messages via
FieldKind::RealDefault(0.0). save_message passes through f64; search
restores via r['cost'].as_f64().

Tests: 6/6 (was 5, +1 cost_roundtrips_via_search asserts 0.00777 f64).

Known deferred (flagged for future):
1. chat_sessions TEXT-PK requires engine multi-schema support (Store::open
   takes single schema) — bespoke DDL retained.
2. kei-crossdomain re-migration deferred — engine TextPairWithMetadata
   extra_columns field not yet shipped; edge DDL hard-codes src_path/
   dst_path vs from_uri/to_uri. Bespoke DDL retained. Follow-up: extend
   engine edge variant with extra_columns + column name customization.

kei-crossdomain tests unchanged 5/5.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 13:34:16 +08:00
Parfii-bot
e6ed7f8b8e feat(w9a): bulk-tag 25 primitives with taxonomy facets
8 capabilities (output/quality/safety/scope/tools) + 12 manifests +
5 roles. Consistent classification per W9-A rules.

Deprecated-alias stubs (tools::cargo-only-bash, tools::read-only)
skipped — no [gate]/[verify] sections.

facet-query results:
  kingdom=capability         → 11 hits (was 3)
  kingdom=capability gate    → 6 hits (was 2)
  kingdom=manifest           → 12 hits (was 0)

Roles tagged but not reachable by current facet_query (walker scans
_capabilities + _manifests). Forward-compat for walker extension.

cargo test -p kei-atom-discovery: 16/16 preserved.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 13:34:16 +08:00
Parfii-bot
eac6a7e58c feat(w9c): /spawn-agent Claude Code skill — click-only wizard for kei-spawn
5-phase skill wrapping kei-spawn CLI: role pick → task desc → scope
preset → confirm → emit composed Agent-tool invocation.

Pattern matches existing skills/site-create + skills/new-agent.
4 AskUserQuestion minimum, sole free-text is task description.

RULE 0.13 / 0.12 / 0.5 / ZERO enforced. Ready for /spawn-agent
invocation once kei-spawn binary built via install.sh.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 13:32:01 +08:00
Parfii-bot
e0e6e1720d docs: HANDOFF-WAKE summary of autonomous Wave 8
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 12:19:07 +08:00
Parfii-bot
26e74cfa15 Merge SP1 — kei-spawn automation envelope 2026-04-23 10:22:38 +08:00
Parfii-bot
948f07bfa8 Merge E2 — kei-capability fork subcommand 2026-04-23 10:22:38 +08:00
Parfii-bot
11b85c2a61 Merge TX3 — ledger creator/fork columns 2026-04-23 10:22:38 +08:00
Parfii-bot
3b549988ea Merge TX2 — kei-sage facet-query + lineage 2026-04-23 10:22:38 +08:00
Parfii-bot
355f01b929 Merge E1 — engine improvements (TextPk/Real/TextArchiveEnum/TextPairWithMetadata) 2026-04-23 10:22:38 +08:00
Parfii-bot
36b7941ad2 Merge TX1 — taxonomy schema extension 2026-04-23 10:22:38 +08:00
Parfii-bot
eac09a6354 feat(e1): engine improvements — TextPk + Real + TextArchiveEnum + TextPairWithMetadata
4 additive FieldKind/EdgeKeyKind variants addressing M1 dogfood +
M4/M5 flags. Backward-compat — existing schemas unchanged.

FieldKind::TextPk — TEXT PRIMARY KEY (kei-chat-store UUID sessions)
FieldKind::Real + RealDefault(f64) — REAL columns (kei-chat-store cost)
FieldKind::TextArchiveEnum — archive verb writes string sentinel instead of 1
EdgeKeyKind::TextPairWithMetadata — src_path/dst_path + id/weight/created_at/extra

Archive verb now dispatches: IntegerFlag writes 1, TextArchiveEnum writes sentinel.
Link/rank handle TextPairWithMetadata via generic weight+id propagation.
PK helpers in verbs/pk.rs abstract integer vs text primary key.

Engine decomposed to stay under 200 LOC:
- schema.rs (149) + field.rs (94, new) + ddl.rs (157, new)
- verbs/pk.rs + create_defaults.rs split from create.rs

Tests: 40/40 (was 32, +8 real_text_pk_smoke).
Sister crates verified backward-compat:
- kei-task 9/9, kei-chat-store 5/5, kei-content-store 4/4
- kei-social-store 5/5, kei-crossdomain 5/5, kei-sage 28/28

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 10:22:22 +08:00
Parfii-bot
02451f5f49 feat(sp1): NEW kei-spawn crate — automation envelope
spawn <task.toml> internally calls prepare + ledger fork, emits
JSON ready for Agent tool invocation. verify wraps post-return
check+ledger update. list-pending shows running forks.

kei-ledger invoked via subprocess (no lib.rs in kei-ledger).
KEI_SPAWN_LEDGER_NOOP=1 test escape hatch for CI without binary.

spec_sha = SHA-256 of task.toml bytes (workspace sha2 dep).

Tests: 6/6 integration (happy, explicit-id, unknown-role, non-spawnable,
verify-missing, end-to-end roundtrip).

Step 3 (Anthropic API) stays with orchestrator — next iteration adds
kei-spawn drive <task.toml> for HTTP automation.

Workspace Cargo.toml: +kei-spawn member.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 10:21:45 +08:00
Parfii-bot
6e7e517f83 feat(e2): kei-capability fork subcommand + lineage stamping
New 'fork' subcommand copies capability dir + rewrites capability.toml
with [lineage].fork_from + parents + creator + created. Refuses
clobber, validates slug regex.

Tests: 4 integration + 2 unit (epoch_to_iso, split_cap_name) = 6/6.

Doc update in AGENT-SUBSTRATE-SCHEMA.md §Orchestrator ergonomics.

Zero-chrono ISO-8601 via Hinnant's algorithm (single-file).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 10:21:45 +08:00
Parfii-bot
55606b176f feat(tx3): kei-ledger v4 migration — creator_id + fork_parent_id + descendants
Schema v4 adds creator_id TEXT + fork_parent_id TEXT columns with
indexes. Migration one-txn matches v2/v3 pattern.

fork() gains --creator + --fork-parent flags. New Descendants
subcommand walks fork_parent_id OR creator_id chain.

Extracted row.rs (AgentRow + SELECT_COLS) + descendants.rs +
dispatch.rs to stay ≤200 LOC.

Tests: 18/18 (was 13, +5: creator roundtrip, fork-parent lineage,
descendants chain, pre-v4 NULL backward-compat, v4 idempotent).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 10:21:45 +08:00
Parfii-bot
5a34c35311 feat(tx2): kei-sage facet query + lineage traversal
3 new subcommands:
- facet-query <key=value> [<k2=v2>...] — AND-filter walks primitives
- lineage <primitive-id> [--depth N] — BFS ancestors/descendants/forks
- author <creator-id> [--limit N] — all primitives by creator

facet_query.rs walks _capabilities/*/*/capability.toml + _manifests/*.toml
via toml parser. Handles missing sections correctly (None != specific).

lineage.rs BFS over parents[] wikilinks + fork-from + created-by edges.

Tests: 34/34 (was 28, +6: 3 facet_smoke + 3 lineage_smoke).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 10:21:45 +08:00