Skip to content

fix(hylafax): check engine lines cheaply every round, without faxstat per line - #127

Merged
DMontgomery40 merged 8 commits into
mainfrom
fleet-20261029/faxbot-issue-81
Oct 30, 2026
Merged

DMontgomery40 merged 8 commits into
mainfrom
fleet-20261029/faxbot-issue-81

Conversation

@DMontgomery40

@DMontgomery40 DMontgomery40 commented Oct 30, 2026 •

Copy link
Copy Markdown
Owner

SSL Fax engine supervisor: cheap checks every round, no faxstat per line

Issue #81 asks the SSL Fax engine's supervisor (hylafax/entrypoint.sh) to check its daemons and lines more cheaply, without noticing a dead daemon, or a line that lost its faxgetty, later than it did when the issue was filed. At that time every 5-second round ran pgrep four times and faxstat -s once per line. Main has since replaced that with a cheap check: remembered process IDs asked with kill -0, and each line's status file. That check ran only every 25 seconds, though, and startup and recovery still asked faxstat once per line.

This branch has two commits:

  1. Read line status from the status files (f725773). line_state reads status/ttyIAXn (the file faxgetty keeps and faxstat reads) with the builtin read, instead of running faxstat -s once per line. Startup (lines_ready), recovery (check_lines) and the cheap check (looks_whole) now share it. idle() still asks faxstat once, only before a restart.
  2. Run the cheap check every round (4f42dd2). The cheap check starts no process (kill -0, the builtin read of /proc/<pid>/stat and the status files, [ -e ]), so it now runs every 5-second round, not every 25 seconds. pgrep, and faxstat once for whether a call is up, still run only when it finds something wrong. Reading the iaxmodem logs for a refused registration and reading the session logs start processes, so they stay on the 25-second round (FAXBOT_ENGINE_LIVENESS_SECONDS).

Compared with when the issue was filed:

  • A stopped faxgetty, faxq, hfaxd or modem is noticed at the next 5-second round, as then. On main it could take up to 25 seconds.
  • A line that is not ready is reported after about 30 to 40 seconds, as then. On main it could take up to about 75.
  • A healthy engine starts no checking process between the 25-second rounds. When the issue was filed it ran pgrep and faxstat every 5 seconds.

Two trade-offs to judge:

  • Refused registrations are still checked only every 25 seconds. When the issue was filed that check ran every 5 seconds. With its own 30-second grace period, a refused line is now restarted after up to about 75 seconds, against about 40 then. The issue's done-when does not name this case, and the check starts a few processes per line, so it stays on the slow round.
  • While something is wrong, the full checks run every 5 seconds. That covers the 30-second readiness grace and any time a line is down while the other line is in a call. On main they ran every 25 seconds in those states. This is the same load as when the issue was filed, but more than main when one line is down and the other is receiving. That resembles the conditions of the 10 October failure, but it happens only after something has already gone wrong.

README: the roadmap entry for the SSL Fax engine now gives the 5-second check, what it reads, and what stays on the 25-second round. I removed the "0.86% of one core instead of 1.54%" figure that was on main, because no record of that measurement exists in the repository. The README now says plainly that the processor saving has not been measured. I also reverted the developer wording the first commit added to the SIP carrier feature line; the roadmap covers it.

