Skip to content

feat(alignment,rfc): add goal-oriented multi-agent peer coordination RFC and M0 projection - #9502

Open
loopx-agent wants to merge 1 commit into
mainfrom
codex/goal-oriented-multi-agent-coordination-m0-20261127
Open

loopx-agent wants to merge 1 commit into
mainfrom
codex/goal-oriented-multi-agent-coordination-m0-20261127

Conversation

@loopx-agent

@loopx-agent loopx-agent commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Establishes LoopX's Goal-Oriented Multi-Agent Peer Coordination design (RFC EN / RFC 中文) and lands its minimal, read-only M0 control-plane slice so specialist Agents sharing one Goal (for example, simplification/refactoring vs. independent verification/benchmarking) can discover each other's active lanes, collision risks, and validation demand directly through shared_goal_alignment_v0 without human relaying.

Architecture & Design Highlights (RFC goal-oriented-multi-agent-coordination-v0)

  • Zero new database / authority: Reuses canonical Todos (file_v0 / sqlite_v0), task leases, shared_goal_alignment_v0, peer_agent_directory_v0, and manager-inbox.
  • Single TypeScript semantic owner: loopx/control_plane/goals/peer_coordination.ts owns matching, priority sorting, deterministic opportunity_id generation (sha256), deduplication, and bounded caps (MAX_PEER_FRONTIER_ITEMS=12, MAX_COLLABORATION_OPPORTUNITIES=8), always marking outputs grants_authority: false and read_only: true.
  • Clear M0–M3 separation: M0 ships read-only pull projection; M1 (<=400 B cursor-deduped Turn-envelope digest), M2 (cooldown-gated bilateral manager-inbox offer/decline), and M3 (host-neutral live route observer profiles) stay cleanly gated behind acceptance criteria.

M0 Changes & Review Fixes (43f0021102)

  • loopx/control_plane/goals/peer_coordination.ts & loopx/control_plane/work_items/task_lease_acquire_decision.ts: Deterministic projectPeerCoordination computing peer_frontiers and collaboration_opportunities across 4 closed kinds (shared_target_collision_risk, peer_verification_needed, peer_unleased_lane_attention, shared_domain_synergy), reusing leaseWriteRepository, comparisonWriteScopes, schedulingScopeRoot, and schedulingScopePairOverlaps.
    • Evaluates peer_verification_needed and peer_unleased_lane_attention independently in idle-caller discovery (PRRT_kwDOStEbEs68g_qG).
    • Uses pre-indexed target_key / task_domain / task_repository / verifier / write-scope prefix-trie lookups and kind-phased cap pruning (MAX_COLLABORATION_OPPORTUNITIES=8) aligned with the exact peerRankByTodo / peer_todo_id / caller_todo_id / opportunity_id total order (PRRT_kwDOStEbEs68kBRs), cutting 160x160 runtime from ~150–165 ms to 0.755–1.09 ms while preserving bit-for-bit parity against the exhaustive reference reducer.
  • loopx/control_plane/goals/shared_goal_work.ts: Extracts caller_lanes (preserving fail-closed caller lease validation) and peer_frontiers using activeLeaseDetails(lease, now) and parseKnownTaskLease(lease): cleanly separates absent leases (false), interpretable task_lease_v0 released/expired records (false), active validated leases (true), and uninterpretable/corrupted peer leases (lease_epoch=0, invalid/missing owner, unrecognized schema_version, unknown/missing status, invalid timestamps -> null without emitting false peer_unleased_lane_attention) (PRRT_kwDOStEbEs68g_qC, PRRT_kwDOStEbEs68kBRn).
  • loopx/control_plane/goals/shared_goal_alignment.ts: Additively projects peer_frontiers and collaboration_opportunities while keeping full backward compatibility with legacy requests that omit them.
  • loopx/control_plane/goals/shared_goal_work_source.py & shared_goal_alignment.py: Forwards canonical Todo lane fields (priority, task_domain, task_repository, target_key, required_write_scopes, completion_validation_required) and validates the new response fields.
  • loopx/cli_commands/shared_goal_alignment.py: Surfaces peer_frontiers and collaboration_opportunities in loopx shared-goal-alignment JSON & Markdown output.
  • Tests & Docs: Bilingual RFC + docs/architecture/rfcs/README.md + regenerated STATUS.md / STATUS.zh-CN.md; TS unit tests (including 50-trial randomized differential oracle parity across globs/ties + 160x160 bounded latency parity), File+SQLite canonical snapshot tests, and CLI regression tests.

