From 4f0d16de5a8237baaee87dce2496782286aaae9f Mon Sep 17 00:00:00 2001 From: Studio Date: Tue, 1 Dec 2026 23:24:23 -0500 Subject: [PATCH] T-148: edits made in the worktree --- libs/research/README.md | 4 ++-- libs/research/src/market-data-store-routed.ts | 8 +++++--- libs/research/test/market-data-store-routed.test.ts | 1 - 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/libs/research/README.md b/libs/research/README.md index a65593d7..93e29a1d 100644 --- a/libs/research/README.md +++ b/libs/research/README.md @@ -131,7 +131,7 @@ Exported from `@stock-bot/research` and `@stock-bot/research/market-data-store-r - **`createRoutedMarketDataStore({ daily, intraday })`** — Composes a full daily `MarketDataStore` (e.g. `createDuckDbMarketDataStore`) with an intraday `bars` reader (`Pick`, e.g. `createQuestDbIntradayBarsReader`). - `bars(q)` with `timeframe: '1m'` delegates directly to `intraday.bars(q)` (preserving lazy iteration, receiver, query identity, and error propagation). Note that `createQuestDbIntradayBarsReader` supports split-unadjusted raw (`adjustment: 'raw'`) `1m` bars. - `bars(q)` with any other timeframe (`'1d'`, `'5m'`, `'1h'`, or malformed inputs) and all other `MarketDataStore` methods (`crossSection`, `fundamentalsAsOf`, `events`, `shortsAsOf`, `macroAsOf`, `fx`, `universe`) delegate directly to `daily`. - - **Shared Vault fence requirement:** The router adds no Vault logic of its own; each delegate enforces its own fence. Always construct `daily`, `intraday`, and any MCP tool (`createQueryDataTool` / `createResearchCopilotMcpServer`) with the exact same `vaultCutoffTs` and `vaultOperatorAuthorized`: + - **Shared Vault fence requirement:** The router adds no Vault logic of its own; each delegate enforces its own fence. Always construct `daily` and `intraday` with the exact same `vaultCutoffTs` and `vaultOperatorAuthorized`, and pass that same `vaultCutoffTs` to `createQueryDataTool` (which is always Vault-fenced and accepts only `{ vaultCutoffTs }`): ```ts const vaultCutoffTs = Date.UTC(2025, 6, 1, 0, 0, 0, 0); @@ -151,7 +151,7 @@ const intraday = createQuestDbIntradayBarsReader({ const store = createRoutedMarketDataStore({ daily, intraday }); const queryDataTool = createQueryDataTool({ store, - vaultContext: { vaultCutoffTs, vaultOperatorAuthorized }, + vaultContext: { vaultCutoffTs }, }); ``` diff --git a/libs/research/src/market-data-store-routed.ts b/libs/research/src/market-data-store-routed.ts index c9594321..a7b52608 100644 --- a/libs/research/src/market-data-store-routed.ts +++ b/libs/research/src/market-data-store-routed.ts @@ -13,8 +13,9 @@ * enforce its own Vault holdout fence and point-in-time predicates. * - Callers MUST construct both `daily` and `intraday` with the exact same * `vaultCutoffTs` and `vaultOperatorAuthorized` values (and pass the same - * `vaultCutoffTs` to MCP tools such as `createQueryDataTool`) so the holdout - * boundary is identical across timeframes. + * `vaultCutoffTs` to MCP tools such as `createQueryDataTool`, which is + * always Vault-fenced) so the holdout boundary is identical across + * timeframes. * - The QuestDB intraday reader (`createQuestDbIntradayBarsReader`) supports * split-unadjusted `adjustment: 'raw'` `1m` bars; non-`'raw'` `1m` requests * and unsupported timeframes (`'5m'`, `'1h'`) are handled by the respective @@ -100,9 +101,10 @@ function isIntraday1mBarsQuery(q: unknown): boolean { * vaultOperatorAuthorized, * }); * const store = createRoutedMarketDataStore({ daily, intraday }); + * // `createQueryDataTool` is always Vault-fenced and accepts only `vaultCutoffTs`. * const queryDataTool = createQueryDataTool({ * store, - * vaultContext: { vaultCutoffTs, vaultOperatorAuthorized }, + * vaultContext: { vaultCutoffTs }, * }); * ``` */ diff --git a/libs/research/test/market-data-store-routed.test.ts b/libs/research/test/market-data-store-routed.test.ts index 1a7c4e90..81b38fb6 100644 --- a/libs/research/test/market-data-store-routed.test.ts +++ b/libs/research/test/market-data-store-routed.test.ts @@ -985,7 +985,6 @@ describe('createRoutedMarketDataStore', () => { store: routedStore, vaultContext: { vaultCutoffTs: VAULT_CUTOFF_TS, - vaultOperatorAuthorized: false, }, }), ],