@openmixer/plugin-qualify 0.20.0 → 0.20.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/bin/plugin-qualify-records-package.mjs +9 -7
  2. package/bin/plugin-qualify-sync.mjs +1 -0
  3. package/bin/plugin-qualify.mjs +34 -0
  4. package/catalogs/ca.json +8 -0
  5. package/dist/clap-loader.js +2 -1
  6. package/dist/clap-loader.js.map +1 -1
  7. package/dist/clap-qualify.d.ts +11 -0
  8. package/dist/clap-qualify.js +16 -0
  9. package/dist/clap-qualify.js.map +1 -1
  10. package/dist/distributed-records.d.ts +16 -3
  11. package/dist/distributed-records.js +38 -4
  12. package/dist/distributed-records.js.map +1 -1
  13. package/dist/host-admission.d.ts +25 -0
  14. package/dist/host-admission.js +41 -5
  15. package/dist/host-admission.js.map +1 -1
  16. package/dist/hostd-search-path.d.ts +38 -0
  17. package/dist/hostd-search-path.js +58 -0
  18. package/dist/hostd-search-path.js.map +1 -0
  19. package/dist/index.d.ts +2 -0
  20. package/dist/index.js +2 -0
  21. package/dist/index.js.map +1 -1
  22. package/dist/jack-registry.js +1 -1
  23. package/dist/judged-layer.d.ts +91 -0
  24. package/dist/judged-layer.js +144 -0
  25. package/dist/judged-layer.js.map +1 -0
  26. package/dist/judgement-line.d.ts +6 -0
  27. package/dist/judgement-line.js +20 -0
  28. package/dist/judgement-line.js.map +1 -0
  29. package/dist/lv2-loader.d.ts +33 -1
  30. package/dist/lv2-loader.js +82 -19
  31. package/dist/lv2-loader.js.map +1 -1
  32. package/dist/measurement/cli.d.ts +2 -0
  33. package/dist/measurement/cli.js +25 -2
  34. package/dist/measurement/cli.js.map +1 -1
  35. package/dist/measurement/format.d.ts +2 -0
  36. package/dist/measurement/format.js +5 -0
  37. package/dist/measurement/format.js.map +1 -1
  38. package/dist/measurement/vocabulary.js +3 -3
  39. package/dist/measurement/vocabulary.js.map +1 -1
  40. package/dist/measurement-grid.d.ts +1 -1
  41. package/dist/measurement-grid.js +5 -3
  42. package/dist/measurement-grid.js.map +1 -1
  43. package/dist/pins-file.d.ts +3 -2
  44. package/dist/pins-file.js +3 -2
  45. package/dist/pins-file.js.map +1 -1
  46. package/dist/probe-judge.js +5 -0
  47. package/dist/probe-judge.js.map +1 -1
  48. package/dist/probe-output.d.ts +10 -0
  49. package/dist/probe-output.js +16 -0
  50. package/dist/probe-output.js.map +1 -1
  51. package/dist/probe-runner.js +24 -5
  52. package/dist/probe-runner.js.map +1 -1
  53. package/dist/qualification-record.d.ts +13 -0
  54. package/dist/qualification-record.js +25 -3
  55. package/dist/qualification-record.js.map +1 -1
  56. package/dist/qualify-adapter-pass.d.ts +1 -2
  57. package/dist/qualify-adapter-pass.js +6 -6
  58. package/dist/qualify-adapter-pass.js.map +1 -1
  59. package/dist/qualify-declarations.d.ts +23 -6
  60. package/dist/qualify-declarations.js +25 -6
  61. package/dist/qualify-declarations.js.map +1 -1
  62. package/dist/qualify-isolated.d.ts +14 -3
  63. package/dist/qualify-isolated.js +22 -9
  64. package/dist/qualify-isolated.js.map +1 -1
  65. package/dist/qualify-pool.js +4 -3
  66. package/dist/qualify-pool.js.map +1 -1
  67. package/dist/qualify-rejudge.js +3 -3
  68. package/dist/qualify-rejudge.js.map +1 -1
  69. package/dist/qualify-sync.d.ts +18 -6
  70. package/dist/qualify-sync.js +68 -38
  71. package/dist/qualify-sync.js.map +1 -1
  72. package/dist/records-package.d.ts +31 -4
  73. package/dist/records-package.js +149 -24
  74. package/dist/records-package.js.map +1 -1
  75. package/dist/run-home.d.ts +4 -0
  76. package/dist/run-home.js +26 -0
  77. package/dist/run-home.js.map +1 -0
  78. package/fixtures/records-rpi5-0.19.1/http___drumkv1.sourceforge.net_lv2@0.2-7d179bdcf9e5.default.probe.json +58 -0
  79. package/fixtures/records-rpi5-0.19.1/http___drumkv1.sourceforge.net_lv2@0.2-7d179bdcf9e5.default.qualification.json +305 -0
  80. package/fixtures/records-rpi5-0.19.1/http___samplv1.sourceforge.net_lv2@0.2-c9cd8fb3102f.default.probe.json +58 -0
  81. package/fixtures/records-rpi5-0.19.1/http___samplv1.sourceforge.net_lv2@0.2-c9cd8fb3102f.default.qualification.json +301 -0
  82. package/package.json +7 -5
  83. package/schema/codes.json +15 -0
  84. package/src/clap-loader.ts +2 -1
  85. package/src/clap-qualify.ts +25 -0
  86. package/src/distributed-records.ts +41 -4
  87. package/src/host-admission.ts +52 -5
  88. package/src/hostd-search-path.ts +85 -0
  89. package/src/index.ts +2 -0
  90. package/src/jack-registry.ts +1 -1
  91. package/src/judged-layer.ts +197 -0
  92. package/src/judgement-line.ts +22 -0
  93. package/src/lv2-loader.ts +89 -17
  94. package/src/measurement/cli.ts +26 -2
  95. package/src/measurement/format.ts +8 -0
  96. package/src/measurement/vocabulary.ts +3 -3
  97. package/src/measurement-grid.ts +5 -3
  98. package/src/pins-file.ts +3 -2
  99. package/src/probe-judge.ts +5 -0
  100. package/src/probe-output.ts +23 -0
  101. package/src/probe-runner.ts +25 -4
  102. package/src/qualification-record.ts +32 -3
  103. package/src/qualify-adapter-pass.ts +6 -5
  104. package/src/qualify-declarations.ts +27 -6
  105. package/src/qualify-isolated.ts +24 -9
  106. package/src/qualify-pool.ts +4 -3
  107. package/src/qualify-rejudge.ts +3 -3
  108. package/src/qualify-sync.ts +74 -41
  109. package/src/records-package.ts +156 -25
  110. package/src/run-home.ts +28 -0
  111. package/tools/_declarations.py +2 -1
  112. package/tools/descriptors.py +40 -3
  113. package/tools/gen-python-declarations.mjs +1 -0
  114. package/tools/isolated-step.mjs +24 -3
  115. package/tools/lv2-measure.mjs +21 -2
  116. package/tools/mod-host-admit.mjs +57 -1
  117. package/tools/scan.py +29 -5
