Skip to content

Fix disposable review app shared grant mapping - #199

Merged
justin808 merged 3 commits into
mainfrom
jg-codex/fix-review-app-shared-grant-mapping
Jul 19, 2026
Merged

Fix disposable review app shared grant mapping#199
justin808 merged 3 commits into
mainfrom
jg-codex/fix-review-app-shared-grant-mapping

Conversation

@justin808

@justin808 justin808 commented Jul 18, 2026

Copy link
Copy Markdown
Member

Why

Disposable review apps currently reference a different repository-managed database credential than the target declared by their shared grant. The diagnostic replay confirmed this is repository-owned mapping drift: the intended shared object and grant subject exist, and shared routing aligns.

This replaces #197, whose proposed mapping followed the persistent-app template instead of the disposable review app's declared shared-grant target.

Related to #194. Diagnostic evidence: #194 (comment)

Implementation

  • Update the disposable review template's database credential mapping to its declared shared-grant target.
  • Add a repository-derived regression spec that compares the disposable template mapping with that grant declaration.
  • Leave the persistent-app template and external provider state unchanged.

TDD evidence

  • RED: bundle exec rspec spec/controlplane/template_mapping_spec.rb — 1 example, 1 intended sanitized mapping failure.
  • GREEN: the same command — 1 example, 0 failures.

Validation

  • YAML parse for the Control Plane config and disposable review template.
  • Focused RuboCop for the new spec.
  • Focused and adjacent Control Plane specs: 3 examples, 0 failures.
  • .agents/bin/validate — all 12 CI-core stages passed.
  • git diff --check.

Scope and churn

Two files only: one scalar template correction plus one focused regression spec. No workload, policy, workflow, persistent-template, external-state, or upstream React on Rails changes.

Summary by CodeRabbit

  • Tests
    • Added validation for Control Plane template mappings used by disposable review apps.
    • Confirmed database credential references resolve to the correct shared secret while preserving the expected field mapping.

@github-actions

Copy link
Copy Markdown

🚀 Quick Review App Commands

Welcome! Here are the commands you can use in this PR:
They require the repository to have cpflow review apps configured, including the CPLN_TOKEN_STAGING secret.

+review-app-deploy

Deploy your PR branch for testing.

+review-app-delete

Remove the review app when done.

+review-app-help

Show detailed instructions, environment setup, and configuration options.

Comment +review-app-help for full setup details.

@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

Adds an RSpec test that loads Control Plane configuration and template YAML, identifies the disposable review app’s shared secret and database credential mapping, then validates the secret reference before and after placeholder substitution.

Changes

Database secret mapping

Layer / File(s) Summary
Resolve review app shared secret
spec/controlplane/template_mapping_spec.rb
Loads repository YAML, selects the disposable review app, verifies its single shared-secret grant, and builds its placeholder.
Validate rendered database mapping
spec/controlplane/template_mapping_spec.rb
Selects the database password mapping, parses its Acpln://secret/... reference, substitutes the grant secret name, and verifies the dictionary and field.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: fixing the disposable review app's shared-grant mapping.
Description check ✅ Passed The description covers the why, implementation, validation, and scope, though it doesn't use the repo's exact template headings.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch jg-codex/fix-review-app-shared-grant-mapping

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@justin808

Copy link
Copy Markdown
Member Author

Address-review summary

Scan scope: full PR history; no earlier address-review checkpoint existed.

Mattered

  • None. Independent maker-distinct adversarial review found no BLOCKING, DISCUSS, or FOLLOWUP items at the exact current head.

Skipped

Verification checkpoint: base-fail/head-pass reproduced independently; full repository validation passed; CI readiness is READY; viewer review inventory pagination is complete with no pending drafts; review-thread pagination is complete with zero unresolved threads.

Next default scan starts after this comment. Say check all reviews to rescan the full PR.

@justin808
justin808 marked this pull request as ready for review July 18, 2026 14:17

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (1)
spec/controlplane/template_mapping_spec.rb (1)

41-44: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Utilize direct RSpec matchers for better failure messages.

