Repository navigation
pre-push: make the push gate work in cone-mode sparse checkouts - #21523
Git-on-my-level wants to merge 9 commits into
Conversation
Cone-mode sparse worktrees do not materialise out-of-cone paths, so a literal trigger or command path that is real at HEAD fails validate_manifest's working-tree existence check, and every sparse checkout hard-fails pre-push at manifest resolution with hundreds of 'explicit trigger path does not exist' errors before any check runs. Validate against the HEAD tree as well as the working tree: present in either passes; absent from both still fails closed (typos unchanged). head_tree_paths() lists HEAD once per invocation, not once per path.
…heckouts Same class as the manifest validation fix: the registry check requires prereg docs to exist on the working tree, and a cone-mode sparse checkout does not materialise out-of-cone paths, so feature-flag-registry failed in any sparse lane whose cone excludes the prereg doc. Accept a prereg path that exists on disk or is tracked at HEAD; neither still fails.
The read scanner iterates tracked paths but skipped any file absent from the working tree, so a cone-mode sparse checkout reported every app/web flag as 'stale registry entry'. Read sources (and chart manifests) from disk first, falling back to the HEAD blob; an alias with no read on disk or at HEAD still fails. Uncommitted deletions are judged against HEAD, which is what the pushed tree will contain.
… checkouts The drift guard that proves registered test commands actually execute cases read test modules from the working tree only, so a cone-mode sparse checkout failed check-manifest-contract with 'does not exist' for every out-of-cone test module. Read disk first, HEAD blob second; absent from both is still an offender.
The registry audit fails every locked invariant whose guard file is absent from the working tree, and guards live across all surfaces, so a cone-mode sparse checkout failed product-invariants on every push. Existence now counts the HEAD tree as well; a guard in neither still fails closed.
…checkouts canonical_prevention_artifact paths are guard files across every surface; a cone-mode sparse checkout does not materialise out-of-cone paths, so validate failed on every push from a sparse lane. Existence now counts the HEAD tree as well; a path in neither still fails.
… checkouts Each area scanner fails when its entry tree is missing from the working tree. A cone-mode sparse checkout legitimately excludes whole areas (app/, desktop/macos/agent, desktop/windows), so the ratchet failed on every push from a sparse lane even though none of those files can have changed there. Skip areas whose entry paths carry the skip-worktree bit (tracked, cone-excluded): they carry no signal in this worktree and CI's dense run still enforces them. User deletions keep their 'H' tag and keep failing closed; a skipped area also never rewrites its baseline.
The C10 check reads docs/api-reference/app-client-openapi.json from the working tree; docs/ is outside every code surface's sparse cone, so a cone-mode sparse lane crashed pre-push. Read disk first, HEAD blob second.
…outs The lint fails when desktop/macos/e2e/flows is missing, which every cone-mode sparse checkout without the desktop surface is. Skip with a note when the directory carries the skip-worktree bit (tracked, cone-excluded — dense CI enforces it); deletions keep failing.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f5cdb4df96
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| out = subprocess.run( | ||
| ["git", "-C", str(key), "ls-tree", "-r", "--name-only", "-z", "HEAD"], | ||
| stdout=subprocess.PIPE, | ||
| stderr=subprocess.DEVNULL, | ||
| check=True, | ||
| ).stdout | ||
| _HEAD_TREE_CACHE[key] = frozenset(entry.decode("utf-8") for entry in out.split(b"\0") if entry) |
There was a problem hiding this comment.
Treat tracked artifact directories as present
In a cone-mode checkout that excludes backend/, git ls-tree -r --name-only lists only files, so the existing directory-valued artifact backend/tests/unit/ in .github/failure-classes/FC-conversation-persistence-expired-transaction.json is absent from both the worktree and this set. Failure-class validation therefore reports missing_canonical_prevention_artifact, leaving app/desktop-only sparse checkouts unable to pass the push gate. Include tree entries or accept a directory when tracked paths have that prefix.
Useful? React with 👍 / 👎.
| if scan.skipped: | ||
| return [], warnings, scan |
There was a problem hiding this comment.
Validate dead-code metadata before skipping an area
When an area's source tree is cone-excluded but its .github/scripts/dead_code/<area>.baseline.json or allowlist is edited, this early return bypasses both metadata loaders even though those files remain materialized and their changes select the dead-code check. For example, malformed backend.allowlist.json exits successfully in an app-only sparse checkout and fails only later in dense CI. Keep the source scan skipped, but still parse and schema-check the baseline and allowlist.
Useful? React with 👍 / 👎.
| def source_text(root: Path, path: str) -> str | None: | ||
| """File content from the working tree, falling back to the HEAD blob. | ||
|
|
||
| Cone-mode sparse checkouts keep out-of-cone paths in the index but do not | ||
| materialise them, so flag reads outside the cone must be scanned at HEAD |
There was a problem hiding this comment.
Apply the HEAD fallback to the rendered registry check
In an app-only cone where backend/ is excluded, the feature-flag check still reads backend/docs/feature-flag-registry.md directly in scripts/check_feature_flag_registry.py, so it reports a missing as-of header even though the file exists at HEAD. If that read alone is converted, render_feature_flag_registry.py also reads its backend runtime manifests and charts only from disk and produces false drift. Extend this fallback to the committed rendered document and its render inputs, or explicitly skip the render comparison when that backend surface is cone-excluded.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
17 issues found across 13 files
Confidence score: 2/5
- HEAD fallbacks in
scripts/feature_flag_registry.py,.github/scripts/check_product_invariants.py,scripts/failure-class,.github/scripts/run_checks.py, andscripts/check_client_compat.pycan treat an ordinary deleted file as sparse-excluded, letting validation pass or scanning stale content. Check the index’sskip-worktreestate before falling back toHEAD. .github/scripts/test_check_product_invariants.pymodels a user deletion rather than a cone-excluded sparse path, so it locks in the wrong behavior;.github/scripts/test_run_checks.pyalso misses the deleted-module failure. Add coverage that distinguishes sparse exclusions from ordinary deletions..github/scripts/check_dead_code.pycan scan only part of an area when cone mode leaves the root present but excludes importing subtrees, making live files appear dead. Detect excluded files before scanning..github/scripts/run_checks.pylets a directory satisfy a Python command path, weakening the previousis_file()check. Keep the file check for materialized commands.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name=".github/scripts/test_check_product_invariants.py">
<violation number="1" location=".github/scripts/test_check_product_invariants.py:383">
P2: This test models a user deletion, not a cone-excluded sparse path, so it locks in acceptance of deleted guards and never verifies the required sparse-vs-deleted distinction. Create an actual cone sparse checkout for the passing case and add a separate user-deletion case that remains fail-closed.</violation>
</file>
<file name="scripts/failure-class">
<violation number="1" location="scripts/failure-class:227">
P2: This fallback treats every missing working-tree path that exists in `HEAD` as sparse-excluded, so an ordinary user deletion of a guard artifact passes validation. Gate the `HEAD` fallback on the path being marked sparse/skip-worktree, while keeping normal worktree deletions missing.</violation>
</file>
<file name="desktop/macos/scripts/desktop-flow-lint.py">
<violation number="1" location="desktop/macos/scripts/desktop-flow-lint.py:85">
P2: `--flows-dir` does not work with a relative path in sparse checkouts because this comparison mixes a relative CLI path with Git’s absolute root. Resolve both paths before computing the Git pathspec so explicit `--flows-dir desktop/macos/e2e/flows` receives the same sparse-skip behavior as the default.</violation>
<violation number="2" location="desktop/macos/scripts/desktop-flow-lint.py:96">
P2: This helper treats any all-`S` index state as cone exclusion, even when sparse-checkout is disabled. Check the active sparse-checkout configuration before returning true, otherwise manually marked files let a deleted flows directory bypass the lint.</violation>
</file>
<file name=".github/scripts/run_checks.py">
<violation number="1" location=".github/scripts/run_checks.py:192">
P2: This treats every HEAD-tracked path missing from disk as sparse-excluded, so user deletions still pass validation or get scanned from stale HEAD content. Check the index `skip-worktree` state, as `check_dead_code._sparse_excluded` does, and reject ordinary worktree deletions.</violation>
<violation number="2" location=".github/scripts/run_checks.py:221">
P2: `_path_exists` allows directories to satisfy Python command paths, regressing the previous `is_file()` contract. Keep `is_file()` for materialized commands while allowing only an absent, HEAD-tracked file for sparse checkouts.</violation>
</file>
<file name=".github/scripts/check_dead_code.py">
<violation number="1" location=".github/scripts/check_dead_code.py:99">
P2: `S` does not prove that cone sparse-checkout excluded the area: a dense checkout can get the same tag from `git update-index --skip-worktree`. Verify sparse-checkout configuration and mode before treating an all-`S` path as safely skipped, or a user can make the gate pass after deleting the area.</violation>
<violation number="2" location=".github/scripts/check_dead_code.py:242">
P2: This sparse guard only runs when the area root is absent, but cone mode can leave `backend/` present while excluding importing subtrees. The partial scan can report live files as dead; detect any excluded files before scanning or read the missing files from `HEAD`.</violation>
</file>
<file name=".github/scripts/check_product_invariants.py">
<violation number="1" location=".github/scripts/check_product_invariants.py:22">
P3: The PR duplicates the sparse HEAD-tree lookup in this script and `scripts/failure-class`. Extract the stdlib lookup into one shared helper so path decoding, caching, and Git failure behavior stay consistent.</violation>
<violation number="2" location=".github/scripts/check_product_invariants.py:369">
P1: `tracked_at_head` treats every missing path present in `HEAD` as valid, including a guard deleted from the worktree. Distinguish sparse `S ` skip-worktree entries from normal or deleted entries before accepting a HEAD-only guard.</violation>
</file>
<file name="scripts/test_failure_class.py">
<violation number="1" location="scripts/test_failure_class.py:150">
P2: This test does not simulate a cone-mode sparse checkout, so it cannot catch regressions that accept user deletions as valid HEAD fallbacks. Configure cone-mode sparse checkout while retaining `.github` and `src`, then assert the out-of-cone artifact is absent without deleting it.</violation>
</file>
<file name="scripts/test_check_feature_flag_registry.py">
<violation number="1" location="scripts/test_check_feature_flag_registry.py:142">
P2: This fixture never enables a sparse checkout, so the test only verifies the generic HEAD fallback after a working-tree deletion. It can pass while cone-mode or sparse-index path discovery is broken; initialize a cone sparse checkout that excludes `app/` before the assertion (and do the equivalent for the prereg fixture).</violation>
</file>
<file name="scripts/feature_flag_registry.py">
<violation number="1" location="scripts/feature_flag_registry.py:112">
P2: This accepts any missing preregistration document whose pathname exists in HEAD, including a user deletion in a normal or sparse-in-cone checkout. Check the path’s skip-worktree state before accepting HEAD membership as sparse evidence; ordinary `H` deletions must continue reporting the missing-file error.</violation>
<violation number="2" location="scripts/feature_flag_registry.py:183">
P1: `source_text` treats a user deletion as a sparse omission: an unstaged deleted path remains indexed, so this fallback scans HEAD’s old blob and lets the registry pass without the deleted read. Restrict the HEAD fallback to `git ls-files -t` entries marked `S` (skip-worktree); an `H` entry or no entry should return `None` and preserve fail-closed deletion detection.</violation>
</file>
<file name=".github/scripts/test_run_checks.py">
<violation number="1" location=".github/scripts/test_run_checks.py:286">
P3: These regression tests do not simulate sparse absence, so the regular unit suite never verifies the new behavior. Use a temporary sparse/index setup or patch the existence boundary so each path is absent from disk but present in `HEAD`, then assert the fallback is what makes validation pass.</violation>
<violation number="2" location=".github/scripts/test_run_checks.py:355">
P2: This fallback masks user deletions: any valid manifest-invoked test module deleted from the worktree is replaced with its `HEAD` blob, so `test_manifest_test_modules_execute_their_cases` passes instead of failing closed. Restrict the `HEAD` fallback to paths marked `skip-worktree`; report ordinary missing worktree files as absent.</violation>
</file>
<file name="scripts/check_client_compat.py">
<violation number="1" location="scripts/check_client_compat.py:208">
P2: This fallback masks user deletions because it treats every missing worktree file with a HEAD blob as a sparse-checkout omission. Check the index for a `skip-worktree` entry before reading HEAD; otherwise re-read the missing path so the compatibility gate fails.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
| file = root / path | ||
| if file.is_file(): | ||
| return file.read_text(encoding="utf-8") | ||
| result = subprocess.run( |
There was a problem hiding this comment.
P1: source_text treats a user deletion as a sparse omission: an unstaged deleted path remains indexed, so this fallback scans HEAD’s old blob and lets the registry pass without the deleted read. Restrict the HEAD fallback to git ls-files -t entries marked S (skip-worktree); an H entry or no entry should return None and preserve fail-closed deletion detection.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At scripts/feature_flag_registry.py, line 183:
<comment>`source_text` treats a user deletion as a sparse omission: an unstaged deleted path remains indexed, so this fallback scans HEAD’s old blob and lets the registry pass without the deleted read. Restrict the HEAD fallback to `git ls-files -t` entries marked `S` (skip-worktree); an `H` entry or no entry should return `None` and preserve fail-closed deletion detection.</comment>
<file context>
@@ -161,6 +169,29 @@ def tracked_code_paths(root: Path) -> list[str]:
+ file = root / path
+ if file.is_file():
+ return file.read_text(encoding="utf-8")
+ result = subprocess.run(
+ ["git", "-C", str(root), "show", f"HEAD:{path}"],
+ stdout=subprocess.PIPE,
</file context>
| if not (root / guard_file).exists(): | ||
| problems.append(f"{name}: {inv['id']} is locked but names a guard that does not exist: {guard_file}") | ||
| tracked = tracked_at_head(root) | ||
| if tracked is None or guard_file not in tracked: |
There was a problem hiding this comment.
P1: tracked_at_head treats every missing path present in HEAD as valid, including a guard deleted from the worktree. Distinguish sparse S skip-worktree entries from normal or deleted entries before accepting a HEAD-only guard.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At .github/scripts/check_product_invariants.py, line 369:
<comment>`tracked_at_head` treats every missing path present in `HEAD` as valid, including a guard deleted from the worktree. Distinguish sparse `S ` skip-worktree entries from normal or deleted entries before accepting a HEAD-only guard.</comment>
<file context>
@@ -341,7 +365,11 @@ def audit_registry(root: Path) -> list[str]:
if not (root / guard_file).exists():
- problems.append(f"{name}: {inv['id']} is locked but names a guard that does not exist: {guard_file}")
+ tracked = tracked_at_head(root)
+ if tracked is None or guard_file not in tracked:
+ problems.append(
+ f"{name}: {inv['id']} is locked but names a guard that does not exist: {guard_file}"
</file context>
| subprocess.run(["git", "-C", str(root), "init", "-q"], check=True, env=env) | ||
| subprocess.run(["git", "-C", str(root), *identity, "add", "-A"], check=True, env=env) | ||
| subprocess.run(["git", "-C", str(root), *identity, "commit", "-qm", "fixture"], check=True, env=env) | ||
| (root / "guards" / "present.py").unlink() |
There was a problem hiding this comment.
P2: This test models a user deletion, not a cone-excluded sparse path, so it locks in acceptance of deleted guards and never verifies the required sparse-vs-deleted distinction. Create an actual cone sparse checkout for the passing case and add a separate user-deletion case that remains fail-closed.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At .github/scripts/test_check_product_invariants.py, line 383:
<comment>This test models a user deletion, not a cone-excluded sparse path, so it locks in acceptance of deleted guards and never verifies the required sparse-vs-deleted distinction. Create an actual cone sparse checkout for the passing case and add a separate user-deletion case that remains fail-closed.</comment>
<file context>
@@ -363,6 +363,32 @@ def test_locked_invariant_naming_a_missing_guard_fails(self):
+ subprocess.run(["git", "-C", str(root), "init", "-q"], check=True, env=env)
+ subprocess.run(["git", "-C", str(root), *identity, "add", "-A"], check=True, env=env)
+ subprocess.run(["git", "-C", str(root), *identity, "commit", "-qm", "fixture"], check=True, env=env)
+ (root / "guards" / "present.py").unlink()
+ self.assertEqual(audit_registry(root), [])
+ # A guard in neither the working tree nor HEAD still fails.
</file context>
| f"'canonical_prevention_artifact' path does not exist: {item}", | ||
| path=str(path), | ||
| tracked = tracked_at_head(root) | ||
| if tracked is None or item not in tracked: |
There was a problem hiding this comment.
P2: This fallback treats every missing working-tree path that exists in HEAD as sparse-excluded, so an ordinary user deletion of a guard artifact passes validation. Gate the HEAD fallback on the path being marked sparse/skip-worktree, while keeping normal worktree deletions missing.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At scripts/failure-class, line 227:
<comment>This fallback treats every missing working-tree path that exists in `HEAD` as sparse-excluded, so an ordinary user deletion of a guard artifact passes validation. Gate the `HEAD` fallback on the path being marked sparse/skip-worktree, while keeping normal worktree deletions missing.</comment>
<file context>
@@ -197,13 +223,15 @@ def validate_canonical_prevention_artifact(value: Any, path: Path, root: Path) -
- f"'canonical_prevention_artifact' path does not exist: {item}",
- path=str(path),
+ tracked = tracked_at_head(root)
+ if tracked is None or item not in tracked:
+ errors.append(
+ error(
</file context>
| return False | ||
| root = Path(top.stdout.strip()) | ||
| try: | ||
| relative = flows_dir.relative_to(root).as_posix() |
There was a problem hiding this comment.
P2: --flows-dir does not work with a relative path in sparse checkouts because this comparison mixes a relative CLI path with Git’s absolute root. Resolve both paths before computing the Git pathspec so explicit --flows-dir desktop/macos/e2e/flows receives the same sparse-skip behavior as the default.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At desktop/macos/scripts/desktop-flow-lint.py, line 85:
<comment>`--flows-dir` does not work with a relative path in sparse checkouts because this comparison mixes a relative CLI path with Git’s absolute root. Resolve both paths before computing the Git pathspec so explicit `--flows-dir desktop/macos/e2e/flows` receives the same sparse-skip behavior as the default.</comment>
<file context>
@@ -59,6 +60,42 @@ def fail(message: str) -> None:
+ return False
+ root = Path(top.stdout.strip())
+ try:
+ relative = flows_dir.relative_to(root).as_posix()
+ except ValueError:
+ return False
</file context>
| relative = flows_dir.relative_to(root).as_posix() | |
| relative = flows_dir.resolve().relative_to(root.resolve()).as_posix() |
| # validate against plain directories): disk only. | ||
| tracked = head_tree_paths(resolved_root) | ||
| relative = resolved.relative_to(resolved_root).as_posix() | ||
| if tracked is None or relative not in tracked: |
There was a problem hiding this comment.
P2: This accepts any missing preregistration document whose pathname exists in HEAD, including a user deletion in a normal or sparse-in-cone checkout. Check the path’s skip-worktree state before accepting HEAD membership as sparse evidence; ordinary H deletions must continue reporting the missing-file error.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At scripts/feature_flag_registry.py, line 112:
<comment>This accepts any missing preregistration document whose pathname exists in HEAD, including a user deletion in a normal or sparse-in-cone checkout. Check the path’s skip-worktree state before accepting HEAD membership as sparse evidence; ordinary `H` deletions must continue reporting the missing-file error.</comment>
<file context>
@@ -102,7 +102,15 @@ def validate_registry(registry: dict[str, list[dict[str, Any]]], *, root: Path =
+ # validate against plain directories): disk only.
+ tracked = head_tree_paths(resolved_root)
+ relative = resolved.relative_to(resolved_root).as_posix()
+ if tracked is None or relative not in tracked:
+ errors.append(f"{label}: prereg file does not exist: {prereg}")
elif "prereg" in entry:
</file context>
| path = REPO_ROOT / relative | ||
| if not path.exists(): | ||
| source = ( | ||
| path.read_text(encoding="utf-8") if path.is_file() else head_blob(REPO_ROOT, relative) |
There was a problem hiding this comment.
P2: This fallback masks user deletions: any valid manifest-invoked test module deleted from the worktree is replaced with its HEAD blob, so test_manifest_test_modules_execute_their_cases passes instead of failing closed. Restrict the HEAD fallback to paths marked skip-worktree; report ordinary missing worktree files as absent.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At .github/scripts/test_run_checks.py, line 355:
<comment>This fallback masks user deletions: any valid manifest-invoked test module deleted from the worktree is replaced with its `HEAD` blob, so `test_manifest_test_modules_execute_their_cases` passes instead of failing closed. Restrict the `HEAD` fallback to paths marked `skip-worktree`; report ordinary missing worktree files as absent.</comment>
<file context>
@@ -309,11 +347,17 @@ def test_manifest_test_modules_execute_their_cases(self) -> None:
path = REPO_ROOT / relative
- if not path.exists():
+ source = (
+ path.read_text(encoding="utf-8") if path.is_file() else head_blob(REPO_ROOT, relative)
+ )
+ if source is None:
</file context>
| blob = subprocess.run(['git', '-C', str(root), 'show', f'HEAD:{relative}'], capture_output=True, text=True) | ||
| if blob.returncode != 0: | ||
| return json.loads(path.read_text()) | ||
| return json.loads(blob.stdout) |
There was a problem hiding this comment.
P2: This fallback masks user deletions because it treats every missing worktree file with a HEAD blob as a sparse-checkout omission. Check the index for a skip-worktree entry before reading HEAD; otherwise re-read the missing path so the compatibility gate fails.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At scripts/check_client_compat.py, line 208:
<comment>This fallback masks user deletions because it treats every missing worktree file with a HEAD blob as a sparse-checkout omission. Check the index for a `skip-worktree` entry before reading HEAD; otherwise re-read the missing path so the compatibility gate fails.</comment>
<file context>
@@ -194,6 +194,23 @@ def validate_catalog(catalog, policy, root=ROOT, prior=None):
+ path = root / relative
+ if path.is_file():
+ return json.loads(path.read_text())
+ blob = subprocess.run(['git', '-C', str(root), 'show', f'HEAD:{relative}'], capture_output=True, text=True)
+ if blob.returncode != 0:
+ return json.loads(path.read_text())
</file context>
| blob = subprocess.run(['git', '-C', str(root), 'show', f'HEAD:{relative}'], capture_output=True, text=True) | |
| if blob.returncode != 0: | |
| return json.loads(path.read_text()) | |
| return json.loads(blob.stdout) | |
| tracked = subprocess.run(['git', '-C', str(root), 'ls-files', '-t', '--', relative], capture_output=True, text=True) | |
| if tracked.returncode == 0 and tracked.stdout.startswith('S '): | |
| blob = subprocess.run(['git', '-C', str(root), 'show', f'HEAD:{relative}'], capture_output=True, text=True) | |
| if blob.returncode == 0: | |
| return json.loads(blob.stdout) | |
| return json.loads(path.read_text()) |
|
|
||
| INVARIANT_DIR = Path("product/invariants") | ||
|
|
||
| _HEAD_TREE_CACHE: dict[Path, frozenset[str] | None] = {} |
There was a problem hiding this comment.
P3: The PR duplicates the sparse HEAD-tree lookup in this script and scripts/failure-class. Extract the stdlib lookup into one shared helper so path decoding, caching, and Git failure behavior stay consistent.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At .github/scripts/check_product_invariants.py, line 22:
<comment>The PR duplicates the sparse HEAD-tree lookup in this script and `scripts/failure-class`. Extract the stdlib lookup into one shared helper so path decoding, caching, and Git failure behavior stay consistent.</comment>
<file context>
@@ -18,6 +18,30 @@
INVARIANT_DIR = Path("product/invariants")
+
+_HEAD_TREE_CACHE: dict[Path, frozenset[str] | None] = {}
+
+
</file context>
| # pre-push at manifest resolution. | ||
| manifest = load_manifest(MANIFEST_PATH) | ||
| first = manifest.checks[0] | ||
| tracked_but_sparse = "web/app/Dockerfile" |
There was a problem hiding this comment.
P3: These regression tests do not simulate sparse absence, so the regular unit suite never verifies the new behavior. Use a temporary sparse/index setup or patch the existence boundary so each path is absent from disk but present in HEAD, then assert the fallback is what makes validation pass.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At .github/scripts/test_run_checks.py, line 286:
<comment>These regression tests do not simulate sparse absence, so the regular unit suite never verifies the new behavior. Use a temporary sparse/index setup or patch the existence boundary so each path is absent from disk but present in `HEAD`, then assert the fallback is what makes validation pass.</comment>
<file context>
@@ -275,6 +276,43 @@ def test_explicit_trigger_path_must_exist(self) -> None:
+ # pre-push at manifest resolution.
+ manifest = load_manifest(MANIFEST_PATH)
+ first = manifest.checks[0]
+ tracked_but_sparse = "web/app/Dockerfile"
+ malformed = Check(
+ first.id,
</file context>
|
Folding batch (2026-11-04): this branch's tip was merged into the survivor PR #24477 ( |
|
Hey @Git-on-my-level 👋 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:
Before your next PR, please skim:
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! |
What
Eight small fixes so
scripts/pre-pushpasses in a cone-mode sparse checkout (e.g. an agent lane scoped tobackend,appvia omi-lane--surfaces). All follow one rule: existence/content checks consult the HEAD tree when the working tree lacks a path; a path in neither still fails closed, and cone-excluded scanners skip with a note because CI's dense run enforces them.run_checks.validate_manifest: literal trigger/command paths may be tracked at HEAD (a sparse checkout legitimately lacks them on disk) — this alone unblocked every sparse push;head_tree_paths()lists HEAD once per invocationfeature_flag_registry: prereg docs valid if tracked at HEAD; the read scanner and chart manifests read disk-first, HEAD-blob-second (previously every app/web flag was misreportedstalein a backend-only lane)check_product_invariants: guards valid if tracked at HEADfailure-class:canonical_prevention_artifactpaths valid if tracked at HEADcheck_dead_code: areas whose entry paths carry the skip-worktree bit are skipped (no signal in this worktree; user deletions keep failing; a skipped area never rewrites its baseline)desktop-flow-lint: same skip rule for the cone-excluded flows dircheck_client_compat: OpenAPI doc read disk-first, HEAD-blob-second (docs/is outside every code cone)test_run_checksdrift guard reads manifest test modules disk-first, HEAD-secondWhy
Dense checkouts are unchanged (disk hit short-circuits every fallback). Sparse agent lanes (m5: ~518 omi worktrees, 10–16 concurrent agents) currently hard-fail pre-push at manifest resolution with hundreds of
explicit trigger path does not existerrors — before any check runs.Evidence
backend scripts .github config contracts contract_tests desktop/macos/scripts product plugins), 8 commits on the lane:scripts/pre-push origin→ "PR preflight passed: 41 checks in 314.30s" (exit 0)test_run_checks62/63 (test_new_marker_requires_tracking_issuefails identically on pristineorigin/main— pre-existing drift),test_check_feature_flag_registry26/26,test_check_product_invariants39/39,test_failure_class32/32,test_check_dead_code16/16,test_desktop_flow_lint6/6Rollout on m5
Nothing to do beyond merging — the checks ship in the repo. After merge, sparse lanes created by omi-workspace
omi-lane --surfaces(separate PR) get a working pre-push; dense worktrees are bit-for-bit unchanged. Verify on one lane: