@vessel-dsp/compiler 0.0.0-stage → 0.3.0

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 (226) hide show
  1. package/README.md +118 -2
  2. package/dist/bake.d.ts +38 -0
  3. package/dist/bake.d.ts.map +1 -0
  4. package/dist/bake.js +101 -0
  5. package/dist/bake.js.map +1 -0
  6. package/dist/bbd-clock.d.ts +171 -0
  7. package/dist/bbd-clock.d.ts.map +1 -0
  8. package/dist/bbd-clock.js +1750 -0
  9. package/dist/bbd-clock.js.map +1 -0
  10. package/dist/block-row.d.ts +51 -0
  11. package/dist/block-row.d.ts.map +1 -0
  12. package/dist/block-row.js +17 -0
  13. package/dist/block-row.js.map +1 -0
  14. package/dist/bypass.d.ts +3 -0
  15. package/dist/bypass.d.ts.map +1 -0
  16. package/dist/bypass.js +228 -0
  17. package/dist/bypass.js.map +1 -0
  18. package/dist/compile.d.ts +24 -0
  19. package/dist/compile.d.ts.map +1 -0
  20. package/dist/compile.js +348 -0
  21. package/dist/compile.js.map +1 -0
  22. package/dist/converter-scale.d.ts +14 -0
  23. package/dist/converter-scale.d.ts.map +1 -0
  24. package/dist/converter-scale.js +133 -0
  25. package/dist/converter-scale.js.map +1 -0
  26. package/dist/couple.d.ts +28 -0
  27. package/dist/couple.d.ts.map +1 -0
  28. package/dist/couple.js +567 -0
  29. package/dist/couple.js.map +1 -0
  30. package/dist/dangling-active-terminal.d.ts +47 -0
  31. package/dist/dangling-active-terminal.d.ts.map +1 -0
  32. package/dist/dangling-active-terminal.js +542 -0
  33. package/dist/dangling-active-terminal.js.map +1 -0
  34. package/dist/declared-program.d.ts +23 -0
  35. package/dist/declared-program.d.ts.map +1 -0
  36. package/dist/declared-program.js +387 -0
  37. package/dist/declared-program.js.map +1 -0
  38. package/dist/denomination.d.ts +48 -0
  39. package/dist/denomination.d.ts.map +1 -0
  40. package/dist/denomination.js +27 -0
  41. package/dist/denomination.js.map +1 -0
  42. package/dist/device-laws.d.ts +237 -0
  43. package/dist/device-laws.d.ts.map +1 -0
  44. package/dist/device-laws.js +3513 -0
  45. package/dist/device-laws.js.map +1 -0
  46. package/dist/diagnostics.d.ts +13 -0
  47. package/dist/diagnostics.d.ts.map +1 -0
  48. package/dist/diagnostics.js +19 -0
  49. package/dist/diagnostics.js.map +1 -0
  50. package/dist/emit.d.ts +8 -0
  51. package/dist/emit.d.ts.map +1 -0
  52. package/dist/emit.js +43 -0
  53. package/dist/emit.js.map +1 -0
  54. package/dist/errors.d.ts +22 -0
  55. package/dist/errors.d.ts.map +1 -0
  56. package/dist/errors.js +39 -0
  57. package/dist/errors.js.map +1 -0
  58. package/dist/firmware-class.d.ts +69 -0
  59. package/dist/firmware-class.d.ts.map +1 -0
  60. package/dist/firmware-class.js +20 -0
  61. package/dist/firmware-class.js.map +1 -0
  62. package/dist/fixtures/circuits.d.ts +1742 -0
  63. package/dist/fixtures/circuits.d.ts.map +1 -0
  64. package/dist/fixtures/circuits.js +13896 -0
  65. package/dist/fixtures/circuits.js.map +1 -0
  66. package/dist/fixtures/expected.d.ts +261 -0
  67. package/dist/fixtures/expected.d.ts.map +1 -0
  68. package/dist/fixtures/expected.js +315 -0
  69. package/dist/fixtures/expected.js.map +1 -0
  70. package/dist/fixtures/index.d.ts +4 -0
  71. package/dist/fixtures/index.d.ts.map +1 -0
  72. package/dist/fixtures/index.js +8 -0
  73. package/dist/fixtures/index.js.map +1 -0
  74. package/dist/fixtures/registry.d.ts +52 -0
  75. package/dist/fixtures/registry.d.ts.map +1 -0
  76. package/dist/fixtures/registry.js +341 -0
  77. package/dist/fixtures/registry.js.map +1 -0
  78. package/dist/generic-tube-fit.d.ts +12 -0
  79. package/dist/generic-tube-fit.d.ts.map +1 -0
  80. package/dist/generic-tube-fit.js +45 -0
  81. package/dist/generic-tube-fit.js.map +1 -0
  82. package/dist/grounded-clock-supply.d.ts +13 -0
  83. package/dist/grounded-clock-supply.d.ts.map +1 -0
  84. package/dist/grounded-clock-supply.js +45 -0
  85. package/dist/grounded-clock-supply.js.map +1 -0
  86. package/dist/identify.d.ts +50 -0
  87. package/dist/identify.d.ts.map +1 -0
  88. package/dist/identify.js +319 -0
  89. package/dist/identify.js.map +1 -0
  90. package/dist/index.d.ts +10 -0
  91. package/dist/index.d.ts.map +1 -0
  92. package/dist/index.js +19 -0
  93. package/dist/index.js.map +1 -0
  94. package/dist/inert-controls.d.ts +15 -0
  95. package/dist/inert-controls.d.ts.map +1 -0
  96. package/dist/inert-controls.js +266 -0
  97. package/dist/inert-controls.js.map +1 -0
  98. package/dist/latch-seed.d.ts +53 -0
  99. package/dist/latch-seed.d.ts.map +1 -0
  100. package/dist/latch-seed.js +257 -0
  101. package/dist/latch-seed.js.map +1 -0
  102. package/dist/link.d.ts +7 -0
  103. package/dist/link.d.ts.map +1 -0
  104. package/dist/link.js +270 -0
  105. package/dist/link.js.map +1 -0
  106. package/dist/lower.d.ts +79 -0
  107. package/dist/lower.d.ts.map +1 -0
  108. package/dist/lower.js +1855 -0
  109. package/dist/lower.js.map +1 -0
  110. package/dist/netlist.d.ts +79 -0
  111. package/dist/netlist.d.ts.map +1 -0
  112. package/dist/netlist.js +4746 -0
  113. package/dist/netlist.js.map +1 -0
  114. package/dist/non-executable-clock-drivers.d.ts +8 -0
  115. package/dist/non-executable-clock-drivers.d.ts.map +1 -0
  116. package/dist/non-executable-clock-drivers.js +33 -0
  117. package/dist/non-executable-clock-drivers.js.map +1 -0
  118. package/dist/open-category.d.ts +98 -0
  119. package/dist/open-category.d.ts.map +1 -0
  120. package/dist/open-category.js +111 -0
  121. package/dist/open-category.js.map +1 -0
  122. package/dist/over-driven-node.d.ts +33 -0
  123. package/dist/over-driven-node.d.ts.map +1 -0
  124. package/dist/over-driven-node.js +188 -0
  125. package/dist/over-driven-node.js.map +1 -0
  126. package/dist/part-catalog.d.ts +15 -0
  127. package/dist/part-catalog.d.ts.map +1 -0
  128. package/dist/part-catalog.js +6712 -0
  129. package/dist/part-catalog.js.map +1 -0
  130. package/dist/part-number.d.ts +32 -0
  131. package/dist/part-number.d.ts.map +1 -0
  132. package/dist/part-number.js +80 -0
  133. package/dist/part-number.js.map +1 -0
  134. package/dist/partition.d.ts +7 -0
  135. package/dist/partition.d.ts.map +1 -0
  136. package/dist/partition.js +242 -0
  137. package/dist/partition.js.map +1 -0
  138. package/dist/port-full-scale.d.ts +70 -0
  139. package/dist/port-full-scale.d.ts.map +1 -0
  140. package/dist/port-full-scale.js +235 -0
  141. package/dist/port-full-scale.js.map +1 -0
  142. package/dist/pot-orientation.d.ts +114 -0
  143. package/dist/pot-orientation.d.ts.map +1 -0
  144. package/dist/pot-orientation.js +551 -0
  145. package/dist/pot-orientation.js.map +1 -0
  146. package/dist/power-domain-control.d.ts +40 -0
  147. package/dist/power-domain-control.d.ts.map +1 -0
  148. package/dist/power-domain-control.js +142 -0
  149. package/dist/power-domain-control.js.map +1 -0
  150. package/dist/proxy-declaration.d.ts +121 -0
  151. package/dist/proxy-declaration.d.ts.map +1 -0
  152. package/dist/proxy-declaration.js +50 -0
  153. package/dist/proxy-declaration.js.map +1 -0
  154. package/dist/registry.d.ts +323 -0
  155. package/dist/registry.d.ts.map +1 -0
  156. package/dist/registry.js +192 -0
  157. package/dist/registry.js.map +1 -0
  158. package/dist/sparse-schedule.d.ts +65 -0
  159. package/dist/sparse-schedule.d.ts.map +1 -0
  160. package/dist/sparse-schedule.js +421 -0
  161. package/dist/sparse-schedule.js.map +1 -0
  162. package/dist/speaker-load.d.ts +38 -0
  163. package/dist/speaker-load.d.ts.map +1 -0
  164. package/dist/speaker-load.js +97 -0
  165. package/dist/speaker-load.js.map +1 -0
  166. package/dist/stage-coverage.d.ts +21 -0
  167. package/dist/stage-coverage.d.ts.map +1 -0
  168. package/dist/stage-coverage.js +124 -0
  169. package/dist/stage-coverage.js.map +1 -0
  170. package/dist/stamp-partition.d.ts +314 -0
  171. package/dist/stamp-partition.d.ts.map +1 -0
  172. package/dist/stamp-partition.js +472 -0
  173. package/dist/stamp-partition.js.map +1 -0
  174. package/dist/supply-reference.d.ts +19 -0
  175. package/dist/supply-reference.d.ts.map +1 -0
  176. package/dist/supply-reference.js +66 -0
  177. package/dist/supply-reference.js.map +1 -0
  178. package/dist/supply-short.d.ts +32 -0
  179. package/dist/supply-short.d.ts.map +1 -0
  180. package/dist/supply-short.js +118 -0
  181. package/dist/supply-short.js.map +1 -0
  182. package/dist/supply-stamps.d.ts +51 -0
  183. package/dist/supply-stamps.d.ts.map +1 -0
  184. package/dist/supply-stamps.js +363 -0
  185. package/dist/supply-stamps.js.map +1 -0
  186. package/dist/terminal-role.d.ts +109 -0
  187. package/dist/terminal-role.d.ts.map +1 -0
  188. package/dist/terminal-role.js +46 -0
  189. package/dist/terminal-role.js.map +1 -0
  190. package/dist/terminal-roles.d.ts +59 -0
  191. package/dist/terminal-roles.d.ts.map +1 -0
  192. package/dist/terminal-roles.js +92 -0
  193. package/dist/terminal-roles.js.map +1 -0
  194. package/dist/transformer.d.ts +181 -0
  195. package/dist/transformer.d.ts.map +1 -0
  196. package/dist/transformer.js +476 -0
  197. package/dist/transformer.js.map +1 -0
  198. package/dist/types.d.ts +3157 -0
  199. package/dist/types.d.ts.map +1 -0
  200. package/dist/types.js +11 -0
  201. package/dist/types.js.map +1 -0
  202. package/dist/unbounded-operating-point.d.ts +35 -0
  203. package/dist/unbounded-operating-point.d.ts.map +1 -0
  204. package/dist/unbounded-operating-point.js +181 -0
  205. package/dist/unbounded-operating-point.js.map +1 -0
  206. package/dist/unexecuted-region.d.ts +3 -0
  207. package/dist/unexecuted-region.d.ts.map +1 -0
  208. package/dist/unexecuted-region.js +122 -0
  209. package/dist/unexecuted-region.js.map +1 -0
  210. package/dist/unimplemented-control-role.d.ts +3 -0
  211. package/dist/unimplemented-control-role.d.ts.map +1 -0
  212. package/dist/unimplemented-control-role.js +61 -0
  213. package/dist/unimplemented-control-role.js.map +1 -0
  214. package/dist/unreachable-output.d.ts +3 -0
  215. package/dist/unreachable-output.d.ts.map +1 -0
  216. package/dist/unreachable-output.js +97 -0
  217. package/dist/unreachable-output.js.map +1 -0
  218. package/dist/unreadable-terminal-role.d.ts +67 -0
  219. package/dist/unreadable-terminal-role.d.ts.map +1 -0
  220. package/dist/unreadable-terminal-role.js +409 -0
  221. package/dist/unreadable-terminal-role.js.map +1 -0
  222. package/dist/unverified-pinout.d.ts +27 -0
  223. package/dist/unverified-pinout.d.ts.map +1 -0
  224. package/dist/unverified-pinout.js +121 -0
  225. package/dist/unverified-pinout.js.map +1 -0
  226. package/package.json +75 -5
