feat(scripts): add -UpdateCommitted to the derived-artifacts gate - #145
Merged
juemerson-at-purestorage merged 1 commit intoAug 25, 2026
Conversation
When the gate reports a stale artifact it already holds, in its scratch tree, exactly the content the comparison demanded. Until now the caller was told to copy those files over the committed copies by hand -- a mechanical step with two ways to get it wrong (missing a file of a .json/.md pair, or round-tripping through an editor and adding a BOM). -UpdateCommitted writes them instead, then exits 0 and lists the repo-relative path of every file it wrote, so the paths paste straight into git diff or git add. Only artifacts the run found stale are written, and only within -Artifact when that narrows the set, so git status afterwards names exactly what moved. Exiting 0 is deliberate: remediating is what the switch asks for, and a non-zero exit from a run that just fixed the problem breaks any caller chaining on it. Without the switch the behaviour is unchanged -- stale still throws, and CI, which passes only -WorkDirectory and -KeepWorkDirectory, cannot reach the write path. The script's header previously said the working tree is never touched. That reasoning was about side effects, not writes, so it is amended rather than dropped: an explicit opt-in is not a side effect, and nothing infers the switch from the environment. Copy-Item rather than read-transform-write, because the committed artifacts carry no BOM and a Set-Content round-trip is one -Encoding default away from adding one. Preserving bytes also settles the line-ending question -- verified by corrupting an artifact, running with the switch, and confirming git status came back empty. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
juemerson-at-purestorage
deleted the
feat/derived-artifacts-update-committed
branch
August 25, 2026 19:46
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
-UpdateCommittedtoscripts/Assert-PfbDerivedArtifacts.ps1.When the gate reports a stale artifact, it already holds — in its scratch tree — exactly the
content the comparison demanded. Until now the caller was told to copy those files over the
committed copies by hand.
-UpdateCommitteddoes the copy, exits 0, and lists the repo-relativepath of every file it wrote:
Paths are printed bare and one per line so each is selectable alone and the block pastes into a
gitcommand — the two things a reader does next.Why
The manual copy is mechanical and has two quiet ways to go wrong: missing one file of a
.json/.mdpair, or round-tripping through an editor and introducing a BOM. Neither shows upuntil the next gate run.
Scope of the write
byte-identically, so
git statusafterwards names exactly what moved.-Artifactwhen that narrows the set.Without it, behaviour is unchanged — stale still throws, exit 1. The workflow
(
verify-derived-artifacts.yml) passes only-WorkDirectoryand-KeepWorkDirectoryand cannotreach the write path.
Two decisions worth review
Exit 0 after a successful update. Remediating is what the switch asks for, so doing it is
success, and a non-zero exit from a run that just fixed the problem breaks any caller chaining on
it. Callers that want the unremediated answer are the ones that must not pass the switch.
The header comment is amended, not dropped. It read "THE WORKING TREE IS NEVER TOUCHED... a
gate that rewrites
Data/as a side effect of checking it is not a gate." That reasoning is aboutside effects rather than writes, and an explicit opt-in is not a side effect — so the paragraph now
states the exception and why the distinction holds, rather than sitting in contradiction with the
code below it.
Copy-Itemrather than read-transform-write, because the committed artifacts carry no BOM and aSet-Contentround-trip is one-Encodingdefault away from adding one. Preserving bytes alsosettles the line-ending question instead of reopening it: the comparison already normalizes CRLF,
so a whole-file copy lands exactly the content the gate demanded.
Verification
Behaviour exercised end to end against the real spec cache (29 pinned versions, 2.0–2.28), by
corrupting
Data/PfbResponseShapeMap.jsonand running the gate:-UpdateCommittedUPDATED, exit 0,git statusempty — restored byte-exactThe
git statusresult also confirms no BOM was introduced and no line endings were damaged.Tests/AssertDerivedArtifacts.Tests.ps1: 25 passed, 0 failed on both PowerShell 7.5 and WindowsPowerShell 5.1 (run together with
Tests/Build-PfbPipelineSelectorMap.Tests.ps1, the other filereferencing this script).
Two new tests, both mutation-checked — removing the
if ($UpdateCommitted)guard and switching thereport to absolute paths each red exactly one test:
switch name. A
Copy-Itemmoved one brace out of the guard still sits a few lines from the wordUpdateCommittedand would keep a text match green while the gate rewroteData/on every run.-UpdateCommittedis asserted to be a[switch]with no default, since as a[bool]it couldbind positionally or by conversion.
Live-test exemption
Exempt. The diff leaves the module source and the manifest entirely untouched, so nothing here
can alter a request the module sends or a response it parses. Changed files are
scripts/Assert-PfbDerivedArtifacts.ps1,Tests/AssertDerivedArtifacts.Tests.ps1andReports/README.md.Docs
Reports/README.mdnow documents-UpdateCommittedas the fix path, with-KeepWorkDirectorykept as the inspect-before-overwriting alternative. The stale-artifact error message points at the
switch for the same reason.
No version bump or CHANGELOG entry — those are the maintainer's call.