Skip to content

fix: certify protected clarification S4 objects - #310

Merged
Joncallim merged 9 commits into
codex/pr198-f1-legacy-clarificationfrom
codex/pr198-f2-s4-clarification-inventory
Jul 30, 2026
Merged

fix: certify protected clarification S4 objects#310
Joncallim merged 9 commits into
codex/pr198-f1-legacy-clarificationfrom
codex/pr198-f2-s4-clarification-inventory

Conversation

@Joncallim

@Joncallim Joncallim commented Jul 30, 2026

Copy link
Copy Markdown
Owner

Source Issue

Issue: #179

Summary

  • keep both protected clarification ledger tables in the exact S4 owner and direct-ACL inventory
  • certify the three clarification routines by their complete PostgreSQL signatures and exact S4 owner
  • require each intended dedicated role to hold exactly one non-grantable EXECUTE, with no PUBLIC, extra grantee, extra overload, or missing grant
  • prove the production finalizer rejects hostile catalog and ACL changes and restores every fixture through transaction rollback

This stacked child addresses PR #198 finding PRRT_kwDOS9dWe86U9jdz / discussion_r3679390472, including the follow-up exact-signature and closed-ACL review.

Exact stack

Files

  • web/scripts/bootstrap-epic-172-s4-roles.ts
  • web/__tests__/epic-172-s4-context.test.ts
  • web/__tests__/epic-172-s4-postgres.test.ts

Validation

  • S4 context contract: 26 passed
  • fresh PostgreSQL 16 bootstrap and migration through 0027: passed
  • production-finalizer hostile matrix: 1 passed; unexpected grantee, intended role with grant option, missing intended grant, and wrong-overload substitution all rejected, with a clean baseline after every rollback
  • full local non-service unit run: 1,732 passed; existing service/environment cases used the repository's local skip convention
  • changed-file ESLint: passed
  • npx tsc --noEmit: passed
  • production build: passed
  • git diff --check: passed
  • mutation check: disabling the exact-signature authority branch made the focused source contract fail, then the restored tree passed

Hosted evidence

  • Web: run 30557711845, job 90922356044 — success
  • PR Contract: run 30558228863, job 90924210052 — success
  • GitGuardian: check 90922387523 — success
  • complete zero-skip unit suite: 1,748/1,748
  • mandatory S4 PostgreSQL: 15/15, including the new rollback-safe hostile finalizer matrix
  • Redis scrub: 3/3; Redis ACL: 3/3; cross-sink sentinel: 1/1 with marker
  • S3 PostgreSQL: 16/16; disabled ingress: 1/1; E2E: 17 passed / 59 expected skips

No parent review thread was replied to or resolved. This PR remains draft.

@Joncallim
Joncallim force-pushed the codex/pr198-f2-s4-clarification-inventory branch from edfdf17 to 10c2154 Compare July 30, 2026 15:38
@Joncallim
Joncallim marked this pull request as ready for review July 30, 2026 16:56
@Joncallim
Joncallim merged commit 9439644 into codex/pr198-f1-legacy-clarification Jul 30, 2026
4 checks passed

@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: f55289591d

ℹ️ 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 on lines +225 to +229
const exactClarificationRoutineValues = EXACT_CLARIFICATION_ROUTINES.map((routine) => `(
${literal(routine.identity)},
${literal(routine.name)},
${literal(routine.grantee)}::pg_catalog.regrole
)`).join(',')

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Install the new finalizer on upgraded databases

When this script is rerun after the parent migration has completed, the newly listed clarification tables already belong to forge_s4_routines_owner, so transferComplete is true and this entire CREATE OR REPLACE path is skipped. Existing deployments therefore retain the old 70-routine finalizer and never run the new clarification signature/grant checks, allowing precisely the drift this change is intended to reject; install or version the updated finalizer independently of the ownership-transfer branch.

AGENTS.md reference: AGENTS.md:L141-L143

Useful? React with 👍 / 👎.

Comment on lines +428 to +432
where observed.routine_oid is null
or observed.proowner <> '${OWNER}'::regrole
or observed.acl_count <> 2
or observed.owner_execute_count <> 1
or observed.expected_execute_count <> 1

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 Validate execution mode in the routine certificate

If an administrator or migration step changes one of these routines to SECURITY INVOKER or resets its fixed search_path, every attribute counted here remains unchanged and finalization still succeeds. For example, an invoker-mode clarification append then accesses protected tables as forge_architect_plan_history_reader, which has no direct table privileges, so protected answer submission fails at runtime; include prosecdef and the expected proconfig in this certificate, as the existing bridge check does.

AGENTS.md reference: AGENTS.md:L141-L143

Useful? React with 👍 / 👎.

@Joncallim
Joncallim deleted the codex/pr198-f2-s4-clarification-inventory branch August 2, 2026 18:22
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