Skip to content

Latest commit

 

History

History
82 lines (68 loc) · 3.61 KB

AGENTS.md

File metadata and controls

82 lines (68 loc) · 3.61 KB

AGENTS.md

Guidance for coding agents working on miapd — a DHCPv6 Prefix Delegation (IA_PD) client daemon for Arista EOS. Read docs/design.md first; it is the terse as-built description of the system, including the hardware findings that shaped it.

Build, test, lint

just build    # workspace, no EOS SDK needed (miapd-eos-sys builds as a stub)
just test     # all unit tests, hardware-free
just clippy   # -D warnings
just fmt      # rustfmt
just deny     # license check

Everything above runs on any machine. The sdk feature flavor compiles the real C++ shim and must ALSO pass before a change is done:

podman exec -e EOS_SDK_DIR=/workspace/eos_sdk_dir -w /workspace/miapd miapd-build \
  sh -c '. "$HOME/.cargo/env" && cargo clippy --workspace --features sdk --all-targets -- -D warnings'

The miapd-build container (AlmaLinux 9.3, glibc-matched to the switch, SDK headers + the switch's libeos mounted) is described in crates/miapd-eos-sys/README.md. ./scripts/package-swix.sh builds the deployable SWIX inside it.

Code conventions

  • No freestanding functions where a method fits; no stringly-typed values. Closed sets are enums (OptionKey, StatusKey, EosOp); domain values are newtypes (PrefixOffset, HostOffset, ValidLifetime, ...). Parsing from strings happens once, at the boundary.
  • All switch access goes through the EosControl trait; daemon logic must stay testable against MockEosControl (which records the exact op sequence) and MockLeaseStore.
  • Comments state constraints the code can't show. No section-number references — docs/design.md uses named sections.
  • Edit files with your editor/tools directly; don't shell out to sed/python for file edits.

Testing expectations

  • Unit tests must stay hardware-free and pass via just test.
  • Changes to miapd-eos-sys (shim), miapd-eos backends, or anything touching SDK/eAPI behavior need validation on a real switch — mocks cannot catch EOS's behavioral quirks (several were only found live). Ask the operator for switch access; never hardcode switch addresses, usernames, or key paths into the repo.
  • The on-switch lab recipe (EOS's bundled kea-dhcp6 on a scratch SVI) is in docs/design.md under "Build, packaging, testing". Use a fresh scratch interface per session and tear everything down afterward.

Hardware gotchas (cost real debugging time — details in docs/design.md)

  • SDK C++ exceptions crossing the cxx bridge terminate the process; every shim function catches internally and is declared Result.
  • SDK-written interface addresses silently lose source arbitration to CLI config — addresses are written via eAPI only. Don't "fix" this back to ip_intf_mgr writes.
  • ip_intf_mgr::ip_addrs returns IPv4 entries too; filter them.
  • Agent config/status persist in Sysdb across daemon deregistration (not reboot). Orphaned address config blocks the same /64 anywhere else — the applied-downstream ledger exists for this; keep it accurate in every install/withdraw path.
  • EOS binary names must not contain dashes. ProcMgr backs off restarts after crashes — a freshly bounced daemon may take minutes to appear.
  • When driving a switch over SSH, use single spaced-out connections; rapid polling loops can exhaust the CLI session broker and lock everyone out.

Housekeeping

  • Keep docs/design.md current when behavior changes; it describes the implemented system, not aspirations.
  • Commit messages: one concise summary line, a short body if needed.
  • The repo must stay free of environment specifics (lab IPs, key paths, container mount paths beyond the documented defaults).