* feat(review): add review queue schema with restore validation
Add the Needs review schema group (media_review_metadata,
media_review_items, media_review_decisions) beside the image annotation
group it cites. review_schema_error validates the catalog, columns,
foreign keys, row values and canonical 8 MiB evidence read-only;
migrate_review_state installs it in a SAVEPOINT after the annotation
group, and verify_database_file requires it under require_library_state.
A review group without a valid annotation group is refused. Decisions
null their pair and image navigation through indexes when those are
deleted. Old backups and annotation-era backups restore and gain the
group; browser fixtures clear the new tables on reset.
* feat(review): persist ambiguous sampler evidence from scans and new outputs
The output scan and the live monitor now queue every file the ingestion
resolver finds ambiguous for Needs review. The file is captured, its metadata
is read again from the capture and resolved with the default profile, and only
an ambiguous result is stored, bound to the capture's annotation byte record
and fenced by its storage epoch. Evidence holds one hashed projection per
selectable candidate; none, more than 16 or over 8 MiB is a limited item.
Recording is idempotent per bytes and evidence and never touches a decision.
Scan statuses, counters, outcome rows and legacy SSE events are unchanged; the
job scope gains review_items/review_errors and the log a Needs review line.
The monitor records after its fallback link, best effort.
* feat(review): explicit association decisions with compatible linking
Needs review gains its queue reads and decisions:
- GET /prompt_manager/review/items lists pending items oldest first with
the exact pending total and an HMAC keyset cursor bound to the storage
epoch and the review index revision.
- GET /prompt_manager/review/items/{id} adds the candidates (role texts,
label, selectability), the dependency fingerprint and the digest.
- POST /prompt_manager/review/items/{id}/decision applies a candidate only
for a capture of the item's bytes that the current file still hashes to
and whose evidence is unchanged, through the ingester's compatible-only
rules in the same transaction as the decision row; a conflict writes
nothing. Leave unresolved records the decision and links nothing.
ingest_resolved_pair keeps its contract; its body moves into
_ingest_resolved_pair_in, which runs in the caller's transaction.
Items keep the file's recorded spelling so targets keep their case on
Windows, and a rescan skips the copy and hash of a file whose size and
mtime match the bytes an item already cites.
* fix(review): build the spelling validation test from native paths
On Windows the locator is case-folded and uses backslashes, so the fixed
POSIX pair /out/a.png no longer folded to itself and the new spelling
check refused the good case. The test now spells a mixed-case native path
and folds it with os.path.normcase, and also refuses a locator of another
file.
* fix(review): Apply sees the file under every spelling and rechecks only its choice
Apply now finds the legacy rows of the same physical file however its root
is reached. The roots are real paths while the monitor links under the
directory it watches, so a symlinked or junctioned root, subst or a mapped
drive used to hide the monitor's row and Apply added a second, differently
linked row. Same-name rows are resolved to their physical identity
(normcase(realpath), else samefile); the dependency fingerprint covers all
of them, two rows refuse the choice, one row is enriched under the
ingester's compatible-only rules, and a same-name row the request did not
classify is a changed association.
Apply re-verifies only what the decision depends on: the bytes are still
ambiguous and still offer the chosen candidate. A resolver change that
rewords the reason or reorders candidates leaves pending items applicable.
The resolver version is one constant in prompt_pair_resolver, shared by
ingestion provenance and Needs review.
The transaction's byte check receives the re-hashed digest (or the body's
for Leave unresolved), every Apply refusal branch is tested with zero
writes, and the root listing and realpath calls run on a worker thread.
* fix(review): validate stored review evidence once per startup
Startup used to run the full review validation twice (the early guard and
the install) and the annotation group's row checks inside each, so every
evidence document was parsed and re-encoded twice. The early guard is now
catalog-only (a review group without annotation tables), and the install
validates the group once, trusting the annotation group it has just
validated. The evidence predicate no longer pattern-scans every document in
SQL, because the streamed canonical pass proves it, and the codec is built
once.
Measured on a database with 40,000 items of 4 KiB evidence: startup open
went from 7.7 s to 2.5 s. A test pins one evidence pass per reopen.
Restore and verify_database_file keep the full validation.
* fix(review): keep one capture worker for interactive requests
Needs review recording from the scan and the monitor shared the capture
store's two workers with the Tag dialog and Apply, so a busy scan could
answer a user's preview or decision with "Too many previews are open".
Background captures now never take the last worker or capture slot, and
wait up to two seconds for room before counting the file as not added.
Interactive captures are admitted or refused at once, as before.
* fix(review): refresh the recorded spelling when a file is seen under a new one
A case-only rename on Windows or macOS keeps size and mtime_ns, so the
rescan skipped the file and the item kept the old spelling. Its target was
then formatted from a name the directory no longer lists, the capture
refused it, and the item stayed pending with no way to apply it. The skip
path and a duplicate insert now record the current spelling for every item
at the locator and move the review index revision; item revisions do not
change, so an open decision stays valid. Tested under case-folding
semantics on every platform.
* fix(review): final capture store close and recoverable stale cursors
Closing the capture store at shutdown now runs under the store lock and is
final: a monitor recording or scan batch still in flight gets a capture
error instead of creating a new temp directory and restore subscription
after the cleanup.
A well-formed queue cursor this process cannot verify (opened before a
ComfyUI restart, whose cursor secret is per process) now answers 409
review-conflict with the current total, like any other stale page, instead
of an uncoded 400. Malformed cursors stay 400.
* fix(review): make only the shutdown cleanup final
The previous commit made every close of the capture store final, which
also refused the explicit closes that swap in a fresh store. Only the host's
on_cleanup hook is final now; an observe after it answers a coded capture
error instead of an unhandled 500.
* refactor(admin): move Needs review recording into its own mixin
_record_scanned_review, _record_review_sync, record_review_file and
_log_review_items move unchanged from py/api/admin.py to
py/api/review_recording.py (ReviewRecordingMixin), keeping admin.py from
growing further past the size ceiling. No behaviour change.
* fix(review): record the review fix round and the skip's residual risks in TESTING.md
The Needs review paragraphs now state the rescan skip's residual risks (an
in-place rewrite that keeps size and mtime_ns is never re-queued; a deleted
or moved file leaves its pending item counted), the physical identity rule
for Apply, the candidate-only recheck and shared resolver version, the
spelling refresh, background capture admission, the final shutdown close,
the stale-cursor answer and the measured startup validation cost.
* fix(review): refuse monitor recording beside record-changing jobs
System S1 (#289) gives every record change a registry admission class. The
scan already records Needs review items under its own records job. The
monitor's recording lasts one file and is not a job, so it now checks the
records admission: while a records or guarded job or hold runs it records
nothing, logs that the file waits for the next scan, and answers deferred.
The fallback link stands and the next "new" scan reads the ambiguous file
again, because a fallback link is not a resolved one.
JobRegistry.blocker and active iterate a snapshot of the jobs, since the
monitor's worker thread now asks them too.
* test(backup): wait for the restore, not a 5 s timer, in the thread test
test_database_is_usable_from_every_thread_after_restore let its worker
wait 5 s for the restore. On a stalled Windows runner (py3.11, where the
previous restore test also took 25 s instead of 0.3 s) the restore took
longer, the wait timed out, and the worker read the old database before
the restore ran. The worker now waits for the event under a 120 s bound
that only a hung test reaches, reports a timeout as an error, and the
main thread releases it even when the restore raises. With a restore
delayed by 6 s the old test fails and the new one passes.
* fix(review): store non-finite evidence as null and count pending items
canonical_evidence now follows main's non-finite policy (#303): NaN and
±Infinity are written as null instead of raising, so a NaN-stamped graph
never turns a review item limited. The System Overview reports the review
queue's pending total in needs_review.pending, read in the same snapshot
as the Library counts.
* fix(review): show the pending count on the System Overview review row
The Overview's review row now reads "N ambiguous image links" with the
concept's line, from needs_review.pending. Its Review metadata action
stays aria-disabled until the Needs review page ships. The system specs
and their concept comparison follow the real count.
* fix(system): answer the Overview and Statistics only after every read ended
asyncio.gather answered at the first failed read while its sibling
executor reads were still inside SQLite. In the suite the test teardown
then deleted the database under the running read, and py3.10 on Ubuntu
segfaulted in get_statistics (test_statistics_failure_is_an_error_envelope).
Both routes now wait for all their reads before answering.
* fix(review): queue only ambiguous files that nothing links, and heal the queue
The maintainer's live scan (19,908 files, scope "new") reported 4,677 files
under Needs review, but the queue held 10,232 items: every file the strict
resolver found ambiguous was queued, including the ones the legacy
browser-parser fallback then linked (all sampled "added" rows) and the ones
already linked to a known prompt (135 of 200 sampled "known" rows).
A file is now queued only when its final outcome is ambiguous and unlinked:
the resolver finds it ambiguous, the fallback links nothing and no saved row
links it already. An ambiguous file that a saved row links is reported as
unchanged ("Already linked to its prompt"), not as Needs review.
The queue heals itself. After each batch, the scan removes the pending items
of every listed file (read, or skipped as known) that a saved row now links.
The monitor does the same for each ambiguous output it links, and never
queues one. Only an undecided item is removed (pending, revision 0, no
decision row), so a decision is never deleted or changed and the schema
needs no new state.
The scan job's scope.review_items now counts this scan's files that are in
the pending queue after it, new or already there, so it agrees with the
review group's ambiguous rows and with the queue total. review_added and
review_settled are new, and the log gains "already in Needs review" and
"left Needs review · now linked" lines. A duplicate whose item is decided is
reported as "decided" and is not counted.
* fix(review): never queue an ambiguous file with nothing to choose
The maintainer's live queue held 39 items whose candidates all read
"unresolved" ("No positive / No negative"). An ambiguous result is now
reviewable only when at least two candidates are resolved with non-blank
positive text. With none the file could not be traced; with exactly one,
the untraced branches may still have made the file, so that text is not
certain either. Both are reported unresolved, never linked and never
queued (also the A1111 two-delimiter case, which has no candidates).
A rescan removes the pending items of such files whose own evidence
offers no choice, with the same safe delete as the linked settle
(pending, revision 0, no decision row). A limited item (over 16 candidates) that holds at least two
candidates is kept. The job scope gains review_untraced and the log
"= N images left Needs review · nothing to choose".
* test(scan): pin only the per-source scope keys beside the review counters
* test(system): match the scan scope keys beside the review counters
336 lines
14 KiB
Python
336 lines
14 KiB
Python
"""Needs review queues a file only when there is something to choose.
|
|
|
|
The maintainer's live queue (#284 / #288) held 39 items whose 11 candidates
|
|
all read "unresolved", "No positive / No negative": the ingestion resolver
|
|
found several sampler branches but could trace no prompt on any of them.
|
|
An ambiguous result is reviewable only when at least two candidates carry a
|
|
resolved prompt text. With none, the file could not be traced; with exactly
|
|
one, the other branches may still have made the file, so the one text is
|
|
not certain either (the resolver never flattens unknown semantics). Both
|
|
stay unresolved and are never queued, and a rescan removes the pending,
|
|
undecided items such files already have.
|
|
"""
|
|
|
|
import os
|
|
import unittest
|
|
from unittest.mock import patch
|
|
|
|
try:
|
|
from tests.test_review import DELIMITERS, write_png
|
|
from tests.test_review_outcome import OutcomeTestCase
|
|
except ImportError: # discovered with tests/ as the top-level directory
|
|
from test_review import DELIMITERS, write_png
|
|
from test_review_outcome import OutcomeTestCase
|
|
|
|
from database.review_schema import evidence_offers_choice
|
|
from utils import review_capture
|
|
|
|
|
|
def opaque_graph(*opaque, traced=()):
|
|
"""Several KSamplers: ``opaque`` positives come from an encoder the
|
|
ingestion resolver does not know, ``traced`` ones from CLIPTextEncode.
|
|
|
|
The first sampler is opaque, so the scan's browser-parser fallback links
|
|
nothing either.
|
|
"""
|
|
graph = {
|
|
"1": {"class_type": "CheckpointLoaderSimple", "inputs": {"ckpt_name": "m"}},
|
|
"2": {"class_type": "CLIPTextEncode", "inputs": {"text": "bad"}},
|
|
}
|
|
sides = [("OpaqueTextEncode", "prompt", t) for t in opaque]
|
|
sides += [("CLIPTextEncode", "text", t) for t in traced]
|
|
for index, (encoder_class, key, text) in enumerate(sides):
|
|
encoder, sampler = str(10 + 2 * index), str(11 + 2 * index)
|
|
graph[encoder] = {"class_type": encoder_class, "inputs": {key: text}}
|
|
graph[sampler] = {
|
|
"class_type": "KSampler",
|
|
"inputs": {
|
|
"model": ["1", 0],
|
|
"positive": [encoder, 0],
|
|
"negative": ["2", 0],
|
|
},
|
|
}
|
|
return graph
|
|
|
|
|
|
def _always_reviewable(_resolution):
|
|
return True
|
|
|
|
|
|
class ChoosableTestCase(OutcomeTestCase):
|
|
def _record_pre_fix(self, name):
|
|
"""An item as the pre-fix recorder stored it (no choosable test)."""
|
|
with patch.object(review_capture, "reviewable", _always_reviewable):
|
|
self._record(name)
|
|
|
|
def _write(self, name, graph):
|
|
write_png(self.output_dir / name, prompt=graph)
|
|
return self.output_dir / name
|
|
|
|
|
|
class TestChoosableCandidates(unittest.TestCase):
|
|
def _resolution(self, *states):
|
|
candidates = []
|
|
for index, state in enumerate(states):
|
|
side = {"text": f"t{index}"} if state == "resolved" else None
|
|
candidates.append(
|
|
{"sampler_id": str(index), "state": state, "positive": side}
|
|
)
|
|
return {"state": "ambiguous", "candidates": candidates}
|
|
|
|
def test_two_resolved_candidates_are_reviewable(self):
|
|
resolution = self._resolution("resolved", "resolved", "unresolved")
|
|
self.assertTrue(review_capture.reviewable(resolution))
|
|
|
|
def test_none_or_one_resolved_candidate_is_not_reviewable(self):
|
|
for states in ((), ("unresolved",) * 11, ("resolved", "unresolved")):
|
|
with self.subTest(states=states):
|
|
resolution = self._resolution(*states)
|
|
self.assertFalse(review_capture.reviewable(resolution))
|
|
|
|
def test_blank_or_missing_text_does_not_count(self):
|
|
resolution = self._resolution("resolved", "resolved")
|
|
resolution["candidates"][0]["positive"] = {"text": " "}
|
|
self.assertFalse(review_capture.reviewable(resolution))
|
|
resolution["candidates"][0]["positive"] = None
|
|
self.assertFalse(review_capture.reviewable(resolution))
|
|
|
|
def test_nested_ambiguous_stage_counts_its_own_candidates(self):
|
|
inner = self._resolution("resolved", "resolved")["candidates"]
|
|
resolution = {
|
|
"state": "ambiguous",
|
|
"candidates": [{"state": "ambiguous", "candidates": inner}],
|
|
}
|
|
self.assertTrue(review_capture.reviewable(resolution))
|
|
|
|
def test_a_result_that_is_not_ambiguous_is_not_reviewable(self):
|
|
resolution = self._resolution("resolved", "resolved")
|
|
resolution["state"] = "resolved"
|
|
self.assertFalse(review_capture.reviewable(resolution))
|
|
|
|
|
|
class TestStoredEvidenceOffersChoice(unittest.TestCase):
|
|
def test_unlimited_evidence_needs_two_choosable_candidates(self):
|
|
side = {"text": "cat"}
|
|
two = [{"state": "resolved", "positive": side}] * 2
|
|
self.assertTrue(evidence_offers_choice({"candidates": two}))
|
|
one = two[:1] + [{"state": "unresolved", "positive": None}]
|
|
self.assertFalse(evidence_offers_choice({"candidates": one}))
|
|
|
|
def test_limited_evidence_offers_a_choice_only_with_two_candidates(self):
|
|
self.assertTrue(
|
|
evidence_offers_choice({"limited": True, "candidate_total": 18})
|
|
)
|
|
for total in (0, 1, None, "18", True):
|
|
with self.subTest(total=total):
|
|
evidence = {"limited": True, "candidate_total": total}
|
|
self.assertFalse(evidence_offers_choice(evidence))
|
|
|
|
def test_malformed_evidence_offers_nothing(self):
|
|
for evidence in (None, [], {"candidates": "x"}, {}):
|
|
with self.subTest(evidence=evidence):
|
|
self.assertFalse(evidence_offers_choice(evidence))
|
|
|
|
|
|
class TestNothingToChooseIsNotQueued(ChoosableTestCase):
|
|
async def test_no_candidate_with_text_could_not_be_traced(self):
|
|
self._roots()
|
|
self._write("none.png", opaque_graph("cat", "dog"))
|
|
|
|
job = await self._scan()
|
|
|
|
self.assertEqual(self._items(), [])
|
|
self.assertEqual(self._pending(), 0)
|
|
self.assertEqual(job["scope"]["review_items"], 0)
|
|
(row,) = job["outcomes"]["review"]
|
|
self.assertEqual(row["path"], "none.png")
|
|
self.assertIn("could not be traced", row["detail"])
|
|
self.assertEqual(job["counters"]["review"], 1, job["counters"])
|
|
self.assertEqual(self._capture_files(), [])
|
|
|
|
async def test_exactly_one_candidate_with_text_stays_unresolved(self):
|
|
"""One traced branch beside untraced ones is not certain: no link."""
|
|
self._roots()
|
|
self._write("one.png", opaque_graph("cat", traced=("dog",)))
|
|
|
|
job = await self._scan()
|
|
|
|
self.assertEqual(self._items(), [])
|
|
(row,) = job["outcomes"]["review"]
|
|
self.assertIn("could not be traced", row["detail"])
|
|
self.assertEqual(job["counters"].get("added", 0), 0, job["counters"])
|
|
self.assertEqual(job["counters"].get("known", 0), 0, job["counters"])
|
|
|
|
async def test_two_candidates_with_text_are_queued(self):
|
|
self._roots()
|
|
self._write("two.png", opaque_graph("x", traced=("cat", "dog")))
|
|
|
|
job = await self._scan()
|
|
|
|
(item,) = self._items()
|
|
self.assertEqual(os.path.basename(item["locator"]), "two.png")
|
|
self.assertEqual(item["candidate_count"], 3)
|
|
self.assertEqual(job["scope"]["review_items"], 1)
|
|
(row,) = job["outcomes"]["review"]
|
|
self.assertIn("more than one prompt could match", row["detail"])
|
|
|
|
async def test_parameters_delimiter_ambiguity_is_not_queued(self):
|
|
"""Two A1111 negative delimiters offer no candidate to choose."""
|
|
self._roots()
|
|
write_png(self.output_dir / "delims.png", parameters=DELIMITERS)
|
|
|
|
job = await self._scan()
|
|
|
|
self.assertEqual(self._items(), [])
|
|
(row,) = job["outcomes"]["review"]
|
|
self.assertIn("could not be traced", row["detail"])
|
|
|
|
def test_recorder_reports_untraced_and_stores_nothing(self):
|
|
self._roots()
|
|
self._write("none.png", opaque_graph("cat", "dog"))
|
|
self._write("one.png", opaque_graph("cat", traced=("dog",)))
|
|
for name in ("none.png", "one.png"):
|
|
with self.subTest(name=name):
|
|
outcome = review_capture.record_ambiguous_file(
|
|
self.api.db, self.api._captures, self.output_dir, 0, name
|
|
)
|
|
self.assertEqual(outcome, "untraced")
|
|
self.assertEqual(self._items(), [])
|
|
self.assertEqual(self._capture_files(), [])
|
|
|
|
def test_monitor_does_not_queue_an_untraced_output(self):
|
|
self._roots()
|
|
path = self._write("none.png", opaque_graph("cat", "dog"))
|
|
|
|
self.assertEqual(self.api.record_review_file(str(path)), "untraced")
|
|
self.assertEqual(self._items(), [])
|
|
|
|
|
|
class TestUntracedItemsLeaveTheQueue(ChoosableTestCase):
|
|
async def test_rescan_removes_pending_items_without_a_choice(self):
|
|
"""The maintainer's 39 items: queued before the rule, gone on rescan."""
|
|
self._roots()
|
|
self._write("none.png", opaque_graph("cat", "dog"))
|
|
self._write("one.png", opaque_graph("cat", traced=("dog",)))
|
|
self._write("two.png", opaque_graph("x", traced=("cat", "dog")))
|
|
for name in ("none.png", "one.png", "two.png"):
|
|
self._record_pre_fix(name)
|
|
revision = self._review_revision()
|
|
self.assertEqual(self._pending(), 3)
|
|
|
|
job = await self._scan("all")
|
|
|
|
(item,) = self._items()
|
|
self.assertEqual(os.path.basename(item["locator"]), "two.png")
|
|
self.assertEqual(self._pending(), 1)
|
|
self.assertGreater(self._review_revision(), revision)
|
|
self.assertEqual(job["scope"]["review_untraced"], 2)
|
|
self.assertEqual(job["scope"]["review_items"], 1)
|
|
self.assertIn(
|
|
"= 2 images left Needs review · nothing to choose", "\n".join(job["log"])
|
|
)
|
|
|
|
async def test_decided_items_of_untraced_files_are_never_touched(self):
|
|
self._roots()
|
|
for name in ("sel.png", "unres.png"):
|
|
self._write(name, opaque_graph("cat", traced=(name, name + "2")))
|
|
self._record_pre_fix(name)
|
|
items = {os.path.basename(i["locator"]): i for i in self._items()}
|
|
self._decide(items["sel.png"], "selected")
|
|
self._decide(items["unres.png"], "unresolved")
|
|
before = (self._items(), self._decisions())
|
|
# The files now carry graphs without a choice, queued pre-fix.
|
|
for name in ("sel.png", "unres.png", "pending.png"):
|
|
self._write(name, opaque_graph("a cow", "dog"))
|
|
self._record_pre_fix(name)
|
|
self.assertEqual(self._pending(), 3)
|
|
|
|
job = await self._scan("all")
|
|
|
|
self.assertEqual((self._items(), self._decisions()), before)
|
|
self.assertEqual(self._pending(), 0)
|
|
self.assertEqual(job["scope"]["review_untraced"], 3)
|
|
|
|
async def test_an_item_with_a_choice_survives_beside_an_untraced_one(self):
|
|
"""Removal judges each item by its own evidence: an item that offers
|
|
a choice is not removed although the file's new bytes offer none."""
|
|
self._roots()
|
|
self._write("f.png", opaque_graph("x", traced=("cat", "dog")))
|
|
self._record_pre_fix("f.png")
|
|
(choosable,) = self._items()
|
|
self._write("f.png", opaque_graph("a cow", "dog"))
|
|
self._record_pre_fix("f.png")
|
|
self.assertEqual(self._pending(), 2)
|
|
|
|
job = await self._scan("all")
|
|
|
|
self.assertEqual([i["id"] for i in self._items()], [choosable["id"]])
|
|
self.assertEqual(job["scope"]["review_untraced"], 1)
|
|
|
|
async def test_limited_items_go_only_without_enough_candidates(self):
|
|
"""A pre-fix delimiter item (no candidate) goes; a limited item of 18
|
|
candidates may hold a choice and stays, though the bytes now offer
|
|
none."""
|
|
self._roots()
|
|
write_png(self.output_dir / "delims.png", parameters=DELIMITERS)
|
|
self._record_pre_fix("delims.png")
|
|
many = [f"prompt {n}" for n in range(17)]
|
|
self._write("many.png", opaque_graph("x", traced=many))
|
|
self._record_pre_fix("many.png")
|
|
kept = [i["id"] for i in self._items() if "many" in i["locator"]]
|
|
self._write("many.png", opaque_graph("a cow", "dog"))
|
|
|
|
job = await self._scan("all")
|
|
|
|
self.assertEqual([i["id"] for i in self._items()], kept)
|
|
self.assertEqual(job["scope"]["review_untraced"], 1)
|
|
|
|
async def test_choosable_pending_item_stays(self):
|
|
self._roots()
|
|
self._write("two.png", opaque_graph("x", traced=("cat", "dog")))
|
|
await self._scan()
|
|
(item,) = self._items()
|
|
|
|
job = await self._scan("all")
|
|
|
|
self.assertEqual([i["id"] for i in self._items()], [item["id"]])
|
|
self.assertEqual(job["scope"]["review_untraced"], 0)
|
|
|
|
async def test_a_failed_removal_is_logged_and_counted_not_fatal(self):
|
|
import logging
|
|
import sqlite3
|
|
|
|
self._roots()
|
|
self._write("none.png", opaque_graph("cat", "dog"))
|
|
self._record_pre_fix("none.png")
|
|
with (
|
|
patch.object(
|
|
self.api.db,
|
|
"settle_untraced_review_items",
|
|
side_effect=sqlite3.OperationalError("database is locked"),
|
|
),
|
|
self.assertLogs("prompt_manager.api", logging.WARNING) as logs,
|
|
):
|
|
job = await self._scan("all")
|
|
|
|
self.assertEqual(job["state"], "finished")
|
|
self.assertEqual(job["scope"]["review_errors"], 1)
|
|
self.assertTrue(any("could not be removed" in line for line in logs.output))
|
|
self.assertEqual(self._pending(), 1)
|
|
await self._scan("all")
|
|
self.assertEqual(self._pending(), 0)
|
|
|
|
def test_monitor_removes_the_pending_item_of_an_untraced_output(self):
|
|
self._roots()
|
|
path = self._write("none.png", opaque_graph("cat", "dog"))
|
|
self._record_pre_fix("none.png")
|
|
# A pre-fix item of other bytes keeps the stat shortcut out of the way.
|
|
self._write("none.png", opaque_graph("a cow", "dog"))
|
|
|
|
self.assertEqual(self.api.record_review_file(str(path)), "untraced")
|
|
self.assertEqual(self._items(), [])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|