Local Verification (rebased onto origin/main@6915df67db, exact head 43f00211020157741baffcf806c16d5a99c67212, zero CI waiting)

  • npm run typecheck:control-plane: passed
  • node --experimental-strip-types --test tests/control_plane_ts/{shared_goal_alignment,shared_goal_work,task_lease_acquire_decision,goal_amendment_authority,goal_amendment_proposal}.test.ts: 95 passed, 0 failed, 4 skipped (PostgreSQL authority tests require local PG server; shared_goal_alignment.test.ts: 34/34 passed, 0 skipped)
  • 160x160 projectPeerCoordination wall-time measurement: 0.755–1.09 ms post-edit vs 149.52–165.36 ms pre-edit baseline
  • uv run --extra test python -m pytest -n 4 tests/control_plane/test_shared_goal_alignment.py tests/control_plane/test_shared_goal_alignment_cli.py tests/canary/test_maintainability_ratchet.py tests/architecture/ -q: 1997 passed, 0 failed (78 File+SQLite alignment/CLI/ratchet + 1919 architecture tests)
  • uv run --extra test ruff check (5 Python files) & uv run --extra test mypy --follow-imports=silent (2 touched control-plane Python modules): passed (pre-existing _SubParsersAction type-arg annotation at untouched shared_goal_alignment.py:122 unchanged)
  • scripts/generate_rfc_status_index.py --check & scripts/check_rfc_bilingual.py --base origin/main --head HEAD: passed
  • examples/semantic-vocabulary-drift-smoke.py (34/34 vocabularies) & examples/control_plane/control-plane-maintainability-ratchet-smoke.py (0 unreviewed/regressions): passed
  • loopx check --scan-path ... (all 15 changed files): ok: true, errors: 0, warnings: 0
  • Change-Quality Qualification: receipt cqr_99c8d82913c4c2b0ad54 (decision: "pass", receipt_valid: true, blocking: false, scope_fingerprint: "99c8d82913c4c2b0ad54161898c098e9458ffe6269fcdf052247148afdf934db")
  • loopx canary premerge --from-git-diff --git-diff-base origin/main --tier standard --goal-id personal-loopx-maintenance: gate.status="passed", merge_gate_passed=true, 4/4 direct + 1/1 py_compile + 10/10 catalog canaries + 8/8 risk-profile smokes + 1/1 public boundary (0 failures, 0 manual holds)

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh

Request changes conclusion (author-owned PR; GitHub blocks formal self-review)

[P2] 损坏的 Peer lease epoch 被显示为活跃。File 与 SQLite 的 CLI 都把持久 Peer 租约 epoch=0 返回为 lease_active=true;相同记录绑定到调用方时,基线与当前头都拒绝。RFC 要求损坏的 Peer 记录降级为 null。活跃标记可能让调用方跳过核对已损坏的租约。 沿用调用方同一租约记录校验,验证 owner 和 epoch 后再返回 true,校验失败的 Peer 项返回 null。 源码

[P2] 空闲调用时丢失同一 P0 Peer 的无租约提醒。在两种 canonical 存储上,该 Peer 的 lease_active=false 且声明待验证。只有一个 Peer,未触及输出上限,CLI 仍只返回 peer_verification_needed。空闲分支的 else if 屏蔽了 peer_unleased_lane_attention,而有调用方通道时两种机会可以并存。 分别计算两种机会再使用统一排序及上限。若这是预期的互斥策略,请在中英文 RFC 中写明并提供同一双命中用例。 源码

动机 / Motivation

给同一 Goal 的 Peer 发现重叠工作和独立验证需求,保留只读与现有执行门禁。 基线 CLI 给出进展通道计数和与调用方有关的冲突,两个协同数组属于此次新增。 使用共享 Goal 对齐视图规划后续工作的 Peer 和维护者。

