Commit Graph

5 Commits

Author SHA1 Message Date
wandering1 ab20302999 refactor(agents): split entry file from role knowledge, add orchestration role
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.
2026-11-16 19:37:15 +08:00
wandering1 fd767d1dcd feat(ioboard): 开入开出板驱动、去抖快照与主机侧单测接入
74HC165 开入 + 光耦继电器开出的完整硬件抽象层,接进 defaultTask
的 50ms 节拍。开入 8 路(第二块 165 数据线板上未接,故只有 8 位),
开出 4 路(高电平吸合)。

驱动 BSP drivers:
- IOBOARD/ioboard.c 装载与移位时序,每步注明数据手册依据;
  SH/LD 拉高前先拉低 CLK,否则装载瞬间多移一位;
  单次读取上界 26us(延时按最慢列 VCC 2V 全温区取值)。
- IOBOARD/ioboard_bits.c 位序组装纯函数,只依赖 stdint.h,
  主机侧可直接 include 做单测:读 8 次为 H,G,F,E,D,C,B,A,
  A 放 bit0(bit(7-i) = reads[i])。
- 极性集中在 IOBOARD_DO_LEVEL_ACTIVE 一处,接口语义统一为
  mask 的 1 = 吸合。

业务接线:
- App/util/ioboard_di.c 通道去抖与双区快照,纯逻辑;
  刻意不 include ioboard.h(其引脚宏会牵入 main.h),
  两处路数常量由测试的编译期静态断言钉住。
- default_task.c 的 default_task_di_poll():读失败不喂去抖、
  不写发布值,只把上一有效值加 valid=0 发布出去,
  避免"全 0"被现场读成开入全部复归。
- 去抖实际粒度 50ms(每个轮询周期喂一拍),最坏上报约 100ms;
  想要真 20ms 需另建定时器,本次不做。
- Src/main.c 在 app_main_init 之前调 ioboard_init(),
  上电即把 4 路出口钉在全释放并确认 165 静止态。

测试:
- test/host/ioboard/ 100 条断言。位序主判据为单比特两端
  (只有 A 得 0x01、只有 H 得 0x80)加八点双射穷举;
  混合图样降级为辅助,因该图样曾先后被算成 0xA5、0x5A、0xAA。
- 去抖覆盖 20ms 边界、抖动不翻、跨 49.7 天回绕。
- 失败语义覆盖"失败保留上次有效值"与"失败窗口内的真实变位不丢"。

文档:
- 新增 docs/硬件平台/开入开出实施说明.md。
- 硬件规格与能力边界 §5 的能力边界现状改写:出口继电器与
  开入回路已具备、业务层未接入;4 路开出只可台架验证,
  不得用于真实跳闸。
- 修正 docs/文档规范.md §3.1:原文要求所有互链用仓库根相对,
  与 check_doc_links.py 的实际解析基准矛盾(markdown 链接按
  当前文档目录解析,反引号路径才按仓库根)。改为区分两类,
  并补 §3.1b 写明对应校验器。
- 清理 docs/任务规划/登记簿.md 改名为硬件改版登记.md 后
  遗留的 9 处旧名引用。

门禁: keil-build 0 Error 0 Warning;主机侧单测 ioboard 100/100、
sb_proto 45/45;pre-commit 48 根钩子全通过。
2026-11-16 18:30:31 +08:00
wandering1 d9f8dbfd90 fix(roles): 角色工具白名单改宿主注册名,ui-specialist 内联技能手册
8 个角色文件:
- 白名单里的 read/grep/glob 是幻影名(宿主未注册过),改为
  ops_grep / ops_glob / ops_inspect_local_file,删除 read
- 公共工具组补 team_gate_* 六项(门禁账本插件已接入,成员
  应能认领与提交门禁)

roles/README:
- tools 字段说明重写:两层名册对照表(全局层可限制 / 作用域层
  不可限制)、三桶语义(可限制 / scopeLocal / unresolved)、
  diag 三行原文;容错口径改为「多写名字不会让策略整批失效」
- 新增「一个必须知道的能力边界」:ops_discover_tools 能激活
  写侧作用域工具,白名单不是安全边界
- 新增「关于模型」:角色 frontmatter 的 provider/model 只有
  subagent_role 路径读,team 注入路径不带模型路由,成员一律
  跑宿主默认模型,换模型走 team_member_revive

ui-specialist:
- 第三部分内联 ui-verify / lvgl-simulator / board-ui-nav /
  font-regen 四个技能全文,成员无需 skill() 路由即得完整
  规程(persona 28855B,上限 65536B);权威源仍是
  .dsh/skills/,段首写明同步纪律

实测:插件真实 parseRoleDocument 通过;白名单计数
43/43/43/43/43/43/41/41;maxToolCalls 3000 不变。
2026-11-16 16:43:50 +08:00
wandering1 9f68b7bc03 feat(dsh): spawn_teammate 角色 persona 自动注入 + 测频带外饱和边界登记
CI / 静态门禁 (pre-commit) (push) Failing after 3m46s
CI / 主机侧单测 (MSVC) (push) Successful in 30s
一、子 Agent 角色自动注入(本批主线)

