Skip to content

Commit 0c1e642

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

11 files changed

Lines changed: 1591 additions & 4 deletions

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ 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 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+
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.
39+
3640
## Compatibility governance role
3741

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

README.zh-CN.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ Codex 执行现在只走 service backend:workflow 从 GitHub-hosted runner 调
3333

3434
这样可以避免每个 source repository 都硬编码 Codex CLI,也不会依赖 `QuantStrategyLab` 组织外的仓库。
3535

36+
自动化授权层和模型置信度分开处理。service 将低风险日常维护视为可自动合并;已 live 的同族策略优化只有在 service-owned 检查给出 trusted proof 时才允许自动合并;新策略/重构策略、live-candidate 提升、插件 position-control、券商/订单执行、workflow 权限和 secrets 相关变更都保留人工复核。`POST /v1/ai/automation/authority` 接收的请求 metadata 只能作为降权提示,不能放宽 live 影响自动化 policy。
37+
38+
自动化运行状态通过 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 或升级人工处理。
39+
3640
## 兼容性治理定位
3741

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

docs/architecture.md

Lines changed: 21 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,19 @@ 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; public
137+
endpoints cannot self-declare it. The review path may read trusted proof from
138+
`CODEX_AUDIT_SERVICE_TRUSTED_AUTOMATION_PROOF_PATH`, keyed by
139+
`trusted_proof_id` and the server-computed prompt SHA-256; proof records carry
140+
the reviewed `source_repository`, `commit_sha`, `diff_hash`, and `changed_paths`.
141+
- **Automation ledger tenancy**: Ledger reads and writes use `source_repository`
142+
as owner when present, otherwise the authenticated repository.
143+
- **Automation control state**: Run task state may be reported by callers, but
144+
control action and health/quota/org-health fields are derived by the service.
145+
- **Operator access**: Cross-repository automation reads/writes require an
146+
explicit operator claim/scope or `CODEX_AUDIT_SERVICE_AUTOMATION_OPERATOR_REPOSITORIES`.
147+
Static-token and no-auth local callers are repository-scoped unless explicitly allowlisted.
127148
- **Sandbox**: Codex sandbox restricted to service-side allowlist (default: `read-only`).
128149
- **Codex reasoning effort**: `CODEX_AUDIT_SERVICE_REASONING_EFFORT` can hard
129150
override CLI effort; unset/`auto` routes low/medium/high by task complexity.

0 commit comments

Comments
 (0)