fix(permission-management): harden permission lifecycle races - #555
Conversation
Codex ReviewVerdict: needs changes [P1] Prevent invalidation from missing a request created after the pending sweepsrc/main/compute/compute-approval-broker.ts:165 Impact: If provider invalidation starts while the durable grant lookup is still awaiting, this operation can create a new pending approval after invalidateProvider has already swept pending requests. invalidateProvider then waits forever on this in-flight promise, so host deletion hangs before repository.delete and the invalidation completion cleanup. Recommendation: Re-check the provider generation/invalidatingProviders immediately before calling request(), or make invalidation cancel/drain requests created after the initial sweep so every operation settles during deletion. Summary: Static inspection found one merge-blocking compute deletion race. Branch and pull request title checks are valid. |
|
Addressed the compute invalidation race in 36368f0. The broker now re-checks both the invalidation barrier and the provider generation immediately before creating a pending approval. If invalidation starts during an asynchronous grant lookup, the operation fails closed and settles, so invalidateProvider can finish draining. A deterministic regression test covers that exact ordering. Validation: 58 targeted tests passed, typecheck passed, lint completed with 0 errors, and the full suite passed with 8,892 tests. |
Codex ReviewVerdict: mergeable No actionable findings. Summary: Static inspection found no concrete merge-blocking defects in the pull request changes. |
Problem
The merged permission-management work in #533 left several time-of-check/time-of-use gaps:
Oncerequest could arrive after deletion completed;/and pruned their grants;Proposed change
Scope and non-goals
permissions:extend-undoIPC method renews only the existing in-memory receipt; no new architectural component or persistent state is introduced.Acceptance criteria and validation
All commands below ran after the final material edit.
npm test -- --run src/main/connectors/service.test.ts src/main/permission-grants/registry.test.ts src/main/permission-grants/reconciliation.test.ts src/main/permission-grants/ipc.test.ts src/main/compute/compute-approval-broker.test.ts src/main/compute/ipc.test.ts src/renderer/src/stores/permission-grants-store.test.ts src/renderer/src/components/PermissionUndoSnackbar.test.tsx src/main/acp/permission-broker-registry.test.ts-> 9 files passed, 161 tests passed.npm run typecheck-> passed.npm run lint-> passed with 0 errors (23 pre-existing warnings outside this change).npm run check:web-api-map-> passed.npm test-> 591 files passed, 11 skipped; 8,891 tests passed, 140 skipped.git diff --check-> passed.Uncovered risk: the policy-race coverage uses deterministic unit seams rather than a packaged Electron end-to-end interaction. The same production settings read and dispatch boundary are exercised directly.
An independent review of the final diff confirmed this behavior-to-check mapping.
Review focus
Refs #533.