Evaluating a boolean expression and then expecting true using be(true) obscures RSpec's built-in diffing capabilities on failure (e.g., outputting expected true, got false instead of providing a detailed string or number comparison diff). Use direct matchers like eq and be_nil to improve test failure observability.

  • spec/controlplane/template_mapping_spec.rb#L41-L44: Replace the boolean assignment and expect(mapping_matches_grant).to be(true) with expect(review_database_reference).to eq(shared_grant_target).
  • spec/controlplane/template_mapping_spec.rb#L15-L15: Replace expect(matches.length == 1).to be(true) with expect(matches.length).to eq(1).
  • spec/controlplane/template_mapping_spec.rb#L22-L22: Replace expect(grants.length == 1).to be(true) with expect(grants.length).to eq(1).
  • spec/controlplane/template_mapping_spec.rb#L33-L33: Replace expect(mappings.length == 1).to be(true) with expect(mappings.length).to eq(1).
  • spec/controlplane/template_mapping_spec.rb#L36-L36: Replace expect(!match.nil?).to be(true) with expect(match).not_to be_nil.
♻️ Proposed RSpec refactors
-    expect(matches.length == 1).to be(true), "expected exactly one disposable review app configuration"
+    expect(matches.length).to eq(1), "expected exactly one disposable review app configuration"
-    expect(grants.length == 1).to be(true), "expected exactly one disposable review app shared grant"
+    expect(grants.length).to eq(1), "expected exactly one disposable review app shared grant"
-    expect(mappings.length == 1).to be(true), "expected exactly one disposable database credential mapping"
+    expect(mappings.length).to eq(1), "expected exactly one disposable database credential mapping"
-    expect(!match.nil?).to be(true), "expected a repository-managed credential reference"
+    expect(match).not_to be_nil, "expected a repository-managed credential reference"
-    mapping_matches_grant = review_database_reference == shared_grant_target
-
-    expect(mapping_matches_grant).to be(true),
-                                     "disposable database credential must match its declared shared grant target"
+    expect(review_database_reference).to eq(shared_grant_target),
+                                         "disposable database credential must match its declared shared grant target"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@spec/controlplane/template_mapping_spec.rb` around lines 41 - 44, Replace
indirect boolean assertions with direct RSpec matchers in
spec/controlplane/template_mapping_spec.rb:15, 22, 33, and 36, asserting each
collection length with eq(1) and match presence with not_to be_nil; at
spec/controlplane/template_mapping_spec.rb:41-44, remove mapping_matches_grant
and directly compare review_database_reference to shared_grant_target with eq.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@spec/controlplane/template_mapping_spec.rb`:
- Around line 41-44: Replace indirect boolean assertions with direct RSpec
matchers in spec/controlplane/template_mapping_spec.rb:15, 22, 33, and 36,
asserting each collection length with eq(1) and match presence with not_to
be_nil; at spec/controlplane/template_mapping_spec.rb:41-44, remove
mapping_matches_grant and directly compare review_database_reference to
shared_grant_target with eq.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 46824044-ee8a-4a1b-863b-720c1a23a386

📥 Commits

Reviewing files that changed from the base of the PR and between 2d409e8 and 560e851.

📒 Files selected for processing (2)
  • .controlplane/templates/app-review.yml
  • spec/controlplane/template_mapping_spec.rb

@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: 560e851872

ℹ️ 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 .controlplane/templates/app-review.yml Outdated
@justin808

Copy link
Copy Markdown
Member Author

Address-review summary

Scan scope: since previous summary at 2026-07-18T14:17:28Z.

Mattered

  • Must-Fix: restored the terminal dictionary-field selector while preserving the configured shared-grant target in 94db28a. The regression spec now validates both target alignment and selector derivation. Source thread; reply.
  • Verification: bundle exec rspec spec/controlplane (3 examples, 0 failures), focused RuboCop, and .agents/bin/validate passed at the exact head below.

Skipped

  • Two late COMMENTED review summaries duplicated status for the handled finding; no separate action was required.

Deferred-work tracking: none.

Next default scan starts after this comment. Say check all reviews to rescan the full PR.

@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: 94db28a8dc

ℹ️ 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 .controlplane/templates/app-review.yml Outdated

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (1)
spec/controlplane/template_mapping_spec.rb (1)

58-64: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use idiomatic RSpec matchers instead of evaluating booleans.

Evaluating expressions to a boolean before passing them to expect(...).to be(true) obscures test failures, as RSpec will only output expected true, got false instead of the actual and expected values. Use idiomatic RSpec matchers (e.g., eq, be_nil) to retain meaningful diffs in failure messages.

  • spec/controlplane/template_mapping_spec.rb#L58-L64: compare rendered_reference values directly against the expected values using eq instead of creating intermediate booleans.
  • spec/controlplane/template_mapping_spec.rb#L22-L22: change to expect(grants.length).to eq(1), ...
  • spec/controlplane/template_mapping_spec.rb#L37-L37: change to expect(mappings.length).to eq(1), ...
  • spec/controlplane/template_mapping_spec.rb#L43-L43: change to expect(match).not_to be_nil, ...
