chore(catalog-source): split per-source kill switches; default pcat off

Verified 2026-06-01 against dev's 103 unique pcat carIds: the current pcat
dump's deep-scrape (7.978 cars with real parts data via schema_parts or
part_groups+part_group_items) targets a US/JDM-market subset — Toyota 2112,
Nissan 1508, Audi 1311, Chevy 1050, Hyundai 745. **None** of sase's TR-market
vehicles intersect that rich subset:

  - 18/103 sase carIds are in dump.cars at all (registry only)
  - 0/103 yield parts via Bridge A (schema_images → schema_parts)
  - 0/103 yield parts via Bridge B (part_groups → part_group_items)

Even the cars that match by exact carId (Fiat Doblo 368 schemas, Renault
Megane, Bravo 456 schemas) have only diagram metadata — no parts annotation.
The dump scraper finished tier-1 (catalog/model/car listing) and tier-2
(schema diagrams) for these, but stopped before tier-3 (parts annotation).

Under the strict "always correct OEM" constraint there is no safe pcat lookup
today. Disable it. The container stays up for future use cases (OEM cross-
reference search, alt-part matching) and so we can flip the env back without
a code change if a richer dump arrives.

EMEX stays on (its catalog-allowlist is the next step).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-01 17:50:07 +03:00
parent 506f11d636
commit 3a3a7d3ebf
5 changed files with 42 additions and 6 deletions

View File

@@ -73,6 +73,10 @@ export default () => ({
enabled: process.env.CATALOG_SOURCE_DB_ENABLED === "true",
pcatUrl: process.env.PCAT_SOURCE_DB_URL,
emexUrl: process.env.EMEX_SOURCE_DB_URL,
// Per-source kill switches. PCAT defaults off — the current dump's deep-scrape
// doesn't cover sase's TR-market vehicles; see service comment for details.
emexEnabled: (process.env.EMEX_SOURCE_DB_ENABLED ?? "true") === "true",
pcatEnabled: process.env.PCAT_SOURCE_DB_ENABLED === "true",
},
otel: {
enabled: process.env.OTEL_ENABLED === "true",

View File

@@ -30,11 +30,14 @@ export class EmexSourceDbService implements OnModuleInit, OnModuleDestroy {
constructor(private readonly config: ConfigService) {}
onModuleInit() {
const enabled = this.config.get<boolean>("catalogSource.enabled");
const masterEnabled = this.config.get<boolean>("catalogSource.enabled");
const emexEnabled = this.config.get<boolean>("catalogSource.emexEnabled");
const url = this.config.get<string>("catalogSource.emexUrl");
if (!enabled || !url) {
if (!masterEnabled || !emexEnabled || !url) {
this.logger.log(
`[emex-src] disabled (enabled=${enabled}, urlSet=${Boolean(url)}); upstream-only`,
`[emex-src] disabled (master=${masterEnabled}, emex=${emexEnabled}, urlSet=${Boolean(
url,
)}); upstream-only`,
);
return;
}

View File

@@ -24,11 +24,19 @@ export class PcatSourceDbService implements OnModuleInit, OnModuleDestroy {
constructor(private readonly config: ConfigService) {}
onModuleInit() {
const enabled = this.config.get<boolean>("catalogSource.enabled");
const masterEnabled = this.config.get<boolean>("catalogSource.enabled");
const pcatEnabled = this.config.get<boolean>("catalogSource.pcatEnabled");
const url = this.config.get<string>("catalogSource.pcatUrl");
if (!enabled || !url) {
// Default off: verified 2026-06-01 that the current pcat dump's deep-scrape
// (7.978 cars with real parts) targets US/JDM-market models (Toyota 2112,
// Nissan 1508, Audi 1311, Chevy 1050, Hyundai 745) and covers 0 of sase's
// 103 dev TR-market pcat carIds via either bridge (schema_parts or
// part_groups+part_group_items). Container stays up for future use cases.
if (!masterEnabled || !pcatEnabled || !url) {
this.logger.log(
`[pcat-src] disabled (enabled=${enabled}, urlSet=${Boolean(url)}); upstream-only`,
`[pcat-src] disabled (master=${masterEnabled}, pcat=${pcatEnabled}, urlSet=${Boolean(
url,
)}); upstream-only`,
);
return;
}

View File

@@ -74,6 +74,9 @@ services:
- CATALOG_SOURCE_DB_ENABLED=${CATALOG_SOURCE_DB_ENABLED:-false}
- PCAT_SOURCE_DB_URL=${PCAT_SOURCE_DB_URL:-}
- EMEX_SOURCE_DB_URL=${EMEX_SOURCE_DB_URL:-}
# Per-source kill switches. pcat default off (dump doesn't cover TR vehicles).
- EMEX_SOURCE_DB_ENABLED=${EMEX_SOURCE_DB_ENABLED:-true}
- PCAT_SOURCE_DB_ENABLED=${PCAT_SOURCE_DB_ENABLED:-false}
depends_on:
sase-redis:
condition: service_healthy
@@ -140,6 +143,9 @@ services:
- CATALOG_SOURCE_DB_ENABLED=${CATALOG_SOURCE_DB_ENABLED:-false}
- PCAT_SOURCE_DB_URL=${PCAT_SOURCE_DB_URL:-}
- EMEX_SOURCE_DB_URL=${EMEX_SOURCE_DB_URL:-}
# Per-source kill switches. pcat default off (dump doesn't cover TR vehicles).
- EMEX_SOURCE_DB_ENABLED=${EMEX_SOURCE_DB_ENABLED:-true}
- PCAT_SOURCE_DB_ENABLED=${PCAT_SOURCE_DB_ENABLED:-false}
depends_on:
sase-redis:
condition: service_healthy

View File

@@ -120,6 +120,21 @@ export const envSchema = z.object({
.default("false"),
PCAT_SOURCE_DB_URL: z.string().url().optional(),
EMEX_SOURCE_DB_URL: z.string().optional(), // mysql://... — not a strict URL per WHATWG
// Per-source kill switches under the master CATALOG_SOURCE_DB_ENABLED.
// EMEX defaults true (catalog-allowlist tightens which catalogs hit the dump).
// PCAT defaults FALSE — verified 2026-06-01 that the dump's deep-scrape covers
// a US/JDM market subset (Toyota/Nissan/Audi/Chevy/Hyundai) that doesn't
// intersect sase's TR-market vehicle pool (0 / 103 dev carIds had real parts
// data through either bridge). Container stays running for future use cases
// (OEM cross-ref, alt-part search).
EMEX_SOURCE_DB_ENABLED: z
.string()
.transform((v) => v === "true")
.default("true"),
PCAT_SOURCE_DB_ENABLED: z
.string()
.transform((v) => v === "true")
.default("false"),
});
export type Env = z.infer<typeof envSchema>;