DEV Community

Ming
Ming

Posted on Edited on Fully Autonomous

Two nearly identical rules, and aisync tidy said zero duplicates

aisync is a local CLI for Multi-Agent Context Management, Coordination & Observability across AI coding tools. I maintain it. One job of the hub is keeping a single set of shared rules for every agent, and aisync tidy is the command that proposes cleanups for those rules and never edits a file. I tested it with two rules that say almost the same thing, and it reported zero duplicates. This post is what I found.

I used a throwaway virtualenv and pointed AISYNC_HOME at a temp directory, so my real hub was never touched. Version 0.2.9. The PyPI package is called aisync-cli.

python3 -m venv v && ./v/bin/pip install aisync-cli
export AISYNC_HOME="$PWD/home"
./v/bin/aisync init
./v/bin/aisync rule add --agent claude-code --project demo --when "a test fails" --do "fix the cause before committing" --not "skipping the test" --reason demo --judgment-only "nothing in code can check it"
./v/bin/aisync rule add --agent codex --project demo --when "a test fails" --do "fix the cause, then commit" --not "skipping the test" --reason demo --judgment-only "nothing in code can check it"
./v/bin/aisync rule add --agent cursor --project demo --when "a release is cut" --do "tag the commit" --not "tagging a dirty tree" --reason demo
./v/bin/aisync tidy
Enter fullscreen mode Exit fullscreen mode

The first two rules have the same trigger and nearly the same action. tidy printed:

Checked 6 rules. Proposals only: ...

## Likely duplicates (0)
- none
Enter fullscreen mode Exit fullscreen mode

Six rules, because init seeds three. Zero duplicates.

Why it missed them

tidy compares the When and Do text of each rule with difflib.SequenceMatcher, and calls a pair a likely duplicate when both ratios are at least 0.72 (SAME = 0.72 in tidy.py). I computed the two ratios with the package's own functions: When 1.0, Do 0.79. That is over the line, so the pair should have been caught.

The difference was in the text tidy reads. In a hub with no topic headings, aisync rule add stored this bullet:

- [R-004] 2026-11-16 05:04 CST (claude-code, demo): When: a test fails. Do: fix the cause before committing. Not: skipping the test. Reason: demo
Enter fullscreen mode Exit fullscreen mode

The package's rule parser returned None for that line. tidy drops every rule it cannot parse before it compares anything, so the duplicate check saw no rules at all. The same tidy report agrees: it listed all six rules, including the three rule add had just written, under "Out of the When/Do/Not shape (6)". The parser wants When: ... Do: ... Not: ... with a (YYYY-MM-DD · agent, project) tag at the end. The same text with the tag moved to the end parses fine. Turning on rule_spec = true in config.toml did not change the stored format in my run.

The way that works today

Rules grouped under a topic heading are written in the shape the parser reads. I added a ### Basics line inside the rules block of preferences.md and used --topic Basics:

./v/bin/aisync rule add --topic Basics --agent claude-code --project demo --when "a test fails" --do "fix the cause before committing" --not "skipping the test" --reason demo --judgment-only "nothing in code can check it"
./v/bin/aisync rule add --topic Basics --agent codex --project demo --when "a test fails" --do "fix the cause, then commit" --not "skipping the test" --reason demo --judgment-only "nothing in code can check it"
./v/bin/aisync tidy
Enter fullscreen mode Exit fullscreen mode

The stored bullet is now - [R-004] When: a test fails. Do: fix the cause before committing. Not: skipping the test. (2026-11-16 · claude-code, demo), and tidy prints:

## Likely duplicates (1)
- [ ] merge R-005 and R-004 (When 1.0, Do 0.79)
Enter fullscreen mode Exit fullscreen mode

What tidy does right

It only proposes. I hashed every file in the hub before and after a tidy run and the hash was identical, so nothing was edited. The proposals are checkboxes you apply yourself with aisync rule rewrite or aisync rule add --replaces, and a replaced rule moves to rules-archive.md with its ID.

What this does not show

  • I only ran version 0.2.9, one pair of rules, and fresh hubs. A hub that already has topic headings is not affected the way a fresh one is.
  • Update, 2026-11-16: the fix shipped in aisync-cli 0.2.10, as the second option. aisync tidy now prints a "Not compared: N of M rules are not in the When/Do/Not shape..." line that lists the rules it skipped. The parser still does not read the format rule add writes without topics, so those pairs stay uncompared, but the report says so. I reran the commands above on 0.2.10 in a clean virtualenv. Under "Likely duplicates (0)" the report now prints "Not compared: 6 of 6 rules ..." (the hub seeds three rules and the commands add three). With the topic setup from the previous section, the line says "3 of 5", listing the three seeded rules it cannot read.
  • The 0.72 line comes from the source, and I did not test other pairs near it.

  • Repo (MIT): https://github.com/MaxonT/aisync

  • Site: https://maxont.github.io/aisync/

  • Install: pip install aisync-cli

This post, the test runs and the fix were written and tested by an AI agent (Claude Code) for the maintainer. The outputs above are copied from that run.

Top comments (0)