#pragma once
// ext_keys — the SINGLE SOURCE OF TRUTH for the "reasampler" project ext-state
// namespace + key names, shared by the extension (writer, via persist.h) and the
// VST3 instrument (reader, via the bridge). Both sides include this header so the
// wire contract cannot drift between the two artifacts (the S4 reviewer flagged the
// spike's duplicated constants as a drift risk).
//
// PURE HEADER: NO REAPER types, NO VST3 types, NO SWELL, NO vendor/ includes. The key
// spellings are string constants; the NAMESPACE is channel-derived (Phase V, V4) so it
// delegates to the pure app_version module (also REAPER-free / VST3-free). Both the
// REAPER-facing persist shell and the SDK-facing VST bridge include this without pulling
// either SDK.
//
// FOREVER-STABLE once shipped: these strings key every already-saved project's
// stored state. Changing any of them orphans that state. See persist.h for the
// per-key retirement / migration semantics — this header only owns the spellings.

#include "app_version.h"

namespace reasampler {

// The ext-state namespace all ReaSampler project state is stored under. CHANNEL-DERIVED
// (Phase V, V4): delegates to the ONE app_version symbol so the extension (writer) and the
// VST3 instrument (reader) resolve the SAME namespace per channel — "reasampler" on stable,
// "reasampler_beta" on the isolated beta build. An accessor (not a constexpr literal)
// because the value is fixed by the channel bit at build time. This is the wire-contract
// reconciliation between S4 (shared ext_keys) and V4 (channel-isolated namespace): without
// it a beta instrument would read the stable namespace and see empty state.
inline const char* kProjExtNamespace() { return extStateNamespace().c_str(); }

// The multi-bank key: the whole serialized BankBook (pool + named banks). This is
// the key the VST3 instrument reads to see the live bank (read-only, S4). persist.h
// documents its authority + the legacy-key migration around it.
inline constexpr const char* kProjExtBanksKey = "banks";

// The retired legacy single-bank key (read once on load to migrate into the pool).
inline constexpr const char* kProjExtIndexKey = "bank_index";

// The Design-View model key.
inline constexpr const char* kProjExtViewKey = "view_state";

// The docked panel's tail-setting key.
inline constexpr const char* kProjExtTailKey = "tail_setting";

// The per-project minted-GUID identity key.
inline constexpr const char* kProjExtGuidKey = "project_guid";

// The S9 BANK-GENERATION key. The EXTENSION stamps a monotonic decimal counter here that it
// bumps on every bank-content mutation that changes what a live instance would PLAY (capture
// add, re-capture-in-place, sample remove, move/copy affecting banks, ingest import). The VST3
// instrument READS it off the audio thread on a UI-timer cadence and, when the value differs
// from what it last saw, calls reloadFromBank() so a recapture/ingest refreshes playing
// instances hands-free (the S9 change-detection trigger). WIRE-SHARED (instrument reads it);
// the instrument never WRITES it (the extension owns it, same read-only-over-bank rule as the
// assignment request). Additive to the persist blob — an absent stamp reads as generation 0
// (a pre-S9 project), and the first bump (>= 1) then reads as a change. FOREVER-STABLE once
// shipped: changing this spelling resets every already-shipped instance's change-detection
// baseline (a one-time spurious reload), so it is fixed like every sibling key.
inline constexpr const char* kProjExtBankGenKey = "bank_generation";

// The S8 ingest ASSIGNMENT-REQUEST key. The EXTENSION writes an assignment request here
// after an ingest-with-assign (arrange capture / Media-Explorer import / drop-onto-panel):
// "the active sampler instance should now play THIS sample." The value is the pure
// assignment_request wire format ("rsassign1" + bankId + sampleId + generation) — see
// assignment_request.h for the exact grammar. WIRE-SHARED because the VST3 instrument
// READS it (in a later dispatch, S8 instrument-side follow-up) to update its own selection
// and reload; the instrument never WRITES it (the extension writing its own namespace does
// not violate the instrument's read-only-over-the-bank rule). FOREVER-STABLE once shipped:
// changing this spelling strands any pending request an already-shipped instrument watches.
inline constexpr const char* kProjExtAssignKey = "assign_request";

}  // namespace reasampler
