Repository navigation
fix(mcpx): Clamp validates request against the dial's own enum first (#1641) - #2883
Conversation
…1641) Set.Clamp ranked the requested value only in the ceiling's enum, so ceiling-ladder values outside a subset dial's enum passed as valid (prompt.autonomy accepted apply/off/advise/ask) and the invalid-value error listed the ceiling's values. Validate against the dial's own enum first, keeping the ceiling ranking for the lowering comparison. Pinned lowering preserved; regression tests added on the subset-dial fixture.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 46 minutes. View limit details
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 |
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4a1c7c63a5
ℹ️ 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".
| for _, bad := range []string{"off", "advise", "ask", "apply"} { | ||
| _, err := view.Clamp("t.dial", bad) |
There was a problem hiding this comment.
Add the required registry-wide clamp validation guard
The regression test checks only the synthetic t.dial and four hard-coded inputs, leaving current and future registered clamped settings outside the guard. This is a class-wide enum-validation fix, and pkgs/mcpx/internal/AGENTS.md explicitly requires registry/table iteration covering every member. Add a guard that iterates registered settings with ClampedBy, derives each ceiling's values absent from the dial's enum, and asserts that those requests are rejected; retain the focused fixture test for its error-message assertions.
AGENTS.md reference: pkgs/mcpx/internal/AGENTS.md:L11-L12
Useful? React with 👍 / 👎.
Fixes #1641.
Problem
Set.Clamp(pkgs/mcpx/internal/settings/clamp.go) ranked the requested value only in the ceiling's enum (cdecl.Rank) — the dial's owndecl.Rankwas never consulted. Ceiling-ladder values outside a subset dial's enum passed as valid:prompt.autonomy({propose, run}) acceptedapply/off/advise/askunder the default ceiling, and the invalid-value error listed the ceiling's ladder instead of the dial's values.Fix
Validate
requestedagainst the dial's own enum first (error names the dial's values), then rank in the ceiling for the lowering comparison. The ceiling check stays as a defensive backstop (unreachable forNew-validated schemas, where the dial enum must be an ordered subset of the ceiling enum).Pinned lowering is preserved: a request above the ceiling still lowers to the ceiling value, including a ceiling below the dial's whole range.
Tests
clamp_test.go:off/advise/ask/applynow error, name[propose run], and never list the ceiling ladder.go test ./internal/settings/ -run 'TestNewRefusesAClampThatCannotHold|TestACallerCannotRaiseAClampedSetting': PASS (run locally in the task worktree).origin/main(b5d334b0) fails the same 5 tests before and after this change (TestEveryDocumentHasAChapter,TestNoUndeclaredEnvRead,TestEverySettingHasAnEffectProbeOrAnExemption,TestTheScriptEnvironmentIsWhatTheCodeSets,TestTheEnvironmentDocIsCurrent— the pre-existing mcpx: internal/settings tests red on clean main — TESTING.md missing from compendium manifest, model.* settings lack effect probes, env doc drift #2846 reds). No new failures; no clamp test fails.Scope notes
promptAutonomy(routes_consumer.go) pre-validates to propose/run before callingClamp, so its behavior is unchanged.🤖 Agent note: queue task 4071 (repo-worker-code, openchamber scheduled lane).