[GH-ISSUE #1609] [Bug] Reference source imports lose Git HEAD after regular-file read admission #544

Closed
opened 2026-10-15 18:26:02 +00:00 by bsakaguchi · 1 comment
Owner

Originally created by @N0zoM1z0 on GitHub (Oct 10, 2026).
Original GitHub issue: https://github.com/morluto/rea/issues/1609

rea import-reference-source imports a valid committed Git repository successfully but returns vcs: { kind: "unknown", head: null, dirty: null }. The observable commit identity is lost for ordinary repositories and linked worktrees.

Verified on Linux x64, Node 24.18.0/npm 11.16.0, at runtime e00c2bf123b6e006c753895fb084cd6f287a8b11, which integrates main 603d04ee. The affected ReferenceSourceVcsAdapter.ts and ReferenceSourceImport.ts are identical to that main revision; the separate allocation work in #1601 does not change them.

Reproduce with a temporary repository containing one committed index.js, then run:

git -C "$fixture" rev-parse HEAD
node scripts/rea.mjs import-reference-source "$fixture" --json

Observed through the actual public CLI:

  • Git reports HEAD f1eb01a5c30cc0ff7d9e68def4eca121fff57891.
  • REA exits 0 with empty stderr but reports {"kind":"unknown","head":null,"dirty":null}.
  • The source SHA256 and Git HEAD remain unchanged.

Expected: {"kind":"git","head":"<the observed commit>","dirty":null}. Dirty-state coverage remains unknown; the readable HEAD should be retained.

The existing compiled production-boundary tests also reproduce the regression:

npm run test:focused -- tests/boundary/filesystem/referenceSourceVcs.test.ts tests/boundary/filesystem/referenceSourceImport.test.ts

Failures are the ordinary committed-repository import and linked-worktree HEAD cases. CI records the same failures in test shard 2 and test shard 4.

The representation mismatch is in resolveSourceHead: its fs.promises.readFile adapter calls readRegularFile(path, { signal }) and always returns a Buffer, ignoring the producer's encoding option. The installed isomorphic-git requests { encoding: "utf8" }; GitRefManager.resolve calls sha.trim(), which requires the returned text. The exception is then converted to unknown VCS state. Adjacent encoded reads, including packed refs and Git-directory pointers, should be checked while preserving the new verified regular-file admission and unreadable-loose-ref handling.

This report establishes the Linux CLI and application-boundary regression. It does not claim a new MCP operation or independent Windows/macOS reproduction. Refs #1065.

Originally created by @N0zoM1z0 on GitHub (Oct 10, 2026). Original GitHub issue: https://github.com/morluto/rea/issues/1609 `rea import-reference-source` imports a valid committed Git repository successfully but returns `vcs: { kind: "unknown", head: null, dirty: null }`. The observable commit identity is lost for ordinary repositories and linked worktrees. Verified on Linux x64, Node 24.18.0/npm 11.16.0, at runtime `e00c2bf123b6e006c753895fb084cd6f287a8b11`, which integrates main `603d04ee`. The affected `ReferenceSourceVcsAdapter.ts` and `ReferenceSourceImport.ts` are identical to that main revision; the separate allocation work in #1601 does not change them. Reproduce with a temporary repository containing one committed `index.js`, then run: ```sh git -C "$fixture" rev-parse HEAD node scripts/rea.mjs import-reference-source "$fixture" --json ``` Observed through the actual public CLI: - Git reports HEAD `f1eb01a5c30cc0ff7d9e68def4eca121fff57891`. - REA exits 0 with empty stderr but reports `{"kind":"unknown","head":null,"dirty":null}`. - The source SHA256 and Git HEAD remain unchanged. Expected: `{"kind":"git","head":"<the observed commit>","dirty":null}`. Dirty-state coverage remains unknown; the readable HEAD should be retained. The existing compiled production-boundary tests also reproduce the regression: ```sh npm run test:focused -- tests/boundary/filesystem/referenceSourceVcs.test.ts tests/boundary/filesystem/referenceSourceImport.test.ts ``` Failures are the ordinary committed-repository import and linked-worktree HEAD cases. CI records the same failures in [test shard 2](https://github.com/morluto/rea/actions/runs/38067916902/job/114259399436) and [test shard 4](https://github.com/morluto/rea/actions/runs/38067916902/job/114259399410). The representation mismatch is in `resolveSourceHead`: its `fs.promises.readFile` adapter calls `readRegularFile(path, { signal })` and always returns a Buffer, ignoring the producer's encoding option. The installed isomorphic-git requests `{ encoding: "utf8" }`; `GitRefManager.resolve` calls `sha.trim()`, which requires the returned text. The exception is then converted to unknown VCS state. Adjacent encoded reads, including packed refs and Git-directory pointers, should be checked while preserving the new verified regular-file admission and unreadable-loose-ref handling. This report establishes the Linux CLI and application-boundary regression. It does not claim a new MCP operation or independent Windows/macOS reproduction. Refs #1065.
Author
Owner

@N0zoM1z0 commented on GitHub (Oct 10, 2026):

Verified the fix already integrated in main 11e3fae6 using runtime fc8bfda6035fbf26151fa4b81d595ec9ce4f5608.

The same committed fixture now succeeds through the public import-reference-source --json CLI with {"kind":"git","head":"f1eb01a5c30cc0ff7d9e68def4eca121fff57891","dirty":null}. Exit code is 0, stderr is empty, and both source SHA256 and Git HEAD remain unchanged.

The relevant Git/worktree, source-import, JSON and adjacent JavaScript cases pass together: 36 tests across five files. Main's fix honors the requested encoding and also keeps isomorphic-git's argument-free promise-API probe from poisoning the recorded source-read failure. The real resource-constraint JSON case and unreadable-reference behavior remain covered.

Closing as fixed on main. This is independent verification of the existing main repair, not a new implementation or a Windows/macOS runtime claim.

<!-- gh-comment-id:6100020512 --> @N0zoM1z0 commented on GitHub (Oct 10, 2026): Verified the fix already integrated in main `11e3fae6` using runtime `fc8bfda6035fbf26151fa4b81d595ec9ce4f5608`. The same committed fixture now succeeds through the public `import-reference-source --json` CLI with `{"kind":"git","head":"f1eb01a5c30cc0ff7d9e68def4eca121fff57891","dirty":null}`. Exit code is 0, stderr is empty, and both source SHA256 and Git HEAD remain unchanged. The relevant Git/worktree, source-import, JSON and adjacent JavaScript cases pass together: 36 tests across five files. Main's fix honors the requested encoding and also keeps isomorphic-git's argument-free promise-API probe from poisoning the recorded source-read failure. The real resource-constraint JSON case and unreadable-reference behavior remain covered. Closing as fixed on main. This is independent verification of the existing main repair, not a new implementation or a Windows/macOS runtime claim.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#544
No description provided.