fix: guard board against commander brief pollution
This commit is contained in:
@@ -704,6 +704,8 @@ export async function runGhCliIssueGuardContract(): Promise<JsonRecord> {
|
||||
assertCondition(boardRowGetRow.issueNumber === 35 && boardRowGetRow.section === "open", "board-row get should return the target row", boardRowGetData);
|
||||
assertCondition(Array.isArray(boardRowGetRow.cells) && boardRowGetRow.cells[1] === "OPEN", "board-row get should expose the GitHub status column", boardRowGetRow);
|
||||
assertCondition(boardRowGetFields.branch === "master" && boardRowGetFields.status === "pass" && boardRowGetFields.validation === "pass" && boardRowGetFields.tasks === "cq-35" && String(boardRowGetFields.focus ?? "").includes("当前关注点"), "board-row get should expose canonical field aliases", boardRowGetFields);
|
||||
const boardRowGetHint = boardRowGetData.codeQueueBoardHint as JsonRecord;
|
||||
assertCondition(boardRowGetHint.detected === false && String(boardRowGetHint.warning ?? "").includes("#20 is the long-term board only"), "board-row get should remind callers not to put daily briefs into #20", boardRowGetHint);
|
||||
|
||||
const boardRowUpsertUpdateRequestCountBefore = mock.requests.length;
|
||||
const boardRowUpsertUpdate = await runCli([
|
||||
@@ -1088,6 +1090,8 @@ export async function runGhCliIssueGuardContract(): Promise<JsonRecord> {
|
||||
const readBodyData = dataOf(readBody.json ?? {});
|
||||
const readIssue = readBodyData.issue as JsonRecord;
|
||||
assertCondition(typeof readIssue.body === "string" && readIssue.body.includes("## 看板(OPEN)"), ".data.issue.body should remain readable", readBodyData);
|
||||
const readBodyHint = readBodyData.codeQueueBoardHint as JsonRecord;
|
||||
assertCondition(readBodyHint.detected === false && String(readBodyHint.warning ?? "").includes("#20 is the long-term board only"), "issue read #20 should remind callers not to put daily briefs into #20", readBodyHint);
|
||||
const selectedJson = readBodyData.json as JsonRecord;
|
||||
assertCondition(typeof selectedJson.body === "string" && selectedJson.body === readIssue.body, "selected json body should match issue body", readBodyData);
|
||||
assertCondition(!("comments" in selectedJson), "--json body should not imply comments field", selectedJson);
|
||||
@@ -1130,6 +1134,29 @@ export async function runGhCliIssueGuardContract(): Promise<JsonRecord> {
|
||||
const profileGuard = profileData.guard as JsonRecord;
|
||||
assertCondition(Array.isArray(profileGuard.failures) && profileGuard.failures.includes("profile-heading-missing"), "#20 guard should report missing heading", profileGuard);
|
||||
|
||||
const pollutedBoardFile = join(tmp, "polluted-board.md");
|
||||
writeFileSync(pollutedBoardFile, [
|
||||
"# Code Queue",
|
||||
"",
|
||||
"## 看板(OPEN)",
|
||||
"",
|
||||
"| Issue | GitHub 状态 | Branch | 验收状态 | 相关 Code Queue 任务 | 当前关注点 | 进度 |",
|
||||
"| --- | --- | --- | --- | --- | --- | --- |",
|
||||
"| #20 | OPEN | master | meta | governance | active | active |",
|
||||
"",
|
||||
"## 更新 2026-05-21 15:18 北京时间",
|
||||
"",
|
||||
"- 这类每日简报段落必须写到每日滚动简报 issue,而不是 #20。",
|
||||
"",
|
||||
].join("\n"), "utf8");
|
||||
const pollutedBoard = await runCli(["gh", "issue", "update", "20", "--repo", "pikasTech/unidesk", "--mode", "replace", "--body-file", pollutedBoardFile, "--dry-run"], env);
|
||||
assertCondition(pollutedBoard.status !== 0, "#20 body guard should reject commander brief update sections", pollutedBoard.json ?? { stdout: pollutedBoard.stdout });
|
||||
const pollutedBoardData = failedDataOf(pollutedBoard.json ?? {});
|
||||
const pollutedBoardGuard = pollutedBoardData.guard as JsonRecord;
|
||||
assertCondition(Array.isArray(pollutedBoardGuard.failures) && pollutedBoardGuard.failures.includes("code-queue-board-contains-commander-brief-updates"), "#20 guard should report commander brief pollution", pollutedBoardGuard);
|
||||
const pollutedBoardHint = pollutedBoardGuard.codeQueueBoardHint as JsonRecord;
|
||||
assertCondition(pollutedBoardHint.detected === true && String(pollutedBoardHint.route ?? "").includes("daily rolling commander brief"), "#20 guard should hint to move updates to the daily brief issue", pollutedBoardHint);
|
||||
|
||||
const commanderBriefBlocked = await runCli(["gh", "issue", "edit", "24", "--repo", "pikasTech/unidesk", "--body-file", missingHeadingFile, "--dry-run"], env);
|
||||
assertCondition(commanderBriefBlocked.status !== 0, "#24 missing heading should fail", commanderBriefBlocked.json ?? { stdout: commanderBriefBlocked.stdout });
|
||||
const commanderBriefData = failedDataOf(commanderBriefBlocked.json ?? {});
|
||||
|
||||
Reference in New Issue
Block a user