oh-my-muse/docs/memorys/2026-06-13-P1RContentAdminRiskAction状态推进.md

10 KiB
Raw Blame History

P1R Content Admin RiskAction 状态推进

日期2026-06-13

结论

本轮只推进 Content 管理端治理写命令 1 个 operation-level completed approval

  • content:adminRiskAction

Content 仍不是整域 completed。其余 37 个 Content operation 继续 dedicated/needs_verification

本轮未修改 OpenAPI未修改 Content 业务实现,未修改 SQL migration未把 content 加入 domain-level completed allowlist。

工作区与基线

工作区:

/Users/qingse/.config/superpowers/worktrees/oh-my-muse/dev-1.0.0

基线 HEAD

b0b4b2c test(p1r): 收口 Content Admin Read completed approval 门禁

实施前 coverage summary

233	144	89	0	0	0

实施后 coverage summary

233	145	88	0	0	0

实施后 Content 状态:

completed=14
needs_verification=37

目标 operation 状态:

adminRiskAction	dedicated	completed	true

代表性非目标 operation 仍保持:

adminListExportTasks	dedicated	needs_verification	false
adminListImportTasks	dedicated	needs_verification	false
createWork	dedicated	needs_verification	false
exportWork	dedicated	needs_verification	false
createStyleCheck	dedicated	needs_verification	true
getStyleCheckResult	dedicated	needs_verification	false

修改范围

本轮修改:

  • muse-cloud/scripts/p1r-audit-api-coverage.py
  • docs/superpowers/reports/p1r-api-coverage.json
  • docs/superpowers/reports/p1r-api-coverage.md
  • muse-cloud/muse-server/src/test/java/cn/iocoder/muse/server/framework/api/P1rApiCoverageReportTest.java
  • muse-cloud/muse-server/src/test/java/cn/iocoder/muse/server/framework/api/P1rContentRealApiGateTest.java
  • muse-cloud/muse-server/src/test/java/cn/iocoder/muse/server/framework/api/P1rEventsRealApiGateTest.java
  • muse-cloud/muse-server/src/test/java/cn/iocoder/muse/server/framework/api/P1rAiRealApiGateTest.java
  • muse-cloud/muse-server/src/test/java/cn/iocoder/muse/server/framework/api/P1rKnowledgeRealApiGateTest.java
  • muse-cloud/muse-server/src/test/java/cn/iocoder/muse/server/framework/api/P1rMarketRealApiGateTest.java
  • muse-cloud/muse-server/src/test/java/cn/iocoder/muse/server/framework/api/P1rAccountRealApiGateTest.java
  • muse-cloud/muse-server/src/test/java/cn/iocoder/muse/server/framework/api/P1rMetaRealApiGateTest.java
  • muse-cloud/muse-server/src/test/java/cn/iocoder/muse/server/framework/api/P1rContentAdminRiskActionCompletedApprovalIT.java
  • docs/agent-specs/.agent
  • docs/agent-specs/2026-06-13-P1RContentAdminRiskActionCompletedApproval审阅版.md
  • docs/agent-specs/2026-06-13-P1RContentAdminRiskActionCompletedApproval执行版.md
  • docs/memorys/2026-06-13-P1RContentAdminRiskAction状态推进.md

未修改:

  • 7 个 OpenAPI。
  • Content 业务实现。
  • SQL migration。
  • Content domain-level completed allowlist。

TDD evidence

RED 阶段先修改 P1R gate 期望值和 adminRiskAction completed 断言,在旧 scanner/report 下运行 focused P1R gates预期失败已出现

Tests run: 49, Failures: 12, Errors: 0, Skipped: 0
BUILD FAILURE

失败点来自旧 report 仍为 completed=144 / needsVerification=89,以及 adminRiskAction 仍为 needs_verification;没有编译错误或无关测试失败。

GREEN 阶段只把 content:adminRiskAction 加入 scanner operation-level allowlist重新生成 report并完成 HTTP+DB _test evidence 和 focused gates。

MockMvc HTTP 入口 + DB 证据

新增:

  • muse-cloud/muse-server/src/test/java/cn/iocoder/muse/server/framework/api/P1rContentAdminRiskActionCompletedApprovalIT.java

验证方式:

  • 使用 Spring Mock web context + MockMvc
  • 通过 /admin-api/muse/content/works/{workId}/risk-actions HTTP 入口进入 AdminContentController
  • 使用真实 ContentAdminServiceImplContentCommandServiceImplContentAuditServiceImpl、mapper 和 PostgreSQL _test 数据库。
  • 启用 method security并用 test-local ss bean 验证 muse:content:risk-action 权限门禁。
  • 注册真实 tenant SQL interceptor。
  • Flyway clean/migrate V1-V21。
  • 密码只从环境变量读取,拒绝 JVM password system property 和 JDBC credential query。
  • @AfterAll 恢复 p1r.flyway.url / p1r.flyway.user,避免污染同一 Surefire JVM 后续 Flyway 测试。

说明:这里的 HTTP 入口证据是执行版要求的 WebApplicationContext + MockMvc 请求路径证据,不是启动真实 socket 端口的 live servlet container 证据。

单类验证数据库:

muse_p1r_content_admin_risk_action_completed_approval_test

通过结果:

P1rContentAdminRiskActionCompletedApprovalIT: tests=8, failures=0, errors=0, skipped=0