调用方可能据租约活跃状态决定先避让还是先核对,错误状态会影响下一步。 同一批 canonical 记录分别通过 File 和 SQLite 的真实 CLI 读取。已有字段逐项相等,读取前后 provider revision、Todo/租约和磁盘持久内容相同。相邻写域触发碰撞提示,外部仓库的同名目标没有误配。重复读回机会 ID 一致,15 条输入输出 12 条 Peer 前沿与 8 条机会,机会的 grants_authority 均为 false。 本地 TypeScript alignment/amendment 在基线 74 项、候选 76 项通过。候选 Python alignment/CLI/amendment 100 项通过,双语 RFC diff 校验通过。独立 CLI 覆盖每后端 6 个场景。 证据来自隔离 File/SQLite 与合成快照。M1–M3、现有部署及远端 CI 未验证。 基线契约

改动思路 / Approach

该改动沿用 canonical Todo/lease → Python 快照适配 → TypeScript 对齐 → CLI JSON/Markdown。沿用 shared goal alignment 和既有仓库、写域重合规则,无需引入新存储或第二个权限检查点。 正向读路径复用 canonical 快照。Peer 分支只检查状态和到期时间,漏掉调用方已验证的记录字段。空闲分支则把可同时为真的两个条件做成互斥。 把读取活跃租约所需的事实校验共用,移除 Peer 和 caller 的不一致。机会排序和上限保留在一个归约器内。

具体改动 / Changes

精确提交 e9e8b4b,本次对照目标 50b4cc9。14 个文件 +1138/−26,新增逻辑主要集中在 297 行匹配器,双语 RFC 与回归夹具占其余大头。

关键代码讲解

  • peerLeaseActive。目前的 Peer 活跃判断只调用 leaseIsActive,缺少 epoch 健全性。 源码

  • projectPeerCoordination。由同一快照构造两组只读数组。空闲分支目前只保留其中一类双命中机会。 源码

  • projectPeerCoordination 调用。将匹配器接入现有对齐协议。 源码

  • render_shared_goal_alignment_markdown。将数组机械渲染为终端摘要。 源码

  • m0-readonly-advisory-correctness(partial)。损坏 Peer 租约投影为 null,自身损坏沿原边界拒绝,四类机会按可观察输入决定,均只读。

对主干的风险 / Risks

File 和 SQLite 都把有效期未到、但 epoch 为 0 的 Peer 租约投影为 lease_active=true;同样的损坏记录属于调用方时,两版本 CLI 均退出 1 并给出 lease epoch must be a positive integer。两后端都能把 Peer 的非法到期时间正确降级为 null。另外,空闲调用方遇到同时无租约和待独立验证的 P0 Peer,只收到验证机会,遗漏了 RFC 同样定义的无租约提醒。 故障恢复信息会影响 Peer 对是否需要核对或避让的判断。修复后仅重跑定向回归即可区分。 复用租约 owner 与 epoch 的现有校验,将校验失败的 Peer 观察降级为 null;为无活动调用方分别计算独立验证与无租约,沿同一排序及上限裁剪。若协议要让二者互斥,应在双语 RFC 明确优先规则并调整验收。

我的整体评价 / Verdict

REQUEST_CHANGES。 请修复两个与 M0 双语契约不一致的分支。两种后端的旧字段和持久零写对照已通过。 先修正提供给 Peer 用来决定下一步的事实,再继续 M1 的持久摘要工作。

English verdict: REQUEST_CHANGES at e9e8b4b. The File and SQLite CLI trials exposed two M0 contract misses: invalid peer lease epochs read as active, and idle dual-match discovery drops the unleased-lane advisory. Existing fields and durable state remained stable.

@loopx-agent
loopx-agent force-pushed the codex/goal-oriented-multi-agent-coordination-m0-20261127 branch from e9e8b4b to 5cca062 Compare November 26, 2026 21:08

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh

Request changes conclusion (author-owned PR; GitHub blocks formal self-review)

[P2] 无法识别的租约版本被当成未租用。File 与 SQLite 的真实 shared-goal-alignment 查询都给出 lease_active=false 和 peer_unleased_lane_attention。M0 的三态契约要求无法解释的记录为 null,此时不能产生“未租用”的建议。相同 fixture 换回已支持的 schema 后正常显示为 true。 在判断活跃性前区分缺失、可解析的已释放或过期记录、不可解释的租约记录。继续用原有 task-lease codec 判断已知记录,并让未知输入只降级该 peer。 源码

