Skip to content

feat(optid): WP-N4 hardware allowlist DB + actuation gate - #136

Merged
Nan0pk merged 1 commit into
mainfrom
claude/optimistic-euler-4v5dcg
Jun 19, 2026
Merged

feat(optid): WP-N4 hardware allowlist DB + actuation gate#136
Nan0pk merged 1 commit into
mainfrom
claude/optimistic-euler-4v5dcg

Conversation

@Nan0pk

@Nan0pk Nan0pk commented Jun 19, 2026

Copy link
Copy Markdown
Owner

WP-N4 — Hardware allowlist DB

Implements the HWID → {domain,state} allow/deny safety gate from SPEC-northstar §3 (actuation rule, clause 2) and §6 WP-N4, following the Hybrid E design in docs/research/0006-hw-allowlist-db-design.md. This is the critical-path unblock for WP-N5/N6/N7.

Verifier PASS criterion (SPEC §6): "Default-deny for risky knobs; seeded safe baseline; denial logged with reason." — all three met.

What landed

  • crates/optid/data/allowlist.toml — seeded safe baseline: NVMe APST allows with max_state caps for buggy deep states, and explicit denies for known-buggy PCIe L1.2 devices. All entries verified = false pending the §4 hardware experiments.
  • crates/optid/build.rs — compiles the baseline into a static table (libinput-quirks pattern, §1.7), keyed by canonical kernel MODALIAS (pci:…, usb:…, acpi:…). Hermetic: one file read, scoped rerun-if-changed.
  • crates/optid/src/allowlist.rsAllowlist::check(domain, hwid, state) -> Verdict. Default-deny on unknown HWID (hwid_not_in_allowlist), explicit-deny entries, and max_state caps (state_exceeds_max). Runtime overrides layered compiled-in < distro (/usr/share) < admin+optctl (/etc) with last-write-wins precedence (§1.9). HWID resolved from a device's sysfs modalias.
  • crates/optid/src/actuator.rs — wires the gate into the single write funnel behind the new --allowlist flag (default disabled per 0006 §7 medium-term). Denials are appended to audit.jsonl with their reason and the write is skipped. The orthogonal ADR-0009 guarded_write path-allowlist is untouched.
  • crates/optctl/src/allow.rsoptctl allow|deny|list-allow: writes admin override entries to /etc/optid/allowlist.d/90-admin.toml; resolves dev-paths/modaliases.
  • packaging/udev/rules.d/99-optid.rules — hot-plug notify draft (§1.5).
  • Docs: appended the 0006 entry to docs/docmap.toml, synced 0006 Next-Steps; validate-doc-sync.py passes.

Design note

The gate landed in actuator.rs (the single funnel every mutation already passes through) rather than decision.rs::fits_contract. fits_contract remains the independent contract gate (clause 1) and is consumed when N5/N6 land. Out of scope (unchanged): the N5/N6/N7 enablers and hardware measurement.

Evidence

  • cargo fmt --all --check, cargo clippy --workspace --all-targets — clean.
  • cargo test --workspace — green (optid 59, optctl 6, rushbench 13).
  • New tests prove: default-deny on unknown HWID; allow on seeded baseline; denial carries a reason; max_state cap; override precedence (admin > distro > seeded); last-file-wins; and the actuator gate's deny+audit / allow / disabled-no-op paths.

Per the Evidence Rule I do not self-certify — the rust-verifier verdict is the proof.

🤖 Generated with Claude Code


Generated by Claude Code

Implement the HWID → {domain,state} allow/deny safety gate from
SPEC-northstar §3 clause 2 / §6 WP-N4, per the Hybrid-E design in
docs/research/0006-hw-allowlist-db-design.md.

- data/allowlist.toml: seeded safe baseline (NVMe APST allows with
  max_state caps for buggy deep states; known-buggy PCIe L1.2 denies).
  All entries verified=false pending §4 hardware experiments.
- build.rs: compiles the baseline into a static table (libinput-quirks
  pattern, §1.7), keyed by canonical kernel MODALIAS.
- src/allowlist.rs: Allowlist::check(domain, hwid, state) -> Verdict with
  default-deny on unknown HWID, explicit-deny entries, and max_state caps.
  Runtime overrides layered from distro (/usr/share) < admin/optctl (/etc)
  with last-write-wins precedence (§1.9). HWID resolved from a device's
  sysfs modalias.
- actuator.rs: wires the gate into the single write funnel behind the
  --allowlist flag (default disabled per §7 medium-term). Denials are
  appended to audit.jsonl with their reason and skipped. The orthogonal
  ADR-0009 guarded_write path-allowlist is untouched.
- optctl allow/deny/list-allow (src/allow.rs): write admin override
  entries to /etc/optid/allowlist.d/90-admin.toml.
- packaging/udev/rules.d/99-optid.rules: hot-plug notify draft (§1.5).
- docmap + 0006 Next-Steps synced; validate-doc-sync passes.

Tests: default-deny on unknown HWID, allow on seeded baseline, denial
carries a reason, max_state cap, override precedence (admin>distro>seeded),
last-file-wins, and actuator gate deny+audit / allow / disabled-no-op.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RFPS9WQ1bQ2Q21LVFAksw8
@Nan0pk
Nan0pk marked this pull request as ready for review June 19, 2026 13:03
@Nan0pk
Nan0pk merged commit 46f27c5 into main Jun 19, 2026
12 checks passed
@Nan0pk
Nan0pk deleted the claude/optimistic-euler-4v5dcg branch June 19, 2026 13:03
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.

2 participants