feat(scheduler): M4 临界区显式化 + 清掉被 pendingInterrupts 取代的 interceptCh

设计依据 docs/zh/input-scheduler-design.md §4.3、§11.1(P5/P6)。

- 临界区语义显式化:让位检查**只在 step 之间**做,执行中的 step
  (工具 RPC / ONNX / CAS 落盘)天然不可抢占;_consolidation_ 整任务
  经 inCriticalSection() 判为不可抢占(它直接改图库)
- 删除 interceptCh 与 drainInterrupts:M3b 起中断一律走 pendingInterrupts,
  旧的「同行注入 + 三处 drain + 批次放弃」已无写入者,属死代码
- 新增 scheduler_critical_test.go 3 项:
  P5/P6 工具执行中 arm 了让位信号也不得挂起、必须等工具返回后的安全点;
  _consolidation_ 判为临界区;无抢占时同批工具必须全部执行(新语义回归)
- 验收:agent 全量 + -race;全仓 build/vet 通过
This commit is contained in:
JianFeeeee
2026-09-13 00:34:39 +08:00
parent c69a1f11af
commit 7565248f61
5 changed files with 151 additions and 109 deletions

View File

@ -110,9 +110,6 @@ type Agent struct {
// childSeq 给完成的任务排个序,用于有界淘汰。
childSeq int64
// 高优先级打断通道interceptLoop 注入process() 在工具循环轮次间非阻塞读取
interceptCh chan *agentIO.InputEvent
// 输入调度器:就绪队列、任务抽象与快照(见 scheduler.go
// M2 起取代 eventLoop 的隐式 channel 排队。
sched *scheduler
@ -312,7 +309,6 @@ func New(cfg AgentConfig) *Agent {
eventBus: cfg.EventBus,
selfInputCh: make(chan selfInputMsg, 64),
childTasks: make(map[string]*childTaskState),
interceptCh: make(chan *agentIO.InputEvent, 64),
sched: newScheduler(256),
priorityLookup: cfg.PriorityLookup,
pluginHealth: newPluginHealthTracker(),