Skip to content

Commit 7b8df0d

Browse files
jonathanMLDevzhocursoragent
authored
Bugfix/legacy facade dual state and v0.3.0 (cppalliance#175)
* fix(server-context): prevent legacy facade dual-state with explicit setup context Add facadeSupersededBy tracking and installExplicitServerContext so mixing legacy facades with setupCoreServer({ context }) throws instead of silent dual-state. Keep client migration in resolveSetupContext. Co-authored-by: Cursor <cursoragent@cursor.com> * chore(release): pin facade deprecation at v0.3.0, opt-in runtime warnings Update deprecation policy and MIGRATION anchors, bump to 0.3.0, move CHANGELOG Unreleased content, and add PINECONE_DEPRECATION_WARNINGS-gated warn helper. Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: zho <jornathanm910923@gmail.com> Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 78bc4ff commit 7b8df0d

17 files changed

Lines changed: 344 additions & 113 deletions

CHANGELOG.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ Tagged releases are published to npm from GitHub Actions when a **GitHub Release
88

99
## [Unreleased]
1010

11+
## [0.3.0] - 2026-06-23
12+
1113
### Added
1214

1315
- `guided_query` tool registered by `setupCoreServer` / package-root import (core-layer handler; no Alliance URL generators or index defaults required).
@@ -29,19 +31,17 @@ Tagged releases are published to npm from GitHub Actions when a **GitHub Release
2931

3032
### Deprecated
3133

32-
- Module-level singleton facades — use `ServerContext` instance methods via `createServer(config)` and `{ context: ctx }` at setup instead. Deprecated in the **next minor release** (see `[Unreleased]` until version is tagged); earliest removal **two minor releases later** per [deprecation-policy.md](docs/deprecation-policy.md#deprecation-window). Affected symbols: `getPineconeClient`, `setPineconeClient`, `clearPineconeClient`, `getServerConfig`, `setServerConfig`, `resetServerConfig`, `registerUrlGenerator`, `unregisterUrlGenerator`, `generateUrlForNamespace`, `hasUrlGenerator`, `resetUrlGenerationRegistry`, `markSuggested`, `requireSuggested`, `resetSuggestionFlow`, `getNamespacesWithCache`, `invalidateNamespacesCache`, `getDefaultServerContext`. See [MIGRATION.md § Legacy module-facade deprecations](docs/MIGRATION.md#unreleased-legacy-module-facade-deprecations) and [deprecation-policy.md](docs/deprecation-policy.md#active-deprecations-legacy-module-facades).
33-
34-
### Added
35-
36-
- Zod schemas for all nine MCP tool success responses (`queryResponseSchema`, `guidedQueryResponseSchema`, etc.) exported from the package root for client-side validation. Success payloads are runtime-validated before return.
37-
- Stable vs experimental response field taxonomy documented in [docs/TOOLS.md](docs/TOOLS.md) and [docs/deprecation-policy.md](docs/deprecation-policy.md#stable-vs-experimental-mcp-response-fields).
38-
- Formal deprecation policy ([docs/deprecation-policy.md](docs/deprecation-policy.md)) and breaking-change release notes template ([docs/templates/breaking-change-release-notes.md](docs/templates/breaking-change-release-notes.md)).
34+
- Module-level singleton facades — use `ServerContext` instance methods via `createServer(config)` and `{ context: ctx }` at setup instead. Deprecated in **0.3.0**; earliest removal **0.5.0** per [deprecation-policy.md](docs/deprecation-policy.md#deprecation-window). Affected symbols: `getPineconeClient`, `setPineconeClient`, `clearPineconeClient`, `getServerConfig`, `setServerConfig`, `resetServerConfig`, `registerUrlGenerator`, `unregisterUrlGenerator`, `generateUrlForNamespace`, `hasUrlGenerator`, `resetUrlGenerationRegistry`, `markSuggested`, `requireSuggested`, `resetSuggestionFlow`, `getNamespacesWithCache`, `invalidateNamespacesCache`, `getDefaultServerContext`. Opt-in runtime warnings when `PINECONE_DEPRECATION_WARNINGS=1` or log level is `DEBUG`. See [MIGRATION.md § Legacy module-facade deprecations](docs/MIGRATION.md#030-legacy-module-facade-deprecations) and [deprecation-policy.md](docs/deprecation-policy.md#active-deprecations-legacy-module-facades).
3935

4036
### Removed
4137

4238
- **Breaking (library):** `buildQueryExperimental` and `buildGuidedQueryExperimental` are no longer re-exported from `@will-cppa/pinecone-read-only-mcp` or `@will-cppa/pinecone-read-only-mcp/alliance`. They were internal helpers used to assemble the `experimental` block on `query` / `query_documents` / `guided_query` success payloads. The assembled fields and Zod schemas (`queryResponseSchema`, `QueryExperimental`, etc.) are unchanged — see [Unreleased stable vs experimental](docs/MIGRATION.md#unreleased-stable-vs-experimental-response-fields).
4339
- **No change:** `HybridQueryResult`, `HybridLegFailed`, and `KeywordIndexNamespacesResult` remain exported as the declared return types of public `PineconeClient` methods.
4440

41+
### Fixed
42+
43+
- Legacy module facades no longer silently diverge from an explicit `ServerContext` passed to `setupCoreServer` / `setupAllianceServer`. Mixing legacy facades with `{ context: ctx }` setup now throws with migration guidance instead of dual-state behavior.
44+
4545
## [0.2.0] - 2026-05-29
4646

4747
- Package root export is the generic **core** layer (`setupCoreServer`); full CLI parity uses `@will-cppa/pinecone-read-only-mcp/alliance` (`setupAllianceServer`, built-in URL generators). `resolveConfig` uses env when set, else defaults: index **`rag-hybrid`**, rerank **`bge-reranker-v2-m3`** (constants `DEFAULT_INDEX_NAME` / `DEFAULT_RERANK_MODEL` in `src/core/config.ts`).

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ const server = await setupAllianceServer(resolveAllianceConfig({ apiKey: '...' }
170170
// Call teardownServer() before re-initializing the process-default context.
171171
```
172172

173-
Do not use this pattern for new code or multi-tenant embedding. See [docs/MIGRATION.md](docs/MIGRATION.md#unreleased-legacy-module-facade-deprecations).
173+
Do not use this pattern for new code or multi-tenant embedding. See [docs/MIGRATION.md](docs/MIGRATION.md#030-legacy-module-facade-deprecations).
174174

175175
### Custom URL generators
176176

docs/MIGRATION.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ When no experimental fields apply, the `experimental` key is **omitted** (not an
6969

7070
**Promotion:** Moving a field from `experimental` to stable requires CHANGELOG, TOOLS.md, and schema updates per [deprecation-policy.md § Stable vs experimental](./deprecation-policy.md#stable-vs-experimental-mcp-response-fields).
7171

72-
## Unreleased: Legacy module-facade deprecations
72+
## 0.3.0: Legacy module-facade deprecations
7373

74-
**Rationale:** Module-level singleton facades (`setPineconeClient`, `registerUrlGenerator`, `getDefaultServerContext`, etc.) delegate to a process-global `ServerContext`. They complicate multi-tenant embedding and hide initialization order. They are marked `@deprecated` in JSDoc; earliest removal is **two minor releases after** the deprecation minor (see [deprecation-policy.md § Deprecation window](./deprecation-policy.md#deprecation-window)).
74+
**Rationale:** Module-level singleton facades (`setPineconeClient`, `registerUrlGenerator`, `getDefaultServerContext`, etc.) delegate to a process-global `ServerContext`. They complicate multi-tenant embedding and hide initialization order. They are marked `@deprecated` in JSDoc since **0.3.0**; earliest removal is **0.5.0** (see [deprecation-policy.md § Deprecation window](./deprecation-policy.md#deprecation-window)).
7575

7676
**Who is affected:** Library embedders importing facade functions from `@will-cppa/pinecone-read-only-mcp` or `/alliance`.
7777

@@ -184,7 +184,7 @@ import { buildQueryExperimental } from '@will-cppa/pinecone-read-only-mcp';
184184

185185
## Unreleased: `ServerContext` instance APIs (initial)
186186

187-
**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 (see [Legacy module-facade deprecations](#unreleased-legacy-module-facade-deprecations)).
187+
**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)).
188188

189189
**Deprecated (migrate before removal):**
190190

docs/deprecation-policy.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,16 @@ APIs deprecated **before** this policy was published follow the removal target r
3434

3535
### Active deprecations - legacy module facades
3636

37-
Module-level singleton facades delegate to `getDefaultServerContext()`. Migrate to **`ServerContext`** instance methods via `createServer(config)` and pass `{ context: ctx }` to `setupCoreServer` / `setupAllianceServer`. Deprecated in the **next published minor** after merge; earliest removal **two minor releases later** (per [Deprecation window](#deprecation-window) above). See [MIGRATION.md § Legacy module-facade deprecations](./MIGRATION.md#unreleased-legacy-module-facade-deprecations).
37+
Module-level singleton facades delegate to `getDefaultServerContext()`. Migrate to **`ServerContext`** instance methods via `createServer(config)` and pass `{ context: ctx }` to `setupCoreServer` / `setupAllianceServer`. Deprecated in **`0.3.0`**; earliest removal **`0.5.0`** (per [Deprecation window](#deprecation-window) above). See [MIGRATION.md § Legacy module-facade deprecations](./MIGRATION.md#030-legacy-module-facade-deprecations).
3838

3939
| Facade | Layer | Replacement | Deprecated in | Earliest removal |
4040
| ------ | ----- | ----------- | ------------- | ---------------- |
41-
| `getPineconeClient` / `setPineconeClient` / `clearPineconeClient` | core | `ctx.getClient()` / `ctx.setClient()` / `ctx.clearClient()` | next minor (TBD at release) | two minors after deprecation minor |
42-
| `getServerConfig` / `setServerConfig` / `resetServerConfig` | core | `ctx.getConfig()` / `ctx.setConfig()` / `ctx.teardown()` | next minor (TBD at release) | two minors after deprecation minor |
43-
| `registerUrlGenerator` / `unregisterUrlGenerator` / `generateUrlForNamespace` / `hasUrlGenerator` / `resetUrlGenerationRegistry` | core | `ctx.registerUrlGenerator()` etc. / `ctx.resetUrlGenerators()` | next minor (TBD at release) | two minors after deprecation minor |
44-
| `markSuggested` / `requireSuggested` / `resetSuggestionFlow` | core | `ctx.markSuggested()` / `ctx.requireSuggested()` / `ctx.resetSuggestionFlow()` | next minor (TBD at release) | two minors after deprecation minor |
45-
| `getNamespacesWithCache` / `invalidateNamespacesCache` | core | `ctx.getNamespacesWithCache()` / `ctx.invalidateNamespacesCache()` | next minor (TBD at release) | two minors after deprecation minor |
46-
| `getDefaultServerContext` | core | Return value of `createServer` or explicit `context` at setup | next minor (TBD at release) | two minors after deprecation minor |
41+
| `getPineconeClient` / `setPineconeClient` / `clearPineconeClient` | core | `ctx.getClient()` / `ctx.setClient()` / `ctx.clearClient()` | **0.3.0** | **0.5.0** |
42+
| `getServerConfig` / `setServerConfig` / `resetServerConfig` | core | `ctx.getConfig()` / `ctx.setConfig()` / `ctx.teardown()` | **0.3.0** | **0.5.0** |
43+
| `registerUrlGenerator` / `unregisterUrlGenerator` / `generateUrlForNamespace` / `hasUrlGenerator` / `resetUrlGenerationRegistry` | core | `ctx.registerUrlGenerator()` etc. / `ctx.resetUrlGenerators()` | **0.3.0** | **0.5.0** |
44+
| `markSuggested` / `requireSuggested` / `resetSuggestionFlow` | core | `ctx.markSuggested()` / `ctx.requireSuggested()` / `ctx.resetSuggestionFlow()` | **0.3.0** | **0.5.0** |
45+
| `getNamespacesWithCache` / `invalidateNamespacesCache` | core | `ctx.getNamespacesWithCache()` / `ctx.invalidateNamespacesCache()` | **0.3.0** | **0.5.0** |
46+
| `getDefaultServerContext` | core | Return value of `createServer` or explicit `context` at setup | **0.3.0** | **0.5.0** |
4747

4848
`teardownServer()` remains supported during the deprecation window; prefer `ctx.teardown()` or `await using` on the setup handle. Documented in MIGRATION.md; not marked `@deprecated` until a later release.
4949

@@ -110,7 +110,7 @@ New response fields added before `1.0.0` default to `experimental` unless explic
110110

111111
Legacy module-level facades are deprecated per the [active deprecations table](./deprecation-policy.md#active-deprecations-legacy-module-facades) above. `ServerContext` + `createServer` / setup APIs are the supported public contract going forward.
112112

113-
See [MIGRATION.md § Legacy module-facade deprecations](./MIGRATION.md#unreleased-legacy-module-facade-deprecations) for before/after embedder snippets.
113+
See [MIGRATION.md § Legacy module-facade deprecations](./MIGRATION.md#030-legacy-module-facade-deprecations) for before/after embedder snippets.
114114

115115
## CHANGELOG format for breaking changes
116116

examples/alliance/library-embedding-demo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
* **Legacy (deprecated):** `setPineconeClient(client)` then
1818
* `await setupAllianceServer(config)` still works during the deprecation window;
19-
* see [docs/MIGRATION.md#unreleased-legacy-module-facade-deprecations](docs/MIGRATION.md#unreleased-legacy-module-facade-deprecations).
19+
* see [docs/MIGRATION.md#030-legacy-module-facade-deprecations](docs/MIGRATION.md#030-legacy-module-facade-deprecations).
2020
*/
2121

2222
import { createServer, PineconeClient } from '@will-cppa/pinecone-read-only-mcp';

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@will-cppa/pinecone-read-only-mcp",
3-
"version": "0.2.0",
3+
"version": "0.3.0",
44
"description": "A Model Context Protocol (MCP) server that provides semantic search over Pinecone vector databases using hybrid search (dense + sparse) with reranking.",
55
"type": "module",
66
"main": "dist/core/index.js",

src/alliance/setup.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ALLIANCE_SERVER_INSTRUCTIONS } from '../constants.js';
22
import type { ServerConfig } from '../core/config.js';
3-
import { getDefaultServerContext, type ServerContext } from '../core/server/server-context.js';
3+
import { resolveDefaultServerContext, type ServerContext } from '../core/server/server-context.js';
44
import { resolveAllianceConfig } from './config.js';
55
import { setupCoreServer, type ServerHandle, type SetupCoreServerOptions } from '../core/setup.js';
66
import { registerBuiltinUrlGenerators } from './url-builtins.js';
@@ -82,7 +82,7 @@ export async function setupAllianceServer(
8282
config: opts.config ?? config,
8383
instructions,
8484
});
85-
resolvedCtx = getDefaultServerContext();
85+
resolvedCtx = resolveDefaultServerContext();
8686
}
8787

8888
registerBuiltinUrlGenerators(resolvedCtx);

src/core/server/client-context.ts

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,42 @@
11
import { PineconeClient } from '../pinecone-client.js';
2-
import { getDefaultServerContext } from './server-context.js';
2+
import { warnLegacyFacade } from './legacy-facade-warn.js';
3+
import { resolveDefaultServerContext } from './server-context.js';
34

45
/**
56
* Return the shared Pinecone client; throws if setPineconeClient has not been called.
67
*
7-
* @deprecated Legacy module facade. Use {@link ServerContext.getClient} on a
8-
* {@link ServerContext} from {@link createServer} instead. Removal follows
9-
* docs/deprecation-policy.md (no earlier than two minor releases after the
10-
* deprecation minor). See docs/MIGRATION.md#unreleased-legacy-module-facade-deprecations.
8+
* @deprecated since 0.3.0 — removal no earlier than 0.5.0. Legacy module facade. Use
9+
* {@link ServerContext.getClient} on a {@link ServerContext} from {@link createServer}
10+
* instead. See docs/MIGRATION.md#030-legacy-module-facade-deprecations.
1111
* @see ServerContext.getClient
1212
*/
1313
export function getPineconeClient(): PineconeClient {
14-
return getDefaultServerContext().getClientIfSet();
14+
warnLegacyFacade('getPineconeClient');
15+
return resolveDefaultServerContext().getClientIfSet();
1516
}
1617

1718
/**
1819
* Set the shared Pinecone client used by all MCP tools.
1920
*
20-
* @deprecated Legacy module facade. Use {@link ServerContext.setClient} on a
21-
* {@link ServerContext} from {@link createServer} instead. Removal follows
22-
* docs/deprecation-policy.md (no earlier than two minor releases after the
23-
* deprecation minor). See docs/MIGRATION.md#unreleased-legacy-module-facade-deprecations.
21+
* @deprecated since 0.3.0 — removal no earlier than 0.5.0. Legacy module facade. Use
22+
* {@link ServerContext.setClient} on a {@link ServerContext} from {@link createServer}
23+
* instead. See docs/MIGRATION.md#030-legacy-module-facade-deprecations.
2424
* @see ServerContext.setClient
2525
*/
2626
export function setPineconeClient(client: PineconeClient): void {
27-
getDefaultServerContext().setClient(client);
27+
warnLegacyFacade('setPineconeClient');
28+
resolveDefaultServerContext().setClient(client);
2829
}
2930

3031
/**
3132
* Clear the shared client (used by {@link teardownServer} and tests).
3233
*
33-
* @deprecated Legacy module facade. Use {@link ServerContext.clearClient} on a
34-
* {@link ServerContext} from {@link createServer} instead. Removal follows
35-
* docs/deprecation-policy.md (no earlier than two minor releases after the
36-
* deprecation minor). See docs/MIGRATION.md#unreleased-legacy-module-facade-deprecations.
34+
* @deprecated since 0.3.0 — removal no earlier than 0.5.0. Legacy module facade. Use
35+
* {@link ServerContext.clearClient} on a {@link ServerContext} from {@link createServer}
36+
* instead. See docs/MIGRATION.md#030-legacy-module-facade-deprecations.
3737
* @see ServerContext.clearClient
3838
*/
3939
export function clearPineconeClient(): void {
40-
getDefaultServerContext().clearClient();
40+
warnLegacyFacade('clearPineconeClient');
41+
resolveDefaultServerContext().clearClient();
4142
}

src/core/server/config-context.ts

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,34 @@
11
import type { ServerConfig } from '../config.js';
2+
import { warnLegacyFacade } from './legacy-facade-warn.js';
23
import {
3-
getDefaultServerContext,
4+
resolveDefaultServerContext,
45
setDefaultServerContext,
56
setPendingServerConfig,
67
} from './server-context.js';
78

89
/**
910
* Replace the process-global server config (called from setup with CLI/env-derived config).
1011
*
11-
* @deprecated Legacy module facade. Use {@link ServerContext.setConfig} on a
12-
* {@link ServerContext} from {@link createServer} instead. Removal follows
13-
* docs/deprecation-policy.md (no earlier than two minor releases after the
14-
* deprecation minor). See docs/MIGRATION.md#unreleased-legacy-module-facade-deprecations.
12+
* @deprecated since 0.3.0 — removal no earlier than 0.5.0. Legacy module facade. Use
13+
* {@link ServerContext.setConfig} on a {@link ServerContext} from {@link createServer}
14+
* instead. See docs/MIGRATION.md#030-legacy-module-facade-deprecations.
1515
* @see ServerContext.setConfig
1616
*/
1717
export function setServerConfig(config: ServerConfig): void {
18+
warnLegacyFacade('setServerConfig');
1819
setPendingServerConfig(config);
1920
}
2021

2122
/**
2223
* Clear active config so the next `getServerConfig()` resolves again (used by {@link teardownServer}).
2324
*
24-
* @deprecated Legacy module facade. Use {@link ServerContext.teardown} on a
25-
* {@link ServerContext} from {@link createServer} instead. Removal follows
26-
* docs/deprecation-policy.md (no earlier than two minor releases after the
27-
* deprecation minor). See docs/MIGRATION.md#unreleased-legacy-module-facade-deprecations.
25+
* @deprecated since 0.3.0 — removal no earlier than 0.5.0. Legacy module facade. Use
26+
* {@link ServerContext.teardown} on a {@link ServerContext} from {@link createServer}
27+
* instead. See docs/MIGRATION.md#030-legacy-module-facade-deprecations.
2828
* @see ServerContext.teardown
2929
*/
3030
export function resetServerConfig(): void {
31+
warnLegacyFacade('resetServerConfig');
3132
setDefaultServerContext(null);
3233
}
3334

@@ -39,12 +40,12 @@ export function resetServerConfig(): void {
3940
* (requires `PINECONE_API_KEY` and `PINECONE_INDEX_NAME` or throws). Alliance apps should
4041
* pass config from `resolveAllianceConfig()` into `setupAllianceServer(config)`.
4142
*
42-
* @deprecated Legacy module facade. Use {@link ServerContext.getConfig} on a
43-
* {@link ServerContext} from {@link createServer} instead. Removal follows
44-
* docs/deprecation-policy.md (no earlier than two minor releases after the
45-
* deprecation minor). See docs/MIGRATION.md#unreleased-legacy-module-facade-deprecations.
43+
* @deprecated since 0.3.0 — removal no earlier than 0.5.0. Legacy module facade. Use
44+
* {@link ServerContext.getConfig} on a {@link ServerContext} from {@link createServer}
45+
* instead. See docs/MIGRATION.md#030-legacy-module-facade-deprecations.
4646
* @see ServerContext.getConfig
4747
*/
4848
export function getServerConfig(): ServerConfig {
49-
return getDefaultServerContext().getConfig();
49+
warnLegacyFacade('getServerConfig');
50+
return resolveDefaultServerContext().getConfig();
5051
}

0 commit comments

Comments
 (0)