feat(studio): integrate memcard persistence and headless controls
Persist cartridge identity and slot configuration, add MemcardBoot and the MemcardBuffer SDK, and consume the runtime's negotiated memcard host controls with protected teardown. Qualify save/reopen and version upgrades through distinct configured runtime processes. Include specs, examples, regression evidence and the consolidated discussion lesson.
This commit is contained in:
@@ -138,3 +138,73 @@ commit. Failure aborts credentials/files and reports a failed grant. Revoke/clos
|
||||
invalidate credentials before asynchronous work cleanup, then remove owned
|
||||
publication and release ownership. File cleanup failure MUST NOT prevent runtime
|
||||
cancellation. An already-admitted release response MUST remain deliverable.
|
||||
|
||||
|
||||
## Cartridge identity and local memcard configuration
|
||||
|
||||
Versioned prometeu.json owns explicit numeric uint32 app_id and optional integral
|
||||
memcard_slots in 1..64. Studio project references preserve both. New projects persist
|
||||
their initial identity. Before shipping a legacy project, the current legacy
|
||||
name/version/language/stdlib hash is adopted once via atomic manifest replacement,
|
||||
with unknown fields preserved. Existing explicit IDs are authoritative and are
|
||||
never regenerated on upgrades/rename/clone. A copied manifest represents the same
|
||||
game; a distinct game requires an explicitly different identity. Invalid values
|
||||
MUST fail rather than fall back to hashing. build/manifest.json propagates ID and
|
||||
coherent slots/capability. Compiler validation additionally requires MemcardBoot
|
||||
and the bootstrap boundary for memcard images.
|
||||
|
||||
Media path and session choice are local runtime-host configuration. The development
|
||||
image location is `.studio/memcard.pmc`, outside rebuildable output; shared external
|
||||
images require explicit selection. Studio creates no media implicitly and never
|
||||
replaces existing saves. Runtime owns creation/mounting/concurrency, headless,
|
||||
player-choice/dirty-discard workflow and reconciliation. Studio consumes only a
|
||||
published interface of its configured runtime installation. It MUST NOT invent
|
||||
flags/JSONL fields, implement an alternative host or duplicate SO/Hub.
|
||||
|
||||
Missing provider controls/dirty-pending diagnostics remain explicit integration
|
||||
dependencies. They do not alter the guest ABI or permit silent memory-only fallback.
|
||||
A process failure does not establish whether publication occurred; supervision
|
||||
errors MUST NOT be presented as durable save failure/rollback. Native host evidence
|
||||
and configured-process reopen evidence MUST be reported separately.
|
||||
|
||||
### Published memcard host integration
|
||||
|
||||
Memcard projects MUST negotiate protocol 1.1 and capability `memcard` with their
|
||||
configured installation before mounting media or booting. Ordinary projects keep
|
||||
the 1.0 flow. Runtime version strings are not capability detection.
|
||||
|
||||
`studio_headless_boot` accepts optional `memcard` mount configuration (`path`,
|
||||
explicit `action:open/create`, explicit `access:read_write/read_only`) and the
|
||||
explicit `memcardChoice:persistent/memory_fresh/memory_existing`. Studio sends
|
||||
the published `memcard_mount` before `boot`, preserving native domain failures.
|
||||
Omitted mount path selects the project-local development path; it does not imply
|
||||
mounting, creation or a memory choice. An explicit create at that default path
|
||||
may create its `.studio` parent; the runtime alone formats and creates the media.
|
||||
Explicit external paths resolve against the project root. No open failure may
|
||||
be retried as create, repaired or converted into a RAM choice automatically.
|
||||
|
||||
Local `.studio/setup.json` MAY set `memcardPath` to explicitly select another
|
||||
image; relative selections resolve against the project root. Desktop Debug passes
|
||||
the published `--memcard` option for opt-in projects, and headless mount defaults
|
||||
to that same selection. An explicit per-session mount path overrides it for that
|
||||
session. No desktop `--create-memcard` is inferred from file absence or launch.
|
||||
Ordinary projects receive no media startup options. The default development
|
||||
selection remains `.studio/memcard.pmc` when `memcardPath` is absent.
|
||||
|
||||
The consumer exposes native state, idle mount/unmount, same-card reconciliation
|
||||
and explicit continuation in memory. These operations preserve the runtime's
|
||||
state and choices; they do not expose private payloads. Reset/shutdown accept
|
||||
explicit `discardUnsaved` and `pendingWrites:wait/cancel`; omission preserves
|
||||
provider defaults. A native refusal MUST retain the process, channel and session
|
||||
association. A subsequent explicit decision can retry. The structured
|
||||
`memcard_error` is carried as `MEMCARD_ERROR` with unchanged native details.
|
||||
An `action_required` advance is an `ACTION_REQUIRED` outcome with native
|
||||
diagnostics, preserving known completed frames and the resident session.
|
||||
|
||||
Human reclaim first attempts protected shutdown without discard consent. On
|
||||
refusal it keeps manual mutation locked and exposes the diagnostics. DEV offers
|
||||
a separately confirmed discard of unsaved game RAM and cancellation of admitted
|
||||
writes before retrying cleanup. Canceling that confirmation sends no consent.
|
||||
Neither task release, Stop, reclaim nor a timeout implicitly permits discard.
|
||||
Forced termination remains infrastructure failure with unknown publication
|
||||
outcome; it MUST NOT manufacture a durable save result.
|
||||
|
||||
Reference in New Issue
Block a user