Skip to content

fix(flow): show rule enable state and unique indexes in the db code digest - #1836

Merged
abrichr merged 2 commits into
mainfrom
agent/1674
Nov 4, 2026
Merged

abrichr merged 2 commits into
mainfrom
agent/1674

Conversation

@abrichr

@abrichr abrichr commented Nov 4, 2026

Copy link
Copy Markdown
Member

Part of #1674

What changed

  • The Postgres code digest in db_snapshot.py now reads rules from pg_rewrite with ev_enabled, so ALTER TABLE ... DISABLE RULE shows as a "(database code)" change. Before, it read pg_rules, which has no enabled state. A view's own _RETURN rule is still left out, the same as pg_rules did.
  • The digest now lists unique indexes (pg_index.indisunique, with indisvalid and pg_get_indexdef). A CREATE UNIQUE INDEX that is not a constraint changes which writes the database accepts, and before this it did not show when it was made or dropped.

How it was tested

  • Two new live tests in tests/test_db_snapshot_postgres.py: test_disabling_a_rule_shows and test_a_unique_index_made_or_dropped_shows.
  • Ran tests/test_db_snapshot_postgres.py and tests/test_frame_database.py against a scratch local Postgres 17 with OPENADAPT_SNAPSHOT_POSTGRES set: 211 passed.
  • Control: with main's db_snapshot.py and the new tests, both new tests fail.
  • ruff check and format are clean on both files. mypy is clean on db_snapshot.py.

What could not be tested

  • Postgres versions other than 17.
  • The other items in Whole-database frame on PostgreSQL: follow-ups from the #1673 review #1674 are not in this PR: partitioned table identity, ALTER SEQUENCE INCREMENT in the diff, reading sequences before BEGIN, pooler session pins, citext/hstore, clock defaults, and row text for tables with no key. Table name collision is already refused on main.

@abrichr abrichr added the review-needed Needs an independent review from another vendor's agent label Nov 4, 2026
@abrichr

abrichr commented Nov 4, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Codex. Reviewed actual head 5d7de36 in a fresh detached worktree.

packages/flow/openadapt_flow/runtime/effects/db_snapshot.py:1325 includes each rule's activation mode; line 1336 includes unique-index validity and its complete definition. Both changes are reflected in the database-code diff. No row change was needed to make the probes detect them.

Validation: 211 snapshot/frame tests pass against an isolated PostgreSQL 16.15 cluster. Eight independent live probes pass: all four rule activation modes, expression/covering/NULLS NOT DISTINCT unique-index creation and deletion, and replacing a same-named index's predicate. Every change is missed by the exact parent implementation, detected by this PR, and followed by a stable reread. Full Flow Ruff/format and mypy pass (591 sources).

The environment used locked package dependencies plus pinned psycopg2-binary 2.9.10. Only PostgreSQL 16 was tested in this review. The other items left open in #1674 are outside this approval. Synthetic data, headless resource gate; I did not change or push this PR.

@abrichr abrichr removed the review-needed Needs an independent review from another vendor's agent label Nov 4, 2026
@abrichr
abrichr merged commit cd87a77 into main Nov 4, 2026
46 checks passed
@abrichr
abrichr deleted the agent/1674 branch November 4, 2026 22:23
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