Skip to content

Latest commit

 

History

History
73 lines (56 loc) · 2.35 KB

examples.md

File metadata and controls

73 lines (56 loc) · 2.35 KB

Example: ratchet on pallets/click

Real commands, real output, on a fresh clone of pallets/click at commit 2247b35ea1c47c727d7a06e51fa280e12a863ff6 (2026-10-04). This is what docs/demo.gif shows; regenerate both with demo.sh.

Honesty note: the "agent bloats the code" step below is a scripted patch (agent_change.patch), not a live agent run. It stands in for a real agent asked to add a feature who pastes a near-duplicate of existing code instead of reusing it -- the exact shape of change ratchet is built to catch. Everything else (ratchet init, ratchet check, the numbers) is the real tool running against the real repo.

1. ratchet init records today's size

$ ratchet init
wrote .ratchet.json
  source   ceiling 11,430 lines
  tests    ceiling 13,385 lines
  per-file limit 400 lines, 21 file(s) already over it recorded at their size
next: commit .ratchet.json, then run `ratchet check` before every commit

.ratchet.json now holds those ceilings, plus a file_ceilings entry for every file already over 400 lines (src/click/core.py, src/click/types.py, and 19 others) -- frozen at their current size, so day one isn't a wall of refusals.

2. An agent duplicates instead of reusing

The feature ask: print a two-column option-like list outside of HelpFormatter. click.formatting already has exactly this in HelpFormatter.write_dl, but the simulated change pastes a new freestanding implementation instead -- twice, with a second near-identical variant "for wider spacing". Applying it:

$ git apply agent_change.patch

3. ratchet check refuses it

$ ratchet check
ratchet: refused -- source grew 72 lines past its limit (11,502 / 11,430)

  src/click/formatting.py  +72

Fix it one of two ways:
  1. remove 72 lines of code (dead code, duplicates), or
  2. allow the growth (humans only -- agents must ask, never run this):
     ratchet grant +72 --group source --reason "why"
exit code: 1

4. The fix: delete the duplicate

The real fix is to call HelpFormatter.write_dl like the rest of the codebase does. For the demo, reverting the file gets to the same place:

$ git checkout -- src/click/formatting.py

5. ratchet check passes again

$ ratchet check
ratchet: ok -- source 11,430/11,430, tests 13,385/13,385
exit code: 0