Skip to content

五层架构重构:skill 机读化 + 门-状态耦合 + 归属强制 + 双编排形态#2

Open
Jinchen-Yang wants to merge 4 commits into
mainfrom
claude/agent-skill-architecture-2wnkhf
Open

五层架构重构:skill 机读化 + 门-状态耦合 + 归属强制 + 双编排形态#2
Jinchen-Yang wants to merge 4 commits into
mainfrom
claude/agent-skill-architecture-2wnkhf

Conversation

@Jinchen-Yang

@Jinchen-Yang Jinchen-Yang commented Jun 29, 2026

Copy link
Copy Markdown
Owner

这是什么

回应"这套 skill 系统分层逻辑不对、没设计好多 agent 交互层/文件层控制/执行层/用户交互层/校验层"的批评。把当前"活在散文和约定里"的四层从约定升级为结构化 + 强制(执行层本就扎实,保留)。ARCHITECTURE.md 是设计文档,P1–P5 已全部实装,sh tools/selftest.sh 11 步全绿。

五层落地

改动
执行层 保留 tools/ 无 LLM 确定性脚本;门脚本加 --report 与机读报告
校验层(门→状态) gatelib.py 共享判据;pinmux/power/protocol --reportdesign/gates/<gate>.yaml;gate_report.py(如 compile);board.py done 校验门 PASS+签字 approved,未过 exit 3(--force 留痕);gate_check.py 与 done 同源
多 agent 层 双形态共用同一 DAG/门/签字:/elec-design(3 机 git 协同)+ 新增 /elec-orchestrate(单人单会话子代理 fan-out);.elec-mode 切换
文件控制层 .github/CODEOWNERS + tools/check_ownership.py(按 .elec-lane 拦越界)+ .githooks/pre-commit(归属+pinmap/protocol 契约门);bootstrap.shcore.hooksPath
用户交互层 人工门改用 AskUserQuestion 取确认 → tools/signoff.py approvedesign/signoffs.yaml,跳门=过门的隐患被堵

能力机读化(P1)

11 个 SKILL.md frontmatter 加 lane/needs/reads/writes/gate/signoff/allowed-tools,正文 lane/needs 散文降为指向 frontmatter 的一行——兑现 CLAUDE.md "frontmatter 标 lane/needs" 的承诺,编排器可机读路由。

新增/改动文件

  • 新增工具:tools/gatelib.py gate_check.py gate_report.py signoff.py check_ownership.py
  • 新增:.claude/skills/elec-orchestrate/SKILL.md.github/CODEOWNERS.githooks/pre-commitdesign/gates/
  • 改:board.py(DAG 加 gate/signoff + done 校验)、pinmux_check/power_budget/gen_protocol(--report)、bootstrap.shselftest.sh(扩到 11 步)、11 个 SKILL.md、CLAUDE.md/STATUS.md/ARCHITECTURE.md

自测

sh tools/selftest.sh → 11 步全绿,含新增:门-状态耦合(未签被拒/签后放行)、--report+gate_check(门 PASS 但缺签字正确拒绝)、目录归属(越界拒/合规放)。

决策记录

  • 运行形态:两者都要(分场景)— 已实现团队 + 单人双形态
  • 本轮范围:用户最终要求"不用审,直接改",故从设计稿推进到完整实现
  • 开放项决议见 ARCHITECTURE.md §9(字段名/Agent vs Workflow/hook 接入/校验位置)

🤖 Generated with Claude Code

claude added 2 commits June 29, 2026 12:56
Diagnose current skill system across five layers (execution, validation,
multi-agent, file-control, user-interaction) and propose making the four
weak layers structured/enforced while keeping the solid execution layer.

Covers machine-readable skill frontmatter (lane/needs/reads/writes/gate/
signoff/allowed-tools), gate->state coupling, ownership enforcement, and
two orchestration modes (3-machine git vs single-operator subagents)
sharing one DAG and one set of gates. Includes phased migration path.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CNFvi9VAv3UgvhmqgqBiv2
…e→state, enforced ownership, dual orchestration)