[P3] 输出上限约束不到配对计算。隔离 TypeScript 对照里,160 个 caller 与 160 个 peer 只返回 8 条机会,候选 reducer 的三次耗时为 123–131 ms。基线同调用约 0.2 ms。范围仅为同进程合成 reducer 计时,尚未测量真实 CLI 延时。 在扩大消费范围前,核验实际大队列成本,使配对、候选保留和排序与输出目标一致,同时维持目前的确定性优先级。 源码

动机 / Motivation

让同一 Goal 的 Agent 通过已有 alignment 读取彼此推进中的工作,发现碰撞和验证需求。 基线主要提供同伴计数和已绑定的 Todo ID,调用方需另读工作详情才能判断交集。 调用 shared-goal-alignment 或 goal-alignment 的同 Goal peers,以及复用其工作来源的 amendment 调用方。

错误的空闲位会把不可验证的任务放入协调建议,造成不必要的协调并削弱碰撞提示可靠性。 此前发现的 epoch=0 降级和闲置调用者双建议已由 File/SQLite 用例覆盖。已支持的活跃 lease 在两 provider 均正常输出 true。 精确基线的公开 alignment CLI 与 authority 测试 48 项通过,候选 60 项通过。候选 amendment CLI 和维护性共 36 项通过,TypeScript 93 项通过、4 项跳过,typecheck、双语 RFC diff 与索引校验通过。File/SQLite 反例各核对了有效与未知版本。 独立验证范围是精确源码、合成快照,以及 File/SQLite 原生 CLI。PostgreSQL 用例按自身环境条件跳过。M0 交付是 CLI 读取,后续 Turn digest、Inbox 协调、前端读取路径及真实大队列耗时需要相应验收。 验收契约

改动思路 / Approach

该改动沿用 loopx shared-goal-alignment → canonical Todo/lease snapshot → sharedGoalWorkFacts → projectPeerCoordination → JSON/Markdown。复用 canonical provider、租约活动性、仓库与 scope overlap 的现有 owner,Python 负责事实转发,使用同一投影支持 JSON 与 Markdown。 新增的 peer 三态需同时表达 true、false、null。当前活动性检查先把未知 schema 当作非 active,阻止了 peer 异常降级。 保持已有同 Goal 只读命令与现有 lease codec,先在该读模型区分未知和确定失效的 lease。

具体改动 / Changes

精确提交 5cca062,本次对照目标 6915df6。14 文件 +1548/-26。包括中英 RFC、单个 TS 匹配 reducer、canonical 源转发、CLI 展示及 File/SQLite 与 TS 回归。

关键代码讲解

  • read_shared_goal_work_source。以同一 provider revision 读 Todo 与 lease 快照。 源码

  • peerLeaseActive。把每个 peer 的租约投影为三态。 源码

  • projectPeerCoordination。匹配已读事实,确定建议排序与上限。 源码

  • projectSharedGoalAlignment。解码请求、保留现有字段及附加只读建议。 源码

  • unknown-peer-lease-remains-unknown(not_met)。无法解释的 peer lease 要保持 lease_active=null,不能被当作已知空闲。

对主干的风险 / Risks

同一合法活跃记录正常为 true。仅改为无法识别的 schema 后,File 与 SQLite 都误判为 false,并发出未租用建议。 错误的空闲 advisory 已在两个 provider 复现。合成大队列另暴露出有界输出之后的配对开销。 在现有活动性语义前先区分无记录和未支持的 schema,保持可验证的 false 与 unknown 分离。

语义与 CI 对齐

同一合法活跃记录正常为 true。仅改为无法识别的 schema 后,File 与 SQLite 都误判为 false,并发出未租用建议。 在现有活动性语义前先区分无记录和未支持的 schema,保持可验证的 false 与 unknown 分离。

我的整体评价 / Verdict

REQUEST_CHANGES。 请先保持不可解释 lease 的不确定性。此前两个修复均由当前入口回归覆盖。 同伴发现可减少重复探查。收益取决于对租约不确定性的诚实表达。

English verdict: REQUEST_CHANGES at 5cca062. The exact head fixes the previous two counterexamples, but both canonical providers still translate an unrecognized peer lease into an unleased advisory. Preserve the unknown state before shipping M0.

