From 13221a94a9f31b2f4933d19ab8c337bb5d9dbd7b Mon Sep 17 00:00:00 2001 From: GAJ3T Date: Sun, 1 Nov 2026 10:19:57 -0500 Subject: [PATCH] After Step 13 --- README.md | 4 + docs/README.md | 3 +- docs/architecture.md | 7 +- docs/build-and-test.md | 25 ++ docs/calibration-comparison.md | 16 +- prompts/ROADMAP.md | 96 +++-- prompts/STATE.md | 135 +++++-- prompts/Step-13A-Report.md | 328 ++++++++++++++++++ prompts/Step-14.md | 194 +++++++++++ prompts/WORKER-QUALITY-GATE.md | 40 +++ .../CalibrationComparisonSession.cs | 15 +- .../Properties/AssemblyInfo.cs | 3 + .../CalibrationComparisonOwnershipTests.cs | 320 +++++++++++++++++ 13 files changed, 1115 insertions(+), 71 deletions(-) create mode 100644 prompts/Step-13A-Report.md create mode 100644 prompts/Step-14.md create mode 100644 src/AutoForge.Application/Properties/AssemblyInfo.cs create mode 100644 src/tests/AutoForge.IntegrationTests/CalibrationComparisonOwnershipTests.cs diff --git a/README.md b/README.md index c43d322..bf9331e 100644 --- a/README.md +++ b/README.md @@ -170,6 +170,10 @@ ownership are separate from proposal and programming evidence. See [comparison usage](docs/calibration-comparison.md) and [Step-13 worker evidence](prompts/Step-13-Report.md). Step-13 requires manual acceptance; Step-14 remains blocked. +Step-13A corrects the remaining owner-release tail: Busy and the exact admitted +drain stay reserved through cleanup, before atomic terminal completion. +See [corrective execution evidence](prompts/Step-13A-Report.md). Step-13/13A +remain pending manual acceptance; no model or programming scope is added. ### Planned diff --git a/docs/README.md b/docs/README.md index 8b55dac..c4f28c8 100644 --- a/docs/README.md +++ b/docs/README.md @@ -28,7 +28,8 @@ pending/manual/stale/units/source checks. All 596 tests pass (594 retained plus two corrective cases). Step-12/12A is accepted. Step-13 adds an explicit verified-image-to-NEW-configuration equivalent synthetic comparison, bounded real captures, canonical metrics/lineage and existing save/readback/replay. -Step-13 awaits manual review; Step-14 and physical execution remain blocked. +Step-13A corrects the comparison release/completion tail while preserving that +scope. Step-13/13A await manual review; Step-14 and physical execution remain blocked. - [Architecture](architecture.md): actual nine-project graph, responsibilities, route ownership and provider/reference boundaries. diff --git a/docs/architecture.md b/docs/architecture.md index 02e12ee..771d513 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -304,7 +304,12 @@ One retained result plus bounded partial run/save evidence is inspectable. New evaluation or Close retires earlier current status; source/head/target supersession also computes Stale without rebase. Hybrid events release before admitted blocking work. Cancel/Close drains outside required gates; resources -dispose even if capture cleanup fails. Explicit saves use existing no-overwrite +dispose even if capture cleanup fails. Step-13A keeps the actual owner/busy/drain +reserved throughout release, then settles terminal state, owner removal and +that exact completion atomically under the comparison gate. Callback/release +work never runs under that state gate; cleanup errors preserve the primary +operation error and settle waiters as failures rather than exposing premature +idle. Shared Close cannot miss an earlier unfinished owner. Explicit saves use existing no-overwrite archive storage, exact serialized readback and per-ID outcomes. A failed save may have published: retry checks the existing catalogue and verifies read-only instead of colliding or overwriting. No compensating file deletion occurs. diff --git a/docs/build-and-test.md b/docs/build-and-test.md index 5df8524..710db20 100644 --- a/docs/build-and-test.md +++ b/docs/build-and-test.md @@ -48,6 +48,7 @@ dotnet test .\src\tests\AutoForge.IntegrationTests\AutoForge.IntegrationTests.cs dotnet test .\src\tests\AutoForge.IntegrationTests\AutoForge.IntegrationTests.csproj --configuration Release --no-restore --filter "FullyQualifiedName~RunbookPreviewTests|FullyQualifiedName~RunbookUi_|FullyQualifiedName~RunbookIsolation_" dotnet test .\src\tests\AutoForge.IntegrationTests\AutoForge.IntegrationTests.csproj --configuration Release --no-restore --filter "FullyQualifiedName~LocalRunbookGenerationTests|FullyQualifiedName~LocalInferenceBoundsTests|FullyQualifiedName~LocalGenerationReviewTests|FullyQualifiedName~LocalGenerationUi_|FullyQualifiedName~LocalGenerationIsolation_|FullyQualifiedName~RunbookPreviewTests" dotnet test .\src\tests\AutoForge.IntegrationTests\AutoForge.IntegrationTests.csproj --configuration Release --no-restore --filter "FullyQualifiedName~Comparison_|FullyQualifiedName~PreviewHandoff_|FullyQualifiedName~TorqueDraft_" +dotnet test .\src\tests\AutoForge.IntegrationTests\AutoForge.IntegrationTests.csproj --configuration Release --no-restore --filter "FullyQualifiedName~ComparisonOwnershipTail_|FullyQualifiedName~ComparisonOwnerCleanup_|FullyQualifiedName~Comparison_|FullyQualifiedName~PreviewHandoff_|FullyQualifiedName~TorqueDraft_" ``` ## Step-12A real local-model/native qualification @@ -106,6 +107,30 @@ exposed the unchanged recording panel's pending-refresh Busy initialization error. Task-owned Client recovery and sequential exact-heading/idle-archive-owner checks passed for all six existing routes. No recording-navigation change was made. +## Step-13A ownership-tail correction + +The actual pre-fix selector `FullyQualifiedName~ComparisonOwnershipTail_` +executed seven cases: all seven failed behaviorally, zero passed/skipped. +Real cancellation callbacks held the old release after actual save work +returned: Busy was false, competing Evaluate/Save admitted and Close/Dispose +could complete with the old drain/callback unfinished. A cancelled actual +evaluation also exposed premature terminal publication. + +The correction releases outside the state gate while retaining owner/busy/drain, +then atomically publishes terminal state/owner removal/completion. Nine new +cases cover successful/failed/cancelled work, actual delayed callback cleanup, +competing admission, orphan prevention, exact drain identity, legitimate retry/ +fresh lifetime and cleanup failure aggregation/per-ID save preservation. +The combined selector above passes 59 cases; final sequential nine-project +Release build passes with zero warnings/errors, followed by 179 unit + 475 +integration = 654 passes, zero failed/skipped. All 645 Step-13 cases remain. +Affected native lifecycle and one legitimate actual comparison/save/report are +verified separately from controlled tail barriers in the +[Step-13A report](../prompts/Step-13A-Report.md). Prior real LLM content and the +original 645-case/numerical/archive evidence remain historical, not rerun claims. +Step-13/13A await manual acceptance. No unrelated recording-navigation/dynamics +fix, runtime setup, new model/physics/schema or Step-14 work is included. + ## Historical Step-12 approval-blocked verification Step-11 is accepted. Step-12 implementation/control tests pass, but required diff --git a/docs/calibration-comparison.md b/docs/calibration-comparison.md index 3d37896..98b054a 100644 --- a/docs/calibration-comparison.md +++ b/docs/calibration-comparison.md @@ -1,6 +1,6 @@ # Verified synthetic calibration comparison -Step-13 is implemented pending manual review. This is a narrow synthetic +Step-13 with corrective Step-13A is implemented pending manual review. This is a narrow synthetic comparison, not manufacturer prediction, safe tuning advice, firmware proof, physical authority or a general AI/runbook executor. @@ -94,6 +94,20 @@ Close retires earlier current status; source/head/proof supersession labels it Stale/as-of without rebase. One previous success and bounded latest partial run/ save evidence remain inspectable, not an unbounded history. +Busy includes the entire completion tail, not merely returned operation work. +The admitted owner and its exact drain remain reserved while cancellation +callbacks/release finish outside the comparison state gate. Only then are +terminal state, owner removal and that completion settled together under the +gate. A competing Evaluate/Save cannot replace the old drain; shared Close/ +Dispose includes all admitted cleanup. After a full drain, legitimate new work +can admit only while open; closed sessions require an independent new lifetime. +Cleanup errors fault operation waiters explicitly, preserving primary error/ +cancellation and per-capture save evidence; combined failures retain both errors. +Controlled tests use a minimal internal real-release observation seam, not a +public test control or mocked coordinator. Native UI uses the same unmodified +commands with no lifecycle probe subscribed. See the +[Step-13A report](../prompts/Step-13A-Report.md) for pre-fix and corrected evidence. + Failed/limited/cancelled physics never becomes a successful pair. A stopped capture can represent complete coverage of a partial run; the run's separate error/metrics/completion determine comparison success. This does not expand or diff --git a/prompts/ROADMAP.md b/prompts/ROADMAP.md index 5edfb0f..76d4677 100644 --- a/prompts/ROADMAP.md +++ b/prompts/ROADMAP.md @@ -3,11 +3,11 @@ ## Status and authority - Initialized: 2026-10-28. -- Current phase: Step-13 comparison reviewed; owner/drain tail requires focused correction. -- Active assignment: [Step-13A](Step-13A.md), ready for manual worker handoff. -- Last accepted milestone: Step-12 with Step-12A, accepted 2026-10-31. -- Last accepted correction/follow-up: Step-12A; all frozen gates closed. -- Outstanding follow-up: Step-13A / R-01 original C-07 owner/drain completion; no Step-12B. +- Current phase: corrected synthetic demonstration accepted; bounded hardware readiness research next. +- Active assignment: [Step-14](Step-14.md), ready for manual worker handoff; research checkpoint only. +- Last accepted milestone: Step-13 with Step-13A, accepted 2026-11-01. +- Last accepted correction/follow-up: Step-13A; R-01 closed. +- Outstanding follow-up: none; no Step-13B required. - Step-05 status: ACCEPTED after Step-05A/Step-05B, 2026-10-29. - Step-06 status: ACCEPTED after Step-06A, 2026-10-30. - Step-07 status: ACCEPTED after Step-07A/Step-07B, 2026-10-30. @@ -19,9 +19,9 @@ - Step-12A status: ACCEPTED 2026-10-31; worker reports 596 passes, clean Release and actual native exact-intent/lifecycle proof. - Step-12 completion prompt: superseded for execution by owner-requested Step-12A; preserve unchanged. - Owner runtime policy: local models only; no Ollama cloud or cloud fallback. -- Step-13 status: NEEDS CORRECTION / C-07 and AC-03; native/645-case evidence reviewed. -- Step-13A status: READY FOR MANUAL WORKER HANDOFF; one ownership-tail correction only. -- Step-14 status: read-only hardware; BLOCKED / NOT ASSIGNED until demonstration acceptance and hardware gates. +- Step-13 status: ACCEPTED 2026-11-01 after Step-13A; complete supported synthetic demonstration. +- Step-13A status: ACCEPTED 2026-11-01; worker reports 654 passes, clean Release and rebuilt affected native proof. +- Step-14 status: READY FOR MANUAL WORKER HANDOFF / READINESS ONLY; actual physical integration unimplemented and separately gated. - Current state and handoff: [STATE.md](STATE.md). - Authority: the master charter, repository/handoff amendment, and the owner's 2026-10-28 architectural realignment. The latest decision cancels the dual-shell @@ -84,7 +84,7 @@ and `Step-01A-Report.md`, then `Step-01B.md`. Accept all necessary corrections before assigning the next major step. Do not use the superseded numeric-dot prompt/report naming convention. -## Assignment sizing and handoff policy - revised 2026-10-28 +## Assignment sizing and handoff policy - revisions 2026-10-28 and 2026-11-01 The owner requested an orchestration-level reassessment to reduce repeated corrective handoffs. Longer prose and larger passing test counts have not been @@ -127,6 +127,28 @@ retroactively to completed assignments. can guarantee zero defects; the goal is fewer preventable handoffs, not weaker review or concealed failures. +### Stronger prospective control from Step-14 + +The owner repeated the request after Step-13A. Its R-01 escaped because the +pending-work gate/self-review did not explicitly hold the post-work release/ +drain tail. The orchestrator also needs smaller prerequisite-first assignments, +not a broad new adapter/protocol/UI/driver state machine in one handoff. + +- Revised shared gate requires source-ordering/evidence ledger for admission, + publication, completion/close and affected real UI paths. Cleanup-tail tests + hold work after it returns, with exact owner/drain identity and no new calls. +- Worker reuses accepted prior art, fixes tightly coupled findings before + COMPLETE and validates the final changed production/native path. Counts and + prose cannot replace a missing executed criterion. +- Apply only relevant rows and record N/A concretely; no extra checklist files, + agents, retrospective new criteria or blanket auditing of unaffected code. +- Orchestrator freezes decisive criteria before manual handoff and reviews + those same rows in one consolidated pass. Separate unverified prerequisites + from implementation and from actual corrective defects. +- Step-14 starts with research/readiness, not source scaffolding or hardware + traffic. Review exact supported initial adapter contract before assigning + code; research completion is not full hardware acceptance or Step-15 entry. + Unassigned future rows remain milestone envelopes, not a requirement to implement their entire scope in one worker turn. If an envelope is too large, split and update the future major-step numbering/dependencies before handoff; letters @@ -596,9 +618,9 @@ evidence; they must not silently discard required capabilities. | 11 | Deterministic simulation runbook validation and preview | 10 and corrections accepted | ACCEPTED 2026-10-31 | Strict schema/limits/allowlist/source-head/template, immutable preview/diff/staleness and no execution; reported 179 unit/368 integration passes | | 12 | Local AI and applicable knowledge integration | 11 accepted | ACCEPTED 2026-10-31 AFTER 12A | Actual local-only original model/native preview and exact intent/lifecycle; immutable validator/authority boundaries, reported 596 passes | | 12A | Local-only Ollama setup and real-model qualification | 12 returned incomplete; owner directive | ACCEPTED 2026-10-31 | Cloud-disabled true/current model proof, exact native +600/-10 output, pending conflicts/Cancel/unmount and reproduced responsive Hybrid dispatch fixes | -| 13 | Comparative evaluation and complete synthetic demonstration | 12 and 12A accepted | NEEDS CORRECTION AFTER REVIEW | Most proof/projection/native/run/archive/645-case evidence supported; C-07 owner/drain tail replacement remains | -| 13A | Retain comparison ownership through cleanup and drain completion | 13 review R-01 / C-07 | READY FOR MANUAL WORKER HANDOFF | Real pre-fix tail-cleanup/reentry/Close proof, owner release outside gates followed by atomic terminal owner/drain publication; supported comparison behavior preserved | -| 14 | Verified OBDX Pro GT read-only integration | 13 plus documented device research/access | BLOCKED / NOT ASSIGNED; HARDWARE GATE | Source-backed device support matrix, explicit physical target, real read-only identification/diagnostics/telemetry recording where supported; no write path | +| 13 | Comparative evaluation and complete synthetic demonstration | 12 and 12A accepted | ACCEPTED 2026-11-01 AFTER 13A | Trusted projection/equivalent real runs/captures/metrics/native demonstration and corrected completion-tail ownership; reported 654 passes | +| 13A | Retain comparison ownership through cleanup and drain completion | 13 review R-01 / C-07 | ACCEPTED 2026-11-01 | Seven actual pre-fix failures/nine corrected cases; callback/release outside gate, reserved owner then atomic terminal/drain/Close, rebuilt native evidence | +| 14 | Verified OBDX Pro GT read-only integration | 13 and 13A accepted; research before implementation | READY FOR READINESS CHECKPOINT; INTEGRATION GATED | Exact attributable GT protocol/interface/Windows/API/licensing/device-readiness matrix and smallest read-only contract first; no hardware/source implementation in current assignment | | 15 | Advanced dashboards, analysis, and comparisons | 13; 14 for real captures | PLANNED | Persist configurable layouts/thresholds, linked charts, larger-capture analysis, raw-data inspection and multi-run/multi-vehicle comparisons with lineage/uncertainty | | 16 | Broader diagnostic protocols and hardware adapters | 14 | PLANNED | Conformance-backed additional CAN/ISO-TP/UDS/KWP2000/J2534 or legacy adapters where verified; same application ports and capability restrictions | | 17 | Curated vehicle knowledge and research workflow | 12; 16 where needed | PLANNED | Sourced profile/module/calibration knowledge, review/promotion workflow, exact applicability, licensing/access controls; research cannot authorize writes | @@ -694,19 +716,20 @@ evidence; they must not silently discard required capabilities. validator; actual native intent/owner and unavailable/invalid/isolation gates verified. Broader diagnostic/scenario planning, retrieval and restricted tools remain planned, not implemented or authority to issue hardware frames. -- **13 assigned:** trusted verified supported-image admission, explicit new-config +- **13 accepted after 13A:** trusted verified supported-image admission, explicit new-config scalar/table projection, equivalent full scenarios/initial state, actual bounded diagnostic captures and canonical idle/vehicle/fuel/shift comparison with lineage/uncertainty. Save/readback/replay and native demonstration reuse accepted contracts. Independent tests and supported timeout/identity/invalid/interruption/ corruption/recovery/config/DTC failure coverage retain earlier regressions; no invented firmware checksum/partial physical-write protocol. -- **14:** verify OBDX Pro GT protocols, drivers, OS/architecture constraints, +- **14 readiness assigned:** verify OBDX Pro GT protocols, drivers, OS/architecture constraints, manufacturer libraries/SDKs, actual J2534 support and C# integration using - attributable sources before implementation. Missing device/driver access means - real-hardware verification is blocked, not passed by mocks. Restrict services to - verified read-only allowlists; diagnostic access does not imply every module is - discoverable or programmable. + attributable sources before implementation. Current assignment is sourced + readiness/specification only: no adapter code, driver install, device open or + vehicle traffic. Review the smallest supported read-only implementation next + within the same milestone; missing device access gates real-hardware proof, + not documentation research. No mock-as-hardware or assumed module capability. ### Longer-term scope preservation @@ -1126,14 +1149,21 @@ history, not repeated redesign without evidence. IsBusy=false before owner Release and drain completion. New admission can replace `_drain` while cleanup remains pending. Prepared [Step-13A](Step-13A.md); no model permissions, hardware scope or unrelated dynamics fixes. +- Accepted Step-13A and corrected Step-13 after reviewed seven actual pre-fix + failures, nine corrective cases, 179 unit + 475 integration = 654 passes, + clean nine-project Release and rebuilt affected native evidence. R-01 closed. +- Strengthened shared worker gate prospectively with source-ordering/cleanup- + tail/final-evidence ledger and prepared [Step-14](Step-14.md) hardware-readiness + research checkpoint. No source/driver/hardware operation or auto handoff. ### Remaining -- Manually execute [Step-13A](Step-13A.md) and shared gate, then review controlled - actual pre-fix/corrected release-tail/Close/new admission proof and regressions. -- Step-14 is blocked/unassigned. Step-13 code and native comparison evidence are - present but not accepted pending C-07 correction. Local-only generation and - earlier work remain accepted; preserve all numerical/history/safety gates. +- Manually execute [Step-14](Step-14.md) readiness research and revised shared + gate, then review source-backed GT requirements and smallest read-only contract + before assigning adapter implementation. No Step-15 entry on research alone. +- Step-13/13A and earlier work are accepted. Step-14 physical integration is + unimplemented; device/driver/native prerequisites and proof remain gated. + Preserve all numerical/history/safety and manual workflow boundaries. - Profile/module metadata, synthetic virtual-module communication and deterministic dynamics/v2 and corrected dashboard are accepted; later features remain planned. Preserve the complete sequence/safety gates. @@ -1148,18 +1178,22 @@ Runtime/model availability is an environmental prerequisite, not a permanent attestation; future missing/changed state must be explicit, with no cloud/model fallback or automatic setup added to the app. The orchestrator ran no checks. -Step-13 R-01 is a concrete new completion-order issue: `_owner=null` and -`IsBusy=false` precede `owner.Release()` and completion of `_drain`. -A delayed cancellation callback/release can leave old work undrained while -new Evaluate/Save replaces the tracked completion. The orchestrator identified -source ordering, not an independently executed failure; Step-13A requires actual -controlled reproduction and correction, reusing accepted local-generation -completion prior art without cleanup under required gates. +Step-13 R-01 is closed by accepted Step-13A: actual pre-fix tail failures +established premature owner/drain replacement, corrected release-before-atomic- +settlement keeps admission reserved through cleanup. Original report remains +unchanged; the added prospective worker ledger prevents relying on pre-work +barriers/prose alone for future completion-tail behavior. + +Step-14 exact GT interface/API/device/Windows prerequisites have not been +verified. Research must distinguish supported primary-source facts, observed +local environment and unknowns. No hardware capability or driver/API exists +merely because a product has OBD/J2534/Pro in its name. Current handoff does not +authorize opening a physical adapter or transmitting to a vehicle. Step-13's actual model/proof/config/metrics/archive/replay evidence remains preserved. Fuel changes are synthetic estimates, no physical/checksum claim. Its disclosed intermittent unchanged dynamics regression and known recording -navigation issue are separately tracked, not automatic Step-13A fixes. +navigation issue are separately tracked, not automatic Step-14 fixes. No blocking Step-10 deficiency remains. Its pending-reopen finding below is historical and closed by accepted Step-10A: diff --git a/prompts/STATE.md b/prompts/STATE.md index 77be7b1..08ea31b 100644 --- a/prompts/STATE.md +++ b/prompts/STATE.md @@ -5,11 +5,11 @@ | Field | Value | |---|---| | Updated | 2026-11-01 | -| Phase | Step-13 reviewed; comparison ownership/drain tail requires focused correction | -| Active step | Step-13A - Retain comparison ownership through cleanup and drain completion | -| Assignment | [Step-13A.md](Step-13A.md) | -| Prerequisites | Step-12 with Step-12A ACCEPTED 2026-10-31 | -| Current executable handoff | [Step-13A.md](Step-13A.md) - one original C-07 lifetime correction | +| Phase | Corrected Step-13 accepted; bounded hardware-readiness research next | +| Active step | Step-14 - OBDX Pro GT readiness and read-only integration specification | +| Assignment | [Step-14.md](Step-14.md) | +| Prerequisites | Step-13 with Step-13A ACCEPTED 2026-11-01 | +| Current executable handoff | [Step-14.md](Step-14.md) - research/readiness only, no adapter implementation | | Assignment status | READY FOR MANUAL WORKER HANDOFF | | Completion handoff status | [Step-12-Completion.md](Step-12-Completion.md) superseded for execution; preserve unchanged | | Original worker report | [Step-12-Report.md](Step-12-Report.md) present and reviewed; preserve INCOMPLETE/BLOCKED observations | @@ -17,11 +17,12 @@ | Worker report | [Step-12A-Report.md](Step-12A-Report.md) present and reviewed; explicitly INCOMPLETE/BLOCKED | | Accepted execution report | [Step-12A-Execution-Report.md](Step-12A-Execution-Report.md) - reviewed; original blocked reports preserved | | Step-13 worker report | [Step-13-Report.md](Step-13-Report.md) present and reviewed; preserve unchanged | -| Expected worker report | `prompts/Step-13A-Report.md` - not yet created | +| Step-13A worker report | [Step-13A-Report.md](Step-13A-Report.md) present and accepted on reviewed evidence | +| Expected worker report | `prompts/Step-14-Report.md` - not yet created | | Owner runtime policy | Local models only; no Ollama cloud or cloud fallback, reaffirmed 2026-10-31 | -| Last accepted correction/follow-up | Step-12A - accepted 2026-10-31; includes evidenced Hybrid dispatch fixes | -| Last accepted major milestone | Step-12 with Step-12A - accepted 2026-10-31 | -| Outstanding follow-up | Step-13A / R-01 comparison owner release and drain publication; no Step-12B | +| Last accepted correction/follow-up | Step-13A - accepted 2026-11-01; R-01 closed | +| Last accepted major milestone | Step-13 with Step-13A - accepted 2026-11-01 | +| Outstanding follow-up | None; no Step-13B required | | Step-02 status | ACCEPTED after Step-02A | | Step-03 status | ACCEPTED after Step-03A/Step-03B | | Step-04 status | ACCEPTED after Step-04A/Step-04B | @@ -37,11 +38,12 @@ | Step-11 status | ACCEPTED 2026-10-31; no correction required | | Step-12 status | ACCEPTED 2026-10-31 after Step-12A actual local-model/native qualification | | Step-12A status | ACCEPTED 2026-10-31; all frozen setup/model/native/regression gates closed | -| Step-13 status | NEEDS CORRECTION for C-07 / AC-03; other implementation/native evidence substantially supported | -| Step-13A status | READY FOR MANUAL WORKER HANDOFF; no hardware/new feature scope | -| Worker execution | Step-13 returned COMPLETE; 179 unit/466 integration = 645 passes and native real-model/target/run/archive evidence reviewed | -| Immediate next action | Manually give worker Step-13A, original Step-13 and shared gate; no automatic invocation | -| Next orchestrator action | Review executed pre-fix/corrected ownership-tail cases and regressions before Step-13 acceptance | +| Step-13 status | ACCEPTED 2026-11-01 after Step-13A; proof/projection/comparison/native and corrected lifetime supported | +| Step-13A status | ACCEPTED 2026-11-01; actual seven pre-fix failures and nine corrected cases reviewed | +| Step-14 status | READY FOR MANUAL WORKER HANDOFF; readiness checkpoint only, physical integration remains unimplemented | +| Worker execution | Step-13A returned COMPLETE; 179 unit/475 integration = 654 passes, clean Release and rebuilt affected native evidence reviewed | +| Immediate next action | Manually give worker Step-14 and revised shared gate; no automatic invocation or hardware traffic | +| Next orchestrator action | Review sourced hardware-readiness report before assigning any adapter code; no hardware milestone acceptance from research alone | ## Repository baseline at initialization @@ -1651,6 +1653,73 @@ Neither is automatic Step-13A cleanup or a reason to edit accepted dynamics. not another model-permission gate or new feature. Last accepted major remains Step-12/12A; Step-14 remains blocked and no hardware assignment is created. +## Step-13A acceptance and corrected Step-13 + +Decision: **ACCEPTED**, 2026-11-01, for Step-13A and corrected Step-13. +R-01 is closed; no Step-13B required. Original Step-13 report and its native +model/proof/projection/capture/replay evidence remain unchanged. + +Reviewed the complete [corrective report](Step-13A-Report.md), actual comparison +completion/Close diff, internal observation/test visibility and all new ownership +tests, related docs, frozen assignment hash, unchanged nine-project references +and existing worker Release outputs. The orchestrator ran no application +builds/tests/native/inference/runtime or hardware commands. + +| Criterion | Decision | Evidence | +|---|---|---| +| AC-01 | ACCEPTED | Seven executed pre-fix behavioral failures; actual cancellation callback/release held after real work returns, Evaluate/Save Busy with unchanged owner/task/config/target/store effects after correction | +| AC-02 | ACCEPTED | Callback/release outside state gate, actual release still attempted on observation failure; primary/cleanup errors retained; same reserved owner/terminal/exact task settlement and shared Close publication under coherent gates | +| AC-03 | ACCEPTED | Exact old drain stays incomplete/reserved until release; no replacement admission, Close/Dispose awaits it; successful retry only after drain and independent fresh closed/page lifetime | +| AC-04 | ACCEPTED ON WORKER EXECUTION EVIDENCE | Reported 179 unit + 475 integration = 654 passes, zero failed/skipped; all 645 prior cases retained, nine new cases; clean nine-project Release and actual rebuilt manual comparison/save/Busy/Cancel/unmount/native recheck | +| AC-05 | ACCEPTED | Own post-green source path/ledger, truthful internal/native/historical-model distinction, aligned docs and original report preservation/task-only cleanup/manual STOP | + +The one internal ReleasingOwner observation is bounded test evidence, not a +public orchestration hook or private model oracle. It neither bypasses the real +workflow nor supplies values; native production has no subscriber. +Owner release now precedes owner removal and exact task settlement. Post-task +notification mutates no successor ownership. Failed cleanup settles waiters as +failure with primary/save evidence retained, not a healthy fallback. + +Worker native recheck preserved original/derived fingerprints, 3361 steps/ +336.1 s, 1346 actual observations per capture and exact 650/1250 rpm behavior/ +unchanged torque axes and unrelated fields. The prior Step-13 real LLM response +and replay proof are historical; no new inference/native replay is claimed. +The prior unchanged dynamics/recording-navigation disclosures remain separate, +not causal corrections; neither recurred in this reported corrective run. + +## Prospective worker-control revision and Step-14 checkpoint + +The owner requested fewer corrective steps. Accountability is shared: the +orchestrator's earlier gate required pending-work tests but did not explicitly +require the post-work callback/release/drain boundary; a prose self-review left +that gap untested. More assertions/test totals alone would not fix the process. + +Revised [WORKER-QUALITY-GATE.md](WORKER-QUALITY-GATE.md) prospectively from +Step-14: inspect accepted owner prior art before adding logic; execute admission, +publication AND completion-tail cases where relevant; include exact source/ +invariant/named-evidence ledger; validate the final production edits/rebuilt +affected paths; reconcile every frozen criterion before COMPLETE. +Worker fixes tightly coupled findings inside the active assignment and returns +BLOCKED/INCOMPLETE for genuinely missing evidence. No retrospective criteria +were added to Step-13A and no automatic agent/worker management is introduced. +The orchestrator will use the same frozen rows, consolidate review findings, +and keep new dependency/state-machine prerequisites out of broad assignments. + +[Step-14](Step-14.md) is deliberately a read-only research/readiness checkpoint: +sourced exact OBDX Pro GT interface/protocol/Windows/library/support matrix, +read-only local prerequisite inventory if accessible, and a bounded initial +adapter contract/qualification specification. No application/adapter source, +driver install, device opening or vehicle traffic is authorized in this prompt. +It must not claim physical integration or hardware acceptance from documentation, +enumeration or mocks. Missing device access is an explicit later integration +gate, not a reason to fabricate research conclusions. + +After this checkpoint returns, review the sourced specification and dependencies +before authorizing the smallest actual read-only implementation as a separate +manual handoff within the Step-14 milestone. Do not auto-advance Step-15 or +renumber completed history. Current hardware behavior remains unimplemented. +No further model/runtime changes or unrelated baseline repairs are assigned. + ## Prerequisites, limitations, and known issues - Step-01A worker evidence establishes portable and native Windows compatibility @@ -1689,22 +1758,19 @@ Step-12/12A; Step-14 remains blocked and no hardware assignment is created. ## Review and progression gate -On manual return, evaluate evidence from [Step-13A](Step-13A.md) -against its matrix, original Step-13 C-07/AC-03 and shared gate using both reports, -actual code/tests, dependency graph, Git changes, -README/docs, and recorded build/test evidence. Do not accept solely on a success -claim; do not claim independent runtime verification. +On manual return, evaluate [Step-14](Step-14.md) readiness evidence against its +frozen research matrix and revised shared gate, cited primary sources, exact +device/interface assertions, local prerequisite observations and proposed +bounded adapter/test contract. No application execution is assigned. -- Inspect actual pre-fix release-tail/competing admission/Close drain cases, - atomic corrected completion, failure/result/save evidence and existing native - comparison behavior. Preserve supported projection/run/model contracts. -- If accepted: accept Step-13A and corrected Step-13, update roadmap/state, prepare bounded Step-14 read-only hardware work only with its prerequisites - and stop for manual handoff. -- If deficient: retain Step-13A open and identify a material unmet contract/ - regression; any further corrective assignment must be narrowly evidenced. - Planned new features are not corrections. -- If blocked: retain the active step, document the prerequisite and required - worker evidence; do not advance or mark unexecuted checks as successful. +- Inspect attributable exact GT evidence, version/architecture/protocol/API/ + licensing limits, unknowns and supported initial read-only boundary. Do not + infer capability from a product name, generic OBD family or synthetic v1/v2. +- If readiness accepted: record the checkpoint only and prepare one narrow + actual integration handoff within Step-14 after prerequisite review; do not + accept the full hardware milestone or advance Step-15 yet. +- If deficient/blocked: identify the exact unsupported source/contract/prerequisite + and retain the checkpoint; no guessed implementation or automatic new letter. - Never create the next major assignment while acceptance or corrections are open. ## History @@ -1798,12 +1864,15 @@ claim; do not claim independent runtime verification. | 2026-10-31 | Step-13 prepared | Explicit verified supported-image projection to NEW immutable configs, equivalent real scenario/capture/comparison/replay and native demonstration; original source/rehearsal isolation preserved, no automatic handoff | | 2026-11-01 | Step-13 returned and reviewed | Reported 645-case/clean Release and actual model/proof/new-config/real-run/archive/replay evidence inspected; most frozen requirements supported | | 2026-11-01 | Step-13 needs focused C-07 correction; Step-13A prepared | Owner/IsBusy cleared before owner Release and public drain settlement permits replacement of undrained completion; source ordering finding, controlled pre-fix worker proof required; no Step-14 | +| 2026-11-01 | Step-13A returned and ACCEPTED; corrected Step-13 ACCEPTED | Actual seven pre-fix tail failures, nine corrected cases/654 passes/clean Release/rebuilt native source evidence reviewed; ownership reserved through release and atomic exact drain settlement, no 13B | +| 2026-11-01 | Worker control strengthened prospectively; Step-14 readiness prepared | Required boundary ledger/completion-tail/final changed-path evidence from Step-14, tighter prerequisite-first scope; manual sourced hardware readiness only, no adapter code/vehicle traffic or retrospective gate | ## Manual handoff instruction -Provide [Step-13A.md](Step-13A.md), original [Step-13.md](Step-13.md) and shared -[worker gate](WORKER-QUALITY-GATE.md) to the separate worker. Execute Step-13A -only and return `prompts/Step-13A-Report.md`, preserving the Step-13 report and -all earlier assignments/reports. Step-13 remains unaccepted; no Step-14. +Provide [Step-14.md](Step-14.md) and revised [worker gate](WORKER-QUALITY-GATE.md) +to the separate worker. Execute the readiness checkpoint only and return +`prompts/Step-14-Report.md` plus its requested sourced readiness document. +No application code/driver install/hardware traffic. Stop for review before +any implementation handoff; full Step-14 hardware acceptance remains pending. Return manually to the orchestrator for review. Reports, including final chat reports, must follow the single plain triple-backtick copy-window requirement. diff --git a/prompts/Step-13A-Report.md b/prompts/Step-13A-Report.md new file mode 100644 index 0000000..a2ca778 --- /dev/null +++ b/prompts/Step-13A-Report.md @@ -0,0 +1,328 @@ +``` +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. +``` diff --git a/prompts/Step-14.md b/prompts/Step-14.md new file mode 100644 index 0000000..e6fc51c --- /dev/null +++ b/prompts/Step-14.md @@ -0,0 +1,194 @@ +# Step-14 - OBDX Pro GT readiness and read-only integration specification + +## STEP IDENTIFIER + +Step-14, hardware-readiness checkpoint only. +Step-13 with Step-13A accepted 2026-11-01; 654 cases reported passing. +This is the sole active manual worker assignment. It does not authorize +adapter implementation or accept the full Step-14 hardware milestone. +Read [STATE.md](STATE.md), [ROADMAP.md](ROADMAP.md) and the revised +[WORKER-QUALITY-GATE.md](WORKER-QUALITY-GATE.md). STOP after the requested report. + +## STEP TITLE + +Establish exact sourced OBDX Pro GT prerequisites and the smallest supported +read-only adapter boundary before any hardware code or vehicle traffic. + +## OBJECTIVE + +One deliverable: an attributable, reviewable GT readiness specification with +known facts, unresolved prerequisites and a bounded first implementation/test +contract. Do not combine research with a new transport/state machine/UI. +This prerequisite-first scope and final evidence reconciliation are deliberate +controls to reduce preventable corrective handoffs. + +Produce `docs/obdx-pro-gt-readiness.md` and `prompts/Step-14-Report.md`. +No application source/tests/project/package/driver/runtime changes, builds/ +tests/inference, adapter opening or physical diagnostic transmission. + +## ARCHITECTURAL CONTEXT + +Existing nine-project .NET 10 modular monolith: Core neutral contracts, +Diagnostics ports/protocol/result validation, Simulation isolated virtual +providers, Application use cases, UI presentation, Client thin Windows MAUI +composition, independent Components and tests under `src/tests`. +Simulation/RecordedReplay/PhysicalHardware are explicit; never substitute one +for another. Existing synthetic JSON v1/v2 is NOT an automotive wire protocol. +Physical read-only support cannot imply programming/clearing/actuation authority. + +Inspect the actual [provider contracts](../src/AutoForge.Diagnostics/ProviderContracts.cs), +relevant session/target composition and existing typed result/capture boundaries +only as needed to propose the smallest safe integration. Do not refactor them. + +## CURRENT IMPLEMENTATION STATE + +- Corrected synthetic comparison/demo accepted; 179 unit + 475 integration = + 654 cases, clean nine-project Release and native affected paths reported. +- Real local-only model and synthetic diagnostics/dynamics/proposals/rehearsal/ + archive/replay are accepted. They are not evidence of physical support. +- No OBDX Pro GT driver/API/protocol/device qualification is established. + Actual local device ownership, hardware/firmware revision, transport and + approved vehicle/bench access may be unavailable. +- Keep existing source, original assignments/reports, user data and model + runtime unchanged. No new permission form for unrelated model/runtime work. + +## REQUIRED IMPLEMENTATION + +### Frozen research matrix + +| ID | Research action | Required outcome | +|---|---|---| +| C-01 | Verify exact GT product/version/interface and primary documentation | Cite precise primary URLs/revisions/retrieval date; do not borrow another OBDX model's claims without explicit GT applicability | +| C-02 | Establish host/API/protocol/licensing requirements | Distinguish documented native interface, any actual J2534 support, USB/serial/wireless transports, Windows/architecture/driver/library constraints and unsupported/unknown items | +| C-03 | Read-only accessible local prerequisite inventory | Distinguish OS-enumerated device/installed files from an actual tested connection; absent/uncertain access is explicit, no driver install/device open/vehicle traffic | +| C-04 | Specify one smallest evidenced read-only adapter slice | Exact request/reply/units/identity/error/limits/lifecycle contract and real hardware qualification plan, reused project/ports; no unsupported frame/API invention or broad feature backlog | +| C-05 | Review source assertions, negative/lifecycle spec and report completeness | Every factual claim attributable or labelled unknown; future admission/publication/completion-tail tests concrete; no implementation/hardware success claimed from research | + +### 1. Exact sourced support matrix + +Prioritize manufacturer product/manual/protocol/SDK/driver/license sources. +Use maintained authoritative repositories if linked or verifiably applicable. +Third-party claims are secondary, labelled and cross-checked. Record source +URL/title/version/date and which exact matrix rows each supports. + +Identify product variants/firmware/hardware revisions and: + +- Documented connection interfaces and host wire framing/API command set. +- Supported vehicle protocols/buses and their exact GT/version conditions. +- Actual J2534 support, if evidenced; do not assume it from a family/name. +- Windows version/CPU architecture, native library ABI/driver/install/access + prerequisites, maintained .NET integration options and distribution/license + constraints. A vendor SDK being downloadable does not prove usability. +- Device metadata versus vehicle/module metadata, supported read-only services + and clear boundaries against writes/reset/clear/actuation/security/programming. +- Timing, framing, request IDs, buffer limits and documented failures relevant + to the first proposed slice. Unknown field sizes are unknown, not invented. + +If sources disagree/unavailable, name the uncertainty and evidence needed. +Do not repeatedly search indefinitely or turn missing specs into plausible +implementation instructions. No private code/data/credentials upload. + +### 2. Read-only local readiness + +If accessible, inspect existing OS device enumeration and installed driver/ +library metadata by exact scoped identity/path. Do not scan personal files, +dump environment/serial identifiers or open serial/Bluetooth/device handles. +No pairing, driver/SDK installation, probing hardware commands or vehicle +connection/startup. Public documentation retrieval is permitted. + +Record observed/not observed/unverified precisely. Discovery in Device Manager +is not verified physical support. If device access is absent, finish source +research and make the future hardware-test prerequisite explicit. +Do not block all research just because no device can be tested in this task. + +### 3. Smallest next implementation contract + +Propose ONE primary new hardware contract, preferably explicit adapter +connection/device identification plus one well-documented read-only capability +if the evidence supports it. Do not bundle a complete CAN/UDS/J2534 stack, +multiple adapters/protocols, DTC clearing, dashboards or physical programming. +If no safe actionable API is evidenced, return no-go/required evidence rather +than scaffolding empty interfaces. + +Specify existing project/port reuse and necessary minimal additions, without +writing code or new assignment files. The plan must state: + +- Exact physical selection/provider identity and no synthetic/replay fallback. +- Eligibility/read-only allowlist before dispatch, actual framing/API outcome + validation before positive result and metadata provenance/unknown handling. +- Bounds/cancellation/deadline/single-owner rules and synchronous-prefix/ + post-work release/drain/Close ordering. +- Normal/rejected/boundary/disconnect/overlap cases with concrete test stimulus + and measurable expected output/unchanged state. Use the revised shared + source-order ledger as the future implementation acceptance design. +- Fault injection below actual adapter boundary; simulated/recorded fixtures + labelled controlled, actual installed-device/native qualification separate. +- Specific missing driver/device/authorized bench/vehicle prerequisites and + how real evidence will establish or reject the proposed supported subset. + +No hardware safe-to-write claim or generic raw-command UI. Restrict physical +testing in the proposed later plan to approved, documented read-only operations. +The orchestrator will review this before authorizing an implementation handoff. + +## FILES OR PROJECTS EXPECTED TO CHANGE + +Create the sourced readiness document and sole worker report named above. +Update `docs/README.md` with its link/current research-only status if appropriate. +No other docs need historical rewrite; no source/tests/dependencies/config/ +orchestration/gate/old report changes. + +## INTERFACE AND DEPENDENCY REQUIREMENTS + +Research/specification only. Preserve nine projects/graph, physical restrictions, +source/unit/protocol/archive and owner contracts. No new package/host/runtime/ +driver/SDK installation, simulation rewrite, cloud/model operations or firmware +reverse engineering without separate scope. No agents, automatic handoff, +staging/commit/push or shared-server/device changes. + +## TESTING REQUIREMENTS + +No application build/test or native hardware smoke is assigned: no code changes. +Validate requested document links, source applicability and required output +shape; inspect cited primary evidence instead of trusting search summaries. +Every C-01..C-05 row needs a specific source/observation/specification result. +Source-ordering ledger may be N/A for executed code because none is changed; +its relevant future tests must be concrete in the specification. +Do not manufacture a passing hardware test or rerun 654 cases as a proxy for +research accuracy. Preserve all earlier execution evidence unchanged. + +## DOCUMENTATION REQUIREMENTS + +The readiness document contains exact GT sourced support matrix, local observed/ +missing prerequisites, bounded proposed adapter/test boundary, licensing risks, +unknowns and explicit go/no-go for that subset. Distinguish research readiness +from implemented/tested physical capability. +No standalone planning/checklist files beyond these requested deliverables. + +## ACCEPTANCE CRITERIA + +| ID | Readiness criterion | Evidence | +|---|---|---| +| AC-01 | C-01/C-02 exact attributable GT interface/API/host/protocol/licensing facts | Primary-source rows, explicit variant/revision scope and labelled unknown/conflicting secondary claims | +| AC-02 | C-03 honest local prerequisites, no physical/installation action | Exact scoped metadata observations or explicit unavailable status; no enumeration-as-tested claim | +| AC-03 | C-04 one bounded implementable read-only subset or justified no-go | Reused real ports, concrete framing/result/owner/negative/hardware test specification and dependencies | +| AC-04 | C-05 final source/coverage reconciliation and preservation | Named source mapping, link checks, self-review and no undocumented/code/hardware claims | +| AC-05 | Research-only report/manual gate truthful | Requested deliverables, precise checkpoint status and STOP before implementation | + +## OUT-OF-SCOPE WORK + +Adapter/application coding/scaffolding, builds/tests, driver/SDK installation, +device open/pairing/vehicle traffic, read-only hardware smoke, protocol execution, +any physical clear/reset/write/security/programming, model/runtime changes, +generic framework, new milestone renumbering or Step-15. + +## REPORTING REQUIREMENTS + +Save `prompts/Step-14-Report.md` entirely inside one plain triple-backtick fence, +no language tag/outside content/nested fences. Include identifier/title, +COMPLETE FOR READINESS or INCOMPLETE/BLOCKED precisely; C/AC source/evidence +mapping, deliverable links, exact proposed subset/no-go/unknowns, local checks +performed, source-ordering self-review/N/A rationale, preservation and issues. +Research can be complete with an explicit unavailable-device prerequisite; +actual physical integration/hardware milestone is still NOT IMPLEMENTED. +Missing authoritative evidence for the proposed subset is a no-go, not assumed +support. Save and STOP for manual review before any implementation assignment. diff --git a/prompts/WORKER-QUALITY-GATE.md b/prompts/WORKER-QUALITY-GATE.md index 7bccba9..ec3d932 100644 --- a/prompts/WORKER-QUALITY-GATE.md +++ b/prompts/WORKER-QUALITY-GATE.md @@ -5,6 +5,11 @@ This supplements the active assignment and existing protected-file/manual workflow rules. It does not impose new criteria on completed work, authorize agents/automation, or replace repository instructions. +Revision 2026-11-01 applies prospectively from Step-14. The existing "test +pending work" rule missed post-work cleanup/release ordering in Step-13. +The added boundary ledger below makes that review executable, not a claim +that more test cases or longer reports alone prevent defects. + ## 1. Before coding: make the contract executable Read the assignment, current implementation and its acceptance cases. Establish @@ -37,6 +42,15 @@ Do not broaden scope to speculative future features. hidden defaults, false zero data, swallowed failure or broad exception mask. - When state/lifetime changes, test competing requests while work is pending, not only sequential commands after each await completes. +- Include the completion tail: operation work has returned, but callbacks/ + resource release/disposal and the advertised drain task are unfinished. + Ownership remains reserved until cleanup and coherent terminal/task settlement; + reject competing admission with exact unchanged-owner/task/call assertions. + Exercise success, operation failure, cancellation and relevant cleanup failure. + A test holding only the HTTP reply before work returns does not cover this tail. +- Before adding an owner/lifecycle path, inspect accepted local prior art and + use its ordering rather than copying an older incomplete pattern. Keep + callbacks/awaited cleanup outside required state gates and verify lock order. - Use controlled schedulers/barriers for timing. No arbitrary sleeps/polling as correctness proof. Always release test barriers/resources in finally cleanup. - Exercise the real implementation under test. Faults may be injected below the @@ -60,9 +74,28 @@ Do one source-path review of the changed flow: 5. Check every required matrix row has a meaningful assertion and executed result. 6. Check actual dependencies/Git scope, docs/README, protected files and no secrets. +For each changed stateful public flow, include this compact ledger in the +required worker report, using actual file/symbol locations and named tests: + +| Boundary | Source ordering / invariant | Executed evidence | +|---|---|---| +| Admission | All rejecting checks before dispatch or valid-state/owner mutation | Rejected input/Busy/stale assertions, exact unchanged state and call counts | +| Publication | Identity/source/current owner and complete data verified at commit, not only prechecked | Held publication/supersession and exact output assertions | +| Completion/close | Reserve owner through callback/release/disposal; coherent terminal state and exact completion task; no late successor mutation | Held post-work cleanup/close/reentry assertions, including failure | +| UI/producer-consumer | Real command/render/lifetime uses the same guarded flow, errors observed, canonical values unchanged | Actual rendered/native affected path; mocks identified precisely | + +Use N/A with a concrete reason for unaffected boundaries (for example a +research-only assignment), not fabricated tests. Keep this inside the report; +do not create another checklist/notes file or delegate this own review. +Review all touched producer/consumer paths once against the frozen matrix, +not one attractive happy path followed by a blanket "self-review passed". + Fix issues found in this pass inside the current assignment and rerun affected checks. Do not declare COMPLETE after only the first plausible green result or hand known defects to the orchestrator as recommendations. +The final validation must cover the last relevant production edits; earlier +green runs or an older native binary are not the final changed-path evidence. +Separate original historical evidence from the actual rebuilt affected checks. This is the worker's own review; do not invoke another agent or automate handoff. It is a short risk-based check, not a new document/report file or broad unrelated @@ -77,6 +110,13 @@ summary and honest native versus headless coverage. Use PASSED, FAILED, NOT EXECUTED or BLOCKED precisely. COMPLETE requires all assigned acceptance checks; use INCOMPLETE/BLOCKED for unresolved requirements. Keep historical reports unchanged and report necessary deviations explicitly. +Before returning COMPLETE, reconcile every frozen criterion to a named +executed assertion/output, the boundary ledger where applicable, final command +exits and unresolved issue list. A full-suite count, prose source review or +stub/native substitution cannot close an unsupported row. +Fix tightly coupled findings now, within the same assignment, rather than +shipping known gaps for another lettered step. Do not invent new scope or +silently waive material regressions to reduce the apparent correction count. After saving the single fenced report, STOP. No future step, orchestration edit, automatic agent communication, staging/commit/push or unauthorized system change. diff --git a/src/AutoForge.Application/Features/Vehicles/Calibration/CalibrationComparisonSession.cs b/src/AutoForge.Application/Features/Vehicles/Calibration/CalibrationComparisonSession.cs index 1b796d8..f8b392f 100644 --- a/src/AutoForge.Application/Features/Vehicles/Calibration/CalibrationComparisonSession.cs +++ b/src/AutoForge.Application/Features/Vehicles/Calibration/CalibrationComparisonSession.cs @@ -38,6 +38,7 @@ public sealed class CalibrationComparisonSession(CalibrationRehearsalSession reh private Task? _close; private long _generation; public event Action? Changed; + internal event Action? ReleasingOwner; public IReadOnlyList Providers => diagnostics.Providers; public CalibrationComparisonSnapshot Snapshot { get { lock (_gate) return _snapshot; } } @@ -306,6 +307,10 @@ public sealed class CalibrationComparisonSession(CalibrationRehearsalSession reh Exception? error = null; try { await Task.Run(() => work(generation, owner.Token)).ConfigureAwait(false); } catch (Exception exception) { error = exception; } + try { ReleasingOwner?.Invoke(completion.Task); } + catch (Exception exception) { error = error is null ? exception : new AggregateException(error, exception); } + try { owner.Release(); } + catch (Exception exception) { error = error is null ? exception : new AggregateException(error, exception); } lock (_gate) { _owner = null; @@ -313,9 +318,8 @@ public sealed class CalibrationComparisonSession(CalibrationRehearsalSession reh _snapshot = _snapshot with { State = error is null ? CalibrationComparisonState.Completed : error is OperationCanceledException ? CalibrationComparisonState.Cancelled : CalibrationComparisonState.Failed, IsBusy = false, Error = error?.Message }; + if (error is null) completion.TrySetResult(); else completion.TrySetException(error); } - owner.Release(); - if (error is null) completion.TrySetResult(); else completion.TrySetException(error); Changed?.Invoke(); } } @@ -360,8 +364,11 @@ public sealed class CalibrationComparisonSession(CalibrationRehearsalSession reh catch (Exception exception) { error = exception; } try { if (drain is not null) await drain.ConfigureAwait(false); } catch (Exception exception) { error = error is null ? exception : new AggregateException(error, exception); } - lock (_gate) _snapshot = _snapshot with { State = CalibrationComparisonState.Closed, IsBusy = false, Error = error?.Message ?? _snapshot.Error }; - completion.TrySetResult(); + lock (_gate) + { + _snapshot = _snapshot with { State = CalibrationComparisonState.Closed, IsBusy = false, Error = error?.Message ?? _snapshot.Error }; + completion.TrySetResult(); + } Changed?.Invoke(); } public async ValueTask DisposeAsync() { await CloseAsync().ConfigureAwait(false); Changed = null; } diff --git a/src/AutoForge.Application/Properties/AssemblyInfo.cs b/src/AutoForge.Application/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..7bed16c --- /dev/null +++ b/src/AutoForge.Application/Properties/AssemblyInfo.cs @@ -0,0 +1,3 @@ +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("AutoForge.IntegrationTests")] diff --git a/src/tests/AutoForge.IntegrationTests/CalibrationComparisonOwnershipTests.cs b/src/tests/AutoForge.IntegrationTests/CalibrationComparisonOwnershipTests.cs new file mode 100644 index 0000000..4cf066c --- /dev/null +++ b/src/tests/AutoForge.IntegrationTests/CalibrationComparisonOwnershipTests.cs @@ -0,0 +1,320 @@ +using AutoForge.Application.Features.Vehicles.Calibration; +using AutoForge.Application.Features.Vehicles.Telemetry.Recording; +using AutoForge.Simulation; + +namespace AutoForge.IntegrationTests; + +public sealed partial class CalibrationRehearsalTests +{ + [Theory] + [InlineData(false, "evaluate")] + [InlineData(false, "save")] + [InlineData(true, "evaluate")] + [InlineData(true, "save")] + public async Task ComparisonOwnershipTail_RealCancellationCallbackReservesAdmissionUntilRelease( + bool failReadback, string contender) + { + using var fixture = new Fixture(dynamics: true); + await using var rehearsal = fixture.Session; + var (operation, head) = await PrepareComparisonAsync(fixture); + using var store = new CompletionTailStore(failReadback); + await using var comparison = CreateComparison(fixture, store); + await comparison.EvaluateAsync(operation, fixture.Workspace.Identifier, head.Identifier, + DynamicsDiagnosticTransportFactory.ProviderIdentifier); + var result = comparison.Snapshot.Result; + var releaseEntered = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); + comparison.ReleasingOwner += completion => releaseEntered.TrySetResult(completion); + store.ReadState = () => comparison.Snapshot; + var save = comparison.SaveCapturesAsync(); + Task? cancellation = null; + Task? competing = null; + try + { + await store.ReadbackEntered.Task.WaitAsync(Deadline); + cancellation = Task.Run(() => comparison.CancelAsync()); + await store.CallbackEntered.Task.WaitAsync(Deadline); + Assert.True(store.CallbackState!.IsBusy); + store.ReleaseReadback.TrySetResult(); + Assert.Same(save, await releaseEntered.Task.WaitAsync(Deadline)); + var tail = comparison.Snapshot; + var reads = fixture.Port.ReadCount; + var writes = fixture.Port.WriteCount; + var configurations = fixture.Configurations.List().Count; + CalibrationComparisonException? rejection = null; + try + { + competing = contender == "evaluate" + ? comparison.EvaluateAsync(operation, fixture.Workspace.Identifier, head.Identifier, + DynamicsDiagnosticTransportFactory.ProviderIdentifier) + : comparison.SaveCapturesAsync(); + } + catch (CalibrationComparisonException exception) { rejection = exception; } + Assert.True(rejection?.Failure == CalibrationComparisonFailure.Busy, + $"tail busy={tail.IsBusy}; state={tail.State}; old drain completed={save.IsCompleted}; " + + $"callback exited={store.CallbackExited}; {contender} admitted={competing is not null}"); + Assert.True(tail.IsBusy); + Assert.Equal(CalibrationComparisonState.Saving, tail.State); + Assert.False(save.IsCompleted); + Assert.False(store.CallbackExited); + Assert.Equal(reads, fixture.Port.ReadCount); + Assert.Equal(writes, fixture.Port.WriteCount); + Assert.Equal(configurations, fixture.Configurations.List().Count); + Assert.Equal(2, store.Inner.SaveCalls); + Assert.Same(result, comparison.Snapshot.Result); + } + finally + { + store.ReleaseReadback.TrySetResult(); + store.ReleaseCallback.TrySetResult(); + await ObserveTailTaskAsync(save); + if (cancellation is not null) await ObserveTailTaskAsync(cancellation); + if (competing is not null) await ObserveTailTaskAsync(competing); + } + Assert.True(store.CallbackExited); + Assert.Equal(1, store.CallbackCalls); + Assert.False(comparison.Snapshot.IsBusy); + Assert.Equal(failReadback ? CalibrationComparisonState.Failed : CalibrationComparisonState.Completed, + comparison.Snapshot.State); + Assert.True(comparison.Snapshot.Saves[0].Persisted && comparison.Snapshot.Saves[0].ReadbackVerified); + Assert.True(comparison.Snapshot.Saves[1].Persisted); + Assert.Equal(!failReadback, comparison.Snapshot.Saves[1].ReadbackVerified); + if (failReadback) Assert.Contains("controlled final readback failure", comparison.Snapshot.Error); + var retry = comparison.SaveCapturesAsync(); + Assert.NotSame(save, retry); + await retry.WaitAsync(Deadline); + Assert.Same(retry, comparison.CancelAsync()); + Assert.All(comparison.Snapshot.Saves, outcome => Assert.True(outcome.ReadbackVerified)); + Assert.Equal(2, store.Inner.SaveCalls); + } + + [Theory] + [InlineData(false)] + [InlineData(true)] + public async Task ComparisonOwnershipTail_CloseOrDisposeIncludesOldDrainAfterCompetingSave(bool dispose) + { + using var fixture = new Fixture(dynamics: true); + await using var rehearsal = fixture.Session; + var (operation, head) = await PrepareComparisonAsync(fixture); + using var store = new CompletionTailStore(false); + await using var comparison = CreateComparison(fixture, store); + await comparison.EvaluateAsync(operation, fixture.Workspace.Identifier, head.Identifier, + DynamicsDiagnosticTransportFactory.ProviderIdentifier); + var result = comparison.Snapshot.Result; + var releaseEntered = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); + var closed = new TaskCompletionSource<(bool DrainSettled, bool CallbackExited)>( + TaskCreationOptions.RunContinuationsAsynchronously); + comparison.ReleasingOwner += completion => releaseEntered.TrySetResult(completion); + store.ReadState = () => comparison.Snapshot; + var save = comparison.SaveCapturesAsync(); + comparison.Changed += () => + { + if (comparison.Snapshot.State == CalibrationComparisonState.Closed) + closed.TrySetResult((save.IsCompleted, store.CallbackExited)); + }; + Task? cancellation = null; + Task? competing = null; + Task? close = null; + try + { + await store.ReadbackEntered.Task.WaitAsync(Deadline); + cancellation = Task.Run(() => comparison.CancelAsync()); + await store.CallbackEntered.Task.WaitAsync(Deadline); + store.ReleaseReadback.TrySetResult(); + Assert.Same(save, await releaseEntered.Task.WaitAsync(Deadline)); + try { competing = comparison.SaveCapturesAsync(); } + catch (CalibrationComparisonException exception) { Assert.Equal(CalibrationComparisonFailure.Busy, exception.Failure); } + if (competing is not null) + { + await competing.WaitAsync(Deadline); + close = dispose ? comparison.DisposeAsync().AsTask() : comparison.CloseAsync(); + Assert.False(close.IsCompleted, + $"replacement admitted=True; old drain completed={save.IsCompleted}; " + + $"callback exited={store.CallbackExited}; Close/Dispose completed={close.IsCompleted}; state={comparison.Snapshot.State}"); + } + else + { + var closeRequested = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); + close = Task.Run(async () => + { + closeRequested.TrySetResult(); + if (dispose) await comparison.DisposeAsync(); else await comparison.CloseAsync(); + }); + await closeRequested.Task.WaitAsync(Deadline); + Assert.False(save.IsCompleted); + Assert.False(closed.Task.IsCompleted); + } + } + finally + { + store.ReleaseReadback.TrySetResult(); + store.ReleaseCallback.TrySetResult(); + await ObserveTailTaskAsync(save); + if (cancellation is not null) await ObserveTailTaskAsync(cancellation); + if (competing is not null) await ObserveTailTaskAsync(competing); + if (close is not null) await close.WaitAsync(Deadline); + } + var terminal = await closed.Task.WaitAsync(Deadline); + Assert.True(terminal.DrainSettled); + Assert.True(terminal.CallbackExited); + Assert.Equal(1, store.CallbackCalls); + Assert.Equal(CalibrationComparisonState.Closed, comparison.Snapshot.State); + Assert.False(comparison.Snapshot.IsBusy); + Assert.Same(result, comparison.Snapshot.Result); + Assert.False(result!.IsCurrent); + Assert.Same(comparison.CloseAsync(), comparison.CloseAsync()); + Assert.Throws(() => { _ = comparison.SaveCapturesAsync(); }); + await using var fresh = CreateComparison(fixture, new ComparisonMemoryStore()); + await fresh.EvaluateAsync(operation, fixture.Workspace.Identifier, head.Identifier, + DynamicsDiagnosticTransportFactory.ProviderIdentifier); + Assert.Equal(CalibrationComparisonState.Completed, fresh.Snapshot.State); + Assert.NotSame(result, fresh.Snapshot.Result); + Assert.Equal(1, fixture.Port.WriteCount); + } + + [Fact] + public async Task ComparisonOwnershipTail_CancelledEvaluationKeepsExactDrainUntilCleanupAndThenRetries() + { + var factory = new ComparisonSignalFaultFactory("held"); + using var fixture = new Fixture(dynamics: true, dynamicsFactory: factory); + await using var rehearsal = fixture.Session; + var (operation, head) = await PrepareComparisonAsync(fixture); + await using var comparison = CreateComparison(fixture, new ComparisonMemoryStore()); + var releaseEntered = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); + var releaseCleanup = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); + var releaseCalls = 0; + void HoldRelease(Task completion) + { + Interlocked.Increment(ref releaseCalls); + releaseEntered.TrySetResult(completion); + releaseCleanup.Task.GetAwaiter().GetResult(); + } + comparison.ReleasingOwner += HoldRelease; + var evaluation = comparison.EvaluateAsync(operation, fixture.Workspace.Identifier, head.Identifier, + DynamicsDiagnosticTransportFactory.ProviderIdentifier); + Task? cancellation = null; + try + { + await factory.Entered.Task.WaitAsync(Deadline); + cancellation = comparison.CancelAsync(); + Assert.Same(evaluation, cancellation); + factory.Release.TrySetResult(); + Assert.Same(evaluation, await releaseEntered.Task.WaitAsync(Deadline)); + var tail = comparison.Snapshot; + Assert.True(tail.IsBusy, + $"cancelled evaluation tail busy={tail.IsBusy}; state={tail.State}; old drain completed={evaluation.IsCompleted}"); + Assert.Equal(CalibrationComparisonState.Evaluating, tail.State); + Assert.False(evaluation.IsCompleted); + Assert.Same(evaluation, comparison.CancelAsync()); + Assert.Throws(() => { _ = comparison.SaveCapturesAsync(); }); + Assert.Null(tail.Result); + } + finally + { + factory.Release.TrySetResult(); + releaseCleanup.TrySetResult(); + await ObserveTailTaskAsync(evaluation); + if (cancellation is not null) await ObserveTailTaskAsync(cancellation); + comparison.ReleasingOwner -= HoldRelease; + } + await Assert.ThrowsAnyAsync(() => evaluation); + Assert.Equal(1, releaseCalls); + Assert.Equal(1, factory.Disposals); + Assert.Equal(CalibrationComparisonState.Cancelled, comparison.Snapshot.State); + Assert.False(comparison.Snapshot.IsBusy); + Assert.False(comparison.Snapshot.PartialRun!.IsComplete); + var next = comparison.EvaluateAsync(operation, fixture.Workspace.Identifier, head.Identifier, + DynamicsDiagnosticTransportFactory.ProviderIdentifier); + Assert.NotSame(evaluation, next); + await next.WaitAsync(Deadline); + Assert.Equal(CalibrationComparisonState.Completed, comparison.Snapshot.State); + Assert.True(comparison.Snapshot.Result!.IsCurrent); + } + + [Theory] + [InlineData(false)] + [InlineData(true)] + public async Task ComparisonOwnerCleanup_FailureSettlesWaitersAndPreservesPrimaryAndSaveEvidence(bool primaryFailure) + { + using var fixture = new Fixture(dynamics: true); + await using var rehearsal = fixture.Session; + var (operation, head) = await PrepareComparisonAsync(fixture); + var store = new ComparisonMemoryStore { FailSaveCall = primaryFailure ? 2 : null }; + await using var comparison = CreateComparison(fixture, store); + await comparison.EvaluateAsync(operation, fixture.Workspace.Identifier, head.Identifier, + DynamicsDiagnosticTransportFactory.ProviderIdentifier); + var result = comparison.Snapshot.Result; + var failure = new IOException("controlled completion cleanup failure"); + void FailRelease(Task _) => throw failure; + comparison.ReleasingOwner += FailRelease; + var save = comparison.SaveCapturesAsync(); + try + { + var error = await Assert.ThrowsAnyAsync(() => save.WaitAsync(Deadline)); + Assert.IsNotType(error); + if (primaryFailure) + { + var aggregate = Assert.IsType(error); + Assert.Contains(aggregate.InnerExceptions, item => item is CalibrationComparisonException); + Assert.Contains(failure, aggregate.InnerExceptions); + } + else Assert.Same(failure, error); + Assert.Equal(CalibrationComparisonState.Failed, comparison.Snapshot.State); + Assert.Contains(failure.Message, comparison.Snapshot.Error); + Assert.False(comparison.Snapshot.IsBusy); + Assert.Same(result, comparison.Snapshot.Result); + Assert.True(comparison.Snapshot.Saves[0].ReadbackVerified); + Assert.Equal(!primaryFailure, comparison.Snapshot.Saves[1].Persisted); + } + finally { comparison.ReleasingOwner -= FailRelease; } + store.FailSaveCall = null; + await comparison.SaveCapturesAsync().WaitAsync(Deadline); + Assert.All(comparison.Snapshot.Saves, outcome => Assert.True(outcome.ReadbackVerified)); + } + + private static async Task ObserveTailTaskAsync(Task task) + { + try { await task.WaitAsync(Deadline); } + catch (Exception exception) when (exception is CalibrationComparisonException or OperationCanceledException) { } + } + + private sealed class CompletionTailStore(bool failReadback) : ITelemetryArchiveStore, IDisposable + { + public ComparisonMemoryStore Inner { get; } = new(); + public Func? ReadState { get; set; } + public CalibrationComparisonSnapshot? CallbackState { get; private set; } + public TaskCompletionSource ReadbackEntered { get; } = new(TaskCreationOptions.RunContinuationsAsynchronously); + public TaskCompletionSource ReleaseReadback { get; } = new(TaskCreationOptions.RunContinuationsAsynchronously); + public TaskCompletionSource CallbackEntered { get; } = new(TaskCreationOptions.RunContinuationsAsynchronously); + public TaskCompletionSource ReleaseCallback { get; } = new(TaskCreationOptions.RunContinuationsAsynchronously); + public bool CallbackExited { get; private set; } + public int CallbackCalls { get; private set; } + private CancellationTokenRegistration _registration; + private int _reads; + public Task SaveAsync(TelemetryCaptureSnapshot capture, CancellationToken cancellationToken = default) + { + if (Inner.SaveCalls == 0) + _registration = cancellationToken.Register(() => + { + CallbackCalls++; + CallbackState = ReadState!(); + CallbackEntered.TrySetResult(); + ReleaseCallback.Task.GetAwaiter().GetResult(); + CallbackExited = true; + }); + return Inner.SaveAsync(capture, cancellationToken); + } + public async Task LoadAsync(string captureId, CancellationToken cancellationToken = default) + { + var readback = await Inner.LoadAsync(captureId); + if (++_reads != 2) return readback; + ReadbackEntered.TrySetResult(); + await ReleaseReadback.Task; + if (failReadback) + throw new TelemetryArchiveException(TelemetryArchiveFailure.ReadFailure, "controlled final readback failure"); + return readback; + } + public Task> ListAsync(CancellationToken cancellationToken = default) => + Inner.ListAsync(cancellationToken); + public void Dispose() => _registration.Dispose(); + } +}