Skip to content

feat(laboratory): results held when a lot they used is rejected; signed rejection of a used lot - #94

Merged
gabalint merged 6 commits into
developfrom
feat/reagent-approval-check
Dec 2, 2026
Merged

gabalint merged 6 commits into
developfrom
feat/reagent-approval-check

Conversation

@gabalint

@gabalint gabalint commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

Summary

Second increment of the roadmap area Reagent and standard lots in use (requirement OQ-011): lots are checked again at approval, and a lot found defective after use is handled.

  • Every lot a result rests on is checked again for the day it was used. These are the lots recorded with the test's current replicates, with the plates a count was read from (for the moment the plates went in), and with the current QC of its batch. The check runs:
    • at the signed test review, which locks the lots so a rejection signed meanwhile follows it;
    • in every gate where the result counts: lot disposition, stability pull acceptance (tested in the system or linked to a lot sample) and reassessment conclusion.
  • A lot that was not fit for use that day never supports a result. The check is made on the lot's record now: release time, used up, receipt, opening for an in-use period, last day of use, and for source lots their release and last day of use.
  • A lot or source lot rejected since holds the result until a concluded impact assessment whose cause is that lot names the test. The latest concluded one decides; an open or withdrawn assessment decides nothing.
    • Not affected: the result goes on.
    • Affected: a conforming result is not reviewed (return it; correct the replicates with a fit lot, or quality records not completed), and a reviewed one does not count. A failing result can still be reviewed, so that its investigation decides it.
  • A review refused for its lots is audited (test.review_refused, with the lots), after the rollback.
  • A used lot is rejected only by quality, with a signature. "Used" means a use of it, a solution prepared from it, or a use of such a solution. The signature meaning is rejected (reject_used_reagent). The unsigned rejection refuses a used lot, and every use and preparation locks the lot, so the check holds until either side commits.
  • After the signature, New impact assessment is offered, prefilled:
    • with the lot, the period of concern from the lot's first use, and the rejection as the problem;
    • Cancel returns to the lot.
  • The lot page gets an Impact assessments section and a notice saying its results wait for an assessment. Assess impact becomes the main action while no assessment names the lot.
  • The test page gets a Lots checked again notice that explains the hold and links each lot and assessment.
  • Architecture: testing still imports neither the laboratory nor the impact module. The bench adapter gains recheck_lots(uses, lock=False) and composes laboratory.eligibility.reagent_fitness with impact.services.reagent_decisions.

These are product choices recorded in docs/product.md and the regulatory matrix note of 2026-12-01. No source read sets a check at approval or what happens to results when a lot is found defective.

No migration. Results recorded with a lot rejected before this release are held the same way until an assessment of that lot decides them (changelog technical note).

Documentation

  • Page docs updated: reagent reject and record, test record and review, new impact assessment, lot record, pull acceptance, reassessment conclusion.
  • docs/product.md (status tables and a new paragraph), architecture (the recheck contract and its locks) and the regulations note.
  • Roadmap card: the second increment moves into "Already built", and the tooltip now names what remains.
  • Changelog entry, and traceability under OQ-011.

Verification

  • ruff check, ruff format --check, Django check, makemigrations --check --dry-run (PostgreSQL), collectstatic, changelog --check.
  • New tests/test_reagent_rejected_since.py (13 tests) covers:
    • the signed rejection: roles, wrong PIN, stale revision, already rejected, use through a preparation;
    • a rejection waiting for a review, and an unsigned rejection racing a use;
    • the review hold, with the refusal audited and nothing signed;
    • open vs concluded assessments, affected-conforming returned and corrected, affected-failing reviewable;
    • a source lot of a solution;
    • the disposition blocked, then cleared by a later assessment;
    • the outcomes and stability wiring, the current QC of a batch, the dated recheck, and the pages.
  • Plate regression in tests/test_plate_count_journey.py: a medium used up between plating and reading does not hold the count.
  • Browser journey e2e/test_reagent_rejected_journey.py: signed rejection in the dialog, the prefilled assessment, the held test, the review after the conclusion.
  • Full PostgreSQL suite, affected browser journeys and the deploy smoke rehearsal: results in the comment below.
  • An independent review found 1 High, 2 Medium and 7 Low issues. Fixed:
    • High: plate lots were checked at reading time;
    • Medium: traceability of the e2e module, and test gaps (QC batch, plates, unsigned rejection race);
    • Low: stability page queries, banner wording, withdrawn assessments on the lot page, and doc/roadmap overclaims.
  • Accepted as is:
    • a sub-second midnight window between the entry check and recorded_at;
    • the ranking choice: the latest concluded assessment decides, and a newer open one does not re-hold a cleared result.

