13 Commits
Author SHA1 Message Date
gongzhiyongandClaude Opus 4.8 fb1eeeebfa fix(swebench): 真实仓 patch 捕获 + agent 稳定性
#1 稳定性:HEARTBEAT_TIMEOUT 30→120(可配 AGENT_HEARTBEAT_TIMEOUT)——真实仓 clone/长
模型调用不再误杀 agent。
#2 正确性/忠实度:
- 透传 GIT_BASE_COMMIT;agent clone 改为浅 fetch+checkout 该 commit(在正确基线上读/改,
  且大仓也快);emit_patch 持久化 base_commit + _git_diff 对 SHA 走浅 fetch。
- agent 读文件预算可配并调大(AGENT_CTX_MAX_FILES=40/BYTES=40000),LLM 看到完整文件,
  避免全量重写截断 → diff 失真。launcher 透传这些 env 给 agent pod。

import + runtime-contract/result-aggregator/security-boundary 测试全绿。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-22 00:25:38 +08:00
gongzhiyongandClaude Opus 4.8 74f5ce2f97 feat(launcher): 弹性 agent 池 — 按需扩缩取代固定预起
agent_autoscale_loop(ENABLE_AGENT_AUTOSCALING):初始只起 AGENT_LAUNCH_MIN_POOL 个,
按每个 run 的 PENDING 任务积压超过空闲 agent 时 top-up,上限 MAX_POOL/per-user cap。
plan_launch_specs 加 count_override/id_start 支持非碰撞增补。trivial run 用少量 agent,
重 run 自动扩展。fail-soft,backend=none 时 no-op。

manifest:MIN/POOL 16→2 + ENABLE_AGENT_AUTOSCALING=1(初始小、按需长)。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-21 22:08:55 +08:00
gongzhiyongandClaude Opus 4.8 98fb0d2bdb feat(sandbox): Daytona 云沙箱后端 — 代码执行移出 Pod(SANDBOX_BACKEND=daytona)
§8.1 提到的"专用 sandbox worker"路径:模型生成代码在 Daytona 隔离沙箱执行,不在
本 Pod 跑;只上传生成文件 + sandbox_runner.py,绝不传 env/secret。复用 _runner.py
保证 SandboxResult 一致。fail-soft:Daytona/传输出错回退 Pod 内 subprocess。
双门控(ENABLE_QUALITY_EVAL+HEICODE_SANDBOX_ISOLATED)不变,不削弱 fail-closed。

依赖:加 daytona==0.189.0;为满足其 otel floor 把 otel 1.24→1.42、instrumentation
0.45b0→0.63b1、pydantic 2.9.2→2.13.4(与 agent 对齐)。import + runtime-contract/
security-boundary/result-aggregator 测试在新依赖下验证全绿。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-21 21:14:07 +08:00
gongzhiyong e263dae115 feat(agent): Jina 搜索改用标准 MCP SDK 接入
- agent/task_executor.py: Jina 搜索从手搓 httpx 改为官方 mcp SDK
  (streamablehttp_client + ClientSession);工具经 OpenAI function-calling 暴露给模型
- agent/requirements.txt: +mcp==1.28.0;pydantic 2.9.2->2.13.4(mcp 要求 >=2.11)
- orchestrator/agent_launcher.py: JINA_API_KEY 经 per-swarm Secret 透传给 agent pod
  (SENSITIVE_ENV_KEYS),不内联 PodSpec
- k8s/orchestrator-local.yaml: 本地部署清单(默认 in-pod 沙箱评估开关 + JINA_API_KEY)

沙箱保持默认 in-pod 方案,未引入 OpenSandbox。
影响范围: agent_swarm(agent/orchestrator) + Agent(新增 Jina MCP 工具)。
密钥经 k8s Secret 注入无明文。不影响 Manager 契约/计费/审计/发布链路。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
(cherry picked from commit deb984ac38)
2026-06-21 20:45:56 +08:00
gongzhiyongandClaude Opus 4.8 167adfcb56 fix(deploy): heicode-test 上云修复 — ACR 名/Redis 明文/plan token/聚合阈值/git grant
- launcher 透传 AGENT_PLAN_MAX_TOKENS 给 agent pod(避网关 >32768 → 400 断 fan-out)
- manifest: ACR heicodeest→heicodetest、AGGREGATE_ACCEPTANCE_THRESHOLD=70、
  HEICODE_SECRET_swe_git_1 走 secretKeyRef(SWE-bench clone 凭据)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-21 20:45:56 +08:00
gongzhiyong 2e7da834c6 Set test orchestrator images to heicodeest ACR 2026-06-20 23:50:47 +08:00
gongzhiyongandClaude 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
local 4d77b9263e chore: 本地测试快照(#7 自底向上分解 + _parse_task 健壮化 + handoff 透传 + 本地部署清单)
CI / tests (push) Failing after 12m5s
CI / guardrails (push) Failing after 12m6s
仅供导出到 xiaohei/Agentswarm 的本地测试镜像快照,非主仓 PR。
2026-06-17 12:58:28 +08:00
gongzhiyongandClaude Opus 4.8 aa4679f610 fix(#56): 补齐 k8s 部署产物 —— 编排器镜像装 kubectl、RBAC 加 secrets、Deployment 接拉起 env + workload-identity label
让 k8s 拉起链路在仓内"可部署即可用"(此前线上实测全缺):

- Dockerfile.orchestrator:装 `kubectl`(pin AKS 1.34;linux/amd64)。launcher 靠 shell
  `kubectl apply/delete` 建/删 agent Pod + 每-swarm key Secret,镜像无 kubectl 则 k8s 后端必失败。
- k8s/rbac/orchestrator-role.yaml:加 `secrets`(create/delete/list/get)——否则建不了模型 key
  Secret、agent keyless。并注明 Role 命名空间须与 AGENT_POD_NAMESPACE 一致。
- k8s/orchestrator-deployment.yaml:
  - pod 模板加 `azure.workload.identity/use: "true"`(AKS webhook 注入 token,配合已注解的
    SA + UAMI 读 heicode-vault)。
  - 接入拉起 env:`AGENT_LAUNCH_BACKEND=kubernetes`、`AGENT_POD_IMAGE=heicode.azurecr.io/swarm-agent:latest`、
    `AGENT_POD_NAMESPACE=swarm-system`(同 RBAC ns)、`ORCHESTRATOR_PUBLIC_URL=ws://orchestrator-service...:8000`、
    `AGENT_OPENAI_API_BASE=https://code.heicode.cc/v1`、`SECRET_RESOLVER=azkv`。
  - image 指向 ACR(`heicode.azurecr.io/swarm-orchestrator`,tag 部署时 pin)。

校验:两个 manifest YAML 解析通过(label/env/secrets 均在);test-agent-launcher / test-swarm-guard /
test-contract-freeze 全绿。无明文密钥。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-14 19:39:10 +08:00
FastheiandClaude 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
FastheiandClaude 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
FastheiandClaude 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
Songhaoz666 d0fa193f79 Initial commit 2026-06-08 17:32:34 +08:00