Skip to content

feat(feedback): scoped RCP receipt feedback + minimal context router - #24

Merged
wefio merged 2 commits into
mainfrom
feat/context-feedback-loop
Sep 5, 2026
Merged

feat(feedback): scoped RCP receipt feedback + minimal context router#24
wefio merged 2 commits into
mainfrom
feat/context-feedback-loop

Conversation

@wefio

@wefio wefio commented Sep 5, 2026

Copy link
Copy Markdown
Owner

变更描述

What(改了什么):
实现 agent-convergence-feedback-design 的第一段可验证代码闭环:把 RCP 的已验证收据通过新的、仅连接既有 daemon 的 nmg session observe 命令投递到指定会话/任务帧的临时 AG;同时提供隔离的 132 参数 ContextRouter 数值原语。

Why(为什么改 / 解决什么问题):
设计缺口 #1「单一事件总线不存在」的具体前半段——reconcile 结果此前无法回流到会话 AG。本 PR 让真实失败能成为有界、可归属的工作记忆反馈;并把「仅路由、无神经专家」的候选做成可在 autodiff 上受训的数值起点。不把文档合并当作整体完成:事件/样本管线、特征语义、四执行器、结果接纳与默认激活门仍全部未实现。

Changes(关键改动点,按文件或模块列出):

  • src/rcp/session-feedback.ts(新):收据→有界 tool_observation,绑定 receipt/contract/session/task 身份,越界失败收据仍可反馈但不可伪造成成功,诊断内容裁剪到预算内。
  • src/rcp/cli/main.tsreconcile ... --nmg optional --session-id <id> --task-frame-id <id> 显式选用会话反馈;经随包 bin/nmg.mjs session observe 通讯,不导入 NMG 内部、不启停 daemon。
  • src/cli/{commands,main}.ts:新增 nmg session observe 命令,仅要求已运行兼容 daemon,缺失时失败关闭而不落库。
  • src/rcp/receipt.ts:区分「收据有效」与「任务通过」;scope 越界只否决 verified 而非使收据无效。
  • src/lab/context-router.ts(新):32→4 线性 132 参数 action-value 原语,允许动作门控、真实 ε 采样、实测动作回归、权重导出。
  • 测试 + owning 文档(详见下方证据;completion-audit.md 明确标记 partial,不关闭工单 10)。

完成检查项

本地质量检查

  • npm run verify:static 通过(build / package:check / check / check:lock / lint / format:check / docs:check / agent:context:check / complexity:gate / verify:packages)
  • 定向 test:product 通过:tests/rcp、session-observe、commands、http-boundary、context-router、agent-verify、complexity-gate(50 项;隔离 embedding 环境变量)
  • 未提交可再生产物(dist/、lib/、generated prompts)
  • 新方法复杂度 ≤15(complexity:gate ok,无超出基线)

RCP

  • 首个实质写入前已在 repo-development 黑板登记 in-flight goal(1788586790890_000024),工单 10 已 claim
  • npm run agent:verify -- <改动路径>:build/docs:check/verify:static/check/package:check 通过;test:product 仅剩与本改动无关的 Windows EPERM 临时目录清理抖动(archive-staging,独立复现与本改动无关)
  • 只提交本 PR 拥有的 13 个文件

CI 完成确认

  • CI 全绿经 RCP 观察确认:All checks passed 与全部 job 均为 SUCCESS

说明:本地全量 test:product 曾因继承的 NMG_EMBED_PROVIDER(hybrid 模式)与 Windows 临时目录 EPERM 抖动失败,二者均已在不含本改动的基线/定向重跑中复现,属环境问题而非本改动。

Close the first half of the convergence design (docs/design/agent-convergence-feedback-design.md)
without claiming the overall task complete: a validated RCP receipt becomes a
bounded temporary tool observation in an explicitly named session/task frame,
and a 132-parameter action-value primitive exists behind the autodiff substrate.

The design task stays open: unified event/sample collection, versioned feature
semantics, the four executor interfaces, validated outcome admission, and all
default-activation gates are still unimplemented. These tests prove only their
exercised mechanisms, not natural task success or intervention benefit.

Why this shape:
- Reconcile drift events never reached session AG. Add explicit opt-in delivery
  through a new resident-only `nmg session observe` CLI (RCP never imports NMG
  internals or starts/stops its daemon; a bounded child bounds outages).
- Failed scope/check receipts used to be unrejectable yet unfedback. Receipt
  validity (structure/hash) and success (verified + scope matched) are now
  separated so real failures stay append-only and visible while forged success
  stays rejected.
- No neural experts or pretrained router transplant. The ContextRouter is an
  isolated observed-action value head: allowed-action gating, real epsilon
  sampling with propensity, detached weights, and analytic-gradients coverage
  in both interpreted and compiled autodiff.

Evidence (run with embedding env removed; Windows EPERM temp-dir flakes and
inherited NMG_EMBED_* were reproduced independently of this change):
- 50 targeted tests pass across tests/rcp, tests/cli/session-observe,
  tests/core/context-router, including real failing npm verification into AG,
  HTTP delivery, duplicate projection, session isolation, scope-failure
  feedback, bounded diagnostics, and compiled finite-difference gradients.
- verify:static, build, docs:check and complexity:gate pass.
Add a short duration hint so a submitter observes via forge-status once the
checks finish (~90s) instead of polling on a fixed schedule.
@wefio
wefio merged commit 61ce84d into main Sep 5, 2026
7 checks passed
@wefio
wefio deleted the feat/context-feedback-loop branch September 5, 2026 15:49
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