test: pin route-GOODBYE reconnect classification before the SDK flip

Merged
IC
3mo ago
+50-0

One test. It pins behaviour that is currently correct, unpinned, and about to change through a dependency rather than through this repo.

What's unpinned

A module restart sends GOODBYE to every route on the connection, so a mid-request call rejects with a bare SubcError — the raw request() path never produces a managed SubcCallError.

isConsumerReconnectTransient reaches its err instanceof SubcCallError branch first, so a bare SubcError falls through to non-transient. Today that means: route dropped, client kept, next call re-opens on the same connection. That's the behaviour every seat here relies on across ck module restart aft.

Nothing asserts it. The nearest test — a plain timeout (non-transient SubcError) KEEPS the client — covers the same class, but a timeout and a GOODBYE can be classified differently, so it would stay green through the change below.

Why now

cortexkit/subconscious#6 proposes putting kind on SubcError itself. If the classifier then reads it, GOODBYE flips false→true and the dropClient decisions consuming this classifier change behaviour — on an SDK bump alone, with no diff in this repo.

I think that flip is probably correct: a route GOODBYE genuinely is the transient class. This isn't an argument against it. It's that a reconnect-policy change arriving through a dependency should land as a red test you adopt deliberately, not as a reconnect storm someone diagnoses later. The comment says so, and says to flip the assertions rather than delete the test when it happens.

Verification

Red control, since a characterization test that can't fail is worse than none:

green                                       55 pass / 0 fail
mutate SubcError → SocketClosedError        (verified applied via cmp, not assumed)
  ↳ simulates exactly the flip: GOODBYE becomes transient
red                                         54 pass / 1 fail — only the new test
restore                                     (verified via cmp)
green                                       55 pass / 0 fail

Full packages/aft-bridge suite: 474 pass / 0 fail. Lint and format clean.

The mutation targets the classification, not the assertion, so it fails for the reason the test exists — expect(client.closed).toBe(0) and expect(madeClients).toBe(1) are what break.

Test-only; no production code touched.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Summary by cubic

Pins the current reconnect classification for route GOODBYE to prevent an SDK-only change from silently changing reconnect policy. Today a mid-request GOODBYE yields a bare SubcError that isConsumerReconnectTransient treats as non-transient: the route drops, the client is kept, the next call reopens on the same connection, and there is no in-place retry.

  • Adds a characterization test in packages/aft-bridge/src/__tests__/subc-transport.test.ts asserting: first call rejects with SubcError (not SubcCallError), client stays open, second call succeeds on the same client, and there is no auto-retry.
  • The fixture carries kind: "outcome_unknown" even though today’s SubcError has only code, so the test will turn red when the classifier starts reading kind.
  • Test-only; no production code.

When the SDK flips

  • When cortexkit/subconscious#6 adds kind to SubcError and the classifier consumes it, GOODBYE will classify transient and this test should fail.
  • Action: flip the assertions to expect client drop and reconnect; do not delete the test.

Greptile Summary

This test-only PR pins the current reconnect policy for route GOODBYE failures before a planned SDK classifier change.

  • Models a route GOODBYE as a bare SubcError carrying kind: "outcome_unknown".
  • Verifies the client remains open, the route reopens on the same connection, and the failed call is not retried in place.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

FilenameOverview
packages/aft-bridge/src/tests/subc-transport.test.tsAdds a focused reconnect-policy characterization test and now explicitly models the structured GOODBYE discriminator requested in the previous review.

Reviews (2): Last reviewed commit: "test: pin route-GOODBYE reconnect classi..." | Re-trigger Greptile

Context used: