A copper SFP in an SFP+ cage mates an RJ45 port (#1514) #1602

Merged
jaylouisw merged 1 commit from fix/1116-0405 into main 2026-11-16 04:41:03 +00:00
Owner

Fixes #1514

connect() refused an SFP+ cage against an RJ45 port outright, even when the spec or the caller said the cage holds 1000base-t-sfp - which is what a copper SFP module is. The refusal contradicted the engine's own media table (CAGE_MEDIA['sfp+'] lists the module, so the cage may carry it) and then offered no medium at all:

CRS305-1G-4S+IN/SFP+4 <-> RT-AX89X/wan: Cannot mate SFP+ to RJ45 (incompatible connectors).
1000BASE-T SFP (1000base-t-sfp) is not supported by both ...; possible media: none.

The module IS the converter: the cage is a module slot, and the socket on the outside of that module is an ordinary RJ45. A 10G port fed from a 1G copper appliance is a common install, and the only way to draw it was { force: true } - a cable the validator says is impossible.

What changed

  • engine/media.js: copperSfpModuleOf() / copperSfpBridge() - a copper module in a cage that can hold it converts that cage to an RJ45 socket for mating. The conditions are facts about the install, not the catalogue: the port must say the module is fitted (spec media, or mediaId on the cable), and the cage's repertoire must be able to hold that part.
  • engine/media.js: commonMedia() returns the module for a bridged pair, so a refusal names a medium and the medium is the part on the floor.
  • engine/media.js: portWithModule(), applied in validation for mediaId, so a caller naming the module is the same claim a spec makes with media.
  • engine/validation.js: completeHardware() keeps mediaDeclared through normalisation.
  • engine/device.js: serialize() writes it (only when set) and load restores it, so a saved lab comes back with the same cage contents.

What deliberately does not change: an EMPTY SFP+ cage still refuses an RJ45 socket. The cage repertoire offers the module as one of eleven things it might hold, and "the cage could hold one" is not "one is in there" - otherwise test/validation.test.js's "rejects an RJ45 port cabled to an SFP cage" and every fibre port in the catalogue would quietly become copper. A coil of fibre-only modules and an SC/APC PON port still refuse copper, and rates still have to agree: a cage pinned to 25G with a 1G module in it refuses a 1G RJ45 port with E_NO_COMMON_SPEED, not a connector verdict.

Tests - test/copper-sfp-bridge.test.js, 29 checks: the rule both ways round, an empty cage and a fibre module still refused, the rate verdict, the CRS305 SFP+4 <-> RT-AX89X wan install from the issue with and without mediaId (the link comes up at 1G, not the cage's 10G), a save/reload round trip, a sweep of every module cage in the CAGES table, and a catalogue-wide sweep asserting a port mates RJ45 iff its spec says the module is fitted. Against the previous media.js the same file gives 14 failures.

Gates: node scripts/syntax-check.js 334 files OK; relevant suites (validation 22, fiber-connectors 31, sfp28-legacy 41, link-roundtrip 36, media-cfp2 30, poe-inference 17, skip-audit 15) all pass; full npm test 264 suites / 9577 assertions / 0 failed.

Fixes #1514 `connect()` refused an SFP+ cage against an RJ45 port outright, even when the spec or the caller said the cage holds `1000base-t-sfp` - which is what a copper SFP module is. The refusal contradicted the engine's own media table (`CAGE_MEDIA['sfp+']` lists the module, so the cage may carry it) and then offered no medium at all: ``` CRS305-1G-4S+IN/SFP+4 <-> RT-AX89X/wan: Cannot mate SFP+ to RJ45 (incompatible connectors). 1000BASE-T SFP (1000base-t-sfp) is not supported by both ...; possible media: none. ``` The module IS the converter: the cage is a module slot, and the socket on the outside of that module is an ordinary RJ45. A 10G port fed from a 1G copper appliance is a common install, and the only way to draw it was `{ force: true }` - a cable the validator says is impossible. **What changed** - `engine/media.js`: `copperSfpModuleOf()` / `copperSfpBridge()` - a copper module in a cage that can hold it converts that cage to an RJ45 socket for mating. The conditions are facts about the install, not the catalogue: the port must say the module is fitted (spec `media`, or `mediaId` on the cable), and the cage's repertoire must be able to hold that part. - `engine/media.js`: `commonMedia()` returns the module for a bridged pair, so a refusal names a medium and the medium is the part on the floor. - `engine/media.js`: `portWithModule()`, applied in validation for `mediaId`, so a caller naming the module is the same claim a spec makes with `media`. - `engine/validation.js`: `completeHardware()` keeps `mediaDeclared` through normalisation. - `engine/device.js`: `serialize()` writes it (only when set) and load restores it, so a saved lab comes back with the same cage contents. **What deliberately does not change:** an EMPTY SFP+ cage still refuses an RJ45 socket. The cage repertoire offers the module as one of eleven things it might hold, and "the cage could hold one" is not "one is in there" - otherwise `test/validation.test.js`'s "rejects an RJ45 port cabled to an SFP cage" and every fibre port in the catalogue would quietly become copper. A coil of fibre-only modules and an SC/APC PON port still refuse copper, and rates still have to agree: a cage pinned to 25G with a 1G module in it refuses a 1G RJ45 port with `E_NO_COMMON_SPEED`, not a connector verdict. **Tests** - `test/copper-sfp-bridge.test.js`, 29 checks: the rule both ways round, an empty cage and a fibre module still refused, the rate verdict, the CRS305 `SFP+4` <-> RT-AX89X `wan` install from the issue with and without `mediaId` (the link comes up at 1G, not the cage's 10G), a save/reload round trip, a sweep of every module cage in the CAGES table, and a catalogue-wide sweep asserting a port mates RJ45 iff its spec says the module is fitted. Against the previous `media.js` the same file gives **14 failures**. Gates: `node scripts/syntax-check.js` 334 files OK; relevant suites (`validation` 22, `fiber-connectors` 31, `sfp28-legacy` 41, `link-roundtrip` 36, `media-cfp2` 30, `poe-inference` 17, `skip-audit` 15) all pass; full `npm test` **264 suites / 9577 assertions / 0 failed**.
A copper SFP in an SFP+ cage mates an RJ45 port (#1514)
Some checks failed
PR rebase / Rebase onto main and arm auto-merge (pull_request) Successful in 39s
CI / Classify the change (pull_request) Failing after 14m20s
CI / Test (Node 18) (pull_request) Has been cancelled
CI / Test (Node 20) (pull_request) Has been cancelled
CI / Test (Node 22) (pull_request) Has been cancelled
CI / Server smoke test (pull_request) Has been cancelled
CI / Docker build (pull_request) Has been cancelled
7479ceb3de
connect() refused an SFP+ cage against an RJ45 port outright, even when the
spec or the caller said the cage holds 1000base-t-sfp - which is what a
copper SFP module is. The refusal contradicted the engine's own media table
(CAGE_MEDIA['sfp+'] lists the module, so the cage may carry it) and then
offered no medium at all: "possible media: none".

The module IS the converter: the cage is a module slot, and the socket on the
outside of that module is an ordinary RJ45. A 10G port fed from a 1G copper
appliance is a common install, and the only way to draw it was { force: true }
- a cable the validator says is impossible.

- engine/media.js: copperSfpModuleOf()/copperSfpBridge() - a copper module in a
  cage that can hold it converts that cage to an RJ45 socket for mating
  purposes. Conditions are facts about the install, not the catalogue: the port
  must say the module is fitted (spec `media`, or `mediaId` on the cable) and
  the cage's repertoire must be able to hold that part. An EMPTY SFP+ cage still
  refuses an RJ45 socket - "the cage could hold one" is not "one is in there".
- engine/media.js: commonMedia() returns the module for a bridged pair, so a
  refusal names a medium and the medium is the part on the floor.
- engine/media.js: portWithModule(), applied in validation for `mediaId`, so
  the caller naming the module is the same claim a spec makes with `media`.
- engine/validation.js: completeHardware()/normalizePort() keep `mediaDeclared`.
- engine/device.js: serialize() writes it (only when set) and load restores it,
  so a saved lab comes back with the same cage contents.
- test/copper-sfp-bridge.test.js: 29 checks - the rule both ways round, rates
  still having to agree (25G-only cage vs 1G RJ45 is E_NO_COMMON_SPEED), the
  CRS305 SFP+4 <-> RT-AX89X wan install from the issue with and without
  mediaId, a save/reload round trip, a sweep of every module cage and a
  catalogue-wide sweep (mating RJ45 iff the spec says the module is fitted).

Against the previous media.js the same file gives 14 failures.

Co-authored-by: jay <jay@jayw.uk>
jaylouisw force-pushed fix/1116-0405 from 7479ceb3de
Some checks failed
PR rebase / Rebase onto main and arm auto-merge (pull_request) Successful in 39s
CI / Classify the change (pull_request) Failing after 14m20s
CI / Test (Node 18) (pull_request) Has been cancelled
CI / Test (Node 20) (pull_request) Has been cancelled
CI / Test (Node 22) (pull_request) Has been cancelled
CI / Server smoke test (pull_request) Has been cancelled
CI / Docker build (pull_request) Has been cancelled
to fd8db2876c
Some checks failed
PR rebase / Rebase onto main and arm auto-merge (pull_request) Failing after 12m42s
CI / Classify the change (pull_request) Failing after 12m50s
CI / Test (Node 18) (pull_request) Has been cancelled
CI / Test (Node 20) (pull_request) Has been cancelled
CI / Test (Node 22) (pull_request) Has been cancelled
CI / Server smoke test (pull_request) Has been cancelled
CI / Docker build (pull_request) Has been cancelled
2026-11-16 04:40:44 +00:00
Compare
jaylouisw scheduled this pull request to auto merge when all checks succeed 2026-11-16 04:40:46 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
jaylouisw/packetforge!1602
No description provided.