fix(guards): block worktree-rewriting git in OneDrive repos; sync segment splitter - #7
Merged
Merged
Conversation
…ment splitter Brings library/guards.py up to the canonical .SYNC/hooks/guards.py: - check_onedrive_git(): pull/rebase/reset --hard|--keep|--merge/checkout -B|-f|-- <path>/ switch -C/restore/merge/branch -f in OneDrive paths are blocked unless the command carries ONEDRIVE_GIT_OK=1; unknown target directory fails closed (T-20260924-532136326: pull --rebase + checkout -B deleted 6039 files in a OneDrive research repo). - _segmente(): real command separators (force-push fix T-20260913-235210967) that this copy was still missing. Tests: hook-master pytest green; .SYNC/hooks/test_guards.py all cases pass against this file. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
Welcome! 👋 Thanks for your first pull request in this repository. A maintainer will review it soon. Please make sure:
Thanks for contributing! |
lukisch
commented
Sep 24, 2026
lukisch
left a comment
Member
Author
There was a problem hiding this comment.
Review Befunde zu PR #7 (fix/onedrive-git-guard)
Reviewer: agy@ASUS-GEI (Antigravity)
Modell: Gemini 3.8 Flash (High)
1. Branch-Schutz & CI Status
- Branch Protection auf \main: nicht aktiv / keine Rulesets hinterlegt.
- GitHub Actions CI (\gh pr checks 7): 13/13 Checks erfolgreich (macOS, Ubuntu, Windows auf Python 3.10, 3.11, 3.12, 3.13 + welcome).
2. Kriterien-Pruefung (Diff & Code in \library/guards.py)
- (a) Faelschliche Treffer ausserhalb OneDrive: Erfolgreich verifiziert. Git-Befehle (pull, rebase, etc.) in \C:/_Local_DEV/repos/...\ werden nicht faelschlich blockiert.
- (b) Umgehungs-Schreibweisen: Robust gegen Pfad-Aliase (/c/...), relative Pfade, Backslashes/Slashes, -C , \cd &&, Umgebungsvariablen-Praefixe (\VAR=val), quoted refs und \git.exe.
- (c) Fail-closed: Bei fehlendem/leerem \cwd\ im Payload wird bei riskanten Operationen zuverlaessig fail-closed blockiert (Exit 2 mit klarer Freigabe-Instruktion \ONEDRIVE_GIT_OK=1), waehrend unkritische Operationen (\git status, non-git) weiterhin durchlaufen.
- (d) Sensible Daten: Keine Nutzernamen, privaten Pfade oder Tokens vorhanden. Code ist sauber neutralisiert und public-ready.
- (e) Interpreter-Invarianten: \library/guards.py\ nutzt ausschliesslich Standardbibliothek (\json,
e, \shlex, \sys), startet fehlerfrei unter \python -S -X utf8\ (ohne site-packages).
3. Testmessungen (synchron im Vordergrund)
- Hook-Master Test-Suite: 107/107 Tests bestanden (pytest mit isoliertem basetemp)
- Guard-Spezifikationstests (\ est_guards.py): 52/52 Testfaelle bestanden (inkl. 22 OneDrive-spezifischer Faelle)
- Manuelle Subprozess-Tests mit -S -X utf8\ und JSON Payloads: alle Exit-Codes (0 / 2) und Fehlermeldungen verifiziert
- Linter:
uff check\ fehlerfrei bestanden
Fazit: PR ist sauber und verifiziert. Ready for squash merge.
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
check_onedrive_git():pull,rebase,reset --hard|--keep|--merge,checkout -B|-f|-- <path>,switch -C,restore,mergeandbranch -fare blocked when the target directory (hookcwd,cd …,git -C …) lies in a OneDrive tree. Explicit release: prefix the command withONEDRIVE_GIT_OK=1. An undeterminable target fails closed._segmente()(real command separators, force-push fix from 2026-09-13) into this library copy, which was still missing it.Why
A scheduled agent run did
pull --rebasefollowed bycheckout -B main origin/mainin a research repo whose.gitlives in OneDrive. The rebase first checked out the remote state and removed every file that existed only in the local commit; resetting the branch then orphaned that commit. 6039 files were gone from the working tree until they were recovered from the dangling commit two months later.Test plan
pytestin hook-master: greentest_guards.py, 22 OneDrive cases in both directions plus the existing bach/git cases) passes againstlibrary/guards.py🤖 Generated with Claude Code