Test-binary RPC actions for cross-process integration tests.
Single daemon-token-authed action: _testing_reset — full DB
wipe + keeper re-seed + optional secondary-account seeding. The
handler wipes every auth-namespace row (no keeper-preserve filter),
flips bootstrap_lock back to its post-bootstrap shape, seeds a
fresh keeper account inline (reusing create_test_account_with_credentials
so cross-process matches in-process write semantics), seeds any
caller-requested extra_accounts (also direct-inserted at this
setup step), refreshes the daemon-token cache to point at the new
keeper, and fires the consumer-supplied domain-state callback. The
new keeper + secondary credentials return as the action output so
the per-test fixture closes over them.
The redesign converges in-process and cross-process keeper
lifetimes: both modes now run against a freshly bootstrapped keeper
per test. Mutation-cascade tests (password change, revoke-all,
hardcoded-username signup uniqueness) and direct keeper-vs-admin
probes work uniformly cross-process.
Keeper ≠admin. The keeper and admin roles are independent.
Keeper authorizes daemon-token / bootstrap paths; admin authorizes
the user-facing admin RPC surface. _testing_reset seeds the keeper
account with [ROLE_KEEPER, ROLE_ADMIN] by default — matching the
production bootstrap_account flow — plus any roles passed via
extra_keeper_roles. Tests probing the keeper-vs-admin separation
(a keeper-only account must 403 on admin RPCs) declare a secondary
via extra_accounts: [{username, roles: [ROLE_KEEPER]}] so the
account is seeded at this same bootstrap-equivalent step.
No free-form runtime bypass. Earlier drafts considered a separate
_testing_seed_role_grant action for arbitrary direct grants; that
was rejected because a runtime bypass would let tests skip the
production consent flow's side-effects (audit emit, WS fan-out) and
silently mask bugs in those paths. The bypass that does exist —
extra_accounts — is framed as bootstrap-time seeding, the same
shape bootstrap_account itself uses to grant the initial
KEEPER + ADMIN pair. Tests that want a role on a *post-bootstrap*
account must route through role_grant_offer_create +
role_grant_offer_accept (the production path); they observe the
full event chain.
Production safety: this module lives under cross_backend/ and starts
with import '../assert_dev_env.js'; — production bundles either
tree-shake the module out or throw at startup. The Rust mirror
(fuz_testing crate) ships a parallel action; `cargo xtask
check-release blocks fuz_testing` from entering production dep
graphs.