Skip to content

Keep each file's mode in every tree CoderHelm writes - #959

Merged
coderhelm[bot] merged 4 commits into
mainfrom
fix/keep-file-modes
Dec 3, 2026
Merged

coderhelm[bot] merged 4 commits into
mainfrom
fix/keep-file-modes

Conversation

@nambok

@nambok nambok commented Dec 3, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Every tree CoderHelm wrote through GitHub's API named each written file a plain file. A conflicted merge of the base, a round's batch write and the merge commit's taken files turned executable scripts into plain files, and could turn a symbolic link or a submodule into a text file. Every tree write now keeps each path's mode. A sweep puts back the modes that earlier commits dropped on open pull requests.

Changes

  • clients::git_mode is the one place that holds mode values.
    • A written path keeps its mode in the tree it is based on.
    • A new path takes its source's mode, and only a new path with no source is a plain file.
    • Text over a symbolic link or a submodule is refused.
    • A path both sides of a merge changed takes its mode as git merges it.
  • batch_write reads the modes of the tip each attempt builds on.
  • write_file sends an executable through a tree, since the contents API names no mode.
  • A codegen build's archive marks the files it left executable. Captured and CodegenOutcome carry those paths, and every commit of a build's output passes them through git_mode::archive_sources, so a new generated script is committed executable.
  • put_tree refuses an entry with no known mode, and GitEntry::from_json no longer fills one in.
  • Merging the base into a pull request uses GitHub's merges API, which keeps modes. When it conflicts, pr::resolve_conflicts now lays whole entries from the base over the branch (merge_plan) instead of re-writing their text as plain files. Merged files take the merged mode, and a link is never merged as text. restack::resolve merges modes the same way.
  • A commit that still changes a mode names each change in three places:
    • its message;
    • the tool call's outcome in the run log (tool_outcome::remark);
    • the worker log.
  • mode_repair, on the pull request watch sweep, reads each open pull request's CoderHelm commits of the last 30 days.
    • It runs once per pull request, claimed on the run and capped per team, per sweep and by the sweep's GitHub budget.
    • It puts back dropped executable bits and unchanged links in one commit, "Restore file modes CoderHelm dropped", moved only as a fast forward.
    • A path a person touched since, a link whose text changed, or a submodule is listed on the run page and in an internal alert instead.
  • Incident case xl_file_modes_kept.

Verification

  • cargo fmt --all --check, rustfmt --check on the incident files, and clippy with -D warnings all pass.
  • cargo test -p common -p worker -p gateway passes.
  • The new case replays these on an invented repository:
    • a pull request with an executable scripts/deploy.sh and a symbolic link, where merging the base keeps both;
    • a fix round editing the script, which stays executable;
    • a new file taken from an executable on the base, which stays executable;
    • a new file a codegen build's archive marks executable, committed executable;
    • the repair restoring both modes and finding nothing to do on a second look, and leaving what is in doubt;
    • a source scan that fails on a mode typed outside the helper.

Every tree CoderHelm wrote through GitHub's API named each written file a
plain file. A conflicted merge of the base, a round's batch write and the
merge commit's taken files turned executable scripts into plain files, and
could turn a symbolic link or a submodule into a text file.

- One helper (clients::git_mode) holds the mode values. A written path keeps
  its mode in the tree it is based on; a new path takes its source's mode;
  only a new path with no source is a plain file. Text over a symbolic link
  or a submodule is refused.
- batch_write reads the modes of the tip each attempt builds on.
  write_file sends an executable through a tree. put_tree refuses an entry
  with no known mode, and the tree reader no longer fills one in.
- A conflicted merge of the base lays whole entries from the base over the
  branch (merge_plan), and a path both sides changed takes its mode as git
  merges it. The file-by-file rebuild does the same.
- A commit that changes a mode names it in its message, in the tool call's
  outcome in the run log, and in the worker log.
- The pull request watch sweep reads each open pull request's CoderHelm
  commits of the last 30 days once. It puts back the executable bits and
  links they dropped in one fast-forward commit, "Restore file modes
  CoderHelm dropped". What is in doubt goes on the run page and into an
  internal alert.
- Incident case xl_file_modes_kept, with a scan that fails on a mode typed
  outside the helper.
@nambok nambok added the ch-review CoderHelm reviews this pull request label Dec 3, 2026
coderhelm[bot]

This comment was marked as outdated.

A codegen build's archive marks the files it left executable. Captured and
CodegenOutcome now carry those paths, and the commits of a build's output
(the codegen tool, a generator's regeneration and the lockfile repair) pass
them as sources through git_mode::archive_sources. A new file the build left
executable is committed 100755, and a path already on the branch keeps the
branch's mode.
coderhelm[bot]

This comment was marked as outdated.

@coderhelm
coderhelm Bot dismissed their stale review December 3, 2026 21:52

Superseded by CoderHelm's latest review

@coderhelm

coderhelm Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

💚 Post-merge health check passed: the deploy of 043d9da completed and stayed green for the full 15-minute watch window (no new failures vs. the pre-merge baseline).
Auto-merge

  • ✅ CoderHelm approved
  • ✅ CI green
    The rest is in the pull request description.

coderhelm[bot]

This comment was marked as outdated.

coderhelm[bot]

This comment was marked as outdated.

coderhelm[bot]

This comment was marked as outdated.

@coderhelm coderhelm Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Approved with notes f14e965 (merged)

/// version, inside the sweep's budget, and moves the branch only as a fast
/// forward from the head it read.
#[test]
fn the_repair_is_claimed_capped_and_never_forced() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🛑 Blocking (correctness): Near-identical helpers added together (scope)

services/worker/src/passes/incidents/xl_file_modes_kept.rs adds the_repair_is_claimed_capped_and_never_forced next to every_writer_reads_the_mode_it_writes, added in the same change. Keep one helper with the shared logic (a parameter for what differs) and call it from both places. If the ticket truly needs it, say why on a line Wider than the ticket: services/worker/src/passes/incidents/xl_file_modes_kept.rs: <why>.

/// A commit CoderHelm made: its GitHub author is a bot (an app's
/// `name[bot]`), or, with no linked account, its author email is a bot's
/// noreply address.
/// A commit that changed file modes says so in the run's log: the tool call

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💬 Nit: New function sits between is_bot_commit and its doc comment (convention)

Lines 820-822 are the doc comment for is_bot_commit. note_mode_changes now sits between them and the function, so rustdoc joins that comment onto note_mode_changes and is_bot_commit loses its doc. Behaviour is unaffected. Moving note_mode_changes above line 820 fixes both docs.

@coderhelm
coderhelm Bot merged commit 043d9da into main Dec 3, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ch-review CoderHelm reviews this pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant