feat(criteria): pass_context for run_command + node_modules/.bin PATH hardening#35
Open
uipreliga wants to merge 1 commit into
Open
feat(criteria): pass_context for run_command + node_modules/.bin PATH hardening#35uipreliga wants to merge 1 commit into
uipreliga wants to merge 1 commit into
Conversation
Opt-in pass_context: true on the run_command criterion serializes the in-flight EvaluationResult (task.json schema) to a temp file and points the scoring command at it via $CODER_EVAL_CONTEXT, giving scoring scripts the agent trajectory and resolved config — not just the filesystem. Script authors can develop offline against a task.json from a previous run, then wire the same script in unchanged. Implementation: - New extra_env passthrough on Sandbox.run_command (last-wins), guarded so it cannot clobber the sandbox-isolation floor (PATH / VIRTUAL_ENV / NODE_PATH / NPM_CONFIG_PREFIX). Also corrects the stale Raises: TimeoutExpired docstring (run_command returns (-1,"",msg)). - pass_context threads Orchestrator -> SuccessChecker -> CheckContext (new run_result field) -> RunCommandChecker; _check_impl's signature is unchanged (state rides on CheckContext). _serialize_context clears success_criteria_results via a non-mutating model_copy so scripts can't depend on list position or leak prior-turn verdicts; the temp dir is deleted on every exit path incl. the timeout return. Missing run_result fails closed to score=0.0. - Security: node_modules/.bin (agent-writable) is now APPENDED, not prepended, to PATH so a planted interpreter shim (python/node/sh/uv) cannot hijack scoring commands. Docs (TASK_DEFINITION_GUIDE + CLAUDE.md) updated; criterion count stays 14. Full suite green, 90.91% coverage. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
uipreliga
requested review from
akshaylive,
bai-uipath and
tmatup
as code owners
July 22, 2026 00:22
|
I'll analyze this and get back to you. |
|
|
||
| if TYPE_CHECKING: | ||
| from coder_eval.models.results import TurnRecord | ||
| from coder_eval.models.results import EvaluationResult, TurnRecord |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

What
Adds an opt-in
pass_context: trueto therun_commandsuccess criterion. When set, the criterion serializes the in-flightEvaluationResult(thetask.jsonschema) to a temp file and points the scoring command at it via$CODER_EVAL_CONTEXT— giving scoring scripts the agent trajectory and the resolved task config, not just the sandbox filesystem.The decisive payoff: script authors can develop offline against a real
task.jsonfrom a previous run (zero agent runs, zero API cost), then wire the same script in unchanged.How
extra_envonSandbox.run_command— additional env vars layered last-wins onto the built environment, guarded so it cannot clobber the sandbox-isolation floor (PATH/VIRTUAL_ENV/NODE_PATH/NPM_CONFIG_PREFIX). Also corrects a staleRaises: subprocess.TimeoutExpireddocstring (the method returns(-1, "", msg)on timeout).Orchestrator→SuccessChecker→CheckContext.run_result→RunCommandChecker._check_impl's signature is unchanged; the new state rides onCheckContext._serialize_contextforce-clearssuccess_criteria_resultsvia a non-mutatingmodel_copy, so scripts can't depend on their position in the YAML or leak prior-turn verdicts (simulationevery_turnmode). The temp dir is deleted on every exit path including the timeout return, and a missingrun_resultfails closed toscore=0.0.node_modules/.bin(agent-writable) is now appended, not prepended, toPATH, so an agent that plants an interpreter shim (python/node/sh/uv) there can no longer hijack a scoring command's interpreter.Notes
tsc) present in bothnode_modules/.binand on the host/venvPATHnow resolves to the host binary instead of the sandbox-local one. A suite-wide spike found zero tasks undertasks/that depend on this ordering.experiments/default.yaml, ormodels/__init__.pychanges (pass_contextis a criterion field, not a merge root).docs/TASK_DEFINITION_GUIDE.md(field-table row + worked example + thesuccess_criteria_results-always-empty / provisional-fields rules) andCLAUDE.md.Testing
extra="forbid"parity, checker-tier (env injection, payload round-trip, emptysuccess_criteria_results, non-mutation, fail-closed, timeout cleanup), end-to-end integration through a real tempdirSandbox, and sandbox security (interpreter-shim exploit regression + package-local-CLI compatibility + PATH ordering +extra_envprotected-key guard).make verifyclean (format / check / pyright / pytest / custom CExxx lint).🤖 Generated with Claude Code