Skip to content

fix(reference): Exclude Git pointer files from source identities - #7667

Merged
morluto merged 2 commits into
morluto:mainfrom
WenyuChiou:fix/reference-source-gitfile-7551
Nov 3, 2026
Merged

morluto merged 2 commits into
morluto:mainfrom
WenyuChiou:fix/reference-source-gitfile-7551

Conversation

@WenyuChiou

@WenyuChiou WenyuChiou commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #7551. Exclude linked-worktree .git pointer files from reference-source inventories so checkout-specific administrative paths do not change source identities. Keep Git HEAD discovery and the existing .git/ directory exclusion provenance.

Problem and expected behavior

Two clean linked worktrees at the same commit produced different root_sha256, graph_sha256, and manifest_id values because the importer hashed each root's .git pointer. The source files and HEAD matched, and repeating the same import was stable. Git administration should be excluded in both its file and directory representations.

Change and scope

  • Add .git to the owning default exclusion list after the existing directory rules. The matcher records the first positive match, so this order preserves the directory pattern .git/.

  • Add regressions for two linked worktrees, repeat imports, ordinary checkout provenance, nested metadata files/directories, similarly named source files, directory-only defaults, and configured-secret precedence over a caller negation.

  • Route every synthetic Git command through an isolated child environment and owned empty config, template, and hook paths. A controlled rejecting hook/template check validates this without modifying host Git settings.

This is a focused fix within existing contribution boundaries. Open #2630 and #5472 concern caller-selected exclusions; this change fixes the default policy. The Git locator, reader lifecycle, caller rules, secret rules, and manifest builder are unchanged. No new provider or target execution capability is added.

Contract and boundary impact

  • Semantic owner and earliest changed stage: DEFAULT_REFERENCE_SOURCE_IGNORE_PATTERNS in ReferenceSourceImportTypes.ts, consumed by the existing import-policy matcher before source capture.
  • Contribution scope and maintainer decision: ordinary inventory fix; advance scope decision not applicable.
  • CLI/MCP contract: existing import behavior is corrected; no option, schema, or tool-catalog change.
  • Provider/platform compatibility: no provider change. Native Windows source imports remain unsupported because safe no-follow opens are unavailable.
  • Evidence/provenance: .git pointers become default-ignored exclusions with pattern .git; ordinary directories retain pattern .git/; HEAD is retained. Ordinary and linked checkout manifests are not asserted identical because exclusion kinds differ.
  • Target authority and cleanup: existing local read boundary and resource ownership remain unchanged. Tests create owned synthetic Git repositories/worktrees and await fixture cleanup.
  • Generated metadata/package/installation: no tracked generated output, dependency, package, or installer change.

Expected effects:

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.

The production importer executes no target code. Native Git runs only to create and verify the synthetic test fixtures.

Evidence and regression coverage

Executed synthetic production-boundary checks reproduced the defect on base 40b9c03f996270e944ff07cafb63be15ce903708: both worktrees were clean with equal commit/tree IDs, but all three identities differed and .git was inventoried. After the fix, eight imports passed: the three identities match across linked worktrees; retry identity and HEAD remain stable; intended file count is two; ordinary-directory and nested-metadata provenance and secret precedence remain correct. These checks called the production importer, not the public CLI.

The tracked regression failed on the baseline at .git exclusion. On Windows after the fix, its matcher/provenance case passes and three import-dependent cases are explicitly skipped.

Boundary coverage addresses inventory identity, file/directory representation, relocation between linked roots, pruning, and source-policy precedence. No reader lifecycle implementation changed.

Validation performed

  • Current-head CI run 40613503831 completed successfully for 95e78b63e5f4fcf1107b635e8f3c7e7344eb6464: source tests, static checks, package build, all eight portable shards, native package checks, and CI required passed.
  • The current-head Linux regression log explicitly passes all 4 tests in referenceSourceGitMetadataExclusion.test.ts on Node 24.22.1.
  • npm run check passed on the production-fix revision f66b147 with pinned Windows Node 24.22.1/npm 11.16.0. npm run check:fast, staged-file lint/format checks, and the per-push gate passed for the final test-only isolation follow-up.
  • Targeted Windows Vitest: 1 passed, 3 import-dependent Windows skips. The actual isolation helper also passed a pinned-Node native Git proof: the unisolated control copies an injected template and rejects its commit; the isolated helper completes commit, worktree, HEAD, and status checks.
  • Test discovery found all 2,688 files exactly once.
  • Offline production-boundary reproduction in cached Linux Node 22.19.0 confirmed the baseline defect and passed eight imports after the fix. That runtime is outside the pinned support range and remains supporting evidence only; current-head supported-runtime qualification is supplied by CI above.
  • Independent review approved the production fix and the exact final isolation follow-up tree a2ba91ee9cdb03873ff5fa81030a5f0608172930. Greptile's current-head review reports 5/5 and confirms the fixture-isolation issue is addressed.

