Compare commits

...
Author SHA1 Message Date
cflmy de10e135ed Report release blocks separately from reconciliation failures
ci/woodpecker/pr/eco Pipeline was successful
ci/woodpecker/push/eco Pipeline was successful
ci/woodpecker/manual/reconcile Pipeline was successful
2026-11-27 22:32:57 +08:00
cflmy b47cf440b7 Check out only governance repositories for release reconciliation 2026-11-27 22:31:32 +08:00
cflmy a8a8098b9a Advance Knowledge to its independently verified CI entry
ci/woodpecker/pr/eco Pipeline was successful
ci/woodpecker/push/eco Pipeline is pending
2026-11-27 22:25:36 +08:00
6 changed files with 49 additions and 10 deletions

No files matched your search

+7 -2
View File
@@ -16,6 +16,11 @@ steps:
MARQDO_GIT_TOKEN: MARQDO_GIT_TOKEN:
from_secret: gitea_reconcile_token from_secret: gitea_reconcile_token
commands: commands:
- python3 scripts/check-layout.py - |
- git submodule update --init set -eu
domains="$(python3 scripts/check-layout.py --root-domain-paths)"
for domain in $domains; do
git submodule update --init -- "$domain"
done
- python3 scripts/check-layout.py --domain-paths
- python3 scripts/reconcile-releases.py --apply --published-after 2026-11-27T02:00:00Z --report-out reconcile-report.json - python3 scripts/reconcile-releases.py --apply --published-after 2026-11-27T02:00:00Z --report-out reconcile-report.json
+1 -1
View File
@@ -82,7 +82,7 @@ bash scripts/integration.sh # 生态候选:真实 CLI 制品 +
经过授权的 webhook 入口由根 `scripts/webhook-adapter.py` 实现:先以仓库 webhook secret 校验 `X-Gitea-Signature`(HMAC-SHA256)原始 body,再只接受 `push`(非删除)与 `pull_request`(opened/synchronized/reopened)事件;仓库必须来自 accepted 根图的远端允许列表,base 使用 accepted 图当前固定 SHA(payload base 只作 hint),CI 聚合要求至少一个状态且全部 success、URL 为允许 CI 主机上的 https。校验通过后交给同一 `candidate-notify.py` 做可达性/去重/重放/基线重验与影响分析,输出计划(不合并、不推送、不建 PR)。通知丢失的恢复由同一脚本 `--reconcile` 承担:扫描允许列表仓库的开放 PR 与 head statuses,对未入账的成功候选执行同一验证(幂等状态文件,重复运行只报 duplicate);API transient 错误有限退避重试,401/403 立即失败,不把触发成功当作下游已处理。外部不可信 PR、未批准 gitlink 或脚本不得在拥有跨仓库写权限/发版密钥的 runner 中运行;区分只读 checkout/test token、受限 issue/PR token、受保护发布权限。日志不得输出凭证、完整 Analysis 或生产 API key。 经过授权的 webhook 入口由根 `scripts/webhook-adapter.py` 实现:先以仓库 webhook secret 校验 `X-Gitea-Signature`(HMAC-SHA256)原始 body,再只接受 `push`(非删除)与 `pull_request`(opened/synchronized/reopened)事件;仓库必须来自 accepted 根图的远端允许列表,base 使用 accepted 图当前固定 SHA(payload base 只作 hint),CI 聚合要求至少一个状态且全部 success、URL 为允许 CI 主机上的 https。校验通过后交给同一 `candidate-notify.py` 做可达性/去重/重放/基线重验与影响分析,输出计划(不合并、不推送、不建 PR)。通知丢失的恢复由同一脚本 `--reconcile` 承担:扫描允许列表仓库的开放 PR 与 head statuses,对未入账的成功候选执行同一验证(幂等状态文件,重复运行只报 duplicate);API transient 错误有限退避重试,401/403 立即失败,不把触发成功当作下游已处理。外部不可信 PR、未批准 gitlink 或脚本不得在拥有跨仓库写权限/发版密钥的 runner 中运行;区分只读 checkout/test token、受限 issue/PR token、受保护发布权限。日志不得输出凭证、完整 Analysis 或生产 API key。
正式发布对账使用 `python3 scripts/reconcile-releases.py --plan --published-after <ISO-8601 时间>`。从固定根及领域 tree 解析受管仓库,核对 Gitea tag、`release-evidence.json`、同 SHA Woodpecker 组件 CI 和资产字节摘要。根 `reconcile` 工作流从当前受保护的 `main` 串行运行,使用 `gitea_reconcile_token` 以专用非管理员账号写追踪工单。`historical-baseline` 表示已登记历史输入,`blocked` 表示发布验证未通过,`tracked` 表示已记录经验证的发布。消费者验收和父级接受均需各自的 CI 与 PR 证据。 正式发布对账使用 `python3 scripts/reconcile-releases.py --plan --published-after <ISO-8601 时间>`。从固定根及领域 tree 解析受管仓库,核对 Gitea tag、`release-evidence.json`、同 SHA Woodpecker 组件 CI 和资产字节摘要。根 `reconcile` 工作流从当前受保护的 `main` 串行运行,只检出领域聚合仓,使用 `gitea_reconcile_token` 以专用非管理员账号写追踪工单。`historical-baseline` 表示已登记历史输入,`blocked` 表示发布验证未通过,`tracked` 表示已记录经验证的发布。扫描完整且追踪写入成功时,已报告的发布阻塞保留为 `blocked`,工作流仍成功结束。消费者验收和父级接受均需各自的 CI 与 PR 证据。
对已验证的发布,`--plan` 计算直接 active 消费者的输入摘要。受保护 `--apply` 按发布和消费者登记一条任务,基线变化时在原任务中记录新输入。输入附精确资产、依赖、消费者基线和根追踪编号。下游独立 CI 及批准后的晋升基于各自的真实结果。 对已验证的发布,`--plan` 计算直接 active 消费者的输入摘要。受保护 `--apply` 按发布和消费者登记一条任务,基线变化时在原任务中记录新输入。输入附精确资产、依赖、消费者基线和根追踪编号。下游独立 CI 及批准后的晋升基于各自的真实结果。
+2 -1
View File
@@ -452,6 +452,7 @@ def main():
paths.add_argument("--active-paths", action="store_true", help="print only direct active component paths") paths.add_argument("--active-paths", action="store_true", help="print only direct active component paths")
paths.add_argument("--active-entries", action="store_true", help="print validated active entries in dependency order") paths.add_argument("--active-entries", action="store_true", help="print validated active entries in dependency order")
paths.add_argument("--domain-paths", action="store_true", help="validate domain URLs and print domain paths") paths.add_argument("--domain-paths", action="store_true", help="validate domain URLs and print domain paths")
paths.add_argument("--root-domain-paths", action="store_true", help="print root domain gitlinks before checkout")
args = parser.parse_args() args = parser.parse_args()
try: try:
revision = git("rev-parse", "--verify", args.revision + "^{commit}").strip() revision = git("rev-parse", "--verify", args.revision + "^{commit}").strip()
@@ -463,7 +464,7 @@ def main():
for path, component in sorted(layers[0].linked.items()): for path, component in sorted(layers[0].linked.items()):
if component["state"] == "active": if component["state"] == "active":
print(path) print(path)
elif args.domain_paths: elif args.domain_paths or args.root_domain_paths:
for path, component in sorted(layers[0].linked.items()): for path, component in sorted(layers[0].linked.items()):
if component["kind"] == "domain": if component["kind"] == "domain":
print(path) print(path)
+16 -5
View File
@@ -44,6 +44,15 @@ class ReconcileError(Exception):
pass pass
class ApiUnavailable(ReconcileError):
"""The API could not supply the facts needed to complete the scan."""
def http_error(method, path, status):
error = ApiUnavailable if status in {401, 403, 429} or status >= 500 else ReconcileError
return error(f"{method} {path}: HTTP {status}")
class NoRedirect(urllib.request.HTTPRedirectHandler): class NoRedirect(urllib.request.HTTPRedirectHandler):
def redirect_request(self, request, fp, code, message, headers, newurl): def redirect_request(self, request, fp, code, message, headers, newurl):
return None return None
@@ -70,9 +79,9 @@ class Gitea:
require(len(payload) <= 8 * MAX_INDEX_BYTES, "API response exceeds size limit") require(len(payload) <= 8 * MAX_INDEX_BYTES, "API response exceeds size limit")
return json.loads(payload) return json.loads(payload)
except urllib.error.HTTPError as error: except urllib.error.HTTPError as error:
raise ReconcileError(f"{method} {path}: HTTP {error.code}") from error raise http_error(method, path, error.code) from error
except (OSError, ValueError, http.client.HTTPException) as error: except (OSError, ValueError, http.client.HTTPException) as error:
raise ReconcileError(f"{method} {path}: {error}") from error raise ApiUnavailable(f"{method} {path}: {error}") from error
def get(self, path): def get(self, path):
return self.request("GET", FORGE + "/api/v1", path, authenticated=True) return self.request("GET", FORGE + "/api/v1", path, authenticated=True)
@@ -99,9 +108,9 @@ class Gitea:
if index: if index:
payload.extend(chunk) payload.extend(chunk)
except urllib.error.HTTPError as error: except urllib.error.HTTPError as error:
raise ReconcileError(f"GET {path}: HTTP {error.code}") from error raise http_error("GET", path, error.code) from error
except (OSError, http.client.HTTPException) as error: except (OSError, http.client.HTTPException) as error:
raise ReconcileError(f"GET {path}: {error}") from error raise ApiUnavailable(f"GET {path}: {error}") from error
require(received == size, f"asset {path} size mismatch") require(received == size, f"asset {path} size mismatch")
return digest.hexdigest(), bytes(payload) return digest.hexdigest(), bytes(payload)
@@ -472,6 +481,8 @@ def reconcile(client, root=PROJECT_ROOT, apply=False, report_out=None, cutoff=No
require(not old or old == {identity_marker(entry)}, require(not old or old == {identity_marker(entry)},
"published release identity or index digest changed") "published release identity or index digest changed")
entry["release_key"], entry["consumer_tasks"] = consumer_inputs(entry, graph) entry["release_key"], entry["consumer_tasks"] = consumer_inputs(entry, graph)
except ApiUnavailable:
raise
except ReconcileError as error: except ReconcileError as error:
entry.update(status="blocked", error=str(error)) entry.update(status="blocked", error=str(error))
@@ -553,7 +564,7 @@ def main(argv):
return 1 return 1
print(json.dumps(report, ensure_ascii=False, indent=2)) print(json.dumps(report, ensure_ascii=False, indent=2))
return int(not report["scan_complete"] or any( return int(not report["scan_complete"] or any(
item["status"] == "blocked" or "tracking_update" in item "tracking_update" in item
or any(task.get("registration") == "blocked" for task in item.get("consumer_tasks", [])) or any(task.get("registration") == "blocked" for task in item.get("consumer_tasks", []))
for item in report["results"])) for item in report["results"]))
@@ -2,9 +2,12 @@
import hashlib import hashlib
import importlib.util import importlib.util
import io
import json import json
import os
import sys import sys
import unittest import unittest
from contextlib import redirect_stdout
from pathlib import Path from pathlib import Path
from unittest.mock import patch from unittest.mock import patch
from urllib.parse import parse_qs, urlsplit from urllib.parse import parse_qs, urlsplit
@@ -229,6 +232,25 @@ class ReconcileTest(unittest.TestCase):
self.assertEqual(entry["status"], "blocked") self.assertEqual(entry["status"], "blocked")
self.assertIn("cover the published assets", entry["error"]) self.assertIn("cover the published assets", entry["error"])
def test_recorded_release_block_does_not_fail_a_complete_operational_scan(self):
self.forge.pipeline_sha = BASE
with (patch.dict(os.environ, {"MARQDO_GIT_TOKEN": "fixture"}),
patch.object(reconcile, "Gitea", return_value=self.forge),
redirect_stdout(io.StringIO()) as stdout):
result = reconcile.main(["--apply"])
self.assertEqual(result, 0)
report = json.loads(stdout.getvalue())
self.assertTrue(report["scan_complete"])
self.assertEqual(report["results"][0]["status"], "blocked")
self.assertEqual(len(self.forge.issues), 1)
def test_asset_api_outage_leaves_the_scan_incomplete(self):
with patch.object(self.forge, "asset", side_effect=reconcile.http_error("GET", "/asset", 503)):
report = self.run_scan(apply=True)
self.assertFalse(report["scan_complete"])
self.assertEqual(report["scan_errors"][REPO], "GET /asset: HTTP 503")
self.assertEqual(self.forge.writes, [])
def test_validated_tracker_detects_an_updated_index_and_disappearing_release(self): def test_validated_tracker_detects_an_updated_index_and_disappearing_release(self):
self.run_scan(apply=True) self.run_scan(apply=True)
self.forge.evidence["assets"][0]["target"] = "x86_64-unknown-linux-gnu" self.forge.evidence["assets"][0]["target"] = "x86_64-unknown-linux-gnu"