Grader: file-exists
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-exists config: path: "add.test.js"| Field | Type | Required | Description |
|---|---|---|---|
path | string | Yes | File path or glob pattern to match in the workspace |
negate | boolean | No | When true, passes when NO files match |
Negated variant
Section titled “Negated variant”Use file-not-exists as a shorthand for negate: true:
graders: - type: file-not-exists config: path: "*.tmp"This is equivalent to type: file-exists with negate: true.
Behavior
Section titled “Behavior”Uses Node.js glob() to search the trajectory’s workDir for files matching the pattern.
Passes when at least one file matches (or NO files match if negated). Fails otherwise.
Supports standard glob patterns:
"add.test.js"— exact file"*.test.js"— all test files"src/**/*.ts"— recursive TypeScript files"output/*.{json,txt}"— multiple extensions
Evidence examples
Section titled “Evidence examples”✔ Files matching 'add.test.js' found: add.test.js✔ Files matching '*.test.js' found: add.test.js, utils.test.js✘ No files matching 'add.test.js' foundSource
Section titled “Source”async grade(input: GraderInput): Promise<GraderResult> { await assertWorkDirAccessible(input.trajectory.workDir);
const matchIter = glob(input.config.path, { withFileTypes: false, cwd: input.trajectory.workDir, });
const matches = []; for await (const item of matchIter) { matches.push(item); }
const passed = matches.length > 0;
return { name: this.metadata.name, kind: "code", passed, score: passed ? 1 : 0, evidence: passed ? `Files matching '${input.config.path}' found: ${matches.join(", ")}` : `No files matching '${input.config.path}' found`, label: passed ? "correct" : "incorrect", };}