Skip to content

fix(setup): resolve repo root across the whole pre-push chain in linked worktrees - #10491

Closed
kodjima33 wants to merge 1 commit into
mainfrom
issues-improver/10293-worktree-hook-fallback
Closed

kodjima33 wants to merge 1 commit into
mainfrom
issues-improver/10293-worktree-hook-fallback

Conversation

@kodjima33

@kodjima33 kodjima33 commented Jul 24, 2026 •

Copy link
Copy Markdown
Collaborator

What

Make the whole pre-push hook chain resolve the repo root without a work tree in linked worktrees.

#10401 fixed the Makefile and the installed hook dispatcher, but the scripts the dispatcher hands off to — scripts/pre-push, scripts/pre-push-singleflight, scripts/pr-preflight — and the Python entrypoints they exec — .github/scripts/preflight_runner.py, .github/scripts/pr_preflight.py — still resolved the root with an unguarded git rev-parse --show-toplevel.

Why

In a linked worktree whose git context resolves to a git dir rather than a work tree, git rev-parse --show-toplevel exits 128 with fatal: this operation must be run in a work tree. The dispatcher survived (#10401 gave it a || pwd fallback), but it then execs pre-push-singleflight → preflight_runner.py → pre-push, each of which re-ran the unguarded call and aborted — so the gate died and the user was forced into a --no-verify push that silently bypasses all local checks. That is exactly the reported symptom (#10293):

$ git push origin <branch>
fatal: this operation must be run in a work tree
error: failed to push some refs to 'https://github.com/BasedHardware/omi.git'

Fix

Fall back to the invoking work tree — git runs hooks with the working directory at the work-tree top, and the dispatcher/gate cd into the resolved root before invoking these scripts — matching the fallback #10401 established for the dispatcher (git rev-parse --show-toplevel 2>/dev/null || pwd; the Python resolvers fall back to Path.cwd()).

What I tested

  • Reproduced the exact failure end-to-end: ran the real installed dispatcher chain under a bare GIT_DIR (which makes show-toplevel exit 128, identical to the reporter's condition). Before the fix it aborted at preflight_runner.py:249 with fatal: this operation must be run in a work tree; after the fix the gate proceeds past root resolution.
  • New regression test scripts/test-pre-push-worktree-fallback.sh (wired into .github/checks-manifest.yaml, local+ci): asserts all five call sites resolve the work-tree root instead of aborting under the 128 condition. Verified it fails against the pre-fix scripts and passes after.
  • Happy path unchanged: every resolver returns the correct root with no GIT_DIR override; existing scripts/test-make-setup.sh and the manifest contract self-test (test_run_checks.py, 22 tests) still pass.

Product invariants affected

none

Failure class (fixes)

Failure-Class: none

fixes #10293


Auto-generated from issue feedback by the mini issues-improver — tested and merged.

Review in cubic

…e-push chain

#10401 fixed the Makefile and the installed hook dispatcher, but the scripts the
dispatcher hands off to (scripts/pre-push, scripts/pre-push-singleflight,
scripts/pr-preflight) and the Python entrypoints they exec
(.github/scripts/preflight_runner.py, .github/scripts/pr_preflight.py) still
resolved the repo root with an unguarded `git rev-parse --show-toplevel`. In a
linked worktree whose git context resolves to a git dir rather than a work tree,
show-toplevel exits 128 ("this operation must be run in a work tree"), so the
gate aborted after the dispatcher — forcing a `--no-verify` push that silently
bypasses local checks, exactly as reported.

Fall back to the invoking work tree (git runs hooks at the work-tree top and the
dispatcher/gate cd into the resolved root first), matching the fallback #10401
established for the dispatcher.

Adds scripts/test-pre-push-worktree-fallback.sh (wired into the check manifest,
local+ci): a bare GIT_DIR reproduces the 128 condition and asserts every call
site in the chain resolves the root instead of aborting. Verified it fails
against the pre-fix scripts and passes after.

Failure-Class: none

fixes #10293
@undivisible

Copy link
Copy Markdown
Collaborator

Already merged in #10491 commit 7aa6c36; closing the superseded PR.

@undivisible
undivisible deleted the issues-improver/10293-worktree-hook-fallback branch July 26, 2026 21:02
@github-actions

Copy link
Copy Markdown
Contributor

Hey @kodjima33 👋

Thank you so much for taking the time to contribute to Omi! We truly appreciate you putting in the effort to submit this pull request.

After careful review, we've decided not to merge this particular PR. Please don't take this personally — we genuinely try to merge as many contributions as possible, but sometimes we have to make tough calls based on:

  • Project standards — Ensuring consistency across the codebase
  • User needs — Making sure changes align with what our users need
  • Code best practices — Maintaining code quality and maintainability
  • Project direction — Keeping aligned with our product principles and locked invariants

Before your next PR, please skim:

  • PRODUCT.md — product north star
  • Product invariants — locked rules (shared chat, memory tiers, agent control plane, integrations, brand)

If this was declined for direction or taste, maintainers should cite an invariant ID or open a proposed one — ask if that citation is missing.

Your contribution is still valuable to us, and we'd love to see you contribute again in the future! If you'd like feedback on how to improve this PR or want to discuss alternative approaches, please don't hesitate to reach out.

Thank you for being part of the Omi community!

tianmind-studio added a commit to tianmind-studio/omi that referenced this pull request Jul 27, 2026
Carry the complete BasedHardware#10293 root-resolution fix from BasedHardware#10491 into the portable pre-push chain, adapting its regression to the explicit Windows Python launcher contract and running it in the native Windows lane.

Tests: native Windows manifest checks pre-push-worktree-fallback, preflight-runner-portability, and check-manifest-contract; Python preflight and manifest unit suites; actionlint.

Failure-Class: none

Co-authored-by: Nik Shevchenko <[email protected]>
tianmind-studio added a commit to tianmind-studio/omi that referenced this pull request Jul 28, 2026
Carry the complete BasedHardware#10293 root-resolution fix from BasedHardware#10491 into the portable pre-push chain, adapting its regression to the explicit Windows Python launcher contract and running it in the native Windows lane.

Tests: native Windows manifest checks pre-push-worktree-fallback, preflight-runner-portability, and check-manifest-contract; Python preflight and manifest unit suites; actionlint.

Failure-Class: none

Co-authored-by: Nik Shevchenko <[email protected]>
Git-on-my-level added a commit that referenced this pull request Jul 30, 2026
Fixes #9724.
Fixes #10293.

## Summary

- make the single-flight runner register only host-supported signals and
replace destructive Windows `os.kill(pid, 0)` probing
- launch the extensionless pre-push script through Git Bash and carry
one explicit Python executable across every hook boundary, including the
`PRE_PUSH_SKIP_PR_PREFLIGHT=1` failure-class hatch
- contain the Windows command tree in a kill-on-close Job Object, with a
bootstrap barrier that assigns the job before the real command can spawn
- bind stale-lock identity to Windows process creation ticks so PID
reuse cannot impersonate the prior owner
- decode Git metadata as UTF-8 so native Windows locales can resolve
non-ASCII worktree paths
- make the check manifest Windows-aware and add a path-scoped native
Windows workflow that executes the manifest-owned portability checks
- preserve the mainline `forwardable_signals` and direct-child fallback
contracts while extending Windows ownership to the full process tree
- restore the linked-worktree repo-root fallback across all five
downstream shell/Python pre-push entrypoints, so a `show-toplevel` exit
128 does not force contributors toward `--no-verify`
- keep native process tests event-driven with pipe handshakes and
`WaitForSingleObject`, without wall-clock polling or leaked handles

## Root cause

The pre-push control plane assumed POSIX signals, process groups,
executable script launching, virtualenv layout, and `python3` naming at
native Windows boundaries. It also let Python decode Git's UTF-8 output
with the active Windows code page, so a worktree path containing
non-ASCII characters could fail before any check ran.

A second gap remained after #10401: the installed hook dispatcher could
recover when `git rev-parse --show-toplevel` failed in a linked
worktree, but `scripts/pre-push`, `scripts/pre-push-singleflight`,
`scripts/pr-preflight`, `.github/scripts/preflight_runner.py`, and
`.github/scripts/pr_preflight.py` repeated the unguarded lookup and
aborted later in the same chain.

Fixing only the first Windows exception or only the Makefile/dispatcher
boundary would expose the next launch, liveness, decoding,
root-resolution, or hatch failure. This PR closes that reachable
portability chain.

## Attribution

The linked-worktree root-resolution slice preserves Nik Shevchenko's
original #10491 implementation through the rebased commit lineage, with
`Co-authored-by: Nik Shevchenko <[email protected]>`. Its regression
was adapted to the explicit Windows Python launcher introduced by this
PR and registered in both manifest lanes plus native Windows CI.

## Verification

- rebased onto current `origin/main` (`ffc13daf4c`) and reran the native
Windows checks
- native Windows manifest run: `pre-push-worktree-fallback`,
`preflight-runner-portability`, and `check-manifest-contract` -> 3
checks passed
- native Windows: `test_preflight_runner.py` -> 23 tests passed with
`ResourceWarning` promoted to an error, including a real Job Object
parent/descendant termination proof, explicit hatch interpreter
coverage, and runner/direct PR-preflight execution from a Chinese
worktree path with `PYTHONUTF8=0`
- native Windows: a temporary Git repository ran the real
`pre-push-singleflight -> preflight_runner -> pre-push` chain with no
`python3` on `PATH`
- native Windows: `test_run_checks.py` -> 33 tests passed, 1 POSIX-only
fixture skipped; the real manifest subprocess path also resolved
`python3` to the active interpreter with an empty `PATH`
- native Windows: full `test_pr_preflight.py` -> 26 tests passed, 3
explicit host-capability skips
- native Windows: `test-pre-push-worktree-fallback.sh` passed against
all five downstream root resolvers under the reproduced exit-128
condition
- `test_pre_push_ci_prediction.py` -> 14 tests passed
- `scripts/test-pre-push-diff-base.sh` passed under Git Bash
- `bash -n` passed for all four touched shell scripts
- Black 26.5.1 passed for the touched Python files with the repository's
120-column/no-string-normalization settings
- actionlint 1.7.12 passed for the Windows workflow
- `python -m py_compile` passed for all touched Python files
- `scripts/failure-class validate --base origin/main --head HEAD ...`
passed with `Failure-Class: none`
- `git diff --check origin/main...HEAD` passed

GNU Make is not installed on the local Windows host, so
`scripts/test-make-setup.sh` could not be rerun there. The new
regression exercises every downstream root resolver directly on native
Windows; Linux CI remains authoritative for the existing Make fixture
and the full manifest.

The committed diff changes the manifest, so the legacy local selector
intentionally attempts every manifest check. On native Windows that
broad run currently stops while collecting the existing
`dev-harness-unit-tests` because its qualification module imports
POSIX-only `fcntl`; the path-scoped Windows workflow therefore executes
the portability contracts by manifest check ID, while Linux CI remains
the full-manifest authority.

## Product invariants affected

none

## Failure class (fixes)

Failure-Class: none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

make setup and pre-push hook fail with 'this operation must be run in a work tree' in linked git worktrees

2 participants