Skip to content

fix(mcpx): Clamp validates request against the dial's own enum first (#1641) - #2883

Merged
dezren39 merged 1 commit into
mainfrom
queue/4071-1641-clamp-dial-enum
Nov 2, 2026
Merged

dezren39 merged 1 commit into
mainfrom
queue/4071-1641-clamp-dial-enum

Conversation

@dezren39

@dezren39 dezren39 commented Oct 31, 2026 •

Copy link
Copy Markdown
Member

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 own decl.Rank was never consulted. Ceiling-ladder values outside a subset dial's enum passed as valid: prompt.autonomy ({propose, run}) accepted apply/off/advise/ask under the default ceiling, and the invalid-value error listed the ceiling's ladder instead of the dial's values.

Fix

Validate requested against 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 for New-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

  • Regression tests added on the existing subset-dial fixture in clamp_test.go: off/advise/ask/apply now error, name [propose run], and never list the ceiling ladder.
  • go test ./internal/settings/ -run 'TestNewRefusesAClampThatCannotHold|TestACallerCannotRaiseAClampedSetting': PASS (run locally in the task worktree).
  • Full package baseline-compare: clean 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

🤖 Agent note: queue task 4071 (repo-worker-code, openchamber scheduled lane).

…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.
@dezren39
dezren39 requested a review from a team as a code owner October 31, 2026 00:25
@coderabbitai

coderabbitai Bot commented Oct 31, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3726644e-93d3-4efd-a177-ac6f2d551d2f
Commits

Reviewing files that changed from the base of the PR and between b5d334b and 4a1c7c6.

Files selected for processing: 2
  • pkgs/mcpx/internal/settings/clamp.go
  • pkgs/mcpx/internal/settings/clamp_test.go
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-31T00:28:01.440236Z 4a1c7c6 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@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: 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".

Comment on lines +99 to +100
for _, bad := range []string{"off", "advise", "ask", "apply"} {
_, err := view.Clamp("t.dial", bad)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

@dezren39
dezren39 merged commit 08e3c68 into main Nov 2, 2026
10 of 11 checks passed
@dezren39
dezren39 deleted the queue/4071-1641-clamp-dial-enum branch November 2, 2026 16:03
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.

mcpx(settings): Clamp validates a dial request against the ceiling's enum, not the dial's — prompt.autonomy accepts apply/off/advise/ask

1 participant