Skip to content

test(request-identity): cover upload hashing edges and every send option in both fingerprint versions - #129

Open
DMontgomery40 wants to merge 11 commits into
mainfrom
fleet-20261029/health-faxbot
Open

DMontgomery40 wants to merge 11 commits into
mainfrom
fleet-20261029/health-faxbot

Conversation

@DMontgomery40

Copy link
Copy Markdown
Owner

Request identity: upload hashing edge cases and every send option in both fingerprint versions

This PR adds tests only, plus a one-line make venv fix. It does not change api/app/request_identity.py or any other application code.

First commit (from this branch, rebased onto main 80bc4b6): upload hashing is tested for two more cases:

  • An empty upload is refused with 400 before any identity is made, and the spool is left at the start and open.
  • If a read fails part-way, by an OS error or by cancellation, the same error is raised, and the original upload is rewound, left open and unchanged. Conversion reads that same upload next.

Second commit (salvaged from fleet/mac-request-identity-tests, d11c42d): the uncommitted, unverified work on that branch, checked and trimmed.

Kept:

  • One table test for every send option. It covers real call, urgent, send-by time, mailbox, workflow, labels, engine, cover-in-header, court digest and patient details. An accepted request is stored under its canonical (version 2) fingerprint, and in a second case under its version-1 fingerprint. Replaying the same Idempotency-Key with one option changed must raise IdempotencyConflict in find_replay, and nothing new may be stored. The version-1 rows are new coverage. Other suites (test_routing_local, test_capacity, test_schedule) only check that an option changes the version-2 fingerprint, and the HTTP tests always store version 2. If an option were left out of the version-1 fingerprint, a replay would match an old record for a different request, and no existing test would notice. I changed the salvaged patient value from a dict to the JSON text that Patient.canonical() actually returns.
  • Changing the order of routing keys or labels does not change a request's identity.
  • Two different send-by times are two different requests. Existing tests only compare "with a send-by time" against "without one".
  • Upload hashing starts from the beginning even when the spool position has moved. It reads at most 64 KiB at a time and rewinds afterwards.
  • make venv now installs the Python SDK in editable mode. CI's test-api job and the full suite workflow both do this (pip install -e ../sdks/python), and tests/test_api.py imports the SDK. The CONTRIBUTING.md row says so.

Dropped:

  • The salvaged test_empty_upload_is_rejected_and_rewound and test_upload_read_failure_propagates_and_rewinds. They duplicate the first commit's tests, which check more: cancellation as well as OS errors, that the error raised is the same object, and that the spool is open and unchanged.

Nothing else from that branch is needed, so it can be deleted once this merges.

No README or roadmap change is needed, because no capability changed.

