Skip to content

Bounded GC for crash-abandoned policy-lock claims and stale secure-temp roots #120

Description

@fitchmultz

Context: follow-up from PR #108 / v0.4.1 (https://github.com/fitchmultz/pi-agent-browser-native/releases/tag/v0.4.1, immutable head d6cde09).

Follow-up: cheap GC for crash-abandoned policy-lock claims and stale secure-temp roots

Observed (2026-08-11, mega-dogfood gate cycle)

  • Killed/aborted Pi test runs (and by extension real Pi crashes) abandon .pi-agent-browser-policy-*.lock-v2 / .lock-v3.claim-* dirs under /tmp/pi-agent-browser-policy-<uid>.
  • 54 accumulated stale claim dirs measurably degraded later policy-lock acquisitions: two contention-window tests (serializes caller-owned live verification, revalidates daemon policy after cross-instance lock contention) failed deterministically in a 7-file suite run and passed 91/0 after quarantining the stale dirs. Healthy runs leave zero claims.
  • Reclaim exists (PID/start-identity probes reclaim proven-dead current-protocol claims) but pays per-candidate process probes at acquisition time; abandoned v2 owners fail closed by design, so buildup taxes every later same-identity acquisition.
  • Separately, TMPDIR pi-agent-browser-* secure-temp roots accumulate from aborted runs (observed 1600+ in one day of heavy testing); stale-root ownership checks handle them but a cheap opportunistic sweep would bound the scan set.

Proposal (post-merge, separate PR)

  • Opportunistic bounded GC at coordination-directory ensure time: reclaim/remove proven-dead current-protocol claims and v2 dirs older than a floor (e.g. 30 min) with dead owners, capped per call (e.g. 8 entries) so acquisition latency stays bounded.
  • Same bounded sweep idea for marked secure-temp stale roots (already ownership-checked; just add an age floor + per-call cap).
  • Keep fail-closed semantics for ambiguous/foreign/legacy entries exactly as today; GC only provably-dead current-protocol artifacts.
  • Tests: unit coverage for cap/floor/dead-proof gating; regression that stale-claim buildup no longer delays an unrelated-identity acquisition.

Non-goals

  • No change to fail-closed abandoned-v2 semantics, lock protocol, or claim formats.
  • Not a substitute for the cross-process global recording claim follow-up (separate file).

Activity

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions