Skip to content

Record the job name in each ASC MHL generation - #46

Merged
owenpkent merged 5 commits into
mainfrom
ascmhl-job-identity
Nov 29, 2026
Merged

owenpkent merged 5 commits into
mainfrom
ascmhl-job-identity

Conversation

@owenpkent

@owenpkent owenpkent commented Nov 29, 2026 •

Copy link
Copy Markdown
Owner

Stacked on #40 (base branch verify-history-supersede); review and merge that one first.

Problem

An ASC MHL generation recorded no job name. Two kinds of entry record no size or date, so the job name is the only thing that can tie a rerun to them:

  • a file a cancelled job never reached
  • a marker for a folder the scan could not list, or a skipped link

Classic manifests name their job, so a rerun clears those entries. In an ASC MHL history nothing could, and after #40 the history kept failing verify for good after an ordinary cancel and rerun.

Change

  • Writer: each generation names its job as Job: <name> in creatorinfo/comment. The ASC MHL schema has no job field; comment is its optional free-text element, written after tool as the schema's sequence requires.
  • Reading a history: an earlier entry with no size or date is dropped for a later generation that names the same job and lists the same path with a hash, or lists hashed files under the folder and nothing unhashed there. Those files are then checked like any other.
  • Between manifests: supersede reads the job name from the manifest that recorded each entry, so a classic rerun answers a history and a history rerun answers a classic manifest.
  • Whose comment: the convention is only read from a generation whose creatorinfo/tool is Offloader, and only from a comment that starts with Job: . A generation with no job name (written before this change, or by another tool) answers nothing and has nothing answered, as before.
  • Which name: the job's own name (Job.recorded_name, from Close three ways verify could pass a folder it should not #40), so a retry the queue shows as A001-2 still records Job: A001. Names are compared whole, ignoring case.
  • An intervening repair still counts: when job A's retry copied a clip and job B later listed the same bytes, A's failure is answered by A's retry, because the retry recorded the digest the path is checked against now.
  • Failures are kept apart by job: two jobs cancelled at the same path are two failures, each answered only by its own job.
  • Memory: reading a history keeps one record per path and a set of folders per job, not every generation's list.

The documented limit is the same as for classic manifests: two different cards given the same job name can clear each other's entries of this kind. Entries that record a size and date are still protected by them.

Tests

New tests in tests/test_verdict_integrity.py cover the written element and its position, another tool's comment, comments that are not this tool's, the recorded name versus the queue's, cancel and rerun in a history, a rerun under another job name, generations with no name on either side, folder markers, an intervening repair, two jobs cancelled at one path, both cross-format directions, and what is held in memory while reading twelve generations.

Local run on Windows: 985 passed, 5 skipped; ruff clean; property tests 95 passed, 1 skipped.

Closes #44

@owenpkent owenpkent left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ordinary recovery requested in #44 works at 20fd62f. The same-job folder-marker test passed here and failed on the exact #40 base, 42e26c6. Eighteen focused Windows tests passed, including cancel and rerun, unnamed generations, and both classic/ASC recovery directions. The new comment is in the optional position allowed by the schema. ASC MHL specification, §6.4.2

I found a case where an already repaired clip fails again, an interoperability issue with other writers’ comments, and increased memory use on repeated generations. All nine GitHub checks passed.

Comment thread src/offloader/verify.py Outdated
elif _hashed(judged) and (
_same_facts(entry.size, entry.modified,
judged.size, judged.modified)
or (nameless and _same_job(job, jobs[judged.recorded_in]))):

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Keep evidence of a successful intervening repair

A cancelled job A left one clip without a checksum. A’s retry copied it, and verifying generation 2 passed. Job B then recorded the same files under another job name with identical checksums. Generation 3 reported both live files as matching and resurrected A’s old no hash failure. The comparison only sees B as the most recent writer and has discarded A’s successful generation 2 record.

Retain the matching repair from the job that recorded the failure and check that its digest still matches the current file. Cover the three-generation case with an unchanged clip.

