From c43df7f94700354a7bca2561dffc751ecb913b45 Mon Sep 17 00:00:00 2001 From: rabbitblood Date: Fri, 24 Apr 2026 04:34:55 -0700 Subject: [PATCH] =?UTF-8?q?fix(precommit):=20skip=20during=20rebase/cherry?= =?UTF-8?q?-pick/merge/revert=20=E2=80=94=20unblocks=20DIRTY=20PR=20rebase?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Trace from molecule-core cycle 107 (2026-04-24): 15 staging PRs stuck DIRTY (real merge conflicts) with 0 merges in 1+ hours. Authors couldn't rebase to fix the conflicts because the pre-commit hook (shipped in 0.1.11) refuses ANY commit that includes forbidden paths in the diff — including rebase replays of historical commits that pre-date the gate. Specifically, agents trying to `git rebase staging` on a PR like "docs(marketing): Phase 30 social copy" fail at the first commit replay because that commit added marketing/* files. The fix would require interactive rebase + manual file deletion + commit amend — agents don't do that, so the PR stays DIRTY indefinitely. Detection: check .git for rebase-merge/, rebase-apply/, CHERRY_PICK_HEAD, MERGE_HEAD, or REVERT_HEAD. These state markers exist only during the corresponding git operation. Skip the hook silently when present. The hook still blocks fresh `git commit` (the failure mode it was designed for). It just doesn't try to police what was already in git history. Bumped to 0.1.14. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../scripts/pre-commit-block-internal-paths.sh | 16 ++++++++++++++++ pyproject.toml | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/molecule_runtime/scripts/pre-commit-block-internal-paths.sh b/molecule_runtime/scripts/pre-commit-block-internal-paths.sh index 0a5682c..29a49d8 100644 --- a/molecule_runtime/scripts/pre-commit-block-internal-paths.sh +++ b/molecule_runtime/scripts/pre-commit-block-internal-paths.sh @@ -27,6 +27,22 @@ if [ -z "${GIT_AUTHOR_NAME:-}${GIT_COMMITTER_NAME:-}" ]; then exit 0 fi +# Skip during rebase / cherry-pick / merge / revert — these REPLAY existing +# commits and the staged file set is whatever was already committed +# upstream. Blocking those forces the agent to manually rewrite history +# (interactive rebase + manual file deletion + commit amend) which most +# agents won't do — net effect was 15+ DIRTY PRs sitting unmergeable on +# molecule-core after the hook landed (cycle 107 trace, 2026-04-24). +# +# Detection via .git state directories. These exist only during the +# corresponding operation and get cleaned up at the end. +GIT_DIR=$(git rev-parse --git-dir 2>/dev/null || echo .git) +for state_dir in rebase-merge rebase-apply CHERRY_PICK_HEAD MERGE_HEAD REVERT_HEAD; do + if [ -e "${GIT_DIR}/${state_dir}" ]; then + exit 0 + fi +done + # Determine if we're in a public Molecule-AI repo. `git remote get-url` # returns nothing in repos without a remote (fine — exit clean). REMOTE=$(git remote get-url origin 2>/dev/null || echo "") diff --git a/pyproject.toml b/pyproject.toml index 20cbb25..f8c38cb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta" [project] name = "molecule-ai-workspace-runtime" -version = "0.1.13" +version = "0.1.14" description = "Molecule AI workspace runtime — shared infrastructure for all agent adapters" requires-python = ">=3.11"