package/src/lv2-loader.ts CHANGED
@@ -64,27 +64,52 @@ function turtleTokens(ttl: string): Token[] {
64
64
  return out;
65
65
  }
66
66
 
67
+ /**
68
+ * The path a file IRI names, as lilv and serd read it: a `file:` URI loses its scheme and authority, and the percent
69
+ * escapes of its path are decoded (`libSurge%20XT.so` is `libSurge XT.so` on the disk). A relative IRI is decoded the
70
+ * same way. A malformed escape leaves the text as written: the name is then looked up as it stands and not found, which
71
+ * is its own, named failure.
72
+ */
73
+ export function iriPath(iri: string): string {
74
+ let path = iri;
75
+ const scheme = /^file:(?:\/\/[^/]*)?(?=\/)/i.exec(iri);
76
+ if (scheme !== null) path = iri.slice(scheme[0].length);
77
+ try {
78
+ return decodeURIComponent(path);
79
+ } catch {
80
+ return path;
81
+ }
82
+ }
83
+
67
84
  /** A plugin a manifest declares, with the files it names for it, each relative to the bundle, in the order named. */
68
85
  export interface ManifestPlugin {
69
86
  readonly uri: string;
70
87
  readonly files: readonly string[];
71
- /** The basename of its `lv2:binary`, when it names one. */
88
+ /** The basename of its `lv2:binary` as it is on the disk (the IRI's escapes decoded), when it names one. `files` keep the IRI's word, which is what a pin holds. */
72
89
  readonly binary?: string;
73
90
  }
74
91
 
92
+ /** A statement of a Turtle text: the subject and predicate expanded, the object as written and, when it names one, expanded. */
93
+ export interface TurtleTriple {
94
+ readonly subject: string;
95
+ readonly predicate: string;
96
+ /** The object's token: an `iri` is as written (a relative one stays relative), a `literal` carries no text. */
97
+ readonly object: { readonly kind: "iri" | "name" | "literal"; readonly text: string };
98
+ /** The object expanded: an absolute or relative IRI, or a prefixed name with a known prefix. */
99
+ readonly objectIri?: string;
100
+ }
101
+
75
102
  /**
76
- * Every plugin a bundle manifest declares and the files it names for it with `lv2:binary` or `rdfs:seeAlso`: the
77
- * files plugin-hostd's pin holds besides `manifest.ttl` itself. A file named outside the bundle (an absolute IRI) is
78
- * not one of them.
103
+ * The statements of a Turtle text, as plugin-hostd reads a manifest to pin a plugin: statements of IRIs and prefixed
104
+ * names, with blank nodes and collections stepped over, not a whole Turtle parser. `lv2`, `rdfs` and `rdf` read even
105
+ * when a file leaves them undeclared.
79
106
  */
