Archive copy must succeed before a packet counts as filed (issue 57) #59

Merged
spencerm merged 1 commits from archive-blocks-filing into main 2026-11-04 03:59:39 +00:00
Owner

Spencer's answer on issue 57 (open question 53): the copy must succeed before the packet counts as filed. If it fails, Admin is told with details and the packet stays in its previous stage so filing can be tried again.

What changes

  • FILE copies in the filing transaction. After the data book is stored, FILE checks the archive folder and copies the seal (data book, documents, manifest), then records the archive_copies row as done. Code is in domain/archive.py (copy_at_filing) and domain/pipeline.py.
  • A failed check or copy blocks the filing. The whole filing rolls back: no seal, no data book, and the packet stays complete. The person filing gets 503 archive_failed with the reason.
  • Admin is told. In its own transaction the server writes an archive.filing_blocked audit row and raises the critical archive_failed condition for that packet (subject filing:<packet id>). The alert names the packet, who tried, the folder and the error. A failed retry only counts on the open condition. The next successful filing clears it.
  • The worker job only catches up. archive-copy now handles filings made while the archive was off, with the same retries and its own archive_failed condition (subject archive).
  • Archive off works as before. With ARCHIVE_ROOT unset, or no folder saved, filing is unchanged.
  • Docs. PLAN question 53, CHANGELOG, FEED.md and SECURITY.md are updated.

Tests

  • test_archive.py is reworked. FILE makes the copy itself. Filing is refused when the folder is gone, and goes through once it is back, with the condition cleared. Filing is refused on a copy error or an unexpected error. No folder saved means no copy.
  • ruff, mypy and the non-PostgreSQL tests pass locally. The PostgreSQL tests run in branch CI.

One known edge: if the database commit fails after the files are written, an orphan folder stays in the archive. Packet Station never deletes there, and a refile writes a new seal folder.

🤖 Generated with Claude Code

Spencer's answer on issue 57 (open question 53): the copy must succeed before the packet counts as filed. If it fails, Admin is told with details and the packet stays in its previous stage so filing can be tried again. ## What changes - **FILE copies in the filing transaction.** After the data book is stored, FILE checks the archive folder and copies the seal (data book, documents, manifest), then records the `archive_copies` row as done. Code is in `domain/archive.py` (`copy_at_filing`) and `domain/pipeline.py`. - **A failed check or copy blocks the filing.** The whole filing rolls back: no seal, no data book, and the packet stays `complete`. The person filing gets 503 `archive_failed` with the reason. - **Admin is told.** In its own transaction the server writes an `archive.filing_blocked` audit row and raises the critical `archive_failed` condition for that packet (subject `filing:<packet id>`). The alert names the packet, who tried, the folder and the error. A failed retry only counts on the open condition. The next successful filing clears it. - **The worker job only catches up.** `archive-copy` now handles filings made while the archive was off, with the same retries and its own `archive_failed` condition (subject `archive`). - **Archive off works as before.** With `ARCHIVE_ROOT` unset, or no folder saved, filing is unchanged. - **Docs.** PLAN question 53, CHANGELOG, FEED.md and SECURITY.md are updated. ## Tests - `test_archive.py` is reworked. FILE makes the copy itself. Filing is refused when the folder is gone, and goes through once it is back, with the condition cleared. Filing is refused on a copy error or an unexpected error. No folder saved means no copy. - ruff, mypy and the non-PostgreSQL tests pass locally. The PostgreSQL tests run in branch CI. One known edge: if the database commit fails after the files are written, an orphan folder stays in the archive. Packet Station never deletes there, and a refile writes a new seal folder. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
spencerm added 1 commit 2026-11-03 22:52:11 +00:00
Archive copy must succeed before a packet counts as filed (Gitea issue 57)
ci / frontend (pull_request) Successful in 1m0s
ci / server (pull_request) Successful in 13m45s
ci / image (pull_request) Skipped
ci / e2e (pull_request) Successful in 5m49s
6adaf7bf25
FILE checks the archive folder and copies the packet inside the filing
transaction. A failed check or copy rolls the filing back, so the packet
stays in its previous stage; the person filing gets 503 archive_failed,
and in its own transaction the server writes an archive.filing_blocked
audit row and raises the critical archive_failed condition to Admin for
that packet (who tried, folder, error). The next successful filing clears
it. The archive-copy job now only catches up filings made while the
archive was off. PLAN question 53, CHANGELOG, FEED and SECURITY updated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
spencerm merged commit 18333600b5 into main 2026-11-04 03:59:39 +00:00
spencerm deleted branch archive-blocks-filing 2026-11-04 03:59:39 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: spencerm/PacketStation#59