Skip to content

feat(consent): persist anonymous session consent after expiry checks - #181

Draft
cursor[bot] wants to merge 6 commits into
mainfrom
cursor/bc-2bd37ab0-7380-4dbf-87a0-b4547b9b40b1-b92f
Draft

feat(consent): persist anonymous session consent after expiry checks#181
cursor[bot] wants to merge 6 commits into
mainfrom
cursor/bc-2bd37ab0-7380-4dbf-87a0-b4547b9b40b1-b92f

Conversation

@cursor

@cursor cursor Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Why

PR #170 composes ManageOwnConsent with persist_consent_ledger for a Keyverse-shaped actor. Anonymous assessment is first-class, but that write path has no current-session expiry or binding check. A later HTTP adapter would have to invent a subject and skip session lifetime.

What this PR does

  • Keep the feat(consent): persist only after owner authorization #170 owner-authorize-then-persist gate (foreign participant, foreign tenant, missing identity, numeric tenant, service grant does not imply research).
  • Add persist_authorized_anonymous_consent_ledger: a current AnonymousSessionContext may persist its own ledger after expiry and exact participant binding.
  • Prove an expired session, unknown server time, and foreign ledger insert no consent_ledger or consent_event row.
  • Prove a current anonymous session inserts the authorized research grant.
  • Record the composition honestly in TRACEABILITY, ADR-0006, UML, SECURITY_AND_DATA, and CHANGELOG.

Out of scope

Test plan

  • cargo test --test consent_anonymous_authorization_write_path --test consent_authorization_write_path --test documentation_architecture_contract --test traceability_active_pr_contract
  • cargo clippy --all-targets -- -D warnings
  • cargo test --test postgres_consent_anonymous_persist --test postgres_consent_authorized_persist (needs TEST_DATABASE_URL)

This is the successor to #170. Prefer this head over owner-only #170 and authorize-only #145. Prefer #142 for durable-tail outbox. Do not merge #70, #112, #120, #123, #134, #145, or #170. Do not merge until exact-head checks and independent last-push approval are satisfied. Never self-approve.

Operator next action

Review the anonymous-session expiry and binding no-row proofs. Keep outbox work on #142. Do not treat this head as HTTP consent.

Open in Web View Automation 

cursoragent and others added 5 commits August 16, 2026 15:53
Require ManageOwnConsent on the participant ledger before any later
consent or outbox composition. Foreign participants, foreign tenants,
missing participant identity, and numeric tenants fail closed. Service
consent still does not imply research contribution.

Co-authored-by: Seongho Bae <seonghobae@users.noreply.github.com>
Keep the authorization write-path gate independent of durable-tail
ordering and point agents at #142 instead of #134.

Co-authored-by: Seongho Bae <seonghobae@users.noreply.github.com>
Compose ManageOwnConsent with persist_consent_ledger so a foreign
participant cannot insert another person's consent row. Keep the
low-level persist adapter for isolation tests. Outbox tail and HTTP
POST /v1/consents stay later slices.

Co-authored-by: Seongho Bae <seonghobae@users.noreply.github.com>
Prove persist_authorized_consent_ledger inserts no consent row when the
actor is in another tenant or lacks a participant identity.

Co-authored-by: Seongho Bae <seonghobae@users.noreply.github.com>
A current anonymous assessment session may persist its own purpose-specific
ledger. An expired session, unknown server time, or foreign participant
inserts no consent row, so anonymous research opt-in cannot bypass owner
authorization.

Co-authored-by: Seongho Bae <seonghobae@users.noreply.github.com>
Protected-main #81 requires claim_deadline_at on processing
integration_consumption rows. Recovery fixtures that omit the column
fail constraint integration_consumption_claim_deadline_shape.
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.

2 participants