T-210: M2.3s — Implement MarketDataStore.macroAsOf, crossSection, QuestDB fx('1m'), and copilot 1m routing

This commit is contained in:
Studio 2026-12-04 15:23:16 -05:00
parent c60365237f
commit 5e255d7e30
8 changed files with 587 additions and 37 deletions

View file

@ -282,6 +282,60 @@ function parseQuestDbPort(raw: string): number {
return port;
}
function hasConflictingUrlSslSetting(rawUrl: string, explicitSsl: boolean): boolean {
let parsed: URL;
try {
parsed = new URL(rawUrl);
} catch {
return false;
}
for (const [rawKey, rawValue] of parsed.searchParams.entries()) {
const key = rawKey.toLowerCase();
const value = rawValue.trim().toLowerCase();
if (key === 'sslmode') {
if (value === 'disable') {
if (explicitSsl) {
return true;
}
} else if (
value === 'require' ||
value === 'verify-ca' ||
value === 'verify-full' ||
value === 'no-verify'
) {
if (!explicitSsl) {
return true;
}
} else {
// `allow`, `prefer`, or any unrecognized sslmode conflicts with an explicit boolean override.
return true;
}
} else if (key === 'ssl') {
if (value === 'false' || value === '0') {
if (explicitSsl) {
return true;
}
} else if (value === 'true' || value === '1') {
if (!explicitSsl) {
return true;
}
} else {
return true;
}
} else if (
(key === 'sslcert' || key === 'sslkey' || key === 'sslrootcert') &&
value.length > 0 &&
!explicitSsl
) {
return true;
}
}
return false;
}
function parseQuestDbConfig(data: {
readonly [ENV_QUESTDB_URL]?: string;
readonly [ENV_QUESTDB_HOST]?: string;
@ -320,6 +374,12 @@ function parseQuestDbConfig(data: {
);
}
const url = parsePgWireUrl(rawUrl, ENV_QUESTDB_URL);
if (ssl !== undefined && hasConflictingUrlSslSetting(url, ssl)) {
throw new ResearchCopilotHostConfigError(
ENV_QUESTDB_SSL,
`Conflicting configuration variable "${ENV_QUESTDB_SSL}": conflicts with SSL query parameters in "${ENV_QUESTDB_URL}".`
);
}
return {
url,
...(ssl !== undefined ? { ssl } : {}),