Remaining limits: the full deterministic suite was not run locally; native Windows source imports remain unsupported; no macOS or real-provider workflow was run. These checks do not establish real Hopper/Ghidra or browser behavior.

The Git fixture-isolation finding is addressed in the published test-only follow-up. Host Git configuration and real repository commit/push checks remain unchanged.

Compatibility, safety, and release

Previously imported Git pointer bytes are now excluded by default, correcting the evidence identity defect. Existing caller policy, configured-secret priority, HEAD provenance, and ordinary-directory exclusion records are preserved. No migration or package metadata change is required. No real Hopper/Ghidra, browser, or other provider workflow was run.

Author readiness

Human owner: @WenyuChiou

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

Match .git pointer files in the default import policy after the existing
directory rules, preserving ordinary-checkout exclusion provenance and Git
HEAD discovery. Cover linked-worktree identities, repeated imports, nested
metadata, similarly named source files, and configured-secret precedence.

Independent review: parent independent review APPROVE for Draft CI on patch
61bddf108952c77858fa71c333b4bb8a05ab33e8b03f5c6bccd879cd19c7c379 and source
tree 2d2372a. Review triggers: delegated
shipping output, source inventory/file I/O behavior, and more than 50 lines.

Validation: npm run check passed with Node 24.22.1/npm 11.16.0 on Windows;
tracked Vitest regression 1 passed/3 Windows skips; test discovery passed.
Eight offline Linux production imports passed on cached Node 22.19.0 as
supporting evidence only. Pinned Linux/macOS Vitest cases await hosted CI.

Fixes morluto#7551
@greptile-apps

greptile-apps Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; the previous fixture-isolation issue is addressed.

Summary

Adds .git to the default exclusions so linked-worktree pointer files do not change source identities.

  • Linked-worktree imports ignore checkout-specific Git pointer files.

Reviews (2) · Last reviewed commit: "test(reference): Isolate worktree fixtur..." · Reviewed by Greptile

Route every fixture Git command through one wrapper with a filtered child
environment, owned empty global config/template/hook paths, and no system
config reads. Keep resource cleanup under the existing temporary owner.
These settings are scoped to synthetic child processes; host Git settings
and this repository's commit/push checks are unchanged.

Targeted independent review: parent review APPROVE on patch
4be9a2af3e40edac3d64f687170e966a87fcf762f1877f2c55016e120bcd90ac and tree
a2ba91e. The reviewer confirmed the native
proof helper hash, complete fixture command coverage, and owned cleanup.
Review triggers: delegated follow-up and fixture file/process boundaries.

Validation: npm run check:fast passed; targeted Vitest 1 passed/3 native
Windows skips. On pinned Node 24.22.1, the actual helper rejects inherited
hooks/templates while commit, worktree creation, HEAD and status checks pass.
The unisolated control copies the injected template and its commit fails.

Refs morluto#7551
@WenyuChiou
WenyuChiou marked this pull request as ready for review October 28, 2026 01:12
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-28T01:12:30.879312Z
We couldn’t complete this review. Comment @codex review to try again.
95e78b6 Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

Copy link
Copy Markdown
Contributor Author

Hi @morluto, a brief consolidated follow-up to avoid separate pings: #7667, #7673 and #7978 address #7551, #7621 and #7440, which are still open. Their current-head CI runs passed, but this does not establish integration with today's main. #7978's description records the Markdown/redaction validation limits (including an incomplete full local check and no real-provider validation). Would you have time to review, or let me know whether these should be refreshed or superseded by another approach?

For the two related test PRs, current main already uses childNodes for #7967's production change, while its added characterization tests are not present; #7977 retains additional lipo/source-admission assertions after the upstream fixture fix. Are those remaining tests useful, or would you prefer either PR closed? #7973 is already closed as superseded. Thanks!

@morluto
morluto merged commit e01fcfb into morluto:main Nov 3, 2026
45 of 46 checks passed
@morluto morluto added the bug Something isn't working label Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Linked-worktree imports hash Git administration files into source identities

2 participants