124 lines
5.9 KiB
Markdown
124 lines
5.9 KiB
Markdown
# CLAUDE.md — rules for all agents working on lucisv
|
|
|
|
lucisv is a ruff-style Verilog/SystemVerilog formatter/linter in Rust.
|
|
Read `README.md` for architecture and `TODO.md` for the backlog before
|
|
doing anything.
|
|
|
|
## Hard invariants (never break these)
|
|
|
|
1. **Never corrupt code.** The formatter either produces verified-correct
|
|
output or emits the input unchanged with an error. No partial output.
|
|
2. **Idempotent.** `format(format(x)) == format(x)`, always.
|
|
3. **Comments are never dropped.**
|
|
4. **Any widening of `verify.rs`'s forgiveness is guilty until proven
|
|
innocent.** Every new or broadened normalization in the safety net
|
|
ships WITH masked-corruption attack tests (crafted (input, corrupted
|
|
output) pairs the normalization could plausibly forgive, asserted
|
|
rejected) — written by the dev, re-attacked by QA. History: the one
|
|
real corruption lucisv ever produced (macro-items, 2026-08-19) slipped
|
|
through a normalization added without such tests.
|
|
|
|
## Simplicity first
|
|
|
|
- Prefer the boring, obvious implementation. If you're building an
|
|
abstraction for a second user that doesn't exist yet, stop.
|
|
- Standard library first. Adding a dependency requires a written
|
|
justification in the feature README.
|
|
- Small functions, descriptive names, shallow nesting. Code should be
|
|
readable top-to-bottom without jumping around.
|
|
- Match the style of the surrounding code (comment density, naming,
|
|
module layout).
|
|
|
|
## Rust standards
|
|
|
|
- `cargo fmt` clean, `cargo clippy --all-targets` clean (no `#[allow]`
|
|
without a comment explaining why), `cargo test` green — all three
|
|
before declaring any work finished.
|
|
- No `unwrap()`/`expect()`/`panic!` in library code paths; return
|
|
`Result`. Tests and `main.rs` argument handling may use them.
|
|
- Public items get a one-line doc comment. Doc comments say what/why,
|
|
not how.
|
|
- No `unsafe`.
|
|
|
|
## Document-based development
|
|
|
|
Every feature lives in `docs/features/<feature-name>/README.md`. That
|
|
README is the single source of truth for the feature and must contain
|
|
these sections:
|
|
|
|
```markdown
|
|
# <feature name>
|
|
## Goal — one paragraph, what and why
|
|
## Assumptions — everything you assumed that isn't enforced by code
|
|
## Handshakes — interfaces/contracts with other modules: what you
|
|
consume from them, what you promise to them
|
|
## Status / TODO — checklist; keep current as you work
|
|
## Work log — dated entries by the dev agent: what was done, key
|
|
decisions, deviations from plan
|
|
## QA log — dated entries by the QA agent: what was verified,
|
|
how, and findings
|
|
## Review — reserved for the lead; do not write here
|
|
```
|
|
|
|
Rules:
|
|
|
|
- **Dev agents**: create/update the feature README *as you work*, not at
|
|
the end. Finished TODOs get checked off in the same README. If you
|
|
change a handshake another module depends on, say so explicitly in
|
|
Handshakes and in the work log.
|
|
- **QA agents**: you verify, you don't redesign. Run the checks, try to
|
|
break the feature, record everything in the QA log. File concrete
|
|
findings (file:line, reproduction) — not opinions. Small unambiguous
|
|
fixes (typos, missing test assertion) you may fix directly and note it.
|
|
- **Review section** is written only by the lead agent after examining
|
|
the work. Respond to review comments by fixing and logging in the work
|
|
log, not by editing the Review section.
|
|
|
|
## Workflow
|
|
|
|
- Do **not** run `git commit` or `git push` — the lead reviews and
|
|
commits all work.
|
|
- Do not touch files outside your feature's stated scope. If you need a
|
|
change in another module, write it as a request in your README's
|
|
Handshakes section and stop.
|
|
- New behavior needs tests in the same change. Every formatter change
|
|
must keep the snapshot + idempotency suite green
|
|
(`cargo test -p vlog_formatter`).
|
|
- Update `TODO.md`: check items your feature completes (leave the item
|
|
text intact).
|
|
|
|
## Parallel lanes (the 2-agent loop)
|
|
|
|
Up to **two dev/QA lanes may run concurrently** when — and only when —
|
|
their features do not collide in `docs/topo.md`: no shared edge between them
|
|
(no `──▶`, no `◀──▶`, and neither touching the same open handshake in
|
|
§2.9), and disjoint file sets. `docs/topo.md` is the authority; if the
|
|
collision question is not answerable from it, the features are not
|
|
proven independent and run serially. Rules for a parallel wave:
|
|
|
|
- **The lead plans the lanes** before anything is dispatched: one brief
|
|
per lane with an explicit file-ownership list. That list is the merge
|
|
contract — a lane touches nothing outside it. A needed change to a
|
|
file the other lane owns (or to any unlisted file) is a Handshake
|
|
request in the lane's README plus a flag in its report, never a
|
|
silent edit; the lead rules on it at merge.
|
|
- **Each lane works in its own git worktree** branched from the same
|
|
trunk commit. Never two agents in one tree. Trunk stays untouched
|
|
while lanes are in flight; the lead merges each lane back only after
|
|
that lane's QA verdict and lead review, and re-runs the full gates on
|
|
the merged tree before pushing.
|
|
- **Roles per lane are unchanged**: one dev (Opus), then one QA
|
|
(Sonnet) in the same worktree, then the lead's review — so at most
|
|
2 devs + 2 QA agents exist at once, and a lane's QA starts only when
|
|
its own dev is done. A QA rework loops inside its lane without
|
|
blocking the other lane.
|
|
- **Tracking lives in `TODO.md`**: the lead writes the wave's section
|
|
(one subsection per lane, each item naming its files) on trunk before
|
|
branching; each lane ticks only its own lines. Shared-by-nature files
|
|
(`TODO.md`, `docs/perf/README.md`) may be appended to by both lanes
|
|
in their own sections — the lead resolves the trivially-parallel
|
|
merge; anything worse than trivially-parallel means the lanes were
|
|
not actually independent, which is a planning failure to record.
|
|
- After merging, the lead updates `docs/topo.md` for any edge a lane added
|
|
or amended, so the next wave plans against reality.
|