Release v0.7.0 - Automatic pairing and validated MA audio playback
Validate and generate manual release / package (push) Waiting to run

This commit is contained in:
Jason committed 2026-12-04 08:58:47 -05:00
1 parent 83d168f5a1
commit 1ed30567fb
48 files changed
+2717 -742

No files matched your search

+77 -100
View File
@@ -1,115 +1,92 @@
# Adaptive Music architecture — 0.6.0
# Adaptive Music architecture — 0.7.0
Independent project by CheddahBoxMB, system-independent, targeting Foundry v14.371
and MA 2.10.6. Standard distribution is one Foundry module ZIP. No additional module,
container, VM/LXC, OS service, subscription, telemetry or core patch is required.
The user reports successful v0.5.0 publication/install/activation and window rendering;
this revision's live MA/Foundry audio is not verified.
Adaptive Music is an independent project by CheddahBoxMB for Foundry v14.371 and
MA 2.10.6, with no system dependency or additional required process. The expanded
operator authorization selects direct trusted-GM browser access and GM-local
credential handling for the standalone module; it supersedes the older gateway-only
scaffolding rule. Optional historical gateway source is not required or deployed.
## Connection and catalog
## Setup and receiver ownership
`connection-wizard.mjs` mounts into the GM ApplicationV2 setup. It collects the MA
origin, private access token, exact dedicated receiver name, existing private
identity/pairing backup and ownership/logging/playback acknowledgments. There are
no credential-bearing world settings, localStorage entries, URLs or logs. The private
connection profile lives in module closure memory until disconnect/reload. A trusted
GM can inspect their own browser memory; all same-origin code must be trusted.
The GM supplies the private trusted HTTPS MA origin and access token. Authentication
reads account-authorized music providers. The official pinned Sendspin SDK generates
one X25519 identity for the campaign, GM user and MA origin. Its identity, pairing
storage, catalog key and name are encrypted in local IndexedDB with a non-extractable
AES-GCM key. The key is stored in the same browser; this does not protect against
trusted-origin scripts or theft of the complete browser profile. The token is never
persisted. Failed attempts retain private inputs in tab memory; changing the MA
origin never reuses its token or identity.
The pinned SDK derives the one known receiver ID from the imported X25519 private
identity. The wizard queries only `players/get` for that ID, checks the exact name
and Sendspin provider, then validates standalone topology with the shared MA client.
It never enumerates household players or registers a new receiver. The selector
contains only this verified imported receiver; import a different authorized backup
to select a different dedicated receiver. Selection alone grants no household control.
Read-only setup allows the existing receiver to be unavailable during handover; writes
still require an available/enabled standalone target with its own active queue.
Connect audio first authenticates the `/ws` API session, then authenticates
`/sendspin` using that token and the SDK-generated client ID. MA 2.10.6 associates
this new web receiver with already-authenticated API sessions for the token. The
same API session must therefore survive pairing, catalog reads and playback.
`sendspin/pair_web_player` pairs only this identity to the calling account. Noise
activation and clock synchronization precede exact ID/name/provider/topology checks.
During startup, a successful null queue lookup is retried briefly on the same
authenticated API session because MA can expose the player before registering its
queue. Playback requires the receiver’s own active queue.
There is no household player list or arbitrary target selector.
A fixed `providers` read filtered to music supplies account-authorized provider IDs.
The existing bounded catalog reader paginates library playlists/radios, validates
provider mappings and returns opaque HMAC references and display names. Normal
selectors show playlists; radio and synthetic transport remain outside normal setup.
Catalog keys derive from the private identity and world ID, so reconnecting with the
same identity/world preserves selections. A full legacy profile can retain its
catalogKey/namespace. Saved references never contain upstream URIs or credentials.
The receiver uses SDK software volume. Fresh receivers do not report volume before
capabilities are advertised, so volume cannot be a preconnection requirement. Static
account-authorized playlist tracks become opaque HMAC references bound to the stored
catalog key and campaign. Scene/world flags persist those references, never MA URIs,
endpoints, tokens or receiver secrets.
The `/ws` API uses first-message token authentication and bounded correlated responses;
`/sendspin` uses first-message authentication followed by official SDK Noise transport.
No HTTP CORS dependency or arbitrary MA proxy is introduced. The SDK/dependency
versions, hashes and licenses remain unchanged from v0.5.0. No upstream install hooks.
## Audio and listeners
## Audio and automatic listeners
The pinned official SDK negotiates PCM, performs Noise and time synchronization,
and decodes audio. A bounded Web Audio scheduler accepts the normal approximately
four-second stream-ahead window (six-second ceiling, 512 nodes and 2 MiB of decoded
buffers). Timestamped partial clears trim only affected audio. Full clears and ends
stop the stream. A software gain and output meter feed the GM speakers and a single
MediaStreamDestination track for listener distribution.
```mermaid
flowchart LR
C[Scene and combat controller] --> N[Owned Foundry playlists]
C --> G[Guarded provider in GM browser]
G -->|Private authenticated WSS| MA[Music Assistant]
MA -->|Authenticated Sendspin| S[GM SDK and Web Audio]
S -->|DTLS SRTP audio| P[Active player browsers]
U[Permission controlled User public keys] --> E[Encrypted invitation bootstrap]
E --> P
S <-->|Encrypted bounded SDP via Foundry module socket| P
```
User document public keys authenticate ephemeral ECDH/AES-GCM invitation delivery.
Private keys stay in memory. Invitations are bound to world, sender, recipient,
epochs and expiry. Each player receives only its own WebRTC capability. Bounded
AES-GCM envelopes carry SDP over Foundry’s module socket; audio uses DTLS-SRTP,
never PCM over that socket. Firefox’s session-level SDP direction default is
correctly overridden by the sole audio media direction. Offers remain recvonly;
answers remain sendonly. Video, data and injected sender media are rejected.
At ready each client generates a memory-only non-extractable P-256 private key and
publishes only its public key and random epoch to its own User document flag.
Foundry's server-enforced User update permissions are the authentication boundary;
socket `from`/`isGM` claims alone are never trusted. The single active GM derives an
AES-GCM key by ECDH with the intended active non-GM's current document public key.
Only an encrypted expiring audio invitation is broadcast, bound to world, sender,
recipient and both epochs. Players authenticate against the current active GM's
User public key. Tampering, unknown fields, replay, wrong world/recipient/epoch,
expired capability and role changes fail closed. Document permission behavior must
also be checked with distinct users in real Foundry before live acceptance.
Up to eight listeners negotiate automatically. Invitations renew after 20 minutes
and expire after 30. Failed negotiation times out after 20 seconds; disconnected
peers are revoked after 10 seconds and the 15-second reconciliation loop can issue
fresh invitations. One user gesture unlocks browser audio when required. A stable
HTMLAudioElement pumps the incoming remote track; Web Audio provides an optional
activated playback path. Default ICE has no public STUN/TURN service. WAN delivery
requires a viable existing ICE route and is not inferred from local tests.
The invitation contains a unique per-peer 256-bit capability, never MA credentials,
SDK keys or endpoint. The existing SignalCodec then encrypts/authenticates bounded
SDP/ICE/DTLS signaling with session/peer/direction/sequence/expiry binding. Audio uses
WebRTC audio tracks, never PCM over Foundry sockets. No microphone, video or data
channel. Up to eight peers; fresh invites replace each user's prior peer. Invitations
last 30 minutes and renew after 20 minutes; failed peers are retried on the 15-second
reconciliation timer. New logins/key epochs trigger delivery. Default ICE servers
are empty. Optional private backup `listenerNetwork` holds explicit ICE settings.
## Transitions and recovery
The listener automatically negotiates and attempts playback. If autoplay is denied,
Campaign audio → Enable Audio uses a direct click. Stop Audio opts out until Enable
Audio. The same HTMLAudioElement survives normal renewals. Latest tab publishing a
User key receives subsequent invitations; use one audio tab per account. Reloads,
network failures, browser suspends and relay expiry can require reconnecting.
The GM also hears decoded audio and can resume their AudioContext through the UI.
Manual override/silence > explicit boss > started combat in the active scene >
ambient > world default > silence. No system actor schemas are used. The existing
serialized controller checks campaign/session/generation and current authority.
A single active GM plus a Web Lock excludes common duplicate tabs; this is not a
server-side distributed fence or seamless handover protocol.
## Policy, authority and fallback
Every queue mutation verifies the exact dedicated target, standalone topology and
its own active queue. Signed snapshots retain ordered duplicates, index, repeat,
whole-second position and state, scoped to campaign/session/fence/generation for up
to 12 hours. Ambiguous writes latch closed and stop automation; they are not retried.
MA Sendspin lacks native pause in 2.10.6, so pause retains a logical stopped-queue
snapshot and resume explicitly seeks its item. A paused restore rebuilds without
briefly playing. This logical pause state is memory-only.
Manual override/silence > explicit eligible boss > started scene combat > scene
ambient > world default > silence. Scene/world flags and module settings persist
ambient/combat/boss/native fallback references. Legacy assignments and native ownership
remain supported. Effects and AmbientSound documents are outside the owned music set.
Bosses use explicit module flags, not system actor schemas. Boss/manual controls are
in a disclosure; companion/synthetic/manual capability tools require advanced development.
Reconnecting to a remembered owned receiver can attach to its existing queue
without replacing it. Automation remains paused for explicit resumption when that
queue is nonempty. Crash/reload cannot guarantee restoration of an interrupted
ambient stack or logical pause position. No crossfade or independent simultaneous
layers is implemented with the single upstream queue. Native playback uses only
explicitly owned playlists; effects and AmbientSound remain untouched.
Explicit catalog playback opt-in enables registered static catalog playlists through
the existing serialized guarded provider. Dynamic/shuffled/autoplay/overlay/ended or
nonstandard speed states remain unsupported. Every mutation checks campaign/session/
generation, current authority, exact target/name/provider, standalone topology and own
active queue. Startup requires an empty idle queue. Signed five-minute snapshots retain
ordered duplicates, index, whole-second position, pause/state and repeat. Ambiguous
writes latch closed; no blind retry or arbitrary queue transfer/group/global stop.
Native fallback uses only explicitly owned Foundry playlists and does not reconcile
an uncertain active MA target automatically.
## Verification boundary
A single active GM plus same-origin Web Lock excludes common duplicate GM tabs.
This is not a distributed MA server-side fence. Foundry disconnect/GM role loss ends
forwarding and writes; it does not guarantee crash restoration. No seamless GM
handover, long-run drift/synchronization guarantee, crossfade or simultaneous layers.
The optional companion remains in gateway/ as development source. No host worker or
TLS route is installed; any production change requires separate authorization.
## Evidence
Offline tests and a Chromium DOM fixture cover this revision. Historical
`evidence/browser-audio.json` measured two local synthetic listeners using the official
PCM decoder, Web Audio and WebRTC: signal at 1.757 s, about 42.3 kbit/s aggregate RTP.
It was not Foundry, real MA, WAN, audibility or synchronization verification. Prior
read-only catalog/target checks and idle queue controls remain separate evidence.
No new credential use, receiver registration, production connection or playback
mutation was performed for v0.6.0. See TESTING.md for remaining acceptance gates.
Source archive evidence separates real MA authentication/provisioning/catalog/audio,
actual browser WebRTC, actual Foundry ApplicationV2 rendering and offline regressions.
Browser integration uses the deployed Foundry origin with local source assets supplied
by Playwright, not an installed logged-in Foundry world. Mac networking, actual User
permission enforcement, Foundry socket delivery and WAN behavior still require the
single consolidated acceptance sequence in TESTING.md.