Skip to content

ci: judge rewritten files with zsh, not only our parser - #1452

Merged
afadesigns merged 1 commit into
mainfrom
ci/fix-sweep-zsh-oracle
Aug 26, 2026
Merged

ci: judge rewritten files with zsh, not only our parser#1452
afadesigns merged 1 commit into
mainfrom
ci/fix-sweep-zsh-oracle

Conversation

@afadesigns

Copy link
Copy Markdown
Owner

The hole

The autofix gate measured corruption as an increase in this linter's own parser-error count. Our parser is more permissive than zsh — it accepts a dangling >, a stray ]], an unterminated block — so a fix producing any of those scored zero errors and passed. The corrupted output was also idempotent, so the convergence invariant stayed quiet as well.

That is how four separate corrupting autofixes reached the corpus while the gate reported corruptions=0 on every run.

The check

A file zsh accepted before the rewrite must still be accepted after it.

Two traps it accounts for:

  • zsh -n exits 0 while still printing some diagnostics. zinit/share/rpm2cpio.zsh prints "redirection with no command" and returns 0. The check reads stderr, not the exit status.
  • $(<file) makes zsh -n open the file, reporting a missing input. That is not a syntax error, so the message is ignored — otherwise the legitimate $(cat f)$(<f) rewrite would look like damage.

Where zsh is absent the check is skipped with a warning rather than failing, so the sweep still runs off CI and on other platforms. The job that runs it is ubuntu-only, where zsh is present; the summary line now ends with zsh=zsh or zsh=none so a silent degradation is visible.

Proof it works

Same script, two binaries:

current main:                 files=402 corruptions=0 ... zsh=zsh
binary from before the fixes: files=402 corruptions=9 ... zsh=zsh

The nine are the files this work repaired — fzf/completion.zsh, prezto/gpg/init.zsh, spaceship ×3, zgen, zinit-autoload, zsh-utils/editor, zsh-vimode-visual — each reported with its line and zsh's own reason, for example:

+ zgen/zgen.zsh [unsafe]: zsh rejects the rewrite at line 316: parse error near `}'

Before this change that same run reported corruptions=0.

Severity: Error — the gate that was supposed to catch destructive fixes could not see them.

The autofix gate measured corruption as an increase in this linter own
parser-error count. Our parser is more permissive than zsh: it accepts a
dangling `>`, a stray `]]`, and an unterminated block, so a fix that
produced any of those scored zero errors and passed. Corrupted output was
also idempotent, so the convergence invariant stayed quiet too.

The gate now also asks zsh. A file zsh accepted before the rewrite must
still be accepted after it.

Two traps the check accounts for. `zsh -n` exits 0 while still printing
some diagnostics, so it reads stderr rather than the exit status. And
`$(<file)` makes `zsh -n` open the file, reporting a missing input that is
not a syntax error, so that message is ignored.

Where zsh is absent the check is skipped with a warning rather than
failing, so the sweep still runs off CI. The job that runs it is
ubuntu-only, where zsh is preinstalled.

Against the binary from before the recent fixer repairs the gate now
reports 9 corrupted files; it reported none.

Signed-off-by: afadesigns <afadesign.official@gmail.com>

@redteamx redteamx 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.

Approved on review.

@redteamx redteamx 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.

Approved on review.

@redteamx redteamx 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.

Approved on review.

@afadesigns
afadesigns merged commit 2c2dce1 into main Aug 26, 2026
19 checks passed
@afadesigns
afadesigns deleted the ci/fix-sweep-zsh-oracle branch August 26, 2026 05:11
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