Skip to content

fix(judge): fail closed when an evaluation has no project scope - #1569

Open
Naveen Chatlapalli (1aifanatic) wants to merge 1 commit into
microsoft:mainfrom
1aifanatic:fix/1303-fail-closed-project-scope
Open

Naveen Chatlapalli (1aifanatic) wants to merge 1 commit into
microsoft:mainfrom
1aifanatic:fix/1303-fail-closed-project-scope

Conversation

@1aifanatic

Copy link
Copy Markdown

Fixes #1303.

The coder queue processor already fails fast on a request with no projectId. This PR covers the two remaining fail-open paths from the issue:

  • Judge. With the REST criteria provider (CRITERIA_API_URL set), an evaluation without projectId fell back to the global criteria provider and could silently score a run against the wrong criteria. POST /api/v1/evaluate now returns 400 when projectId is missing or not a non-empty string. evaluateWorkspace also throws before consulting any provider, as defense in depth for in-process callers. The single-tenant filesystem provider ignores projectId, so it stays optional in local dev.
  • Report generator. A report with no projectId now fails with an explicit error instead of fetching /report-templates/<id>?projectId=undefined and reporting a confusing "template not found".

RequestDocument.projectId is already non-optional in the shared types.

Documented in docs/architecture/criteria-provider.md under Project scoping.

Validation: pnpm exec vitest run apps/judge/src/judge-agent.test.ts apps/workers/report-generator/src/report-queue-processor.test.ts (21 passed, 4 new); tsc --noEmit for judge and report-generator; git diff --check.

🤖 Generated with Claude Code

The judge resolved criteria against the global scope when a run arrived
without a projectId, silently evaluating against the wrong criteria. In
REST mode the evaluate endpoint now returns 400 and evaluateWorkspace
throws before touching a provider. The report-generator also fails a
report with no projectId instead of fetching a template from project
"undefined".

Fixes microsoft#1303.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

Harden worker/judge project-scope: fail-closed instead of resolving against "undefined"/global

1 participant