Context
PR #36 added the rootkey handshake ({type:"init",rootKey:"<base64>"}) and structured error-frame broadcast on the control socket. The native side (Android FGS + iOS NodeJSService) and the JS bridge both got direct test coverage, but the backend validation logic in backend/index.js did not.
Specifically untested today:
init handler: rejects non-string rootKey, rejects wrong-length-after-decode, ignores second init after consumption.
handleFatal / uncaughtException path: tagged-phase routing, broadcast-then-exit, the 100ms flush wait.
SimpleRpcServer.broadcastError: per-client try/catch, frame shape.
Why deferred
The backend/ directory has no test runner today (no mocha/tap/jest, no *.test.js invocation in package.json). Adding meaningful coverage means:
- Pick + add a test runner (likely
node --test for zero-deps).
- Refactor the inline
init handler in backend/index.js into something importable (or build a small test harness that drives the full process via child_process.spawn + a fake control-socket client).
PR #36 review explicitly deferred this as out of scope for the rootkey landing.
Acceptance
Context
PR #36 added the rootkey handshake (
{type:"init",rootKey:"<base64>"}) and structured error-frame broadcast on the control socket. The native side (Android FGS + iOS NodeJSService) and the JS bridge both got direct test coverage, but the backend validation logic inbackend/index.jsdid not.Specifically untested today:
inithandler: rejects non-stringrootKey, rejects wrong-length-after-decode, ignores second init after consumption.handleFatal/uncaughtExceptionpath: tagged-phase routing, broadcast-then-exit, the 100ms flush wait.SimpleRpcServer.broadcastError: per-client try/catch, frame shape.Why deferred
The
backend/directory has no test runner today (no mocha/tap/jest, no*.test.jsinvocation inpackage.json). Adding meaningful coverage means:node --testfor zero-deps).inithandler inbackend/index.jsinto something importable (or build a small test harness that drives the full process viachild_process.spawn+ a fake control-socket client).PR #36 review explicitly deferred this as out of scope for the rootkey landing.
Acceptance
node --test, or align with whatever the rest of the repo standardises on).inithandler: malformed payload → process exits non-zero with broadcast{type:"error",phase:"init",…}.privateStorageDir): broadcast{type:"error",phase:"construct",…}before exit.phase:"runtime".