Skip to content

formatter hooks: content-mutation disclosure protocol is maintained by convention in each plugin, not by a module (deepening candidate) #3409

Description

@kyle-sexton

Context

Six hooks (go-format, ruff-format, biome-format, bash-format, powershell-format, eol-normalizer) hand-write the same four-step protocol: snapshot to mktemp, cmp -s after the formatter runs, name the rewrite on the user channel, release the snapshot on every exit arm. The blocks are near-identical, differing only in variable prefix (_fmt_before, _go_before, _ps_before, _ruff_before, _biome_before, _eol_tmp).

Because the protocol lives in each plugin rather than behind one interface, the same defect recurs plugin by plugin. The rollout itself landed one plugin at a time (f5b8a3d bash, b3e9735 biome, 1b10069 powershell, 3c9351d eol-normalizer, b1b1c22 the rest), then #3401 (a7f9537) fixed powershell's leaked snapshot and undisclosed rewrite, while the identical leak sat unrepaired next door in go-format. Both remaining defect families were verified live on 2026-08-27 and are filed as #3405 (go-format snapshot leak on both error arms) and #3406 (ruff/biome/bash emitting two JSON documents on a rewrite-plus-findings run, against the single-document invariant documented at lib/hook-utils.sh:75-78).

Deletion test: concentrates. A future maintainer would rebuild this module substantially the same way; the protocol (snapshot lifetime, disclosure wording, single-document stdout composition) is exactly the knowledge that should live once. Two adapters exist naturally: the six production hooks and the test suite exercising every exit arm.

Proposed work

Acceptance criteria

References

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions