@grayhaven/nerve-rules 0.1.0 → 0.2.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.
package/dist/index.d.ts CHANGED
@@ -22,6 +22,15 @@ declare const missingGroundReturn: Rule;
22
22
  declare const shieldDrainUnconnected: Rule;
23
23
  declare const unconnectedAssignedPin: Rule;
24
24
  declare const wireSignalMismatch: Rule;
25
+ declare const terminalIncompatible: Rule;
26
+ declare const missingSeal: Rule;
27
+ declare const sealIncompatible: Rule;
28
+ /**
29
+ * Org approval gate (PRD §30 acceptance: organizations override approval
30
+ * state without mutating library data). Pass the approved MPN list from
31
+ * org config; anything else in the BOM is flagged.
32
+ */
33
+ declare const requireApprovedParts: (approvedMpns: ReadonlyArray<string>) => Rule;
25
34
  /** All built-in rules, in stable order. */
26
35
  declare const builtinRules: ReadonlyArray<Rule>;
27
36
 
@@ -47,4 +56,4 @@ declare const isShieldSignal: (signal: string) => boolean;
47
56
  */
48
57
  declare const differentialPartner: (signal: string) => string | undefined;
49
58
 
50
- export { AMPACITY_BY_AWG, branchMissingLabel, builtinRules, differentialPairNotTwisted, differentialPartner, gaugeCurrentMismatch, gaugeOutsideConnectorRange, isGroundSignal, isPowerSignal, isShieldSignal, missingGroundReturn, missingRevision, missingWireColor, missingWireGauge, missingWireLength, parseAwg, requiredAwgForCurrent, shieldDrainUnconnected, spliceMissingNotes, twistGroupTooSmall, unconnectedAssignedPin, wireSignalMismatch };
59
+ export { AMPACITY_BY_AWG, branchMissingLabel, builtinRules, differentialPairNotTwisted, differentialPartner, gaugeCurrentMismatch, gaugeOutsideConnectorRange, isGroundSignal, isPowerSignal, isShieldSignal, missingGroundReturn, missingRevision, missingSeal, missingWireColor, missingWireGauge, missingWireLength, parseAwg, requireApprovedParts, requiredAwgForCurrent, sealIncompatible, shieldDrainUnconnected, spliceMissingNotes, terminalIncompatible, twistGroupTooSmall, unconnectedAssignedPin, wireSignalMismatch };
package/dist/index.js CHANGED
@@ -327,6 +327,79 @@ var wireSignalMismatch = rule(
327
327
  },
328
328
  { code: "HK-CONN-011" }
329
329
  );
330
+ var terminalIncompatible = rule(
331
+ "terminalIncompatible",
332
+ (ctx) => {
333
+ for (const c of ctx.hir.connectors) {
334
+ if (c.compatibleTerminals === void 0) continue;
335
+ for (const p of c.pins) {
336
+ if (p.terminal !== void 0 && !c.compatibleTerminals.includes(p.terminal)) {
337
+ ctx.report({
338
+ severity: Err,
339
+ message: `Pin ${c.ref}.${p.pin} uses terminal ${p.terminal}, which is not compatible with ${c.mpn} (allowed: ${c.compatibleTerminals.join(", ")}).`,
340
+ target: refs.pin(c.ref, p.pin)
341
+ });
342
+ }
343
+ }
344
+ }
345
+ },
346
+ { code: "HK-CONN-012" }
347
+ );
348
+ var missingSeal = rule(
349
+ "missingSeal",
350
+ (ctx) => {
351
+ const wired = wiredPins(ctx.hir);
352
+ for (const c of ctx.hir.connectors) {
353
+ if (c.sealed !== true) continue;
354
+ for (const p of c.pins) {
355
+ if (wired.has(`${c.ref}:${p.pin}`) && p.seal === void 0) {
356
+ ctx.report({
357
+ severity: Err,
358
+ message: `Connector ${c.ref} (${c.mpn}) is sealed, but populated pin ${p.pin} has no seal assigned.`,
359
+ target: refs.pin(c.ref, p.pin)
360
+ });
361
+ }
362
+ }
363
+ }
364
+ },
365
+ { code: "HK-CONN-013" }
366
+ );
367
+ var sealIncompatible = rule(
368
+ "sealIncompatible",
369
+ (ctx) => {
370
+ for (const c of ctx.hir.connectors) {
371
+ if (c.compatibleSeals === void 0) continue;
372
+ for (const p of c.pins) {
373
+ if (p.seal !== void 0 && !c.compatibleSeals.includes(p.seal)) {
374
+ ctx.report({
375
+ severity: Err,
376
+ message: `Pin ${c.ref}.${p.pin} uses seal ${p.seal}, which is not compatible with ${c.mpn} (allowed: ${c.compatibleSeals.join(", ")}).`,
377
+ target: refs.pin(c.ref, p.pin)
378
+ });
379
+ }
380
+ }
381
+ }
382
+ },
383
+ { code: "HK-CONN-014" }
384
+ );
385
+ var requireApprovedParts = (approvedMpns) => {
386
+ const approved = new Set(approvedMpns);
387
+ return rule(
388
+ "requireApprovedParts",
389
+ (ctx) => {
390
+ for (const item of ctx.hir.bom) {
391
+ if (!approved.has(item.mpn)) {
392
+ ctx.report({
393
+ severity: Warn,
394
+ message: `Part ${item.mpn} (${item.category ?? "part"}) is not on the approved parts list.`,
395
+ target: refs.bom(item.mpn)
396
+ });
397
+ }
398
+ }
399
+ },
400
+ { code: "HK-DOC-004" }
401
+ );
402
+ };
330
403
  var builtinRules = [
331
404
  missingRevision,
332
405
  branchMissingLabel,
@@ -341,7 +414,10 @@ var builtinRules = [
341
414
  missingGroundReturn,
342
415
  shieldDrainUnconnected,
343
416
  unconnectedAssignedPin,
344
- wireSignalMismatch
417
+ wireSignalMismatch,
418
+ terminalIncompatible,
419
+ missingSeal,
420
+ sealIncompatible
345
421
  ];
346
422
  export {
347
423
  AMPACITY_BY_AWG,
@@ -356,13 +432,17 @@ export {
356
432
  isShieldSignal,
357
433
  missingGroundReturn,
358
434
  missingRevision,
435
+ missingSeal,
359
436
  missingWireColor,
360
437
  missingWireGauge,
361
438
  missingWireLength,
362
439
  parseAwg,
440
+ requireApprovedParts,
363
441
  requiredAwgForCurrent,
442
+ sealIncompatible,
364
443
  shieldDrainUnconnected,
365
444
  spliceMissingNotes,
445
+ terminalIncompatible,
366
446
  twistGroupTooSmall,
367
447
  unconnectedAssignedPin,
368
448
  wireSignalMismatch
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grayhaven/nerve-rules",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "description": "Built-in validation and linting rules for Grayhaven Nerve.",
6
6
  "exports": {
@@ -10,12 +10,12 @@
10
10
  }
11
11
  },
12
12
  "dependencies": {
13
- "@grayhaven/nerve": "0.1.0"
13
+ "@grayhaven/nerve": "0.2.0"
14
14
  },
15
15
  "devDependencies": {
16
16
  "typescript": "^5.8.3",
17
17
  "vitest": "^3.2.4",
18
- "@grayhaven/nerve-connectors": "0.1.0"
18
+ "@grayhaven/nerve-connectors": "0.2.0"
19
19
  },
20
20
  "license": "Apache-2.0",
21
21
  "files": [