v2 evidence: bind release evidence with ts/nonce, pin actual-only quota, ledger onboarding checklist, ledger failure outbox, read-only gate verifier (no live wiring)

- cloud/evidence_binding.py: bind/validate/nonce single-use store;
  release endpoint consumes nonce on first validated submission,
  replay -> 409 evidence_replayed, stale/future -> 409
  evidence_stale, partial -> 400, absent -> old path + label.
  Binding blocks exact replay and stale evidence, NOT restamping
  (unsigned evidence cannot prove content freshness).
- cloud/quota.py docstring: actual-only is the v2 integration
  position (already converged in v1 base via fef09ae, NOT in
  main); original PR semantics (#86 all-rows vs #90 actual-only)
  still pending coordinator confirmation at merge time.
- cloud/ledger_onboarding.py: DDL checklist referencing
  PG_DDL/PG_MARKER_DDL constants, read-only verify_ledger_ready
  and ledger_setup_report; default stays OFF, PG DDL stays an
  operator action (never claimed as executed).
- cloud/ledger_outbox.py + worker hook: ledger write failures
  go to a JSONL outbox in addition to the log and can be
  replayed; task outcome still unaffected (rule 7 kept),
  audit fail-closed untouched -- asymmetry documented, not
  silently changed.
- cloud/gate_verification.py: read-only verifier over an
  injected reader (match/mismatch/skipped); live wiring in
  merge/release is NOT possible on the current contract (no
  repo/ref in body or task row, no guaranteed trusted token),
  proven in the module header; no fake verification claimed.
- cloud/tests/test_v2_evidence.py: 18 new tests, all passing.

(cherry picked from commit bd85e33cd5e846fa6ee5d7e2440182dbd9c758b0)
This commit is contained in:
host committed 2026-11-04 21:03:32 +00:00
1 parent f16941347f
commit 27c2acd5d0
9 files changed
+1263 -2

No files matched your search

+12
View File
@@ -14,6 +14,18 @@ automations._automation_quota_exceeded),且三处已经
绝不能触发上限;服务端 _quota_unpriced_tokens 改为本
模块口径(行为变化仅限含 estimated 无价行的用户:此
前可能被估算行误拦,此后不再误拦;真实花费的拦阻不变)。
集成 v2 确认(临时口径,非原 PR 已定):本收敛来自
集成基底(非 main),原 PR 语义(main 里 #86 计全部
vs #90 actual-only 的分歧)并未在 main 上改动;合轨
时须由协调员另行确认 actual-only 是否成为原 PR 口径,
本轨只把集成 v2 的口径钉死并补双侧回归测试(见
cloud/tests/test_v2_evidence.py),绝不把临时口径写
成原 PR 已定。受影响调用方:server._quota_snapshot /
_check_unpriced_token_cap、worker._quota_limit_and_used /
_quota_exceeded、automations._automation_quota_exceeded,
三处均经本模块 monthly_usage + decide,改一处即三处
同口径;USD 求和不受影响(estimated 行 usd 为 NULL,
SUM 本就跳过)。
- 默认配额解析:server、worker、automations 各一份
CLOUD_DEFAULT_QUOTA_USD_MICROS 解析,现统一为
default_quota_usd_micros(默认值 $10/月 = 10_000_000