Comment thread src/offloader/ascmhl.py
else's text, and is never taken for a name.
"""
text = root.findtext(f"{{{NAMESPACE}}}creatorinfo/{{{NAMESPACE}}}comment") or ""
if not text.startswith(JOB_COMMENT_PREFIX):

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Check which tool wrote the job comment

creatorinfo/comment is ordinary free text. A manifest identifying a different exporter in creatorinfo/tool and carrying the operator’s comment Job: A001 is read as job A001. That changes how existing third-party histories are interpreted and contradicts the reader’s documented contract.

Check the creator tool before interpreting this convention, or use an explicitly namespaced identifier. Include a foreign writer with a matching comment prefix in the compatibility tests. ASC MHL specification, §6.4.2

Comment thread src/offloader/verify.py Outdated
continue
failed.add(mark)
found.append(entry)
later.append((job, listed))

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Avoid retaining every historical file record to answer folder markers

later keeps every generation’s entire entry list alive, including repeated successful records. I measured Python allocations during history parsing with 1,000 identical paths per generation and no failures. At three generations the parent peaked at 3.26 MiB and this head at 3.95 MiB. At twelve generations the parent peaked at 3.75 MiB and this head at 11.63 MiB. Both produced the same 1,000 current entries and added zero historical entries.

Keep the per-job directory evidence needed to answer a possible marker in a compact index. Completed generations can then release their individual file records once their relevant hashes and failures have been processed.

@owenpkent owenpkent left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same-history repair, writer identity, and duplicate cancellation cases from the first review are addressed at e5627c4. I ran 24 focused tests on Windows and checked recovery across classic MHL and ASC MHL with the real writers. The cross-format case below still fails. I shared a separate folder-integrity finding privately with the maintainer.

Comment thread src/offloader/verify.py Outdated
if _same_source(verdict, answer):
if _is_newer(answered_in, failed_in, when):
verdict.superseded_by = answered_in
elif _records_nothing(verdict) and same_job_later(answered_in):

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Keep the repairing ASC generation available to classic manifests

A cancelled classic MHL job A left a clip without a checksum. A successful ASC retry by A made both reports pass. After ASC job B recorded the same file and digest, verify_tree() returned no-checksum for the classic report again. The ASC report still passed and the media bytes were unchanged. The ASC reader remembers A's matching digest internally, but this cross-format check sees only B as the recorder. Carry the matching repair's generation and date into supersede() so it can credit A when that generation postdates the failure. A mixed-format test should keep both reports passing after B's update.

A file a cancelled job never reached and a folder marker record no size or
date, so the job name is the only thing that ties a rerun to them. A
generation recorded none, and a history kept failing verify after an
ordinary cancel and rerun.

Each generation now names its job in creatorinfo/comment. Reading a history
drops such an entry for a later generation of the same job that lists the
path with a hash, or the files under the folder, and supersede reads the
job name from the manifest that recorded each entry, so the two formats
answer each other.
A retry that listed a folder's files answered the folder's marker even
after later content had replaced one of those files: the retry's record
was gone from the view and its checksum was no longer checked. A listing
now answers a marker only while every hash in it agrees with the latest
record of its path.

Between formats, supersede saw only the latest generation as the recorder
of a path, so a classic failure a history's retry had answered came back
once another job listed the same bytes. A verdict now carries the earlier
generations that recorded the digest it was checked against, and supersede
credits whichever of them answers the failure.

@owenpkent owenpkent left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same-history stale-folder case and the ordinary cross-format retry cases from the last review now pass. All 50 focused Windows tests passed at 140cb7a. I found a recorded-time case that reopens a repaired classic failure and a scaling issue for repeated, differently named jobs. I shared a separate cross-format folder-integrity finding privately with the maintainer.

Comment thread src/offloader/verify.py Outdated
kept = repairs.setdefault(key, [])
known = [(jobs[judged.recorded_in], judged.size,
judged.modified), *(w[:3] for w in kept)]
if witness[:3] not in known:

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Preserve the repair that is later by its recorded time

A classic cancellation at 12:00 was cleared by an ASC retry at 13:00. When the next generation recorded the same job, files, and digests at 11:00, as can happen when host clocks disagree, the classic clip returned to no-checksum. The newer sequence number wins this deduplication, which drops the 13:00 witness. Cross-format supersession then correctly rejects the 11:00 timestamp, but has lost the valid 13:00 record. Keep the witness with the latest comparable recorded time for each matching identity, or retain candidates for which time ordering is ambiguous. A regression test should keep the classic report passing after the clock moves backward.

Comment thread src/offloader/verify.py Outdated
witness = _Witness(job, entry.size, entry.modified,
generation)
kept = repairs.setdefault(key, [])
known = [(jobs[judged.recorded_in], judged.size,

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Index repair witnesses when the same files are recorded under different job names

For every matching record, known copies the keys of all witnesses already kept for that path and scans them again. In a healthy 12-generation archive of 40 unchanged files with a distinct job name for each run, single-manifest verification returned 40 file verdicts carrying 440 historical witnesses. With more named runs, deduplicating one path takes quadratic work in the generation count. The existing storage test uses one job name and misses this case. Use a per-path dictionary keyed by job and source facts, retaining the records required by the time-ordering rule. Extend the storage test to cover different job names and document how much evidence the returned report retains.

…p the best-dated witness

Between formats, a classic folder marker was answered whenever some file
under the folder still matched a generation of the same job, even after
another file that generation listed there had been replaced. A report now
carries each generation's folder evidence, and a marker is answered only
by a generation whose own listing of the folder still stands whole.

Of the earlier records that agree with a path's latest one, the one with
the later number was kept. With two hosts' clocks disagreeing, that could
be the one dated earlier, which cannot answer a failure written between
them. The one with the latest recorded time is kept instead, one per job
and source, indexed so that many differently named jobs cost no rescans.

@owenpkent owenpkent left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous partial-folder false pass and clock-ordering regression are addressed at 33735df. The indexed witness lookup also covers repeated job names without rebuilding the list on every insertion. All 53 focused Windows tests passed. I checked a healthy three-generation archive independently and confirmed that the verifier withdrew credit for a generation after one of its two recorded file checksums changed.

One recovery case still fails through the default CLI. A repaired file from another job can reopen an earlier folder marker in the same directory.

Comment thread src/offloader/verify.py Outdated
under = [v for v in newer.verdicts if _entry_key(v.path).startswith(prefix)]
return bool(under) and all(v.result is EntryResult.OK and v.expected
for v in under)
if not under or not all(v.result is EntryResult.OK and v.expected

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Keep a repaired sibling from reopening another job’s folder failure

Job A’s classic folder marker cleared after its successful ASC retry. Job B then had a read failure on a different clip in that folder and repaired that clip in a classic MHL run. At that point the ASC report passed and credited B’s repair, B’s classic report also passed, and both destination clips matched their sources. A’s folder marker nevertheless returned to no-checksum, so default offloader verify exited 1.

This guard examines the merged history. B’s old verdict keeps its NO_CHECKSUM result even after it acquires superseded_by, so the guard returns before evaluating A’s intact generation. Resolve file-level repairs before evaluating folder markers, or make the folder check use the recorded children of its candidate generation. Keep requiring every checksum from the credited retry to match. A regression test can use two jobs with distinct clips in the same folder and the two manifest formats.

…marker

A history's report holds every job's records. Job B's unhashed entry for
its own clip stayed a line under the folder after B repaired it, and the
folder check read any unhashed line there as the folder not being
accounted for: job A's marker, already answered by A's retry, came back.

An unhashed entry that has been superseded now counts as settled, files
are answered before folder markers, and the folder pass repeats until
nothing changes. A missing, mismatched, unreadable or unanswered entry
under the folder still keeps the marker.

@owenpkent owenpkent left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No actionable findings at b5c4ced. The verifier settles file repairs before deciding which folder markers they can clear. A sibling that still lacks a verified repair keeps the folder failing. After the sibling is repaired, the default CLI returns 0 and each failure is credited to the correct manifest. A later replacement of the retry’s own clip still withdraws the folder credit.

All 54 focused Windows tests passed. I also passed the three real reports from the repaired-sibling case to supersede() in all six orders. Every order preserved both repair attributions and the passing verdict.

@owenpkent
owenpkent changed the base branch from verify-history-supersede to main November 29, 2026 22:16
@owenpkent
owenpkent merged commit 2bef8b7 into main Nov 29, 2026
9 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.

ASC MHL generations record no job identity, so a rerun cannot clear a folder marker

1 participant