Repository navigation
Preserve concurrent Git exclude edits during start - #1685
Conversation
Architecture-Review: unchanged; start still installs the same repository-local Git ignore rules before adding a task checkout. Co-Authored-By: Codex <noreply@openai.com>
Architecture-Review: unchanged; start retains the same ignore entries and the landed Git directory guard. Co-Authored-By: Codex <noreply@openai.com>
Architecture-Review: unchanged; this resolves shared imports while retaining the landed cleanup and destination checks. Co-Authored-By: Codex <noreply@openai.com>
There was a problem hiding this comment.
loopzero primary review by claude on ced390ba03879265aec1dcdcc1e4dabd27f3330d, 38.2s: approve (0 critical, 0 important, 2 suggestion)
Settings per native call (launch configuration and CLI claims, not backend attestation):
- Call 1: requested model claude-opus-5-5 (effort medium); CLI-reported model claude-opus-5-5 (effort unknown); configured model claude-opus-5-5 (effort medium)
Native Claude output is retained in the restricted local review receipt.
| missing = [entry for entry in EXCLUDES if entry not in lines] | ||
| if missing: | ||
| # An editor can append an unterminated line before this write. | ||
| rules = b"\n" + b"\n".join(missing) + b"\n" |
There was a problem hiding this comment.
suggestion: Separator newline is added even when the file already ends with one
rules always starts with b"\n". Most exclude files end with a newline, including Git's default template, so start inserts an empty line before the generated rules, and does it again on every replace-retry pass. Git ignores blank lines in exclude files, so nothing breaks, but the file gets messier each time. The safe gap is narrow: an editor can only append between stream.read() and os.write, and that window is also why the prefix is unconditional. Smallest fix: keep the bytes from stream.read() as data and add the leading newline only when data is non-empty and does not end with b"\n". This leaves a small chance of a joined line if an unterminated append lands in that window. Or keep the current behaviour and say in the comment that the blank line is intentional.
| finally: | ||
| temp.unlink(missing_ok=True) | ||
| while True: | ||
| fd = os.open(exclude, os.O_RDWR | os.O_CREAT | os.O_APPEND | os.O_NOFOLLOW, 0o666) |
There was a problem hiding this comment.
suggestion: Replacing the exclude path with a symlink or directory during the loop raises a raw OSError
exclude is resolved and checked once, before the loop. If the path becomes a symlink before os.open runs, O_NOFOLLOW raises OSError(ELOOP); if it becomes a directory, os.open raises IsADirectoryError. Either way the caller gets a raw OSError instead of the WorktreeError the start command reports cleanly. Both are unlikely during a write, but wrapping os.open to turn ELOOP/EISDIR into WorktreeError("Git exclude is outside its Git directory") would keep error handling consistent with the containment check just above.
|
@Mergifyio queue |
✅ Merged into
|
|
No description provided. |
Preserve concurrent Git exclude edits during start
Context and goal
Closes #1544
Acceptance
Base
main @ ef5d13c
Base: ef5d13c
Notes
This draft supersedes #1612 and builds on the landed exclude destination and cleanup guards.
Validation
Recorded for
ced390ba0387uv run --group dev ruff check src tests: exit 0uv run --group dev tach check: exit 0uv run --python 3.14 python scripts/check_architecture_docs.py: exit 0scripts/size_budget.sh: exit 0uv run --group dev pytest -q: exit 0Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.Review