Skip to content

Clarify recovery hints and file-operation diagnostics - #4346

Merged
max-sixty merged 18 commits into
mainfrom
codex/recovery-hints
Oct 21, 2026
Merged

max-sixty merged 18 commits into
mainfrom
codex/recovery-hints

Conversation

@max-sixty

@max-sixty max-sixty commented Oct 2, 2026 •

Copy link
Copy Markdown
Owner

GitHub PR-not-found errors keep the selected repository and its source in the diagnosis, preserve the CLI error, and render gh repo set-default as a separate recovery hint. Relocation warnings identify the blocking path and explain that --clobber backs it up; config migration hints name the command that applies the updates.

Copy and promote failures use the shared path formatter and retain their underlying I/O errors. Failed copies name both source and destination, including when the source is readable and the destination is invalid. Promote recovery commands use shell-quoted paths.

Validation: the required local pre-merge gate passes 5,392 tests (one skipped), Clippy, formatting, locked dependencies, documentation and doctests. Focused error-path tests check quoted paths, destination context and retained I/O causes; command snapshots cover the recovery hints. Independent review found no remaining issues.

Remote patch coverage is 90.06% (136/151 lines) against a 98.55% gate. The 15 misses are existing filesystem-failure paths whose diagnostic formatting changed; exercising most would require races, fault injection or special permission/ownership fixtures. The maintainer approved landing with this coverage gap and the independent subagent review after the automated review job completed without posting a verdict. Linux, macOS and Windows CI, including all advisory affected-tests jobs, passed.

This was written by Codex on behalf of max-sixty

@worktrunk-bot worktrunk-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new GitHub 404 hint doesn't follow the project's pattern for hints that suggest a command. See the inline suggestion.

Comment thread src/git/remote_ref/github.rs Resolved

@worktrunk-bot worktrunk-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

codecov/patch fails at this head: 87.25% of the diff is hit, against a 98.39% target. The new test covers the metadata, create-directory, copy, and create-symlink arms. All of the remaining misses are in src/copy.rs, on error arms this PR rewrote to call format_path_for_display, where rustfmt split each .context(...) over several lines:

  • reading symlink {} in copy_leaf, which needs read_link to fail with something other than NotFound right after a successful stat
  • reading metadata for {} on entry.file_type() in copy_dir_recursive
  • reading permissions for {} and setting permissions on {} in the phase-3 permissions loop

None of these is reachable through an ordinary filesystem setup, so they aren't gaps that more tests would close. Under the Coverage section of AGENTS.md, a failing codecov/patch still needs explicit maintainer approval before merge. That decision is what remains here.

@max-sixty max-sixty closed this Oct 2, 2026
@max-sixty
max-sixty deleted the codex/recovery-hints branch October 2, 2026 18:40
@max-sixty
max-sixty restored the codex/recovery-hints branch October 11, 2026 01:07
@max-sixty max-sixty reopened this Oct 11, 2026
Foreground cancellation intentionally reaches every active scope in one process. A signal-producing run_custom unit test could therefore cancel the parallel missing-binary unit test under cargo test. Move raw custom-child SIGTERM coverage to the existing CLI PTY matrix, where each invocation owns its cancellation state, and retain the spawn-failure trace test.
@max-sixty max-sixty changed the title Clarify recovery hints and displayed paths Clarify recovery hints and safely publish ignored files Oct 11, 2026

@worktrunk-bot worktrunk-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Holding this for a maintainer decision rather than approving, because the diff widens what --force can overwrite. On main, Windows' forced copy_leaf called remove_if_exists, whose fs::remove_file fails on a read-only destination, so the existing file was kept and the copy errored. Now publish_leaf in src/copy/windows.rs handles that PermissionDenied with replace_readonly (FILE_RENAME_IGNORE_READONLY_ATTRIBUTE), so wt step copy-ignored --force replaces read-only ignored files on Windows. That matches Unix, where rename ignores the file's mode, and the documented "--force overwrites them". It is still a deletion the read-only attribute used to block, and the running-tend review reference holds that kind of change for a human. I found no correctness defects in the staging or publication paths.

Cover blocked destinations and denied source cleanup with real filesystem regressions. Require reflink-copy 0.1.30 to keep mode preservation in its owning dependency. Share directory-write applicability probes and strengthen adjacent assertions for privileged runners.
@max-sixty