P1 capability metadata: add machine-readable frontmatter to all 11 skills
(lane/needs/reads/writes/gate/signoff/allowed-tools); demote prose lane/needs
to a frontmatter pointer line.

P2 gate→state coupling: shared tools/gatelib.py; pinmux_check/power_budget/
gen_protocol gain --report writing design/gates/<gate>.yaml; generic
tools/gate_report.py (e.g. compile); board.py done now verifies required
gate==PASS and signoff==approved (exit 3, --force leaves a trace);
tools/gate_check.py shares the same gatelib.check_spec verdict.

P3 file-ownership enforcement: .github/CODEOWNERS, tools/check_ownership.py
(blocks out-of-lane writes by .elec-lane), .githooks/pre-commit (ownership +
pinmap/protocol contract gates), bootstrap.sh sets core.hooksPath.

P4 structured sign-off: manual-gate skills now take AskUserQuestion approval
then tools/signoff.py approve writing design/signoffs.yaml.

P5 single-operator orchestration: new /elec-orchestrate fans out subagents in
one session, sharing the same DAG/gates/signoffs as the team-mode /elec-design;
mode selected via .elec-mode.

selftest.sh extended to 11 steps (gate→state, --report+gate_check, ownership);
all green. Docs synced: CLAUDE.md, STATUS.md, ARCHITECTURE.md (marked landed).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CNFvi9VAv3UgvhmqgqBiv2
@Jinchen-Yang Jinchen-Yang changed the title docs: 五层架构 + 双编排形态设计稿 五层架构重构:skill 机读化 + 门-状态耦合 + 归属强制 + 双编排形态 Jun 29, 2026
claude added 2 commits June 29, 2026 17:39
…oard robustness

- gitignore: add .elec-mode (per-machine orchestration mode, must not be committed)
- ownership: treat design/gates/ and design/signoffs.yaml as SHARED coordination
  state (any lane may write its own gate report / sign-off) — resolves the
  conflict where firmware-scaffold (控制 lane) must write design/gates/compile.yaml
  while design/ is otherwise 硬件/lead-owned. CLAUDE.md table updated to match.
- pre-commit: protocol gate now BLOCKS when contracts/protocol.h/.py are out of
  sync with protocol.yaml (asks to git add the regenerated pair) instead of
  silently mutating the working tree.
- board.py: status now surfaces gate/signoff requirements (consistent with list);
  iter_tasks() ignores non-task yaml so a stray file can't crash the board.
- selftest: step 11 also asserts the gates/ shared carve-out; 11 steps green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CNFvi9VAv3UgvhmqgqBiv2
…consistency, CLI guards)

Independent multi-angle review of the branch surfaced real issues; fixes:

- gate freshness (校验层 hole): gate reports now store target_sha (content hash
  of the checked file); gatelib.check_spec rejects a PASS whose target changed
  since the report was written — a stale/unrelated PASS can no longer satisfy
  board.py done. compile gate (dir target) is exempt as before.
- bootstrap.sh: pip install no longer aborts the script under set -e (offline /
  PEP668), so git-hook install + lane reminder always run — enforcement is not
  silently skipped when pip hiccups.
- pre-commit protocol gate: non-destructive. gen_protocol.py gains --out-dir;
  the hook generates into a temp dir and compares against the STAGED blob
  (git show :path) instead of clobbering the working tree and relying on a side
  effect. Verified end-to-end (sync passes, stale .h/.py blocks).
- lane consistency: interconnect/power-design/test-checklist were lane:any but
  write to lead/硬件-owned dirs (contracts/, design/) — a non-lead lane would be
  blocked by the ownership hook. Set lane:lead to match board.py owner; note
  that the reasoning stays model-agnostic (correctness via gates).
- CLI robustness: trailing value-flags (--by/--lane/--note/--detail) no longer
  raise IndexError across board.py/signoff.py/gate_report.py/gate tools.

selftest 11 steps green; targeted tests for stale-gate, --out-dir, and hook
sync/stale all pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CNFvi9VAv3UgvhmqgqBiv2
@Jinchen-Yang
Jinchen-Yang marked this pull request as ready for review June 30, 2026 01:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants