Skip to content

Batch 673: dryrun reference view built once per check, peek reads guarded (BACKLOG #6819-#6821, #5105, #5107) - #3256

Queued
wshallwshall wants to merge 8 commits into
mainfrom
b673/dryrun-group
Queued

wshallwshall wants to merge 8 commits into
mainfrom
b673/dryrun-group

Conversation

@wshallwshall

Copy link
Copy Markdown
Collaborator

Batch 673 (pipeline), dryrun.py group. Branched from origin/main and merges clean with current main (git merge-tree exit 0). wiring_runner.py is not touched.

BACKLOG #6819 -- PARTIAL

  • _shareable_payload now calls build_payload instead of repeating its code. The test failed before the change. No behaviour change.
  • Remainder: for a non-HL7 type, public route_message, route_only and transform_one decode bytes as UTF-8, so raw binary bytes raise, or arrive without mfb64 carriage. dry_run itself carries or decodes the body first.

BACKLOG #6820 -- PARTIAL

  • check builds the reference view once per run, through the new public dry_run_reference_view and a new reference_view keyword on dry_run and route_message.
  • Values are decoded on every read (_PreviewReferenceSet), so one fixture's edits do not leak into the next.
  • Behaviour change (tightening): a loader fault now fails the dry-run leg, naming the type only.
  • Tests failed without the fix: 4 loads instead of 1, and 2 or 3 false failures with a shared dict.
  • The CodeSetError half was already met (vault #3340).
  • Remainder:
    • the dryrun CLI and trace_dry_run still rebuild the view per message;
    • the size-cap half is not adjudicated (the live sync has no cap either).

BACKLOG #6821 -- BUILT for S08-34

  • Peek field reads and the marker check now sit inside the PEEK_READ_FAULTS guard, giving the listener's peek read failed (<type>) text. 8 test cases failed before the fix.
  • The ingress_guards.py docstring was corrected.
  • S08-35 was already met (strict_validation_due).

BACKLOG #5105 and #5107 -- CLOSE, no change

  • #5105: both steps were met by engine PR 2867 (test_env_cast_sys_exit.py, test_user_code_system_exit.py; 31 pass).
  • #5107: steps 1 and 2 were met by PR 2867 (ERROR <reason> matching plus the timeout exclusion; warm_validation), and step 3 by PR 2811. The 45 tests covering it pass.

Proposed banners are in the bodies of commits b0938654c0c (supersedes) and 8b466587634.

Checks (Builder):

  • Clean: ruff check and format, the changelog fragment check, mypy linux and win32, and mypy on 3 test files.
  • pytest: 702 passed on the targeted files, plus the dependency-boundary (89) and sandbox (181) suites.
  • Full suite not run. Read the full pytest legs and the tests mypy leg.

QA: xhigh. Rounds: 2 + 1 unrepaired, plus one more. Tag: xhigh effort -> 10 inline angles -> dedup (no verify) -> sweep -> <=15 findings (round-1ea6927283, round-a793edb7e7, round-5d09231ab9, round-4d4f2dd7f2).

  • Round 3 found that the sealed-cache rows in docs/ASVS-L2-PHASE0-CHANGES.md would have become false. The sealed cache was replaced instead, so that document is unchanged and stays true.
  • Round 4 reviewed that head.
  • The head, 16ddee0, fixes a changelog sentence, and no review round ran on it.

Open findings, to file under R2:

  1. check builds the view eagerly, so a loader fault fails the leg even for parse-only fixtures, and the catch logs nothing and names no set.
  2. Raw bytes in public route_message (the #6819 remainder).
  3. The dryrun CLI and trace still rebuild the view per message.
  4. The HL7PeekError text skips safe_exc, unlike the listener's, and it now covers the moved reads too.
  5. The peek read failed literal exists in 5 copies, and the field-read order differs from _read_ingress_fields.
  6. docs/CONFIGURATION.md still says "best-effort".
  7. The peek test does not cover message_type or control_id faults.

… its branch

_shareable_payload repeated build_payload's non-HL7 branch inline. It now
returns build_payload(raw, content_type), the one construction the
per-consumer path and the sandbox child use, so the fan-out's shared
object cannot drift from the others. No behaviour change: both built the
same RawMessage.

Adjudicated: the duplication is real; the correctness half of the claim
is not a defect of this function. A bytes body that is not UTF-8, or a
binary body handed to route_message raw, raises UnicodeDecodeError the
same way in build_payload, and dry_run carries a binary feed and decodes
a text feed before route_message (_dry_run_raw), as the listener does.

Test: test_shareable_payload_delegates_to_build_payload, which failed on
the code before the change (the object was not build_payload's).

BACKLOG #6819.
route_message rebuilt _dry_run_reference_view on every call, so check,
which previews every fixture on every inbound, re-read and re-parsed
each file-backed reference set each time. _encoded_reference_file now
keeps each file's table, as the store encodes it, keyed by path and the
file's stat signature (mtime_ns, size, inode), taken before the read. A
changed signature reads the file again. Values are decoded per preview,
so each preview still gets its own copy of a container value. The cache
holds at most 64 paths, oldest out first. A failed load or an
unencodable value is never cached, so the once-per-set skip warning and
the unencodable warning behave as before.

Adjudicated: the per-message rebuild is real (three previews read the
file three times; the test fails 3 == 1 with the cache disabled). The
"bare continue on CodeSetError" half is NOT-A-BUG at origin/main: it
logs a warning naming the set, once per set per process (vault #3340,
test_dryrun_logs_a_reference_file_it_skips_once). The "no file-size
cap" half matches the live sync, whose _load_file_source has none
either; the file is operator configuration.

Tests: test_dryrun_reads_an_unchanged_reference_file_once (fails on the
code before the change), test_dryrun_reference_containers_are_fresh_per_preview
(guards the per-preview copy).

BACKLOG #6820.
dry_run caught only HL7PeekError around Peek.parse and read
message_type, control_id, summarize(peek) and doc_ref_marker_refusal
outside it. The live listener takes the same reads inside one guard
over PEEK_READ_FAULTS (BACKLOG #1594). A parser fault in one of them
raised out of dry_run, and so out of messagefoundry check. They now sit
inside the guard: HL7PeekError keeps its text, and any other
PEEK_READ_FAULTS member is ERROR "parse error: peek read failed
(<type>)", the listener's text, naming the type alone.

Adjudicated: S08-34 is real; test_a_peek_read_fault_is_an_error_result
(eight cases: IndexError, KeyError, TypeError, ValueError at summarize
and at the marker check) raised on the code before the change. S08-35
is NOT-A-BUG at origin/main: dry_run already gates the strict validate
with ingress_guards.strict_validation_due(ic, text).

Proposed banners, for the Lander:
#6819: BUILT. _shareable_payload delegates to build_payload (no
behaviour change); the decode half is not a defect of this function,
since build_payload decodes the same way and dry_run carries or decodes
before route_message.
#6820: BUILT. An unchanged reference file is read once per process,
keyed on its stat signature; the CodeSetError half was already met
(logged once per set, vault #3340) and the size-cap half matches the
live sync.
#6821: BUILT for S08-34; S08-35 already met (strict_validation_due).
#5105: CLOSE, already met by engine PR 2867 (batch 609): a cast's
sys.exit refuses the reload (test_env_cast_sys_exit.py), and one class,
UserCodeCalledSysExit in dryrun.py, formats the code with int.__int__
(test_user_code_system_exit.py). No change on this branch.
#5107: CLOSE, all three steps met: step 1 by ERROR <reason> in .expect
and the timeout exclusion in checks.py (PR 2867), step 2 by
warm_validation before the clock (PR 2867), step 3 by PR 2811. No
change on this branch.

BACKLOG #6821.
The tests mypy leg refused two lines of the new #6820 tests: the counting
loader read load_code_set off the dryrun module, which does not export
it, and the edited Handler took Message where a Handler takes Message or
RawMessage. The loader now comes from config.code_sets and the Handler
takes the union. No behaviour change.

BACKLOG #6820.
…of a process cache

The round's code-review (round-1ea6927283) found the #6820 process-wide,
stat-keyed cache unsound: a same-size rewrite inside one timestamp tick
or a time-preserving in-place copy served a stale table, a policy
sidecar edit never invalidated it, FIFO eviction missed every lookup past
64 sets, its eviction raced another thread, and os.stat raised
ValueError where the loader had refused with CodeSetError. The cache is
gone. route_message, _dry_run_raw and dry_run take reference_view; None,
the default, builds the view on the call as before. check builds it once
per run and passes it for every fixture, so each file is read once and
every fixture reads one snapshot, as messages read the live cache. The
tests now pin the passed view (no load) and check's single load over
three fixtures, which reads four loads with the view dropped.

#6821: ingress_guards.py's module docstring said the dry run catches
only HL7PeekError; it now says both catch PEEK_READ_FAULTS with one
text, and that only the HL7PeekError text still differs. dry_run returns
from each except arm rather than through a sentinel.

Declined, as open findings for the report: sharing the listener's peek
reads and fault text through ingress_guards (it touches wiring_runner,
which another Builder holds this wave); the HL7PeekError text parity
(pre-existing and documented).

BACKLOG #6820, #6821.
…d, and a loader fault fails the leg

The round's code-review (round-a793edb7e7) found that check's one view
handed every fixture the same mutable values, so a Handler that edited a
container it read changed what later fixtures read; reproduced as 2/3
false failures. Each set is now the live engine's own sealed reference
cache (sealed_reference_set), so every read decodes its own copy, as the
engine's does. test_check_fixtures_each_read_a_fresh_reference_value
fails "2/3 run(s) failed" with a plain shared view.

The view is built before the fixture loop, outside each fixture's guard,
so a loader fault it does not turn into a skipped set (a RecursionError
from deep TOML, a ValueError from a NUL in the path) ended check with a
traceback. It now fails the dry-run leg naming the type alone.

The builder is public as dry_run_reference_view, in __all__, so a caller
building a view once does not reach into a private name. The parity
prose in dryrun.py, checks.py and the fragment now says what is shared
and that reads are fresh copies. The check test passes
suppress_search=True and asserts "3 run(s) clean".

Not built, for the report: the dryrun CLI and trace_dry_run loops still
rebuild the view per message (dryrun_trace.py is another Builder's file
this wave); the fragment says so.

Proposed banner for #6820: PARTIAL. check builds the reference view
once per run (each set a sealed cache, fresh copy per read); the
CodeSetError half was already met (vault #3340) and the size-cap half
matches the live sync. Open: the dryrun CLI and trace_dry_run still
rebuild it per message.

BACKLOG #6820.
The unrepaired review round (round-5d09231ab9) found that building the
preview view from sealed_reference_set made two assurance rows false:
docs/ASVS-L2-PHASE0-CHANGES.md says the sealed-cache key seals only the
engine's own caches, in the engine process only, and check, dryrun and
verify would now mint and use it. It also made the no-view path about 50
percent slower per message (AES-GCM per row). A false control claim must
be fixed, so the view's sets are now _PreviewReferenceSet, a plain
Mapping that keeps each value as the store's JSON text and decodes it on
every read: fresh copies as before, no key, and no json.loads of values
no Handler reads. The fresh-value test still fails 2/3 with a plain
shared dict.

Stale prose that round named is updated: route_message's inline comment
names the passed view, and test_dryrun_logs_a_reference_file_it_skips_once
no longer says check rebuilds the view per fixture.

Banners for the Lander (supersede the earlier commit bodies):
#6819: PARTIAL. _shareable_payload delegates to build_payload (no
behaviour change). Open: public route_message, route_only and
transform_one still decode bytes as UTF-8 for a non-HL7 type, so raw
binary bytes raise or arrive without mfb64 carriage; dry_run itself
carries or decodes first (_dry_run_raw).
#6820: PARTIAL. check builds the reference view once per run, values
decoded per read; CodeSetError half already met (vault #3340). Open: the
dryrun CLI and trace_dry_run still rebuild per message, and no file-size
cap (the live sync has none either; not adjudicated here).
#6821: BUILT for S08-34; S08-35 already met (strict_validation_due).
#5105: CLOSE, met by engine PR 2867; no change here.
#5107: CLOSE, all three steps met (PR 2867, PR 2811); no change here.

BACKLOG #6820.
The final review round (round-4d4f2dd7f2) found the #6820 fragment's
"a caller that passes no view keeps the old behaviour" false: every
read now decodes its own copy on that path too, so one Handler's edit
to a reference value no longer reaches a later Handler of the same
message. The fragment now says so, and no longer says check previews
every fixture on every inbound. Text only.

BACKLOG #6820.
@wshallwshall wshallwshall added the qa Builder QA record posted; not a merge gate label Nov 24, 2026
@wshallwshall

Copy link
Copy Markdown
Collaborator Author

QA: level xhigh. Rounds: 2 + 1 unrepaired, plus one more. Tag: xhigh effort -> 10 inline angles -> dedup (no verify) -> sweep -> <=15 findings (last round round-4d4f2dd7f2). The head, 16ddee0, is text only and was not reviewed. Lander: ready to merge. The batch 673 Manager opened this PR; see the body for the R2 findings.

@wshallwshall

Copy link
Copy Markdown
Collaborator Author

Lander: enqueuing at pinned head 16ddee0. QA round-4d4f2dd7f2 (exit 0) covers the branch; the head adds a changelog only. Finding 1, the eager reference view failing the check dry-run leg on a loader fault, I rule ORDINARY under decision d20261123T150929936-d70a0b. It is a fail-closed over-refusal that passes nothing main refused, it is not on a default-on inbound HL7 path, and every commit is reviewed. The missing diagnostics (no log line, no set named) are queued. Findings 2-4 (MAIN) and 5-7 (ORDINARY) are queued for filing under R2.

@wshallwshall
wshallwshall added this pull request to the merge queue Nov 24, 2026
Any commits made after this event will not be merged.
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 24, 2026
@github-actions github-actions Bot added the ci-red A required check went red. Attribute it before retrying. label Nov 24, 2026
@github-actions

Copy link
Copy Markdown

CI failed in test (ubuntu-latest, py3.14) / Tests (pytest) while this pull request was in the merge queue, so the queue ejected it.

Its own head can still be green: the queue revalidates the merge, and the path gates that skip on a pull request run there. Read the run before retrying.

https://github.com/MEFORORG/MessageFoundry/actions/runs/45447384304

@wshallwshall

Copy link
Copy Markdown
Collaborator Author

Lander: re-enqueued once at pinned head 16ddee0. Queue CI run 45447384304 failed only on test (ubuntu-latest): tests/test_dicom_scu_reactor_race.py::test_the_same_stalls_lose_a_response_without_the_hold ('the stalls never reproduced the race'), a non-deterministic race-reproduction control in DICOM code this PR does not touch. It is queued for filing as a flake.

@wshallwshall
wshallwshall added this pull request to the merge queue Nov 24, 2026
Any commits made after this event will not be merged.

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

ci-red A required check went red. Attribute it before retrying. qa Builder QA record posted; not a merge gate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant