Repository navigation
Restrict time.clock_gettime and clock_gettime_ns in the workflow sandbox - #2055
Open
Jackmeson1 wants to merge 1 commit into
Open
Jackmeson1 wants to merge 1 commit into
Jackmeson1 wants to merge 1 commit into
Conversation
The runtime-only restrictions on the time module block time(), monotonic(), perf_counter(), process_time() and the other clock readers, but not clock_gettime() or clock_gettime_ns(), so workflow code could read the clocks through them without the sandbox raising. Add both to the restricted set. Calls while the workflow module is imported stay allowed, as for the other time entries. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019TTGAv6fe859ebbCLLfLHP Signed-off-by: Jackmeson1 <130693642+Jackmeson1@users.noreply.github.com>
This branch has not been deployed
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 was changed
Adds
clock_gettimeandclock_gettime_nsto the default workflow sandbox's runtime-onlytimerestrictions. Calling either through the sandbox now raisesRestrictedWorkflowAccessError; importing or referencing them and calling them during workflow-module import remain allowed.Why?
The existing restrictions block clock readers such as
time,monotonicandprocess_time, but omit these two functions. On 01af1f6, both can readCLOCK_REALTIMEfrom a sandboxed workflow without raising.This tightens the default restrictions: with default failure handling, an uncaught violation fails the workflow task. Only these two names are added; argument-dependent time functions remain outside this change. The sandbox remains best effort, as documented in the README. No replay divergence was reproduced.
Checklist
Related: none. This is a narrow fix to the sandbox restriction list.
How was this tested:
Outside-sandbox validation on Linux x86_64 (Colab), using the Rust bridge built from this checkout and pytest 9.1.1:
time,monotonic,clock_gettimeandclock_gettime_ns. Each call succeeds before the runtime transition and then must raiseRestrictedWorkflowAccessErrorwith the expected qualified name. Missing functions are skipped.CLOCK_REALTIMEcalls, guarded by platform availability. Its workflow converts restriction errors toApplicationErrorso the test can assert the resulting workflow failure.DID NOT RAISE RestrictedWorkflowAccessError, and the worker test fails withDID NOT RAISE WorkflowFailureError; the two existing-clock controls pass. Adding only one name leaves two failures.pytest tests/worker/workflow_sandbox: 35 passed, 1 skipped on 01af1f6; 39 passed, 1 skipped with the fix on Python 3.13.16 and 3.14.8; 40 passed on 3.10.22. I also ran time-skipping V2 on 3.13.16: 39 passed, 1 skipped.pytest -n 4 --dist=worksteal, on Python 3.13.16: 1549 passed, 5 skipped on 01af1f6; 1553 passed, 5 skipped with the fix. The saved JUnit reports show four added cases and no changed statuses among existing tests.poe lint, which passed with ruff 0.15.22, pyright 1.1.403, mypy 1.18.2, basedpyright 1.34.0 and pydocstyle 6.3.0.Any docs updates needed?
Added
changelog/breaking-changes/punctual-platypus.md. The README documents the general restriction behavior and best-effort limitation.AI disclosure: this was prepared with AI assistance (Claude Opus 5.5).
🤖 Generated with Claude Code