Repository navigation
Description
Context
Coordinated with FastLED/cli#229 and #155. Two source investigations confirmed FastLED has one production getrandom call in crates/fastled-cli/src/commands.rs: fill 32 bytes, encode lowercase hex, and fail startup if entropy generation fails. The token authorizes the local test-server endpoints. Token length, encoding and HTTP authorization policy belong to FastLED.
kernal-api already pins optional getrandom =0.4.3 behind crash, but exposes no secure-randomness capability. Its private crash/spool.rs random_suffix falls back to timestamp XOR process ID; that collision-avoidance helper is not suitable for authorization tokens and must not be reused for this API. The backend fill contract reports partial-read failures, so failure behavior must not expose partially generated output as success.
Proposal
Add a facade-owned secure entropy operation with an explicit per-call byte limit and owned error contract. Reuse the existing private OS-random backend without exposing its types or enabling crash/profiling facilities. Keep token serialization and security policy in the application. Document actual OS blocking/readiness behavior; do not claim cancellation or deadlines merely because a blocking call is wrapped in a future.
Acceptance criteria
- Focused RED test before implementation, then GREEN and broad checks in both repositories.
- Facade-owned types, bounded output/allocation, empty and oversized requests defined; no backend error types leak.
- Entropy failure returns an error, never timestamp/PID/pseudorandom fallback or partially initialized successful output. Errors and logs contain no generated bytes.
- Deterministic injected backend tests cover success, partial-write failure, limit rejection before backend invocation and error mapping; native supported-platform smoke tests verify the OS path without claiming statistical tests prove cryptographic quality.
- Resolve and document blocking, readiness, cancellation and timeout semantics honestly before adopting the contract.
- Feature isolation keeps crash, profiler and unrelated heavy dependencies disabled; no second random provider or runtime is introduced.
- FastLED preserves its 32-byte lowercase-hex token and startup-failure policy, removes direct getrandom imports/manifest dependency, and retains authorization policy regressions.
- Review, supported-platform validation, usable release and exact published adoption before closing.
Decisions
- Scope is secure entropy, not token generation: product wire format stays in FastLED.
- Reuse the already selected backend rather than the insecure-for-tokens crash suffix fallback.
- Prefer an opt-in capability so ordinary consumers do not enable unrelated crash facilities.
- No build-time improvement claim without comparable measurements.
Related issues
#155 tracks complete FastLED dependency migration. Existing WASM guest randomness proposals are a separate ABI boundary, not duplicates of this native application capability.
Activity
refactor: generate test capability entropy through kernal-api
refactor: generate test capability entropy through kernal-api
zackees commentedon Sep 16, 2026
Complete on both sides; closing with the evidence, same as #190 and #182.
kernal-api — landed in
4e59628(feat(random): add bounded secure operating-system entropy), insrc/random.rswithdocs/secure-random.mdandtests/secure_random.rs. Against this issue's criteria:MAX_RANDOM_BYTES = 64 * 1024, andSecureRandom::new(max_operations, timeout)bounds outstanding work to 1–64 operations with a positive caller timeout of at most one day.success_and_partial_failure_never_confuse_outputis the injected-backend test covering exactly the partial-write case, alongsidetimed_out_native_work_keeps_capacity_until_completionanddropped_request_keeps_capacity_until_completion.crash/spool.rs's timestamp-XOR-PID helper, which this issue explicitly ruled out for authorization tokens.FastLED — adoption landed with FastLED/cli#242 (merged).
crates/fastled-cli/src/commands.rsreads:and the migration went further than this issue required — direct
getrandomis not merely removed but banned, enforced bytests/unit/test_kernal_boundary.py:The remaining
getrandominCargo.lockis the transitive one behind kernal-api's own private backend, which is the intended shape. The 32-byte lowercase-hex token and startup-failure policy stayed in FastLED, as this issue required.🤖 Generated with Claude Code