Skip to content

Issue #226: atomically consume history-preview consent under concurrent requests - #237

Merged
KAVentures merged 4 commits into
mainfrom
fix/issue226-atomic-history-preview-consent
Oct 16, 2026
Merged

KAVentures merged 4 commits into
mainfrom
fix/issue226-atomic-history-preview-consent

Conversation

@KAVentures

Copy link
Copy Markdown
Owner

Problem

Historical evidence backfill is OFF by default, but its merged preview/confirm path previously verified the token and deleted the token/digest/window/expiry as separate SQLite writes. Two simultaneous authenticated confirmations could both pass validation and send the same historical evidence; an in-flight preview could also interleave with the field deletion.

Change

  • Add a small generic, transactional SyncState.consume_if_matches primitive. SQLite DELETE ... WHERE value = ? succeeds exactly once across threads/processes and removes companion keys in the same transaction.
  • Require atomic consent consumption after revalidating source-policy/evidence and before first upload, with an expiry recheck after potentially slow validation.
  • Add actual two-thread racing confirmation test plus direct token-consumption concurrency test.
  • Document single-use properties. No uploads in CI and no permission/default change.

Required acceptance

Run Python tests, Windows/macOS/Linux packages and privacy regressions. Leave OWG_ENABLE_HISTORY_BACKFILL OFF pending the full real Gateway/privacy/migration review; this PR does not enable historical uploads or close #226. Please do not auto-merge.

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.

Verified record graph: authorized audit-log joins, outcome receipts, and handoffs

1 participant