Copy link
Copy Markdown
Owner Author

@worktrunk-bot Please review final head c859a3c. It integrates main's isolated signal unit test, retains the raw TERM subprocess regression, exercises real copy/promote publication and cleanup failures, and gives permission preservation to reflink-copy 0.1.30. Permission-denial tests now share the actual write-applicability probe and strengthened assertions.

The complete local canonical run passed 5,277 tests; its single stderr-owner guard failure is repaired and included in 262 passing final targeted tests. Final pre-commit, Clippy, formatting, lockfile, documentation and doctest checks pass. Independent final-delta review approves the code. The PR description records the exact composed validation basis. Maintainer decision remains pending for the Windows read-only --force behavior.

This was written by Codex on behalf of max-sixty

@worktrunk-bot worktrunk-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing new to flag at c859a3c. The only thing still holding this PR is the Windows read-only --force behavior from my previous review, which needs a maintainer decision.

max-sixty pushed a commit that referenced this pull request Oct 11, 2026
…RM (#4434)

reflink-copy 0.1.30's `reflink_or_copy` passes `PermissionDenied` from
the clone attempt straight through instead of falling back to `fs::copy`
(it does the same for `NotFound` and `AlreadyExists`). On the reporter's
kernel `FICLONE` returns `EPERM` rather than `EOPNOTSUPP`, so `wt step
copy-ignored` failed with "Operation not permitted" on a file that `cp
--reflink=auto` copies without trouble.

`copy_leaf` now goes through a small wrapper that retries with a byte
copy when the reflink attempt returns `PermissionDenied`. The file is
then reported as written in full rather than reflinked. A real
permission problem on the source or destination fails the retry with the
same error, so it is still reported. The crate's `AutoRemovedFile`
deletes the destination it created before returning the error, so the
retry doesn't call `fs::copy`, which could overwrite a file another
process puts there in that gap. It copies into a temp file beside the
destination, gives it the source's mode, and moves it into place with a
no-clobber rename (`persist_noclobber`, as `utils::write_new_atomically`
does). The destination only ever appears complete. If something already
occupies it, the retry fails with `AlreadyExists`, which `copy_leaf`
already skips. A failed copy removes only its own temp file, and if that
removal fails the error says so.

No CI filesystem rejects `FICLONE` with `EPERM`, so the regression test
`test_reflink_rejected_with_eperm_falls_back_to_copy` covers the retry
decision with synthetic errors: `PermissionDenied` falls back, a failing
retry still errors, and success and `AlreadyExists` pass through without
a retry.
`test_rejected_reflink_fallback_does_not_overwrite_racing_destination`
creates a file at the destination between the rejected reflink and the
retry, and checks that the file survives.
`test_failed_copy_cleanup_leaves_racing_destination` checks that a
failed copy leaves a file at the destination alone and leaves no temp
file. `test_discard_temp_reports_cleanup_failure` checks that a failed
temp-file removal is reported.
`test_copy_to_new_file_copies_contents_and_mode` checks the contents and
mode. The full path was not run on an EPERM-rejecting filesystem.

#4346 also edits this call site in `src/copy.rs` and keeps the bare
`reflink_copy::reflink_or_copy`. Whichever lands second should route its
call through the wrapper.

Closes #4433 — automated triage

---------

Co-authored-by: worktrunk-bot <[email protected]>
Co-authored-by: Claude <[email protected]>
@max-sixty

Copy link
Copy Markdown
Owner Author

@worktrunk-bot Please refresh this PR branch against current main and resolve its mechanical merge conflicts so it can get current CI. Preserve the proposed behavior and the current draft state, run the focused checks for the resulting diff, and report any conflict that requires a semantic or product decision.

This requests branch maintenance; the outstanding maintainer review remains pending.

This was written by Codex on behalf of max-sixty

worktrunk-bot and others added 3 commits October 14, 2026 14:23
Route the staged leaf copy through main's EPERM reflink fallback (#4434)
and keep both Windows-only dependencies (windows-sys, dirs).
Prepare copied leaves in their final parent. Use owned Linux FICLONE and
macOS atomic clonefile, and let Windows' ordinary copy API own metadata and
native acceleration. Preserve atomic forced replacement and no-clobber
creation, with an exclusive-create fallback when the filesystem cannot
publish by exclusive rename.

Exercise direct-child Windows inheritance, directory-symlink publication,
partial-file cleanup and actual Unix ENOTSUP. Keep ordinary-copy summaries
accurate when filesystem acceleration is opaque.
@worktrunk-bot

Copy link
Copy Markdown
Collaborator

I merged current main into the branch as 461cbf2. Your follow-up e21f097 builds on that commit, so the branch now has both.

Two files conflicted:

At 461cbf2, cargo build --locked, cargo fmt --check and cargo clippy --all-targets were clean, and the copy unit tests and copy/promote integration tests passed in the bot sandbox except two. Both of those fail the same way at the old head c859a3c:

  • test_copy_dir_recursive_does_not_count_a_non_regular_file and test_copy_ignored_skips_non_regular_files both bind a Unix socket, which the sandbox blocks.
  • test_copy_ignored_preserves_file_executable_permissions got 0664 instead of 0644 for a non-executable file. The subject of your 76ae926 ("preserve normal copied-file permissions") suggests it targets the same thing.

CI never finished on 461cbf2: your push cancelled test (macos) and feature-powerset, and codecov/patch reported a failure. The current CI run is on e21f097.

@worktrunk-bot worktrunk-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copied_leaf_inherits_from_final_parent, the Windows test added in the merge commit 76ae926, fails in CI at this head. In affected tests (windows, advisory), SetSecurityInfo in direct_child_permissions returns 5 (ERROR_ACCESS_DENIED), failing the assertion at src\copy\windows.rs:221. The required full-tests (windows-2025, windows) job runs the same test and was still pending when I reviewed, so expect it to fail the same way. The log can't tell whether the denial came from the call on the parent directory or the later one on the forced destination. One thing to check: both calls open their handle with only WRITE_DAC. I haven't confirmed whether SetSecurityInfo also needs READ_CONTROL to apply a protected DACL to a file object.

A smaller point is inline: a doc comment sits on the wrong test.

Comment thread src/copy/windows.rs Resolved
Comment thread src/copy/windows.rs Resolved
Let SetNamedSecurityInfoW acquire the filesystem security handle instead
of choosing its access mask in the fixture. Preserve the protected ACL
and inheritance comparisons, report the path and returned error, and
attach the inheritance documentation to the correct test.

Cover unsupported publication of dangling symlinks and owned staging
cleanup, and distinguish permission-probe fixture errors from writable
fixtures. Production copy behavior is unchanged.
@max-sixty

Copy link
Copy Markdown
Owner Author

make any fixes pls @worktrunk-bot

@worktrunk-bot

Copy link
Copy Markdown
Collaborator

I found nothing to fix at f765a6e, so I haven't pushed. Every CI check passes except codecov/patch, every review thread is resolved, and the branch merges cleanly with current main (7 commits behind).

codecov/patch is at 95.84%: 24 of 577 patch lines are missed, against a 98.50% target. None of the misses can be reached on the CI runners:

  • src/copy.rs, 20 lines:
    • The Linux FICLONE success arm (L109-110). ext4 rejects the clone, so CI only takes the fallback.
    • The PublishedLeaf::Created fallback for filesystems without exclusive rename (L336-340).
    • A source that disappears between stat and copy (L267).
    • Error-context arms whose format_path_for_display call rustfmt split across lines (L578-581, L640-651).
    • An unreachable panic! arm in a test (L926).
  • Test skip branches, 4 lines: picker/summary.rs L210-211 and step/promote.rs L557-558 only run when permissions don't restrict writes, as under root.

Covering these would mean adding test seams to the copy code, which AGENTS.md says not to do just to raise the percentage. Two things still need a maintainer: the coverage exception and the Windows read-only --force behavior.

In the bot sandbox, test_copy_ignored_preserves_file_executable_permissions fails with 0664 vs 0644. The cause is the sandbox's umask of 002. The source file is created as 0664, and wt preserves that mode correctly. The test hard-codes 0644 and has the same assertion on main, so this PR doesn't cause it.

@max-sixty max-sixty changed the title Clarify recovery hints and safely publish ignored files Clarify recovery hints and file-operation diagnostics Oct 21, 2026
@max-sixty
max-sixty merged commit b3d6fd2 into main Oct 21, 2026
36 of 37 checks passed
@max-sixty
max-sixty deleted the codex/recovery-hints branch October 21, 2026 17:32
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.

2 participants