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:31:29 -05:00
parent 5e255d7e30
commit 373936c312
6 changed files with 168 additions and 129 deletions

View file

@ -282,7 +282,12 @@ function parseQuestDbPort(raw: string): number {
return port;
}
function hasConflictingUrlSslSetting(rawUrl: string, explicitSsl: boolean): boolean {
function isQuestDbUrlTlsParamKey(rawKey: string): boolean {
const key = rawKey.trim().toLowerCase();
return key === 'uselibpqcompat' || key === 'ssl' || key.startsWith('ssl');
}
function hasQuestDbUrlTlsOptions(rawUrl: string): boolean {
let parsed: URL;
try {
parsed = new URL(rawUrl);
@ -290,45 +295,8 @@ function hasConflictingUrlSslSetting(rawUrl: string, explicitSsl: boolean): bool
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
) {
for (const [rawKey] of parsed.searchParams.entries()) {
if (isQuestDbUrlTlsParamKey(rawKey)) {
return true;
}
}
@ -374,10 +342,10 @@ function parseQuestDbConfig(data: {
);
}
const url = parsePgWireUrl(rawUrl, ENV_QUESTDB_URL);
if (ssl !== undefined && hasConflictingUrlSslSetting(url, ssl)) {
if (ssl !== undefined && hasQuestDbUrlTlsOptions(url)) {
throw new ResearchCopilotHostConfigError(
ENV_QUESTDB_SSL,
`Conflicting configuration variable "${ENV_QUESTDB_SSL}": conflicts with SSL query parameters in "${ENV_QUESTDB_URL}".`
`Conflicting configuration variable "${ENV_QUESTDB_SSL}": cannot be combined with TLS/SSL query parameters in "${ENV_QUESTDB_URL}". Configure TLS in either the URL or "${ENV_QUESTDB_SSL}", not both.`
);
}
return {