174 lines
10 KiB
Markdown
174 lines
10 KiB
Markdown
# Step-10A - Close ownership during pending rehearsal reopen
|
|
|
|
## STEP IDENTIFIER
|
|
|
|
Step-10A, single-issue correction of existing Step-10 C-07/C-11 / AC-03.
|
|
Step-10 is NOT ACCEPTED. Step-09 and earlier accepted work remain accepted.
|
|
This is the sole active assignment; Step-11 local AI remains blocked.
|
|
|
|
## STEP TITLE
|
|
|
|
Bind close/disposal completion to the current rehearsal lifetime so a pending
|
|
reopen cannot publish a new target after Close or Dispose has finished.
|
|
|
|
## OBJECTIVE
|
|
|
|
Fix one current-owner/close-task lifetime issue. Preserve the supported target,
|
|
backup, approval, source-head/CAS, fresh verification/recovery/Restore and bounded
|
|
audit. Do not redesign programming or implement new features.
|
|
|
|
Read [STATE.md](STATE.md), original [Step-10](Step-10.md), its preserved
|
|
[report](Step-10-Report.md) and [WORKER-QUALITY-GATE.md](WORKER-QUALITY-GATE.md).
|
|
Reproduce the actual interleaving, fix and self-review inside this assignment,
|
|
write `prompts/Step-10A-Report.md`, and STOP.
|
|
|
|
## ARCHITECTURAL CONTEXT
|
|
|
|
Keep all nine projects, one Client, Simulation-owned real target, typed
|
|
Diagnostics ports and existing Application/UI rehearsal ownership.
|
|
No project/package/host, new protocol, general lifetime framework, physical
|
|
driver or model/source mutation. Source/tests stay under `src`, tests under
|
|
`src/tests`. Original in-memory supported-image and safety limits remain.
|
|
|
|
## CURRENT IMPLEMENTATION STATE
|
|
|
|
Worker-reported Step-10 evidence: 179 unit + 257 integration passes (436 total,
|
|
zero failed/skipped), clean full nine-project Release build and native complete
|
|
backup/scalar/table Apply/Restore/reopen/source-isolation checks. Preserve all
|
|
405 prior cases and 31 additions plus their original reports.
|
|
|
|
One original lifetime requirement remains in
|
|
[CalibrationRehearsalSession](../src/AutoForge.Application/Features/Vehicles/Calibration/CalibrationRehearsalSession.cs):
|
|
|
|
- CloseAsync (around line 444) returns any non-null _closeTask immediately.
|
|
- Completed Close retains that task. New Open clears it only after successful
|
|
factory creation and current-owner publication (around line 90).
|
|
- A new admitted Open can therefore be pending while Close returns the previous
|
|
lifetime's already-completed task without cancellation/generation change/drain.
|
|
- Dispose sets _disposed but also returns via that prior close completion;
|
|
EnsureCurrent permits Closed for an opening owner and does not test _disposed.
|
|
The pending Open can then publish Ready/new target after disposal returned.
|
|
|
|
Existing tests/native checks fully await reopen before closing again; held-read
|
|
and post-commit tests do not force this factory-before-publication window.
|
|
This is source-inspection evidence, not an orchestrator-executed reproduction.
|
|
Reinspect Git and preserve existing worker changes/history before editing.
|
|
|
|
## REQUIRED IMPLEMENTATION
|
|
|
|
Make the smallest sound coordination/ordering change so a new admitted target
|
|
lifetime cannot reuse a previous lifetime's completed or failed close task.
|
|
Current Close/Dispose must invalidate/cancel its actual pending owner and wait
|
|
for that owner's cleanup before returning; late factory results cannot publish.
|
|
|
|
Retain one shared close completion for repeated callers within the same lifetime.
|
|
Bind it safely before competing callers can start cleanup twice. Do not publish
|
|
success before current work drains, clear it only after successful publication,
|
|
or discard the existing single-owner/cancellation/error contract.
|
|
|
|
Preserve valid sequential reopen, failed-open state, old inactive evidence,
|
|
late-registration/operation rejection, and exact target disposal. A fully disposed
|
|
page session remains unusable; successful Close alone may permit explicit fresh
|
|
Open. Old approvals/backups never authorize a new instance.
|
|
No wait may hold a gate needed by cleanup.
|
|
|
|
### Frozen corrective matrix
|
|
|
|
| ID | Input/precondition | Required result |
|
|
|---|---|---|
|
|
| C-01 | Normal close/repeated close and sequential explicit reopen | Existing target closes once; same-lifetime repeated Close shares completion; reopen gets a distinct instance/revision-zero state without old backup/approval |
|
|
| C-02 | Prior Close completed; actual factory is held during new admitted Open; competing Close arrives | New Close does not return the old completion or finish while Open/cleanup is held. It cancels/invalidates current Open; after release, created target is disposed exactly once and no Ready/current target is published. |
|
|
| C-03 | Same pending reopen, then Dispose/page unmount | Disposal drains the actual opening owner/target and cannot return through the prior close task. No late Ready/backup/approval publication; disposed session rejects further operations. |
|
|
| C-04 | Earlier Close failed or pending Open itself fails; current close callers/cleanup also compete | Current lifetime gets its own shared completion/error, not a replay of stale failure. Cleanup executes once, errors remain explicit, rejected opens preserve required inactive evidence and later valid sequential behavior. |
|
|
| C-05 | Original target/backup/approval/CAS/readback/reconcile/Restore/audit/units/source/native contracts | All 436 baseline cases and meaningful new regressions pass, limits/data semantics preserved, no existing-model/physical side effects or new AI work |
|
|
|
|
## FILES OR PROJECTS EXPECTED TO CHANGE
|
|
|
|
Existing rehearsal-session open/close/disposal coordination and, only if a
|
|
real coupled assertion requires it, page cleanup. Focused integration tests with
|
|
a test-only factory/target barrier wrapper and directly related lifecycle/docs/
|
|
README/verification record. No programming/target/approval/port redesign.
|
|
Only `prompts/Step-10A-Report.md` under `prompts`; no assignment, roadmap/state,
|
|
gate, previous report or protected-file edit.
|
|
|
|
## INTERFACE AND DEPENDENCY REQUIREMENTS
|
|
|
|
Preserve nine projects/references, actual Simulation target state, exact
|
|
source/instance/revision/head/backup/approval binding, defensive full images,
|
|
single owner, volatile audit limit 32, unknown/reconcile/Restore semantics and
|
|
unchanged diagnostics/dynamics/recording/replay/source configurations.
|
|
No hardware/model write, new schema/unit/template, oracle, silent fallback,
|
|
early close-success or error-swallowing shortcut.
|
|
No dependency/system/workload install/update/repair/rollback, staging/commit/
|
|
push or destructive Git. Preserve existing dirty work and protected history.
|
|
|
|
## TESTING REQUIREMENTS
|
|
|
|
1. Establish C-02/C-03 using a controlled wrapper forwarding the actual
|
|
SimulatedCalibrationTargetFactory. Hold the second factory creation/return
|
|
after Open admission but before publication. Run the held synchronous Open
|
|
in a task-owned concurrent test so the competing Close/Dispose can execute.
|
|
Do not mock away the rehearsal service or use a production race selector.
|
|
2. Record actual pre-fix assertions: prior close completion is reused/finishes
|
|
without current drainage, then released Open publishes an active target after
|
|
closure/disposal. This must be behavior evidence, not a compilation failure.
|
|
If observed behavior differs, report exact results rather than inventing a
|
|
failure. Deadlines are cleanup safety guards, not timing-race proof.
|
|
3. After the fix, assert current-close completion identity, cancellation/drain,
|
|
no late publication, actual created target's dispose count, retained inactive
|
|
evidence and further-operation rejection. Exercise both Close and Dispose.
|
|
4. Include a prior failed-close case, failing/rejected reopen and repeated current
|
|
close callers; preserve visible current cleanup errors and valid normal reopen.
|
|
5. Release every barrier and drain opening/closing work in finally before
|
|
disposing providers/observers. No stranded workers, sleeps/polling or GC/memory
|
|
benchmarks as correctness proof.
|
|
|
|
Run focused cases, then sequentially:
|
|
|
|
- `dotnet build .\src\AutoForge.slnx --configuration Release --no-restore`
|
|
- `dotnet test .\src\AutoForge.slnx --configuration Release --no-build`
|
|
|
|
Preserve 436 baseline cases (179 unit, 257 integration) plus meaningful new
|
|
assertions. Record exact commands/exits/warnings/per-project counts; build all
|
|
nine projects/native Client. Install/restore nothing absent a genuine chosen-
|
|
command missing dependency.
|
|
|
|
Native recheck: normal isolated target/backup/Apply/Restore/Close/reopen, source/
|
|
unit isolation and calibration route close/re-entry. The pending-factory race is
|
|
controlled test proof, not a human-timed native claim. Clean only exact task-owned
|
|
profiles/artifacts; preserve unrelated files/preferences.
|
|
|
|
## DOCUMENTATION REQUIREMENTS
|
|
|
|
Align current target-lifetime close completion/cancellation/drain and matching
|
|
evidence with actual behavior. Preserve original Step-10 programming/native
|
|
results unchanged; no new backup durability or physical/model claim.
|
|
Step-10 remains pending review; Step-11 is not implemented or assigned.
|
|
|
|
## ACCEPTANCE CRITERIA
|
|
|
|
| ID | Criterion | Evidence |
|
|
|---|---|---|
|
|
| AC-01 | C-01..C-03 current Close/Dispose drains pending reopen with no old completion reuse or late target publication | Actual safely cleaned pre-fix and controlled post-fix factory/target/cancellation assertions |
|
|
| AC-02 | C-04 same-lifetime shared completion, current errors, failed-open/close and valid sequential reopen preserved | Completion identity/dispose-count/error/state tests and source-path ordering review |
|
|
| AC-03 | C-05 original 436 regressions, new cases, full Release/native build and required baseline pass | Exact complete worker results and native/control distinction |
|
|
| AC-04 | Original scope/history/protection/docs/self-review/report/manual gate preserved | Own post-green source-path review and `prompts/Step-10A-Report.md` |
|
|
|
|
## OUT-OF-SCOPE WORK
|
|
|
|
Programming/approval/backup/recovery redesign, target/port/model/physics changes,
|
|
new durable storage/schema/limits/unit family, local AI/runbooks, hardware,
|
|
new project/package/host and unrelated cleanup. No future assignment, agents,
|
|
automatic handoff, orchestration/shared-gate edit, staging, commit or push.
|
|
|
|
## REPORTING REQUIREMENTS
|
|
|
|
Save `prompts/Step-10A-Report.md` entirely inside exactly one plain triple-backtick
|
|
fence, no language tag/outside text/nested fences. Include identifier/title/status,
|
|
functions/files/interfaces, C-01..C-05/AC-01..AC-04 mapping, actual pre/post
|
|
barrier/completion/state/target-disposal results, commands/exits/warnings/
|
|
per-project counts, native versus controlled coverage, docs/README, own post-
|
|
green source-path self-review, limitations/deviations/blockers and preservation.
|
|
COMPLETE requires all assigned checks; otherwise report INCOMPLETE/BLOCKED with
|
|
the precise unmet criterion. Save and STOP; do not begin Step-11.
|