Doctrines can auto-approve inventory-validated compliant submissions - #135
Merged
Merged
Conversation
Add a per-doctrine Auto-approve setting (Off by default) that approves a submission the moment it is graded, with no human reviewer, when it: - came from ESI inventory validation (never a pasted fit, which is unverifiable text and can't be tied to a real hull), - was graded against that doctrine, and - reached the configured verdict tier (Compliant only, or Compliant or with substitutions). Auto-approvals keep reviewed_by NULL (with reviewed_at set) as the marker that renders as "Approved by rule" in the status badge and on the submission page, distinct from a reviewer approval. They record an AUTO_APPROVED action in the submission log, never notify reviewers (notify_reviewers_new_submission now bails on any non-pending submission), and notify the pilot that their fit passed automatically. The status flip happens inside submit_fit's transaction, before the compliance_changed signal is emitted, so subscribers see the final APPROVED state once. The pilot notification is enqueued from the view call sites (after the transaction commits), matching the existing reviewer-notification pattern. Migration 0039 adds Doctrine.auto_approve and the AUTO_APPROVED action.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a per-doctrine Auto-approve setting (Off by default) that approves a submission automatically, with no human reviewer, the moment it is graded — when the submission:
Behaviour
reviewed_byNULL (withreviewed_atset). That pairing is the marker that renders as "Approved by rule" in the status badge and on the submission page, kept visually distinct from a reviewer approval (which keeps the reviewer's name).AUTO_APPROVEDaction is written to the submission's audit log (no actor).notify_reviewers_new_submissionnow bails on any non-pending submission, so the guard is inherited by every caller.Ordering / correctness
submit_fit's existing transaction, before thecompliance_changedsignal is emitted, so subscribers see the finalAPPROVEDstate once rather than PENDING-then-APPROVED.ship_inventory,submission_recheck) after the transaction commits — matching the existing reviewer-notification pattern — never from inside the open transaction.submit_fit.UI
Migration
0039_doctrine_auto_approve_and_moreaddsDoctrine.auto_approveand theAUTO_APPROVEDsubmission-log action.SubmissionActionLog.actorwas already nullable — no nullability change needed.Tests
New
fitcheck/tests/test_auto_approve.pycovers the verdict-tier matrix (mode × verdict), ESI-only and doctrine gating, the EFT-never-auto-approve rule, single final-state signal emission, reviewer-notification suppression, the pilot "Approved by rule" notification (and that a reviewer-less pending submission still stays silent), the re-check-view flow, and that the human review path is unaffected.Full suite: 774 passed (758 baseline + 16 new).
manage.py checkandmakemigrations --checkclean.