Migration and portable listener state
824e49fddb4dcc071fc8e72558aadea224704447. Version 2026.11.0-rc.1. License MIT. Status: source candidate; complete gate and disposable live suite are the qualification authority; not published and not production-qualified. This is the component's committed documentation, not proof of a distribution release or production qualification.
Keep original exports intact and private. The CLI supports the server-owned,
two-phase melodee-user-state/1 portability workflow in addition to the C2B
read-only verification of the historical schema-1 archive. Preview never mutates
listener state; apply requires the current plan revision and explicit --yes.
The owner's real export is never applied by this repository's tests.
Portable user state
# Exact export; the digest is preserved. Write it to a private file.
melodee state export --out /private/user-state.json
melodee state inspect /private/user-state.json # schema + canonical digest
# Non-mutating preview with explicit legacy mappings.
melodee state preview /private/user-state.json \
--mapping legacy-track-1=<canonical-track-id> --idempotency-key migration-1
melodee state plan <plan-id> # decision items
melodee state apply <plan-id> --revision <planRevision> --limit 200 --yes
# repeat with the returned planRevision until status is "applied"
melodee state unresolved
melodee state resolve <unresolved-id> --track <canonical-track-id>
melodee state plans
melodee state apply-job <plan-id> --yes # durable job, resumable
state inspect mirrors the published schema and bounds locally and recomputes
the canonical SHA-256 exactly as the API does. A declared digest mismatch exits 4.
state preview sends the document, optional mappings, target account and
idempotency key to the server; it records a plan and writes nothing. Decisions are
apply, skipped, skip_newer, conflict, unresolved; conflicts and
unresolved references are printed explicitly. Apply is revision-bound, bounded
per batch and idempotent on replay. Favorite/dislike absence never deletes a local
fact, ratings are only replaced when strictly newer, existing summaries or
preferences are conflicts, and playlists are create-only.
A durable apply job can be followed with admin jobs watch <job-id> and cancelled
with admin jobs cancel <job-id> --reason ... --yes when the account holds the
admin_jobs capability. Re-running apply after an interrupted batch is safe.
Historical schema-1 archive
melodee legacy inspect /private/legacy-user-state.zip -o json
melodee legacy verify /private/legacy-user-state.zip -o json
melodee legacy inspect /private/entity-states.ndjson -o json
melodee playlist validate docs/examples/playlist.json -o json
melodee concert validate docs/examples/concert.json -o json
melodee mql inspect docs/examples/legacy-mql.json -o json
See synthetic examples. The legacy ZIP inspector accepts a
flat archive or exactly one safe root directory (the authoritative export uses
legacy-user-state/), bounds decompressed bytes, rejects traversal, absolute
paths, links, extra directories, duplicate/unknown members and expansion beyond
limits, and never extracts files. legacy inspect counts rows only.
legacy verify additionally requires schema version 1, a UTC generation
timestamp and manifest checksums/counts covering exactly the twelve NDJSON
members. It verifies each member's SHA-256 and exact row count, validates the
five row schemas observed in the authoritative export, and checks evidence
relationships (state/play references, entity kind, known users, duplicate
evidence IDs, contradictory identity evidence, duplicate state keys). Seven
members are empty in the authoritative export and have no observed schema; a
non-empty one fails closed instead of being guessed. The manifest is unsigned, so
integrity proves agreement with the manifest, not authenticity.
The report is aggregate-only: no titles, artists, identifiers, usernames, emails
or credential values. User credential/privilege fields are parsed only to
validate shape and are never imported. credentials_imported and
roles_imported are always false. No canonical resolution is claimed. The
observed schema and source digest are in
LEGACY-SCHEMA-1; real-archive
qualification is in C2B-LEGACY.
JSON/NDJSON inspection is syntax/row-shape only. Structural errors use a nonzero exit. Do not open arbitrary source exports in an untrusted environment. The historical archive is not uploaded or applied by the CLI; use the portable document workflow above for server-backed migration.
Draft static playlists keep ordered entry occurrences, including repeats; dynamic definitions are not evaluated. Concert entries carry performing Artist and optional original Artist context, explicit variant or studio intent. Local validation cannot prove any Track exists. The server must reconcile to canonical Track identities, keep missing/ambiguous positions, and offer alternatives without auto-substituting a cover. Native export/import will use the API-owned versioned format and explicit operation/revision, user mapping, idempotency, and reviewed preview/apply. Historical summary play counts are not dated events; overlap must not be counted twice.
Historical MQL JSON schema-2 is inspected without translating legacy query fields,
adopting public visibility or executing queries; raw MQL inspection merely checks
size/UTF-8/content. Native MQL is executed only by the server through
melodee mql validate|execute|preview; the CLI never evaluates it.