Skip to content

Rename the drain to autofix - #60

Merged
kristofferR merged 2 commits into
mainfrom
rename-drain-to-autofix
Jul 27, 2026
Merged

Rename the drain to autofix#60
kristofferR merged 2 commits into
mainfrom
rename-drain-to-autofix

Conversation

@kristofferR

Copy link
Copy Markdown
Owner

drain was carrying three unrelated jobs at once — the installer, the per-repository permission to write code, and the fix-before-review invariant — while the same word, correctly, also meant "consume the shared REST quota" on adjacent lines of the same docs. Nothing else in the chain was ever called anything but fix: the action is fix, the report says fix, the session is a fix session.

The feature is now autofix, which pairs with autoreview: one keeps open pull requests reviewed, the other keeps them fixed.

crq drain install              ->  crq autofix install
crq drain [on|off|default]     ->  crq autofix [on|off|default]

This is a hard break

No compatibility path, by design. The persisted keys move with the name:

before after
drain autofix
drains autofix_by_host
repo_drain repo_autofix

A pre-rename binary sharing the state ref therefore sees no autofix switches and no dispatch health, and vice versa — every host has to be upgraded together. Unknown-member round-tripping means neither side erases the other's keys, so this degrades to "does not see", not "destroys".

The installed artifacts move too: crq-autofix, crq-autofix.service, no.kristofferr.crq-autofix, autofix.log / autofix.err. An existing crq-drain install must be disabled and removed before crq autofix install, or two watchers run side by side.

Everything else

The invariant is fix-first now, and findings are cleared rather than drained. drain survives only where it means draining a resource or a stream — the REST quota, a child's stdout, git's credential-helper lines.

Also fixes the crq help layout bug where "install and start unattended autofix" was printed under the on|off|default line instead of the install line it describes.

Three fixes the preflight surfaced

All predate this diff, all in the files it renames:

  • The install plan took its repository list straight off a map, so a re-install rewrote the unit with the repositories in a new order, and --dry-run described a different service than the install that followed it. Reproduced on this host before the fix. Now uses the existing sortedRepoList, with a test.
  • Environment= assignments were not percent-escaped. systemd expands specifiers in Environment= values, so a % in a path or a review command was eaten or failed to load the unit. $ is deliberately left alone — unlike ExecStart, it is literal there.
  • The repository key trimmed .git before lowercasing, so a .GIT suffix survived into the key and matched nothing.

The eight remaining preflight findings are skipped: two ask to move dispatch CAS writes out of watch.go into the service apply layer (an architectural change, not a rename), and the rest are pre-existing test-strengthening and doc-wording notes unrelated to this diff.

Verification

gofmt, go build, go vet, go test ./... clean. Swapped live on cachyos: old crq-drain.service disabled and removed, crq-autofix.service active and enabled, crq autofix listing correct. crq drain now exits unknown command: drain.

"Drain" was doing three unrelated jobs — the installer, the per-repository
permission to write code, and the fix-before-review invariant — while the
same word, correctly, also meant "consume the shared REST quota" on adjacent
lines. Nothing in the chain but the name was ever called anything other than
fix: the action is `fix`, the report says `fix`, the session is a fix session.

The feature is now autofix, which pairs with autoreview: one keeps open pull
requests reviewed, the other keeps them fixed.

  crq drain install        ->  crq autofix install
  crq drain [on|off|default]   crq autofix [on|off|default]

A hard break, with no compatibility path. The persisted keys move with it —
drain -> autofix, drains -> autofix_by_host, repo_drain -> repo_autofix — so
a pre-rename binary sharing the state ref sees no autofix switches and no
dispatch health. Every host has to be upgraded together. The installed
artifacts move too: crq-autofix, crq-autofix.service,
no.kristofferr.crq-autofix, autofix.log/autofix.err.

The invariant is fix-first now, and findings are cleared rather than drained.
"Drain" survives only where it means draining a resource or a stream: the REST
quota, a child's stdout, git's credential-helper lines.

Three fixes the preflight surfaced in the files this touches:

- the install plan took its repository list straight off a map, so a re-install
  rewrote the unit in a new order and --dry-run described a different service
  than the install that followed it;
- Environment= assignments were not percent-escaped, and systemd expands
  specifiers there, so a '%' in a path or a review command was eaten;
- the repository key trimmed ".git" before lowercasing, so a ".GIT" suffix
  survived into the key and matched nothing.
@kristofferR

Copy link
Copy Markdown
Owner Author

@codex review

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 4eaa104b-2178-4c26-9fbe-957c1818c928

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch rename-drain-to-autofix

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3300dfb3e9

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/state/state.go
Comment thread internal/state/state.go
Comment thread internal/crq/autofix.go
The rename is a hard break in the state and the CLI, but a break in naming
stops nothing that is already running. A host that ran `crq drain install`
keeps an enabled crq-drain unit, and `crq autofix install` only enabled and
restarted crq-autofix beside it: two watchers then scan the same fleet, each
starting sessions and racing the other's dispatch claims.

The install now stops the old one first — `systemctl --user disable --now`,
or launchd's disable plus bootout, since bootout alone comes back at the next
login. It is detected from the unit still being on disk rather than attempted
blindly, so a first install runs no pointless command and needs no failure
text to know it was benign, and --dry-run names what it will retire.
@kristofferR
kristofferR merged commit 4d17703 into main Jul 27, 2026
2 checks passed
@kristofferR
kristofferR deleted the rename-drain-to-autofix branch July 27, 2026 18:56
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.

1 participant