♻️ Proposed refactor for all sites

Lines 22:

-    expect(grants.length == 1).to be(true), "expected exactly one disposable review app shared grant"
+    expect(grants.length).to eq(1), "expected exactly one disposable review app shared grant"

Lines 37:

-    expect(mappings.length == 1).to be(true), "expected exactly one disposable database credential mapping"
+    expect(mappings.length).to eq(1), "expected exactly one disposable database credential mapping"

Lines 43:

-    expect(!match.nil?).to be(true), "expected a repository-managed dictionary-field reference"
+    expect(match).not_to be_nil, "expected a repository-managed dictionary-field reference"

Lines 58-64:

-    mapping_matches_grant = rendered_reference.fetch(:target) == grant.fetch("secret_name")
-    mapping_matches_field = rendered_reference.fetch(:field) == mapping.fetch("name").split("_").last.downcase
-
-    expect(mapping_matches_grant).to be(true),
-                                     "renderer substitution must target the declared shared grant"
-    expect(mapping_matches_field).to be(true),
-                                     "renderer substitution must retain the declared dictionary field"
+    expect(rendered_reference.fetch(:target)).to eq(grant.fetch("secret_name")),
+                                                 "renderer substitution must target the declared shared grant"
+    expect(rendered_reference.fetch(:field)).to eq(mapping.fetch("name").split("_").last.downcase),
+                                                "renderer substitution must retain the declared dictionary field"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@spec/controlplane/template_mapping_spec.rb` around lines 58 - 64, Replace
boolean-based assertions in spec/controlplane/template_mapping_spec.rb:58-64
with direct eq expectations comparing rendered_reference[:target] and
rendered_reference[:field] to their expected values. Also update
spec/controlplane/template_mapping_spec.rb:22 to use eq(1) for grants.length,
line 37 to use eq(1) for mappings.length, and line 43 to use not_to be_nil for
match, preserving each existing failure message.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@spec/controlplane/template_mapping_spec.rb`:
- Around line 58-64: Replace boolean-based assertions in
spec/controlplane/template_mapping_spec.rb:58-64 with direct eq expectations
comparing rendered_reference[:target] and rendered_reference[:field] to their
expected values. Also update spec/controlplane/template_mapping_spec.rb:22 to
use eq(1) for grants.length, line 37 to use eq(1) for mappings.length, and line
43 to use not_to be_nil for match, preserving each existing failure message.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f3af6738-cdc0-407b-a575-bc5c3204290c

📥 Commits

Reviewing files that changed from the base of the PR and between 560e851 and 7158096.

📒 Files selected for processing (1)
  • spec/controlplane/template_mapping_spec.rb

@justin808

Copy link
Copy Markdown
Member Author

Address-review summary

Scan scope: since previous summary at 2026-07-18T14:52:40Z.

Binding: maintainer-selected PORTABLE codex-collaboration@gpt-5.6-sol/xhigh (operator-selected and dispatcher-attested; no fallback).

Mattered

  • P2 portable shared-grant mapping: fixed in 7158096. The committed review-app template now uses {{SHARED_SECRET_DATABASE}}, the regression spec derives that placeholder from the declared grant, and simulated v5.2.0 substitution verifies the configured target while retaining the terminal field selector. Reply/evidence; thread resolved.

Skipped

Validation

  • TDD RED: focused spec exited 1 with 1 expected portability failure.
  • TDD GREEN: focused spec exited 0 with 1 example and 0 failures.
  • Exact-head checks: YAML parse, Ruby syntax, focused RuboCop, focused spec, full spec/controlplane, diff/scope/protected-identifier/persistent-template guards, and .agents/bin/validate all passed; repository validation included 119 RSpec examples and 2 Playwright smoke tests.
  • Current-head GMCC snapshot: 10 checks terminal (8 passed, 2 skipped, 0 pending/failing), independent current-head review present, APPROVED, MERGEABLE, and 0 unresolved review threads.

Review-fix inventory is closed. Merge/deploy remains maintainer-gated for the coordinator's audit and deployed verification; no merge, deployment, or verification PR was attempted here.

Next default scan starts after this comment. Say check all reviews to rescan the full PR.

@justin808
justin808 merged commit 97733de into main Jul 19, 2026
14 checks passed
@justin808
justin808 deleted the jg-codex/fix-review-app-shared-grant-mapping branch July 19, 2026 06:46
@github-actions

github-actions Bot commented Jul 19, 2026

Copy link
Copy Markdown

✅ Review App Deleted

Review app for PR #199 is deleted

🎮 Control Plane Console
📋 View Workflow Logs

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