Skip to content

Commit 0116fd4

Browse files
Pigbibicodex
andcommitted
Add automation authority and ledger endpoints
Co-Authored-By: Codex <noreply@openai.com>
1 parent 09fc747 commit 0116fd4

11 files changed

Lines changed: 1881 additions & 6 deletions

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ When a source issue contains a `codex-pr-feedback` marker from a failed CI run o
3333

3434
This avoids hard-coding Codex CLI setup in every source repository and avoids depending on a repository outside the `QuantStrategyLab` organization.
3535

36+
Automation authority is intentionally split from model confidence. The service treats routine low-risk maintenance as auto-merge eligible, allows already-live same-family strategy optimization to auto-merge only when service-owned checks provide trusted proof and the repo/autonomy policy already allows auto-merge, and keeps new/reconstructed strategies, live-candidate promotion, plugin position-control changes, broker/order execution changes, workflow permissions, and secrets behind human review. `POST /v1/ai/automation/authority` accepts request metadata only as restrictive hints; it cannot relax the policy for live-impacting automation.
37+
38+
Static-token dashboards can read automation control and run-ledger state only for repositories listed in `CODEX_AUDIT_SERVICE_DASHBOARD_REPOSITORIES`; write endpoints still require GitHub OIDC or local test auth.
39+
40+
Automation run state is persisted through the service ledger. Async Codex jobs are recorded automatically; external workflows can also call `POST /v1/ai/automation/runs`. Ledger ownership follows `source_repository` when present, otherwise the authenticated repository. Operators and dashboards can read `GET /v1/ai/automation/runs`, `GET /v1/ai/automation/runs/{run_id}`, and `GET /v1/ai/automation/control` to decide whether to continue, pause auto-fix, switch to review-only, or escalate.
41+
3642
## Compatibility governance role
3743

3844
`QuantStrategyLab/AIAuditBridge` is an ops/control-plane consumer only:

README.zh-CN.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,16 @@ Codex 执行现在只走 service backend:workflow 从 GitHub-hosted runner 调
3131

3232
当源 issue 中出现 CI 失败或 requested-changes review 产生的 `codex-pr-feedback` marker 时,bridge 会把本次运行视为有界重试。只要 marker 指向的 PR 仍然 open、同仓、base 是请求的 source ref,并且 head 分支属于同一个 monthly issue,bridge 会更新现有 PR 分支,而不是再创建一个新 PR。在清理该 PR 上旧的受控自动合并 label 前,bridge 会复用 baseline policy label;如果 policy 无效,或 auto-merge / human-review label 无法安全区分,则跳过 label mutation。
3333

34+
Automation authority 与模型置信度分离:低风险例行维护可进入 auto-merge;已 live 的同族策略优化只有在服务端可信 proof 完整、且仓库/自治策略本身已允许 auto-merge 时才可自动合并;新建/重构策略、live-candidate 晋升、影响仓位控制的插件、broker/order 执行、workflow 权限与 secrets 始终保留人工复核边界。`POST /v1/ai/automation/authority` 中的请求 metadata 只能收紧决策,不能放宽 live-impacting 自动化策略。
35+
36+
Static-token dashboard 只能读取 `CODEX_AUDIT_SERVICE_DASHBOARD_REPOSITORIES` 中列出的仓库的 automation control 与 run-ledger 状态;写接口仍要求 GitHub OIDC 或本地测试 auth。
37+
3438
这样可以避免每个 source repository 都硬编码 Codex CLI,也不会依赖 `QuantStrategyLab` 组织外的仓库。
3539

40+
自动化授权层和模型置信度分开处理。service 将低风险日常维护视为可自动合并;已 live 的同族策略优化只有在 service-owned 检查给出 trusted proof 时才允许自动合并;新策略/重构策略、live-candidate 提升、插件 position-control、券商/订单执行、workflow 权限和 secrets 相关变更都保留人工复核。`POST /v1/ai/automation/authority` 接收的请求 metadata 只能作为降权提示,不能放宽 live 影响自动化 policy。
41+
42+
自动化运行状态通过 service ledger 持久化。异步 Codex job 会自动记录;外部 workflow 也可调用 `POST /v1/ai/automation/runs` 写入状态。Ledger owner 优先使用 `source_repository`,没有时回退到认证仓库。Dashboard 或运维脚本可读取 `GET /v1/ai/automation/runs``GET /v1/ai/automation/runs/{run_id}``GET /v1/ai/automation/control`,判断继续执行、暂停 auto-fix、切到 review-only 或升级人工处理。
43+
3644
## 兼容性治理定位
3745