dsh-plugin-subagent-roles fork(仓库 .dsh/plugins/)新增事件路径注入:
spawn_teammate 的 prompt 首行写 @role:<角色id>,插件在子会话首轮模型
请求组装之前把 .dsh/roles/<id>.md 的 persona 注入其系统提示词,并应用
工具白名单。此前只有 subagent_role 路径自动注入,team 路径需 Lead 手工
拼接 persona,本批把两条路径拉齐。

实现要点(细节见 docs/环境与部署/子Agent角色自动注入实现说明.md):
- 在 lead 会话的 tool/call(spawn_teammate) 截获 @role 标记,在
  subagent/catalog 拿 childId 后经 agents.get(childId) 注入——子会话侧
  user/message 必然晚于首轮 system/message,只能在 lead 侧接力。
- tools.restrict() 只校验全局工具名,ops_* 等作用域工具混入会整批抛错;
  降级为解析报错尾部 known global tools 求交集后重试。
- 保留子会话 @role 标记兜底路径(第 2 步起生效)+ 双去重集合。
- 诊断日志 ~/.dsh/role-inject-diag.log,一次健康注入 4 行。

配套文档与口径:
- 新增 docs/环境与部署/子Agent角色自动注入实现说明.md(实现参考 +
  排障速查,9 章),docs/README.md 索引挂载。
- AGENTS.md 委派策略改为自动注入口径(无需手工拼接)。
- .dsh/roles/README.md 删去"调用预算"列:budget.js 的 arm() 只由
  subagent_role 委派路径调用,teammate 路径不挂账,原列是假上限承诺;
  改加脚注指向实现说明 §1.1。

二、测频幅值门放宽至 5 V + 带外饱和边界登记(freq.h)

- FREQ_AMP_MIN 50 V -> 5 V(用户裁定 2026-11-13):台架低端注入(标定
  用 5~25 V 档)与低负荷工况也能测频;浮空二次域噪声几十 mV,仍差两个
  数量级,噪声不测频的本意不变。
- 注释同步登记:IA 回退候选同拿 5.0 比较,二次电流 0.5~2 A 够不到
  "5 A",只注电流实际不回退测频(电流域门限另裁);窗环钳位区间
  [72,96] 只对 41.7~55.6 Hz 满足整倍条件,带外读数饱和钉沿。
- docs/算法/采集与算法层设计说明.md 新增 §7.3 准确测频带与带外饱和
  (60 Hz 实证钉 ~55;用户裁定不改参数,只登记边界)。

验证:/keil-build 0 错误 0 警告(Code=256592 RO=32036 RW=2088
ZI=152584);pre-commit 52 钩子全绿(含 3 根 manual 阶段:cppcheck、
test-cppcheck、test-coverage)。
2026-11-14 10:07:27 +08:00
wandering1 1355dbe1b1 fix(cfg): 配置热重载吞段缺陷修复 + 两点标定工具链与台架实测落档
修复运行期改配置被打回出厂值的缺陷:cfg_file_poll() 按段循环复用同一
份读缓冲,而 s_parse() 通过 s_split_line()/s_key_value() 就地改写缓冲
(把换行与等号换成 NUL)。第一个段解析完,缓冲里已没有键值行,后续 7
个段静默保持出厂值;随后 run_par_store_save() 又把这份出厂值写回
config.ini,用户的标定值被永久覆盖。开机路径 cfg_file_load() 只解析一
轮,所以该缺陷长期不可见,只在运行中改配置时发作。

- s_parse() 改为非破坏性:入参 const char *,逐行 memcpy 到栈缓冲
  (CFG_LINE_TEST_MAX + 1)后再交给会破坏缓冲的解析子函数;超长行跳
  过(保存侧已拒绝落盘超长受管键行)。
- 新增 TC-CONFIG-063:同时改两段内容,断言第二个注册段也重载成功、
  含负值 INT 键存活,把「热重载吞段」钉成机器面。

新增两点标定台架工具链(test/host/):
- cal_two_point.py:整数算术镜像 adc_cal_two_point(),支持单路模式与
  从执行卡 CALDATA 表批量求解(--from-doc),带合法带与零点自检拦截。
- cal_write.py:复用 iec104_master 作库,经 104 定值段写 r 后写 b 并
  读回校验,是所有写入的唯一入口。

adc_task 的 meas: 心跳行精度提到 4 位小数,标定读数需要。

文档:新增《采样数据校正全流程》(端到端导航)与《ADC 两点标定执行
流程》(台架执行卡,含 CALDATA 可填表);ADC通道映射说明新增 §7.3 台
架实测结果(UA 554.687914、IA 29.634259,出厂默认值保持不变);配置
文件设计说明新增解析器契约 v1.19;采集与算法层设计说明 §13 系列与
README 索引同步。

台架实测:UA r=554.687914(出厂 1000.0 偏大 1.80 倍,根因是接线分压
使 PT 一次侧只拿到一半电压,实测与参数算定 606.06 只差 8.5%)、IA
r=29.634259(与出厂 29.4118 只差 0.76%,反证链路未算错)。UN 按用户
裁定本轮不标定,保护闭锁(vl=0x11)是预期行为,未伪造 VALID。

同时入库 .dsh/roles 角色定义(原被 .gitignore 挡住)。
2026-11-13 01:35:58 +08:00