AGENTS.md 6.6 KB

Prod2U CPLD Operating Rules

This checkout implements the Prod2U door-temperature controller. The active product contract is projects/prod2u-door-temp/project.json, projects/prod2u-door-temp/requirements.zh-CN.md, and docs/prod2u-door-temp-protocol.zh-CN.md. Generated contracts, constraints, source manifests, tests, TD inputs, and packages must derive from that contract.

Current authority is limited to the above contract files, this AGENTS.md, and generated artifacts. Historical design documents are not active authority.

Execution priorities

  1. Core limit one-shot behavior and startup close/seek first.
  2. Keep behavior simple and deterministic inside the declared constraints.
  3. Form a minimally usable, synthesizable version quickly.
  4. Reduce LUT and Slice after core function is correct.
  5. Reduce LUT and Packed Slice after core function is correct.
  6. Generalization, security, exception coverage, compatibility, long-term maintenance, performance tuning, and perfect documentation are lower priority.

"Reliable" means deterministic under these assumptions: host obeys command order; no new command is sent while a motor is running; duty is 0..100; motor command is 00/01/02; no undeclared concurrency; hardware wiring matches the current project/ADC.

Model and effort policy

  • MODEL_POLICY=unconstrained.
  • REASONING_EFFORT_POLICY=unconstrained.
  • MODEL_OR_EFFORT_IS_ACCEPTANCE_GATE=false.

Dynamic agent rules

  • No fixed sub-agent roster, fixed Team A/B/C/D, fixed agent count, agent registry, message bus, dedicated agent database, complex run-state, role definitions copied for every tool, or heavy JSON evidence.
  • The root AGENTS.md is the single long-term, tool-independent rule source.
  • Tool-specific rules (.devin/, .cursor/, .codex/, .agents/) are only kept if they are thin tool adapters that point here; they must not reproduce the full product contract or define a static team.
  • Sub-agents are created dynamically only for independent, temporary tasks and end when that task ends. Different writers never modify the same file or logic without coordination.

Git and worktree rules

  • Do not reset, clean, stash, restore, overwrite, or delete changes from unknown sources.
  • Work directly on dev only when it is clean and no other session is touching the same files.
  • When dev is dirty or another session is active, use a temporary branch/worktree.
  • Temporary branches/worktrees are conflict-prevention measures, not a long-lived branch system.
  • All accepted production code, tests, and docs must end up in dev.
  • The final state of every task is a clean dev working tree with accepted changes committed/merged.
  • Delete temporary branches/worktrees created for this task once they are no longer needed.

Product contract

  • UART: 25 MHz, 115200 8N1, 217 clocks/bit, A5 5A framing, CRC-16/CCITT-FALSE.
  • Supported frame types: 0x01 SET_ALL, 0x02 GET_TEMPERATURE, 0x82 TEMPERATURE_DATA.
  • SET_ALL payload: 8 PTC values, 4 FAN values, X/Y motor commands (14 bytes total).
  • PTC active high; FAN active low at FPGA output.
  • PWM ~20 Hz.
  • Watchdog 10 s -> PTC 0, FAN 20.
  • Ordinary motor move: 450 steps at 1000 steps/s. X and Y may overlap.
  • No ACK, BUSY, ERROR, command queue, preemption, legacy protocol compatibility, background temperature scan, or runtime limit usage.

Limit one-shot contract

  • X limit: CON30 pin3 / FPGA B9. Y limit: CON12 pin3 / FPGA A11. Active high.
  • Limit is used only once per FPGA power-on, global hardware reset, or reconfiguration.
  • Startup closes both dampers: PTC 0%, FAN 10%, motor EN_n 0, DIR = 1 (close).
  • Per axis:
    • If synchronized limit is already high: axis does not move, marked reached.
    • Else start a burst of up to 450 full STEP rising edges at 1000 steps/s.
    • After a full burst, hold STEP low for 50 ms, then start the next burst.
    • Max 10 bursts. After 10 bursts not reached: mark exhausted, do not retry, do not send fault frame.
    • X and Y may move concurrently and stop independently.
  • When limit is observed high inside the current 450-step burst:
    • The stopped axis produces no new STEP rising edge.
    • If STEP is low, no next rising edge is produced.
    • If STEP is high, the current high pulse completes its full half-cycle and falls; no new rising edge after that.
  • startup_done is sticky. It is only cleared by the next FPGA power-on, global hardware reset, or reconfiguration.
  • After startup_done:
    • startup motor start = 0, active mask = 0, stop mask = 0;
    • the limit stop mask to the motor engine is 0;
    • the startup FSM does not return to check/move states;
    • the burst counter does not restart;
    • limit changes have no effect on calibration, interrupts, stops, position, or ordinary motor moves.
  • During startup_done == 0:
    • SET_ALL and GET_TEMPERATURE are dropped; no caching, no response, watchdog is not fed.
    • The simplest implementation keeps the frame parser reset/flushed so partial frames cannot become valid commands later.

Tooling preference

  • Prefer Windows PowerShell for local command orchestration unless a repository tool explicitly uses another shell.
  • Use Python for cross-platform scripts and deterministic automation.

Necessary tests

  • Product, protocol, generator, packaging, and Git protection Python tests.
  • Icarus testbenches for the active Prod2U top, including startup one-shot and runtime limit inert behavior.
  • Verilator lint, cocotb UART tests, and formal checks when the environment is available and cost is reasonable.

Evidence boundaries

  • Distinguish source, simulation, formal, TD, package, and physical-hardware evidence.
  • fail, blocked, not_run, placeholder, or exploratory evidence is never a pass.
  • Receipts bind run ID, exact full commit, project hash, source-manifest hash, command, tool version, status, and applicable bitstream hash.

Remote ChatGPT adviser usage

  • If a task provides an exact ChatGPT conversation URL, the local top-level Agent may use the existing Playwright MCP / Microsoft Edge session to open that URL and continue the conversation.
  • Upload only the current core/source package; do not create new sessions, use share links, switch browsers, use the API, or send sub-agents separately.
  • Use natural language; do not force JSON, fixed turn budgets, or short timeouts.
  • If Playwright MCP is unavailable, record the blocker and continue locally; the adviser is not a hard gate.

Protected operations

  • Never access COM or JTAG, program hardware, install drivers, or modify global PATH.
  • Do not create fixed ChatGPT Adviser plugins, ledgers, or sessions.
  • Hardware validation is not_run unless explicitly authorized in a future task.