feat(api): admin agent config read and save (13/15) - #481
ccf-lisa[bot] wants to merge 1 commit into
Conversation
|
Important Review skippedBot user detected. To trigger a single review, invoke the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
Thirteenth layer of the agent remote-configuration stack (split from #465): GET /api/admin/agents/{id}/config returns the current overlay (verbatim only to agent:configure holders, redacted otherwise, fail-closed) with an admin ETag, and GET …/config/revisions/{rev} returns one revision the same way; PUT saves a new revision with If-Match (428 without, 409 on conflict, 200 for a no-op), validating the overlay on its own and against the instances a save validates against (only errors the overlay introduces block; file-origin errors are warnings). Needs agent:configure to write. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
5133f09 to
60616fa
Compare
| // precise 422 rather than by the transport with a 413. agentConfigBodyLimitStr is the | ||
| // same limit for echo's BodyLimit middleware. | ||
| agentConfigBodyLimit = 4 * agentconfig.MaxOverlayBytes | ||
| agentConfigBodyLimitStr = "1M" |
There was a problem hiding this comment.
[Should-fix] CORE-DUP-001 · Logic or literal duplicated where it must stay in sync
agentConfigBodyLimit (4 × 256 KiB) and agentConfigBodyLimitStr = "1M" are the same limit in two forms that must stay equal. The comment says so, but nothing enforces it. readJSONBody(ctx, agentConfigBodyLimit) already returns 413 above the limit, so the extra echomiddleware.BodyLimit on PUT (and later preview/revert) is a second, hand-synced copy.
Why: Copies drift: one gets fixed or changed and the other does not.
Fix: Drop echomiddleware.BodyLimit(agentConfigBodyLimitStr) and rely on readJSONBody, or derive the string with strconv.Itoa(agentConfigBodyLimit) (echo's BodyLimit accepts a plain byte count).
ccf-review · 2d2585c08f9a · rules@6be9e11b8bc6
Part 13/15 of the agent remote-configuration stack
This stack splits #465 into reviewable layers of at most ~1000 changed lines each (counted without
docs/,go.sumand Markdown). The last layer's tree is identical to #465, which already has its review history.Stacked on #480 (
lisa/agent-config/12-agent-config-report). Review and merge in order.What's in this layer
Thirteenth layer of the agent remote-configuration stack (split from #465): GET /api/admin/agents/{id}/config returns the current overlay (verbatim only to agent:configure holders, redacted otherwise, fail-closed) with an admin ETag, and GET …/config/revisions/{rev} returns one revision the same way; PUT saves a new revision with If-Match (428 without, 409 on conflict, 200 for a no-op), validating the overlay on its own and against the instances a save validates against (only errors the overlay introduces block; file-origin errors are warnings). Needs agent:configure to write.
Size: +1180 -0 = 1180 changed lines (without docs/go.sum).
size-exception: over 1000 LOC because of the tests that cover this layer; the implementation part is well under 1000.
Verification
Each layer builds on its own:
go build,go vet(also with-tags integration),golangci-lint runandgo test ./...pass, andmake swagleaves the tree clean. Integration suites for the packages this layer touches pass locally on testcontainers Postgres.🤖 Generated with Claude Code