Skip to content

refactor(core): replace update helpers with CRUD verbs - #2859

Open
codyhartsook wants to merge 1 commit into
kagent-dev:mainfrom
codyhartsook:codyhartsook/scoped-authorization-followup
Open

codyhartsook wants to merge 1 commit into
kagent-dev:mainfrom
codyhartsook:codyhartsook/scoped-authorization-followup

Conversation

@codyhartsook

@codyhartsook codyhartsook commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #2710 and its request to remove Kubernetes helpers named after database transaction concepts.

  • Replace GetForUpdate and SaveUpdate with Get and Update.
  • Make kubecrud.Update authorize the namespace and name it is about to write.
  • Keep ModelConfig-owned Secret coordination in model.Service, but authorize update before the first side effect.
  • Correct EP-1270 to describe the actual per-operation authorization order.

Authorization behavior

AgentTemplate uses a plain read-modify-write sequence: Get authorizes and reads, then Update authorizes and writes.

ModelConfig preauthorizes update from the request reference, then performs its separately authorized read before writing owned Secrets and retrying the ModelConfig write. A denied update therefore writes neither the API key Secret nor the ModelConfig.

Reads and deletes still authorize before reading, so their denial does not reveal whether the resource exists.

Scope

The unrelated matcher hardening and Testify-only test rewrite are intentionally excluded, keeping this follow-up atomic.

Testing

  • make -C go lint — 0 issues
  • (cd go && go test -short ./...) — pass

@github-actions github-actions Bot added the enhancement-proposal Indicates that this PR is for an enhancement proposal label Sep 17, 2026
@codyhartsook
codyhartsook force-pushed the codyhartsook/scoped-authorization-followup branch from f302003 to 8a0b85c Compare September 17, 2026 17:55
GetForUpdate implied locking that never happened, while SaveUpdate relied on every caller pairing it with an earlier authorization check. Replace them with the canonical Get and Update operations, with Update authorizing the object identity it writes.

ModelConfig keeps its owned-Secret workflow local and preauthorizes update before any side effect, then performs the separately authorized read. Document the operation ordering and cover denied writes without retaining the unrelated matcher and Testify churn.

Signed-off-by: Cody Hartsook <[email protected]>
@codyhartsook
codyhartsook force-pushed the codyhartsook/scoped-authorization-followup branch from 8a0b85c to 565c21c Compare September 17, 2026 18:23
@codyhartsook codyhartsook changed the title refactor(core): replace GetForUpdate with plain Kubernetes read-modify-write refactor(core): replace update helpers with CRUD verbs Sep 17, 2026
@codyhartsook
codyhartsook marked this pull request as ready for review September 17, 2026 18:44
@codyhartsook
codyhartsook requested a review from a team as a code owner September 17, 2026 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement-proposal Indicates that this PR is for an enhancement proposal

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant