gongzhiyong and Claude Opus 4.8
1288fd19d7
feat(swarm): 协作聚合收敛取代蜂后选优 + sandbox 用 pytest 验证
...
CI / tests (push) Failing after 15m3s
CI / guardrails (push) Failing after 15m3s
按 juejin 协作聚合模型重构收敛(取代 best-of-N 选优):
- 删蜂后选优(queen.py/test-queen.py)
- 新增聚合节点 result_aggregator.py:共享池收集→同文件 LLM/AST 整合→沙箱验证→单次落 main
- 质量驱动闭环:不达标打回迭代(AGGREGATE_ACCEPTANCE_THRESHOLD + MAX_REVIEW_CYCLES)
- agent 停 git 工作分支,产出走 task.result.files 共享池(AGENT_GIT_PUSH_ENABLED 默认 false)
- sandbox_runner 改用 pytest(原生支持 pytest 风格 class),修 stdlib runner 收集失败
- 文档同步重写为协作聚合模型
本地验证:产物仓单分支 main + 三函数完整 + pytest 12/12 pass_rate=100 一次达标。
影响:Swarm 收敛/聚合层;Manager/客户端契约不变(artifact字段/sequence/状态机;契约测试全过)。
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com >
2026-06-20 22:03:00 +08:00
gongzhiyong and Claude Opus 4.8
28a6c618ab
feat(benchmark): SC-10 P_rework 计入评审重开( #10 )
...
CI / tests (push) Failing after 11m18s
CI / guardrails (push) Failing after 11m19s
修正 P_rework 已知低估:此前 ReworkCount 仅由 retry_count>0 派生,漏了 cross_review/queen
质量门的重开(reopen_task 不增 retry_count——是质量决策非失败)。
- cross_review + queen_quality_gate 重开时累计 run.metadata["rework_reopens"]
- run_collector:rework_count = retry 派生 + rework_reopens
测试 test-benchmark-collector/metrics 通过。影响:仅 benchmark 度量(P_rework 更准),不改运行路径。
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com >
2026-06-19 22:51:49 +08:00
gongzhiyong and Claude Opus 4.8
2672a3d4b6
feat(orchestrator): SC-7 蜂后落 main — git push 最优产物( #16 )
...
CI / guardrails (pull_request) Successful in 11s
CI / tests (pull_request) Failing after 11m52s
CI / tests (push) Failing after 11m53s
CI / guardrails (push) Failing after 11m53s
让蜂后选最优后把产物合并到产物仓 main,run 交付一份连贯产物而非 N 个碎片分支:
- create 存 git grant 引用(repo_url + secret_ref,均非明文)到 run.metadata;凭据不存
- queen.promote_to_main:从 secret_ref 现取凭据 → clone base_branch → 写最优产物 → commit → push;
_auth_url 嵌入并 URL-encode 凭据(不入日志);best-effort 不破坏终态
- main.py 终态:winner → promote_to_main → deliverable.promoted_to_main{branch,commit_sha}
- Dockerfile.orchestrator 加 git CLI
- test-queen 扩展(auth_url 编码 + no_git_grant 分支),14 检查全过;全套契约通过
注:真实 git push e2e 需重建 orchestrator 镜像 + 部署 + gitea 产物仓验证(后续);
当前纯代码 + 单元测完成。凭据经 secret_ref 现取、不存 run、不入日志(组织规则#8)。
影响:仅 orchestrator 终态聚合;不涉及 Manager 契约/计费/发布链路。
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com >
2026-06-19 21:38:43 +08:00
gongzhiyong and Claude Opus 4.8
7314662f97
feat(orchestrator): M4 失败隔离 + P-guard 确认(SC-11/12)
...
SC-12 失败隔离:单 task 失败不再拖垮整个 run。
- refresh_swarm_run_status:next_status 仅在"有失败且无任何完成产物"时 failed;
有完成工作则走 completed,交蜂后/convergence 判定(失败仍由 termination_reason 反映)。
- 解决那次 LLM 网关 404 致单 task 失败 → 整 run FAILED 的单点问题。
SC-11 P-guard:guard.diagnose 已由 assess_swarm_health 在派发循环接入(探索确认,零改动);
检测无 Agent/无模型/依赖死锁/预算耗尽/种子不可分解。
全套测试通过:runtime-contract / merge-smoke / workflow-e2e / contract-freeze
+ task-competition / queen / run-isolation。
影响:仅 orchestrator 终态判定;Manager status 映射不变(failed/completed)。
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com >
2026-06-19 19:25:43 +08:00
gongzhiyong and Claude Opus 4.8
50bc8b019f
feat(orchestrator): M3 蜂后质量门打回 — 质量驱动迭代(SC-9)
...
把收敛从"任务完成即停"升级为"质量驱动":
- queen.should_bounce(纯函数):最优候选已评分且 < 阈值且未触顶 → 打回;无阈值/未评分/达标/触顶 → 接受(诚实,不在算不出的分上打回,组织规则#9)
- queen_quality_gate(接入 refresh_swarm_run_status,在 cross_review 之后/状态提交之前):
评分不达标 → reopen_task 回灌 impl 任务 + review_cycles++ → run 保持 RUNNING 迭代;
达标/触顶 → 继续终态,winner 标到 deliverable
- _queen_threshold:QUEEN_ACCEPTANCE_THRESHOLD(env / run.metadata),默认 None=禁用,
保持现有完成语义不变(可由 operator 启用)
- 717 复用门已聚合的 run.metadata[queen],不重复聚合
测试 scripts/test-queen.py 扩展 should_bounce(5 检查),共 11 检查全过。
注:SC-8 convergence 全 authoritative(BLOCKED→override run.status)动 Manager 终态语义,
需契约评审,列为后续;质量驱动收敛的核心已由 queen_quality_gate 实现。
SC-10 P_rework 计入评审重开属度量层(E),后续。
影响:仅 orchestrator 终态/重开路径;门默认禁用,不改 Manager 契约/完成语义。
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com >
2026-06-19 19:16:42 +08:00
gongzhiyong and Claude Opus 4.8
c2413b5edd
feat(orchestrator): M2 蜂后结果聚合 — best-of-N 选最优(SC-5/6/7)
...
新增 orchestrator/queen.py(蜂后:不执行/不分配,只仲裁最终结果):
- collect_candidates:各 completed task 的 impl 产物为候选(复用 quality.collect_generated_files)
- score_candidates:用 swarm 共享 test 跑各候选 impl 评分(复用 sandbox.run_tests;
fail-closed:未确认隔离则不评分,unscored!=0,组织规则#9)
- select_best:纯函数,测试通过率最高者胜(best-of-N — 单模型没有的涌现杠杆)
- aggregate_run:终态收集→评分→选最优,best-effort 不破坏终态路径
接入 main.py completed 分支:winner 标到 deliverable.selected,verdict 存 run.metadata[queen]。
测试 scripts/test-queen.py(6 检查全过)。
注:SC-7 的 git push 最优到产物仓 main 待端到端阶段(需 orchestrator git CLI + 凭据持久化);
当前先标记 winner(SWE-bench 语境产物是 patch,选最优即够)。
影响:仅 orchestrator 终态聚合;不涉及 Manager 契约/计费/发布链路。
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com >
2026-06-19 19:00:15 +08:00
gongzhiyong and Claude Opus 4.8
c257e7e562
feat(orchestrator): P0 run 边界隔离 — 蜂后防跨 run 抢夺(agent_swarm#8)
...
run-boundary isolation:agent 只能竞争/认领属于自己 run 的 task,杜绝跨 run 抢夺
(A run 的 agent 抢 B run 的 task → 计费错账/结果污染)。
- 新增 extract_swarm_from_agent / _agent_belongs_to_run(复用 -agent- 前缀)
- swarm_dispatch:候选过滤为本 run 的 task
- handle_task_bid/yield/takeover:拒绝跨 run 请求(cross_run_denied)
- 测试 scripts/test-run-isolation.py(7 检查全过)
影响:仅 orchestrator 派发/竞争路径;不涉及 Manager 契约/计费字段/发布链路。
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com >
2026-06-19 18:42:39 +08:00
Fasthei and Claude Opus 4.8
1edf73aba4
fix(swarm/#70): 任务超时透传+提默认 / 事件时间线降噪 / 失败 termination_reason 准确
...
真机端到端实测(#70 )暴露三问题,本 PR 全部修复(仅 agent + orchestrator,不跨仓):
问题1【阻断】单任务超时只有 60s,生成类任务必挂
- agent/main.py: TASK_TIMEOUT_SECONDS 默认 60→300(仅对外部/独立启动 agent 生效)。
- agent_launcher.py: 新增 DEFAULT_TASK_TIMEOUT_SECONDS=300、_budget_duration_seconds、
resolve_task_timeout(base=env 默认 300,与 run budget.duration_seconds 取较小);
plan_launch_specs 把 TASK_TIMEOUT_SECONDS 透传进每个 agent env(非敏感,inline,
k8s 不进 Secret)。
问题2【体验】事件时间线全是内部噪音(纯附加,未碰冻结契约)
- swarm_runtime.py: is_client_visible(=event_type∈FROZEN_CLIENT_EVENT_TYPES,单一真源);
emit_event 给 envelope 加 metadata.client_visible 布尔 + 关键客户端事件回填可选
payload.message(人话进度,仅取已有字段,不伪造)。task.heartbeat/retried/
deployment.status_changed/timeline/budget 标 client_visible=false,仍持久化+回调
但客户端据此过滤出时间线。冻结事件集/类型/sequence/artifact 形状一字未动。
- event-schema.md: 文档化两个附加字段 + 新增 §6.1,明确未解冻。
问题3【正确性】失败/超时 termination_reason 仍报 "tasks_completed"
- convergence.py: 新增 TIMEOUT/MAX_RETRIES_EXCEEDED/TASK_FAILED;classify_failure_reason
按 timeout→max_retries→task_failed 取最具体(仅凭真实 per-task 信号);FAILED 分支
再不会返回 tasks_completed(该 reason 仅用于成功),budget/rounds 仅在通用失败时才覆盖。
- task_queue.py: fail_task 永久失败时把 reason 落到 task.result({"success":false,"error":reason}),
不覆盖已有结果,供 convergence 读取。
- main.py: compute_convergence_report 快照补 retry_count/max_retries。
测试:新增 test_resolve_task_timeout、扩 test-convergence(failed_timeout/max_retries/
generic + "FAILED 永不报 tasks_completed"不变量)。本地全过:test-agent-launcher /
test-convergence / test-runtime-contract / test-contract-freeze / test-merge-smoke /
test-workflow-e2e / test-security-boundary。
影响:agent + orchestrator + 文档;不动 Manager↔Swarm 冻结契约字段(问题2 纯附加)。
栈在 #64(agent_swarm git 注入)之上,#64 合并后本 PR base 自动转 main。
Closes #70
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com >
2026-06-16 18:29:39 +08:00
zsbgnw12 and GitHub
bdddef2c23
Merge branch 'main' into fix/orphan-agent-lifecycle
2026-06-16 12:07:27 +08:00
gongzhiyong and Claude Opus 4.8
b394ce99d5
fix(swarm): reap orphan agents on terminal run + retry backoff + surface task errors
...
孤儿 agent 事故修复(2026-06-15 swarm-69e470561bd7-seed 跨 workspace 执行)。
不改去中心化认领逻辑(swarm_dispatch 不动),仅治理 agent pod 生命周期与可观测性:
- B1 终态回收: refresh_swarm_run_status 终态后 best-effort stop_launched 回收 pod+secret
(此前仅 Manager stop 才回收,自然完成/失败的 run agent 残留 → 孤儿留在共享池抢别的 swarm 任务)
- B2 防驱逐: agent pod 加 karpenter.sh/do-not-disrupt(AGENT_POD_ALLOW_DISRUPTION=1 可关)
- stop_launched: backend=kubernetes 时按标签删,不再被内存集合 _k8s_swarms 门控(跨重启可靠)
- C 重试退避: Task.next_retry_at + fail_task 指数退避 5→30→180s(cap 300, TASK_RETRY_BACKOFF_*),
is_task_ready 门控;TASK_MAX_RETRIES 可配
- D 错误上浮: task_executor 失败时聚合 subtask error 到顶层 error(根治通用 "Task failed"),
_execute_subtask 打印 LLM 响应片段
- 配额硬上限 16: _clamp_user_cap
契约测试全过: runtime-contract / merge-smoke / workflow-e2e / contract-freeze /
max-agents-per-user / security-boundary。
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com >
2026-06-16 04:33:01 +08:00
gongzhiyong and Claude Opus 4.8
f9f1d9a6d5
fix: 注入 GIT_REPO_URL,让 agent 克隆绑定仓库到 workspace(修复任务因空 workspace 必败)
...
根因(实测复现): agent 启动未注入 GIT_REPO_URL → 从不 clone → /workspace 为空 →
任何"读/改仓库代码"的任务被 LLM 以 "no source files to analyze or repair" 判 failed。
对照: 简单建文件任务在空 workspace 下仍 success,证明执行管线/模型/解析/落盘均正常。
公开库只需 GIT_REPO_URL(无凭据)。
- agent_launcher.git_launch_env(body): 从 resource_grants[].metadata.repo_url 提取仓库,
注入 GIT_REPO_URL(+GIT_PROVIDER/GIT_DEFAULT_BRANCH/GIT_BASE_BRANCH)。纯函数,无 I/O。
- plan_launch_specs(git_env=...): 合并进每个 agent 的 env。
- launch_swarm_agents: 解析并传入 git_env; 记 agent_launch.repo_bound 诊断字段。
- 私有库凭据(GIT_TOKEN 经 grant secret_ref + 入 k8s Secret)留作干净后续。
- tests: test-agent-launcher 新增 test_git_launch_env + plan_specs 的 git_env 合并断言。
Refs #66
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com >
2026-06-16 01:41:06 +08:00
gongzhiyong and Claude Opus 4.8
4309eac2ce
fix( #66 ): 退役 _manager_provided_agents 逃生门 + pod 数[3,16]上下限 + 消费 metadata.max_agents_per_user
...
去中心化是唯一行为(对齐 runtime-contract §3.3): 所有蜂群统一播种单一目标任务 + Swarm 自己拉 agent 池;
orchestration_plan.agents 不再控制拉起/任务创建, 退化为无害元数据。修复"任务建了但无 agent 认领、永久 pending"。
- main.py: 删除 _manager_provided_agents 两处分支(任务创建改无条件播种、拉起永远执行) + 函数退役
- agent_launcher.py: launch_count clamp 到 [AGENT_LAUNCH_MIN_POOL=3, AGENT_LAUNCH_MAX_POOL=16]
- main.py: max_agents_per_user(body) 消费 metadata.max_agents_per_user(HM 下发; >0 优先, 否则 env)
- main.py: WS 注册兜底按 agent 所属 run 的 metadata cap 反查(fail-soft 回退 env), 与拉起口径一致
- docs/integration/runtime-contract.md §3.3: 同步架构师裁定口径(2026-06-15)
- tests: test-agent-launcher / test-max-agents-per-user / test-merge-smoke 同步断言
Refs #66
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com >
2026-06-16 00:19:14 +08:00
Fasthei and Claude Opus 4.8
efa865cac4
fix(launcher/#63): 拉起 agent 注入 git 绑定(GIT_REPO_URL + azkv 凭据)— 修 HM #92
...
现象(HM #92):蜂群"需绑定 git 仓库才能使用",但 agent 实际拿不到仓库。
根因:HM 已在 swarm create 的 resource_grants 下发 git 绑定(resource_type=git +
metadata.repo_url + secret_ref=azkv://),但 swarm 拉起侧只把 grant 用于校验/脱敏/审批,
launcher 从不消费它 → 被拉起 agent 的 env 没有 GIT_REPO_URL/凭据 → 无法 clone。
(agent 侧 agent/main.py + agent/git_operations.py 早已读取这些 env,缺的纯是注入。)
修复(仅 launcher 注入,比照模型 key 的服务端解析路径):
- 新增 resolve_git_grant(body):从 resource_grants(含 per-agent)取首个 git grant,
repo_url(metadata) → GIT_REPO_URL(非密文 inline);secret_ref(azkv) 服务端解析 →
GIT_USERNAME/GIT_PASSWORD。复用 azkv 读取(workload identity;dev/CI 用
HEICODE_SECRET_<name>)。有 repo 无凭据仍注入 GIT_REPO_URL(公有仓可 clone;私有仓
报错,不伪造)。
- plan_launch_specs 增加 git_env 合并;create 路径解析并透传。
- k8s 后端:GIT_PASSWORD 与模型 key 同走 per-swarm Secret 的 secretKeyRef,绝不内联
PodSpec;GIT_REPO_URL/GIT_USERNAME 为非密文 inline。SENSITIVE_ENV_KEYS 统一管控。
- git KV secret 值约定 JSON {"git_username","git_password"}(接受 git_token/token 形式
+ 裸 token),待 HM #92 对齐。
git 凭据不入 create 请求体/回调/日志/argv(_reject_plaintext_secrets 已覆盖
resource_grants)。
文档:runtime-contract §3.3 env 表 + 约束、security-boundary §6 增 git 绑定解析口径。
测试:scripts/test-agent-launcher.py 增 resolve_git_grant/凭据提取/k8s git secret 用例。
影响:仅 agent_swarm(Swarm/Agent + 密钥/secret_ref + 文档);不改 Manager/客户端/release/
契约状态机/计费/审计字段。HM 侧 binding_id(B 路径)解析另在 HM #92 处理,与本 PR 无关。
验收:
python scripts/test-runtime-contract.py
python scripts/test-contract-freeze.py
REDIS_FAKE=1 python scripts/test-key-injection-contract.py
python scripts/test-security-boundary.py
python scripts/test-agent-launcher.py
python scripts/test-git-workflow.py
python scripts/test-merge-smoke.py
python scripts/test-workflow-e2e.py
(全部通过)
Refs HM #92 , Closes #63
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com >
2026-06-15 12:17:51 +08:00
gongzhiyong and Claude Opus 4.8
9aadc802df
fix( #56 ): surface why a swarm run produces nothing (no silent black box)
...
#56 : a created run only seeds the task; if no expert agent connects, the run hangs
at `running` forever with no `agent.*` events and an empty /result — and the cause
(P-guard already detects NO_AGENTS_CONNECTED) was only in run.metadata["health"] /
/diagnostics, never on the surfaces HM/cockpit actually poll (/events, /result).
This makes a stuck run explain itself (no new Manager event type, no contract change):
- launch_swarm_agents now records run.metadata["agent_launch"]
{backend, planned, launched, launched_ids, model_key_resolved, note}. The note
pinpoints WHY there are 0 agents — e.g. AGENT_LAUNCH_BACKEND=none (no auto-launch),
k8s launch failed (kubectl/RBAC + Pod Workload Identity, #16/#60 A.3), or the model
key didn't resolve. No secret recorded — only a model_key_resolved bool.
- /result and /diagnostics now carry `health` (P-guard blockers) + `agent_launch`.
- assess_swarm_health emits ONE `timeline.updated` per distinct blocker-set (registered
event; dedup by summary, reset when healthy) so /events and the cockpit (#39 ) show
"swarm blocked: no_agents_connected" instead of silence. Still NO unregistered
swarm.health event.
Scope: this surfaces the diagnosis. Actually executing a run still requires the
deployment to set AGENT_LAUNCH_BACKEND=kubernetes AND the #16/#60 A.3 Pod Workload
Identity / KV grant (infra, cross-team) — called out in the launch note.
Tests (scripts/test-swarm-guard.py): blocked run emits timeline.updated exactly once
(dedup) + still no swarm.health; /result + /diagnostics carry health w/ no_agents_connected;
launch_swarm_agents records the backend=none note. test-contract-freeze + test-agent-launcher
still green.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com >
2026-06-14 16:52:44 +08:00
gongzhiyong and Claude Opus 4.8
9d07bfeb76
feat( #51 ): add SSE endpoint GET /api/swarms/{id}/events/stream
...
Real-time event stream for the cockpit, reverse-proxied by HM to the client
EventSource (orchestrator SSE → HM → client). The SSE overlay over the existing
GET /events?after=<sequence>:
- Replays history after `after`, then holds the connection and pushes new events.
- Reuses the existing swarm_events:{swarm_id} store + per-swarm INCR sequence — no
new storage, no schema change.
- Each frame: `id: <sequence>` / `event: message` / `data: <envelope JSON>`, where
data is byte-identical to /events so SSE and polling share one cursor space (a
dropped SSE can fall back to /events?after=<last id> with no gap/dup).
- Supports Last-Event-ID header (takes precedence over the `after` query) for
end-to-end resume through HM.
- Heartbeat `: ping` every ~15s + X-Accel-Buffering:no to survive nginx ingress /
HM reverse-proxy buffering.
- Closes after a terminal event (swarm.completed/failed/stopped); releases on client
disconnect (request.is_disconnected).
- Auth: require_runtime_auth (service token) — caller is HM, never the client direct.
Adds TERMINAL_CLIENT_EVENT_TYPES to swarm_runtime. Events are already redacted at
emit time, so frames are streamed as-is. No change to the callback POST path,
event schema, sequence, or terminal definitions (event-schema v1 frozen).
Verified: contract-freeze / runtime-contract / merge-smoke / workflow-e2e all pass;
plus a dedicated SSE check (history replay, id ordering, Last-Event-ID resume,
byte-identical envelope, terminal close).
Part of #40 (the SSE half). HM reverse-proxy side = heicode-mananger#46.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com >
2026-06-13 23:07:35 +08:00
Fasthei and Claude Opus 4.8
94ef894ace
feat(benchmark): 阶段2 数据采集 — 真实 run 终态自动采集 SwarmMetrics 并落库(+可选导出)
...
把采集器接进真实运行,让数据自己累积,为后续【经验标定】O/系数/S_gain 攒真实
用户数据(这些量只能由真实运行事后标定,不能先验写死)。本阶段不编任何公式。
- orchestrator/main.py:run 终态(completed/failed)在终态事件后调 capture_run_metrics。
只读 run 状态、try/except 包裹绝不失败 run;默认开,BENCHMARK_CAPTURE=0 可关。
- orchestrator/swarm_runtime.py:record_benchmark_metrics → 落 run.metadata['benchmark']。
- benchmark/collectors/capture.py:collect(run_collector) → 持久化 → 可选导出(to_thread)。
- benchmark/export/:MetricsExporter;默认 NoopExporter(无依赖/无凭据);
BENCHMARK_EXPORT_TARGET=blob 启用 Azure Blob(连接串或 Workload/Managed Identity,
凭据经环境注入,绝不写进代码),归档 <scenario>/<swarm_id>.json。
诚实:缺项指标 NaN→null,不伪造(规则#9)。
验证:新增 test-benchmark-capture.py + 现有 collector/selfcert + 契约冒烟(runtime/
merge/freeze)全 PASS。
影响范围:agent_swarm。运行时新增**只读**终态钩子(不改派发/执行/契约/计费/审计字段);
导出默认关,无密钥落地。Client/Manager/Agnet/CodeGW/发布链路不涉及。
依赖:benchmark/ 需在镜像内(quality.py 早已 import benchmark;由 #44 Dockerfile 修复覆盖)。
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com >
2026-06-12 17:57:59 +08:00
观风听雪 and GitHub
ad343e6404
Merge pull request #36 from xmindlab-heicode/feat/review-timeline-events
...
评审/返工时间线对客户端可见:review/rework 4 类脱敏事件纳入冻结集(Refs #34)
2026-06-11 17:15:50 +08:00
Songhaoz666 and Claude Opus 4.8
a7d2bb2870
评审/返工时间线对客户端可见:review/rework 4 类脱敏事件纳入冻结集(Refs #34)
...
文档:event-schema §4 增 4 类(标 ⭐ + 脱敏说明)、header 13→17;frontend-event-api 评审/返工时间线行推进为已定义 + header 注明部分推进 + 剩余跨仓项(HM 注册、cockpit 渲染、仅脱敏摘要);review-loop-protocol §3.2 由"事件不进 Manager 流"更正为"已脱敏外发"。
测试:新增 scripts/test-review-timeline-events.py(单元投影脱敏 + run_cross_review 真实站点发出 + 断言无 evidence/summary 泄漏 + 4 类在冻结集);test-contract-freeze 的 13-精确断言改为"13 核心为子集"(因 #34 扩到 17)。接入 CI。本地全绿(含 e2e/cross-review 回归)。
影响范围:仅 agent_swarm(orchestrator + docs + 测试 + CI)。Manager:回调新增 4 类(向后兼容;HM agent_callback.go 需登记方可对客户端暴露)。密钥/内容:脱敏投影不含 evidence/summary/原文/密钥。不改契约鉴权/计费/审批链。
Refs #34
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com >
2026-06-11 17:10:57 +08:00
Fasthei and GitHub
02b8b08ab3
Merge branch 'main' into feat/swarm-io
2026-06-11 17:03:58 +08:00
Fasthei and GitHub
282df74f94
Merge pull request #37 from xmindlab-heicode/feat/usage-cost-phase
...
用量按 review-retry 成本归属:usage 事件标 cost_phase(Refs #16)
2026-06-11 16:49:37 +08:00
Songhaoz666 and Claude Opus 4.8
dd96b73b2d
Swarm I/O:接收用户 prompt(追加输入)+ 返回结果(/result + swarm.completed 带答案)(Refs #40)
...
补齐「客户端如何把 prompt 给我们 + 如何拿到结果」的端到端路径。
输入:
- POST /api/swarms/{id}/input(+别名):接收用户后续 prompt,注入 source=user_append 任务进共享池
(终态 run 自动 reopen 为 running;stopped 拒绝 RUN_STOPPED)。指令原文作任务描述下发给 agent,
**不回显进事件流**——仅产一条 task.created(user_append) 类别 message。(初始 prompt 仍走 create
的 requirement.objective)
输出:
- GET /api/swarms/{id}/result(+别名):返回 {summary, deliverable, artifacts[], termination_reason,
status}(build_run_result)。产物内容在 artifact.uri(git/runtime),result 给摘要+定位。
- swarm.completed 事件 payload 增带 summary + deliverable,客户端看一条终态事件即得答案。
文档:runtime-contract §3 增 input/result 行;event-schema swarm.completed 标注带 summary/deliverable;
CLIENT_GUIDE §3.5/§3.6(input/result)+ §3.2 表 + 修正 §5「Agent 平台拉起」为「Swarm 拉起 + 从
secret_ref 解析 key」(对齐 team 决议)+ 新增 §9 完整工作流地图(client→HM→Swarm→output→client)。
测试 scripts/test-swarm-io.py(TestClient:input 注入 + 原文不入事件流 + 终态 reopen + stopped 拒绝 +
result 形状)接入 CI。e2e/contract 回归通过。
影响范围:仅 agent_swarm(新增 2 只读/写端点 + 终态事件增字段 + 文档 + 测试 + CI)。
追加输入原文不入事件流/回调/日志;不改鉴权/计费账本/审批链。SSE 实时流仍归 HM Phase2(#46)。
Refs #40
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com >
2026-06-11 16:28:37 +08:00
Songhaoz666 and Claude Opus 4.8
9516b5c696
Swarm 负责拉起 agent + 执行限额(team 决议,反转 AM 拉起)(Refs #16)
...
团队决议:由 Swarm 运行时(非 AM)拉起专家 agent 池并执行每用户限额。
代码:
- orchestrator/agent_launcher.py(新):plan_launch_specs(纯,按 min(池大小, MAX_AGENTS_PER_USER
−已连) 限额 + 组装每 agent env)、resolve_model_key(override→azkv secret_ref 解析(部署
SecretResolver/dev HEICODE_SECRET_<name>)→OPENAI_API_KEY 兜底,解析不到不伪造)、可插拔后端
launch()(none 默认/subprocess/command 模板,fail-soft)、stop_launched。
- orchestrator/main.py:create 播种后调 launch_swarm_agents(仅去中心化、非 Manager 显式 agent;
从 create x-user-id 取 user_id;key 服务端解析,不入 create 体);stop_swarm_run 调 stop_launched。
文档:runtime-contract §3.3 由「AM 拉起(提案待确认)」改为「Swarm 拉起 + 限额(已定)」,
更新 env 来源列(key=Swarm 从 secret_ref 解析、AGENT_ID/CAPABILITIES=Swarm launcher、
HEICODE_USER_ID=从 create 透传)+ 后端/限额/解析约束;security-boundary §6 增 Swarm 拉起 +
服务端解析 key(不上 argv/日志)说明。
测试:scripts/test-agent-launcher.py(限额封顶、env 组装、key 解析优先级、command 模板、
none no-op)接入 CI。e2e/contract 回归通过(默认 backend=none,行为不变)。
影响范围:仅 agent_swarm(orchestrator + docs + 测试 + CI)。默认 backend=none 不自动拉起、
向后兼容;密钥仅服务端 env 注入、不入 create 体/回调/日志/argv(满足 §3.1 + security-boundary)。
不改 Manager↔Swarm 契约鉴权/计费账本/审批链。
Refs #16
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com >
2026-06-11 15:07:23 +08:00
Songhaoz666 and Claude Opus 4.8
e4a120b715
/metrics 暴露 run 级 cost_by_phase{initial,review_retry}(Refs #16 #37)
...
回应 @Mem0ried 在 PR #37 的对接问题:除逐条 budget.alert 事件的 cost_phase 外,详情
聚合也需能拆 initial/review_retry。build_runtime_metrics 新增 cost_by_phase 滚动汇总
(按 swarm_id,从各任务 usage.model_cost_usd/model_tokens 按 rework_attributions 归类),
GET …/{id}/metrics 返回 {initial,review_retry}:{cost_usd,model_tokens}。HM 详情聚合 /
客户端 08 用量抽屉可直接展示拆分,无需从事件推导。
测试 test-usage-cost-phase.py 增 /metrics 断言(reworked→review_retry、非 reworked→initial);
usage-billing §5 记录该字段。
Refs #16
Refs #37
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com >
2026-06-11 14:36:07 +08:00
Songhaoz666 and Claude Opus 4.8
56e080bfa1
用量按 review-retry 成本归属:usage 事件标 cost_phase(Refs #16)
...
emit_usage_event 给每条 budget.alert 用量事件加 cost_phase:任务进入
run.metadata["rework_attributions"](cross-review 已 reopen)后的再执行标 review_retry,
否则 initial;并带 attempt(retry_count)。初次执行先于任何 attribution → initial,redo 在
run_cross_review 记录 attribution 之后 → review_retry,时序天然正确。计费/采集侧按 swarm_id
聚合时可用 cost_phase 拆分 initial vs review_retry 成本,满足「review retry 成本可归属」。
usage-billing-schema §4.2/§5/§6 同步:payload 加 cost_phase/attempt,§5 改为已打标,§6 缺口表
review_retry 标 ✅ 。测试 scripts/test-usage-cost-phase.py 接入 CI。
影响范围:仅 agent_swarm(usage 事件加字段 + 文档 + 测试);向后兼容;不改鉴权/契约/审批链/密钥。
Refs #16
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com >
2026-06-11 09:44:36 +08:00
Fasthei and GitHub
5e29618bf5
Merge pull request #32 from xmindlab-heicode/feat/max-agents-per-user
...
每用户并发 Agent 上限:MAX_AGENTS_PER_USER 默认 10
2026-06-10 22:44:39 +08:00
Songhaoz666 and Claude Opus 4.8
56bff469c1
每用户并发 Agent 上限:MAX_AGENTS_PER_USER 默认 10
...
需求:限制每个用户在 swarm 中并发的 Agent 数为 10。按「并发 WS 连接数/用户」口径实现,env 可调(默认 10)。
orchestrator/main.py:ConnectionManager 新增 per-user 记账(agent_user / user_agents + user_agent_count / can_bind_user / bind_user / unbind);max_agents_per_user() 读 MAX_AGENTS_PER_USER(默认 10)。WS register 携带 user_id 且该用户已达上限时回 registration_rejected(reason,limit) 并 close(1008),不注册;同 agent_id 重连放行;断开 unbind 释放名额。未带 user_id 的 Agent 为 unbound、不受限。
agent/main.py:新增 user_id 构造参数 + HEICODE_USER_ID 环境回退,并在 register 载荷中带上(仅在设置时)。
测试 scripts/test-max-agents-per-user.py:单元 + WS 集成(MAX_AGENTS_PER_USER=3)。接入 CI。docs/integration/security-boundary.md §6 记录该配额。
影响范围:仅 agent_swarm;不改 Manager↔Swarm 契约、计费、审批链、密钥处理。
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com >
2026-06-10 22:01:22 +08:00
Fasthei and GitHub
eb643c9b02
Merge branch 'main' into feat/audit-trace-freeze
2026-06-10 21:39:22 +08:00
Songhaoz666 and Claude Opus 4.8
3411daf00b
复审整改(PR #30 ):审计接口读取完整事件流,消除 >500 事件静默截断
...
Fasthei 复审阻塞点:build_audit_trace_for_run 只调用一次 list_events(limit=500),
而 list_events 把 limit 钳到 500 并用 next_cursor 暴露下一页——501+ 事件的 run 只返回
前 500 条审计记录,无报错/无 truncated 标记,违背 #17「每步 trace 可回放」核心 DoD。
修复:build_audit_trace_for_run 改为循环跟随 next_cursor 读到为空,拼出完整事件流再
装配审计记录(main.py)。
测试:test-audit-trace.py 新增 test_pagination_no_truncation——存 612 条事件(>500 且非
500 整数倍),断言 audit count == 完整事件数(613,含创建事件)、replay 行数 == count 不截断、
audit_id 连续到末条(aud_000613)。本地全绿。
影响范围:仅 agent_swarm(orchestrator 只读审计装配 + 测试);无契约/计费/审批/密钥改动。
Refs #17
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com >
2026-06-10 21:14:50 +08:00
Songhaoz666 and Claude Opus 4.8
af4ace4340
审计/链路追踪落地(可回放审计记录 FROZEN v1)(Refs #17)
...
issue #17 要求「每步 trace 可回放(谁/何模型/何工具/何审批)+ schema 冻结 + 测试」。
本仓已持久化事件流 + 任务谱系 + 每任务 usage(model_id) + 审批;本 PR 把它们规整为
统一、有序、可回放的审计记录并冻结 schema。
代码:
- orchestrator/audit.py(新,纯模块,无 Redis/WS/FastAPI/模型):build_audit_trace(
events, task_facts, approvals, lineage) 逐事件产审计记录(who/when/model_id/tool_count/
approval{id,decision}/result/lineage),audit_id 由序位确定(非随机,可字节级复现);
replay(records) 产人读步骤行。无内容、无密钥、缺信号不伪造(model/tool 缺则 null)。
- orchestrator/main.py:build_audit_trace_for_run(装配器,从 list_events + 任务 usage +
run.approvals 取数)+ 读接口 GET …/{id}/audit(三别名路由,复用既有鉴权)。
文档:docs/integration/audit-trace-schema.md → FROZEN v1:§3.1 回放装配、§5 冻结记录形;
诚实标注**有意排除**(prompt/代码原文、model 请求响应体刻意不留痕——无内容原则;
无 SK/MCP 工具层故无工具名谱系),按规则 #9 不伪造、不在本次扩展。
测试:scripts/test-audit-trace.py(纯模块 + 集成):逐步 who/model/tool/approval 重建、
result 归类、有序回放、**断言无 secret_ref/azkv/明文泄漏**;接入 CI。
影响范围:仅 agent_swarm(orchestrator 新增只读审计接口 + 纯模块 + 文档 + 测试 + CI)。
- Manager:新增只读 GET …/{id}/audit;不改回调/契约/计费/审批链。
- 密钥/审计:审计记录只含非内容元数据 + secret_ref 永不写入;归因按 user/channelId,不引入 tenant。
Refs #17
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com >
2026-06-10 18:06:50 +08:00
Songhaoz666 and Claude Opus 4.8
15fe5d379b
契约冻结 v1:Manager/客户端 Swarm Run 查询契约(Refs #2 #14 #15)
...
回应 HM 驾驶舱(heicode-mananger #28/#45/#46)经 agent_swarm#14(runtime-contract)
+ #15(event-schema)提出的消费需求。HM 只读查询已落地(HM PR #53),唯一前置是本
仓契约冻结。本 PR 把回调契约冻结为 v1 并落代码 + 测试。
代码(orchestrator/):
- swarm_runtime.emit_event:回调 envelope 新增 **per-swarm 严格递增 `sequence`**
(INCR 计数键 swarm_event_seq:{swarm_id},从 1、无空洞,供客户端 events?after= 去重/续传)。
- 新增冻结的客户端 13 类事件(FROZEN_CLIENT_EVENT_TYPES)中此前缺的 6 类,均**附加**发出
(不动既有 deployment.status_changed,HM 仍用其更新 AgentDeployment.Status):
· swarm.completed/failed(refresh_swarm_run_status 终态)、swarm.stopped(stop_run);
· approval.approved/rejected(record_approval_decision 决定落地);
· handoff.created(child 任务建立时)。
- artifact.created envelope 补扁平字段:created_at(默认 occurred_at)、task_id(回填)、
size_bytes 透传(未知则省略,不伪造,规则 #9)。
- redis_client 新增原子 incr(真实 + 两处 fake stub)。
文档(docs/integration/,FROZEN v1):
- event-schema.md:envelope sequence、artifact 扁平字段、事件注册表标注 ⭐ 13 类 + 新增 6 类、
对齐状态更新(title/threshold_pct/sequence/artifact 已在 emit 统一处理)。
- runtime-contract.md:冻结 stop 端点 + ID 映射;§4.1 新增**状态机映射表**——运行时不臆造
preparing/degraded/verifying(规则 #9),由 HM/客户端按表映射真实状态
(blocked→degraded、评审期→verifying 等);终态另发 swarm.* 事件。
测试:
- 新增 scripts/test-contract-freeze.py(hermetic):sequence 单调/每-swarm/无空洞、13 类
round-trip、artifact 形状(含未知 size 不伪造)、approval.*/swarm.stopped 真实发出、
明文凭据脱敏而 azkv secret_ref 透传。接入 CI + CLAUDE.md 提交前清单。
- test-workflow-e2e.py:全流程 e2e 额外断言 swarm.completed + sequence 无空洞。
- 两处 FakeRedis stub 补 incr。
影响范围:仅 agent_swarm(orchestrator + docs/integration + 测试 + CI + CLAUDE.md)。
- Manager:回调**新增** sequence 字段与 6 类事件——向后兼容(旧消费方忽略新字段/新类型即可);
HM 注册表需登记新 6 类方能对外暴露(agent_swarm#15.2,已在 doc 列为剩余项)。
- 计费/审计:不涉及(查询面不计费由 HM 保证;本仓未改计费/审计字段)。
- 密钥:envelope 不含明文凭据;secret_ref 仍为 azkv 引用,HM 对客户端再脱敏。
Refs #2
Refs #14
Refs #15
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com >
2026-06-10 17:35:04 +08:00
Songhaoz666 and Claude Opus 4.8
e1292ca6fd
复审整改补漏(PR #26 ):修正 assess_swarm_health 残留的过时 docstring
...
第 3 点整改时改了函数体(不再 emit swarm.health、改存 run.metadata),
但函数 docstring 仍写「emits an internal swarm.health event」——与代码及
紧邻注释自相矛盾,正是 Fasthei 指出的同类「文档/代码冲突」。改为如实描述:
存 run.metadata["health"] + 内部 health_log,INTERNAL only,不发 Manager 事件。
仅注释/文档串改动,无逻辑变更;test-swarm-guard 仍全绿。
Refs #6
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com >
2026-06-10 16:58:22 +08:00
Songhaoz666 and Claude Opus 4.8
f2662e4268
复审整改(PR #26 ):删死开关 helper、文档对齐"无条件"、swarm.health 改内部、#6 降为 Refs
...
回应 Fasthei 终审三点:
1) [P1 文档/代码冲突 + 死代码] 删除从不被调用的 *_enabled() helper(autonomous_tasks.proposals_enabled
/ task_competition.task_competition_enabled / convergence.convergence_report_enabled)及其
import os;模块 docstring 与四份协议文档(autonomous-task-generation / task-competition-protocol
/ review-loop-protocol / convergence-protocol)从"默认关/未接入/待 PR/cutover 转无条件"全部改为
"无条件接入(无开关)",删除引用死 helper 的过时集成代码样例;同步删除三个模块单测里的
"flag default OFF" 断言。
2) [P1 验收] #6 "Closes" 降为 "Refs":#6 DoD 需 ARB 决策记录链接,当前只有 owner 指示断言、无链接。
product-positioning.md 改为如实记录决策来源(owner 指示 + 本 PR + 文档)并把"补 ARB 记录链接(或
owner 明确接受断言)"列为关闭 #6 的前置;纠正其"flag 门控、默认行为不变"的过时表述(重构已无条件)。
3) [P2 契约卫生] assess_swarm_health 不再 emit_event("swarm.health")(避免向订阅全部的 Manager 回调
投递未注册事件);改为存 run.metadata["health"] + 内部 health_log。test-swarm-guard 相应断言
"无 swarm.health 外发 + 内部 health_log 已记"。
本地受影响 11 套全绿。影响范围:agent_swarm(orchestrator 模块/文档/测试);不改 Manager↔Swarm 契约。
Refs #6
Refs #7
Refs #8
Refs #11
Refs #12
Refs #18
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com >
2026-06-10 16:48:27 +08:00
Songhaoz666 and Claude Opus 4.8
f281370209
去中心化蜂群重构:从 Master 中心化切换为播种+自组织(唯一行为)
...
把本仓从「Master 分解→派发→单评审」重构为去中心化自组织蜂群,并设为唯一行为
(本仓即 swarm 运行时,模式选择在仓外,无 ENABLE_swarm 开关)。依据:heicodeDocs 弱中心
定义 + 蜂群文章(stigmergy)+ OpenAI Swarm(handoff)。
流程(全部无条件生效):
- 播种 build_seed_task_specs(不主控分解)→ 自选 swarm_dispatch(能力+τ+负载+预算,唯一派发)
→ 自主分解 task_proposal(autonomous_tasks)→ 竞争/接管 task_bid/yield/takeover(task_competition)
→ 同伴交叉评审 ≥2 评审者(cross_review,取代单 critic)→ 收敛 ConvergenceReport+termination_reason
(convergence)→ 守卫 guard.diagnose(检测无法运作并列原因)。
删除:planner 主控分解、贪心/ACO/scored 派发与 scored_matchmake、单 critic 评审环、
全部 ENABLE_* swarm 构建开关。master_agent.synthesize 作为汇总工具保留。
测试:test-workflow-e2e 改写为真实 swarm 全流程;test-merge-smoke 改为 seeder/cross-review;
新增 test-swarm-{seed,dispatch,autonomous,competition,cross-review,convergence,guard} + 模块单测;
CI 同步。本地 18 套全绿。
影响范围:agent_swarm(orchestrator + 新模块 + 测试 + docs + CI)。不改 Manager↔Swarm 事件契约
(新事件均为运行时内部状态/遥测,不进 HM 注册表);不影响 Client/计费/密钥/审计/发布链路。
无新增长期开关。
诚实边界:不动 benchmark 验收(G_E 仍需真实 run,#13);convergence 暂为解释性(不强制覆盖
run.status);前端可见状态为跨端(#18);「去中心化是否更优」未证(需 Group C)。
#6 的 DoD(Path B 决策 + 定位文档)本 PR 已满足并实现 Path B → 关闭 #6。
#7/#8/#11/#12 的运行时机制已落地(事件 + e2e),但其 DoD 含前端可见状态(跨端 #18)与
多 Agent 回放,故以 Refs 链接、不自动关闭,留维护者在前端/验收就绪后关闭。
Closes #6
Refs #7
Refs #8
Refs #11
Refs #12
Refs #18
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com >
2026-06-10 16:11:47 +08:00
Songhaoz666 and Claude Opus 4.8
62610a7e3f
调度评分:多维可解释打分匹配 + dispatch.decision_made(Closes #9)
...
把派发从「能力子集 + 空闲」升级为任务为中心的多维可解释打分匹配。
新增/改动:
- orchestrator/dispatch_score.py(新):DispatchCandidate/DispatchScore + 加权掩码归一
打分(score_candidate/rank_candidates)+ build_dispatch_decision_event。
- orchestrator/main.py:抽出三模式共用的 finalize_dispatch;新增 scored_matchmake
(ENABLE_DISPATCH_SCORE,默认关,与 ACO 择一)——为每个就绪任务在有能力的空闲 Agent
间按 capability/历史成功(τ)/负载/预算压力/权限择优,记录可解释决策;_run_budget_pressure
计算真实预算占比。
- orchestrator/swarm_runtime.py:SwarmRun.dispatch_decisions + record_dispatch_decision
(内部状态,非 Manager 事件)。
- 测试:scripts/test-dispatch-score.py(公式 24 项)+ scripts/test-dispatch-scored.py
(集成 11 项:按 τ/负载多 Agent 择优 + 排除原因 + 可回放记录);CI 纳入两者。
- docs/scheduling/dispatch-score-schema.md、CLAUDE.md 同步。
诚实边界:risk_score/estimated_cost/estimated_time 本仓无来源 → None 并在 payload
uncollected_dimensions 披露(不伪造,规则 #9);dispatch.decision_made 暂为 Swarm 内部
记录,未进 Manager 事件契约(需 event-schema 注册,跨端)。flag 关闭时贪心/ACO 路径逐字节不变。
Closes #9
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com >
2026-06-10 14:08:08 +08:00
Songhaoz666 and Claude Opus 4.8
a289495823
复审整改(PR #24 ):沙箱 fail-closed 隔离门控 + 可回放 DecisionTrace
...
回应 Fasthei 的 Request changes 两个阻塞项:
1) 安全 / fail-closed 沙箱隔离(原仅靠 ENABLE_QUALITY_EVAL + 运维约定):
- 新增第二道显式确认 HEICODE_SANDBOX_ISOLATED(断言运行在隔离 Pod 内)。
- sandbox.run_tests() 与 quality.evaluate_run_quality() 执行任何代码前调用
assert_isolated(),未确认即抛 SandboxIsolationError——不写文件、不起子进程。
- 启动期 assert_quality_eval_safe():ENABLE_QUALITY_EVAL 开但隔离未确认 → 拒绝启动
(平台级硬失败,非运维口头约定)。
- 文档(security-boundary §8.1/§9、CLAUDE.md)与测试同步:test-sandbox/test-quality
先断言未确认时硬失败,再显式确认后继续。
2) #10 DecisionTrace 可回放(原仅存被选中任务的标量):
- Decision 现记录完整重放上下文:整个候选集(每候选 tau/eta/weight/p_norm/dependents)、
alpha/beta/epsilon、seed、free_slots、total_weight、explore_draw、select_pick、
select_index、explored 分支。
- 新增 DecisionEngine.replay_decision(trace):仅凭一条 trace(无 RNG/活体状态)复现被选任务;
test-decision-engine 断言「重放==实选」跨 50 次决策(探索+利用)成立。
- decision-engine.md §3.3 更新为可回放 DecisionTrace。
附:新增 docs/TESTING.md(reviewer 速查:依赖安装 + 每套测试命令,复审者此前因缺 fakeredis
未能跑到断言)。本地 11 项 gate 全绿。
影响范围:Swarm(orchestrator + 测试 + 文档)。不改 Manager↔Swarm 契约;新增开关
HEICODE_SANDBOX_ISOLATED(默认未设=拒绝执行)。仍非验收:gain/Benchmark_Agent 仍 NaN。
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com >
2026-06-10 13:22:54 +08:00
Songhaoz666 and Claude Opus 4.8
d487923646
benchmark: 落地决策层(τ/η/P)、质量(Q_quality)、通信遥测;关闭 #10 #23
...
四块互相交织的 benchmark 覆盖增量,统一提交:
1) 通信遥测(#23):orchestrator 路由 peer 消息时按 correlation_id 计请求/应答到
SwarmRun.collaboration(内部状态,不进 Manager 事件流);collector 算 s_communication。
治理计数由 run.approvals 派生(合规/总数)→ s_governance。
2) Q_quality 掩码归一(v2.1 裁定):metrics.quality_score 改为对 present 输入加权归一,
非编码任务自动忽略 TestPassRate,全缺 → NaN(不伪造)。
3) 质量插桩 / Group B:新增 Pod 内代码测试沙箱(orchestrator/sandbox.py,环境清洗 +
超时强杀 + 资源限额 + 路径越界校验,门控 ENABLE_QUALITY_EVAL)与 held-out fixture
(benchmark/fixtures/);run 完成时用留出测试评分得 TestPassRate → Q_quality →
collector 合成 reward。安全边界见 docs/integration/security-boundary.md §8.1。
4) 决策引擎 / Group A(#10,Option A score-at-pull):新增 orchestrator/decision_engine.py
—— 信息素 τ(Redis 持久、(role,agent) 键控、冷启动 0.5、ρ 蒸发、夹紧、学习常开)+
η 启发式评分 + ε-greedy 概率采样;每次 dispatch 产一条 DecisionTrace →
SwarmRun.decisions;collector 算 tau/eta/p_decision。概率选择门控 ENABLE_ACO_DISPATCH
(默认关,CI 用 ACO_SEED 固定)。
覆盖:单次 run 真实可算字段由 4 提升至最多 10/15(新增 communication/reward/tau/eta/
p_decision,外加 governance 有条件)。
测试:新增 test-sandbox / test-quality / test-decision-engine;扩充 collector/metrics 用例;
CI 纳入全部 benchmark 套件 + flag-on 的 ACO e2e。本地 11 项 gate 全绿。
诚实边界(未越界声称):
- Group A 为单边匹配(Option B 待 Group C);概率派发优于贪心未证;默认关闭。
- reward 的 CodeReview/UserAcceptance 未采集(掩码忽略);P_risk 为审批派生低估。
- s_gain/s_swarm/g_e/g_e_cost/benchmark 仍 NaN —— 需基线(#21/#13),本 PR 不动验收。
影响范围:Swarm(orchestrator + benchmark + docs + CI)。不改 Manager↔Swarm 事件契约
(遥测均为运行时内部状态);不影响 Client/计费/密钥/发布链路。新增 ENABLE_QUALITY_EVAL /
ENABLE_ACO_DISPATCH 两个开关,默认关闭。
Closes #10
Closes #23
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com >
2026-06-10 12:51:32 +08:00
Songhaoz666 and Claude Opus 4.8
54cb327348
Agent Swarm v6:基准 v2.1、主控 Agent、实质性对等回复、客户端指南
...
- 基准标准 v2.1:SwarmMetrics(15 字段)、τ/η/P_decision/reward 公式、对称 G_E,c(修正 C_base=1.0 退化)、Σλ=1.0 校验;新增基线对比与运行记录 schema;指标覆盖缺口分析;参考系数暂留为元数据(待量化)。
- 主控 Agent 实体(分解 / 评审决策 / 汇总);事件契约修正(timeline.title、budget.threshold_pct、handoff 角色、task.released)+ 契约校验脚本。
- 实质性 LLM 对等回复(含降级回退);集成契约(runtime / event / usage / audit / frontend / capability / security);CLIENT_GUIDE 客户端指南;CI 工作流;治理与交付文档。
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com >
2026-06-09 16:21:18 +08:00