Skip to content

fix(config): reject rule_based matchers with no values - #409

Merged
zpzjzj merged 1 commit into
alibaba:mainfrom
Walternater:fix/reject-empty-matchers
Nov 18, 2026
Merged

zpzjzj merged 1 commit into
alibaba:mainfrom
Walternater:fix/reject-empty-matchers

Conversation

@Walternater

Copy link
Copy Markdown
Contributor

Summary

skill-up validate accepted a rule_based matcher that names a matcher and gives it nothing to match:

judge:
  type: rule_based
  success:
    - output_contains:
        all: []

validate printed ✓ eval.yaml is valid, and a run then reported a full pass with one expectation and zero checks:

{"text": "output_contains", "passed": true, "evidence": "output satisfies all contains checks ()"}

So a half-filled or template-generated rule silently passed every case. validateRecognizableRules (added for #294) rejects rules that name no matcher at all, but a matcher that is present and empty slips through and the runtime evaluates it as "nothing to check, passed". Unlike an unknown matcher key, this one is not caught by strict YAML decoding because all is a real field.

Related issues

Same class as #294 (unknown matcher names silently dropped) and #365 (zero checks pass). No separate issue opened for this edge; say the word if you would rather track it there.

Changes

  • internal/config/validator.go: new validateNonVacuousRules, run over judge.success and judge.failure next to validateRecognizableRules. It rejects:
    • output_contains with no all/any/not,
    • output_matches with no all/any/not,
    • turn_response_contains with no contains_all/contains_any,
    • turn_response_not_contains with no not_contains.
      The error names the field, e.g. judge.success[0].output_contains must include at least one of all, any, or not.
  • Applies to the eval-level judge and to case-level judges, since both go through validateJudgeTypeAndLocalFields.
  • docs/guide/writing-evals.md and docs/zh/guide/writing-evals.md: one sentence after the output_contains explanation; CHANGELOG.md entry under Fixed.

Test plan

  • Table tests at the eval and case level: each empty matcher is rejected with the field named, and matchers that carry values (not, any, contains_all, not_contains) are still accepted.
  • Negative control: removing the two new validateNonVacuousRules calls turns the five new tests red with exactly those messages; restoring them makes them green.
  • CLI check on the fixture above: main prints ✓ eval.yaml is valid; the branch prints validation failed: ... judge.success[0].output_contains must include at least one of all, any, or not.
  • make test and make verify (0 issues).

Notes

  • Scope is deliberately narrow: a judge that declares no success rules is unchanged; this only rejects matchers that are present but vacuous.
  • Not touched here: tool_called with an empty name fails at runtime instead of passing vacuously, and an unknown report.artifacts entry is a separate gap I found while probing validate.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-14T04:37:52.320166Z 972e52b 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: 972e52bf27

ℹ️ 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 thread internal/config/validator.go Resolved

zpzjzj commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator

Review of 9871920: rejecting "" addresses the earlier finding, but validateNonBlankMatcherValues currently also rejects meaningful whitespace-only matchers through strings.TrimSpace(value) == "". The runtime passes literal values directly to strings.Contains and regex values directly to regexp.MatchString, without trimming. For example, output_contains: {not: ["\n"]} is a valid single-line-output check, and output_matches: {not: [" "]} can reject double spaces; neither is a vacuous matcher, but both now fail config validation. Please reject the actual empty string rather than all whitespace-only strings, and retain coverage showing whitespace checks can distinguish matching from non-matching output. The comment claiming [" "] matches every response should be adjusted as well.

@zpzjzj zpzjzj left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Requesting changes on 9871920: the whitespace-matcher regression remains. validateNonBlankMatcherValues uses TrimSpace, although a newline or two spaces is a meaningful literal/regex matcher, not an empty one. Please reject the actual empty string, preserve valid whitespace-only checks, and add regression coverage. No new runtime test was run in this pass.

@Walternater

Copy link
Copy Markdown
Contributor Author

Fixed in e4074a8. validateNonBlankMatcherValues now rejects value == "" only, so whitespace matchers validate again, and the comment that claimed [" "] matches every response is gone.

I checked the runtime before changing the check, and it confirms your reading: evalOutputContains passes each value to strings.Contains untrimmed (internal/judge/rule_based.go:130, :146, :162) and evalOutputMatches to regexp.MatchString (:259, :273, :287), so not: ["\n"] is a real single-line check and not: [" "] a real double-space check. Only "" is vacuous.

Coverage now shows a whitespace matcher distinguishing matching from non-matching output, at both layers:

  • internal/judge/rule_based_test.go — six cases on the runtime: output_contains: {not: ["\n"]} passes on "one line only" and fails on "first line\nsecond line"; output_contains: {not: [" "]} passes on single-spaced text and fails on "extra space"; output_matches: {not: [" "]} passes on single-spaced text.
  • internal/config/validator_test.go — the old "whitespace-only … is rejected" case is replaced by "whitespace matchers are accepted": not: ["\n"], all: [" ", "\t"], output_matches not: [" ", "\\s{3}"], turn_response_contains.contains_any: ["\n"], turn_response_not_contains.not_contains: [" "]. The "" cases stay, and still assert must not be empty.

Negative control: putting strings.TrimSpace back turns "whitespace matchers are accepted" red and nothing else.

Also updated: the validateNonVacuousRules / validateNonBlankMatcherValues doc comments, both writing-evals.md paragraphs (they now say whitespace is compared as written), and the CHANGELOG line.

CLI: skillup validate accepts output_contains: {not: ["\n"]} and still rejects output_contains: {all: [""]} with judge.success[0].output_contains.all[0] must not be empty. go test ./internal/config ./internal/judge passes; make verify 0 issues.

zpzjzj commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator

Please move this changelog entry to the current Unreleased > Fixed section. Since v0.16.0 was released on November 17, its current position would place it under an already released version after merging. The code looks good; this is the only remaining adjustment.

@Walternater
Walternater force-pushed the fix/reject-empty-matchers branch from e4074a8 to bb8cf69 Compare November 18, 2026 02:16
@Walternater

Copy link
Copy Markdown
Contributor Author

Moved it in bb8cf69.

git rebase origin/main onto the current main (which has ## [0.16.0] - 2026-11-17), so the hunk no longer applies at a line that sits under the released heading: the entry now starts the ## [Unreleased] > ### Fixed list, above the "Use prompt-file delivery..." entry. The rest of the branch is unchanged.

GOPROXY=… go test ./internal/config ./internal/judge passes and make verify reports 0 issues.

zpzjzj commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator

Please move this changelog entry to Unreleased > Fixed for the next release. Its current position would place it under v0.16.0, which has already been released.

@Walternater
Walternater force-pushed the fix/reject-empty-matchers branch from bb8cf69 to 1b86c02 Compare November 18, 2026 08:19
@Walternater

Copy link
Copy Markdown
Contributor Author

You were right, and my previous bb8cf69 did not actually contain the move — thanks for the nudge.

I had edited CHANGELOG.md in the working tree and then squashed with git reset --soft, which commits the index, not the working tree, so the committed file still had the entry under ## [0.16.0]. The verify run and the local grep both looked at the working tree, so they agreed with the wrong state.

1b86c02 has the entry at the top of ## [Unreleased] > ### Fixed; git show HEAD:CHANGELOG.md (and the file at that ref) now show it above the "Use prompt-file delivery..." entry, and the 0.16.0 section is untouched. Same tests and make verify as before, CI is running on the new head.

@zpzjzj zpzjzj left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@zpzjzj
zpzjzj added this pull request to the merge queue Nov 18, 2026
Merged via the queue into alibaba:main with commit 502750d Nov 18, 2026
19 checks passed
hobostay added a commit to hobostay/skill-up that referenced this pull request Nov 20, 2026
alibaba#409 landed the empty output/turn-response matcher checks, so this change
keeps the remaining gaps and addresses the review on the path grammar:

- tool_called requires a non-whitespace tool name; an empty name never
  matches an invocation, so a success rule failed silently and a failure
  rule became a no-op.
- files_exist/files_not_exist reject the workspace root (".", "/", "\",
  ".\"); the root always exists, so files_exist passed without checking
  anything and files_not_exist failed for the wrong reason.
- Both judge rule_based checks and expect checks share one host-independent
  path grammar (both "/" and "\" are separators), and validateExpect now
  rejects root aliases too, so validation and execution agree.
- post_condition must_contain_any/all/must_not_contain reject the empty
  entry, which is a substring of every response; whitespace matchers stay
  valid.

Tests cover the shared grammar, root aliases in both file directions,
tool_called names, expect alignment, and post_condition entries.

Co-Authored-By: Claude Code <[email protected]>
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.

2 participants