@@ -335,9 +335,9 @@ export async function generateFromEntryPoint(options: {
335335 // purely additive — apps that never adopt metric views must not produce
336336 // empty noise.
337337 if ( queryFolder ) {
338- const metricConfig = await readMetricConfig ( queryFolder ) ;
339- if ( metricConfig ) {
340- const resolution = resolveMetricConfig ( metricConfig ) ;
338+ const mvConfig = await readMetricConfig ( queryFolder ) ;
339+ if ( mvConfig ) {
340+ const resolution = resolveMetricConfig ( mvConfig ) ;
341341
342342 // Metric schemas persist in the shared typegen cache as a `metrics`
343343 // section (sibling of `queries`, same file/version), keyed by metric key
@@ -353,11 +353,11 @@ export async function generateFromEntryPoint(options: {
353353 // dropping the entry) instead of storing data. A null prototype also
354354 // keeps partition reads from resolving inherited names ("constructor",
355355 // "toString", ...) as phantom entries.
356- const metricsSection : Record < string , MetricCacheEntry > =
356+ const mvCacheSection : Record < string , MetricCacheEntry > =
357357 Object . create ( null ) ;
358358 if ( ! noCache && cache . metrics ) {
359359 for ( const key of Object . keys ( cache . metrics ) ) {
360- metricsSection [ key ] = cache . metrics [ key ] ;
360+ mvCacheSection [ key ] = cache . metrics [ key ] ;
361361 }
362362 }
363363
@@ -375,7 +375,7 @@ export async function generateFromEntryPoint(options: {
375375 // the single notice below so the misconfiguration isn't silently hidden.
376376 const stickyDegradedHits : string [ ] = [ ] ;
377377 for ( const entry of resolution . entries ) {
378- const prior = metricsSection [ entry . key ] ;
378+ const prior = mvCacheSection [ entry . key ] ;
379379 if (
380380 prior !== undefined &&
381381 isRevivableMetricCacheEntry ( prior ) &&
@@ -402,10 +402,10 @@ export async function generateFromEntryPoint(options: {
402402 // status probe, the blocking preflight, and the default DESCRIBE fetcher
403403 // share this lazily-created instance, so a pass that never contacts the
404404 // warehouse constructs zero clients.
405- let metricClient : WorkspaceClient | undefined ;
406- const getMetricClient = ( ) : WorkspaceClient => {
407- metricClient ??= new WorkspaceClient ( { } ) ;
408- return metricClient ;
405+ let mvClient : WorkspaceClient | undefined ;
406+ const getMvClient = ( ) : WorkspaceClient => {
407+ mvClient ??= new WorkspaceClient ( { } ) ;
408+ return mvClient ;
409409 } ;
410410
411411 // Blocking-mode preflight: ensure the warehouse is running before the
@@ -422,36 +422,28 @@ export async function generateFromEntryPoint(options: {
422422 describeNeeded . length > 0
423423 ) {
424424 try {
425- const state = await getWarehouseState ( getMetricClient ( ) , warehouseId ) ;
425+ const state = await getWarehouseState ( getMvClient ( ) , warehouseId ) ;
426426 const decision = decidePreflight ( state , mode ) ;
427427 if ( decision === "fatal" ) {
428428 preflightFatalMessage = `warehouse ${ warehouseId } is ${ state } ` ;
429429 } else if ( decision === "startWaitProceed" ) {
430430 // treatStoppedAsTransient rides out the stale pre-start
431431 // STOPPED/STOPPING reading, same as the query preflight.
432- await startWarehouse ( getMetricClient ( ) , warehouseId ) ;
433- const settled = await waitUntilRunning (
434- getMetricClient ( ) ,
435- warehouseId ,
436- {
437- maxMs : MV_PREFLIGHT_WAIT_MAX_MS ,
438- treatStoppedAsTransient : true ,
439- } ,
440- ) ;
432+ await startWarehouse ( getMvClient ( ) , warehouseId ) ;
433+ const settled = await waitUntilRunning ( getMvClient ( ) , warehouseId , {
434+ maxMs : MV_PREFLIGHT_WAIT_MAX_MS ,
435+ treatStoppedAsTransient : true ,
436+ } ) ;
441437 if ( settled !== "RUNNING" ) {
442438 // With treatStoppedAsTransient, a non-RUNNING resolve is
443439 // exactly DELETED/DELETING — the warehouse was deleted while
444440 // we waited. Fatal, same as catching it at decision time.
445441 preflightFatalMessage = `warehouse ${ warehouseId } is ${ settled } ` ;
446442 }
447443 } else if ( decision === "waitThenProceed" ) {
448- const settled = await waitUntilRunning (
449- getMetricClient ( ) ,
450- warehouseId ,
451- {
452- maxMs : MV_PREFLIGHT_WAIT_MAX_MS ,
453- } ,
454- ) ;
444+ const settled = await waitUntilRunning ( getMvClient ( ) , warehouseId , {
445+ maxMs : MV_PREFLIGHT_WAIT_MAX_MS ,
446+ } ) ;
455447 if ( settled === "DELETED" || settled === "DELETING" ) {
456448 // Deleted mid-wait: fatal. A STOPPED/STOPPING resolve (this
457449 // wait runs without treatStoppedAsTransient) stays a soft
@@ -486,7 +478,7 @@ export async function generateFromEntryPoint(options: {
486478 describeNeeded . length === 0 ;
487479 if ( ! describeNow ) {
488480 try {
489- gateState = await probeWarehouseState ( getMetricClient , warehouseId ) ;
481+ gateState = await probeWarehouseState ( getMvClient , warehouseId ) ;
490482 } catch ( err ) {
491483 // probeWarehouseState only throws on a deterministic failure (auth,
492484 // bad warehouse id) — a connectivity blip already returned undefined.
@@ -521,7 +513,7 @@ export async function generateFromEntryPoint(options: {
521513 } else if ( describeNow ) {
522514 const fetcher =
523515 metricFetcher ??
524- createWorkspaceDescribeFetcher ( getMetricClient ( ) , warehouseId ) ;
516+ createWorkspaceDescribeFetcher ( getMvClient ( ) , warehouseId ) ;
525517 ( { schemas : described , failures } = await syncMetrics (
526518 { entries : describeNeeded } ,
527519 fetcher ,
@@ -591,7 +583,7 @@ export async function generateFromEntryPoint(options: {
591583 // belongs to describeNeeded[i].
592584 const entry = describeNeeded [ i ] ;
593585 const failure = failureByKey . get ( entry . key ) ;
594- metricsSection [ entry . key ] = {
586+ mvCacheSection [ entry . key ] = {
595587 hash : metricCacheHash ( entry . source , entry . lane ) ,
596588 schema : described [ i ] ,
597589 retry :
@@ -605,9 +597,9 @@ export async function generateFromEntryPoint(options: {
605597 // doesn't haunt the cache file forever.
606598 const configuredKeys = new Set ( resolution . entries . map ( ( e ) => e . key ) ) ;
607599 let prunedCount = 0 ;
608- for ( const key of Object . keys ( metricsSection ) ) {
600+ for ( const key of Object . keys ( mvCacheSection ) ) {
609601 if ( ! configuredKeys . has ( key ) ) {
610- delete metricsSection [ key ] ;
602+ delete mvCacheSection [ key ] ;
611603 prunedCount ++ ;
612604 }
613605 }
@@ -616,7 +608,7 @@ export async function generateFromEntryPoint(options: {
616608 // — a warm pass over a shrunk config has nothing to describe but must
617609 // still shrink the file.
618610 if ( describeNeeded . length > 0 || noCache || prunedCount > 0 ) {
619- cache . metrics = metricsSection ;
611+ cache . metrics = mvCacheSection ;
620612 await saveCache ( cache ) ;
621613 }
622614
@@ -627,7 +619,7 @@ export async function generateFromEntryPoint(options: {
627619 for ( const schema of described ) {
628620 describedByKey . set ( schema . key , schema ) ;
629621 }
630- const metricSchemas = resolution . entries . map ( ( entry ) => {
622+ const mvSchemas = resolution . entries . map ( ( entry ) => {
631623 const schema =
632624 hitSchemas . get ( entry . key ) ?? describedByKey . get ( entry . key ) ;
633625 if ( schema !== undefined ) return schema ;
@@ -643,25 +635,25 @@ export async function generateFromEntryPoint(options: {
643635 return emptyMetricSchema ( entry ) ;
644636 } ) ;
645637
646- const metricFile =
638+ const mvFile =
647639 mvOutFile ?? path . join ( path . dirname ( outFile ) , METRIC_TYPES_FILE ) ;
648- const metricDeclarations = generateMetricTypeDeclarations ( metricSchemas ) ;
649- await fs . mkdir ( path . dirname ( metricFile ) , { recursive : true } ) ;
650- await fs . writeFile ( metricFile , metricDeclarations , "utf-8" ) ;
640+ const mvDeclarations = generateMetricTypeDeclarations ( mvSchemas ) ;
641+ await fs . mkdir ( path . dirname ( mvFile ) , { recursive : true } ) ;
642+ await fs . writeFile ( mvFile , mvDeclarations , "utf-8" ) ;
651643
652644 // Emit the semantic-metadata JSON bundle alongside the .d.ts. The hook
653645 // imports this artifact (via a registration call from the consuming
654646 // app) and exposes the per-metric subset on its return value.
655- const metadataFile =
647+ const mvMetadataFile =
656648 mvMetadataOutFile ??
657- path . join ( path . dirname ( metricFile ) , METRIC_METADATA_FILE ) ;
658- const metadataJson = generateMetricsMetadataJson ( metricSchemas ) ;
659- await fs . mkdir ( path . dirname ( metadataFile ) , { recursive : true } ) ;
660- await fs . writeFile ( metadataFile , metadataJson , "utf-8" ) ;
649+ path . join ( path . dirname ( mvFile ) , METRIC_METADATA_FILE ) ;
650+ const metadataJson = generateMetricsMetadataJson ( mvSchemas ) ;
651+ await fs . mkdir ( path . dirname ( mvMetadataFile ) , { recursive : true } ) ;
652+ await fs . writeFile ( mvMetadataFile , metadataJson , "utf-8" ) ;
661653
662654 logger . debug (
663655 "Wrote MetricRegistry augmentation + metadata bundle for %d metric(s)%s" ,
664- metricSchemas . length ,
656+ mvSchemas . length ,
665657 failures . length > 0 ? ` (${ failures . length } failure(s))` : "" ,
666658 ) ;
667659 }
0 commit comments