Skip to content

fix(validate): catch workspace setup_error causes at validate-time#1087

Merged
christso merged 4 commits intomainfrom
fix/1078-validate-workspace-paths
Apr 13, 2026
Merged

fix(validate): catch workspace setup_error causes at validate-time#1087
christso merged 4 commits intomainfrom
fix/1078-validate-workspace-paths

Conversation

@christso
Copy link
Copy Markdown
Collaborator

Closes #1078

Problem

agentv validate passed eval files that would fail at runtime with setup_error when workspace hook scripts or template paths didn't exist. These errors are detectable statically.

Changes

New validateWorkspacePaths() function in packages/core/src/evaluation/validation/workspace-path-validator.ts. Called alongside validateFileReferences for all eval files.

What it catches

1. Hook script paths — command args that look like relative file paths (./, ../, or script extensions: .mjs, .js, .ts, .sh, .py, etc.) are resolved using the same cwd precedence as the runtime:

hook.cwd ?? workspaceFileDir ?? evalDir

If the resolved path doesn't exist → error.

2. workspace.template — the template path is resolved and checked for existence.

Both checks apply to inline workspace: objects and to paths inside external workspace files (workspace: "path.yaml").

What it doesn't flag

  • System binaries (node, bash, etc.) — no path separator or script extension
  • String arguments without script extensions (-c, echo hello, etc.)

Red/Green UAT

RED — hook script missing:

$ agentv validate bad-hook.eval.yaml

Validation Summary
✗ bad-hook.eval.yaml
  ✗ [workspace.hooks.before_all.command] Hook script not found: ../../scripts/eval-config/setup.mjs (resolved to /scripts/eval-config/setup.mjs)

RED — template missing:

$ agentv validate bad-template.eval.yaml

Validation Summary
✗ bad-template.eval.yaml
  ✗ [workspace.template] Template path not found: ./nonexistent-template (resolved to /tmp/agentv-test-uat/nonexistent-template)

GREEN — valid eval, no workspace:

$ agentv validate good.eval.yaml

Validation Summary
✓ good.eval.yaml
Total files: 1  Valid: 1  Invalid: 0

Tests

10 new unit tests covering all cases: no workspace, valid/missing workspace file ref, valid/missing template, valid/missing hook script, system binary (not flagged), hook cwd resolution, external workspace file hooks.

🤖 Generated with Claude Code

christso and others added 2 commits April 13, 2026 21:36
Adds validateWorkspacePaths() to detect two classes of errors that
surface as setup_error at runtime but are statically checkable:

1. workspace.hooks.*.command — script arguments that look like relative
   file paths (./foo, ../bar/setup.mjs) are resolved using the same cwd
   precedence as the runtime (hook.cwd ?? workspaceFileDir ?? evalDir)
   and checked for existence.

2. workspace.template — the template path is resolved and checked.

Both checks apply to inline workspace configs and to paths inside
external workspace files (workspace: "path.yaml"). The external file
existence case is already caught by eval-validator; the new validator
focuses on the internal hook script paths and template that were
previously only caught at runtime.

Closes #1078

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Apr 13, 2026

Deploying agentv with  Cloudflare Pages  Cloudflare Pages

Latest commit: d239a1f
Status: ✅  Deploy successful!
Preview URL: https://dbe1a131.agentv.pages.dev
Branch Preview URL: https://fix-1078-validate-workspace.agentv.pages.dev

View logs

christso and others added 2 commits April 13, 2026 21:43
- Combine duplicate node:fs/promises imports into one
- Fix JSDoc: "two classes" now correctly lists two, clarify external file note
- Remove redundant workspace string existence check (eval-validator owns it)
- Add command arg index to error location: command[1] instead of command
- Add .bash and .zsh to script extension heuristic
- Add tests for: after_each/after_all hooks, script alias, external workspace template

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@christso christso marked this pull request as ready for review April 13, 2026 21:45
@christso
Copy link
Copy Markdown
Collaborator Author

Post-review fixes applied

Addressed code review findings:

  • Combined duplicate imports from node:fs/promises into one line
  • Fixed JSDoc — changed "two classes, listed three" to correctly list two items, and added a note that external file existence is owned by eval-validator
  • Removed redundant existence check for workspace string references — eval-validator.ts already catches this and emits an error that gates the extra validation from running at all. My validator now silently skips when it can't read the file (eval-validator will have already reported the error)
  • Added arg index to error locationworkspace.hooks.before_all.command[1] instead of workspace.hooks.before_all.command, matching the convention used by file-reference-validator
  • Added .bash and .zsh extensions to looksLikeFilePath heuristic
  • Added test coverage for: after_each/after_all hook names, deprecated script alias, template path inside external workspace file

Regarding the hook.cwd resolution concern: The reviewer suggested the runtime resolves hook.cwd against process.cwd(), but this is incorrect — yaml-parser.ts:parseWorkspaceScriptConfig pre-resolves relative cwd values against the eval file directory (or workspace file directory for external files) at parse time, which is exactly what this validator does. Resolution is correct.

@christso christso merged commit fb360c9 into main Apr 13, 2026
4 checks passed
@christso christso deleted the fix/1078-validate-workspace-paths branch April 13, 2026 22:42
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.

validate: detect workspace setup errors that cause runtime setup_error failures

1 participant