44// Corpus mode dumps all four PromQL corpora as JSONL and writes a heuristic
55// anomaly report. The default mode remains the ad-hoc SQL/PromQL inspector.
66
7- use asap_devtools:: { lower_promql , SqlCatalog } ;
7+ use asap_devtools:: { lower_promql_with_data_ingestion_interval , SqlCatalog } ;
88use asap_frontend_sql:: lower_sql_dialect;
99use asap_types:: pre_asap:: schema:: { Column , DataType , Schema } ;
1010use asap_types:: types:: AccuracyTarget ;
@@ -201,12 +201,16 @@ fn structural_shape(expression: &str) -> String {
201201 out
202202}
203203
204- fn run_corpus ( name : & str , source : & str ) -> CorpusResult {
204+ fn run_corpus ( name : & str , source : & str , interval_ms : u64 ) -> CorpusResult {
205205 let mut result = CorpusResult :: default ( ) ;
206206 for ( index, expression) in corpus_lines ( source) . into_iter ( ) . enumerate ( ) {
207207 let normalized_expression = normalize ( expression) ;
208208 let structural_shape = structural_shape ( expression) ;
209- match lower_promql ( expression, AccuracyTarget :: Exact ) {
209+ match lower_promql_with_data_ingestion_interval (
210+ expression,
211+ AccuracyTarget :: Exact ,
212+ interval_ms,
213+ ) {
210214 Ok ( ir) => result. lowered . push ( DumpRecord {
211215 corpus : name. to_string ( ) ,
212216 query_number : index + 1 ,
@@ -394,7 +398,7 @@ fn anomaly_report(all: &[DumpRecord], language: &str, manual_notes: &str) -> Str
394398 report
395399}
396400
397- fn run_corpora ( out_dir : PathBuf ) {
401+ fn run_corpora ( out_dir : PathBuf , interval_ms : u64 ) {
398402 std:: fs:: create_dir_all ( & out_dir)
399403 . unwrap_or_else ( |e| panic ! ( "failed to create {}: {e}" , out_dir. display( ) ) ) ;
400404 let corpora = [
@@ -406,7 +410,7 @@ fn run_corpora(out_dir: PathBuf) {
406410 let mut all = Vec :: new ( ) ;
407411 let mut summary = Vec :: new ( ) ;
408412 for ( name, source) in corpora {
409- let mut result = run_corpus ( name, source) ;
413+ let mut result = run_corpus ( name, source, interval_ms ) ;
410414 let total = result. lowered . len ( ) + result. failed . len ( ) ;
411415 write_jsonl ( & out_dir. join ( format ! ( "{name}.jsonl" ) ) , & result. lowered ) ;
412416 write_jsonl (
@@ -542,14 +546,25 @@ async fn main() {
542546 let mut args = std:: env:: args ( ) . skip ( 1 ) ;
543547 if args. next ( ) . as_deref ( ) == Some ( "--corpora" ) {
544548 let mut out_dir = PathBuf :: from ( "artifacts/promql_pre_asap" ) ;
549+ let mut interval_ms = None ;
545550 while let Some ( arg) = args. next ( ) {
546551 if arg == "--out-dir" {
547552 out_dir = PathBuf :: from ( args. next ( ) . expect ( "--out-dir requires a path" ) ) ;
553+ } else if arg == "--data-ingestion-interval-ms" {
554+ interval_ms = Some (
555+ args. next ( )
556+ . expect ( "--data-ingestion-interval-ms requires a value" )
557+ . parse ( )
558+ . expect ( "--data-ingestion-interval-ms must be an unsigned integer" ) ,
559+ ) ;
548560 } else {
549561 panic ! ( "unknown corpus-mode argument: {arg}" ) ;
550562 }
551563 }
552- run_corpora ( out_dir) ;
564+ run_corpora (
565+ out_dir,
566+ interval_ms. expect ( "--data-ingestion-interval-ms is required for --corpora" ) ,
567+ ) ;
553568 return ;
554569 }
555570 if std:: env:: args ( ) . nth ( 1 ) . as_deref ( ) == Some ( "--sql-corpora" ) {
0 commit comments