…RFC and M0 projection

Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
@loopx-agent
loopx-agent force-pushed the codex/goal-oriented-multi-agent-coordination-m0-20261127 branch from 5cca062 to 43f0021 Compare November 26, 2026 21:49

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh

Approval conclusion (author-owned PR; GitHub blocks formal self-approval)

动机 / Motivation

让同一 Goal 的 Agent 通过已有 alignment 读取彼此推进中的工作,发现碰撞和验证需求。 基线主要提供同伴计数和已绑定的 Todo ID,调用方需另读工作详情才能判断交集。 调用 shared-goal-alignment 或 goal-alignment 的同 Goal peers,以及复用其工作来源的 amendment 调用方。

这次补上的是已实际出现的未知租约误报。按规范保留 null 能避免从同伴数据推断出可接手的任务。 File/SQLite 中已知活动租约为 true,无未租用建议。未知租约为 null,回应依然 read_only。160×160 相同范围合成 reducer 返回 8 条,本机三次 1.4–2.1 ms,上一候选同构输入的三次结果为 123–131 ms。 候选原生 alignment 与 provider 回归 64 项通过,amendment 定向用例通过。TypeScript 141 项通过、4 项跳过。typecheck、双语 RFC diff 和 RFC 索引通过。基线保留 read_only 并没有两组新增投影。 证据涵盖固定源码、真实 File/SQLite CLI 和合成 TS 对照。4 个 PostgreSQL 条件用例跳过。合成计时不覆盖真实大 Goal CLI I/O,M1–M3、安装和远程 CI 未纳入本次核验。 验收契约

改动思路 / Approach

该改动沿用 loopx shared-goal-alignment → canonical Todo/lease snapshot → sharedGoalWorkFacts → projectPeerCoordination → JSON/Markdown。Python 从同一 canonical provider 快照转发事实。TypeScript 保留决策和排序,目录前缀索引复用原有 scope 匹配,覆盖预期定序。 先验证已知 lease 格式,再判定是否活跃。索引只筛可能匹配的条目,最终 scope 匹配仍调用租约已有语义。输出按既定优先级截断。 复用已有的 canonical provider 与 scope 判定。按仓库、目标、域和路径做一次预计算,对前 8 项保留原有效信号和定序。

具体改动 / Changes

精确提交 43f0021,本次对照目标 6915df6。15 文件 +2376/-29。相较上一审,生产变化集中在 peer 三态编解码、基于现有 scope 语义的匹配索引和按排序截断,另有针对性回归。

关键代码讲解

  • read_shared_goal_work_source。以同一 provider revision 读 Todo 与 lease 快照。 源码

  • parseKnownTaskLease。先校验 lease 版本与字段,再区分活动、失效和未知。 源码

  • projectPeerCoordination。复用范围匹配语义并按既定偏序截断建议。 源码

  • projectSharedGoalAlignment。保留已有属性并增加只读协调投影。 源码

  • unknown-peer-lease-remains-unknown(implemented)。未知或损坏 peer lease 保持 null,caller 的执行许可不从 advisory 推导,机会排序和数量保持 RFC 定义。

对主干的风险 / Risks

File/SQLite 中未知 schema 和损坏 epoch 均不会发出未租用建议。Caller 的损坏 epoch 仍报错。额外 262,450 个合成 scope 对照未见过滤遗漏。 大 Goal 的真实 I/O 延迟与候选分布没有形成性能验收,M0 建议上限的观测来自同机合成数据。 先区分缺失、已知失效和无法解释的租约。索引只提前排除可证明不相交的候选,并保留已有规范匹配作为最终判断。

我的整体评价 / Verdict

APPROVE。 此前的租约 P2 已在两种持久化后端关闭。上一轮索引成本疑虑在同构合成对照中显著缓解。按 RFC 的 M0 只读边界通过。 协作建议可以帮助发现重复工作,实际 claim、写入与授权仍由原有入口独立决定。

English verdict: APPROVE at 43f0021. The exact head preserves unknown peer lease state on File and SQLite, keeps existing caller rejection, and matches the exhaustive scope oracle and prior ordering. This approves the M0 read projection. Large-goal CLI I/O and later milestones were outside the verified scope.

This branch has not been deployed

No deployments
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