Skip to content
This repository was archived by the owner on Nov 15, 2026. It is now read-only.

fix: contain scripts, journal write rollback, hold bound targets, close test gaps (SIM-06) - #34

Merged
gavinying merged 3 commits into
v2from
sim-06-batch-2
Nov 12, 2026
Merged

gavinying merged 3 commits into
v2from
sim-06-batch-2

Conversation

@gavinying

Copy link
Copy Markdown
Collaborator

Second batch of SIM-06.

  • Script paths. A script: of ../x.py, an absolute path or a symlink resolved outside the deployment root and was executed with --allow-scripts. Scripts must now stay inside the deployment root; model and data paths stay unrestricted because they are read, not executed. The --script command-line option is unchanged.
  • Write rollback. Every Modbus write deep-copied all cells of the device to be able to roll back. A journal now records the previous raw value of only the cells the write, its on_write hook and its bindings change, and a rejected write restores them in place (the cells dict keeps its identity). Test: a hook that changes another property and then refuses the write.
  • Bindings under hold. A binding re-applied after every write and tick, silently dropping a client write to a bound target while reporting success. Under writePolicy: hold a client-written target is now left alone, as hold already does for generators (documented in model-validation.md); under overwrite it follows its source again. This stays a modsim runtime behavior; no rule was added to the modpoll-wot simulation-data schema.
  • Tests. Failed writes assert ILLEGAL_VALUE instead of any non-None; the seed test now fails if the seed is ignored (a different seed must give a different sequence); the encoder rejects wrong types without touching the register; asynchronous hooks are rejected at load and at call time; the --comm serial path is covered with a stubbed server; test_root_adam_deployment skips when examples/models is not fetched.

Note on one commit: the first commit also carries the new seed test and the skip guard, because they live in tests/test_deployment.py with the script-path test.

Verification: uv run pytest 130 passed / 3 skipped, uv run mypy and black 24.4.2 clean. The script-path, journal and binding tests fail without their fixes.

🤖 Generated with Claude Code

gavinying and others added 3 commits November 12, 2026 15:12
A script path of ../x.py, an absolute path or a symlink resolved outside the
deployment root and was executed with --allow-scripts. model and data paths
stay unrestricted; they are read, not executed.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…en bound target (SIM-06)

A Modbus write deep-copied every cell of the device (about 3 ms for 8000 cells)
to be able to roll back. It now records the previous raw value of only the cells
the write, its on_write hook and its bindings change, and restores them in
place. Under writePolicy hold, bindings no longer overwrite a target the client
wrote, matching how hold treats generators.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ns, serial transport (SIM-06)

Writes that fail now assert ILLEGAL_VALUE instead of any non-None result, the
seed test distinguishes a followed seed from an ignored one, the encoder and
synchronous-hook defenses are exercised, and the serial transport is covered
with a stubbed server. test_root_adam_deployment skips without fetched models.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@gavinying
gavinying merged commit 37353d6 into v2 Nov 12, 2026
10 checks passed
@gavinying
gavinying deleted the sim-06-batch-2 branch November 12, 2026 07:16
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant