Skip to content

Fix main's CI (tests leave the v10 control schema behind) + round-2 review fixes for the key tables - #110

Merged
warheart1984-ctrl merged 5 commits into
mainfrom
feat/phase1-control-schema
Oct 16, 2026
Merged

warheart1984-ctrl merged 5 commits into
mainfrom
feat/phase1-control-schema

Conversation

@warheart1984-ctrl

Copy link
Copy Markdown
Owner

Main's CI is red on #107's and #108's merge commits. Cause (reproduced locally): tests that create and drop their own schemas (test_block_anchors, test_pg_replay) did not drop v10's new <schema>_control twin, and CI runs the suite twice on the same Postgres server, so the second pass fails with schema "jarvis_control" already exists / "restored_control" already exists. These fixes were finished just after the merges, so they are not in main yet.

Test fix (the red CI)

Those two tests now drop the control schema twin. Verified by running the schema-managing test files twice on one server in whole-suite Postgres mode (149 passed each pass, 0 leftover control schemas; without the fix the second pass fails exactly as in CI).

Four Codex findings on #107 (round 2), all valid, each with a test that fails when the fix is removed

  • Key issuance racing a deletion: the BEFORE INSERT trigger reads the tenant row FOR SHARE, so a transition to deleting/deleted waits for an uncommitted insert (then revokes that key) and an insert waits for an uncommitted transition (then is refused). A two-thread test holds each side open in turn (and cleans up after itself).
  • --expires-days 0 meant "never": it now means "expires now", omitting it still means no expiry, negative is refused.
  • Rollback SQL did not quote a mixed-case control schema name: pg_schema.v10_rollback_sql(schema) quotes it as v10 created it (tests migrate and roll back a mixed-case schema).
  • A repeated deleted overwrote the first deleted_at: now coalesce(deleted_at, now()).

Not deployed; the live box is still on v9 (no migration has run there). Drill (v9 -> v10, key tenants, rollback) was re-run on the fixed code earlier: 52/52.

🤖 Generated with Claude Code

warheart1984-ctrl and others added 2 commits October 16, 2026 18:34
Tests that manage their own schemas now drop the v10 control schema twin (a second run on the same server failed with 'schema already exists'); key issuance reads the tenant row FOR SHARE so it cannot race a deletion; --expires-days 0 means 'expires now'; the rollback SQL quotes the control schema (v10_rollback_sql); a repeated 'deleted' keeps the first deleted_at.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-16T22:52:59.263206Z b680f05 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f7ad9b81a7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread app/pg_schema.py Outdated
warheart1984-ctrl and others added 3 commits October 16, 2026 18:44
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…x round 3)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b680f05d2d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread app/pg_schema.py
def quote(name: str) -> str:
return '"' + name.replace('"', '""') + '"'

return V10_ROLLBACK.replace("__CONTROL__", quote(control_schema_name(schema))).replace("__LEDGER__", quote(validate_schema_name(schema)))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid recursive placeholder substitution in rollback SQL

When a valid ledger schema contains the literal __LEDGER__ (for example, foo__LEDGER__bar), the second replacement also rewrites that substring inside the already-substituted control-schema identifier, producing malformed SQL such as "foo"foo__LEDGER__bar"bar_control". Consequently, v10_rollback_sql() cannot roll back every schema accepted by validate_schema_name(); construct the two statements independently or use collision-proof formatting rather than sequential global replacements.

Useful? React with 👍 / 👎.

@warheart1984-ctrl
warheart1984-ctrl merged commit 432b4d1 into main Oct 16, 2026
3 checks passed
@warheart1984-ctrl
warheart1984-ctrl deleted the feat/phase1-control-schema branch October 17, 2026 03:13
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