11 KiB
Issue #2: release the PCB launched by a failed database open
Branch: codex/temp-issue-2-icdb-recovery.
Field failure
The issue attachment records an iCDB lost-server-session error while opening
1GPHY_8211. The supervisor declined the database log viewer and cancelled the
worker. Because document identity had not been established, the existing
document-close helper was never called. PCB and its launcher remained alive;
the subsequent Repair attempt returned REPAIR_DATABASE_IN_USE and the other
380 queued entries were skipped. There is no evidence of native Repair actually
running on that field database.
Change
The worker now has a separate startup-failure close path. It requires a current
iCDB diagnosis or a database-load-failure dialog belonging to this PCB during
startup. It checks the private desktop, excludes pre-existing process IDs, and
matches the complete PCB path and ReusableCircuit argument. Only an enabled
empty PCB main window, without modal dialogs, MDI documents or database address
records, receives a cooperative WM_CLOSE. A requested close is not treated as
success until process exit is observed. Ambiguous or busy sessions are retained.
The supervisor allows up to 40 seconds for fatal-error cleanup so that the
worker's 20-second startup-close window can complete before recovery begins.
The existing repair preconditions, backups and success checks remain in force.
Each attempt writes startup-close.json and close-request/result events.
Verification
Regression tests cover the missing pre-identity cleanup route, real observed
empty-window titles, exact path matching, pre-existing processes, another
desktop, live address records, modal and MDI windows, disabled windows, unrelated
failure records and a close request that does not result in exit.
Delayed dialog/address release and delayed process exit are also covered.
Validation: python -m pytest -q — 491 passed, one existing pywinauto COM-mode
warning; python -m compileall -q src tests and git diff --check passed.
A new isolated local library was created with the existing
tools/validate_icdb_open_repair_reopen.py tool, output
diagnostics/issue2-startup-20261102. No production library was changed.
The test damages only the new copy's database header; it does not reproduce the
field server-session-loss condition.
The real Mentor opening run produced MENTOR_DATABASE_LOAD_FAILED, then:
startup_close_requestedfor the launched PCB PID 6532;startup_close_result: CLOSED;- worker and supervisor both recorded
process_exit_confirmed, with no remaining PCB processes.
The subsequent separate native Repair run was able to start and completed as
RESTORED_REVIEW_REQUIRED, using the fixture's historical backup. This proves
the failed-open session no longer blocks the next repair operation in this
fixture. It does not prove automatic recovery of the field database or establish
that an older backup contains the desired design revision.
The separate open-after run on the same restored fixture completed native
integration, Save/IsSaved/Close/Quit, confirmed process release and returned
PASS, safe_to_continue=True, READY (IsVerifiedReuseBlock, raw=1).
The compare phase passed all seven checks, including absence of the original
opening error and unchanged source-fixture database SHA-256. Its
server_session_loss_reproduced field is explicitly false.
Reproduction commands (set PYTHONPATH=src; setup requires a new output name):
python tools/validate_icdb_open_repair_reopen.py setup --output issue2-startup-20261102
python tools/validate_icdb_open_repair_reopen.py open-before --output issue2-startup-20261102
python tools/validate_icdb_open_repair_reopen.py repair --output issue2-startup-20261102
python tools/validate_icdb_open_repair_reopen.py open-after --output issue2-startup-20261102
python tools/validate_icdb_open_repair_reopen.py compare --output issue2-startup-20261102
The stages are deliberately separate: the test fixture has a format-corruption error and historical-backup recovery, not the field lost-session auto-repair trigger. The test does not change production handling of old-backup recovery.
READY filtering, hash-scope changes and CBB CRUD are outside this focused fix.
Approved Task 1 follow-up: lifecycle and repair outcomes
The empty-PCB close path now receives the launcher process handle and waits for
its normal exit after PCB exits. It checks database addresses again during that
wait, so a late address record prevents a false CLOSED result. The startup
record includes PCB, launcher and address release state. A connected COM server
with no active document emits pcb_document_wait; it remains in startup and
continues reading the current native failure rather than implying identity.
Native Repair reads bounded Output text and records only the text appended after
this run's Repair invocation as operation evidence. Database logs are restricted
to the current native PID and start time. Output, native log copies, the complete
backup, native result and attempt record remain available under native-repair.
Detailed native evidence is preserved separately from its directory path.
The result distinguishes MISSING_HEALTHY_BACKUP, NATIVE_REPAIR_FAILED,
DATABASE_BUSY, UNKNOWN_DIALOG, and TIMEOUT_UNRELEASED. A failed tool receives
cooperative close only after a terminal native error, an enabled exact-project
main window, no other windows/prompts and no target database address. The worker
then waits for normal process exit. Unknown/custom prompts and incomplete native
operations receive no close action. A failure classification can coexist with
unreleased state; that state always stops the queue. Terminal DATABASE_BUSY
errors also retain the native tool without close, reopen or queue continuation.
Unreadable, absent, hung or truncated initial Output waits within the deadline
and retains the tool without requesting Repair; a readable empty string is a
valid invocation baseline. A busy-project message in
this fresh native process's initial loading Output prevents Repair invocation
entirely; it is not hidden by the later invocation baseline.
Before reopening or continuing, the parent independently checks relevant PCB, Library Manager, Repair, importer and close-helper processes, all known project/ PCB/shared-library addresses, and exclusive read access to every existing known database. Process-observation errors and exclusive-access failures block reuse. Only a conclusively failed, released, independently revalidated project-local target may allow the next CBB. Shared or unknown scope, busy owners, timeouts, unknown prompts and historical restores stop for review.
Before accepting native success, the parent validates native process identity and true exit, exact project/database, empty address state, confirmed backup/ repair evidence and absence of restore/failure/unknown-prompt contradictions. Missing or wrong-typed fields fail closed. Independent process, address and database-handle probes remain additional requirements.
Native REPAIRED is retained as native_status; summaries count a repair only
after the same request reopens, completes Verify and returns authoritative
PASS/GREEN with confirmed release. A failed reopen becomes
REPAIR_VALIDATION_FAILED; incomplete or contradictory native success/release
becomes UNCONFIRMED and prevents reopening.
Historical restoration remains RESTORED_REVIEW_REQUIRED. The original error,
stage and evidence references, a pre-repair-result.json snapshot, native
evidence and validation evidence remain attached even if the retry raises.
tests/fixtures/issue2-lost-session-sanitized.json contains selected fields from
the actual issue attachment, with paths, machine and process identities
sanitized. Replay asserts PCB_STARTING, the selected PRJ/database, normal PCB
and launcher release before native Repair, and exactly one automatic repair and
one reopen even if the opening error repeats. Separate replays cover the actual
2026-10-28 missing-backup Output, delayed exits/addresses, unknown custom prompts,
successful native repair and historical restoration. These are nonnative tests.
The attachment contains logs only. No matching 1GPHY_8211 faulty project was
found in the sibling Skyworth_CBB_Lib collection. This host runs Windows 11;
Windows 10 behavior and recovery of the real field database remain unverified.
The coordinator's prepared diagnostics/issue2-frozen-20261102 fixture damages a
copied database header; it does not reproduce field lost-server-session loss.
Candidate packaging and frozen/native tests remain coordinator work after review.
Task 1 checks: full suite once, 532 passed with the existing pywinauto COM warning;
after the final initial-busy gate regression, the related final suite passed all
234 tests. Compileall and git diff --check passed. The coordinator will run
candidate/frozen validation against the final implementation.
Task 1 review fix round: 259 related tests passed (17.86s); compileall and
git diff --check passed. These checks include busy retention, real readback
failure branches, 30 malformed-success variants at both release and reopen/
counting boundaries, and a complete actual worker-result replay control.
Runtime fix round 2 adds iCDBProjectBackup.exe and ReuseBlockImporter.exe to
the process helper's fixed query whitelist. Without these entries, the real
parent release probe rejected its own required queries and always denied safe
release. New tests keep the release validator and process helper real and stub
only WMI: no owners permits release, either native owner prevents it, and
arbitrary query names remain rejected. Focused validation: 172 passed. Candidate
c823a4b must be rebuilt with this correction before frozen/native validation;
field recovery remains unverified.
Runtime fix round 3 uses the actual frozen-worker window capture. A single Afx
shell titled exactly iCDB Project Backup now waits, before invocation only,
for the exact project title within the existing deadline. Two owned-process
input-indicator classes (UAC_InputIndicatorOverlayWnd, UAC Input Indicator)
are ignored only with empty titles. Wrong/duplicate target windows, ambiguous
shells, named/lookalike auxiliary windows, unknown prompts, missing Output and
busy verdicts still retain the tool without unsafe commands. The native loading
line Checking if project is in use. is excluded from busy evidence; the actual
ownership verdict continues to control the busy gate.
Sanitized recorded-shape replay includes real shell children, RichEdit Output readback, startup-to-loaded transition and both input indicators before and after load. Focused validation: 189 passed (12.40s); compile and scoped diff checks passed. New source/frozen native validation and rebuilding the candidate remain coordinator work; these replay results do not establish field recovery.