gapfill2: worker/sub90 coverage tests, G7 rollback branch, G5 caller-contract docs

H1 worker.py 92%->94% (277->210 miss): 35 real-assertion tests
covering goal-signal, tenant/env, followup, poll/wait,
process/watchdog and injected defensive branches; prod code 0 changes.
H2 sub-90 sweep: approval_timeout 100%, merge_gate_hard 100%,
worker_sweep 98% (only __main__ line 174 left); 14 tests.
H3 G7 rollback except:pass (server.py:6615-6616) covered by an
injected rollback-raising connection; original error still propagates,
status stays completed, retry succeeds; no semantics change.
H4 caller contract documented only (docstrings in _audit_scorecard
endpoint, check_baseline_stale, build_scorecard, baseline store):
current_main_head caller-supplied, any string as-is, no format checks,
missing/empty treated as not passed with no stale determination at the
endpoint, always 200, overall never rewritten; no new validation or
rejection, no response-structure change. 3 doc tests pin the wording.
H5 design notes (no decisions, no code changes) live in
verification/code-to10-gapfill2-design-notes.md, referenced by the
batch summary.
No bug found by the new tests; no existing assertion touched.
This commit is contained in:
host committed 2026-11-04 16:20:10 +00:00
1 parent 5d0651e70a
commit aba06d9a24
7 files changed
+1062 -2

No files matched your search

+15 -1
View File
@@ -31,6 +31,9 @@
build_scorecard(..., baseline_head=None) 的 baseline_head 是机器字段,
只能由调用方显式传入当前 main 头;本模块绝不在生产代码里探测
版本控制状态、绝不读版本控制目录、绝不编造一个头。
接受任意字符串、原样记录,不做任何格式校验(不要求形如
commit hash);本模块不验证该值是否真实、可信,可信 main 头
的来源仍是调用方责任。
不传入(或传入空串)时 baseline_head 为 None,并在 missing_items
里记 baseline_head_missing,不把缺失读成“与当前一致”。
check_baseline_stale(scorecard, current_main_head) 是唯一的漂移判定:
@@ -916,6 +919,16 @@ def check_baseline_stale(scorecard, current_main_head):
参数全部由调用方传入:scorecard 是 build_scorecard 的输出 dict,
current_main_head 是调用方当前确认的 main 头。本函数不在生产
代码里探测版本控制状态,也不读版本控制目录。
调用方契约(gapfill2 H4,只写文档、不改行为):
current_main_head 接受任意字符串、原样比对,不做任何格式
校验(不要求形如 commit hash,不校验长度、字符集、前缀);
本函数不验证该值是否真实、可信、是否确为 main 头——可信
main 头的来源仍是调用方责任。空串先归一化为 None,与未
传入同等处理。注意端点层与函数层的区别:评分卡端点在缺失
或空串时根本不调用本函数(不做判定、不附加判定字段);
调用方若直接调本函数且 current_main_head 缺失,本函数按
失败关闭返回 stale=True(见下三种情形之二),那是函数层
面的判定结果,不是端点行为。
返回 dict(调用方凭 stale / usable_as_pass_basis 判断,绝不能
只看旧卡的 overall / overall_pass):
@@ -1068,7 +1081,8 @@ def build_scorecard(evidence, thresholds=None, rubric_version=None,
(user_side_items 可选占位),product=build_product_scorecard
(无真实产品轮证据时恒为 not_pass)。新增键不改变旧字段的值。
另新增 rubric_version(见 cloud/scorecard_rubric.py)、
baseline_head(机器字段,见 check_baseline_stale)、
baseline_head(机器字段,见 check_baseline_stale;接受任意
字符串原样记录、不做格式校验,空串按未传入处理)、
evidence_ledger_head 与 evidence_row_ids(见
compute_evidence_ledger)三个机制字段;无证据行时头为 None。
"""