80
- export function manifestPlugins(ttl: string): ManifestPlugin[] {
81
- // the three vocabularies every manifest uses, so a manifest that leaves a prefix undeclared still reads
107
+ export function turtleTriples(ttl: string): TurtleTriple[] {
82
108
  const prefixes = new Map<string, string>([
83
109
  ["lv2", "http://lv2plug.in/ns/lv2core#"],
84
110
  ["rdfs", "http://www.w3.org/2000/01/rdf-schema#"],
85
111
  ["rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#"],
86
112
  ]);
87
- const subjects = new Map<string, { typed: boolean; files: string[]; binary?: string }>();
88
113
  const expand = (t: Token): string | undefined => {
89
114
  if (t.kind === "iri") return t.text;
90
115
  if (t.kind !== "name") return undefined;
@@ -93,6 +118,7 @@ export function manifestPlugins(ttl: string): ManifestPlugin[] {
93
118
  const base = colon < 0 ? undefined : prefixes.get(t.text.slice(0, colon));
94
119
  return base === undefined ? undefined : base + t.text.slice(colon + 1);
95
120
  };
121
+ const out: TurtleTriple[] = [];
96
122
  const tokens = turtleTokens(ttl);
97
123
  let state: "subject" | "predicate" | "object" | "after" = "subject";
98
124
  let depth = 0;
@@ -134,16 +160,29 @@ export function manifestPlugins(ttl: string): ManifestPlugin[] {
134
160
  state = "object";
135
161
  } else if (state === "object") {
136
162
  state = "after";
137
- if (subject === undefined) continue;
138
- const entry = subjects.get(subject) ?? { typed: false, files: [] };
139
- subjects.set(subject, entry);
140
- const object = expand(t);
141
- if (predicate === RDF_TYPE && object === LV2_PLUGIN) entry.typed = true;
142
- if ((predicate === LV2_BINARY || predicate === RDFS_SEE_ALSO) && t.kind === "iri" && !/^[A-Za-z][A-Za-z0-9+.-]*:/.test(t.text) && !t.text.startsWith("/")) {
143
- const file = t.text.replace(/^(\.\/)+/, "");
144
- if (!entry.files.includes(file)) entry.files.push(file);
145
- if (predicate === LV2_BINARY && entry.binary === undefined) entry.binary = basename(file);
146
- }
163
+ if (subject === undefined || predicate === undefined) continue;
164
+ const objectIri = expand(t);
165
+ out.push({ subject, predicate, object: { kind: t.kind as "iri" | "name" | "literal", text: t.text }, ...(objectIri === undefined ? {} : { objectIri }) });
166
+ }
167
+ }
168
+ return out;
169
+ }
170
+
171
+ /**
172
+ * Every plugin a bundle manifest declares and the files it names for it with `lv2:binary` or `rdfs:seeAlso`: the
173
+ * files plugin-hostd's pin holds besides `manifest.ttl` itself. A file named outside the bundle (an absolute IRI) is
174
+ * not one of them.
175
+ */
176
+ export function manifestPlugins(ttl: string): ManifestPlugin[] {
177
+ const subjects = new Map<string, { typed: boolean; files: string[]; binary?: string }>();
178
+ for (const { subject, predicate, object, objectIri } of turtleTriples(ttl)) {
179
+ const entry = subjects.get(subject) ?? { typed: false, files: [] };
180
+ subjects.set(subject, entry);
181
+ if (predicate === RDF_TYPE && objectIri === LV2_PLUGIN) entry.typed = true;
182
+ if ((predicate === LV2_BINARY || predicate === RDFS_SEE_ALSO) && object.kind === "iri" && !/^[A-Za-z][A-Za-z0-9+.-]*:/.test(object.text) && !object.text.startsWith("/")) {
183
+ const file = object.text.replace(/^(\.\/)+/, "");
184
+ if (!entry.files.includes(file)) entry.files.push(file);
185
+ if (predicate === LV2_BINARY && entry.binary === undefined) entry.binary = basename(iriPath(file));
147
186
  }
148
187
  }
149
188
  return [...subjects.entries()]
@@ -151,6 +190,39 @@ export function manifestPlugins(ttl: string): ManifestPlugin[] {
151
190
  .map(([uri, e]) => ({ uri, files: e.files, ...(e.binary === undefined ? {} : { binary: e.binary }) }));
152
191
  }
153
192
 
193
+ const PATCH_WRITABLE = "http://lv2plug.in/ns/ext/patch#writable";
194
+ const RDFS_RANGE = "http://www.w3.org/2000/01/rdf-schema#range";
195
+ const ATOM_PATH = "http://lv2plug.in/ns/ext/atom#Path";
196
+
197
+ /**
198
+ * The content an LV2 plugin declares it plays from: the parameters it lists as `patch:writable` whose `rdfs:range` is
199
+ * `atom:Path` (a sampler's sample, a drum machine's kit), sorted. Read from the bundle on the search path whose
200
+ * manifest declares `uri`, in the manifest and every file it names for the plugin. Empty when the plugin declares none
201
+ * or no bundle on the path holds it (#318).
202
+ */
203
+ export function lv2ContentParams(uri: string, env: Readonly<Record<string, string | undefined>>, home: string = homedir()): string[] {
204
+ for (const bundle of lv2BundlesOnPath(env, home)) {
205
+ let manifest: string;
206
+ try {
207
+ manifest = readFileSync(join(bundle, "manifest.ttl"), "utf8");
208
+ } catch {
209
+ continue;
210
+ }
211
+ const plugin = manifestPlugins(manifest).find((p) => p.uri === uri);
212
+ if (plugin === undefined) continue;
213
+ const triples = [manifest, ...plugin.files.filter((f) => f.endsWith(".ttl")).map((f) => {
214
+ try {
215
+ return readFileSync(join(bundle, f), "utf8");
216
+ } catch {
217
+ return "";
218
+ }
219
+ })].flatMap(turtleTriples);
220
+ const paths = new Set(triples.filter((t) => t.predicate === RDFS_RANGE && t.objectIri === ATOM_PATH).map((t) => t.subject));
221
+ return [...new Set(triples.filter((t) => t.subject === uri && t.predicate === PATCH_WRITABLE && t.objectIri !== undefined && paths.has(t.objectIri)).map((t) => t.objectIri!))].sort();
222
+ }
223
+ return [];
224
+ }
225
+
154
226
  /** The plugins a bundle manifest declares, each with its `lv2:binary` basename. */
155
227
  export function pluginsInManifest(ttl: string): { uri: string; binary?: string }[] {
156
228
  return manifestPlugins(ttl).map((p) => (p.binary === undefined ? { uri: p.uri } : { uri: p.uri, binary: p.binary }));
@@ -35,7 +35,7 @@
35
35
  import { join } from "node:path";
36
36
 
37
37
  import type { MeasurementDocument, MeasurementRun, MeasuredPlugin } from "./format.js";
38
- import { buildMeasurementDocument } from "./format.js";
38
+ import { buildMeasurementDocument, readIntegrity } from "./format.js";
39
39
  import { measuredPluginsFromProbeOutput } from "./probe-json.js";
40
40
  import { buildRun, costMethodFromProbeProvenance, hostFromProbeProvenance } from "./provenance.js";
41
41
  import type { MeasurementHost, LatencyMethod } from "./format.js";
@@ -237,10 +237,17 @@ export function buildPipeline(options: MeasureOptions, native?: HostingTools): P
237
237
  });
238
238
  }
239
239
 
