feat(release): 从预检评论接单并固定候选版本
build / build (push) Successful in 2m28s

This commit is contained in:
姚章浩
2026-11-24 14:39:43 +08:00
parent 8d873680cc
commit 4a12b20e9b
9 changed files with 447 additions and 8 deletions
+37 -4
View File
@@ -42,12 +42,19 @@ def owner_plan(task_id):
timeline(task_id), key=lambda row: row.get('createdAt', ''))) if (row.get('actor') or {}).get('id') == cd.RELEASE_OWNER]
match = next((row for row in matches if row), None)
if match is None:
raise cd.CDError('release owner must post a kg-release-v1 plan on the release task')
plan = json.loads(match[1])
from release_handoff import frozen_approval
plan = frozen_approval(task_id)
cd.require(plan, 'release owner must confirm the scope preview or post a kg-release-v1 plan')
else:
plan = json.loads(match[1])
candidate.check_plan(plan)
cd.require(plan['task'] == task_id, 'release plan belongs to another task')
for item in plan['items']:
requirement = task(item['task'])
if 'commit' in item:
# The owner's authenticated plan binds this requirement to the exact landed commit.
# verify_source also checks the complete first-parent range and exact candidate CI.
continue
identifier = requirement.get('identifier')
pr = candidate.read_forge(candidate.API + f'/pulls/{item["pr"]}')
fields = ' '.join(str(v or '') for v in (pr.get('title'), pr.get('body'), (pr.get('head') or {}).get('ref')))
@@ -96,21 +103,47 @@ def publish_candidate(plan, receipt, run):
f'归档 `{receipt["bundle"]}`\n\n'
f'构建记录 {cd.FORGE}/{cd.REPO}/actions/runs/{run}\n\n'
f'发布任务 {task(plan["task"])["url"]}')
body += ('\n\n请在本包执行实测,用 kg-qa-v1 代码块回填 sha、bundle、url、required、passed、failed、blocked、verdict。'
'业务单记录用例,发布单记录批次回归;每份报告附对应证据。')
key = 'ready ' + receipt['bundle']
add_comment(plan['task'], key, body)
for item in plan['items']:
item_id = item['task']
status = (task(item_id).get('status') or {}).get('id')
if status == TESTING:
cd.require(any(f'[KG candidate {key}]' in (row.get('content') or '') for row in timeline(item_id)),
f'{item_id}: another QA round is already in progress')
if not any(f'[KG candidate {key}]' in (row.get('content') or '') for row in timeline(item_id)):
cd.require((STATE / 'handoffs' / (plan['task'] + '.preview.json')).is_file(),
f'{item_id}: another QA round is already in progress')
add_comment(item_id, key, body)
if (STATE / 'handoffs' / (plan['task'] + '.preview.json')).is_file():
summon_qa(plan, item_id, body)
continue
cd.require(status == WAIT_TEST, f'{item_id}: requirement must be in 待测试')
add_comment(item_id, key, body)
cd.require((task(item_id).get('status') or {}).get('id') == WAIT_TEST,
f'{item_id}: task status changed during candidate handoff')
managed = (STATE / 'handoffs' / (plan['task'] + '.preview.json')).is_file()
invitation = STATE / cd.acceptance_digest(plan) / (item_id + '.qa-invite.json')
if managed:
cd.record(invitation, {'state': 'sending'})
hfx.hifox(CLI, 'task', 'edit', item_id, '--status', TESTING)
cd.require((task(item_id).get('status') or {}).get('id') == TESTING, f'{item_id}: testing status not verified')
if managed:
cd.record(invitation, {'state': 'sent', 'via': 'status'})
if (STATE / 'handoffs' / (plan['task'] + '.preview.json')).is_file():
summon_qa(plan, plan['task'], body + '\n请实测批次回归,报告写在本发布单。')
def summon_qa(plan, target, body):
directory = STATE / cd.acceptance_digest(plan)
path = directory / (target + '.qa-invite.json')
if path.exists():
cd.require(cd.read_json(cd.immutable_file(path)).get('state') == 'sent', 'QA invitation outcome needs reconciliation')
return
cd.record(path, {'state': 'sending'})
result = hfx.hifox(CLI, 'task', 'summon', target, '--agent', 'crew:baa5ca58-1228-4da5-9bf8-b9927075e4be', '--body', body)
cd.record(path, {'state': 'sent', 'result': result})
def register(task_id):