Grader: file-matches
Taxonomy
Section titled “Taxonomy”| Property | Value |
|---|---|
| Determinism | static |
| Cost | low |
| Portability | t1-universal |
| Reference | reference-free |
| Temporal scope | trajectory-level |
| Score kind | code |
Config
Section titled “Config”graders: - type: file-matches config: path: "**/Program.cs" pattern: "static\\s+\\w+\\s+Add\\("| Field | Type | Required | Description |
|---|---|---|---|
path | string | Yes | Glob pattern to select files in the workspace |
pattern | string | Yes | JavaScript regex pattern to match against file content |
negate | boolean | No | When true, passes when the pattern does NOT match any file |
Negated variant
Section titled “Negated variant”Use file-not-matches as a shorthand for negate: true:
graders: - type: file-not-matches config: path: "**/Program.cs" pattern: "null!"This is equivalent to type: file-matches with negate: true.
Behavior
Section titled “Behavior”- Finds files matching
pathin the workspace using glob - Validates the regex pattern (fails immediately if invalid)
- Reads each matching file as UTF-8
- Tests file content against the regex
Passes when the pattern matches at least one file’s content (or NO files match if negated). Fails otherwise.
Regex flags
Section titled “Regex flags”Use the (?flags) prefix syntax for inline regex flags:
(?i)pattern— case-insensitive(?m)pattern— multiline (^/$match line start/end)(?s)pattern— dotAll (.matches newlines)
graders: - type: file-matches config: path: "**/*.cs" pattern: "(?i)public static void main"Unreadable files
Section titled “Unreadable files”If a matching file can’t be read (EACCES, EISDIR, etc.), it is skipped and noted in the evidence string. This handles agent workspaces that may contain build artifacts or directories matching a broad glob. Binary files are NOT skipped — readFile("utf-8") returns mojibake for binary content, which simply won’t match most patterns.
Evidence examples
Section titled “Evidence examples”✔ Pattern /static\s+Add/ matched in Program.cs✘ Pattern /static\s+Add/ not found in any file matching '**/Program.cs'✘ No files matching '**/Program.cs' found✘ Invalid regex pattern: [bad. Error: Unterminated character class✔ Pattern /Add/ matched in b.cs (skipped 1 unreadable file: obj/Debug/app.dll)