2 Commits

Author SHA1 Message Date
ffcfaf46e2 chore(version): release/v1.3.x 路牌推到 1.3.9(本版内容:驻留子轮次计数) 2026-09-13 15:41:03 +08:00
cd88b2dfe5 fix(resident): 子的「轮次」一直显示 0 —— info() 根本没填 Rounds
现象(用户线上联调实录 + 我复验):父侧 `resident_agents` 列出 `输入ch=[timer] 轮次=0
处理表=2` —— **处理表已有两条记录,轮次却是 0**,自相矛盾,容易被读成"子没干活"。

根因:`residentChild.info()` 构造 `ResidentInfo` 时**从来没有填过 Rounds 字段**
(结构体里有这个字段,于是永远输出零值),不是计数漏加。

改法:`Rounds = 已执行轮次数`(调度器执行计数,单调不减)。新增 `Agent.roundsExecuted()`
并写明为什么**不能**用 inputch 处理表条数当轮次:那张表记的是"当前上下文窗口内"的轮次,
压缩会清空(设计 §8.3)—— 用它会让父看到轮次倒退。

判据:inputch 路由测试里补一条断言 —— 子处理完输入后 `info().Rounds > 0`。
2026-09-13 15:41:02 +08:00
4 changed files with 26 additions and 1 deletions

View File

@ -34,6 +34,11 @@ func TestResident_InputchRoutingIsExclusive(t *testing.T) {
if got := parent.DumpScheduler().Stats.Enqueued; got != before {
t.Fatalf("划给子的 inputch父不应再入队before=%d after=%d", before, got)
}
// 轮次必须真的涨:此前 info() 根本没填 Rounds ⇒ 父永远读到 0
// (现场:子处理表已有 2 条,轮次却显示 0被误判成"子没干活")。
if got := parent.residents["r-route"].info().Rounds; got <= 0 {
t.Fatalf("子处理的轮次应 > 0实际 %d", got)
}
}
// 归属到一个不存在(或已销毁)的 agent 时**不吞输入**:父兜底处理。

View File

@ -504,6 +504,13 @@ func (rc *residentChild) info() ResidentInfo {
ID: rc.id, State: state, InputChs: append([]string(nil), rc.inputChs...),
AllowedOutputs: append([]string(nil), rc.allowed...),
ContextFull: full, CreatedAt: rc.createdAt, TableSize: len(table),
// Rounds = 子**已执行的轮次数**(调度器的执行计数,单调不减)。
//
// 此前这里根本没填这个字段 ⇒ 父看到的永远是 `轮次=0`,与"处理表已有 N 条"
// 自相矛盾(现场:子明明处理了两轮,父读到 rounds=0误判成"子没干活")。
// 注意它**不等于** len(table):处理表记的是"当前上下文窗口内"的轮次,
// 压缩会清空§8.3),所以窗口内的条数会被重置,而轮次总数不会。
Rounds: rc.agent.roundsExecuted(),
}
if len(table) > 0 {
info.Table = table

View File

@ -745,6 +745,18 @@ func newKernelInterruptTask(evt *agentIO.InputEvent) *Task {
}
// DumpScheduler 返回调度器的原子快照(供状态页/测试断言)。
// roundsExecuted 返回本 agent 已执行的轮次数(供驻留子状态面展示)。
//
// 一轮 = 一次被执行的输入(排队与中断都算)。为什么不用 inputch 处理表的条数:
// 那张表记的是"当前上下文窗口内"的轮次,压缩会清空(设计 §8.3)——
// 拿它当轮次会让父看到轮次倒退。
func (a *Agent) roundsExecuted() int {
if a.sched == nil {
return 0
}
return int(a.DumpScheduler().Stats.Executed)
}
func (a *Agent) DumpScheduler() SchedulerSnapshot {
if a.sched == nil {
return SchedulerSnapshot{}

View File

@ -28,6 +28,7 @@ var (
//
// ❗main 上此值始终是**下一个未发布中版本**,不随 patch 发布变动
//(见 docs/git-branching.md §2.1);已发布的版本号看对应的 release/vX.Y.x 与 tag。
// 1.3.9:驻留子的「轮次」不再是恒 0info() 此前没填 Rounds
// 1.3.8inputch 划给子后输入只流向子(补上"进内核之前"的输入路由)。
// 1.3.7:驻留子继承父的输出通道(此前子侧 childIO 空壳 ⇒ 子不会发消息)。
// 1.3.6:人格文本不再在播种时固化版本 + 存量实例一次性去版本化(生产实例
@ -35,7 +36,7 @@ var (
// 1.3.5:系统提示词(人格卡)支持版本占位符 —— 人格卡是配置项,写死版本号
// 会随发版说谎(线上写 v1.0.3、内核 1.3.xagent 就自报 1.0.3)。
// 支持 {{kernel_version}} / {{kernel_commit}} / {{sdk_version}}。
Version = "1.3.8"
Version = "1.3.9"
// Commit 是构建时的 Git commit hash。
Commit = "unknown"