Skip to content

perf: parallel inbox reads and deliveries, kept final reads, background listening - #1111

Merged
cryptskii merged 2 commits into
mainfrom
cryptskii/eager-darwin-1668e4
Oct 4, 2026
Merged

cryptskii merged 2 commits into
mainfrom
cryptskii/eager-darwin-1668e4

Conversation

@cryptskii

Copy link
Copy Markdown
Collaborator

Summary

This batch speeds up syncing, sending and verification (DLV multi-hop walks included), keeps the app listening in the background, and makes database commits faster.

Inbox sync and delivery

  • A sync reads every route at once, and each route's members' pages at once. What comes back is processed in the same order as before.
  • A delivery asks the first K members at once and replaces each one that fails with the next. It takes one round of answers instead of one per member, and still lands on exactly K members (b0x delivery fan-out carries its own quorum literal (quorum_k: 3) instead of deriving from the authoritative register quorum #867; a_send_lands_on_exactly_the_register_quorum_of_members holds).
  • Member clients offer HTTP/2 over ALPN. The node's listener (axum-server) already offers h2, so concurrent requests to a member share one connection. No node change is needed.

Verification (lineage walk, SoFi/DLV reader, reply checks)

  • New sdk::final_reads keeps two kinds of reads for the life of the process:
    • Immutable objects: kept only once their bytes re-hash to the address.
    • Cells Core read as final: a final value holds its cell for good (storage spec §9, finality 2). Core evaluates the kept reads again on every use. Nothing open, undecided or unserved is kept, and each store is bounded by bytes.
  • The lineage walk's root cells, the SoFi/DLV attempt cells (through keep_completion), and immutable fetches all go through it. A later walk or verification therefore starts from what an earlier one read.
  • A step's manifest prefetches its authority evidence, transition witness and successor evidence together, instead of three round trips in turn.

Background and storage

  • Backgrounding keeps the poller and its waits running when the device has contacts (Backgrounded::Listening), so a transfer lands without the recipient opening the app.
  • The foreground service starts as connectedDevice only. The declared NFC permission satisfies its prerequisite, and it has no Android 15 daily cap (dataSync does). The service stops itself in onTimeout.
  • The client DB uses WAL with synchronous = FULL, so every commit is still durable at return. get_db_size counts the log.

Related Issues

None.

Testing

  • cargo clippy --release -p dsm_sdk --all-targets --all-features -- -D warnings is clean.
  • CI purity gates and production safety checks pass, as does scripts/real_code_guard.py.
  • Targeted tests pass in release:
    • the b0x, inbox poller, contacts, client DB and final_reads suites;
    • the bilateral_finality_tests and frontier_verification_tests modules in one process;
    • the DLV held-key e2e test.
  • Code map rebuilt at f4ff913. The evidence for every moved pin ran in release and passed. 144 code-only pins were repinned; make requirement-map-intent reports 0 failing.
  • Full dsm_sdk release suite: running locally, and CI runs it too.

New tests:

  • A device with contacts keeps listening in the background.
  • The byte budget drops the earliest entry first.
  • Only bytes that re-hash to their address are kept as the object.
  • In the DLV held-key test, a later verifier in the same process does not ask the nodes again for a key it already read as final, still re-reads the open key, and reaches the same result.

Notes

  • Test isolation. Tests reuse identities over fresh fleets and run several devices in one process. Kept reads are therefore forgotten when a test fleet starts and when the harness enters or creates a device, as in a real per-device process. This is test-only (#[cfg(test)]).
  • Held-key test precondition. a_key_held_by_an_exercise_its_own_bytes_refute_is_skipped_on_those_bytes_alone now forgets the process-wide kept reads before its "verifier that has read nothing yet" walk. Without that, the precondition no longer holds once reads are kept across verifiers.
  • Anchor lockfiles. The excluded anchor crates' lockfiles (which need the tropic01 sibling) pick up the h2 edge on their next local build.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Y4wDTToHmJfkYYJvMKXt3u


Generated by Claude Code

claude added 2 commits October 4, 2026 04:21
…nd listening

Inbox sync and delivery:
- A sync reads every route at once, and each route's members' pages at
  once; what came back is processed in the order it always was.
- A delivery asks the first K members at once and replaces each that
  fails with the next, so it takes one round of answers and still lands
  on exactly K members (#867).
- Member clients offer HTTP/2 over ALPN; the node's listener already
  offers it, so concurrent requests to a member share one connection.

Verification:
- Immutable objects and cells Core read as final are kept for the
  process's life (sdk::final_reads): an object is its bytes, and a final
  value holds its cell for good (storage spec §9, finality 2). Core
  evaluates the kept reads again on every use; nothing open, undecided
  or unserved is kept. The lineage walk, the SoFi/DLV reader and every
  later verification start from what an earlier one read.
- A step's manifest prefetches the authority evidence, transition
  witness and successor evidence together, instead of three round trips
  in turn.

Background and storage:
- Backgrounding keeps the poller and its waits running when this device
  has contacts (Backgrounded::Listening), so a transfer lands without
  the recipient opening the app.
- The foreground service starts as connectedDevice only: the NFC
  permission satisfies it, and it has no Android 15 daily cap. It stops
  itself on onTimeout.
- The client database uses WAL with synchronous = FULL; its size counts
  the log.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y4wDTToHmJfkYYJvMKXt3u
Code only; every pin's evidence ran at f4ff913 in release.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y4wDTToHmJfkYYJvMKXt3u
@cryptskii
cryptskii merged commit 2251f98 into main Oct 4, 2026
27 checks passed
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.

2 participants