Skip to content

state_exec: the resource intrinsics and state-watch speak for the running process - #927

Merged
transfix merged 5 commits into
masterfrom
fix/state-exec-running-process
Oct 31, 2026
Merged

transfix merged 5 commits into
masterfrom
fix/state-exec-running-process

Conversation

@transfix

Copy link
Copy Markdown
Owner

Found while deflaking AriNet.SnapshotWaitsThroughWorkBetweenRequests (#920).

The bug. A host that runs many programs on one shared scheduler gives each intrinsics_context a placeholder process (make_process(), status ready) and leaves pid unset. Ariadne's action and resident lanes do this (submit_action, ensure_resident).

  • time-elapsed, time-limit, step-count, memory-limit, message-count, message-limit and the message-byte pair read ctx->proc, so in those lanes they reported 0. A loop bounded by (time-elapsed) never ended.
  • state-watch registered its handler for ctx->pid (0). The async scheduler silently ignores an unknown pid, so a watch set from an on: action or a resident never fired.

The fix. Two helpers in intrinsics.cpp: running_process(ctx) (the scheduler's current_process(), else ctx->proc) and running_pid(ctx) (current_pid(), else ctx->pid).

  • Every resource reader uses running_process.
  • state-watch and state-unwatch take the watch id from, and register with, the running process.
  • That is what self-pid, budget-usage, msg-send and await already did.
  • With no step running (a bare evaluator, a unit-test context) nothing changes.

Tests (ariadne_host_test, AriadneResourceIntrinsics.*). Each fails against master's intrinsics.cpp:

  • AResidentSeesItsOwnProcess: an on_tick resident's loop bounded by (time-elapsed) ends because the clock passed 0.05 s, not because it hit the 100000-iteration safety cap, and (step-count) is non-zero.
  • AnActionSeesItsLimits: a button's on: sees its (time-limit), not the placeholder's 0, and a non-zero step count.
  • AResidentsWatchFires: a watch set from a resident fires when a later tick changes the node. On master it never fires.

Locally every ariadne_* and state_exec_* suite passes (38 binaries), including state_exec_locks_test, whose watch tests use a fixture with a separate placeholder proc per program.

Docs: docs/STATE_EXEC_DEVELOPER_GUIDE.md, "Which process they report on".

Not changed: memory-usage reads the context's memory tracker, which such a host keeps per program.

nicotina-ci and others added 4 commits October 30, 2026 20:02
…ning process

A host that runs programs on a shared scheduler gives each intrinsics context a placeholder
process and no pid: Ariadne's action and resident lanes do. time-elapsed, time-limit,
step-count, memory-limit and the message counters read that placeholder, so they reported 0
there, and a loop bounded by (time-elapsed) never ended. state-watch registered its handler
for pid 0, which the scheduler ignored, so a watch set from an action or a resident never
fired.

They now use the process the scheduler is stepping (running_process / running_pid), as
self-pid, budget-usage, msg-send and await already did, and the context's own only with no
step running. Tests (AriadneResourceIntrinsics.*): a resident's clock-bounded loop ends by
the clock with a non-zero step count, an action sees its time limit, and a resident's watch
fires; each fails on master. Docs: the developer guide.
# Conflicts:
#	src/cvc/tests/ariadne_host_test.cpp
# Conflicts:
#	src/cvc/tests/ariadne_host_test.cpp
…ing-process

# Conflicts:
#	src/cvc/tests/ariadne_host_test.cpp
@transfix
transfix enabled auto-merge (squash) October 31, 2026 17:48
… file

#917 adds its resident-restart tests where these were, after the module-tick tests; at the end
they no longer conflict with it, whichever lands first.
@transfix
transfix merged commit baf8b6d into master Oct 31, 2026
21 of 27 checks passed
@transfix
transfix deleted the fix/state-exec-running-process branch October 31, 2026 19:17
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