240
+ // a run of the prober's dimensions alone takes the pin too: a plugin measured with no integrity block cannot be pinned
241
+ // from its figures (plugin-qualify#316), and the measurer names the files without instantiating anything
242
+ const pinned = !hosting && probed && native !== undefined && (options.plugins !== undefined || current !== undefined);
243
+ if (pinned && native !== undefined) {
244
+ steps.push({ id: "pin", command: native.tool, args: ["--pin"], perPlugin: true, produces: join(options.workDir, "pins.jsonl") });
245
+ }
246
+
240
247
  return {
241
248
  steps,
242
249
  ...(probed && current !== undefined ? { finalCatalog: current } : {}),
243
- ...(hosting && options.plugins === undefined && current !== undefined ? { hostingScan: current } : {}),
250
+ ...((hosting || pinned) && options.plugins === undefined && current !== undefined ? { hostingScan: current } : {}),
244
251
  ...(costProvenance === undefined ? {} : { costProvenance }),
245
252
  };
246
253
  }
@@ -599,6 +606,8 @@ export interface AssemblyInput {
599
606
  readonly catalog?: unknown;
600
607
  /** The hosting pass's lines ({@link hostingLine}), one per plugin. Absent when it did not run. */
601
608
  readonly hosting?: readonly unknown[];
609
+ /** The measurer's `--pin` lines ({@link hostingLine}), one per plugin, for a run with no hosting pass. Absent when the pin step did not run. */
610
+ readonly pins?: readonly unknown[];
602
611
  /** The cost pass's provenance JSON, already parsed. Absent on a latency-only run. */
603
612
  readonly costProvenance?: unknown;
604
613
  /** Host facts, for a run whose provenance the cost pass did not write. */
@@ -636,6 +645,7 @@ export function assembleDocument(input: AssemblyInput): MeasurementDocument {
636
645
  const plugins: MeasuredPlugin[] =
637
646
  probed.length > 0 && input.catalog !== undefined ? measuredPluginsFromProbeOutput(input.catalog, probed) : [];
638
647
  if (input.hosting !== undefined) mergeHosting(plugins, measuredPluginsFromSweep({ measurements: input.hosting }), input.options.dimensions);
648
+ if (input.pins !== undefined) mergePins(plugins, input.pins);
639
649
  const costMethod = costMethodFromProbeProvenance(input.costProvenance);
640
650
  const host = hostFromProbeProvenance(input.costProvenance) ?? input.host;
641
651
  const run: MeasurementRun = buildRun({
@@ -655,6 +665,20 @@ export function assembleDocument(input: AssemblyInput): MeasurementDocument {
655
665
  return buildMeasurementDocument(run, plugins);
656
666
  }
657
667
 
668
+ /** The pin lines folded into the prober's plugins, by URI: a plugin without one keeps none, and a line for a plugin not measured adds none. */
669
+ function mergePins(plugins: MeasuredPlugin[], rows: readonly unknown[]): void {
670
+ for (const row of rows) {
671
+ if (typeof row !== "object" || row === null) continue;
672
+ const r = row as Record<string, unknown>;
673
+ const integrity = readIntegrity(r["integrity"]);
674
+ const at = plugins.findIndex((p) => p.uri === r["uri"]);
675
+ if (integrity === undefined || at < 0) continue;
676
+ const p = plugins[at]!;
677
+ const version = typeof r["version"] === "string" && r["version"] !== "" ? r["version"] : undefined;
678
+ plugins[at] = { ...p, ...(p.integrity === undefined ? { integrity } : {}), ...(p.version === undefined && version !== undefined ? { version } : {}) };
679
+ }
680
+ }
681
+
658
682
  /**
659
683
  * The hosting pass's plugins folded into the prober's, by URI: each keeps the hosting dimensions the
660
684
  * run asked for and the pin, and a plugin only the hosting pass measured joins with its own topology.
@@ -303,6 +303,8 @@ export interface MemoryFootprint {
303
303
  /** Activated, after processing: what a long-running host carries. */
304
304
  readonly atRestKb?: number;
305
305
  readonly notesHeldKb?: number;
306
+ /** The notes held (voices sounding) when `notesHeldKb` was read, the count `basis` says where it came from. */
307
+ readonly notesHeld?: number;
306
308
  readonly secondInstanceKb?: number;
307
309
  readonly basis?: VoiceBasis;
308
310
  readonly unmeasuredReason?: string;
@@ -950,6 +952,11 @@ function readLatency(value: unknown): LatencyMeasurement | undefined {
950
952
  }
951
953
 
952
954
  /** A KB figure: finite and never negative. */
955
+ function notesCount(value: unknown): number | undefined {
956
+ const n = positiveNumber(value);
957
+ return n !== undefined && Number.isInteger(n) ? n : undefined;
958
+ }
959
+
953
960
  function kilobytes(value: unknown): number | undefined {
954
961
  const n = finiteNumber(value);
955
962
  return n !== undefined && n >= 0 ? n : undefined;
@@ -963,6 +970,7 @@ export function readMemoryFootprint(value: unknown): MemoryFootprint | undefined
963
970
  ...optional("afterActivateKb", kilobytes(value.afterActivateKb)),
964
971
  ...optional("atRestKb", kilobytes(value.atRestKb)),
965
972
  ...optional("notesHeldKb", kilobytes(value.notesHeldKb)),
973
+ ...optional("notesHeld", notesCount(value.notesHeld)),
966
974
  ...optional("secondInstanceKb", kilobytes(value.secondInstanceKb)),
967
975
  ...optional("basis", isVoiceBasis(value.basis) ? value.basis : undefined),
968
976
  ...reasonOf(value),
@@ -94,9 +94,9 @@ const UNMEASURED_DESCRIPTIONS: Readonly<Record<UnmeasuredCode, string>> = {
94
94
  "needs-impulse-response":
95
95
  "A convolver requiring an IR file the prober did not load.",
96
96
  "unpinnable":
97
- "The files the host loads cannot be pinned (plugin-qualify spec §11.1): a path holding ',', '=' or " +
98
- "whitespace, a manifest using @base or a percent-encoded IRI, or a CLAP plugin with more parameters than the " +
99
- "host accepts. The plugin stays unpinned, never partly pinned.",
97
+ "The files the host loads cannot be pinned (plugin-qualify spec §11.1): a manifest using @base, a file name " +
98
+ "longer than a pin path, or a CLAP plugin with more parameters than the host accepts. A name with a space or a " +
99
+ "separator of pin_set is pinned percent-encoded. The plugin stays unpinned, never partly pinned.",
100
100
  "no-voices":
101
101
  "An instrument whose voice-info declares a voice capacity of 0: there is no voice to hold down, so its " +
102
102
  "cost with notes held cannot be taken.",
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * Pure: no file, no process. `probe-runner.ts` runs what `runnerInvocations` plans.
9
9
  */
10
- import { GRID_CONTINUITY_QUANTUM } from "./qualify-declarations.js";
10
+ import { COST_REFERENCE_RATE, GRID_CONTINUITY_QUANTUM, LONG_QUANTUM_FRAMES } from "./qualify-declarations.js";
11
11
 
12
12
  /** One cell of the grid. */
13
13
  export interface GridCell {
@@ -55,7 +55,7 @@ const byRateThenQuantum = (a: GridCell, b: GridCell): number => a.rate - b.rate
55
55
 
56
56
  /**
57
57
  * The cells of a grid, in the order they are taken: for `hosts`, each host's own cell in the order the hosts are given,
58
- * then `GRID_CONTINUITY_QUANTUM` at every rate; for `full`, those cells first as well, then the rest of the product by
58
+ * then `GRID_CONTINUITY_QUANTUM` at every rate, then the long quantum at the reference rate when the run measures that rate; for `full`, those cells first as well, then the rest of the product by
59
59
  * rate and quantum; for named cells, as named. A cell is listed once.
60
60
  */
61
61
  export function gridCells(
@@ -64,7 +64,9 @@ export function gridCells(
64
64
  ): GridCell[] {
65
65
  if (spec.kind === "cells") return unique(spec.cells);
66
66
  const continuity = [...context.rates].sort((a, b) => a - b).map((rate) => ({ rate, quantum: GRID_CONTINUITY_QUANTUM }));
67
- const lead = unique([...context.hosts, ...continuity]);
67
+ // the console was judged at the long quantum until its basis moved to the reference one: that cell stays measured
68
+ const long = context.rates.includes(COST_REFERENCE_RATE) ? [{ rate: COST_REFERENCE_RATE, quantum: LONG_QUANTUM_FRAMES }] : [];
69
+ const lead = unique([...context.hosts, ...continuity, ...long]);
68
70
  if (spec.kind === "hosts") return lead;
69
71
  const product = context.rates.flatMap((rate) => context.quanta.map((quantum) => ({ rate, quantum }))).sort(byRateThenQuantum);
70
72
  const inProduct = new Set(product.map(cellKey));
package/src/pins-file.ts CHANGED
@@ -127,8 +127,9 @@ export function pinClearLine(uri: string): string {
127
127
 
128
128
  /**
129
129
  * The line of one pin, or `undefined` when the integrity block is not a whole pin. The uri is one word, quoted when it
130
- * holds a space. A file path inside the bundle cannot hold whitespace, a comma or an equals sign (the protocol's PATH
131
- * limit: they are the separators of the words of a pin), so a plugin with such a file has no pin, refused by name.
130
+ * holds a space. A file path is the prober's, percent-encoded as plugin-hostd-protocol writes a pin path (Surge XT's
131
+ * "Surge XT.clap" is Surge%20XT.clap), so it holds no whitespace, comma or equals sign; one that does was not encoded,
132
+ * and the plugin has no pin, refused by name.
132
133
  */
133
134
  export function pinLine(entry: PinEntry): string | undefined {
134
135
  const { files, layout } = entry.integrity;
@@ -320,6 +320,11 @@ export function judgeProbeOutput(output: ProbeOutput, profiles: readonly HostPro
320
320
  };
321
321
  }
322
322
  }
323
+ // a run that admitted the plugin and says why its note test could not be observed (a sampler with nothing to play): shown,
324
+ // never deciding (#318)
325
+ if (ran && admission !== undefined && admission.admitted && admission.code !== undefined) {
326
+ reasons = [{ dimension: "hostAdmission", rating: "suitable", code: admission.code, params: admission.params }, ...reasons];
327
+ }
323
328
  const owed = facts.owed?.[profile.id];
324
329
  if (owed !== undefined) reasons = [owed, ...reasons];
325
330
  const rating = worstRating(reasons.map((r) => r.rating));
@@ -63,6 +63,14 @@ export interface ProbeCost {
63
63
  readonly warmupBlocks: number;
64
64
  /** For an instrument: the notes it held while it was timed, how many and why that many. */
65
65
  readonly voices?: VoicesHeld;
66
+ /** For an instrument: its cost at each count of notes held (probe output 1.4), in the cost's own unit. */
67
+ readonly voiceCurve?: readonly VoiceCurvePoint[];
68
+ }
69
+
70
+ export interface VoiceCurvePoint {
71
+ readonly held: number;
72
+ readonly median: number;
73
+ readonly percentile: { readonly p: number; readonly value: number };
66
74
  }
67
75
 
68
76
  export interface ProbeRtSafety {
@@ -255,15 +263,30 @@ function readCost(v: unknown, where: string): ProbeCost {
255
263
  if (median < 0 || value < 0) invalid(`${where} holds a negative cost`);
256
264
  const voices = o["voices"] === undefined ? undefined : readVoicesHeld(o["voices"]);
257
265
  if (o["voices"] !== undefined && voices === undefined) invalid(`${where} voices is not a count of held notes with its basis`);
266
+ const voiceCurve = o["voiceCurve"] === undefined ? undefined : readVoiceCurve(o["voiceCurve"], `${where} voiceCurve`);
258
267
  return {
259
268
  median,
260
269
  percentile: { p, value },
261
270
  blocks: posInt(o, "blocks", where),
262
271
  warmupBlocks: count(o, "warmupBlocks", where),
263
272
  ...(voices === undefined ? {} : { voices }),
273
+ ...(voiceCurve === undefined ? {} : { voiceCurve }),
264
274
  };
265
275
  }
266
276
 
277
+ function readVoiceCurve(v: unknown, where: string): VoiceCurvePoint[] {
278
+ if (!Array.isArray(v)) invalid(`${where} is not a list`);
279
+ return (v as unknown[]).map((e, i) => {
280
+ const at = `${where} entry ${i}`;
281
+ const o = record(e, at);
282
+ const pct = record(o["percentile"], `${at} percentile`);
283
+ const median = num(o, "median", at);
284
+ const value = num(pct, "value", `${at} percentile`);
285
+ if (median < 0 || value < 0) invalid(`${at} holds a negative cost`);
286
+ return { held: posInt(o, "held", at), median, percentile: { p: num(pct, "p", `${at} percentile`), value } };
287
+ });
288
+ }
289
+
267
290
  function readRtSafety(v: unknown, where: string): ProbeRtSafety {
268
291
  const o = record(v, where);
269
292
  const events = o["events"] === undefined ? undefined : (stringList(o["events"]) ?? invalid(`${where} events is not a list of strings`));
@@ -12,7 +12,7 @@
12
12
  * unavailable, an output that could not be written), 3 is no such plugin.
13
13
  */
14
14
  import { spawnSync } from "node:child_process";
15
- import { existsSync, mkdtempSync, readFileSync, rmSync } from "node:fs";
15
+ import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync } from "node:fs";
16
16
  import { availableParallelism, loadavg, tmpdir } from "node:os";
17
17
  import { join } from "node:path";
18
18
 
@@ -22,7 +22,7 @@ import type { HostProfile } from "./host-profiles.js";
22
22
  import { OPENMIXER_CONSOLE_PROFILE, shippedHostProfile } from "./host-profiles.js";
23
23
  import { IN_PROCESS_TIER_HOST, ISOLATED_TIER_HOST } from "./qualification-record.js";
24
24
  import type { PluginTarget } from "./loader.js";
25
- import { ADAPTER_RUN_HOSTS, SPAWNED_ADMISSIONS, admitPlugin, admitUnderAdapter, admittedHostOf, type AdmissionRuns, type HostAdmission } from "./host-admission.js";
25
+ import { ADAPTER_RUN_HOSTS, SPAWNED_ADMISSIONS, noJackServerProblem, admitPlugin, admitUnderAdapter, admittedHostOf, type AdmissionRuns, type HostAdmission } from "./host-admission.js";
26
26
  import { judgeProbeOutput, judgmentVerdicts, type Judgment } from "./probe-judge.js";
27
27
  import { readProbeOutput, type ProbeOutput } from "./probe-output.js";
28
28
  import { budgetCells, gridCells, hostCells, runnerInvocations, type GridCell, type GridSpec, type RunnerInvocation } from "./measurement-grid.js";
@@ -30,6 +30,10 @@ import type { MemoryBound } from "./memory-bound.js";
30
30
  import { mergeProbeRuns, ProbeMergeError } from "./probe-merge.js";
31
31
  import type { QualifyVerdict } from "./qualify-cli.js";
32
32
  import {
33
+ MEMORY_PASS_PROBE_NOTES,
34
+ PROBE_NOTES_CURVE,
35
+ PROBE_NOTES_CURVE_ENV,
36
+ PROBE_NOTES_ENV,
33
37
  CLAP_QUALIFY_TIMEOUT_S,
34
38
  CLAP_SWEEP_BLOCKS,
35
39
  CLAP_SWEEP_FRAMES,
@@ -182,7 +186,11 @@ function runOne(target: PluginTarget, options: ProbeTargetOptions, invocation: R
182
186
  const log = join(work, "child.stderr.log");
183
187
  try {
184
188
  let args: string[];
185
- let runEnv: Record<string, string | undefined> = { ...env };
189
+ // a HOME of the run's own, under its scratch directory: a plugin that reads its user data from HOME (Surge XT) dies
190
+ // or stays silent without one, and a probe must never write into the caller's real home
191
+ const home = join(work, "home");
192
+ mkdirSync(home);
193
+ let runEnv: Record<string, string | undefined> = { ...env, HOME: home };
186
194
  let expectedId: string;
187
195
  const wall = options.wallS === undefined ? {} : { wallS: options.wallS };
188
196
  const bound = options.memory === undefined ? {} : { dataBytes: options.memory.bytes };
@@ -196,7 +204,7 @@ function runOne(target: PluginTarget, options: ProbeTargetOptions, invocation: R
196
204
  target.binaryPath,
197
205
  expectedId,
198
206
  );
199
- runEnv = { ...env, LD_PRELOAD: interposer };
207
+ runEnv = { ...runEnv, LD_PRELOAD: interposer, [PROBE_NOTES_CURVE_ENV]: env[PROBE_NOTES_CURVE_ENV] ?? PROBE_NOTES_CURVE.join(",") };
200
208
  } else {
201
209
  expectedId = target.uri;
202
210
  const child = locateNativeTool(LV2_MEASURE_TOOL_NAME, env, options.exists ?? existsSync).path;
@@ -204,6 +212,14 @@ function runOne(target: PluginTarget, options: ProbeTargetOptions, invocation: R
204
212
  { ...at, ...wall, out, log, ...(child === undefined ? {} : { child }) },
205
213
  target.uri,
206
214
  );
215
+ // an instrument that declares no voice capacity is played with this many notes held, so its cost and its memory
216
+ // under notes are measured, not left voices-unknown; a count the caller set wins
217
+ runEnv = {
218
+ ...runEnv,
219
+ [PROBE_NOTES_ENV]: env[PROBE_NOTES_ENV] ?? String(MEMORY_PASS_PROBE_NOTES),
220
+ // and timed at each count of the curve, the cost against the notes held
221
+ [PROBE_NOTES_CURVE_ENV]: env[PROBE_NOTES_CURVE_ENV] ?? PROBE_NOTES_CURVE.join(","),
222
+ };
207
223
  }
208
224
  // under a bound, the interposer ends the child the moment an allocation is refused, with the status that names it
209
225
  if (options.memory !== undefined) runEnv = { ...runEnv, [MEMORY_BOUND_EXIT_ENV]: "1" };
@@ -322,12 +338,17 @@ export function qualifyTargets(
322
338
  const admissions: Record<string, HostAdmission> = {};
323
339
  // an LV2 plugin is also run once under plugin-hostd's LV2 adapter, recorded beside the verdicts (#223)
324
340
  const adapter = target.format === "lv2" ? admitUnderAdapter(target.uri, admissionRuns, admissionEnv) : undefined;
341
+ // no JACK server is the machine's, not the plugin's: the run stops by name instead of recording resp -201 in every record
342
+ const noJack = noJackServerProblem(adapter);
343
+ if (noJack !== undefined) throw new ProbeRunnerError(noJack);
325
344
  // and that run decides its omx-clap-host verdict, the isolated tier
326
345
  if (adapter !== undefined) for (const host of ADAPTER_RUN_HOSTS) admissions[host] = adapter;
327
346
  if (target.format === "lv2") {
328
347
  for (const profile of judgedProfiles) {
329
348
  const host = admittedHostOf(profile);
330
349
  if (host !== undefined) admissions[profile.id] = admitPlugin(host, target.uri, admissionRuns, admissionEnv);
350
+ const noJackHost = noJackServerProblem(admissions[profile.id]);
351
+ if (noJackHost !== undefined) throw new ProbeRunnerError(noJackHost);
331
352
  }
332
353
  }
333
354
  for (const profile of judgedProfiles) {
@@ -20,11 +20,12 @@ import { join } from "node:path";
20
20
 
21
21
  import type { Adjustment } from "./history-adjust.js";
22
22
  import type { Judgment, RecordReason } from "./probe-judge.js";
23
- import { sha256Hex, PROBE_OK, type ProbeGridPoint, type ProbeOutput } from "./probe-output.js";
23
+ import { sha256Hex, PROBE_NOT_ATTEMPTED, PROBE_OK, type ProbeGridPoint, type ProbeOutput } from "./probe-output.js";
24
24
  import type { VoicesHeld } from "./measurement/format.js";
25
25
  import { writeFileWhole } from "./whole-file.js";
26
26
  import { HOSTING_CODE } from "./hosting-codes.js";
27
27
  import { MEASUREMENT_UNMEASURED_REASONS } from "@openmixer/omx-contract";
28
+ import { judgementRules, latencyMsOf, LATENCY_LINE_MS } from "./judgement-line.js";
28
29
 
29
30
  export const QUALIFICATION_RECORD_SCHEMA = "plugin-qualify.qualification-record/1";
30
31
 
@@ -201,6 +202,8 @@ export type RecordGridPoint = Omit<ProbeGridPoint, "latency" | "memory"> & {
201
202
  /** The footprint as measured, with what it comes to: what a client adding the plugin reads (`memory-budget.ts`). */
202
203
  readonly memory?: MemoryFootprint & { readonly firstInstanceKb?: number; readonly perInstanceKb?: number };
203
204
  readonly latency: (Omit<NonNullable<ProbeGridPoint["latency"]>, "measuredFrames"> & { readonly measuredFrames: number }) | UnmeasuredLatency;
205
+ /** The measured latency in milliseconds at the cell's rate, beside the record's `latencyLineMs`; absent when none was measured. */
206
+ readonly latencyMs?: number;
204
207
  };
205
208
 
206
209
  const UNMEASURED_WORDS: ReadonlySet<string> = new Set(Object.values(MEASUREMENT_UNMEASURED_REASONS).map((r) => r.word));
@@ -220,12 +223,20 @@ export function memoryOfCell(p: ProbeGridPoint): Pick<RecordGridPoint, "memory">
220
223
  return { memory: { ...p.memory, ...(first === undefined ? {} : { firstInstanceKb: first }), ...(per === undefined ? {} : { perInstanceKb: per }) } };
221
224
  }
222
225
 
226
+ /** A grid point as the record writes it: its footprint, its latency or why there is none, and the latency in milliseconds. */
227
+ export function gridPointOf(output: ProbeOutput, p: ProbeGridPoint): RecordGridPoint {
228
+ const latency = latencyOfCell(output, p);
229
+ const frames = (latency as { measuredFrames?: number }).measuredFrames;
230
+ return { ...p, ...memoryOfCell(p), latency, ...(frames === undefined ? {} : { latencyMs: latencyMsOf(frames, p.rate) }) };
231
+ }
232
+
223
233
  /** The unmeasured word of a cell whose run did not end well, by its outcome code. */
224
234
  const OUTCOME_WORD: Readonly<Record<string, string>> = {
225
235
  "probe.crashed": word("probeCrashed"),
226
236
  "probe.timeout": word("probeTimeout"),
227
237
  "probe.refused-instantiation": word("refusedInstantiation"),
228
238
  "probe.non-finite-output": word("nonFiniteOutput"),
239
+ [PROBE_NOT_ATTEMPTED]: word("notAttempted"),
229
240
  };
230
241
 
231
242
  /**
@@ -361,6 +372,10 @@ export interface QualificationRecord {
361
372
  /** Who measured and when. */
362
373
  readonly tool: Readonly<Record<string, string>>;
363
374
  readonly measuredAt: string;
375
+ /** The latency line the cells' `latencyMs` stand against (`LATENCY_LINE_MS`); absent on a record written before it was declared. */
376
+ readonly latencyLineMs?: number;
377
+ /** The rules the verdicts were judged by (`judgementRules`); absent on a record written before they were stated. */
378
+ readonly rules?: string;
364
379
  /** The second verdict, per host class of the history that was read; absent until `adjust --history` has run. */
365
380
  readonly history?: readonly HistoryBlock[];
366
381
  /** Where the record came from when it was not measured on this device: the distributed set's provenance, as the set's package wrote it. */
@@ -419,7 +434,19 @@ export interface NotMeasured {
419
434
  readonly code: string;
420
435
  }
421
436
 
422
- const safe = (text: string): string => text.replace(/[^A-Za-z0-9._-]/g, "_");
437
+ /**
438
+ * A name part as plugin-hostd-protocol's descriptor name rule writes it (PHD_DESCRIPTOR_SAFE_CHAR): each byte of the
439
+ * UTF-8 text outside [A-Za-z0-9._-] is one "_", as plugin-hostd's descriptors.c reads the name. "é" is two bytes: "__".
440
+ */
441
+ export function descriptorNamePart(text: string): string {
442
+ let out = "";
443
+ for (const byte of Buffer.from(text, "utf8")) {
444
+ const c = String.fromCharCode(byte);
445
+ out += /[A-Za-z0-9._-]/.test(c) && byte < 0x80 ? c : "_";
446
+ }
447
+ return out;
448
+ }
449
+ const safe = descriptorNamePart;
423
450
 
424
451
  /** `<id>@<version>-<sha256 first 12>.<offer>`: one binary and one offer, whatever the run. */
425
452
  export function qualificationBaseName(output: ProbeOutput): string {
@@ -483,13 +510,15 @@ export function buildQualificationRecord(
483
510
  tiers: tiersOf(judgment),
484
511
  cost: judgment.hosts.map((h) => ({ host: h.verdict.host, ...h.cost })),
485
512
  measurements: {
486
- grid: o.grid.map((p) => ({ ...p, ...memoryOfCell(p), latency: latencyOfCell(o, p) })),
513
+ grid: o.grid.map((p) => gridPointOf(o, p)),
487
514
  ...(o.behaviour === undefined ? {} : { behaviour: o.behaviour }),
488
515
  ...(unmeasuredFigures(o).length === 0 ? {} : { unmeasured: unmeasuredFigures(o) }),
489
516
  },
490
517
  ...(notMeasured.length === 0 ? {} : { notMeasured }),
491
518
  tool: o.run.tools,
492
519
  measuredAt: o.run.startedAt,
520
+ latencyLineMs: LATENCY_LINE_MS,
521
+ rules: judgementRules(),
493
522
  probe: {
494
523
  file: copy.file,
495
524
  sha256: copy.sha256,
@@ -22,7 +22,6 @@ import { HOSTD_ENV } from "./hostd-pin-files.js";
22
22
  import { freeDeadJackSlots } from "./jack-registry.js";
23
23
  import { cellKey, type GridCell } from "./measurement-grid.js";
24
24
  import { defaultAddressSpaceLimit } from "./direct-limit.js";
25
- import { PROBE_OK } from "./probe-output.js";
26
25
  import { QUALIFICATION_RECORD_SCHEMA, type AdapterBlock, type QualificationRecord } from "./qualification-record.js";
27
26
  import { ADMIT_ADDRESS_KB_ENV, ADMIT_STATE_DIR_ENV, ADMIT_STEP_MS_ENV, PI_CELLS } from "./qualify-declarations.js";
28
27
  import { digestFiles, type SyncContext, type SyncState } from "./qualify-sync.js";
@@ -90,7 +89,8 @@ const REAPING_JACKD = `trap 'kill -TERM $p 2>/dev/null' TERM; trap 'kill -KILL $
90
89
 
91
90
  /** `jackd` on a name of its own and the dummy driver, at the cell's rate and quantum; `undefined` when none came up. */
92
91
  export const startPrivateJack: JackStarter = (cell) => {
93
- const name = `omx-qualify-${String(process.pid)}-${String(cell.quantum)}`;
92
+ // the rate is in the name: the cells of one pass run at the same quantum at two rates, on servers alive together
93
+ const name = `omx-qualify-${String(process.pid)}-${String(cell.rate)}-${String(cell.quantum)}`;
94
94
  // the rows of servers of ours that were killed, freed before this one asks for a row
95
95
  freeDeadJackSlots();
96
96
  let child: ChildProcess;
@@ -238,8 +238,7 @@ const readRecord = (path: string): QualificationRecord | undefined => {
238
238
  };
239
239
 
240
240
  /**
241
- * The run of each LV2 plugin of the state whose probe ended well (one that did not has no verdict a run could decide), at
242
- * each cell. Each record is written whole as its plugin ends.
241
+ * The run of each LV2 plugin of the state, whatever its probe ended with, at each cell. Each record is written whole as its plugin ends.
243
242
  */
244
243
  export function adapterPass(ctx: SyncContext, state: SyncState, options: AdapterPassOptions = {}): AdapterPassResult {
245
244
  const read = hostVersions(ctx.env, options.versions);
@@ -279,7 +278,9 @@ export function adapterPass(ctx: SyncContext, state: SyncState, options: Adapter
279
278
  count.failed++;
280
279
  continue;
281
280
  }
282
- if (record.probe.outcome !== PROBE_OK) continue;
281
+ // a probe that crashed, hung or measured nothing is run too: the adapter's own process is not the probe's, and its
282
+ // answer replaces whatever the main run recorded there (a missing JACK server's no-jack-client), so no record keeps a
283
+ // stale code. The probe's outcome stays in the record beside it.
283
284
  if (options.force !== true && adapterFinished(record, versions)) {
284
285
  count.already++;
285
286
  continue;