A copper SFP is a converter: an SFP cage holding one mates an RJ45 port (#1514) #1598

Closed
jaylouisw wants to merge 1 commit from fix/1116-0335 into main
Owner

Fixes #1514

t.connect("sw","SFP+4","ap","wan",{mediaId:"1000base-t-sfp"}) was refused:

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, which is why CAGE_MEDIA["sfp+"] already listed 1000base-t-sfp while the mating rule said the pair was impossible. The only way to draw the cable was force: true, recording a link the validator calls impossible.

What changed

  • engine/media.js: new MODULE_FACE / MODULE_CAGES / moduleBridge(). A module with an RJ45 face (1000base-t-sfp) bridges an sfp/sfp+/sfp28/sfp56 cage to an rj45 port, but only where the cage's own media list offers that module. commonMedia() uses it, negotiateSpeed() returns the module rate for a bridged pair (the cage clocks the module, not the far cage) and refuses when a port cannot reach it, and canMate() asks whether a module could bridge before returning the connector verdict, so a Fast-Ethernet-only peer gets E_NO_COMMON_MEDIA naming the face instead of a connector lie.
  • Still refused, deliberately: two fibre cages joined by copper, an optics-only cage meeting an RJ45 plug (E_CONNECTOR_MISMATCH, same words), a fibre medium into an RJ45 socket.
  • engine/validation.js: E_BIDI_SAME_WAVELENGTH and E_BIDI_MISMATCH were emittable by canMate and missing from RULES; the property test only caught it now that this branch is reachable. Both documented, and the module answer is asked before the single-strand lecture.
  • docs/CONNECTORS.md section 4.1 rewritten ("the one that is always correct" is not), docs/PHYSICAL_LAYER.md error table gains the two BiDi codes.

Verification

  • test/sfp-copper-module.test.js - 21 checks; 8 fail against main (the connect, both mediaId spellings, the link record, symmetry, the module rate, and the two canMate face answers).
  • test/sfp28-legacy.test.js (45) and test/validation.test.js (22) re-stated in module terms: the connector refusal they pin is now the optics-only cage, and the bare 1000base-t lead into a cage is still E_MEDIA_NOT_SUPPORTED.
  • test/link-options.test.js (26): a copper host can now also be reached through the SFP+ cage with a copper module, so the assertion is "every option is copper, and the plain RJ45 run is among them" rather than "exactly one option".
  • node scripts/syntax-check.js 334 files OK; full npm test: 264 suites, 9574 assertions, 0 failures.
Fixes #1514 `t.connect("sw","SFP+4","ap","wan",{mediaId:"1000base-t-sfp"})` was refused: ``` 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, which is why `CAGE_MEDIA["sfp+"]` already listed `1000base-t-sfp` while the mating rule said the pair was impossible. The only way to draw the cable was `force: true`, recording a link the validator calls impossible. ## What changed - `engine/media.js`: new `MODULE_FACE` / `MODULE_CAGES` / `moduleBridge()`. A module with an RJ45 face (`1000base-t-sfp`) bridges an `sfp`/`sfp+`/`sfp28`/`sfp56` cage to an `rj45` port, but only where the cage's own media list offers that module. `commonMedia()` uses it, `negotiateSpeed()` returns the module rate for a bridged pair (the cage clocks the module, not the far cage) and refuses when a port cannot reach it, and `canMate()` asks whether a module *could* bridge before returning the connector verdict, so a Fast-Ethernet-only peer gets `E_NO_COMMON_MEDIA` naming the face instead of a connector lie. - Still refused, deliberately: two fibre cages joined by copper, an optics-only cage meeting an RJ45 plug (`E_CONNECTOR_MISMATCH`, same words), a fibre medium into an RJ45 socket. - `engine/validation.js`: `E_BIDI_SAME_WAVELENGTH` and `E_BIDI_MISMATCH` were emittable by `canMate` and missing from `RULES`; the property test only caught it now that this branch is reachable. Both documented, and the module answer is asked before the single-strand lecture. - `docs/CONNECTORS.md` section 4.1 rewritten ("the one that is always correct" is not), `docs/PHYSICAL_LAYER.md` error table gains the two BiDi codes. ## Verification - `test/sfp-copper-module.test.js` - 21 checks; 8 fail against `main` (the connect, both mediaId spellings, the link record, symmetry, the module rate, and the two `canMate` face answers). - `test/sfp28-legacy.test.js` (45) and `test/validation.test.js` (22) re-stated in module terms: the connector refusal they pin is now the optics-only cage, and the bare `1000base-t` lead into a cage is still `E_MEDIA_NOT_SUPPORTED`. - `test/link-options.test.js` (26): a copper host can now also be reached through the SFP+ cage with a copper module, so the assertion is "every option is copper, and the plain RJ45 run is among them" rather than "exactly one option". - `node scripts/syntax-check.js` 334 files OK; full `npm test`: 264 suites, 9574 assertions, 0 failures.
A copper SFP is a converter: an SFP cage holding one mates an RJ45 port (#1514)
Some checks failed
PR rebase / Rebase onto main and arm auto-merge (pull_request) Failing after 10m35s
CI / Classify the change (pull_request) Failing after 10m37s
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
3f13e4a927
A CRS305 SFP+ cage could not be cabled to an RJ45 port at all:

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

CAGE_MATE answers which cages meet, and sfp+ and rj45 never do - right for a
fibre module, wrong for a copper one, because the module *is* the converter: it
seats in the cage and presents an RJ45 socket at its face, so the run leaving it
is ordinary CAT5e. The only way to draw the cable was force: true, which records
a link the validator calls impossible.

MODULE_FACE/moduleBridge() state the face a module presents and apply it only
where a cage can really hold the module: an sfp/sfp+/sfp28/sfp56 cage that offers
1000base-t-sfp against an rj45 port. The link is named by the module and runs at
the module rate (negotiateSpeed returns it rather than intersecting two cages
that were never asked to share a rate), and the port must be able to clock that
rate. Everything the old rule refused for the right reason still refuses: two
fibre cages are never joined by copper, an optics-only cage still answers
E_CONNECTOR_MISMATCH, and a Fast-Ethernet-only peer gets E_NO_COMMON_MEDIA
naming what the module presents.

While here: canMate has always been able to emit E_BIDI_SAME_WAVELENGTH and
E_BIDI_MISMATCH and neither was in validation.RULES, so the property test only
caught it once an RJ45/copper-module pair reached that branch. Both are now
documented, and the module answer is asked before the single-strand lecture,
which was about a module the far end was never going to see light from.

Tests: test/sfp-copper-module.test.js (21 checks, 8 failing before the fix);
sfp28-legacy and validation re-stated in module terms; 264 suites, 9574
assertions, 0 failures.
Author
Owner

Same four-way collision as #1588 — see the analysis there. main already carries a mediaDeclared-gated copper-SFP rule from 2c39a647 (PR #1602); this branch's module-faces table bridges off the cage rather than off a declaration, so rebasing means replacing that rule. Left for Jay's decision.

Same four-way collision as #1588 — see the analysis there. `main` already carries a `mediaDeclared`-gated copper-SFP rule from `2c39a647` (PR #1602); this branch's module-faces table bridges off the cage rather than off a declaration, so rebasing means replacing that rule. Left for Jay's decision.
Author
Owner

Closing as superseded: #1514 is already fixed on main by commit 2c39a647 — A copper SFP in an SFP+ cage mates an RJ45 port (#1514) (#1602), merged 2026-11-16 04:40.

Main now has, in engine/media.js:

  • copperSfpBridge(pa, pb) — when one cage is rj45/combo and the other is a module slot, it returns 1000base-t-sfp instead of nothing;
  • commonMedia() calls it in the !cagesMate() branch, so the picker is offered the module again (the "possible media: none" gap is gone);
  • portWithModule() + mediaDeclared — a caller-named copper module narrows the port's media, so mediaId is honoured without letting an optic into a socket with no room for it;
  • engine/validation.js and test/copper-sfp-bridge.test.js (208 lines) cover the mating rule and the rate.

Because main now carries a bridging rule in the same functions, every retry of #1514 conflicts in engine/media.js and nowhere else — that is why all three of these sat blocked. Closing rather than picking a winner: the issue is answered, and keeping three conflicting duplicates of one behaviour in the queue means nobody's CI tells them apart.

The branch is left intact, not deleted. If this shape is preferred over main's, reopen or re-push it against current main as a replacement change and it can be judged on its own merits.
This branch's distinct shape: the mating rule plus engine/validation.js and docs (CONNECTORS.md, PHYSICAL_LAYER.md). Main's 2c39a647 already updates validation.js and its CONNECTORS.md:241 / PHYSICAL_LAYER.md:165 describe 1000base-t-sfp as the copper SFP module legal in sfp/sfp+, so the prose landed with it.

Closing as **superseded**: #1514 is already fixed on main by commit `2c39a647` — *A copper SFP in an SFP+ cage mates an RJ45 port (#1514) (#1602)*, merged 2026-11-16 04:40. Main now has, in `engine/media.js`: - `copperSfpBridge(pa, pb)` — when one cage is `rj45`/`combo` and the other is a module slot, it returns `1000base-t-sfp` instead of nothing; - `commonMedia()` calls it in the `!cagesMate()` branch, so the picker is offered the module again (the "possible media: none" gap is gone); - `portWithModule()` + `mediaDeclared` — a caller-named copper module narrows the port's media, so `mediaId` is honoured without letting an optic into a socket with no room for it; - `engine/validation.js` and `test/copper-sfp-bridge.test.js` (208 lines) cover the mating rule and the rate. Because main now carries a bridging rule in the same functions, every retry of #1514 conflicts in `engine/media.js` and nowhere else — that is why all three of these sat blocked. Closing rather than picking a winner: the issue is answered, and keeping three conflicting duplicates of one behaviour in the queue means nobody's CI tells them apart. The branch is left intact, not deleted. If this shape is preferred over main's, reopen or re-push it against current main as a replacement change and it can be judged on its own merits. **This branch's distinct shape:** the mating rule plus `engine/validation.js` and docs (`CONNECTORS.md`, `PHYSICAL_LAYER.md`). Main's `2c39a647` already updates `validation.js` and its `CONNECTORS.md:241` / `PHYSICAL_LAYER.md:165` describe `1000base-t-sfp` as the copper SFP module legal in `sfp`/`sfp+`, so the prose landed with it.
jaylouisw closed this pull request 2026-11-16 07:26:53 +00:00
Some checks failed
PR rebase / Rebase onto main and arm auto-merge (pull_request) Failing after 10m35s
CI / Classify the change (pull_request) Failing after 10m37s
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

Pull request closed

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!1598
No description provided.