Skip to content

Respect static-entitlement precedence during provisioning - #158

Open
pquerna wants to merge 1 commit into
mainfrom
paul.querna/CXP-1454/static-provisioning-precedence
Open

pquerna wants to merge 1 commit into
mainfrom
paul.querna/CXP-1454/static-provisioning-precedence

Conversation

@pquerna

@pquerna pquerna commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Summary

When a resource type declares static_entitlements, sync uses that list instead of dynamic entitlements. Provisioning must use the same precedence.

Previously, a static entitlement without provisioning—or an unknown entitlement while static mode was selected—fell through to the first dynamic mapping's grant/revoke SQL. For example, requesting an unsupported static Viewer entitlement could run an unrelated Admin assignment query and report success.

Stop the lookup after static resolution when static mode is configured, including an explicitly empty static list. Supported static operations and dynamic-only configuration retain their behavior.

Regression proof

TestStaticProvisioningDoesNotFallThrough calls real Entitlements, Grant, and Revoke paths against an in-process SQLite database. Its ten cases cover both operations for unsupported static, unknown static, empty static, supported static, and dynamic-only modes.

Before the fix, six forbidden-fallback cases execute the Admin SQL; four valid controls pass. With the fix, all ten pass. Assertions inspect the Admin and Viewer rows, proving both absence of unwanted mutation and continued execution of valid operations.

go test ./pkg/bsql -run '^TestStaticProvisioningDoesNotFallThrough$' -count=1 -v

Scope

Related: CXP-1454. This fixes the static-to-dynamic fallthrough subcase only. It does not solve selection among multiple dynamic mappings or establish a durable producing-mapping identity.

No exported API, configuration schema, stable ID, dependency, or SQL-execution changes. The rejected calls now fail before SQL rather than executing an unrelated mapping. The README records the static precedence contract.

Proof is local SQLite fixture behavior, not a live database/provider or deployed connector. Native DB2-tagged builds and external database workflows were not exercised.

Checks

Worker full test/build/lint and binary-launch checks passed. Parent reviewed the exact source/tests and integrated this commit independently of the logging fix into the original checkout. Parent make test, make build, make lint (zero issues), and rebuilt CLI --version all passed on that independent branch.

Honor the same static-entitlement precedence as sync. Unsupported, unknown, or explicitly empty static configurations must not execute an unrelated dynamic mapping's grant or revoke SQL. Keep valid static and dynamic-only provisioning unchanged.

Co-authored-by: c1-squire-dev[bot] <c1-squire-dev[bot]@users.noreply.github.com>
@pquerna
pquerna requested a review from a team November 19, 2026 17:54
@linear-code

linear-code Bot commented Nov 19, 2026

Copy link
Copy Markdown

CXP-1454

@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor
Superseded — see the current review report for commit 29cef8602eac

Connector PR Review: Respect static-entitlement precedence during provisioning

Blocking Issues: 0 | Suggestions: 0 | Threads Resolved: 0
Criteria: Criteria status: loaded .claude/skills/ci-review.md from trusted base 4ac5716f73e6.
Review mode: full
View review run

Review Summary

getProvisioningConfig (pkg/bsql/provisioning.go:36-40) now returns "not found" once static resolution fails whenever s.config.StaticEntitlements != nil. Before this change, an unsupported static entitlement, an unknown one, or an empty static list fell through to the first dynamic mapping's grant/revoke SQL. The new nil check is the same one sync uses (entitlements.go:15, sql_syncer.go:169), so an explicit static_entitlements: [] puts the resource type in static mode for both sync and provisioning. The change applies to all three callers: Grant, Revoke, and the grant-replacement revoke at query.go:1141. Rejected requests now return an error before any SQL runs, which is safer than the old success-after-the-wrong-mutation.

The new table test covers grant and revoke across five modes. It asserts the actual row state in SQLite, so it shows both that nothing unwanted is mutated and that valid static and dynamic-only provisioning still works.

I scanned the full PR diff for security and correctness issues.

On criteria: the Provisioning P1-P6 and section F rules don't apply because entity sourcing is unchanged. No breaking changes under B1-B9: no IDs, slugs or schema changed, and none of the examples/*.yml configs pairs static_entitlements with dynamic entitlements in one resource type. Sections A-D and S don't apply because there are no logging, span, JSON or sync-path changes. README documents the new contract.

Operational note, not a finding: a deployed config that has both static entitlements and a dynamic mapping with provisioning will now get an error on Grant/Revoke. Before, it silently ran the dynamic SQL. That is the intended fix and it is stated in the PR.

Security Issues

None found.

Correctness Issues

None found.

Suggestions

None.

@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Connector PR Review: Respect static-entitlement precedence during provisioning

Blocking Issues: 0 | Suggestions: 0 | Threads Resolved: 0
Criteria: Criteria status: loaded .claude/skills/ci-review.md from trusted base 4ac5716f73e6.
Review mode: full
View review run

Review Summary

getProvisioningConfig (pkg/bsql/provisioning.go:36-40) now returns "not found" once static resolution fails whenever s.config.StaticEntitlements != nil. Before this change, an unsupported static entitlement, an unknown one, or an empty static list fell through to the first dynamic mapping's grant/revoke SQL. The new nil check is the same one sync uses (entitlements.go:15, sql_syncer.go:169), so an explicit static_entitlements: [] puts the resource type in static mode for both sync and provisioning. The change applies to all three callers: Grant, Revoke, and the grant-replacement revoke at query.go:1141. Rejected requests now return an error before any SQL runs, which is safer than the old success-after-the-wrong-mutation.

The new table test covers grant and revoke across five modes. It asserts the actual row state in SQLite, so it shows both that nothing unwanted is mutated and that valid static and dynamic-only provisioning still works.

I scanned the full PR diff for security and correctness issues.

On criteria: the Provisioning P1-P6 and section F rules don't apply because entity sourcing is unchanged. No breaking changes under B1-B9: no IDs, slugs or schema changed, and none of the examples/*.yml configs pairs static_entitlements with dynamic entitlements in one resource type. Sections A-D and S don't apply because there are no logging, span, JSON or sync-path changes. README documents the new contract.

Operational note, not a finding: a deployed config that has both static entitlements and a dynamic mapping with provisioning will now get an error on Grant/Revoke. Before, it silently ran the dynamic SQL. That is the intended fix and it is stated in the PR.

Security Issues

None found.

Correctness Issues

None found.

Suggestions

None.


Reviewed commit: 29cef8602eac

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No blocking issues found — see the full review report

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