Skip to content

A daemon killed during a background reclaim returns the device to the pool with the last holder's data #1233

Closed as not planned

Description

@V3RON

A daemon that is killed while a released device's background reclaim is still running (SIGKILL, a crash, power loss) puts that device back in the pool with the last holder's apps and data on it.

LeaseReleaseCoordinator writes the deferred-reclaim marker (deferredReclaimLeaseId) only for reclaim none, or background when lease-end participants exist (src/leasing/lease-release-coordinator.ts:271, #hasParticipants at :349). With the default modules there are no participants, so a background reclaim leaves no marker; an await reclaim (maintenance, nuke) leaves none either. At startup, ReclaimCoordinator.recoverInterrupted (src/core/reclaim-coordinator.ts:141) then finds no marker, only shuts the device down and calls completeReclaimWithoutPurge (:169). On iOS the reclaim is shut down, erase, mark (src/drivers/ios/index.ts), so a kill anywhere before the erase finishes leaves the old data in place. The next holder gets it.

The test pins this today: src/core/reclaim-coordinator.test.ts:371 "recovers an unleased interrupted reclaim through shutdown, a committed fact, and itself as the emitter". docs/internal/flows/startup.md:67 documents it ("else shut down"). ADR 0019's amendment states the intent "a reusable device never returns to the pool with its last holder's data", but only for the unreadable-platform case.

Expected. A device whose reclaim was interrupted is purged before it is granted again, whichever reclaim kind was running.

Possible fix. Write the deferred-reclaim marker for every release and clear it after a successful purge; startup finishes the purge for any device that still carries it. Needs a decision on whether this amends ADR 0019, and on the startup cost (an erase per interrupted device).

A graceful stop waits for background reclaims, so only an unclean stop triggers this.

Found in a code review, checked by hand.

Written by an agent.

Activity

  1. added
    bug:new
    platform:ios
    on Nov 3, 2026
  2. V3RON commented on Nov 3, 2026

    @V3RON
    ContributorAuthor

    This was generated by AI during triage.

    Triage notes

    Confirmed by reading the code at e84d27d (no repro test or branch; this routine changes no code):

    • src/leasing/lease-release-coordinator.ts:271-273 sets deferReclaim only for reclaim none, or background when #hasParticipants (:349, just leaseEnd !== undefined). await and participant-less background releases leave no deferredReclaimLeaseId.
    • src/core/reclaim-coordinator.ts:152-169: recoverInterrupted without the marker only shuts the device down and calls completeReclaimWithoutPurge, so the device goes back to the pool unpurged.
    • The test at src/core/reclaim-coordinator.test.ts:371 and docs/internal/flows/startup.md:66-67 describe this as intended today.

    Duplicates: none found. Related, closed: #676 (wrong emitter on the same recovery path), #469 (participants before reclaim), #43 (startup reclaim off the critical path).

    Labels: kept bug:new; added platform:ios (erase is the purge that gets skipped).

    Left for the maintainer:

    • Whether this amends ADR 0019 (its "never returns with the last holder's data" rule today covers only the unreadable-platform case).
    • Whether Android is affected too. It depends on whether the next boot after an unpurged shutdown restores the clean snapshot. I did not check this; add platform:android if it is.
    • Whether the startup cost (one erase per interrupted device, in the background under a claim) is acceptable.
    • Next step: run triage-bug to get a failing repro test, then bug:ready.

    Written by an agent.

  3. self-assigned this
    on Nov 7, 2026
  4. V3RON commented on Nov 7, 2026

    @V3RON
    ContributorAuthor

    This was generated by AI during triage.

    Handoff

    Done

    Cannot reproduce on origin/main (fc5ac8c3e1d670689cb4eb14396850e7af691ccb). A temporary fast-e2e probe sent SIGKILL during shutdown or destroy for both background release and awaited nuke, on iOS and Android, with reusable identity and no participants. All eight cases deleted the old device at startup, rejected its lease renewal, and provisioned a different registry device for the next lease.

    pnpm test:e2e e2e/startup-reconcile.test.ts
    13 passed (including the temporary eight-case probe)
    pnpm exec vitest run --project unit src/core/reclaim-coordinator.test.ts src/core/startup-converger.test.ts
    36 passed
    

    Not done

    No failing reproduction, trial fix, remote repro branch, or PR. Removed only the temporary probe; checkout clean. No slow lane run.

    Findings

    #1210, commit 8b027283, implemented ADR 0061 §2 after the earlier notes. registry.ts:861 stamps every release; domain.ts:399-400 forbids regrant; startup-converger.ts:49-52,64-70 deletes spent devices after recovery.

    Blocked on

    Reporter: a current-main commit/config and exact crash steps showing the next holder receiving previous-holder data. Fake-driver tests prove retirement/provisioning, not real-device filesystem contents. Moving to bug:needs-info.

    Written by an agent.

  5. added
    bug:needs-info
    and removed
    bug:new
    on Nov 7, 2026
  6. removed their assignment
    on Nov 7, 2026
  7. github-actions commented on Nov 22, 2026

    @github-actions
    Contributor

    Closing: no reply in two weeks. Comment with the missing information and it reopens for triage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug:needs-infoplatform:ios

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions