feat(runtime): preserve structured Play v2 diagnostics
Intrepid/Prometeu/Runtime/pipeline/head This commit looks good
Intrepid/Prometeu/Runtime/pipeline/head This commit looks good
Confirm loaded PBX identity, emit bounded fault envelopes and retain the primary crash report through teardown. Start background IO before audio initialization and update native protocol and process fixtures.
This commit is contained in:
@@ -1,16 +1,17 @@
|
||||
# Studio Play Protocol v1
|
||||
# Studio Play Protocol v2
|
||||
|
||||
This protocol belongs to the interactive desktop host. It does not extend or replace
|
||||
the deterministic headless automation protocol. The mode and Java adapter are
|
||||
implemented and exercised on macOS ARM64 with a relocated installation of current
|
||||
debug binaries. Protocol fixtures do not qualify other platforms or release builds.
|
||||
implemented and exercised on macOS ARM64 with the qualified release umbrella
|
||||
installation. Protocol fixtures alone do not qualify a binary or other platforms.
|
||||
|
||||
The Studio starts `prometeu-runtime --studio --run <directory>` directly. No native
|
||||
window/event loop is created in this mode. The parent listens on two ephemeral IPv4
|
||||
loopback ports: control/input and video. Both connect/authenticate before readiness.
|
||||
The parent sends a BOOTSTRAP message through private child stdin and closes stdin.
|
||||
Bootstrap payload: session ID (16 bytes), random token (32 bytes), control/video ports
|
||||
(u16 each), disposable-save selection (u8: 0 persistent, 1 explicitly disposable).
|
||||
(u16 each), disposable-save selection (u8: 0 persistent, 1 explicitly disposable),
|
||||
and expected PBX SHA-256 (32 raw bytes). The payload is exactly 85 bytes.
|
||||
Token material must not appear in arguments or logs. No reconnect or automatic restart.
|
||||
|
||||
All integer fields use little-endian encoding. Messages have this 32-byte header:
|
||||
@@ -18,7 +19,7 @@ All integer fields use little-endian encoding. Messages have this 32-byte header
|
||||
| Offset | Type | Meaning |
|
||||
| --- | --- | --- |
|
||||
| 0 | 4 bytes | ASCII PST1 |
|
||||
| 4 / 6 | u16 / u16 | major 1 / minor 0 |
|
||||
| 4 / 6 | u16 / u16 | major 2 / minor 0 |
|
||||
| 8 / 10 | u16 / u16 | type / flags (zero) |
|
||||
| 12 | u32 | payload bytes, validated before allocation |
|
||||
| 16 | u64 | strictly increasing nonzero sequence per direction/channel |
|
||||
@@ -26,23 +27,88 @@ All integer fields use little-endian encoding. Messages have this 32-byte header
|
||||
|
||||
Types: HELLO=1, READY=2, START=3, PAUSE=4, RESUME=5, STOP=6, RESULT=7,
|
||||
INPUT=8, FRAME=9, FRAME_RECEIVED=10, PING=11, PONG=12, ERROR=13,
|
||||
STOPPED=14, BOOTSTRAP=15. Unknown types/flags/versions, invalid sizes, replay,
|
||||
STOPPED=14, BOOTSTRAP=15, FAULT=16. Unknown types/flags/versions, invalid sizes, replay,
|
||||
invalid UTF-8 and truncated messages fail the connection. Control payload limit is
|
||||
64 KiB; FRAME limit is 16 MiB including metadata. Overflow is rejected.
|
||||
|
||||
| Message | Payload |
|
||||
| --- | --- |
|
||||
| HELLO | session[16], token[32], role u8 (control=1, video=2) |
|
||||
| READY | width/height/fps/format u32; UTF-8 runtime version in remaining bytes |
|
||||
| READY | width/height/fps/format u32; actual PBX SHA-256[32]; UTF-8 runtime version in remaining bytes |
|
||||
| START / PAUSE / RESUME / STOP / PING | empty; nonzero request ID for commands |
|
||||
| RESULT | command u16, status u16 (0 success, 1 invalid state, 2 save blocked), input epoch u64, tick u64, UTF-8 diagnostic remainder |
|
||||
| INPUT | input epoch u64, buttons u16, reserved u16=0, touch x/y i32 |
|
||||
| FRAME | session[16], input epoch u64, frame ID u64, width/height/stride/format u32, pixels |
|
||||
| FRAME_RECEIVED | input epoch u64, frame ID u64 |
|
||||
| PONG | input epoch u64, tick u64, state u32 (0 ready, 1 running, 2 paused) |
|
||||
| ERROR | UTF-8 diagnostic |
|
||||
| ERROR | bounded UTF-8 JSON host-error envelope, unsolicited request=0 |
|
||||
| FAULT | bounded UTF-8 JSON VM-fault envelope, unsolicited request=0 |
|
||||
| STOPPED | empty; correlated with successful STOP |
|
||||
|
||||
## Program identity and diagnostics
|
||||
|
||||
The host MUST hash the exact PBX bytes supplied to VM initialization, rather than
|
||||
reopening the path or echoing the expected digest. READY MUST carry that actual
|
||||
identity. The host MUST reject a mismatch before READY and Studio MUST compare
|
||||
READY against the prepared compilation before START. The host retains the observed
|
||||
identity after firmware removes a crashed VM session, for its final diagnostic.
|
||||
Play v1 peers are incompatible; no silent downgrade is permitted. PBX, guest ABI,
|
||||
save policy and the headless wire contract are unchanged. Existing exact native
|
||||
bundle qualification and artifact guards remain required.
|
||||
|
||||
Both terminal envelopes have this shape:
|
||||
|
||||
```json
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"sessionId": "03030303030303030303030303030303",
|
||||
"programSha256": "abababababababababababababababababababababababababababababababab",
|
||||
"tick": 7,
|
||||
"truncated": false,
|
||||
"fault": {
|
||||
"kind": "vm_trap", "pc": 42, "summary": "...",
|
||||
"trap": {
|
||||
"pc": 42, "code": 10, "opcode": 35, "message": "...",
|
||||
"span": {"file_id": 7, "start": 18, "end": 23}, "resource": null
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
`programSha256` is a JSON string or null, never the literal text "null". `tick` is
|
||||
an unsigned 64-bit integer. FAULT's `fault` is the canonical CrashReport projection
|
||||
also used by headless: `vm_trap` includes unsigned 32-bit PC/code, unsigned 16-bit
|
||||
opcode, message, nullable span and resource; `vm_panic` includes message and
|
||||
nullable PC; `vm_init` includes `initError` and null PC. A span uses compilation-local
|
||||
file ID and half-open UTF-8 byte offsets, all unsigned 32-bit fields. It is optional. A trap MUST carry a known
|
||||
program digest; an initialization failure may have no confirmed digest. The
|
||||
consumer rejects inconsistent top-level/trap PCs and mismatched session/program.
|
||||
|
||||
ERROR uses the same envelope with `kind=load|host|transport|watchdog`, summary,
|
||||
null PC and null program digest. It MUST NOT claim an executed source location.
|
||||
Categories are producer facts, not parsed log text. Failures before authenticated
|
||||
channels exist are reported locally by Studio as preparation/connection failures.
|
||||
|
||||
Each diagnostic string is limited to 8 KiB UTF-8 at a character boundary. The whole
|
||||
envelope MUST fit the 64 KiB control limit, including JSON escaping. Rich detail may
|
||||
be omitted and strings shortened further to fit, with `truncated=true`; category,
|
||||
numeric code, PC and span are preserved. Studio validates types, integer ranges,
|
||||
UTF-8, identity, nesting (maximum 32) and size before publishing neutral values.
|
||||
|
||||
Terminal messages are flushed with a bounded 2-second observation before channels
|
||||
close. Studio drains terminal control after process exit or video EOF with a
|
||||
bounded wait, and preserves the first structured failure as the primary cause.
|
||||
Consequent EOF/teardown MUST NOT replace it with a generic connection diagnostic.
|
||||
An unreachable peer cannot be promised delivery. Cleanup and ownership still wait
|
||||
for actual process exit. No token or source text enters these envelopes.
|
||||
|
||||
## Execution and presentation
|
||||
|
||||
The host MUST start its background IO worker before potentially blocking platform
|
||||
audio initialization. A memory-card mount admitted during host setup must be able
|
||||
to progress before the first firmware/VM tick, under its existing deadlines. This
|
||||
does not authorize advancing the guest before START or weakening save watchdogs.
|
||||
|
||||
Pixel format 1 is compact RGBA8: R,G,B,A bytes, stride equal to width. Never memcpy
|
||||
native u32 `0xRRGGBBAA` as wire pixels. FRAME metadata occupies 48 bytes; dimensions
|
||||
must match readiness and payload length exactly. Zoom is entirely a Studio concern.
|
||||
|
||||
Reference in New Issue
Block a user