SetProvenance¶
Namespace Nfty.Core.Output in assembly Nfty.Core.
Whether the CookBook in front of you is the one a Set on disk was cooked from, and what to say when it is not.
Why it matters. Generator walks a recipe's layerOrder and consumes one weighted draw per layer, so moving a layer moves which draw reaches it. The same seed over a reordered — or otherwise edited — book therefore rolls different variants and different colors: not a re-render of the same collection, a different collection. Extending a Set with a book that did not cook it silently interleaves two generations under one set of token ids, and nothing else in the output records that it happened. set.json's cookbookSha256 is the only thread tying a Set back to its source archive, so it is what this compares.
A warning, never a refusal. Deliberately re-cooking an edited book is a legitimate thing to want; the author is the one who knows. And the text lives here rather than in a front-end for the same reason the reports in Stats/ do — the CLI and a GUI should say the identical thing, not something similar.
Methods¶
IsSameBook(string?, string?)¶
Whether a CookBook is the one a Set was cooked from.
Parameters
recordedSha256(string?) - What the Set recorded at cook time.cookbookSha256(string?) - The hash of a CookBook on disk.
Returns. True when the two hashes are the same.
Remarks
Case-insensitive: both sides are written lowercase by ArchiveIo.HashFile, but set.json is plain JSON a person can edit, and an uppercase copy of the same hash is the same hash. Ordinal-ignore-case, not the current culture's, because a hex digit must compare the same under every locale.
A null on either side is FALSE here rather than "cannot tell", which is the opposite of what SetProvenance.Warning() does with one - and deliberately so. Warning is asked "should I interrupt?", where silence is the honest answer to an unanswerable question; this is asked "is this the book?", where an unanswerable question is not a yes.
Warning(string?, string?)¶
The warning to show before extending, or null when there is nothing to warn about.
Parameters
recordedSha256(string?) - What the Set recorded at cook time —SetManifest.CookbookSha256, asSetWriter.ReadExistingreports it. Null when the Set predates the field, has no readableset.json, or was cooked from a book that never came from a file.cookbookSha256(string?) - The hash of the CookBook about to be used —LoadedCookBook.SourceSha256. Null for an in-memory book that never came from a file.
Returns. The warning text, or null when the two agree or cannot be compared.
Remarks
A null on either side means "cannot tell", which is not "they differ". Both sides are legitimately absent — an unsaved book has no file to hash, and a Set can be cooked from one — so warning on a null would fire on the ordinary case and train the author to ignore the one message that matters. Silence is the honest answer to a question that was not asked.