Add two rows to the anti-pattern table in lead-orchestrator.md, both
learned from the DI/DO board verification on 2026-11-16.
Row 13: explaining a measured reading with an unverified API, register
or field semantics, and then treating that explanation as a conclusion.
Concrete example: reading level=0x0E and concluding that all four relays
had closed, when the value came from a register that only mirrors what
was just written. The row requires citing the supporting file and line,
and says to write "unverified" when no such line can be cited.
Row 14: writing an expected reading into a task brief as fact. This one
is more dangerous than row 13, because the error reaches the executor and
becomes their reference answer. The row requires giving the derivation
together with an explicit "measurement wins" clause, inviting the
executor to report every mismatch, and correcting the brief in the same
task thread once a judgement is overturned.
Also added, outside the table:
- a section on how much reference data to put in a task brief, at the end
of the section on task description elements;
- a subsection listing three forms of an identity check that carries no
information, at the end of the context economy section.
Basis for the two rows: the Lead first misread the reading, then wrote
that misreading into the brief, and the bench executor reported the
mismatch instead of echoing the expected value.
Verification:
- anti-pattern table has 14 data rows, all three columns wide
- nothing in the file contains the string ZF as a register name
- the row 14 text is byte-identical to before the rework
- CRLF 0, BOM absent, bom drift check passes
- doc link check reports the same 6 pre-existing issues, none here
- mojibake check passes
The suite ran on the bench and reset the target every 56 seconds, right
after the last Phase 3 assertion. Root cause was the suite itself: the
worker thread entry function returned instead of calling vTaskDelete.
Returning from a FreeRTOS task function is undefined behaviour, and on the
Cortex-M4F port the saved LR points at prvTaskExitError, so the return
trips configASSERT. This project routes configASSERT to
vApplicationAssertFailed, which resets the MCU. The assert banner never
reached the console because the reset happened 0.27 s after the last
line, while its bytes were still queued.
Two assertions were also wrong in ways that hid real state:
- The "which relay is commanded" mask was computed as MASK_ALL & ~bit,
i.e. the complement of what the comment claimed, so the suite reported
the three idle relays as commanded and failed every Phase 3 row even
though the shadow register was correct.
- The "other relays stay released" check was written as (a|b)==b, which
is the same predicate as "at least bit b set" and therefore duplicated
the check above it instead of testing the remaining channels. It now
asserts (active & ~only)==0.
Phase counters are also reset on entry to each phase. The report macro
only prints, so without a reset each phase summary carried every earlier
phase's failures and Phase 2 read 44/62 with no failures of its own.
Hard-coded 0x0F masks are replaced by IOBOARD_TEST_DO_MASK_ALL.
Bench result after the fix: the suite completes in about 54 s with one
reset cause line (boot only), and prints Phase 4, the final release check
and "IOBOARD Tests: 17/17 PASSED". Phase 2 moves to 21/21 and Phase 3 to
16/16.
Still unverified, and not claimed as passing: the eight DI channel order
needs a person to short the terminals, and the relay polarity needs a
person to hear the contacts. Note that ioboard_do_read_level reads ODR,
so the Phase 3 level assertions prove write intent propagation, not
electrical actuation.
Keil build with the suite enabled: Code=264880, 0 errors 0 warnings.
Product build after the suite switch is restored: Code=257932, unchanged.
Three of the six DWT CYCCNT users wrote the counter to zero on init:
console_log, net_latency_test and ch395f_reuse_bench. Every one of them
only ever takes the difference (CYCCNT - t0) against a local snapshot, so
the reset bought nothing and instead caused a bogus ~2^32 delta for
anyone who sampled across it. That delta trips the task_prof glitch guard
(TASK_PROF_GLITCH_CYC = 10 s worth of cycles), which discards the sample,
so a whole worst-case measurement could vanish silently.
All three call sites now leave the counter alone; the shared contract is
"enable only, never reset", documented at each of the six users. The
documented behaviour in the link latency test guide (section 4.3) is
updated to match.
Net source change is three deleted lines, no new executable code.
Verification:
- grep for a zero assignment to CYCCNT across the tree: no hits left.
- Keil build: Code=257932 RO-data=32108 RW-data=2104 ZI-data=152688,
0 errors 0 warnings.
- Host unit tests: console_log 153/153, task_prof 27/27, ioboard 100/100,
sb_link 164/164.
- Four console_log assertions pinned the absolute number of DWT register
touches; dropping the reset write lowers it by one, so their expected
counts move from 3 to 2 (and 4 to 3 for TC-CONLOG-093). The test text
now says why the third write disappeared.
- check_doc_links: 6 known issues, unchanged from baseline.
AGENTS.md stopped being the store of record for build steps, Python env,
hardware pins, doc conventions, log cost and task ownership. Those facts
already live in docs, skills and role files; the entry file now only
points at them. This commit moves every reference that used to name the
entry file to the authoritative landing point, so a reader who follows a
link arrives at the fact instead of at a sentence that no longer exists.
What changed is links and prose, not behaviour. Code, scripts and tests
only have comment and docstring lines touched; the only non-comment edit
in the whole changeset is one note string inside the generated pin table
JSON, and its generator was changed in the same step so the two stay
byte-identical.
New landing points created before the references were retargeted:
- The console single-writer log design doc, section 7.1, is now the single
authority for log cost: about 90 B flash and 216 B stack per DBG_ line,
and the rule that deep call chains must predefine DBG_LINE_BUF_MAX.
It also carries the full list of the twelve translation units that have
tightened it, plus the grep command that decides the truth if the list
and the code ever disagree.
- The document writing standard, section 2, now holds the BOM list.
- keil-build skill gains an exit code table: 0 success, 1 build failure,
2 BuildEnvError, 3 usage, 4 build lock held. This corrects a belief
that was never actually written down anywhere: exit 2 does not simply
mean environment error, argparse also exits 2 and the wrapper script
was remapped so the two no longer collide.
Regenerated and checked byte for byte:
- The end-to-end architecture SVG in docs/images from its generator.
- tools/netlist_semantics/pinout_kb.json from gen_kb.py.
Both are idempotent; running the generators again produces no diff.
Deliberately not touched, because machines read them:
- scripts/check_bom_drift.py joins every line containing BOM and asserts
four paths are present, so the entry file BOM line must stay one line.
- scripts/gen_task_table.py reads the TASK_TABLE anchors directly.
- scripts/rename_maps and scripts/archive keep their historical wording;
they describe what happened, not what is true now.
Verified: doc links report the same six pre-existing findings as the base
commit and no new ones, generated-fresh passes, bom drift is clean across
101 files, and AGENTS.md itself is unchanged in this commit.
The entry file had grown to 194 lines, of which a large part duplicated
knowledge that already lived in skills, docs or role files. Worse, three
pieces of project knowledge existed only there, and ten roles were all
module implementers or reviewers: no role carried the Lead side
collaboration protocol, so "Lead only orchestrates, never implements" and
"the reviewer must not be the implementer" had no home anywhere.
AGENTS.md 194 lines / 13908 B -> 121 lines / 12283 B, 13 sections -> 9.
- Dropped four sections whole, each with an existing landing point:
build and verify (keil-build / serial-boot-test skills), Python env
(new-machine-setup skill), hardware pins (hardware spec doc section 2),
docs and diagrams (writing standard plus draw-diagram skill).
- Compressed project overview, iron rules, pre-commit, platform
constraints and module conventions into pointers plus the few facts that
must be seen every turn.
- The directory map changes from "directory | responsibility | can I
modify it" to "directory | can I modify it" and hands the detail to the
architecture overview section 7. The value of this table on the entry
file is the permission semantics, not a second copy of the tree.
- Delegation policy is the one section that grows in substance: four
always-present rules, reviewer is not implementer, rework needs fresh
evidence, the gate flow, three measured limits of the ledger plugin and
member revive/rebind.
Three machine anchors are untouched: the TASK_TABLE comment pair and its
body, the BOM list line (one line, four paths, the bom-drift checker
concatenates every line containing BOM), and the hook count sentence.
Line endings stay CRLF.
New roles:
- .dsh/roles/lead-orchestrator.md: the Lead collaboration protocol in two
parts, generic methodology and this project's specifics. Twelve
anti-patterns with the case behind each, an eleven-role split table
(what it owns, what it must not touch, when to call it), and ten
documented gaps between what the entry file claimed and what
dsh-plugin-team-ledger v0.2.0 actually does.
- .dsh/roles/bench-runner.md: bench execution and evidence collection, an
execution layer and explicitly not a decision layer. It has no write
tools and no gate submit/accept, because the person who reads the log
must not also judge the run.
Existing roles:
- mcu-specialist gains the kernel-before-start rule, including the legal
counterexample vTaskDelete(testTaskHandle) in Src/freertos.c. The
criterion is not "create or delete" but whether the call waits for the
scheduler or for time.
- algo-specialist gains the RS-485 wiring gate with the two contract
defects it stands on: a weak rx hook with a single 256 byte buffer, and
a direction switch back to RX that does not wait for TC.
- storage-specialist's owner statement is rewritten rather than appended:
defaultTask owns the config engine because its static state is unlocked,
and reading still advances the poll baseline and the debounce counters.
- README: eleven roles, order unified across the overview table, the
detailed sections and the selection guide.
Verified: gen_task_table --check, bom drift, mojibake, generated fresh and
doc links all clean, and doc links report the same six pre-existing
findings as before this change. Role files are CRLF free, no BOM.
Bench verification of the IO board needs an observation window: production
build has no consumer of ioboard_di_snap_read(), so the DI values were
invisible. Add TEST_SUITE_IOBOARD as a semi-automatic bench sequence and fix
two real bugs found while wiring it in.
New files:
- test/board/ioboard_test.h, test/board/ioboard_test_task.c
Test suite:
- Owns its own thread (iobTest, 4096 words) instead of running in testTask:
testTask is osPriorityBelowNormal, below defaultTask whose 1ms console
drain loop can starve a blocking wait in a lower priority context.
- Phases: bit-order self-check, DI eight-point bijection, DO point-by-point
toggle with operator confirmation, release-all on every exit path.
- Only exit is ioboard_release_all(); it is called from the entry guard,
every phase failure, the write-failure branch and the thread tail.
- Sample window is 20 reads x 2ms = 40ms and does overlap the 50ms
production poll. That is stated as harmless in the header: the driver
wraps the whole read in taskENTER_CRITICAL (26us, not the whole 40ms),
both sides only read, and a torn cross-reader sample is caught by the
debounce layer rather than acted upon.
default_task.c fix:
- DEFAULT_TASK_DI_PUBLISH_EN was defined twice: once at file scope and once
inside default_task_func(). #define has no scope, so the second was a
redefinition of the first. Collapsed to a single authoritative site.
- Add TEST_SUITE_STORAGE to the disable list: the STORAGE suite owns the
file system via testTask, and default_task_di_poll() referenced four
statics that live inside an !TEST_SUITE_STORAGE block, which broke the
STORAGE build with 11 errors.
- Shrink the !TEST_SUITE_STORAGE block to cover only
default_task_net_cfg_save_notify() and move the three declarations out;
move edges/fails into the #else branch so the empty branch references
none of the four statics.
Registration and gates:
- MDK-ARM/STM32F407-Demo.uvprojx and simulator/CMakeLists.txt entries.
- scripts/check_test_suite.py: whitelist TEST_SUITE_IOBOARD.
- scripts/stack_report.py: let a self-started thread that is not declared in
Src/freertos.c osThreadAttr_t still be budget checked.
- test/run_all_suites.py: bring the suite into the orchestrator view.
Verified: six-build matrix all 0 errors 0 warnings. CH395F/STORAGE/GD5F/RTC
and the product build are bit-identical at Code=257936; the IOBOARD build is
Code=264640 (+6704), which is the evidence that the suite really enters the
image. Host unit tests 100/100, stack report 1760/4096 words (57%).