Skip to content

docs(agents): add peripheral-existence guardrail (halt on phantom) - #3507

Merged
zackees merged 1 commit into
masterfrom
feat/agent-docs-peripheral-existence-guardrail
Jul 1, 2026
Merged

zackees merged 1 commit into
masterfrom
feat/agent-docs-peripheral-existence-guardrail

Conversation

@zackees

@zackees zackees commented Jul 1, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Adds agents/docs/peripheral-existence.md — a greppable guardrail that requires agents to verify a peripheral EXISTS on the target chip (against BOTH the vendor CMSIS PAL header AND the datasheet peripheral chapter) before writing any code that names a <Peripheral>_Type / <Peripheral>_BASE.
  • If either source is absent, halt and report on the driving issue. Do NOT fabricate the missing typedef in the vendor header repo to make the build pass.
  • Cross-linked from agents/docs/register-maps.md, .claude/agents/platform-port-agent.md (description + Step 5 + Key Rules), .claude/skills/platform-port/SKILL.md, and the CLAUDE.md task table.

Why

Filed against the LPC804 phantom-DMA_Type cascade documented in #3506. LPC804 silicon has no DMA peripheral — NXP's own LPC804.h from mcux-sdk has zero DMA_Type / DMA0_BASE / FSL_FEATURE_SOC_DMA_COUNT — but an agent invented one at reserved AHB slot 0x50008000 so downstream driver code would compile. The shipped driver would write control words into reserved memory at runtime.

Four-PR cascade the guardrail is designed to prevent recurring:

  • FastLED/framework-arduino-lpc8xx#35 — phantom DMA_Type on LPC804
  • FastLED/fbuild#916 — bumped ArduinoCore-LPC8xx to pull the phantom
  • FastLED/FastLED#3500 — widened spi_arm_lpc_dma.h gate to LPC804
  • FastLED/FastLED#3505 — widened AutoResearch harness gate to LPC804

What's in the doc

  • The rule (verify against vendor CMSIS + datasheet chapter, refuse to fabricate).
  • Copy-pasteable verification recipe (grep <CHIP>.h, <CHIP>_features.h, drivers dir, feature flag).
  • Corroborating signals (FSL_FEATURE_SOC_<PERIPH>_COUNT absent, no fsl_<peripheral>* in devices/<CHIP>/drivers/, base address in reserved range).
  • Vendor SDK path table for NXP, ST, Nordic, RPi, Espressif, Atmel, Silabs, PJRC.
  • A false-negative guard so verification of absence is as rigorous as verification of presence (case-sensitive multi-name grep, verify against exact chip variant not family header, check for vendor bugs).
  • Historical LPC804 anti-example with links to the driving issue and the cascade PRs.

