Skip to content

#65: the kernel seal reaches the kernel and nothing else; acquire_for_kernel is test-only - #941

Open
MattJackson wants to merge 1 commit into
predevfrom
lane-cabi-kernel-seal
Open

MattJackson wants to merge 1 commit into
predevfrom
lane-cabi-kernel-seal

Conversation

@MattJackson

Copy link
Copy Markdown
Collaborator

CONTRACT-ABI lane, item 3 (#65, SPEC l.2260; TODO caps/token.rs:106-109). ARCHITECT ruling 2026-10-14 approved this mechanism.

Before: KernelSeal::acquire_for_kernel() was a #[doc(hidden)] pub fn — any crate naming busbar-contract (every linked plugin) could mint every Pass/Grant; only a CI text scan stood in the way.

After:

  • contract KernelSeal::deliver() (#[inline], so only a caller's image references the symbol) hands a fresh seal to extern "Rust" __busbar_kernel_root, declared by the contract, defined only by busbar-kernel.
  • kernel src/seal.rs: the #[no_mangle] definition wraps the seal in a module-private Held and returns Box<dyn Any> (ZST, no alloc); seal::acquire() (#[inline(never)], same object as the definition, so the definition is always linked) downcasts it back. Non-kernel callers get a box they cannot open; a second definer is a duplicate-symbol link error.
  • acquire_for_kernel exists only under cfg(test) / dev-only test-seal; kernel production sites (teller.rs Kernel::new, host_services.rs idempotency key) and test_support::tokens::seal use seal::acquire(). Kernel gains a dev edge busbar-contract features=["test-seal"] so its tests mint as before (test_seal_is_dev_only keeps the feature off non-dev edges).
  • two #[allow(unsafe_code)] items (contract deliver, kernel definition), each with a SAFETY note.
  • gates: one-memory-abi excuses __busbar_kernel_root at exactly crates/busbar-kernel/src/seal.rs (planted anywhere else = RED, new selftest); structure-lint's no_mangle ban lists seal.rs.

RED: busbar-kernel/src/tests/members/seal_tests.rs — (1) builds the mechanism with rustc: the honest program links and opens its seal, a program defining the root symbol to catch the seal fails to link as a duplicate symbol; (2) deliver() hands a non-kernel caller no seal. Contract doc: compile_fail fixture on acquire_for_kernel without test-seal (rendered only when the feature is off).

Shared files (disjoint hunks, ruling 20): kernel Cargo.toml (#901 #897 #893 #571 #503), host_services.rs (#864), structure_lint/choke_points.rs (#904).

No customer-visible behaviour; no third-party dependency change.

…_kernel is test-only

KernelSeal::acquire_for_kernel() was a #[doc(hidden)] pub fn any crate naming busbar-contract
could call (caps/token.rs:106-109; SPEC #65 l.2260: "no public/forgeable KernelSeal constructor").
ARCHITECT ruling 2026-10-14 (mechanism approved):

- contract: KernelSeal::deliver() (#[inline]) builds a seal and hands it to the extern "Rust"
  symbol __busbar_kernel_root, which the contract declares and only busbar-kernel defines.
- kernel (new src/seal.rs): the #[no_mangle] definition wraps the seal in Held, a type private to
  the module, and returns it as Box<dyn Any> (zero-sized, no allocation); seal::acquire()
  (#[inline(never)], beside the definition so the definition is always linked) downcasts it back.
  A caller outside the kernel gets a box it cannot open; a second definer is a duplicate symbol.
- acquire_for_kernel survives only under cfg(test) / the dev-only test-seal feature; the kernel's
  production sites (teller.rs Kernel::new, host_services.rs idempotency key) and test_support take
  seal::acquire(); the kernel's own tests reach the test seal through a dev edge.
- gates: one-memory-abi excuses __busbar_kernel_root at exactly crates/busbar-kernel/src/seal.rs
  (planted elsewhere = RED, selftest added); structure-lint's no_mangle ban lists seal.rs.

RED: tests/members/seal_tests.rs builds the mechanism with rustc and proves the honest program
links and opens its seal while a program defining the root symbol fails to link as a duplicate
symbol; the release-path test proves deliver() hands a non-kernel caller no seal. The contract
doc carries a compile_fail fixture for acquire_for_kernel outside test-seal.

This branch has not been deployed

No deployments
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