Skip to content
This repository was archived by the owner on Aug 24, 2026. It is now read-only.

fix: 注册层门禁硬化——issue #31 审计收敛(ADR-0022) - #32

Merged
randypanding merged 1 commit into
mainfrom
fix/issue-31-gate-hardening
Aug 19, 2026
Merged

fix: 注册层门禁硬化——issue #31 审计收敛(ADR-0022)#32
randypanding merged 1 commit into
mainfrom
fix/issue-31-gate-hardening

Conversation

@randypanding

Copy link
Copy Markdown
Contributor

概要

独立验证 issue #31(独立审计,基准 55818ef)后实施的收敛修复。当前 HEAD(012ac71/ADR-0021)复测:15/15 变异全部双门禁放行——snapshot-diff 只能拦"未同步 golden"的篡改,语义层防线确实缺失。本 PR 实装 validate.py 语义防线 + 声明侧对齐,详见 ADR-0022。

验证结论(issue #31 说法核实)

  • A-1/A-2/A-3/A-4:属实(15/15 变异复现:K/L/M/N/O/P/Q/A/B/E/F/G/I/J 双绿,R 仅模拟器拦)
  • B-1B-7、C-1C-4、D-1~D-5:属实(静态核验:verify 出边全依赖 review.*、owner_ratify 无生产者、flow_ref 无校验且 governance/ 不存在、wave-plan card 缺 trace_id 等)
  • 部分已被 ADR-0021 缓解(snapshot 差分、platform-direct 立场、机制绑定),但语义层防线缺失成立

修复(收敛判据对照)

判据 修复 拦截验证
1. K–Q → validate≠0 capability-whitelist:agent.allow ⊆ profile.allow K/O 重放 caught ✓
2. 变异 A must_run × shell 工具交叉校验 A 重放 caught ✓(B 按 platform-direct 显式豁免——ADR-0022 决策 3)
3. 变异 E 场景载体非空 + asserts_floor_total=79 E 重放 caught ✓
4. F/G/I/J 生产者引用解析 / check 降级防护 / 输出语义 / io_guarantees 重放 caught ✓
5. 变异 R deadlock:any 边不计相位出边 R validate=1 ✓
6. flow_ref fail-closed + external_flow_refs 豁免清单 负向测试 ✓
7. owner_ratify event_producers 补生产者(owner,经平台通道)
8. 分类可达 per-change_class 求解器 + review dispatch 表 + review.waived 边 doc~prod 七类全可达 ✓
9. 通道覆盖 side-effects delivery_channels(tool_required/platform_direct/runtime_builtin) 负向测试 ✓
10. CT 执行者 CT-TA-004/CT-CUR-001/CT-RES-001 升级 validate-executed(3→6) validate 实装 ✓

另含:B-2(deployer must_run→check:rollback-plan-required)、B-4(review-decision.json)、B-5(credential.impersonation + internal_flow 对齐 steps.md)、B-6(curator write_file deny)、B-7(arbiter.steps.md + reviewer workflow 绑定 + 孤儿检测)、C-3(card_gate.requires 条件化)、C-4(扫描器枚举)、D-4(账本类目语义 + ambiguity_rule)、D-5(JSON Schema 语法校验 + wave-plan trace_id)。

不修(documented,ADR-0022 决策 3)

  • A-5:C1 型 PR 跳过 base 侧门禁——规则与数据同源演进的既有 tradeoff(CODEOWNERS + adr-required + head 双跑 + snapshot-diff 兜底)
  • B-1"塞工具"方向:按 ADR-0021 platform-direct 立场,以三通道词表显式化

测试

  • 本地:validate ✓ / simulate 24 场景 ✓ / snapshot --check ✓ / pytest 60 全绿(含 21 条新负向回归)
  • 修复后变异重放:14/14 caught(B 为设计豁免)

实装 validate.py 语义防线(不可随 golden 越过):
- capability-whitelist:agent.allow ⊆ profile.allow(变异 K–Q 拦截)
- must_run 执行通道 × 工具面交叉校验(变异 A)
- 执行通道词表(tool_required/platform_direct/runtime_builtin,判据 9)
- event_producers seat:/agent: 引用解析(变异 F)
- 场景断言防掏空:载体非空 + asserts_floor_total(变异 E)
- check 降级防护:有 CI 执行点须 active(变异 G)
- test-author 输出语义禁判决族(变异 I;CT-TA-004 升级 validate-executed)
- profile.io_guarantees 输出契约(变异 J)
- deadlock 修复:any 边不计相位出边(变异 R 由 validate 拦截)
- per-change_class 相位可达性求解(C-1 分类死锁灭绝)
- dispatch extra_keys 钥匙有主(C-2:owner_ratify 补生产者)
- flow_ref fail-closed + external 豁免清单(D-3)
- JSON Schema 语法校验(D-5);workflow 绑定/孤儿检测(B-7)
- adversary credential.impersonation 声明化(B-5)

声明侧对齐:review dispatch 表 / review.waived / card_gate.requires
条件化(C-3)/ curator 提案 deny(B-6)/ arbiter+reviewer workflow 绑定 /
review-decision.json(B-4)/ wave-plan card trace_id(D-5)/ 账本类目
语义(D-4)/ maintain_loop 扫描器显式化(C-4)/ CT 3 条升级
validate-executed(D-1)。含 21 个负向回归测试(60 全绿)。
@coderabbitai

coderabbitai Bot commented Aug 19, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@randypanding, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 9 minutes

Limit details: You’ve used all 3 included reviews currently available.

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits within each organization.

For paid Pro and Pro+ reviews, CodeRabbit uses a developer's included PR review attempts over the past 7 days to set the current hourly allowance. At typical activity levels, the full plan allowance applies. Higher sustained activity can lower the allowance until earlier attempts leave the 7-day window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7aca4960-d5e6-493f-adc0-43595a064634

📥 Commits

Reviewing files that changed from the base of the PR and between 012ac71 and 761c30a.

📒 Files selected for processing (23)
  • decisions/ADR-0022-registry-gate-hardening.md
  • registry/agents/arbiter.yaml
  • registry/agents/curator-main.yaml
  • registry/agents/deployer.yaml
  • registry/agents/red-adversary.yaml
  • registry/agents/reviewer.yaml
  • registry/projects.yaml
  • registry/schemas/review-decision.json
  • registry/schemas/wave-plan.json
  • registry/workflows/arbiter.steps.md
  • scripts/simulate-wave.py
  • scripts/validate.py
  • standards/archetype-profiles.yaml
  • standards/attention-ledger.yaml
  • standards/change-classes.yaml
  • standards/control-tests.yaml
  • standards/flows.yaml
  • standards/intent-routing.yaml
  • standards/scenarios.yaml
  • standards/side-effects.yaml
  • standards/team-collaboration.yaml
  • tests/golden/declarations.json
  • tests/test_validate.py

Comment @coderabbitai help to get the list of available commands.

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Harden registry semantic gates and governance declarations

🐞 Bug fix ✨ Enhancement 🧪 Tests 📝 Documentation ⚙️ Configuration changes 🕐 40+ Minutes

Grey Divider

AI Description

• Enforces cross-file capabilities, workflows, schemas, events, and execution-channel invariants.
• Aligns governance declarations to keep every change class reachable and auditable.
• Adds 21 negative regressions covering the independently reproduced audit mutations.
Diagram

graph TD
  D["Registry declarations"] --> V["Semantic validator"] --> G{"Gates pass?"} -->|Yes| S["Wave simulator"] --> C["CI approval"]
  G -->|No| E["Validation errors"]
  T["Mutation tests"] --> V
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Modular validation rule packages
  • ➕ Separates capability, workflow, schema, and reachability domains
  • ➕ Makes individual invariants easier to test and maintain
  • ➕ Reduces continued growth of one validation script
  • ➖ Requires a larger refactor beyond the audit-remediation scope
  • ➖ Could introduce ordering or shared-context inconsistencies
  • ➖ Adds migration risk while closing active semantic gaps
2. Schema-only enforcement
  • ➕ Uses standardized tooling for structural declaration checks
  • ➕ Reduces custom validation code for local document constraints
  • ➖ Cannot adequately enforce graph reachability or cross-file references
  • ➖ Cannot model agent-to-profile capability subsets and execution channels
  • ➖ Would leave most reproduced audit mutations undetected

Recommendation: Keep the centralized validator for this remediation because the new guarantees are primarily cross-file invariants and must land atomically with their declarations. Consider extracting cohesive rule modules later while retaining one fail-closed entry point; schema-only validation is insufficient.

Files changed (23) +802 / -60

Enhancement (3) +79 / -14
review-decision.jsonDefine review decision event schema +47/-0

Define review decision event schema

• Adds the payload contract for approve, changes-requested, and waived review events, including class, seat, and traceability fields.

registry/schemas/review-decision.json

control-tests.yamlPromote semantic controls to validator execution +16/-14

Promote semantic controls to validator execution

• Upgrades test-author verdict isolation, curator admin exclusion, and researcher write exclusion from manual checks to validator-enforced controls.

standards/control-tests.yaml

side-effects.yamlClassify side effects by delivery channel +16/-0

Classify side effects by delivery channel

• Introduces tool-required, platform-direct, and runtime-builtin channels so every allowed side effect has an auditable execution path.

standards/side-effects.yaml

Bug fix (7) +359 / -39
deployer.yamlReplace deployer must-run action with registered check +3/-1

Replace deployer must-run action with registered check

• Changes the rollback prerequisite to a registered check reference with an explicit CI and environment execution channel.

registry/agents/deployer.yaml

wave-plan.jsonComplete wave-plan class and trace contracts +8/-1

Complete wave-plan class and trace contracts

• Requires card-level trace IDs and permits trivial and spike change classes, closing planner-to-builder trace propagation.

registry/schemas/wave-plan.json

simulate-wave.pyValidate dispatch-based review ownership +5/-2

Validate dispatch-based review ownership

• Updates the happy-path simulation to recognize the review dispatch table and require a test-author seat assignment.

scripts/simulate-wave.py

validate.pyEnforce registry semantic invariants +272/-13

Enforce registry semantic invariants

• Adds fail-closed checks for capability subsets, execution channels, event references, per-class reachability, workflows, flow references, scenario floors, and JSON schemas. It also validates output semantics, must-run executability, CI check status, adversary credentials, and correct deadlock detection.

scripts/validate.py

attention-ledger.yamlCorrect attention conservation semantics +7/-4

Correct attention conservation semantics

• Renames the synchronous limit from weekly frequency to category count and documents runtime frequency auditing.

standards/attention-ledger.yaml

intent-routing.yamlMake flow references fail-closed +23/-7

Make flow references fail-closed

• Normalizes local references to resolvable file anchors, registers external governance exceptions, and aligns ambiguity handling with the attention budget.

standards/intent-routing.yaml

team-collaboration.yamlMake review dispatch and phase reachability explicit +41/-11

Make review dispatch and phase reachability explicit

• Adds per-change-class review dispatch, waived review events, owner ratification producers, and conditional card requirements. Updates phase transitions, ACLs, merge policy, and attention semantics to eliminate class-specific deadlocks.

standards/team-collaboration.yaml

Tests (2) +193 / -1
declarations.jsonRefresh the declaration snapshot +1/-1

Refresh the declaration snapshot

• Regenerates the canonical declaration snapshot for the hardened agent, schema, workflow, and standards configuration.

tests/golden/declarations.json

test_validate.pyAdd negative semantic-gate regressions +192/-0

Add negative semantic-gate regressions

• Adds 21 mutation-style tests covering capability escalation, missing execution surfaces, gutted scenarios, dangling references, deadlocks, schemas, workflows, and credential declarations.

tests/test_validate.py

Documentation (3) +132 / -1
ADR-0022-registry-gate-hardening.mdDocument registry gate-hardening decisions +123/-0

Document registry gate-hardening decisions

• Records the reproduced issue #31 findings, adopted semantic defenses, declaration changes, intentional exceptions, and acceptance criteria.

decisions/ADR-0022-registry-gate-hardening.md

projects.yamlClarify dependency registry boundaries +4/-0

Clarify dependency registry boundaries

• Documents that the project manifest covers open-source dependencies while internal mechanisms are governed by profile bindings.

registry/projects.yaml

flows.yamlEnumerate maintenance issue producers +5/-1

Enumerate maintenance issue producers

• Makes external scanners and internal finding paths explicit, removing ambiguity about who opens maintenance issues.

standards/flows.yaml

Other (8) +39 / -5
arbiter.yamlBind arbiter to its fixed workflow +1/-0

Bind arbiter to its fixed workflow

• Adds the required steps reference so the arbiter's fixed workflow is executable and non-orphaned.

registry/agents/arbiter.yaml

curator-main.yamlRestrict curator governance file writes +4/-0

Restrict curator governance file writes

• Denies direct write-file access to standards, the validator, and CODEOWNERS, expressing proposal-only governance authority.

registry/agents/curator-main.yaml

red-adversary.yamlDeclare adversary credential impersonation lifecycle +6/-0

Declare adversary credential impersonation lifecycle

• Defines platform-issued, scoped, one-time target credentials for adversary-executed control tests and their destruction policy.

registry/agents/red-adversary.yaml

reviewer.yamlBind reviewer to the existing workflow +3/-0

Bind reviewer to the existing workflow

• Declares the reviewer workflow as fixed and references its steps file, eliminating an orphan workflow.

registry/agents/reviewer.yaml

arbiter.steps.mdDefine the arbiter fixed procedure +8/-0

Define the arbiter fixed procedure

• Adds the evidence handling, jurisdiction, decision publication, and teardown sequence referenced by the arbiter declaration.

registry/workflows/arbiter.steps.md

archetype-profiles.yamlDeclare planner output guarantees and adversary boundaries +5/-1

Declare planner output guarantees and adversary boundaries

• Requires planner outputs to preserve wave, card, contract, and trace fields. Aligns adversary behavior with scoped impersonation and platform-executed freeze handling.

standards/archetype-profiles.yaml

change-classes.yamlAlign class-specific review requirements +6/-4

Align class-specific review requirements

• Clarifies waived review for documentation and adds test-author review alongside owner keys for dependency, schema, and production classes.

standards/change-classes.yaml

scenarios.yamlProtect the scenario registry from assertion removal +6/-0

Protect the scenario registry from assertion removal

• Adds an assertion-count floor and documents the requirement that every scenario retain assertions or an executable hook.

standards/scenarios.yaml

@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (8) 📘 Rule violations (1) 📜 Skill insights (0)

Grey Divider


Action required

1. Mutable profiles bypass whitelist 🐞 Bug ⛨ Security
Description
The new agent whitelist only enforces agent.allow ⊆ profile.allow, while profiles themselves are
checked only against the global side-effect vocabulary, so a PR can add a privileged capability to
both the profile and agent and pass validation. This defeats the advertised K–Q semantic defense and
the newly promoted curator/researcher control tests, including allowing vcs_admin for curator or
write capabilities for researcher.
Code

scripts/validate.py[R385-388]

+    _prof_allow = set(((prof.get("capabilities") or {}).get("allow")) or [])
+    excess = allow - _prof_allow
+    if excess:
+        fail(f"agent:{aid} capabilities.allow 越出 profile({arch}) 白名单: {sorted(excess)}"
Relevance

●●● Strong

Recent precedent accepts findings exposing fail-open capability and profile validation.

PR-#5

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The profile check only rejects words outside the global vocabulary, and the instance check then
trusts that profile as the complete boundary. The changed control-test declarations require stronger
archetype-specific properties, so adding vcs_admin to both curator profile and instance, or adding
a write word to both researcher profile and instance, satisfies every new check while violating
those claims.

scripts/validate.py[237-241]
scripts/validate.py[382-389]
standards/control-tests.yaml[125-134]
standards/control-tests.yaml[179-188]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Coordinated edits to an archetype profile and its agent instances bypass the new capability whitelist because the profile is treated as mutable authority and is only checked against the global vocabulary.

## Issue Context
The control tests now claim validator-enforced invariants such as curator never receiving `vcs_admin` and researcher receiving no write capability. Add explicit semantic invariants for these archetypes (or an independently protected capability policy) rather than deriving the boundary solely from the same mutable profile.

## Fix Focus Areas
- scripts/validate.py[237-241]
- scripts/validate.py[382-389]
- standards/control-tests.yaml[125-134]
- standards/control-tests.yaml[179-188]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Waived events fail schema 🐞 Bug ≡ Correctness
Description
reviewer_seat is unconditionally required and restricted to human seats, but review.waived is
produced by mechanism:card-gate for doc/trivial changes. A truthful waived event therefore cannot
satisfy the newly declared payload contract, blocking the fast paths this PR adds.
Code

registry/schemas/review-decision.json[R12-14]

+    "decision",
+    "reviewer_seat",
+    "trace_id"
Relevance

●●● Strong

Team precedent favors aligning schemas with every documented event producer.

PR-#4

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The schema requires reviewer_seat and permits only test_author or curator, whereas the
dispatch and event producer declarations explicitly assign waived decisions to
mechanism:card-gate. No valid enum value represents that producer.

registry/schemas/review-decision.json[8-15]
registry/schemas/review-decision.json[28-40]
standards/team-collaboration.yaml[331-332]
standards/team-collaboration.yaml[357-359]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The review-decision schema requires a human `reviewer_seat` even for `waived` decisions produced by card-gate.

## Issue Context
Use conditional JSON Schema branches: require an appropriate human seat for approve/changes_requested, and represent the card-gate mechanism (or omit reviewer_seat and require a producer field) for waived decisions.

## Fix Focus Areas
- registry/schemas/review-decision.json[8-15]
- registry/schemas/review-decision.json[28-40]
- standards/team-collaboration.yaml[331-332]
- standards/team-collaboration.yaml[357-359]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Schema validation misses invalid schemas 🐞 Bug ☼ Reliability
Description
The new JSON Schema gate checks only JSON parsing and a few top-level fields, so invalid nested
schemas such as {"properties":{"x":{"type":"bogus"}}} pass validation. As a result, malformed IO
contracts can still merge despite this PR marking JSON Schema syntax validation as implemented.
Code

scripts/validate.py[R838-842]

+    if not isinstance(_sch, dict) or _sch.get("type") != "object":
+        fail(f"schema {sp.name} 顶层须为 type: object(io 契约载体——ADR-0022)")
+        continue
+    if not isinstance(_sch.get("properties"), dict):
+        fail(f"schema {sp.name} 缺 properties 对象(ADR-0022)")
Relevance

●●● Strong

The PR claims schema validation; precedent favors rejecting malformed registry inputs.

PR-#10

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The implementation verifies only top-level type, properties, required shape, and
required/property correspondence; it never traverses or validates schema keywords. Therefore invalid
values in nested type, enum, items, conditionals, and other keywords are accepted by the new
gate.

scripts/validate.py[831-850]
tests/test_validate.py[482-493]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The validator does not validate registry schemas against their declared JSON Schema metaschema, allowing invalid keyword values and malformed nested schemas.

## Issue Context
Use a Draft 2020-12 metaschema validator such as `Draft202012Validator.check_schema` for every schema, report validation errors through `fail`, and retain repository-specific checks only where they add policy beyond the metaschema.

## Fix Focus Areas
- scripts/validate.py[831-850]
- tests/test_validate.py[482-493]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


View high (4)
4. Guarantees permit omitted fields 🐞 Bug ≡ Correctness
Description
io_guarantees.output_must_have is checked only against schema properties, not required, so a
planner output may legally omit contracts_ref (or any other declared guarantee) while validation
still passes. This defeats the new output-contract gate and allows consumers to receive incomplete
wave plans.
Code

scripts/validate.py[R507-511]

+            _must_have = ((prof.get("io_guarantees") or {}).get("output_must_have")) or []
+            _missing = [k for k in _must_have if k not in _oprops]
+            if _missing:
+                fail(f"agent:{aid} 输出 schema {_out_ref} 缺 {arch}.io_guarantees.output_must_have "
+                     f"必备字段 {_missing}(输出契约链断裂,ADR-0022)")
Relevance

●●● Strong

Team strengthens validators when declared output contracts permit incomplete payloads.

PR-#5
PR-#10

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The new profile guarantee includes contracts_ref, while the validator compares guarantees
exclusively to schema property names. The schema exposes contracts_ref as a property but does not
require it, proving a payload can omit a declared guarantee and still validate.

standards/archetype-profiles.yaml[94-95]
scripts/validate.py[499-511]
registry/schemas/wave-plan.json[8-14]
registry/schemas/wave-plan.json[119-121]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`output_must_have` currently verifies only that fields are declared in schema `properties`; it must also verify that those fields are required in emitted output.

## Issue Context
The planner profile now declares `contracts_ref` as guaranteed, but `wave-plan.json` does not list it in its top-level `required` array. Thus a syntactically valid planner output can omit it.

## Fix Focus Areas
- scripts/validate.py[507-511]
- standards/archetype-profiles.yaml[94-95]
- registry/schemas/wave-plan.json[8-14]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


5. Rejections lack mandatory rationale 🐞 Bug ≡ Correctness
Description
The new review-decision schema states that rationale is mandatory for changes_requested, but
neither the unconditional required list nor a conditional rule enforces it. A schema-valid
rejection event can therefore omit the only documented rework basis and send the builder back to
build without a reason.
Code

registry/schemas/review-decision.json[R33-35]

+    "rationale": {
+      "type": "string",
+      "description": "changes_requested 时必填(返工依据)"
Relevance

●●● Strong

Team accepts missing enforcement of documented mandatory contract fields.

PR-#4
PR-#10

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The rationale property description explicitly declares the field mandatory for
changes_requested, but the schema's only required array excludes it and there is no if/then
or equivalent conditional requirement. Together, these citations show that the documented contract
is not enforced by validation.

registry/schemas/review-decision.json[8-15]
registry/schemas/review-decision.json[28-35]
registry/schemas/review-decision.json[28-46]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The review-decision contract documents `rationale` as required for `changes_requested`, but the JSON Schema does not enforce that condition, allowing such payloads to omit the rationale.

## Issue Context
A payload containing all top-level required fields and `decision: "changes_requested"` but omitting `rationale` is accepted. This removes the stated return-work basis from a review event; add an `if`/`then` condition requiring a non-empty rationale when the decision is `changes_requested`, plus positive and negative schema tests.

## Fix Focus Areas
- registry/schemas/review-decision.json[8-15]
- registry/schemas/review-decision.json[28-35]
- registry/schemas/review-decision.json[46-46]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


6. Waiver producer lacks channel access 🐞 Bug ≡ Correctness
Description
review.waived is newly declared as produced by mechanism:card-gate, but the changed review.*
ACL permits writes only from test_author and curator. Consequently the card-gate cannot publish
the waiver event required by doc/trivial's new verify → integrate transition, leaving those
classes blocked at verify when ACL enforcement is applied.
Code

standards/team-collaboration.yaml[R75-79]

+      review.*:    {read: [team_members, scheduler, owner], write: [test_author, curator]}
+                                      # review 裁定= decision 类自述事件(合并闸门钥匙之一);
+                                      # test_author=代码符合性(logic/dep/schema/prod),
+                                      # curator=spike 入库审核(dispatch 表——ADR-0022);
+                                      # payload 契约=registry/schemas/review-decision.json
Relevance

●●● Strong

Direct producer-to-channel ACL gaps match the repository’s fail-closed security priorities.

PR-#5

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The PR adds review.waived to the verify exit condition and explicitly assigns its production to
card-gate, but the ACL modified in the same PR never grants card-gate write access. The
review-decision schema also describes these events as being published via the review.* channel.

standards/team-collaboration.yaml[75-79]
standards/team-collaboration.yaml[310-313]
standards/team-collaboration.yaml[328-332]
registry/schemas/review-decision.json[5-5]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The review channel ACL does not authorize the mechanism selected as the producer of `review.waived`.

## Issue Context
Doc and trivial dispatch modes depend on `review.waived` to satisfy the new verify-to-integrate condition. The declared producer is `mechanism:card-gate`, while `review.*` write access is limited to the two human/agent seats.

## Fix Focus Areas
- standards/team-collaboration.yaml[75-79]
- standards/team-collaboration.yaml[310-313]
- standards/team-collaboration.yaml[328-332]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


7. Owner ratification remains unenforced 🐞 Bug ⛨ Security
Description
The new extra_keys: [owner_ratify] metadata is only checked for a producer or textual mention; it
is never required by the verify-to-integrate transition or the reachability solver. Dependency and
schema changes can therefore reach integration after gate.pass and review.approve without the
declared owner third key.
Code

standards/team-collaboration.yaml[R362-363]

+        dep:     {mode: seat, seat: test_author, extra_keys: [owner_ratify]}
+        schema:  {mode: seat, seat: test_author, extra_keys: [owner_ratify]}
Relevance

●● Moderate

Semantically strong concern, but no close precedent enforces metadata in reachability.

PR-#5

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The only verify-to-integrate edge requires gate.pass plus a review event, while the validator
merely checks that each extra_keys string has provenance and then computes reachability without
adding or requiring that key. The integrator declaration also describes required checks and verifier
verdict but no executable owner-ratification consumer exists in this repository.

standards/team-collaboration.yaml[307-313]
standards/team-collaboration.yaml[357-371]
scripts/validate.py[190-207]
standards/archetype-profiles.yaml[174-179]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`owner_ratify` is declared as an extra merge key for dependency and schema changes but is not consumed by the executable phase transition or validator solver.

## Issue Context
Model class-specific merge requirements structurally and ensure both the runtime transition/integrator and validator require the extra keys before integration. Merely checking that a producer name exists is insufficient.

## Fix Focus Areas
- standards/team-collaboration.yaml[310-310]
- standards/team-collaboration.yaml[362-363]
- standards/team-collaboration.yaml[371-371]
- scripts/validate.py[190-207]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

8. supply-audit remains planned 📘 Rule violation ≡ Correctness
Description
The changed maintenance-flow declaration references supply-audit, but its registry entry has
status: planned rather than an approved/active status. This can make the declared issue-opening
path depend on a check that is not approved for use.
Code

standards/flows.yaml[R76-79]

+    open: "外部扫描器自动开(含指标/证据/期望状态引用)——dependabot/scorecard 平台带外
+      (显式依赖,体系外);supply-audit(checks.yaml planned)激活后并入。本仓内机制
+      不自开 issue:drift-check 产 drift 报告经 owner 周审转 proposals、CT 失败经
+      adversary findings、escape 经 owner——入口收敛于外部扫描器(ADR-0022 显式化,
Relevance

●●● Strong

Recent precedent rejects active registry references to unapproved entries.

PR-#21

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The changed flow names supply-audit as a scanner that will participate in issue creation, while
the corresponding entry in standards/checks.yaml is explicitly marked planned. The cited
compliance rule prohibits references to entries whose status is not approved.

Rule 2771006: Registry entries must only reference entries with approved status
standards/flows.yaml[76-80]
standards/checks.yaml[78-83]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The maintenance flow references `supply-audit` while its check registry entry is still `planned`, contrary to the requirement that referenced entries be approved.

## Issue Context
Either implement and approve/activate the check before declaring it as a flow dependency, or remove/defer the reference until that status transition occurs.

## Fix Focus Areas
- standards/flows.yaml[76-80]
- standards/checks.yaml[78-83]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


9. Waived merge copies stay stale 🐞 Bug ⚙ Maintainability
Description
The PR adds review.waived to the canonical transition but leaves sibling machine-facing
declarations requiring only review.approve. Consumers or auditors using the team orchestration or
attention ledger will still treat doc/trivial merges as impossible, recreating the classification
deadlock this change intends to remove.
Code

standards/team-collaboration.yaml[R310-313]

+      - {from: verify,  to: integrate, when: "gate.pass AND (review.approve OR review.waived)"}   # waived=doc/trivial
+                                     # 免 review(dispatch 表判定,card_gate 产事件)——waived≠免判卷:verifier gate
+                                     # 照跑(change-classes trivial.review 注)。ADR-0022:原"AND review.approve"使
+                                     # review=none 类按 change_class 分类死锁(issue #31 C-1)
Relevance

●● Moderate

The inconsistency is plausible, but no close synchronization precedent was found.

PR-#11

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The changed phase graph permits review.approve OR review.waived, but
registry/teams/dev-wave.yaml still describes orchestration merge as `gate.pass AND
review.approve`, and the attention ledger repeats the same old predicate. These are sibling copies
of the enumeration extended by this PR.

standards/team-collaboration.yaml[307-313]
registry/teams/dev-wave.yaml[26-30]
standards/attention-ledger.yaml[54-57]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Sibling merge-policy declarations still require only `review.approve` after the canonical graph adds `review.waived`.

## Issue Context
Update all copies to include waived decisions, or remove duplicated predicates and reference the canonical structured policy. Add validator coverage to prevent future divergence.

## Fix Focus Areas
- standards/team-collaboration.yaml[310-313]
- registry/teams/dev-wave.yaml[26-30]
- standards/attention-ledger.yaml[54-57]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Context sources
✅ Compliance rules (platform): 11 rules
Review mode: 🧠 Deep: This changes the central validator plus schemas, workflow declarations, standards, and regression tests across 44 hunks, creating many independent, easy-to-miss semantic and cross-file consistency risks.

Grey Divider

Tip of the day
💡 Did you know, you can show, collapse, or hide each part of a finding: code, evidence, and all

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment thread standards/flows.yaml
Comment on lines +76 to +79
open: "外部扫描器自动开(含指标/证据/期望状态引用)——dependabot/scorecard 平台带外
(显式依赖,体系外);supply-audit(checks.yaml planned)激活后并入。本仓内机制
不自开 issue:drift-check 产 drift 报告经 owner 周审转 proposals、CT 失败经
adversary findings、escape 经 owner——入口收敛于外部扫描器(ADR-0022 显式化,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

1. supply-audit remains planned 📘 Rule violation ≡ Correctness

The changed maintenance-flow declaration references supply-audit, but its registry entry has
status: planned rather than an approved/active status. This can make the declared issue-opening
path depend on a check that is not approved for use.
Agent Prompt
## Issue description
The maintenance flow references `supply-audit` while its check registry entry is still `planned`, contrary to the requirement that referenced entries be approved.

## Issue Context
Either implement and approve/activate the check before declaring it as a flow dependency, or remove/defer the reference until that status transition occurs.

## Fix Focus Areas
- standards/flows.yaml[76-80]
- standards/checks.yaml[78-83]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment thread scripts/validate.py
Comment on lines +385 to +388
_prof_allow = set(((prof.get("capabilities") or {}).get("allow")) or [])
excess = allow - _prof_allow
if excess:
fail(f"agent:{aid} capabilities.allow 越出 profile({arch}) 白名单: {sorted(excess)}"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

2. Mutable profiles bypass whitelist 🐞 Bug ⛨ Security

The new agent whitelist only enforces agent.allow ⊆ profile.allow, while profiles themselves are
checked only against the global side-effect vocabulary, so a PR can add a privileged capability to
both the profile and agent and pass validation. This defeats the advertised K–Q semantic defense and
the newly promoted curator/researcher control tests, including allowing vcs_admin for curator or
write capabilities for researcher.
Agent Prompt
## Issue description
Coordinated edits to an archetype profile and its agent instances bypass the new capability whitelist because the profile is treated as mutable authority and is only checked against the global vocabulary.

## Issue Context
The control tests now claim validator-enforced invariants such as curator never receiving `vcs_admin` and researcher receiving no write capability. Add explicit semantic invariants for these archetypes (or an independently protected capability policy) rather than deriving the boundary solely from the same mutable profile.

## Fix Focus Areas
- scripts/validate.py[237-241]
- scripts/validate.py[382-389]
- standards/control-tests.yaml[125-134]
- standards/control-tests.yaml[179-188]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +362 to +363
dep: {mode: seat, seat: test_author, extra_keys: [owner_ratify]}
schema: {mode: seat, seat: test_author, extra_keys: [owner_ratify]}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

3. Owner ratification remains unenforced 🐞 Bug ⛨ Security

The new extra_keys: [owner_ratify] metadata is only checked for a producer or textual mention; it
is never required by the verify-to-integrate transition or the reachability solver. Dependency and
schema changes can therefore reach integration after gate.pass and review.approve without the
declared owner third key.
Agent Prompt
## Issue description
`owner_ratify` is declared as an extra merge key for dependency and schema changes but is not consumed by the executable phase transition or validator solver.

## Issue Context
Model class-specific merge requirements structurally and ensure both the runtime transition/integrator and validator require the extra keys before integration. Merely checking that a producer name exists is insufficient.

## Fix Focus Areas
- standards/team-collaboration.yaml[310-310]
- standards/team-collaboration.yaml[362-363]
- standards/team-collaboration.yaml[371-371]
- scripts/validate.py[190-207]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +12 to +14
"decision",
"reviewer_seat",
"trace_id"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

4. Waived events fail schema 🐞 Bug ≡ Correctness

reviewer_seat is unconditionally required and restricted to human seats, but review.waived is
produced by mechanism:card-gate for doc/trivial changes. A truthful waived event therefore cannot
satisfy the newly declared payload contract, blocking the fast paths this PR adds.
Agent Prompt
## Issue description
The review-decision schema requires a human `reviewer_seat` even for `waived` decisions produced by card-gate.

## Issue Context
Use conditional JSON Schema branches: require an appropriate human seat for approve/changes_requested, and represent the card-gate mechanism (or omit reviewer_seat and require a producer field) for waived decisions.

## Fix Focus Areas
- registry/schemas/review-decision.json[8-15]
- registry/schemas/review-decision.json[28-40]
- standards/team-collaboration.yaml[331-332]
- standards/team-collaboration.yaml[357-359]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment thread scripts/validate.py
Comment on lines +838 to +842
if not isinstance(_sch, dict) or _sch.get("type") != "object":
fail(f"schema {sp.name} 顶层须为 type: object(io 契约载体——ADR-0022)")
continue
if not isinstance(_sch.get("properties"), dict):
fail(f"schema {sp.name} 缺 properties 对象(ADR-0022)")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

5. Schema validation misses invalid schemas 🐞 Bug ☼ Reliability

The new JSON Schema gate checks only JSON parsing and a few top-level fields, so invalid nested
schemas such as {"properties":{"x":{"type":"bogus"}}} pass validation. As a result, malformed IO
contracts can still merge despite this PR marking JSON Schema syntax validation as implemented.
Agent Prompt
## Issue description
The validator does not validate registry schemas against their declared JSON Schema metaschema, allowing invalid keyword values and malformed nested schemas.

## Issue Context
Use a Draft 2020-12 metaschema validator such as `Draft202012Validator.check_schema` for every schema, report validation errors through `fail`, and retain repository-specific checks only where they add policy beyond the metaschema.

## Fix Focus Areas
- scripts/validate.py[831-850]
- tests/test_validate.py[482-493]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +310 to +313
- {from: verify, to: integrate, when: "gate.pass AND (review.approve OR review.waived)"} # waived=doc/trivial
# 免 review(dispatch 表判定,card_gate 产事件)——waived≠免判卷:verifier gate
# 照跑(change-classes trivial.review 注)。ADR-0022:原"AND review.approve"使
# review=none 类按 change_class 分类死锁(issue #31 C-1)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

6. Waived merge copies stay stale 🐞 Bug ⚙ Maintainability

The PR adds review.waived to the canonical transition but leaves sibling machine-facing
declarations requiring only review.approve. Consumers or auditors using the team orchestration or
attention ledger will still treat doc/trivial merges as impossible, recreating the classification
deadlock this change intends to remove.
Agent Prompt
## Issue description
Sibling merge-policy declarations still require only `review.approve` after the canonical graph adds `review.waived`.

## Issue Context
Update all copies to include waived decisions, or remove duplicated predicates and reference the canonical structured policy. Add validator coverage to prevent future divergence.

## Fix Focus Areas
- standards/team-collaboration.yaml[310-313]
- registry/teams/dev-wave.yaml[26-30]
- standards/attention-ledger.yaml[54-57]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment thread scripts/validate.py
Comment on lines +507 to +511
_must_have = ((prof.get("io_guarantees") or {}).get("output_must_have")) or []
_missing = [k for k in _must_have if k not in _oprops]
if _missing:
fail(f"agent:{aid} 输出 schema {_out_ref} 缺 {arch}.io_guarantees.output_must_have "
f"必备字段 {_missing}(输出契约链断裂,ADR-0022)")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

7. Guarantees permit omitted fields 🐞 Bug ≡ Correctness

io_guarantees.output_must_have is checked only against schema properties, not required, so a
planner output may legally omit contracts_ref (or any other declared guarantee) while validation
still passes. This defeats the new output-contract gate and allows consumers to receive incomplete
wave plans.
Agent Prompt
## Issue description
`output_must_have` currently verifies only that fields are declared in schema `properties`; it must also verify that those fields are required in emitted output.

## Issue Context
The planner profile now declares `contracts_ref` as guaranteed, but `wave-plan.json` does not list it in its top-level `required` array. Thus a syntactically valid planner output can omit it.

## Fix Focus Areas
- scripts/validate.py[507-511]
- standards/archetype-profiles.yaml[94-95]
- registry/schemas/wave-plan.json[8-14]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +33 to +35
"rationale": {
"type": "string",
"description": "changes_requested 时必填(返工依据)"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

8. Rejections lack mandatory rationale 🐞 Bug ≡ Correctness

The new review-decision schema states that rationale is mandatory for changes_requested, but
neither the unconditional required list nor a conditional rule enforces it. A schema-valid
rejection event can therefore omit the only documented rework basis and send the builder back to
build without a reason.
Agent Prompt
## Issue description
The review-decision contract documents `rationale` as required for `changes_requested`, but the JSON Schema does not enforce that condition, allowing such payloads to omit the rationale.

## Issue Context
A payload containing all top-level required fields and `decision: "changes_requested"` but omitting `rationale` is accepted. This removes the stated return-work basis from a review event; add an `if`/`then` condition requiring a non-empty rationale when the decision is `changes_requested`, plus positive and negative schema tests.

## Fix Focus Areas
- registry/schemas/review-decision.json[8-15]
- registry/schemas/review-decision.json[28-35]
- registry/schemas/review-decision.json[46-46]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +75 to +79
review.*: {read: [team_members, scheduler, owner], write: [test_author, curator]}
# review 裁定= decision 类自述事件(合并闸门钥匙之一);
# test_author=代码符合性(logic/dep/schema/prod),
# curator=spike 入库审核(dispatch 表——ADR-0022);
# payload 契约=registry/schemas/review-decision.json

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

9. Waiver producer lacks channel access 🐞 Bug ≡ Correctness

review.waived is newly declared as produced by mechanism:card-gate, but the changed review.*
ACL permits writes only from test_author and curator. Consequently the card-gate cannot publish
the waiver event required by doc/trivial's new verify → integrate transition, leaving those
classes blocked at verify when ACL enforcement is applied.
Agent Prompt
## Issue description
The review channel ACL does not authorize the mechanism selected as the producer of `review.waived`.

## Issue Context
Doc and trivial dispatch modes depend on `review.waived` to satisfy the new verify-to-integrate condition. The declared producer is `mechanism:card-gate`, while `review.*` write access is limited to the two human/agent seats.

## Fix Focus Areas
- standards/team-collaboration.yaml[75-79]
- standards/team-collaboration.yaml[310-313]
- standards/team-collaboration.yaml[328-332]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

@randypanding
randypanding merged commit f5d88e8 into main Aug 19, 2026
12 of 13 checks passed
@randypanding
randypanding deleted the fix/issue-31-gate-hardening branch August 19, 2026 09:05
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant