Skip to content

refactor: enforce unidirectional layer deps (core ← pkg ← cmd) - #77

Merged
M09Ic merged 6 commits into
masterfrom
refactor/unidirectional-layer-deps
Jul 28, 2026
Merged

refactor: enforce unidirectional layer deps (core ← pkg ← cmd)#77
M09Ic merged 6 commits into
masterfrom
refactor/unidirectional-layer-deps

Conversation

@M09Ic

@M09Ic M09Ic commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

背景

aiscan 包命名暗示分层规则:core/ 是内核,pkg/ 是功能实现,cmd/ 是入口。但实际存在大量 Z 字形跨层依赖(core 导入 pkg,pkg 又导入 core),导致命名完全失去意义,也让 agent 内核无法独立编译。

改动

包移动

  • core/runner → pkg/runner(组合根属于 pkg 层,不是 core)
  • core/transport → pkg/transport(同理)
  • pkg/agent/truncate → core/truncate(纯工具,core 使用)
  • pkg/util → core/util
  • pkg/aop → core/aop(事件 backbone,core/output 使用)
  • pkg/telemetry → core/telemetry

新增

  • core/provider:从 pkg/agent/provider 提取 ProviderConfig + InferFromBaseURL,使 core/config 不再依赖 pkg/agent

删除

  • core/harness:零 importer 的死代码

修复

  • AOP fixture session.end.data.stop → reason,修复 JSON Schema 验证失败
  • bash.RunForeground PTY drain 竞态防御性检测(0 字节 + Completed 时写 warn)

结果

core/ 对 pkg/ 依赖归零。依赖方向严格为:cmd → pkg/runner → pkg/* → core/*

测试

  • go build ./... 通过(含 -tags full)
  • go test ./core/... ./pkg/commands/... ./pkg/agent/... ./pkg/runner/... ./pkg/web/... 全部通过

Generated with Claude Code

@M09Ic
M09Ic force-pushed the refactor/unidirectional-layer-deps branch from 5006781 to fa0e668 Compare July 28, 2026 08:09
@M09Ic
M09Ic changed the base branch from master to fix/web-runtime-integrity July 28, 2026 08:10
@M09Ic
M09Ic force-pushed the fix/web-runtime-integrity branch from e7a6aee to 63479ba Compare July 28, 2026 08:13
@M09Ic
M09Ic force-pushed the refactor/unidirectional-layer-deps branch from fa0e668 to 04e7ade Compare July 28, 2026 08:14
@M09Ic
M09Ic changed the base branch from fix/web-runtime-integrity to master July 28, 2026 08:14
@M09Ic
M09Ic merged commit 1361fbd into master Jul 28, 2026
13 checks passed
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.

1 participant