Notes for reviewers

  • A reviewed conforming result found affected does not count, and nothing repeats it yet. Its lot is not released on it. This is listed as remaining work in docs/product.md.
  • Opening the nonconformance in OpenBGA Lab Ops still waits for the Lab Ops inbound API. The nonconformance recorded by hand at the assessment's conclusion works today.

🤖 Generated with Claude Code

Gabriel Balint and others added 6 commits December 2, 2026 01:05
…ed rejection of a used lot

Every lot a result rests on (current replicates, the plates a count was read
from, the current QC of its batch) is checked again for the day it was used
when the test is reviewed and wherever the result counts toward a decision:
lot disposition, pull acceptance, reassessment conclusion. A lot or source lot
rejected since holds the result until the latest concluded impact assessment
of that lot decides it. A used lot is rejected only with a quality signature,
which offers the impact assessment from the lot's first use. A review refused
for its lots is audited (test.review_refused).

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

- A count read from plates repeats the plates' lots in its own evidence; they
  are now checked only for the moment the plates went in (a medium used up
  between plating and reading no longer holds the count).
- Stability study pages check the lots of all pulls at once.
- A withdrawn assessment does not count as the lot's assessment.
- The test page names a lot not fit that day apart from one rejected since.
- Tests: current QC of the batch, plates, an unsigned rejection racing a use;
  e2e journey traced; product and roadmap wording.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The lots are checked through review_state_refusal as before and once more
under lock in the signed review.

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

The signed review locks the lots first, then asks review_state_refusal; a
refusal for the lots is audited after the rollback. Tests look signatures up
by object type.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gabalint

gabalint commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator Author

Verification of the final candidate (546abc0; c93455e only adds the PR number to the changelog entry):

  • Static checks: ruff check, ruff format --check, Django check, makemigrations --check --dry-run (PostgreSQL), collectstatic and changelog --check all pass.
  • Full PostgreSQL suite (pytest -n auto): 3748 passed, 3 skipped.
  • Browser journeys: 7 passed — e2e/test_reagent_rejected_journey.py, plus reagent in use, calculation bench, impact assessment, plate count and page docs.
  • Deploy smoke rehearsal on a local copy of the synthetic demo data: 7/7.
    1. /health/ and /ready/ answer.
    2. A lot is recorded and released.
    3. A solution is prepared from it.
    4. The analyst is refused the rejection of the used lot (403).
    5. Quality signs the rejection and lands on New impact assessment, prefilled with the first use and the rejection's reason.
    6. The lot page says no assessment was started and offers Assess impact first.
    7. The page docs describe Sign and reject.
  • Earlier local gate runs caught two issues, both fixed in this branch:
    • a validation test stubs review_state_refusal with two arguments, so the signature is kept;
    • the refusal audit was skipped when the unlocked check refused first, so the review now locks the lots before it asks.
  • CI on c93455e: application, browser, container-smoke and entry pass; validation-pack is running.

@gabalint
gabalint merged commit 58216bd into develop Dec 2, 2026
5 checks passed
@gabalint
gabalint deleted the feat/reagent-approval-check branch December 2, 2026 06:59
@gabalint

gabalint commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator Author

Merged as 58216bd. Develop CI run 46828972154 succeeded at 07:15:48Z (application, browser, container-smoke and validation-pack all pass).

The synthetic demo switched its running release from d59ff84 to 58216bd at 07:17:10Z, read from the demo itself. The deployment smoke test passed 7/7 on https://fresh-coa-lims.onrender.com:

  • /health/ and /ready/ answer;
  • a lot is recorded, released and used through a preparation;
  • the analyst is refused its rejection (403);
  • quality signs the rejection and lands on the prefilled impact assessment;
  • the lot page says no assessment was started;
  • the page docs describe Sign and reject.

The smoke test left one rejected synthetic lot and one prepared solution, and started no assessment. There is no migration in this change.

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