Skip to content

Teach tutorial 24's alarms step by step, with a walk test of every step (G282s) - #973

Open
johannesPettersson80 wants to merge 5 commits into
mainfrom
work/g282s-tutorial-24-readme
Open

johannesPettersson80 wants to merge 5 commits into
mainfrom
work/g282s-tutorial-24-readme

Conversation

@johannesPettersson80

@johannesPettersson80 johannesPettersson80 commented Dec 3, 2026 •

Copy link
Copy Markdown
Owner

What

Tutorial 24 teaches the tank example's alarms step by step in the runtime display, from a real run, and a native test walks every step (G282s).

The old README toured the alarm features in sections. The new one follows the example README standard (specification 25 §3.5) in fifteen steps, each with what the run showed:

  1. copy the tank example, build it and run it;
  2. read how TankVessel declares its level alarms with the Alarm library, the program's own rise detection (LevelRiseAlarm, which extends Alarm.Alarm), and the pump's trip with its first-out group;
  3. the Overview at rest, with the rise alarm suppressed in Auto;
  4. to 8. log in as the operator, raise the setpoint to 2.6 m, and handle T-101 level high: its details, acknowledge, shelve for 15 min, unshelve;
  5. and 10. Manual at 100 %: the rise alarm, then the high-high trip of the pump and its first out;
  6. and 12. back in Auto the tank drains to the low alarm; Reset trip, and the low alarm returns to normal;
  7. to 15. acknowledge the cleared alarms, read the event log, log out.

"What happened" covers:

  • the four ISA-18.2 states;
  • a limit with its deadband, as a formula, worked with the run's readings;
  • the drain time from the tank's mass balance, t = (2A/c)(√h₀ − √h₁) = 22.5 s, against the run's 22.6 s;
  • the rise in Manual;
  • the first out.

"Try it yourself" takes an alarm out of service as an engineer, adds a comment, and lifts the rise alarm's suppression in Auto.

The ten screenshots come from one walk of the README's steps on the runtime at 1×, at 1920×1080, and replace the nine old ones. I reviewed each against its step. The README is off the pending list in scripts/example_readmes.json.

Found on the way

  • Another user's command id (G386). In the walk test, the engineer took the alarm out of service with the command id that the operator's setpoint had used. The runtime answered with the operator's applied and wrote nothing. The fix is its own pull request (G386, specification 39 §12.8): a command id now belongs to the user who sends it. Here, the test's ids carry the user's name.
  • Discovery in example copies. The test harness turned discovery off only in a runtime.toml that has a [runtime.discovery] table. The tank example has none, so each of its copies advertised itself (discovery is on by default), and tutorial 15's mesh test found three runtimes where it expects one. tests/support/runtime_toml.rs now turns discovery off in every copy unless a test keeps it.
  • The fall after Reset trip. While the pump is tripped, the controller tracks a closed valve. After the reset it opens the valve gradually, and the level falls until the inflow meets the outflow c·√h. How far it falls depends on the level at the reset: the lower the level, the less flows out. Step 12 first stated one run's fall as a general fact. It now reports the run (the reset at 0.10 m, then 2.7 s more, to 0.07 m) and says that a later reset falls less. The walk test resets at 0.10 m, as the run did.
  • The value column. The high-high alarm's row showed the current level ("2.786 < 2.800"), not the reading that raised the alarm. G384 (Show the reading that raised a limit alarm, not the display's next read (G384) #955) fixed that, and the screenshots were taken after it merged: 2.5002 > 2.5000, 2.803 > 2.800 and 0.296 < 0.300. The display shows enough decimals to tell the reading from the limit.

The tests

