A pending label alone can send a workflow back to material it has already inspected. This independent helper compares current declarations with prior records and returns separate work lists.
Keep current material separate from its review record
The function accepts two synthetic lists rather than actual files. current contains an alias ID, a revision number, a declared SHA and current hold reasons. records contains the revision and SHA at inspection time, an explicit full-frame inspection flag and the recorded status. The current material and the previous evidence remain independently inspectable inputs.
Each list is bounded to 64 rows. Revisions must be positive integers and inspection flags must be actual booleans. IDs and hold reasons are short ASCII aliases. The helper reads no photos, manuscripts, addresses, accounts or private paths, and it does not anonymize arbitrary real data. Every value in the published examples is independently synthetic.
Return the reason for a new inspection
An absent record, a changed revision or a different SHA places an item in new_inspections. Even matching revision and fingerprint declarations are insufficient if full inspection evidence is missing. The reasons no_record, revision_changed, fingerprint_changed and inspection_evidence_missing make the next comparison explicit instead of returning one undifferentiated pending flag.
The SHA is a supplied string. This function does not locate a current file or calculate a disk hash. Editing a revision label or copying a new hash into an old record must not be treated as a completed review. A trustworthy adapter must freeze the current file and a reviewer must create the inspection evidence before these comparisons can carry their intended meaning.
Retain inspected holds in a follow-up list
A held or follow_up record with matching revision, fingerprint and inspection evidence belongs in existing_followups. Leaving the new-inspection list does not erase its record or its hold reasons. A current hold also prevents an old complete status from entering the completion list. This is an explicit policy in the independent example, not a field-for-field copy of every state in the native selector.
Conversely, an empty current hold list does not automatically promote an old held record to complete. The follow-up result still needs to be established in the record. There is no hold-release command and the original inputs are not changed. The helper partitions work; it does not perform the operational steps that resolve it.
Explore the implementation
Complete independent synthetic implementation
"""Independent synthetic workset; declared metadata, no I/O or authorization."""
from copy import deepcopy
import re
ALIAS = re.compile(r'[A-Za-z0-9_][A-Za-z0-9_.-]{0,47}\Z')
def _index(rows, recorded):
if not isinstance(rows, list) or len(rows) > 64:
raise ValueError('Expected at most 64 rows')
required = {'id', 'revision', 'sha256'} | ({'full_frame_checked', 'status'} if recorded else {'holds'})
indexed = {}
for source in rows:
if not isinstance(source, dict) or set(source) != required:
raise ValueError('Unexpected or missing fields')
row = deepcopy(source)
if not isinstance(row['id'], str) or not ALIAS.fullmatch(row['id']):
raise ValueError('Synthetic alias required')
if row['id'] in indexed:
raise ValueError('Duplicate id; preserve rejected evidence separately')
if type(row['revision']) is not int or row['revision'] < 1:
raise ValueError('Positive revision required')
if not isinstance(row['sha256'], str) or not re.fullmatch(r'[0-9a-f]{64}', row['sha256']):
raise ValueError('Lowercase SHA-256 declaration required')
if recorded:
if type(row['full_frame_checked']) is not bool or row['status'] not in ('complete', 'held', 'follow_up'):
raise ValueError('Explicit inspection evidence and known status required')
else:
holds = row['holds']
if not isinstance(holds, list) or len(holds) > 8:
raise ValueError('At most eight hold aliases required')
if any(not isinstance(x, str) or not ALIAS.fullmatch(x) for x in holds) or len(holds) != len(set(holds)):
raise ValueError('Unique hold aliases required')
indexed[row['id']] = row
return indexed
def plan(current, records):
current, records = _index(current, False), _index(records, True)
inspections, followups, complete = [], [], []
for key, item in sorted(current.items()):
previous = records.get(key)
if previous is None:
reason = 'no_record'
elif previous['revision'] != item['revision']:
reason = 'revision_changed'
elif previous['sha256'] != item['sha256']:
reason = 'fingerprint_changed'
elif not previous['full_frame_checked']:
reason = 'inspection_evidence_missing'
else:
reason = None
if reason:
inspections.append({'id': key, 'reason': reason, 'holds': item['holds']})
elif previous['status'] == 'complete' and not item['holds']:
complete.append(key)
else:
followups.append({'id': key, 'recorded_status': previous['status'], 'holds': item['holds']})
return {'new_inspections': inspections, 'next_inspection': inspections[0] if inspections else None,
'existing_followups': followups, 'complete_ids': complete,
'historical_only_record_ids': sorted(set(records) - set(current)),
'records_authenticated': False, 'performs_execution': False,
'changes_holds': False, 'goal_complete': False}
No next inspection does not finish the whole goal
complete_ids contains only matching complete records without current holds. IDs that exist only in historical records remain in historical_only_record_ids; they are not deletion candidates. Follow-up actions, missing scope and operational checks can remain even when the current list has no new inspection. For that reason, goal_complete always remains false.
next_inspection selects the first alias in sorted order. This is a reproducibility rule for the example, not an optimization of value, deadlines or risk. A real application can add priorities, owners and due dates through a separate policy. Choosing a row must still be kept distinct from permission to execute work on it.
Reproduce the tests and five stored cases
The 29 test methods cover a new revision under the same fingerprint, a changed fingerprint under the same revision, a current hold conflicting with old completion, missing inspection evidence and historical-only records. Duplicate IDs, malformed values, unknown fields and size limits are rejected. Input preservation and output isolation are tested as well. Subtest combinations are not added to the headline method count.
The five cases are actual local Python outputs from this helper. The selector below only displays their stored JSON; it neither inspects visitor files nor executes Python in the browser. Extract the ZIP and run unittest and make_records.py to reproduce the contract. The native workflow's earlier 24 tests and this independent package's 29 tests are separate bodies of evidence.
Connect file capture and execution management separately
Import plan from workset in the extracted folder and supply the two synthetic lists. Start by reading reason in new inspections and holds plus recorded_status in existing follow-ups. If you extend inspection scope or hold reasons, first define what actual review evidence those fields represent. Code that sets a flag to true must not stand in for the inspection itself.
This package provides no collection, file hashing, authentication, locking, persistence, execution or publication. records_authenticated, performs_execution, changes_holds and goal_complete remain false. The existing gallery and before/after projection module linked below addresses where a photo can appear publicly. The packages are separate responsibilities; no automatic integration between them is claimed.