Acceptance items from #3506

  • Guardrail document under agents/docs/.
  • Discoverable by grep for DMA, async driver, phantom peripheral, peripheral existence, vendor CMSIS, FSL_FEATURE_SOC.
  • Linked from agents/docs/register-maps.md.
  • Linked from the platform-port-agent agent description.
  • Historical anti-example (framework-arduino-lpc8xx#35) linked.
  • Reproduction recipe copy-pasteable and idempotent.

Scope

Docs and agent-config only. No source code, build system, or driver changes. The four-PR cascade revert is intentionally out of scope for this PR — it is tracked separately in the refs on #3506.

Closes #3506.

Test plan

  • grep confirms all six discoverability keywords appear in peripheral-existence.md.
  • Cross-reference links go where they claim: register-maps.md header note + cross-references section; platform-port-agent.md description + Step 5 body + Key Rules; platform-port/SKILL.md LED Output Drivers; CLAUDE.md task table.
  • CI green on docs-only diff.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation
    • Added a new reference guide for verifying that a peripheral exists on the exact chip variant before using it in driver or register-map work.
    • Expanded platform-porting and register-map guidance with a clear “halt if missing” rule and stronger checks against phantom peripherals.
    • Updated onboarding/agent instructions to point to the new verification guidance and related examples.

Adds `agents/docs/peripheral-existence.md` requiring agents to verify any
`<Peripheral>_Type` typedef / `<Peripheral>_BASE` address is actually
present in BOTH the vendor CMSIS PAL header for the specific chip variant
AND the chip datasheet chapter before writing driver code against it. If
either source is absent, halt development and report on the driving issue;
do NOT fabricate the missing typedef in the vendor header repo to make the
build compile.

Cross-linked from:
- `agents/docs/register-maps.md` (pre-flight before shim tier decisions)
- `.claude/agents/platform-port-agent.md` (description + Step 5 + Key Rules)
- `.claude/skills/platform-port/SKILL.md` (LED Output Drivers section)
- `CLAUDE.md` "Read the Right File for Your Task" table row

Discoverable by grep for: DMA, async driver, phantom peripheral, peripheral
existence, vendor CMSIS, FSL_FEATURE_SOC.

Canonical anti-example is the four-PR LPC804 phantom-`DMA_Type` cascade
(framework-arduino-lpc8xx#35, fbuild#916, #3500, #3505) — LPC804 silicon
has no DMA peripheral; NXP's own `LPC804.h` has zero `DMA_Type` /
`DMA0_BASE` / `FSL_FEATURE_SOC_DMA_COUNT`, but an agent fabricated one at
reserved AHB slot `0x50008000` so downstream driver code would compile.
Doc includes copy-pasteable verification recipe (grep vendor CMSIS
header + features + drivers dir) plus a false-negative guard so
verification of absence is as rigorous as verification of presence.

Closes #3506.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Jul 1, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4d64fe20-cd2b-4d84-ac9f-9e08af00ecaf

📥 Commits

Reviewing files that changed from the base of the PR and between 13f8eb1 and 72c08c7.

📒 Files selected for processing (5)
  • .claude/agents/platform-port-agent.md
  • .claude/skills/platform-port/SKILL.md
  • CLAUDE.md
  • agents/docs/peripheral-existence.md
  • agents/docs/register-maps.md

📝 Walkthrough

Walkthrough

This PR adds a new agent documentation file, agents/docs/peripheral-existence.md, establishing a guardrail requiring verification that a peripheral exists on a target chip (via vendor CMSIS header and datasheet) before defining peripheral typedefs, base addresses, or pointers. It cross-links this guardrail from register-maps.md, platform-port-agent.md, the platform-port skill, and CLAUDE.md.

Changes

Peripheral existence guardrail

Layer / File(s) Summary
New peripheral-existence guardrail document
agents/docs/peripheral-existence.md
Adds a document defining the two-source verification rule (vendor CMSIS header + datasheet), applicability scope, verification recipe with worked LPC804 example, vendor SDK path mapping, absent/present outcome handling, false-negative guard, and the LPC804 phantom DMA_Type anti-example with cross-references.
register-maps.md cross-reference and upfront check
agents/docs/register-maps.md
Adds an upfront instruction to verify peripheral existence before register-map work and a cross-reference entry pointing to the new guardrail document.
Agent, skill, and top-level doc wiring
.claude/agents/platform-port-agent.md, .claude/skills/platform-port/SKILL.md, CLAUDE.md
Updates the platform-port agent description and clockless driver/Key Rules sections, the platform-port skill's LED driver instructions, and the CLAUDE.md task-routing table to require peripheral-existence verification and halting on phantom peripherals.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • FastLED/FastLED#3350: Introduces the same register-map/porting documentation flow (agents/docs/register-maps.md) that this PR extends with the peripheral-existence guardrail.
  • FastLED/FastLED#3438: Updates the LPC register-map migration plan and retires the same LPC804 phantom DMA_Type anti-example referenced in this PR's guardrail doc.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/agent-docs-peripheral-existence-guardrail

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@zackees
zackees merged commit 5309dd7 into master Jul 1, 2026
1 check passed
@zackees
zackees deleted the feat/agent-docs-peripheral-existence-guardrail branch July 1, 2026 14:49
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Jul 1, 2026
zackees added a commit that referenced this pull request Jul 1, 2026
…MA silicon (#3513)

Reverts the FastLED-side of the phantom LPC804 DMA cascade (PRs #3500 + #3505).
LPC804 silicon has no DMA peripheral. Empirical evidence:

- NXP's own `mcux-sdk/devices/LPC804/LPC804.h`: zero `DMA_Type` typedef,
  zero `DMA0_BASE` macro. Only `CRC_BASE = 0x50000000` in the 0x5000_xxxx
  AHB range; 0x50008000 is a reserved slot.
- `LPC804_features.h`: no `FSL_FEATURE_SOC_DMA_COUNT`. LPC845's file has
  `FSL_FEATURE_SOC_DMA_COUNT = 1` and `FSL_FEATURE_DMA_NUMBER_OF_CHANNELS
  = 25`.
- `devices/LPC804/drivers/`: no `fsl_inputmux_connections.h`. LPC845's
  driver dir has it (INPUTMUX exists to route peripheral requests to
  DMA channels — no DMA, no INPUTMUX).
- UM11065 has only 3 DMA references, all copy-paste leftovers in ADC /
  DAC / CAPT / I2C / SPI comment blocks referring to "DMA trigger
  flags" for a peripheral that does not exist on this die.

Diagnosis credit @phatpaul (#3499 comment 4855252061). The revert follows
the guardrail landed in #3506 / #3507 (`agents/docs/peripheral-existence.md`).

## Changes

- `src/platforms/arm/lpc/spi_arm_lpc_dma.h` — narrow build gate back to
  `FL_IS_ARM_LPC_845` only. Add a compile-time `#error` that fires with
  a clear "LPC804 has no DMA" diagnostic + link to peripheral-existence
  guardrail if a user tries to opt into `FASTLED_LPC_SPI_DMA` on LPC804.
  Delete the earlier "LPC804 vendor CMSIS PAL prerequisite" text and the
  LPC804-specific `FASTLED_LPC_SPI_DMA_CHANNEL` default (0 → dropped;
  the LPC845 default of 4 stands).
- `examples/AutoResearch/AutoResearchSpiDma.h` — narrow harness gate
  back to LPC845 only.
- `examples/AutoResearch/AutoResearchLowMemory.h` — narrow include +
  bind gates back to LPC845 only.
- `ci/autoresearch/phases.py` — collapse `LPC_DMA_SPI_ENVS` back to
  `LPC_WS2812_ENVS` (LPC845 environments only). Drop the
  `is_lpc804 → core_hz = 15_000_000` branch (always 24 MHz now).
- `ci/autoresearch/args.py` — update `--dma-spi` `--help` text: drop
  LPC804 mention + fbuild prerequisite; note LPC804 not supported.
- `src/platforms/arm/lpc/README.md` — LPC804 row now clearly documents
  "no DMA-async SPI" with citation to the guardrail. `spi_arm_lpc_dma.h`
  files entry marked LPC845-only. Feature-defines section corrected.
  References/Shipped entry for #3500 strikethrough-annotated with
  "REVERTED — see peripheral-existence.md."

Follow-up (out of scope for this PR):

- Revert `framework-arduino-lpc8xx#35` (the fabricated `DMA_Type` in
  `variants/lpc804/LPC804.h`).
- Revert or supersede `fbuild#916` (bumped ArduinoCore-LPC8xx pin for
  the fabricated typedef).
- Close FastLED #3499 as INVALID.

## Verification

- `bash compile wasm --examples AutoResearch` — clean
- `bash lint` — python_pipeline passes; cpp_linting fails only on the
  same pre-existing Rust-binary silent-fail this Windows environment
  has (unrelated to this diff; see #3510)

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

agent-docs: guardrail — verify peripheral EXISTS in vendor CMSIS + datasheet before building any async driver (halt on phantom)

1 participant