-
Notifications
You must be signed in to change notification settings - Fork 0
governance: auto-fix 上限执法 + 额度/成本熔断(P2-8,ADR-0040) #116
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
2b4cc9a
governance: auto-fix 上限执法 + 成本熔断(P2-8,ADR-0040)
randypanding 6563331
governance: auto-fix 上限执法 + 成本熔断(P2-8,ADR-0040)
randypanding 590d4b8
governance: auto-fix 上限执法 + 成本熔断(P2-8,ADR-0040)
randypanding 986a2a1
governance: auto-fix 上限执法 + 成本熔断(P2-8,ADR-0040)
randypanding f4bee7e
governance: auto-fix 上限执法 + 成本熔断(P2-8,ADR-0040)
randypanding 6b6b4f2
governance: auto-fix 上限执法 + 成本熔断(P2-8,ADR-0040)
randypanding 7a8b368
governance: auto-fix 上限执法 + 成本熔断(P2-8,ADR-0040)
randypanding 7806ace
ci: 修复 gate 脚本语法检查块——注释不得插在未续行的命令中间(ADR-0040)
randypanding File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| name: auto-fix-limit | ||
| # agent 修复循环上限执法(ADR-0040,P2-8 .github#93): | ||
| # 小时级扫描受管仓 agent open PR 的 gate 失败计数(真源=Checks API,崩溃续接), | ||
| # 达上限(policy/automation-limits.yaml,默认 3)→ 撤 auto-merge + 关 PR + 开说明 issue; | ||
| # 熔断变量置位时每轮撤全部 open PR 的 auto-merge(硬停机器执法,旁路窗口 ≤1h)。 | ||
| # 脚本细节/注入通道见 governance/auto-fix-limit.sh 头注。 | ||
| on: | ||
| schedule: | ||
| - cron: "18 * * * *" # 每小时 :18(避开整点 governance-drift 高峰) | ||
| workflow_dispatch: | ||
| # 注入入口(T1 测试/聚焦扫描):空=走 policy 真源,不留常开旁路 | ||
| inputs: | ||
| max_attempts: | ||
| description: "auto-fix 上限覆盖(空=policy 值)" | ||
| required: false | ||
| default: "" | ||
| check_name: | ||
| description: "计数的 check 名覆盖(空=gate)" | ||
| required: false | ||
| default: "" | ||
| repos: | ||
| description: "扫描仓覆盖(逗号表,空=REPOS.yaml 全量 active)" | ||
| required: false | ||
| default: "" | ||
| all_prs: | ||
| description: "扫描全部 open PR(true=不限 agent 作者;空=仅 agent+opt-in)" | ||
| required: false | ||
| default: "" | ||
| dry_run: | ||
| description: "1=只报告不执行写操作(T1 预检)" | ||
| required: false | ||
| default: "" | ||
|
|
||
| permissions: {} | ||
|
|
||
| # 串行化:关 PR/开 issue 的"查重→写"非原子,并发运行会重复开 issue(同 governance-drift 设计) | ||
| concurrency: | ||
| group: auto-fix-limit | ||
| cancel-in-progress: false | ||
|
|
||
| jobs: | ||
| scan: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 15 | ||
| permissions: | ||
| contents: read | ||
| steps: | ||
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
| with: | ||
| persist-credentials: false | ||
| - name: 扫描并执法(超限关 PR;exit 1=有超限 2=基础设施故障) | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GOVERNANCE_TOKEN }} | ||
| AUTOFIX_MAX_ATTEMPTS: ${{ inputs.max_attempts }} | ||
| AUTOFIX_CHECK_NAME: ${{ inputs.check_name }} | ||
| AUTOFIX_REPOS: ${{ inputs.repos }} | ||
| AUTOFIX_ALL_PRS: ${{ inputs.all_prs }} | ||
| AUTOFIX_DRY_RUN: ${{ inputs.dry_run }} | ||
| run: bash governance/auto-fix-limit.sh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| name: cost-check | ||
| # 额度/成本熔断(ADR-0040,P2-8 .github#93): | ||
| # 6h 周期拉取 /orgs/{org}/settings/billing/usage 当月 Actions 分钟 vs | ||
| # policy/automation-limits.yaml 声明预算——≥80% 告警 issue;≥100% 置 org 变量 | ||
| # AUTO_MERGE_DISABLED + 撤全部 open PR auto-merge + P0 issue。复位仅人工(变量 PATCH/DELETE | ||
| # + P0 留评论),脚本观察到复位后自动关 P0。脚本细节/注入通道见 governance/cost-check.sh 头注。 | ||
| on: | ||
| schedule: | ||
| - cron: "42 */6 * * *" # 每 6h :42(避开整点 governance-drift 与 :18 auto-fix-limit) | ||
| workflow_dispatch: | ||
| # 注入入口(T2 注入式测试:79%/85%/100% 全场景不依赖真实超支):空=真实 API/真源 | ||
| inputs: | ||
| usage_minutes_override: | ||
| description: "当月 Actions 分钟用量覆盖(数值;空=billing API 真实值)" | ||
| required: false | ||
| default: "" | ||
| quota_minutes_override: | ||
| description: "月预算分钟覆盖(空=policy 值)" | ||
| required: false | ||
| default: "" | ||
| llm_tokens_used_override: | ||
| description: "LLM token 用量覆盖(pending 数据源的注入测试通道)" | ||
| required: false | ||
| default: "" | ||
| llm_tokens_quota_override: | ||
| description: "LLM token 月预算覆盖(空=policy 值)" | ||
| required: false | ||
| default: "" | ||
| dry_run: | ||
| description: "1=只报告不执行写操作(含不置熔断变量——注入预检用)" | ||
| required: false | ||
| default: "" | ||
|
|
||
| permissions: {} | ||
|
|
||
| concurrency: | ||
| group: cost-check | ||
| cancel-in-progress: false | ||
|
|
||
| jobs: | ||
| check: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 15 | ||
| permissions: | ||
| contents: read | ||
| steps: | ||
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
| with: | ||
| persist-credentials: false | ||
| - name: 用量检查与熔断(exit 1=触发告警/熔断 2=基础设施故障) | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GOVERNANCE_TOKEN }} | ||
| COST_USAGE_MINUTES_OVERRIDE: ${{ inputs.usage_minutes_override }} | ||
| COST_QUOTA_MINUTES_OVERRIDE: ${{ inputs.quota_minutes_override }} | ||
| COST_LLM_TOKENS_USED_OVERRIDE: ${{ inputs.llm_tokens_used_override }} | ||
| COST_LLM_TOKENS_QUOTA_OVERRIDE: ${{ inputs.llm_tokens_quota_override }} | ||
| COST_DRY_RUN: ${{ inputs.dry_run }} | ||
| run: bash governance/cost-check.sh | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
4. Dispatch grants org-wide mutations
🐞 Bug⛨ SecurityAgent Prompt
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools