docs: check in the AI-assistant guidance contributors were missing - #132
Merged
Conversation
Code Review by Qodo🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)
Great, no issues found!Qodo reviewed your code and found no material issues that require reviewTip of the day💡 Did you know, you can describe a rule in plain language on the Rules page and Qodo drafts it for you |
PR Summary by QodoAdd repository guidance for AI coding assistants
AI Description
Diagram
High-Level Assessment
Files changed (2)
|
The repo has never carried a CLAUDE.md or AGENTS.md, so anyone pointing an
assistant at defib started from whatever it could infer by grepping. That is
a bad place to start on a tool whose failure mode is an erased camera.
This adds the file, fact-checked line by line against the tree rather than
transcribed from an older mental model. Corrections over the draft that was
sitting untracked locally:
- Rockchip USB recovery was missing entirely. src/defib/rockusb/ is ~1.5k
LOC, has its own extra, its own profile (rv1106) and a RECOVERY field in
the profile schema; a chip whose boot ROM answers only on USB is now a
first-class case, not a footnote.
- LOC figures were understated ~2.3x (Python) and ~8x (C).
- The CLI list named 7 of 19 commands, omitting restore -- a headline
feature in the README.
- The agent speaks 13 opcodes, not 6, and comes up at 115200; 921600 is
negotiated afterwards via CMD_SET_BAUD.
- Per-SoC load addresses live in agent/Makefile, not link.ld, and all-socs
builds 4 of the 10 supported SoCs.
- There is no FastAPI server. src/defib/web/ is a one-line placeholder.
- Power controllers are not entry-point plugins. The group is declared in
pyproject but nothing reads it; factory.py is a hardcoded if/elif.
- 112 profile JSON files. `defib list-chips` shows 123 because the 11
V500/CV6xx chips are hardcoded in their protocol classes rather than
filed -- not, as first written, because board variants expand.
- Three transports named, six exist; mypy has a second override for usb.*;
CI runs both JS test files.
Writing the protocol section down surfaced something worth stating outright:
HiSiliconStandard.matches() is just "does a profile JSON exist with this
stem", entry points load alphabetically as [CV6xx, Standard, V500], and
find_protocol returns the first match. The only reason Standard does not
swallow the V500 chips is that they deliberately have no profile file. So
adding one for a V500-family chip would silently route it to the wrong
protocol. That trap is now documented in both the architecture section and
the add-a-chip checklist.
Beyond the corrections it writes down what the repo has never documented
anywhere, which is what an outside contributor working on their own camera
actually needs:
- That there are no guard rails. No confirmation prompt, no --dry-run and
no --force exists in the CLI; install/restore/agent flash/agent write
start erasing on invocation. Hence the rule the dump-flash commit already
implied: back up before you write, with the command to do it.
- The three ways to work without hardware -- MockTransport, QEMU over
socket://, .dcap replay -- including that `defib replay` only prints a
capture and driving a protocol from one is a Python-level activity.
- The /dev/uart-* udev symlink convention that serial_ports.py and PoE port
discovery both depend on but nothing creates for you, the dialout group,
and which commands need root.
- The add-a-chip checklist, including the hand-maintained PROFILES copy in
web/index.html that nothing regenerates -- the omission that caused #121.
Safety claims are held to what is on master: the Rockchip zero-capacity and
out-of-range read guards are real but live on an unmerged branch, so they are
not listed here yet.
AGENTS.md is a symlink to CLAUDE.md so assistants that look for the
vendor-neutral name find the same text. Windows checkouts without symlink
support will see a one-line file containing "CLAUDE.md" instead.
Verified by running every command the file documents, in a clean worktree:
715 passed / 2 skipped, 16 fuzz, ruff clean, mypy clean over 66 files,
5412/5412 agent C tests, 86 JS tests, and cross-compiles for the default SoC
and hi3516cv300. The uv sync line adds --extra rockchip, which CI does not
currently install.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
widgetii
force-pushed
the
docs/agent-guidance
branch
from
September 1, 2026 19:48
8f14337 to
87b7e23
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The repo has never carried a
CLAUDE.mdorAGENTS.md, so anyone pointing an AI assistant at defib started from whatever it could infer by grepping — a bad place to start on a tool whose failure mode is an erased camera.This adds the file, fact-checked line by line against the tree.
Corrections over the draft that was sitting untracked
src/defib/rockusb/is ~1.5k LOC with its own extra, its own profile (rv1106) and aRECOVERYfield in the profile schemaagentsubcommands;restorewas omitted, a headline README featureCMD_SET_BAUDafterwardslink.ldlink.ldis generic; addresses are per-SoCifeqstanzas inagent/Makefile.all-socsbuilds 4 of 10src/defib/web/is a one-line placeholder and thewebextra is vestigialdefib.powergroup is declared in pyproject but nothing reads it;power/factory.pyis a hardcodedif/elifdefib list-chipsshows 123 because the 11 V500/CV6xx chips are hardcoded in their protocol classes rather than filedusb.*, and CI runs both JS test filesOne thing the review surfaced
Writing the protocol section down made a latent trap visible:
HiSiliconStandard.matches()is just "does a profile JSON exist with thisstem", the entry points load alphabetically as
[CV6xx, Standard, V500], andfind_protocol()returns the first match. The only reasonStandarddoes notswallow the V500 chips is that they deliberately have no profile file. So
adding a profile JSON for a V500-family chip would silently route it to the
wrong protocol. Documented in both the architecture section and the add-a-chip
checklist.
What it adds beyond corrections
The things this repo has never documented anywhere:
--dry-run,no
--forceexists in the CLI —install/restore/agent flash/agent writestart erasing on invocation. So: back up before you write, with the command.
Plus a read-only vs irreversible command table.
MockTransport, QEMU oversocket://,.dcapreplay — including the trap thatdefib replayonlyprints a capture.
/dev/uart-*udev symlink convention thatserial_ports.pyand PoE port discovery depend on but nothing creates foryou, the
dialoutgroup, and which commands need root.PROFILEScopyin
web/index.htmlthat nothing regenerates — the omission behind web: 65 frame-blast (PRESTEP0) chips are selectable but the web build never sends PRESTEP0 #121.flash agent, not an AI one.
Safety claims are held to what is on
master: the Rockchip zero-capacity andout-of-range read guards are real but live on an unmerged branch, so they are
not listed yet.
AGENTS.mdis a symlink toCLAUDE.mdso assistants looking for thevendor-neutral name find the same text. Windows checkouts without symlink
support will see a one-line file containing
CLAUDE.md.Verification
Every command the file documents was run in a clean worktree:
pytest tests/ --ignore=tests/fuzz— 715 passed, 2 skippedpytest tests/fuzz/ --hypothesis-seed=0— 16 passedruff check src/ tests/— cleanmypy src/defib/ --ignore-missing-imports— clean, 66 filesmake -C agent test HOST_CC=gcc— 5412/5412node --test web/protocol.test.js web/profile-parity.test.js— 86 passedmake -C agentandmake -C agent SOC=hi3516cv300— both buildThe
uv syncline adds--extra rockchip, which CI does not currentlyinstall — worth considering for the
testjob so the sixtests/test_rockusb_*.pyfiles run with pyusb present.
Not included
README.mdis stale in the same ways — it still says "HiSilicon, Goke, andother SoC families" with no mention of Rockchip despite #125 having shipped,
and omits
dump-flash/detect. Left for a separate PR.