fix(policy): let the ref guard finish when history carries a policy it cannot read - #36
Merged
Merged
Conversation
…t cannot read A `.aimhooman.json` this version cannot parse — a field a later version added, say — made the final ref guard refuse every update that would introduce it. Pull, merge, reset and `--no-verify` all aborted, and pulling the fix did not help either, because the revert's own scan threw on its parent's policy. Nothing printed pointed at a way out. History is not the receiving developer's to fix. Commit-target policy resolution now takes a tolerance flag: the guard asks for it, gets a result carrying the parse error instead of an exception, scans under the profile local config can reach, and reports which commit it could not read. A parent whose policy is unreadable still counts toward the strict floor, so an unparsable file cannot switch strict enforcement off. The worktree and the index keep the hard error, and so does anything the developer asked about directly — `check --commit` and `audit` should still say plainly that the file is unreadable.
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.
A
.aimhooman.jsonthis version cannot parse — a field a later version added,say — made the final ref guard refuse every update that would introduce it.
git pullaborted. So didmerge,reset --hard, and--no-verify, sincereference-transactiondoes not honour it.Pulling the upstream fix did not help either. The revert's own scan resolves its
parent's policy, which is the unreadable commit, so that threw as well. Nothing
printed pointed at any way out.
The escape existed but was undocumented and unhinted:
git -c core.hooksPath=/dev/null pullfast-forwards in one command, andgit checkout <sha>works through the detached-HEAD carve-out. Uninstalling wasnever the only option, but nothing said so.
What changed
History is not the receiving developer's to fix, so the change belongs in policy
resolution rather than in the guard's catch.
resolvePolicytakes atolerantflag for commit targets. With it, anunparseable policy returns a result carrying
profile: nulland the parsemessage instead of throwing.
scanCommitasks for tolerance only when itscaller does, falls back to the profile local config can reach, and pushes a
warning naming the commit it could not read.
The strict floor stays conservative: a parent whose policy is unreadable counts
toward it. An unparseable file must not be a way to switch strict enforcement
off, which is what ignoring it would mean.
headPolicytakes the same flag, since HEAD is itself a commit and reading itfor the migration-ack baseline threw for the same reason.
The fallback is sourced from local config rather than the staged policy. During
a fast-forward the index holds the same unreadable blob, so the staged route
would fail the same way.
What did not change
The worktree and the index keep the hard error. So does anything the developer
asked about directly:
check --commitandauditshould say plainly that thefile is unreadable, because there the loud answer is the right one. Only the
guard that runs over incoming history is tolerant, and it reports every fallback
it made.
Tests
Two added. Tolerant commit resolution returns the parse error instead of
throwing, while the direct call still throws. A commit scan with tolerance
finishes under a reachable profile and names the commit in its diagnostics,
while the same scan without tolerance still refuses.
Full suite green,
npm run checkgreen.