Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,19 @@ project uses [semantic versioning][semver].
superseded only when both entries record the same source size and
modification date. A folder marker, or a file a cancelled job never
reached, records neither and is superseded only by a manifest naming the
same job; ASC MHL records no job name, so its markers and never-reached
entries are never superseded. Only an entry with no size or date counts as
same job. Only an entry with no size or date counts as
a folder marker. Which entry is later is judged by the manifest that
recorded it, not by the newest generation of the history it was read from.
A classic manifest now records the job's own name, without the `-2` the
app's queue adds to a second entry for the same card, and names are
compared whole.
- **A cancel and rerun left an ASC MHL history failing `verify`.** A file a
cancelled job never reached, or a folder that could not be listed, records
no size or date, and a generation recorded no job name to tie the rerun to
it. Each generation now names its job as `Job: <name>` in
`creatorinfo/comment`, and `verify` uses it inside a history and between a
history and a classic manifest. A generation written before this names no
job, so its entries of that kind still fail.
- **An ASC MHL history hid what its earlier generations recorded.** `verify`
checked only the newest generation, so a clip an earlier card's run had
recorded as failed passed once a second card wrote a generation of its own,
Expand Down
16 changes: 14 additions & 2 deletions docs/ascmhl.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@ comparison with the previous generation is per algorithm: hex digests
case-insensitively, C4 exactly, so another tool's uppercase hex is not
recorded as `failed`.

Each generation names the job that wrote it, as `Job: <name>` in
`creatorinfo/comment`. The schema has no field for a job, and `comment` is its
free-text one. `verify` reads the name back to tie a rerun to an entry that
records no size or date (a file a cancel never reached, a folder that could not
be listed), so cancelling a job and running it again leaves the history
passing. The name is the job's own: a retry the app's queue shows as `A001-2`
still records `Job: A001`. The convention is only read from a generation whose
`creatorinfo/tool` is Offloader, since `comment` is free text and another
exporter's operator may have typed the same words; and a comment that does not
start with `Job: ` is never read as a name.

## Directory hashes

