diff --git a/scripts/release_handoff.py b/scripts/release_handoff.py index 9b5112b..d1df9a4 100644 --- a/scripts/release_handoff.py +++ b/scripts/release_handoff.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 """HiFox comment handoffs on the release executor. All user-visible actions are scoped to a verified event.""" import argparse +import html import json import re import sys @@ -125,8 +126,17 @@ def preflight(task, event=None): lines = [f"{s[:12]} {candidate.git('show', '-s', '--format=%s', s, cwd=assistant.SOURCE)}" for s in scope['extra']] safe_title = ' '.join(task['title'].splitlines()).replace('```', '') body = f"发布范围预览 · {task['identifier']}\n\n线上基线 `{scope['base']}`\n\n候选 `{sha}`\n\n本次修复:{safe_title}\n\n同批改动:\n" + '\n'.join(lines or ['无']) + '\n\n请负责人在这条评论下回复「确认范围」,系统将据此准备候选包。' - comment = coordinator.add_comment(launch['id'], 'scope ' + cd.acceptance_digest(scope), body) - stored = next(r for r in comments(launch['id']) if r['id'] == comment) + marker = '[KG candidate scope ' + cd.acceptance_digest(scope) + ']' + entries = [r for r in comments(launch['id']) if r['content'].startswith(marker + '\n')] + if not entries: + cli('task', 'comment', launch['id'], '--body', marker + '\n\n' + body) + entries = [r for r in comments(launch['id']) if r['content'].startswith(marker + '\n')] + cd.require(len(entries) == 1, 'expected one scope preview comment') + stored = entries[0] + normalized = html.unescape(stored['content']).replace( + f"[{task['identifier']}](mention://task/{task['id']})", task['identifier']) + cd.require(normalized == marker + '\n\n' + body, 'scope preview readback differs from plan') + comment = stored['id'] cd.record(path, {'plan': scope, 'comment': comment, 'content': stored['content']}) return {'state': 'awaiting_scope', 'url': launch['url'], 'plan': scope}