覆盖内容:

  • 拒绝非 _test 数据库、JVM password system property 和 JDBC credential query。
  • V1-V21 schema gate覆盖 muse_content_governance_action 的 JSONB target_ids、unique command 约束、work 索引和 updated_at trigger。
  • duplicate (tenant_id, command_id) 返回 SQLState 23505
  • WorkMapper.selectByIdForUpdate 源码断言包含 FOR UPDATE
  • API version、RBAC 和 Bean Validation 拒绝路径均 no-write。
  • work scope happy path 写 governance action、command/audit envelope不写 Content Events outbox。
  • chapter / block scope happy path 只允许 target 属于 URL work。
  • notify_owner 返回 pending_notification,其它支持 action 返回 executed
  • command replay 返回首次结果,不重复写 governance action、command/audit 或 outbox。
  • command conflict、revision conflict、unsupported action、unsupported targetScope、空 targetIds、null targetIds、missing/cross-work/cross-tenant target、block->chapter->work 链路不匹配和 cross-tenant work 都整体回滚。
  • command row 断言 tenant_idcommand_idcommand_type=adminRiskActionowner_user_idtarget_type=worktarget_idrequest_hash
  • governance action row 断言 tenant_idwork_idoperator_user_idcommand_idaudit_log_idactionreasontarget_scopetarget_idsexpected_versionstatus
  • command/audit snapshot 解析断言 operationId=adminRiskActionside=admintargetType=worktargetIdstatus=succeededreasonrequestSummaryresult
  • no-write / rollback 使用 row_to_json(t)::textmuse_content_workmuse_content_chaptermuse_content_blockmuse_content_governance_actionmuse_content_command_logmuse_content_event_publish_outbox 做全表快照比对。

组合验证

组合验证使用真实 PostgreSQL _test 库:

muse_p1r_content_admin_risk_action_combined_test

通过结果:

P1rContentAdminRiskActionCompletedApprovalIT: tests=8, failures=0, errors=0, skipped=0
P1rContentAdminReadCompletedApprovalIT: tests=5, failures=0, errors=0, skipped=0
P1rContentPlanningCompletedApprovalIT: tests=11, failures=0, errors=0, skipped=0
P1rContentCoreCompletedApprovalIT: tests=12, failures=0, errors=0, skipped=0
P1rContentEventsPublishFlywayMigrationIT: tests=4, failures=0, errors=0, skipped=0
combined: tests=40, failures=0, errors=0, skipped=0

focused Content tests

执行版 focused tests 已单独运行,并确认 XML 为本轮 fresh 产物:

ContentAdminServiceTest: tests=13, failures=0, errors=0, skipped=0
AdminContentControllerTest: tests=8, failures=0, errors=0, skipped=0
focused total: tests=21, failures=0, errors=0, skipped=0

P1R mixed gates

P1R mixed gates 已 fresh 运行:

P1rApiCoverageReportTest: tests=6, failures=0, errors=0, skipped=0
P1rContentRealApiGateTest: tests=5, failures=0, errors=0, skipped=0
P1rEventsRealApiGateTest: tests=7, failures=0, errors=0, skipped=0
P1rAiRealApiGateTest: tests=7, failures=0, errors=0, skipped=0
P1rKnowledgeRealApiGateTest: tests=8, failures=0, errors=0, skipped=0
P1rMarketRealApiGateTest: tests=6, failures=0, errors=0, skipped=0
P1rAccountRealApiGateTest: tests=5, failures=0, errors=0, skipped=0
P1rMetaRealApiGateTest: tests=5, failures=0, errors=0, skipped=0
mixed total: tests=49, failures=0, errors=0, skipped=0

scanner / report

执行命令:

python3 muse-cloud/scripts/p1r-audit-api-coverage.py --check

通过后确认:

233	145	88	0	0	0
51	14	37	0	0	0
adminRiskAction	dedicated	completed	true

protected diff

以下保护面 diff 为空:

docs/api-contracts
muse-cloud/muse-module-content/muse-module-content-server/src/main/java
muse-cloud/sql/muse

git diff --check 无输出。

fresh implementation review

Lagrange data-integrity/testing review

PASS
findings=none

Lagrange 已只读验证:

  • P1rContentAdminRiskActionCompletedApprovalIT 使用 MockMvc HTTP + WebApplicationContext + 真实 PostgreSQL _test
  • 真实 controller/service/mapper、method security、tenant interceptor、Flyway V1-V21、command/governance 行级事实、command/audit snapshot、no-write / rollback 和 XML evidence 均闭合。
  • coverage 为 233/145/88/0/0/0Content 为 14 completed / 37 needs_verification,非目标 Content operation 仍保持 needs_verification
  • protected diff 与 git diff --check 均无问题。

Gauss scope review

PASS
findings=none

Gauss 已只读验证:

  • diff 只在 scanner/report、P1R gate tests、新 IT、docs/agent-specsdocs/memorys 范围内。
  • protected diff 为空。
  • scanner 只追加 content:adminRiskAction operation-level keyAPPROVED_COMPLETED_DOMAINS 仍为 {"ai", "knowledge"}
  • summary 为 233/145/88/0/0/0Content 为 14 completed / 37 needs_verification
  • adminRiskActiondedicated/completed/requiresCommandId=true,抽样非目标 Content operation 仍为 dedicated/needs_verification
  • 文档没有宣称 Content 51/51、Account remaining、Market remaining 或总 P1R completed。

后续路线

content:adminRiskAction 之后Content 仍剩余 37 个 dedicated/needs_verification operation。后续应继续按 operation-level approval 切片推进,优先只选择证据闭合、外部依赖少、可用 HTTP+DB _test 证明的 operation不要把 Content 51/51、Account remaining、Market remaining 或总 P1R completed 混入本轮结论。