fix: add aipod imageRef work-ready runner reuse

This commit is contained in:
AgentRun Codex
2026-06-11 01:21:56 +08:00
parent 59272f8edb
commit 5a6e5a4bbd
22 changed files with 598 additions and 32 deletions
+21 -9
View File
@@ -2,7 +2,7 @@
本文是 AgentRun `v0.1` runner/backend 启动前的权威装配 SPEC。所有会进入运行时容器、进程、文件系统或环境变量的执行输入,都必须先落到本文定义的装配模型,再由 manager/runner 渲染为受控 Job 输入;不得在 CLI、Queue、runner Job、issue 过程或临时热补丁中绕过装配模型直接拼接 credential、host path 或隐式环境。
`RuntimeAssembly` 只回答一个问题:一次 run 到底用哪份 backend 镜像、哪个 profile/credential scope、哪份 session、哪份代码、初始 prompt、skill 和工具 credential。`BackendImageRef``ProfileRef``SessionRef``ResourceBundleRef` 仍是四个一等运行时要素;credential 注入不是第五个杂项要素,而是挂在 `ProfileRef``ResourceBundleRef` 或 tool scope 上的 SecretRef 装配引用。初始 prompt 与 skill 注入也不是第五条运行时路径,它们属于 `ResourceBundleRef` 指向的 Git-only 非敏感内容。
`RuntimeAssembly` 只回答一个问题:一次 run 到底用哪份 backend/env 镜像、哪个 profile/credential scope、哪份 session、哪份代码、初始 prompt、skill 和工具 credential。`BackendImageRef``ProfileRef``SessionRef``ResourceBundleRef` 仍是四个一等运行时要素;credential 注入不是第五个杂项要素,而是挂在 `ProfileRef``ResourceBundleRef` 或 tool scope 上的 SecretRef 装配引用。初始 prompt 与 skill 注入也不是第五条运行时路径,它们属于 `ResourceBundleRef` 指向的 Git-only 非敏感内容。
## 最简四要素
@@ -10,7 +10,7 @@
| 要素 | 最小字段 | v0.1 含义 | 不包含 |
| --- | --- | --- | --- |
| `BackendImageRef` | `image` | digest-pinned backend/runner 镜像。 | API KEY、profile config、用户代码、session 文件。 |
| `BackendImageRef` | `source` 或已解析 `image` | Aipod env image Dockerfile source 与最终 digest-pinned backend/runner 镜像。 | API KEY、profile config、用户代码、session 文件、可变 image tag。 |
| `ProfileRef` | `profile``secretRef` | provider profile 和 API KEY/配置 SecretRef。 | backend 镜像、session、repo 文件、GitHub/业务工具 credential。 |
| `SessionRef` | `sessionId``null` | backend 会话文件持久化引用;P0 可以为 `null`。 | API KEY、完整 `CODEX_HOME`、Git workspace。 |
| `ResourceBundleRef` | `kind="gitbundle"``repoUrl``bundles[]`、可选 `ref` / `commitId` / `promptRefs` / `requiredSkills` | 初始代码/文件输入、工具目录、skill 目录、required skill 校验和稳定初始 promptP0 固定 Git-only gitbundle,默认从 repo/ref 解析实际 commit。 | 上传文件、对象存储 artifact、inline env、Secret value、会话历史、旧 inline seed、inline skill manifest。 |
@@ -20,7 +20,13 @@ P0 最小 JSON 形态:
```json
{
"backendImageRef": {
"image": "127.0.0.1:5000/agentrun/agentrun-mgr@sha256:..."
"source": {
"kind": "env-image-dockerfile",
"repoUrl": "git@github.com:pikasTech/agentrun.git",
"commitId": "0000000000000000000000000000000000000000",
"dockerfilePath": "deploy/container/Containerfile"
},
"image": "127.0.0.1:5000/agentrun/agentrun-mgr-env@sha256:..."
},
"profileRef": {
"profile": "codex",
@@ -124,10 +130,15 @@ HWLAB Workbench 的 project/workspace 不属于 RuntimeAssembly 四要素,也
### BackendImageRef
- `image` 必须是 digest-pinned image
- image 来源必须是 CI/CD artifact catalog、GitOps manifest 或 manager allowlist;客户端不能在 run payload 中传任意镜像。
- `BackendImageRef.source` 是 env image Dockerfile source,来自 AipodSpec `spec.imageRef` 或受控 runtime default`kind` 固定为 `env-image-dockerfile`,最小字段为 `repoUrl`、完整 `commitId` 和仓库内相对 `dockerfilePath`
- `BackendImageRef.image` 是 source 解析后的 digest-pinned image,必须来自 CI/CD artifact catalog、GitOps manifest 或 manager allowlist;客户端不能在 run payload 中传任意可变镜像。
- runner Job 创建前必须先用 `source` 解析 env image identity,并优先从 artifact catalog / registry 复用已有 digest;未命中只能返回明确 build-required 或进入受控 CI/CD,不能在普通任务容器内现装依赖。
- v0.1 可以继续使用现有 agentrun runner 镜像,不要求立即拆独立 backend image。
- 验收时只需要能追溯实际 Deployment/Job image digestsource commit。
- 验收时必须能追溯实际 Deployment/Job image digestsource commit、Dockerfile path、env identity 和 reuse/build 状态
- runner 镜像必须是 work-ready 执行环境:基础 CLI、Bun/Node/npm、Git/SSH/GitHub CLI、kubectl、curl、ripgrep 和 AgentRun 生产依赖必须在 env image 构建阶段进入镜像或受控预装层。普通任务不得在运行时用 `apt``apk``bun install``npm install` 或等价命令补装基础环境。
- `workReady` capability 摘要必须出现在 manager health、runner job dry-run/response、queue dispatch response 和 runner startup event 中;摘要只能包含版本、工具名、版本号、依赖策略和 `valuesPrinted=false`,不得输出 env value、token 或 Secret 文件内容。
- runner 启动后必须先执行短 smoke:镜像层检查 `bun``node``npm``git``ssh``gh``rg``curl``kubectl`Artificer/UniDesk 工具型 gitbundle 装配后再检查 `tran``trans``apply_patch`。缺失时必须快速 `infra-failed`,不能把问题留给 prompt 内排查。
- 项目依赖不属于默认 runtime preflight。AgentRun 自身 `node_modules` 固定为镜像层 `/opt/agentrun/node_modules`boot 后只 symlink 到源码 checkout;业务 repo 的 `bun install`/`npm install` 只能由显式任务、派生镜像或受控 workspace cache 承担,不能成为每个 Aipod/Queue task 的默认前置。
### ProfileRef
@@ -230,7 +241,7 @@ skill 只来自 gitbundle 复制进 workspace 的 `.agents/skills/<name>/SKILL.m
5. Runner materialize tool credential 到该 run 允许的 env/file projection;未实现的 tool scope 必须显式 failed/blocked,不能静默跳过后让 agent 自己猜凭据。
6. Runner materialize `kind="gitbundle"` resource bundle 到 workspaceP0 未实现时必须显式 blocked,不能猜测 host path。
7. Runner 按 `bundles[]` 复制目录或文件,准备 workspace `tools/`、发现 `.agents/skills`,校验 `requiredSkills`,读取并校验 `promptRefs`,写入有界 assembly event。
8. Runner 启动 backend,并在 event 中记录 image digest、profile、SecretRef 名称/key、tool credential scope、sessionRef、repoUrl、requested ref/commit、materialized commit、bundles、promptRefs、requiredSkills、tools 和 skillDirs 摘要。
8. Runner 启动 backend,并在 event 中记录 imageRef source、env identity、image digest、reuse/build 状态、profile、SecretRef 名称/key、tool credential scope、sessionRef、repoUrl、requested ref/commit、materialized commit、bundles、promptRefs、requiredSkills、tools 和 skillDirs 摘要。
任何一个要素缺失或不合法,都必须按该要素失败;不得静默 fallback。
@@ -239,8 +250,9 @@ skill 只来自 gitbundle 复制进 workspace 的 `.agents/skills/<name>/SKILL.m
### A1 BackendImageRef 验收
- 实际 manager Deployment 和 runner Job 使用 digest-pinned image。
- event、CLI 或诊断输出能看到 image digest 可追溯 GitOps/catalog。
- run payload 不能传任意 image 字符串。
- event、CLI 或诊断输出能看到 imageRef source、env identity、image digest 可追溯 GitOps/catalog 条目
- run payload 不能传任意 image 字符串Aipod 只能声明 env image Dockerfile sourcedispatch 解析后才进入 runner job image
- 启动 Aipod 时命中已有 env identity 必须 reuse digest-pinned image;不得触发任务内 `apt`/`apk`/`bun install`/`npm install`
### A2 ProfileRef 验收