Merge origin/master into feat/2010-hwlab-release-production-lane

This commit is contained in:
Codex
2026-07-15 09:26:46 +02:00
114 changed files with 4006 additions and 561 deletions
+8 -1
View File
@@ -14,7 +14,7 @@ bun scripts/cli.ts agentrun get tasks --limit 20
bun scripts/cli.ts agentrun describe task/<taskId>
bun scripts/cli.ts agentrun describe task/<taskId> --input -o json
bun scripts/cli.ts agentrun describe aipodspec/<name>
bun scripts/cli.ts agentrun events run/<runId> --limit 20
bun scripts/cli.ts agentrun events run/<runId> --after-seq 0 --expect 10 --timeout 120s --limit 20
bun scripts/cli.ts agentrun events run/<runId> --detail-seq <seq> -o json
bun scripts/cli.ts agentrun logs session/<sessionId> --tail 120
bun scripts/cli.ts agentrun result run/<runId> --command <commandId>
@@ -53,6 +53,13 @@ AipodSpec/Artificer、task manifest 和 queue 渐进披露见 [references/resour
- `unidesk-trans` required skill、runner tools bundle、`unidesk-ssh` SecretRef 和 endpoint presence 缺一项即归为装配失败;
- Secret 输出只显示对象、key、presence/fingerprint 与 `valuesPrinted=false`
- 默认输出保持低噪声表格/摘要;机器消费显式 `-o json|yaml``--raw`
- 主代理观察 active run 时默认使用单次长轮询:
- `--after-seq` 是可继续拉取的增量游标;
- `--expect <N>` 是等待条件;
- `--timeout <duration>` 默认 `120s`,达到 `expect` 或目标 run/command 终态时提前返回;
- timeout 到期返回当前事件,即使 0 条也明确披露 `timedOut``observed``nextAfterSeq`
- `--limit` 只控制输出预算,不得承担等待条件;
- CLI 只发起一个 manager-held 请求,禁止本地高频短轮询或忙轮询。
- 读取 task 的可重建输入:
- 使用 `agentrun describe task/<taskId> --input -o json`
- 该入口只投影 task create 字段、AipodSpec identity、资源引用和脱敏 provenance
@@ -62,6 +62,13 @@ Artificer 内部执行边界:
`agentrun events` 是高频渐进披露入口:
- active run 的推荐观察入口是:
- `bun scripts/cli.ts agentrun events run/<runId> --after-seq <cursor> --expect 10 --timeout 120s --limit 20`
- manager 在单个请求内等待 after-seq 后新增事件达到 `expect`,或目标 run/command 进入终态;
- 未达到条件时最多等待 `timeout`,默认 `120s`
- timeout 的部分返回和空返回都必须明确披露 `timedOut``observed``nextAfterSeq`
- 后续继续使用返回的 `nextAfterSeq`,不要恢复高频短轮询;
- `limit` 是独立输出预算,不能替代 `expect`
- 默认 human、`-o json``-o yaml` 最多返回 20 条同构事件摘要,并用一条 lookahead 披露 `hasMore``nextAfterSeq`
- tool call 只展示 identity、seq/type/status、commandId、工具、命令首行、exit/duration、output bytes/hash、truncation 与 `outputOmitted`
- 默认不得展开 stdout、stderr、skill 正文或完整 payload,也不得通过提高全局 stdout 阈值掩盖 dump
@@ -72,7 +79,7 @@ Artificer 内部执行边界:
- durable `resolutionAuthority` 保持原事实或显式脱敏,基于其他字段的非权威判断只进入独立 inference 字段;
- 标准 Git URL 移除 userinfo、query 和 fragmentSCP-like 与未知 remote 只披露不可逆 fingerprint
- credential value 和 URL credential 固定脱敏,`valuesPrinted=false`
- `--detail-seq``--after-seq``--limit``--full``--raw` 互斥,并在请求 manager 前 fail closed
- `--detail-seq``--after-seq``--expect``--timeout``--limit``--full``--raw` 互斥,并在请求 manager 前 fail closed
- 完整事件继续使用显式 `--full``--raw`,或按 `afterSeq=item.seq-1 --limit 1 --full` 下钻;
- 该 CLI 只渲染 AgentRun durable facts,不删除事件、不按正文去重,也不改变 Kafka/SSE 事件链。
@@ -189,6 +189,15 @@ bun scripts/cli.ts platform-infra sub2api codex-pool cleanup-probes --target D60
- 账号人类可读名称使用 `runtime apply --kind account-name --name <new-name>`
- 只接受单个精确账号 selector,先 dry-run,确认后自动回读名称;
- 只更新名称,不携带 credentials、priority、分组、容量、代理、状态或可调度字段。
- 单账号成本标注与优先级调优使用以下最短路径:
- 已知账号 selector 时,首个诊断入口固定为:
`runtime errors --target <target> --since <window> --group <group> --account <account>`
- 同一次账号级查询直接读取评分、可归因上游失败率、TTFT、用量、Token、标准 API 计费基数和当前名称成本标注;
- 只有需要确认 priority、capacity、schedulable、proxy 或临时不可调度规则时,才补一次 `runtime get --account <account>`
- 只有需要跨账号比较时才使用全组 `runtime errors --group <group>`;单账号任务不得先跑全组大报表,再重复账号级查询;
- priority 数值越小越优先。成本只参与人工经济性判断,必须同时考虑可靠性、TTFT、容量、可调度状态和样本置信度,不得按成本自动排序;
- 名称成本标注和 priority 是两个独立 runtime 字段:分别先 dry-run,再顺序 confirm;禁止并发更新同一账号,避免整对象更新互相覆盖;
- 两项 confirm 已各自回读一致后,最后只执行一次 `runtime get` 验收完整状态;不重复 confirm,不用全组查询代替账号回读。
- 模型映射先用 `runtime models --account ...` 获取原生配置与实时上游能力:
- 只有实时模型列表或真实模型请求证明支持时才确认写入。
- 禁止把名称相近的模型猜测为别名。
+40 -3
View File
@@ -30,12 +30,48 @@ testRuntime:
mode: prebuilt-images
repository: pikainc/pikaoa
commitPolicy: cli-required
branch: master
worktreeRemote: https://github.com/pikainc/pikaoa.git
readUrl: https://gitea.example.invalid/mirrors/pikainc-pikaoa.git
snapshotPrefix: refs/unidesk/snapshots/gitea-actions/pikaoa-master-test01
images:
api: registry.invalid/pikaoa/api:${commit}
worker: registry.invalid/pikaoa/worker:${commit}
web: registry.invalid/pikaoa/web:${commit}
migration: registry.invalid/pikaoa/migration:${commit}
initializer: registry.invalid/pikaoa/api:${commit}
pullPolicy: IfNotPresent
ci:
lane: pikaoa-test
namespace: pikaoa-ci
pipeline: pikaoa-test-test01-pac
pipelineRunPrefix: pikaoa-test-test01
serviceAccountName: pikaoa-test-test01-tekton-runner
workspaceSize: 1Gi
pipelineTimeout: 20m0s
toolsImage: registry.invalid/tools:latest
buildkitImage: registry.invalid/buildkit:rootless
build:
dockerfiles:
api: deploy/api.Dockerfile
worker: deploy/worker.Dockerfile
web: deploy/web.Dockerfile
images:
api: registry.invalid/pikaoa/api
worker: registry.invalid/pikaoa/worker
web: registry.invalid/pikaoa/web
networkMode: host
gitops:
readUrl: https://gitea.example.invalid/mirrors/pikainc-pikaoa.git
writeUrl: https://gitea.example.invalid/mirrors/pikainc-pikaoa.git
branch: test01-pikaoa-test-gitops
manifestPath: deploy/gitops/test01-test/resources.yaml
credential:
secretName: pac-gitea-pikaoa-test-test01
tokenKey: token
username: unidesk-admin
author:
name: PikaOA Test Fixture
email: pikaoa-test-fixture@unidesk.local
database:
configRef: config/platform-db/postgres-pk01.yaml#exports.connectionStrings.pikaoa-test-database-url
name: pikaoa_test
@@ -82,8 +118,9 @@ testRuntime:
sourceRef: ./secrets/pikaoa-test.env
sourceKey: PIKAOA_SESSION_SECRET
targetKey: PIKAOA_SESSION_SECRET
migration:
jobName: pikaoa-migrate
initializer:
mode: fresh-database-only
jobName: pikaoa-init
backoffLimit: 2
command:
- /usr/local/bin/pikaoa
+209 -6
View File
@@ -21,7 +21,7 @@ modules:
- audit
extensionContract:
registration: module-descriptor
persistence: schema-owned-migrations
persistence: schema-owned-initialization
api: versioned-http-routes
events: transactional-outbox
workers: named-consumer
@@ -49,12 +49,48 @@ testRuntime:
mode: prebuilt-images
repository: pikainc/pikaoa
commitPolicy: cli-required
branch: master
worktreeRemote: https://github.com/pikainc/pikaoa.git
readUrl: http://gitea-http.devops-infra.svc.cluster.local:3000/mirrors/pikainc-pikaoa.git
snapshotPrefix: refs/unidesk/snapshots/gitea-actions/pikaoa-master-nc01
images:
api: 127.0.0.1:5000/pikaoa/api:${commit}
worker: 127.0.0.1:5000/pikaoa/worker:${commit}
web: 127.0.0.1:5000/pikaoa/web:${commit}
migration: 127.0.0.1:5000/pikaoa/api:${commit}
initializer: 127.0.0.1:5000/pikaoa/api:${commit}
pullPolicy: IfNotPresent
ci:
lane: pikaoa-test
namespace: pikaoa-ci
pipeline: pikaoa-test-nc01-pac
pipelineRunPrefix: pikaoa-test-nc01
serviceAccountName: pikaoa-test-nc01-tekton-runner
workspaceSize: 8Gi
pipelineTimeout: 20m0s
toolsImage: 127.0.0.1:5000/hwlab/hwlab-ci-node-tools:node22-alpine-bun-v1
buildkitImage: 127.0.0.1:5000/hwlab/buildkit:rootless
build:
dockerfiles:
api: deploy/api.Dockerfile
worker: deploy/worker.Dockerfile
web: deploy/web.Dockerfile
images:
api: 127.0.0.1:5000/pikaoa/api
worker: 127.0.0.1:5000/pikaoa/worker
web: 127.0.0.1:5000/pikaoa/web
networkMode: host
gitops:
readUrl: http://gitea-http.devops-infra.svc.cluster.local:3000/mirrors/pikainc-pikaoa.git
writeUrl: http://gitea-http.devops-infra.svc.cluster.local:3000/mirrors/pikainc-pikaoa.git
branch: nc01-pikaoa-test-gitops
manifestPath: deploy/gitops/nc01-test/resources.yaml
credential:
secretName: pac-gitea-pikaoa-test-nc01
tokenKey: token
username: unidesk-admin
author:
name: PikaOA Test NC01 CI
email: pikaoa-test-nc01-ci@unidesk.local
database:
configRef: config/platform-db/postgres-pk01.yaml#exports.connectionStrings.pikaoa-test-database-url
name: pikaoa_test
@@ -65,6 +101,15 @@ testRuntime:
sourceKey: DATABASE_URL
targetKey: DATABASE_URL
runtime:
replicas:
api: 1
worker: 1
web: 1
resources:
api: { requests: { cpu: 100m, memory: 128Mi }, limits: { cpu: 1, memory: 512Mi } }
worker: { requests: { cpu: 100m, memory: 128Mi }, limits: { cpu: 1, memory: 512Mi } }
web: { requests: { cpu: 50m, memory: 64Mi }, limits: { cpu: 500m, memory: 256Mi } }
initializer: { requests: { cpu: 100m, memory: 128Mi }, limits: { cpu: 1, memory: 512Mi } }
secretName: pikaoa-test-runtime
apiServiceName: pikaoa-api
apiPort: 8080
@@ -101,8 +146,9 @@ testRuntime:
sourceRef: /root/.unidesk/.state/secrets/platform-infra/pikaoa-test.env
sourceKey: PIKAOA_SESSION_SECRET
targetKey: PIKAOA_SESSION_SECRET
migration:
jobName: pikaoa-migrate
initializer:
mode: fresh-database-only
jobName: pikaoa-init
backoffLimit: 2
command:
- /usr/local/bin/pikaoa
@@ -137,6 +183,163 @@ testRuntime:
livenessPath: /healthz
readinessPath: /healthz
releaseRuntime:
defaultTargetId: NC01
targets:
NC01:
enabled: true
validationOnly: false
node: NC01
route: NC01:k3s
namespace: pikaoa
ttlSeconds: 86400
waitTimeoutSeconds: 300
fieldManager: unidesk-pikaoa-release-runtime
taskState:
rootPath: /var/lib/unidesk/pikaoa-release-runtime
statusRequestTimeoutSeconds: 10
logTailLines: 80
cleanup:
mode: delete-namespace
requireOwnershipLabels: true
source:
mode: prebuilt-images
repository: pikainc/pikaoa
commitPolicy: cli-required
branch: release
worktreeRemote: https://github.com/pikainc/pikaoa.git
readUrl: http://gitea-http.devops-infra.svc.cluster.local:3000/mirrors/pikainc-pikaoa.git
snapshotPrefix: refs/unidesk/snapshots/gitea-actions/pikaoa-release-nc01
images:
api: 127.0.0.1:5000/pikaoa/api:${commit}
worker: 127.0.0.1:5000/pikaoa/worker:${commit}
web: 127.0.0.1:5000/pikaoa/web:${commit}
initializer: 127.0.0.1:5000/pikaoa/api:${commit}
pullPolicy: IfNotPresent
ci:
lane: pikaoa
namespace: pikaoa-ci
pipeline: pikaoa-nc01-pac
pipelineRunPrefix: pikaoa-nc01
serviceAccountName: pikaoa-nc01-tekton-runner
workspaceSize: 8Gi
pipelineTimeout: 20m0s
toolsImage: 127.0.0.1:5000/hwlab/hwlab-ci-node-tools:node22-alpine-bun-v1
buildkitImage: 127.0.0.1:5000/hwlab/buildkit:rootless
build:
dockerfiles:
api: deploy/api.Dockerfile
worker: deploy/worker.Dockerfile
web: deploy/web.Dockerfile
images:
api: 127.0.0.1:5000/pikaoa/api
worker: 127.0.0.1:5000/pikaoa/worker
web: 127.0.0.1:5000/pikaoa/web
networkMode: host
gitops:
readUrl: http://gitea-http.devops-infra.svc.cluster.local:3000/mirrors/pikainc-pikaoa.git
writeUrl: http://gitea-http.devops-infra.svc.cluster.local:3000/mirrors/pikainc-pikaoa.git
branch: nc01-pikaoa-gitops
manifestPath: deploy/gitops/nc01/resources.yaml
credential:
secretName: pac-gitea-pikaoa-nc01
tokenKey: token
username: unidesk-admin
author:
name: PikaOA NC01 CI
email: pikaoa-nc01-ci@unidesk.local
database:
configRef: config/platform-db/postgres-pk01.yaml#exports.connectionStrings.pikaoa-database-url
name: pikaoa
username: pikaoa
schema: pikaoa
connection:
sourceRef: /root/.unidesk/.state/secrets/platform-infra/pikaoa.env
sourceKey: DATABASE_URL
targetKey: DATABASE_URL
runtime:
replicas:
api: 1
worker: 1
web: 1
resources:
api: { requests: { cpu: 250m, memory: 256Mi }, limits: { cpu: 1, memory: 1Gi } }
worker: { requests: { cpu: 100m, memory: 256Mi }, limits: { cpu: 1, memory: 1Gi } }
web: { requests: { cpu: 100m, memory: 128Mi }, limits: { cpu: 500m, memory: 512Mi } }
initializer: { requests: { cpu: 250m, memory: 256Mi }, limits: { cpu: 1, memory: 1Gi } }
secretName: pikaoa-runtime
apiServiceName: pikaoa-api
apiPort: 8080
workerMetricsPort: 8081
webPort: 8080
webApiUpstreamEnv: PIKAOA_API_UPSTREAM
attachment:
storageRoot: /var/lib/pikaoa/attachments
maxBytes: 104857600
claimName: pikaoa-attachments
storageRequest: 20Gi
storageClassName: null
fsGroup: 65532
accessModes:
- ReadWriteOnce
workerInterval: 2s
outbox:
batchSize: 50
maxAttempts: 4
retryDelay: 2s
sessionTTL: 8h
shutdownTimeout: 10s
administrator:
username: admin
password:
sourceRef: ~/.unidesk/.env/pikaoa-admin-password.txt
targetKey: PIKAOA_BOOTSTRAP_ADMIN_PASSWORD
employee:
username: employee
password:
sourceRef: ~/.unidesk/.env/pikaoa-employee-password.txt
targetKey: PIKAOA_BOOTSTRAP_EMPLOYEE_PASSWORD
sessionSecret:
sourceRef: /root/.unidesk/.state/secrets/platform-infra/pikaoa.env
sourceKey: PIKAOA_SESSION_SECRET
targetKey: PIKAOA_SESSION_SECRET
initializer:
mode: fresh-database-only
jobName: pikaoa-init
backoffLimit: 2
command:
- /usr/local/bin/pikaoa
- migrate
- up
- --config
- /etc/pikaoa/pikaoa.yaml
exposure:
serviceName: pikaoa-web
serviceType: NodePort
hostIP: 152.53.229.148
port: 32096
observability:
configRef: config/platform-infra/observability.yaml
otlpEndpoint: otel-collector.platform-infra.svc.cluster.local:4317
prometheus:
configRef: config/platform-infra/observability.yaml#metricsBackend.discovery.labelSelector
scrape: true
apiPath: /metrics
workerPath: /metrics
exporterFailure:
warning: true
blocking: false
probes:
api:
livenessPath: /healthz
readinessPath: /readyz
worker:
livenessPath: /healthz
readinessPath: /readyz
web:
livenessPath: /healthz
readinessPath: /healthz
delivery:
targets:
NC01:
@@ -158,9 +361,9 @@ delivery:
source:
repository: pikainc/pikaoa
worktreeRemote: https://github.com/pikainc/pikaoa.git
branch: master
branch: release
readUrl: http://gitea-http.devops-infra.svc.cluster.local:3000/mirrors/pikainc-pikaoa.git
snapshotPrefix: refs/unidesk/snapshots/gitea-actions/pikaoa-master-nc01
snapshotPrefix: refs/unidesk/snapshots/gitea-actions/pikaoa-release-nc01
build:
dockerfiles:
api: deploy/api.Dockerfile
+48 -2
View File
@@ -446,7 +446,7 @@ sourceAuthority:
naming: gitea-actions-immutable-source
prefix: refs/unidesk/snapshots/gitea-actions/selfmedia-release-nc01
legacyGitMirror: null
- key: pikaoa-nc01
- key: pikaoa-test-nc01
targetId: NC01
credentialOverride:
github:
@@ -486,12 +486,58 @@ sourceAuthority:
publicRead: false
readUrl: http://gitea-http.devops-infra.svc.cluster.local:3000/mirrors/pikainc-pikaoa.git
gitops:
branch: nc01-pikaoa-gitops
branch: nc01-pikaoa-test-gitops
flushDisposition: gitea-writeback
snapshot:
naming: gitea-actions-immutable-source
prefix: refs/unidesk/snapshots/gitea-actions/pikaoa-master-nc01
legacyGitMirror: null
- key: pikaoa-nc01
targetId: NC01
credentialOverride:
github:
transport: https-token
sourceRef: pikainc-selfmedia-gh-token.txt
sourceKey: GH_TOKEN
format: raw-token
requiredFor:
- upstream-mirror
- mirror-sync
- managed-repository-fetch
- github-head-observe
- github-hooks-list
- github-hooks-reconcile
permissions:
contents: read
metadata: read
webhooks: read-write
gitFetchCredential:
apiVersion: unidesk.ai/v1
kind: GitFetchCredential
authMode: github-https-token
host: github.com
secretRef:
namespace: devops-infra
name: gitea-github-sync-secrets
key: github-token-pikainc-pikaoa-release
upstream:
repository: pikainc/pikaoa
cloneUrl: https://github.com/pikainc/pikaoa.git
branch: release
visibility: private
gitea:
owner: mirrors
name: pikainc-pikaoa
mirrorMode: controlled-push
publicRead: false
readUrl: http://gitea-http.devops-infra.svc.cluster.local:3000/mirrors/pikainc-pikaoa.git
gitops:
branch: nc01-pikaoa-gitops
flushDisposition: gitea-writeback
snapshot:
naming: gitea-actions-immutable-source
prefix: refs/unidesk/snapshots/gitea-actions/pikaoa-release-nc01
legacyGitMirror: null
targets:
- id: JD01
+96 -31
View File
@@ -65,9 +65,10 @@ deliveryProvenance:
admission:
policyName: unidesk-pac-delivery-provenance-v2
bindingName: unidesk-pac-delivery-provenance-v2
failurePolicy: Fail
failurePolicy: Ignore
validationActions:
- Deny
- Warn
- Audit
capabilities:
sentinelInternalPublish:
enabled: false
@@ -178,22 +179,6 @@ repositories:
variables:
NODE: NC01
LANE: v03
- extends: templates.repositories.hwlabV03
variables:
NODE: NC01
LANE: production
id: hwlab-nc01-production
name: hwlab-nc01-production
secretName: pac-gitea-hwlab-nc01-production
params:
source_branch: release
gitops_branch: release-gitops
source_snapshot_prefix: refs/unidesk/snapshots/gitea-actions/hwlab-node-runtime/release
pipeline_name: hwlab-nc01-production-ci-image-publish
pipeline_run_prefix: hwlab-nc01-production-ci-poll
service_account: hwlab-nc01-production-tekton-runner
lane: production
runtime_namespace: hwlab-production
- id: selfmedia-nc01
name: selfmedia-nc01
namespace: selfmedia-ci
@@ -229,15 +214,15 @@ repositories:
runtime_service_port: "4317"
health_path: /healthz
health_url: http://selfmedia.selfmedia.svc.cluster.local:4317/healthz
- id: pikaoa-nc01
name: pikaoa-nc01
- id: pikaoa-test-nc01
name: pikaoa-test-nc01
namespace: pikaoa-ci
providerType: gitea
url: https://gitea.pikapython.com/mirrors/pikainc-pikaoa
cloneUrl: http://gitea-http.devops-infra.svc.cluster.local:3000/mirrors/pikainc-pikaoa.git
owner: mirrors
repo: pikainc-pikaoa
secretName: pac-gitea-pikaoa-nc01
secretName: pac-gitea-pikaoa-test-nc01
tokenKey: token
webhookSecretKey: webhook.secret
concurrencyLimit: 1
@@ -246,9 +231,9 @@ repositories:
source_branch: master
source_snapshot_prefix: refs/unidesk/snapshots/gitea-actions/pikaoa-master-nc01
node: NC01
pipeline_name: pikaoa-nc01-pac
pipeline_run_prefix: pikaoa-nc01
service_account: pikaoa-nc01-tekton-runner
pipeline_name: pikaoa-test-nc01-pac
pipeline_run_prefix: pikaoa-test-nc01
service_account: pikaoa-test-nc01-tekton-runner
pipeline_timeout: 20m0s
workspace_pvc_size: 8Gi
image_repository: 127.0.0.1:5000/pikaoa/api
@@ -258,16 +243,16 @@ repositories:
registry_probe_base: http://127.0.0.1:5000
gitops_read_url: http://gitea-http.devops-infra.svc.cluster.local:3000/mirrors/pikainc-pikaoa.git
gitops_write_url: http://gitea-http.devops-infra.svc.cluster.local:3000/mirrors/pikainc-pikaoa.git
gitops_branch: nc01-pikaoa-gitops
gitops_branch: nc01-pikaoa-test-gitops
gitops_username: unidesk-admin
gitops_secret_name: pac-gitea-pikaoa-nc01
gitops_manifest_path: deploy/gitops/nc01/resources.yaml
runtime_namespace: pikaoa
gitops_secret_name: pac-gitea-pikaoa-test-nc01
gitops_manifest_path: deploy/gitops/nc01-test/resources.yaml
runtime_namespace: pikaoa-test
runtime_deployment: pikaoa-api
runtime_service: pikaoa-web
runtime_service_port: "8080"
health_path: /healthz
health_url: http://pikaoa-web.pikaoa.svc.cluster.local:8080/healthz
health_url: http://pikaoa-web.pikaoa-test.svc.cluster.local:8080/healthz
consumers:
- extends: templates.consumers.agentrunV02
variables:
@@ -393,11 +378,20 @@ consumers:
NODE: NC01
LANE: production
id: hwlab-nc01-production
repositoryRef: hwlab-nc01-production
repositoryRef: hwlab-nc01-v03
lane: production
pipeline: hwlab-nc01-production-ci-image-publish
pipelineRunPrefix: hwlab-nc01-production-ci-poll
argoApplication: hwlab-node-production
params:
source_branch: release
gitops_branch: release-gitops
source_snapshot_prefix: refs/unidesk/snapshots/gitea-actions/hwlab-node-runtime/release
pipeline_name: hwlab-nc01-production-ci-image-publish
pipeline_run_prefix: hwlab-nc01-production-ci-poll
service_account: hwlab-nc01-production-tekton-runner
lane: production
runtime_namespace: hwlab-production
sourceArtifact:
mode: remote-pipeline-annotation
renderer: hwlab-runtime-lane
@@ -504,8 +498,49 @@ consumers:
hostNetwork: true
dnsPolicy: ClusterFirstWithHostNet
fsGroup: 1000
- id: pikaoa-test-nc01
repositoryRef: pikaoa-test-nc01
node: NC01
lane: pikaoa-test
namespace: pikaoa-ci
pipeline: pikaoa-test-nc01-pac
pipelineRunPrefix: pikaoa-test-nc01
argoNamespace: argocd
argoApplication: pikaoa-test-nc01
closeoutGitOpsMirrorFlush: false
argoBootstrap:
project: default
repoUrl: http://gitea-http.devops-infra.svc.cluster.local:3000/mirrors/pikainc-pikaoa.git
targetRevision: nc01-pikaoa-test-gitops
path: deploy/gitops/nc01-test
destinationNamespace: pikaoa-test
automated: true
repositoryCredential:
secretName: argocd-repo-pikaoa-test-nc01
username: unidesk-admin
deliveryProvenance:
required: true
markerValue: admission-pac-v2:pikaoa-test-nc01
executionServiceAccountName: pikaoa-test-nc01-tekton-runner
gitOps:
repoUrl: http://gitea-http.devops-infra.svc.cluster.local:3000/mirrors/pikainc-pikaoa.git
targetRevision: nc01-pikaoa-test-gitops
runnerServiceAccount:
name: pikaoa-test-nc01-tekton-runner
automountServiceAccountToken: false
roleBindingName: pikaoa-test-nc01-tekton-runner
sourceArtifact:
mode: embedded-pipeline-spec
renderer: pikaoa-test-runtime
configRef: config/pikaoa.yaml#testRuntime.targets.NC01
pipelineRunPath: .tekton/pikaoa-test-nc01-pac.yaml
maxKeepRuns: 8
taskRunTemplate:
hostNetwork: true
dnsPolicy: ClusterFirstWithHostNet
fsGroup: 1000
- id: pikaoa-nc01
repositoryRef: pikaoa-nc01
repositoryRef: pikaoa-test-nc01
node: NC01
lane: pikaoa
namespace: pikaoa-ci
@@ -514,6 +549,19 @@ consumers:
argoNamespace: argocd
argoApplication: pikaoa-nc01
closeoutGitOpsMirrorFlush: false
params:
source_branch: release
source_snapshot_prefix: refs/unidesk/snapshots/gitea-actions/pikaoa-release-nc01
pipeline_name: pikaoa-nc01-pac
pipeline_run_prefix: pikaoa-nc01
service_account: pikaoa-nc01-tekton-runner
gitops_branch: nc01-pikaoa-gitops
gitops_secret_name: pac-gitea-pikaoa-nc01
gitops_manifest_path: deploy/gitops/nc01/resources.yaml
runtime_namespace: pikaoa
runtime_deployment: pikaoa-api
runtime_service: pikaoa-web
health_url: http://pikaoa-web.pikaoa.svc.cluster.local:8080/healthz
argoBootstrap:
project: default
repoUrl: http://gitea-http.devops-infra.svc.cluster.local:3000/mirrors/pikainc-pikaoa.git
@@ -524,10 +572,27 @@ consumers:
repositoryCredential:
secretName: argocd-repo-pikaoa-nc01
username: unidesk-admin
deliveryProvenance:
required: true
markerValue: admission-pac-v2:pikaoa-nc01
executionServiceAccountName: pikaoa-nc01-tekton-runner
gitOps:
repoUrl: http://gitea-http.devops-infra.svc.cluster.local:3000/mirrors/pikainc-pikaoa.git
targetRevision: nc01-pikaoa-gitops
runnerServiceAccount:
name: pikaoa-nc01-tekton-runner
automountServiceAccountToken: false
roleBindingName: pikaoa-nc01-tekton-runner
sourceArtifact:
mode: embedded-pipeline-spec
renderer: pikaoa-release-runtime
configRef: config/pikaoa.yaml#releaseRuntime.targets.NC01
pipelineRunPath: .tekton/pikaoa-nc01-pac.yaml
maxKeepRuns: 8
taskRunTemplate:
hostNetwork: true
dnsPolicy: ClusterFirstWithHostNet
fsGroup: 1000
templates:
repositories:
agentrunV02:
@@ -131,3 +131,7 @@
## R7 [completed]
将 Artificer 固化为所有执行型子代理任务的强制默认执行面:用户只说“子代理”时必须使用 Artificer;只有用户明确指定原生子代理,或 Artificer 经有界 readiness/真实派单证据确认故障不可用时,才允许原生子代理执行;禁止主代理因方便、速度、空闲槽或历史习惯自行降级,并要求 Artificer 恢复后立即停止原生扩展并交接,完成任务后将详细报告写入[任务报告](./details/agentrun-runtime-reliability/R7_Task_Report.md)。
## R8 [in_progress]
解决 [UniDesk #2103](https://github.com/pikasTech/unidesk/issues/2103):将 `agentrun events` 的主工作流改为保留 `--after-seq` 分片游标并使用 `--expect <N>``--timeout <duration>` 的 manager/API 长轮询;达到期望新增事件数立即返回,超时返回已观察事件及明确 timeout/next cursor,禁止 CLI 本地高频忙轮询或无输出,并同步 CLI、manager、测试与 `unidesk-code-queue` skill 文档,完成任务后将详细报告写入[任务报告](./details/agentrun-runtime-reliability/R8_Task_Report.md)。
@@ -0,0 +1,25 @@
# R1.1 任务报告
## 调查范围
- 上海工业自动化、能源、电气和大型外企公开岗位。
- 资料收集由 `gpt-5.6-luna`、低思考等级子代理执行。
- 子任务及原始资料:<https://github.com/pikasTech/unidesk/issues/2143#issuecomment-4977675145>。
## 核验结论
- 第一批保留:
- 施耐德供应链规划数字化转型负责人 `009KHM`,涉及 AI Agent、Skill、Harness、机器学习与全栈能力,投递前确认管理职责占比;
- 采埃孚算法工程师 `Req 89163`,涉及控制、规划、PID/MPC、C++、Linux、MATLAB/Simulink/ROS。
- 补充核验:
- 施耐德电子硬件设计 `009LNN` 需要继续核对完整职责和年限门槛;
- 博世 IoT Computing 需补齐稳定详情页,强化学习研究岗有博士或顶会成果等明显硬门槛。
- 观察池:
- Rockwell 当前只有搜索页级证据;
- GE、ABB、Siemens 暂无足够稳定的上海具体岗位证据。
## 主代理复核
- 最终优先级按硬门槛、方向匹配和证据稳定性重排。
- 未修改源码、未创建 PR。
- 任务后复盘未发现值得扩展为独立工程 issue 的重复性问题。
@@ -0,0 +1,26 @@
# R1.2 任务报告
## 调查范围
- 上海 AI、机器人、汽车智能化、嵌入式和系统软件公开岗位。
- 资料收集由 `gpt-5.6-luna`、低思考等级子代理执行。
- 子任务及原始资料:<https://github.com/pikasTech/unidesk/issues/2142#issuecomment-4977676186>。
## 核验结论
- 第一批保留:
- Apple Embedded Software Engineer `200644032-3715`,核心要求为 C/C++、ARM、驱动和通信协议,公开页未显示明确年限硬门槛;
- 华为上海 AI 底层软件栈岗位 `jobId 32189`,投递前先确认 HC、校招或社招资格和页面有效性。
- 第二批或挑战岗:
- NVIDIA Isaac Lab `JR2013813` 仍有约 3 年机器学习或仿真基础设施要求;
- NVIDIA Senior Isaac Lab 明确 4 年以上要求;
- Apple Senior ML/AI 明确约 8 年经验要求。
- 观察池:
- 小米当前主要是动态机会池;
- Tesla、蔚来尚无可稳定复核的当前上海具体岗位证据。
## 主代理复核
- 纠正了子代理原始结果中对 Senior、高年限岗位的过高排序。
- 未修改源码、未创建 PR。
- 子代理反馈的 CLI 参数疑问不属于本次求职资料范围,未扩展为工程支线。
@@ -0,0 +1,36 @@
# R1 任务报告
## 完成结果
- 使用两个 `gpt-5.6-luna`、低思考等级子代理并行收集上海大公司岗位资料。
- 主任务:<https://github.com/pikasTech/unidesk/issues/2141>。
- 主代理复核:<https://github.com/pikasTech/unidesk/issues/2141#issuecomment-4977709829>。
- 全程只处理公开招聘资料,没有在 GitHub issue 中写入候选人隐私信息。
## 最终岗位分层
- 第一批:
- Apple Embedded Software Engineer
- 采埃孚 Algorithm Engineer
- 施耐德供应链规划数字化转型负责人;
- 华为上海 AI 底层软件栈岗位,先确认 HC 和资格。
- 第二批或挑战岗:
- NVIDIA Isaac Lab
- 博世 IoT Computing 或强化学习研究岗位;
- 施耐德电子硬件设计岗位。
- 观察池:
- Rockwell、GE、ABB、Siemens
- 小米、Tesla、蔚来;
- 获得稳定具体岗位页并完成硬门槛核验后才升级。
## 执行计划
- 2026-07-16 09:00 完成岗位证据矩阵,记录硬门槛、项目证据、简历版本和投递结论。
- 2026-07-16 13:30 投递第一批岗位,分别使用嵌入式、算法控制、Agent 或工业智能、AI 系统软件简历版本。
- 2026-07-17 13:30 处理挑战岗,对高年限、博士或顶会门槛明确记录差距,不盲投。
- 上述节奏已写入 Decision Center 的“找工作”待办及三个子待办。
## 交付边界
- 本任务没有源码修改或 PR。
- 两个子代理都完成了任务后复盘,没有选出需要在当前范围推进的工程改进项。
@@ -0,0 +1,53 @@
# R1.6.1.3 任务报告
## 任务回链
- MDTODO`R1.6.1.3`
- GitHub`pikasTech/unidesk#2129``pikasTech/unidesk#2110`
- Target`NC01`
- 交付边界:本任务只完成生产 release 控制面、只读计划与定向测试,不执行生产 mutation。
## 已完成
- `config/pikaoa.yaml#releaseRuntime.targets.NC01` 成为生产运行面唯一 owning selector
- namespace、单副本、resources、附件 PVC、Service、OTel、Prometheus、release source、fresh initializer policy 均由 YAML 声明;
- Secret 继续引用既有受控 distribution 与 PK01 PostgreSQL export,不打印值;
- 公网 hostname、FRP port、Caddy/TLS 事实保留在同一生产 delivery 声明。
- `config/platform-infra/pipelines-as-code.yaml` 新增独立 `pikaoa-nc01` Repository/consumer
- 只跟随 `release``refs/unidesk/snapshots/gitea-actions/pikaoa-release-nc01`
-`pikaoa-test-nc01/master` 的 Secret、PipelineRun、GitOps branch、Argo application 完全隔离;
- production sourceArtifact 使用 `pikaoa-release-runtime` renderer 生成 `.tekton/pikaoa-nc01-pac.yaml`
- test/release 共用 renderer 已修复真实 PaC 缺陷:
- TaskSpec workspace 声明 `mountPath: /workspace`step 不再手工挂载 workspacetoken Secret mounts 保留;
- BuildKit metadata 解析允许 JSON 冒号两侧空白,只接受 `containerimage.digest` 的完整 `sha256:<64hex>`
- metadata 不可读时使用本地 registry manifest `Docker-Content-Digest` 受控兜底。
- Gitea mirror webhook status 只解析选中 repository 的 credential 与 topology
- `--repo pikaoa-nc01` 不再读取未选 `pikaoa-test-nc01` token
- 现场状态显示 release commit `07a9a9db3cad` 已 committed。
## 验证证据
- `bun test scripts/src/pikaoa-test-delivery-renderer.test.ts scripts/src/platform-infra-gitea-config.test.ts scripts/src/platform-infra-pipelines-as-code-bootstrap.test.ts``24 pass / 0 fail`
- `platform-infra pipelines-as-code plan --target NC01 --consumer pikaoa-nc01`:识别独立 production Repository、consumer、Tekton 与 Argo 路径。
- `platform-infra gitea mirror webhook status --target NC01 --repo pikaoa-nc01``READY=true`release head、Gitea 与 snapshot 均为 `07a9a9db3cad`
- source-artifact `plan/check`desired hash 已生成;产品 `.tekton/pikaoa-nc01-pac.yaml` 尚未写入,符合本任务禁止直接编辑固定产品主 worktree 的边界。
## 主代理后续命令
`/root/pikaoa` clean worktree 审核并写入产品 release artifact
```bash
bun scripts/cli.ts platform-infra pipelines-as-code source-artifact plan --target NC01 --consumer pikaoa-nc01 --source-worktree /root/pikaoa
bun scripts/cli.ts platform-infra pipelines-as-code source-artifact write --target NC01 --consumer pikaoa-nc01 --source-worktree /root/pikaoa --confirm
bun scripts/cli.ts platform-infra pipelines-as-code source-artifact check --target NC01 --consumer pikaoa-nc01 --source-worktree /root/pikaoa
```
产品 artifact 提交、正常 release PR merge 后,由主代理执行只读 bootstrap 计划并按正常入口触发交付:
```bash
bun scripts/cli.ts platform-infra gitea mirror webhook status --target NC01 --repo pikaoa-nc01
bun scripts/cli.ts platform-infra pipelines-as-code plan --target NC01 --consumer pikaoa-nc01
bun scripts/cli.ts platform-infra pipelines-as-code status --target NC01 --consumer pikaoa-nc01
```
交付完成后再按原入口验收 `pikaoa` namespace、initializer、API/Worker/Web、附件 PVC、OTel/Prometheus 与 `https://oa.pikapython.com`;不得人工创建 PipelineRun、Argo refresh 或生产 namespace mutation。
@@ -0,0 +1,80 @@
# R4.1.1 任务报告
## 状态
- MDTODO`R4.1.1`
- GitHub issue`pikasTech/unidesk#2039`
- 状态:`in_progress`
- 原因:源码修复与定向验证已完成,尚未合并 PR,也未执行合并后的 NC01 原入口运行面验收。
## 问题事实
- PR #1808 引入同名 `ValidatingAdmissionPolicy` 与 binding
- 使用 `failurePolicy: Fail`
- 使用 `validationActions: [Deny]`
- 阻断不满足 provenance CEL 的 PipelineRun 创建或更新。
- PR #1812 继续收紧 watcher 的 queue transition
- 假定同一次 UPDATE 完成 `spec.status: PipelineRunPending -> absent`
- 同时完成 `state: queued -> started`
- NC01 官方 `pipelines-as-code-watcher` 的真实更新不满足该原子假定:
- live `unidesk-pac-delivery-provenance-v2` 拒绝 watcher
- HWLAB `df925768` 与 AgentRun 自动队列停在 Pending。
## 本次语义回退
- owning YAML 将同名 v2 policy 改为 Kubernetes 原生 warning-only
- `failurePolicy: Ignore`
- `validationActions: [Warn, Audit]`
- 保留现有观察项的计算和披露:
- CEL、marker、creator 与 ServiceAccount
- queue transition、spec/config SHA、版本与 resource epoch
- 默认 RBAC。
- admission/provenance 观察项不再作为以下入口的阻断条件:
- 业务 admission 与 bootstrap
- status、history 与 debug
- 外层 PaC delivery eligibility。
- admission 漂移输出结构化 `blocking: false` warning;真实 consumer bootstrap 缺失不降级:
- runner ServiceAccount、RoleBinding 或 Argo repository credential 未就绪时,status 保持 `ok: false`
- 顶层 status 继续要求 `bootstrap_ready=true`,避免 false green。
- PaC bootstrap 的 `pac-admission` 阶段在 live identity 或 generation 尚未精确收敛时显示 `state: warning`,整体结果仍可成功。
- 外层 GitHub/Gitea PaC push event 继续作为:
- 唯一流水线触发;
- 唯一 delivery authority。
- admission exact identity 仅决定 `admissionProvenanceVerified` 与 warning,不再让已观察到的 outer event 失去 eligibility。
## 明确保留
- PR #1808 的 source artifact、三阶段 terminal、GitOps/status/history/debug 可观测性与无关后续改动。
- YAML-owned policy/binding 名称 `unidesk-pac-delivery-provenance-v2`,以便受控 bootstrap 通过 server-side apply 原位收敛现有 live v2。
- provenance、creator、marker、ServiceAccount、spec/config SHA、版本、epoch、RBAC 与 drift 的只读计算和结构化披露。
- GitHub PR merge 继续作为唯一正式交付触发。
- 未新增以下入口或机制:
- PipelineRun、mirror、trigger、sync、flush、Argo sync 或 runtime patch
- 数据库迁移、合同、锁、租约、第二 authority 或 fallback。
## 定向验证
- `sh -n scripts/src/platform-infra-pipelines-as-code-remote.sh`
- `bun test scripts/src/platform-infra-pac-provenance.test.ts scripts/src/platform-infra-pipelines-as-code-bootstrap.test.ts`
- 结果:`23 pass, 0 fail, 239 expect()`
- `node` 调用 `runPacStatusFixtureChecks()`
- 结果:`ok=true, checks=34`
- `bun scripts/cli.ts platform-infra pipelines-as-code plan --target NC01`
- 结果:YAML source-of-truth、single-path、Gitea source 与 runtime-zero-docker 策略均为 `true`
- `git diff --check`
- 结果:通过。
## 合并后受控收敛
- 主代理在 PR 合并后先执行只读计划:
- `bun scripts/cli.ts platform-infra pipelines-as-code bootstrap --target NC01 --consumer agentrun-nc01-v02 --dry-run`
- 确认计划只体现 owning YAML 的同名 v2 warning-only 收敛后,再执行:
- `bun scripts/cli.ts platform-infra pipelines-as-code bootstrap --target NC01 --consumer agentrun-nc01-v02 --confirm`
- 不需要 prunepolicy 与 binding 名称保持不变,bootstrap 使用 server-side apply 原位把 live `Fail/Deny` 更新为 `Ignore``Warn/Audit`
- bootstrap 不是流水线补跑入口;禁止随后人工执行 PipelineRun、mirror、trigger、sync、flush、Argo sync 或 runtime patch。
- 运行面验收由主代理观察既有 merge 事件自动恢复,并通过原 `status``history` 与受影响 HWLAB/AgentRun 原入口完成。
## 当前阻塞
- 无源码或定向验证阻塞。
- 运行面验收仍等待 PR 合并及主代理执行受控 bootstrap,因此任务保持 `in_progress`
@@ -0,0 +1,77 @@
# R7.2 任务报告
## 任务定位
- MDTODO`R7.2`
- GitHub issue`pikasTech/unidesk#2010`
- Pull request`pikasTech/unidesk#2101`
- Target`NC01`
- targetWorkspace`/root/unidesk/.worktree/2010-hwlab-release-production-lane`
- repository/ref`pikasTech/unidesk` / `feat/2010-hwlab-release-production-lane`
## 本轮结果
-`config/hwlab-node-lanes.yaml` 中以 `lanes.v03` 为 baseline 增加短 production override。
- production lane 独立声明:
- `release` source branch
- source workspace、snapshot、Pipeline、PipelineRun、ServiceAccount
- GitOps branch/path、artifact catalog、Argo Application、namespace
- `https://hwlab.pikapython.com` YAML publicExposure
- PostgreSQL database、role、Secret consumer 和 migration ledger
- Kafka client、direct publish、refresh replay、projector 和 live SSE consumer group。
- production 与 development 共享同一个 HWLAB Gitea PaC Repository CR;两个 lane 使用独立 consumer,并由 consumer params 覆盖 source branch、snapshot、Pipeline 和 runtime identity。
- 共享 Repository 避免同一镜像仓库重复声明 PaC Repository;独立 consumer 仍保持 production 自动交付路径与 development 完全隔离。
- 通用 HWLAB lane parser 和 plan 已投影 migration ledger,并从 owning YAML 动态生成合法 lane 提示。
- `config/platform-infra/kafka.yaml` 已声明 production Cloud API Kafka ACL,未改变 topic、实时和回放架构。
## Target 原入口证据
以下命令均在 `NC01:/root/unidesk/.worktree/2010-hwlab-release-production-lane` 执行:
- `git diff --check`:通过。
- `bun --check`
- `scripts/src/hwlab-fake-model-provider.ts`:通过;
- `scripts/src/hwlab-node-lanes.ts`:通过;
- `scripts/src/hwlab-node/entry.ts`:通过;
- `scripts/src/hwlab-node/plan.ts`:通过。
- `bun scripts/cli.ts hwlab nodes control-plane plan --node NC01 --lane production`
- `status=ok`
- namespace 为 `hwlab-production`
- external PostgreSQL 与 publicExposure 均被选中;
- Secret values 未输出。
- `bun scripts/cli.ts hwlab nodes control-plane plan --node NC01 --lane v03`
- `status=ok`
- namespace 为 `hwlab-v03`
- development 配置继续可解析。
- `bun scripts/cli.ts platform-infra pipelines-as-code plan --target NC01 --consumer hwlab-nc01-production`
- Repository 为共享的 `hwlab-nc01-v03`
- consumer 为独立的 `hwlab-nc01-production`
- Tekton Pipeline 为 `hwlab-nc01-production-ci-image-publish`
- Argo Application 为 `hwlab-node-production`
- `single-path``yaml-source-of-truth``public-repository-url``gitea-internal-source``runtime-zero-docker` 均为 `true`
- `bun scripts/cli.ts platform-infra pipelines-as-code plan --target NC01 --consumer hwlab-nc01-v03`:通过,development consumer 保持独立。
- 解析后隔离断言全部通过:
- source branch、workspace、Pipeline、PipelineRun prefix、ServiceAccount
- GitOps branch、runtime namespace、Argo Application、public origin
- PostgreSQL database、role、Secret、migration ledger
- Kafka direct publish、refresh replay 和 live SSE group
- shared Repository、independent consumer 和各 lane branch 参数。
## Primary Workspace 边界
- primary workspace 仅用于读取 runtime-managed skills、执行受控 GitHub CLI 和发出 `trans` 命令。
- 未在 primary workspace 读取、编辑、验证或提交目标源码。
- 未把 runner 容器本地结果作为 Target 原入口证据。
## 未执行范围
- 未创建或推进 HWLAB `release` branch。
- 未人工触发 PipelineRun、Gitea mirror、Argo refresh/sync 或 GitOps rollout。
- 未修改运行面 Pod、Secret、Caddy、FRP 或 PostgreSQL。
- 未运行 Vitest、裸 `tsc`、浏览器、web-probe 或重型构建。
- 未切换 `https://hwlab.pikapython.com`,也未声明 production 已上线。
## 后续阶段
- PR 合并授权、`release` 初始化和 production 自动 rollout 由 `pikasTech/unidesk#2010` 后续阶段控制。
- 只有 `release` 正常提交自动触发唯一 production PipelineRun,并收敛到 Argo `Synced/Healthy` 后,才执行 production 公网原入口验收并完成 MDTODO R7.2。
@@ -0,0 +1,20 @@
# R3.2 任务报告
- 目标:修复 PaC 在 `expectedRevision``observedRevision` 相同时,因补充 owning Git fetch 失败而误判 `relation=unknown` 的问题。
- 交付:
- Issue[UniDesk #2052](https://github.com/pikasTech/unidesk/issues/2052)。
- PR[UniDesk #2055](https://github.com/pikasTech/unidesk/pull/2055)。
- 合并提交:`dbc4169d83b4b856324345d79503862e682d3e86`
- 结果:
- 两个合法 revision 值完全相同时直接判定为 `exact`
- owning Git fetch 失败保留 `pac-owning-git-fetch-failed``blocking=false``mutation=false` 的结构化 warning。
- 不同 revision 继续保持 `unknown``stale``diverged` 的既有阻塞语义。
- remote 输出前与 evaluator 消费前复用同一幂等正规化函数,避免证据字段二次处理漂移。
- 验证:
- evaluator fixture 34/34 通过。
- source-artifact 32/32 通过。
- failure-evidence 5/5 通过。
- 新增具名测试 2/2 通过。
- remote shell 语法与 PaC CLI help 通过。
- 完整三文件测试 47/48;唯一失败是合并前 `origin/master` 已存在的 admission consumer 列表断言未包含 `selfmedia-production-nc01`,不属于本 PR diff。
- 边界:未修改或操作 YAML、Secret、PipelineRun、Argo、Gitea、mirror、rollout 或其他运行面。
@@ -0,0 +1,22 @@
# R3.3 任务报告
## 结论
生产期次 `prod-webterm-20260714174507` 的 Kokoro/Misaki 不可发音字符故障已完成源码修复、release 与 master 双分支交付、生产续跑和公网验收。根因是口播文本中的 `[…]` 经 NFKC 规范化后变成 `[...]`,Misaki 生成未知音素;现由既有 TTS 归一化层恢复为保留停顿语义且受支持的 Unicode 省略号 `…`
## 交付
- release PR `pikainc/selfmedia#37`merge commit `48e92b281ddef06948b1ea158551f93a6caf37a6`
- master 回补 PR `pikainc/selfmedia#38`merge commit `c3872d0c8fb0bba8e9a9f0c36338a98126d42081`
- 定向与关联测试 9 通过、0 失败;真实失败样本修复后未知音素计数为 0。
- 生产 source artifact verifiersource worktree clean、commit exact、embedded PipelineRun 与 runtime provenance aligned。
## 原入口验收
- WebTerm 通过同一后端终端会话触发 `voice -> inspect` 续跑,job `20260714-184250-7841e80a` 成功。
- 生成视频 `output/episode.mp4`,大小 20,572,896 bytesvoice、subtitles、render、inspect 全部成功。
- 公网 `http://152.53.229.148:4319/healthz` 返回 200;匿名 `/api/v1/editions` 返回 401;根页面返回 200。
## 边界
未人工创建 PipelineRun、未直接修改 Pod/Argo/GitOps、未重跑已经成功的前置阶段。
@@ -0,0 +1,29 @@
# R4.1 任务报告
## 目标
依据 [UniDesk #2064](https://github.com/pikasTech/unidesk/issues/2064),为 Pipelines-as-Code 自动交付增加 YAML-first 的 120 秒端到端预算可见性。超预算只输出非阻塞提示,证据不完整时保持 partial,不改变任何业务滚动终态。
## 交付
- PR[UniDesk #2067](https://github.com/pikasTech/unidesk/pull/2067)。
- 实现提交:`c96cab96f763d5256d1e94f7421b8b0f2f33d06d`
- 合并提交:`2a88bc0a8b4d89ef0b9b009e98b73702a65e2a68`
- owning YAML`config/platform-infra/pipelines-as-code.yaml#deliveryTiming.endToEndBudgetSeconds`
- typed warning`pac-automatic-delivery-over-budget`
- 固定语义:`blocking=false``mutation=false`
- hint 只指向 env identity、依赖缓存、BuildKit/cache、stage timing 与现有只读 `status/history` 入口。
- `status/history` 只有流水线耗时、缺少完整端到端证据时投影 `partial``overBudget=null`,不提前报警。
## 验证
- `bun test scripts/src/platform-infra-pac-delivery-timing.test.ts scripts/src/platform-infra-pipelines-as-code-bootstrap.test.ts`15/15 通过。
- `plan --target NC01 --consumer selfmedia-nc01 --json`:正确读取并投影 120 秒 owning YAML 预算,`mutation=false`
- 真实 `delivery-timing`SELFMEDIA 端到端 202 秒,正确输出 `202s/120s` warningArgo 为 `Synced/Healthy`runtime 为 `1/1`
- 真实 `status/history`PipelineRun 为 193 秒但缺少完整端到端时间证据,均保持 `partial` 且无 warning。
- `git diff --check`:通过。
- PR 合并由主代理 guarded merge 完成;本子任务未部署、未创建人工 PipelineRun、未执行 sync/refresh 或其他运行面 mutation。
## 边界
R4.1 已完成超预算事实的非阻塞可见性。实际将 SELFMEDIA 自动交付压缩到 120 秒预算内仍属于 R4 后续 env reuse 与镜像阶段优化,不由本子任务冒充完成。
@@ -0,0 +1,5 @@
# R4.2 任务报告
UniDesk PR #2074 与 SELFMEDIA PR #48 已按依赖顺序合并,merge commits 分别为 7d1af2953d6226d41fd0d7dec898d4a5944daade 与 0dbf92e1abc8d47cf5a9ffd7e8a569429d37ac03。config/env-identity.yaml 声明 package manifest 的依赖语义字段,同一 renderer 同时生成 PaC identity 与 Docker 安装 manifestscripts、name、version 不再使依赖环境失效,依赖、lockfile、工具、模型、runtime 输入仍正确失效。
PR #48 因 Dockerfile、策略和 renderer 首次变化按预期 miss,端到端 193 秒。随后 Web-only PR #50 是真实业务验收:ENV_REUSE=hitsourcePrepare=2 秒、envIdentity=0 秒、imageBuild=34 秒、gitopsPublish=2 秒,PipelineRun 46 秒、端到端 56 秒,低于 owning YAML 的 120 秒预算;Argo Synced/Healthyruntime 1/1,构建与运行 digest 精确一致。全程由正常 master PR merge 自动触发,未人工创建 PipelineRun、刷新 Argo 或修改 release。
@@ -0,0 +1,15 @@
# R5.1 任务报告
## 交付
- PR `pikainc/selfmedia#43`merge commit `44d675eb8b7fba23237d4302b4b5a27ce7b41a0a`
- 登录页、生产导控台、作业监看、产物面板、错误提示与内置 Codex 终端全部改为中文。
- 阶段、作业、终端连接/运行、会话恢复、生成方式和分镜类型使用集中中文映射;技术路径、品牌和协议只在中文语义旁保留。
- `bun test web/tests` 9 项通过,NC01 Web 构建通过。
## 测试集群验收
- 仅由 master PR merge 自动发布到开发公网 `http://152.53.229.148:4317`;未触碰 release/生产 4319。
- 公网登录后的退休英文标签扫描命中 0;页面标题、按钮、状态、空态、终端工具栏与辅助文本均为中文。
- 1920x1080 桌面和 390x844 移动端无页面级横向溢出;工厂保持紧凑工业风、直角/小倒角。
- 后续资源 API PR #46 自动发布后,公网中文界面仍保持一致。
@@ -0,0 +1,16 @@
# R5.2 任务报告
## 交付
- PR `pikainc/selfmedia#44`merge commit `d151cfa87e586d083fce04b10a60b0ce022df5ae`
- 规范路径 `/editions/:editionId/resources/:resourceId`,资源为 `sources|script|article|slides|audio|subtitles|output|artifacts`;期次短路径规范化到 sources。
- 切期立即清除旧详情并显示目标期次中文加载态;AbortController 与 request identity 双重阻止乱序覆盖。
- 非法期次、非法资源和坏路径显示中文不存在状态,不回退其他期次;支持复制期次/资源链接。
## 测试集群验收
- master PR merge 自动交付端到端 59 秒,`ENV_REUSE=hit`Argo `Synced/Healthy`、runtime 1/1exact verifier 对齐。
- 公网 4317 直接打开、刷新、前进/后退均恢复同一 edition/resource。
- 人为延迟旧期请求 900ms 后快速切回:最终 URL、选择器、标题、身份与内容全部为新期,旧期正文计数 0。
- 加载期明确显示 `正在加载期次:<目标期次>`;非法资源刷新后仍显示 `这个资源地址不存在`
- 公网页面健康 200、匿名 API 401;未发布 release/生产 4319。
@@ -0,0 +1,5 @@
# R5.3.1 任务报告
SELFMEDIA PR #46 已合并到 mastermerge commit 为 f0fccd8536c7930be73347be95602c0d480b8493。开发集群提供 GET/PUT /api/v1/editions/:id/resources/:resourceId,并由统一 TypeScript CLI 的 resource show/update 使用同一路径;metadata、sources、script、article、slides 可编辑,固定路径、revision/If-Match、结构校验、原子写入与跨期/越界拒绝均已实现。
公网 4317 真实验收中,Web 保存测试期次标题后,内嵌 WebTerm 的持久 Codex 会话通过 bun /app/scripts/selfmedia-cli.ts resource show 读取到相同标题、metadata 内容和 revisionAPI key 未被读取或打印。随后同源 PUT 先完成外部并发更新,再用旧 revision 请求,返回 HTTP 409 与 revision_conflict;测试期次最终恢复原始标题并刷新确认。未触碰 release、生产 namespace 或 4319。
@@ -0,0 +1,7 @@
# R5.3.2 任务报告
SELFMEDIA PR #50 已合并到 mastermerge commit 为 6125213083a12bdb5bfe8a621b7bc9a7125d2e6b。开发 PaC 自动交付成功,PipelineRun 46 秒、端到端 56 秒,ENV_REUSE=hitimageBuild=34 秒;Argo 最终观测精确 GitOps commit 14c781a9c999runtime digest 与本次构建 sha256:4dd5682c4c8 一致。
公网 4317 验证了期次元数据结构化编辑、来源/文稿/微信文章/分镜资源编辑入口、只读资源说明、中文加载与保存状态、终端协同按钮。真实冲突场景返回 409 revision_conflict,页面显示保存冲突、保留草稿并禁用覆盖;重新加载后恢复原始内容。RESTful 深链可直接打开微信公众号文章资源,浏览器后退恢复原期次/资源,非法资源显示中文 not-found。专用“交付巡检”运行按钮弹出中文确认框,确认后创建单步作业并在 9 秒内成功,作业尾号 1d8be9d2。
桌面 1920x1080 与移动 390x844 均完成截图复核;两种视口 document scrollWidth 等于 innerWidth,未见横向溢出,控制台无 error/warning。未触碰 release、生产 namespace 或 4319。
@@ -0,0 +1,20 @@
# R5.3.3 任务报告
## 结论
SELFMEDIA 已在 `edition.yaml#spec.production` 提供期次级配音、字幕和视频覆盖,REST API、统一 CLI、Web 工具带与 `voice``subtitles``render` 单步共享同一资源真相;空字段继承 `config/tools.yaml`。PR [#51](https://github.com/pikainc/selfmedia/pull/51) 已合并到 `master`merge commit 为 `283034bd05895753675b716b86918b7db306a8d7`
## 实现与验证
- 支持音色、模型语速、后处理语速、分段停顿、字幕字号/边框/边距、输出帧率、CRF 和编码预设。
- metadata 保存继续使用 revision、`If-Match`、结构校验、原子写入与 HTTP 409 冲突合同。
- Artificer 在 NC01 完成 14 项定向测试与 Web 构建,工具带保持紧凑直角工业风,编码预设使用中文标签。
- 正常 PR merge 自动触发 PaCPipelineRun 成功,Argo `Synced/Healthy`runtime `1/1`。本次修改命中环境身份文件,`ENV_REUSE=miss`,镜像构建 148 秒,Pipeline 161 秒,PR merge 至 Pipeline 完成 172 秒;该超预算事实为非阻塞性能证据。
- 公网 `4317` 真实闭环:Web 临时保存 `segmentPauseMs=260`;内嵌 WebTerm 的持久 Codex 会话通过正式 CLI 创建 voice 作业 `20260714-202500-998ac72d`14 秒成功;API/manifest 投影显示有效值 260。
- 验收后 Web 清空覆盖,并由卡片专用“本地配音”运行按钮和中文确认框创建作业 `20260714-202706-48f34f1d`13 秒成功;metadata 不再含 tts 覆盖,音频恢复全局有效值 `segmentPauseMs=150`
- WebTerm 重启按钮已实测,重启代次 42,会话以“恢复上次会话”恢复;默认字号 15 像素、凭据就绪,未打印凭据。
- 桌面 1920x1080 与移动 390x844 均无横向溢出;截图为 `/tmp/selfmedia-r5-production-settings-desktop.png``/tmp/selfmedia-r5-production-settings-mobile.png`
## 边界
只合并和部署 `master` 开发集群;未触碰 `release`、生产 namespace 或公网 `4319`,未人工创建 PipelineRun,未执行 Argo sync/refresh 或 Pod patch。
@@ -0,0 +1,18 @@
# R5.3 任务报告
## 结论
SELFMEDIA 首批 Web 手动编辑工作台已完成。PR [#46](https://github.com/pikainc/selfmedia/pull/46) 建立期次资源 REST API 与统一 CLIPR [#50](https://github.com/pikainc/selfmedia/pull/50) 建立 RESTful 深链内的资源编辑器,PR [#51](https://github.com/pikainc/selfmedia/pull/51) 增加期次级配音、字幕和视频参数工具带;均只合并 `master`
## 能力
- 可编辑 metadata、来源、文稿、微信公众号 Markdown、场景/分镜,以及配音、字幕和视频生产参数。
- 保存状态、未保存草稿、保存中、错误和 revision 冲突均使用中文;冲突时保留草稿并禁止覆盖。
- Web 与 WebTerm/CLI 使用同一 edition/resource API、revision 与磁盘资源,不建立第二状态库。
- 产物资源保持只读,参数通过 metadata 的 `spec.production` 编辑;单步仍由卡片内专用“运行”按钮和确认框创建。
- 公网 `4317` 已完成 Web 保存、WebTerm CLI 回读/运行、manifest 有效值、刷新保持和恢复原值闭环。
- 桌面和移动端均无横向溢出,Web 工厂保持紧凑直角工业风。
## 边界
未发布 `release`、生产 namespace 或公网 `4319`
@@ -0,0 +1,18 @@
# R5 任务报告
## 结论
SELFMEDIA 开发集群 Web 工厂的中文化、RESTful 深链和首批手动编辑能力已完成,并已通过公网 `http://152.53.229.148:4317` 真实验收。交付由 PR [#43](https://github.com/pikainc/selfmedia/pull/43)、[#44](https://github.com/pikainc/selfmedia/pull/44)、[#46](https://github.com/pikainc/selfmedia/pull/46)、[#50](https://github.com/pikainc/selfmedia/pull/50) 和 [#51](https://github.com/pikainc/selfmedia/pull/51) 组成。
## 终态
- 页面按钮、状态、空态、错误、确认框、终端工具栏和辅助文本使用中文;保留技术标识时提供中文语义。
- 每一期与资源使用 `/editions/:editionId/resources/:resourceId` 深链,可复制、刷新恢复、前进后退;切期显示目标期次加载态并清空上一期内容,乱序响应不会覆盖当前选择。
- Web 可编辑期次元数据、来源、文稿、微信公众号文章、场景/分镜、配音、字幕和视频参数;保存、冲突和继承状态中文可见。
- Web、WebTerm 和统一 TypeScript CLI 共享同一 REST API、revision 合同与 edition/resource 真相;单步运行使用独立按钮和确认框。
- 公网真实闭环验证了 Web 编辑、WebTerm CLI、voice 单步、manifest 有效值、恢复原配置、Codex 持久 session/restart、桌面与移动布局。
- 自动交付只由正常 `master` PR merge 触发,运行面最终为 Argo `Synced/Healthy`、runtime `1/1`
## 边界
全程未发布 `release`、生产 namespace 或公网 `4319`
@@ -0,0 +1,43 @@
# R6.1 任务报告
## 目标
修复 SELFMEDIA 生产首次 env-reuse cache miss 时,BuildKit 已推送镜像但在收尾返回 `context deadline exceeded`,导致 GitOps 阶段未执行的问题;保持自动交付,不用手工补跑。
## 现场根因
- 失败发布提交:`91c23dd0e45916336e03e65532dea7daa73b0323`
- 失败 PipelineRun`selfmedia-production-nc01-91c23dd0e45916336e03e65532dea7dacl775`
- PipelineRun 178 秒后在 `image-build` exit 1。
- 日志证明 layers、config、manifest 和 registry push 已完成,digest 为 `sha256:b95b17386db89a5ba5e88a1990eeea8c182c9602d1902e52c78f8194b4e54be7`,随后最后一行才出现 `error: context deadline exceeded`
- 旧生产运行面始终保持 Synced/Healthy,没有错误滚动。
## 实现
- GitHub issuepikainc/selfmedia#56
- Artificer 提交:`5bc294aab2d44371d6facf17228b763501da131c`
- 开发 PRpikainc/selfmedia#57
- master 合并提交:`a97f87756923bf9c82dca9ff5d9956a603f068ff`
- 生产 PRpikainc/selfmedia#58
- release 合并提交:`1b8117de839d6274535e43f17bd2fbb7114ba2a1`
- `deploy/scripts/build-image.sh` 提取单一 POSIX sh 构建函数。
- 只有日志同时证明 layers 和 manifest 推送完成,且最后非空行是 deadline 错误时,才执行一次相同构建重试。
- 正常成功不重试;普通错误不重试;第二次失败原样失败;不把镜像存在当作成功。
- 没有新增阻塞校验;超过 120 秒仍只记非阻塞 warning 和 env-reuse hint。
## 验证
- `sh -n deploy/scripts/build-image.sh deploy/scripts/build-image.test.sh` 通过。
- 四类脚本测试通过:首次成功、特定 deadline 后重试成功、非目标错误不重试、第二次仍失败。
- 开发 PipelineRun`selfmedia-nc01-a97f87756923bf9c82dca9ff5d9956a603f068ff-txkxm`Succeeded88 秒,env reuse hit。
- 开发阶段耗时:source 1 秒、identity 0 秒、image build 66 秒、GitOps 3 秒。
- 开发 GitOps revision`15a48f1585abc45c7998ed504e0c7696482cddbb`
- 开发 ArgoSynced/Healthy;运行镜像 digest`sha256:7b267759a4f0db041dce82d08237ac58bd12d4784d650b2b492b79a2eb0f1125`4317 健康。
- 生产 PipelineRun`selfmedia-production-nc01-1b8117de839d6274535e43f17bd2fbb7j4w42`Succeeded59 秒。
- 生产阶段耗时:source 2 秒、identity 0 秒、image build 41 秒、GitOps 3 秒。
- 生产 GitOps revision`b80059b19aeb4edf6b018c986f17e9d496915f1f`
- 生产 ArgoSynced/Healthy1/1;运行镜像 digest`sha256:8b21258fc6aeb7ad353a7a84ac1dfd7b68e439f16e673910d9dabc4db4c19464`4319 健康。
## 交付边界
全程只通过 PR merge 触发自动 PaC;没有手工 PipelineRun、Argo sync/refresh、Pod patch、mirror sync 或镜像/GitOps 补齐。
@@ -0,0 +1,77 @@
# R6 任务报告
## 目标
完成 Web 导航加载范围与全局增量刷新重构:资源切换只加载目标资源;切期保留大范围加载;手动和自动刷新保留旧内容、增量更新实际所需数据并保护编辑草稿;先验证开发 4317,再自动发布生产 4319。
## 交付
- GitHub issuepikainc/selfmedia#52
- Artificer 功能提交:`92f61c5782fbb1669e1e7dec58102c6dadcabf04`
- 并发边界修正:`d07e436a01daf6a0bc611b62bbb8038ec7467ecd`
- 功能 PRpikainc/selfmedia#53
- master 合并提交:`cb0ae1d1e6e8ede83e0da433724887999edce1a7`
- 首次 master→release PR #54 因生产 PaC add/add 历史冲突关闭。
- 协调分支合并提交:`1d6b5f9c945f4454bb71af3e1b5179a36020a92b`,双亲为 release `48e92b2` 与 master `cb0ae1d`;合并树与 origin/master 内容零差异。
- 生产发布 PRpikainc/selfmedia#55release 合并提交 `91c23dd0e45916336e03e65532dea7daa73b0323`
- 生产首次 cache miss 暴露的 BuildKit 收尾超时已在子任务 R6.1 / issue #56 修复。
- 最终生产 release 提交:`1b8117de839d6274535e43f17bd2fbb7114ba2a1`
## 功能行为
- `config/server.yaml#spec.webRefresh` 是唯一配置真相:
- 默认 5000ms
- 可选 5000/10000/30000/60000ms
- 允许关闭。
- 全局刷新协调器只刷新健康、系统、期次列表、任务、当前期次详情、当前可见资源及打开的元数据。
- 手动和自动刷新保留旧内容,不出现整页加载,不清空当前期次或生产信号链。
- 同一请求在途时不重叠;资源保存只排队一次尾随刷新。
- 刷新响应以 request id 和 edition identity 双重隔离,旧期次响应不能覆盖新期次。
- dirty/saving/conflict 状态保留本地草稿;后台新 revision 只提示,不覆盖编辑内容。
- 切资源只更新资源路由和资源工作台;切期仍清空旧期内容并显示目标期次大范围加载。
- Web 保持中文、紧凑、直角工业风。
## 自动化验证
- Artificer 修正后:18 个测试通过、101 个断言通过。
- Web build 通过。
- 双视口 E2E:2 个测试、26 个断言通过。
- E2E 覆盖双期次、禁用 abort、延迟旧响应、切期加载和资源保存唯一尾随刷新。
- 开发功能 PipelineRun`selfmedia-nc01-cb0ae1d1e6e8ede83e0da433724887999edce1a7-kkbs5`Succeeded79 秒,env reuse hit。
- 最终开发 PipelineRun`selfmedia-nc01-a97f87756923bf9c82dca9ff5d9956a603f068ff-txkxm`Succeeded88 秒。
- 最终开发 GitOps revision`15a48f1585abc45c7998ed504e0c7696482cddbb`Argo Synced/Healthy。
- 最终生产 PipelineRun`selfmedia-production-nc01-1b8117de839d6274535e43f17bd2fbb7j4w42`Succeeded59 秒。
- 最终生产 GitOps revision`b80059b19aeb4edf6b018c986f17e9d496915f1f`Argo Synced/Healthy,运行副本 1/1。
- 开发入口:`http://152.53.229.148:4317`
- 生产入口:`http://152.53.229.148:4319`
## 生产浏览器验收
- 登录鉴权和公网 IP 访问正常。
- 自动刷新实际默认值为 `5000`
- 选项为:关闭、5 秒、10 秒、30 秒、1 分钟。
- 来源证据切换到口播文案:
- 当前期次标题保持;
- 生产信号链 loading 数量 0
- 生产信号链 loading mutation 数量 0。
- 手动刷新:
- 当前期次标题和资源内容保持;
- 生产信号链 loading 数量 0
- loading mutation 数量 0。
- 未保存草稿在增量刷新后保持,状态为“未保存”,生产信号链 loading 数量和 mutation 数量均为 0。
- 通过浏览器侧 500ms 延迟目标期次详情请求,明确观察到切期的大范围 loading,随后目标期次正常 ready。
- 1920×1080 桌面截图通过视觉核验:
- `/tmp/selfmedia-r6-prod-desktop.png`
- SHA-256`82cd37358a42d077af8a2ffd572b44bbfc0a8175a5c2a94636448e8d0c441725`
- 390×844 移动端:
- viewport、body 与 scrollWidth 均为 390
- 刷新控件 x=12、y=67、width=366、height=35
- masthead x=0、y=0、width=390、height=148
- 无横向溢出。
- 移动端截图:
- `/tmp/selfmedia-r6-prod-mobile.png`
- SHA-256`782fd23c7c7b31d67189289edefa5eede14cd02edc41610d5a4b0c260237a9a6`
## 发布约束
全程通过 GitHub PR merge 自动触发 PaC。没有手工 PipelineRun、Argo sync/refresh、Pod patch、mirror sync 或运行面补齐。
@@ -0,0 +1,32 @@
# R7 任务报告
## 结果
已修复全局手动/周期增量刷新清空 SelfMedia 内嵌 WebTerm 的问题,并通过正常 PR merge 自动发布到开发 4317 与生产 4319。
## 实现
- `App` 在 WebTerm 每次打开周期锁定当时的 terminal config;全局刷新产生的新 `system.terminal` 对象不再进入已打开终端的 effect identity。
- 关闭终端后清除锁定配置,再次打开时采纳最新配置。
- 新增 WebTerm 自身“刷新终端”按钮,参考 `../webterm`:发送临时行数 resize60ms 后恢复真实行数 resize,再执行 xterm 全行 refresh 与 focus。
- 手动重绘不关闭 WebSocket、不 reset、不清历史;原有重新连接、重启 Codex、锁定、字号和 resume 保持独立。
- 新增纯逻辑测试覆盖两轮全局刷新配置引用保持、双 resize 顺序、延迟、refresh 与 focus。
## GitHub
- Issue[pikainc/selfmedia#59](https://github.com/pikainc/selfmedia/issues/59)
- 开发 PR[pikainc/selfmedia#60](https://github.com/pikainc/selfmedia/pull/60)master merge `de66aff05d2055af2515737eaef4586c4b352c6e`
- 生产 PR[pikainc/selfmedia#61](https://github.com/pikainc/selfmedia/pull/61)release merge `dab3b629f58556f03f0b99150dd139db5b6b653f`
## 验证
- NC01`bun test web/tests` 20/20、`bun run --cwd web build``git diff --check` 通过。
- 开发自动 PaCPipelineRun 成功,env reuse=hitArgo Synced/HealthyGitOps revision `2827bf77ac6a…`runtime digest `sha256:98afdb185cd…`
- 生产自动 PaCPipelineRun 89 秒成功,env reuse=hitArgo Synced/HealthyGitOps revision `bb91a645582b…`runtime digest `sha256:e31a865d16c…`
- 4317 与 4319:默认 5 秒自动刷新跨两个周期并再执行一次全局手动刷新,均为 WebSocket `starts=1 / closes=0`、新增 snapshot=0、xterm identity 不变。
- 4317 与 4319:“刷新终端”均只发送两次 resize,实测行数 `15→16`WebSocket 不关闭,xterm identity 不变。
- 4317 与 4319:390×844 下按钮完整可见且终端连接未重建。
## 非阻塞观察
PaC 状态仍披露既有 `pac-argo-revision-unknown` 只读诊断;实际 PipelineRun、Argo 与 runtime digest 已一致,未阻断滚动,本任务未执行任何人工补跑。
@@ -0,0 +1,17 @@
# R8.1 任务报告
## 交付结果
- 创建并关闭 [UniDesk #2113](https://github.com/pikasTech/unidesk/issues/2113)。
- [UniDesk PR #2114](https://github.com/pikasTech/unidesk/pull/2114) 已合并到 mastermerge commit 为 db0020863f63104f93cd039ba0cd003c56d3a691。
- unidesk-selfmedia skill 的高频流程已固化唯一源码验证入口:
- trans NC01:/root/.worktrees/selfmedia/<task> argv bun run verify:web。
- skill 明确禁止先探测 node_modules、手工安装依赖,再分别重复 Web 测试、生产构建和差异检查。
- skill 明确源码验证不替代浏览器、公网、鉴权、WebTerm 与 PaC/Argo 运行面验收。
## 验证证据
- unidesk-selfmedia skill quick_validate 通过。
- git diff --check 通过。
- SELFMEDIA #62 的全新 worktree 实测已证明首次单调用自动安装、第二次单调用复用依赖。
- 未修改运行配置,未执行部署。
@@ -0,0 +1,35 @@
# R8 任务报告
## 交付结果
- 创建并关闭 [SELFMEDIA #62](https://github.com/pikainc/selfmedia/issues/62)。
- [SELFMEDIA PR #63](https://github.com/pikainc/selfmedia/pull/63) 已合并到 mastermerge commit 为 9fb96215c15bc38e700922a328181a1680f1a707。
- 新增唯一 CLI 子命令 verify web,并提供 package 脚本 bun run verify:web。
- 现有 CLI 主体迁入 scripts/src/cli-main.tsscripts/selfmedia-cli.ts 保持为 18 行的无第三方依赖自举入口。
- 依赖复用身份由根目录或 web 目录的 package.json 与 bun.lock 哈希生成;身份一致时复用 node_modules,变化时执行 bun install --frozen-lockfile。
- 同一命令依次执行 Web 测试、Web 生产构建与 git diff --check HEAD,按 JSONL 输出阶段、状态、耗时和紧凑失败摘要。
## 验证证据
- 全新 worktree 的根目录和 web/node_modules 均不存在。
- 第一次仅调用 bun scripts/selfmedia-cli.ts verify web
- 根目录依赖 installed506 ms
- Web 依赖 installed426 ms
- Web 测试 passed241 ms
- 生产构建 passed17024 ms
- 差异格式检查 passed19 ms
- 总耗时 18239 ms。
- 第二次仅调用同一命令:
- 根目录依赖 reused
- Web 依赖 reused
- Web 测试、生产构建和差异格式检查全部通过;
- 没有重复安装依赖。
- 暂存变更后使用 bun run verify:web 验证失败契约,命令准确发现 scripts/src/cli-main.ts 末尾多余空行并返回 exit 1;修正后再次运行全部通过。
- 原有 CLI help 和 check 入口仍可运行。
- 仓库全量 typecheck 仍报告既有 web-auth.e2e.test.ts:105 unknown 类型错误;该文件不在本次改动范围,未将既有问题扩大为新门禁。
- 未手工触发 PipelineRun、Argo、rollout 或 release 发布。
## 调用缩减
- 改进前需要依赖存在性探测、根目录安装、Web 安装、Web 测试、生产构建和 diff 检查等多次调用,并可能在首次失败后重复。
- 改进后源码 Web 验证只需一次 bun run verify:web;首次自动准备依赖,后续自动复用。
@@ -0,0 +1,32 @@
# R9.1 D518 Qwen3-TTS 0.6B 临时 Docker GPU 实验报告
## 结论
实验按预设停止边界完成,未解锁正式部署。Qwen3-TTS 模型和 NGC 基础镜像均成功获取,临时镜像也完成构建;容器首次启动在导入阶段因 Torch/TorchAudio CUDA ABI 不兼容退出,尚未进入模型加载,因此没有把该候选用于 6 GiB RTX 2060 的适配结论外推为成功或显存失败。
## 锁定身份
- Qwen 源码 ref022e286b98fbec7e1e916cb940cdf532cd9f488e。
- ModelScope 模型 ref70b274883e68023af521a9199603192d58ccdd3f。
- Python 包:qwen-tts 0.1.1。
- 基础镜像:nvcr.io/nvidia/pytorch:25.05-py3。
- 基础镜像 digestsha256:a0b4dc04f3ca1e539a5c6ea06f79bc45a33d5acd5cbf87dce7910365a924227c。
- 临时镜像:sha256:2019d93f4d55915c7ca388f6dfce13decda61417fd66dd10fd727a963e2e8ab9。
- 低显存参数:CUDA 0、float16、SDPA。
## 现场证据
- D518 Docker、NVIDIA runtime 和 RTX 2060 6144 MiB 可用。
- 官方 ModelScope 权重 14/14 文件完成,缓存约 2.4 GiB。
- NGC 镜像 59 个层完成,临时 Docker 镜像构建成功。
- 首次容器启动报缺少 torchaudio;加入官方 torchaudio 2.8.0 后确认其与 NGC Torch 2.8.0a0+5228986c39.nv25.05 的 libtorchaudio CUDA ABI 不兼容。
- 容器 OOMKilled=falseGPU 仍为约 780 MiB 基线;失败发生在模型加载之前。
- health、冷/热请求、WAV 与 ffprobe 因服务未就绪未执行。
## 清理与接力
- 临时容器、自定义网络、临时构建镜像和 NGC 基础镜像均已清理。
- 保留 D518 /tmp/selfmedia-voice-r9-1/model 的模型缓存及有界日志证据。
- 子 issue 最终证据:https://github.com/pikasTech/unidesk/issues/2133#issuecomment-4977796868
- 下一候选已登记为 R9.1.1 / UniDesk #2148CosyVoice3 0.5B 使用稳定匹配的 Torch/TorchAudio 组合继续验证。
- 正式 YAML-first apply、FRP、公网和 SelfMedia 接入仍保持锁定。
@@ -0,0 +1,22 @@
# R2.10 任务报告
## 范围
通过 PK01 Sub2API 受控 CLI 调整手工 runtime 账号 ID `27` 的人类可读成本标注与账号全局优先级;未修改 Sub2API 源码、版本、YAML 管理范围或外部哨兵。
## 近期证据
近 24 小时原生账号聚合:账号原名称 `https://sub.yjxm1221.top plus 0.01`,尝试 `2472`、成功 `2429`、失败 `43`,可归因上游客户错误 `40`,失败率 `1.74%`;评分 `94.5/A`、置信度 highTTFT P95 `11709ms`、样本 `1944`;请求 `2429`、Token `20.252M`、标准 API 计费基数 `242.2789 USD`。账号当时 active、schedulable,容量 `50`,优先级 `1`,窗口内临时不可调度命中 `30` 次。
## 决策与执行
新采购成本为每 1 USD 标准 API 计费对应 `0.025 CNY`。账号质量和时延仍优秀,但新成本高于 `iceiu 0.011`,因此优先级从 `1` 调整到 `3`:排在免费账号优先级 `1``iceiu` 优先级 `2` 之后,仍排在约 0.03 成本的优先级 `5` 账号之前。
- account-name dry-run:精确命中 ID `27`,仅名称从 `https://sub.yjxm1221.top plus 0.01` 变为 `https://sub.yjxm1221.top plus 0.025`
- priority dry-run:精确命中 ID `27`,仅优先级从 `1` 变为 `3`
- 两项 confirm 均 `writeSucceeded=1``writeFailed=0``reconciled=1``mismatched=0`
- 最终只读快照:名称 `https://sub.yjxm1221.top plus 0.025`,优先级 `3`active、schedulable=trueproxy `3`,容量 `50`,原临时不可调度模板保持不变。
## 结论
成本标注与优先级已按最新价格、近期质量和时延完成精准 runtime 调优,最终状态与期望一致。
@@ -0,0 +1,28 @@
# R2.11 任务报告
## 改进目标
关联 UniDesk #2144,将单账号成本标注与优先级调优从“先全组聚合、再账号下钻”的重复流程收敛为账号级首入口,减少无关数据聚合、输出预算触发和重复查询。
## 固化路径
Sub2API skill 的账号池权威 reference 已明确:
- 已知账号 selector 时,首次调用 `runtime errors --target <target> --since <window> --group <group> --account <account>`
- 一次读取账号评分、可归因上游失败率、TTFT、用量、Token、标准 API 计费基数和名称成本标注。
- 仅在需要当前 priority、capacity、schedulable、proxy 或临时不可调度规则时补一次 `runtime get`
- 全组查询仅用于跨账号比较;单账号任务不再以全组大报表作为前置。
- 名称与 priority 分别 dry-run、顺序 confirm,最后一次 `runtime get` 验收,禁止并发更新同一账号。
- 成本不自动决定 priority,仍需结合可靠性、TTFT、容量、可调度状态和样本置信度人工判断。
## 验证
- 使用参数化账号级命令完成 1 小时只读 smoke,单次返回评分、失败归因、TTFT、用量、Token 和成本。
- smoke 未调用独立 usage、profit 或全组大报表,未触发 stdout 预算保护。
- `quick_validate.py .agents/skills/unidesk-sub2api` 通过。
- `git diff --check` 通过。
- 本改进仅修改 skill reference 与 MDTODO,不修改 Sub2API 运行面。
## 结论
同类单账号调优的必要查询从“全组诊断加账号诊断加 runtime 读取”收敛为“账号诊断,按需补 runtime 读取”;写入和最终验收仍保持受控 dry-run、顺序 confirm 与回读边界。
@@ -1,23 +1,38 @@
# R2.2.16 任务报告
## 结
## 结
用户 `mail0795336304@163.com` 的“卡住约 15 分钟”不发生在 Sub2API 的在途请求、账号排队或 proxy 3 出网阶段。服务端证据显示,上一笔请求于 2026-07-14 14:43:33UTC+8)成功结束,下一笔直到 14:59:54 才进入 Sub2API,中间约 16 分 21 秒没有该用户的新入站请求。卡点因此位于 Sub2API 入站之前,优先怀疑客户端、本地 Agent 状态机或客户端到入口之间的请求提交链路
- PK01 owning YAML 与实际运行镜像均为 `0.1.155`;运行状态 healthy
- 上下文窗口超限可仅通过 Sub2API v0.1.155 官方配置实现:
- 官方入口为 `/api/v1/admin/error-passthrough-rules`
- 新增 YAML 模板 `openai-context-window-client-error`
- 同时匹配 OpenAI 平台、错误码 `400/502` 与上下文超限关键词;
- 将最终状态码映射为 `400`,保留上游具体响应体并继续记录监控事件。
- 规则已通过受控 CLI 写入 PK01,并由官方 API 回读为 `ruleId=1``state=synced`
- “首 Token 超过 180 秒后切号”无法通过 v0.1.155 官方配置等价实现:
- `openai_response_header_timeout` 只约束 HTTP 响应头,不是 TTFT;
- `stream_data_interval_timeout` 可约束流读取静默时间,默认已为 180 秒,但超时返回普通流错误,不会形成账号 failover;
- 因此未设置不等价超时项,也未修改 Sub2API 源码。
- Grok、账号、分组、优先级和调度状态均未改动。
## 原生运维证据
## 持久化
- 用户 ID:22;账号状态 active;用户并发上限 10,调查时 current concurrency 为 0。
- API Key:名称 `pika_win`、ID 46、分组 `unidesk-codex-pool`;调查时 current concurrency 为 0。
- 最近 30 分钟共 7 笔请求,均为成功,无用户可见错误。
- 14:43:33 完成请求 `client:1daa3f3e-99a5-4fc4-809c-6f6ef854a2b2`,流式、`gpt-5.6-sol`,耗时 28.922 秒,账号 33。
- 14:59:54 下一笔请求 `client:8d1f8ef9-e703-482c-ace9-0d8f13a5c8e3` 才进入服务端;内部 request ID `efdb251f-8e86-4f18-99ee-fa1094419dc0`15:00:43 完成,HTTP 200,耗时 49.115 秒。
- 最新请求使用上游账号 `https://api.iceiu.com plus 0.03`ID 33)、模型 `gpt-5.6-sol`、proxy 3;没有 failover、select failure 或 forward failure。
- proxy 3 为 `platform-infra-sub2api-pk01-local-egress-proxy`127.0.0.1:10809;对应 Hysteria 客户端自 7 月 8 日持续 active,调查窗口无错误日志,当前存在正常连接。
- PRhttps://github.com/pikasTech/unidesk/pull/2072
- Merge commit`9a0bf6c7f76b2b736035989a32b7743991da7d73`
- owning YAML`config/platform-infra/sub2api-codex-pool.yaml#runtime.errorPassthroughRules`
- 受控 CLI`platform-infra sub2api codex-pool error-passthrough list|apply|delete`
- 技能参考:`.agents/skills/unidesk-sub2api/references/codex-pool.md`
- 官方源码版本:https://github.com/Wei-Shaw/sub2api/tree/v0.1.155
## 判定边界
## 验证
Sub2API v0.1.153 当前原生 request 明细记录请求完成耗时,但未记录流式首字时间和逐事件间隔。因此不能从现有数据精确证明客户端何时展示首字;不过“16 分 21 秒无入站请求”、用户/API Key 并发均为 0,以及随后请求 49 秒正常完成,足以排除 Sub2API 内部排队、上游账号占槽 15 分钟和 proxy 3 在该窗口报错
## 建议
让用户侧保留该时段客户端日志,重点检查本地 Agent 是否在上一轮完成后未推进状态、请求是否直到 14:59:54 才真正发出,以及本地 HTTP/SSE 客户端是否错误等待已经关闭的流。后续 CLI 可泛化补充按用户邮箱映射用户 ID、请求间空窗和 TTFT/末事件可见性;本次只读调查未取消请求,也未修改 runtime、YAML、proxy 或调度
- TypeScript 相关文件 `bun --check` 全部通过
- `git diff --check origin/master...HEAD` 通过。
- dry-run:目标规则为 `missing``mutation=false`
- confirm apply`mutation=true``state=synced`
- 再次 list`mutation=false``ruleId=1``state=synced`
- `platform-infra sub2api status --target PK01`
- `sub2api-app` healthy
- 镜像 `docker.1panel.live/weishaw/sub2api:0.1.155`
- `config/platform-infra/sub2api.yaml`
- PK01 `image.tag: 0.1.155`
@@ -0,0 +1,3 @@
# R2.2 通用故障归因与调优任务报告
本分支集中保留客户可见错误归因、所有分组诊断、failover/重试、TTFT、runtime CRUD、临时不可调度模板及账号粒度评分的基础能力。原 R2.2.1-R2.2.15 均已完成;客户专项事件、账号优先级、利润和 Grok 接入已迁到独立职责分支。
@@ -0,0 +1,23 @@
# R2.4.1 任务报告
## 结论
用户 `mail0795336304@163.com` 的“卡住约 15 分钟”不发生在 Sub2API 的在途请求、账号排队或 proxy 3 出网阶段。服务端证据显示,上一笔请求于 2026-07-14 14:43:33UTC+8)成功结束,下一笔直到 14:59:54 才进入 Sub2API,中间约 16 分 21 秒没有该用户的新入站请求。卡点因此位于 Sub2API 入站之前,优先怀疑客户端、本地 Agent 状态机或客户端到入口之间的请求提交链路。
## 原生运维证据
- 用户 ID:22;账号状态 active;用户并发上限 10,调查时 current concurrency 为 0。
- API Key:名称 `pika_win`、ID 46、分组 `unidesk-codex-pool`;调查时 current concurrency 为 0。
- 最近 30 分钟共 7 笔请求,均为成功,无用户可见错误。
- 14:43:33 完成请求 `client:1daa3f3e-99a5-4fc4-809c-6f6ef854a2b2`,流式、`gpt-5.6-sol`,耗时 28.922 秒,账号 33。
- 14:59:54 下一笔请求 `client:8d1f8ef9-e703-482c-ace9-0d8f13a5c8e3` 才进入服务端;内部 request ID `efdb251f-8e86-4f18-99ee-fa1094419dc0`15:00:43 完成,HTTP 200,耗时 49.115 秒。
- 最新请求使用上游账号 `https://api.iceiu.com plus 0.03`ID 33)、模型 `gpt-5.6-sol`、proxy 3;没有 failover、select failure 或 forward failure。
- proxy 3 为 `platform-infra-sub2api-pk01-local-egress-proxy`127.0.0.1:10809;对应 Hysteria 客户端自 7 月 8 日持续 active,调查窗口无错误日志,当前存在正常连接。
## 判定边界
Sub2API v0.1.153 当前原生 request 明细记录请求完成耗时,但未记录流式首字时间和逐事件间隔。因此不能从现有数据精确证明客户端何时展示首字;不过“16 分 21 秒无入站请求”、用户/API Key 并发均为 0,以及随后请求 49 秒正常完成,足以排除 Sub2API 内部排队、上游账号占槽 15 分钟和 proxy 3 在该窗口报错。
## 建议
让用户侧保留该时段客户端日志,重点检查本地 Agent 是否在上一轮完成后未推进状态、请求是否直到 14:59:54 才真正发出,以及本地 HTTP/SSE 客户端是否错误等待已经关闭的流。后续 CLI 可泛化补充按用户邮箱映射用户 ID、请求间空窗和 TTFT/末事件可见性;本次只读调查未取消请求,也未修改 runtime、YAML、proxy 或调度。
@@ -1,4 +1,4 @@
# R2.2.17 任务报告
# R2.4.2 任务报告
## 结果
@@ -1,4 +1,4 @@
# R2.2.18 任务报告
# R2.4.3 任务报告
## 结果
@@ -1,4 +1,4 @@
# R2.2.19 任务报告
# R2.4.4 任务报告
## 结果
@@ -17,4 +17,4 @@
## 后续
内部监控超时、请求切号关联和 P0/P1/P2 快速查询分别由 R2.2.23 与 R2.2.21 继续增强;这些后续能力不改变本任务的原生只读边界。
内部监控超时、请求切号关联和 P0/P1/P2 快速查询分别由 R2.4.8 与 R2.4.6 继续增强;这些后续能力不改变本任务的原生只读边界。
@@ -1,4 +1,4 @@
# R2.2.20 任务报告
# R2.4.5 任务报告
## 目标
@@ -1,4 +1,4 @@
# R2.2.21 任务报告
# R2.4.6 任务报告
## 结果
@@ -1,4 +1,4 @@
# R2.2.22 任务报告
# R2.4.7 任务报告
## 结论
@@ -1,4 +1,4 @@
# R2.2.23 任务报告
# R2.4.8 任务报告
## 结果
@@ -1,4 +1,4 @@
# R2.2.24 任务报告
# R2.4.9 任务报告
## 结论
@@ -0,0 +1,3 @@
# R2.4 客户事件与原生诊断任务报告
本分支汇总用户卡顿反馈、一键用户追踪、原生智能诊断与渠道监控、P0/P1/P2 快查,以及错误 #17440#17490#17511 的专项调查。迁入的九项任务及报告均保持完成状态。
@@ -0,0 +1,108 @@
# R2.5.10 任务报告
## 范围与来源
- 窗口:最近 8 小时。
- 目标:PK01。
- 数据源:
- Sub2API 原生 admin/ops 分组概要、账号可用性与并发;
- 原生 admin usage 账号流水、Token 与 `actual_cost`
- 原生 request-errors 与 system-log 账号评分证据。
- 全程只读,未修改 runtime、YAML、优先级、账号或运行面。
- Grok 按现有利润策略排除,不进入 OpenAI 账号成本与利润聚合。
## 分组概要
- `unidesk-codex-pool`
- Ops 请求 2,155
- 客户错误 29,错误率 1.35%;
- 上游错误率 7.33%
- TTFT P99 893,414 ms
- usage 流水约 1,940 请求、13.264M Token、189.5743 标准 API USD。
- `自用`
- Ops 请求 3,291
- 客户错误 0
- 上游错误率 0.21%
- TTFT P99 24,285 ms
- usage 流水约 2,942 请求、21.951M Token、344.7493 标准 API USD。
- 当前账号可用 8/10、并发 5/225、排队 0。
- 账号 29、30 因余额不足 403 不可用。
## 盈利池账号评分与流水
- `https://sub2.pokexiao.com pro 0.05`
- 100/A,高置信度;
- 192 次尝试,失败率 0TTFT P95 6,797 ms
- 192 条流水、2.567M Token、26.8695 API USD。
- `https://api.iceiu.com plus 0.03`
- 100/A,高置信度;
- 223 次尝试,失败率 0TTFT P95 4,619 ms
- 223 条流水、0.435M Token、21.1954 API USD。
- `https://sub.yjxm1221.top plus 0.01`
- 99.5/A,高置信度;
- 630 次尝试,失败率 0.16%TTFT P95 9,806 ms
- 约 627 条流水、3.988M Token、50.0402 API USD。
- `https://ai.whistlelads.com plus 0.03`
- 99/A,高置信度;
- 296 次尝试,失败率 0.34%TTFT P95 9,070 ms
- 约 295 条流水、3.009M Token、39.7672 API USD。
- `https://sub2.pokexiao.com plus 0.03`
- 88/B,高置信度;
- 627 次尝试,失败率 3.99%TTFT P95 7,554 ms
- 25 个客户错误,占盈利池 29 个客户错误的 86.2%;
- 约 602 条流水、3.229M Token、51.4244 API USD。
- `https://api.recurdream.com plus 0.02`
- 20/insufficient,低置信度;
- 仅 1 次尝试且发生 failover,最终恢复;
- 盈利池无足够 usage 流水,不能据此判定退役。
- `lyon9801 0.10``https://sub.yjxm1221.top pro 0.06`
- 该窗口无尝试,评分证据不足。
- `https://api.lwylink.xyz pro 0.1``https://api.lwylink.xyz plus 0.05`
- 无尝试且当前余额不足,不可用。
## 自用池账号评分与流水
- `https://sub2.pokexiao.com pro 0.05`
- 100/A,高置信度;
- 549 次尝试,失败率 0TTFT P95 9,381 ms
- 549 条流水、3.757M Token、64.4262 API USD。
- `https://sub2.pokexiao.com plus 0.03`
- 99.4/A,高置信度;
- 990 次尝试,失败率 0.20%,一次 failover 成功;
- TTFT P95 7,149 ms
- 约 988 条流水、6.778M Token、102.8114 API USD。
- `https://ai.whistlelads.com plus 0.03`
- 99.1/A,高置信度;
- 770 次尝试,失败率 0.26%,一次 failover 成功;
- TTFT P95 10,806 ms
- 约 768 条流水、6.238M Token、93.7645 API USD。
- `https://api.iceiu.com plus 0.03`
- 99/A,高置信度;
- 301 次尝试,失败率 0.33%TTFT P95 7,456 ms
- 301 条流水、0.663M Token、43.9813 API USD。
- `https://sub.yjxm1221.top plus 0.01`
- 96.8/A,高置信度;
- 335 次尝试,失败率 0.90%,两次 failover 均恢复;
- TTFT P95 13,377 ms
- 约 328 条流水、4.471M Token、39.3431 API USD。
- `https://api.recurdream.com plus 0.02`
- 40/insufficient,低置信度;
- 9 次尝试、3 次 failover 均恢复,未产生客户错误;
- 约 6 条流水、0.262M Token、1.4470 API USD。
## 经济汇总
- 盈利池收入:约 ¥18.9574。
- 盈利池采购成本:约 ¥5.2183。
- 自用池采购成本:约 ¥10.8493。
- 不扣自用成本利润:约 ¥13.7392。
- 扣除自用成本利润:约 ¥2.8899。
- 单价口径为人民币倍率,即每 1 标准 API USD 对应的人民币售价或采购成本,不是汇率换算。
## 结论
- 盈利池主要质量问题集中在 `https://sub2.pokexiao.com plus 0.03`,但其自用池表现为 99.4/A,暂不能解释为账号整体不稳定;应继续按盈利池模型、请求类型和极端 TTFT 请求下钻。
- 盈利池 TTFT P99 约 893 秒,而活跃账号 P95 仅约 4.6–9.8 秒,表明是少量极端长尾,不支持整体降低账号评分或全面降优先级。
- `https://api.recurdream.com plus 0.02` 样本过少,评分低但 failover 均恢复,不足以退役。
- 账号 29、30 是明确余额故障,应保持不可用,不纳入质量比较。
- Ops 请求、评分尝试和 usage 流水来自不同原生接口,时间边界与计费过滤不同,数量不能强行一一相等。
@@ -0,0 +1,37 @@
# R2.5.11 任务报告
## 结论
- PK01 `unidesk-codex-pool` 最近 8 小时复核时约有 2295 个请求、32 个客户可见错误,客户错误率 1.39%。
- 32 个客户错误不是同一种账号故障:
- 17 个为上下文窗口超限,属于客户输入约束,不扣账号分;
- 2 个为 `glm-5.2` 未被分组账号支持,属于模型路由配置,不扣账号分;
- 11 个为 `Upstream service temporarily unavailable`
- 2 个为 `Upstream request failed`
- 状态码分布为 502 共 29 个、404 共 2 个、524 共 1 个;同步 30 个、流式 2 个。
- 账号 `https://sub2.pokexiao.com plus 0.03` 原始客户错误 25 个,其中 17 个上下文超限被排除,只有 8 个明确上游错误参与评分;修正后评分为 96.2/A,而不是此前把全部客户错误计入后的 88/B。
- 两个代表性同步 502 均已触发 failover,但请求上下文随后立即 `context canceled`,切号没有剩余执行窗口;这不是当前池并发不足,因为观察时容量 225、在用约 5、排队 0。
## Priority 调整
- 账号 27 `https://sub.yjxm1221.top plus 0.01` 保持 priority 1,兼顾最低成本和高质量。
- 账号 28 `https://ai.whistlelads.com plus 0.03`、31 `https://sub2.pokexiao.com plus 0.03`、33 `https://api.iceiu.com plus 0.03` 调整为 priority 5;账号 32 `https://sub2.pokexiao.com pro 0.05` 保持 priority 5。
- 账号 35 `https://api.recurdream.com plus 0.02` 调整为 priority 20:成本低,但样本少且存在已恢复的上游失败,需要继续观察。
- `lyon9801 0.10` 保持 priority 20,作为零毛利应急账号;账号 19 `https://sub.yjxm1221.top pro 0.06` 保持 priority 50。
- 全部写入均通过受控 runtime priority dry-run、confirm 和逐账号自动回读完成;未修改分组、容量、代理、凭据、状态、可调度或临时不可调度规则。
## 工具与 SKILL
- PR #2077 增加 runtime priority 单账号与精准批量 dry-run/confirm、仅字段更新和逐账号自动对账。
- PR #2082 将评分、请求量、Token、标准 API 美元计费基数、人民币采购倍率和人民币上游成本聚合到一次 `runtime errors --group ... --since ...` 查询。
- 可靠性扣分改为保守的明确归因:只计入原生 upstream 分类、稳定上游网关消息、failover 和 `forward_failed`;上下文、输入校验、模型路由、内部/业务、无账号和未知归因错误全部保留可见但不扣分。
- CLI 输出新增 `scoreableUpstreamErrorRequests``excludedNonUpstreamErrorRequests`、排除原因桶和账号成本流水表。
- `runtime.ts` 从超过 3000 行按输出投影、远端脚本头部和远端脚本尾部拆分,相关文件均低于 2000 行。
- `unidesk-sub2api` SKILL 已固化一次查询完成评分与流水分析、完整账号名称输出和非上游错误不扣分的规则。
## 验证
- 相关 TypeScript 文件 `bun --check` 全部通过,`git diff --check` 通过。
- PK01 真实只读回归中,账号 31 一次显示 624 请求、3.607M Token、56.3256 API USD、0.030 CNY/API USD 和 1.6898 CNY 上游成本。
- `runtime list --target PK01` 回归通过,账号名称、priority 和 runtime 状态正常显示。
- PR #2082 已合并,merge commit 为 `3464e93acd8a2d688933f03f0f78303cdf9c6c64`;该交付为 CLI/SKILL 轻量变更,`rollout=not-applicable`
@@ -0,0 +1,5 @@
# R2.5.12 任务报告
- 原生 trace 证实并发限额错误发生于 SSE 已提交后的 HTTP 200 阶段,`upstream_error_response_already_written=true`;官方临时不可调度规则依赖 HTTP 状态码,不能挽救当前流。
- 现有通用模板已覆盖 429/502/503/504/524 的 `concurrency limit exceeded`,继续追加规则无效,因此未修改模板。
- 已在 `unidesk-sub2api` 禁止事项中固化:未获明确授权时,不修改 Sub2API 源码、版本,也不启用、扩展或调整外部哨兵。
@@ -1,4 +1,4 @@
# R2.2.25 任务报告
# R2.5.1 任务报告
## 结果
@@ -1,4 +1,4 @@
# R2.2.26 任务报告
# R2.5.2 任务报告
## 范围
@@ -1,4 +1,4 @@
# R2.2.27 任务报告
# R2.5.3 任务报告
## 目标
@@ -1,4 +1,4 @@
# R2.2.28 任务报告
# R2.5.4 任务报告
## 范围
@@ -1,8 +1,8 @@
# R2.2.29 任务报告
# R2.5.5 任务报告
## 目标
按 R2.2.28 的最近 4 小时评分与用量结论,精准调整 PK01 Sub2API runtime-manual 账号的全局 priority。只修改 priority,不修改分组、容量、代理、凭据、状态、可调度或临时不可调度规则。
按 R2.5.4 的最近 4 小时评分与用量结论,精准调整 PK01 Sub2API runtime-manual 账号的全局 priority。只修改 priority,不修改分组、容量、代理、凭据、状态、可调度或临时不可调度规则。
## 执行与保护
@@ -1,4 +1,4 @@
# R2.2.30 任务报告
# R2.5.6 任务报告
## 目标
@@ -7,7 +7,7 @@
## 已完成登记
- 子 Issuehttps://github.com/pikasTech/unidesk/issues/2037
- MDTODOR2.2.30,进行中。
- MDTODOR2.5.6,进行中。
- 独立 worktree`/root/unidesk/.worktree/sub2api-runtime-priority`
- 分支:`feat/sub2api-runtime-priority`,基于最新 `origin/master` 创建并推送,worktree clean。
@@ -1,4 +1,4 @@
# R2.2.31 任务报告
# R2.5.7 任务报告
## 窗口与范围
@@ -1,4 +1,4 @@
# R2.2.32 任务报告
# R2.5.8 任务报告
## 经济口径
@@ -0,0 +1,68 @@
# R2.5.9 任务报告
## 范围
- 目标:PK01 Sub2API v0.1.155。
- 原生观测窗口:约 2026-07-15 00:20 至 02:20UTC+8)。
- 范围:全部 3 个分组;只读使用原生 admin Ops overview、request-errors、upstream-errors、account-availability、usage、system-log 索引及稳定 request trace。
- 查询有秒级时间漂移:全分组概要为 2214 个请求;随后分组下钻分别为 622、1593、7 个请求。
## 全局用户可见错误
- 全分组概要:2214 个请求、25 个客户错误,客户错误率 1.13%;27 个上游错误,上游错误率 1.22%。
- `unidesk-codex-pool`:621 个请求、19 个客户错误,错误率 3.06%;20 个上游错误,错误率 3.22%。
- 17 个同步 502 来自账号 31 `https://sub2.pokexiao.com plus 0.03`,模型为 `claude-opus-4-8`,原始语义是输入超过模型上下文窗口。
- 代表请求 `97a552d6-2b4d-45ff-a449-240201e5f127` 最终 502,未触发 failover;这不是随机账号不稳定,切号通常不能解决超上下文输入。
- 2 个 `glm-5.2` 请求因组内没有支持账号快速返回 404,其中同步、流式各 1 个。
- `自用`:1586 个请求、0 个客户错误;4 个上游错误全部经 4 次 failover 恢复,客户错误率 0%。
- 另有 2 个 HTTP 200 后 `forward_failed` 的流式 degraded 请求,稳定请求 ID 为 `abc711f6-aff0-486f-a94b-09426ee4cac1``57f1308e-cbe9-4804-bcd9-a2fb5149e944`;它们不计入原生客户错误率,但客户可能感知到流式中断。
- `grok`:7 个请求、6 个客户错误;SLA 分母排除 3 个 business-limited 后错误率为 75%。
- 唯一账号 36 `https://sub.yjxm1221.top grok` 出现 3 次上游 502 overload。
- 3 次均触发 failover,但排除失败账号后没有其他候选;随后另有 3 个请求在路由阶段直接 503。
- 代表请求 `dfd99f91-52e4-4de9-bea9-d64a3e8e623b` 在 1346 ms 收到上游 502,同毫秒进入切号,2 ms 后因 `no available accounts` 返回 502。因此不是切号超时,而是单账号池没有备用候选。
## 首字延迟
- `unidesk-codex-pool`TTFT P50 3729 ms、P95 8983 ms、P99 10688 ms、最大 101398 ms。
- `自用`TTFT P50 4076 ms、P95 12768 ms、P99 23386 ms、最大 540382 ms,长尾明显高于商业池。
- `grok`:成功流式首 token 样本不足,TTFT 不可用;唯一成功请求总耗时 2264 ms,不能代替 TTFT。
- 当前 Sub2API 原生 Ops 响应未提供 `/v1/responses``/v1/responses/compact` 的独立 request-level TTFT,因此本窗口不能可靠拆分普通与 compact;总耗时没有被冒充为 TTFT。
- 账号长尾重点:
- `https://sub.yjxm1221.top plus 0.025`:自用池 TTFT P95 19286 ms、P99 49075 ms、最大 540382 ms。
- `https://ai.whistlelads.com plus 0.03`:自用池 P95 14827 ms、P99 25735 ms、最大 27701 ms。
- `https://api.iceiu.com plus 0.03`:自用池 P95 9088 ms、P99 18947 ms、最大 31725 ms。
- `https://sub2.pokexiao.com plus 0.03`:商业池最大 101398 ms;自用池 P99 14588 ms、最大 59814 ms。
## 账号评分
评分是分组内、窗口内分析结果;可靠性 60、TTFT 25、当前可用性 15。上下文错误会降低可靠性分,因此不能直接解释为供应商网络质量。
### unidesk-codex-pool
- `https://ai.whistlelads.com plus 0.03`:100/A,高置信,130 次尝试、0 失败,TTFT P95 9906 ms。
- `https://sub2.pokexiao.com pro 0.05`:100/A,中置信,14 次尝试、0 失败,TTFT P95 4839 ms。
- `https://api.iceiu.com plus 0.03`:100/A,高置信,55 次尝试、0 失败,TTFT P95 5416 ms。
- `https://sub2.pokexiao.com plus 0.03`:86.3/B,高置信,373 次尝试、17 次失败,TTFT P95 6557 ms;扣分全部来自超上下文请求,不应据此退役账号。
### 自用
- `https://sub2.pokexiao.com pro 0.05`:100/A,高置信,113 次尝试、0 失败,TTFT P95 7035 ms。
- `https://api.iceiu.com plus 0.03`:100/A,高置信,161 次尝试、0 失败,TTFT P95 9088 ms。
- `https://sub2.pokexiao.com plus 0.03`:99.6/A,高置信,764 次尝试、1 次失败,1 次 failover 成功,TTFT P95 7152 ms。
- `https://ai.whistlelads.com plus 0.03`:96.3/A,高置信,200 次尝试、2 次失败,1 次 failover 成功,TTFT P95 14827 ms。
- `https://sub.yjxm1221.top plus 0.025`:94/A,高置信,193 次尝试、3 次失败,2 次 failover 均成功,TTFT P95 19286 ms;主要风险是极端长尾。
- `https://api.recurdream.com plus 0.02`100/insufficient,低置信,仅 3 次尝试,不能与高样本账号等价排序。
### grok 与无样本账号
- `https://sub.yjxm1221.top grok`20/insufficient,低置信,4 次尝试、3 次失败,3 次 failover 均无候选;虽然样本少,但失败模式明确。
- `lyon9801 0.10``https://sub.yjxm1221.top pro 0.06``https://api.recurdream.com plus 0.02` 在商业池等账号本窗口无流量,保持 insufficient,不伪造评分。
- `https://api.lwylink.xyz pro 0.1``https://api.lwylink.xyz plus 0.05` 当前均因余额不足 403 不可用;两个 OpenAI 分组均为 8/10 可用。
## 结论与建议
1. 当前不是 Sub2API 总并发问题:全局查询时使用量分别为 11/225、10/225、0/10,排队均为 0;不建议以降低并发作为主修复。
2. 商业池最大错误源是超上下文请求被包装成 502。应优先调查 Sub2API 的 Anthropic 兼容错误映射,把确定的输入/上下文错误转换为明确 4xx;不要给账号加临时不可调度,也不要靠切号掩盖客户输入问题。
3. Grok 是当前真实可靠性短板。单账号结构使 failover 必然失败;源头方案是增加独立可用候选或在没有候选时快速、明确降级。仅增加冷却规则会减少重复撞击,但不能恢复请求。
4. 自用池的上游 5xx 已被切号吸收,但 2 个流式 degraded 仍需继续观察;账号 27 的 540 秒 TTFT 极端值应在后续窗口确认是否复现,再决定是否调整 priority,不能凭单个最大值自动降级。
5. 评分上,账号 32、33 最稳定;账号 31 在自用池表现优良,商业池 B 级主要受客户上下文错误污染;账号 27 可靠性尚可但时延长尾最明显;Grok 账号需要优先补冗余。
@@ -0,0 +1,41 @@
# R2.6.10 任务报告
## 结论
若 2026-08 不再采购固定账号 `lyon9801 0.0`,售价保持 `0.15 CNY per API USD`,并且营业流量维持当前日均,预计可以盈利。按其他活跃账号实际加权平均边际成本接管 lyon 流量,预计盈利池利润约 `1442.93 CNY/月`;扣除自用成本后的整体利润约 `1051.71 CNY/月`
## 数据口径
- 快照截至 2026-07-15 02:06 UTC,来源为 PK01 Sub2API 原生 admin usage,共 20 次分页读取。
- 当前日均线性外推至 31 天;预计盈利池标准 API 计费基数约 `11650.914122 API USD`,售价 `0.15 CNY per API USD`,营业额 `1747.637118 CNY`
- 下月不计 `lyon9801 0.0``1300 CNY` 固定成本,也不假设 lyon 继续以零边际成本承接流量。
- 当前 lyon 在盈利池占 `24.5497%`,在自用池占 `19.0978%`
## 替代成本
- 非 lyon 盈利池账号当前加权平均采购倍率:`0.026153228 CNY per API USD`
- 非 lyon 自用池账号当前加权平均采购倍率:`0.031014832 CNY per API USD`
- lyon 盈利池流量按该平均倍率替代,预计新增采购成本 `74.805089 CNY/月`
- lyon 自用流量按该平均倍率替代,预计新增采购成本 `74.713171 CNY/月`
- 替代后盈利池总采购成本约 `304.709018 CNY/月`;自用总采购成本约 `391.213866 CNY/月`
## 利润情景
- 只删除固定成本、仍假设 lyon 流量零边际成本的理论上限:不扣自用 `1517.733190 CNY`,扣自用 `1201.232495 CNY`
- 按其他账号当前加权平均成本接管的现实预测:不扣自用 `1442.928101 CNY`,扣自用 `1051.714235 CNY`
- 若 lyon 流量都能由 `0.01` 倍率账号承接:不扣自用 `1489.130568 CNY`,扣自用 `1148.540377 CNY`
- 若 lyon 流量只能由 `0.06` 倍率账号承接:不扣自用 `1346.117462 CNY`,扣自用 `885.079784 CNY`
## 日均现实预测
- 营业额:约 `56.38 CNY/天`
- 盈利池采购成本:约 `9.83 CNY/天`
- 自用采购成本:约 `12.62 CNY/天`
- 不扣自用利润:约 `46.55 CNY/天`
- 扣自用利润:约 `33.93 CNY/天`
## 风险
移除 lyon 后,其他盈利池账号需多承接约 `32.54%` 流量,自用池其他账号需多承接约 `23.61%`,合计非 lyon 账号负载约增加 `27.74%`。财务预测成立的前提是剩余账号具有该容量,且错误率、重试和客户流失不恶化;本报告未把可靠性下降造成的收入损失货币化。因此建议将 `1051.71 CNY/月` 视为当前流水不变时的中心估计,而非保证值。
本次仅只读评估,未修改账号、YAML、runtime、Sub2API 或外部哨兵。
@@ -0,0 +1,23 @@
# R2.6.11 任务报告
## 交付
- 已通过 [PR #2087](https://github.com/pikasTech/unidesk/pull/2087) 合并到 `master`,合并提交 `062faeb81f680728d08cd4eabef01f5e3fdf5372`
- `profit` 新增 `--sale-rate <CNY/API_USD>`,只覆盖本次只读候选售价,不修改 YAML。
- `profit` 新增可重复的 `--scenario-without-account <id-or-exact-name>`,使用精确账号 ID 或完整名称模拟账号退出。
- 情景在同一次 Sub2API 原生 usage 聚合中自动移除选中账号绑定的期间成本,并把其盈利池和自用池流量分别按各自剩余账号的实际加权采购倍率重分配。
- 默认 Kubernetes 风格汇总和显式 JSON 直接披露理论利润上限、重分配利润、日均营业额与成本、账号流量占比、替代成本和剩余账号负载增幅,不再需要 `--accounts` 分页及手工算术。
- selector 不存在时失败;剩余账号有未知成本、没有替代计费基数或仍有未分类流量时输出 `partial`,不把未知成本当作零。
- Sub2API skill 描述和 `references/codex-pool.md` 已同步通用入口、计算语义与容量风险边界;核心代码和文档入口未固化具体账号、月份或售价。
## 验证
- PK01 真实只读命令一次返回 `status=complete`、两种利润、日均值、两池账号占比和负载增幅:`profit --month 2026-07 --forecast --sale-rate 0.15 --scenario-without-account 'lyon9801 0.0'`
- 显式 `--json` 保留精确十进制、完整账号名称、替代成本和负载增幅。
- 非法 `--sale-rate -1` 在发起远端请求前明确拒绝。
- `quick_validate.py .agents/skills/unidesk-sub2api` 通过。
- `git diff --check` 通过。
## 边界
本次只修改 UniDesk CLI 与 skill 文档;未修改 Sub2API 源码、版本、YAML、runtime、外部哨兵或线上账号。
@@ -0,0 +1,43 @@
# R2.6.12 任务报告
## 综合结论
- 本月 `lyon9801 0.0``1300 CNY` 已经发生,属于沉没成本;本月应继续保持高利用率,优先消耗其零边际成本能力,不建议提前停用。
- 下月默认不续固定号。按当前流量和其他账号实际加权成本接管,售价 `0.15 CNY/API USD` 时预计不扣自用利润 `1447.41 CNY/月`,扣自用利润 `1055.78 CNY/月`
- 即使售价仍为 YAML 当前 `0.10 CNY/API USD`,不续固定号后预计不扣自用利润 `863.06 CNY/月`,扣自用利润 `471.44 CNY/月`,仍为正。
## 固定号经济性
- 当前 lyon 流量份额只避免约 `150.35 CNY/月`替代采购成本,远低于 `1300 CNY`固定费;在当前份额下,相关流量需约增长 `8.65` 倍才覆盖固定费。
- 即使现有盈利池和自用池全部由 lyon 承接,按当前其他账号成本最多避免约 `697.25 CNY/月`采购成本,仍低于固定费;总流量需约增长 `1.86` 倍且 lyon 能承接全部流量,才接近纯成本保本。
- 当前流量下合理续费上限:保持当前份额约 `150 CNY/月`;若能稳定承接全部现有两池流量,理论上限约 `700 CNY/月``1300 CNY/月`不具备纯财务合理性。
- 保留 lyon 相对不续的月度增量代价约为:不扣自用 `1224.78 CNY`,扣自用 `1149.65 CNY`。只有其可靠性预计能避免超过约 `1150 CNY/月`的客户流失、补偿、故障和支持成本时,续费才可能合理。
## 售价建议
- 财务转正不依赖把售价从 `0.10`提高到 `0.15`;不续固定号后,两个售价下均盈利。
- `0.15`相较 `0.10`把扣自用利润从约 `471.44 CNY`提高到约 `1055.78 CNY`,增加约 `584.34 CNY/月`安全垫。
- 建议把 `0.15`作为新销售或可调整套餐的目标核算价;存量客户是否调整应结合市场、承诺和流失风险,不应仅凭成本立即统一涨价。
- YAML 当前 `saleRateCnyPerApiUsd` 仍为 `0.10`;本轮 `0.15`只是只读情景,不代表实际售价已变更。
## 容量与可靠性
- 移除 lyon 后,盈利池其他账号需增加约 `32.64%`负载,自用池其他账号需增加约 `23.77%`,因此不能只看利润直接切除。
- 续费决策前应使用 Sub2API 原生账号级评分、客户可见错误、普通请求与压缩请求 TTFT、并发限制和 failover 成功率,确认剩余账号能承接增量。
- 不默认使用外部哨兵;如需运行时试切或调整 priority,必须另获明确授权,并继续使用官方 runtime 能力和受控 CLI。
- 优先级原则应为“质量达标后按边际成本排序”:稳定的 `0.01`/`0.02`账号优先,质量合格的 `0.03`账号承担主力与冗余,`0.05`/`0.06`账号作为容量和故障兜底;不得在没有最新评分时仅按账号名称直接批量调整。
## 自用成本
- 不续固定号后的自用采购成本预计约 `391.62 CNY/月`,应作为独立预算披露,不用盈利池利润掩盖。
- 建议日常同时观察“不扣自用”和“扣自用”两种口径:前者判断销售业务,后者判断整体现金收益。
## 建议执行顺序
1. 本月继续充分使用已付费 lyon,不提前退场。
2. 月末前用原生账号级指标确认剩余账号容量和质量,不做未经授权的试切。
3. 下月默认不续;只有报价降至约 `700 CNY/月`以内,或流量与可量化可靠性价值显著提升时重新评估。
4. 新销售按 `0.15`核算,存量价格单独评估。
5. 不续后持续观察客户可见错误、TTFT、重试与切号成功率;若可靠性损失接近约 `1150 CNY/月`,再评估固定直连账号或其他高质量容量方案。
本任务只形成运营建议,未修改 YAML、runtime、Sub2API、外部哨兵、账号或售价。
@@ -1,4 +1,4 @@
# R2.2.33 任务报告
# R2.6.1 任务报告
## 结果
@@ -1,4 +1,4 @@
# R2.2.34 任务报告
# R2.6.2 任务报告
## 修正结论
@@ -1,4 +1,4 @@
# R2.2.35 任务报告
# R2.6.3 任务报告
## 结论
@@ -1,4 +1,4 @@
# R2.2.36 任务报告
# R2.6.4 任务报告
## 交付
@@ -0,0 +1,6 @@
# R2.6.5 任务报告
- owning YAML 增加 `2026-07` 的 lyon9801 一次性期间成本 1300 CNY;账号流量边际倍率改为 0.0。
- 利润 CLI 增加 `--month YYYY-MM`,使用 Sub2API 原生 `/api/v1/admin/usage/stats` 按分组和账号聚合,约 8 秒完成;短时 `--since` 保留逐条 usage 精确窗口。
- 账号 15 已通过 runtime CRUD 从 `lyon9801 0.10` 改为 `lyon9801 0.0`,全局 priority 从 20 调为 1,写后自动回读均 reconciled。
- 7 月至今:收入 525.078160 CNY,盈利池流量成本 103.817293 CNY,自用流量成本 142.692022 CNY,期间成本 1300 CNY;不扣自用净利润 -878.739133 CNY,扣自用净利润 -1021.431155 CNY。
@@ -0,0 +1,5 @@
# R2.6.6 任务报告
- 利润 CLI 增加 `--month YYYY-MM --forecast`,按月初至当前实际秒数线性外推收入、盈利池流量成本和自用流量成本;一次性期间成本只扣一次。
- 2026-07 实测缩放系数 2.20319165:预计整月收入 1157.554135 CNY,盈利池流量成本 228.743080 CNY,自用流量成本 315.207563 CNY,一次性成本 1300 CNY。
- 预计整月不扣自用利润 -371.188945 CNY,扣除自用利润 -686.396508 CNY。该结果是 run-rate 预测,不是已实现收益。
@@ -0,0 +1,42 @@
# R2.6.7 任务报告
## 结论
亏损的决定性原因不是 `lyon9801 0.0` 占比过低,而是当前整月销售流水不足以覆盖其 `1300 CNY` 月度一次性成本。提高 lyon 占比可以降低其他账号边际成本,但在当前收入规模下不能单独扭亏。
## 数据口径
- 统计月:2026-07,截至 2026-07-15 01:53 UTC,按月内流水线性外推,缩放系数 `2.20184522`
- 整月预计收入:`1159.137600 CNY`
- 盈利池流量成本:`228.951233 CNY`
- 自用池流量成本:`316.145204 CNY`
- `lyon9801 0.0` 一次性成本:`1300 CNY`,边际成本按 `0.0` 计算。
- 不扣自用预计利润:`-369.813633 CNY`
- 扣除自用预计利润:`-685.958837 CNY`
## lyon9801 占比与价值
- 盈利池月初至今标准 API 美元计费基数合计 `5264.391840 USD`,其中 `lyon9801 0.0``1291.868865 USD`,占 `24.54%`
- 自用池月初至今标准 API 美元计费基数合计 `5719.246077 USD`,其中 `lyon9801 0.0``1092.319869 USD`,占 `19.10%`
- lyon 盈利池整月预计收入贡献约 `284.45 CNY`,只覆盖固定成本的 `21.9%`
- 按其他自用账号平均边际成本估算,lyon 在自用池整月约避免 `74.64 CNY` 采购成本;收入贡献与避免成本合计约 `359.09 CNY`,只覆盖固定成本的 `27.6%`
## 亏损归因
1. 固定成本是决定性约束。即使盈利池和自用池全部由零边际成本的 lyon 承接,整月收入仍只有 `1159.14 CNY`,理论最好利润为 `1159.14 - 1300 = -140.86 CNY`
2. 盈利池其他账号边际成本扩大亏损。当前 `228.95 CNY` 盈利池流量成本使不扣自用亏损从理论最低 `-140.86 CNY` 扩大到 `-369.81 CNY`
3. 自用池成本进一步扩大管理口径亏损。当前 `316.15 CNY` 自用成本使扣自用亏损达到 `-685.96 CNY`
4. lyon 占比有提升空间,但不是根因。当前盈利池占比 `24.54%` 不算低;即使提升至 `100%`,最多消除现有盈利池边际成本,仍亏 `140.86 CNY`
## 盈亏平衡
- 理想零边际成本:整月收入至少达到 `1300 CNY`,比当前预测增加约 `12.15%`
- 保持当前盈利池成本率且不扣自用:整月收入约需 `1619.98 CNY`,比当前预测增加约 `39.76%`
- 保持当前成本结构并扣除自用:整月收入约需 `2013.93 CNY`,比当前预测增加约 `73.74%`
## 建议
- 保持 `lyon9801 0.0` 的高优先级,让新增盈利池流量优先落到该账号,以降低边际成本;不应把提高占比误判为足以单独扭亏。
- 首要经营目标应是增加盈利池销售流水:理想状态至少增长 `12.2%`,按当前账号组合更实际的保本目标约为增长 `40%`
- 自用池单独核算预算和成本,不用盈利池收入掩盖自用消耗;扣自用口径用于整体现金成本,不扣自用口径用于盈利池经营判断。
- 本次仅只读分析,未修改 runtime、Sub2API 源码、版本或外部哨兵。
@@ -0,0 +1,24 @@
# R2.6.8 任务报告
## 口径
沿用 R2.6.7 截至 2026-07-15 01:53 UTC 的 2026-07 整月线性预测:盈利池标准 API 美元计费基数 `11591.376000 USD`,盈利池流量成本 `228.951233 CNY`,自用流量成本 `316.145204 CNY``lyon9801 0.0` 本月一次性成本 `1300 CNY`。售价按 `0.15 CNY per API USD` 计算,不做汇率换算。
## 结果
- 整月预计收入:`1738.706400 CNY`
- 不扣自用预计利润:`1738.706400 - 228.951233 - 1300 = 209.755167 CNY`
- 扣除自用预计利润:`209.755167 - 316.145204 = -106.390037 CNY`
- 相比售价 `0.10`,两种利润口径均改善 `579.568800 CNY`
- 若盈利池和自用池全部由零边际成本的 `lyon9801 0.0` 承接,理论利润为 `438.706400 CNY`
## 保本售价
- 保持当前盈利池账号组合、不扣自用:约 `0.131904 CNY per API USD`
- 保持当前账号组合并覆盖自用成本:约 `0.159178 CNY per API USD`
## 判断
售价 `0.15` 足以使盈利池经营口径转正,预计利润约 `209.76 CNY`;但不足以同时覆盖当前自用池成本,整体现金成本口径仍预计亏损约 `106.39 CNY`。提高 `lyon9801 0.0` 占比会继续改善结果:若边际成本充分降至零,`0.15` 售价下理论利润可达约 `438.71 CNY`
本次只读计算,未修改 YAML、runtime、Sub2API 源码、版本或外部哨兵。
@@ -0,0 +1,34 @@
# R2.6.9 任务报告
## 新鲜快照
使用最新 `origin/master` 的利润 CLI,从 PK01 Sub2API 原生 `/api/v1/admin/usage/stats` 拉取 20 次分页查询。统计窗口为 2026-07-01 00:00 UTC 至 2026-07-15 02:01:35 UTC,实际已过 `14.084440241` 天;盈利池计费基数 `5282.65742955 API USD`,盈利池采购成本 `104.2007966605 CNY`,自用采购成本 `143.759478531 CNY`。缺失成本账号和未分类流量均为零。
售价按 `0.15 CNY per API USD` 重算;`lyon9801 0.0``1300 CNY` 是本月一次性成本,日均仅用于利润摊销,不代表每天发生现金支出。
## 实际日均与整月日均
线性外推不会改变日均值:实际已过时长计算和整月预测除以 31 天结果一致。
- 每日标准 API 计费基数:`375.070456 API USD`
- 每日营业额:`56.260568 CNY`
- 盈利池每日变动采购成本:`7.398292 CNY`
- 自用池每日变动采购成本:`10.206971 CNY`
- lyon 本月固定成本日均摊销:`41.935484 CNY`
- 不扣自用的每日总成本:`49.333776 CNY`,每日利润 `6.926793 CNY`
- 扣除自用的每日总成本:`59.540747 CNY`,每日利润 `-3.280178 CNY`
## 月度对应值
- 整月预计营业额:`1744.077622 CNY`
- 盈利池变动成本:`229.347041 CNY`
- 自用变动成本:`316.416113 CNY`
- 固定成本:`1300 CNY`
- 不扣自用预计利润:`214.730581 CNY`
- 扣除自用预计利润:`-101.685532 CNY`
## 判断
每日经营在固定成本前是正贡献:不扣自用时为 `48.862277 CNY/天`,扣自用时为 `38.655305 CNY/天`。前者高于固定成本日均摊销 `41.935484 CNY/天`,因此盈利池口径盈利;后者低于固定成本摊销,因此整体口径每天约亏 `3.28 CNY`。此前计算方向正确,新快照将整体预计亏损从约 `106.39 CNY` 更新为约 `101.69 CNY`
本次只读复核,未修改 YAML、runtime、Sub2API 或外部哨兵。
@@ -0,0 +1,3 @@
# R2.6 成本与利润统计任务报告
本分支汇总 YAML-first 利润 CLI、CNY per API USD 口径修正、最近 7 天统计和单次聚合优化。四项历史任务及报告均已迁入并保持完成状态。
@@ -0,0 +1,7 @@
# R2.7.1 Sub2API 原生 Grok 接入 Codex 调查报告
只读核查官方最新发布 `v0.1.155`、源码和相关 issue/PR。最新版本原生支持 `platform=grok`,账号类型包括 xAI OAuth 和 API Key;公开 `/v1/responses``/responses``/backend-api/codex/responses` 可服务 Codex Responses 请求。正确拓扑是 Codex 使用绑定 Grok 分组的 Sub2API API Key,由分组选择 Grok provider,再转发到 OAuth subscription proxy 或 xAI API。
普通接入无需修改 Sub2API 源码。客户端应直接使用 `grok-4.5` 与 Responses wire API;只有消费端必须保留别名时才配置 `model_mapping`。不应把 Grok 伪装成 `platform=openai`,否则会绕过 Grok 专属 OAuth、身份头、请求净化、配额和监控逻辑。
官方演进证据包括 Grok subscription PR #3310、Codex compatibility PR #3558、CLI identity issue #3952 与综合修复 PR #4009。任务未修改 runtime、YAML、代码或部署。
@@ -0,0 +1,41 @@
# R2.7.2 Codex Grok profile 接入 Sub2API 报告
## 结果
已把 `/root/.codex/config.toml.grok` 调整为独立的 Sub2API Grok Responses provider
- `model_provider = "Sub2API_Grok"`
- `model = "grok-4.5"`
- `review_model = "grok-4.5"`
- `model_reasoning_effort = "high"`
- `base_url = "https://api.pikapython.com/v1"`
- `wire_api = "responses"`
- `requires_openai_auth = true`
- `supports_websockets = false`
`/root/.codex/auth.json.grok` 原本已经是 Codex 需要的 `OPENAI_API_KEY` 结构,且其中 Key 正是绑定 Sub2API Grok 分组的 Key,因此未替换密钥,只做结构、fingerprint 和权限验证。两个文件权限均保持 `0600`,未输出完整密钥。
## 验证
- TOML 解析成功,provider、模型、base URL 和 Responses transport 均符合预期。
- JSON 解析成功,仅包含 `OPENAI_API_KEY`;验证前后 fingerprint 均为 `2d90208c41f3`
- 使用该 Key 请求 `https://api.pikapython.com/v1/models` 返回 HTTP 200,共 22 个 Grok 模型,包含 `grok-4.5``grok-4.3``grok-build-0.1` 和 Grok Composer,证明 Key 已绑定原生 Grok 分组。
## 最小推理 smoke
第一次 `grok-4.5` Responses smoke
- 最终 HTTP 502。
- Sub2API request ID`5fb6cb9f-5243-4f6a-a4c9-70a908b12a3e`
- 请求已进入 `grok` 分组和账号 `https://sub.yjxm1221.top grok`(账号 36)。
- 上游返回 502 后触发 failover,但该分组只有一个账号,排除原账号后出现 `no available accounts`
第二次有界复测:
- 最终 HTTP 503。
- Sub2API request ID`25064661-32e1-42ad-9ec3-84c154bf870e`
- trace 结论为 `account-select-failed`6ms 内出现 `no available accounts`,说明前一次失败后当前 Grok 池无可调度候选。
## 结论
Codex profile、认证文件、Sub2API API Key 和 Grok 分组路由均已正确配置。当前不能完成成功推理验收的原因是 Grok 分组唯一上游账号返回 502 后没有第二候选,而不是本地配置或鉴权格式错误。没有为掩盖该问题继续盲目重试,也未修改 Sub2API runtime、分组或账号状态。
@@ -0,0 +1,36 @@
# R2.7.3 Grok 账号测试与网关路径复核报告
## 新证据
用户在 Sub2API 管理端对 `https://sub.yjxm1221.top grok` 执行账号连接测试成功:账号类型为 API Key,模型为 `grok-4.5`,上游返回正常文本。这证明账号凭据、base URL 和最小 xAI Responses 请求可用。
## 网关复测
使用绑定 Grok 分组的 Sub2API Key,经公开 `/v1/responses` 复测:
- 结构化 Codex 风格请求返回 502,请求 ID `86069838-2559-45a7-a683-8b029f03b447`
- 账号连接测试同形态的 `input:"hi" + stream:true` 请求,在调度恢复后仍返回 502,请求 ID `dfd99f91-52e4-4de9-bea9-d64a3e8e623b`
- 502 后 `v0.1.155` 会把 Grok 账号临时不可调度 2 分钟;期间请求返回 503 `no available accounts`。这解释了中间的 503,但不是首个 502 的根因。
- 原生窗口显示账号 36 可恢复为 `AVAILABLE=true`,因此不是永久禁用或认证错误。
## `v0.1.155` 源码路径差异
管理端 `testGrokAccountConnection`
- 直接使用账号的 API Key 和 base URL。
- 请求体固定为 `model + input:"hi" + stream:true`
- 不经过分组调度。
- 不注入 Grok prompt-cache identity。
公开 Grok gateway 的 `forwardGrokResponses`
- 先经过分组调度和模型映射。
- 调用 `resolveGrokCacheIdentity`,按 Sub2API API Key、模型和请求内容生成租户隔离 identity。
- 即使是 Grok API Key 账号,也会向 Responses body 写入 `prompt_cache_key`,并写入 `X-Grok-Conv-Id` header;只有 Free OAuth 专属工具注入受 `IsGrokOAuth()` 限制。
- 第三方 base URL 因而收到的载荷不等同于管理端连接测试。
## 结论
“账号连接测试成功”与“Codex 经 Sub2API Grok 分组成功”并不矛盾。前者证明最小直连可用;后者当前稳定在上游账号 36 返回 502 后失败。根据 `v0.1.155` 源码,最值得优先验证的差异是公开网关为第三方 Grok API Key 上游增加的 `prompt_cache_key` / `X-Grok-Conv-Id` 及其他 Responses 净化,而不是本地 `config.toml.grok``auth.json.grok` 或账号凭据。
本任务保持只读,没有修改账号、runtime、分组或 Sub2API 源码。当前 Codex profile 配置仍正确,但该第三方上游尚未通过真实 Codex 网关载荷验收。
@@ -0,0 +1,3 @@
# R2.7 Grok 原生接入与 Codex 兼容任务报告
本分支汇总官方 Grok provider 源码调查、`~/.codex` Grok profile 配置,以及管理端账号直连测试与公开 Responses 网关差异复核。三项任务均已形成独立报告;当前结论是本地 profile 和分组 Key 正确,第三方 Grok API Key 上游仍需验证对网关缓存 identity 与真实 Codex 载荷的兼容性。
@@ -0,0 +1,26 @@
# R2.8 MDTODO 层级治理任务报告
## Skill 规则
已在通用 `mdtodo-edit` skill 中加入层级约束:同一个 SUBITEM 下的直接 SUBSUBITEM 一般不超过 20;接近上限时必须按稳定职责、阶段或交付面拆成兄弟 SUBITEM,禁止机械按每 20 条分桶;已超限时先重组层级和编号,并保留状态、语义与报告关联。
## 文件重组
将原 `R2.2.1-R2.2.38` 按职责重组:
- `R2.2`:通用故障归因、failover、runtime CRUD 与临时不可调度,15 项。
- `R2.3`system-log 索引能力,保持原编号。
- `R2.4`:客户反馈、专项事件与原生诊断,9 项。
- `R2.5`:版本、账号质量评分、用量归因和调度优先级,8 项。
- `R2.6`:成本与利润统计,4 项。
- `R2.7`Grok 原生接入与 Codex 兼容,3 项。
已迁移并重新编号历史报告,保留完成/进行中状态;原进行中的账号质量聚合和 runtime priority CLI 分别迁为 `R2.5.3``R2.5.6`。已消除并行 stash 遗留的冲突标记和重复 `R2.2.37`,为官方 Grok 调查、Codex profile 配置和网关复核分配独立编号与报告。
## 验证
- `mdtodo-edit` skill 通过 `quick_validate.py`
- MDTODO 无重复 ID、无 Git 冲突标记。
- 直接 SUBSUBITEM 数量为 `R2.2=15``R2.4=9``R2.5=8``R2.6=4``R2.7=3`
- 没有职责分支超过 20。
- 已完成任务的报告链接均存在;仍进行中的父任务允许尚无总结报告。
@@ -0,0 +1,22 @@
# R2.9 任务报告
## 范围
通过 PK01 Sub2API 受控 CLI 调整手工 runtime 账号 ID `33` 的人类可读成本标注与账号全局优先级;未修改 Sub2API 源码、版本、YAML 管理范围或外部哨兵。
## 近期证据
近 24 小时原生账号聚合:账号原名称 `https://api.iceiu.com plus 0.03`,尝试 `1039`、成功 `1030`、失败 `9`,可归因上游客户错误 `6`,失败率 `0.87%`;评分 `90.3/A`、置信度 highTTFT P95 `58247ms`、样本 `915`;请求 `1030`、Token `3.512M`、标准 API 计费基数 `103.3889 USD`。账号当时 active、schedulable,容量 `20`,优先级 `5`
## 决策与执行
新采购成本为每 1 USD 标准 API 计费对应 `0.011 CNY`。考虑其 A 级可靠性、成本显著低于 0.03 档但 TTFT 慢于最优账号,将优先级从 `5` 适度提高到 `2`,保留在免费账号优先级 `1` 之后。
- account-name dry-run:精确命中 ID `33`,仅名称从 `https://api.iceiu.com plus 0.03` 变为 `https://api.iceiu.com plus 0.011`
- priority dry-run:精确命中 ID `33`,仅优先级从 `5` 变为 `2`
- 两项 confirm 均 `writeSucceeded=1``writeFailed=0``reconciled=1``mismatched=0`
- 最终只读快照:名称 `https://api.iceiu.com plus 0.011`,优先级 `2`active、schedulable=trueproxy `3`,容量 `20`,原临时不可调度模板保持不变。
## 结论
成本标注与优先级已按近期质量和成本完成精准 runtime 调优,最终状态与期望一致。
@@ -0,0 +1,36 @@
# R3.1 任务报告
## 结果
- PK01 Sub2API 原生最近 24 小时 usage 选中 17 名活跃非管理员用户。
- 每人计划增加 `10 USD`,计划总额 `170 USD`
- 模式为 `dry-run``mutation=false`
- `writeAttempted=0``writeSucceeded=0``writeFailed=0``reconciled=0`,没有实际充值。
## 用户名单
| 邮箱 | 用户 ID | 请求数 | 当前余额 USD | 计划余额 USD |
|---|---:|---:|---:|---:|
| Bernard@test.com | 23 | 2 | 99.96938600 | 109.96938600 |
| MacRsh@test.com | 11 | 341 | 42.92200430 | 52.92200430 |
| darrendreamc@163.com | 13 | 182 | 30.52278440 | 40.52278440 |
| huiguo@test.com | 15 | 472 | 56.49675000 | 66.49675000 |
| hyglql@test.com | 10 | 935 | 546.01330750 | 556.01330750 |
| laogen@test.com | 7 | 1678 | 370.04147180 | 380.04147180 |
| mail0795336304@163.com | 22 | 227 | 662.40832140 | 672.40832140 |
| miuser@test.com | 21 | 54 | 688.02232555 | 698.02232555 |
| name@test.com | 9 | 274 | 421.88935290 | 431.88935290 |
| phuohuo163@outlook.com | 20 | 248 | 565.16767640 | 575.16767640 |
| ren@test.com | 3 | 155 | 201.19074850 | 211.19074850 |
| ric@test.com | 4 | 23 | 42.35029270 | 52.35029270 |
| skylin008@gmail.com | 17 | 68 | 245.71857260 | 255.71857260 |
| wenrui@test.com | 5 | 68 | 30.73914185 | 40.73914185 |
| xiaoyang@test.com | 2 | 2012 | 5413.81344685 | 5423.81344685 |
| yinl0801@qq.com | 19 | 483 | 851.18146340 | 861.18146340 |
| zhuo@test.com | 16 | 89 | 149.21926750 | 159.21926750 |
## 精确确认名单
用户 ID`23,11,13,15,10,7,22,21,9,20,3,4,17,5,2,19,16`
该名单仅用于后续明确授权时固定选择范围。本任务未使用 `--confirm`,不得把本报告解释为实际充值授权或完成记录。
@@ -0,0 +1,44 @@
# R3.2 任务报告
## 结果
- 已通过 [Issue #2097](https://github.com/pikasTech/unidesk/issues/2097) 和 [PR #2102](https://github.com/pikasTech/unidesk/pull/2102) 增加 Sub2API 原生公告受控 CLI。
- PR 已合并到 `master`merge commit 为 `43f34ccfe82c3be55b731d0e5c7e416de1bcccb5`
- CLI 支持公告 `list``get``create`:默认 Kubernetes 风格紧凑文本,显式 `--json` 输出机器结构。
- `create` 支持标题、Markdown 正文、状态、通知模式、原生 targeting 以及 Unix 秒或 RFC3339 时间窗。
- `create` 默认 dry-run;只有显式 `--confirm` 才调用原生创建 API。
- 确认创建后的回读对账覆盖 ID、`title``content``status``notify_mode``targeting``starts_at``ends_at`;任一差异均返回失败并披露 `mismatchedFields`
## 原生能力依据
- Sub2API 官方仓库 `Wei-Shaw/sub2api``v0.1.155` 原生提供 `/api/v1/admin/announcements`
- 原生后端支持分页列表、按 ID 查看、创建、更新、删除和阅读状态;本次按授权范围接入列表、查看和受控创建。
- 未修改 Sub2API 源码、版本、外部哨兵或运行面配置。
## 补偿公告预览
- 标题:`服务稳定性补偿说明`
- 内容语义:计划向最近 24 小时有实际使用记录的 17 名活跃用户每人增加 10 USD,总计 170 USD,确认后发放。
- 文案使用“计划”和“确认后发放”,没有表述为已经到账。
- dry-run 返回 `mutation=false``writeAttempted=0`,完整预览正确。
- PK01 原生公告列表只读验证返回 `mode=read-only``mutation=false``total=0``returned=0`
## 验证
- scoped CLI help 通过。
- 显式 JSON dry-run 输出合同通过。
- 字段级对账纯内存 fixture 通过:全匹配无差异,多字段差异和 ID 差异均准确披露;`network=false`
- `git diff --check` 通过。
- 子代理交付 commit`2ab5fb87a2693ad6076e3abdeb3801c74269be69`
- 主代理纠偏 commit`2c0cf9479197a37728a3c697da230fb9e7ce28de`
## 写入边界
- 本轮没有使用 `--confirm`
- 公告发布数为 0。
- 充值写入数为 0。
- 实际公告发布和每人 10 USD 充值仍需用户对具体公告参数及固定用户名单再次明确授权。
## 后续改进
- post-task 已登记 [Issue #2106](https://github.com/pikasTech/unidesk/issues/2106),用于改进 `platform-infra` 深层 scoped help 的渐进披露,减少后续无效调用;不作为本任务合并门禁。
@@ -0,0 +1,37 @@
# R3.3 任务报告
## 结果
通过 Sub2API 受控 CLI 精确查询了北京时间 `2026-07-14 17:00:00``18:00:00` 的活跃非管理员用户。该窗口按 `Asia/Shanghai` 转换为 UTC `2026-07-14T09:00:00Z``2026-07-14T10:00:00Z`,使用半开区间 `[start,end)`
共选中 7 名用户:
| 邮箱 | 用户 ID | 请求数 |
|---|---:|---:|
| MacRsh@test.com | 11 | 1 |
| huiguo@test.com | 15 | 31 |
| hyglql@test.com | 10 | 126 |
| laogen@test.com | 7 | 158 |
| mail0795336304@163.com | 22 | 26 |
| yinl0801@qq.com | 19 | 3 |
| zhuo@test.com | 16 | 35 |
## CLI 改进
- owning YAML `config/platform-infra/sub2api-codex-pool.yaml#credits.timezone` 新增默认时区 `Asia/Shanghai`
- `credits grant` 新增通用 `--active-start/--active-end` 精确时间窗。
- 未带偏移的 ISO 时间由 CLI 按 YAML IANA 时区换算为 UTC;本地与 UTC 边界同时披露。
- 远端继续使用 Sub2API 原生 admin usage 和用户 API,并按 UTC 半开区间逐条过滤。
- PK01 旧 Python 缺少 `zoneinfo`,因此时区换算在 Bun/Intl 控制面完成,远端只接收已验证 UTC 边界。
实现通过 [PR #2117](https://github.com/pikasTech/unidesk/pull/2117) 合并,merge commit 为 `7b43da1ab842183d36476e174e17fb7f45891b57`
## 验证
- `bun --check scripts/src/platform-infra-sub2api-codex/credits.ts`:通过。
- `bun --check scripts/src/platform-infra-sub2api-codex/config.ts`:通过。
- `git diff --check`:通过。
- PK01 原入口 dry-run`ok=true``selection=active-window``selected=7`
- 写入证据:`mutation=false``writeAttempted=0``writeSucceeded=0`
没有执行充值,没有修改 Sub2API 源码、版本、哨兵或运行面配置。
@@ -0,0 +1,30 @@
# R3.4 任务报告
## 结果
`config/platform-infra/sub2api-codex-pool.yaml#credits.excludedUsers` 中加入:
- `zhuo@test.com`
- `huiguo@test.com`
排除列表是通用精确 selector 配置,支持用户 ID 或邮箱,邮箱按大小写不敏感匹配。活跃时间窗与显式 `--users` 模式均在生成补偿计划和确认 selector 前应用该列表。
## CLI 可见性
默认 Kubernetes 风格输出新增 `EXCLUDED` 表格,披露邮箱、用户 ID、窗口请求数、`yaml-excluded-user` 原因和匹配 selector。汇总首行同时披露 `selected``excluded`。全部候选被排除时显示 `--users <none>`,不再给出可执行的空确认提示。
## 验证
- Bun 语法检查和 `git diff --check` 通过。
- 北京时间 `2026-07-14 17:00:00``18:00:00` 固定窗口 dry-run
- `selected=5`
- `huiguo@test.com` 请求数 31,按 YAML 排除;
- `zhuo@test.com` 请求数 35,按 YAML 排除;
- `mutation=false``writeAttempted=0`
- 显式 `--users 15,16` dry-run
- `selected=0``excluded=2``total-usd=0`
- `mutation=false``writeAttempted=0`
实现通过 [PR #2119](https://github.com/pikasTech/unidesk/pull/2119) 合并,merge commit 为 `7920322030270a49164d78971dae2f0a6454997c`
没有执行充值,没有修改 Sub2API 源码、版本、哨兵或运行面。
@@ -0,0 +1,30 @@
# R3.5 任务报告
## 查询窗口
- 本地时间:`2026-07-14 17:00:00``18:00:00 Asia/Shanghai`
- UTC`2026-07-14T09:00:00Z``10:00:00Z`
- 区间:半开区间 `[start,end)`
- 数据源:Sub2API 原生 `/api/v1/admin/usage``input_tokens``output_tokens`
- 所有 1,267 条 usage 的 Token 字段覆盖均为 `complete`
## 用户用量
| 用户 | ID | 分类 | 请求数 | 输入 Token | 输出 Token | 总 Token |
|---|---:|---|---:|---:|---:|---:|
| MacRsh@test.com | 11 | 补偿候选 | 1 | 506 | 12,309 | 12,815 |
| hyglql@test.com | 10 | 补偿候选 | 126 | 593,470 | 187,782 | 781,252 |
| laogen@test.com | 7 | 补偿候选 | 158 | 1,608,741 | 180,207 | 1,788,948 |
| mail0795336304@163.com | 22 | 补偿候选 | 26 | 29,735 | 21,641 | 51,376 |
| yinl0801@qq.com | 19 | 补偿候选 | 3 | 52,270 | 3,396 | 55,666 |
| huiguo@test.com | 15 | YAML 排除员工 | 31 | 61,069 | 30,623 | 91,692 |
| zhuo@test.com | 16 | YAML 排除员工 | 35 | 701,758 | 26,110 | 727,868 |
| admin@sub2api.platform-infra.local | 1 | 管理员排除 | 887 | 2,327,308 | 706,151 | 3,033,459 |
## CLI 改进
credits 固定窗口现在按用户聚合请求数、输入 Token、输出 Token、总 Token,以及 Token 字段覆盖行和缺失行。缺失字段会标记 `partial`,精确用户模式没有 usage 窗口时标记 `unavailable`。原有角色、状态、余额和对账列保持不变。
实现通过 [PR #2122](https://github.com/pikasTech/unidesk/pull/2122) 合并,merge commit 为 `2add8477e4ea95070e896a66b29769ad1597f9bf`
查询为 dry-run`mutation=false``writeAttempted=0`,没有执行充值。
@@ -0,0 +1,46 @@
# R3.6 任务报告
## 执行范围
按用户明确授权,仅对固定用户 ID `11,10,7,22,19` 每人增加 `30 USD`,总额 `150 USD`;并发发布服务稳定性补偿公告。未使用移动活跃窗口,未包含 YAML 排除员工、管理员或其他用户。
## 充值结果
受控入口:`platform-infra sub2api codex-pool credits grant`,目标 `PK01`,显式 `--confirm`
- selected: 5
- writeAttempted: 5
- writeSucceeded: 5
- writeFailed: 0
- reconciled: 5
- mutation: true
| 用户 | ID | 充值前 | 增加 | 充值后 | 对账 |
|---|---:|---:|---:|---:|---|
| MacRsh@test.com | 11 | 42.92200430 USD | 30 USD | 72.92200430 USD | true |
| hyglql@test.com | 10 | 542.68010850 USD | 30 USD | 572.68010850 USD | true |
| laogen@test.com | 7 | 349.15434580 USD | 30 USD | 379.15434580 USD | true |
| mail0795336304@163.com | 22 | 662.40832140 USD | 30 USD | 692.40832140 USD | true |
| yinl0801@qq.com | 19 | 841.79106140 USD | 30 USD | 871.79106140 USD | true |
充值原因为 `2026-07-14 service stability compensation: 30 USD for five authorized active users`,批次使用受控 CLI 幂等键并逐用户回读余额。
## 公告结果
受控入口:`platform-infra sub2api codex-pool announcements create`,目标 `PK01`,显式 `--confirm`
- announcement ID: 1
- status: active
- notify mode: popup
- targeting: 全体用户(空条件)
- starts/ends: 无限制
- writeAttempted: 1
- mutation: true
- reconciled: true
- mismatchedFields: 空
标题为“服务稳定性补偿说明”。正文说明符合本次补偿条件的用户已到账 `30 USD`
## 结论
充值和公告两条并发操作均成功到达终态并通过 Sub2API 原生回读对账,无失败用户、无公告字段漂移、无范围扩大。
@@ -0,0 +1,7 @@
# R3 任务报告
- 新增受控 `credits grant`:支持 `--active-since` 选取原生 usage 中的活跃非管理员用户,也支持精确用户 ID/邮箱 selector;默认 dry-run。
- 活跃窗口只允许生成计划;确认必须固定使用 dry-run 返回的精确用户 ID 列表,防止移动窗口改变名单。
- 每个用户的余额 add 写入使用由精确名单、金额和原因生成的确定性 `Idempotency-Key`,随后逐用户回读余额。
- 24 小时 dry-run 选中 18 个用户,每人拟增 20 USD,总额 360 USD`writeAttempted=0``mutation=false`,未实际充值。确认 selector 为 `18,23,11,13,15,10,7,22,21,9,20,3,4,17,5,2,19,16`
- 单用户精确 selector dry-run 验证通过,移动活跃窗口带 `--confirm` 会在本地拒绝。实际充值必须等待用户对具体名单、金额和原因再次明确授权。
+16
View File
@@ -0,0 +1,16 @@
# 个人求职信息管理
- 本文件承载公开岗位调查、岗位证据核验、投递节奏和求职资料维护。
- 个人敏感材料不进入 GitHub issue、AgentRun prompt 或公开调查报告。
## R1 [completed]
并行调查上海大公司高匹配公开岗位并形成可投递清单,关联 [GitHub issue #2141](https://github.com/pikasTech/unidesk/issues/2141),完成任务后将详细报告写入[任务报告](./details/personal-job-search/R1_Task_Report.md)。
### R1.1 [completed]
使用 `gpt-5.6-luna` 低思考等级核验上海工业自动化、能源、电气与大型外企岗位,关联 [GitHub issue #2143](https://github.com/pikasTech/unidesk/issues/2143),完成任务后将详细报告写入[任务报告](./details/personal-job-search/R1.1_Task_Report.md)。
### R1.2 [completed]
使用 `gpt-5.6-luna` 低思考等级核验上海 AI、机器人、汽车智能化与系统软件岗位,关联 [GitHub issue #2142](https://github.com/pikasTech/unidesk/issues/2142),完成任务后将详细报告写入[任务报告](./details/personal-job-search/R1.2_Task_Report.md)。
@@ -132,6 +132,9 @@
##### R1.5.9.13 [in_progress]
接入仅跟随产品 master 的 pikaoa-test-nc01 独立测试 CI/CD,通过正常 source PR merge 自动交付 NC01 pikaoa-test,保持生产 consumer 不触发(pikasTech/unidesk#2105),完成任务后将详细报告写入[任务报告](./details/pikaoa-enterprise-platform/R1.5.9.13_Task_Report.md)。
###### R1.5.9.13.1 [in_progress]
修复 PikaOA 首次 PaC bootstrap 未同步 admission provenance desired policy/binding 的缺口,使配置指纹漂移降级为非阻塞 warning 且正常产品 PR merge 产生的 PipelineRun 能继续执行,执行记录见 [pikasTech/unidesk#2127](https://github.com/pikasTech/unidesk/issues/2127),完成任务后将详细报告写入[任务报告](./details/pikaoa-enterprise-platform/R1.5.9.13.1_Task_Report.md)。
### R1.6
审核并合并双仓 PR,执行首次受控 PaC bootstrap,由正常 source PR merge 自动发布,依赖 R1.3-R1.5,完成任务后将详细报告写入[任务报告](./details/pikaoa-enterprise-platform/R1.6_Task_Report.md)。
@@ -142,6 +145,12 @@
##### R1.6.1.1 [completed]
将 PK01 PostgreSQL 逻辑备份正规化为 YAML-first 多数据库 logicalDumps,保留 Sub2API 并新增 PikaOA 独立 dump、timer、retention 与受控状态/可恢复性摘要(pikasTech/unidesk#2115),完成任务后将详细报告写入[任务报告](./details/pikaoa-enterprise-platform/R1.6.1.1_Task_Report.md)。
##### R1.6.1.2
为 NC01 pikaoa namespace 的生产附件 PVC 建立 YAML-first Restic 离机备份、受控状态与 restore smoke,复用 PK01 /var/backups/unidesk 且失败只告警不阻塞业务,执行记录见 [pikasTech/unidesk#2128](https://github.com/pikasTech/unidesk/issues/2128),完成任务后将详细报告写入[任务报告](./details/pikaoa-enterprise-platform/R1.6.1.2_Task_Report.md)。
##### R1.6.1.3 [completed]
建立仅跟随产品 release 的 PikaOA 生产 PaC/Tekton/GitOps/Argo lane,以 fresh initializer 在 NC01 pikaoa namespace 启动 API/Worker/Web/附件 PVC,接入 PK01 host PostgreSQL、OTel/Prometheus 和 oa.pikapython.com TLS 公网入口,执行记录见 [pikasTech/unidesk#2129](https://github.com/pikasTech/unidesk/issues/2129),完成任务后将详细报告写入[任务报告](./details/pikaoa-enterprise-platform/R1.6.1.3_Task_Report.md)。
### R1.7
通过 CLI、OTel、Prometheus 和 https://oa.pikapython.com 桌面/移动原入口验证完整主路径,依赖 R1.6,完成任务后将详细报告写入[任务报告](./details/pikaoa-enterprise-platform/R1.7_Task_Report.md)。
@@ -54,7 +54,8 @@
#### R4.1.1 [in_progress]
解决 [UniDesk #2039](https://github.com/pikasTech/unidesk/issues/2039)分层确认 AgentRun #358 合并后无 PipelineRun 是 webhook/mirror 缺口、只读 status 假阻塞还是 admission 实际拒绝;保留 #1769 对伪造 marker、错误 creator 和未授权 ServiceAccount 的真实安全拒绝,将 live spec/config SHA、API defaulting、版本及等价一致性漂移降级为结构化非阻塞 warning,禁止人工 mirror、PipelineRun、trigger、sync、flush 或 apply,并用修复 PR 的新真实 merge 事件验收自动交付,完成任务后将详细报告写入任务报告,完成任务后将详细报告写入[任务报告](./details/pr-merge-driven-automatic-delivery/R4.1.1_Task_Report.md)。
解决 [UniDesk #2039](https://github.com/pikasTech/unidesk/issues/2039)现场确认 PR #1808/#1812 引入的 `ValidatingAdmissionPolicy` 以错误的原子 queue transition 假设拒绝官方 PaC watcher,导致 HWLAB `df925768` 与 AgentRun 自动流水线停在 Pending;以新提交语义回退业务阻断型 admission 围栏,保留 provenance、creator、marker、ServiceAccount 和漂移为结构化 `blocking=false` warning,禁止继续扩展 CEL 围栏、人工 PipelineRun、mirror、trigger、sync、flush 或 runtime patch,并由既有 merge 事件自动恢复及完成原入口验收,完成任务后将详细报告写入[任务报告](./details/pr-merge-driven-automatic-delivery/R4.1.1_Task_Report.md)。
### R4.2
依赖 R4.1,让 YAML-owned pipeline 输出标准 terminal evidence,由单一 controller 自动 reconcile GitOpsArgo/status 必须针对同一 GitOps repository 和 commit graph 验证 exact/descendant,并把 source、artifact、GitOps、revision、runtime digest 形成可审计链,完成任务后将详细报告写入[任务报告](./details/pr-merge-driven-automatic-delivery/R4.2_Task_Report.md)。
@@ -27,3 +27,98 @@
### R3.1 [completed]
按用户最新要求将非选中 consumer 的全局配置一致性错误降级为结构化 non-blocking warning,避免开发 source-artifact/状态/交付被生产配置阻塞;当前选中 target/consumer 的字段、权限、ownership 与安全校验仍 fail-closed,并由定向测试证明两类边界,完成任务后将详细报告写入[任务报告](./details/selfmedia-production-delivery/R3.1_Task_Report.md)。
### R3.2 [completed]
依据 [UniDesk #2052](https://github.com/pikasTech/unidesk/issues/2052) 修复 PaC 在 expectedRevision 与 observedRevision 完全相同时仍因 owning Git fetch 失败误判 `relation=unknown`:相同 revision 直接判定 exact,额外 fetch 失败仅输出 `blocking=false` warning,保持真实不一致和 mutation target 安全边界;用独立 worktree/PR 和定向 evaluator/source-artifact/CLI 验证收口,完成任务后将详细报告写入[任务报告](./details/selfmedia-production-delivery/R3.2_Task_Report.md)。
### R3.3 [completed]
依据 [SELFMEDIA #36](https://github.com/pikainc/selfmedia/issues/36) 修复生产期次 prod-webterm-20260714174507 在 voice 阶段因 utterance-story-04-07 含 Kokoro/Misaki 无法发音字符而失败:读取真实文本与 phoneme 定位字符,在既有 TTS 归一化职责内做最小修复并增加定向测试;先用 step run voice 单步验证,release PR 正常自动交付后从 voice 续跑至 inspect,不重跑已成功阶段,再将同一修复回补 master 并完成公网产物验收,完成任务后将详细报告写入[任务报告](./details/selfmedia-production-delivery/R3.3_Task_Report.md)。
## R4 [in_progress]
依据用户最新要求为 SELFMEDIA 自动交付增加 120 秒端到端预算可见性并继续优化 env reuse:超过 owning YAML 阈值只输出 blocking=false、mutation=false 的结构化 warning 与 env reuse hint,不能阻断 PipelineRun、GitOps/Argo、runtime 或 health;针对当前 ENV_REUSE=hit 但 imageBuild 仍为 181-184 秒、端到端为 203-210 秒的事实,定位真实耗时并通过正常 master/release PR 自动交付将流水线优先压到 120 秒预算内,完成任务后将详细报告写入[任务报告](./details/selfmedia-production-delivery/R4_Task_Report.md)。
### R4.1 [completed]
依据 [UniDesk #2064](https://github.com/pikasTech/unidesk/issues/2064) 在 owning YAML 声明 120 秒自动端到端预算;交付超过阈值时在 delivery-timing 与适用状态投影中输出 blocking=false、mutation=false 的 typed warning 和 env reuse 优化 hint,120 秒内不报警、时间证据不完整保持 partial,任何 warning 不得阻断业务滚动,完成任务后将详细报告写入[任务报告](./details/selfmedia-production-delivery/R4.1_Task_Report.md)。
### R4.2 [completed]
依据 [UniDesk #2065](https://github.com/pikasTech/unidesk/issues/2065) 对 SELFMEDIA 已 ENV_REUSE=hit 但 imageBuild 181-184 秒的问题做目标侧阶段定位,优化依赖、模型/工具层和 BuildKit/cache 复用且保持身份变化正确失效;通过正常 master/release PR merge 验收端到端预算、digest、Argo/runtime health 与 exact verifier,完成任务后将详细报告写入[任务报告](./details/selfmedia-production-delivery/R4.2_Task_Report.md)。
## R5 [completed]
依据用户最新要求改进 SELFMEDIA 开发集群 Web 工厂:所有用户可见页面全量中文化;每一期和资源提供可刷新恢复的 RESTful 深链,切期时 URL、数据和加载状态严格同步并防止乱序响应覆盖;尽可能提供期次、文稿、来源、时间轴、文章、场景、图片、TTS、视频参数和单步重跑的手动编辑能力,与 WebTerm/CLI 共享同一 edition/resource 真相。全部只合并 master 并在测试集群验收,禁止发布 release、生产 namespace 或公网 4319,完成任务后将详细报告写入[任务报告](./details/selfmedia-production-delivery/R5_Task_Report.md)。
### R5.1 [completed]
依据 [SELFMEDIA #41](https://github.com/pikainc/selfmedia/issues/41) 将所有用户可见页面、按钮、状态、空态、错误、确认框、终端工具栏和辅助文本统一为中文;技术字段、命令和品牌名保留时补中文语义,建立可审计文案结构和静态/浏览器验证,保持紧凑工业风,只上线 master 测试集群,完成任务后将详细报告写入[任务报告](./details/selfmedia-production-delivery/R5.1_Task_Report.md)。
### R5.2 [completed]
依据 [SELFMEDIA #40](https://github.com/pikainc/selfmedia/issues/40) 为每一期和资源建立可复制、刷新恢复、前进后退一致的 RESTful 深链;切期/切资源时显示目标期次中文加载态,使用请求 identity/abort 防止乱序覆盖,无效深链显示中文 not-found,并在 master 测试集群完成快速切期和慢请求验证,完成任务后将详细报告写入[任务报告](./details/selfmedia-production-delivery/R5.2_Task_Report.md)。
### R5.3 [completed]
依据 [SELFMEDIA #39](https://github.com/pikainc/selfmedia/issues/39) 增强 Web 手动编辑工作台,首批覆盖期次元数据、选题、文稿、来源、时间轴、微信公众号文章、场景文本/图片/缩放、TTS 与视频参数;保存和冲突状态中文可见,复用同一 API/CLI source of truth,卡片独立运行按钮与确认框不变,只上线 master 测试集群,完成任务后将详细报告写入[任务报告](./details/selfmedia-production-delivery/R5.3_Task_Report.md)。
#### R5.3.1 [completed]
依据 [SELFMEDIA #45](https://github.com/pikainc/selfmedia/issues/45) 建立期次资源编辑 REST API 与同路径 CLI:从同一期既有文件读取并通过 revision/If-Match、结构校验和原子写入保存,首批覆盖元数据、来源、文稿、微信 Markdown 与分镜;WebTerm CLI 复用同一 API,禁止任意路径写入、跨期次覆盖、第二状态库和 release/生产发布,完成任务后将详细报告写入[任务报告](./details/selfmedia-production-delivery/R5.3.1_Task_Report.md)。
#### R5.3.2 [completed]
依据 [SELFMEDIA #47](https://github.com/pikainc/selfmedia/issues/47) 在 RESTful 期次/资源深链中加入紧凑工业风手动编辑工作台:消费 #45 的 revision/ETag API,覆盖元数据、来源、文稿、微信 Markdown、场景/分镜以及只读资源说明,中文显示 dirty/saving/saved/conflict/error,切期取消旧草稿并禁止跨期保存;保留卡片独立运行按钮与确认框,只上线 master 测试集群,完成任务后将详细报告写入[任务报告](./details/selfmedia-production-delivery/R5.3.2_Task_Report.md)。
#### R5.3.3 [completed]
依据 [SELFMEDIA #49](https://github.com/pikainc/selfmedia/issues/49) 在现有 edition.yaml 权威资源中加入受结构校验的期次级配音、字幕和视频参数覆盖,由 REST API、CLI、Web 与 voice/subtitles/render 单步共享同一真相;缺省继承 config/tools.yaml,只允许 master 开发集群与公网 4317 验收,禁止 release、生产 namespace 和 4319,完成任务后将详细报告写入[任务报告](./details/selfmedia-production-delivery/R5.3.3_Task_Report.md)。
## R6 [completed]
依据 [SELFMEDIA #52](https://github.com/pikainc/selfmedia/issues/52) 重构 Web 导航加载与全局刷新:同一期切换资源仅加载目标资源,不让当前期次和生产信号链进入重新加载;切期继续显示大范围目标期加载并防乱序;增加 YAML-first 的全局手动刷新和默认 5 秒可选自动刷新,保留旧内容、避免重叠请求并保护 dirty/saving/conflict 草稿。先合并 master 并在 4317 验收,再通过 master 到 release 的正常 PR 自动滚动生产 4319,禁止手工 PipelineRun、Argo sync 或运行面 patch,完成任务后将详细报告写入[任务报告](./details/selfmedia-production-delivery/R6_Task_Report.md)。
### R6.1 [completed]
修复 SELFMEDIA #56:生产首次缓存未命中时 BuildKit 已推送镜像但收尾 context deadline exceeded;实现仅对该特定错误的一次有界重试,覆盖脚本测试,先走 master/4317 自动 PaC 验收,再走 release/4319,禁止手工补跑,完成任务后将详细报告写入[任务报告](./details/selfmedia-production-delivery/R6.1_Task_Report.md)。
## R7 [completed]
依据 [SelfMedia #59](https://github.com/pikainc/selfmedia/issues/59) 修复全局手动/周期增量刷新清空内嵌 WebTerm:终端配置、xterm 与 WebSocket 生命周期独立于业务投影刷新,只有 WebTerm 自身“刷新终端”按钮按 ../webterm 的临时行数 resize→真实行数 resize→本地 refresh 语义无损重绘;先在开发入口 4317 验证终端连接/历史不变,再通过 release PR 自动发布并在生产入口 4319 复测,完成任务后将详细报告写入[任务报告](./details/selfmedia-production-delivery/R7_Task_Report.md)。
## R8 [completed]
依据 [SELFMEDIA #62](https://github.com/pikainc/selfmedia/issues/62) 增加仓库自带的单命令 Web 验证入口:自动按锁文件准备根目录与 web 依赖,依次运行 Web 测试、生产构建和 git diff --check,输出紧凑阶段摘要、耗时、依赖复用状态与失败原因;在全新 worktree 首次调用和同 worktree 第二次调用中证明原有多步探测、安装和重复验证收敛为一次调用,不修改运行配置、不部署开发或生产环境,完成任务后将详细报告写入[任务报告](./details/selfmedia-production-delivery/R8_Task_Report.md)。
### R8.1 [completed]
依据 [UniDesk #2113](https://github.com/pikasTech/unidesk/issues/2113) 在 unidesk-selfmedia skill 固化 SelfMedia Web 源码验证最短路径:通过 trans 在 NC01 目标 worktree 单次运行 bun run verify:web,替代依赖探测、安装、Web 测试、生产构建和差异格式检查的手工多步调用;明确该入口不替代浏览器、公网、鉴权、WebTerm 与 PaC/Argo 运行面验收,通过 skill quick_validate 并证明同类源码验证只需一次受控调用,完成任务后将详细报告写入[任务报告](./details/selfmedia-production-delivery/R8.1_Task_Report.md)。
## R9 [in_progress]
依据 [UniDesk #2132](https://github.com/pikasTech/unidesk/issues/2132) 在 D518 部署先进中文语音推理服务并接入 SELFMEDIA 开发集群:先在 D518 临时目录以 Docker GPU smoke 验证 Qwen3-TTS 0.6B CustomVoice,成功后由 owning YAML 和受控 CLI 固化 D518 推理容器、NC01 FRPS、D518 FRPC、Secret sourceRef 与公网直连端口,再扩展 SelfMedia 远程 TTS 引擎并通过正常 master 自动交付在 4317 完成 voice 单步 smoke;禁止修改 release、生产 namespace/4319、手工长期运维或引入 Caddy,完成任务后将详细报告写入[任务报告](./details/selfmedia-production-delivery/R9_Task_Report.md)。
### R9.1 [completed]
依据 [UniDesk #2133](https://github.com/pikasTech/unidesk/issues/2133) 由 Artificer 经 trans 在 D518 /tmp 完成 Qwen3-TTS 0.6B CustomVoice Docker GPU smoke:锁定官方上游 ref、镜像/构建、低显存参数和 health/speech API,以固定中文技术资讯文本验证首次与热调用、WAV 解码、实时率和峰值显存;成功后清理临时容器并留下可接力证据,失败则在一次官方低显存参数尝试后停止且不无界更换模型,完成任务后将详细报告写入[任务报告](./details/selfmedia-production-delivery/R9.1_Task_Report.md)。
#### R9.1.1 [in_progress]
依据 [UniDesk #2148](https://github.com/pikasTech/unidesk/issues/2148) 在 Qwen3-TTS 因 Torch/TorchAudio ABI 不兼容停止后,由 Artificer 经 trans 在 D518 /tmp 验证下一候选 CosyVoice3 0.5B:锁定官方 source/model ref 和 Apache-2.0 许可,使用稳定匹配的 Torch/TorchAudio Docker GPU 组合与本地自有或开源生成的中文参考 WAV,提供 health/speech API并以固定技术资讯文本完成 WAV、实时率和峰值显存 smoke;成功后为 R9.4 提供正式模型身份,失败则记录首个确定阻塞并停止无界试错,完成任务后将详细报告写入[任务报告](./details/selfmedia-production-delivery/R9.1.1_Task_Report.md)。
### R9.2 [in_progress]
依据 [SELFMEDIA #65](https://github.com/pikainc/selfmedia/issues/65) 由 Artificer 为 voice 单步增加 YAML 显式选择的 remote-openai-speech 自托管引擎:基础地址只从 YAML 声明的环境变量读取,模型、音色、指令、语速和引擎进入缓存身份,cache miss 调用 /v1/audio/speech 并原子写入 WAV,保留现有分段、edition 覆盖、FFmpeg 语速/响度和 timeline,禁止硬编码公网端口或静默回退 Kokoro,完成任务后将详细报告写入[任务报告](./details/selfmedia-production-delivery/R9.2_Task_Report.md)。
### R9.3 [in_progress]
依据 [SELFMEDIA #66](https://github.com/pikainc/selfmedia/issues/66) 由 Artificer 为 SelfMediaDeployment renderer 增加通用 runtime.environment 与 networkPolicy.allowedTcpEndpoints:严格校验并把普通业务环境变量投影到 backend,按 CIDR 和 TCP ports 为被 blockedCidrs 排除的地址生成精确 egress 例外,默认空配置保持现有语义;禁止删除网络隔离、放开全端口、硬编码 D518/语音服务或修改生产配置,完成任务后将详细报告写入[任务报告](./details/selfmedia-production-delivery/R9.3_Task_Report.md)。
#### R9.3.1 [in_progress]
依据 [SELFMEDIA #69](https://github.com/pikainc/selfmedia/issues/69) 将部署校验从全仓唯一 PipelineRun 断言改为按 owning target/环境独立验证:参数化解析开发与生产 PaC 制品,保留缺失、重复、错误归属的真实失败,但不得让合法多环境配置互相阻塞;用一个多环境 smoke 证明通用合同后完成本改进,且不得触碰或阻塞 R9 语音运行面,完成任务后将详细报告写入[任务报告](./details/selfmedia-production-delivery/R9.3.1_Task_Report.md)。
### R9.4 [in_progress]
依据 [UniDesk #2139](https://github.com/pikasTech/unidesk/issues/2139) 将 D518 先进语音推理与 NC01 直连 FRP 固化为 YAML-first 受控服务:owning YAML 声明 Docker GPU 服务、模型/source ref、持久缓存、NC01 FRPS、D518 FRPC、Secret sourceRef、端口和 health/speech smokeCLI 提供 plan、secret init、apply、status、logs、validate;可在 R9.1 下载期间完成代码和渲染,但必须等 GPU HTTP/WAV smoke 成功后才允许正式 apply,且不触碰 release、生产 namespace、4319 或 Caddy,完成任务后将详细报告写入[任务报告](./details/selfmedia-production-delivery/R9.4_Task_Report.md)。
+170 -66
View File
@@ -15,9 +15,9 @@
增强 CLI 使用 Sub2API 原生 admin/ops 数据诊断请求错误、账号可用性、并发和 request trace,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.1_Task_Report.md)。
### R2.2 [in_progress]
### R2.2 [completed]
在连续新窗口复核临时不可调度、failover、客户可见错误率和流式 degraded 请求,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.2_Task_Report.md)。
集中跟踪 Sub2API 通用客户错误归因、failover、临时不可调度模板、runtime CRUD 和所有分组诊断能力,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.2_Task_Report.md)。
#### R2.2.1 [completed]
@@ -69,70 +69,174 @@
#### R2.2.16 [completed]
紧急只读追踪用户 mail0795336304@163.com 反馈请求卡住15分钟:定位用户ID、近30分钟请求、当前请求/并发、request ID、账号与模型,区分排队、上游首字、流式间隔、代理网络或客户连接,不取消请求且不修改runtime、YAML、proxy或调度,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.2.16_Task_Report.md)。
#### R2.2.17 [completed]
复盘用户直接反馈的只读追踪过程并交由 Artificer 实现 [Issue #2000](https://github.com/pikasTech/unidesk/issues/2000):增加通用的一键用户追踪 CLI,以邮箱或用户ID关联请求空窗、用户/API Key并发、client/internal request ID、上游账号名称、proxy基础设施和证据化归因,采用Kubernetes列表风格与稳定ID渐进披露,减少手工API与重复trace调用,不改运行面,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.2.17_Task_Report.md)。
#### R2.2.18 [completed]
将 PK01 的 Sub2API 通过 owning YAML 从 v0.1.153 受控升级到 v0.1.155:只修改 PK01 target镜像版本,依次执行状态核对、plan、apply dry-run、镜像预拉、受控apply、状态与公开健康验证,保持账号池runtime和Codex pool配置原样,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.2.18_Task_Report.md)。
#### R2.2.19 [completed]
交由 Artificer 实现 [Issue #2004](https://github.com/pikasTech/unidesk/issues/2004):增强 Sub2API CLI 拉取 v0.1.155 原生智能诊断与渠道监控状态,泛化所有分组/渠道概要和指定对象下钻,以Kubernetes列表风格呈现TTFT、上游与客户错误率、原生建议和证据边界,以及7/15/30天渠道运行状态、平台/模型、对话延迟、端点PING、可用率、最近记录和刷新事实,使用稳定ID渐进披露,不重算第二套诊断且不修改运行面,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.2.19_Task_Report.md)。
#### R2.2.20 [completed]
快速缓解错误 #17440:基于 request e5c08dde-9e60-4a14-9458-5574cec00b65 的真实链路,将精确短语 Input must be a list 补入通用 504 临时不可调度规则,对全部非 lyon9801 账号精准批量 dry-run、确认下发和自动回读对账,不改容量、优先级、代理或 Sub2API 源码,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.2.20_Task_Report.md)。
#### R2.2.21 [completed]
交由 Artificer 实现 [Issue #2013](https://github.com/pikasTech/unidesk/issues/2013):定义并实现 Sub2API P0/P1/P2 故障快速查询 CLI,P0 为上游故障穿透客户,P1 为首字延迟偏高且普通与 compact 分开统计并突出极端离群,P2 为上游错误率偏高;支持所有分组概要与按等级、分组、账号名称、模型、请求类型、稳定 request ID 下钻,默认 Kubernetes 列表风格和固定分页,不靠手工 limit,不修改运行面,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.2.21_Task_Report.md)。
#### R2.2.22 [completed]
主代理只读追踪客户错误 #17490request ID 4eb9a84b-7346-47a8-bb66-fb7b44317279):使用 Sub2API 原生 Ops、trace、账号完整名称、failover/retry/临时不可调度和近期窗口证据,定位账号 https://sub2.pokexiao.com plus 0.03 的同步502为何穿透客户,区分候选耗尽、context取消、不可重试阶段或模板未命中;先调查,不盲目新增generic 502规则,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.2.22_Task_Report.md)。
#### R2.2.23 [completed]
交由 Artificer 实现 [Issue #2016](https://github.com/pikasTech/unidesk/issues/2016):增强 CLI 对 Sub2API 内部账号/渠道监控的原生只读访问,展示探测 timeout、cadence、阶段耗时、账号选择、上游首字节、切号/重试和最终状态,支持所有监控对象概要与稳定 ID 下钻,默认 Kubernetes 列表风格且不靠手工 limit;不修改运行面、不发新探针,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.2.23_Task_Report.md)。
#### R2.2.24 [completed]
只读调查错误 #17511request ID `f7ff0efe-64d3-4dd7-8716-20bdfc3a2f90`)为何上游 502 后未成功切号,重建流式请求的账号选择、首字节、响应提交、failover、排除列表、context deadline 与最终客户错误链,并与内部 monitor 请求 #17490 对照,不修改运行面,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.2.24_Task_Report.md)。
#### R2.2.25 [completed]
将 PK01 Sub2API 从 v0.1.155 受控回退到 v0.1.147:只修改 owning YAML 版本事实,在最新 master 的独立干净 worktree提交并通过受控 GitHub PR 合并,随后使用原 platform-infra Sub2API 交付入口完成 PK01 rollout,并核验实际镜像、版本、健康状态和原入口可用性,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.2.25_Task_Report.md)。
#### R2.2.26 [completed]
只读执行 PK01 Sub2API 最近4小时所有分组的上游账号质量评分:使用原生 Ops 账号请求量、客户/上游错误、切号、重试、临时不可调度、TTFT 和当前可用性,完整报告账号名称、评分、等级、置信度和扣分原因;兼容 v0.1.147,不修改 runtime、YAML 或调度配置,完成任务后将详细报告写入任务报告,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.2.26_Task_Report.md)。
#### R2.2.27 [in_progress]
交由 Artificer 实现 [Issue #2035](https://github.com/pikasTech/unidesk/issues/2035):增强 Sub2API 最近窗口账号质量分析,在同一分组、同一账号、同一窗口的一张 Kubernetes 列表中聚合展示评分/等级/置信度/失败率/TTFT 与请求数/TokenM/B/金额($);复用 v0.1.147 原生 admin usage 分页,JSON 保留精确值与来源,字段缺失不伪造为零,并修复 `--group <id>` 精确下钻错误,不修改运行面,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.2.27_Task_Report.md)。
#### R2.2.28 [completed]
只读核查 PK01 Sub2API 当前全部 OpenAI 上游账号的实际 priority、分组成员关系、可调度与可用状态,并结合最近4小时分组内评分、失败率、TTFT、Token和金额给出分层的推荐优先级调整方案;报告完整账号名称,区分立即建议、观察建议和证据不足,不直接修改 runtime、YAML或调度配置,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.2.28_Task_Report.md)。
#### R2.2.29 [completed]
按 R2.2.28 的最近4小时评分与用量结论,精准调整 PK01 Sub2API 账号全局 priority:只更新明确列出的 runtime-manual 账号,变更前全量预检、失败自动回滚、变更后批量回读对账;不修改分组、容量、代理、凭据、状态、可调度或临时不可调度规则,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.2.29_Task_Report.md)。
#### R2.2.30 [in_progress]
交由 Artificer 实现 [Issue #2037](https://github.com/pikasTech/unidesk/issues/2037):为 Sub2API runtime 接入账号全局 priority 的单账号与精准批量 dry-run/confirm、所有 selector 预检、写后自动回读对账、所有权提示和 Kubernetes 列表/显式 JSON 输出;明确 lower-is-higher、没有分组优先级,兼容 v0.1.147,不自动调整评分、不部署或修改运行面,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.2.30_Task_Report.md)。
#### R2.2.31 [completed]
只读复核 PK01 Sub2API 全局 priority 调整生效后约25分钟的新窗口:按全部分组和完整账号名称统计请求量、流量份额、客户/上游错误、失败率、TTFT、切号、Token与原生金额,并将账号名称尾部0.02/0.025/0.03/0.05/0.06/0.1作为上游采购成本权重综合评价当前分层,给出下一轮优先级建议;不修改运行面,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.2.31_Task_Report.md)。
#### R2.2.32 [completed]
按用户确认的经济口径修正 PK01 Sub2API runtime:将账号15名称从lyon9801标注为lyon9801 0.10,并按净售价0.10减采购成本重新调整全局priority,将零毛利账号15从1降至20、将成本0.02且近期表现良好的账号35从20升至5;执行前校验名称/旧值,变更后回读,不修改分组、容量、代理、凭据、状态、可调度或临时不可调度规则,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.2.32_Task_Report.md)。
#### R2.2.33 [completed]
实现 YAML-first 的 Sub2API 利润统计 CLI:默认读取最近24小时原生 admin usage,按账号完整名称聚合请求、TokenM/B)和 actual_cost,并依据 YAML 声明的盈利分组、自用分组、净收入系数与账号名称尾部采购成本系数,输出不扣除自用成本和扣除自用成本两种利润口径;缺失成本或未分类流量必须标记 partial,默认 Kubernetes 列表风格、显式 --json 保留精确值,兼容 v0.1.147,不修改 runtime,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.2.33_Task_Report.md)。
#### R2.2.34 [completed]
纠正 Sub2API 利润 CLI 的币种与倍率语义:原生 actual_cost 是标准 API 美元计费基数,售价 0.10 和账号名称尾部 0.02/0.025/0.03/0.05/0.06/0.10 都表示每 1 美元标准 API 计费对应的人民币单价;将 YAML、字段名、Kubernetes 表格、JSON 和 skill 统一改为 CNY per API USD,重新统计最近24小时人民币利润,不做汇率换算且不修改 runtime,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.2.34_Task_Report.md)。
#### R2.2.35 [completed]
只读计算 PK01 Sub2API 最近7天成本与利润:使用已修正的 CNY per API USD 口径,从原生 admin usage 按完整账号名称聚合标准 API 美元计费基数、人民币收入和人民币采购成本,分别给出不扣除自用成本与扣除自用成本的人民币利润;不修改 runtime,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.2.35_Task_Report.md)。
#### R2.2.36 [completed]
由 Artificer 优化 Sub2API 利润统计 CLI 的单次聚合与渐进披露,减少 7 天成本利润计算中的重复查询、外部解析和手工算术;默认 Kubernetes 风格与显式 JSON 都应直接保留紧凑汇总,账号明细语义化下钻,缺失历史成本时输出参数化利润公式;不修改 runtime 或部署,关联 [GitHub issue #2043](https://github.com/pikasTech/unidesk/issues/2043),完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.2.36_Task_Report.md)。
核对 Sub2API v0.1.155 官方源码与配置能力并按支持边界实施两项源头调优:将确定的模型上下文超限错误避免包装为通用上游502,以及在官方配置确实支持响应首 token 超过180秒触发当前请求failover时通过 owning YAML和受控CLI启用;Grok不处理,不修改Sub2API源码,不用隐藏UniDesk补丁伪造上游能力,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.2.16_Task_Report.md)。
### R2.3 [completed]
调查并收敛 Sub2API 原生 system-log 索引未保留策略事件的能力缺口,关联 [Issue #2027](https://github.com/pikasTech/unidesk/issues/2027),完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.3_Task_Report.md)。
### R2.4 [completed]
集中跟踪客户直接反馈、专项请求事件和 Sub2API 原生诊断能力,形成按用户、请求、账号和监控对象快速下钻的运维入口,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.4_Task_Report.md)。
#### R2.4.1 [completed]
紧急只读追踪用户 mail0795336304@163.com 反馈请求卡住15分钟:定位用户ID、近30分钟请求、当前长请求/并发、request ID、账号与模型,区分排队、上游首字、流式间隔、代理网络或客户连接,不取消请求且不修改runtime、YAML、proxy或调度,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.4.1_Task_Report.md)。
#### R2.4.2 [completed]
复盘用户直接反馈的只读追踪过程并交由 Artificer 实现 [Issue #2000](https://github.com/pikasTech/unidesk/issues/2000):增加通用的一键用户追踪 CLI,以邮箱或用户ID关联请求空窗、用户/API Key并发、client/internal request ID、上游账号名称、proxy基础设施和证据化归因,采用Kubernetes列表风格与稳定ID渐进披露,减少手工API与重复trace调用,不改运行面,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.4.2_Task_Report.md)。
#### R2.4.3 [completed]
将 PK01 的 Sub2API 通过 owning YAML 从 v0.1.153 受控升级到 v0.1.155:只修改 PK01 target镜像版本,依次执行状态核对、plan、apply dry-run、镜像预拉、受控apply、状态与公开健康验证,保持账号池runtime和Codex pool配置原样,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.4.3_Task_Report.md)。
#### R2.4.4 [completed]
交由 Artificer 实现 [Issue #2004](https://github.com/pikasTech/unidesk/issues/2004):增强 Sub2API CLI 拉取 v0.1.155 原生智能诊断与渠道监控状态,泛化所有分组/渠道概要和指定对象下钻,以Kubernetes列表风格呈现TTFT、上游与客户错误率、原生建议和证据边界,以及7/15/30天渠道运行状态、平台/模型、对话延迟、端点PING、可用率、最近记录和刷新事实,使用稳定ID渐进披露,不重算第二套诊断且不修改运行面,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.4.4_Task_Report.md)。
#### R2.4.5 [completed]
快速缓解错误 #17440:基于 request e5c08dde-9e60-4a14-9458-5574cec00b65 的真实链路,将精确短语 Input must be a list 补入通用 504 临时不可调度规则,对全部非 lyon9801 账号精准批量 dry-run、确认下发和自动回读对账,不改容量、优先级、代理或 Sub2API 源码,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.4.5_Task_Report.md)。
#### R2.4.6 [completed]
交由 Artificer 实现 [Issue #2013](https://github.com/pikasTech/unidesk/issues/2013):定义并实现 Sub2API P0/P1/P2 故障快速查询 CLI,P0 为上游故障穿透客户,P1 为首字延迟偏高且普通与 compact 分开统计并突出极端离群,P2 为上游错误率偏高;支持所有分组概要与按等级、分组、账号名称、模型、请求类型、稳定 request ID 下钻,默认 Kubernetes 列表风格和固定分页,不靠手工 limit,不修改运行面,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.4.6_Task_Report.md)。
#### R2.4.7 [completed]
主代理只读追踪客户错误 #17490request ID 4eb9a84b-7346-47a8-bb66-fb7b44317279):使用 Sub2API 原生 Ops、trace、账号完整名称、failover/retry/临时不可调度和近期窗口证据,定位账号 https://sub2.pokexiao.com plus 0.03 的同步502为何穿透客户,区分候选耗尽、context取消、不可重试阶段或模板未命中;先调查,不盲目新增generic 502规则,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.4.7_Task_Report.md)。
#### R2.4.8 [completed]
交由 Artificer 实现 [Issue #2016](https://github.com/pikasTech/unidesk/issues/2016):增强 CLI 对 Sub2API 内部账号/渠道监控的原生只读访问,展示探测 timeout、cadence、阶段耗时、账号选择、上游首字节、切号/重试和最终状态,支持所有监控对象概要与稳定 ID 下钻,默认 Kubernetes 列表风格且不靠手工 limit;不修改运行面、不发新探针,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.4.8_Task_Report.md)。
#### R2.4.9 [completed]
只读调查错误 #17511request ID `f7ff0efe-64d3-4dd7-8716-20bdfc3a2f90`)为何上游 502 后未成功切号,重建流式请求的账号选择、首字节、响应提交、failover、排除列表、context deadline 与最终客户错误链,并与内部 monitor 请求 #17490 对照,不修改运行面,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.4.9_Task_Report.md)。
### R2.5 [in_progress]
集中跟踪 Sub2API 版本基线、上游账号质量评分、用量归因和账号全局调度优先级,保留只读评估与受控 runtime 调整边界,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.5_Task_Report.md)。
#### R2.5.1 [completed]
将 PK01 Sub2API 从 v0.1.155 受控回退到 v0.1.147:只修改 owning YAML 版本事实,在最新 master 的独立干净 worktree提交并通过受控 GitHub PR 合并,随后使用原 platform-infra Sub2API 交付入口完成 PK01 rollout,并核验实际镜像、版本、健康状态和原入口可用性,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.5.1_Task_Report.md)。
#### R2.5.2 [completed]
只读执行 PK01 Sub2API 最近4小时所有分组的上游账号质量评分:使用原生 Ops 账号请求量、客户/上游错误、切号、重试、临时不可调度、TTFT 和当前可用性,完整报告账号名称、评分、等级、置信度和扣分原因;兼容 v0.1.147,不修改 runtime、YAML 或调度配置,完成任务后将详细报告写入任务报告,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.5.2_Task_Report.md)。
#### R2.5.3 [in_progress]
交由 Artificer 实现 [Issue #2035](https://github.com/pikasTech/unidesk/issues/2035):增强 Sub2API 最近窗口账号质量分析,在同一分组、同一账号、同一窗口的一张 Kubernetes 列表中聚合展示评分/等级/置信度/失败率/TTFT 与请求数/TokenM/B/金额($);复用 v0.1.147 原生 admin usage 分页,JSON 保留精确值与来源,字段缺失不伪造为零,并修复 `--group <id>` 精确下钻错误,不修改运行面,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.5.3_Task_Report.md)。
#### R2.5.4 [completed]
只读核查 PK01 Sub2API 当前全部 OpenAI 上游账号的实际 priority、分组成员关系、可调度与可用状态,并结合最近4小时分组内评分、失败率、TTFT、Token和金额给出分层的推荐优先级调整方案;报告完整账号名称,区分立即建议、观察建议和证据不足,不直接修改 runtime、YAML或调度配置,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.5.4_Task_Report.md)。
#### R2.5.5 [completed]
按 R2.5.4 的最近4小时评分与用量结论,精准调整 PK01 Sub2API 账号全局 priority:只更新明确列出的 runtime-manual 账号,变更前全量预检、失败自动回滚、变更后批量回读对账;不修改分组、容量、代理、凭据、状态、可调度或临时不可调度规则,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.5.5_Task_Report.md)。
#### R2.5.6 [in_progress]
交由 Artificer 实现 [Issue #2037](https://github.com/pikasTech/unidesk/issues/2037):为 Sub2API runtime 接入账号全局 priority 的单账号与精准批量 dry-run/confirm、所有 selector 预检、写后自动回读对账、所有权提示和 Kubernetes 列表/显式 JSON 输出;明确 lower-is-higher、没有分组优先级,兼容 v0.1.147,不自动调整评分、不部署或修改运行面,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.5.6_Task_Report.md)。
#### R2.5.7 [completed]
只读复核 PK01 Sub2API 全局 priority 调整生效后约25分钟的新窗口:按全部分组和完整账号名称统计请求量、流量份额、客户/上游错误、失败率、TTFT、切号、Token与原生金额,并将账号名称尾部0.02/0.025/0.03/0.05/0.06/0.1作为上游采购成本权重综合评价当前分层,给出下一轮优先级建议;不修改运行面,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.5.7_Task_Report.md)。
#### R2.5.8 [completed]
按用户确认的经济口径修正 PK01 Sub2API runtime:将账号15名称从lyon9801标注为lyon9801 0.10,并按净售价0.10减采购成本重新调整全局priority,将零毛利账号15从1降至20、将成本0.02且近期表现良好的账号35从20升至5;执行前校验名称/旧值,变更后回读,不修改分组、容量、代理、凭据、状态、可调度或临时不可调度规则,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.5.8_Task_Report.md)。
#### R2.5.9 [completed]
只读分析 PK01 Sub2API 最近2小时所有分组的用户可见错误、普通与 compact 请求首字延迟分布及完整账号名称质量评分,关联请求量、上游错误、failover、重试、临时不可调度、当前可用性和样本置信度,给出主因与调度观察建议,不修改 runtime、YAML 或运行面,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.5.9_Task_Report.md)。
#### R2.5.10 [completed]
只读统计 PK01 Sub2API 最近8小时所有分组的账号质量评分与流水,按完整账号名称聚合请求量、Token(M/B)、标准API美元计费基数、客户/上游错误、failover、重试、临时不可调度、TTFT、当前可用性、评分等级与置信度,并区分盈利池和自用池;不修改runtime、YAML或运行面,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.5.10_Task_Report.md)。
#### R2.5.11 [completed]
精确分析 PK01 最近8小时盈利池客户可见错误:按状态码、响应详情、账号、模型、同步/流式、端点、阶段、failover/retry和代表request ID重建具体原因;随后结合两分组账号评分、样本置信度、采购成本和盈利贡献,生成精确全局priority方案,先dry-run再确认写入并批量回读,不修改分组、容量、代理、凭据、可调度或临时不可调度规则,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.5.11_Task_Report.md)。
#### R2.5.12 [completed]
只读确认流式并发限额错误发生于 SSE 已提交后的 HTTP 200 degraded 阶段,核验官方临时不可调度配置无法挽救当前流后停止追加无效规则;固化默认不修改 Sub2API 源码、版本或外部哨兵的边界,仅在用户明确授权时允许这些手段,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.5.12_Task_Report.md)。
### R2.6 [completed]
集中跟踪 Sub2API 标准 API 美元计费基数、人民币采购成本、售价和多口径利润统计,保持 YAML-first 的经济口径,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.6_Task_Report.md)。
#### R2.6.1 [completed]
实现 YAML-first 的 Sub2API 利润统计 CLI:默认读取最近24小时原生 admin usage,按账号完整名称聚合请求、TokenM/B)和 actual_cost,并依据 YAML 声明的盈利分组、自用分组、净收入系数与账号名称尾部采购成本系数,输出不扣除自用成本和扣除自用成本两种利润口径;缺失成本或未分类流量必须标记 partial,默认 Kubernetes 列表风格、显式 --json 保留精确值,兼容 v0.1.147,不修改 runtime,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.6.1_Task_Report.md)。
#### R2.6.2 [completed]
纠正 Sub2API 利润 CLI 的币种与倍率语义:原生 actual_cost 是标准 API 美元计费基数,售价 0.10 和账号名称尾部 0.02/0.025/0.03/0.05/0.06/0.10 都表示每 1 美元标准 API 计费对应的人民币单价;将 YAML、字段名、Kubernetes 表格、JSON 和 skill 统一改为 CNY per API USD,重新统计最近24小时人民币利润,不做汇率换算且不修改 runtime,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.6.2_Task_Report.md)。
#### R2.6.3 [completed]
只读计算 PK01 Sub2API 最近7天成本与利润:使用已修正的 CNY per API USD 口径,从原生 admin usage 按完整账号名称聚合标准 API 美元计费基数、人民币收入和人民币采购成本,分别给出不扣除自用成本与扣除自用成本的人民币利润;不修改 runtime,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.6.3_Task_Report.md)。
#### R2.6.4 [completed]
由 Artificer 优化 Sub2API 利润统计 CLI 的单次聚合与渐进披露,减少 7 天成本利润计算中的重复查询、外部解析和手工算术;默认 Kubernetes 风格与显式 JSON 都应直接保留紧凑汇总,账号明细语义化下钻,缺失历史成本时输出参数化利润公式;不修改 runtime 或部署,关联 [GitHub issue #2043](https://github.com/pikasTech/unidesk/issues/2043),完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.6.4_Task_Report.md)。
#### R2.6.5 [completed]
扩展 YAML-first 利润算法:将 lyon9801 的边际采购倍率改为 0.0,并把 2026-07 的 1300 元一次性账号成本作为期间固定成本单列;利润 CLI 支持按月聚合并分别披露流量成本、一次性成本和扣除后的两种利润口径,再依据近期账号质量与边际利润调整账号全局 priority,不修改 Sub2API 源码、版本、外部哨兵、分组、容量、代理、凭据或可调度状态,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.6.5_Task_Report.md)。
#### R2.6.6 [completed]
基于本月已有 Sub2API 原生流水增加整月收益 run-rate 估算:将月初至当前的收入、盈利池流量成本和自用流量成本按已过时间线性外推至月末,一次性期间成本只扣一次,输出不扣自用与扣除自用两种整月预计利润、缩放系数和 MTD 实际基准;保持 YAML-first 经济口径,不修改 runtime 或 Sub2API,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.6.6_Task_Report.md)。
#### R2.6.7 [completed]
只读分析 2026-07 整月收益预测亏损根因:按盈利池与自用池、完整账号名称、标准 API 美元计费基数、边际成本和一次性成本拆解,量化 lyon9801 当前流量占比、固定成本覆盖率、全量切向 lyon 的理论上限和当前组合盈亏平衡流水,判断亏损主要来自 lyon 占比、总流水不足、自用成本还是其他账号边际成本;不修改 runtime 或 Sub2API,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.6.7_Task_Report.md)。
#### R2.6.8 [completed]
按售价 0.15 CNY per API USD 只读重算 2026-07 整月预测收入、盈利池利润、扣除自用后的整体利润、当前组合保本售价和全量 lyon 理论利润;沿用 R2.6.7 同一流水快照与成本结构,不修改 YAML、runtime 或 Sub2API,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.6.8_Task_Report.md)。
#### R2.6.9 [completed]
复核售价 0.15 CNY per API USD 的整月预测:重新拉取当前 Sub2API 原生流水,并按实际已过时长计算每日标准 API 计费基数、营业额、盈利池变动成本、自用成本、lyon9801 固定成本日均摊销及两种日利润,核对月度外推是否一致;只读,不修改配置或运行面,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.6.9_Task_Report.md)。
#### R2.6.10 [completed]
评估 2026-08 不再采购固定账号 lyon9801 0.0 时的预期盈利:售价保持 0.15 CNY per API USD,按最新日均流水外推 31 天,分别计算直接取消 1300 元固定成本的理论上限,以及 lyon 当前盈利池和自用池流量按其他活跃账号实际加权平均边际成本接管的现实预测;披露容量与质量风险,只读且不调整账号,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.6.10_Task_Report.md)。
#### R2.6.11 [completed]
将固定账号退出核算流程沉淀到通用利润 CLI 和 Sub2API skill:增加可复用的排除账号情景参数,一次原生 usage 聚合直接输出售价覆盖、理论上限、按剩余账号分组加权成本重分配的现实利润、日均营业额与成本、账号流量占比和剩余账号负载增幅;保持默认 Kubernetes 列表风格与显式 JSON,避免账号分页和手工算术,不修改 Sub2API 运行面,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.6.11_Task_Report.md)。
#### R2.6.12 [completed]
基于最新 0.15 售价情景、当前 0.10 YAML 口径、lyon9801 固定成本、两池替代成本、账号负载增幅和可靠性价值,形成综合运营建议:明确本月沉没成本利用、下月续费决策、可接受固定号价格、售价策略、容量与质量门槛、自用预算和账号优先级原则;只做建议,不修改配置或运行面,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.6.12_Task_Report.md)。
### R2.7 [completed]
集中跟踪 Sub2API 原生 Grok 账号、分组、Codex Responses 接入和第三方 Grok 上游兼容性,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.7_Task_Report.md)。
#### R2.7.1 [completed]
只读调查 Sub2API 官方源码和 issue,确认最新原生 Grok provider 通过 Sub2API 接入 Codex 的受支持路径,区分 OAuth、API Key、Responses、模型映射和源码能力边界;不修改 runtime、YAML、代码或部署,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.7.1_Task_Report.md)。
#### R2.7.2 [completed]
`~/.codex/config.toml.grok``~/.codex/auth.json.grok` 调整为通过 Sub2API 原生 Grok 分组接入 Codex;保留密钥脱敏和文件权限,验证现有 Key 的分组与模型能力,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.7.2_Task_Report.md)。
#### R2.7.3 [completed]
结合管理端 `https://sub.yjxm1221.top grok` API Key 账号连接测试成功的新证据,复核 Codex Grok profile 经 Sub2API `/v1/responses` 的网关链路,区分账号直连测试与分组调度路径,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.7.3_Task_Report.md)。
### R2.8 [completed]
整理本 MDTODO FILE 的职责层级和编号,并把同一 SUBITEM 下的直接 SUBSUBITEM 一般不超过 20 固化到 mdtodo-edit skill,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.8_Task_Report.md)。
### R2.9 [completed]
`https://api.iceiu.com/` 对应上游账号的人民币采购成本标注调整为 `0.011`,结合 Sub2API 原生近期账号评分、错误率、TTFT、用量和当前 runtime 优先级选择适度提高后的优先级;手工账号使用精准 runtime CRUD,变更前 dry-run、确认写入后逐字段回读对账,不修改 Sub2API 源码、版本或外部哨兵,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.9_Task_Report.md)。
### R2.10 [completed]
`https://sub.yjxm1221.top/` 对应上游账号的人民币采购成本标注调整为 `0.025`,结合 Sub2API 原生近期账号评分、错误率、TTFT、用量和当前 runtime 优先级适当调整优先级;手工账号使用精准 runtime CRUD,变更前 dry-run、确认写入后逐字段回读对账,不修改 Sub2API 源码、版本或外部哨兵,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.10_Task_Report.md)。
### R2.11 [completed]
依据 [UniDesk #2144](https://github.com/pikasTech/unidesk/issues/2144) 将单账号成本标注与优先级调优的最短路径固化到 Sub2API skill:账号级 `runtime errors --group --account --since` 作为评分、可靠性、TTFT、用量和成本首入口,仅在读取当前 runtime 字段时补一次 `runtime get`;全组概要只用于跨账号比较,名称和 priority 分别 dry-run、顺序 confirm、最终单次回读,不修改运行面,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R2.11_Task_Report.md)。
## R3 [completed]
增加 Sub2API 客户余额精准批量充值 CLI:支持从原生最近24小时用量提取活跃用户并生成每人增加20美元的补偿计划,也支持显式用户ID或账号 selector;默认 dry-run 输出完整账号、用户ID、当前余额、增额和目标余额,写入必须显式 --confirm 并自动回读对账。本轮只实现并验证 dry-run,禁止实际充值,必须等待用户再次明确授权,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R3_Task_Report.md)。
### R3.1 [completed]
从 PK01 Sub2API 原生最近24小时 usage 精确列出活跃非管理员用户,并生成每人增加10 USD额度的批量补偿 dry-run:披露完整邮箱、用户ID、请求数、当前余额、增额和目标余额,实际写入数必须为0;不使用 --confirm,不执行充值,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R3.1_Task_Report.md)。
### R3.2 [completed]
交由 Artificer 实现 [Issue #2097](https://github.com/pikasTech/unidesk/issues/2097):对接 Sub2API 原生公告后端并增加受控公告 CLI,支持公告列表、精确查看、创建 dry-run、显式确认发布和写后回读对账;为最近24小时17名活跃用户每人10 USD、总额170 USD的补偿生成公告预览,本轮禁止实际发布公告或充值,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R3.2_Task_Report.md)。
### R3.3 [completed]
通过 Sub2API 受控 CLI 精确拉取北京时间 2026-07-14 17:00:00 至 18:00:00 的活跃非管理员用户;时间解释必须读取 owning YAML 的默认 Asia/Shanghai 时区,不用相对窗口近似,不执行充值或其他运行面写入;若 CLI 缺少绝对时间窗能力,先按通用方式补齐并验证后再查询,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R3.3_Task_Report.md)。
### R3.4 [completed]
在 Sub2API credits owning YAML 的排除列表中加入内部员工账号 zhuo@test.com 与 huiguo@test.com,并让活跃用户补偿 dry-run 按通用精确 selector 排除并披露 employee-excluded 原因;复测北京时间固定窗口不再选中这两个账号,不执行充值,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R3.4_Task_Report.md)。
### R3.5 [completed]
增强 Sub2API credits 固定时间窗查询,按原生 usage 的实际字段为每名用户聚合请求次数、输入 Token、输出 Token 和总 Token,并重新列出北京时间 2026-07-14 17:00 至 18:00 的客户与 YAML 排除账号;必须披露字段来源和缺失值,不执行充值,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R3.5_Task_Report.md)。
### R3.6 [completed]
按用户明确授权,对固定补偿候选用户 ID 11、10、7、22、19 每人增加 30 USD,总额 150 USD,并并发发布服务稳定性补偿公告;两条操作都必须通过 Sub2API 原生受控 CLI 显式 confirm,使用精确名单、写后回读和公告字段对账,禁止扩大到 YAML 排除员工或管理员,完成任务后将详细报告写入[任务报告](./details/sub2api-upstream-reliability/R3.6_Task_Report.md)。
+9 -7
View File
@@ -78,7 +78,7 @@
5. `secrets sync` 按 YAML 声明补齐允许生成的本地来源,并下发 `pikaoa-test-runtime`
6. 使用同一 commit 依次执行:
- `--step migration`
- `--step init`,仅初始化全新数据库
- `--step api`
- `--step worker`
- `--step web`
@@ -87,7 +87,7 @@
## 单步运行
- foundation 不需要 `--commit`,也不检查业务 Secret。
- migration、api、worker、web 和 all 必须显式提供 `--commit`
- init、api、worker、web 和 all 必须显式提供 `--commit`
- 每个 `start` 立即返回任务 ID;使用同一 target、instance 和 step 的 `status` 查询终态。
- request identity 包含:
- target
@@ -108,19 +108,21 @@
- 提供新的 `--commit` 修订标识;
- 修改 foundation 的稳定 manifest 结构。
- 不为重跑引入第二状态库、控制器、租约或长期历史存储。
- 迁移、rollout 或运行面查询失败返回具名失败码,不静默进入下一阶段。
- initializer、rollout 或运行面查询失败返回具名失败码,不静默进入下一阶段。
- OTel exporter、配置版本和 commit 对齐漂移只产生 `blocking=false` warning,不恢复 dedicated 门禁。
## 交付阶段
- 当前阶段先稳定 YAML-first CLI 原入口和固定 NC01 测试运行面。
- CLI 闭环通过后,再建设独立 test CI/CD:
- 复用同一 owning YAML
- 按 foundation、Secret sync、migration、api、worker、web 顺序编排
- `pikaoa-test-nc01` 独立 test CI/CD 复用同一 owning YAML
- 产品 `master` 只生成 `.tekton/pikaoa-test-nc01-pac.yaml`
- API、Worker、Web 并行构建并以 digest 发布 GitOps
- initializer 通过 Argo `PreSync` 在 API、Worker、Web 前初始化全新数据库
- 不创建专用测试集群;
- 不生成动态 namespace
- 不创建 namespace-local PostgreSQL
- 不把测试 CI/CD 变成生产交付或用户业务的阻塞门禁。
- GitOps 接管后,手动 `test-target start|stop` mutation 仅用于暂停 Argo 自动同步后的有界调试;禁止 CLI direct-apply 与 Argo 同时写入。
- 生产 `pikaoa-nc01` 保留 `release` source authority,但当前不 bootstrap、不生成 `.tekton`、不创建 PipelineRun。
- PR、构建或单测不能替代固定 NodePort 原入口验收。
## 本地验证
+19
View File
@@ -22,3 +22,22 @@
- `browserOutputPolicy.maxFramesPerSecond` 是每个浏览器连接、每个终端的最大输出消息频率;
- `browserOutputPolicy.maxFrameBytes` 是单条聚合输出消息的字节上限;
- 后端必须按终端独立排队,小数据在频率窗口内合并,积压数据按窗口顺序发送,禁止用字节阈值绕过频率上限。
- 持久 Codex Session 创建:
- 适用于本地 provider 的 `mycx``oncx` runtime 自动恢复标签;
- 新建必须直接调用原生 `codex app-server`,按顺序完成 `initialize``initialized``thread/start``thread/name/set`
- `thread/start` 必须显式传入 `ephemeral=false`,并以返回的 thread ID 作为后续恢复 Session ID
- 禁止通过附带 `--profile``mycx``oncx` 包装器启动 app-server,当前 Codex 只允许 profile 用于 runtime 命令;
- `mycx` 创建沿用默认 Codex home`oncx` 创建必须沿用包装器声明的 `CODEX_HOME``CODEX_SQLITE_HOME` 和凭据环境清理规则;
- Webterm 运行在使用 `/usr/local/bin/host-shell` 的容器中时,app-server 必须通过宿主 namespace 执行原生 Codex
- 容器与宿主工作目录分层:
- 容器进程工作目录必须使用容器内存在的目录;
- 目标工作目录只通过 `thread/start.cwd` 传给宿主 Codex
- 禁止把仅宿主存在的路径直接作为容器 `spawn.cwd`
- 只有 `thread/name/set` 成功后才能把 Session ID 写入 runtime 数据域,再通过 `mycx|oncx resume <session-id> <prompt>` 启动终端;
- 恢复 prompt 必须作为 CLI 参数传入,禁止在 xterm 中模拟键盘输入;
- runtime 记录与 YAML 预置恢复标签必须共存,runtime 数据域不得改变 owning YAML 的预置定义。
- 持久 Session 最小验收:
- 先执行目标的受控 `status`,确认 provider 健康和 runtime 数据域正确;
- 再从真实浏览器加号入口创建一个持久 Session,关闭标签后从恢复列表重新打开;
- 创建与恢复后的 Session ID 相同、标签为 runtime 自动恢复且终端进入 running,才判定端到端合同成立;
- 单元测试只验证 app-server 消息顺序、模式环境和宿主 namespace 启动参数,不能替代真实浏览器验收。
+19 -11
View File
@@ -222,9 +222,9 @@ function evaluatePacAdmissionState(inputValue) {
if (annotations["unidesk.ai/pac-controller-identity"] !== expected.controllerIdentity) reasons.push(`${kind}-controller-identity-mismatch`);
if (annotations["unidesk.ai/effective-config-sha256"] !== expected.configSha256) reasons.push(`${kind}-config-sha256-mismatch`);
}
if (policySpec.failurePolicy !== "Fail") reasons.push("policy-failure-policy-not-fail");
if (policySpec.failurePolicy !== "Ignore") reasons.push("policy-failure-policy-not-ignore");
if (bindingSpec.policyName !== expected.policyName) reasons.push("binding-policy-name-mismatch");
if (!Array.isArray(bindingSpec.validationActions) || bindingSpec.validationActions.length !== 1 || bindingSpec.validationActions[0] !== "Deny") reasons.push("binding-validation-actions-not-deny");
if (!Array.isArray(bindingSpec.validationActions) || stableCanonicalJson(bindingSpec.validationActions) !== stableCanonicalJson(["Warn", "Audit"])) reasons.push("binding-validation-actions-not-warning-only");
if (!Number.isInteger(policyMetadata.generation) || !Number.isInteger(policyStatus.observedGeneration) || policyStatus.observedGeneration < policyMetadata.generation) reasons.push("policy-generation-not-observed");
if (warnings.length > 0) reasons.push("policy-expression-warning");
if (roleMetadata.name !== "unidesk-pac-consumer-runner") reasons.push("default-role-missing");
@@ -258,6 +258,9 @@ function evaluatePacAdmissionState(inputValue) {
configured: true,
required: true,
ready: reasons.length === 0,
blocking: false,
warning: reasons.length > 0,
warnings: reasons,
source: "live-admissionregistration-v1",
policyName: stringOrNull(policyMetadata.name),
bindingName: stringOrNull(bindingMetadata.name),
@@ -357,13 +360,18 @@ function classifyPacPipelineRun(consumerInput, itemInput) {
deliveryClass,
reason,
candidate,
deliveryAuthorityEligible: outer && (!provenanceRequired || admissionProvenanceVerified),
deliveryAuthorityEligible: outer,
deliveryOwner: outer ? admissionProvenanceVerified ? "pac-controller-admission" : "pac-controller-observed" : null,
executionOwner: inner ? "tekton-child-unattached" : null,
parentPipelineRun: null,
parentRelation: inner ? "unproven" : null,
metadataObservationOnly: outer && !admissionProvenanceVerified,
admissionProvenanceVerified,
admissionWarning: outer && !admissionProvenanceVerified ? {
code: "pac-admission-provenance-unverified",
blocking: false,
reasons: Array.isArray(admissionState.reasons) ? admissionState.reasons : [],
} : null,
admissionPolicyReady: admissionState.ready === true,
admissionPolicyName: stringOrNull(admissionState.policyName),
admissionBindingName: stringOrNull(admissionState.bindingName),
@@ -1285,19 +1293,19 @@ function runPacStatusFixtureChecks() {
};
const classificationCases = [
{ id: "admission-provenance-verified", expected: true, item: verifiedRun, state: admissionState },
{ id: "pre-bootstrap-run-fails-closed", expected: false, item: { ...verifiedRun, metadata: { ...verifiedRun.metadata, creationTimestamp: "2025-12-31T23:59:59Z" } }, state: admissionState },
{ id: "forged-name-candidate-fails-closed", expected: false, item: { ...verifiedRun, metadata: { ...verifiedRun.metadata, annotations: { ...verifiedRun.metadata.annotations, [provenance.markerAnnotation]: "forged" } } }, state: admissionState },
{ id: "forged-label-candidate-fails-closed", expected: false, item: { ...verifiedRun, metadata: { ...verifiedRun.metadata, name: "unrelated", labels: { ...verifiedRun.metadata.labels, "tekton.dev/pipeline": consumer.pipeline }, annotations: { ...verifiedRun.metadata.annotations, [provenance.markerAnnotation]: "forged" } } }, state: admissionState },
{ id: "forged-pipeline-ref-candidate-fails-closed", expected: false, item: { ...verifiedRun, metadata: { ...verifiedRun.metadata, name: "unrelated", annotations: { ...verifiedRun.metadata.annotations, [provenance.markerAnnotation]: "forged" } }, spec: { ...verifiedRun.spec, pipelineRef: { name: consumer.pipeline } } }, state: admissionState },
{ id: "wrong-service-account-fails-closed", expected: false, item: { ...verifiedRun, spec: { taskRunTemplate: { serviceAccountName: "default" } } }, state: admissionState },
{ id: "policy-identity-mismatch-fails-closed", expected: false, item: verifiedRun, state: { ...admissionState, configSha256: `sha256:${"2".repeat(64)}` } },
{ id: "pre-bootstrap-run-warning-only", expected: false, item: { ...verifiedRun, metadata: { ...verifiedRun.metadata, creationTimestamp: "2025-12-31T23:59:59Z" } }, state: admissionState },
{ id: "marker-mismatch-warning-only", expected: false, item: { ...verifiedRun, metadata: { ...verifiedRun.metadata, annotations: { ...verifiedRun.metadata.annotations, [provenance.markerAnnotation]: "forged" } } }, state: admissionState },
{ id: "candidate-label-warning-only", expected: false, item: { ...verifiedRun, metadata: { ...verifiedRun.metadata, name: "unrelated", labels: { ...verifiedRun.metadata.labels, "tekton.dev/pipeline": consumer.pipeline }, annotations: { ...verifiedRun.metadata.annotations, [provenance.markerAnnotation]: "forged" } } }, state: admissionState },
{ id: "candidate-pipeline-ref-warning-only", expected: false, item: { ...verifiedRun, metadata: { ...verifiedRun.metadata, name: "unrelated", annotations: { ...verifiedRun.metadata.annotations, [provenance.markerAnnotation]: "forged" } }, spec: { ...verifiedRun.spec, pipelineRef: { name: consumer.pipeline } } }, state: admissionState },
{ id: "service-account-mismatch-warning-only", expected: false, item: { ...verifiedRun, spec: { taskRunTemplate: { serviceAccountName: "default" } } }, state: admissionState },
{ id: "policy-identity-mismatch-warning-only", expected: false, item: verifiedRun, state: { ...admissionState, configSha256: `sha256:${"2".repeat(64)}` } },
];
for (const item of classificationCases) {
const result = classifyPacPipelineRun({ ...consumer, admissionState: item.state }, item.item);
checks.push({
id: item.id,
ok: result.admissionProvenanceVerified === item.expected && result.deliveryAuthorityEligible === item.expected,
expectedOk: item.expected,
ok: result.admissionProvenanceVerified === item.expected && result.deliveryAuthorityEligible === true,
expectedOk: true,
actualOk: result.deliveryAuthorityEligible,
expectedCode: item.expected ? "admission-owned-pac-push-provenance-verified" : "pac-push-metadata-observed-but-admission-provenance-unverified",
actualCode: result.reason,
@@ -0,0 +1,205 @@
import { rmSync } from "node:fs";
import { describe, expect, test } from "bun:test";
import { runAgentRunCommand } from "./agentrun";
const RUN_ID = "run_long_poll_fixture";
const agentRunClientYaml = [
"version: 1",
"kind: AgentRunConfig",
"metadata:",
" name: agentrun",
"manager:",
" baseUrl: __BASE_URL__",
" timeoutMs: 15000",
"auth:",
" env: HWLAB_API_KEY",
" file: /tmp/hwlab-api-key.env",
" header: Authorization",
" scheme: Bearer",
"client:",
" role: render-only",
" transport: direct-http",
" sessionPolicy:",
" tenantId: unidesk",
" projectId: test",
" providerId: NC01",
" backendProfile: codex",
" workspaceRef:",
" kind: opaque",
" executionPolicy:",
" sandbox: workspace-write",
" approval: never",
" timeoutMs: 7200000",
" network: enabled",
" secretScope:",
" allowCredentialEcho: false",
].join("\n");
function renderedText(value: Awaited<ReturnType<typeof runAgentRunCommand>>): string {
if (!("renderedText" in value) || typeof value.renderedText !== "string") throw new Error("expected rendered AgentRun CLI output");
return value.renderedText;
}
function event(seq: number): Record<string, unknown> {
return {
id: `evt_${seq}`,
seq,
type: "backend_status",
payload: { commandId: "cmd_fixture", phase: `phase-${seq}`, message: `event-${seq}` },
};
}
async function withManager(
handler: (request: Request) => Response | Promise<Response>,
action: () => Promise<void>,
): Promise<void> {
const server = Bun.serve({ port: 0, fetch: handler });
const previousConfig = process.env.AGENTRUN_CLIENT_CONFIG;
const previousKey = process.env.HWLAB_API_KEY;
const configPath = `/tmp/unidesk-agentrun-events-long-poll-${process.pid}-${Date.now()}.yaml`;
process.env.AGENTRUN_CLIENT_CONFIG = configPath;
process.env.HWLAB_API_KEY = "fixture-secret";
await Bun.write(configPath, agentRunClientYaml.replace("__BASE_URL__", server.url.href.replace(/\/$/u, "")));
try {
await action();
} finally {
server.stop(true);
rmSync(configPath, { force: true });
if (previousConfig === undefined) delete process.env.AGENTRUN_CLIENT_CONFIG;
else process.env.AGENTRUN_CLIENT_CONFIG = previousConfig;
if (previousKey === undefined) delete process.env.HWLAB_API_KEY;
else process.env.HWLAB_API_KEY = previousKey;
}
}
describe.serial("AgentRun events manager-held long polling", () => {
test("forwards default 120s timeout and returns as soon as expect is reached", async () => {
let requests = 0;
await withManager(async (request) => {
requests += 1;
const url = new URL(request.url);
expect(url.pathname).toBe(`/api/v1/runs/${RUN_ID}/events`);
expect(url.searchParams.get("afterSeq")).toBe("100");
expect(url.searchParams.get("expect")).toBe("2");
expect(url.searchParams.get("timeoutMs")).toBe("120000");
expect(url.searchParams.get("limit")).toBe("21");
await Promise.all([Bun.sleep(10), Bun.sleep(20)]);
return Response.json({
ok: true,
data: {
items: [event(101), event(102)],
timedOut: false,
observed: 2,
nextAfterSeq: 102,
completionReason: "expect-reached",
},
});
}, async () => {
const result = await runAgentRunCommand(null, ["events", `run/${RUN_ID}`, "--after-seq", "100", "--expect", "2", "-o", "json"]);
expect(result.ok).toBe(true);
const payload = JSON.parse(renderedText(result)) as Record<string, unknown>;
expect(payload).toMatchObject({ count: 2, expect: 2, timeoutMs: 120000, timedOut: false, observed: 2, nextAfterSeq: 102, completionReason: "expect-reached" });
expect(requests).toBe(1);
});
});
test("renders partial and empty timeout responses with an explicit cursor", async () => {
for (const fixture of [
{ items: [event(201)], observed: 1, nextAfterSeq: 201 },
{ items: [], observed: 0, nextAfterSeq: 200 },
]) {
await withManager((request) => {
const url = new URL(request.url);
expect(url.searchParams.get("timeoutMs")).toBe("3000");
return Response.json({ ok: true, data: { ...fixture, timedOut: true, completionReason: "timeout" } });
}, async () => {
const result = await runAgentRunCommand(null, ["events", `run/${RUN_ID}`, "--after-seq", "200", "--expect", "10", "--timeout", "3s", "-o", "json"]);
const payload = JSON.parse(renderedText(result)) as Record<string, unknown>;
expect(payload).toMatchObject({ timedOut: true, observed: fixture.observed, nextAfterSeq: fixture.nextAfterSeq, completionReason: "timeout" });
});
}
});
test("returns concurrent event arrivals in one manager request", async () => {
let requests = 0;
await withManager(async () => {
requests += 1;
const arrivals: Record<string, unknown>[] = [];
await Promise.all([
Bun.sleep(10).then(() => arrivals.push(event(301))),
Bun.sleep(20).then(() => arrivals.push(event(302))),
]);
return Response.json({ ok: true, data: { items: arrivals, timedOut: false, observed: 2, nextAfterSeq: 302, completionReason: "expect-reached" } });
}, async () => {
const result = await runAgentRunCommand(null, ["events", `run/${RUN_ID}`, "--after-seq", "300", "--expect", "2", "--timeout", "1m", "-o", "json"]);
const payload = JSON.parse(renderedText(result)) as { items?: Array<{ seq?: number }> };
expect(payload.items?.map((item) => item.seq)).toEqual([301, 302]);
expect(requests).toBe(1);
});
});
test("returns immediately when the target is terminal before expect is reached", async () => {
await withManager(() => Response.json({
ok: true,
data: {
items: [],
timedOut: false,
observed: 0,
nextAfterSeq: 400,
completionReason: "target-completed",
},
}), async () => {
const result = await runAgentRunCommand(null, ["events", `run/${RUN_ID}`, "--after-seq", "400", "--expect", "10", "--timeout", "120s", "-o", "json"]);
const payload = JSON.parse(renderedText(result)) as Record<string, unknown>;
expect(payload).toMatchObject({ timedOut: false, observed: 0, nextAfterSeq: 400, completionReason: "target-completed" });
});
});
test("rejects invalid duration before request and preserves manager errors", async () => {
let requests = 0;
await withManager(() => {
requests += 1;
return Response.json({ ok: false, failureKind: "manager-unavailable", message: "event notifier unavailable" }, { status: 503 });
}, async () => {
const invalid = await runAgentRunCommand(null, ["events", `run/${RUN_ID}`, "--expect", "2", "--timeout", "3minutes", "-o", "json"]);
expect(invalid.ok).toBe(false);
expect(renderedText(invalid)).toContain("--timeout must use a positive integer duration with ms, s, or m units");
expect(requests).toBe(0);
const failed = await runAgentRunCommand(null, ["events", `run/${RUN_ID}`, "--expect", "2", "--timeout", "1s", "-o", "json"]);
expect(failed.ok).toBe(false);
expect(renderedText(failed)).toContain("event notifier unavailable");
expect(requests).toBe(1);
});
});
test("fails visibly when a manager ignores the long-poll response contract", async () => {
await withManager(() => Response.json({ ok: true, data: { items: [], nextAfterSeq: 500 } }), async () => {
const result = await runAgentRunCommand(null, ["events", `run/${RUN_ID}`, "--after-seq", "500", "--expect", "2", "--timeout", "1s", "-o", "json"]);
expect(result.ok).toBe(false);
expect(renderedText(result)).toContain("schema-mismatch");
expect(renderedText(result)).toContain("must include boolean timedOut and non-negative observed fields");
});
});
test("accepts 60m and rejects zero, values above 60m, and hour units before request", async () => {
let requests = 0;
await withManager((request) => {
requests += 1;
const url = new URL(request.url);
expect(url.searchParams.get("timeoutMs")).toBe("3600000");
return Response.json({ ok: true, data: { items: [], timedOut: true, observed: 0, nextAfterSeq: 0, completionReason: "timeout" } });
}, async () => {
const accepted = await runAgentRunCommand(null, ["events", `run/${RUN_ID}`, "--expect", "1", "--timeout", "60m", "-o", "json"]);
expect(accepted.ok).toBe(true);
expect(requests).toBe(1);
for (const invalidDuration of ["0ms", "61m", "1h"]) {
const invalid = await runAgentRunCommand(null, ["events", `run/${RUN_ID}`, "--expect", "1", "--timeout", invalidDuration, "-o", "json"]);
expect(invalid.ok).toBe(false);
}
expect(requests).toBe(1);
});
});
});
+1
View File
@@ -371,6 +371,7 @@ export function agentRunQuery(args: string[], names: string[]): string {
const params = new URLSearchParams();
const keyMap: Record<string, string> = {
"after-seq": "afterSeq",
"timeout-ms": "timeoutMs",
"backend-profile": "backendProfile",
"command": "commandId",
"command-id": "commandId",
+5 -4
View File
@@ -59,7 +59,7 @@ export function agentRunHelp(): unknown {
"bun scripts/cli.ts agentrun get tasks -o json",
"bun scripts/cli.ts agentrun describe task/<taskId>",
"bun scripts/cli.ts agentrun describe task/<taskId> --input -o json",
"bun scripts/cli.ts agentrun events run/<runId> --after-seq 0 --limit 100",
"bun scripts/cli.ts agentrun events run/<runId> --after-seq 0 --expect 10 --timeout 120s --limit 100",
"bun scripts/cli.ts agentrun events run/<runId> --detail-seq <seq>",
"bun scripts/cli.ts agentrun logs session/<sessionId> --tail 100",
"bun scripts/cli.ts agentrun result run/<runId> --command <commandId>",
@@ -292,9 +292,10 @@ export function agentRunHelpText(args: string[]): string {
}
if (verb === "events") {
return [
"Usage: bun scripts/cli.ts agentrun events run/<runId> [--after-seq N] [--limit 100] [-o json|yaml] [--full|--raw]",
"Usage: bun scripts/cli.ts agentrun events run/<runId> [--after-seq N] [--expect N [--timeout 120s]] [--limit 100] [-o json|yaml] [--full|--raw]",
" bun scripts/cli.ts agentrun events run/<runId> --detail-seq <seq> [-o json|yaml]",
"",
"--expect waits in one manager-held request until N new events, target completion, or timeout; --timeout defaults to 120s. --limit remains an independent output budget.",
"--detail-seq returns one bounded Secret-safe EventDetail projection. Use the separate --after-seq <seq-1> --limit 1 --full|--raw path only for explicit complete disclosure.",
].join("\n");
}
@@ -390,7 +391,7 @@ export function agentRunHelpText(args: string[]): string {
" bun scripts/cli.ts agentrun get tasks --queue commander --limit 20",
" bun scripts/cli.ts agentrun describe task/<taskId>",
" bun scripts/cli.ts agentrun describe run/<runId> --node NC01 --lane nc01-v02",
" bun scripts/cli.ts agentrun events run/<runId> --after-seq 0 --limit 100",
" bun scripts/cli.ts agentrun events run/<runId> --after-seq 0 --expect 10 --timeout 120s --limit 100",
" bun scripts/cli.ts agentrun logs session/<sessionId> --tail 100",
"",
"Use --raw on a resource command when you need the direct AgentRun REST envelope.",
@@ -407,7 +408,7 @@ export function agentRunHelpText(args: string[]): string {
" bun scripts/cli.ts agentrun describe task/<taskId>",
" bun scripts/cli.ts agentrun describe task/<taskId> --input -o json",
" bun scripts/cli.ts agentrun describe run/<runId> --node NC01 --lane nc01-v02",
" bun scripts/cli.ts agentrun events run/<runId> --after-seq 0 --limit 100",
" bun scripts/cli.ts agentrun events run/<runId> --after-seq 0 --expect 10 --timeout 120s --limit 100",
" bun scripts/cli.ts agentrun events run/<runId> --detail-seq <seq>",
" bun scripts/cli.ts agentrun logs session/<sessionId> --tail 100",
" bun scripts/cli.ts agentrun retry task/<taskId> --idempotency-key <key> --reason <text> --dry-run",
+11
View File
@@ -360,6 +360,13 @@ export interface EventLikePageDisclosure {
hasMore: boolean;
nextAfterSeq: number | string | null;
detailCommand: string;
wait: {
expect: number;
timeoutMs: number;
timedOut: boolean;
observed: number;
completionReason: string | null;
} | null;
}
export function renderEventLike(command: string, raw: Record<string, unknown>, options: AgentRunResourceOptions, kind: string, items: Record<string, unknown>[], sourceName: string, pageDisclosure: EventLikePageDisclosure | null = null): RenderedCliResult {
@@ -376,6 +383,7 @@ export function renderEventLike(command: string, raw: Record<string, unknown>, o
effectiveLimit: pageDisclosure.effectiveLimit,
fetchedCount: pageDisclosure.fetchedCount,
hasMore: pageDisclosure.hasMore,
...(pageDisclosure.wait === null ? {} : pageDisclosure.wait),
disclosure: {
output: "omitted; metadata only",
identity: "item.identity; detail --detail-seq item.seq",
@@ -415,6 +423,9 @@ export function renderEventLike(command: string, raw: Record<string, unknown>, o
])),
];
if (pageDisclosure !== null) lines.push(`Detail: ${pageDisclosure.detailCommand}`);
if (pageDisclosure?.wait !== null && pageDisclosure?.wait !== undefined) {
lines.push(`Wait: expect=${pageDisclosure.wait.expect} observed=${pageDisclosure.wait.observed} timedOut=${String(pageDisclosure.wait.timedOut)} timeoutMs=${pageDisclosure.wait.timeoutMs} nextAfterSeq=${String(nextAfterSeq ?? 0)}${pageDisclosure.wait.completionReason === null ? "" : ` reason=${pageDisclosure.wait.completionReason}`}`);
}
if (nextAfterSeq !== undefined && nextAfterSeq !== null) lines.push(`Next: bun scripts/cli.ts ${nextPagedResourceCommand(command, String(nextAfterSeq), options.limit)}`);
return renderedCliResult(raw.ok !== false, command, lines.join("\n"));
}
+70 -4
View File
@@ -178,6 +178,8 @@ export function parseResourceOptions(args: string[]): AgentRunResourceOptions {
commandId: null,
sessionId: null,
afterSeq: null,
expect: null,
timeoutMs: 120_000,
eventDetailSeq: null,
tail: null,
fullText: false,
@@ -196,7 +198,7 @@ export function parseResourceOptions(args: string[]): AgentRunResourceOptions {
mdtodoId: null,
passthroughArgs: [],
};
const valueFlags = new Set(["-o", "--output", "--limit", "--cursor", "--queue", "--state", "--reader-id", "--task", "--task-id", "--run", "--run-id", "--command", "--command-id", "--session", "--session-id", "--after-seq", "--detail-seq", "--tail", "--reason", "-f", "--file", "--filename", "--aipod", "--idempotency-key", "--node", "--lane", "--target", "--target-workspace", "--repo", "--ref", "--mdtodo-id"]);
const valueFlags = new Set(["-o", "--output", "--limit", "--cursor", "--queue", "--state", "--reader-id", "--task", "--task-id", "--run", "--run-id", "--command", "--command-id", "--session", "--session-id", "--after-seq", "--expect", "--timeout", "--detail-seq", "--tail", "--reason", "-f", "--file", "--filename", "--aipod", "--idempotency-key", "--node", "--lane", "--target", "--target-workspace", "--repo", "--ref", "--mdtodo-id"]);
const booleanFlags = new Set(["--full", "--raw", "--debug", "--input", "--unread", "--dry-run", "--full-text", "--prompt-stdin", "--stdin"]);
for (let index = 0; index < args.length; index += 1) {
const arg = args[index] ?? "";
@@ -243,7 +245,7 @@ export function parseResourceOptions(args: string[]): AgentRunResourceOptions {
);
}
if (options.eventDetailSeq !== null) {
const conflictingOptions = ["--after-seq", "--limit", "--full", "--raw"]
const conflictingOptions = ["--after-seq", "--expect", "--timeout", "--limit", "--full", "--raw"]
.filter((flag) => resourceOptionPresent(args, flag));
if (conflictingOptions.length > 0) {
throw new AgentRunRestError(
@@ -253,7 +255,7 @@ export function parseResourceOptions(args: string[]): AgentRunResourceOptions {
details: {
conflictingOptions: ["--detail-seq", ...conflictingOptions],
recoveryActions: [
"Use --detail-seq <seq> without --after-seq, --limit, --full, or --raw for the bounded Secret-safe EventDetail projection.",
"Use --detail-seq <seq> without --after-seq, --expect, --timeout, --limit, --full, or --raw for the bounded Secret-safe EventDetail projection.",
"Use --after-seq <seq-1> --limit 1 --full -o json or --raw only when explicitly requesting the complete durable event.",
],
valuesPrinted: false,
@@ -262,6 +264,18 @@ export function parseResourceOptions(args: string[]): AgentRunResourceOptions {
);
}
}
if (resourceOptionPresent(args, "--timeout") && options.expect === null) {
throw new AgentRunRestError(
"validation-failed",
"--timeout requires --expect <N>; timeout controls the manager-held long poll and is not a client-side polling interval.",
{
details: {
recoveryActions: ["Use --expect <N> [--timeout <duration>] or remove --timeout for an immediate paged read."],
valuesPrinted: false,
},
},
);
}
return options;
}
@@ -278,6 +292,18 @@ function validateResourceOptionsForVerb(verb: AgentRunResourceVerb, options: Age
},
);
}
if (options.expect !== null && verb !== "events") {
throw new AgentRunRestError(
"validation-failed",
"--expect and --timeout are supported only by agentrun events run/<runId>.",
{
details: {
recoveryActions: ["Use: bun scripts/cli.ts agentrun events run/<runId> --after-seq <N> --expect <N> [--timeout 120s]."],
valuesPrinted: false,
},
},
);
}
}
function resourceOptionPresent(args: string[], flag: string): boolean {
@@ -308,6 +334,8 @@ export function applyResourceOption(options: AgentRunResourceOptions, flag: stri
else if (flag === "--command" || flag === "--command-id") options.commandId = requiredValue(value, flag);
else if (flag === "--session" || flag === "--session-id") options.sessionId = requiredValue(value, flag);
else if (flag === "--after-seq") options.afterSeq = parseNonNegativeInt(value, "--after-seq", 0, Number.MAX_SAFE_INTEGER);
else if (flag === "--expect") options.expect = parsePositiveInt(value, "--expect");
else if (flag === "--timeout") options.timeoutMs = parseDurationMs(value, "--timeout");
else if (flag === "--detail-seq") options.eventDetailSeq = parsePositiveInt(value, "--detail-seq");
else if (flag === "--tail") options.tail = parseNonNegativeInt(value, "--tail", 100, 1000);
else if (flag === "--reason") options.reason = requiredValue(value, flag);
@@ -330,6 +358,17 @@ function parsePositiveInt(raw: string | null, flag: string): number {
return value;
}
export function parseDurationMs(raw: string | null, flag: string): number {
if (raw === null || raw.length === 0) throw new Error(`${flag} requires a duration`);
const match = /^(\d+)(ms|s|m)$/u.exec(raw.trim());
if (match === null) throw new Error(`${flag} must use a positive integer duration with ms, s, or m units, such as 500ms, 120s, or 3m`);
const amount = Number(match[1]);
const multiplier = match[2] === "ms" ? 1 : match[2] === "s" ? 1_000 : 60_000;
const value = amount * multiplier;
if (!Number.isSafeInteger(value) || value < 1 || value > 3_600_000) throw new Error(`${flag} must be between 1ms and 60m`);
return value;
}
export function parseNonNegativeInt(raw: string | null, flag: string, defaultValue: number, maxValue: number): number {
if (raw === null || raw.length === 0) return defaultValue;
const value = Number(raw);
@@ -607,6 +646,7 @@ export async function resourceEvents(config: UniDeskConfig | null, command: stri
const effectiveLimit = options.full || options.raw ? requestedLimit : Math.min(requestedLimit, 20);
const requestLimit = options.full || options.raw ? effectiveLimit : Math.min(500, effectiveLimit + 1);
const eventArgs = ["events", runId, "--after-seq", String(options.afterSeq ?? 0), "--limit", String(requestLimit)];
if (options.expect !== null) eventArgs.push("--expect", String(options.expect), "--timeout-ms", String(options.timeoutMs));
const result = await runAgentRunRestCommand(config, "runs", eventArgs);
if (options.raw) return renderMachine(command, result, "json", result.ok !== false);
if (options.full) return renderMachine(command, result, options.output === "yaml" ? "yaml" : "json", result.ok !== false);
@@ -616,7 +656,32 @@ export async function resourceEvents(config: UniDeskConfig | null, command: stri
const hasMore = fetchedItems.length > visibleItems.length;
const lastVisibleSeq = visibleItems.length === 0 ? null : nonNegativeIntegerOrNull(visibleItems.at(-1)?.seq);
const responseNextAfterSeq = nonNegativeIntegerOrNull(record(innerData(result)).nextAfterSeq);
const nextAfterSeq = hasMore ? lastVisibleSeq : responseNextAfterSeq;
const nextAfterSeq = hasMore ? lastVisibleSeq : responseNextAfterSeq ?? options.afterSeq ?? 0;
const waitData = record(innerData(result));
const observed = nonNegativeIntegerOrNull(waitData.observed);
if (options.expect !== null && (typeof waitData.timedOut !== "boolean" || observed === null)) {
throw new AgentRunRestError(
"schema-mismatch",
"AgentRun manager long-poll response must include boolean timedOut and non-negative observed fields.",
{
details: {
runId,
expect: options.expect,
timeoutMs: options.timeoutMs,
returnedTimedOutType: typeof waitData.timedOut,
returnedObserved: waitData.observed ?? null,
valuesPrinted: false,
},
},
);
}
const waitDisclosure = options.expect === null ? null : {
expect: options.expect,
timeoutMs: options.timeoutMs,
timedOut: waitData.timedOut === true,
observed: observed ?? fetchedItems.length,
completionReason: stringOrNull(waitData.completionReason) ?? stringOrNull(waitData.reason),
};
const targetArgs = [
options.node === null ? null : `--node ${options.node}`,
options.lane === null ? null : `--lane ${options.lane}`,
@@ -629,6 +694,7 @@ export async function resourceEvents(config: UniDeskConfig | null, command: stri
hasMore,
nextAfterSeq,
detailCommand,
wait: waitDisclosure,
});
}
+17 -7
View File
@@ -523,7 +523,16 @@ export async function runAgentRunSessionsRest(action: string | undefined, id: st
export async function runAgentRunRunsRest(action: string | undefined, id: string | undefined, args: string[]): Promise<Record<string, unknown>> {
if (action === "create") return await agentRunRestRequest("agentrun runs create", "POST", "/api/v1/runs", await requiredJsonBody(args, "runs create"));
if (action === "show" && id) return await agentRunRestRequest("agentrun runs show", "GET", `/api/v1/runs/${encodeURIComponent(id)}`);
if (action === "events" && id) return await agentRunRestRequest("agentrun runs events", "GET", `/api/v1/runs/${encodeURIComponent(id)}/events${agentRunQuery(args, ["after-seq", "limit"])}`);
if (action === "events" && id) {
const timeoutMs = Number(agentRunOption(args, "timeout-ms") ?? "0");
return await agentRunRestRequest(
"agentrun runs events",
"GET",
`/api/v1/runs/${encodeURIComponent(id)}/events${agentRunQuery(args, ["after-seq", "expect", "timeout-ms", "limit"])}`,
undefined,
Number.isSafeInteger(timeoutMs) && timeoutMs > 0 ? timeoutMs + 5_000 : undefined,
);
}
if (action === "result" && id) return await agentRunRestRequest("agentrun runs result", "GET", `/api/v1/runs/${encodeURIComponent(id)}/result${agentRunQuery(args, ["command-id", "command"])}`);
if (action === "cancel" && id) return await agentRunRestRequest("agentrun runs cancel", "POST", `/api/v1/runs/${encodeURIComponent(id)}/cancel`, cancelBodyFromArgs(args));
throw new AgentRunRestError("validation-failed", `unsupported runs command: ${[action, id].filter(Boolean).join(" ") || "(empty)"}`);
@@ -1157,14 +1166,15 @@ export async function sessionRunnerJobBody(args: string[], defaults: Record<stri
return runnerBody;
}
export async function agentRunRestRequest(command: string, method: AgentRunHttpMethod, pathValue: string, body?: unknown): Promise<Record<string, unknown>> {
export async function agentRunRestRequest(command: string, method: AgentRunHttpMethod, pathValue: string, body?: unknown, requestTimeoutMs?: number): Promise<Record<string, unknown>> {
const clientConfig = readAgentRunClientConfig();
if (activeAgentRunRestTarget !== null) return await agentRunLaneRestRequest(command, method, pathValue, body, clientConfig, activeAgentRunRestTarget);
const effectiveTimeoutMs = Math.max(clientConfig.manager.timeoutMs, requestTimeoutMs ?? 0);
if (activeAgentRunRestTarget !== null) return await agentRunLaneRestRequest(command, method, pathValue, body, clientConfig, activeAgentRunRestTarget, effectiveTimeoutMs);
const auth = resolveAgentRunAuth(clientConfig);
const bridgeBase = agentRunRestBridgeMetadata(clientConfig, auth, method, pathValue);
const startedAt = Date.now();
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), clientConfig.manager.timeoutMs);
const timeout = setTimeout(() => controller.abort(), effectiveTimeoutMs);
let response: Response;
try {
const headers: Record<string, string> = {
@@ -1178,7 +1188,7 @@ export async function agentRunRestRequest(command: string, method: AgentRunHttpM
response = await fetch(new URL(pathValue, clientConfig.manager.baseUrl), init);
} catch (error) {
const timedOut = isAbortLikeError(error);
throw new AgentRunRestError(timedOut ? "agentrun-timeout" : "agentrun-connect-failed", timedOut ? `AgentRun server request timed out for ${method} ${pathValue} after ${clientConfig.manager.timeoutMs}ms` : `AgentRun server connection failed for ${method} ${pathValue}: ${error instanceof Error ? error.message : String(error)}`, { bridge: { ...bridgeBase, elapsedMs: Date.now() - startedAt } });
throw new AgentRunRestError(timedOut ? "agentrun-timeout" : "agentrun-connect-failed", timedOut ? `AgentRun server request timed out for ${method} ${pathValue} after ${effectiveTimeoutMs}ms` : `AgentRun server connection failed for ${method} ${pathValue}: ${error instanceof Error ? error.message : String(error)}`, { bridge: { ...bridgeBase, elapsedMs: Date.now() - startedAt } });
} finally {
clearTimeout(timeout);
}
@@ -1215,7 +1225,7 @@ export function isAbortLikeError(error: unknown): boolean {
return error.name === "AbortError" || /abort|timed out|timeout/iu.test(error.message);
}
export async function agentRunLaneRestRequest(command: string, method: AgentRunHttpMethod, pathValue: string, body: unknown, clientConfig: AgentRunClientConfig, target: AgentRunRestTarget): Promise<Record<string, unknown>> {
export async function agentRunLaneRestRequest(command: string, method: AgentRunHttpMethod, pathValue: string, body: unknown, clientConfig: AgentRunClientConfig, target: AgentRunRestTarget, requestTimeoutMs = clientConfig.manager.timeoutMs): Promise<Record<string, unknown>> {
const bridgeBase = agentRunLaneRestBridgeMetadata(clientConfig, target, method, pathValue);
const startedAt = Date.now();
const proxyBaseUrl = `http://127.0.0.1:${target.spec.runtime.managerPort}`;
@@ -1225,7 +1235,7 @@ export async function agentRunLaneRestRequest(command: string, method: AgentRunH
body: body ?? null,
baseUrl: proxyBaseUrl,
serviceBaseUrl: target.spec.runtime.internalBaseUrl,
timeoutMs: clientConfig.manager.timeoutMs,
timeoutMs: requestTimeoutMs,
authEnv: clientConfig.auth.env,
header: clientConfig.auth.header,
scheme: clientConfig.auth.scheme,
+2
View File
@@ -76,6 +76,8 @@ export interface AgentRunResourceOptions {
commandId: string | null;
sessionId: string | null;
afterSeq: number | null;
expect: number | null;
timeoutMs: number;
eventDetailSeq: number | null;
tail: number | null;
fullText: boolean;
@@ -0,0 +1,153 @@
import { describe, expect, test } from "bun:test";
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { resolve } from "node:path";
import { renderPikaoaTestDesiredPipeline } from "./pikaoa-test-delivery-renderer";
function pacDocument(): Record<string, unknown> {
return Bun.YAML.parse(readFileSync(resolve(import.meta.dir, "../../config/platform-infra/pipelines-as-code.yaml"), "utf8")) as Record<string, unknown>;
}
function rendererBinding(id = "pikaoa-test-nc01"): Parameters<typeof renderPikaoaTestDesiredPipeline>[0] {
const document = pacDocument();
const repositories = document.repositories as Array<Record<string, unknown>>;
const consumers = document.consumers as Array<Record<string, unknown>>;
const consumer = consumers.find((item) => item.id === id);
const repository = repositories.find((item) => item.id === consumer?.repositoryRef);
if (repository === undefined || consumer === undefined) throw new Error(`PikaOA PaC fixture is required: ${id}`);
return {
consumer,
repository: {
...repository,
params: {
...(repository.params as Record<string, unknown>),
...((consumer.params as Record<string, unknown> | undefined) ?? {}),
},
},
} as Parameters<typeof renderPikaoaTestDesiredPipeline>[0];
}
function sourceFixture(): string {
const root = mkdtempSync(resolve(tmpdir(), "pikaoa-test-renderer-"));
mkdirSync(resolve(root, "deploy"), { recursive: true });
for (const file of ["api.Dockerfile", "worker.Dockerfile", "web.Dockerfile"]) writeFileSync(resolve(root, "deploy", file), "FROM scratch\n");
return root;
}
describe("PikaOA test PaC renderer", () => {
test("shares one PaC repository while isolating master and release consumers", () => {
const document = pacDocument();
const repositories = document.repositories as Array<Record<string, unknown>>;
const consumers = document.consumers as Array<Record<string, unknown>>;
const repository = repositories.find((item) => item.id === "pikaoa-test-nc01");
const testConsumer = consumers.find((item) => item.id === "pikaoa-test-nc01");
const productionConsumer = consumers.find((item) => item.id === "pikaoa-nc01");
const duplicateProductionRepository = repositories.find((item) => item.id === "pikaoa-nc01");
expect((repository?.params as Record<string, unknown>).source_branch).toBe("master");
expect((testConsumer?.sourceArtifact as Record<string, unknown>).pipelineRunPath).toBe(".tekton/pikaoa-test-nc01-pac.yaml");
expect((testConsumer?.sourceArtifact as Record<string, unknown>).renderer).toBe("pikaoa-test-runtime");
expect((productionConsumer?.params as Record<string, unknown>).source_branch).toBe("release");
expect((productionConsumer?.params as Record<string, unknown>).source_snapshot_prefix).toBe("refs/unidesk/snapshots/gitea-actions/pikaoa-release-nc01");
expect(productionConsumer?.repositoryRef).toBe("pikaoa-test-nc01");
expect(duplicateProductionRepository).toBeUndefined();
expect((productionConsumer?.sourceArtifact as Record<string, unknown>).renderer).toBe("pikaoa-release-runtime");
expect((productionConsumer?.sourceArtifact as Record<string, unknown>).configRef).toBe("config/pikaoa.yaml#releaseRuntime.targets.NC01");
});
test("renders release runtime from its isolated owning selector", () => {
const source = sourceFixture();
try {
const rendered = renderPikaoaTestDesiredPipeline(rendererBinding("pikaoa-nc01"), source);
expect(rendered.configRef).toBe("config/pikaoa.yaml#releaseRuntime.targets.NC01");
const serialized = JSON.stringify(rendered.pipeline);
expect(serialized).toContain("pikaoa-nc01-pac");
expect(serialized).toContain("refs/unidesk/snapshots/gitea-actions/pikaoa-release-nc01");
expect(serialized).toContain("pac-gitea-pikaoa-nc01");
expect(serialized).not.toContain("pikaoa-test-nc01-pac");
} finally {
rmSync(source, { recursive: true, force: true });
}
});
test("renders parallel digest builds and a PreSync fresh database initializer", () => {
const source = sourceFixture();
try {
const rendered = renderPikaoaTestDesiredPipeline(rendererBinding(), source);
const spec = rendered.pipeline.spec as Record<string, unknown>;
const tasks = spec.tasks as Array<Record<string, unknown>>;
for (const task of tasks) {
const taskSpec = task.taskSpec as Record<string, unknown>;
expect(taskSpec.workspaces).toEqual([{ name: "workspace", mountPath: "/workspace" }]);
const steps = taskSpec.steps as Array<Record<string, unknown>>;
for (const step of steps) {
const mounts = (step.volumeMounts ?? []) as Array<Record<string, unknown>>;
expect(mounts.some((mount) => mount.name === "workspace")).toBe(false);
}
}
for (const name of ["build-api", "build-worker", "build-web"]) {
const task = tasks.find((item) => item.name === name);
expect(task?.runAfter).toEqual(["source"]);
expect(JSON.stringify(task)).toContain("buildctl-daemonless.sh build");
expect(JSON.stringify(task)).toContain("$(params.revision)");
expect(JSON.stringify(task)).not.toContain("source-token");
const buildScript = (((task?.taskSpec as Record<string, unknown>).steps as Array<Record<string, unknown>>)[0]?.script) as string;
expect(buildScript).toContain('"containerimage.digest"[[:space:]]*:[[:space:]]*"\\(sha256:[0-9a-f]\\{64\\}\\)"');
expect(buildScript).toContain(".*/\\1/p");
expect(buildScript).not.toContain("\u0001");
expect(buildScript).toContain("Docker-Content-Digest:");
expect(buildScript).toContain("build_status=$?");
expect(buildScript).toContain('"code":"buildctl-nonzero-artifact-verified"');
expect(buildScript).toContain('"artifactVerified":true');
}
const digest = "sha256:" + "a".repeat(64);
const metadata = JSON.stringify({ "containerimage.digest": digest }, null, 2);
const parsedDigest = /"containerimage\.digest"\s*:\s*"(sha256:[0-9a-f]{64})"/u.exec(metadata)?.[1];
expect(parsedDigest).toBe(digest);
const sourceTask = tasks.find((item) => item.name === "source");
expect(JSON.stringify(sourceTask)).toContain("source-token");
expect(JSON.stringify(sourceTask)).toContain("GIT_ASKPASS");
expect(JSON.stringify(sourceTask)).toContain("$(params.gitops-secret-name)");
for (const task of tasks) {
const taskSpec = task.taskSpec as Record<string, unknown> | undefined;
if (taskSpec === undefined) continue;
expect(taskSpec.workspaces).toEqual([{ name: "workspace", mountPath: "/workspace" }]);
const steps = taskSpec.steps as Array<Record<string, unknown>>;
for (const step of steps) {
expect((step.volumeMounts as Array<Record<string, unknown>> | undefined)?.some((mount) => mount.name === "workspace") ?? false).toBe(false);
}
}
const publish = tasks.find((item) => item.name === "gitops-publish");
expect(publish?.runAfter).toEqual(["build-api", "build-worker", "build-web"]);
const script = ((((publish?.taskSpec as Record<string, unknown>).steps as Array<Record<string, unknown>>)[0]?.script) as string);
for (const evidence of [
'"status":"published"',
'"registryVerified":true',
'"publishedCount":3',
'"requiredServiceCount":3',
'"gitopsCommit"',
'"service":"api"',
'"service":"worker"',
'"service":"web"',
]) expect(script).toContain(evidence);
const encoded = /printf '%s' '([A-Za-z0-9+/=]+)' \| base64 -d/u.exec(script)?.[1];
if (encoded === undefined) throw new Error("embedded GitOps manifest is required");
const manifest = Buffer.from(encoded, "base64").toString("utf8");
expect(manifest).toContain("argocd.argoproj.io/hook: PreSync");
expect(manifest).toContain("name: pikaoa-init");
expect(manifest).toContain("name: initializer");
expect(manifest).not.toContain("kind: Secret");
expect(manifest).toContain("secretName: pikaoa-test-runtime");
expect(manifest).toContain("image: __PIKAOA_API_IMAGE__");
expect(manifest).toContain("pikaoa.unidesk.io/source-commit: __PIKAOA_SOURCE_COMMIT__");
expect(script).toContain('s|__PIKAOA_SOURCE_COMMIT__|$SOURCE_COMMIT|g');
expect(script).toContain("GitOps manifest contains unresolved provenance or image placeholders");
expect(script).not.toContain("grep -Eq '$(params.revision)");
expect(script).toContain("grep -Eq '__PIKAOA_SOURCE_COMMIT__|__PIKAOA_(API|WORKER|WEB)_IMAGE__'");
expect(script).toContain("git ls-remote --exit-code --heads");
expect(script).toContain("git -C /workspace/gitops checkout --orphan");
} finally {
rmSync(source, { recursive: true, force: true });
}
});
});
@@ -0,0 +1,379 @@
import { existsSync } from "node:fs";
import { resolve } from "node:path";
import {
pikaoaTestRuntimeConfigRef,
pikaoaReleaseRuntimeConfigRef,
resolvePikaoaReleaseRuntimeTargetByConfigRef,
resolvePikaoaTestRuntimeTargetByConfigRef,
type TestTargetSpec,
} from "./pikaoa-test-target";
import { renderPikaoaTestRuntimeManifest, type PikaoaTestRenderContext } from "./pikaoa-test-runtime-manifest";
import { stableJsonSha256 } from "./stable-json";
export interface PikaoaTestRendererBinding {
readonly consumer: {
readonly id: string;
readonly node: string;
readonly lane: string;
readonly namespace: string;
readonly pipeline: string;
readonly pipelineRunPrefix: string;
readonly sourceArtifact: {
readonly configRef: string;
readonly mode: string;
readonly renderer: string;
};
};
readonly repository: {
readonly id: string;
readonly params: Readonly<Record<string, string>>;
};
}
export interface PikaoaTestRenderedPipeline {
readonly pipeline: Record<string, unknown>;
readonly configRef: string;
readonly effectiveConfigSha256: string;
readonly sourceWorktreeRemote: string;
}
export function renderPikaoaTestDesiredPipeline(binding: PikaoaTestRendererBinding, sourceWorktree: string): PikaoaTestRenderedPipeline {
const release = binding.consumer.sourceArtifact.renderer === "pikaoa-release-runtime";
const target = release
? resolvePikaoaReleaseRuntimeTargetByConfigRef(binding.consumer.sourceArtifact.configRef)
: resolvePikaoaTestRuntimeTargetByConfigRef(binding.consumer.sourceArtifact.configRef);
const configRef = release ? pikaoaReleaseRuntimeConfigRef(target.id) : pikaoaTestRuntimeConfigRef(target.id);
if ((!release && binding.consumer.sourceArtifact.renderer !== "pikaoa-test-runtime") || binding.consumer.sourceArtifact.mode !== "embedded-pipeline-spec") {
throw new Error(`${binding.consumer.sourceArtifact.renderer} requires embedded-pipeline-spec`);
}
if (binding.consumer.sourceArtifact.configRef !== configRef) {
throw new Error(`sourceArtifact.configRef must equal resolved owning selector ${configRef}`);
}
assertBinding(target, binding);
assertSourceRepositoryContract(target, sourceWorktree);
return {
pipeline: pipeline(target),
configRef,
effectiveConfigSha256: stableJsonSha256(target),
sourceWorktreeRemote: target.source.worktreeRemote,
};
}
export function pikaoaTestSourceWorktreeRemote(targetId: string): string {
return resolvePikaoaTestRuntimeTargetByConfigRef(pikaoaTestRuntimeConfigRef(targetId)).source.worktreeRemote;
}
export function pikaoaReleaseSourceWorktreeRemote(targetId: string): string {
return resolvePikaoaReleaseRuntimeTargetByConfigRef(pikaoaReleaseRuntimeConfigRef(targetId)).source.worktreeRemote;
}
function pipeline(target: TestTargetSpec): Record<string, unknown> {
const runtimeManifest = renderGitOpsManifest(target);
return {
apiVersion: "tekton.dev/v1",
kind: "Pipeline",
metadata: { name: target.ci.pipeline, namespace: target.ci.namespace },
spec: {
params: [
{ name: "revision", type: "string" },
{ name: "source-snapshot-prefix", type: "string", default: target.source.snapshotPrefix },
{ name: "git-read-url", type: "string", default: target.source.readUrl },
{ name: "gitops-read-url", type: "string", default: target.gitops.readUrl },
{ name: "gitops-write-url", type: "string", default: target.gitops.writeUrl },
{ name: "gitops-username", type: "string", default: target.gitops.credentialUsername },
{ name: "gitops-secret-name", type: "string", default: target.gitops.credentialSecretName },
],
workspaces: [{ name: "workspace" }],
tasks: [
sourceTask(target),
imageBuildTask(target, "api"),
imageBuildTask(target, "worker"),
imageBuildTask(target, "web"),
gitOpsTask(target, runtimeManifest),
],
},
};
}
function sourceTask(target: TestTargetSpec): Record<string, unknown> {
return {
name: "source",
taskSpec: {
params: [
{ name: "revision", type: "string" },
{ name: "source-snapshot-prefix", type: "string" },
{ name: "git-read-url", type: "string" },
{ name: "gitops-username", type: "string" },
{ name: "gitops-secret-name", type: "string" },
],
workspaces: [{ name: "workspace", mountPath: "/workspace" }],
steps: [{
name: "checkout",
image: target.ci.toolsImage,
imagePullPolicy: "IfNotPresent",
script: `#!/bin/sh
set -eu
revision="$(params.revision)"
case "$revision" in *[!0-9a-f]*|'') echo 'revision must be a full lowercase source commit' >&2; exit 2;; esac
test "\${#revision}" -eq 40
askpass=/tmp/pikaoa-source-git-askpass
cat >"$askpass" <<'ASKPASS'
#!/bin/sh
case "$1" in
*Username*) printf '%s' "$PIKAOA_GIT_USERNAME" ;;
*Password*) cat /var/run/pikaoa-source/token ;;
*) exit 1 ;;
esac
ASKPASS
chmod 700 "$askpass"
export PIKAOA_GIT_USERNAME="$(params.gitops-username)"
export GIT_ASKPASS="$askpass"
export GIT_TERMINAL_PROMPT=0
rm -rf /workspace/source
git init /workspace/source
git -C /workspace/source remote add origin "$(params.git-read-url)"
git -C /workspace/source fetch --depth=1 origin "$(params.source-snapshot-prefix)/$revision"
git -C /workspace/source checkout --detach FETCH_HEAD
test "$(git -C /workspace/source rev-parse HEAD)" = "$revision"
rm -f "$askpass"
printf '{"ok":true,"phase":"source","sourceCommit":"%s","valuesPrinted":false}\n' "$revision"
`,
securityContext: nonRootSecurity(),
volumeMounts: [
{ name: "source-token", mountPath: "/var/run/pikaoa-source", readOnly: true },
],
}],
volumes: [{ name: "source-token", secret: { secretName: "$(params.gitops-secret-name)", items: [{ key: target.gitops.credentialTokenKey, path: "token" }] } }],
},
params: [
{ name: "revision", value: "$(params.revision)" },
{ name: "source-snapshot-prefix", value: "$(params.source-snapshot-prefix)" },
{ name: "git-read-url", value: "$(params.git-read-url)" },
{ name: "gitops-username", value: "$(params.gitops-username)" },
{ name: "gitops-secret-name", value: "$(params.gitops-secret-name)" },
],
workspaces: [{ name: "workspace", workspace: "workspace" }],
};
}
function imageBuildTask(target: TestTargetSpec, component: "api" | "worker" | "web"): Record<string, unknown> {
const taskName = `build-${component}`;
const imageRepository = target.build.images[component];
const dockerfile = target.build.dockerfiles[component];
return {
name: taskName,
runAfter: ["source"],
taskSpec: {
params: [{ name: "revision", type: "string" }],
workspaces: [{ name: "workspace", mountPath: "/workspace" }],
results: [{ name: "digest", type: "string" }, { name: "image", type: "string" }],
steps: [{
name: "build",
image: target.ci.buildkitImage,
imagePullPolicy: "IfNotPresent",
workingDir: "/workspace/source",
env: [{ name: "BUILDKITD_FLAGS", value: "--oci-worker-no-process-sandbox --oci-worker-net=host --allow-insecure-entitlement network.host" }],
script: `#!/bin/sh
set -eu
revision="$(params.revision)"
tag=${shellSingleQuote(imageRepository)}:"$revision"
metadata=/tmp/${component}-metadata.json
set +e
buildctl-daemonless.sh build \\
--frontend dockerfile.v0 \\
--local context=. \\
--local dockerfile=. \\
--opt filename=${shellSingleQuote(dockerfile)} \\
--opt network=${shellSingleQuote(target.build.networkMode)} \\
--output "type=image,name=$tag,push=true" \\
--metadata-file "$metadata"
build_status=$?
set -e
metadata_compact=$(tr -d '\\n\\r' < "$metadata")
digest=$(printf '%s' "$metadata_compact" | sed -n 's/.*"containerimage.digest"[[:space:]]*:[[:space:]]*"\\(sha256:[0-9a-f]\\{64\\}\\)".*/\\1/p' | head -n1)
if ! printf '%s' "$digest" | grep -Eq '^sha256:[0-9a-f]{64}$'; then
registry_host=${shellSingleQuote(imageRepository.split("/")[0] ?? "")}
registry_path=${shellSingleQuote(imageRepository.split("/").slice(1).join("/"))}
headers=$(wget --server-response --spider --header='Accept: application/vnd.oci.image.manifest.v1+json, application/vnd.docker.distribution.manifest.v2+json' "http://$registry_host/v2/$registry_path/manifests/$revision" 2>&1 || true)
digest=$(printf '%s\\n' "$headers" | awk 'BEGIN{IGNORECASE=1} /^[[:space:]]*Docker-Content-Digest:/ {gsub(/\\r/, "", $2); print $2; exit}')
fi
case "$digest" in sha256:[0-9a-f][0-9a-f]*) test "\${#digest}" -eq 71 ;; *) echo 'build digest missing from metadata and registry manifest' >&2; exit 3;; esac
if [ "$build_status" -ne 0 ]; then
printf '{"level":"warning","code":"buildctl-nonzero-artifact-verified","component":"${component}","buildctlExitCode":%s,"artifactVerified":true,"valuesPrinted":false}\\n' "$build_status" >&2
fi
printf '%s' "$digest" > "$(results.digest.path)"
printf '%s@%s' ${shellSingleQuote(imageRepository)} "$digest" > "$(results.image.path)"
printf '{"ok":true,"phase":"${taskName}","sourceCommit":"%s","imageTag":"%s","digest":"%s","valuesPrinted":false}\n' "$revision" "$tag" "$digest"
`,
securityContext: { privileged: true, runAsUser: 1000, runAsGroup: 1000 },
}],
},
params: [{ name: "revision", value: "$(params.revision)" }],
workspaces: [{ name: "workspace", workspace: "workspace" }],
};
}
function gitOpsTask(target: TestTargetSpec, runtimeManifest: string): Record<string, unknown> {
const manifestB64 = Buffer.from(runtimeManifest, "utf8").toString("base64");
return {
name: "gitops-publish",
runAfter: ["build-api", "build-worker", "build-web"],
taskSpec: {
params: [
{ name: "revision", type: "string" },
{ name: "gitops-read-url", type: "string" },
{ name: "gitops-write-url", type: "string" },
{ name: "gitops-username", type: "string" },
{ name: "gitops-secret-name", type: "string" },
{ name: "api-image", type: "string" },
{ name: "worker-image", type: "string" },
{ name: "web-image", type: "string" },
],
workspaces: [{ name: "workspace", mountPath: "/workspace" }],
steps: [{
name: "publish",
image: target.ci.toolsImage,
imagePullPolicy: "IfNotPresent",
env: [{ name: "SOURCE_COMMIT", value: "$(params.revision)" }],
script: `#!/bin/sh
set -eu
askpass=/tmp/pikaoa-git-askpass
cat >"$askpass" <<'ASKPASS'
#!/bin/sh
case "$1" in
*Username*) printf '%s' "$PIKAOA_GIT_USERNAME" ;;
*Password*) cat /var/run/pikaoa-gitops/token ;;
*) exit 1 ;;
esac
ASKPASS
chmod 700 "$askpass"
export PIKAOA_GIT_USERNAME="$(params.gitops-username)"
export GIT_ASKPASS="$askpass"
export GIT_TERMINAL_PROMPT=0
case "$SOURCE_COMMIT" in *[!0-9a-f]*|'') echo 'source commit must be a full lowercase commit' >&2; exit 2;; esac
test "\${#SOURCE_COMMIT}" -eq 40
api_image="$(params.api-image)"
worker_image="$(params.worker-image)"
web_image="$(params.web-image)"
for image in "$api_image" "$worker_image" "$web_image"; do
case "$image" in *@sha256:[0-9a-f]*) ;; *) echo 'required digestRef missing' >&2; exit 4;; esac
done
rm -rf /workspace/gitops
mkdir -p /workspace/gitops
git -C /workspace/gitops init
git -C /workspace/gitops remote add origin "$(params.gitops-read-url)"
if git ls-remote --exit-code --heads "$(params.gitops-read-url)" ${shellSingleQuote(target.gitops.branch)} >/dev/null 2>&1; then
git -C /workspace/gitops fetch --depth=1 origin ${shellSingleQuote(target.gitops.branch)}
git -C /workspace/gitops checkout -B ${shellSingleQuote(target.gitops.branch)} FETCH_HEAD
else
git -C /workspace/gitops checkout --orphan ${shellSingleQuote(target.gitops.branch)}
git -C /workspace/gitops rm -rf . >/dev/null 2>&1 || true
fi
manifest=/workspace/gitops/${shellSingleQuote(target.gitops.manifestPath)}
mkdir -p "$(dirname "$manifest")"
printf '%s' ${shellSingleQuote(manifestB64)} | base64 -d > "$manifest"
sed -i \\
-e "s|__PIKAOA_SOURCE_COMMIT__|$SOURCE_COMMIT|g" \\
-e "s|__PIKAOA_API_IMAGE__|$(params.api-image)|g" \\
-e "s|__PIKAOA_WORKER_IMAGE__|$(params.worker-image)|g" \\
-e "s|__PIKAOA_WEB_IMAGE__|$(params.web-image)|g" \\
"$manifest"
if grep -Eq '__PIKAOA_SOURCE_COMMIT__|__PIKAOA_(API|WORKER|WEB)_IMAGE__' "$manifest"; then
echo 'GitOps manifest contains unresolved provenance or image placeholders' >&2
exit 6
fi
git -C /workspace/gitops config user.name ${shellSingleQuote(target.gitops.authorName)}
git -C /workspace/gitops config user.email ${shellSingleQuote(target.gitops.authorEmail)}
git -C /workspace/gitops add -- ${shellSingleQuote(target.gitops.manifestPath)}
if git -C /workspace/gitops diff --cached --quiet; then
changed=false
else
git -C /workspace/gitops commit -m "chore(gitops): deploy pikaoa $SOURCE_COMMIT"
git -C /workspace/gitops push "$(params.gitops-write-url)" HEAD:${shellSingleQuote(target.gitops.branch)}
changed=true
fi
gitops_commit=$(git -C /workspace/gitops rev-parse HEAD)
case "$gitops_commit" in [0-9a-f][0-9a-f][0-9a-f][0-9a-f]*) ;; *) echo 'gitops commit missing' >&2; exit 5;; esac
rm -f "$askpass"
printf '{"ok":true,"status":"published","phase":"gitops-publish","sourceCommitId":"%s","registryVerified":true,"publishedCount":3,"reusedCount":0,"requiredServiceCount":3,"services":[{"service":"api","digestRef":"%s","digest":"%s"},{"service":"worker","digestRef":"%s","digest":"%s"},{"service":"web","digestRef":"%s","digest":"%s"}],"gitopsCommit":"%s","changed":%s,"valuesPrinted":false}\n' \
"$SOURCE_COMMIT" "$api_image" "\${api_image##*@}" "$worker_image" "\${worker_image##*@}" "$web_image" "\${web_image##*@}" "$gitops_commit" "$changed"
`,
securityContext: nonRootSecurity(),
volumeMounts: [
{ name: "gitops-token", mountPath: "/var/run/pikaoa-gitops", readOnly: true },
],
}],
volumes: [{ name: "gitops-token", secret: { secretName: "$(params.gitops-secret-name)", items: [{ key: target.gitops.credentialTokenKey, path: "token" }] } }],
},
params: [
{ name: "revision", value: "$(params.revision)" },
{ name: "gitops-read-url", value: "$(params.gitops-read-url)" },
{ name: "gitops-write-url", value: "$(params.gitops-write-url)" },
{ name: "gitops-username", value: "$(params.gitops-username)" },
{ name: "gitops-secret-name", value: "$(params.gitops-secret-name)" },
{ name: "api-image", value: "$(tasks.build-api.results.image)" },
{ name: "worker-image", value: "$(tasks.build-worker.results.image)" },
{ name: "web-image", value: "$(tasks.build-web.results.image)" },
],
workspaces: [{ name: "workspace", workspace: "workspace" }],
};
}
function renderGitOpsManifest(target: TestTargetSpec): string {
const context: PikaoaTestRenderContext = {
instanceId: "default",
commit: "__PIKAOA_SOURCE_COMMIT__",
step: "all",
namespace: target.namespace,
expiresAt: "gitops-managed",
apiImage: "__PIKAOA_API_IMAGE__",
workerImage: "__PIKAOA_WORKER_IMAGE__",
webImage: "__PIKAOA_WEB_IMAGE__",
initializerImage: "__PIKAOA_API_IMAGE__",
};
const manifest = renderPikaoaTestRuntimeManifest(target, context, { secretMode: "existing", initializerHook: "argo-presync" });
return manifest.map((object) => Bun.YAML.stringify(object, null, 2).trim()).join("\n---\n") + "\n";
}
function assertBinding(target: TestTargetSpec, binding: PikaoaTestRendererBinding): void {
const expected: Readonly<Record<string, string>> = {
id: target.source.branch === "release" ? "pikaoa-nc01" : "pikaoa-test-nc01",
node: target.node,
lane: target.ci.lane,
namespace: target.ci.namespace,
pipeline: target.ci.pipeline,
pipelineRunPrefix: target.ci.pipelineRunPrefix,
sourceBranch: target.source.branch,
gitopsBranch: target.gitops.branch,
serviceAccount: target.ci.serviceAccountName,
};
const actual: Readonly<Record<string, string | undefined>> = {
id: binding.consumer.id,
node: binding.consumer.node,
lane: binding.consumer.lane,
namespace: binding.consumer.namespace,
pipeline: binding.consumer.pipeline,
pipelineRunPrefix: binding.consumer.pipelineRunPrefix,
sourceBranch: binding.repository.params.source_branch,
gitopsBranch: binding.repository.params.gitops_branch,
serviceAccount: binding.repository.params.service_account,
};
for (const [key, value] of Object.entries(expected)) {
if (actual[key] !== value) throw new Error(`PikaOA runtime binding ${key} must equal owning YAML value ${value}`);
}
}
function assertSourceRepositoryContract(target: TestTargetSpec, sourceWorktree: string): void {
for (const path of Object.values(target.build.dockerfiles)) {
if (!existsSync(resolve(sourceWorktree, path))) throw new Error(`PikaOA source worktree is missing ${path}`);
}
}
function nonRootSecurity(): Record<string, unknown> {
return { allowPrivilegeEscalation: false, runAsNonRoot: true, runAsUser: 1000, runAsGroup: 1000 };
}
function shellSingleQuote(value: string): string {
return `'${value.replaceAll("'", `'"'"'`)}'`;
}

Some files were not shown because too many files have changed in this diff Show More