Skip to content

Doctrines can auto-approve inventory-validated compliant submissions - #135

Merged
TrueMessenger merged 1 commit into
mainfrom
feat/auto-approve-by-rule
Jul 8, 2026
Merged

TrueMessenger merged 1 commit into
mainfrom
feat/auto-approve-by-rule

Conversation

@TrueMessenger

Copy link
Copy Markdown
Owner

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:

  • 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.

Behaviour

  • Auto-approvals keep reviewed_by NULL (with reviewed_at set). 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).
  • An AUTO_APPROVED action is written to the submission's audit log (no actor).
  • Reviewers are not pinged: notify_reviewers_new_submission now bails on any non-pending submission, so the guard is inherited by every caller.
  • The pilot is notified that their fit passed automatically ("Approved by rule").

Ordering / correctness

  • The status flip runs inside submit_fit's existing transaction, before the compliance_changed signal is emitted, so subscribers see the final APPROVED state once rather than PENDING-then-APPROVED.
  • The pilot notification is enqueued from the view call sites (ship_inventory, submission_recheck) after the transaction commits — matching the existing reviewer-notification pattern — never from inside the open transaction.
  • The re-check flow inherits auto-approval for free, since it goes through submit_fit.

UI

  • Doctrine edit card and create wizard gain the Auto-approve select, with help text noting it applies only to inventory (ESI) submissions.
  • Submission status badge + detail page show "Approved by rule" for the auto case.

Migration

0039_doctrine_auto_approve_and_more adds Doctrine.auto_approve and the AUTO_APPROVED submission-log action. SubmissionActionLog.actor was already nullable — no nullability change needed.

Tests

New fitcheck/tests/test_auto_approve.py covers 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 check and makemigrations --check clean.

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.
@TrueMessenger
TrueMessenger merged commit 5596bff into main Jul 8, 2026
4 checks passed
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