Each directory gets a `content` and a `structure` hash, and the root gets both
Expand Down Expand Up @@ -120,7 +131,8 @@ path any generation lists is judged by the latest generation that lists it: a
`failed` or unhashed latest record fails, a hashed one is checked, and each
file is hashed once however many generations list it. An earlier failure is
dropped only for a later hashed record of the same source file (same size and
modification date); otherwise it is still reported. Directory hashes are the
modification date) or, when it records neither, for a later generation of the
same job; otherwise it is still reported. Directory hashes are the
newest generation's, over the files it lists. The rules and limits are in
[data-safety.md](data-safety.md#an-asc-mhl-history-is-verified-as-one).

Expand Down Expand Up @@ -149,7 +161,7 @@ one reproduces exactly:

And the end-to-end check: rebuilding that scenario and diffing the manifest
against the one the reference project shipped produces **no differences** beyond
hostname, tool name and file modification times. That test is in
hostname, tool name, the job comment and file modification times. That test is in
`tests/test_ascmhl.py` and skips cleanly when the reference tree is not present.

Getting there took two corrections worth recording:
Expand Down
46 changes: 36 additions & 10 deletions docs/data-safety.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,8 @@ Supersession runs one way only:
ordinary way to recover, so such an entry is superseded when the newer
manifest lists the same path with a hash that matches and both manifests
name the same job, the rule a folder marker gets below, with the same
limit. ASC MHL records no job name, so in an ASC MHL history such an entry
keeps failing `verify` after the rerun; the classic manifest of the same
jobs is answered.
limit. The same holds inside an ASC MHL history, whose generations each
record the job name as well, and between a history and a classic manifest.
- A folder marker (a source folder that could not be listed, or a skipped
link, recorded as one unhashed entry at the folder's path) is superseded by a
newer manifest for the same destination root when that manifest lists at
Expand All @@ -271,17 +270,18 @@ Supersession runs one way only:
mismatched or unreadable entry under the folder keeps the marker failing: a
rerun lists the files inside a folder, never the folder itself, so
exact-path matching could never clear it. A marker records no size or date,
so the job name (MHL 1.1 `creatorinfo/name`) is what ties the rerun to the
card. Only an entry that records neither is treated as a marker: a failed
so the job name (MHL 1.1 `creatorinfo/name`; in ASC MHL the `Job: ` text
in `creatorinfo/comment`) is what ties the rerun to the card. Only an entry that records neither is treated as a marker: a failed
file records both, and files a later run lists under its path never answer
it. Names are compared whole, ignoring case. A manifest records the job's
own name: when the app's queue renames a second entry for a card `A001-2`
to keep report folders apart, its manifest still says `A001`, so a queued
retry names the same job as the run it repeats. The suffix is never worked
back out of a name, since a card can really be called `A001-2` and
`Shoot-100` and `Shoot-101` are two jobs. ASC MHL records no job
name, so a marker in an ASC MHL history is never superseded and keeps
failing `verify` even after a rerun copied the folder. **Limit:** two
`Shoot-100` and `Shoot-101` are two jobs. An ASC MHL generation
written before the job name was recorded, or by another tool, names no job:
a marker or never-reached entry in it is never answered and keeps failing
`verify`, and it answers none in other manifests. **Limit:** two
different cards given the same job name (a naming template without
`{card}`, or `--name` reused) still clear each other's folder markers and
never-reached entries; entries that record a size and date are protected
Expand Down Expand Up @@ -336,8 +336,34 @@ any generation lists is judged by the latest generation that lists it:
the same relative path is a later record of the path and no evidence the
first clip was copied, so the earlier failure is still reported, beside the
check of the later file. An earlier record with no size or date (a file a
cancelled job never reached) has nothing to compare and stays failing; see
the limit on job names above.
cancelled job never reached, or a folder marker) has nothing of the source
to compare, so the job name decides: it is dropped for a later generation
that names the same job and lists the path with a hash, or lists hashed
files under the folder and nothing unhashed there. Those files are then
checked like any other. With no job name on either side it stays failing;
see the limit on job names above.
- The record that answers an earlier failure need not be the latest one. When
job A's retry copied a clip and job B later listed the same bytes under its
own name, A's failure is still answered by A's retry, because the retry
recorded the digest the path is checked against now. A record the latest
one disagrees with answers nothing. The same goes for a folder marker: a
retry that listed the folder's files answers it only while every one of
those records still agrees with the latest record of its path, so content
that later replaced one of them puts the marker back. All of this holds
between a history and a classic manifest too: a classic folder marker is
answered by a generation of the same job only while that generation's own
listing of the folder still stands whole, not because some file under the
folder happens to match. Another job's unhashed entry under the folder
does not hold the marker open once that entry has itself been superseded;
files are settled first, then folders.
- For this a report keeps, per path, one earlier record for each distinct
job and source that agrees with the latest record: the one with the latest
recorded time, so a generation with a later number and an earlier date
(two hosts whose clocks disagree) does not hide a repair that is properly
dated. A path listed by twelve differently named jobs carries eleven such
records; listed twelve times by one job, none.
- Failures with no size or date are kept apart by job: two jobs cancelled at
the same path are two failures, and each is answered only by its own job.
- A path whose latest record has a hash is checked against it, missing,
mismatched and unreadable all failing, even when the newest generation does
not list it. The verdict names the generation the record came from.
Expand Down
30 changes: 30 additions & 0 deletions src/offloader/ascmhl.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,31 @@

_MANIFEST_PATTERN = re.compile(r"^(\d{4,})_.*\.mhl$", re.IGNORECASE)

#: How a generation names the job that wrote it, in `creatorinfo/comment`.
#: The schema has no field for a job; `comment` is its free-text one. `verify`
#: reads the name back, because it is the only thing that ties a rerun to an
#: entry that records no size or date (a file a cancelled job never reached,
#: a folder that could not be listed).
JOB_COMMENT_PREFIX = "Job: "


def job_name_from(root: ET.Element) -> str | None:
"""The job name an ASC MHL generation records, or None.

None for a manifest another tool wrote, or one written before the name
was recorded. `comment` is ordinary free text, and an operator of some
other exporter may well have typed `Job: A001` into it, so the convention
is only read from a generation whose `creatorinfo/tool` is this tool. A
comment that does not start with the prefix is never taken for a name.
"""
creator = f"{{{NAMESPACE}}}creatorinfo/{{{NAMESPACE}}}"
if (root.findtext(f"{creator}tool") or "").strip() != PRODUCT_NAME:
return None
text = root.findtext(f"{creator}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

return None
return text[len(JOB_COMMENT_PREFIX):].strip() or None


def _utc(when: _dt.datetime | float) -> _dt.datetime:
if isinstance(when, (int, float)):
Expand Down Expand Up @@ -379,6 +404,11 @@ def write_manifest(job: Job, root: Path, *, destination_index: int = 0,
ET.SubElement(creator, "creationdate").text = _iso(moment)
ET.SubElement(creator, "hostname").text = platform.node()
ET.SubElement(creator, "tool", {"version": __version__}).text = PRODUCT_NAME
if job.recorded_name and job.recorded_name.strip():
# After `tool`, where the schema's sequence puts it. The job's own
# name, not the queue's `-2` variant of it: `Job.recorded_name`.
ET.SubElement(creator, "comment").text = (
JOB_COMMENT_PREFIX + job.recorded_name)

info = ET.SubElement(manifest, "processinfo")
ET.SubElement(info, "process").text = process
Expand Down
Loading
Loading