-
Notifications
You must be signed in to change notification settings - Fork 0
feat: 波次预算执法闭环——conductor T7 解析存储 + cost-check 波次视图硬停三件套(W2-C3 后半,IR-0006) #433
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,9 @@ name: conductor | |
| # arbiter 裁决(宪法 §11 唤醒矩阵事件行"仲裁请求处理(/claim 等,转 arbiter)"); | ||
| # 仲裁是叠加授权层,transitions.yaml 转移表语义不变。三态:0=allow 继续原动作、 | ||
| # 1=deny 审计 no-op(对齐 silent-drop)、2=infra run 红灯 fail-closed 不放行。 | ||
| # W2-C3(.github#414 / BEH-07 / IFACE-03):T7 增设 wave schema 谓词——卡 body | ||
| # 波次块(budget/capabilities/evidence)非法拒绝就绪(fail-closed);合法 wave-meta | ||
| # 解析后以幂等标记(wave-meta:v1)评论落卡(conductor 解析存储)。 | ||
| on: | ||
| issues: | ||
| types: [labeled] | ||
|
|
@@ -55,6 +58,7 @@ jobs: | |
| path: gov | ||
| sparse-checkout: | | ||
| governance/transitions.yaml | ||
| governance/wave_schema.py | ||
| scripts/gh-app-token.sh | ||
| persist-credentials: false | ||
| # arbiter 受信 checkout(ADR-0055):conductor 只在 main 上下文运行事件路由, | ||
|
|
@@ -437,6 +441,44 @@ jobs: | |
| api(E["APP_TOKEN"], f"/repos/{REPO}/issues/{ISSUE}/labels/state%3Awave-planned", "DELETE") | ||
| raise SystemExit(0) | ||
|
|
||
| # ---- W2-C3(.github#414 / BEH-07 / IFACE-03):T7 wave schema 谓词 ---- | ||
| # 卡 body 波次块(budget/capabilities/evidence)存在但非法 → 拒绝就绪 | ||
| # (fail-closed:wave_schema.py validate exit 3;无块=缺省无约束语义,放行)。 | ||
| # 合法且含块 → 解析 wave-meta(结构化 JSON),转移成功后以幂等标记评论 | ||
| # 存储在本卡(下游 cost-check 波次视图按卡 body 同源对账,评论=解析结果的 | ||
| # 机器可读镜像)。 | ||
| wave_meta_json = None | ||
| if t["id"] == "T7": | ||
| import tempfile | ||
| with tempfile.NamedTemporaryFile("w", suffix=".md", delete=False, | ||
| encoding="utf-8") as btf: | ||
| btf.write(iss.get("body") or "") | ||
| body_path = btf.name | ||
| try: | ||
| rc_v = subprocess.call(["python3", "gov/governance/wave_schema.py", | ||
| "validate", "--body-file", body_path]) | ||
| if rc_v == 3: | ||
| audit("verdict=DENIED-wave-schema-invalid T7 拒绝——波次块非法" | ||
| "(W2-C3 IFACE-03;fail-closed,标签已回退)") | ||
| api(E["APP_TOKEN"], f"/repos/{REPO}/issues/{ISSUE}/labels/state%3Aready", "DELETE") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win 检查回退标签的写入结果。 Line 463 忽略了删除 在删除失败时记录 HTTP 状态并以失败退出。 🤖 Prompt for AI Agents |
||
| raise SystemExit(0) | ||
| if rc_v != 0: | ||
| audit(f"verdict=ABORT wave_schema validate rc={rc_v}(fail-closed——infra)") | ||
| raise SystemExit(1) | ||
| p = subprocess.run(["python3", "gov/governance/wave_schema.py", "parse", | ||
| "--body-file", body_path, "--card", f"{REPO}#{ISSUE}"], | ||
| capture_output=True, text=True) | ||
| finally: | ||
| os.unlink(body_path) | ||
| if p.returncode != 0: | ||
| audit(f"verdict=ABORT wave_schema parse rc={p.returncode}(fail-closed——infra)") | ||
| raise SystemExit(1) | ||
| try: | ||
| wave_meta_json = json.loads(p.stdout or "{}") | ||
| except json.JSONDecodeError: | ||
| audit("verdict=ABORT wave-meta 解析输出非 JSON(fail-closed)") | ||
| raise SystemExit(1) | ||
|
|
||
| # ---- ADR-0085:T8 卡完成谓词(存在绑定本卡且已合并的 PR)---- | ||
| def check_merged_pr(issue_number): | ||
| """卡完成谓词:存在 body 含 Card: <repo>#<n> 绑定行且已合并的 PR。 | ||
|
|
@@ -542,6 +584,28 @@ jobs: | |
| f"claim->in-progress assignee={actor}") | ||
| else: | ||
| swap_state(t["from_state"], t["to_state"]) | ||
| # W2-C3(.github#414):T7 解析存储——合法 wave-meta 以幂等标记评论 | ||
| # 落卡(重投/重复标签不重复评论;写失败=fail-closed 红灯,状态已切 | ||
| # 但存储缺失在 run 日志+on-failure 评论双面可见) | ||
| if t["id"] == "T7" and wave_meta_json: | ||
|
Comment on lines
586
to
+590
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 4. Metadata failure strands ready card T7 changes the card state before reading or writing the wave-meta comment, so a comment API failure leaves the card in ready without the required parsed metadata. Redelivery cannot repair it because T7 only matches wave-planned → ready, making the failed storage step a permanent no-op unless someone manually rolls the state back. Agent Prompt
|
||
| marker = "wave-meta:v1" | ||
| st_cm, cms = api(E["APP_TOKEN"], | ||
| f"/repos/{REPO}/issues/{ISSUE}/comments?per_page=100") | ||
| if st_cm != 200: | ||
| audit(f"verdict=ABORT wave-meta 评论读取失败 HTTP {st_cm}(fail-closed)") | ||
| raise SystemExit(1) | ||
|
Comment on lines
+594
to
+596
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift 在状态转移前持久化 此处读取评论失败时,Line 586 的 先写入元数据再转移状态,或在元数据写入失败时将状态补偿回 🤖 Prompt for AI Agents |
||
| if not any(marker in (c.get("body") or "") for c in cms or []): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 8. Marker comments are spoofable The idempotency check accepts the substring wave-meta:v1 in any comment, so any preexisting human comment containing that text suppresses the authoritative T7 metadata write. The card then reaches ready with no parsed metadata comment even though the workflow reports the transition as allowed. Agent Prompt
|
||
| st_pc, _ = api(E["APP_TOKEN"], | ||
| f"/repos/{REPO}/issues/{ISSUE}/comments", "POST", | ||
| {"body": f"<!-- {marker} -->\n" | ||
| "**wave-meta(T7 解析存储,IR-0006 W2-C3 / IFACE-03)**\n" | ||
| "```json\n" | ||
| + json.dumps(wave_meta_json, ensure_ascii=False, sort_keys=True) | ||
| + "\n```"}) | ||
| if st_pc not in (200, 201): | ||
| audit(f"verdict=ABORT wave-meta 评论写失败 HTTP {st_pc}(fail-closed)") | ||
| raise SystemExit(1) | ||
| audit("wave-meta 评论已存储(T7 解析存储,W2-C3)") | ||
| out.write("invoke=none\n") | ||
| audit(f"event={ev} transition={t['id']} sender_role={role} verdict=ALLOWED " | ||
| f"{t['from_state']}->{t['to_state']} action=noop") | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -9,13 +9,19 @@ | |||||||||||||
| # LLM token 通道(W2-C3 .github#216,ADR-0062):data_source=ciw-metering 时按角色档归账 | ||||||||||||||
| # (CI-Workflows metering-ledger 分支 → metering.py aggregate,先验链后归账); | ||||||||||||||
| # 链断/拉取失败 = INFRA fail-closed(exit 2),不静默归零不盲熔断。 | ||||||||||||||
| # 波次预算通道(W2-C3 .github#414,BEH-07 / ADR-0103):open type:card 卡 body 的 | ||||||||||||||
| # budget 块(四元组+on_exceed)vs 统一账本按 subject 聚合(evidence-query 三源 | ||||||||||||||
| # 先验链后归账);hard-stop 卡超限 → 与 Actions/LLM 同一硬停档三件套(熔断变量+ | ||||||||||||||
| # 撤 auto-merge+P0,ADR-0040 复位流程不变);链断/块非法 = INFRA fail-closed。 | ||||||||||||||
| # 熔断消费点:agent 派发/automerge 前置检查(AGENTS.md 行为契约)+ auto-fix-limit.sh | ||||||||||||||
| # 每轮机器执法撤 auto-merge。复位仅人工(owner PATCH/DELETE 变量 + P0 issue 留评论); | ||||||||||||||
| # 本脚本观察到"变量已复位且用量 <100%"后自动关闭 P0 issue(复位留痕=issue 评论历史)。 | ||||||||||||||
| # | ||||||||||||||
| # 用法: GH_TOKEN=<org admin token> bash cost-check.sh | ||||||||||||||
| # 注入(T2,不依赖真实超支): COST_USAGE_MINUTES_OVERRIDE / COST_QUOTA_MINUTES_OVERRIDE / | ||||||||||||||
| # COST_LLM_TOKENS_USED_OVERRIDE / COST_LLM_TOKENS_QUOTA_OVERRIDE / COST_DRY_RUN=1(只报告不写) | ||||||||||||||
| # COST_LLM_TOKENS_USED_OVERRIDE / COST_LLM_TOKENS_QUOTA_OVERRIDE / | ||||||||||||||
| # COST_WAVE_CARDS_FILE(本地卡清单 JSON)/ COST_WAVE_LEDGER_DIR(本地统一账本目录)/ | ||||||||||||||
| # COST_DRY_RUN=1(只报告不写) | ||||||||||||||
| # 退出码: 0=未达阈值 | 1=触发告警/熔断(运行变红=可见信号)| 2=基础设施故障(fail-closed) | ||||||||||||||
| set -uo pipefail | ||||||||||||||
|
|
||||||||||||||
|
|
@@ -193,6 +199,57 @@ llm_channel_account() { | |||||||||||||
| } | ||||||||||||||
| # @w2c3-llm-channel-end | ||||||||||||||
|
|
||||||||||||||
| # ---------- 波次预算对账(W2-C3 .github#414,BEH-07 / ADR-0103:统一账本 subject 聚合) ---------- | ||||||||||||||
| # @w2c3-wave-channel-begin(governance/tests/test-cost-wave-channel.sh 按标记对提取本函数体 | ||||||||||||||
| # 离线单测——标记对缺失=测试红,防"测试测影子",同 llm-channel 模式) | ||||||||||||||
| wave_channel_check() { | ||||||||||||||
| # → stdout 单行 "WAVE-EXCEEDED<TAB>超限行json" | "WAVE-OK<TAB>说明" | "INFRA<TAB>说明"。 | ||||||||||||||
| # 卡面=$GOV_REPO open type:card(body 含 budget 块才有约束,缺省=无预算语义); | ||||||||||||||
| # 聚合源=统一账本(evidence-query.sh 三源拉取+验链→shadow-evidence-unified.jsonl, | ||||||||||||||
| # 文件名命中 wave_check 的 shadow-evidence-*.jsonl glob——先验链后归账,同 LLM 通道)。 | ||||||||||||||
| # 本函数经命令替换调用(子 shell),不直接调 infra/ok(计数会丢)——标签由调用方 | ||||||||||||||
| # 在父 shell 落账。env 注入(T2):COST_WAVE_CARDS_FILE=本地卡清单 JSON、 | ||||||||||||||
| # COST_WAVE_LEDGER_DIR=本地账本目录(shadow-evidence-*.jsonl)。 | ||||||||||||||
| local cards="${COST_WAVE_CARDS_FILE:-}" led="${COST_WAVE_LEDGER_DIR:-}" out rc=0 | ||||||||||||||
| if [[ -z "$cards" ]]; then | ||||||||||||||
| cards=$(mktemp) || { printf 'INFRA\t波次卡清单临时文件创建失败\n'; return 0; } | ||||||||||||||
| if ! "$GH" issue list --repo "$GOV_REPO" --state open --label type:card --limit 300 \ | ||||||||||||||
| --json number,body >"$cards" 2>/dev/null; then | ||||||||||||||
|
Comment on lines
+216
to
+217
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 5. Card scan stops at 300 The production wave card query is capped at 300 issues, so every matching open card beyond that limit is omitted from budget reconciliation. An over-budget hard-stop card outside the first 300 therefore cannot trip the circuit breaker. Agent Prompt
Comment on lines
+216
to
+217
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win 🔎 Supported by static analysis🏁 Script executed: #!/usr/bin/env bash
set -euo pipefail
count=$(gh issue list \
--repo Cloudbird-Software/.github \
--state open \
--label type:card \
--limit 10000 \
--json number \
--jq 'length')
printf 'open type:card count: %s\n' "$count"
test "$count" -le 300Repository: Cloudbird-Software/.github Length of output: 189 🏁 Script executed: #!/usr/bin/env bash
set -euo pipefail
printf '%s\n' '--- repository conventions ---'
find /tmp/coderabbit-repo-knowledge/cloudbird-software-github-0dfcc7f5 -maxdepth 2 -type f -name '*.md' -print
printf '%s\n' '--- cost-check.sh relevant flow ---'
sed -n '170,245p' governance/cost-check.sh
printf '%s\n' '--- directly bound wave-check definitions and callers ---'
rg -n -C 8 'wave-check|wave_schema|wave_channel_check|--limit 300|WAVE-OK|INFRA' governanceRepository: Cloudbird-Software/.github Length of output: 50382 🏁 Script executed: #!/usr/bin/env bash
set -euo pipefail
printf '%s\n' '--- governance convention ---'
cat /tmp/coderabbit-repo-knowledge/cloudbird-software-github-0dfcc7f5/conventions/governance.md
printf '%s\n' '--- gh issue list limit contract ---'
gh issue list --help | sed -n '/--limit/,+3p'
printf '%s\n' '--- wave channel continuation and policy contract ---'
sed -n '234,305p' governance/cost-check.shRepository: Cloudbird-Software/.github Length of output: 3610 分页读取全部预算卡片
🤖 Prompt for AI Agents |
||||||||||||||
| printf 'INFRA\t波次卡清单拉取失败(%s open type:card)——预算面不可知,fail-closed\n' "$GOV_REPO" | ||||||||||||||
| return 0 | ||||||||||||||
| fi | ||||||||||||||
| fi | ||||||||||||||
| if [[ -z "$led" ]]; then | ||||||||||||||
| led=$(mktemp -d) || { printf 'INFRA\t统一账本临时目录创建失败\n'; return 0; } | ||||||||||||||
| if ! bash "$DIR/evidence-query.sh" >"$led/shadow-evidence-unified.jsonl" 2>"$led/eq.err"; then | ||||||||||||||
| printf 'INFRA\t统一账本查询失败(链断/拉取失败——不可信数据不判定,不盲熔断):%.200s\n' \ | ||||||||||||||
| "$(tail -c 200 "$led/eq.err" 2>/dev/null)" | ||||||||||||||
| return 0 | ||||||||||||||
| fi | ||||||||||||||
| fi | ||||||||||||||
| out=$(python3 "$DIR/wave_schema.py" wave-check --cards "$cards" --ledger-dir "$led" 2>/dev/null) || rc=$? | ||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 6. Card identity ignores org The added channel fetches cards from configurable $ORG/.github, but wave_schema.py always constructs Cloudbird-Software/.github#N for lookup. With an ORG override, legitimate ledger usage is ignored or another organization’s same-numbered card is charged, causing false negatives or false hard stops. Agent Prompt
|
||||||||||||||
| if [[ $rc -eq 2 ]]; then | ||||||||||||||
| printf 'INFRA\twave-check 执行失败(参数/环境 rc=2)\n'; return 0 | ||||||||||||||
|
Comment on lines
+230
to
+232
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win 将所有非 hard-stop 的
仅允许 建议修复- if [[ $rc -eq 2 ]]; then
- printf 'INFRA\twave-check 执行失败(参数/环境 rc=2)\n'; return 0
+ if [[ $rc -ne 0 && $rc -ne 4 ]]; then
+ printf 'INFRA\twave-check 执行失败(rc=%s)\n' "$rc"; return 0
fi📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||
| fi | ||||||||||||||
|
Comment on lines
+230
to
+233
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 2. Wave failures become ok wave_channel_check handles only exit code 2 from wave_schema.py; any other unexpected failure can leave out empty, which the next Python snippet parses as [] and reports as WAVE-OK. For example, a chain-valid ledger record with a non-numeric cost value raises during aggregation and silently disables the hard stop. Agent Prompt
|
||||||||||||||
| python3 -c 'import json,sys | ||||||||||||||
| rows = json.loads(sys.stdin.read() or "[]") | ||||||||||||||
| bad = [r for r in rows if r.get("error")] | ||||||||||||||
| if bad: | ||||||||||||||
| print("INFRA\t波次卡块非法(预算面盲区,fail-closed):" + "; ".join(r["card"] + " " + r["error"] for r in bad)) | ||||||||||||||
| sys.exit(0) | ||||||||||||||
| hard = [r for r in rows if r.get("exceeded_dims") and r.get("on_exceed") == "hard-stop"] | ||||||||||||||
| warn = [r for r in rows if r.get("exceeded_dims") and r.get("on_exceed") == "warn"] | ||||||||||||||
| if hard: | ||||||||||||||
| print("WAVE-EXCEEDED\t" + json.dumps(hard, ensure_ascii=False)) | ||||||||||||||
| sys.exit(0) | ||||||||||||||
| nb = sum(1 for r in rows if not r.get("error")) | ||||||||||||||
| extra = "" | ||||||||||||||
| if warn: | ||||||||||||||
| extra = ";warn 超限(只报告不判定):" + ", ".join(r["card"] + ":" + "+".join(r["exceeded_dims"]) for r in warn) | ||||||||||||||
| print("WAVE-OK\t预算卡 %d 张对账无 hard-stop 超限%s" % (nb, extra))' <<<"$out" | ||||||||||||||
| } | ||||||||||||||
| # @w2c3-wave-channel-end | ||||||||||||||
|
|
||||||||||||||
| PCT_TOK="" | ||||||||||||||
| USED_TOK="" | ||||||||||||||
| LLM_ROLES="" | ||||||||||||||
|
|
@@ -226,6 +283,24 @@ else | |||||||||||||
| infra "LLM token 数据源未知:$LT_SOURCE(policy cost.llm_tokens.data_source 无此形态)" | ||||||||||||||
| fi | ||||||||||||||
|
|
||||||||||||||
| # ---------- 波次预算通道(W2-C3 .github#414,BEH-07:统一账本按 subject 聚合对账) ---------- | ||||||||||||||
| STOP_WAVE="False" | ||||||||||||||
| WAVE_EXCEEDED="" | ||||||||||||||
| WAVE_SUMMARY="" | ||||||||||||||
| WLINE=$(wave_channel_check) || true | ||||||||||||||
| IFS=$'\t' read -r WTAG WVAL <<<"$WLINE" | ||||||||||||||
| case "$WTAG" in | ||||||||||||||
| WAVE-EXCEEDED) | ||||||||||||||
| # BEH-07:hard-stop 卡超限 → 进硬停档三件套(下方与 Actions/LLM 同档执法) | ||||||||||||||
| STOP_WAVE="True"; WAVE_EXCEEDED="$WVAL" | ||||||||||||||
| WAVE_SUMMARY="波次预算超限(hard-stop,BEH-07): $WVAL" | ||||||||||||||
| ok "$WAVE_SUMMARY" | ||||||||||||||
| ;; | ||||||||||||||
| WAVE-OK) WAVE_SUMMARY="波次预算(波次视图): $WVAL"; ok "$WAVE_SUMMARY" ;; | ||||||||||||||
| INFRA) infra "$WVAL" ;; | ||||||||||||||
| *) infra "波次通道输出不可解析(期望 WAVE-EXCEEDED/WAVE-OK/INFRA 标签):$WLINE" ;; | ||||||||||||||
| esac | ||||||||||||||
|
|
||||||||||||||
| # ---------- 熔断当前状态 ---------- | ||||||||||||||
| BREAKER_SET=0 | ||||||||||||||
| # 读取 rc 单独捕获(W2-C3 顺带修复的潜在缺陷):变量存在且 value=false(人工复位后 | ||||||||||||||
|
|
@@ -287,23 +362,29 @@ set_breaker() { # PATCH 已有 / POST 新建(404 时) | |||||||||||||
| fi | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| # ---------- 硬停档(任一指标 ≥100%) ---------- | ||||||||||||||
| if [[ "$STOP_MIN" == "True" || "$STOP_TOK" == "True" ]]; then | ||||||||||||||
| # ---------- 硬停档(任一指标 ≥100%,或波次预算 hard-stop 卡超限——BEH-07) ---------- | ||||||||||||||
| if [[ "$STOP_MIN" == "True" || "$STOP_TOK" == "True" || "$STOP_WAVE" == "True" ]]; then | ||||||||||||||
| TRIPPED=1 | ||||||||||||||
| act "硬停档触发(Actions=${PCT_MIN}% LLM=${PCT_TOK:--}%)——置 $CB_VARIABLE + 撤 auto-merge + P0" | ||||||||||||||
| act "硬停档触发(Actions=${PCT_MIN}% LLM=${PCT_TOK:--}% 波次超限=${STOP_WAVE})——置 $CB_VARIABLE + 撤 auto-merge + P0" | ||||||||||||||
| set_breaker | ||||||||||||||
|
Comment on lines
+365
to
369
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 3. Wave breaker issue auto-closes On a first wave hard-stop when the breaker variable was initially absent or false, set_breaker does not update the previously read BREAKER_SET=0; the later reset branch can therefore immediately close the P0 issue just created by this block. The same wave-unaware reset path can close an existing P0 when the wave channel is INFRA, falsely announcing recovery while its budget state is unknown. Agent Prompt
|
||||||||||||||
| strip_all_automerge | ||||||||||||||
| label_ensure "$GOV_REPO" cost-circuit-breaker b60205 | ||||||||||||||
| P0_EXISTING=$(gov_open_issues cost-circuit-breaker | grep -m1 "成本熔断" | cut -f1) | ||||||||||||||
| if [[ "$STOP_WAVE" == "True" ]]; then | ||||||||||||||
| P0_TITLE="P0 成本熔断:波次预算超限达硬停档($CB_VARIABLE 已置位,BEH-07)" | ||||||||||||||
| else | ||||||||||||||
| P0_TITLE="P0 成本熔断:Actions 分钟 ${PCT_MIN}% 达硬停档($CB_VARIABLE 已置位)" | ||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win 为 LLM-only 硬停生成正确的 P0 标题。 当 在 Actions 分支前增加 LLM-only 分支。 🤖 Prompt for AI Agents |
||||||||||||||
| fi | ||||||||||||||
| P0_BODY="P0:额度/成本熔断已置位(ADR-0040,运行 $(date -u +%FT%TZ))。 | ||||||||||||||
|
|
||||||||||||||
| - Actions 分钟($YEAR-$MONTH): $USED_MIN / $AM_QUOTA = ${PCT_MIN}%(阈值 $AM_STOP%)${PCT_TOK:+ | ||||||||||||||
| - ${LLM_SUMMARY:-LLM token: $USED_TOK}(阈值 $LT_STOP%,ADR-0062 归账通道)} | ||||||||||||||
| - ${LLM_SUMMARY:-LLM token: $USED_TOK}(阈值 $LT_STOP%,ADR-0062 归账通道)}${WAVE_EXCEEDED:+ | ||||||||||||||
| - 波次预算超限(BEH-07,ADR-0103 统一账本 subject 聚合): $WAVE_EXCEEDED} | ||||||||||||||
| - 已执行:org 变量 \`$CB_VARIABLE\`=true;全部 open PR 的 auto-merge 已撤销。 | ||||||||||||||
| - 效果:agent 派发与 automerge 前置检查将拒绝启动(AGENTS.md);auto-fix-limit 每轮机器执法撤销新 enable。 | ||||||||||||||
|
|
||||||||||||||
| 处置(仅 $CB_RESET_BY,人工): | ||||||||||||||
| 1. 排查用量根因(失控循环查 auto-fix-limit 的 issue 历史); | ||||||||||||||
| 1. 排查用量根因(失控循环查 auto-fix-limit 的 issue 历史;波次超限查上列卡的 dispatch/计量记录——收口超限卡或调 budget 块后再复位); | ||||||||||||||
| 2. 复位:\`gh api -X PATCH orgs/$ORG/actions/variables/$CB_VARIABLE -f name=$CB_VARIABLE -f value=false\`(或 DELETE 该变量); | ||||||||||||||
| 3. 在本 issue 留复位评论(留痕);cost-check 确认变量复位且用量 <${AM_STOP}% 后自动关闭本 issue。" | ||||||||||||||
| if [[ -n "$P0_EXISTING" ]]; then | ||||||||||||||
|
|
@@ -312,7 +393,7 @@ if [[ "$STOP_MIN" == "True" || "$STOP_TOK" == "True" ]]; then | |||||||||||||
| fi | ||||||||||||||
| else | ||||||||||||||
| mutate "$GH" issue create --repo "$GOV_REPO" \ | ||||||||||||||
| --title "P0 成本熔断:Actions 分钟 ${PCT_MIN}% 达硬停档($CB_VARIABLE 已置位)" \ | ||||||||||||||
| --title "$P0_TITLE" \ | ||||||||||||||
| --body "$P0_BODY" --label cost-circuit-breaker >/dev/null 2>&1 \ | ||||||||||||||
| || infra "P0 issue 开立失败" | ||||||||||||||
| fi | ||||||||||||||
|
|
||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1. Empty blocks bypass enforcement
🐞 Bug≡ CorrectnessAgent Prompt
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools