Skip to content

Connections refactor, phase B (7/10): move active-connection selectors into src/connections/ - #2348

Merged
kmcginnes merged 1 commit into
aws:mainfrom
mjuarros:connections-phase-b-active-connection
Oct 1, 2026
Merged

kmcginnes merged 1 commit into
aws:mainfrom
mjuarros:connections-phase-b-active-connection

Conversation

@mjuarros

@mjuarros mjuarros commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Phase B, PR 7 of #2298. Pure refactor, no behavior change. Follows #2344 (PR 6).

What this does

Moves the active-connection selectors into connections/activeConnection.ts, bodies byte-identical, no renames:

  • activeConfigSelector, activeConnectionAtom (from core/StateProvider/configuration.ts)
  • queryEngineSelector, useQueryEngine (from core/connector.ts)

Importers switch to @/connections. The @/core barrel no longer re-exports the moved selectors. configuration.ts keeps the schema/merge selectors (and now imports activeConfigSelector from @/connections for mergedConfigurationSelector); connector.ts keeps explorerAtom, useExplorer, and serverLogger (and imports activeConnectionAtom from @/connections).

Init-cycle safety

This is the first module code the @/connections index exports that reads the persisted atoms. activeConnection.ts imports those atoms from @/core/StateProvider/storageAtoms directly — the specific path, not the @/core barrel — per the module rule. And storageAtoms.ts continues to deep-import the transform from @/connections/legacyConnection rather than the index, keeping atom readers out of its top-level-await init graph.

Because the index now genuinely exports atom-reading selectors, the explanatory comment on that deep import (added in PR 6) is tightened from "atom readers the index may export" to state the fact: the index exports the active-connection selectors, which read these atoms. The preload tests (storageAtoms.test.ts, storedConnectionShapes.test.ts) pass without hanging, confirming no cycle was introduced.

Tests

The activeConfigSelector/activeConnectionAtom suites move out of configuration.test.ts and the queryEngineSelector suite out of connector.test.ts, into connections/activeConnection.test.ts. configuration.test.ts keeps the merge/type-config coverage; connector.test.ts keeps the explorerAtom suite.

Compatibility (per the epic's hard rules)

  • Storage keys and persisted/file field names unchanged.
  • Persisted atoms stay in storageAtoms.ts.
  • Phase A golden fixtures untouched.
  • No symbol renames.

Verification

  • pnpm checks green (lint, format, types across all 4 workspace projects).
  • pnpm test green — 3150 tests / 241 files.
  • No init cycle: the top-level-await preload tests pass; the module-import rule (specific storageAtoms path, deep legacyConnection import) is what keeps atom readers out of the init graph.
  • The queryEngineSelector gremlin-fallback and activeConnectionAtom URL-normalization tests were verified by mutation (they go red when the moved logic is broken).

Blocked features

None.

Phase B (7/10) of the connections refactor (aws#2298). Move the active-connection
selectors into src/connections/activeConnection.ts: activeConfigSelector and
activeConnectionAtom (from core/StateProvider/configuration.ts), and
queryEngineSelector and useQueryEngine (from core/connector.ts).

Importers switch to @/connections. activeConnection.ts reads the persisted
atoms from @/core/StateProvider/storageAtoms directly, not the @/core barrel.
This is the first module code the index exports that reads those atoms, so the
storageAtoms deep-import comment is updated to state the index now exports the
active-connection selectors. configuration.ts keeps the schema/merge selectors;
connector.ts keeps explorerAtom and serverLogger. Tests move alongside the
selectors. No renames, byte-identical bodies.
@mjuarros
mjuarros marked this pull request as ready for review October 1, 2026 20:41
@kmcginnes
kmcginnes merged commit 1fd4f8e into aws:main Oct 1, 2026
3 checks passed
kmcginnes pushed a commit that referenced this pull request Oct 2, 2026
…ode into src/connections/ (#2349)

Phase B, PR 8 of #2298. Pure refactor, no behavior change. Follows #2348
(PR 7).

## What this does

Moves the Exported Connection File code into `src/connections/`, via
`git mv` (history preserved, bodies byte-identical, no renames):

- `parseConnectionFile` + the `ExportedConnectionFile` type (from
`utils/`)
- `saveConfigurationToFile` (from `utils/`)
- `useImportConnectionFile` (from `modules/AvailableConnections/`)
- their tests, plus `connectionFileGoldenFiles.test.ts` and its
`__fixtures__/` (the golden test now exercises connections-module code,
so it moves with the module)

Importers switch to `@/connections`. Inside the module, core is imported
by specific path (`@/core/entities`, `@/core/ConfigurationProvider`,
`@/core/StateProvider/storageAtoms`, `@/core/StateProvider/appStore`),
never the `@/core` barrel.

## Default export

`saveConfigurationToFile` keeps its `export default` in the file and is
re-exported from the module index as a **named** export (`export {
default as saveConfigurationToFile }`) — the same pattern
`core/ConfigurationProvider/index.ts` and `utils/index.ts` already use.
The two former default-importers switched to the named import.

## Compatibility (per the epic's hard rules)

- **Phase A golden fixtures byte-unchanged** — git records all 5 as
`R100` pure renames; the byte-exact export golden test passes unchanged
in its new home.
- Storage keys and persisted/file field names unchanged.
- Persisted atoms stay in `storageAtoms.ts`; `useImportConnectionFile`
reads them via the specific `storageAtoms` path (no new init cycle).
- No symbol renames.

## Verification

- `pnpm checks` green (lint, format, types across all 4 workspace
projects).
- `pnpm test` green — 3150 tests / 241 files.
- The golden test was verified to still bite by mutation: altering the
exported legacy `url` value turns it red against the un-edited `?raw`
fixture bytes.
- No init cycle: the `storageAtoms`/`storedConnectionShapes` preload
tests pass.

Also updates two stale path references the move left behind
(`docs/agents/testing.md`, the shared-file-envelope ADR).

## Blocked features

None.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants