Skip to content

Commit 42fad89

Browse files
authored
refactor: trim internal-only exports from the public barrels (#203) (#206)
Remove four internal-only re-exports from the package root and /alliance entry to shrink the public surface and blast radius: trimOptional, createUnconfiguredAllianceContext (core), and the concrete URL generators generatorMailing, generatorSlackCpplang (alliance). The symbols stay in their modules; only the barrel re-exports are dropped, and no in-repo importer used them via the barrel. Deprecated-in-window legacy facades are kept. Add a snapshot guard test that pins the runtime value-export allow-list for both barrels, so a future internal symbol leaking into a barrel fails CI. Document the removal in CHANGELOG (Breaking, library) and MIGRATION.
1 parent 91ff308 commit 42fad89

5 files changed

Lines changed: 84 additions & 7 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ Tagged releases are published to npm from GitHub Actions when a **GitHub Release
1919
- **Breaking (library API):** `PineconeClient.listNamespacesWithMetadata()` now returns `{ namespaces, warnings }` instead of a bare array. Migration: [MIGRATION.md § Unreleased PineconeClient.listNamespacesWithMetadata](docs/MIGRATION.md#unreleased-pineconeclientlistnamespaceswithmetadata-return-shape).
2020
- **Instructions:** Trimmed operator/install/deploy content (env-var setup, misconfiguration note, Alliance CLI index/rerank defaults, stderr logging config) from `CORE_SERVER_INSTRUCTIONS` and `ALLIANCE_INSTRUCTIONS_APPENDIX` — reduces per-session token cost; no behavior change. Replaced colliding Alliance appendix steps 4–5 with unnumbered "Manual Alliance flow" bullets (includes `PINECONE_DISABLE_SUGGEST_FLOW=true` escape clause). Full detail remains in [docs/CONFIGURATION.md](docs/CONFIGURATION.md).
2121

22+
### Removed
23+
24+
- **Breaking (library):** Trimmed internal-only re-exports from the package root and `/alliance` entry to shrink the public surface and blast radius: `trimOptional`, `createUnconfiguredAllianceContext` (core), and the concrete URL generators `generatorMailing`, `generatorSlackCpplang` (alliance). These were internal helpers, not part of the documented API; register built-ins via `registerBuiltinUrlGenerators` and build contexts via `createServer` / `createIsolatedContext`. A snapshot test now guards the runtime export surface so internal symbols cannot leak back in. See [MIGRATION.md](docs/MIGRATION.md#internal-only-re-exports-removed-203). (#203)
25+
2226
## [0.4.0] - 2026-06-24
2327

2428
### Added

docs/MIGRATION.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,16 @@ import { buildQueryExperimental } from '@will-cppa/pinecone-read-only-mcp';
252252

253253
`PineconeClient.query()` return types (`HybridQueryResult`, etc.) and all Zod response schemas remain on the public surface.
254254

255+
### Internal-only re-exports removed (#203)
256+
257+
**Who is affected:** Library embedders that imported any of these internal helpers from the package root or `/alliance`:
258+
259+
- `trimOptional` (a string-trim helper)
260+
- `createUnconfiguredAllianceContext` (an internal context factory used by setup guards)
261+
- `generatorMailing`, `generatorSlackCpplang` (the concrete Alliance URL generators)
262+
263+
**After:** none of these are part of the supported surface. Trim whitespace yourself, build contexts with `createServer` / `createIsolatedContext`, and register the built-in URL generators with `registerBuiltinUrlGenerators` (the documented entry point) instead of importing the individual generators. The public runtime export surface is now guarded by a snapshot test so internal symbols cannot leak back in.
264+
255265
## Unreleased: `ServerContext` instance APIs (initial)
256266

257267
**Rationale:** Process-global singletons (Pinecone client slot, config, URL registry, suggest-flow gate, namespaces cache) complicate testing and multi-tenant embedding. The initial milestone introduces an opt-in **`ServerContext`**; legacy module facades are deprecated since **0.3.0** (see [Legacy module-facade deprecations](#030-legacy-module-facade-deprecations)).

src/alliance/index.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,5 @@ export {
1313
export type { AllianceServerConfig } from './config.js';
1414
export type { AllianceServerContext } from '../core/server/server-context.js';
1515
export { setupAllianceServer, type SetupAllianceServerOptions } from './setup.js';
16-
export {
17-
registerBuiltinUrlGenerators,
18-
generatorMailing,
19-
generatorSlackCpplang,
20-
} from './url-builtins.js';
16+
export { registerBuiltinUrlGenerators } from './url-builtins.js';
2117
export type { RegisterBuiltinUrlGeneratorsOptions } from './url-builtins.js';
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,77 @@
11
import { describe, expect, it } from 'vitest';
22
import * as core from '../index.js';
3+
import * as alliance from '../../alliance/index.js';
4+
5+
/**
6+
* Guards the public runtime export surface of both barrels (#203). Types are
7+
* erased at runtime, so only value exports appear here; this catches an internal
8+
* symbol accidentally leaking into a barrel and growing the blast radius. When a
9+
* genuinely public symbol is added, add it to the allow-list in the same change.
10+
*/
11+
const CORE_PUBLIC_EXPORTS = [
12+
'PineconeClient',
13+
'ServerContext',
14+
'SourceRegistry',
15+
'buildSourceRegistry',
16+
'countResponseSchema',
17+
'createIsolatedContext',
18+
'createServer',
19+
'generateUrlForNamespace',
20+
'generateUrlsResponseSchema',
21+
'getDefaultServerContext',
22+
'guidedQueryResponseSchema',
23+
'hasUrlGenerator',
24+
'keywordSearchResponseSchema',
25+
'keywordSearchSuccessResponseSchema',
26+
'listNamespacesResponseSchema',
27+
'namespaceRouterResponseSchema',
28+
'queryDocumentsResponseSchema',
29+
'queryResponseSchema',
30+
'queryResultRowSchema',
31+
'querySuccessResponseSchema',
32+
'registerUrlGenerator',
33+
'resolveConfig',
34+
'setPineconeClient',
35+
'setupCoreServer',
36+
'suggestQueryParams',
37+
'suggestQueryParamsResponseSchema',
38+
'teardownServer',
39+
'toolErrorSchema',
40+
'unregisterUrlGenerator',
41+
'validateMetadataFilter',
42+
'validateMetadataFilterDetailed',
43+
];
44+
45+
const ALLIANCE_PUBLIC_EXPORTS = [
46+
...CORE_PUBLIC_EXPORTS,
47+
'ALLIANCE_DEFAULT_INDEX_NAME',
48+
'ALLIANCE_DEFAULT_RERANK_MODEL',
49+
'DEFAULT_ALLIANCE_RERANK_MODEL',
50+
'registerBuiltinUrlGenerators',
51+
'resolveAllianceConfig',
52+
'setupAllianceServer',
53+
].sort();
354

455
describe('public export surface', () => {
556
it('does not export internal experimental block builders', () => {
657
expect('buildQueryExperimental' in core).toBe(false);
758
expect('buildGuidedQueryExperimental' in core).toBe(false);
859
});
60+
61+
it('does not export the internal-only symbols trimmed in #203', () => {
62+
for (const name of ['trimOptional', 'createUnconfiguredAllianceContext']) {
63+
expect(name in core).toBe(false);
64+
}
65+
for (const name of ['generatorMailing', 'generatorSlackCpplang']) {
66+
expect(name in alliance).toBe(false);
67+
}
68+
});
69+
70+
it('core barrel value exports match the allow-list', () => {
71+
expect(Object.keys(core).sort()).toEqual([...CORE_PUBLIC_EXPORTS].sort());
72+
});
73+
74+
it('alliance barrel value exports match the allow-list', () => {
75+
expect(Object.keys(alliance).sort()).toEqual(ALLIANCE_PUBLIC_EXPORTS);
76+
});
977
});

src/core/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ export {
1111
ServerContext,
1212
createServer,
1313
createIsolatedContext,
14-
createUnconfiguredAllianceContext,
1514
getDefaultServerContext,
1615
} from './server/server-context.js';
1716
export type {
@@ -65,7 +64,7 @@ export {
6564
hasUrlGenerator,
6665
} from './server/url-registry.js';
6766
export type { UrlGenerationResult, UrlGenerator, UrlGeneratorFn } from './server/url-registry.js';
68-
export { resolveConfig, trimOptional } from './config.js';
67+
export { resolveConfig } from './config.js';
6968
export type { SourceDefinition } from './server/source-config.js';
7069
export { SourceRegistry, buildSourceRegistry } from './server/source-registry.js';
7170
export type { AggregatedCacheResult, PerSourceCacheResult } from './server/source-registry.js';

0 commit comments

Comments
 (0)