314 lines
22 KiB
Markdown
314 lines
22 KiB
Markdown
# Step-10 - Verified simulated programming and recovery
|
|
|
|
## STEP IDENTIFIER
|
|
|
|
Step-10. Step-09 was accepted on 2026-10-30 with no corrective assignment.
|
|
This is the sole active implementation assignment. Step-11 local AI is blocked.
|
|
|
|
## STEP TITLE
|
|
|
|
Rehearse approved logical calibration writes against an isolated simulation
|
|
image, verifying backup, changed/unchanged readback and separately approved restore.
|
|
|
|
## OBJECTIVE
|
|
|
|
One user outcome: take a saved authoring proposal through an explicit simulated
|
|
target/backup/approval/write/readback/restore workflow with truthful failure states.
|
|
One primary new contract: a guarded target mutation bound to an exact image
|
|
revision and immutable approval, not a change to the authoring configuration.
|
|
|
|
Read [STATE.md](STATE.md), [ROADMAP.md](ROADMAP.md),
|
|
[authoring contracts](../docs/calibration-authoring.md) and
|
|
[WORKER-QUALITY-GATE.md](WORKER-QUALITY-GATE.md). Make the frozen matrix executable
|
|
before coding, self-review after first green, write `prompts/Step-10-Report.md`,
|
|
and STOP. Do not begin local AI or any physical operation.
|
|
|
|
## ARCHITECTURAL CONTEXT
|
|
|
|
Keep all nine projects, one Client and generic Components. Core holds reusable
|
|
calibration values/definitions; Diagnostics exposes a narrow typed simulated
|
|
programming target port; Simulation owns its real mutable target image.
|
|
Application owns backup/approval/command/reconciliation/verification and UI owns
|
|
interaction. Client composes the explicit simulation provider.
|
|
|
|
Application/UI must not reference Simulation implementation, read its private
|
|
state/oracle, or manufacture target readback from proposal/request/configuration.
|
|
Use logical scalar/table operations, not a new wire protocol, binary offset or
|
|
unrestricted command channel. No new project/package/host or generic programming/
|
|
workflow framework. Source/tests stay under `src`, tests under `src/tests`.
|
|
|
|
## CURRENT IMPLEMENTATION STATE
|
|
|
|
Accepted authoring offers one immutable source-bound workspace, Baseline/Proposed
|
|
revisions, exact scalar/table values/axes/diffs and guarded head commits.
|
|
Worker baseline: 179 unit + 226 integration passes (405 total, zero failed/
|
|
skipped), clean nine-project Release build and native authoring checks.
|
|
The orchestrator did not run them. No programming target/service exists yet.
|
|
|
|
Use the actual [authoring service](../src/AutoForge.Application/Features/Vehicles/Calibration/CalibrationAuthoringService.cs),
|
|
[calibration contracts](../src/AutoForge.Core/Calibration/SyntheticEngineCalibration.cs)
|
|
and [configuration service](../src/AutoForge.Application/Features/Vehicles/Simulation/DynamicsConfigurationService.cs).
|
|
The supported image is exactly `engine.warm-idle-target` (rpm) and
|
|
`engine.torque-curve` (fixed rpm axis, N*m cells), with existing template validation.
|
|
|
|
The source warm baseline is 650 rpm; the saved proposal can be 1250 rpm and
|
|
360->350 N*m at 2000 rpm. Those are synthetic values, not manufacturer data.
|
|
A configuration-derived authoring baseline is not the target backup. Inspect
|
|
Git/prior art and preserve accepted behavior, dirty work and historical reports.
|
|
|
|
## REQUIRED IMPLEMENTATION
|
|
|
|
### Frozen contract matrix
|
|
|
|
| ID | Input/precondition | Required result |
|
|
|---|---|---|
|
|
| C-01 | Explicit current supported authoring workspace/config/module plus Simulation provider | Open one fresh isolated target instance at image revision 0, with complete supported source values. No implicit open/write; physical/replay/wrong-provider/source rejects before target creation or mutation. |
|
|
| C-02 | Read target, create original backup and verify with a second independent read | Identity/revision/shape/axes/units/values match exactly; immutable verified volatile backup covers both keys/all cells. Wrong/incomplete/mismatched read rejects before approval; baseline is not used as a fake response. |
|
|
| C-03 | Prepare/approve immutable current proposal 650->1250, then Apply | Display exact target-to-proposal diff; approval binds target/source/definition, actual before image/revision, proposal/head and action. Re-read/CAS before dispatch, one write, fresh readback; scalar=1250, every torque cell unchanged, authoring baseline/config remain 650. |
|
|
| C-04 | Next saved proposal additionally changes 2000-rpm torque 360->350 | New approval binds fresh target revision; exactly that cell changes, axes and all other values stay intact; full readback equality is checked, not just acknowledgement or selected cell. |
|
|
| C-05 | Missing/mismatched backup/confirmation/token/proposal/head/source/target revision, no-op proposal, invalid candidate or wrong target kind | Typed visible rejection before approval consumption/write/target mutation; current backup/image/approval/history remain intact except error notification. No auto-rebase, broad writes or inferred authority. |
|
|
| C-06 | Head/workspace/target identity or image changes after approval but before dispatch | Rejected stale approval with zero writes; exact accepted source/proposal/before-image cannot silently follow current data. Reopen creates a new instance and invalidates old approvals/backups. |
|
|
| C-07 | Same operation requested twice; competing operation; cancellation/close before or after dispatch | No second mutation or lost ownership. Exact repeated operation shares/returns its outcome; conflicts reject before mutation. Cancel-before-dispatch writes zero; once dispatch may have happened, outcome is not falsely labeled unchanged/success. |
|
|
| C-08 | Negative acknowledgement, dropped acknowledgement/exception after actual commit, mismatched fresh readback or read failure | Full fresh readback determines verification. Never label Applied from acknowledgement alone. Unverified/uncertain mutation remains visible RecoveryRequired with reason/evidence; no blind resend or automatic restore. |
|
|
| C-09 | Explicit reconcile after an uncertain outcome | Read-only exact current-image evidence identifies unchanged, candidate-matching or divergent/unavailable state; no write or stale cached proof. Only exact target/revision/content evidence may resolve verification; original uncertainty remains in the operation record. |
|
|
| C-10 | Prepare and explicitly approve restore of original backup on same live rehearsal target | Bind fresh current revision/image and original verified backup; one guarded restore and full independent readback. Original 650/360 values and all other cells/axes restored, revision advances; no authoring/history/config rewrite. |
|
|
| C-11 | Wrong-target backup, failed/unknown restore, pending dispose/late read or failed test | No restore permission, false Restored result or old-generation publication; errors persist, owner/target cleanup drains outside required gates and allows safe close. Barriers/resources released in finally. |
|
|
| C-12 | Bounded audit/results, real UI/unit and coexistence paths, full verification | At most 32 dispatched mutation outcomes per target session; exact boundary rejects a new attempt before write. All 405 cases plus new coverage pass; real simulation port and native UI work; no existing diagnostics/model/archive/replay or physical side effects. |
|
|
|
|
### A. Explicit isolated simulation target, not a dynamics application
|
|
|
|
Introduce one explicit simulation-only provider with a unique identifier such as
|
|
`autoforge.simulation.calibration-rehearsal`. Opening requires the exact selected
|
|
configuration/profile revision and its actual EngineModuleIdentifier/definition.
|
|
Reject PhysicalHardware, RecordedReplay and any unregistered/mismatched provider
|
|
or descriptor; metadata/capability claims alone cannot authorize a write.
|
|
|
|
The target owns an independently stored immutable-at-read mutable-at-commit
|
|
supported image, seeded once from the selected configuration and validated
|
|
template. Thereafter Read returns actual target state, and Write/Restore use
|
|
compare-and-swap against the exact instance/image revision and full validated
|
|
candidate. Revision starts 0 and increments once per successful changed commit.
|
|
Validation/conflict/cancellation before commit leaves the image unchanged.
|
|
|
|
Preserve unique instance identity across all reads. Each read defensively copies
|
|
both supported keys, axis, units and cells. The typed port supplies explicit
|
|
outcomes/errors, not a success-shaped fallback. Actual Simulation implementation
|
|
is exercised in normal/failure tests; test-only fault forwarding may simulate
|
|
lost replies/divergent readback below Application without mocking the workflow.
|
|
|
|
This target is an isolated programming rehearsal, not a live dynamics session.
|
|
Do not modify `DynamicsConfiguration`, its fingerprint/catalogue, an existing
|
|
DynamicsEngine, signal source, diagnostics schema or profile calibration identity.
|
|
No model telemetry may claim 1250 rpm merely because the rehearsal image stores
|
|
that number. Wiring to a fresh run/functional performance proof is later work.
|
|
|
|
Target/backup/results are process-memory only. Close destroys that target;
|
|
reopen recreates source values under a new identity. No persist-after-close,
|
|
crash recovery, firmware block transfer or real-device backup claim is assigned.
|
|
|
|
### B. Independent supported-image backup and explicit approval
|
|
|
|
Prepare the original target backup once before the first mutation. Read through
|
|
the real target port, validate identity/applicability/revision/complete supported
|
|
shape/values and compare against a second independent read of that same target.
|
|
If either differs or is unavailable, do not publish VerifiedBackup/Ready status.
|
|
Copy the actual observed image; never call an authoring baseline a verified read.
|
|
|
|
The backup is explicitly "Verified in-memory backup of supported simulation
|
|
image": one scalar plus the complete fixed-axis table, not an entire ECU.
|
|
Keep its target instance/source/definition/image revision and immutable contents.
|
|
It remains the original backup across multiple writes on that instance.
|
|
|
|
Prepare a candidate only from an immutable saved **current Proposed head** of
|
|
the accepted authoring workspace, with exact source applicability. Read current
|
|
target state to form the actual before-image and precise target-to-candidate diff.
|
|
Different head/workspace/source invalidates pending apply approval; do not replace
|
|
it silently. An identical target/candidate is a visible no-op rejection, not a
|
|
new Applied or verified mutation.
|
|
|
|
Explicit user confirmation produces a single-use opaque approval bound to:
|
|
action Apply or Restore, target provider/kind/instance/source/definition,
|
|
verified original backup identity, expected current image revision/contents,
|
|
exact candidate values and selected proposal/workspace/head (for Apply).
|
|
Authoring revisions themselves remain Baseline/Proposed, not Approved/Applied.
|
|
This local approval records a deliberate rehearsal action, not cryptographic
|
|
authorization, manufacturer permission or a physical-write capability.
|
|
|
|
Before dispatch, revalidate approval, source/head and a fresh target read against
|
|
the approved before-image/revision. The target also atomically compares its actual
|
|
revision at commit so a change after that read cannot slip through.
|
|
Never consume approval or count a dispatched result before all preconditions
|
|
pass. Once dispatch begins, prevent token reuse; if cancellation loses certainty,
|
|
do not re-enable the same approval as though no write happened.
|
|
|
|
### C. Fresh verification, uncertain outcomes and separately approved restore
|
|
|
|
One operation owner serializes target preparation/mutation/reconciliation/close.
|
|
Guard eligibility before state changes. Commands carry an opaque operation ID;
|
|
repeating the exact active/completed request shares/returns that result rather
|
|
than issuing another write. Reusing an ID with different inputs rejects.
|
|
Conflicting actions while work/drain is pending reject visibly; no gate is held
|
|
across an await needed by cleanup. Close cancels and drains with a shared
|
|
completion/generation guard; no stale success may publish into a new target.
|
|
|
|
After mutation dispatch, request an independent full Read. Compare target
|
|
instance/source/definition/revision, both keys, units, axes and every changed/
|
|
unchanged cell to the exact expected image. A positive acknowledgement or
|
|
echoed candidate is not verification. Keep acknowledgement versus readback
|
|
separate in the result; do not hide protocol/port/readback errors.
|
|
|
|
If dispatch may have committed but fresh proof is missing/divergent, label
|
|
RecoveryRequired/Unknown with precise actual evidence and block new Apply.
|
|
Never retry a write or restore automatically. Explicit Reconcile is read-only:
|
|
compare a fresh complete image to approved before/after plus expected revision.
|
|
Classify unchanged/candidate-matching/divergent/unavailable honestly. Exact
|
|
identity/revision/content proof may establish VerifiedAppliedAfterReconciliation;
|
|
preserve the original lost-ack/verification failure in audit. Divergence never
|
|
becomes success merely because one requested value matches.
|
|
|
|
Restore is a separate prepared/confirmed operation using the immutable original
|
|
backup of that same target instance/source/definition. Read fresh current state,
|
|
bind its revision in a new restore approval and use the same atomic CAS/full
|
|
readback rules. Restore must work after multiple successful writes; it restores
|
|
the original supported values, not the author's latest proposal. Current revision
|
|
advances; restored value equality does not pretend time/version went backwards.
|
|
Wrong/closed/new instance or invalid backup rejects, and failed/uncertain restore
|
|
retains RecoveryRequired rather than a healthy completion.
|
|
|
|
Preserve a bounded immutable result/audit list in the owning rehearsal session:
|
|
at most 32 **dispatched mutation outcomes** (Apply/Restore, successful or uncertain).
|
|
At capacity reject a new dispatch before consuming approval/write; exact operation
|
|
replays still return their existing result. Preparation/reconciliation update
|
|
bounded current evidence, not a hidden unbounded history.
|
|
Include operation/action, proposal/head and target/backup/revision identities,
|
|
approval, full before/expected/actual evidence, acknowledgement, verification/
|
|
recovery status/error and explicit timestamps. This audit is volatile/local,
|
|
not a new disk format or an external security attestation.
|
|
|
|
### D. Actual UI, provenance and existing source isolation
|
|
|
|
Extend the existing calibration area or add a clearly named rehearsal route.
|
|
Use real Application services and the Simulation target provider composed by
|
|
Client. Explicitly open a target, read/prepare backup/proposal, inspect exact
|
|
diff/source/preconditions, confirm Apply, inspect separate acknowledgement/
|
|
readback, reconcile if required, prepare/confirm Restore and close.
|
|
|
|
Show synthetic/isolated/process-memory scope prominently, current target instance/
|
|
revision, original backup coverage, proposal/head, pending/uncertain/error status
|
|
and bounded audit. Never call authoring source metadata a verified ECU identity.
|
|
No implicit programming on proposal Save, page entry, unit switch or render.
|
|
Unconfirmed/rejected actions leave real target and saved authoring data unchanged.
|
|
|
|
Use existing display-unit conversion for human-facing torque; programming and
|
|
audit compare canonical rpm/N*m with exact fixed axes. Unit changes cannot mutate
|
|
candidate/approval/before-image or dispatch commands.
|
|
Old live diagnostics/dynamics/recording/replay remain separate; merely opening
|
|
the rehearsal cannot connect/reset/stop or rewrite them.
|
|
A closed rehearsal's immutable backup/result can remain inspectable as inactive
|
|
evidence, but cannot authorize a new target. Reset/new rehearsal is explicit.
|
|
|
|
## FILES OR PROJECTS EXPECTED TO CHANGE
|
|
|
|
Narrow Core evidence/target-value contracts if needed, typed Diagnostics target
|
|
ports, Simulation-owned rehearsal state, Application guarded workflow/readback/
|
|
audit, calibration UI/Client DI, focused tests and related README/docs.
|
|
No existing dynamics model/wire/configuration/schema or authoring status rewrite.
|
|
No new project/package/host or private oracle exposed to Application/UI.
|
|
Under `prompts`, create only `Step-10-Report.md`.
|
|
|
|
## INTERFACE AND DEPENDENCY REQUIREMENTS
|
|
|
|
Preserve nine projects/references, one Client, pure Components, accepted exact
|
|
source/template/unit/head/value validation, immutable configurations/archives,
|
|
recording/replay and lifetime/clock semantics. No physical provider implementation,
|
|
unrestricted hardware command, emissions/safety/security bypass or inferred
|
|
write permission. Simulation-only actions grant no authority to physical targets.
|
|
No broad catch/silent failure/false backup/ack-only verification/automatic restore.
|
|
Do not fix the separately disclosed recording navigation/refresh issue here.
|
|
No dependency/system/workload install/update/repair/rollback, staging/commit/push
|
|
or destructive Git. Preserve protected/history/orchestration files and dirty work.
|
|
|
|
## TESTING REQUIREMENTS
|
|
|
|
Map C-01..C-12 to meaningful named tests before handoff:
|
|
|
|
- Real configuration/profile/authoring plus actual Simulation target reads.
|
|
Verify two independent backup reads, complete defensive images, explicit
|
|
target/kind/source/definition validation and missing/corrupted reads.
|
|
- Apply scalar 650->1250 with all torque cells unchanged; second proposal changes
|
|
only 2000-rpm torque 360->350; full changed/unrelated readback and separately
|
|
approved original Restore recover 650/360 plus every other value.
|
|
- Independent invalid source/head/token/revision/shape/unit/value vectors;
|
|
stale mutation between precheck and target CAS; exact prior-state/write-count
|
|
assertions. Rejected calls and unit switches cannot consume an approval.
|
|
- Faults injected below the real workflow: rejected before commit, commit then
|
|
lost ack/cancel, fresh read failure, wrong readback/target identity, divergent
|
|
unchanged cell and restore failure. Read-only reconciliation proof uses actual
|
|
target values/revision, not a mocked successful service.
|
|
- Controlled pending-operation/drain/close/late-publication, same operation ID,
|
|
conflicting requests and bounded 32/33 result capacity. Barriers establish
|
|
interleavings; no sleeps/polling/stress timing as correctness proof. Release
|
|
resources in finally and await owned work.
|
|
- Real rendered backup/approval/apply/reconcile/restore/invalid actions, safe
|
|
error/status/unit presentation and real diagnostics/dynamics/recording/replay
|
|
coexistence with zero unassigned source/model/store writes.
|
|
|
|
Run focused cases, then sequentially:
|
|
|
|
- `dotnet build .\src\AutoForge.slnx --configuration Release --no-restore`
|
|
- `dotnet test .\src\AutoForge.slnx --configuration Release --no-build`
|
|
|
|
Preserve 405 baseline cases (179 unit, 226 integration) plus meaningful new
|
|
coverage. Map necessary UI-only assertion changes without deleting safety/
|
|
error/source checks. Build all nine projects/native Client. Install/restore
|
|
nothing absent a genuine chosen-command missing dependency.
|
|
|
|
Native smoke on rebuilt Client: explicitly create source/proposals, open isolated
|
|
target, prepare verified volatile backup, approve/apply scalar then table edit,
|
|
inspect full readback/audit, explicitly approve/verify original Restore, close/
|
|
reopen and confirm new-instance/no-old-approval behavior. Verify original
|
|
configuration/live source remains unchanged and old routes/unit preferences work.
|
|
Native normal success is not controlled port/uncertain/race fault proof.
|
|
Clean only exact task-owned profiles/artifacts; never reset unrelated app data.
|
|
|
|
## DOCUMENTATION REQUIREMENTS
|
|
|
|
Update README/index/architecture/build guide and rehearsal usage/contracts:
|
|
isolated Simulation typed target (not a new wire/real driver), supported-image
|
|
volatile backup coverage, approval/source/CAS/single-use operation semantics,
|
|
fresh readback/uncertain/reconcile/approved Restore, bounded audit and actual
|
|
normal/control evidence. Step-09 is accepted; Step-10 remains pending manual
|
|
review. No crash durability, model application, complete ECU backup, tested
|
|
performance, manufacturer compatibility or physical programming is claimed.
|
|
|
|
## ACCEPTANCE CRITERIA
|
|
|
|
| ID | Criterion | Evidence |
|
|
|---|---|---|
|
|
| AC-01 | C-01/C-02 actual isolated simulation target, source-kind/applicability gates and independent supported-image backup | Real target/config/port tests with complete defensive reads and no fake source echo |
|
|
| AC-02 | C-03..C-06 exact immutable approval/head/backup/revision and atomic validated mutation | Exact scalar/table/unrelated-value results, stale/CAS/negative vectors and zero-write rejected actions |
|
|
| AC-03 | C-07..C-11 one operation owner, fresh verification/unknown/reconciliation and separately approved Restore | Controlled real-port/lifetime/idempotence/fault cases and full original-image readback |
|
|
| AC-04 | C-12 bounded audit, real UI/native workflow/source isolation, 405 regressions and full Release build | Exact 32/33/no-call/state assertions, native/control distinction and worker commands/results |
|
|
| AC-05 | Matrix/self-review/docs/README/history/protection/manual gate accurately describe implemented limits | Own post-green source-path review, named executed evidence and `prompts/Step-10-Report.md` |
|
|
|
|
## OUT-OF-SCOPE WORK
|
|
|
|
Physical programming/driver/protocol/firmware blocks, dynamics application or
|
|
performance reruns, durable calibration/backup/audit format/storage, AI/runbooks,
|
|
new template/unit family, arbitrary offsets/commands, new package/project/host
|
|
and unrelated cleanup. No future assignment, agents, automatic handoff,
|
|
orchestration/shared-gate edit, staging, commit or push.
|
|
|
|
## REPORTING REQUIREMENTS
|
|
|
|
Save `prompts/Step-10-Report.md` wholly inside exactly one plain triple-backtick
|
|
fence, no language tag/outside text/nested fences. Include identifier/title/status,
|
|
functions/files/interfaces, C-01..C-12/AC-01..AC-05 matrix with named executed
|
|
evidence, exact backup/approval/write/readback/unknown/reconcile/restore/negative/
|
|
owner/audit outcomes and source-isolation counts, commands/exits/warnings/
|
|
per-project counts, native versus controlled coverage, docs/README, own
|
|
post-green source-path self-review, limitations/deviations/blockers and
|
|
preservation review. COMPLETE requires all assigned checks; otherwise report
|
|
INCOMPLETE/BLOCKED with the precise unmet criterion.
|
|
Save and STOP; do not begin Step-11.
|