fix(connectors): derive the connect-code shape beside the minter (TASK-159) - #1937
Merged
Merged
Conversation
…K-159)
The route carried its own `CONNECT_CODE_SHAPE = /^[0-9a-f]{32}$/`, tied to
`mintConnectCode` by a comment only. Widen the minter, update the seven pins on
minted output, and every real code is refused with the shape message while the
suite stays green — no fixture is a minted code.
- `CONNECT_CODE_BYTES = 16` is now the one number: the minter draws from it and
the predicate is built from it (`{CONNECT_CODE_BYTES * 2}`), so neither can be
changed without the other.
- `isConnectCodeShape` is exported beside `mintConnectCode`; the route calls it
and its local regex (and the comment that tied them) is gone.
- Witnesses: the predicate accepts what the minter produces and refuses one
character either side, refusing non-hex and uppercase (the caller lowercases
first); the route asserts it ASKED the service for the shape, so re-adding a
local copy reddens instead of drifting; the existing route-tier `it.each` of
four malformed inputs stays the negative side.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ties the Telegram route's connect-code shape to the minter, so the two cannot answer the shape question differently. Row TASK-159, moved out of TASK-156 by wren (its build, #1935, never touches the enable path).
The failure path the row names
backend/routes/webhooks/telegram.ts:40carried its ownCONNECT_CODE_SHAPE = /^[0-9a-f]{32}$/, linked tomintConnectCode(backend/services/telegramConnectCode.ts:17,crypto.randomBytes(16).toString('hex')) by a comment and nothing else.randomBytes(20). The seven pins on minted output go red.{40}. The suite is green again.The change
CONNECT_CODE_BYTES = 16is the one number. The minter draws from it (crypto.randomBytes(CONNECT_CODE_BYTES)) and the predicate is built from it (new RegExp(\^[0-9a-f]{${CONNECT_CODE_BYTES * 2}}$`)`), so neither side can move without the other. This is wren's shape from 74639 rather than the row's two-constant version, per vera's 74633 ruling on the tension between the row's mutation and the better implementation.isConnectCodeShapeis exported besidemintConnectCodeand added tomodule.exports; the route calls it and its local regex — plus the comment that tied the two together — is gone.Witnesses
telegramConnectCode.test.js(width derived from the same call, not a literal)telegramConnectCode.test.jsCONNECT_CODE_BYTEStelegramConnectCode.test.jstelegram.webhook.connectCode.test.js, assertingisConnectCodeShapewas called with the normalisedJOINED_CODEit.each, four inputs (the negative half of the pair)The route-side witness is wren's 74639 point: the row's witness as written proves only that the service is self-consistent, while re-adding a local regex to the route tomorrow keeps every suite green. The service mock in that suite already spreads
jest.requireActual, so wrappingisConnectCodeShapewith a recordingjest.fnis additive — it reddens on a local copy and changes nothing else.Ledger — 5 mutations, baseline and restore 24/24
{32}{32}accepts what the minter produces…Two disclosures rather than tidying:
{32}and{CONNECT_CODE_BYTES * 2}are the same regex, so hardcoding the width is behaviourally invisible — the derivation is a property of the pair, not of either half. M5 is the row's mutation implemented as the drift actually happens (minter widened, predicate stale) and it reddens the derived witness, which is what the row's one-edit mutation could not do.Scope
{16 * 2}is{32}. Two files of source, two suites of tests.telegramConnectCode.test.js:14,integrations.linkedUserId.test.js:381,installableInstallationService.test.js×5) are untouched: they are 32-hex literals and stay correct, and under this change they are what reddens if the width ever moves.telegram.webhook.test.js,installableInstallationService.test.js,integrations.linkedUserId.test.js)..tslint 0 errors; the fourmax-lenwarnings in the route file are pre-existing at the same lines minus two (measured againstHEAD~1via--stdin). No diagnostic on any added.jsline.Gate: Vera.