Repository navigation
feat(gateway): report TENANT_RLS_MODE, require 052 receipt columns, run 048 off-proof in CI - #240
Conversation
… at boot The startup runtime_posture log line and GET /health now carry tenant_rls_mode (off or enforce; the default stays off). REQUIRED_TRUST_COLUMNS now includes receipts.enforcement_mode and receipts.gateway_build, so a database missing migration 052 fails the boot schema check. Signed-off-by: Christopher <131207452+PetrefiedThunder@users.noreply.github.com>
Create an empty amw_rls_off_migration database and set TENANT_RLS_OFF_MIGRATION_DATABASE_URL in the migration round-trip step, so the PG-gated default-off test runs. The proof-log gate fails the job if it skips. Signed-off-by: Christopher <131207452+PetrefiedThunder@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
No actionable comments were generated in the recent review.
|
Precedence: RELEASE_COMMIT_SHA override, RAILWAY_GIT_COMMIT_SHA, GIT_COMMIT_SHA, staged .build_commit_sha. All set sources must be 7-40 hex and agree, otherwise the build fails. Signed-off-by: Christopher <131207452+PetrefiedThunder@users.noreply.github.com>
Signed-off-by: Christopher <131207452+PetrefiedThunder@users.noreply.github.com>
PetrefiedThunder
left a comment
There was a problem hiding this comment.
Delta review of eabf2ae against main 26613d6. The branch is not behind main, all 48 required checks are green on this head (only the two license matrix placeholders are skipped), and 0 threads are unresolved.
Claims checked:
- gateway/app/main.py:194,1267: TENANT_RLS_MODE appears in the runtime_posture line and in /health. openapi.json:5955 changes only the description, and it matches the source.
- gateway/app/db/database.py:128-129: enforcement_mode and gateway_build are now in REQUIRED_TRUST_COLUMNS[receipts], and a sqlite boot-check test covers them.
- ci.yml:463,520-526: the amw_rls_off_migration DB is created, its env var is set, and the 048 default-off test is selected. The proofs job log shows 3 passed with no skips under -rs.
- write_build_commit_sha.py:50-89 and Dockerfile:12-14: the order is RELEASE, then RAILWAY, then GIT_COMMIT, then staged. Each value must be 7-40 hex, comparison is case-insensitive, any disagreement or a missing source fails the build, and BUILD_COMMIT_SHA/COMMIT_SHA are not read. Smoke cases are at smoke_gateway_image.sh:148-157.
- The default stays off (config.py:69 plus validator), and the hash chain and duplicate guard are not touched.
- Tests follow the real-data rule: the SHA/OTHER constants already existed as placeholders, and nothing else is invented.
Non-blocking notes:
- main.py:1265-1267: /health echoes the configured mode, not whether RLS is actually on in the database. 048 enables RLS only if it ran under enforce, so flipping the setting later reports enforce while RLS is still off. Suggest wording it as "configured" in the comment and openapi description, or a follow-up that reads pg_class.relrowsecurity.
- write_build_commit_sha.py:87: a short SHA and a full SHA that share a prefix do not count as agreeing. This fails closed, which I think is right, but it is worth a docstring line or a test.
- write_build_commit_sha.py:69: a whitespace-only arg is treated as unset (fine for empty Docker ARGs). This is a docstring nit only.
- tests/test_tenant_rls_reporting.py:54: Settings() reads env/.env, so a local TENANT_RLS_MODE=enforce would fail it. Use monkeypatch.delenv or _env_file=None.
- build_metadata.py:10 still accepts 7-64 while the writer now caps at 40. They are consistent in practice, but worth noting.
I could not run the tests locally because the review venv lacks pytest_asyncio. CI on 3.11-3.14 covers them.
REVIEW: PASS codex eabf2ae
Codex follow-ups from #234 and #236.
runtime_posturelog line, which is the one operator posture line, now includestenant_rls_mode.GET /healthreturnstenant_rls_mode:offorenforce, a validated enum and never a secret. The default staysoff.REQUIRED_TRUST_COLUMNS["receipts"]now includesenforcement_modeandgateway_buildfrom migration 052, so a database without them fails at startup.amw_rls_off_migrationdatabase and setsTENANT_RLS_OFF_MIGRATION_DATABASE_URLin the migration round-trip step. That step now runstest_047_048_negative_paths.py::test_postgres_default_off_creates_policies_but_leaves_rls_disabled, which skipped before.proof_log_gate.pyalready fails the job on anySKIPPEDline, so the test has to run.Tests: new
gateway/tests/test_tenant_rls_reporting.pycovers the posture line and/healthfor both modes, the off default, and the boot check naming the missing 052 columns. CHANGELOG updated, anddocs/openapi.jsonregenerated for the/healthdescription.Local: full gateway suite 5971 passed, 102 skipped. The 048 proof passes against a local PostgreSQL 16 empty database.
This PR doesn't touch the duplicate guard or the hash-chain code. It doesn't port
tenant_rls.py; that's a separate PR.Note
Medium Risk
Startup will refuse databases missing migration 052 receipt columns, and Docker builds can fail when commit SHA sources disagree; health/logging changes are low risk.
Overview
Exposes tenant RLS posture in ops surfaces: the startup
runtime_posturelog andGET /healthnow includetenant_rls_mode(offorenforce; default unchanged). OpenAPI/CHANGELOGdocument the health field.Boot fails earlier on databases that never ran migration 052:
receipts.enforcement_modeandreceipts.gateway_buildare required trust columns at schema check, not only on first receipt write.CI Postgres proofs add a dedicated empty DB (
amw_rls_off_migration) andTENANT_RLS_OFF_MIGRATION_DATABASE_URLso the migration 048 “default-off RLS” negative proof runs instead of skipping.Gateway image commit stamping is reworked:
write_build_commit_sha.pyand the Dockerfilebuild-metadatastage acceptRELEASE_COMMIT_SHA→RAILWAY_GIT_COMMIT_SHA→GIT_COMMIT_SHA→ staged.build_commit_sha, require every set source to be a 7–40 hex SHA and agree, and fail the build on mismatch (stale pinned override vs Railway/CI). Smoke script and unit tests cover the new paths;BUILD_COMMIT_SHA/COMMIT_SHAremain ignored.Reviewed by Cursor Bugbot for commit eabf2ae. Bugbot is set up for automated code reviews on this repo. Configure here.
Build commit stamp (added)
railway upbuilds failed the stamp step because.build_commit_shais gitignored.gateway/scripts/write_build_commit_sha.pynow resolves, highest precedence first:RELEASE_COMMIT_SHAbuild arg (explicit override, kept so the pinned staging variable keeps working)RAILWAY_GIT_COMMIT_SHA(declared as anARGingateway/Dockerfile, so Railway passes it at build time)GIT_COMMIT_SHAbuild arg (CI:--build-arg GIT_COMMIT_SHA=$(git rev-parse HEAD)).build_commit_shaEvery set source must be a 7-40 char hex SHA and all set sources must agree, otherwise the build fails; a stale pin cannot be stamped.
BUILD_COMMIT_SHA/COMMIT_SHAstay unread (stale service variables). Tests intest_write_build_commit_sha.pyand new smoke cases insmoke_gateway_image.sh.