Exemplar audit

From Kevin-Liu-01/Agent-Machines · View interactive version

Exemplar audit is an AI agent skill from the GitHub repository Kevin-Liu-01/Agent-Machines. Compare implementation against canonical open-source references. Clone exemplars into /tmp, diff edge cases, error paths, and protocol invariants. Use when building a new subsystem, after a refactor, or when reviewing code that implements a known standard (POSIX, FUSE, WAL, S3, NFS, etc.).

How to use this skill

Skill file

Exemplar Audit

Find what the best implementations do that we don't, then close the

gaps. This is the "measure twice" pass: compare our code against

battle-tested references before declaring it done.

When to use

Procedure

1. Identify exemplars

Check these sources in order:

  1. This monorepo first. The best reference for "how we do X" is

often another subsystem that already does X well. GitHub Actions

workflows, Terraform modules, Rust crates, Go controllers -- scan

for the most mature sibling before looking externally.

  1. Module docs and READMEs in the subsystem being audited.

Look for "References", "Inspired by", "See also", or citations

to external projects.

  1. storage.md, architecture.md, or equivalent design docs.

These often name reference implementations.

  1. The internet. Search for "canonical open-source implementation

of {thing}". Prefer projects with >1000 stars, active maintenance,

and a test suite.

Examples of good exemplars by domain:

| Domain | Internal exemplar | External exemplar |

|--------|-------------------|-------------------|

| GitHub Actions | host-agent-rust.yml, host-agent-kvm.yml | -- |

| Terraform | apps/cloud/apps/dcs/tf/main.tf | checkov rules |

| Rust CI crate | host-agent (same workspace) | -- |

| FUSE filesystem | -- | fuser SimpleFS, FUSE memfs |

| SQLite metadata | -- | JuiceFS pkg/meta/sql.go |

| WAL replication | -- | Litestream, libSQL bottomless |

| S3 chunk store | -- | JuiceFS pkg/object/s3.go |

| VFS layer | -- | Linux fs/fuse/dir.c |

| Content-addressed storage | -- | git sha1-file.c, Perkeep |

2. Clone or read

Clone into /tmp to avoid polluting the workspace:

git clone --depth 1 https://github.com/cberner/fuser /tmp/fuser
git clone --depth 1 https://github.com/juicedata/juicefs /tmp/juicefs

For smaller references, read online (GitHub raw, crates.io source).

3. Compare

For each exemplar, check:

and error paths, not just the happy path. grep for ENOTEMPTY,

ENOSPC, EINVAL, rename, unlink, etc.

we trust? Do they check return values we ignore?

atomicity, nlink consistency, fsync durability, WAL checkpoint

ordering.

mapping, cleaner state machines, fewer allocations.

4. Report and fix

For each gap found:

  1. State the invariant or edge case in one sentence.
  2. Cite the exemplar file and line.
  3. Check if we have a test for it. If not, write one (fail first).
  4. Fix the code if needed.

Do not cargo-cult patterns we don't need. If the exemplar handles

NFS-specific locking and we don't serve NFS, skip it. Every adopted

pattern must have a real consumer in our system.

What NOT to do

prevent bugs we'd otherwise ship.

relevant to our use case.

isn't yielding findings, move on.

Output

Return a table:

| Gap | Exemplar | Our status | Fix |

|-----|----------|------------|-----|

| rename over non-empty dir | fuser SimpleFS L412 | missing | added test + check |

| WAL checkpoint past replicated | Litestream wal.go L890 | missing | added watermark guard |

| (none found) | JuiceFS chunk GC | clean | -- |

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.