From d0248b474b26c871bf17712d641b58f5673d07bc Mon Sep 17 00:00:00 2001 From: Yernat Yestekov <2068106+doublewhy@users.noreply.github.com> Date: Wed, 12 Aug 2026 12:34:15 -0700 Subject: [PATCH] test(runtime): bind wall readback to predecessor (#1122) --- ...-437-wall-readback-concurrency-addendum.md | 40 +++++++++++++++++++ docs/requirements/DSL-437/requirement.md | 5 ++- ...st_dsl_437_benign_participant_execution.py | 4 +- 3 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 docs/decisions/issue-1122-dsl-437-wall-readback-concurrency-addendum.md diff --git a/docs/decisions/issue-1122-dsl-437-wall-readback-concurrency-addendum.md b/docs/decisions/issue-1122-dsl-437-wall-readback-concurrency-addendum.md new file mode 100644 index 00000000..4958c5e9 --- /dev/null +++ b/docs/decisions/issue-1122-dsl-437-wall-readback-concurrency-addendum.md @@ -0,0 +1,40 @@ +# Issue 1122 Wall-Readback Concurrency Addendum + +Date: 2026-08-12 + +Issue: #1122. Requirement: DSL-437. Related: #861. + +## Gap And Existing Surface + +The DSL-437 wall-driver regression assumed that a real-time clock remained at +absolute tick zero after `RuntimeManager.apply()` started its driver. Under +contention, the driver may validly advance before a reader acquires the shared +participant-execution lock. The incumbent lock, time-runtime readback, snapshot, +and wall-driver surfaces are sufficient; this is a test-oracle defect, not a +new runtime semantic or public contract. + +## Decision + +A blocked-read concurrency check binds its result to the full predecessor +`TimeCoordinateModel` captured for that critical section. The test holds the +runtime read inside the shared lock, captures the predecessor snapshot, waits +longer than one wall tick, and proves that the manager snapshot remains +unchanged. After release, the returned segment, tick, and microstep must equal +the captured predecessor coordinate. + +This evidence does not assert absolute tick zero. A valid wall advance before +the blocked read is outside the critical section being tested and cannot make +the result fail. An advance during the read still changes the snapshot or +returned coordinate and fails deterministically. + +## Alternatives And Verification + +Retaining `tick == 0` was rejected because scheduler contention can invalidate +that unrelated timing assumption. Sleeping less or increasing the tick period +only changes the race probability. Injecting a private test clock was rejected +because the existing predecessor snapshot is the canonical shared-time state +cut and no runtime hook is required. + +Verification runs the focused blocked-read test repeatedly under CPython 3.14 +free-threaded contention, the surrounding DSL-437 wall-driver tests, Ruff, and +the DSL-437 requirement and repository policy gates. diff --git a/docs/requirements/DSL-437/requirement.md b/docs/requirements/DSL-437/requirement.md index aa4821f1..478b9f7a 100644 --- a/docs/requirements/DSL-437/requirement.md +++ b/docs/requirements/DSL-437/requirement.md @@ -6,7 +6,7 @@ type: FUNCTIONAL priority: MUST wave: 1 created_at: 2026-07-24T04:32:00.397864Z -updated_at: 2026-07-24T14:02:11.974014Z +updated_at: 2026-08-12T00:00:00.000000Z --- # DSL-437 — Benign participant activity and runtime execution semantics @@ -22,6 +22,9 @@ Ordinary user and automation activity improves range realism, but benign simulat ## Traceability - DOCUMENTS → GITHUB_ISSUE `861` (DSL-437 — Deterministic live activity policy and target bindings) +- DOCUMENTS → GITHUB_ISSUE `1122` (Predecessor-bound wall-readback concurrency regression) +- DOCUMENTS → DOCUMENTATION `docs/decisions/issue-1122-dsl-437-wall-readback-concurrency-addendum.md` (Predecessor-bound wall-readback concurrency evidence) +- TESTS → TEST `implementations/python/tests/test_dsl_437_benign_participant_execution.py` (Native participant scheduling, wall-paced advancement, and predecessor-bound readback) - CONSTRAINS → GITHUB_ISSUE `117` (Joint time semantics and language/runtime surfaces) - CONSTRAINS → GITHUB_ISSUE `118` (Time model contracts, conformance, and provenance) - CONSTRAINS → ADR `ADR-022` (Participant Behavior and Interaction Semantics) diff --git a/implementations/python/tests/test_dsl_437_benign_participant_execution.py b/implementations/python/tests/test_dsl_437_benign_participant_execution.py index cd2e319c..e2202eaf 100644 --- a/implementations/python/tests/test_dsl_437_benign_participant_execution.py +++ b/implementations/python/tests/test_dsl_437_benign_participant_execution.py @@ -2000,6 +2000,8 @@ def read_state() -> None: reader.start() assert time_runtime.read_entered.wait(timeout=1.0) predecessor = manager.snapshot + assert predecessor.time_model_state is not None + predecessor_coordinate = predecessor.time_model_state.clocks[policy.clock_address].coordinate time.sleep(0.1) assert manager.snapshot == predecessor @@ -2010,7 +2012,7 @@ def read_state() -> None: assert not isinstance(outcome[0], Exception) state = outcome[0] assert isinstance(state, TimeRuntimeStateModel) - assert state.clocks[policy.clock_address].coordinate.tick == 0 + assert state.clocks[policy.clock_address].coordinate == predecessor_coordinate assert manager.destroy().success