Skip to content

Detect configs expired from the swarm and re-store them - #2151

Open
mpretty-cyro wants to merge 1 commit into
session-foundation:devfrom
mpretty-cyro:feature/config-recovery
Open

Detect configs expired from the swarm and re-store them#2151
mpretty-cyro wants to merge 1 commit into
session-foundation:devfrom
mpretty-cyro:feature/config-recovery

Conversation

@mpretty-cyro

Copy link
Copy Markdown
Collaborator

Config messages have a 30-day TTL that is refreshed by the expire bump already piggybacked on every poll. A device offline past the TTL loses its config from the swarm and nothing noticed. This reads the bump's own answer to detect that case and re-stores from local state. Reasoning for each rule is in the code.

  • Detect missing config hashes from the unchanged array the server returns for an extend-only expire. An absent key means detection is unavailable, not that every config is gone.
  • Re-store on a later poll, only once local state is level with the swarm, so a stale local config can never overwrite a newer remote one.
  • Chunk the recovery batch at 20 sub-requests; the server rejects the whole sequence above that, and a single config can split into ~66 parts.
  • Run the obsolete-hash deletes as a separate pass after the stores, built only from restores that fully landed, so a delete can never go out over a config we did not finish storing.
  • Bar a settled hash for an hour rather than for the session; a backgrounded session can outlive the TTL, which would strand the config it just restored.
  • Drop the per-store semaphore and let BatchApiExecutor coalesce; the semaphore was bounding batch size by accident, not by design.

…re-store them

Config messages have a 30-day TTL that is refreshed by the expire bump already
piggybacked on every poll. A device offline past the TTL loses its config from
the swarm and nothing noticed. This reads the bump's own answer to detect that
case and re-stores from local state. Reasoning for each rule is in the code.

- Detect missing config hashes from the `unchanged` array the server returns for
  an extend-only expire. An absent key means detection is unavailable, not that
  every config is gone.
- Re-store on a later poll, only once local state is level with the swarm, so a
  stale local config can never overwrite a newer remote one.
- Chunk the recovery batch at 20 sub-requests; the server rejects the whole
  sequence above that, and a single config can split into ~66 parts.
- Run the obsolete-hash deletes as a separate pass after the stores, built only
  from restores that fully landed, so a delete can never go out over a config we
  did not finish storing.
- Bar a settled hash for an hour rather than for the session; a backgrounded
  session can outlive the TTL, which would strand the config it just restored.
- Drop the per-store semaphore and let BatchApiExecutor coalesce; the semaphore
  was bounding batch size by accident, not by design.
@mpretty-cyro mpretty-cyro self-assigned this Aug 5, 2026
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