Skip to content

governance: flaky_governance 参数落地 + 隔离到期回炉 sweep(P2-9,ADR-0043) - #122

Merged
randypanding merged 3 commits into
mainfrom
p2-9-flaky-governance
Aug 20, 2026
Merged

governance: flaky_governance 参数落地 + 隔离到期回炉 sweep(P2-9,ADR-0043)#122
randypanding merged 3 commits into
mainfrom
p2-9-flaky-governance

Conversation

@randypanding

Copy link
Copy Markdown
Contributor

摘要

P2-9(#94 / ADR-0043)治理侧:

  1. testing.yaml:T-08 flaky_governance 工具接入(flaky-retry.sh + flaky-sweep)+ flaky_governance 参数段(retry_max=2 / 窗口 30 天 / 阈值 3 次 / 隔离 ≤30 天)——CI-Workflows flaky-retry.sh 的拉取真源
  2. governance/flaky-sweep.sh:每日扫描受管仓 tests/quarantine.yaml——结构校验(test/owner/expires/adr + ≤30 天)+ 过期条目开升级 issue(过期隔离不豁免=自动回炉执法)
  3. .github/workflows/flaky-sweep.yml:每日 02:30(GOVERNANCE_TOKEN,fail-closed)

验证

  • YAML/bash 语法
  • retry 语义三用例(CI-Workflows 侧 self-test 3/3)
  • 合并后 dispatch 首跑(预期:无 quarantine.yaml 的仓全部跳过,零误报)

C1:governance/ + .github/ + policy 路径,ADR-0043 背书。

@coderabbitai

coderabbitai Bot commented Aug 20, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@randypanding, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 4 minutes

Limit details: You’ve used all 10 included reviews currently available.

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

Wait for the limit to reset, then comment @coderabbitai review or push new commits to the PR.

An organization admin can change what happens after included review limits in Billing.

How do review limits work?

CodeRabbit enforces per-developer PR review limits within each organization.

For paid Pro and Pro+ reviews, CodeRabbit uses a developer's included PR review attempts over the past 7 days to set the current hourly allowance. At typical activity levels, the full plan allowance applies. Higher sustained activity can lower the allowance until earlier attempts leave the 7-day window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: bbe7d9f3-e53b-4876-ae2c-58423a3e33f3

📥 Commits

Reviewing files that changed from the base of the PR and between 27f4a9c and 27491cb.

📒 Files selected for processing (3)
  • .github/workflows/flaky-sweep.yml
  • governance/flaky-sweep.sh
  • governance/policy/testing.yaml

Comment @coderabbitai help to get the list of available commands.

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

落地 flaky 测试治理参数与隔离到期扫描

✨ Enhancement ⚙️ Configuration changes 🕐 20-40 Minutes

Grey Divider

AI Description

• 集中定义 flaky 重试、统计窗口、隔离阈值及期限参数。
• 每日扫描受管仓隔离清单,校验结构并识别过期条目。
• 为违规仓创建升级 issue,缺少治理令牌时关闭失败。
Diagram

graph TD
  A["Daily Workflow"] --> B["Sweep Script"] --> C["Governance Config"] --> D["Active Repos"] --> E["Quarantine Files"] --> F{"Violations Found"} -->|"violations"| G["GitHub Issues"]
  F -->|"clean"| H["Healthy Result"]
Loading
High-Level Assessment

当前集中式方案最适合组织级治理:参数由 testing.yaml 提供单一真源,扫描器依据 REPOS.yaml 覆盖全部活跃仓,避免在每个业务仓复制定时任务。已考虑由各仓自行执行检查,但该方案更易产生配置漂移,也增加令牌和工作流维护成本。

Files changed (3) +102 / -2

Enhancement (1) +56 / -0
flaky-sweep.sh实现跨仓隔离到期与结构违规扫描 +56/-0

实现跨仓隔离到期与结构违规扫描

• 读取活跃仓清单和统一隔离期限,逐仓获取 tests/quarantine.yaml 并校验 test、owner、expires、adr 字段。脚本对过期或违规清单创建升级 issue,对非 404 拉取失败采用 fail-closed,并汇总扫描结果。

governance/flaky-sweep.sh

Other (2) +46 / -2
flaky-sweep.yml新增每日 flaky 隔离扫描工作流 +31/-0

新增每日 flaky 隔离扫描工作流

• 新增每日 02:30 和手动触发的治理任务,以固定版本检出代码并运行 flaky-sweep.sh。工作流要求 GOVERNANCE_TOKEN,缺失时立即失败,并限制并发与执行时长。

.github/workflows/flaky-sweep.yml

testing.yaml建立 flaky_governance 机器可执行参数真源 +15/-2

建立 flaky_governance 机器可执行参数真源

• 将 T-08 接入 flaky-retry.sh 和 flaky-sweep,并明确重试记账、隔离候选及到期回炉语义。新增重试上限、30 天统计窗口、事件阈值和最长隔离期限参数。

governance/policy/testing.yaml

@randypanding
randypanding merged commit a0cda3f into main Aug 20, 2026
7 checks passed
@randypanding
randypanding deleted the p2-9-flaky-governance branch August 20, 2026 07:21
@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (5) 📘 Rule violations (2) 📜 Skill insights (0)

Grey Divider


Action required

1. Manifest content never parsed 🐞 Bug ≡ Correctness
Description
python3 - consumes the heredoc as its program, leaving sys.stdin unavailable for
yaml.safe_load; the outer here-string does not provide a separate data stream to the Python
program. Consequently every valid quarantine manifest is treated as empty, so expired and malformed
entries are never detected.
Code

governance/flaky-sweep.sh[R22-25]

+  OUT=$(python3 - "$r" "$MAX_DAYS" <<'PYEOF'
+import sys, yaml, datetime
+repo, max_days = sys.argv[1], int(sys.argv[2])
+d = yaml.safe_load(sys.stdin) or {}
Relevance

●●● Strong

Heredoc consumes stdin so YAML parsing silently returns empty; matches accepted validation-hardening
pattern.

PR-#61

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The Python interpreter is invoked with - and a heredoc at lines 22-42, while the parser attempts
to read the same stdin at line 25. Findings are derived exclusively from OUT at lines 44-46, and
unchanged zero counters make the final check succeed at lines 55-56.

governance/flaky-sweep.sh[22-46]
governance/flaky-sweep.sh[55-56]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The embedded Python program and quarantine YAML both attempt to use stdin. Ensure Python receives the program separately from the manifest data, and propagate parser failures.

## Issue Context
`python3 -` reads the heredoc from stdin as source code, so `yaml.safe_load(sys.stdin)` cannot then read the quarantine manifest supplied outside the command substitution.

## Fix Focus Areas
- governance/flaky-sweep.sh[22-43]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Malformed manifests falsely pass 🐞 Bug ☼ Reliability
Description
The parser assumes both the document and every quarantined entry are mappings, then accesses
missing required fields after merely recording them. Scalar/list documents, non-mapping entries, or
entries missing expires raise uncaught exceptions; without set -e or an explicit status check,
the shell continues with empty output and can exit successfully.
Code

governance/flaky-sweep.sh[R30-33]

+        if not e.get(k):
+            malformed.append(f"{e} 缺 {k}")
+    try:
+        exp = datetime.date.fromisoformat(str(e["expires"]))
Relevance

●●● Strong

Accepted precedent requires rejecting unusable/malformed input rather than silently passing
structural checks.

PR-#61

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Lines 28-33 call d.get, e.get, and e["expires"] without type validation or skipping invalid
entries. The shell enables only -u and pipefail, and the final result depends solely on counters
that parser exceptions do not increment.

governance/flaky-sweep.sh[8-8]
governance/flaky-sweep.sh[28-39]
governance/flaky-sweep.sh[55-56]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Validate the top-level YAML type, the `quarantined` collection type, and each entry before accessing fields. Treat every parsing or schema exception as a counted fail-closed violation.

## Issue Context
The current code calls mapping methods and indexes required keys without validating types or stopping after a missing-key finding. Command-substitution failure is not checked because the script omits `set -e`.

## Fix Focus Areas
- governance/flaky-sweep.sh[8-8]
- governance/flaky-sweep.sh[22-43]
- governance/flaky-sweep.sh[55-56]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Structural violations exit green 🐞 Bug ≡ Correctness
Description
Parsed structural violations populate MAL_LIST, but line 52 only increments EXPIRED; MALFORMED
is reserved for content-fetch failures. A repository containing only invalid quarantine entries is
therefore reported as 违规仓=0 and the workflow exits successfully.
Code

governance/flaky-sweep.sh[R51-52]

+    echo "ISSUE repo '$r': 过期 $(grep -c . <<<"$EXP_LIST" || true) / 违规 $(grep -c . <<<"$MAL_LIST" || true)"
+    ISSUES=$((ISSUES+1)); EXPIRED=$((EXPIRED+$(grep -c . <<<"$EXP_LIST" || true)))
Relevance

●●● Strong

Deterministic counter bug causing false-green exit; matches accepted fail-closed correctness fixes.

PR-#19
PR-#61

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Lines 44-46 separately extract and act on MAL_LIST, but lines 51-52 increment only issue and
expired counters. Lines 55-56 label MALFORMED as the invalid-repository count and use it for the
exit decision, although that variable is incremented only on fetch failure at line 20.

governance/flaky-sweep.sh[18-20]
governance/flaky-sweep.sh[44-56]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Increment the malformed repository counter whenever `MAL_LIST` is non-empty and ensure the final status fails for structural violations.

## Issue Context
The parser emits structural findings into `MAL_LIST`, but only fetch failures currently increment the counter checked at script exit.

## Fix Focus Areas
- governance/flaky-sweep.sh[44-56]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


View high (1)
4. Failed issue posts look successful 🐞 Bug ☼ Reliability
Description
The API wrapper uses curl without --fail-with-body, so HTTP 4xx/5xx responses return success and
the unlabeled fallback is not attempted; transport failures from both attempts are also ignored
because set -e is disabled. The script then unconditionally prints ISSUE and increments
ISSUES, even when no escalation issue exists.
Code

governance/flaky-sweep.sh[R49-50]

+    api -X POST "https://api.github.com/repos/$ORG/$r/issues" -d "$(jq -n --arg t "$TITLE" --arg b "$BODY" '{title:$t,body:$b,labels:["flaky-quarantine"]}')" >/dev/null 2>&1 || \
+      api -X POST "https://api.github.com/repos/$ORG/$r/issues" -d "$(jq -n --arg t "$TITLE" --arg b "$BODY" '{title:$t,body:$b}')" >/dev/null
Relevance

●●● Strong

PR #19 established that API failures must be validated and treated fail-closed, not as success.

PR-#19

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The shared API helper at line 12 does not fail on HTTP error status. Lines 49-52 discard responses
and unconditionally report/count an issue, matching the repository's previously accepted fail-open
API-response bug pattern.

governance/flaky-sweep.sh[12-12]
governance/flaky-sweep.sh[49-56]
PR-#19

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Make the API helper fail on non-2xx responses, validate the issue response, and only increment `ISSUES` after confirmed creation. If both labeled and unlabeled creation fail, record a failure that makes the sweep exit nonzero.

## Issue Context
Plain `curl -sS` treats GitHub HTTP errors as successful transfers, defeating the `||` fallback and allowing issue-creation failures to be reported as successes.

## Fix Focus Areas
- governance/flaky-sweep.sh[12-12]
- governance/flaky-sweep.sh[49-56]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

5. Daily sweep duplicates issues 🐞 Bug ☼ Reliability
Description
Every run with a persistent expired or malformed entry unconditionally creates another issue without
looking for an existing sweep-owned issue. Because the workflow runs daily, unresolved violations
will produce one duplicate issue per repository per day.
Code

governance/flaky-sweep.sh[R46-49]

+  if [[ -n "$EXP_LIST" || -n "$MAL_LIST" ]]; then
+    TITLE="[flaky] $r 隔离清单待处置(过期回炉/结构违规,ADR-0043)"
+    BODY="flaky-sweep 每日检测(ADR-0043):\n\n## 过期条目(已自动回炉——过期隔离不豁免,须修复测试或走 ADR 重新隔离)\n${EXP_LIST:--}\n\n## 结构违规\n${MAL_LIST:--}\n\n处置:修复测试后经 PR 移除条目(引用 ADR);或新 ADR 重新隔离。"
+    api -X POST "https://api.github.com/repos/$ORG/$r/issues" -d "$(jq -n --arg t "$TITLE" --arg b "$BODY" '{title:$t,body:$b,labels:["flaky-quarantine"]}')" >/dev/null 2>&1 || \
Relevance

●●● Strong

Team previously accepted deduplication fixes for daily automation issue creation.

PR-#51
PR-#19

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The workflow is scheduled daily at lines 4-7. For every nonempty finding list, lines 46-50
immediately POST a new issue; there is no lookup, update, reopen, or close operation anywhere in the
new script.

.github/workflows/flaky-sweep.yml[4-7]
governance/flaky-sweep.sh[46-54]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Use a dedicated label or marker to find an existing open flaky-sweep issue and update or comment on it instead of creating a duplicate. Optionally close the owned issue when the repository becomes healthy.

## Issue Context
The scheduled workflow runs every day, while the script's only issue lifecycle operation is an unconditional POST whenever findings remain.

## Fix Focus Areas
- .github/workflows/flaky-sweep.yml[4-7]
- governance/flaky-sweep.sh[46-50]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


6. flaky-sweep opens forbidden issues 📘 Rule violation § Compliance
Description
The new automation reports quarantine violations by creating repository issues, but the automation
standard permits machine feedback only through failed check runs or ordinary PR comments. This
introduces a feedback channel outside the documented bot standards.
Code

governance/flaky-sweep.sh[R49-50]

+    api -X POST "https://api.github.com/repos/$ORG/$r/issues" -d "$(jq -n --arg t "$TITLE" --arg b "$BODY" '{title:$t,body:$b,labels:["flaky-quarantine"]}')" >/dev/null 2>&1 || \
+      api -X POST "https://api.github.com/repos/$ORG/$r/issues" -d "$(jq -n --arg t "$TITLE" --arg b "$BODY" '{title:$t,body:$b}')" >/dev/null
Relevance

●● Moderate

PR intentionally uses issues for escalation; standards conflict is plausible but not clearly matched
historically.

PR-#51
PR-#19

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Rule 2801912 requires new automation to follow standards/automation/. That standard applies to
Actions workflows and limits machine feedback to failed check runs or ordinary PR comments, while
the added POST request creates a standalone issue.

Rule 2801912: Automation bots must comply with documented standards in standards/automation/
standards/automation/bot-channels.md[3-18]
governance/flaky-sweep.sh[47-50]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The sweep creates standalone GitHub issues even though the documented automation feedback standard limits bots to failed check runs or ordinary PR comments.

## Issue Context
Replace automatic issue creation with an approved feedback mechanism, or update the automation standard through the required governance process before using standalone issues as an escalation channel.

## Fix Focus Areas
- governance/flaky-sweep.sh[47-51]
- standards/automation/bot-channels.md[3-18]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Informational

7. GOVERNANCE_TOKEN bypasses approved scripts 📘 Rule violation ⛨ Security
Description
The workflow injects a generic organization secret that flaky-sweep.sh reuses for API operations
across every active repository. It neither obtains tokens through scripts/ghcb or
scripts/gh-app-token.sh nor limits each token to one target repository.
Code

.github/workflows/flaky-sweep.yml[25]

+          GH_TOKEN: ${{ secrets.GOVERNANCE_TOKEN }}
Relevance

● Weak

Recent PR #73 rejected the same cross-repository token-scope complaint on similar reasoning.

PR-#73

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Rule 2778539 requires authenticated automation to invoke an approved token script with
single-repository scope. The workflow directly maps secrets.GOVERNANCE_TOKEN to GH_TOKEN, while
the script sends that same token as a bearer credential while iterating over all repositories.

Rule 2778539: Agent operations must obtain GitHub tokens via approved scripts with single-repo scope
.github/workflows/flaky-sweep.yml[23-31]
governance/flaky-sweep.sh[12-16]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The sweep uses `GOVERNANCE_TOKEN` directly for authenticated GitHub API calls across multiple repositories instead of obtaining a single-repository token through an approved script.

## Issue Context
Provide the approved GitHub App credentials to the job, and obtain a fresh or cached repo-scoped token with `scripts/ghcb "$r"` for each repository before making API calls. Do not expose or reuse a generic organization-wide token.

## Fix Focus Areas
- .github/workflows/flaky-sweep.yml[23-31]
- governance/flaky-sweep.sh[12-16]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Context sources
✅ Compliance rules (platform): 14 rules
Review mode: ⚖️ Balanced: This adds behavior across a GitHub workflow, a fail-closed Bash/API scanner, and governance configuration, with security-sensitive token use, issue creation, YAML parsing, and multiple edge cases that warrant a complete single-pass review.
ⓘ  6 issues published inline · 7 in summary

Grey Divider

Tip of the day
💡 Did you know, you can copy the agent prompt from any finding and feed it to your IDE agent

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment thread governance/flaky-sweep.sh
Comment on lines +49 to +50
api -X POST "https://api.github.com/repos/$ORG/$r/issues" -d "$(jq -n --arg t "$TITLE" --arg b "$BODY" '{title:$t,body:$b,labels:["flaky-quarantine"]}')" >/dev/null 2>&1 || \
api -X POST "https://api.github.com/repos/$ORG/$r/issues" -d "$(jq -n --arg t "$TITLE" --arg b "$BODY" '{title:$t,body:$b}')" >/dev/null

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

2. flaky-sweep opens forbidden issues 📘 Rule violation § Compliance

The new automation reports quarantine violations by creating repository issues, but the automation
standard permits machine feedback only through failed check runs or ordinary PR comments. This
introduces a feedback channel outside the documented bot standards.
Agent Prompt
## Issue description
The sweep creates standalone GitHub issues even though the documented automation feedback standard limits bots to failed check runs or ordinary PR comments.

## Issue Context
Replace automatic issue creation with an approved feedback mechanism, or update the automation standard through the required governance process before using standalone issues as an escalation channel.

## Fix Focus Areas
- governance/flaky-sweep.sh[47-51]
- standards/automation/bot-channels.md[3-18]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment thread governance/flaky-sweep.sh
Comment on lines +22 to +25
OUT=$(python3 - "$r" "$MAX_DAYS" <<'PYEOF'
import sys, yaml, datetime
repo, max_days = sys.argv[1], int(sys.argv[2])
d = yaml.safe_load(sys.stdin) or {}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

3. Manifest content never parsed 🐞 Bug ≡ Correctness

python3 - consumes the heredoc as its program, leaving sys.stdin unavailable for
yaml.safe_load; the outer here-string does not provide a separate data stream to the Python
program. Consequently every valid quarantine manifest is treated as empty, so expired and malformed
entries are never detected.
Agent Prompt
## Issue description
The embedded Python program and quarantine YAML both attempt to use stdin. Ensure Python receives the program separately from the manifest data, and propagate parser failures.

## Issue Context
`python3 -` reads the heredoc from stdin as source code, so `yaml.safe_load(sys.stdin)` cannot then read the quarantine manifest supplied outside the command substitution.

## Fix Focus Areas
- governance/flaky-sweep.sh[22-43]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment thread governance/flaky-sweep.sh
Comment on lines +30 to +33
if not e.get(k):
malformed.append(f"{e} 缺 {k}")
try:
exp = datetime.date.fromisoformat(str(e["expires"]))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

4. Malformed manifests falsely pass 🐞 Bug ☼ Reliability

The parser assumes both the document and every quarantined entry are mappings, then accesses
missing required fields after merely recording them. Scalar/list documents, non-mapping entries, or
entries missing expires raise uncaught exceptions; without set -e or an explicit status check,
the shell continues with empty output and can exit successfully.
Agent Prompt
## Issue description
Validate the top-level YAML type, the `quarantined` collection type, and each entry before accessing fields. Treat every parsing or schema exception as a counted fail-closed violation.

## Issue Context
The current code calls mapping methods and indexes required keys without validating types or stopping after a missing-key finding. Command-substitution failure is not checked because the script omits `set -e`.

## Fix Focus Areas
- governance/flaky-sweep.sh[8-8]
- governance/flaky-sweep.sh[22-43]
- governance/flaky-sweep.sh[55-56]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment thread governance/flaky-sweep.sh
Comment on lines +51 to +52
echo "ISSUE repo '$r': 过期 $(grep -c . <<<"$EXP_LIST" || true) / 违规 $(grep -c . <<<"$MAL_LIST" || true)"
ISSUES=$((ISSUES+1)); EXPIRED=$((EXPIRED+$(grep -c . <<<"$EXP_LIST" || true)))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

5. Structural violations exit green 🐞 Bug ≡ Correctness

Parsed structural violations populate MAL_LIST, but line 52 only increments EXPIRED; MALFORMED
is reserved for content-fetch failures. A repository containing only invalid quarantine entries is
therefore reported as 违规仓=0 and the workflow exits successfully.
Agent Prompt
## Issue description
Increment the malformed repository counter whenever `MAL_LIST` is non-empty and ensure the final status fails for structural violations.

## Issue Context
The parser emits structural findings into `MAL_LIST`, but only fetch failures currently increment the counter checked at script exit.

## Fix Focus Areas
- governance/flaky-sweep.sh[44-56]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment thread governance/flaky-sweep.sh
Comment on lines +49 to +50
api -X POST "https://api.github.com/repos/$ORG/$r/issues" -d "$(jq -n --arg t "$TITLE" --arg b "$BODY" '{title:$t,body:$b,labels:["flaky-quarantine"]}')" >/dev/null 2>&1 || \
api -X POST "https://api.github.com/repos/$ORG/$r/issues" -d "$(jq -n --arg t "$TITLE" --arg b "$BODY" '{title:$t,body:$b}')" >/dev/null

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

6. Failed issue posts look successful 🐞 Bug ☼ Reliability

The API wrapper uses curl without --fail-with-body, so HTTP 4xx/5xx responses return success and
the unlabeled fallback is not attempted; transport failures from both attempts are also ignored
because set -e is disabled. The script then unconditionally prints ISSUE and increments
ISSUES, even when no escalation issue exists.
Agent Prompt
## Issue description
Make the API helper fail on non-2xx responses, validate the issue response, and only increment `ISSUES` after confirmed creation. If both labeled and unlabeled creation fail, record a failure that makes the sweep exit nonzero.

## Issue Context
Plain `curl -sS` treats GitHub HTTP errors as successful transfers, defeating the `||` fallback and allowing issue-creation failures to be reported as successes.

## Fix Focus Areas
- governance/flaky-sweep.sh[12-12]
- governance/flaky-sweep.sh[49-56]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment thread governance/flaky-sweep.sh
Comment on lines +46 to +49
if [[ -n "$EXP_LIST" || -n "$MAL_LIST" ]]; then
TITLE="[flaky] $r 隔离清单待处置(过期回炉/结构违规,ADR-0043)"
BODY="flaky-sweep 每日检测(ADR-0043):\n\n## 过期条目(已自动回炉——过期隔离不豁免,须修复测试或走 ADR 重新隔离)\n${EXP_LIST:--}\n\n## 结构违规\n${MAL_LIST:--}\n\n处置:修复测试后经 PR 移除条目(引用 ADR);或新 ADR 重新隔离。"
api -X POST "https://api.github.com/repos/$ORG/$r/issues" -d "$(jq -n --arg t "$TITLE" --arg b "$BODY" '{title:$t,body:$b,labels:["flaky-quarantine"]}')" >/dev/null 2>&1 || \

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

7. Daily sweep duplicates issues 🐞 Bug ☼ Reliability

Every run with a persistent expired or malformed entry unconditionally creates another issue without
looking for an existing sweep-owned issue. Because the workflow runs daily, unresolved violations
will produce one duplicate issue per repository per day.
Agent Prompt
## Issue description
Use a dedicated label or marker to find an existing open flaky-sweep issue and update or comment on it instead of creating a duplicate. Optionally close the owned issue when the repository becomes healthy.

## Issue Context
The scheduled workflow runs every day, while the script's only issue lifecycle operation is an unconditional POST whenever findings remain.

## Fix Focus Areas
- .github/workflows/flaky-sweep.yml[4-7]
- governance/flaky-sweep.sh[46-50]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant