refactor: make Gitea the sole CI authority

This commit is contained in:
pikastech
2026-07-21 17:18:48 +02:00
parent 1115f134fd
commit 5115460df2
23 changed files with 337 additions and 214 deletions
+11 -9
View File
@@ -2,7 +2,7 @@
name: unidesk-cicd
description: >-
UniDesk CI/CD 控制面,覆盖 PaC consumer 首发 bootstrap、Tekton/Argo、GitOps、
git-mirror、L2/L3 手动计划发布、Secret、observability、CI tools image、PipelineRun 清理、
Gitea 单一 source authority、L2/L3 手动计划发布、Secret、observability、CI tools image、PipelineRun 清理、
Tekton 大对象与 Kine/SQLite 控制面退化、AgentRun 与 HWLAB 部署,
以及 branch-follower 退役只读诊断。
用户提到 CI/CD、deploy、rollout、PipelineRun、PaC、bootstrap、GitOps、Tekton、
@@ -14,7 +14,7 @@ description: >-
# UniDesk CI/CD
HWLAB G14 和 AgentRun CI/CD 的受控入口。任何 PR 监控、Tekton/Argo、git-mirror、Secret、observability、CI tools image、PipelineRun 清理或 AgentRun 部署都必须走 `bun scripts/cli.ts`
HWLAB G14 和 AgentRun CI/CD 的受控入口。任何 PR 监控、Tekton/Argo、Gitea source authority、Secret、observability、CI tools image、PipelineRun 清理或 AgentRun 部署都必须走 `bun scripts/cli.ts`
- `$unidesk-devlevel` 用 L2 Development 和 L3 Production 描述两种集群部署方式:
- 本 skill 负责这两种方式的手动计划发布、运行面操作和事故处理;
@@ -41,7 +41,6 @@ bun scripts/cli.ts cicd status --node <NODE>
bun scripts/cli.ts hwlab g14 monitor-prs --lane v02 --once --dry-run
bun scripts/cli.ts hwlab g14 control-plane status --lane v02
bun scripts/cli.ts hwlab nodes control-plane status --node NC01 --lane v03 --json
bun scripts/cli.ts hwlab g14 git-mirror status --lane v02
bun scripts/cli.ts agentrun control-plane status
bun scripts/cli.ts platform-infra gitea mirror status --target JD01
bun scripts/cli.ts platform-infra gitea mirror webhook status --target JD01
@@ -166,7 +165,7 @@ bun scripts/cli.ts hwlab nodes control-plane legacy-cicd --help
- PR monitor 与自动合并: [references/pr-monitor.md](references/pr-monitor.md)。
- Tekton/Argo、node-scoped runtime lane、D601 infra bootstrap: [references/control-plane.md](references/control-plane.md)。
- HWLAB/AgentRun legacy git-mirror source authority 与 flush: [references/git-mirror.md](references/git-mirror.md)。
- legacy git-mirror 退役状态与清理边界: [references/git-mirror.md](references/git-mirror.md)。
- JD01/NC01 Gitea mirror + Pipelines-as-Code 正式架构、三 consumer 覆盖矩阵、target 级 webhook path 和旧入口处置: [references/gitea-pac.md](references/gitea-pac.md)。
- AgentRun/HWLAB env reuse 机制、证据解释和 PaC status/history 观察口径: [references/env-reuse.md](references/env-reuse.md)。
- Secret、observability、platform-infra、CI tools image、PipelineRun 清理和 rollout 补记: [references/platform-ops.md](references/platform-ops.md)。
@@ -294,12 +293,15 @@ bun scripts/cli.ts hwlab nodes control-plane legacy-cicd --help
- warning 必须保留对象、配置路径、错误码和修复入口,但不得改变交付成功终态、跳过业务功能、写回配置或触发补救 mutation;
- 发现既有阻塞实例时逐例降级为 non-blocking warning,不以历史测试、旧门禁或旧合同继续阻止滚动;
- 当前选中对象缺少渲染必需输入、Secret/权限不成立、目标无法唯一解析或 mutation target 不安全时,仍在 mutation 前 fail-closed;这类损害预防不得扩展成全局配置一致性门禁。
- CI/CD source authority 只能来自 YAML 声明的 Kubernetes 托管 source authority
- legacy lane 由受控命令在 k8s 内同步并创建不可变 `refs/unidesk/snapshots/.../<commit>` stage ref
- Gitea/PaC migrated lane 由 GitHub PR merge 更新 GitHub webhook bridge、Gitea controlled mirror 与 immutable snapshot ref,禁止合并后人工同步或创建 snapshot;该 source 更新不触发 PipelineRun
- CI/CD source authority 只能来自 YAML 声明的 Gitea authority
- GitHub PR merge 只更新 GitHub webhook bridge、Gitea authority branch 与 immutable snapshot ref,禁止合并后人工同步或创建 snapshot;该 source 更新不触发 PipelineRun
- build/status/publish 只消费对应 snapshothost worktree、本地 `git fetch/pull`、可变 branch ref 或 Pipeline 内直连 GitHub 都不能作为 authoritative source。
- source branch、snapshot、GitOps branch、artifact catalog、Argo 和 runtime checkout 必须使用同一 Gitea repository
- CLI plan 与 Pipeline 必须从同一个 `gitops_read_url` 恢复 catalog
- promotion 只通过 YAML 声明的 Gitea SecretRef 写回同一仓库;
- 禁止 `git-mirror-http``git-mirror-write`、mirror cache、sync/flush Job、fallback 或第二 authority。
- CLI 必须组合 `config/platform-infra/gitea.yaml``config/platform-infra/pipelines-as-code.yaml`,按 consumer、node、lane、upstream repository、branch 和 Gitea repository 精确解析 delivery authority。不得用 URL 片段或 repo 专属条件判断迁移;当前选中对象零匹配或多匹配时返回 `unknown``mutation=false` 并在 mutation 前 fail-closed,非选中对象和全局一致性错误只进入 `blocking=false` warning。
- PaC 与 `unknown` authority 的 help、plan、status、失败态 `Next``REPAIR` 和实际执行 guard 都不得包含或执行 mutation command`trigger-current|refresh|sync|flush`在 YAML 精确解析为 `legacy-manual` 后进入旧实现,且只从 `legacy-cicd` / `legacy-ops` scoped help 发现;平台 bootstrap、Secret 与配置维护使用独立 scoped help,不得充当 source delivery recovery。
- PaC 与 `unknown` authority 的 help、plan、status、失败态 `Next``REPAIR` 和实际执行 guard 都不得包含或执行 legacy source mutation。`trigger-current|refresh|sync|flush`保留退役诊断,不得创建 Job 或写 ref;平台 bootstrap、Secret 与配置维护使用独立 scoped help,不得充当 source delivery recovery。
- JD01/NC01 `agentrun-<node>-v02``sentinel-<node>-v03``hwlab-<node>-v03` 在手动 webhook 后由 PaC/Tekton/GitOps 自动收敛并写入状态。仅在显式调查发布链故障时读取 `cicd status --node <NODE>``platform-infra pipelines-as-code status|history --target <NODE> --consumer <id>``cicd branch-follower``cicd gitea-actions-poc` 只保留历史/迁移只读用途。
- PaC `.tekton` 文件必须用 Repository CR 的 target/node 参数隔离 JD01/NC01,避免同一个 Gitea push 在一个 target cluster 内额外创建另一个 target 的 PipelineRun。`history --id` 必须按运行面 provenance 和实际 PipelineRun prefix 唯一归属 consumer;零匹配、多匹配或显式 consumer 不一致均 fail-closed,不得回退到默认 consumer 或默认 node。
- PaC source artifact 必须遵循以下边界:
@@ -446,7 +448,7 @@ bun scripts/cli.ts hwlab nodes control-plane legacy-cicd --help
- PR 自动合并、v0.2/v0.3 lane 差异:读 [references/pr-monitor.md](references/pr-monitor.md)。
- Legacy 手动触发、定点 PipelineRun/source commit、RBAC/Pipeline/Argo、node-scoped runtime lane:读 [references/control-plane.md](references/control-plane.md)。
- Legacy git-mirror source authority 或 flush:读 [references/git-mirror.md](references/git-mirror.md)。
- legacy git-mirror 退役核查:读 [references/git-mirror.md](references/git-mirror.md)。
- AgentRun/HWLAB env reuse、`IMAGE_STATUS=reused``ENV_REUSE=hit``skipped,skip=<n>` 或 PaC history/status 解释:读 [references/env-reuse.md](references/env-reuse.md)。
- JD01/NC01 Gitea+PaC 覆盖、旧 branch-follower/Gitea Actions POC 处置和只读观察顺序:读 [references/gitea-pac.md](references/gitea-pac.md)。
- Secret、observability、CI tools image、PipelineRun/PV 清理:读 [references/platform-ops.md](references/platform-ops.md)。
@@ -87,7 +87,7 @@ Use these interpretations:
- Sentinel `ENV_REUSE=hit`: node dependency directory was present and linked before verify/build.
- Sentinel `cache=hit`: BuildKit cache evidence, separate from dependency reuse.
- HWLAB v0.3 `skipped,skip=<n>` in PaC history: service-level artifact planning skipped builds for already reusable services; inspect the detail id before interpreting it as AgentRun-style image reuse.
- HWLAB v0.3 `env-reuse-git-mirror-checkout`: a `codeIdentity` change with unchanged `envIdentity` should mark the service as affected/rolled out while still skipping image build. Evidence is in `plan-artifacts` and `collect-artifacts`: `affectedServices` includes the service, `buildServices=[]`, the artifact has `ciAffected=true`, `ciReason` such as `code-input-changed`, a new `componentCommitId`/`codeInputHash`, and `publishState=reused` / `buildBackend=reused-env-catalog`. This is correct env reuse consumption, not a missed rebuild.
- HWLAB v0.3 `env-reuse-gitea-checkout`: a `codeIdentity` change with unchanged `envIdentity` should mark the service as affected/rolled out while still skipping image build. Evidence is in `plan-artifacts` and `collect-artifacts`: `affectedServices` includes the service, `buildServices=[]`, the artifact has `ciAffected=true`, `ciReason` such as `code-input-changed`, a new `componentCommitId`/`codeInputHash`, and `publishState=reused` / `buildBackend=reused-env-catalog`. This is correct env reuse consumption, not a missed rebuild.
- HWLAB v0.3 shared TS runtime env groups build one representative environment image and let compatible TS services consume that same artifact with different runtime checkout/entrypoint metadata. A semantic env identity change, such as dependency maps, `engines`, `packageManager`, `overrides`, `resolutions`, `type`, or env launcher inputs, should schedule the representative build service; consumer services should keep shared artifact provenance and skip individual image builds.
- HWLAB v0.3 non-reuse image build is expected when `envIdentity` changes, such as shared dependency or env launcher inputs. Then `buildServices` should include services whose environment identity changed and build TaskRuns should be present.
- HWLAB v0.3 treats `package.json` env identity semantically. Arbitrary top-level metadata fields do not count; meaningful env inputs include dependency maps, `overrides`, `resolutions`, `engines`, `packageManager`, and `type`. Use one of those fields when deliberately testing non-reuse behavior.
@@ -1,42 +1,23 @@
# Git Mirror Authority
# Legacy Git Mirror 退役
## 默认只读入口
`git-mirror-http``git-mirror-write`、mirror cache、sync/flush Job 和相关 Secret 已退出 CI/CD 运行架构。它们不得作为 source cache、GitOps write endpoint、故障 fallback 或第二 authority 保留。
Gitea/PaC migrated consumer 的 mirror、authority branch 与 immutable snapshot 由 GitHub PR merge 更新;GitOps publication 只在手动 plan/trigger 后发生。默认只允许读取:
## 稳定规则
- source branch、immutable snapshot、GitOps branch、artifact catalog、Argo 和 runtime checkout 统一使用 owning YAML 声明的 Gitea repository。
- CLI `release plan` 与 Pipeline 内 planner 必须使用同一个 `gitops_read_url`
- GitOps promotion 必须通过 Gitea SecretRef 写回同一仓库,不得恢复匿名 mirror write 或 SSH fallback。
- 历史 `git-mirror status|sync|flush|trigger-current` 只允许返回退役诊断,不得创建 Job、写 ref 或重建 runtime。
- 运行面仍存在 legacy 对象时,先确认活跃 consumer 已无引用,再执行:
```bash
bun scripts/cli.ts platform-infra gitea mirror status --target <NODE>
bun scripts/cli.ts platform-infra gitea mirror webhook status --target <NODE>
bun scripts/cli.ts hwlab nodes git-mirror status --node <NODE> --lane <lane>
bun scripts/cli.ts agentrun git-mirror status --node <NODE> --lane <lane>
bun scripts/cli.ts hwlab nodes control-plane infra source-authority retire-legacy-runtime --node <NODE> --lane <lane> --dry-run
bun scripts/cli.ts hwlab nodes control-plane infra source-authority retire-legacy-runtime --node <NODE> --lane <lane> --confirm
```
已迁移或 `unknown` authority 必须在远端调用或异步 Job 创建前 fail-closed。状态和失败 `Next` 只能指向 status/history 与自动链修复引用,不得建议 mirror sync/flush、直接 Gitea push、host git、fixed workspace 或第二套 source resolver
- 受控退役只删除 owning YAML 精确命名的旧 Deployment、Service、ConfigMap、PVC、Secret 与同步/flush Job;不得修改 Pipeline、PipelineRun、Argo、registry 或业务 workload
- status 对 Gitea authority 的正确终态是 `legacySourceRuntimeEnabled=false``legacySourceRuntimeAbsent=true`
发布链故障必须修 `config/platform-infra/gitea.yaml``config/platform-infra/pipelines-as-code.yaml`、planner、webhook bridge、受控 mirror worker 或源码,并通过修复 PR 合并后的 plan 与手动 webhook 验收。不得使用 branch-follower、裸建 PipelineRun 或 legacy mirror mutation 补齐当前交付。
## 故障处理
## Legacy scope
Git mirror mutation 只属于 owning YAML 精确解析为 `legacy-manual` 的 lane,并且只能从显式 scoped help 发现:
```bash
bun scripts/cli.ts hwlab nodes git-mirror legacy-ops --help
bun scripts/cli.ts agentrun git-mirror legacy-ops --help
```
Legacy scope 仍须遵守:
- source selection 只使用 YAML 声明的 immutable snapshot,不读取 host worktree、`.worktree/*` 或可变 branch ref
- GitHub transport、proxy、Secret sourceRef 与 snapshot prefix 全部来自 owning YAML
- `sync``flush` 与 apply 只服务明确 legacy lane,不能作为 PaC 恢复手段;
- 验收使用只读 status 证明 mirror、GitOps、Argo、runtime 与目标 source commit 对齐,不能只看 PipelineRun terminal。
## 退役状态清理
Branch-follower 已退役。旧状态清理不属于 mirror 自动链,也不使用默认 `cleanup-state`。确需清理时使用 `cicd branch-follower retired-maintenance --help` 中的受控入口;固定 canonical owning YAML,先列候选,再显式确认。
## D601 legacy transport
D601 legacy lane 的 GitHub upstream transport 由 YAML 固定为 SSH over `ssh.github.com:443`HTTP proxy 仅承担 SSH CONNECT。输出若漂移为 HTTPS token、host env 或未声明 transport,修 owning YAML 和平台配置,不增加 fallback。
Legacy mirror status 中的 GitHub 字段可能来自 `refs/mirror-stage/...` cache,必须标记来源。push 已成功但 post-push fetch 因 transient 失败时,CLI 可以在同一个 legacy 受控实现内做一次有界 recheck;这项行为不得复制到 migrated PaC consumer 的 operator Next。
Gitea source 或 GitOps 链故障只能修 `config/platform-infra/gitea.yaml``config/platform-infra/pipelines-as-code.yaml`、对应 owning YAML、controller、planner 或 Pipeline。修复后重新执行 `release plan`,范围准确时只发送一次手动 webhook。禁止用 mirror sync、flush、直接 Gitea push、裸建 PipelineRun 或 Argo sync 补齐交付。
@@ -37,7 +37,7 @@ GitHub 是唯一上游写入权威。目标 source branch 的 GitHub PR merge
- Gitea source authority、GitHub webhook bridge、公网暴露与 source snapshot 归属 `config/platform-infra/gitea.yaml`
- PaC controller、Repository CR、consumer 参数、Tekton pipeline 名称与 Argo Application 归属 `config/platform-infra/pipelines-as-code.yaml`
- CLI 必须组合两份 YAML,并按 consumer、node、lane、upstream repository、branch 与 Gitea repository 精确解析 authority。不得用 URL heuristic 或 repo 专属特例;`unknown`、歧义和配置错误都必须 `mutation=false` 并 fail-closed。
-人工 mutation 入口只允许在 owning YAML 精确解析为 `legacy-manual` 后从 scoped help 使用;Gitea/PaC migrated consumer 和 `unknown` authority 都不得回退到 legacy 实现。
- source mutation 入口已退役;历史 help/status 只能返回只读诊断,Gitea/PaC consumer 和 `unknown` authority 都不得回退到 legacy 实现。
- 包含 `gitea-actions` 的历史 snapshot prefix 只为既有 ref 保留,不代表 Gitea Actions 仍是有效触发架构。
- node 级状态入口是 `bun scripts/cli.ts cicd status --node <NODE>`consumer 级默认下钻入口是 `platform-infra pipelines-as-code status|history --target <NODE> --consumer <id>`
- Gitea 公网入口: