AutoForge/prompts/Step-10-Report.md

25 KiB

# Step-10 - Verified simulated programming and recovery

## Status

COMPLETE. The isolated Simulation image/typed port, guarded backup/approval/
dispatch/readback/reconciliation/Restore workflow, executable contracts,
post-green self-review, full nine-project Release build/regressions and actual
native rehearsal checks passed.

Step-10 remains pending manual orchestrator review. This report does not grant
acceptance. Accepted Step-09 and all 405 baseline cases are preserved.
Step-11 local AI and every physical operation remain unimplemented/unassigned.
No agents, automatic handoff, staging, commit or push occurred.

## Functions, files and interfaces

- [CalibrationProgrammingPort.cs](../src/AutoForge.Diagnostics/CalibrationProgrammingPort.cs):
  separate narrow ISimulatedCalibrationTargetFactory/ISimulatedCalibrationTarget
  contracts and defensive Identity/Image/Commit/Acknowledgement models.
  No new wire protocol, raw commands, firmware blocks or hardware driver.
- [SimulatedCalibrationTarget.cs](../src/AutoForge.Simulation/SimulatedCalibrationTarget.cs):
  actual explicit autoforge.simulation.calibration-rehearsal provider, independently
  stored supported image, unique instance identity, complete actual Read,
  validated atomic instance/revision CAS and target destruction on Close.
  Seeded once from the exact source configuration; it never changes a
  DynamicsEngine/configuration/profile/diagnostic source.
- [CalibrationRehearsalModels.cs](../src/AutoForge.Application/Features/Vehicles/Calibration/CalibrationRehearsalModels.cs):
  typed failures/states, immutable verified volatile backup, preparation,
  single-use approval and bounded mutation/reconciliation evidence.
- [CalibrationRehearsalSession.cs](../src/AutoForge.Application/Features/Vehicles/Calibration/CalibrationRehearsalSession.cs):
  fresh-session factory, NewOperationId, OpenAsync, PrepareBackupAsync,
  PrepareApplyAsync, PrepareRestoreAsync, Approve, ExecuteAsync,
  ReconcileAsync, CloseAsync/DisposeAsync and immutable Snapshot.
  One operation owner, exact request replay/conflict guards, full independent
  readback, explicit RecoveryRequired and generation-safe drainage.
- [CalibrationAuthoringService.cs](../src/AutoForge.Application/Features/Vehicles/Calibration/CalibrationAuthoringService.cs):
  minimal internal synchronous current-head dispatch guard and shared pure
  CalibrationValueDifferences extraction. Existing authoring validation,
  Baseline/Proposed status, immutable history and exact diff semantics remain.
- [CalibrationRehearsalPanel.razor](../src/AutoForge.UI/Features/Vehicles/Calibration/CalibrationRehearsalPanel.razor):
  actual explicit provider/open/backup/proposal/prepare/confirm/dispatch/
  reconcile/Restore/close controls, selected/current head feedback, distinct
  acknowledgement/readback, full image/audit inspection and safe errors.
  [CalibrationPage.razor](../src/AutoForge.UI/Features/Vehicles/Calibration/CalibrationPage.razor)
  hosts this separate page-owned rehearsal beside the authoring editor.
- [AddAutoForgeUi.cs](../src/AutoForge.UI/Features/Foundation/AddAutoForgeUi.cs)
  and [MauiProgram.cs](../src/AutoForge.Client/MauiProgram.cs):
  fresh rehearsal factory registration and the explicit real Simulation port.
  This is not a diagnostic-provider fallback or a model permission.

Tests:

- [CalibrationRehearsalTests.cs](../src/tests/AutoForge.IntegrationTests/CalibrationRehearsalTests.cs)
- [CalibrationRehearsalLifecycleTests.cs](../src/tests/AutoForge.IntegrationTests/CalibrationRehearsalLifecycleTests.cs)
- [CalibrationRehearsalReviewTests.cs](../src/tests/AutoForge.IntegrationTests/CalibrationRehearsalReviewTests.cs)
- [CalibrationRehearsalUiTests.cs](../src/tests/AutoForge.IntegrationTests/CalibrationRehearsalUiTests.cs)
- [CalibrationRehearsalIsolationTests.cs](../src/tests/AutoForge.IntegrationTests/CalibrationRehearsalIsolationTests.cs)

