refactor: replace .script_sizes.json with a git-diff truncation guard - #493
Merged
Conversation
check_sizes.sh now compares each changed scripts/**/*.py against its byte size at a git base revision (HEAD locally, the PR merge-base in CI) instead of a static snapshot, so there is no baseline file to rot and new scripts are protected the day they land. The snapshot had drifted to 212 stale entries and 39 unprotected scripts (autolens_workspace#490). - scripts/check_sizes.sh: git-blob comparison; --update removed; --base <ref> added; fails closed (exit 2) on an unresolvable base; ALLOW_SHRINK retained; now tracked executable so CI can invoke it directly - .script_sizes.json: deleted - .github/workflows/script_size_guard.yml: new advisory guard (PR merge-base; push-to-main via event.before with HEAD^ fallback); deliberately not in Heart's required workflows - AGENTS.md: Bulk-edit safety contract updated to the no-snapshot guard Verified: six controls green in-repo (incl. a truncation two commits back caught via merge-base) and a zero-false-positive replay over HEAD~25/~100/~300 (123/366/402 changed scripts). Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018PyJgsC7kxEucPp1iJ6F93
4 tasks
…(reverted next commit)
…e guard (reverted next commit)" This reverts commit a41e34e.
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.
Summary
Replaces the static
.script_sizes.jsontruncation baseline with git itself:scripts/check_sizes.shnow compares each changedscripts/**/*.pyagainst its blob size atHEAD(local) or an explicit--base <ref>(CI uses the PR merge-base). The snapshot had rotted to 212 stale entries and 39 scripts with no baseline at all; a git base cannot go stale, and new scripts are protected the day they land. The--updatecontract — the part nobody followed and the direct cause of the rot — is removed entirely.Closes #490.
scripts/check_sizes.sh— rewritten: git-blob comparison,--base <ref>added,--updateremoved, fails closed (exit 2) on an unresolvable base,ALLOW_SHRINK=1retained; now tracked executable (was 644, so a fresh checkout could not invoke it directly).script_sizes.json— deleted.github/workflows/script_size_guard.yml— new advisory guard: PR runs check against the merge-base, pushes tomainagainstevent.before(falling back toHEAD^); concurrency mirrorsnavigator_check.yml. Deliberately not added to Heart's required workflows — the other five workspace repos have no size guard.AGENTS.md— "Bulk-edit safety" contract updated (incident rationale and whole-file-write rule kept)Sibling PR applying the identical change to autogalaxy_workspace: PyAutoLabs/autogalaxy_workspace#219.
Scripts Changed
scripts/check_sizes.sh— snapshot logic replaced by git-diff comparison against a base revision; no tutorial/example scripts touched, so no notebook regeneration is neededTest Plan
ALLOW_SHRINK=1warns + exit 0; legitimate −10% edit OK; truncation committed two commits back on a branch still caught via merge-base--baseexits 2 with a clear error, never a silent pass--base HEAD~25/~100/~300= 123/366/402 changed scripts, all within tolerancesize-guardrun red (99% scripts/imaging/start_here.py 26105b -> 60bvs the merge-base), then was reverted in 3298530 — the guard is proven non-vacuousGenerated by the PyAutoLabs agent workflow.
🤖 Generated with Claude Code
https://claude.ai/code/session_018PyJgsC7kxEucPp1iJ6F93