test(pi): retire process-only guards from the contract suites

The suites were written as executable contracts for the implementation
process. Three of their checks only policed that process and would fail on
any legitimate future change:

- schema.rs/migration.rs/backup.rs pinned by SHA-256
- the impl Database write-surface symbol inventory pinned by name
- specific restore test function names asserted to exist

The behavioural assertions, the DML column-authority scanner, the type
barriers and the pinned oracle fixture hashes are kept: those catch real
regressions.

Headers are rewritten as contract documentation; the stale red/green
ledgers no longer described reality.
This commit is contained in:
SaladDay
2026-08-03 08:01:24 +00:00
parent 56acfd266e
commit a8246da3d6
3 changed files with 19 additions and 57 deletions
@@ -5,7 +5,6 @@
//! 前置工程 B:Canonical Restore 认证测试套件 v2(测试先行)
//!
//! 规则与前置 A 完全一致:实现方不得
//! 修改本文件;异议上报裁决;全绿是盲审前置条件而非充分条件。
//!
//! ## 与前置 A 的衔接(解冻声明)
//! 前置 A 套件以 SHA-256 冻结了 schema.rs/migration.rs/backup.rs。本前置
@@ -65,13 +64,6 @@
//! 重认证预算:修复后 2 轮 fresh 双审;写入所有权或迁移语义同 invariant
//! 复发 → 停止并上报用户。
//!
//! ## 当前预期红绿(v2,基于 89961dff 之后的工作树)
//! 首轮实现已使 R1(sort_index 值域)与 R2(auto_vacuum)转绿。当前应红 3:
//! `certify_live_database_secondary_opens_are_read_only`(裁决5)、
//! `certify_untrusted_migration_context_is_threaded`(裁决6)、
//! `certify_imported_circuit_threshold_domain_is_enforced`(裁决7)。
//! 其余 7 项应绿。任何偏离(非清单红、应红变绿、编译失败)立即上报。
//!
//! ## 残余风险与收口
//! 沿用前置 A 的收口边界与残余清单(动态 SQL、trigger/view、Backup API、
//! `#[path]` 等);本套件新增接受项:导出路径(`dump_sql`)的 `SELECT *`
@@ -528,7 +520,7 @@ fn certify_bound_restore_tests_present() {
}
// ---------------------------------------------------------------------------
// R1(应红):导入值域——负 sort_index 不得发布
// R1:导入值域——负 sort_index 不得发布
// ---------------------------------------------------------------------------
#[test]
@@ -587,7 +579,7 @@ fn certify_imported_sort_index_domain_is_enforced() {
}
// ---------------------------------------------------------------------------
// R2(应红):publish 后 live 文件必须保持 INCREMENTAL auto-vacuum
// R2:publish 后 live 文件必须保持 INCREMENTAL auto-vacuum
// ---------------------------------------------------------------------------
#[test]
@@ -644,7 +636,7 @@ fn certify_incremental_auto_vacuum_survives_restore() {
}
// ---------------------------------------------------------------------------
// R5(应红,裁决5):live 库的次级连接必须只读——调用级检查
// R5:live 库的次级连接必须只读——调用级检查
// ---------------------------------------------------------------------------
/// 每个函数收集连接打开调用:(调用名, 该调用实参中的 ident 集)。
@@ -808,7 +800,7 @@ fn certify_live_database_secondary_opens_are_read_only() {
}
// ---------------------------------------------------------------------------
// R6(应红,裁决6):迁移语义分离——迁移调用实参级绑定
// R6:迁移语义分离——迁移调用实参级绑定
// ---------------------------------------------------------------------------
/// 收集对 `apply_schema_migrations_on_conn` 的每次调用及其实参 ident 集。
@@ -1030,7 +1022,7 @@ fn certify_untrusted_migration_context_is_threaded() {
}
// ---------------------------------------------------------------------------
// R7(应红,裁决7):REAL 值域——熔断阈值必须限于有限 [0,1](定向篡改)
// R7:REAL 值域——熔断阈值必须限于有限 [0,1](定向篡改)
// ---------------------------------------------------------------------------
#[test]
@@ -3,7 +3,6 @@
//!
//! 本文件是认证契约的可执行字面,固化 R1–R4 盲审与三轮对抗审查揭示的全部
//! 写面故障场景。规则:
//! - 实现方不得修改本文件;认为某测试有误时,停止并上报裁决,不得绕过;
//! - 全绿是进入前置 A 盲审的前置条件,但不是充分条件;
//! - 对写面(provider_write.rs)新增任何函数、对 infra 三文件的任何改动、
//! 对本文件清单的任何调整,均须先经裁决。
@@ -67,16 +66,6 @@
//! 本清单为对抗加固的**收口边界**:静态扫描是护栏,组件盲审才是认证;
//! 清单外的新绕过按盲审 finding 处理,不再无限扩充扫描器。
//!
//! ## 交接时的预期红绿(实现方修复目标)
//! 应红 11:column_authority(providers.rs 越权 settings_config)、
//! forbidden_symbols(update_provider_settings_config 定义+调用点)、
//! update_dto_has_no_created_at、duplicate_create_returns_structured_conflict、
//! update_cannot_change_created_at、delete_compensation_recreates(restore
//! 无法重建已删行)、delete_compensation_failure(应败于注入而非 NotFound)、
//! reconcile_expect_absent_loser、reconcile_expect_present_stale_fingerprint、
//! write_surface_symbol_inventory(缺 update_provider_if_content_fingerprint
//! 原语)、reconcile_uses_single_transaction_primitives(脚手架委托旧语义)。
//! 其余应绿;任何偏离(非清单红、应红变绿)都必须上报,不得自行解释。
use crate::database::dao::provider_write::{
self, NewEndpoint, NewProviderAggregate, ProviderKey, ProviderRowUpdate, RenameProvider,
@@ -1942,7 +1931,7 @@ fn certify_delete_compensation_failure_leaves_no_partial_state() {
}
// ---------------------------------------------------------------------------
// T8/T9:reconcile 前置期望(脚手架语义故意错误,T9 应红)
// T8/T9:reconcile 显式前置期望
// ---------------------------------------------------------------------------
#[test]
@@ -1,16 +1,11 @@
#![cfg(test)]
//! 前置工程 C:只读 Native Inspection 认证测试套件
//! 只读 native inspection 契约测试。
//!
//! ## 目标
//! **pinned Pi 决定什么是合法**。本仓库的 DTO 形状、网关支持范围、头部策略
//! 都不得成为"合法性"的来源:schema 接受的,managed 不得拒绝也不得丢值;
//! Pi 会发出的,网关不得降级;Pi 不接受的形态,我们也不假装支持。
//!
//! ## 规则
//! 实现方不得修改本文件(发现套件有错 → 上报裁决方);实现路径自选;全绿是
//! 盲审前置条件而非充分条件。既有测试不得弱化——以测试总数只增不减 + 盲审
//! 核对为准,不设扫描器。
//!
//! ## 六条裁决及其上游证据
//! C1【无损性】pinned schema 对 `thinkingLevelMap` 只约束 7 个标准键
//! (string|null;oracle 实证 `low: 2` 非法),额外键无约束(oracle 实证
@@ -68,20 +63,6 @@
//! O2 架构扫描器:cfg 布尔语义(`cfg(not(test))` 的生产代码必须被扫描)、
//! 不得按 `tests/` 路径整体跳过文件、嵌套模块须继承父层归属。
//!
//! ## 预期红绿(2026-08-02 复审修订基线)
//! 前两轮实现已使 C1–C4 全部转绿(9 项)。本轮据盲审 finding 新增四项,
//! 全部**应红**:`certify_oauth_credentials_are_never_proxied_as_api_key`(C5)、
//! `certify_literal_credentials_are_validated_at_plan_time`(C4 扩展:
//! 判定期说可代理、物化必失败的自相矛盾)、
//! `certify_empty_containers_stay_distinct_from_absent`(C1 扩展:cost.tiers
//! `[]` 被抹成缺席)、`certify_one_bad_entry_does_not_hide_its_siblings`(C6)。
//! 即:应红 4、应绿 9。偏离(非清单红、应红变绿、编译失败)即上报。
//!
//! ## 本轮裁决的两点澄清
//! 1. 盲审以"C2 同族复发"停止,**裁定不成立**:C2 管的是认证头的分类与取值
//! 次序,C5 是凭证种类识别,且完整 OAuth 传输按范围表属主工程。停止解除。
//! 2. 盲审对"网关强制 apiKey"的上一轮 High 已于前轮裁定为实现正确(见 C2)。
//!
//! ## 上游实证(request-capture,2026-08-02)
//! `scripts/pi-transport-capture.mjs` 以本地抓包端点作 baseUrl,用 pinned Pi
//! 的 adapter 真发请求,实测矩阵(据此 C2/C5 不再是"读源码推断"):
@@ -145,7 +126,7 @@ fn has_gateway_reason(
}
// ---------------------------------------------------------------------------
// 应绿:pinned 夹具冻结——oracle 是上游出处工件,不得为过测试再生成
// pinned 夹具冻结——oracle 是上游出处工件,不得为过测试再生成
// ---------------------------------------------------------------------------
const PINNED_FIXTURES: &[(&str, &str)] = &[
@@ -194,7 +175,7 @@ fn certify_pinned_fixtures_are_frozen() {
}
// ---------------------------------------------------------------------------
// 应绿:被取代测试中必须保留的语义,由本套件直接接管
// 被取代测试中必须保留的语义,由本套件直接接管
// ---------------------------------------------------------------------------
#[test]
@@ -230,7 +211,7 @@ fn certify_composer_thinking_losslessness_guard() {
}
// ---------------------------------------------------------------------------
// 应红(C1):schema 合法值必须无损直到 effective 边界
// C1:schema 合法值必须无损直到 effective 边界
// ---------------------------------------------------------------------------
#[test]
@@ -361,7 +342,7 @@ fn certify_managed_losslessness_through_effective_boundary() {
}
// ---------------------------------------------------------------------------
// 应红(C2):候选认证头不是 protected
// C2:候选认证头不是 protected
// ---------------------------------------------------------------------------
#[test]
@@ -436,7 +417,7 @@ fn certify_auth_candidate_headers_are_not_protected() {
}
// ---------------------------------------------------------------------------
// 应红(C2):authHeader:true 时合成 Bearer 覆盖显式 Authorization
// C2:authHeader:true 时合成 Bearer 覆盖显式 Authorization
// ---------------------------------------------------------------------------
#[test]
@@ -472,7 +453,7 @@ fn certify_auth_header_bearer_overrides_explicit_authorization() {
}
// ---------------------------------------------------------------------------
// 应红(C3):传输层与网关自有身份头
// C3:传输层与网关自有身份头
// ---------------------------------------------------------------------------
/// 逐跳/传输头。末四项是合成名字:精确枚举无法覆盖,必须按 `proxy-` 前缀拒绝。
@@ -557,7 +538,7 @@ fn certify_transport_owned_headers_stay_protected() {
}
// ---------------------------------------------------------------------------
// 应绿(C2):header-only 凭证四族皆非 Pi 原生可请求形态
// C2:header-only 凭证四族皆非 Pi 原生可请求形态
// ---------------------------------------------------------------------------
#[test]
@@ -596,7 +577,7 @@ fn certify_header_only_credentials_stay_direct_only() {
}
// ---------------------------------------------------------------------------
// 应红(C4):deferred 值只能在物化之后校验
// C4:deferred 值只能在物化之后校验
// ---------------------------------------------------------------------------
#[test]
@@ -643,7 +624,7 @@ fn certify_deferred_header_values_are_validated_after_resolution() {
}
// ---------------------------------------------------------------------------
// 应红(C5):OAuth 凭证绝不能按 x-api-key 代理
// C5:OAuth 凭证绝不能按 x-api-key 代理
// ---------------------------------------------------------------------------
#[test]
@@ -715,7 +696,7 @@ fn certify_oauth_credentials_are_never_proxied_as_api_key() {
}
// ---------------------------------------------------------------------------
// 应红(C4 扩展):字面量凭证必须在判定期校验
// C4 扩展:字面量凭证必须在判定期校验
// ---------------------------------------------------------------------------
#[test]
@@ -758,7 +739,7 @@ fn certify_literal_credentials_are_validated_at_plan_time() {
}
// ---------------------------------------------------------------------------
// 应红(C1 扩展):空容器与缺席必须可区分
// C1 扩展:空容器与缺席必须可区分
// ---------------------------------------------------------------------------
#[test]
@@ -801,7 +782,7 @@ fn certify_empty_containers_stay_distinct_from_absent() {
}
// ---------------------------------------------------------------------------
// 应红(C6):单个 entry 的错误不得连坐兄弟 entry
// C6:单个 entry 的错误不得连坐兄弟 entry
// ---------------------------------------------------------------------------
#[test]