Skip to content

Grant cora_app SELECT+INSERT on five entries_ tables missing it - #644

Merged
xmap merged 1 commit into
mainfrom
fix-entries-table-grants
Aug 10, 2026
Merged

Grant cora_app SELECT+INSERT on five entries_ tables missing it#644
xmap merged 1 commit into
mainfrom
fix-entries-table-grants

Conversation

@xmap

@xmap xmap commented Aug 10, 2026

Copy link
Copy Markdown
Owner

Summary

  • Five entries_* tables carried a header comment falsely claiming cora_app gets SELECT+INSERT via the role-init migration's ALTER DEFAULT PRIVILEGES clause, which covers sequences only, never tables. Adds a purely additive migration granting the five tables their missing privileges, targeting each table's current (post-rename) name.
  • Currently dormant, not live: the 2-BM pilot's DATABASE_URL still connects as the owner role cora, not cora_app.
  • Hardens test_entries_table_grants.py's rename-lineage tracking (a table renamed into the entries_ prefix from a differently-named origin was previously invisible to the check) and adds a live-Postgres integration test proving cora_app can actually INSERT into all five tables, not just that a GRANT statement exists in migration text.

Test plan

  • atlas migrate validate --env local clean
  • Full architecture suite: 30408 passed
  • Full unit suite: 12908 passed
  • tests/integration/test_cora_app_role_revoke_postgres.py: 12 passed (5 new, against a live Postgres testcontainer)
  • Gate review (4 agents: architecture, test coverage, cross-BC consistency, migration-safety specialist): migration-safety verdict LOCK, 0 P0s; 2 independently-converged P1s fixed in this branch

🤖 Generated with Claude Code

Five entries_* tables (entries_run_readings/entries_run_observations,
entries_operation_procedure_steps/...activities,
entries_run_feed_heartbeats, entries_operation_procedure_diagnostics,
entries_operation_procedure_outcomes) carried a header comment
claiming cora_app gets SELECT+INSERT via the role-init migration's
ALTER DEFAULT PRIVILEGES clause. That clause covers sequences only,
never tables, so none of the five ever had a working grant. Dormant
today because the 2-BM pilot's DATABASE_URL still connects as the
owner role, but every write would fail the day anything switches to
the restricted cora_app role.

Two of the five were renamed after creation, so the fix migration
targets their current identifiers (entries_run_observations,
entries_operation_procedure_activities) rather than the names in the
original bug report - an earlier draft using the old names failed
atlas migrate validate with a 42P01, confirming the point.

Also hardened the test_entries_table_grants fitness test that encoded
this finding: it now follows ALTER TABLE ... RENAME TO across ALL
tables' history (not just ones already named entries_/events), closing
a blind spot where a table renamed INTO the prefix from a differently
named origin (entries_conduit_verdicts, originally
observations_conduit_traversals) was invisible to the check. Added a
parametrized integration test that inserts into all five tables as a
real cora_app-credentialed connection against a live Postgres
container, since a regex match against migration text proves a GRANT
statement exists, not that Postgres honors it.

Gate review (4 agents: architecture, test coverage, cross-BC
consistency, migration-safety specialist): migration-safety LOCK, no
P0s; two independently-converged P1s (the rename-lineage blind spot,
and the missing positive integration test) both fixed and verified
against a live Postgres testcontainer in this same commit. Cosmetic P2
(GRANT column alignment) not addressed.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  apps/api/src/cora/infrastructure
  schema_version.py
Project Total  

This report was generated by python-coverage-comment-action

@xmap
xmap merged commit 27ba02a into main Aug 10, 2026
19 checks passed
@xmap
xmap deleted the fix-entries-table-grants branch August 10, 2026 20:52
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.

1 participant