Skip to content

ci: quality + security gate, pre-commit hooks, dev workflow#3

Merged
RodCor merged 2 commits into
mainfrom
chore/ci-hardening
May 30, 2026
Merged

ci: quality + security gate, pre-commit hooks, dev workflow#3
RodCor merged 2 commits into
mainfrom
chore/ci-hardening

Conversation

@RodCor

@RodCor RodCor commented May 30, 2026

Copy link
Copy Markdown
Owner

Adds the automated checks that keep main and develop clean and secure,
plus contributor tooling.

CI (.github/workflows/ci.yml) — every PR + push to main/develop

  • fmtcargo fmt --all --check (blocking)
  • clippycargo clippy --workspace (advisory*)
  • testcargo test --workspace on ubuntu + macOS (blocking)
  • auditcargo-audit RUSTSEC scan (blocking)
  • denycargo-deny licenses + bans (advisory*)

Local pre-commit (.githooks/pre-commit)

Opt in with ./scripts/install-hooks.sh. Runs fmt (blocking) + clippy
(advisory) on staged Rust changes — mirrors CI so red CI is caught early.

* clippy + cargo-deny start advisory because main has a small
pre-existing lint backlog; both run and surface findings on every PR.
Flip to hard gates once a cleanup PR clears the backlog (see CONTRIBUTING.md).

Also

  • deny.toml — license allow-list + source policy.
  • CONTRIBUTING.md — branch model, setup, checks table.
  • .gitignore — ignore /bench/ (internal repo, never public).
  • cargo fmt normalization of files left unformatted by an earlier merge.
  • redact.rs test: split the synthetic Slack-token literal so secret
    scanning doesn't flag the fixture (detector still exercised; test passes).

🤖 Generated with Claude Code

RodCor and others added 2 commits May 30, 2026 10:54
Adds the automated checks that keep main + develop clean and secure, plus
contributor tooling and docs.

CI (.github/workflows/ci.yml) — runs on every PR and push to main/develop:
  - fmt     cargo fmt --all --check            (blocking)
  - clippy  cargo clippy --workspace            (advisory*)
  - test    cargo test --workspace              (blocking; ubuntu + macOS)
  - audit   cargo-audit RUSTSEC scan            (blocking)
  - deny    cargo-deny licenses + bans          (advisory*)

Local pre-commit (.githooks/pre-commit; opt in via scripts/install-hooks.sh):
  fmt --check (blocking) + clippy (advisory) on staged Rust changes.

* clippy + cargo-deny start advisory (continue-on-error) because main
  carries a small pre-existing lint backlog; both run and surface findings
  on every PR. Flip to hard gates once a cleanup PR clears the backlog.
  See CONTRIBUTING.md.

Supporting changes:
  - deny.toml: license allow-list + source policy.
  - CONTRIBUTING.md: branch model (feature -> develop -> main -> tag),
    setup, and the checks table.
  - .gitignore: ignore /bench/ (internal kimetsu-bench repo, never public).
  - cargo fmt --all normalization of files left unformatted by an earlier
    merge, so the fmt gate is green from day one.
  - redact.rs test: split the synthetic Slack token literal so GitHub
    secret scanning doesn't flag the fixture (detector still exercised via
    concat! at runtime; test passes).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The brain test suite exercises the per-user GlobalUser brain at
