Skip to content

Report error for task.hash/task.workDir in process script section#159

Open
bentsherman wants to merge 2 commits into
mainfrom
restrict-task-hash-workdir-in-script
Open

Report error for task.hash/task.workDir in process script section#159
bentsherman wants to merge 2 commits into
mainfrom
restrict-task-hash-workdir-in-script

Conversation

@bentsherman

Copy link
Copy Markdown
Member

Summary

The implicit task variable in a process exposes properties such as task.hash and task.workDir that depend on the task hash, which in turn is derived from the process script. Using these properties in the script: (or stub:) section therefore creates a circular dependency.

This PR adds a rule in TypeCheckingVisitorEx that reports a type error for each use of task.hash or task.workDir in the script and stub sections.

Details

  • A new TaskScriptPropertyVisitor inner class walks the script/stub body and flags any PropertyExpression whose property is hash/workDir and whose receiver resolves to TaskConfig (so detection is type-based, not just name-based).
  • The check runs on both script:/shell: (node.exec when node.type != "exec") and stub: (node.stub).
  • The exec: section is exempt, since it does not contribute to the command hash in the same way.

Tests

Added cases to TypeCheckingTest:

  • error reported for task.hash and task.workDir in the script: section
  • error reported for task.hash and task.workDir in the stub: section
  • other task properties (task.cpus, task.process, task.attempt) are still allowed
  • task.hash/task.workDir are allowed in the exec: section

🤖 Generated with Claude Code

bentsherman and others added 2 commits June 30, 2026 17:46
Signed-off-by: Ben Sherman <bentshermann@gmail.com>
The implicit `task` variable exposes properties such as `task.hash` and
`task.workDir` that depend on the task hash, which in turn is derived from
the process script. Using these properties in the `script:` (or `stub:`)
section therefore creates a circular dependency.

Add a rule in TypeCheckingVisitorEx that reports a type error for each use
of `task.hash` or `task.workDir` in the script and stub sections. The
`exec:` section is exempt since it does not contribute to the command hash
in the same way.

Signed-off-by: Ben Sherman <bentshermann@gmail.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

1 participant