Checks on this head (4f42dd2, on main 7446857)

  • bash -n hylafax/entrypoint.sh: OK.
  • make test-local PYTEST_ARGS='tests/test_hylafax_scripts.py tests/test_hylafax_engine.py tests/test_sip_compose.py tests/test_polling.py tests/test_measured_codec.py': 217 passed, 18 skipped. The skips are the PostgreSQL variants of the shared database fixture. No PostgreSQL URL was given because this is not a schema change; CI runs them.
  • make test-local PYTEST_ARGS='tests/test_hylafax_scripts.py' on f725773 before my commit: 38 passed.
  • Fails before, first commit: I copied main's entrypoint.sh over the branch file and ran -k "without_starting_faxstat or stops_being_ready". Result: 4 failed, 3 passed. The start test failed, and so did the three variants where faxstat does not list idle lines. I restored the file with git checkout.
  • Fails before, second commit: three test functions (10 cases) now set the slow round to 30 seconds and expect the report within 5 seconds (8 for the line that stops being ready). The cases are a stopped faxgetty, faxq or hfaxd, a lost modem, and the six variants of a line that stops being ready. Against f725773's entrypoint.sh, all 10 failed; the session-log test passed. All pass on this head. The test that no pgrep or faxstat runs while the lines are whole still guards the no-process claim.
  • Secret scan against origin/main: no suspicious added lines.
  • Lint: the repository defines no lint gate in the Makefile or CI, and shellcheck is not installed.

Not checked

  • No live HylaFAX host, Telnyx or other live service was used. Every engine path ran against the stand-in daemons in test_hylafax_scripts.py.
  • The Docker loopback proof (FAXBOT_SSLFAX_PROOF) was not run.
  • Reading status/ttyIAXn directly assumes faxgetty's status file holds the same text faxstat -s shows. Main's cheap check already relied on this, but it has not been checked against a real engine here.
  • The processor time saved has not been measured.
  • Jev unavailable. I checked the wording by reading it.
  • README.md will conflict textually with fix: readiness item 2, the remaining console defects D23–D27 (combines #118, #120, #121) #122. That PR was still open at push time, so this branch is not rebased.

Pre-existing failures

None found in the suites run.

Closes #81

🤖 Generated with Claude Code

DMontgomery40 and others added 6 commits October 29, 2026 23:28
Issue #86 was seen through `faxbot status`, which reads the outbound board
(GET /outbound/now), and `faxbot status ID`, which reads GET /fax/{id}; the
HTTP settle test checked only Sent's details (GET /admin/fax-jobs/{id}).

The test now checks all three before and after settling through
POST /certainty/items/{id}/settle: before, each shows "Needs review" and the
board lists the fax under needs_you; after, both fax reads show the settled
state with no review notice, and the board no longer lists it.

One board aggregate serves every viewer for outbound_now.AGGREGATE_SECONDS
(2 seconds), so the test drops the cached aggregate before its second board
read, as the next poll would see it; test_outbound_now.py does the same.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Issue #81 asks that the engine's supervisor check more cheaply without
reporting a stopped line later than it did when the issue was filed. At
that time every 5-second round ran pgrep and faxstat. The cheaper check
that followed (remembered process IDs and the status files) ran only every
25 seconds, so a stopped faxgetty, faxq, hfaxd or modem could go unnoticed
for up to 25 seconds, and a line that was not ready for up to about 75.

That check starts no process (kill -0, the builtin read of /proc and the
status files, a test for each line's device), so it now runs every round.
pgrep, and faxstat once for whether a call is up, still run only when it
finds something wrong. Reading the iaxmodem logs for a refused
registration and reading the session logs start processes, so they stay
on the 25-second round (FAXBOT_ENGINE_LIVENESS_SECONDS).

The tests for a stopped faxgetty, faxq or hfaxd, a lost modem and a line
that stops being ready now set the slow round to 30 seconds and expect
the report within a few seconds. On the previous head all ten fail.

The README drops the "0.86% of one core instead of 1.54%" figure, because
no record of that measurement exists. It now says plainly that the
processor saving has not been measured. It also drops the developer
wording added to the SIP carrier feature line; the roadmap entry covers
the supervisor.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@DMontgomery40
DMontgomery40 marked this pull request as ready for review October 30, 2026 20:20
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-30T20:32:37.665390Z 0dc84d9 New commits
ℹ️ 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.

@DMontgomery40
DMontgomery40 merged commit 630644f into main Oct 30, 2026
6 checks passed
@DMontgomery40
DMontgomery40 deleted the fleet-20261029/faxbot-issue-81 branch October 30, 2026 20:41
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.

SSL Fax engine supervisor polls with pgrep and faxstat every few seconds

1 participant