$HOME/.kimetsu and takes a writer lock on ~/.kimetsu/project.lock. Run
multi-threaded (cargo's default), concurrent tests contend on that shared
lock and one panics ("project writer lock is already held") — a
pre-existing flake surfaced now that CI runs the suite.

Fix: the test job points HOME/TMP/TEMP/GIT_CEILING_DIRECTORIES at a
throwaway dir under RUNNER_TEMP and runs with --test-threads=1, giving
each test an isolated project root. Verified locally: full workspace goes
from 1 failed to all-green under this setup.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@RodCor
RodCor merged commit c283d34 into main May 30, 2026
7 of 11 checks passed
@RodCor
RodCor deleted the chore/ci-hardening branch May 30, 2026 14:22
RodCor added a commit that referenced this pull request Jun 2, 2026
…lish

- BOM tolerance (#1): strip a leading UTF-8 BOM before parsing existing
  settings.json/hooks.json/config.toml/.mcp.json, so a config saved by a
  BOM-emitting editor (older Windows Notepad) no longer fails install with
  'expected value at line 1 column 1'.
- Bounded transcript read (#7): the Stop hook now streams the transcript
  JSONL line-by-line (count_transcript_jsonl) instead of loading the whole
  file, so a long session's multi-MB transcript never lands in memory.
- Install polish (#3): document that --force overwrites an existing
  CLAUDE.md (incl. the global one); warn instead of silently ignoring
  --scope global for the workspace-only kimetsu target; canonicalize
  --workspace leniently so a global install doesn't fail on a missing path.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
RodCor pushed a commit that referenced this pull request Jun 29, 2026
…m sync

Slice A — fleet concurrent-write safety (multiple agents/hooks/Codex+Claude write
one local brain.db at once):
- IMMEDIATE write transactions (projector::with_write_txn) + bounded SQLITE_BUSY
  retry so concurrent writers serialize cleanly; migrate loop also IMMEDIATE +
  under-lock re-check.
- ANN sidecar atomic save (tmp+rename, manifest-last) — no torn .usearch across
  processes.
- Per-event origin `<machine>/<agent>` (schema v8 events.origin, nullable +
  backfill-safe), stamped from a process-global set in CLI run(); carried through
  insert/read/rebuild + SyncEvent.
- Proof: threaded test (6x25 cites -> no lost updates, deterministic rebuild) +
  #[ignore] multi-process test (4 procs x 8 cites -> use_count 32).

Slice B — convergent team sync (two teammates who exchange events reach identical
brain state):
- Hybrid Logical Clock (kimetsu-core/clock.rs): globally-sortable + causal HLC;
  Event.hlc (schema v9, backfilled from rowid); read_events_ordered now ORDER BY
  hlc -> deterministic total-order replay realizes per-field LWW.
- Rebuild-after-import in sync_dir + `brain sync import` so the merged log
  re-projects in HLC order (convergent).
- Concurrent supersede-to-different-survivor surfaced via a sync_conflicts
  projection + `brain sync --status`.
- Session-end auto-sync when [sync] dir configured ([sync] auto opt-out).
- Proof: two-brain convergence test (divergent supersedes/cites exchanged in
  opposite orders -> identical superseded_by/use_count/confidence + 1 conflict on
  both); HLC unit tests; v7->v9 migration test; E2E two-workspace `brain sync`.

Schema 7 -> 9 (forward-only, additive: events.origin/hlc nullable + backfilled).
Gate: fmt; clippy lean + --features embeddings (-D warnings); kimetsu-core 43,
kimetsu-brain 480, kimetsu-cli 251 tests pass (isolated).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
RodCor pushed a commit that referenced this pull request Jun 29, 2026
…ution)

Makes the shared LIVE brain on kimetsu-remote team-GA: a team writes to one
server-hosted brain and every event is attributed to the user who wrote it.
Write-safety already came from Slice A (per-request connection + IMMEDIATE txns);
the gap was per-user attribution on a multi-user server.

- Thread-local origin override (kimetsu-core/event.rs): OriginScope RAII guard;
  process_origin() prefers the thread-local. Each remote request runs on ONE
  spawn_blocking thread, so the per-request override is visible to Event::new and
  cleared on return (tokio reuses blocking threads).
- Token -> user identity (auth.rs): AuthConfig.token_names + user_for_token
  (configured name else a stable non-secret anon-<fingerprint>); tokens-file gains
  a [names] table (back-compat).
- Server attribution (lib/state/rpc): `serve --node <id>` sets the HLC node once
  at startup; dispatch_request wraps the blocking dispatch in
  OriginScope("<node>/user:<name>").
- CLI write-to-remote (kimetsu-cli/remote_client.rs + main.rs): `kimetsu brain
  memory add --remote <url> --repo <id> [--token | KIMETSU_REMOTE_TOKEN]` posts a
  JSON-RPC tools/call via reqwest.
- Metric: aggregate, unlabeled kimetsu_remote_memory_writes_total (the /metrics
  endpoint is intentionally unauthenticated -> no repo/user labels).

Proof: OriginScope / user_for_token / remote_client unit tests; a remote
integration test asserting the brain event origin == "remote/user:webuser"; E2E
(boot serve --node srv1, CLI memory add --remote -> event origin "srv1/user:alice",
hlc node srv1, memory_writes_total 1). Completes the #3 epic (A+B in 6061341).

Gate: fmt; clippy lean + --features embeddings + -p kimetsu-remote (-D warnings);
kimetsu-core 45, kimetsu-cli 243 + cli_smoke 10, kimetsu-remote 33 + integration
suites pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
RodCor pushed a commit that referenced this pull request Jul 3, 2026
…m sync

Slice A — fleet concurrent-write safety (multiple agents/hooks/Codex+Claude write
one local brain.db at once):
- IMMEDIATE write transactions (projector::with_write_txn) + bounded SQLITE_BUSY
  retry so concurrent writers serialize cleanly; migrate loop also IMMEDIATE +
  under-lock re-check.
- ANN sidecar atomic save (tmp+rename, manifest-last) — no torn .usearch across
  processes.
- Per-event origin `<machine>/<agent>` (schema v8 events.origin, nullable +
  backfill-safe), stamped from a process-global set in CLI run(); carried through
  insert/read/rebuild + SyncEvent.
- Proof: threaded test (6x25 cites -> no lost updates, deterministic rebuild) +
  #[ignore] multi-process test (4 procs x 8 cites -> use_count 32).

Slice B — convergent team sync (two teammates who exchange events reach identical
brain state):
- Hybrid Logical Clock (kimetsu-core/clock.rs): globally-sortable + causal HLC;
  Event.hlc (schema v9, backfilled from rowid); read_events_ordered now ORDER BY
  hlc -> deterministic total-order replay realizes per-field LWW.
- Rebuild-after-import in sync_dir + `brain sync import` so the merged log
  re-projects in HLC order (convergent).
- Concurrent supersede-to-different-survivor surfaced via a sync_conflicts
  projection + `brain sync --status`.
- Session-end auto-sync when [sync] dir configured ([sync] auto opt-out).
- Proof: two-brain convergence test (divergent supersedes/cites exchanged in
  opposite orders -> identical superseded_by/use_count/confidence + 1 conflict on
  both); HLC unit tests; v7->v9 migration test; E2E two-workspace `brain sync`.

Schema 7 -> 9 (forward-only, additive: events.origin/hlc nullable + backfilled).
Gate: fmt; clippy lean + --features embeddings (-D warnings); kimetsu-core 43,
kimetsu-brain 480, kimetsu-cli 251 tests pass (isolated).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
RodCor pushed a commit that referenced this pull request Jul 3, 2026
…ution)

Makes the shared LIVE brain on kimetsu-remote team-GA: a team writes to one
server-hosted brain and every event is attributed to the user who wrote it.
Write-safety already came from Slice A (per-request connection + IMMEDIATE txns);
the gap was per-user attribution on a multi-user server.

- Thread-local origin override (kimetsu-core/event.rs): OriginScope RAII guard;
  process_origin() prefers the thread-local. Each remote request runs on ONE
  spawn_blocking thread, so the per-request override is visible to Event::new and
  cleared on return (tokio reuses blocking threads).
- Token -> user identity (auth.rs): AuthConfig.token_names + user_for_token
  (configured name else a stable non-secret anon-<fingerprint>); tokens-file gains
  a [names] table (back-compat).
- Server attribution (lib/state/rpc): `serve --node <id>` sets the HLC node once
  at startup; dispatch_request wraps the blocking dispatch in
  OriginScope("<node>/user:<name>").
- CLI write-to-remote (kimetsu-cli/remote_client.rs + main.rs): `kimetsu brain
  memory add --remote <url> --repo <id> [--token | KIMETSU_REMOTE_TOKEN]` posts a
  JSON-RPC tools/call via reqwest.
- Metric: aggregate, unlabeled kimetsu_remote_memory_writes_total (the /metrics
  endpoint is intentionally unauthenticated -> no repo/user labels).

Proof: OriginScope / user_for_token / remote_client unit tests; a remote
integration test asserting the brain event origin == "remote/user:webuser"; E2E
(boot serve --node srv1, CLI memory add --remote -> event origin "srv1/user:alice",
hlc node srv1, memory_writes_total 1). Completes the #3 epic (A+B in 6061341).

Gate: fmt; clippy lean + --features embeddings + -p kimetsu-remote (-D warnings);
kimetsu-core 45, kimetsu-cli 243 + cli_smoke 10, kimetsu-remote 33 + integration
suites pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant