---
name: omaralex24-klav-engineering-rules
description: "Evidence-backed engineering rules for OmarAlex24/klav, generated by Everdoc from static analysis and git history: boundaries, contracts, co-change, hotspots, docs hygiene. Use when editing, reviewing, or planning changes in this repository."
---

# OmarAlex24/klav engineering rules

Generated by Everdoc from OmarAlex24/klav @ [`034e81b52d1b`](https://github.com/OmarAlex24/klav/tree/034e81b52d1b693c65ff95181cd555c6734bc8e8) (v0.15.1) by static analysis and the last 127 commits; no LLM. Every rule cites the counts it rests on. Regenerate instead of editing by hand.

Follow these rules when changing this repository. Each states the constraint, then the observed ratio it rests on, then evidence.

## Boundaries

- **Point dependencies down the layer stack.** Apps and CLIs may depend on adapters, libraries, and contracts, never the reverse: 13 of 16 layered workspace edges (81.3%) comply; fix the 3 upward edges listed below. _(error, confidence 81.3%, 16 observations)_
  - klav-ffi (adapter) → klav-daemon (app)
  - klav-sdk (library) → klav-daemon (app)
  - klav-sdk (library) → klav-forward (cli)

## Contracts

- **Pair every new RPC with a handler.** 100% of RPCs (372/372) are paired with handlers — do not leave new RPCs unhandled. _(info, confidence 100%, 372 observations)_
- **Remove or wire RPCs nothing calls.** 93.3% of handled RPCs (347/372) have a caller in the repository; 25 RPCs have a handler but no caller — confirm an external client uses them or delete them. _(info, confidence 93.3%, 372 observations)_
  - DaemonEngine.grantChangeApply has 1 handler and no caller ([`crates/klav-ffi/src/daemon.rs:1732`](https://github.com/OmarAlex24/klav/blob/034e81b52d1b693c65ff95181cd555c6734bc8e8/crates/klav-ffi/src/daemon.rs#L1732))
  - DaemonEngine.proxyTunnels has 1 handler and no caller ([`crates/klav-ffi/src/daemon.rs:1926`](https://github.com/OmarAlex24/klav/blob/034e81b52d1b693c65ff95181cd555c6734bc8e8/crates/klav-ffi/src/daemon.rs#L1926))
  - DaemonEngine.sandboxList has 1 handler and no caller ([`crates/klav-ffi/src/daemon.rs:2030`](https://github.com/OmarAlex24/klav/blob/034e81b52d1b693c65ff95181cd555c6734bc8e8/crates/klav-ffi/src/daemon.rs#L2030))
  - …and 7 more
- **Pair every new HTTP route with a handler.** 100% of HTTP routes (129/129) are paired with handlers — do not leave new HTTP routes unhandled. _(info, confidence 100%, 129 observations)_

## Co-change

- **Change `apps/ios/Mac/MacModel.swift` together with `apps/ios/Mac/SampleEngine.swift`.** When modifying `apps/ios/Mac/MacModel.swift`, also inspect/update `apps/ios/Mac/SampleEngine.swift` — co-changed in 16/21 commits (76.2%). _(warning, confidence 76.2%, 16 observations)_
  - feat(mac): polish Sentinel tabs, item allow flow, repo linking, and agent setup prompt (#125) ([#125](https://github.com/OmarAlex24/klav/pull/125), 2026-12-04)
  - feat(mac): add Import, Trash restore/purge, Vault/Project creation, and Attachments (#123) ([#123](https://github.com/OmarAlex24/klav/pull/123), 2026-12-03)
  - feat(apple): add database items and environment links to the Mac and iPhone apps (#113) ([#113](https://github.com/OmarAlex24/klav/pull/113), 2026-12-03)
  - …and 2 more
- **Change `crates/klav-client/src/agents.rs` together with `crates/klav-client/src/audit.rs`.** When modifying `crates/klav-client/src/agents.rs`, also inspect/update `crates/klav-client/src/audit.rs` — co-changed in 9/12 commits (75%). _(warning, confidence 75%, 9 observations)_
  - fix(daemon): keep local reads responsive during network reads (#105) ([#105](https://github.com/OmarAlex24/klav/pull/105), 2026-12-02)
  - feat(client,daemon,ffi,apps): the SQL approval card from the sealed blob and Postgres Activity rows (ADR 0052 layer 16) (#66) ([#66](https://github.com/OmarAlex24/klav/pull/66), 2026-11-29)
  - feat(server): pg_guard switch and the generic sealed-blob route (ADR 0052 layer 14) (#63) ([#63](https://github.com/OmarAlex24/klav/pull/63), 2026-11-29)
  - …and 2 more
- **Change `crates/klav-sdk/src/proxy.rs` together with `crates/klav-proxy/src/profiles.rs`.** When modifying `crates/klav-sdk/src/proxy.rs`, also inspect/update `crates/klav-proxy/src/profiles.rs` — co-changed in 7/7 commits (100%). _(warning, confidence 100%, 7 observations)_
  - feat(proxy,sdk): northflank-addon Postgres transport and live pg_guard approval path (ADR 0052 layer 13) (#65) ([#65](https://github.com/OmarAlex24/klav/pull/65), 2026-11-29)
  - feat(proxy): Postgres wire for direct profiles, SCRAM, read-only session, guard and approvals (ADR 0052 layer 12) (#64) ([#64](https://github.com/OmarAlex24/klav/pull/64), 2026-11-29)
  - feat(core,proto): pg-scram SCRAM-SHA-256, pg profile, SQL classes and sealed statement (ADR 0052 layers 9-10) (#61) ([#61](https://github.com/OmarAlex24/klav/pull/61), 2026-11-29)
  - …and 2 more
- **Change `klav-ffi` together with `klav-cli`.** When modifying `klav-ffi`, also inspect/update `klav-cli` — co-changed in 22/25 commits (88%). _(warning, confidence 88%, 22 observations)_
  - feat(client,daemon,ffi,cli): add restore/purge and expose Mac parity operations on DaemonEngine (#122) ([#122](https://github.com/OmarAlex24/klav/pull/122), 2026-12-03)
  - feat(cli): implement database items in agent and proxy flows (#111) ([#111](https://github.com/OmarAlex24/klav/pull/111), 2026-12-03)
  - feat(client): fulfill database secret requests with environment links (#110) ([#110](https://github.com/OmarAlex24/klav/pull/110), 2026-12-03)
  - …and 2 more
- **Change `crates/klav-daemon/src/server.rs` together with `crates/klav-client/src/proxy_admin.rs`.** When modifying `crates/klav-daemon/src/server.rs`, also inspect/update `crates/klav-client/src/proxy_admin.rs` — co-changed in 13/18 commits (72.2%). _(info, confidence 72.2%, 13 observations)_
  - feat(client): fulfill database secret requests with environment links (#110) ([#110](https://github.com/OmarAlex24/klav/pull/110), 2026-12-03)
  - fix(daemon): keep local reads responsive during network reads (#105) ([#105](https://github.com/OmarAlex24/klav/pull/105), 2026-12-02)
  - feat(client,daemon,ffi,cli): sandbox secret requests on the person's side (ADR 0053 layer 4) (#75) ([#75](https://github.com/OmarAlex24/klav/pull/75), 2026-11-29)
  - …and 2 more
- **Change `crates/klav-ffi/src/daemon.rs` together with `crates/klav-ffi/src/lib.rs`.** When modifying `crates/klav-ffi/src/daemon.rs`, also inspect/update `crates/klav-ffi/src/lib.rs` — co-changed in 9/10 commits (90%). _(info, confidence 90%, 9 observations)_
  - feat(client): fulfill database secret requests with environment links (#110) ([#110](https://github.com/OmarAlex24/klav/pull/110), 2026-12-03)
  - feat(client,daemon,ffi,cli): sandbox secret requests on the person's side (ADR 0053 layer 4) (#75) ([#75](https://github.com/OmarAlex24/klav/pull/75), 2026-11-29)
  - feat(client,cli,apps): WebSocket tunnels in grants, cards and the switch (ADR 0052 layer 7) (#60) ([#60](https://github.com/OmarAlex24/klav/pull/60), 2026-11-29)
  - …and 2 more
- **Change `crates/klav-daemon/src/presence.rs` together with `crates/klav-daemon/src/protocol.rs`.** When modifying `crates/klav-daemon/src/presence.rs`, also inspect/update `crates/klav-daemon/src/protocol.rs` — co-changed in 9/11 commits (81.8%). _(info, confidence 81.8%, 9 observations)_
  - feat(client,daemon,ffi,cli): add restore/purge and expose Mac parity operations on DaemonEngine (#122) ([#122](https://github.com/OmarAlex24/klav/pull/122), 2026-12-03)
  - feat(client,daemon,ffi,cli): sandbox secret requests on the person's side (ADR 0053 layer 4) (#75) ([#75](https://github.com/OmarAlex24/klav/pull/75), 2026-11-29)
  - feat(forward,client,cli): Postgres listener, --preset postgres and SQL approvals (ADR 0052 layer 15) (#67) ([#67](https://github.com/OmarAlex24/klav/pull/67), 2026-11-29)
  - …and 2 more
- **Change `crates/klav-server/src/routes/agents.rs` together with `crates/klav-proto/src/agent.rs`.** When modifying `crates/klav-server/src/routes/agents.rs`, also inspect/update `crates/klav-proto/src/agent.rs` — co-changed in 8/8 commits (100%). _(info, confidence 100%, 8 observations)_
  - feat(server): sandbox secret requests switch, proxy path, caps and expiry (ADR 0053 layer 3) (#73) ([#73](https://github.com/OmarAlex24/klav/pull/73), 2026-11-29)
  - feat(core,proto): sandbox secret request fields, attach_sandbox and grant v6 (ADR 0053 layer 2) (#71) ([#71](https://github.com/OmarAlex24/klav/pull/71), 2026-11-29)
  - feat(server): pg_guard switch and the generic sealed-blob route (ADR 0052 layer 14) (#63) ([#63](https://github.com/OmarAlex24/klav/pull/63), 2026-11-29)
  - …and 2 more
- **Change `crates/klav-cli/src/commands/proxy.rs` together with `crates/klav-cli/src/cli.rs`.** When modifying `crates/klav-cli/src/commands/proxy.rs`, also inspect/update `crates/klav-cli/src/cli.rs` — co-changed in 7/9 commits (77.8%). _(info, confidence 77.8%, 7 observations)_
  - fix(proxy): verify-full TLS inside Northflank addon tunnels (#88) ([#88](https://github.com/OmarAlex24/klav/pull/88), 2026-11-30)
  - feat(client,daemon,ffi,cli): sandbox secret requests on the person's side (ADR 0053 layer 4) (#75) ([#75](https://github.com/OmarAlex24/klav/pull/75), 2026-11-29)
  - feat(forward,client,cli): Postgres listener, --preset postgres and SQL approvals (ADR 0052 layer 15) (#67) ([#67](https://github.com/OmarAlex24/klav/pull/67), 2026-11-29)
  - …and 2 more
- **Change `klav-ffi` together with `klav-client`.** When modifying `klav-ffi`, also inspect/update `klav-client` — co-changed in 24/25 commits (96%). _(info, confidence 96%, 24 observations)_
  - feat(client,daemon,ffi,cli): add restore/purge and expose Mac parity operations on DaemonEngine (#122) ([#122](https://github.com/OmarAlex24/klav/pull/122), 2026-12-03)
  - feat(cli): implement database items in agent and proxy flows (#111) ([#111](https://github.com/OmarAlex24/klav/pull/111), 2026-12-03)
  - feat(client): fulfill database secret requests with environment links (#110) ([#110](https://github.com/OmarAlex24/klav/pull/110), 2026-12-03)
  - …and 2 more
- **Change `klav-cli` together with `klav-client`.** When modifying `klav-cli`, also inspect/update `klav-client` — co-changed in 24/31 commits (77.4%). _(info, confidence 77.4%, 24 observations)_
  - feat(client,daemon,ffi,cli): add restore/purge and expose Mac parity operations on DaemonEngine (#122) ([#122](https://github.com/OmarAlex24/klav/pull/122), 2026-12-03)
  - feat(cli): implement database items in agent and proxy flows (#111) ([#111](https://github.com/OmarAlex24/klav/pull/111), 2026-12-03)
  - feat(client): fulfill database secret requests with environment links (#110) ([#110](https://github.com/OmarAlex24/klav/pull/110), 2026-12-03)
  - …and 2 more

## Hotspots

- **Test `apps/ios/Mac/SampleEngine.swift` before editing.** `apps/ios/Mac/SampleEngine.swift` absorbed 4 bug fixes recently — verify edge cases and run targeted tests before editing. _(warning, confidence 15.4%, 26 observations)_
  - fix(mac): kickstart uninitialized klavd LaunchAgent and add Start now button (#126) ([#126](https://github.com/OmarAlex24/klav/pull/126), 2026-12-04)
  - fix(mac): make agent rows look clickable and let any agent become a sandbox issuer (#103) ([#103](https://github.com/OmarAlex24/klav/pull/103), 2026-12-01)
  - fix(mac): search the menu bar in memory and open a result on click (#47) ([#47](https://github.com/OmarAlex24/klav/pull/47), 2026-11-27)
  - …and 1 more
- **Test `apps/ios/Mac/MenuBar.swift` before editing.** `apps/ios/Mac/MenuBar.swift` absorbed 4 bug fixes recently — verify edge cases and run targeted tests before editing. _(warning, confidence 30.8%, 13 observations)_
  - fix(mac): kickstart uninitialized klavd LaunchAgent and add Start now button (#126) ([#126](https://github.com/OmarAlex24/klav/pull/126), 2026-12-04)
  - fix(mac): show one-time codes on demand, page Activity, notify secret requests (#118) ([#118](https://github.com/OmarAlex24/klav/pull/118), 2026-12-03)
  - fix(mac): focus master password field when opening locked menu bar panel (#96) ([#96](https://github.com/OmarAlex24/klav/pull/96), 2026-12-01)
  - …and 1 more
- **Test `apps/ios/Mac/MacModel.swift` before editing.** `apps/ios/Mac/MacModel.swift` absorbed 3 bug fixes recently — verify edge cases and run targeted tests before editing. _(warning, confidence 12%, 25 observations)_
  - fix(mac): show one-time codes on demand, page Activity, notify secret requests (#118) ([#118](https://github.com/OmarAlex24/klav/pull/118), 2026-12-03)
  - fix(mac): draw the map once, fit it to the window and keep zoom off the nodes (#98) ([#98](https://github.com/OmarAlex24/klav/pull/98), 2026-12-01)
  - fix(mac): search the menu bar in memory and open a result on click (#47) ([#47](https://github.com/OmarAlex24/klav/pull/47), 2026-11-27)
- **Test `crates/klav-client/src/proxy_admin.rs` before editing.** `crates/klav-client/src/proxy_admin.rs` absorbed 3 bug fixes recently — verify edge cases and run targeted tests before editing. _(warning, confidence 12.5%, 24 observations)_
  - fix(daemon): keep local reads responsive during network reads (#105) ([#105](https://github.com/OmarAlex24/klav/pull/105), 2026-12-02)
  - fix(proxy): verify-full TLS inside Northflank addon tunnels (#88) ([#88](https://github.com/OmarAlex24/klav/pull/88), 2026-11-30)
  - fix(client,klavd,mac): start new accounts with the MCP gateway on, warn only when something older may be on the account (#46) ([#46](https://github.com/OmarAlex24/klav/pull/46), 2026-11-27)
- **Test `crates/klav-daemon/src/server.rs` before editing.** `crates/klav-daemon/src/server.rs` absorbed 3 bug fixes recently — verify edge cases and run targeted tests before editing. _(warning, confidence 13.6%, 22 observations)_
  - fix(daemon): keep local reads responsive during network reads (#105) ([#105](https://github.com/OmarAlex24/klav/pull/105), 2026-12-02)
  - fix(daemon): make proxy Touch ID reasons short enough for the macOS sheet (#91) ([#91](https://github.com/OmarAlex24/klav/pull/91), 2026-11-30)
  - fix(client,klavd,mac): start new accounts with the MCP gateway on, warn only when something older may be on the account (#46) ([#46](https://github.com/OmarAlex24/klav/pull/46), 2026-11-27)

## Docs hygiene

- **Fix broken documentation links.** Fix 1 broken link in 1 guide and check links when moving files: 99.9% of 1,918 doc links resolve. _(warning, confidence 99.9%, 1,918 observations)_
  - docs/probar-mac.md: `extension.md#cargar-sin-empaquetar` does not resolve ([`docs/probar-mac.md:82`](https://github.com/OmarAlex24/klav/blob/034e81b52d1b693c65ff95181cd555c6734bc8e8/docs/probar-mac.md#L82))
- **Update guides that mention changed code.** When changing an entity a guide mentions, update the guide in the same change: 76 guides mention code modified after the guide's last edit (12/89 are fresh). _(info, confidence 13.5%, 89 observations)_
  - CLAUDE.md: `health` is defined in crates/klav-cli/src/cli.rs, changed 2026-12-03 after this page (2026-11-29) ([`CLAUDE.md:20`](https://github.com/OmarAlex24/klav/blob/034e81b52d1b693c65ff95181cd555c6734bc8e8/CLAUDE.md#L20))
  - CLAUDE.md: `klavd` is defined in crates/klav-daemon/src/main.rs, changed 2026-11-29 after this page (2026-11-29) ([`CLAUDE.md:22`](https://github.com/OmarAlex24/klav/blob/034e81b52d1b693c65ff95181cd555c6734bc8e8/CLAUDE.md#L22))
  - CLAUDE.md: `inject` is defined in crates/klav-cli/src/cli.rs, changed 2026-12-03 after this page (2026-11-29) ([`CLAUDE.md:24`](https://github.com/OmarAlex24/klav/blob/034e81b52d1b693c65ff95181cd555c6734bc8e8/CLAUDE.md#L24))
  - …and 7 more