The initial success/negative/backup/fault/owner/capacity/rendered contracts
were written before production implementation. Post-green review added the
remaining cancellation/head/clock/cleanup/real-coexistence coverage.
Tests forward the actual Simulation target below Application; the workflow
is not mocked and no implementation private state/oracle supplies readback.

## Frozen C-01..C-12 matrix

All rows below are PASSED. Named methods were executed tests, not suggestions.

| ID | Named evidence and exact result |
|---|---|
| C-01 | ExplicitTargetAndIndependentBackup_ReadActualDefensiveRevisionZeroImage; WrongSourceAndDescriptorRejectBeforeTargetFactoryOpens. Explicit valid workspace/source and the registered Simulation provider open one fresh independent target. PhysicalHardware, RecordedReplay, undefined/wrong provider/descriptor/workspace reject with OpenCount=0. Actual source/definition is validated before seed; wrong config/definition rejects. No target opens on authoring Save or render. |
| C-02 | ExplicitTargetAndIndependentBackup_ReadActualDefensiveRevisionZeroImage; IndependentBackupFailure_NeverPublishesFakeVerifiedOrApproval (identity/revision/cell/shape/read-failure). Exactly two independent real-port reads establish revision-zero identity/shape/axis/unit/value equality. Backup covers scalar 650 and all six original torque rows, is defensively copied, and remains the original backup. Wrong/partial/mismatched/unavailable second reads publish no verified backup/approval and write zero. |
| C-03 | ScalarThenTableApplyAndSeparatelyApprovedRestore_VerifyTheFullActualImage; RenderedRehearsal_BackupConfirmationApplyAndRestoreUseActualPortWithoutAuthoringStatusRewrite. Preparation shows actual before 650->candidate 1250, delta +600 rpm. Immutable approval binds exact source/instance/backup/head/before revision/action. Fresh precheck plus source-head guard precede one dispatch. Independent full readback establishes revision 1, scalar 1250 and every torque cell unchanged; source config/baseline remain 650 and authoring remains Proposed. |
| C-04 | The same real target and actual rendered test; native full readback. Saved next proposal changes only 2000-rpm torque 360->350. Fresh approval binds current target revision 1; one dispatch/readback yields revision 2, scalar 1250, fixed original axes and exactly that cell changed. All other cells are checked, not only acknowledgement or selected value. |
| C-05 | InvalidConfirmationTokenActionHeadAndNoOp_RejectBeforeConsumptionOrWrite; ActualTargetRejectsBadIdentityRevisionShapeAndValuesBeforeAtomicCommit; accepted authoring/template regressions. Missing backup, wrong/unconfirmed token/action, stale head/source/image, no-op, wrong kind and invalid shape reject before approval consumption or mutation. Direct real target CAS rejects wrong instance/revision and cancelled/invalid full candidate while image stays revision 0. Required source-unit/shape/value validation is the unchanged tested Core template, not a new weak write validator. |
| C-06 | FreshReadAndActualTargetCas_PreventChangesBeforeAndAfterDispatchPrecheck; AuthoringHeadChangesDuringHeldFreshPrecheck_RejectBeforeApprovalConsumptionOrCommit; CloseReopen_InvalidatesOldTargetBackupApprovalAndRetainsInactiveAudit. Head/workspace changes during held precheck reject StaleSource, zero dispatch and unconsumed approval. Actual image changes before precheck reject with WriteCount=0; change after the read conflicts at actual target CAS and fresh divergent evidence remains RecoveryRequired, not Applied. Reopen creates a new instance and old approval/backup cannot authorize it. |
| C-07 | HeldPrecheck_SharesExactOperationRejectsConflictsAndCancelBeforeDispatchWritesZero; CancellationAfterCommitAndClose_DrainsOutsideGateAndNeverPublishesLateApplied; CancelAfterActualCommitWithoutClose_BlocksNewApplyUntilReadOnlyReconciliation. Exact active request returns the same Task; conflicting ID/action or competing operation rejects. Cancel before dispatch writes zero, keeps approval unconsumed and creates no audit mutation. After actual commit, cancellation consumes approval, retains one RecoveryRequired outcome and blocks new Apply. Close shares/drains completion outside required gates; old-generation late Applied cannot become current evidence. Exact completed mutation repeats return the same existing outcome, including at capacity. |
| C-08 | UncertainCommit_RequiresReadOnlyReconcileAndPreservesOriginalFailure (lost ack/read failure/wrong identity/unchanged-cell mismatch); PositiveEchoWithoutMutation_IsNotAppliedAndFreshRevisionProofResolvesUnchanged; FailedOrLostRestore_RemainsRecoveryRequiredAndOriginalBackupNeverChanges. Acknowledgement alone never establishes Applied. Actual commit with lost acknowledgement/missing proof is RecoveryRequired with precise original evidence. Divergent unchanged cells/identity are not hidden. An echoed positive ack with actual revision 0/value 650 is not Applied. Failed/unknown Restore remains RecoveryRequired, not Restored or healthy unchanged success. |
| C-09 | RejectedPortAndDivergentReconcile_NeverBlindlyRetryOrRestore; UncertainCommit_RequiresReadOnlyReconcileAndPreservesOriginalFailure; rendered lost-ack test. Explicit fresh read-only reconciliation proves unchanged at exact before revision, candidate-matching only at the expected next revision, or divergent/unavailable. Lost-ack actual candidate proof becomes VerifiedAppliedAfterReconciliation while preserving original failure/initial evidence. Divergent/unavailable remains RecoveryRequired. No write is resent and no restore is automatic; write count stays unchanged through reconciliation. |
| C-10 | ScalarThenTableApplyAndSeparatelyApprovedRestore_VerifyTheFullActualImage; FailedOrLostRestore_RemainsRecoveryRequiredAndOriginalBackupNeverChanges. After two successful applies, a distinct fresh Restore preparation/confirmation/approval binds original backup and current revision 2. One full guarded write plus independent readback restores 650 and torque (240,300,360,350,300,180) on unchanged axes, at revision 3. Authoring/configuration/history are not rewritten. Lost-ack Restore can become VerifiedRestoredAfterReconciliation only from exact full revision/content proof. |
| C-11 | HeldBackupReadAfterClose_CannotPublishOldBackupIntoNewInstance; PendingPortFailureDuringClose_PersistsErrorAndSharesFailedCleanupCompletion; CloseReopen_InvalidatesOldTargetBackupApprovalAndRetainsInactiveAudit. Pending/late reads cannot publish a backup after close/new generation. A held real-port failure during close remains visible and repeated close shares the failed completion, while target cleanup still runs. Wrong/new instance has no old-backup restore authority. Test barriers release in finally; owned work is drained and disposal clears subscriptions on failure. |
| C-12 | DispatchedAuditLimit_IsExactly32AndExactOperationReplayConsumesNoSlot; RehearsalIsolation_ActualLiveRecordingReplayAndConfigurationRemainIsolatedFromApplyRestore; RenderedRehearsal_LostAckRecoveryAndUnitRerendersDoNotResendMutation; CompletionClockFailure_CannotLoseAnAlreadyDispatchedAuditOutcome. Exactly 32 dispatched Apply/Restore outcomes are retained; changed attempt 33 rejects before consume/write, while exact known repeat adds no slot. Preparations/command IDs retain bounded current evidence, not hidden unbounded history. Unit rerender changes no approval/read/write. Actual existing live transport/model/store-Save deltas are zero, with unchanged config/export/trace/status/archive/authoring/replay. A failed completion clock explicitly records null/error rather than losing a dispatched outcome. All 405 regressions plus 31 new cases and native workflow passed. |

