The wrapper keeps spawn / wait / kill, key injection and the herdr
diagnostic probe; what it decided in bash is now lib_py/delegation/wrapper.py,
reached through one `_decide` helper:
- finalize_unfinished: the clock choice, the disk grace and broker
re-observation, the close request / label, the close and the event
(finalize-begin / finalize-end; bash runs only the busy probe between them)
- start_stall_watch: whether to watch (MAM_STALL_WATCH, remote, human)
- _map_sub_rc, _rc_for (+ MAM_DELEGATE_FAIL_CLOSED), the subscriber
early-exit check and cmd_wait's rc normalisation
- mam_int / mam_int_knob run lib_py/ints.py, which is also the runner's
_positive_int: one implementation of the Issue #26 rule
No behaviour change: tests/test_issue17_item4_decisions.py runs the old
bash functions (copied verbatim from 7209750) and the new wrapper on the
same inputs and compares output, FINAL_JOB_STATUS and the registry /
publish calls. Three static tests that pinned the old bash literals now
pin the Python entry points instead.
Refs #17
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
26 lines
1023 B
Bash
26 lines
1023 B
Bash
#!/usr/bin/env bash
|
|
# lib_int.sh - the integer rule for knobs (Issue #26), on its own so scripts
|
|
# that run without lib.sh (diff_collect.sh and loop_lock.sh, which the Python
|
|
# runner and the tests source alone) read their knobs the same way. lib.sh
|
|
# sources it. Sourcing it defines the functions and the path they run.
|
|
#
|
|
# Issue #17 item 4: the rule itself is lib_py/ints.py, which the loop runner
|
|
# imports too (runner.py::_positive_int); these functions only call it.
|
|
_MAM_INTS_PY="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/lib_py/ints.py"
|
|
|
|
# mam_int <value> <min>
|
|
#
|
|
# Blanks around, digits only, read as DECIMAL, min <= n <= 999999999 (see
|
|
# lib_py/ints.py). Prints n and returns 0, or returns 1.
|
|
mam_int() {
|
|
python3 -I "$_MAM_INTS_PY" int "${1-}" "$2"
|
|
}
|
|
|
|
# mam_int_knob <ENV_NAME> <default> <min>
|
|
#
|
|
# The value of $ENV_NAME through mam_int; unset or empty gives <default>, an
|
|
# invalid value gives <default> with a warning on stderr.
|
|
mam_int_knob() {
|
|
python3 -I "$_MAM_INTS_PY" knob "$1" "${!1-}" "$2" "$3"
|
|
}
|