Skip to content

refactor: replace .script_sizes.json with a git-diff truncation guard - #493

Merged
Jammy2211 merged 3 commits into
mainfrom
feature/script-size-guard-git-based
Aug 20, 2026
Merged

refactor: replace .script_sizes.json with a git-diff truncation guard#493
Jammy2211 merged 3 commits into
mainfrom
feature/script-size-guard-git-based

Conversation

@Jammy2211

@Jammy2211 Jammy2211 commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

Summary

Replaces the static .script_sizes.json truncation baseline with git itself: scripts/check_sizes.sh now compares each changed scripts/**/*.py against its blob size at HEAD (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 --update contract — 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, --update removed, fails closed (exit 2) on an unresolvable base, ALLOW_SHRINK=1 retained; 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 to main against event.before (falling back to HEAD^); concurrency mirrors navigator_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 needed

Test Plan

  • Six controls green in-repo: clean tree OK; truncation flagged (exit 1); new file OK; ALLOW_SHRINK=1 warns + exit 0; legitimate −10% edit OK; truncation committed two commits back on a branch still caught via merge-base
  • Fail-closed: unresolvable --base exits 2 with a clear error, never a silent pass
  • Zero-false-positive replay over real history: --base HEAD~25/~100/~300 = 123/366/402 changed scripts, all within tolerance
  • CI positive control on this PR: the deliberate truncation commit a41e34e turned the size-guard run red (99% scripts/imaging/start_here.py 26105b -> 60b vs the merge-base), then was reverted in 3298530 — the guard is proven non-vacuous
  • Smoke tests pass for all affected workspaces (3.12 + 3.13 green on the final head)

Generated by the PyAutoLabs agent workflow.

🤖 Generated with Claude Code

https://claude.ai/code/session_018PyJgsC7kxEucPp1iJ6F93

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
@Jammy2211
Jammy2211 merged commit e8df826 into main Aug 20, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pending-release PR queued for the next release build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: replace .script_sizes.json with a git-diff truncation guard

2 participants