## Acceptance criteria

| ID | Result | Evidence |
|---|---|---|
| AC-01 | PASSED | C-01/C-02 actual independent Simulation target/port, source-kind/applicability validation and two-read supported-image backup; no baseline/request echo substituted for readback. |
| AC-02 | PASSED | C-03..C-06 exact approval/head/backup/revision/content binding, full scalar/table/unrelated-cell results, stale/CAS/negative tests and zero-write rejected paths. |
| AC-03 | PASSED | C-07..C-11 controlled real-port idempotence/cancellation/drain/late/fault/reconciliation, original errors retained and separately approved full original Restore. |
| AC-04 | PASSED | C-12 exact 32/33 capacity, real rendered/native workflow and zero unassigned source calls; all 436 cases and all nine Release projects pass. |
| AC-05 | PASSED | Executable matrix, own post-green producer/consumer review/fixes, truthful docs/README/report, protected history/dependencies/manual workflow and cleanup preserved. |

## Commands and outcomes

Current SDK: dotnet --version -> 10.0.403 under unchanged global.json policy.
Tests remain existing xUnit v2/VSTest. No package/SDK/workload/tool was
installed, restored, updated or repaired.

Final focused, build and complete regression commands ran sequentially:

| Exact command | Exit | Result |
|---|---:|---|
| dotnet test .\src\tests\AutoForge.IntegrationTests\AutoForge.IntegrationTests.csproj --configuration Release --no-restore --filter "FullyQualifiedName~CalibrationRehearsalTests|FullyQualifiedName~RenderedRehearsal|FullyQualifiedName~RehearsalIsolation|FullyQualifiedName~CalibrationAuthoringTests" | 0 | 86 passed: 31 new rehearsal cases plus 55 accepted authoring cases; zero failed/skipped. |
| dotnet build .\src\AutoForge.slnx --configuration Release --no-restore | 0 | All nine projects/native Client; 0 warnings, 0 errors. XAML source-generation output was informational. |
| dotnet test .\src\AutoForge.slnx --configuration Release --no-build | 0 | 179 unit + 257 integration = 436 passed; zero failed/skipped. |
| git --no-pager diff --check | 0 | No whitespace errors; existing LF-to-CRLF notices for README/build guide only. |
| git --no-pager diff --exit-code -- prompts global.json Directory.Build.props Directory.Packages.props NuGet.Config src\AutoForge.Core src\AutoForge.Diagnostics src\AutoForge.Simulation src\AutoForge.Application\Features\Vehicles\Telemetry | 0 | Existing protected/history/dependency/Core/live/recording/replay tracked implementations unchanged before adding this report. New typed-port/rehearsal files are explicitly in scope. |