@@ -0,0 +1,118 @@
1
+ // Diodes wired forward across a supply, which no built circuit contains.
2
+ //
3
+ // A warning rather than a refusal, matching the other two: the program builds, the pedal
4
+ // renders, and this says the rendered circuit contains a short that the source almost certainly
5
+ // did not intend. `ibanez-ts808` and `ibanez-ts9` each carry **1.074 A** through a
6
+ // reverse-polarity protection diode on a 9 V supply, and reported nothing until now.
7
+ //
8
+ // Evidence is connectivity plus terminal roles, both of which this pipeline already reads to
9
+ // tell an anode from a cathode. No component name, no `Description`, no part number.
10
+ /** Role tokens naming a diode's ends, as `terminalRoleToken` leaves them. */
11
+ const anodeRoles = new Set(["anode", "a", "p", "plus", "positive"]);
12
+ const cathodeRoles = new Set(["cathode", "k", "c", "minus", "negative"]);
13
+ /**
14
+ * A diode whose **anode sits on a supply node and whose cathode sits on ground** is forward
15
+ * biased by the whole supply. In a real circuit that is a dead short: the junction conducts
16
+ * until something fails.
17
+ *
18
+ * The runtime does not diverge on it, which is why this went unseen. `DIODE_VOLTAGE_LIMIT` caps
19
+ * the junction voltage at `0.9 V` before the current is computed, so instead of running away the
20
+ * diode settles at about **1 A** — and the supply is an ideal source, so it simply sinks that
21
+ * current and the pedal renders a plausible level. `ibanez-ts808` renders a gain of `0.506` with
22
+ * a 1 A short on its rail. The clamp is a convergence device that turned out to be hiding a
23
+ * circuit defect, which is the same shape as several other masks found the same day.
24
+ *
25
+ * **Directness is required, and it is what makes this precise.** The check asks that the anode
26
+ * be *on* a node a `voltage-source` or `rail` device terminates, and the cathode be ground
27
+ * itself. An indicator LED fed through a series resistor does not match, because its anode sits
28
+ * on the resistor's node rather than the supply's — so the common legitimate arrangement is
29
+ * excluded by construction rather than by a special case.
30
+ *
31
+ * Measured over the pedal corpus: **6 diodes across 6 packets** match structurally, of which the
32
+ * two that compile carry `1.074 A` each. The other four are in the unsupported population, so
33
+ * they are flagged the moment their packets compile.
34
+ *
35
+ * The warning states the structure and the polarity, and does **not** claim the source is wrong.
36
+ * A protection diode reversed in the source and a protection diode this pipeline has mis-read
37
+ * look identical from here; what makes it reportable is that either way the compiled circuit
38
+ * contains a short. Checked on `ibanez-ts808`: the source itself declares `anode` on the 9 V
39
+ * node and `cathode` on ground, so the role reading is not at fault there — but that is a
40
+ * per-packet finding rather than something this stage should assert.
41
+ */
42
+ export function findSupplyShorts(netlist) {
43
+ const positiveSupplyNodes = new Set();
44
+ const negativeSupplyNodes = new Set();
45
+ for (const device of netlist.devices) {
46
+ if (device.kind !== "voltage-source" && device.kind !== "rail") {
47
+ continue;
48
+ }
49
+ const volts = device.parameters.volts;
50
+ for (const node of device.nodes) {
51
+ if (node !== 0) {
52
+ if (volts !== undefined && volts < 0) {
53
+ negativeSupplyNodes.add(node);
54
+ }
55
+ else {
56
+ positiveSupplyNodes.add(node);
57
+ }
58
+ }
59
+ }
60
+ }
61
+ if (positiveSupplyNodes.size === 0 && negativeSupplyNodes.size === 0) {
62
+ return [];
63
+ }
64
+ const warnings = [];
65
+ for (const device of netlist.devices) {
66
+ if (device.kind !== "diode" || device.nodes.length !== 2) {
67
+ continue;
68
+ }
69
+ const ends = diodeEnds(device);
70
+ if (ends === null) {
71
+ continue;
72
+ }
73
+ const [anode, cathode] = ends;
74
+ if (positiveSupplyNodes.has(anode) && cathode === 0) {
75
+ warnings.push({
76
+ code: "diode-forward-across-supply",
77
+ device: device.id,
78
+ detail: `diode ${device.id} has its anode on positive supply node ${anode} and its cathode on ground, ` +
79
+ "so the whole supply forward biases it: the compiled circuit contains a short across " +
80
+ "the supply, which the runtime renders rather than diverging on only because the " +
81
+ "junction voltage is clamped",
82
+ });
83
+ }
84
+ else if (negativeSupplyNodes.has(cathode) && anode === 0) {
85
+ warnings.push({
86
+ code: "diode-forward-across-supply",
87
+ device: device.id,
88
+ detail: `diode ${device.id} has its anode on ground and its cathode on negative supply node ${cathode}, ` +
89
+ "so the whole supply forward biases it: the compiled circuit contains a short across " +
90
+ "the supply, which the runtime renders rather than diverging on only because the " +
91
+ "junction voltage is clamped",
92
+ });
93
+ }
94
+ }
95
+ return warnings;
96
+ }
97
+ /**
98
+ * A diode's `(anode, cathode)` nodes, or `null` when its roles do not name exactly one of each.
99
+ *
100
+ * No positional fallback. A diode whose ends are unlabelled cannot be said to point anywhere, and
101
+ * guessing would let this warning accuse a circuit of a short on the strength of terminal order.
102
+ */
103
+ function diodeEnds(device) {
104
+ const roles = device.identity.terminalRoles;
105
+ const only = (accepted) => {
106
+ const found = roles.flatMap((role, index) => role !== null && accepted.has(role) ? [index] : []);
107
+ return found.length === 1 ? (found[0] ?? null) : null;
108
+ };
109
+ const anode = only(anodeRoles);
110
+ const cathode = only(cathodeRoles);
111
+ if (anode === null || cathode === null) {
112
+ return null;
113
+ }
114
+ const a = device.nodes[anode];
115
+ const c = device.nodes[cathode];
116
+ return a === undefined || c === undefined ? null : [a, c];
117
+ }
118
+ //# sourceMappingURL=supply-short.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"supply-short.js","sourceRoot":"","sources":["../src/supply-short.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,EAAE;AACF,yFAAyF;AACzF,gGAAgG;AAChG,mFAAmF;AACnF,qFAAqF;AACrF,EAAE;AACF,6FAA6F;AAC7F,qFAAqF;AAIrF,6EAA6E;AAC7E,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;A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AAC,CAAC,CAAC,CAAC,EAAE,CAClD,CAAC;QACF,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACvD,CAAC,CAAC;IACF,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC;IAC/B,MAAM,OAAO,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC;IACnC,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QACxC,OAAO,IAAI,CAAC;IACb,CAAC;IACD,MAAM,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC9B,MAAM,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAChC,OAAO,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAC3D,CAAC"}
@@ -0,0 +1,51 @@
1
+ import type { Program } from "./types";
2
+ /** Where a supply stamp lives: which block holds it and which source it is. */
3
+ export type SupplyAddress = {
4
+ readonly blockIndex: number;
5
+ readonly sourceIndex: number;
6
+ };
7
+ export type ResolvedSupply = {
8
+ readonly address: SupplyAddress;
9
+ readonly railComponentId: string;
10
+ readonly role: string;
11
+ readonly nominalVolts: number | null;
12
+ /**
13
+ * How the rail reached its stamp, compared as a whole value.
14
+ *
15
+ * `rail-device` is the rail's own lowered device matched to a stamp through
16
+ * `block.nodeIds`. `domain-source` is the fallback below: the rail is a
17
+ * label or port with no lowered device, and the stamp is the one the
18
+ * domain's own source components lower to. A host can show or ignore the
19
+ * weaker path; both are typed evidence, never names.
20
+ */
21
+ readonly via: "rail-device" | "domain-source";
22
+ };
23
+ /**
24
+ * Why a rail was left on its compiled values, compared as whole values.
25
+ *
26
+ * Closed on purpose: callers switch on `reason`, and the prose in `detail` is
27
+ * for a human reading a report, never for a test to match.
28
+ */
29
+ export type SupplyRefusalReason = "no-power-section" | "mains-ac-source" | "unknown-source-kind" | "source-kind-conflict" | "derived-rail" | "rail-not-main-supply" | "no-stamp-for-rail" | "ambiguous-stamp";
30
+ export type RefusedSupply = {
31
+ readonly railComponentId: string | null;
32
+ readonly reason: SupplyRefusalReason;
33
+ readonly detail: string;
34
+ };
35
+ export type SupplyResolution = {
36
+ readonly supplies: readonly ResolvedSupply[];
37
+ readonly refused: readonly RefusedSupply[];
38
+ };
39
+ /**
40
+ * Join the document's power domains to the program's `dc-source` stamps.
41
+ *
42
+ * Only rails in an `external-dc` domain -- declared, or inferred from the
43
+ * domain's source components when `sourceKind` is absent -- whose
44
+ * `derivation` is `direct` and whose `role` is `main-supply` are candidates.
45
+ * Each candidate's `railComponentId` resolves to its lowered device, whose
46
+ * nodes are matched to the single `dc-source` stamp with a terminal on one
47
+ * of them. Zero or several such stamps is a refusal naming the rail, never
48
+ * a guess.
49
+ */
50
+ export declare function resolveSupplyStamps(source: string, program: Program): SupplyResolution;
51
+ //# sourceMappingURL=supply-stamps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"supply-stamps.d.ts","sourceRoot":"","sources":["../src/supply-stamps.ts"],"names":[],"mappings":"AAgEA,OAAO,KAAK,EAAU,OAAO,EAAE,MAAM,SAAS,CAAC;AAG/C,+EAA+E;AAC/E,MAAM,MAAM,aAAa,GAAG;IAC3B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC5B,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;IAChC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC;;;;;;;;OAQG;IACH,QAAQ,CAAC,GAAG,EAAE,aAAa,GAAG,eAAe,CAAC;CAC9C,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,mBAAmB,GAC5B,kBAAkB,GAClB,iBAAiB,GACjB,qBAAqB,GACrB,sBAAsB,GACtB,cAAc,GACd,sBAAsB,GACtB,mBAAmB,GACnB,iBAAiB,CAAC;AAErB,MAAM,MAAM,aAAa,GAAG;IAC3B,QAAQ,CAAC,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC,QAAQ,CAAC,MAAM,EAAE,mBAAmB,CAAC;IACrC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC9B,QAAQ,CAAC,QAAQ,EAAE,SAAS,cAAc,EAAE,CAAC;IAC7C,QAAQ,CAAC,OAAO,EAAE,SAAS,aAAa,EAAE,CAAC;CAC3C,CAAC;AAoCF;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAClC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,GACd,gBAAgB,CAoNlB"}
@@ -0,0 +1,363 @@
1
+ // Which compiled `dc-source` stamps are the circuit's external supply.
2
+ //
3
+ // A compiled Program cannot tell its external rail from its derived ones: the
4
+ // compiler ignores power domains, so klon-centaur's +9, +18 and -9 all lower to
5
+ // plain `dc-source` stamps. A battery profile must be applied to the external
6
+ // rail only, otherwise one cell is counted three times. The document model
7
+ // declares which rail is external in typed fields (`CircuitPowerDomain` /
8
+ // `CircuitPowerRailBinding`: `sourceKind`, `role`, `derivation`,
9
+ // `railComponentId`, `nominalVoltage`), and this module joins that declaration
10
+ // to the compiled stamps.
11
+ //
12
+ // Typed evidence only. This module never reads component names, designators,
13
+ // descriptions, or any other prose: a rail is its `railComponentId`, a source
14
+ // is its lowered device kind, and a stamp is its terminal rows. Renaming every
15
+ // component in the document without touching the typed linkage returns the
16
+ // same resolution.
17
+ //
18
+ // Two joins, both through the compiler's own lowering rather than geometry:
19
+ //
20
+ // 1. Source kind. Most real packets predate `sourceKind`, so when it is
21
+ // absent the domain's `sourceComponentIds` are classified by the same typed
22
+ // discriminator the device laws use (`device-laws.ts`): a `voltage-source`
23
+ // device with a positive finite `frequency` parameter lowers to `ac-source`
24
+ // and everything else in that kind lowers to `dc-source`; a `rail` with a
25
+ // finite `volts` parameter lowers to `voltage-source` and without one stays
26
+ // `open`; a `transformer` is mains-side magnetics. Any mains evidence makes
27
+ // the domain mains: a boundary touching the wall socket is mains-fed even
28
+ // when it also names DC rails downstream of its rectifier. An explicit
29
+ // `sourceKind` still wins, and a clean contradiction between it and the
30
+ // lowered evidence is its own refusal rather than a silent override.
31
+ // 2. Rail to stamp. The rail's device is read from the compiler netlist
32
+ // (`readNetlist`, the same stage `compile` runs first, so declared `node:`
33
+ // keys and the `nodes:` ledger resolve exactly as they did at compile
34
+ // time), and its nodes are matched to `dc-source` stamps through
35
+ // `block.nodeIds`, which translates a stamp's row back to its source node
36
+ // (`lower.ts` builds `nodeIds` as row -> source `NodeId`). Either terminal
37
+ // may identify the rail -- a battery-style supply hangs it off one end or
38
+ // the other depending on grounding, while a single-ended `rail` asserts
39
+ // its potential on the positive terminal with the sign in its volts --
40
+ // except ground on the negative side: node 0 is the common return every
41
+ // supply shares, so it can never name a rail.
42
+ // 3. Rail labels with no device. A port or label rail lowers to no device, so
43
+ // its own nodes cannot name a stamp -- but the domain's `sourceComponentIds`
44
+ // say which components feed it, and the stamp is the `dc-source` those
45
+ // sources lower to, read from the program through `block.nodeIds` exactly
46
+ // as in join 2. Only sources with DC evidence (the device-laws
47
+ // discriminator: a `voltage-source` without a positive finite `frequency`,
48
+ // a `rail` with a finite `volts`) contribute; a jack, an `ac-source`, a
49
+ // transformer, or an `open` never counts. Exactly one distinct stamp maps
50
+ // the rail (`via: "domain-source"`); zero keeps `no-stamp-for-rail` and
51
+ // more than one is `ambiguous-stamp`. The mains rule still runs first, so
52
+ // none of this can reach a mains-fed domain.
53
+ //
54
+ // The inputs are the `.vdsp` source text and the program compiled from it (the
55
+ // node resolution does not depend on compile jack options, so none are taken).
56
+ // Pure: reads both inputs, mutates neither, and leaves the program's stamps
57
+ // exactly as compiled. A source text that cannot be read throws exactly as
58
+ // `compile` does on the same text.
59
+ import { parseInterchangeYaml, } from "@vessel-dsp/core";
60
+ import { readNetlist } from "./netlist.js";
61
+ import { GROUND } from "./types.js";
62
+ function sourceEvidence(device) {
63
+ // Mirrors the `voltage-source` law: a positive finite `frequency`
64
+ // parameter is what makes the device an AC source; presence of the
65
+ // parameter, not anything in the packet's prose, is the discriminator.
66
+ if (device.kind === "voltage-source") {
67
+ const frequency = device.parameters.frequency;
68
+ return frequency !== undefined &&
69
+ Number.isFinite(frequency) &&
70
+ frequency > 0
71
+ ? "ac"
72
+ : "dc";
73
+ }
74
+ // Mirrors the `rail` law: a rail with a finite declared voltage asserts a
75
+ // potential (a `voltage-source` law); one without stays `open`.
76
+ if (device.kind === "rail") {
77
+ const volts = device.parameters.volts;
78
+ return typeof volts === "number" && Number.isFinite(volts)
79
+ ? "dc"
80
+ : "none";
81
+ }
82
+ // Mains-side magnetics: not a `dc-source` stamp, but mains evidence the
83
+ // same way an `ac-source` device is.
84
+ if (device.kind === "transformer") {
85
+ return "ac";
86
+ }
87
+ return "none";
88
+ }
89
+ /**
90
+ * Join the document's power domains to the program's `dc-source` stamps.
91
+ *
92
+ * Only rails in an `external-dc` domain -- declared, or inferred from the
93
+ * domain's source components when `sourceKind` is absent -- whose
94
+ * `derivation` is `direct` and whose `role` is `main-supply` are candidates.
95
+ * Each candidate's `railComponentId` resolves to its lowered device, whose
96
+ * nodes are matched to the single `dc-source` stamp with a terminal on one
97
+ * of them. Zero or several such stamps is a refusal naming the rail, never
98
+ * a guess.
99
+ */
100
+ export function resolveSupplyStamps(source, program) {
101
+ const document = parseInterchangeYaml(source);
102
+ const netlist = readNetlist(source);
103
+ const deviceById = new Map(netlist.devices.map((device) => [device.id, device]));
104
+ const componentById = new Map(document.components.map((component) => [component.id, component]));
105
+ const power = document.power;
106
+ if (power === undefined || power.domains.length === 0) {
107
+ return {
108
+ supplies: [],
109
+ refused: [
110
+ {
111
+ railComponentId: null,
112
+ reason: "no-power-section",
113
+ detail: "document declares no power section, so no rail can be shown external: every compiled supply keeps its compiled volts and sourceOhms.",
114
+ },
115
+ ],
116
+ };
117
+ }
118
+ const supplies = [];
119
+ const refused = [];
120
+ for (const domain of power.domains) {
121
+ const evidence = domain.sourceComponentIds.map((id) => sourceEvidenceOf(deviceById.get(id)));
122
+ const dc = evidence.filter((kind) => kind === "dc").length;
123
+ const ac = evidence.filter((kind) => kind === "ac").length;
124
+ // Any mains evidence makes the domain mains: a boundary touching the
125
+ // wall socket is mains-fed even when it also names DC rails downstream
126
+ // of its rectifier (the amp B+ case). Pure DC evidence is external.
127
+ const inferred = ac > 0
128
+ ? "mains-ac"
129
+ : dc > 0
130
+ ? "external-dc"
131
+ : undefined;
132
+ const explicit = domain.sourceKind;
133
+ if (explicit !== undefined && inferred !== undefined && explicit !== inferred) {
134
+ if (domain.rails.length === 0) {
135
+ refused.push({
136
+ railComponentId: null,
137
+ reason: "source-kind-conflict",
138
+ detail: `domain "${domain.id}" declares sourceKind "${explicit}" but its source components lower as ${inferred === "mains-ac" ? "mains" : "external DC"}, so nothing in it can be trusted as external: it keeps its compiled values.`,
139
+ });
140
+ }
141
+ for (const rail of domain.rails) {
142
+ refused.push({
143
+ railComponentId: rail.railComponentId,
144
+ reason: "source-kind-conflict",
145
+ detail: `domain "${domain.id}" declares sourceKind "${explicit}" but its source components lower as ${inferred === "mains-ac" ? "mains" : "external DC"}: rail "${rail.railComponentId}" keeps its compiled values.`,
146
+ });
147
+ }
148
+ continue;
149
+ }
150
+ const effective = explicit ?? inferred;
151
+ if (effective === "mains-ac") {
152
+ if (domain.rails.length === 0) {
153
+ refused.push({
154
+ railComponentId: null,
155
+ reason: "mains-ac-source",
156
+ detail: `domain "${domain.id}" is a mains-ac inlet with no declared rails: rectifier behavior is out of scope, so nothing is mapped.`,
157
+ });
158
+ }
159
+ for (const rail of domain.rails) {
160
+ refused.push({
161
+ railComponentId: rail.railComponentId,
162
+ reason: "mains-ac-source",
163
+ detail: `domain "${domain.id}" is a mains-ac inlet, so rail "${rail.railComponentId}" is refused: rectifier behavior is out of scope and it keeps its compiled values.`,
164
+ });
165
+ }
166
+ continue;
167
+ }
168
+ if (effective === undefined) {
169
+ if (domain.rails.length === 0) {
170
+ refused.push({
171
+ railComponentId: null,
172
+ reason: "unknown-source-kind",
173
+ detail: `domain "${domain.id}" declares no sourceKind and its source components show no external DC or mains evidence, so nothing can be shown external.`,
174
+ });
175
+ }
176
+ for (const rail of domain.rails) {
177
+ refused.push({
178
+ railComponentId: rail.railComponentId,
179
+ reason: "unknown-source-kind",
180
+ detail: `domain "${domain.id}" declares no sourceKind and its source components show no external DC or mains evidence, so rail "${rail.railComponentId}" cannot be shown external or derived: it keeps its compiled values.`,
181
+ });
182
+ }
183
+ continue;
184
+ }
185
+ for (const rail of domain.rails) {
186
+ if (rail.derivation !== "direct") {
187
+ refused.push({
188
+ railComponentId: rail.railComponentId,
189
+ reason: "derived-rail",
190
+ detail: `rail "${rail.railComponentId}" is a converter output (derivation "${rail.derivation}"), not a battery terminal: it keeps its compiled values.`,
191
+ });
192
+ continue;
193
+ }
194
+ if (rail.role !== "main-supply") {
195
+ refused.push({
196
+ railComponentId: rail.railComponentId,
197
+ reason: "rail-not-main-supply",
198
+ detail: `rail "${rail.railComponentId}" is a direct rail with role "${rail.role}", not the external main supply: it keeps its compiled values.`,
199
+ });
200
+ continue;
201
+ }
202
+ const device = deviceById.get(rail.railComponentId);
203
+ if (device === undefined) {
204
+ // A rail binding that names a component the document does not contain is a
205
+ // defect in the power declaration (a typo, a deleted part). The fallback below
206
+ // reads the domain's sources, so applying it here would silently repair the
207
+ // typo and hide it: refuse by name instead.
208
+ if (!componentById.has(rail.railComponentId)) {
209
+ refused.push({
210
+ railComponentId: rail.railComponentId,
211
+ reason: "no-stamp-for-rail",
212
+ detail: `rail "${rail.railComponentId}" names a component the document does not contain, so no node can be resolved for it and nothing is mapped.`,
213
+ });
214
+ continue;
215
+ }
216
+ // Fallback: the rail is a label or port with no lowered device, so
217
+ // its own nodes cannot name a stamp. The domain's
218
+ // `sourceComponentIds` say which components feed it, and the stamp
219
+ // is the `dc-source` those sources lower to -- read from the
220
+ // program's lowered stamps through `block.nodeIds`, never from
221
+ // the components' kinds or names. A source that lowers to
222
+ // anything else (a jack, an `ac-source`, a transformer, an
223
+ // `open`) never counts. Zero such stamps keeps
224
+ // `no-stamp-for-rail`; more than one distinct stamp is
225
+ // `ambiguous-stamp`, never a pick.
226
+ const sourced = matchDomainSourceStamps(domain.sourceComponentIds, deviceById, program);
227
+ if (sourced.length === 1) {
228
+ const address = sourced[0];
229
+ supplies.push({
230
+ address,
231
+ railComponentId: rail.railComponentId,
232
+ role: rail.role,
233
+ nominalVolts: rail.nominalVoltage?.value ?? domain.ratedVoltage?.value ?? null,
234
+ via: "domain-source",
235
+ });
236
+ continue;
237
+ }
238
+ if (sourced.length > 1) {
239
+ const at = sourced
240
+ .map((match) => `block ${match.blockIndex} source ${match.sourceIndex}`)
241
+ .join("; ");
242
+ refused.push({
243
+ railComponentId: rail.railComponentId,
244
+ reason: "ambiguous-stamp",
245
+ detail: `rail "${rail.railComponentId}" has no lowered device, and its domain's sources lower to ${sourced.length} dc-source stamps (${at}), so no single external supply can be named and nothing is mapped.`,
246
+ });
247
+ continue;
248
+ }
249
+ const component = componentById.get(rail.railComponentId);
250
+ refused.push({
251
+ railComponentId: rail.railComponentId,
252
+ reason: "no-stamp-for-rail",
253
+ detail: component === undefined
254
+ ? `rail "${rail.railComponentId}" names a component the document does not contain, so no node can be resolved for it and nothing is mapped.`
255
+ : `rail "${rail.railComponentId}" is a ${component.kind} symbol with no lowered device, so no stamp can carry it and nothing is mapped.`,
256
+ });
257
+ continue;
258
+ }
259
+ const matches = matchStamps(new Set(device.nodes), program);
260
+ if (matches.length === 1) {
261
+ const address = matches[0];
262
+ supplies.push({
263
+ address,
264
+ railComponentId: rail.railComponentId,
265
+ role: rail.role,
266
+ nominalVolts: rail.nominalVoltage?.value ?? domain.ratedVoltage?.value ?? null,
267
+ via: "rail-device",
268
+ });
269
+ }
270
+ else if (matches.length === 0) {
271
+ const railNodes = new Set(device.nodes);
272
+ const nodes = railNodes.size === 0
273
+ ? "no resolvable node"
274
+ : `node${railNodes.size === 1 ? "" : "s"} ${[...railNodes].sort((a, b) => a - b).join(", ")}`;
275
+ refused.push({
276
+ railComponentId: rail.railComponentId,
277
+ reason: "no-stamp-for-rail",
278
+ detail: `rail "${rail.railComponentId}" sits on ${nodes}, which carries no dc-source stamp: it keeps its compiled values.`,
279
+ });
280
+ }
281
+ else {
282
+ const at = matches
283
+ .map((match) => `block ${match.blockIndex} source ${match.sourceIndex}`)
284
+ .join("; ");
285
+ refused.push({
286
+ railComponentId: rail.railComponentId,
287
+ reason: "ambiguous-stamp",
288
+ detail: `rail "${rail.railComponentId}" matches ${matches.length} dc-source stamps (${at}), so no single external supply can be named and nothing is mapped.`,
289
+ });
290
+ }
291
+ }
292
+ }
293
+ return { supplies, refused };
294
+ }
295
+ function sourceEvidenceOf(device) {
296
+ return device === undefined ? "none" : sourceEvidence(device);
297
+ }
298
+ /**
299
+ * Every `dc-source` stamp with a terminal on one of `nodes`, in
300
+ * `program.blocks` order then stamp order.
301
+ *
302
+ * Either terminal may identify the rail: a battery-style supply hangs it off
303
+ * one end or the other depending on grounding, while a single-ended `rail`
304
+ * asserts its potential on the positive terminal with the sign in its volts
305
+ * (the germanium positive-ground case). Ground on the negative side never
306
+ * counts: node 0 is the common return every supply shares, so it cannot name
307
+ * a rail.
308
+ */
309
+ function matchStamps(nodes, program) {
310
+ const matches = [];
311
+ program.blocks.forEach((block, blockIndex) => {
312
+ if (block.kind !== "mna") {
313
+ return;
314
+ }
315
+ for (const stamp of block.stamps) {
316
+ if (stamp.kind !== "dc-source") {
317
+ continue;
318
+ }
319
+ const positiveNode = block.nodeIds[stamp.positive];
320
+ const negativeNode = block.nodeIds[stamp.negative];
321
+ const touches = (positiveNode !== undefined && nodes.has(positiveNode)) ||
322
+ (negativeNode !== undefined &&
323
+ negativeNode !== GROUND &&
324
+ nodes.has(negativeNode));
325
+ if (touches) {
326
+ matches.push({ blockIndex, sourceIndex: stamp.sourceIndex });
327
+ }
328
+ }
329
+ });
330
+ return matches;
331
+ }
332
+ /**
333
+ * The distinct `dc-source` stamps the domain's source components lower to.
334
+ *
335
+ * Only sources that exist as netlist devices and carry DC evidence -- the
336
+ * same discriminator the device laws use, so a jack, an `ac-source`, a
337
+ * transformer, or an `open` never counts -- contribute their nodes; the stamp
338
+ * itself comes from the program's lowered result, never from a component's
339
+ * kind string or name. Two sources sharing one stamp still name one supply;
340
+ * two sources on two stamps is genuinely ambiguous.
341
+ */
342
+ function matchDomainSourceStamps(sourceComponentIds, deviceById, program) {
343
+ const seen = new Set();
344
+ const out = [];
345
+ for (const id of sourceComponentIds) {
346
+ const device = deviceById.get(id);
347
+ if (device === undefined) {
348
+ continue;
349
+ }
350
+ if (sourceEvidence(device) !== "dc") {
351
+ continue;
352
+ }
353
+ for (const match of matchStamps(new Set(device.nodes), program)) {
354
+ const key = `${match.blockIndex}:${match.sourceIndex}`;
355
+ if (!seen.has(key)) {
356
+ seen.add(key);
357
+ out.push(match);
358
+ }
359
+ }
360
+ }
361
+ return out;
362
+ }
363
+ //# sourceMappingURL=supply-stamps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"supply-stamps.js","sourceRoot":"","sources":["../src/supply-stamps.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,EAAE;AACF,8EAA8E;AAC9E,gFAAgF;AAChF,8EAA8E;AAC9E,2EAA2E;AAC3E,0EAA0E;AAC1E,iEAAiE;AACjE,+EAA+E;AAC/E,0BAA0B;AAC1B,EAAE;AACF,6EAA6E;AAC7E,8E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