``` STEP: Step-13A - Retain comparison ownership through cleanup and drain completion STATUS: COMPLETE - R-01 corrective worker execution verified. MANUAL GATE: Step-13/13A acceptance remains pending; STOP. Step-14 unassigned. DATE: 2026-11-01 BASE: 18c9d0d ("WIP 13"); initial worktree clean; no staging/commit/push. R-01 AND ACTUAL PRE-FIX REPRODUCTION The previous ObserveAsync cleared _owner and published terminal IsBusy=false before owner.Release and before settling the exact task stored in _drain. A cancellation callback holding the owner's private cancellation gate could leave release blocked while a new Evaluate/Save replaced _drain. Close could then follow only the newer completion and miss the original owner. Added and EXECUTED the real feature-boundary regressions BEFORE changing this production order. The only initial production additions were an internal release observation event and test-assembly visibility; neither fixed/reordered admission, release or terminal publication. Real owning rehearsal/projection/dynamics runs and actual encoded captures prepared the comparison. Pre-fix command: dotnet test .\src\tests\AutoForge.IntegrationTests\AutoForge.IntegrationTests.csproj --configuration Release --no-restore --filter "FullyQualifiedName~ComparisonOwnershipTail_" --verbosity minimal FAILED; exit 1; 7 failed, 0 passed, 0 skipped; approximately 6 s. Compilation succeeded. All barriers/resources were released/drained in finally. This is a behavioral reproduction, not a prose race or compilation failure. | Actual pre-fix condition | Observed failure | |---|---| | Successful real pair Save; callback/release held; competing Save | tail busy=False; state=Completed; old drain completed=False; callback exited=False; save admitted=True | | Successful real pair Save; callback/release held; competing Evaluate | tail busy=False; state=Completed; old drain completed=False; callback exited=False; evaluate admitted=True | | Actual final-readback failure; callback/release held; competing Save | tail busy=False; state=Failed; old drain completed=False; callback exited=False; save admitted=True | | Actual final-readback failure; callback/release held; competing Evaluate | tail busy=False; state=Failed; old drain completed=False; callback exited=False; evaluate admitted=True | | New Save replaced drain; Close | replacement admitted=True; old drain completed=False; callback exited=False; Close/Dispose completed=True; state=Closed | | New Save replaced drain; Dispose | replacement admitted=True; old drain completed=False; callback exited=False; Close/Dispose completed=True; state=Closed | | Actual cancelled evaluation; completion-release boundary held | cancelled evaluation tail busy=False; state=Cancelled; old drain completed=False | CONTROLLED BOUNDARY AND NARROW TEST SEAM CompletionTailStore wraps the accepted real comparison capture/codec/store data. It registers a callback on the actual owner token passed through SaveAsync. The callback reads the real comparison snapshot, then remains synchronously held. CancelAsync is invoked on a test worker because this actual callback holds Owner.Cancel's private gate. Final archive readback can then return or fail, so operation work finishes while actual owner.Release remains blocked. No comparison coordinator, physics, signal samples, target proof or saved result is mocked. The successful delayed readback is the actual already persisted capture, not a cancellation-to-success fallback invented by the coordinator. Existing Changed notification occurs only after completion; it cannot signal this post-work/pre-release interval without timing polling. Therefore the one minimal INTERNAL ReleasingOwner(Task) observation event signals the actual release boundary and exact original completion task. It supplies no public controls, values, proof, metrics or fake successful completion. The cancelled evaluation case also holds this real release boundary after actual signal cancellation/diagnostic disposal; cleanup-error cases exercise observer failure. Application grants only IntegrationTests internal visibility, following existing test-friend prior art. Native production has no subscriber to this event. No sleeps/polling, alternate host or new lifetime framework. IMPLEMENTATION AND ATOMIC ORDER 1. Start reserves the real owner, generation and exact completion/_drain under the comparison gate, with Evaluating/Saving and IsBusy=true. 2. Actual operation work finishes or faults/cancels. Ownership stays reserved. 3. Release observation and owner.Release execute OUTSIDE the comparison gate. A held callback/release cannot expose idle or admit another operation. 4. Observation/release errors are explicitly captured. Actual release is still attempted after observation failure. Primary and additional errors are retained together with AggregateException rather than masking either. 5. Under ONE comparison gate, remove the same reserved owner, publish truthful Completed/Failed/Cancelled state (unless Closing owns terminal publication), and settle that exact operation completion task. Continuations are async. 6. Changed notification follows outside the gate. No old owner can clear or overwrite a legitimately admitted successor because admission was blocked until release and completion settlement finished. 7. Close retains its shared task and captured owner/drain, cancels and awaits outside required gates, then publishes Closed/IsBusy=false and settles its shared completion under the same gate. Existing visible Close error and result-retirement semantics are preserved. No callback/release/await was moved under the comparison state gate. The owner remains the reservation, not a second duplicate owner framework. The specific old _drain cannot be replaced during its unfinished tail. FILES AND PUBLIC CONTRACTS | File | Change | |---|---| | [CalibrationComparisonSession.cs](../src/AutoForge.Application/Features/Vehicles/Calibration/CalibrationComparisonSession.cs) | Release before atomic owner/terminal/completion publication; explicit cleanup error capture/aggregation; atomic shared Close terminal settlement; one internal real-release observation event | | [AssemblyInfo.cs](../src/AutoForge.Application/Properties/AssemblyInfo.cs) | IntegrationTests-only internal visibility for that observation seam | | [CalibrationComparisonOwnershipTests.cs](../src/tests/AutoForge.IntegrationTests/CalibrationComparisonOwnershipTests.cs) | Nine real ownership-tail/cleanup cases reusing existing owning comparison fixtures, actual models/transport/captures and store codec | | [README.md](../README.md) | Corrective ownership-tail status and separate report link; manual review still pending | | [documentation index](../docs/README.md) | Step-13/13A pending acceptance status | | [comparison usage](../docs/calibration-comparison.md) | Busy through release, exact drain/Close ordering, primary/cleanup error and internal-vs-native evidence semantics | | [architecture](../docs/architecture.md) | Actual reservation/release/publication gate order without new graph or framework | | [build/test](../docs/build-and-test.md) | Separate corrective pre-fix/focused/full/native evidence; preserved historical Step-13/LLM claims | | [this report](Step-13A-Report.md) | Sole new file under prompts; original reports/assignments/state unchanged | Public comparison/source/projection/archive interfaces are unchanged. No UI modification, new project/package/reference/host/schema/protocol/physics/ metrics/proof change. Core/Simulation/Diagnostics and independent Components remain unchanged; Application/UI gain no private numerical oracle. FROZEN CORRECTIVE MATRIX - NAMED EXECUTED EVIDENCE All new named cases are in the ownership test file linked above. | Contract | Executed evidence and corrected decisive result | Status | |---|---|---| | C-01 | ComparisonOwnershipTail_RealCancellationCallbackReservesAdmissionUntilRelease, success/failure x Evaluate/Save = 4 cases. Tail remains Saving/IsBusy=true, original task incomplete and callback unexited; both contenders reject typed Busy before work. Target reads/writes, configuration count and store calls unchanged; original result/save evidence retained. | PASSED | | C-02 | ComparisonOwnershipTail_CloseOrDisposeIncludesOldDrainAfterCompetingSave = 2 cases. Replacement Save rejects Busy. Close/Dispose includes the old drain and actual callback; Closed notification records old task settled AND callback exited. Callback runs once; retained result Stale; shared Close task retained; closed Save rejects; independent fresh comparison succeeds. | PASSED | | C-03 | Four success/final-readback-failure cases above, actual cancelled evaluation case below, and ComparisonOwnerCleanup_FailureSettlesWaitersAndPreservesPrimaryAndSaveEvidence = 2 cases. Successful/failed/cancelled terminal publication follows release. Cleanup-only failure returns its IOException; primary Save failure plus cleanup failure preserves both in AggregateException. Waiters settle as failures, not timeout/false success; per-ID publication/readback/error evidence remains. | PASSED | | C-04 | ComparisonOwnershipTail_CancelledEvaluationKeepsExactDrainUntilCleanupAndThenRetries = 1 case. Actual cancelled signal run disposed once; exact same evaluation drain retained through held cleanup and repeated Cancel; Save rejects Busy; then Cancelled terminal state, bounded partial data and valid next real full evaluation. Other tail cases retry Save only after full release, skip already verified files, and verify fresh closed/page lifetimes. | PASSED | | C-05 | Combined 59-case selector, full 179 unit + 475 integration = 654, actual nine-project Release and native affected commands. All 645 prior cases retained; unchanged metrics/fingerprints/caps/proof/authority and old manual/unit/source behavior verified. | PASSED | | Acceptance | Mapping and executed criterion | Status | |---|---|---| | AC-01 | Actual 7-case behavioral pre-fix failure; corrected C-01 rejects both contenders with zero new work effects while old release is held | PASSED | | AC-02 | C-02/C-03 real callback/drain/Close/Dispose, once-only cleanup, truthful waiter and primary/partial-save error outcomes | PASSED | | AC-03 | C-04 same old completion reservation, no premature/late successor mutation, valid post-drain retry and fresh independent native lifetime | PASSED | | AC-04 | C-05 645 retained plus 9 new cases, nine-project Release, actual affected native comparison/save/report/owner checks | PASSED | | AC-05 | Post-green source-path self-review, directly related docs, protected history/cleanup and separate single fenced report | PASSED; manual acceptance pending | CORRECTED COMMANDS AND COUNTS Test platform: VSTest / xUnit v2, no MTP separator/flags. Current SDK dotnet --version: 10.0.403; permitted latestPatch roll-forward from the existing global.json 10.0.402. No SDK/workload/package/runtime update. Focused combined command: dotnet test .\src\tests\AutoForge.IntegrationTests\AutoForge.IntegrationTests.csproj --configuration Release --no-restore --filter "FullyQualifiedName~ComparisonOwnershipTail_|FullyQualifiedName~ComparisonOwnerCleanup_|FullyQualifiedName~Comparison_|FullyQualifiedName~PreviewHandoff_|FullyQualifiedName~TorqueDraft_" --verbosity minimal PASSED; exit 0; 59 passed, 0 failed, 0 skipped; approximately 12 s. Nine new corrective cases plus the retained 50-case comparison/pinned-draft group. Required sequential commands: dotnet build .\src\AutoForge.slnx --configuration Release --no-restore PASSED; exit 0; all nine projects; 0 warnings, 0 errors; 5.80 s. dotnet test .\src\AutoForge.slnx --configuration Release --no-build PASSED; exit 0; 179 unit + 475 integration = 654; 0 failed, 0 skipped. Unit approximately 238 ms; integration approximately 12 s. All original 645 cases preserved, plus 9 corrective integration cases. | Project | Build | Tests | |---|---|---| | AutoForge.Core | PASSED | N/A, non-test | | AutoForge.Diagnostics | PASSED | N/A, non-test | | AutoForge.Simulation | PASSED | N/A, non-test | | AutoForge.Application | PASSED | N/A, non-test | | AutoForge.Components | PASSED | N/A, non-test | | AutoForge.UI | PASSED | N/A, non-test | | AutoForge.Client | PASSED, actual Windows MAUI Hybrid executable | N/A | | AutoForge.UnitTests | PASSED | 179 passed, 0 failed/skipped | | AutoForge.IntegrationTests | PASSED | 475 passed, 0 failed/skipped | Prior Step-13's intermittent unchanged dynamics TaskCanceledException and recording-navigation Busy issue remain separate historical disclosures. Neither occurred in this corrective full/native execution. Their source files have no diff; no causality inferred from the prior flaky run and no unrelated repair/waiver. No dependencies restored/installed because none were missing. ACTUAL REBUILT NATIVE CHECKS - NOT CONTROLLED TAIL OR NEW LLM CLAIMS Actual [Client executable](../src/AutoForge.Client/bin/Release/net10.0-windows10.0.26100.0/win-x64/AutoForge.Client.exe); task PID 40220, created 2026-11-01T09:06:02.1060905-05:00. Task-owned isolated step13a-webview/CDP 9387, not an alternate app host. Application assembly SHA256: 561A6E48E4C2F5AB441FA5202ADCBCB3F0C05D53D3C2D5FC692FA217FFE5A58B. Initial user preferences Metric/Road; initial archive files 0. No test release subscriber exists in native production. Explicit actual synthetic profile/revision -> warm original -> Baseline -> MANUAL runbook template/validation -> pinned complete draft -> separate Save -> fresh isolated target/two-read backup/prepare/confirmation/approval/Apply/full actual readback -> owning comparison -> explicit two-capture Save/readback. No repeated inference was run. Original real LLM content and qualification in the preserved [Step-13 report](Step-13-Report.md) remain HISTORICAL evidence. No model/runtime permission forms, chat, pull/install/restart/config/unload. Original configuration: sha256:v1:e8991ae139b54959ec53a4fe64b08dc9bfc03feb533496cf741f2c9f3a2342da Derived NEW configuration: sha256:v1:3ee252697bfb69f36f4b99dca4c0267f7517a17a459666fb47551fa6ed978450 Workspace 7ce9775e197043fc9c8da2d3f8d5f98e. Baseline a54ea42c082d4d56891e5b3c9c02e4c7, revision 1. Proposed 00eabb196e53472cb545c21a712696ed, revision 2; history 2/32. Copy alone retained revision 1; separate Save created revision 2. Exact scalar 650->1250 rpm; cells [240,300,360,350,300,180] -> [240,300,350,350,300,180] N*m; axis [650,1000,2000,3200,4200,5000] unchanged. Actual target instance 1132fcd0d939427f89d6e16334496dcb, revision 0->1. Two-read backup 195a79aa86864c6bab1ec437b010b575. Preparation a995b7be3ea64678bda3af36efe20b46. Explicit approval 915e552f3e5947b7bb05d3b9ab54df16. Actual Apply 47ee64ca9a4d4b7e851e95a9bea48959; completed 2026-11-01T14:07:14.9347123+00:00. Acknowledgement True/revision 1, separately verified actual complete image. VerifiedApplied / CandidateMatching with every unchanged cell/axis/unit checked. Native comparison e3aa975405424ba2a0f6dbe5a02239c0; proof a8084d560cd64ea588ce25de5e7ca6a8; proof as of 2026-11-01T14:07:15.0903722+00:00. Profile autoforge.synthetic.test-truck@1; engine module.engine.primary; transmission module.transmission.primary; model autoforge.synthetic.longitudinal@1; definition autoforge.synthetic.engine-authoring@1. Provider autoforge.simulation.dynamics, actual v2 signals. | Real native metric | Baseline | Derived | |---|---|---| | Run/session | dynamics-run-000001 / diagnostic-session-000001 | dynamics-run-000002 / diagnostic-session-000002 | | Capture | bf2305069faa4c8fb2ba3fb3404a7cfc | 0905ad908ef741058e17ca6dd69d5ba9 | | Completion / actual observations | Complete / 1346 | Complete / 1346 | | Warm target rpm | 650 | 1250 | | Actual last-ten maximum idle error rpm | 4.084768079337664E-10 | 7.855760486563668E-10 | | Actual last-ten maximum stationary speed m/s | 0 | 0 | | Model steps / total virtual seconds | 3361 / 336.1 | 3361 / 336.1 | | Warm/Accelerate/Cruise/Brake/ReturnIdle steps | 100/103/3000/58/100 | 100/103/3000/58/100 | | Acceleration / brake seconds | 10.3 / 5.800000000000001 | 10.3 / 5.800000000000001 | | Sampled cruise count / speed range m/s | 600 / 20.1168..20.1168 | 600 / 20.1168..20.1168 | | Fuel consumed kg | 0.518385971679477 | 0.5184897031483956 | | Distance m | 6193.507764002321 | 6193.389583605566 | | Final actual shift count | 4 | 4 | Data/proof/fingerprints remain the supported Step-13 semantics, not redesigned. 3900 steps/1562 scheduled observations, both modules every five steps plus completion, and existing 4096-observation/16 MiB observation/1 MiB header/ 32 MiB archive bounds unchanged. Sparse ranges are not continuous extrema; final shift count is not a complete shift timeline or real-world improvement. Native Save completed with BOTH persisted True/readback verified True and "exact readback verified" per ID. Independent saved-byte inspection also validated actual final raw response step 3361/time 336.1, matching exact header config/run and transmission.shift-count 4/count/Good. Baseline file 8670832 bytes; encoded observations 8668539 bytes; SHA256 ed5560f957deb38b06f439b3f7cab014d5dd2c75f0b71ebbcb2fc6241de3e902. Derived file 8668935 bytes; encoded observations 8666642 bytes; SHA256 ea5d6e02b06376ed93bb3d03ad2adcf3ed8f1af278a704554a341674338f3797. No overwrite, compensating deletion or altered source/recording owner. Affected native owner checks: - Observed "Evaluating; operation/drain pending True." BEFORE competing action/ Cancel, not a completed request retrospectively labelled pending. - Competing Evaluate visibly rejected "One comparison/run/save owner is active; cancel and drain first." - Cancel reached "Cancelled; operation/drain pending False.", visible cancellation, same last successful report retained Stale/as-of. Save evidence preserved. - Global ImperialUS toggle/restored Metric/Road left canonical report exactly unchanged except the legitimate Current->Stale retirement label. - Close reached Closed; new Evaluate rejected "This page comparison owner is closed." - Current-head manual template validation still produced Current / NoChanges. - Reentry created Idle/fresh owner with no old comparison report/authority and unchanged authoring history 2/32. - Fresh target was explicitly backed up/approved/applied again; actual new Apply 7baee970d538423fabb73bfad3b6e798. Fresh evaluation unmounted only AFTER observed pending True; Home "AutoForge foundation" rendered with no late report. Subsequent calibration entry again created independent Idle owner. - Final actual original export remained 650/[240,300,360,350,300,180], exact original five-phase scenario (10/60/300/60/10 s; driving target 20.1168 m/s). Original Metric/Road preferences restored; Blazor error display none. These are ordinary actual native affected-lifecycle checks. The held cancellation/ release tail and cleanup-error interleavings are CONTROLLED real-boundary tests, not claimed to be naturally reproduced native timing or newly generated LLM data. Existing replay/store boundary tests ran in the 59-case/full selections; no new native replay/model/physical capability is claimed. POST-GREEN SOURCE-PATH SELF-REVIEW Reviewed Start/Evaluate/Save -> actual work/capture/target/store -> ObserveAsync -> release observation/Owner.Release -> exact task settlement -> Cancel/Close/ Dispose -> UI observer/fresh lifetime. Reused the accepted local-generation completion order without a general framework. Confirmed: - No owner/busy release before cleanup, no _drain replacement interval. - Callback and release work outside required state gates; actual callback reads real state without deadlock while holding its own cancellation gate. - Primary success/error/cancel and per-ID saved/readback/error outcomes preserved. - Cleanup failure cannot prevent actual release attempt or strand completion; combined failures retain both, never a success-shaped fallback. - Terminal owner/state/completion and shared Close terminal task coherent under the comparison gate; async continuations cannot observe partial publication. - Old completion has no later state mutation capable of clearing a successor. - Busy/Closed rejection precedes new work, config/target/capture/store effects; full-drain retry and independent new lifetime work normally. - No proof/value/physics/archive checks weakened, no unassigned runtime or file rollback, and no unrelated baseline failures repaired. PRESERVATION, DOCUMENTATION AND EXACT CLEANUP All old prompt reports and assignments preserved; sole new prompt file is this report. Protected CURRENT hashes rechecked: [Step-13A.md](Step-13A.md) DC55E75163EAC8D5A9B4A384AA961C05DCB3087BC7250EC86E7C8511629C7BFA [STATE.md](STATE.md) 6E912BAEAD65CC36D73BC5A2280178DEAD47DBB55359218F36531C48C6D1EDA3 [ROADMAP.md](ROADMAP.md) 31B4277C62111B9BF86AA46BD1E351931D98DF259A874EBA1D163A701BC534EF [WORKER-QUALITY-GATE.md](WORKER-QUALITY-GATE.md) F9C0B14516B70345E4CE93AD1EDB8856094BC92E26A37AEB16EDE687AD021804 [Step-13-Report.md](Step-13-Report.md) C1D8E1F33D26675189DDC8E559620EAEE7FB342ECB5DFE905C6C2ACF08896340 [Step-13.md](Step-13.md) 121A97B67A6604BE53E8C5742A7F2001971A99F3B6E9E861671C39704B6BA535 [Step-12A-Execution-Report.md](Step-12A-Execution-Report.md) C5056359F33CC95C4D53F2ACAF7DBAB9E59B8B99CE66B0CD99B3475B427621F5 Git whitespace/scope checks passed. Git LF/CRLF notices are not build warnings. Nine-project graph/manifests/dependencies unchanged; only internal test visibility. No agents, permission/model/runtime work, staging/commits/push or Step-14. EXECUTED cleanup: - Stopped only freshly path/creation-time-verified task Client PID 40220 and any exact task-profile WebView descendants; no name-based process termination. - Removed only the two exact task-generated/verified archive IDs above after successful Save/readback/raw-context/hash checks. Initial/final user archive count 0; no unknown/user file or compensating rollback deletion. - Removed ten exact task native helper/evidence files, inspected step13a-webview profile, and the exact owned oversized pre-fix temporary output. - Session root/files directory and all other session data preserved. Remaining Step13A native targets 0; CDP 9387 listeners 0. - Restored original Metric/Road preferences. - Shared Ollama PID 50460, binary and original 2026-10-31 14:39:16 creation/ installed-model/store/configuration remain untouched. No inference rerun. Persistent result: focused R-01 source/tests/docs and this separate report. STOP FOR MANUAL ORCHESTRATOR REVIEW; no acceptance or next-step invocation. ```