Checks on this head

  • make test-local PYTEST_ARGS='tests/test_request_identity.py' (SQLite): 33 passed.

  • make test-local on test_request_identity, plus every test file that imports request_identity (test_access_outbound, test_api, test_batching, test_batching_index_page, test_capacity, test_outbound_idempotency, test_routing_local, test_schedule): 202 passed, 92 skipped in 5 min 10 s. The 92 skipped are exactly the 92 collected PostgreSQL variants, which skip when no PostgreSQL URL is set. This PR has no schema change; the full suite runs them.

  • python -m py_compile api/tests/test_request_identity.py: compiles.

  • The repository has no linter or Python type checker (CONTRIBUTING.md, "What CI runs"), so there is none to run.

  • Each new test exercises real behaviour. I mutated api/app/request_identity.py one change at a time, ran tests/test_request_identity.py against each mutation, then restored the file:

    Mutation Tests that fail
    Remove the empty-document refusal the empty-upload test only
    Rewind on success and on Exception only, not on cancellation the interrupted-hashing test, cancelled case only
    Rewind on success only the interrupted-hashing test (read-error and cancelled) and the existing oversize test
    Leave the options out of the version-1 fingerprint all 10 legacy table cases and the send-by-value test
    Leave the options out of the version-2 fingerprint all 10 canonical table cases and the send-by-value test
    Stop sorting label lists the routing-order test only
    Bind only whether a send-by time was given the send-by-value test only (the table's deadline cases still pass, so the test is not a duplicate)
    Skip the initial rewind before hashing the bounded-chunk test only
    Read the whole upload at once the bounded-chunk test only
  • The secret scan against origin/main found no suspicious added lines.

Not checked

  • make venv was not run, because uv is not installed on the machine where these checks ran. The added -e sdks/python follows uv's pip install -e form and matches what CI installs.
  • No live fax, telephony or other services were used. All tests use synthetic data.
  • Jev was unavailable, so I checked the wording by reading it.

No failures in the tests run, so none are pre-existing.

No open issue matches this work.

🤖 Generated with Claude Code

DMontgomery40 and others added 11 commits October 30, 2026 20:23
Sent, Received, Expected and Recipients records now open from an
address that keeps the list filter with the record (?fax=, ?item=,
?expected=, ?recipient= plus status/show/q), so a copied link, a
reload or Back restores the same record over the same filtered
list. A record this person may not see opens nothing: Received
shows a safe not-found line and the detail dialogs keep their
server-checked errors.

Rows in the four lists were click-only; each now opens from a real
link with a visible focus outline (copy link, new tab and keyboard
included), and moving to another page puts the focus on its
heading. Query-only moves keep the scroll position, so Back lands
where the list was left. The fax Send queues, Dashboard and
Received follow into Sent through the record address.

The command line already named the same records (faxes sent get,
faxes received get, faxes expected show, recipients show), so no
CLI change was needed; the console/CLI parity and settings
coverage checks pass unchanged. These lists have no paging
controls, so there is no page number to keep in the address yet.

Issue #54 (spec #48, after #49 and #51).
The focus move to a new page's heading tried once, right after the page
mounted, and gave up when no heading was there yet. Overview shows a
spinner until its data lands, so moving there left focus on the panel;
Number moves, Logs, Blocked senders and NPI record had no page heading
(h1) at all, so focus never moved on those either.

The shell now waits a bounded time for the page heading to appear and
focuses it then. It stops waiting when the person moves focus into the
page themselves, or when they leave the page. The four pages without an
h1 now render their existing title as the page heading, with the same
look.

The every-page navigation test now checks, for each page it opens, that
focus lands on that page's heading inside main (the Terminal hands it to
its shell once that opens), so a page without a heading fails the test.
Its timeout grows to 120 s for the extra waits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Overview shows a spinner before its heading. Opening it from another
page must still end with the keyboard focus on its heading. On the
code before the previous commit this test fails (focus stays on the
body), alongside the every-page check that lists Number moves, Blocked
senders, NPI record and Logs as pages without a heading to focus.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Two gaps in opening the received document a copied link names
(#/faxes/received?item=...):

- Someone without the owners list saw nothing at all: the page waited
  for a list it never loads. They now see the same short not-found line
  as for any document they may not see, and nothing opens.
- A document beyond the loaded list is read on its own. That answer was
  dropped whenever the page re-rendered before it arrived (the console
  shell hands the page a fresh callback on each of its renders), and it
  was never asked for again, so the link opened nothing. The answer now
  counts for as long as the address still names that document.

Both tests fail on the previous commit's Received.tsx.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The README said the command line opens a sent and a received fax with
`faxbot faxes sent get` and `faxbot faxes received get`. Those names
belong to the removed `jobs` and `inbound` groups; the commands are
`faxes sent show` and `faxes received show`. The record and roadmap
lines now give the right names (also in the received-history entry),
add the list filters the console's addresses match (`faxes sent list
--status/--hours/--held`, `faxes expected list --show/--search`), and
say what a record you may not see shows: Received says it could not be
found, the other lists show only why it could not be loaded.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ound trip

Opening a fax in Sent now travels in the address (?fax=), so the shell's
jobToOpen state was never set and the Sent page's openJobId/onOpened
wiring did nothing. Both are removed from the shell and PageContext;
JobsList keeps its openJobId prop for callers outside the shell.

A shell-level test signs in at a filtered Sent list, opens a fax from
its row link, checks the address carries the filter and the fax, then
goes Back (details close over the same filtered list) and Forward (the
same fax opens again).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The "Open it" buttons in a sent fax's details (the fax that carries its
remaining pages, the fax it continues, an uncertain fax's linked fax)
opened the other fax in place, so the address still named the first
fax: a copied link or a reload showed the wrong fax, and Back skipped
the first one. They now open the other fax through its address, like
a row link, so Back returns to the fax they were opened from.

The test fails on the previous JobsList.tsx (the address is never
told).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Adds the useful parts of the unverified request-identity work salvaged on
fleet/mac-request-identity-tests:

- A table test that stores an accepted request under the canonical
  (version 2) fingerprint and, separately, under the version-1 fingerprint,
  then replays the same Idempotency-Key with one changed send option
  (real call, urgent, send-by time, mailbox, workflow, labels, engine,
  cover-in-header, court digest, patient details). find_replay must refuse
  every one with IdempotencyConflict and store nothing. The version-1 rows
  are new coverage: other suites only check that an option changes the
  version-2 fingerprint, so an option dropped from the earlier-version
  fingerprint would replay an old record for a different request unnoticed.
  The patient value uses the JSON text that Patient.canonical() returns.
- Routing order and label order do not change a request's identity.
- Two different send-by times are different requests, not only "with" and
  "without" a send-by time.
- Upload hashing starts from the beginning even when the spool was moved,
  reads in bounded chunks and rewinds afterwards.

make venv now also installs the Python SDK in editable mode, as the CI
test-api job and the full suite workflow do (pip install -e ../sdks/python);
the API tests import it. CONTRIBUTING.md says so.

The salvaged empty-upload and read-failure tests are left out: the previous
commit covers both more strictly (cancellation too, the same error object,
the spool left open and unchanged).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@DMontgomery40
DMontgomery40 marked this pull request as ready for review October 30, 2026 20:44
@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:45:21.463239Z ad9fd4c Draft marked ready
ℹ️ 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 chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ad9fd4ce15

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +353 to +356
if (found) {
setRecordMissing(false);
setSelected((current) => (current?.id === found.id ? current : found));
return;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Invalidate pending document reads when selecting a listed item

If an older document A is loading through getWork(A) and the administrator uses Back or Forward to select document B already present in work, this branch selects B without changing recordAsked.current from A. When A's request finishes, its stale-response guard still passes and replaces B's details with A's, even though the address names B. Update the request-selection token on every address change, including this branch, so an outstanding read cannot reopen the wrong document.

Useful? React with 👍 / 👎.

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