tutorial_projects::hmi_alarms::tutorial_24_handles_the_tank_alarms_as_its_readme_walks_them walks steps 3 to 14 and the first two Try-its through the requests the display sends, at 1×. It reads each value and time with ctl read, in the runtime's logical time:

  • step 5: the high alarm 36 to 39.5 s after the setpoint (37.5 s in the run), at no scan below 2.5 m, with its raised reading between 2.5 and 2.51;
  • step 9: the trip 2.5 to 5 s after the valve opening (3.6 s), with its raised reading between 2.8 and 2.82. At the scan read, the pump is tripped, the inflow stopped and the level below 2.82 m. ctl read polls, so that scan can come after the trip: on macOS in CI it came about 0.13 s late, with the level already falling (2.784 m), and the first round, which checked the level there, failed once (run 47020466196, passed on the suite's retry);
  • step 11: the low alarm 21.5 to 23.5 s after the trip, where (2A/c)(√2.8 − √0.3) gives 22.5 s;
  • step 12: the walk presses Reset trip once the level reads 0.10 m, as the run did. The lowest level comes 1.5 to 3.5 s after the first read showing the pump running, between 0.035 and 0.075 m (2.7 s and 0.066 m in the run), and the low alarm returns above 0.35 m 15 to 20 s after the reset (17.2 s). The first read after the reset comes some hundred milliseconds late (0.084 m in one builder run), so the bounds hold for a reset read down to 0.06 m;
  • the states, the first out, the actions each role is offered, and the event log.

tutorial_24_try_it_the_rise_alarm_alarms_in_auto_without_its_suppression builds the README's Suppressed := FALSE edit and checks the rise alarm in Auto.

hmi_tank_level_example::a_high_high_level_trips_the_pump_and_is_the_first_out_until_reset steps the program one cycle at a time. It now runs until the high-high alarm comes in and requires the pump tripped and no inflow in that cycle: the trip in the same scan, which the walk's polled reads cannot catch for certain.

The screen test scripts/hmi-screen-tests/tests/tutorial-alarms.spec.mjs walks steps 3 to 14 in Chromium.

Mutants, each failing at its own assertion. Of the example's program:

  • the high-high alarm not latching: step 10, latching false;
  • the rise alarm never suppressed: step 3's wait for the suppressed rise alarm times out (the wait is that claim);
  • the high limit at 2.4 m: step 5, "the alarm comes in as the level passes 2.5 m: 2.40";
  • the high-high alarm in no group: step 10, first_out false;
  • the pump tripped a scan late: hmi_tank_level_example's trip test, "the pump tripped in the scan the alarm came in". The walk catches it only when its read lands on the trip scan, as it did in the last check ("step 9: the trip stops the inflow", the pump not tripped and the inflow 0.05);
  • the controller tracking an open valve while the pump is tripped: step 12, "0 s, from 0.084 m to 0.084 m": the level never falls after the reset.

Of the test, the walk pressing Reset trip at once, as the first round did: step 12, "4.3 s, from 0.265 m to 0.174 m". That is the first round's README run, which the new bounds refuse.

Checks

On the builder, over the merge of main with G384 (392d288):

  • fmt, the example README checker and the changelog fragments;
  • Clippy -D warnings on trust-runtime's tests with all features, and Windows Clippy;
  • tutorial_projects whole (22 tests), and the two tutorial 24 tests twice more;
  • hmi_tank_level_example, examples_build_and_validate and tutorial_ctl_commands;
  • every test program that starts an example runtime, since the harness turns discovery off in every copy (15 programs);
  • the docs command-line tests (5);
  • the screen test tutorial-alarms.spec.mjs in Chromium, with a runtime built from the same tree;
  • the seven mutants above, each restored after its run.

Step 12's bounds were then widened for a late first read (37972a1), and a focused check ran on the builder: fmt, Clippy, the two tutorial 24 tests three more times, and the two step-12 mutants again, each failing at its own assertion ("0 s, from 0.084 m to 0.084 m"; "4.3 s, from 0.265 m to 0.174 m").

After main. This branch then took main at d794363f6 and #966's pin-project-lite 0.2.19 (G397, e90222778), without which Supply Chain fails on every pull request. Over that head, on the builder: fmt, the README check, the changelog fragments, Clippy on trust-runtime (all targets and features), tutorial_projects, hmi_tank_level_example, examples_build_and_validate, tutorial_ctl_commands and every program that reads tests/support/runtime_toml.rs, the documentation tests and Windows Clippy, and the pre-push contracts.

The macOS retry. Step 9's level then came from the alarm's raised reading, and the same-scan trip moved to the harness test (a9e5a0f). On the builder over that head: fmt, Clippy -D warnings on trust-runtime's tests, the two tutorial 24 tests three times (102 s each), hmi_tank_level_example (10 tests), the pump-a-scan-late mutant against both tests, and Windows Clippy.

Tutorial 24's README is rewritten to the README standard from a real run of the tank
example: how the program declares its alarms with the Alarm library and its own rise
detection, acknowledging, shelving and unshelving the high-level alarm, the high-high trip
in Manual and its first out, the drain to the low-level alarm (22.5 s by the tank's mass
balance), the reset, and the event log. Its "Try it yourself" takes an alarm out of
service as an engineer, adds a comment, and lifts the rise alarm's suppression in Auto.

A native walk test (tutorial_projects/hmi_alarms.rs) follows every step through the
display's API at 1x and checks each value the README states. The test harness now turns
discovery off in every example copy unless a test keeps it, so a copy without a
[runtime.discovery] table no longer advertises itself to another test's search.

Specification: 25 3.5
…hat run

A walk of the README's steps on the runtime at 1x gave the run's values, and
the README now reports them: the high alarm 37.5 s after the setpoint, raised
at 2.5002 m against the 2.5000 m limit, and the trip 3.6 s after the valve
opening. After Reset trip the controller opens the valve gradually from
closed, so the level falls a little more until the inflow meets the outflow.
How far it falls depends on the level at the reset. The run reset at 0.10 m
and fell for 2.7 s more, to 0.07 m, and the README says that a later reset
falls less.

The ten screenshots come from that walk, taken after G384's value column, and
replace the nine old ones.

The walk test presses Reset trip at 0.10 m, as the run did. Its bounds hold
for a reset read down to 0.06 m, since the first read after the reset comes
some hundred milliseconds late.

Specification: 25 3.5
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-12-03T02:32:00.818615Z
We couldn’t complete this review. Comment @codex review to try again.
2273fc1 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

…trip in the harness (G282s)

On macOS the walkthrough test failed once at step 9 (run 47020466196): the scan that `ctl read`
returned came about 0.13 s after the trip, when the level, 2.784 m, was already falling inside
the high-high alarm's deadband, and the step asserted a level above 2.8 m. `ctl read` polls, so
the first scan it sees with the alarm active can be a later one than the trip.

Step 9 now reads the level at the trip from the alarm's own record, `raised` (limit 2.8, high,
the level just above 2.8 m), as step 5 does, and from the polled scan only what holds at every
scan from the trip on: the pump tripped, no inflow, the level below 2.82 m.

The walkthrough could catch a trip one scan late only when its poll landed on the trip scan.
The example's harness test, which steps the program one cycle at a time, now runs until the
high-high alarm comes in and asserts that the pump tripped and the inflow stopped in that cycle.
The mutant that calls the pump before the vessel fails it at that assertion.

This branch has not been deployed

No deployments
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