Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
f848196
chore(tools): backfill r3 ops scripts from r3work workspace
nghqqa Sep 22, 2026
b46e8ba
feat(bridge): M1-1 publish semantics hardening + acceptance records
nghqqa Sep 22, 2026
0baa644
feat(bridge): M1-2 crash recovery + M1-3 orchestration contract
nghqqa Sep 22, 2026
8b30fb1
docs: STATUS updated - M1 unit-level closed, next actions listed
nghqqa Sep 22, 2026
6bc84f2
feat(approval): M2-A approval spec + binding validator (pure logic la…
nghqqa Sep 22, 2026
81e0045
feat(bridge): pre-dispatch run-manifest (memo 9.2, write-once, fail-c…
nghqqa Sep 22, 2026
22cb6eb
feat(costmeter): budget-guard scaffold + local span-count collector
nghqqa Sep 22, 2026
55b0ff9
feat(bridge): run-manifest probes live-wired via R5 read-only recon
nghqqa Sep 22, 2026
0ae8843
docs(gate): M2 ticket storage options pre-research (proposal P-1)
nghqqa Sep 22, 2026
1e8b6ec
feat(rag): wire RAG into V0 dispatch path - snapshot binding + requir…
nghqqa Sep 22, 2026
260e1f6
feat(approval): SQLite WAL ticket store (P-1 decided) + retry-cost co…
nghqqa Sep 22, 2026
e29e7aa
feat(approval): gate_cli ticket operations + B-chain audit correction
nghqqa Sep 22, 2026
a6006dc
refactor(approval): abstract TicketStore interface (SQLite stays V0-o…
nghqqa Sep 22, 2026
cac7b8a
feat(orchestrator): architecture v3 skeleton - graded parallel review…
nghqqa Sep 22, 2026
1d3fa6e
docs(auth): scope v3 real-Agent validation into R1/R2 request
nghqqa Sep 22, 2026
b00a095
feat(v3): M3.5 local wiring - shadow mode at dispatch boundary + run …
nghqqa Sep 22, 2026
359532a
fix(v3): M3.5 review fixes + local smoke + authorization decision pac…
nghqqa Sep 22, 2026
2140824
prep(integration): pre-authorization local readiness package
nghqqa Sep 22, 2026
4d4be36
ops(R4+R7): run-copy and corpus sync executed per user approval
nghqqa Sep 22, 2026
190f466
prep(real-case): prerun gate + acceptance errata + trigger/budget ana…
nghqqa Sep 22, 2026
67d6446
docs(real-case): round-9 records - trigger analysis, prerun gate, bud…
nghqqa Sep 22, 2026
c179601
feat(bridge): controlled-case readiness - targeted claim, publish-unk…
nghqqa Sep 22, 2026
fcced07
feat(backend): PG prep + execution-protection fixes on backend branch
nghqqa Sep 22, 2026
0500a12
feat(backend): PostgreSQLTicketStore implemented + verified on isolat…
nghqqa Sep 22, 2026
4a686a8
feat(backend): reconcile identity + target_key tests + PG RunStore + …
nghqqa Sep 22, 2026
51e1a89
fix(backend): execution-protection hardening + migration runner (roun…
nghqqa Sep 22, 2026
18586cc
feat(backend): read-only HTTP service + migration runner + correct ex…
nghqqa Sep 22, 2026
f7716b1
feat(backend): HTTP read-only query + approval endpoints + migration …
nghqqa Sep 23, 2026
aba3c54
feat(backend): M2 approval vertical loop (fixture HTTP + store level)
nghqqa Sep 23, 2026
7db7f96
wip(backend): console_pg HTTP service + findings/validations persistence
nghqqa Sep 23, 2026
973fb80
fix(backend): M2 HTTP approval loop + migration runner scoping
nghqqa Sep 23, 2026
903e995
feat(gate): CASE1 pre-run gate script (read-only, no execution)
nghqqa Sep 23, 2026
b8dae41
docs(gate): CASE1 authorization status + sync delta + budget/credenti…
nghqqa Sep 23, 2026
e82bcfa
docs(backend): CASE1 first real PR review completed
nghqqa Sep 23, 2026
02a9ec3
feat(bridge): trusted run context passthrough + model switch prep
nghqqa Sep 23, 2026
74a3c50
chore(test)+docs: repo-wide pytest import mode, TEST-DEBT inventory, …
nghqqa Sep 23, 2026
f538141
docs(backend): CASE2 read-only screening - candidates, acceptance tab…
nghqqa Sep 23, 2026
008273e
docs(backend): CASE2 pre-authorization final review + itemized author…
nghqqa Sep 23, 2026
b6e338f
docs(backend): CASE2 executed - first genuine RAG consumption, human …
nghqqa Sep 23, 2026
9a998b3
fix(bridge): CASE2 retrospective - gate marker contract, RAG probe sp…
nghqqa Sep 23, 2026
59ccd1a
feat(approval): close human-gate ticket lifecycle
nghqqa Sep 23, 2026
25c3a70
test(backend): validate gate ticket deployment wiring
nghqqa Sep 23, 2026
b79cd39
test(backend): pgvector isolated verification and deployment wiring a…
nghqqa Sep 23, 2026
84ad9af
chore(rpd): 24h autonomous round - RPD state, gate display contract, …
nghqqa Sep 23, 2026
8e00041
docs(rpd): final report - MANUAL-REQUIRED, PR #233 delivered
nghqqa Sep 23, 2026
05d6d40
docs(rpd): record final head 8e00041 in RPD state
nghqqa Sep 23, 2026
a14ce1d
docs(rpd): pin final head 05d6d40 in RPD state
nghqqa Sep 23, 2026
db62d1c
docs(rpd): register human decision items D-A..D-E (all default WAITIN…
nghqqa Sep 23, 2026
9dcf3f6
docs(rpd): PR #233 scope audit - PR_SCOPE_ACCEPTABLE=true
nghqqa Sep 23, 2026
5c2312f
docs(rpd): execution decision 20260924 - no explicit approvals found,…
nghqqa Sep 23, 2026
d82e475
docs(rpd): night round closed BLOCKED - controller drops spec.env, CA…
nghqqa Sep 23, 2026
88e2e4d
feat(da): unlock case_retrieval formal wiring - k8s-native spec.env w…
nghqqa Sep 23, 2026
c9efd09
docs(rpd): CASE2-B executed - second genuine RAG consumption, HIGH fi…
nghqqa Sep 24, 2026
849e69c
docs(rpd): sync final state to MANUAL-REQUIRED with CASE2-B record
nghqqa Sep 24, 2026
f7e19e4
docs(rpd): CASE2-B evidence recheck 14/14; register HIGH-DECISION and…
nghqqa Sep 24, 2026
e94be2e
feat(rag-image-sync): v6scope reviewer image deployed and verified in…
nghqqa Sep 24, 2026
953c538
feat(iso-chain): closure implementation CL-02..CL-07 + deterministic …
nghqqa Sep 24, 2026
07abc1f
docs(rpd): CL-08 BLOCKED - deepseek-flash reasoning exhausts per-requ…
nghqqa Sep 24, 2026
1539ebc
docs(rpd): sync final state - two human decisions pending
nghqqa Sep 24, 2026
307f1ba
docs(rpd): CL-08 final block - model diff headers corrupted 2/2 candi…
nghqqa Sep 24, 2026
74a2782
docs(rpd): archive iso ticket DBs, fix final blocker wording
nghqqa Sep 24, 2026
ec66209
docs(case2b-fix): archive PoC rerun harness and fix evidence
nghqqa Sep 24, 2026
81e2b25
docs(case2b-fix): archive fix verification evidence (PoC rerun, test …
nghqqa Sep 24, 2026
2e98d4e
chore: stop tracking session hook-state dir (.mimosa)
nghqqa Sep 24, 2026
0ef8d80
docs(rpd): calibration round - CASE2-B manual fix verified, decisions…
nghqqa Sep 24, 2026
2c3921e
feat(d-b): approval enforcement wiring + isolated PG E2E + readiness
nghqqa Sep 24, 2026
8b7a90c
feat(d-b): readiness report - spawn race fix, approver node_id identi…
nghqqa Sep 24, 2026
f5bd76a
Merge branch 'feat/d-b-approval-readiness' into feat/rpd-24h-delivery
nghqqa Sep 24, 2026
527fd40
fix(test): D-B enforce test suite - stable actor_id, outbox init, app…
nghqqa Sep 24, 2026
8de06ed
feat(d-b): D-B formal enablement - all synthetic verification 13/13 PASS
nghqqa Sep 24, 2026
d4cb79b
docs(e2e): Productized E2E Case 1 report - HIGH/CWE-22 confirmed, no …
nghqqa Sep 24, 2026
829d536
feat(orchestration): freeze ticket ownership into deterministic contr…
nghqqa Sep 24, 2026
e332287
docs(e2e): R2 evidence index - formal PENDING ticket via deterministi…
nghqqa Sep 24, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ demo-platform/frontend/node_modules/
# Local model/API credentials used only for authorized offline/isolated runs.
key.key
run-secrets/
.case1_evidence/

.mimosa/
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"schemaVersion": "mimosa-finding-ledger-batch/v1",
"batchId": "posttooluse-b393a96375de1df50f5bd7820066a0e8",
"runId": null,
"runStatus": "completed",
"coverage": {
"status": "complete",
"reasons": []
},
"source": {
"component": "zcode-hook",
"operationId": "PostToolUse"
},
"revision": null,
"diffHash": null,
"rulesVersion": null,
"sessionHash": "8f6330ff85a8ccb9802d0cf3e3fbf74a8ef30e37e0998175d8f74bbf43d299a6",
"reportRef": null,
"events": [
{
"eventId": "hook-8dd2ce07a19f348349dcd940fd36f5d7",
"findingId": "mimosa-4bea54d9de6627eaf2d828b3",
"type": "static_fix_verified",
"at": "2026-09-24T03:59:06.243Z",
"identity": {
"projectRelativeFile": "tools/approval/d_b_pg_e2e.py",
"ruleId": "security",
"codeEvidenceHash": "b618b768aee498ccb5778b3e8f945c1cfb8b654a361d09bb95cb365376f5cbde",
"confidence": "stable"
},
"scope": "direct",
"line": 71,
"endLine": 71,
"reasonCode": "static_rescan_passed",
"reportedToAgent": false,
"evidence": {
"kind": "static_scan",
"boundary": "observed",
"producer": "deterministic",
"evidenceHash": "b618b768aee498ccb5778b3e8f945c1cfb8b654a361d09bb95cb365376f5cbde"
},
"sequence": 0
}
],
"observedFindingIds": [],
"verifiedFiles": [],
"recordedAt": "2026-09-24T03:59:06.577Z"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"schemaVersion": "mimosa-finding-ledger-batch/v1",
"batchId": "pretooluse-e67207afc70f138a20bd17c48b7445f3",
"runId": null,
"runStatus": "completed",
"coverage": {
"status": "complete",
"reasons": []
},
"source": {
"component": "zcode-hook",
"operationId": "PreToolUse"
},
"revision": null,
"diffHash": null,
"rulesVersion": null,
"sessionHash": "8f6330ff85a8ccb9802d0cf3e3fbf74a8ef30e37e0998175d8f74bbf43d299a6",
"reportRef": null,
"events": [
{
"eventId": "hook-5b71b5bc27ea69f041ef675c8fcdb870",
"findingId": "mimosa-4bea54d9de6627eaf2d828b3",
"type": "finding_blocked",
"at": "2026-09-24T03:56:29.502Z",
"identity": {
"projectRelativeFile": "tools/approval/d_b_pg_e2e.py",
"ruleId": "security",
"codeEvidenceHash": "b618b768aee498ccb5778b3e8f945c1cfb8b654a361d09bb95cb365376f5cbde",
"confidence": "stable"
},
"scope": "direct",
"line": 71,
"endLine": 71,
"reasonCode": "deny",
"reportedToAgent": true,
"evidence": {
"kind": "source",
"boundary": "candidate",
"producer": "deterministic",
"evidenceHash": "b618b768aee498ccb5778b3e8f945c1cfb8b654a361d09bb95cb365376f5cbde"
},
"sequence": 0
}
],
"observedFindingIds": [],
"verifiedFiles": [],
"recordedAt": "2026-09-24T03:56:29.814Z"
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"schemaVersion": "mimosa-hook-status/v1",
"recordedAt": "2026-09-24T07:17:52.457Z",
"sessionId": "sess_3de6bfbd-2011-4592-a2c1-dfecab33cd69",
"event": "PostToolUse",
"toolName": "Edit",
"file": "tools/approval/enforce.py",
"outcome": "clear",
"coverage": "complete",
"findingCount": 0,
"durationMs": 18,
"hostState": "hook_complete",
"reportHint": ".mimosa/reports/"
}
1 change: 1 addition & 0 deletions docs/productization/.rpd-base-head
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
BASE_HEAD=b79cd39cbcd78731ac50b2ff0f25b00a5a11514e
224 changes: 224 additions & 0 deletions docs/productization/ACCEPTANCE.md

Large diffs are not rendered by default.

103 changes: 103 additions & 0 deletions docs/productization/ARCHITECTURE-V3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# 架构 v3:分级并行审查流水线(ARCHITECTURE-V3)

**日期**:2026-09-22 | **状态**:设计定稿 + 骨架实现(feature flag 默认关闭,旧串行链未动)
**性质**:审查执行模型从固定串行 `reviewer → fixer → verifier` 升级为分级、并行、两段独立验证的流水线。
**不变量**:不自动合并;补丁下载/建议交付;不推送被审查仓库;人工批准后才进入修复;并发默认上限 1;调度权唯一归属。

## 1. 流水线(11 步)

```
1 PR 事件 → 固定 run/仓库/head SHA/RAG snapshot(沿用 run-manifest 既有机制)
2 风险分级(纯规则,可配置,记入 manifest)
3 按风险选审查器集合
4 独立审查器并行提出 findings(单 PR 内并发 ≤2)
5 聚合器去重、排序、保留来源
6 finding validation:独立 verifier 只读 原始 diff + 申报上下文 + findings,
不读任何 agent 的内部推理
7 发布审查结论 + 覆盖说明(部分完成必须可见)
8 人工门(仅当需要修复):TicketStore 票据(M2 语义,未拍板不启用)
9 fixer 生成补丁
10 patch validation:独立验证补丁正确性/测试/回归风险(与 6 是两件事)
11 产出补丁下载 + 最终证据(run-manifest / 阶段状态 / 检索证据)
```

**两个验证阶段的区分(不可合并)**:
- **finding validation**(步骤 6):问题是否真实、可达、可复现——防误报;
- **patch validation**(步骤 10):补丁是否正确、测试是否通过、无新增回归——防修复引入新问题。
一个 finding 被确认不代表其补丁正确;补丁验证不得引用 finding 验证结论替代自身证据。

## 2. 风险分级(tools/orchestrator/risk.py,纯逻辑)

| 档 | 条件(可配置 RiskRules) | 审查器集合 | 附加 |
|---|---|---|---|
| TRIVIAL | <50 行 且 <5 文件 且 无敏感路径 | 通用 1 个 | — |
| LITE | 50–500 行 或 5–20 文件,无敏感路径 | 通用 + 1 专业 | — |
| FULL | >500 行 或 >20 文件 或 **命中任一敏感路径** | 全部已启用专业审查器 | **human_review_required=true** |

- 敏感路径默认集:`auth / crypto / permission / credential / migration`(子串匹配,可配置扩充);
- **敏感路径命中 → 无条件 FULL**(小 diff 不豁免);
- 行数 = additions+deletions 合计;理由(reasons)逐条可解释,随 manifest 落盘。

## 3. 阶段状态与 run 级 outcome(tools/orchestrator/stages.py)

**维度状态(每个 run × 每个审查/验证维度独立记录)**:
`PENDING / RUNNING / SUCCEEDED / FAILED / TIMEOUT / SKIPPED / NOT_APPLICABLE / CANCELLED`
(SUCCEEDED/SKIPPED/NOT_APPLICABLE/CANCELLED 不可逆;FAILED/TIMEOUT 仅可在重试预算内回 RUNNING,预算耗尽后停留态即报告态;attempts 记录重试。)

**run 级 outcome(独立枚举,由 `derive_outcome()` 显式派生,绝不覆盖维度状态)**:
`REVIEW_COMPLETED / REVIEW_PARTIAL / CONCLUSION_PUBLISHED / AWAITING_APPROVAL / FIXING / PATCH_VALIDATING / WRITEBACK_OK / WRITEBACK_FAILED / MANUAL_ATTENTION`

派生规则(摘要):
- 任一非 CANCELLED/NOT_APPLICABLE 维度处于 TIMEOUT/FAILED/SKIPPED → 不得 REVIEW_COMPLETED,只能是 REVIEW_PARTIAL(附 coverage.missing 明细);
- **关键安全审查器**(config.critical_reviewers)TIMEOUT/FAILED → 不得发布为通过;只能 REVIEW_PARTIAL 或 MANUAL_ATTENTION;
- 审查完成 ≠ 结论已发布 ≠ 回写成功——三者独立判定。

**降级策略(显式配置,不自动换模型)**:单 agent 超时/模型不可用 → 按 `degradation_policy ∈ {delay, degrade, manual}` 处理;degrade=标 TIMEOUT/SKIPPED 并发布覆盖不足;run 硬上限(hard_deadline)与每阶段重试预算(max_attempts)由配置给出,耗尽 → 对应阶段 FAILED + outcome 转人工。

## 4. 调度(tools/orchestrator/scheduler.py)

- `DispatchPlanner.build_plan(run_ctx, risk, config)` → 有序 PlanStep 列表(审查器并行组→聚合→finding 验证→发布→门→fixer→补丁验证→交付);
- **并发上限**:多 PR 全局 = 1(`MAX_PR_CONCURRENCY`,完成两路并发测试并获授权前不调高);单 PR 内审查器并发 = 2(可配 1=全串行);一个 worker 同一时间只执行一个任务;全部并发任务共享全局模型/资源预算(对接 costmeter 预算守卫);
- **调度权唯一归属**:run 的派发决策只能出自 DispatchPlanner;bridge 是现网执行器,v3 在 flag 关闭时不产生任何派发行为——**不形成第二套调度事实源**;隔离靠 run 的独立工作目录/会话/证据路径/消息空间(M3 验证对象),不靠改任务名。

## 5. 聚合与 finding verifier(aggregate.py / verify_finding.py)

- 聚合:确定性去重(同路径同类别 + 标题词集 Jaccard ≥ 0.5 合并),severity 取最大,**sources 保留全部来源 reviewer**;输出含 dropped_duplicates 便于审计;
- finding verifier 接口:输入只有 `VeriferInput(finding, diff, allowed_context_paths)`——**类型上不存在其他 agent 的推理字段**(结构性隔离,测试固化);判定 CONFIRMED/REFUTED/INCONCLUSIVE + 证据。

## 6. 存储抽象(tools/approval/store.py)

```python
class TicketStore(Protocol): # 接口:create/get/active_for/transition/close
class SQLiteTicketStore(TicketStore) # V0 单实例实现(原 SqliteTicketStore,别名保留)
class PostgreSQLTicketStore(TicketStore) # 迁移占位(NotImplementedError + DSN 形状)
```

**SQLite 边界(明确且不承诺)**:单 Controller、单部署实例、无多实例高可用、**不承诺多用户 SaaS**。未来多 Controller/多用户/共享部署 → 必须迁 PostgreSQLTicketStore;接口已固定,迁移只换适配器,M2 语义单测全部复用。

## 7. 控制台字段契约(console_contract.py)

`build_console_payload()` 固定输出:risk_level、reviewers[]{name,status,detail}、findings{count,by_source}、finding_validation{status,confirmed,refuted,inconclusive}、coverage{complete,missing[]}、degradations[]{stage,reason}、fixer.status、patch_validation.status、github_writeback.status、rag{snapshot_id,evidence_refs}、manifest{run_id,...}。
**禁止把部分完成/降级压缩成单一绿色"成功"**:coverage.complete=false 时 payload 顶层必须可见(测试固化)。

## 8. 实施顺序与现状

| # | 项 | 状态 |
|---|---|---|
| 1 | 本文档 | ✅ |
| 2 | 状态机与数据结构 | ✅ stages.py |
| 3 | 风险分级纯逻辑 | ✅ risk.py |
| 4 | 调度器接口 | ✅ scheduler.py(串行默认 + 并发2 执行器) |
| 5 | 聚合器纯逻辑 | ✅ aggregate.py |
| 6 | finding verifier 接口 | ✅ verify_finding.py |
| 7 | feature flag 三态接线 | ✅ off(默认)/shadow/on;**桥派发边界已接 shadow**(v3_shadow_hook,fail-soft),on 仍不接真实 Agent |
| 8 | 两审查器并行本地测试 | ✅ tests/orchestrator/ |
| 9 | 超时/部分完成/降级测试 | ✅ tests/orchestrator/ |
| 10 | 控制台字段契约 | ✅ console_contract.py |
| 11 | 真实 Agent 接入 | ⬜ 最后(R1/R2 授权后);本地纵向链路已通(adapter fixture/shadow,M3.5) |

旧串行链(bridge process/conclude)**在新流程通过回归并获接线授权前不得删除**。

## 9. 验收矩阵(详见 ACCEPTANCE-ARCHV3)

路由三档/敏感升级/并行/去重保源/verifier 隔离/单超时可发布/关键超时不可通过/run 硬上限/重试预算耗尽/PR 更新失效/门后 fixer/两验证独立/RAG 快照一致/SQLite 边界/控制台部分状态——全部有对应测试(本地面)。真实 Agent、真实 RAG、真实 GitHub 集成为独立未验证项,**测试通过不冒充生产验证**。
Loading
Loading