From b7baa24b5ed87256fb846236b08c75ff02887e9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=98=BF=E7=99=BD=E5=8F=94?= <11794527+absfan@user.noreply.gitee.com> Date: Mon, 9 Nov 2026 10:26:09 +0800 Subject: [PATCH] fix: identify foreign CBB checkpoints in release evidence --- docs/releases/2026-11-09-pr10-review309.md | 7 +++ .../2026-11-09-other-pr-latest-reviews.md | 25 +++++++++ src/cbb_refresh_verify/library_lock.py | 13 +++++ tests/test_review_foreign_release_evidence.py | 52 +++++++++++++++++++ 4 files changed, 97 insertions(+) create mode 100644 docs/releases/2026-11-09-pr10-review309.md create mode 100644 docs/superpowers/plans/2026-11-09-other-pr-latest-reviews.md create mode 100644 tests/test_review_foreign_release_evidence.py diff --git a/docs/releases/2026-11-09-pr10-review309.md b/docs/releases/2026-11-09-pr10-review309.md new file mode 100644 index 0000000..38ff3d3 --- /dev/null +++ b/docs/releases/2026-11-09-pr10-review309.md @@ -0,0 +1,7 @@ +# PR #10 comment 309 + +Release proof now records the requested CBB, effective BLOCK/LIBRARY proof scope, identities/statuses of archived checkpoints and retained owners, and `reconciled_foreign_blockers`. For example, a BlockA operation which safely reconciles BlockB's historical checkpoint explicitly lists BlockB and the full-library proof. `data_recovery_confirmed` remains false. No extra gate, automatic backup or native action was added. + +Three regressions first failed on missing evidence fields. After the fix, 94 backend/lease/release regressions passed; compileall and git diff --check passed. The tests use real temporary file/lease handles with the process-query boundary replaced; no production library was opened. Full regression is run again at the integrated chain tip. Real Mentor/shared-network acceptance and a rebuilt package remain outstanding. + +Review: https://git.simgreek.com/Skyworth_Digital_Hardware/cbb-refresh-verify-795/pulls/10#issuecomment-309 diff --git a/docs/superpowers/plans/2026-11-09-other-pr-latest-reviews.md b/docs/superpowers/plans/2026-11-09-other-pr-latest-reviews.md new file mode 100644 index 0000000..0ac61ac --- /dev/null +++ b/docs/superpowers/plans/2026-11-09-other-pr-latest-reviews.md @@ -0,0 +1,25 @@ +# Latest reviews for PR #10/#11/#12 + +Scope: user selected only the 2026-11-09 comments #309/#310/#313. Earlier deep-review backlog stays out of scope. Preserve ICDB automatic Repair OFF, serial writes, current icon and independent-library admission. No merge to main, issue closure or release. + +## PR #10 + +- [ ] Reproduce BlockA releasing historical BlockB checkpoints and retained owners without naming BlockB in proof. +- [ ] Record requested block, actual proof scope, checkpoint identities and foreign names in existing release proof. Preserve original checkpoint bytes and data_recovery_confirmed=False; no new blocking gate. +- [ ] Run backend/lease regressions, compile/diff checks, commit on codex/review-native-backend. + +## PR #11/#12 + +- [ ] Forward-merge backend into UI, then UI into residual branch; no history rewriting. +- [ ] Test one unreadable process/thread not affecting another, without fabricated modal windows; cover preview and action-time rechecks. +- [ ] Enumerate only target-process threads/windows, store incomplete-read metadata per PID. Keep unknown/active writers protected rather than adding a blind force override. +- [ ] Persist window identities and at most a 4 KiB output excerpt, preserve full preview in memory, stop duplicating activity output. +- [ ] Carry exact preview block scope into native Cancel and recheck identity/scope before clicking. +- [ ] Run residual/UI regressions, compile/diff checks, commit on residual branch. + +## Chain tip + +- [ ] Merge residual fixes into PR #13, preserving ca39fb3 and icon. +- [ ] Address #11's line-ending note once at the tip: application.py to LF; pin it and main_window.py in EditorConfig. Preserve all other file endings and the global * -text rule. +- [ ] Independent review, integrated full suite, compile/diff checks, validation records and fast-forward pushes to existing PR branches. +- [ ] Update PR descriptions with precise results and no new package/native acceptance. Leave #3 as historical umbrella, without merging or closing it. diff --git a/src/cbb_refresh_verify/library_lock.py b/src/cbb_refresh_verify/library_lock.py index 7ea8712..f0fd06c 100644 --- a/src/cbb_refresh_verify/library_lock.py +++ b/src/cbb_refresh_verify/library_lock.py @@ -559,6 +559,16 @@ def release_retained_library(library, evidence_dir, *, block_name=None): records = [checkpoint_record(path) for path, data in before.items() if data is not None] scoped = (block_name if block_name and all(record and record.get('block_name') == block_name for record in records) and (owner is None or owner.get('block_name') == block_name) else None) + reconciled = [{'kind': 'checkpoint', 'path': str(path), 'recognized': metadata is not None, + **{key: (metadata or {}).get(key) for key in ('block_name', 'lease_id', 'pid', 'status', 'time')}} + for path, data in before.items() if data is not None + for metadata in (checkpoint_record(path),)] + if owner: + reconciled.append({'kind': 'retained_owner', 'path': str(lease.path), + 'block_name': owner.get('block_name'), 'lease_id': owner['lease_id'], + 'status': 'OWNER_RELEASE_UNCONFIRMED'}) + foreign = sorted({item['block_name'] for item in reconciled + if block_name and item.get('block_name') and item['block_name'] != block_name}) proof_context = (_prove_library_released(library, allow_unknown_checkpoint=True) if unknown else _prove_library_released(library, block_name=scoped) if scoped else _prove_library_released(library)) @@ -570,6 +580,9 @@ def release_retained_library(library, evidence_dir, *, block_name=None): root = evidence/('release-' + uuid4().hex) root.mkdir(parents=True, exist_ok=False) record = {'library': str(library), 'status': 'RELEASE_CONFIRMED', **proof, + 'requested_block_name': block_name, 'proof_scope': 'BLOCK' if scoped else 'LIBRARY', + 'proof_block_name': scoped, 'reconciled_checkpoints': reconciled, + 'reconciled_foreign_blockers': foreign, 'unknown_checkpoint_archived': unknown, 'data_recovery_confirmed': False, 'evidence_path': str(root/'release.json')} (root/'release.json').write_text(json.dumps(record, ensure_ascii=False, indent=2), encoding='utf-8') diff --git a/tests/test_review_foreign_release_evidence.py b/tests/test_review_foreign_release_evidence.py new file mode 100644 index 0000000..4a7981a --- /dev/null +++ b/tests/test_review_foreign_release_evidence.py @@ -0,0 +1,52 @@ +import json +from pathlib import Path + +import pytest + +from cbb_refresh_verify import library_lock as locks + + +@pytest.mark.parametrize('retained_owner', [False, True]) +def test_releasing_another_blocks_checkpoint_names_its_owner(tmp_path, monkeypatch, retained_owner): + library = tmp_path/'library/lib.lmc' + library.parent.mkdir(); library.touch() + monkeypatch.setattr('cbb_refresh_verify.owner_probe.query_owners', lambda *_: []) + lease = None + if retained_owner: + with locks.LibraryLock(library, block_name='BlockB', safe_to_release=lambda: False) as lease: + pass + else: + locks._persist_blocker(library, lease_id='b'*32, block_name='BlockB') + before = locks.blocker_path(library).read_bytes() + try: + proof = locks.release_retained_library(library, tmp_path/'evidence', block_name='BlockA') + assert proof['requested_block_name'] == 'BlockA' + assert proof['proof_scope'] == 'LIBRARY' + assert proof['reconciled_foreign_blockers'] == ['BlockB'] + assert proof['data_recovery_confirmed'] is False + checkpoint = next(r for r in proof['reconciled_checkpoints'] if r['kind'] == 'checkpoint') + assert checkpoint['block_name'] == 'BlockB' and checkpoint['status'] == 'OWNER_RELEASE_UNCONFIRMED' + assert checkpoint['lease_id'] + proof_path = Path(proof['evidence_path']) + assert json.loads(proof_path.read_text('utf-8'))['reconciled_foreign_blockers'] == ['BlockB'] + assert (proof_path.parent/'blocker-before-0.json').read_bytes() == before + assert not locks.blocker_path(library).exists() + if retained_owner: + assert any(r['kind'] == 'retained_owner' and r['block_name'] == 'BlockB' + for r in proof['reconciled_checkpoints']) + finally: + if lease: + with locks._guard: + owner = locks._owners.pop(lease.key, None) + if owner: + owner['handle'].Close() + + +def test_matching_checkpoint_uses_block_scope_without_foreign_targets(tmp_path, monkeypatch): + library = tmp_path/'library/lib.lmc' + library.parent.mkdir(); library.touch() + monkeypatch.setattr('cbb_refresh_verify.owner_probe.query_owners', lambda *_: []) + locks._persist_blocker(library, lease_id='a'*32, block_name='BlockA') + proof = locks.release_retained_library(library, tmp_path/'evidence', block_name='BlockA') + assert proof['proof_scope'] == 'BLOCK' and proof['proof_block_name'] == 'BlockA' + assert proof['reconciled_foreign_blockers'] == []