document-archive-healthy: a REST delete only SOFT-deletes in Paperless — the check's own cleanup leaves its fixture in the trash, where it keeps its checksum and refuses every later consume as a duplicate while search reports the archive clear #1332
Labels
No labels
agent-blocked
agent-working
autopilot
bug
deferred
deploy-pending
enhancement
landing-pr
model-haiku
model-opus
model-sonnet
needs-design
needs-info
needs-triage
no-triage
out-of-scope
priority
ready-for-agent
ready-for-human
ready-for-session
rehearsal-183
snapshot-pending
standing-drive
wayfinder:grilling
wayfinder:map
wayfinder:prototype
wayfinder:research
wayfinder:task
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Matou/idss#1332
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The failure
Drive
20260908T225808Z(targetbrands, on7d7052fc, sig132bf7d1dfb0): 11 legs green —deploy-document-archiveheld (825.2s) — and red atdocument-archive-healthyafter the full 360s warm-up re-probe (#556),362307ms(artifacts/legs.json,artifacts/verdict.json→firstRedLeg: document-archive-healthy).Parperless was serving throughout.
logs/guest-failed-units.logreports "0 loaded units listed";logs/guest-resources.log:23-26,39shows granian on:28981, both celery processes,manage.py document_consumerand redis all up since 23:34–23:35.The evidence
logs/guest-control-plane.loggives the shape exactly::130, 23:36:01) —paperless: the document was taken in but cannot be found by searching — the document archive kept nothing findable on the dataset:131-165, 23:36:14 → 23:43:46) and every probe of the second loop after them (:166-201,attempt=1 attempts=1, right to 23:49:49) — the identicalpaperless: the document archive took the document in but could not process it (the OCR/consume pipeline failed)Not one probe in eleven minutes came back green.
logs/guest-system-journal.log:3-4names the cause verbatim:repeated on every 10s probe to the end of the run.
The defect (two stacked, verified against the pinned source)
I realized the pinned paperless-ngx source the guest runs (
/nix/store/91q0r1c79ar72b45w14ax1ky5hnyvlg1-source,pyproject.toml:3→version = "2.20.15", matching the guest'sccvgk07…-paperless-ngx-2.20.15in the traceback) and read it.1 —
control-plane/cmd/control-plane/paperlesshealth.go:293-302(pre-fix):paperlessConfirmFindableread the search ONCE, immediately after the consume task reported SUCCESS. Paperless commits its full-text index through a whooshAsyncWriter(src/documents/index.py:139-148,open_index_writer;add_to_indexis connected todocument_consumption_finishedatsrc/documents/apps.py:27), which under writer contention hands the commit to a background thread and returns. The index can therefore land AFTER the task is SUCCESS — probe 1 called a document the archive HAD kept unfindable.2 —
paperlesshealth.go:344-361(pre-fix), the wedge: probe 1's cleanup then found nothing to delete, so document #1 stayed live and probes 2+ were refused as duplicates. The wedge became permanent once a later cleanup DID delete it:DELETE /api/documents/<id>/only soft-deletes in Paperless 2.x.pre_check_duplicate(src/documents/consumer.py:804-826) queriesDocument.global_objects— trash included — matchingchecksum/archive_checksum, and appends exactly the giveaway the journal printed (:816-818). Full-text search reads the LIVE dataset only, sopaperlessEnsureClean's search gate (#1169,paperlesshealth.go:325-337) saw a perfectly clear archive and handed in a document the consumer could only refuse. No warm-up window of any length could clear it.The fix
paperlessDeleteFixturespurges what it deletes —POST /api/trash/ {"action":"empty","documents":[…]}(src/documents/views.py:3238-3241→documents/tasks.py:355-374, run inline,documents.delete()"effectively a hard delete") — and sweeps any fixture an interrupted run left trashed, matched on the check's OWN reserved title (paperlessFixtureTitle) so a community's real trashed documents are never named.paperlessEnsureCleangates on the TRASH as well as the search: a search-clear archive is not a consume-clear archive.paperlessConfirmFindablere-reads across a short bounded window (paperlessFindWindow, 15s) instead of demanding an eventually-consistent index be instantaneous.Suspected layer
The port's deploy-time health check (
control-plane/cmd/control-plane/paperlesshealth.go, ADR 0062) — its re-run contract against the upstream's real delete semantics. Not the render, not the deploy:internal/clan/paperless.gostood the service up correctly anddeploy-document-archivewas green.GOTCHAS #200 records the hazard.
Proposed ruling (Ruled by the healer under ADR 0174 — veto anytime)
Two-way door, confident, mechanical — not a design decision.
Why it is a mechanical repair, not a design decision. Nothing about what the check means to do changed. It already meant to "delete the fixture again at the end, so a retry never trips over its own leftovers" (the file's own header comment,
paperlesshealth.go:17-19) and already meant to prove the document "comes back from a full-text search". It simply did not do either:DELETEdoes not delete in Paperless, and an eventually-consistent index was read as if it were immediate. The change makes the code do what it already said it did. No new default, no changed message at a trust moment, no route shape, no secrets shape, no security posture. The operator-facing summaries are byte-identical — the sentencepaperless: the document was taken in but cannot be found by searching — the document archive kept nothing findable on the datasetis re-added unchanged (it appears twice now, once per exit branch), and the check'sSummaryline is untouched.Revertible how.
git revert 8a5d0568restores the file wholesale — the change is confined to four functions in one non-exported file plus additive tests and a GOTCHAS entry. It touches no schema, no dependency, no infra state, no persisted data shape, and nothing outside this checkout. Nothing downstream reads the new helpers.Proven by which test. Three new tests in
control-plane/cmd/control-plane/provision_paperless_health_test.go, each watched fail first with the drive's own error sentences:TestPaperlessHealth_ReRunsAgainstPaperlessRealDeleteSemantics— drives the check TWICE againstfakePaperlessWithTrash, a double that models the upstream faithfully (a delete soft-deletes; the checksum stays occupied from the trash; trashed documents are invisible to search;POST /api/trash/purges). Pre-fix the second run reds with the drive's exact sentence; post-fix both runs pass and the fake's trash and live sets are both empty.TestPaperlessHealth_TrashedLeftoverIsSweptBeforeHandingInANewDocument— a prior run's trashed fixture must be swept before this run hands in its own document.TestPaperlessHealth_FindRidesOutTheIndexCommitLag— the post-consume search misses once, as the AsyncWriter lag makes it; pre-fix this reds with probe 1's exact sentence.Rules 1 and 2 self-check. 3 files; 144 changed non-test lines (
paperlesshealth.go113/23,docs/GOTCHAS.md8/0) — the test file is 200/0, additions only, zero removed lines. Every one of the 23 removed lines is product code in the two rewritten function bodies; no assertion/expectation removed or edited, no test or leg declaration removed, no skip added. (My crude rails regex flagged one removed line — it matched the substringt.Errorinsidefmt.Errorf, product code, and that exact sentence is re-added.) No.sandcastle/rehearsal-*or.forgejo/workflows/path in the diff. Not pushed. Built on the workstation (never the drive host) and closed through the close-report gate — the same gate a swarm worker passes.drive
20260908T225808Zred atdocument-archive-healthy(sig 132bf7d1dfb0) — self-fixed on the fast lane, commite0a0937f0f9691167f227e241aff4f15bd7f7df7; checks: targeted (red-first):go test ./control-plane/cmd/control-plane/ -run 'TestPaperlessHealth_(ReRunsAgainstPaperlessRealDeleteSemantics|TrashedLeftoverIsSweptBeforeHandingInANewDocument|FindRidesOutTheIndexCommitLag)' -v→ all three FAIL before the fix, reproducing the drive's two sentences verbatim (… took the document in but could not process it (the OCR/consume pipeline failed)×2, and… cannot be found by searching — the document archive kept nothing findable on the dataset); all three PASS after (2.015s). package:go test ./control-plane/...→ ok,control-plane/cmd/control-plane24.705s, all other packages ok;TestComposeProvision_DocumentArchiveActivatesOnlyOnARealConsumeAndFindPASS in all three subtests (the negative "keeps nothing findable" subtest now takes 16.03s — the honest cost of the bounded find window, and it still reds). regression:TestPaperlessHealth_StaleFixtureDoesNotGreenVacuously(#1169's vacuous-green guard) still PASS. trees:go test ./internal/...→ no failures. root cause verified against the realized pinned source/nix/store/91q0r1c79ar72b45w14ax1ky5hnyvlg1-source(paperless-ngx 2.20.15,pyproject.toml:3):src/documents/consumer.py:804-826pre_check_duplicatequeriesDocument.global_objectsand appends the trash note;src/documents/views.py:3207-3242TrashViewwith{"action":"empty","documents":[…]}→src/documents/tasks.py:355-374empty_trash, called inline, a hard delete;src/documents/index.py:139-148open_index_writerusesAsyncWriter;src/documents/views.py:2665-2670confirms?task_id=IS honoured (so the SUCCESS the check read was genuinely its own task, not a stale one).go build ./...→ clean;gofmt -l control-plane/→ clean;go vet ./control-plane/...→ clean. commit shape: 3 files, 144 changed non-test lines, one commit8a5d0568, not pushed; working tree clean.. evidence:/home/swarm/swarm/Matou/idss/test-results/private-path/20260908T225808Zon matou-workstation.close-report for #1332 — status
success✅ close-report gates passed — every claim verified against main; issue closed.
envelope