gongzhiyong and Claude Opus 4.8
207e027fbb
feat( #56 ): 补 azkv SECRET_RESOLVER —— 用 Pod workload identity 从 heicode-vault 读模型 key
...
#56 缺口:`_resolve_secret_ref` 此前只读 dev 环境映射 `HEICODE_SECRET_<name>`,
没有生产从 Azure Key Vault 取 key 的实现(原注释写"适配器在仓外",实际缺)。
本次在仓内补上,走刚建好的 Pod workload identity:
- `_resolve_from_keyvault`:`DefaultAzureCredential` + `SecretClient` 读 azkv:// ref;
**lazy import** azure SDK,任何失败(未启用/不可解析/SDK 缺/无凭证/网络/secret 不存在)
返回 None —— 不伪造、不抛。
- `_azkv_enabled`:**仅当** Pod 注入了 workload identity(`AZURE_FEDERATED_TOKEN_FILE`)
或显式 `SECRET_RESOLVER=azkv` 才真连 KV —— dev/CI/测试保持 hermetic、不碰网络。
- `_parse_azkv_ref`:解析 `azkv://<vault>/secrets/<name>[/<ver>]`(裸名→`https://<name>.vault.azure.net`,
全 host 保留,兼容短形式)。
- `_resolve_secret_ref` 顺序:dev 环境映射 → KV(workload identity),保持既有 dev 行为不变。
- requirements:加 `azure-keyvault-secrets`(lazy import;`azure-identity` 已在)。
测试 `test-agent-launcher.py` 新增:azkv 解析、gating(默认关、两种开关)、disabled→None。
`test-agent-launcher` / `test-key-injection-contract` 全绿。
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com >
2026-06-14 19:17:29 +08:00
gongzhiyong and Claude Opus 4.8
185c0033b1
docs( #56 ): 模型网关域名 A.4 更正 code.xinghanlab.com → code.heicode.cc(HM 权威口径)
...
HM #56 评论:code.heicode.cc 为正式地址,code.xinghanlab.com 为前期过渡域名。
runtime-contract §3.3.1 A.4 的 AGENT_OPENAI_API_BASE 示例同步更正为
https://code.heicode.cc/v1。纯文档,无代码改动 。
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com >
2026-06-14 18:21:36 +08:00
gongzhiyong
a117c02e3f
docs( #56 ): 更正模型 key 库名 heicode-kv → heicode-vault(HM 实测口径)
...
agent_swarm#56 评论:模型 key 的真实 Key Vault 库名是 `heicode-vault`
(`https://heicode-vault.vault.azure.net `),早期契约文档误写为 `heicode-kv`;
且生产 `SECRET_RESOLVER` 须指向 `heicode-vault`。
- runtime-contract.md §3.3.1 A.3:库名更正 + 标注 SECRET_RESOLVER 指向 heicode-vault
+ 明确 Swarm 需提供 Pod 身份的 clientId+objectId 给 HM 授权(只读、限 swarm-model-key-*)。
- security-boundary.md:secret_ref 示例 host 同步更正。
- test-key-injection-contract.py:模型 key fixture host 同步更正(resolver 仅取末段名,
功能不变;测试仍全绿)。
纯文档/fixture 更名,无事件 schema/契约字段改动。
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com >
2026-06-14 17:12:27 +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
Fasthei and GitHub
9852df8cb4
Merge pull request #53 from xmindlab-heicode/docs/benchmark-collector-landed
...
docs(README): benchmark 采集器已落地,仅评分标准待定
2026-06-14 13:05:24 +08:00
gongzhiyong and Claude Opus 4.8
4aaf63cea5
docs(README): benchmark collector has landed — only scoring standard pending
...
The capability table claimed "🔴 规划中(采集器尚未落地)", but the benchmark
collector is in fact implemented under benchmark/: metric formulas (metrics.py:
S_swarm/G_E/G_E,c/Benchmark_Agent + governance/collaboration/communication/
robustness), live-run collection (collectors/), the 4 baseline runners (runners/),
G_E/G_E,c comparison (baselines.compare), self-cert merge (selfcert_collector),
and telemetry export to Cosmos/Blob (export/).
Updated the row to 🟡 : collector landed; the remaining piece is the scoring
standard — the O (observability) formula, BASE_COEFFICIENTS, and S_gain thresholds
must be empirically calibrated from accumulated real user usage data (long-term
ticket). Keeps the honesty rule: metrics lacking real inputs return NaN, never
fabricated scores.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com >
2026-06-14 01:12:43 +08:00
Fasthei and GitHub
1faa407aed
Merge pull request #52 from xmindlab-heicode/feat/sse-events-stream-51
...
feat(#51 ): SSE 实时事件流 GET /api/swarms/{id}/events/stream(驾驶舱实时流,HM 反代给客户端)
2026-06-13 23:45:58 +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 GitHub
a978244cdd
Merge pull request #50 from xmindlab-heicode/fix/rbac-naming-swarm-system-44
...
fix(k8s/#44): RBAC 清单对齐 swarm-system + swarm-orchestrator (Bug2)
2026-06-12 18:37:41 +08:00
Fasthei and Claude Opus 4.8
f8b42d373b
fix(k8s/#44): RBAC 清单对齐 swarm-system + swarm-orchestrator(修 #44 Bug2)
...
orchestrator-deployment.yaml 用 ns swarm-system + SA swarm-orchestrator,但
rbac/* 仍是 ns default + SA orchestrator-sa → 按官方清单 apply 后 SA 不匹配,
orchestrator 无权拉 agent pod(#44 Bug2)。
统一三件套到 swarm-system + swarm-orchestrator(= 生产实际运行的命名):
- serviceaccount: swarm-orchestrator / swarm-system
- role: orchestrator-role / swarm-system
- rolebinding: subject swarm-orchestrator/swarm-system, roleRef orchestrator-role
至此「从仓库 apply」可复现生产 RBAC。
影响范围:agent_swarm k8s 部署物料。不改契约/计费/审计/密钥/运行时代码。
注:agent-deployment-*/orchestrator-deployment-simple 等备用清单仍引用旧 orchestrator-sa,
属独立清理项(非 #44 Bug2 范围),另行跟进。
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com >
2026-06-12 18:37:04 +08:00
Fasthei and GitHub
b8dec09054
Merge pull request #49 from xmindlab-heicode/feat/redis-tls-auth-url
...
fix(redis/#44): 补回漏合的 keys() 集群 fan-out + Dockerfile COPY benchmark/ (2b0f2fe )
2026-06-12 18:26:22 +08:00
zsbgnw12 and GitHub
019e404a77
Merge pull request #47 from xmindlab-heicode/feat/benchmark-selfcert-collector
...
feat(benchmark): 自证采集器(阶段0+1) + 真实 run 数据采集落库(阶段2)
2026-06-12 18:20:35 +08:00
Fasthei and Claude Opus 4.8
27739af446
feat(benchmark): 导出器接入 Cosmos NoSQL + Blob 存储账户(可组合多 target)
...
阶段3 数据落库:BENCHMARK_EXPORT_TARGET 支持逗号组合 cosmos,blob(默认 none)。
- CosmosExporter:Cosmos DB for NoSQL,一 run 一文档(id=swarm_id,分区键 /swarm_id)。
- BlobExporter:存储账户归档 <scenario>/<swarm_id>.json。
- get_exporters() 解析多 target;某 target 缺凭据/未知则跳过+告警,不影响其它与 run。
- capture 对每个 exporter 独立 to_thread 导出,互不影响。
- orchestrator/requirements:加 azure-cosmos/azure-storage-blob/azure-identity(懒导入)。
安全:所有连接串/AccountKey 仅从环境读(经 Secret/secret_ref 注入),
绝不写进代码/日志/提交(组织安全规则)。
验证:新增 test-benchmark-export.py(target 解析/隔离/doc 成形) + capture/selfcert/
collector 回归全 PASS。
影响范围:agent_swarm benchmark 导出层 + 依赖;运行时只读钩子不变;导出默认关、无密钥落地。
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com >
2026-06-12 18:12:46 +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
Fasthei and Claude Opus 4.8
b5cc68c977
feat(benchmark): 落地自证采集器(阶段0+1)— S_gain≡G_E 接通 S_swarm + leaderboard
...
阶段0(定口径,docs/benchmark/emergence-evaluation.md §6 v2.1-impl):
- S_gain ≡ G_E(差值,不强制归一 [0,100],与标准「见涌现增益」字面一致)。
- 聚合 S_gain 取对最强基线(Q_base 最大)的 G_E(最保守,避免挑弱基线虚高)。
- Q ≡ Q_quality;swarm_valid 仍要求对全部基线 G_E>0 且 G_E,c>0。
阶段1(采集器):
- 新增 benchmark/collectors/selfcert_collector.py:把套件 5 份 BenchmarkRunRecord
(swarm+4基线)+ 可选活体 SwarmMetrics 合流,经 baselines.compare 算 G_E/G_E,c,
补全 run_collector 无法自算的 s_gain/g_e/g_e_cost/s_swarm,可能时产出 Benchmark_Agent。
- benchmark/leaderboard:实现排行榜聚合+渲染(标准 §11 字段)。
- run-benchmark-suite.py 接入自证 + leaderboard 输出。
诚实纪律(组织规则 #9):缺真实输入一律 NaN+coverage False,不伪造。
- O(可观测性)标准无公式 → 恒 NaN;Gov 计数器未实现 → 无活体治理则 NaN。
- 故完整 Benchmark_Agent 数字仍待 O 公式 + Gov 计数器(阶段2),采集器明列缺口。
验证:新增 test-benchmark-selfcert.py(17 项)+ 现有 benchmark 测试(metrics/
collector/comparison/runners)+ offline suite + 契约冒烟(runtime/merge/freeze)全 PASS。
影响范围:仅 agent_swarm benchmark 模块 + docs;不改 Manager↔Swarm 契约/计费/审计/密钥/发布链路。
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com >
2026-06-12 17:38:19 +08:00
Fasthei and Claude Opus 4.8
2b0f2fe6f2
fix(redis): cluster 模式 keys() 跨所有主分片 fan-out + 修 Dockerfile 漏拷 benchmark/( #44 )
...
实测 heicode-rd(OSSCluster,2 分片):默认 keys() 只命中单节点,
漏掉其它分片上的 key → agent_registry/task_queue 枚举不全。
cluster 模式下改用 target_nodes=PRIMARIES,redis-py 合并各节点结果。
附带修 agent_swarm#44 Bug1:Dockerfile.orchestrator 漏 COPY benchmark/
(orchestrator/quality.py 启动即 import benchmark.fixtures/metrics)→
原镜像 CrashLoopBackOff。新增 .dockerignore 控制构建上下文。
影响范围:仅 agent_swarm orchestrator(连接层 + 构建物料);
不改契约/计费/审计/密钥落地。
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com >
2026-06-12 17:11:28 +08:00
Fasthei and GitHub
161a369c0e
Merge pull request #46 from xmindlab-heicode/feat/redis-tls-auth-url
...
feat(redis): 支持 TLS + 密码 + REDIS_URL(接托管 Redis,如 heicode-rd)
2026-06-12 17:01:10 +08:00
Fasthei and Claude Opus 4.8
35aab3a643
feat(redis): 加 REDIS_CLUSTER 支持 OSS Cluster 端点(heicode-rd 必需)
...
heicode-rd(Azure Redis Enterprise)database clusteringPolicy=OSSCluster,
裸 redis.Redis 客户端在多分片下 keys()/跨 slot 操作会误路由/抛 MOVED。
- REDIS_CLUSTER truthy → 用 redis.asyncio.cluster.RedisCluster(URL 或
host/port 两种入参,密码/TLS 同样支持)。cluster 模式无 DB select,
REDIS_DB 被忽略(仅逻辑 DB0)。
- 不设时维持 standalone 行为,完全向后兼容。
- 测试加 cluster 用例;manifest/DELIVERY 补 REDIS_CLUSTER 说明。
验证:连接配置单测 4 项 + REDIS_FAKE 回退 + test-runtime-contract /
test-contract-freeze / test-merge-smoke 全 PASS。
影响范围:仅 agent_swarm orchestrator 连接层;不改契约/计费/审计/密钥落地。
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com >
2026-06-12 17:00:37 +08:00
Fasthei and Claude Opus 4.8
aa498fc318
feat(redis): 支持 TLS + 密码 + REDIS_URL(接托管 Redis,如 heicode-rd)
...
orchestrator/redis_client.py 之前只支持裸 redis.Redis(host,port,db)
明文连接,无法连 Azure Redis Enterprise(强制 TLS + access key)。
改动:
- 新增 REDIS_URL(优先),rediss:// 自动启用 TLS,凭据写在 URL;
否则用离散 REDIS_HOST/PORT/DB + 可选 REDIS_PASSWORD / REDIS_SSL。
- 完全向后兼容:都不设时维持现有明文 redis-service:6379 行为。
- 凭据只读 env(经 Secret/secret_ref 注入),日志只打脱敏目标,
绝不输出 URL / 密码。
- 新增 scripts/test-redis-connection-config.py(无需真实 redis)。
- k8s manifest 补 Secret 引用示例;DELIVERY.md 补环境变量表。
验证:新单测 3 项 + REDIS_FAKE 回退 + test-runtime-contract /
test-contract-freeze / test-merge-smoke 全 PASS。
影响范围:仅 agent_swarm(orchestrator 连接层)。
不改 Manager↔Swarm 契约 / 计费 / 审计字段 / 发布链路。
涉及密钥:仅新增「从环境读取」路径,无任何密钥写入代码或日志。
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com >
2026-06-12 16:50:27 +08:00
Fasthei and GitHub
b83638a475
Merge pull request #42 from xmindlab-heicode/feat/agent-launcher-k8s-backend
...
agent_launcher:补回一等 kubernetes 后端(每 agent 一 Pod,key 经 Secret 引用不内联)(Refs #16)
2026-06-11 23:05:38 +08:00
Fasthei and GitHub
d7c9cd64b6
Merge branch 'main' into feat/agent-launcher-k8s-backend
2026-06-11 23:05:02 +08:00
Fasthei and GitHub
0d6dec18eb
Merge pull request #43 from xmindlab-heicode/feat/key-injection-contract
...
模型 key 注入对接:定死 HM #60 参数(KV value JSON + per-user 吊销握手)(Refs #16 #60)
2026-06-11 23:04:15 +08:00
Songhaoz666 and Claude Opus 4.8
82eb2bbdd5
A.3 措辞纠正:KV RBAC 归属 HM/运维(其库 heicode-kv)+ Swarm 先 provision Pod 身份(Refs #16 #60)
...
回应 @zsbgnw12 在 #43 的纠正:heicode-kv 是 HM 侧库,库上 RBAC 授权由 HM/运维做,
Swarm 仅提供 Pod 的 Workload Identity id + 收窄作用域。并如实标注:我方 Pod 的
Workload Identity 目前未 provision(仓内无 azure.workload.identity 注解 / IaC),
A.3 第一步是 Swarm 侧建 UAMI→federate orchestrator-sa→注解 SA,属 AKS/Azure 基础设施
动作,不在本仓。参数面(A.1/A.2/A.4/A.5+B.1/B.2)不受影响、仍冻结。
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com >
2026-06-11 21:23:38 +08:00
Songhaoz666 and Claude Opus 4.8
0cbab3f750
模型 key 注入对接:定死 HM #60 参数(KV value JSON + per-user 吊销握手)(Refs #16 #60)
...
回应 HM「#60 落地前需 Swarm 定死的参数清单」。Swarm 侧逐条定死并落实现:
- A.2 KV secret value 格式:JSON {"openai_api_key":"sk-..."}(对齐 callback 签名密钥
约定),解析字段 openai_api_key;裸 sk- 串兼容;解析不到/字段缺失不伪造。实现
agent_launcher._extract_model_key + _resolve_secret_ref。
- A.5 吊销信号(事件驱动):sk- per-user 长存;stop 为唯一终态(completed/failed 经
…/input 可重开故保 key)。某用户全部 run 被 stop(retained 集清空)时,运行时发
恰好一次 swarm.pool_terminated{user_id, secret_ref},HM 据此吊销 sk- + 清 KV。
单 run swarm.stopped 不触发吊销。实现 swarm_runtime.retain_run_for_user /
release_run_and_maybe_terminate_pool(per-user retained 集 + 一次性 flag)。
- A.1 粒度:每用户一把、跨 run 复用;KV 命名 swarm-model-key-<user_id>(文档)。
- A.4 OPENAI_API_BASE:Swarm 部署常量(已实现),不经 create 下发(文档确认)。
- A.3 KV 读 RBAC:⚠ 待定(联调阻塞前置)——如实标注归属未敲定,不伪造已就绪。
- B.1:CLIENT_GUIDE §9 /events 游标改 after=<next_after>(HM 不透明游标,非 sequence)。
swarm.pool_terminated 为 HM 控制面生命周期事件,不入 FROZEN_CLIENT_EVENT_TYPES、
不渲染驾驶舱;payload secret_ref 为 azkv:// 引用(非明文 key)。
文档:runtime-contract §3.3.1(参数表)、event-schema(注册 + 说明)、
security-boundary §6(吊销握手 + RBAC 待定)。测试 scripts/test-key-injection-contract.py
(KV 格式解析 + 吊销握手:单 run/多 run 保留/不重复吊销/teardown 后重新武装)+ CI 步。
不动 Manager 面接口、HMAC 回调、审批链、计费/审计字段语义。
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com >
2026-06-11 17:57:15 +08:00
Songhaoz666 and Claude Opus 4.8
af26455a8b
agent_launcher:新增一等 kubernetes 后端(每 agent 一 Pod,key 经 Secret 引用不内联)(Refs #16)
...
回应「我们跑在 k8s pods 上」——此前 launcher 只有 dev 的 subprocess + 通用 command hook,
未把 k8s 作为一等后端,且把 OPENAI_API_KEY 内联进 env(在 k8s 会落 etcd)。本次:
- 新增 AGENT_LAUNCH_BACKEND=kubernetes:每 agent 一个 Pod(build_pod_manifest)——资源
requests/limits、标签 heicode-swarm-id/heicode-user-id(GC/teardown)、restartPolicy OnFailure、
serviceAccountName;非敏感 env 内联,**OPENAI_API_KEY 经 secretKeyRef 引用每-swarm k8s Secret
(build_secret_manifest,via kubectl apply -f - stdin),绝不内联进 PodSpec(不落 etcd/argv)**。
- stop_launched:k8s 按标签 kubectl delete pod,secret;subprocess 仍 terminate。
- config:AGENT_POD_IMAGE/NAMESPACE/SERVICE_ACCOUNT/CPU|MEM_REQUEST|LIMIT;ORCHESTRATOR_URL=
集群内 Service DNS。文档注明前置(kubectl + 最小 RBAC ServiceAccount + NetworkPolicy)与
硬化替代(azkv CSI SecretProviderClass,编排器全程不碰明文)。
文档:runtime-contract §3.3 后端列表加 kubernetes(含密钥/RBAC/Service DNS/CSI);
security-boundary §6 增 K8s pod 边界(Secret 引用不内联、最小 RBAC、NetworkPolicy、CSI 硬化)。
测试:test-agent-launcher 增 k8s manifest 断言(标签、secretKeyRef 非内联、原文不在 Pod manifest、
资源限额、无 secret 则省略 key)。
影响范围:仅 agent_swarm(launcher + 文档 + 测试)。默认仍 backend=none,CI/e2e 不变。
Refs #16
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com >
2026-06-11 17:19:35 +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
1480146e07
Merge pull request #41 from xmindlab-heicode/feat/swarm-io
...
Swarm I/O:接收用户 prompt(追加输入)+ 返回结果(Refs #40)
2026-06-11 17:06:04 +08:00
Fasthei and GitHub
02b8b08ab3
Merge branch 'main' into feat/swarm-io
2026-06-11 17:03:58 +08:00
Fasthei and GitHub
c04c306d78
Merge pull request #38 from xmindlab-heicode/feat/frontend-api-freeze
...
frontend-event-api:明确 run/task/event 稳定 API + Agent 调度入口已统一(Refs #18)
2026-06-11 17:03:36 +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
Fasthei and GitHub
10d54fee61
Merge pull request #35 from xmindlab-heicode/feat/runtime-contract-agent-env
...
Swarm 负责拉起 agent + 执行限额 + runtime-contract §3.3(Refs #16)
2026-06-11 16:45:36 +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
fb367c4373
runtime-contract §3.3:拉起触发链标为「提案待确认」,不冻结(Refs #16)
...
回应 HM 复审(#16):§3.3 此前把「AM 拉起(HM 触发)」写成已定论超前了——该触发链
(谁调 AM、何时拉起、agent 池由谁提供)尚未与 AM(@azgy)/HM(@zsbgnw12) 敲定。本次:
- 顶部加冻结状态说明:env 字段清单已稳定,触发链未冻结、待确认。
- 澄清 §1「派发」= 指派给已连入 agent,非编排器拉 pod(§1 与 §3.3 不矛盾,但都未定义拉起方)。
- 把拉起流程明确标为「提案」:去中心化下无 per-run agent 清单;agent 为 per-user 常驻池,
由 HM 触发 AM 拉起(AM 无批量接口则 HM 循环调模板 POST /agents)。
仅文档。Refs #16
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com >
2026-06-11 14:33:48 +08:00
Songhaoz666 and Claude Opus 4.8
0787e337f6
frontend-event-api:明确 run/task/event 稳定 API + Agent 调度入口已统一(Refs #18)
...
新增 §6「Swarm 侧冻结口径」:①「前端可渲染 run/task/event 稳定 API」本仓已冻结——REST
(/{id}、/tasks、/events?after=<sequence>、/workflow、/metrics、/diagnostics、/audit) +
event-schema FROZEN v1 客户端事件集 + per-swarm sequence 去重续传;②「Agent Registry/调度入口
统一」蜂群内单实现——agent_registry(WS 注册) + swarm_dispatch 自选(能力+τ+负载+预算,见
agent-capability-schema/dispatch_score/decision_engine);③ 外部/后续(非本仓):SSE 传输
(HM Phase2 #46 )、跨平台统一 registry/quota/routing(Infra #2 )、cockpit 渲染(客户端仓)。
纯文档、纯追加 §6(不动 header/§4/§5),与 #34 对同文件的改动不重叠,可无冲突合并。
Refs #18
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com >
2026-06-11 09:45:00 +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
Songhaoz666 and Claude Opus 4.8
2e792bc8eb
runtime-contract §3.3:蜂群专家 agent 拉起环境契约(Refs #16)
...
回应 agent_swarm#16 的接线问题:钉死「per-user sk- 怎么进 agent」。编排器不拉 agent / 无 AM 客户端 / 不持 key,agent 由 AM 拉起(HM 触发,同模板 mintAgentModelToken→env)。新增 §3.3 列出 AM 拉起蜂群专家 agent 必须注入的 env(OPENAI_API_KEY=per-user sk-、OPENAI_API_BASE=HM /v1、OPENAI_MODEL、ORCHESTRATOR_URL、AGENT_ID、AGENT_CAPABILITIES、HEICODE_USER_ID、可选 WORKSPACE_DIR/GIT_REPO_URL),均为 agent/main.py 实读;key 走 HM→AM server→server、不经 create 体;token 绑 agent 生命周期;并注明运行时事件前置(SWARM_RUNTIME_ENABLED 真派发 + agent 连入)。
仅文档;无代码/契约逻辑改动。Refs #16
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com >
2026-06-11 08:51:16 +08:00
Fasthei and GitHub
5138d9a370
Merge pull request #33 from xmindlab-heicode/feat/client-guide-billing
...
CLIENT_GUIDE 校正:计费口径挑明 + §5/§7 去除已删除的 ENABLE_* 开关(Refs #16)
2026-06-10 22:48:45 +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
a01472ffd0
CLIENT_GUIDE 校正:计费口径挑明 + §5/§7 去除已删除的 ENABLE_* 开关(Refs #16)
...
计费(§5/§8):把"经 secret_ref 注入 / NewAPI 计量"挑明为——OPENAI_API_KEY = HM 为该用户现签的 per-user sk-,OPENAI_API_BASE = HM /v1,由 Agent 平台拉起 agent 时注入进程 env(不入 create 请求/回调/日志),模型调用扣发起用户 user.Quota、按 token 名归集;交叉引用 usage-billing §1/§2。回应 HM agent_swarm#16 / heicode-mananger#60。
文档/代码冲突修正(§5/§7):去中心化重构(#26 已合并)已删除 ENABLE_PLANNER_FALLBACK / ENABLE_REVIEW_LOOP 及单 critic 主控评审环,蜂群为唯一行为、无开关;CLIENT_GUIDE §5 仍写"设这些 flag 启用工作流"已过时。§5 重写为无条件流程(播种→自选→自主分解#7→竞争/接管#8→交叉评审#11→收敛#12→synthesize 汇总),列出仅剩的真实开关(MAX_REVIEW_CYCLES / MAX_AGENTS_PER_USER / ENABLE_QUALITY_EVAL+HEICODE_SANDBOX_ISOLATED / ENABLE_SUBTASK_HANDOFF);§7 本地联调示例去掉已删除的 flag。
仅文档;无代码/契约改动。Refs #16
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com >
2026-06-10 22:42:33 +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
e64ce6144a
Merge pull request #30 from xmindlab-heicode/feat/audit-trace-freeze
...
审计/链路追踪落地:可回放审计记录 FROZEN v1(Refs #17)
2026-06-10 21:39:53 +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
Fasthei and GitHub
5a3296e7d1
Merge pull request #28 from xmindlab-heicode/feat/contract-freeze
...
契约冻结 v1:Manager/客户端 Swarm Run 查询契约(Refs #2 #14 #15)
2026-06-10 18:36:38 +08:00
Fasthei and GitHub
4bc98cf177
Merge pull request #31 from xmindlab-heicode/feat/security-boundary-freeze
...
安全边界强制点:可验证边界 FROZEN v1 + 契约测试(Refs #19)
2026-06-10 18:26:46 +08:00
Songhaoz666 and Claude Opus 4.8
727737dd9b
安全边界强制点:可验证边界 FROZEN v1 + 契约测试(Refs #19)
...
issue #19 要求「secret 仅 ref/不落明文;workspace/tool/MCP/tenant 沙箱强制;边界可验证 + 测试」。
本仓**已强制**的三类边界此前散落、缺统一验证;本 PR 把它们合为一套可验证测试并冻结文档。
测试:scripts/test-security-boundary.py(hermetic,19 断言)覆盖本仓强制边界:
- secret:billing_context.secret_ref 非 azkv:// 入口拒绝;明文 password/access_token 等字段
在任意层级拒绝;非 azkv 的 *_ref 拒绝(validate_create_request / _reject_plaintext_secrets)。
- 脱敏:明文凭据 → [redacted];azkv secret_ref 透传(HM 对客户端再脱敏)(_redact_sensitive)。
- workspace:绝对路径 / `..` 逃逸 / 空路径拒绝,合法相对路径落在 workspace 根内
(task_executor._resolve_workspace_path)。
- 沙箱 fail-closed:未确认隔离时 assert_isolated 抛 SandboxIsolationError,确认后放行。
文档:docs/integration/security-boundary.md → FROZEN v1:§9 覆盖表标注「✅ ✔ 已实现+测试」
三类强制边界;其余按规则 #9 据实标 ⏸「本次不做」并给理由——tool/MCP 权限引擎(无工具层可治理)、
allowed_paths 按 grant 强制(待资源授权链)、Pod 强化沙箱(Infra)、租户隔离(有意不引入,
按 user/channelId 归因)。CI 新增该测试步。
影响范围:仅 agent_swarm(新增测试 + 文档冻结 + CI)。无运行时逻辑改动;不改 Manager↔Swarm
契约、计费、审批链、密钥处理(仅为既有强制点补可验证测试)。
Refs #19
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com >
2026-06-10 18:11:25 +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