feat(optid): WP-N4 hardware allowlist DB + actuation gate - #136
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 withmax_statecaps for buggy deep states, and explicit denies for known-buggy PCIe L1.2 devices. All entriesverified = falsepending the §4 hardware experiments.crates/optid/build.rs— compiles the baseline into astatictable (libinput-quirks pattern, §1.7), keyed by canonical kernel MODALIAS (pci:…,usb:…,acpi:…). Hermetic: one file read, scopedrerun-if-changed.crates/optid/src/allowlist.rs—Allowlist::check(domain, hwid, state) -> Verdict. Default-deny on unknown HWID (hwid_not_in_allowlist), explicit-deny entries, andmax_statecaps (state_exceeds_max). Runtime overrides layeredcompiled-in < distro (/usr/share) < admin+optctl (/etc)with last-write-wins precedence (§1.9). HWID resolved from a device's sysfsmodalias.crates/optid/src/actuator.rs— wires the gate into the single write funnel behind the new--allowlistflag (default disabled per 0006 §7 medium-term). Denials are appended toaudit.jsonlwith their reason and the write is skipped. The orthogonal ADR-0009guarded_writepath-allowlist is untouched.crates/optctl/src/allow.rs—optctl 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/docmap.toml, synced 0006 Next-Steps;validate-doc-sync.pypasses.Design note
The gate landed in
actuator.rs(the single funnel every mutation already passes through) rather thandecision.rs::fits_contract.fits_contractremains 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).max_statecap; 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