Per-project Release results: AutoForge.Core, AutoForge.Diagnostics,
AutoForge.Simulation, AutoForge.Application, AutoForge.Components,
AutoForge.UI, AutoForge.Client, AutoForge.UnitTests and
AutoForge.IntegrationTests all PASSED. Portable projects remain net10.0;
Client remains net10.0-windows10.0.26100.0 / win-x64.

405 baseline cases (179 unit + 226 integration) remain present and pass; this
step adds 31 integration cases without deleting/weakening baseline assertions.
The focused UI test was extended to exercise the second saved table proposal,
not only first Apply/Restore. Existing template, authoring, archive, gauge and
replay limits remain unchanged. Rehearsal adds only the explicit 32 dispatched
mutation-outcome bound per target.

Iteration evidence:

- Initial compilation failures involved generic owner type inference and one
  Razor namespace import. Both were corrected before executable results.
- The first executable focused run had 21 passes/2 failures: a test's
  post-write read-failure flag also intercepted the next operation's
  precheck after an earlier write. Fault forwarding now binds to the intended
  next dispatch count, below the real Application workflow.
- The first green run passed 23 cases. Post-green review expanded coverage
  to 31 new cases; the combined accepted-authoring selection passed 86.
- A native second-proposal selection issue was inspected with exact
  selected/current-head feedback and an actual rendered second-proposal
  event regression (passed). Fast native event/DOM sequencing rejected
  stale source without another write; explicit settled current-head selection
  then completed the real table Apply/Restore path. Native-helper null
  readiness predicates were also corrected; their errors are not claimed
  as implementation failures or successful smoke observations.
- Final focused, nine-project build and complete 436-case suite were rerun
  after source/head feedback and UI test additions. Compilation failures
  are not claimed as behavioral pre-fix reproductions.

## Native evidence versus controlled proof