3846
`QuantStrategyLab/AIAuditBridge` 只作为 ops/control-plane 的消费侧参与兼容治理:

docs/architecture.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ operations: **Analyze**, **Execute**, and **Review**.
4343
| `health.py` | Online endpoint metrics, error rates, latency tracking |
4444
| `quota.py` | Per-repo budget enforcement, model cost estimation |
4545
| `autonomy.py` | Confidence scoring, change risk classification |
46+
| `automation_authority.py` | Machine-readable live-impact authority policy |
47+
| `automation_run_ledger.py` | Persistent automation run state and runtime control suggestions |
4648
| `feedback.py` | Closed-loop change tracking and evaluation |
4749

4850
### Adapters (`service/adapters/`)
@@ -70,6 +72,10 @@ operations: **Analyze**, **Execute**, and **Review**.
7072
| `/v1/ai/health` | GET | Online service health snapshot | No |
7173
| `/healthz` | GET | Liveness check | No |
7274
| `/v1/ai/quota` | GET | Provider usage, Codex account limits, and internal estimates | No |
75+
| `/v1/ai/automation/authority` | POST | Evaluate auto/human-review authority for live-impacting changes | No |
76+
| `/v1/ai/automation/control` | GET | Convert health/quota/org-health into continue/review-only/pause/escalate | No |
77+
| `/v1/ai/automation/runs` | GET/POST | Read or record automation run ledger entries | No |
78+
| `/v1/ai/automation/runs/{id}` | GET | Read one automation run ledger entry | No |
7379
| `/v1/ai/feedback/*` | GET/POST | Change tracking and evaluation | No |
7480

7581
Health status vocabulary is defined in [`health_taxonomy.md`](health_taxonomy.md). Do not use `/v1/ai/health` as a substitute for monthly audit results, artifact freshness, or strategy-level health evidence.
@@ -114,6 +120,8 @@ POST /v1/ai/review
114120
→ optional Codex verification
115121
→ extract confidence scores
116122
→ compute consensus + recommended action
123+
→ cap action through automation authority policy
124+
→ re-cap through service/quota/org health runtime guards
117125
→ return {results, consensus, recommended_action}
118126
```
119127

@@ -124,6 +132,24 @@ POST /v1/ai/review
124132
requirement.
125133
- **Authorization**: Source repository org must match OIDC claims repository org
126134
(prevents cross-org escalation).
135+
- **Automation authority**: Request metadata can only make a decision stricter.
136+
Live-equivalent auto-merge requires service-owned trusted proof and an
137+
existing repo/autonomy policy decision that already allows auto-merge; public
138+
endpoints cannot self-declare it. The review path may read trusted proof from
139+
`CODEX_AUDIT_SERVICE_TRUSTED_AUTOMATION_PROOF_PATH`, keyed by
140+
`trusted_proof_id` and the server-computed prompt SHA-256; proof records carry
141+
the reviewed `source_repository`, `commit_sha`, `diff_hash`, and `changed_paths`,
142+
and the caller must be that repository or an explicit automation operator.
143+
- **Automation ledger tenancy**: Ledger reads and writes use `source_repository`
144+
as owner when present, otherwise the authenticated repository; `caller_repository`
145+
is audit metadata, not read authorization.
146+
- **Automation control state**: Run task state may be reported by callers, but
147+
control action and health/quota/org-health fields are derived by the service.
148+
- **Operator access**: Cross-repository automation reads/writes require an
149+
explicit operator claim/scope or `CODEX_AUDIT_SERVICE_AUTOMATION_OPERATOR_REPOSITORIES`.
150+
Static-token and no-auth local callers are repository-scoped unless explicitly allowlisted.
151+
- **Dashboard read access**: Static-token dashboards may read automation control
152+
and ledger state only for repositories listed in `CODEX_AUDIT_SERVICE_DASHBOARD_REPOSITORIES`.
127153
- **Sandbox**: Codex sandbox restricted to service-side allowlist (default: `read-only`).
128154
- **Codex reasoning effort**: `CODEX_AUDIT_SERVICE_REASONING_EFFORT` can hard
129155
override CLI effort; unset/`auto` routes low/medium/high by task complexity.

0 commit comments

Comments
 (0)