From 0f0de0dd8ea8beb764768d8cd431857e64c16e79 Mon Sep 17 00:00:00 2001 From: Aqua Date: Thu, 12 Nov 2026 10:33:48 +0000 Subject: [PATCH] Dings: DingCatalog.Identity owns PatchId/FaustName/revision derivation (step 1); record owner as ruled, migration plan Co-Authored-By: Claude Sonnet 5.5 --- docs/dings-patch-identity-authority-map.md | 24 ++++++++++++++++- src/AquaSynth.Dings/DingCatalog.cs | 7 +++++ tests/AquaSynth.Dsl.Tests/DingCatalogTests.cs | 26 ++++++++++++++++++- tools/AquaLower/Program.cs | 2 +- tools/AquaSynthDingsHost/AquaDaemonClient.cs | 3 ++- tools/earcon-workshop/web/earcon.js | 2 ++ 6 files changed, 60 insertions(+), 4 deletions(-) diff --git a/docs/dings-patch-identity-authority-map.md b/docs/dings-patch-identity-authority-map.md index dc09396..a3d5133 100644 --- a/docs/dings-patch-identity-authority-map.md +++ b/docs/dings-patch-identity-authority-map.md @@ -259,7 +259,9 @@ user. Any process of that user can send `Play`. There is no per-caller identity pipe: `DingsCommand` carries an instrument, not a caller, so the Host cannot know who asked. -## PROPOSED: one owner (a recommendation for the stewarding decision, not decided) +**Status (2026-11-12): the owner is RULED.** The operator tier, relayed through Persona, ruled that `DingCatalog` is the single owner of Dings patch identity. The sections below were written as a proposal; they are kept as the analysis behind the ruling. Their per-step claims are still unverified plans, except step 1, which landed on branch `aqua/dingcatalog-owner-step1`. + +## One owner: DingCatalog (ruled; analysis below was written as a PROPOSAL) **Proposal.** `DingCatalog` (`src/AquaSynth.Dings`) becomes the only place that decides what a voice is, and also the only place that derives the daemon keys from it. Its @@ -268,6 +270,8 @@ and one function in that assembly produces `PatchId`, `FaustName` and the revisi the daemon (`AquaLower` and the test need only the faust-name part of it, not `patchId` or revision). Everything else keys on the catalog id and takes the rest from the catalog. +End state versus this change: the content revision named above is deferred (step 3 of the migration order). Until it lands, `revision` is the literal 1 and the catalog function returns it; the revision hash is not part of the first consolidation. + **What the others become.** - B (Host/daemon): the Host stops composing `patchId`/`faustName`/`revision`; it calls the catalog function. `AquaLower/Program.cs:19` and `DingCatalogTests.cs:45` call only the faust-name slice of it. The daemon @@ -338,3 +342,21 @@ what the MCP bridge can learn about its caller. and whether the Host's `Ping`/`GetVolume` have different callers in practice. The pipe protocol above is from reading, not from a captured exchange. Nothing was built, run, or listened to for this note. + +## Migration plan (ruled 2026-11-12: DingCatalog is the owner) + +Rules for every step: deprecate before removing (mark the old path with a pointer, keep it working, delete in a later pass after the window); `patchId`, `faustName`, `revision = 1`, session ids, compile keys and `sessions/<...>.cc` names stay byte-identical until step 3; no change to the Host or pipe protocol. Deprecation window: one merged release of the owner path with the old path still working and marked; removal only in a separate PR after the operator hears or reviews nothing regressed. + +**Step 1 (done in this change).** `DingCatalog.Identity(instrument)` returns `PatchId`, `FaustName`, `Revision` (literal 1). `AquaDaemonClient` and `AquaLower --dings` call it. The guard test no longer carries a private copy of the rule: it compares against literals per instrument, and `IdentityPinsTheOldDerivedValuesForAllFourInstruments` pins the old derived values for all four. +- Verify: the pin test; `DingCatalogTests` and `StoreFileNameTests`; `AquaLower --dings tools/aqua-feel/lowered-dings` leaves `git status` clean (the checked-in mirror is byte-identical). +- Not verified: the Host sending the same JSON to the daemon at runtime (compile-checked and read, not run against a daemon). +- Rollback: revert the commit; no stored state or wire format moved. +- Echo sites in this step: the `lowered-dings` mirror is tied to the catalog by `AquaLower` calling `Identity` and stays test-guarded. Earcon Workshop `IDENTITIES` is NOT tied: it is browser JS with its own voice model (`fmRatio`, `harmonics`, seconds-based decay) and shares only ids, so tying needs a generated file and a build step, which is step 5. It is marked deprecated with a pointer, and still works. + +**Step 2. Agent identity for the registry** (`AgentInstrumentRegistry` key). Blocked on the open question (what the bridge can learn about its caller). Verify: a test that the same agent id maps to the same instrument across sessions, and listening before and after, which nobody has done. Deprecate: keep the session-id keyed path behind the new key for one release. Rollback: revert; assignments are an in-memory cache. + +**Step 3. Content revision** (replace the literal 1 with a catalog hash). Deliberately breaks byte-identity: compile keys, session ids and `sessions/<...>.cc` names all change. Needs its own ruling on what feeds the hash and whether old session files are left or removed. Verify: receipts before and after, with the old keys listed as expected to change. Rollback: revert to literal 1; new session files stay as orphans, harmless. + +**Step 4. One validation gate** (`DingService` versus `DingsPlaybackHost`). Make the Host the owner and let the bridge forward; keep the bridge check as deprecated fail-fast for one window. Verify: `DingsBridgeTests`. Rollback: revert; both gates read one dictionary, so behaviour is the same either way. + +**Step 5. Echo sites by reference.** (a) Neutral fallback in `tools/dings-voices/build.mjs` names a catalog instrument id. (b) Earcon Workshop `IDENTITIES`: export the shared ids and root frequencies from the catalog into a checked-in file (as `lowered-dings` is), guarded by a test, and have `earcon.js` read it; the voice-model parameters stay workshop-owned and the drifted values (table in section E) need an owner's decision first. Deprecation: `IDENTITIES` keeps its inline values, marked, until the generated file is read in production. Verify: `tools/earcon-workshop/test.mjs`, the guard test, and an ear check, since the workshop values were never tuned to the catalog. Rollback: revert; the inline values still exist. diff --git a/src/AquaSynth.Dings/DingCatalog.cs b/src/AquaSynth.Dings/DingCatalog.cs index 4da53ec..5f1241f 100644 --- a/src/AquaSynth.Dings/DingCatalog.cs +++ b/src/AquaSynth.Dings/DingCatalog.cs @@ -4,8 +4,15 @@ public sealed record DingNote(double Semitones, int DelayMilliseconds, float Gai public sealed record DingEvent(string Id, string Meaning, IReadOnlyList Notes); public sealed record DingInstrument(string Id, string Description, string TimbreFamily, string Script, float RootFrequency, float Brightness, float DecaySeconds, bool UsesNoise); +/// The daemon-facing identity of a catalog instrument. Revision is the literal 1 until the deferred content-revision step. +public sealed record DingPatchIdentity(string PatchId, string FaustName, int Revision); + public static class DingCatalog { + /// The only derivation of PatchId, FaustName and revision from an instrument id. Host, AquaLower and the tests call this. + public static DingPatchIdentity Identity(DingInstrument instrument) => + new($"dings.{instrument.Id}", $"dings_{instrument.Id.Replace('-', '_')}", 1); + public static readonly IReadOnlyDictionary Events = new DingEvent[] { new("session.start", "Opening welcome", [new(0, 0), new(7, 220)]), diff --git a/tests/AquaSynth.Dsl.Tests/DingCatalogTests.cs b/tests/AquaSynth.Dsl.Tests/DingCatalogTests.cs index 5e6f9a6..bd5f555 100644 --- a/tests/AquaSynth.Dsl.Tests/DingCatalogTests.cs +++ b/tests/AquaSynth.Dsl.Tests/DingCatalogTests.cs @@ -34,6 +34,30 @@ public sealed class DingCatalogTests Assert.InRange(pair.Second.DelayMilliseconds - pair.First.DelayMilliseconds, 180, 320); } + // Independent oracle: literals captured from the pre-DingCatalog.Identity derivation in AquaDaemonClient/AquaLower. + // Session ids, compile keys and store file names hang off these; they must not move without the deferred revision decision. + private static readonly Dictionary Pinned = new() + { + ["warm-bell"] = ("dings.warm-bell", "dings_warm_bell"), + ["glass-chime"] = ("dings.glass-chime", "dings_glass_chime"), + ["soft-triangle"] = ("dings.soft-triangle", "dings_soft_triangle"), + ["muted-pluck"] = ("dings.muted-pluck", "dings_muted_pluck"), + }; + private static Dictionary PinnedFaustNames => Pinned.ToDictionary(x => x.Key, x => x.Value.FaustName); + + [Fact] + public void IdentityPinsTheOldDerivedValuesForAllFourInstruments() + { + Assert.Equal(Pinned.Keys.Order(), DingCatalog.Instruments.Keys.Order()); + foreach (var instrument in DingCatalog.Instruments.Values) + { + var identity = DingCatalog.Identity(instrument); + Assert.Equal(Pinned[instrument.Id].PatchId, identity.PatchId); + Assert.Equal(Pinned[instrument.Id].FaustName, identity.FaustName); + Assert.Equal(1, identity.Revision); + } + } + // tools/aqua-feel measures the lowered files in tools/aqua-feel/lowered-dings; regenerate them with // `dotnet run --project tools/AquaLower -- --dings tools/aqua-feel/lowered-dings` when the catalog changes. [Fact] @@ -42,7 +66,7 @@ public sealed class DingCatalogTests var dir = Path.Combine(RepositoryRoot(), "tools", "aqua-feel", "lowered-dings"); foreach (var instrument in DingCatalog.Instruments.Values) { - var expected = FaustEmitter.EmitScript(instrument.Script, new FaustExportOptions("dings_" + instrument.Id.Replace('-', '_'))).Source; + var expected = FaustEmitter.EmitScript(instrument.Script, new FaustExportOptions(PinnedFaustNames[instrument.Id])).Source; Assert.Equal(expected, File.ReadAllText(Path.Combine(dir, instrument.Id + ".dsp"))); } diff --git a/tools/AquaLower/Program.cs b/tools/AquaLower/Program.cs index 8ee3fd7..103b913 100644 --- a/tools/AquaLower/Program.cs +++ b/tools/AquaLower/Program.cs @@ -16,7 +16,7 @@ if (args.Length == 2 && args[0] == "--dings") var instruments = new List(); foreach (var ins in DingCatalog.Instruments.Values.OrderBy(i => i.Id, StringComparer.Ordinal)) { - var export = FaustEmitter.EmitScript(ins.Script, new FaustExportOptions("dings_" + ins.Id.Replace('-', '_'))); + var export = FaustEmitter.EmitScript(ins.Script, new FaustExportOptions(DingCatalog.Identity(ins).FaustName)); File.WriteAllText(Path.Combine(dingDir, ins.Id + ".dsp"), export.Source); instruments.Add(new { id = ins.Id, rootFrequency = ins.RootFrequency, dsp = ins.Id + ".dsp", controlPath = "/ding/frequency", warnings = export.Warnings }); Console.WriteLine($"{ins.Id}: {export.Source.Length} chars, {export.Warnings.Count} warnings"); diff --git a/tools/AquaSynthDingsHost/AquaDaemonClient.cs b/tools/AquaSynthDingsHost/AquaDaemonClient.cs index 2d5a15e..aa4de12 100644 --- a/tools/AquaSynthDingsHost/AquaDaemonClient.cs +++ b/tools/AquaSynthDingsHost/AquaDaemonClient.cs @@ -17,7 +17,8 @@ public sealed class AquaDaemonClient : IAsyncDisposable { EnsureStarted(); var id = $"ding-{Guid.NewGuid():N}"; - var envelope = new { command = "instrument.sample", payload = new { commandId = id, patchId = $"dings.{instrument.Id}", faustName = $"dings_{instrument.Id.Replace('-', '_')}", script = instrument.Script, durationSeconds = 1.5f, gain, controls = new Dictionary { ["/ding/frequency"] = frequency }, revision = 1 } }; + var identity = DingCatalog.Identity(instrument); + var envelope = new { command = "instrument.sample", payload = new { commandId = id, patchId = identity.PatchId, faustName = identity.FaustName, script = instrument.Script, durationSeconds = 1.5f, gain, controls = new Dictionary { ["/ding/frequency"] = frequency }, revision = identity.Revision } }; await process!.StandardInput.WriteLineAsync(JsonSerializer.Serialize(envelope, json)); await process.StandardInput.FlushAsync(cancellationToken); var line = await process.StandardOutput.ReadLineAsync(cancellationToken) ?? throw new InvalidOperationException("Aqua daemon closed before returning a render receipt."); diff --git a/tools/earcon-workshop/web/earcon.js b/tools/earcon-workshop/web/earcon.js index 6dcee6a..6eae20c 100644 --- a/tools/earcon-workshop/web/earcon.js +++ b/tools/earcon-workshop/web/earcon.js @@ -17,6 +17,8 @@ export const EVENTS = { waiting: { label: "Waiting", meaning: "Needs you: quiet, sparse, slow low sway, three soft notes", notes: [[0, 0, 0.55], [5, 450, 0.55], [0, 900, 0.55]] }, }; +// DEPRECATED as an identity owner (ruled 2026-11-12: DingCatalog owns Dings patch identity; see +// docs/dings-patch-identity-authority-map.md, 'Migration plan'). Kept working; do not add ids or copy catalog values here. // Timbre identities. rootHz in the calm mid register; fmRatio/fmIndex/fmDecay shape the bell; harmonics > 0 selects the // additive triangle; attack is seconds. Values start from the Dings catalog instruments and were not tuned by ear. export const IDENTITIES = {