Skip to content

fix: lock analysis-run retention purge to a granted admin role - #137

Closed
cursor[bot] wants to merge 4 commits into
feat/role-responsibility-agent-ontologyfrom
cursor/bc-c3526cf9-3186-42b1-aa06-20649262057b-4901
Closed

fix: lock analysis-run retention purge to a granted admin role#137
cursor[bot] wants to merge 4 commits into
feat/role-responsibility-agent-ontologyfrom
cursor/bc-c3526cf9-3186-42b1-aa06-20649262057b-4901

Conversation

@cursor

@cursor cursor Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Buyer impact

Operators empty a run-bearing analysis-run registry only after GRANT analysis_run_retention_admin and SET ROLE analysis_run_retention_admin. Then run select purge_analysis_run_registry('approved-retention-purge'), export analysis_run_retention_event (it now records the invoking session role), delete those rows, and roll back 0019 then 0018. A runtime login that only knows the public phrase cannot empty the registry. A raw DELETE still fails.

Designers still change citation-chip and close-button appearance in frontend/src/styles/tokens.css and click those controls in Storybook (cd frontend && pnpm run storybook).

Why this PR

Successor to #129. That slice added the approved purge, but SECURITY DEFINER plus PostgreSQL's default PUBLIC execute grant meant any SQL login could wipe the registry with the documented phrase. NIST SP 800-53 Rev. 5 AC-3 treats that phrase as a procedure name, not an authorization secret.

Stacked on #74 / ADR 0018 / package 0.86.0. Do not merge before #74. Do not merge #105 onto protected main.

What shipped

  • analysis_run_retention_admin (NOLOGIN) receives EXECUTE; PUBLIC does not
  • analysis_run_retention_event records invoking_session_role, invoking_current_role, and optional client_network_address
  • Live contract: a table-DML runtime role is denied; a member of the admin role can purge
  • Dark-mode chip border token and buyer-facing component docstrings

Verification

  • python3 -m pytest -q tests/test_analysis_run_registry_schema.py tests/test_documentation_hygiene.py — 15 passed against local PostgreSQL 16
  • cd frontend && pnpm run lint && pnpm run test && pnpm run build && pnpm run build-storybook — 45 tests passed; Storybook 10.5.8 built
Open in Web View Automation 

cursoragent and others added 4 commits August 16, 2026 15:47
Operators can empty a run-bearing analysis-run registry with
purge_analysis_run_registry('approved-retention-purge') instead of a
superuser trigger disable. Repeated citation chips and close buttons
use named design tokens and a Storybook catalog on Node 24.

Co-authored-by: Seongho Bae <[email protected]>
#125 already uses ADR 0017 and package 0.85.0 for POST /api/analysis-runs.
Keep this retention-purge slice on the next free numbers.

Co-authored-by: Seongho Bae <[email protected]>
The documented approval phrase is a procedure name, not a secret.
REVOKE PUBLIC execute, grant only analysis_run_retention_admin, and
record the invoking session role on each retention event so a runtime
DATABASE_URL login cannot empty the registry.

Co-authored-by: Seongho Bae <[email protected]>

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review

Do not merge this head. It is a conflicting duplicate of the #129 privilege fix.

Next action: take #134 (analysis_run_retention_grant + REVOKE PUBLIC, rebased onto current #74, ADR 0019 / v0.87.0). This branch still sits on dea0b3a and conflicts with #74 after #124 / #127 / #125 landed. The role-only analysis_run_retention_admin model is weaker than #134's revocable grant table once the compose app login is the migration owner (a superuser bypasses REVOKE; the in-function grant check still runs).

#134's remaining gap is test cleanup (DROP OWNED BY before DROP ROLE), not the product control. Do not open a third purge successor.

View PR

Open in Web View Automation 

Sent by Cursor Automation: Fix Issues

@seonghobae

Copy link
Copy Markdown
Contributor

Superseded by canonical #145 (ADR 0020 / v0.87.0) on live #74 (7f2d4bc). #145 keeps the admin-role execute lock from this PR and adds the unrevoked session-grant lock from #134. Do not merge this PR.

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