The actual rebuilt Windows Client was operated through a task-owned WebView2
profile and local DevTools port 9380 with a temporary built-in Node/WebSocket
helper. No second web host, new dependency or production debug/fault feature
was added.

Normal native workflow:

1. Explicitly created the warm profile/configuration through the existing
   simulation route, retained its exact original export/fingerprint, then
   created authoring baseline and saved the 1250-rpm proposal. Rehearsal
   remained Inactive/audit 0 on Save; no implicit target or mutation.
2. Selected autoforge.simulation.calibration-rehearsal and opened an isolated
   Simulation instance. Two actual independent reads produced the verified
   supported-image backup at revision 0. Unconfirmed approval visibly rejected.
3. Confirmed/approved scalar Apply. Unit switch preserved the exact unconsumed
   approval text/identity and audit 0. One dispatch/full readback showed
   1250 rpm at revision 1, with all six original torque cells. Repeating the
   exact action returned the existing result with audit count 1.
4. Saved the table proposal and explicitly selected its current saved head.
   Fresh preparation showed only 2000-rpm torque 360->350, delta -10 N*m.
   New confirmation/approval/dispatch produced revision 2 with scalar 1250,
   that cell 350, and all unrelated cells/axes unchanged.
5. Prepared original-backup Restore separately. Its diff was table 350->360
   and scalar 1250->650. A new explicit Restore approval/dispatch plus full
   independent readback yielded revision 3 with scalar 650 and all torque
   cells (240,300,360,350,300,180) on the original six rpm axes.
6. Closed the target. Its backup was explicitly labeled inactive, not
   new-instance authority. Reopen created a different instance with audit 0,
   no old backup and no approval. Restore without a fresh backup rejected.
7. Original source export stayed byte-for-byte string-identical, fingerprint:
   sha256:v1:e8991ae139b54959ec53a4fe64b08dc9bfc03feb533496cf741f2c9f3a2342da.
   Original warm-idle parameter remained 650 rpm and original 2000-rpm torque
   remained 360 N*m. A separately opened real dynamics session stepped to
   model step 7 / 0.7 seconds and read engine speed 631.80416 rpm / Good /
   SYNTHETIC_DYNAMIC, not the rehearsal's 1250 image. This is unchanged-source
   diagnostic evidence, not performance validation of the proposal.
8. Closed that ordinary dynamics source and exercised replay/home navigation.
   Replay was Unloaded; no capture was substituted. Original Metric/Road
   preferences were restored and observed. No native unhandled error overlay
   appeared during the completed workflow.

Completed native target/backup/action evidence:

- Target instance f6c8f8226562440d84b9726e916d42a2.
- Original backup cfc96e2c5dcd4838a9d94625da35ba6c, revision 0.
- Table Apply operation 7ef765105d294289a3bcb6e9fa0be308:
  actual revision 2 / CandidateMatching / VerifiedApplied.
- Original Restore operation 0981ac75b8a7419f81c340706cf5a138:
  actual revision 3 / CandidateMatching / VerifiedRestored.
- Fresh reopened instance 5a13d4429f744d2db37362026c299b3b:
  no prior backup/approval/audit and no old restore permission.

Native inspection opened the full before/expected/actual details. Exact first
readback was scalar 1250 and torque (240,300,360,350,300,180); second was scalar
1250 and torque (240,300,350,350,300,180); Restore was scalar 650 and the
complete original tuple. Every rpm axis stayed 650,1000,2000,3200,4200,5000.

Native limitations: normal success/readiness/source feedback is not controlled
port-fault, cancellation, concurrency or 32/33-capacity proof. Those cases use
actual target forwarding plus explicit barriers in headless tests. Initial
fast automated selection caused visible stale-head rejection and a helper
DOM-readiness timeout, preserving the prior one-write state; that incomplete
attempt was closed/destroyed, not represented as restored. The second rebuilt
native session performed the entire successful backup/two-Apply/Restore/
reopen/source-isolation sequence.

Cleanup PASSED: both task-owned Client process sessions completed; only their
specific PIDs 8828 and 25884 were terminated after target/source close or page
cleanup. The task-only WebView profile/helper were removed, no task WebView
processes remained and port 9380 had no listener. Native profile/configuration/
proposal/rehearsal data were volatile only. The real app-local recordings
directory remained empty; no user archive/file or existing/default WebView
data was deleted or reset. Original user preference values were restored.

