--- story: E07-S02 owner: codebuff status: done started: 2026-11-10 completed: 2026-11-10 depends-on: [E07-S01, E04-S01] --- # E07-S02 Claim ## Intended change Two launchers, one shared implementation: `scripts/launch-editor.ps1` and `scripts/launch-compiler.ps1`. Both take an exclusive lock beside the writable image, wait for the emulator to exit and the image to flush, and refuse a second writable session. D151 moves the editor to the target machine: the launcher copies `../vim/vim-improved.d81`, writes `../vim/vim128.prg` into the copy as `vim128`, starts `x128` in 80-column mode, and autostarts the editor **from that disk**. `docs/editor-workflow.md` states the order, stale-lock recovery and the one-writable-session rule. ## File area - `scripts/lib/Nova128Launcher.psm1` (new): session lock, flush wait, `Add-Nova128DiskFile`, `Invoke-Nova128Emulator` (80-column and disk-autostart support, VDC/VIC-II screenshot choice) - `scripts/launch-editor.ps1`, `scripts/launch-compiler.ps1` (new) - `tests/disk/launchers.tests.ps1` (new) - `docs/editor-workflow.md` (new), `docs/decisions.md` (D148, D151), `docs/architecture.md` (ยง10) - `planning/claims/E07-S02.md` - generated files under `build/` ## Acceptance evidence - [x] Editor launcher uses `x128` in 80-column mode and autostarts the C128 Vim: `scripts/launch-editor.ps1` defaults to `../vim/vim128.prg`, copies `../vim/vim-improved.d81` to `build/newlang-edit.d81`, writes the editor into the copy as `vim128`, and autostarts `work.d81:vim128` in `x128 -80col` from the image's folder. `tests/disk/launchers.tests.ps1` runs it against a copy of the fixture disk, asserts the emulator exits, the session lock is released, the image stays writable, and `vim128` is on the session disk. - [x] Compiler launcher uses `x128` and autostarts the compiler: it defaults to `build/n128c.prg`, prepares `build/newlang-dev.d81` (copy plus injection) unless `-SkipPrepare`, and autostarts it in `x128`; the test exercises the same sequence with `-SkipPrepare` on a disposable image. - [x] Launchers wait for process/image flush before returning: the shared `Exit-Nova128ImageSession` waits for emulator exit and `Wait-Nova128ImageFlush` reopens the image exclusively with retries; the test holds the lock and asserts refusal, then asserts the image is reopenable immediately after each launcher returns. - [x] Documentation and warnings prohibit simultaneous writable attachment: `docs/editor-workflow.md` and the launcher banners state that only one writable session may exist and that the previous session must be closed before editing or inspecting the disk; the lock enforces it. ## Coordination notes - Depends on E07-S01 (image preparation) and E04-S01 (container/autostart); both are complete. The compiler launcher reuses `prepare-disk.ps1`. - D151 changed the editor default from `x64sc` to the C128 build at the user's request. The C64 editor is still reachable with `-Emulator x64sc`, but its program lives inside `vim-improved.d81`, so `-EditorPrg` must name an extracted `vim`. - Autostarting the editor from the session disk is required, not cosmetic: a host-loaded copy has no device number from its load, and `vim128` then reports `written` while the image never receives the file. - VICE's `x64sc` plain `-exitscreenshot` is the VIC-II screen; `x128` in 80-column mode needs the same plain option (VDC), while `-exitscreenshotvicii` captures a blank 40-column screen. ## Work log - The lock test first failed with "cannot access the lock file" instead of a lock message: a live holder opens the file without sharing, so reading it can fail. An unreadable lock now counts as held. - The screenshot assertion failed for `x64sc` because `-exitscreenshotvicii` is the `x128` spelling; the option is now chosen by emulator and display mode. - The compiler test passed no disk, so the launcher correctly refused with "disk image not found"; the test now copies its source image first. - D151: the C128 editor was validated at the prompt, then its saves failed in three distinct ways (1541 drive type, true-drive emulation, host autostart) before the disk-autostart form worked. ## Completion - Tests run: `tests/disk/launchers.tests.ps1`, `tests/disk/vim-roundtrip.tests.ps1`, `git diff --check`. - Results: `launcher tests passed` covering the disk copy with `vim128` injected, lock refusal, flush wait, and both x128 sessions; the source disk stayed `0FF83A621B59B312F1BAE9F1D0785421500D22FD00F833A9CA918EBCA7105983`. - Remaining risks: the lock is advisory and PID-based, so a recycled PID in the window before the lock is read is treated as alive; a launcher killed from outside leaves a lock for the next run to replace; and the flush wait assumes VICE exits cleanly, which cannot be forced if the process is killed.