## Own post-green source-path review

Reviewed actual authoring/configuration/profile selection -> registered typed
factory -> Simulation-owned independent image -> two-read backup -> prepared
before/candidate -> confirmation/approval -> fresh precheck/source-head guard ->
actual target CAS -> independent full readback -> audit/reconciliation ->
separately approved Restore -> close/unmount/new generation.

Public entry points reviewed were target Open/ReadAsync/CommitAsync/DisposeAsync,
rehearsal NewOperationId/Open/PrepareBackup/PrepareApply/PrepareRestore/Approve/
Execute/Reconcile/Close/Dispose/Snapshot, and actual rendered controls/units/
authoring notifications. Normal, rejected, no-op, stale, uncertain, capacity,
repeat, cancellation and cleanup paths were walked against C-01..C-12.

Review fixes/additions completed within Step-10:

- After a real commit, caller cancellation now publishes RecoveryRequired
  into the still-open session, not only its audit, preventing a new Apply
  before read-only reconciliation. Close remains generation guarded.
- Immutable dispatched evidence survives completion-clock failure with an
  explicit null/error timestamp instead of losing a counted mutation outcome.
- Opening revalidates the current workspace before publication; head dispatch
  admission uses a narrow synchronous authoring guard, while target CAS covers
  later image changes. No required gate remains held across async cleanup.
- Disposal clears subscriptions even when target/port cleanup reports failure.
  Authoring-to-panel notifications marshal UI fields through the dispatcher.
- Added positive-ack-without-real-mutation, held source-head changes, actual
  cancellation after commit, failed close completion and real live/recording/
  replay coexistence tests. Original errors/initial evidence remain explicit.
- Added selected/current-head feedback and precise rejection reasons, and
  executed actual rendered second-proposal/table Apply before Restore.

Validation/eligibility precede consume/write/count commitments. Full changed
and unchanged image equality plus exact revision determines proof, never an
ack/request echo. Exact repeats cannot create another write; unknown outcomes
never silently retry/restore. Backup/approval/audit values are copied and
bounded. New instances cannot inherit authority. Application/UI do not read
private Simulation state, and no source configuration/model/authoring status/
recording/replay is mutated by rehearsal.

Affected focused/full checks were rerun after these changes, with final 86/436
passes and native complete workflow. No known unresolved defect in the
assigned exit contract remains.

## Documentation and preservation

Updated [README.md](../README.md),
[documentation index](../docs/README.md),
[architecture](../docs/architecture.md),
[build/test guide](../docs/build-and-test.md) and
[authoring contracts](../docs/calibration-authoring.md); added
[rehearsal usage/contracts](../docs/calibration-rehearsal.md).
They distinguish accepted Step-09 from Step-10 pending review, isolated typed
Simulation target from a real wire/model application, volatile supported-image
backup, single-use exact approval/CAS/readback, RecoveryRequired/read-only
reconciliation/separate Restore, bounded audit and native/control evidence.

Worktree began clean on main at 997b17f and HEAD is unchanged. Existing
prompts/state/roadmap/assignment/history/shared gate were not edited; this is
the only new prompts file. Protected instruction files were not created or
modified. The index remains empty. No new project/package/host/schema/protocol
or project-reference change, dependency/system operation, agent, automatic
handoff, staging/commit/push occurred.

Core/source template, existing DynamicsEngine/diagnostic protocols/providers/
oracles/configuration catalogue, authoring statuses/history and recording/
replay implementation remain unchanged except the explicitly scoped shared
authoring diff extraction/current-head dispatch guard. New Diagnostics and
Simulation files implement the narrow isolated target only.
Source/tests remain under src/src/tests; docs remain under docs. The separately
disclosed recording navigation/refresh issue was not modified.

Out of scope remains physical programming/driver/firmware blocks, dynamics
application/performance reruns, durable/full-device calibration backups/audit,
AI/runbooks, new templates/units/offsets and unrelated cleanup.

STOP.