1use crate::{
16 graph_route::{NMEM_GRAPH_ROUTE_EVIDENCE_PROTOCOL, NMEM_GRAPH_ROUTE_READINESS_PROTOCOL},
17 graph_summary::{nowledge_graph_route_readiness_summary, GraphRouteReadinessSummary},
18 previous_wrapper_preflight::{
19 CUTOVER_CONTROLS_PROTOCOL, LIBRARY_READINESS_PROTOCOL, OPERATIONS_READINESS_PROTOCOL,
20 },
21 source_mutation::{
22 REQUIRED_SOURCE_MUTATION_FAMILIES, SOURCE_MUTATION_DUAL_WRITE_READINESS_PROTOCOL,
23 },
24};
25use hawdb_core::{HawDBError, Result};
26use hawdb_evidence::{
27 blackbox::{blackbox_readiness_from_manifest_json, BlackboxReadinessReport},
28 inventory::REQUIRED_NOWLEDGE_REPLACEMENT_QUERY_FAMILIES,
29 replacement_contract::{
30 NOWLEDGE_SEARCH_PROJECTION_SCAN_FILTER_FIELDS, SEARCH_CANDIDATE_EVIDENCE_ROUTE,
31 SEARCH_CANDIDATE_EVIDENCE_SOURCE, SEARCH_CANDIDATE_PRIMARY_ENGINE,
32 SEARCH_CANDIDATE_SHADOW_EVIDENCE_PROTOCOL,
33 },
34 resource_profile::production_resource_profile_ready,
35};
36use hawdb_route_ownership::graph::{
37 graph_read_route_catalog_digest, required_query_families_for_route,
38 GRAPH_READ_ROUTE_CATALOG_VERSION, REQUIRED_BOUNDED_READ_ROUTES, ROUTE_OWNERSHIP_PROTOCOL,
39 SEARCH_ROUTE,
40};
41use std::collections::{BTreeMap, BTreeSet};
42use std::path::Path;
43
44const HAWDB_NOWLEDGE_REPLACEMENT_SUMMARY_PROTOCOL: &str = "hawdb-nowledge-replacement-summary";
45const GRAPH_LAYER_REPLACEMENT_SCOPE: &str = "kuzu_ladybug_graph_layer";
46const SEARCH_PROJECTION_REPLACEMENT_SCOPE: &str = "lancedb_search_projection";
47const SQLITE_CONTENT_STORE_SCOPE: &str = "sqlite_content_store";
48const LARGE_BLOB_VALUE_STORE_SCOPE: &str = "large_blob_value_store";
49const HAWDB_NOWLEDGE_SEARCH_PROJECTION_EVIDENCE_PROTOCOL: &str =
50 "hawdb-nowledge-search-projection-evidence";
51const HAWDB_NOWLEDGE_SEARCH_PROJECTION_SHADOW_EVIDENCE_PROTOCOL: &str =
52 "hawdb-nowledge-search-projection-shadow-evidence";
53const HAWDB_SEARCH_PROJECTION_SHADOW_EVIDENCE_SOURCE: &str = "hawdb-rust-library";
54const HAWDB_BOUNDED_READ_EVIDENCE_PROTOCOL: &str = "hawdb-nowledge-mem-bounded-read-evidence-v2";
55const HAWDB_NOWLEDGE_QUERY_RUNTIME_PREFLIGHT_PROTOCOL: &str =
56 "hawdb-nowledge-query-runtime-preflight-v1";
57const HAWDB_QUERY_REPORT_PROTOCOL: &str = "hawdb-nowledge-mem-query-report-v1";
58const ROUTE_PARITY_EVIDENCE_SOURCE: &str = "route_parity_evidence";
59const ROUTE_PARITY_FULL_MATCH_PER_MILLION: u64 = 1_000_000;
60const FINAL_CATEGORY_STARTUP: &str = "startup";
61const FINAL_CATEGORY_ROUTE_COVERAGE: &str = "route_coverage";
62const FINAL_CATEGORY_GRAPH_REPLACEMENT: &str = "graph_replacement";
63const FINAL_CATEGORY_SEARCH_PROJECTION: &str = "search_projection";
64const FINAL_CATEGORY_STORAGE_RECOVERY: &str = "storage_recovery";
65const FINAL_CATEGORY_BACKGROUND_QOS: &str = "background_qos";
66const FINAL_CATEGORY_BLACKBOX: &str = "blackbox";
67const FINAL_CATEGORY_LIBRARY_ONLY: &str = "library_only";
68const FINAL_CATEGORY_REPLACEMENT_SUMMARY_CUTOVER: &str = "replacement_summary_cutover";
69
70const STARTUP_CHECKS: &[&str] = &[
71 "integration_bundle_protocol",
72 "replacement_summary_protocol",
73 "hawdb_submodule",
74 "legacy_coexistence",
75 "content_store_boundary",
76 "previous_wrapper_preflight",
77];
78const ROUTE_COVERAGE_CHECKS: &[&str] = &[
79 "bounded_read_evidence",
80 "bounded_read_evidence_alignment",
81 "graph_route_readiness",
82 "graph_route_readiness_alignment",
83 "graph_route_parity_alignment",
84 "route_ownership",
85 "search_route_ownership_alignment",
86 "active_search_route_ownership_alignment",
87 "active_search_route_readiness_alignment",
88 "query_runtime_preflight",
89 "query_runtime_preflight_alignment",
90];
91const GRAPH_REPLACEMENT_CHECKS: &[&str] = &[
92 "graph_replacement_evidence",
93 "query_family_replacement_evidence",
94];
95const SEARCH_PROJECTION_CHECKS: &[&str] = &[
96 "search_projection_replacement_evidence",
97 "search_candidate_primary_evidence",
98];
99const STORAGE_RECOVERY_CHECKS: &[&str] = &["storage_recovery_evidence", "operations_readiness"];
100const BACKGROUND_QOS_CHECKS: &[&str] = &["background_maintenance_evidence"];
101const BLACKBOX_CHECKS: &[&str] = &["blackbox_redaction", "blackbox_operational_evidence"];
102const LIBRARY_ONLY_CHECKS: &[&str] = &["library_readiness", "cutover_controls"];
103
104pub const INTEGRATION_READINESS_PROTOCOL: &str = "hawdb-nowledge-mem-integration-readiness";
105pub const HAWDB_INTEGRATION_BUNDLE_PROTOCOL: &str = "nowledge-mem-hawdb-integration-bundle";
106pub const FINAL_CUTOVER_PREFLIGHT_PROTOCOL: &str = "hawdb-nowledge-mem-final-cutover-preflight-v1";
107
108#[derive(Debug, Clone, PartialEq, Eq)]
109pub struct IntegrationCheckReport {
110 pub name: String,
111 pub ready: bool,
112 pub evidence_fields: Vec<String>,
113 pub failed_evidence_fields: Vec<String>,
114 pub blocker_codes: Vec<String>,
115}
116
117impl IntegrationCheckReport {
118 pub fn json(&self) -> serde_json::Value {
119 serde_json::json!({
120 "name": self.name,
121 "ready": self.ready,
122 "evidence_fields": self.evidence_fields,
123 "failed_evidence_fields": self.failed_evidence_fields,
124 "blocker_codes": self.blocker_codes,
125 })
126 }
127}
128
129#[derive(Debug, Clone, PartialEq, Eq)]
130pub struct IntegrationNextAction {
131 pub action: String,
132 pub reason: String,
133 pub evidence_fields: Vec<String>,
134}
135
136impl IntegrationNextAction {
137 pub fn json(&self) -> serde_json::Value {
138 serde_json::json!({
139 "action": self.action,
140 "reason": self.reason,
141 "evidence_fields": self.evidence_fields,
142 })
143 }
144}
145
146#[derive(Debug, Clone, PartialEq, Eq)]
147pub struct IntegrationReadinessReport {
148 pub protocol: String,
149 pub ready: bool,
150 pub failed_checks: Vec<String>,
151 pub checks: Vec<IntegrationCheckReport>,
152 pub blocker_codes: Vec<String>,
153 pub next_actions: Vec<IntegrationNextAction>,
154}
155
156impl IntegrationReadinessReport {
157 pub fn json(&self) -> serde_json::Value {
158 serde_json::json!({
159 "protocol": self.protocol,
160 "ready": self.ready,
161 "failed_checks": self.failed_checks,
162 "checks": self.checks.iter().map(IntegrationCheckReport::json).collect::<Vec<_>>(),
163 "blocker_codes": self.blocker_codes,
164 "next_actions": self.next_actions.iter().map(IntegrationNextAction::json).collect::<Vec<_>>(),
165 })
166 }
167}
168
169#[derive(Debug, Clone, PartialEq, Eq)]
170pub struct FinalCutoverPreflightReport {
171 pub protocol: String,
172 pub production_cutover_ready: bool,
173 pub integration_ready: bool,
174 pub replacement_summary_production_cutover_ready: bool,
175 pub startup_ready: bool,
176 pub route_coverage_ready: bool,
177 pub graph_replacement_ready: bool,
178 pub search_projection_ready: bool,
179 pub storage_recovery_ready: bool,
180 pub background_qos_ready: bool,
181 pub blackbox_ready: bool,
182 pub library_only_ready: bool,
183 pub check_count: usize,
184 pub ready_check_count: usize,
185 pub failed_check_count: usize,
186 pub next_action_count: usize,
187 pub next_action_names: Vec<String>,
188 pub blocking_categories: Vec<String>,
189 pub failed_checks: Vec<String>,
190 pub failed_evidence_fields: Vec<String>,
191 pub blocker_codes: Vec<String>,
192}
193
194impl FinalCutoverPreflightReport {
195 pub fn json(&self) -> serde_json::Value {
196 serde_json::json!({
197 "protocol": self.protocol,
198 "production_cutover_ready": self.production_cutover_ready,
199 "integration_ready": self.integration_ready,
200 "replacement_summary_production_cutover_ready": self.replacement_summary_production_cutover_ready,
201 "startup_ready": self.startup_ready,
202 "route_coverage_ready": self.route_coverage_ready,
203 "graph_replacement_ready": self.graph_replacement_ready,
204 "search_projection_ready": self.search_projection_ready,
205 "storage_recovery_ready": self.storage_recovery_ready,
206 "background_qos_ready": self.background_qos_ready,
207 "blackbox_ready": self.blackbox_ready,
208 "library_only_ready": self.library_only_ready,
209 "check_count": self.check_count,
210 "ready_check_count": self.ready_check_count,
211 "failed_check_count": self.failed_check_count,
212 "next_action_count": self.next_action_count,
213 "next_action_names": self.next_action_names,
214 "blocking_categories": self.blocking_categories,
215 "failed_checks": self.failed_checks,
216 "failed_evidence_fields": self.failed_evidence_fields,
217 "blocker_codes": self.blocker_codes,
218 })
219 }
220}
221
222#[derive(Debug, Clone, PartialEq, Eq)]
223pub struct StorageRecoveryCutoverReadiness {
224 pub required: bool,
225 pub ready: bool,
226 pub protocol_matches: bool,
227 pub durable: bool,
228 pub checkpoint_boundary_present: bool,
229 pub wal_replay_bounded: bool,
230 pub replay_boundary_consistent: bool,
231 pub torn_tail_clean: bool,
232 pub blocker_codes: Vec<String>,
233}
234
235#[derive(Debug, Clone, PartialEq, Eq)]
236pub struct IntegrationBundleProtocolCutoverReadiness {
237 pub protocol_matches: bool,
238}
239
240#[derive(Debug, Clone, PartialEq, Eq)]
241pub struct ReplacementSummaryProtocolCutoverReadiness {
242 pub protocol_matches: bool,
243 pub graph_layer_replacement_scope_ready: bool,
244 pub search_projection_replacement_scope_ready: bool,
245 pub content_store_out_of_scope: bool,
246 pub large_blob_store_out_of_scope: bool,
247}
248
249#[derive(Debug, Clone, PartialEq, Eq)]
250pub struct HawDBSubmoduleCutoverReadiness {
251 pub present: bool,
252 pub path_present: bool,
253 pub commit_present: bool,
254 pub blocker_codes: Vec<String>,
255}
256
257#[derive(Debug, Clone, PartialEq, Eq)]
258pub struct LegacyCoexistenceCutoverReadiness {
259 pub old_database_retained: bool,
260 pub mode_safe: bool,
261 pub old_database_not_deleted: bool,
262 pub blocker_codes: Vec<String>,
263}
264
265#[derive(Debug, Clone, PartialEq, Eq)]
266pub struct ContentStoreBoundaryCutoverReadiness {
267 pub present: bool,
268 pub engine_sqlite: bool,
269 pub messages_available: bool,
270 pub source_chunks_available: bool,
271 pub blocker_codes: Vec<String>,
272}
273
274#[derive(Debug, Clone, PartialEq, Eq)]
275pub struct PreviousWrapperPreflightCutoverReadiness {
276 pub ready: bool,
277 pub blocker_codes: Vec<String>,
278}
279
280#[derive(Debug, Clone, PartialEq, Eq)]
281pub struct BackgroundMaintenanceCutoverReadiness {
282 pub required: bool,
283 pub ready: bool,
284 pub protocol_matches: bool,
285 pub executable_search_projection_graph_delta_count_present: bool,
286 pub admitted_search_projection_graph_delta_count_present: bool,
287 pub deferred_search_projection_graph_delta_count_present: bool,
288 pub rejected_search_projection_graph_delta_count_present: bool,
289 pub executable_search_projection_graph_delta_operations_present: bool,
290 pub admitted_search_projection_graph_delta_operations_present: bool,
291 pub max_search_projection_graph_delta_complete_through_graph_commit_epoch_present: bool,
292 pub foreground_admission_probe_ready: bool,
293 pub memory_pressure_ready: bool,
294 pub memory_budget_bytes_present: bool,
295 pub estimated_memory_bytes_present: bool,
296 pub blocker_codes: Vec<String>,
297}
298
299#[derive(Debug, Clone, PartialEq, Eq)]
300pub struct LibraryReadinessCutoverReadiness {
301 pub protocol_matches: bool,
302 pub present: bool,
303 pub ready: bool,
304 pub production_path_ready: bool,
305 pub production_path_in_process: bool,
306 pub production_path_cli_not_required: bool,
307 pub production_path_env_control_plane_not_required: bool,
308 pub production_path_spawned_helper_not_required: bool,
309 pub ready_area_count_present: bool,
310 pub blocked_area_count_zero: bool,
311 pub redaction_ready: bool,
312 pub query_text_redacted: bool,
313 pub parameters_redacted: bool,
314 pub local_paths_redacted: bool,
315 pub graph_opened: bool,
316 pub search_projection_opened: bool,
317 pub graph_ready: bool,
318 pub query_ready: bool,
319 pub storage_ready: bool,
320 pub background_ready: bool,
321 pub query_family_ready: bool,
322 pub graph_route_ready: bool,
323 pub search_route_ownership_ready: bool,
324 pub search_projection_ready: bool,
325 pub search_projection_shadow_ready: bool,
326 pub search_candidate_shadow_ready: bool,
327 pub workload_fixture_ready: bool,
328 pub production_resource_profile_ready: bool,
329 pub blocker_codes: Vec<String>,
330}
331
332#[derive(Debug, Clone, PartialEq, Eq)]
333pub struct CutoverControlsReadiness {
334 pub protocol_matches: bool,
335 pub ready: bool,
336 pub graph_reads_hawdb: bool,
337 pub graph_read_effective: bool,
338 pub graph_production_status_effective: bool,
339 pub search_reads_hawdb: bool,
340 pub search_read_effective: bool,
341 pub search_production_status_effective: bool,
342 pub dual_writes_enabled: bool,
343 pub projection_catch_up_enabled: bool,
344 pub initial_import_safe: bool,
345 pub initial_import_inactive_for_cutover: bool,
346 pub initial_import_cutover_catch_up_ready: bool,
347 pub initial_import_safe_for_read_cutover: bool,
348 pub query_text_redacted: bool,
349 pub parameters_redacted: bool,
350 pub local_paths_redacted: bool,
351 pub blocker_codes: Vec<String>,
352}
353
354#[derive(Debug, Clone, PartialEq, Eq)]
355pub struct OperationsReadinessCutoverReadiness {
356 pub protocol_matches: bool,
357 pub present: bool,
358 pub ready: bool,
359 pub graph_open: bool,
360 pub graph_writable: bool,
361 pub search_projection_open: bool,
362 pub search_projection_not_stale: bool,
363 pub storage_lifecycle_ready: bool,
364 pub storage_lifecycle_action_ready: bool,
365 pub storage_recovery_ready: bool,
366 pub slow_query_ready: bool,
367 pub background_maintenance_ready: bool,
368 pub query_text_redacted: bool,
369 pub parameters_redacted: bool,
370 pub local_paths_redacted: bool,
371 pub blocker_codes: Vec<String>,
372}
373
374#[derive(Debug, Clone, PartialEq, Eq)]
375pub struct GraphReplacementCutoverReadiness {
376 pub production_cutover_ready: bool,
377 pub shadow_evidence_ready: bool,
378 pub dual_engine_evidence_present: bool,
379 pub dual_engine_evidence_ready: bool,
380 pub dual_engine_evidence_consistent: bool,
381 pub source_mutation_protocol_matches: bool,
382 pub source_mutation_ready: bool,
383 pub source_mutation_required_family_count_matches: bool,
384 pub source_mutation_evidence_family_count_matches: bool,
385 pub source_mutation_ready_family_count_matches: bool,
386 pub source_mutation_missing_required_families_empty: bool,
387 pub source_mutation_blocker_codes_empty: bool,
388 pub blocker_codes: Vec<String>,
389}
390
391#[derive(Debug, Clone, PartialEq, Eq)]
392pub struct QueryFamilyReplacementCutoverReadiness {
393 pub required_query_families_present: bool,
394 pub missing_required_query_families_empty: bool,
395 pub blocked_query_families_empty: bool,
396 pub min_replacement_readiness_full: bool,
397 pub blocker_codes: Vec<String>,
398}
399
400#[derive(Debug, Clone, PartialEq, Eq)]
401pub struct SearchProjectionCutoverReadiness {
402 pub evidence_protocol_matches: bool,
403 pub evidence_ready: bool,
404 pub fts_ready: bool,
405 pub vector_ready: bool,
406 pub document_identity_ready: bool,
407 pub incremental_update_ready: bool,
408 pub predicate_pushdown_ready: bool,
409 pub production_filter_pruning_ready: bool,
410 pub compressed_vector_projection_required: bool,
411 pub compressed_vector_projection_ready: bool,
412 pub shadow_present: bool,
413 pub shadow_protocol_matches: bool,
414 pub shadow_evidence_source_matches: bool,
415 pub shadow_ready: bool,
416 pub shadow_document_count_parity: bool,
417 pub shadow_document_identity_parity: bool,
418 pub shadow_table_parity_ready: bool,
419 pub shadow_embedding_identity_parity: bool,
420 pub shadow_incremental_watermark_parity: bool,
421 pub shadow_pushdown_ready: bool,
422 pub shadow_descriptor_scan_filter_fields_ready: bool,
423 pub shadow_document_pruning_ready: bool,
424 pub shadow_pruning_candidate_count_ready: bool,
425 pub shadow_pruned_document_count_positive: bool,
426 pub shadow_scanned_document_count_positive: bool,
427 pub primary_scan_filter_fields_ready: bool,
428 pub shadow_scan_filter_fields_ready: bool,
429 pub shadow_descriptor_field_summaries_ready: bool,
430 pub blocker_codes: Vec<String>,
431}
432
433#[derive(Debug, Clone, PartialEq, Eq)]
434pub struct SearchCandidateCutoverReadiness {
435 pub protocol_matches: bool,
436 pub evidence_source_matches: bool,
437 pub route_matches: bool,
438 pub ready: bool,
439 pub primary_engine_matches: bool,
440 pub candidate_count_parity: bool,
441 pub row_count_parity: bool,
442 pub text_retriever_ready: bool,
443 pub vector_retriever_ready: bool,
444 pub fts_top_k_overlap_ready: bool,
445 pub vector_top_k_overlap_ready: bool,
446 pub source_chunk_identity_ready: bool,
447 pub fail_soft_observed: bool,
448 pub projection_marker_status_visible: bool,
449 pub projection_watermark_ready: bool,
450 pub embedding_identity_ready: bool,
451 pub candidate_identity_ready: bool,
452 pub filter_pushdown_ready: bool,
453 pub filter_pushdown_field_summary_present: bool,
454 pub filter_pushdown_required_fields_ready: bool,
455 pub shadow_scan_filter_pushdown_ready: bool,
456 pub shadow_scan_field_pruning_ready: bool,
457 pub shadow_scan_field_summary_present: bool,
458 pub blocker_codes: Vec<String>,
459}
460
461#[derive(Debug, Clone, PartialEq, Eq)]
462pub struct BoundedReadCutoverReadiness {
463 pub present: bool,
464 pub protocol_matches: bool,
465 pub ready: bool,
466 pub max_rows_present: bool,
467 pub mode_matches: bool,
468 pub execution_cap_matches: bool,
469 pub estimated_payload_bytes_present: bool,
470 pub max_estimated_payload_bytes_present: bool,
471 pub payload_budget_not_exceeded: bool,
472 pub row_limit_enforced_before_output: bool,
473 pub operator_row_cap_enabled: bool,
474 pub blocking_operator_memory_reports_complete: bool,
475 pub blocking_operator_memory_within_budget: bool,
476 pub spill_within_budget: bool,
477 pub streaming_evidence_present: bool,
478 pub route_catalog_version_matches: bool,
479 pub route_catalog_digest_present: bool,
480 pub route_coverage_ready: bool,
481 pub blocker_codes: Vec<String>,
482}
483
484#[derive(Debug, Clone, PartialEq, Eq)]
485pub struct BoundedReadAlignmentCutoverReadiness {
486 pub evidence_ready: bool,
487 pub ready: bool,
488 pub alignment_evidence_ready: bool,
489 pub summary_ready: bool,
490 pub protocol_matches: bool,
491 pub readiness_matches: bool,
492 pub mode_matches: bool,
493 pub max_rows_matches: bool,
494 pub estimated_payload_bytes_matches: bool,
495 pub max_estimated_payload_bytes_matches: bool,
496 pub payload_budget_exceeded_matches: bool,
497 pub streaming_matches: bool,
498 pub covered_routes_matches: bool,
499 pub evidence_route_catalog_version_ready: bool,
500 pub summary_route_catalog_version_ready: bool,
501 pub evidence_route_catalog_digest_ready: bool,
502 pub summary_route_catalog_digest_ready: bool,
503 pub route_catalog_version_matches: bool,
504 pub route_catalog_digest_matches: bool,
505 pub blocker_codes: Vec<String>,
506}
507
508#[derive(Debug, Clone, PartialEq, Eq)]
509pub struct GraphRouteCutoverReadiness {
510 pub protocol_matches: bool,
511 pub evidence_protocol_matches: bool,
512 pub evidence_ready: bool,
513 pub route_count_present: bool,
514 pub required_route_count_matches: bool,
515 pub route_coverage_ready: bool,
516 pub missing_required_routes_empty: bool,
517 pub query_runtime_route_count_matches: bool,
518 pub query_runtime_report_count_ready: bool,
519 pub query_plan_profile_summary_ready: bool,
520 pub relationship_property_pruning_summary_ready: bool,
521 pub missing_query_runtime_routes_empty: bool,
522 pub route_query_runtime_ready: bool,
523 pub route_primary_ready: bool,
524 pub primary_ready_route_count_matches: bool,
525 pub route_primary_blocker_codes_empty: bool,
526 pub evidence_route_coverage_present: bool,
527 pub evidence_route_coverage_matches: bool,
528 pub evidence_route_coverage_blocker_codes_empty: bool,
529 pub route_query_profiles_ready: bool,
530 pub blocker_codes: Vec<String>,
531}
532
533#[derive(Debug, Clone, PartialEq, Eq)]
534pub struct GraphRouteAlignmentCutoverReadiness {
535 pub ready: bool,
536 pub evidence_protocol_matches: bool,
537 pub evidence_ready: bool,
538 pub evidence_route_primary_ready: bool,
539 pub summary_route_primary_ready: bool,
540 pub route_primary_ready_matches: bool,
541 pub route_query_plan_evidence_ready_matches: bool,
542 pub route_query_profile_evidence_ready_matches: bool,
543 pub route_query_api_behavior_evidence_ready_matches: bool,
544 pub route_relationship_property_pruning_evidence_ready_matches: bool,
545 pub relationship_property_pruning_required_count_matches: bool,
546 pub relationship_property_pruning_report_count_matches: bool,
547 pub primary_ready_routes_match: bool,
548 pub evidence_required_routes_covered: bool,
549 pub summary_required_routes_covered: bool,
550 pub evidence_route_catalog_version_ready: bool,
551 pub summary_route_catalog_version_ready: bool,
552 pub evidence_route_catalog_digest_ready: bool,
553 pub summary_route_catalog_digest_ready: bool,
554 pub route_catalog_version_matches: bool,
555 pub route_catalog_digest_matches: bool,
556 pub blocker_codes: Vec<String>,
557}
558
559#[derive(Debug, Clone, PartialEq, Eq)]
560pub struct GraphRouteParityAlignmentCutoverReadiness {
561 pub ready: bool,
562 pub required_route_count_present: bool,
563 pub ready_route_count_matches: bool,
564 pub missing_routes_empty: bool,
565 pub not_ready_routes_empty: bool,
566 pub route_mismatch_routes_empty: bool,
567 pub protocol_mismatch_routes_empty: bool,
568 pub blocker_routes_empty: bool,
569 pub blocker_codes: Vec<String>,
570}
571
572#[derive(Debug, Clone, PartialEq, Eq)]
573pub struct RouteOwnershipCutoverReadiness {
574 pub protocol_matches: bool,
575 pub ready: bool,
576 pub production_cutover_ready: bool,
577 pub require_all_hawdb: bool,
578 pub required_route_count_matches: bool,
579 pub explicit_route_count_matches: bool,
580 pub hawdb_route_count_matches: bool,
581 pub legacy_route_count_zero: bool,
582 pub missing_required_routes_empty: bool,
583 pub unknown_routes_empty: bool,
584 pub duplicate_routes_empty: bool,
585 pub conflicting_routes_empty: bool,
586 pub hawdb_not_ready_routes_empty: bool,
587 pub route_readiness_present: bool,
588 pub route_readiness_ready: bool,
589 pub search_route_projection_evidence_present: bool,
590 pub route_catalog_version_matches: bool,
591 pub route_catalog_digest_matches: bool,
592 pub blocker_codes_empty: bool,
593 pub blocker_codes: Vec<String>,
594}
595
596#[derive(Debug, Clone, PartialEq, Eq)]
597pub struct SearchRouteOwnershipAlignmentCutoverReadiness {
598 pub ready: bool,
599 pub evidence_ready: bool,
600 pub summary_ready: bool,
601 pub protocol_matches: bool,
602 pub readiness_matches: bool,
603 pub production_cutover_ready_matches: bool,
604 pub require_all_hawdb_matches: bool,
605 pub required_route_count_matches: bool,
606 pub explicit_route_count_matches: bool,
607 pub hawdb_route_count_matches: bool,
608 pub lancedb_route_count_matches: bool,
609 pub missing_required_routes_matches: bool,
610 pub lancedb_routes_matches: bool,
611 pub blocker_codes_match: bool,
612 pub blocker_codes: Vec<String>,
613}
614
615#[derive(Debug, Clone, PartialEq, Eq)]
616pub struct ActiveSearchRouteReadinessAlignmentCutoverReadiness {
617 pub ready: bool,
618 pub evidence_ready: bool,
619 pub summary_ready: bool,
620 pub protocol_matches: bool,
621 pub readiness_matches: bool,
622 pub production_cutover_ready_matches: bool,
623 pub require_all_hawdb_matches: bool,
624 pub required_route_count_matches: bool,
625 pub evidence_route_count_matches: bool,
626 pub ready_route_count_matches: bool,
627 pub hawdb_route_count_matches: bool,
628 pub lancedb_handle_count_matches: bool,
629 pub missing_required_routes_matches: bool,
630 pub non_hawdb_routes_matches: bool,
631 pub lancedb_handle_routes_matches: bool,
632 pub candidate_not_ready_routes_matches: bool,
633 pub candidate_identity_not_ready_routes_matches: bool,
634 pub embedding_identity_not_ready_routes_matches: bool,
635 pub zero_vector_semantics_not_ready_routes_matches: bool,
636 pub cjk_tokenization_not_ready_routes_matches: bool,
637 pub metadata_pushdown_not_ready_routes_matches: bool,
638 pub ranking_window_not_ready_routes_matches: bool,
639 pub ranking_not_ready_routes_matches: bool,
640 pub fail_soft_not_ready_routes_matches: bool,
641 pub fail_soft_reason_codes_not_ready_routes_matches: bool,
642 pub repair_rebuild_markers_not_ready_routes_matches: bool,
643 pub blocker_codes_match: bool,
644 pub blocker_codes: Vec<String>,
645}
646
647#[derive(Debug, Clone, PartialEq, Eq)]
648pub struct QueryRuntimePreflightCutoverReadiness {
649 pub protocol_matches: bool,
650 pub ready: bool,
651 pub database_opened: bool,
652 pub redaction_ready: bool,
653 pub rows_redacted: bool,
654 pub parameters_redacted: bool,
655 pub local_paths_redacted: bool,
656 pub raw_errors_redacted: bool,
657 pub probe_count_present: bool,
658 pub probe_counts_match: bool,
659 pub failed_probe_count_zero: bool,
660 pub route_coverage_ready: bool,
661 pub route_catalog_version_matches: bool,
662 pub route_catalog_digest_present: bool,
663 pub probe_details_ready: bool,
664 pub blocker_codes: Vec<String>,
665}
666
667#[derive(Debug, Clone, PartialEq, Eq)]
668pub struct QueryRuntimePreflightAlignmentCutoverReadiness {
669 pub ready: bool,
670 pub evidence_ready: bool,
671 pub summary_ready: bool,
672 pub protocol_matches: bool,
673 pub readiness_matches: bool,
674 pub database_opened_matches: bool,
675 pub probe_count_matches: bool,
676 pub passed_probe_count_matches: bool,
677 pub failed_probe_count_matches: bool,
678 pub required_route_count_matches: bool,
679 pub covered_route_count_matches: bool,
680 pub covered_routes_matches: bool,
681 pub required_routes_covered_matches: bool,
682 pub route_coverage_ready_matches: bool,
683 pub evidence_route_catalog_version_ready: bool,
684 pub summary_route_catalog_version_ready: bool,
685 pub evidence_route_catalog_digest_ready: bool,
686 pub summary_route_catalog_digest_ready: bool,
687 pub route_catalog_version_matches: bool,
688 pub route_catalog_digest_matches: bool,
689 pub blocker_codes: Vec<String>,
690}
691
692impl IntegrationBundleProtocolCutoverReadiness {
693 pub fn evidence_ready(&self) -> bool {
694 self.protocol_matches
695 }
696}
697
698impl ReplacementSummaryProtocolCutoverReadiness {
699 pub fn evidence_ready(&self) -> bool {
700 self.protocol_matches
701 && self.graph_layer_replacement_scope_ready
702 && self.search_projection_replacement_scope_ready
703 && self.content_store_out_of_scope
704 && self.large_blob_store_out_of_scope
705 }
706}
707
708impl HawDBSubmoduleCutoverReadiness {
709 pub fn evidence_ready(&self) -> bool {
710 self.present && self.path_present && self.commit_present
711 }
712}
713
714impl LegacyCoexistenceCutoverReadiness {
715 pub fn evidence_ready(&self) -> bool {
716 self.old_database_retained && self.mode_safe && self.old_database_not_deleted
717 }
718}
719
720impl ContentStoreBoundaryCutoverReadiness {
721 pub fn evidence_ready(&self) -> bool {
722 self.present
723 && self.engine_sqlite
724 && self.messages_available
725 && self.source_chunks_available
726 }
727}
728
729impl PreviousWrapperPreflightCutoverReadiness {
730 pub fn evidence_ready(&self) -> bool {
731 self.ready
732 }
733}
734
735impl LibraryReadinessCutoverReadiness {
736 pub fn evidence_ready(&self) -> bool {
737 self.protocol_matches
738 && self.present
739 && self.ready
740 && self.production_path_ready
741 && self.production_path_in_process
742 && self.production_path_cli_not_required
743 && self.production_path_env_control_plane_not_required
744 && self.production_path_spawned_helper_not_required
745 && self.ready_area_count_present
746 && self.blocked_area_count_zero
747 && self.redaction_ready
748 && self.query_text_redacted
749 && self.parameters_redacted
750 && self.local_paths_redacted
751 && self.graph_opened
752 && self.search_projection_opened
753 && self.graph_ready
754 && self.query_ready
755 && self.storage_ready
756 && self.background_ready
757 && self.query_family_ready
758 && self.graph_route_ready
759 && self.search_route_ownership_ready
760 && self.search_projection_ready
761 && self.search_projection_shadow_ready
762 && self.search_candidate_shadow_ready
763 && self.workload_fixture_ready
764 && self.production_resource_profile_ready
765 }
766}
767
768impl CutoverControlsReadiness {
769 pub fn evidence_ready(&self) -> bool {
770 self.protocol_matches
771 && self.ready
772 && self.graph_reads_hawdb
773 && self.graph_read_effective
774 && self.graph_production_status_effective
775 && self.search_reads_hawdb
776 && self.search_read_effective
777 && self.search_production_status_effective
778 && self.dual_writes_enabled
779 && self.projection_catch_up_enabled
780 && self.initial_import_safe
781 && self.initial_import_safe_for_read_cutover
782 && self.query_text_redacted
783 && self.parameters_redacted
784 && self.local_paths_redacted
785 }
786}
787
788impl OperationsReadinessCutoverReadiness {
789 pub fn evidence_ready(&self) -> bool {
790 self.protocol_matches
791 && self.present
792 && self.ready
793 && self.graph_open
794 && self.graph_writable
795 && self.search_projection_open
796 && self.search_projection_not_stale
797 && self.storage_lifecycle_ready
798 && self.storage_lifecycle_action_ready
799 && self.storage_recovery_ready
800 && self.slow_query_ready
801 && self.background_maintenance_ready
802 && self.query_text_redacted
803 && self.parameters_redacted
804 && self.local_paths_redacted
805 }
806}
807
808impl GraphReplacementCutoverReadiness {
809 pub fn evidence_ready(&self) -> bool {
810 self.production_cutover_ready
811 && self.shadow_evidence_ready
812 && self.dual_engine_evidence_present
813 && self.dual_engine_evidence_ready
814 && self.dual_engine_evidence_consistent
815 && self.source_mutation_protocol_matches
816 && self.source_mutation_ready
817 && self.source_mutation_required_family_count_matches
818 && self.source_mutation_evidence_family_count_matches
819 && self.source_mutation_ready_family_count_matches
820 && self.source_mutation_missing_required_families_empty
821 && self.source_mutation_blocker_codes_empty
822 }
823}
824
825impl QueryFamilyReplacementCutoverReadiness {
826 pub fn evidence_ready(&self) -> bool {
827 self.required_query_families_present
828 && self.missing_required_query_families_empty
829 && self.blocked_query_families_empty
830 && self.min_replacement_readiness_full
831 }
832}
833
834impl SearchProjectionCutoverReadiness {
835 pub fn evidence_ready(&self) -> bool {
836 self.evidence_protocol_matches
837 && self.evidence_ready
838 && self.fts_ready
839 && self.vector_ready
840 && self.document_identity_ready
841 && self.incremental_update_ready
842 && self.predicate_pushdown_ready
843 && self.production_filter_pruning_ready
844 && self.compressed_vector_projection_required
845 && self.compressed_vector_projection_ready
846 && self.shadow_present
847 && self.shadow_protocol_matches
848 && self.shadow_evidence_source_matches
849 && self.shadow_ready
850 && self.shadow_document_count_parity
851 && self.shadow_document_identity_parity
852 && self.shadow_table_parity_ready
853 && self.shadow_embedding_identity_parity
854 && self.shadow_incremental_watermark_parity
855 && self.shadow_pushdown_ready
856 && self.shadow_descriptor_scan_filter_fields_ready
857 && self.shadow_document_pruning_ready
858 && self.shadow_pruning_candidate_count_ready
859 && self.shadow_pruned_document_count_positive
860 && self.shadow_scanned_document_count_positive
861 && self.primary_scan_filter_fields_ready
862 && self.shadow_scan_filter_fields_ready
863 && self.shadow_descriptor_field_summaries_ready
864 }
865}
866
867impl SearchCandidateCutoverReadiness {
868 pub fn evidence_ready(&self) -> bool {
869 self.protocol_matches
870 && self.evidence_source_matches
871 && self.route_matches
872 && self.ready
873 && self.primary_engine_matches
874 && self.candidate_count_parity
875 && self.row_count_parity
876 && self.text_retriever_ready
877 && self.vector_retriever_ready
878 && self.fts_top_k_overlap_ready
879 && self.vector_top_k_overlap_ready
880 && self.source_chunk_identity_ready
881 && self.fail_soft_observed
882 && self.projection_marker_status_visible
883 && self.projection_watermark_ready
884 && self.embedding_identity_ready
885 && self.candidate_identity_ready
886 && self.filter_pushdown_ready
887 && self.filter_pushdown_field_summary_present
888 && self.filter_pushdown_required_fields_ready
889 && self.shadow_scan_filter_pushdown_ready
890 && self.shadow_scan_field_pruning_ready
891 && self.shadow_scan_field_summary_present
892 }
893}
894
895impl BoundedReadCutoverReadiness {
896 pub fn evidence_ready(&self) -> bool {
897 self.present
898 && self.protocol_matches
899 && self.ready
900 && self.max_rows_present
901 && self.mode_matches
902 && self.execution_cap_matches
903 && self.estimated_payload_bytes_present
904 && self.max_estimated_payload_bytes_present
905 && self.payload_budget_not_exceeded
906 && self.row_limit_enforced_before_output
907 && self.operator_row_cap_enabled
908 && self.blocking_operator_memory_reports_complete
909 && self.blocking_operator_memory_within_budget
910 && self.spill_within_budget
911 && self.streaming_evidence_present
912 && self.route_catalog_version_matches
913 && self.route_catalog_digest_present
914 && self.route_coverage_ready
915 }
916}
917
918impl BoundedReadAlignmentCutoverReadiness {
919 pub fn evidence_ready(&self) -> bool {
920 self.evidence_ready
921 && self.ready
922 && self.alignment_evidence_ready
923 && self.summary_ready
924 && self.protocol_matches
925 && self.readiness_matches
926 && self.mode_matches
927 && self.max_rows_matches
928 && self.estimated_payload_bytes_matches
929 && self.max_estimated_payload_bytes_matches
930 && self.payload_budget_exceeded_matches
931 && self.streaming_matches
932 && self.covered_routes_matches
933 && self.evidence_route_catalog_version_ready
934 && self.summary_route_catalog_version_ready
935 && self.evidence_route_catalog_digest_ready
936 && self.summary_route_catalog_digest_ready
937 && self.route_catalog_version_matches
938 && self.route_catalog_digest_matches
939 }
940}
941
942impl GraphRouteCutoverReadiness {
943 pub fn evidence_ready(&self) -> bool {
944 self.protocol_matches
945 && self.evidence_protocol_matches
946 && self.evidence_ready
947 && self.route_count_present
948 && self.required_route_count_matches
949 && self.route_coverage_ready
950 && self.missing_required_routes_empty
951 && self.query_runtime_route_count_matches
952 && self.query_runtime_report_count_ready
953 && self.query_plan_profile_summary_ready
954 && self.relationship_property_pruning_summary_ready
955 && self.missing_query_runtime_routes_empty
956 && self.route_query_runtime_ready
957 && self.route_primary_ready
958 && self.primary_ready_route_count_matches
959 && self.route_primary_blocker_codes_empty
960 && self.evidence_route_coverage_present
961 && self.evidence_route_coverage_matches
962 && self.evidence_route_coverage_blocker_codes_empty
963 && self.route_query_profiles_ready
964 }
965}
966
967impl GraphRouteAlignmentCutoverReadiness {
968 pub fn evidence_ready(&self) -> bool {
969 self.ready
970 && self.evidence_protocol_matches
971 && self.evidence_ready
972 && self.evidence_route_primary_ready
973 && self.summary_route_primary_ready
974 && self.route_primary_ready_matches
975 && self.route_query_plan_evidence_ready_matches
976 && self.route_query_profile_evidence_ready_matches
977 && self.route_query_api_behavior_evidence_ready_matches
978 && self.route_relationship_property_pruning_evidence_ready_matches
979 && self.relationship_property_pruning_required_count_matches
980 && self.relationship_property_pruning_report_count_matches
981 && self.primary_ready_routes_match
982 && self.evidence_required_routes_covered
983 && self.summary_required_routes_covered
984 && self.evidence_route_catalog_version_ready
985 && self.summary_route_catalog_version_ready
986 && self.evidence_route_catalog_digest_ready
987 && self.summary_route_catalog_digest_ready
988 && self.route_catalog_version_matches
989 && self.route_catalog_digest_matches
990 }
991}
992
993impl GraphRouteParityAlignmentCutoverReadiness {
994 pub fn evidence_ready(&self) -> bool {
995 self.ready
996 && self.required_route_count_present
997 && self.ready_route_count_matches
998 && self.missing_routes_empty
999 && self.not_ready_routes_empty
1000 && self.route_mismatch_routes_empty
1001 && self.protocol_mismatch_routes_empty
1002 && self.blocker_routes_empty
1003 }
1004}
1005
1006impl SearchRouteOwnershipAlignmentCutoverReadiness {
1007 pub fn evidence_ready(&self) -> bool {
1008 self.ready
1009 && self.evidence_ready
1010 && self.summary_ready
1011 && self.protocol_matches
1012 && self.readiness_matches
1013 && self.production_cutover_ready_matches
1014 && self.require_all_hawdb_matches
1015 && self.required_route_count_matches
1016 && self.explicit_route_count_matches
1017 && self.hawdb_route_count_matches
1018 && self.lancedb_route_count_matches
1019 && self.missing_required_routes_matches
1020 && self.lancedb_routes_matches
1021 && self.blocker_codes_match
1022 }
1023}
1024
1025impl ActiveSearchRouteReadinessAlignmentCutoverReadiness {
1026 pub fn evidence_ready(&self) -> bool {
1027 self.ready
1028 && self.evidence_ready
1029 && self.summary_ready
1030 && self.protocol_matches
1031 && self.readiness_matches
1032 && self.production_cutover_ready_matches
1033 && self.require_all_hawdb_matches
1034 && self.required_route_count_matches
1035 && self.evidence_route_count_matches
1036 && self.ready_route_count_matches
1037 && self.hawdb_route_count_matches
1038 && self.lancedb_handle_count_matches
1039 && self.missing_required_routes_matches
1040 && self.non_hawdb_routes_matches
1041 && self.lancedb_handle_routes_matches
1042 && self.candidate_not_ready_routes_matches
1043 && self.candidate_identity_not_ready_routes_matches
1044 && self.embedding_identity_not_ready_routes_matches
1045 && self.zero_vector_semantics_not_ready_routes_matches
1046 && self.cjk_tokenization_not_ready_routes_matches
1047 && self.metadata_pushdown_not_ready_routes_matches
1048 && self.ranking_window_not_ready_routes_matches
1049 && self.ranking_not_ready_routes_matches
1050 && self.fail_soft_not_ready_routes_matches
1051 && self.fail_soft_reason_codes_not_ready_routes_matches
1052 && self.repair_rebuild_markers_not_ready_routes_matches
1053 && self.blocker_codes_match
1054 }
1055}
1056
1057impl RouteOwnershipCutoverReadiness {
1058 pub fn evidence_ready(&self) -> bool {
1059 self.protocol_matches
1060 && self.ready
1061 && self.production_cutover_ready
1062 && self.require_all_hawdb
1063 && self.required_route_count_matches
1064 && self.explicit_route_count_matches
1065 && self.hawdb_route_count_matches
1066 && self.legacy_route_count_zero
1067 && self.missing_required_routes_empty
1068 && self.unknown_routes_empty
1069 && self.duplicate_routes_empty
1070 && self.conflicting_routes_empty
1071 && self.hawdb_not_ready_routes_empty
1072 && self.route_readiness_present
1073 && self.route_readiness_ready
1074 && self.search_route_projection_evidence_present
1075 && self.route_catalog_version_matches
1076 && self.route_catalog_digest_matches
1077 && self.blocker_codes_empty
1078 }
1079}
1080
1081impl QueryRuntimePreflightCutoverReadiness {
1082 pub fn evidence_ready(&self) -> bool {
1083 self.protocol_matches
1084 && self.ready
1085 && self.database_opened
1086 && self.redaction_ready
1087 && self.rows_redacted
1088 && self.parameters_redacted
1089 && self.local_paths_redacted
1090 && self.raw_errors_redacted
1091 && self.probe_count_present
1092 && self.probe_counts_match
1093 && self.failed_probe_count_zero
1094 && self.route_coverage_ready
1095 && self.route_catalog_version_matches
1096 && self.route_catalog_digest_present
1097 && self.probe_details_ready
1098 }
1099}
1100
1101impl QueryRuntimePreflightAlignmentCutoverReadiness {
1102 pub fn evidence_ready(&self) -> bool {
1103 self.ready
1104 && self.evidence_ready
1105 && self.summary_ready
1106 && self.protocol_matches
1107 && self.readiness_matches
1108 && self.database_opened_matches
1109 && self.probe_count_matches
1110 && self.passed_probe_count_matches
1111 && self.failed_probe_count_matches
1112 && self.required_route_count_matches
1113 && self.covered_route_count_matches
1114 && self.covered_routes_matches
1115 && self.required_routes_covered_matches
1116 && self.route_coverage_ready_matches
1117 && self.evidence_route_catalog_version_ready
1118 && self.summary_route_catalog_version_ready
1119 && self.evidence_route_catalog_digest_ready
1120 && self.summary_route_catalog_digest_ready
1121 && self.route_catalog_version_matches
1122 && self.route_catalog_digest_matches
1123 }
1124}
1125
1126impl BackgroundMaintenanceCutoverReadiness {
1127 pub fn evidence_ready(&self) -> bool {
1128 self.required
1129 && self.ready
1130 && self.protocol_matches
1131 && self.executable_search_projection_graph_delta_count_present
1132 && self.admitted_search_projection_graph_delta_count_present
1133 && self.deferred_search_projection_graph_delta_count_present
1134 && self.rejected_search_projection_graph_delta_count_present
1135 && self.executable_search_projection_graph_delta_operations_present
1136 && self.admitted_search_projection_graph_delta_operations_present
1137 && self.max_search_projection_graph_delta_complete_through_graph_commit_epoch_present
1138 && self.foreground_admission_probe_ready
1139 && self.memory_pressure_ready
1140 && self.memory_budget_bytes_present
1141 && self.estimated_memory_bytes_present
1142 }
1143}
1144
1145impl StorageRecoveryCutoverReadiness {
1146 pub fn evidence_ready(&self) -> bool {
1147 self.required
1148 && self.ready
1149 && self.protocol_matches
1150 && self.durable
1151 && self.checkpoint_boundary_present
1152 && self.wal_replay_bounded
1153 && self.replay_boundary_consistent
1154 && self.torn_tail_clean
1155 }
1156}
1157
1158pub fn integration_readiness_usage() -> String {
1159 "nowledge-mem-integration-readiness requires [--require-ready] <integration-bundle-json>"
1160 .to_string()
1161}
1162
1163pub fn run_integration_readiness(
1164 mut args: impl Iterator<Item = String>,
1165) -> Result<(serde_json::Value, bool)> {
1166 let mut require_ready = false;
1167 while let Some(arg) = args.next() {
1168 match arg.as_str() {
1169 "--require-ready" => {
1170 require_ready = true;
1171 }
1172 path => {
1173 if args.next().is_some() {
1174 return Err(HawDBError::Semantic(integration_readiness_usage()));
1175 }
1176 let bundle = read_json_file(Path::new(path))?;
1177 return Ok((integration_readiness_json(&bundle), require_ready));
1178 }
1179 }
1180 }
1181 Err(HawDBError::Semantic(integration_readiness_usage()))
1182}
1183
1184pub fn integration_readiness_json(bundle: &serde_json::Value) -> serde_json::Value {
1185 integration_readiness(bundle).json()
1186}
1187
1188pub fn final_cutover_preflight_json(bundle: &serde_json::Value) -> serde_json::Value {
1189 final_cutover_preflight(bundle).json()
1190}
1191
1192pub fn final_cutover_preflight(bundle: &serde_json::Value) -> FinalCutoverPreflightReport {
1193 let integration = integration_readiness(bundle);
1194 let graph_replacement = graph_replacement_cutover_readiness(bundle);
1195 let failed_evidence_fields = integration
1196 .checks
1197 .iter()
1198 .flat_map(|check| check.failed_evidence_fields.iter().cloned())
1199 .collect::<BTreeSet<_>>()
1200 .into_iter()
1201 .collect::<Vec<_>>();
1202 let ready_check_count = integration
1203 .checks
1204 .iter()
1205 .filter(|check| check.ready)
1206 .count();
1207 let check_count = integration.checks.len();
1208 let startup_ready = integration_check_group_ready(&integration, STARTUP_CHECKS);
1209 let route_coverage_ready = integration_check_group_ready(&integration, ROUTE_COVERAGE_CHECKS);
1210 let graph_replacement_ready =
1211 integration_check_group_ready(&integration, GRAPH_REPLACEMENT_CHECKS);
1212 let search_projection_ready =
1213 integration_check_group_ready(&integration, SEARCH_PROJECTION_CHECKS);
1214 let storage_recovery_ready =
1215 integration_check_group_ready(&integration, STORAGE_RECOVERY_CHECKS);
1216 let background_qos_ready = integration_check_group_ready(&integration, BACKGROUND_QOS_CHECKS);
1217 let blackbox_ready = integration_check_group_ready(&integration, BLACKBOX_CHECKS);
1218 let library_only_ready = integration_check_group_ready(&integration, LIBRARY_ONLY_CHECKS);
1219 let replacement_summary_production_cutover_ready =
1220 graph_replacement.production_cutover_ready && graph_replacement.evidence_ready();
1221 let category_readiness = FinalCutoverCategoryReadiness {
1222 startup_ready,
1223 route_coverage_ready,
1224 graph_replacement_ready,
1225 search_projection_ready,
1226 storage_recovery_ready,
1227 background_qos_ready,
1228 blackbox_ready,
1229 library_only_ready,
1230 replacement_summary_production_cutover_ready,
1231 };
1232 let blocking_categories = final_cutover_blocking_categories(&category_readiness);
1233 let next_action_names = integration
1234 .next_actions
1235 .iter()
1236 .map(|action| action.action.clone())
1237 .collect::<BTreeSet<_>>()
1238 .into_iter()
1239 .collect::<Vec<_>>();
1240 let next_action_count = next_action_names.len();
1241 FinalCutoverPreflightReport {
1242 protocol: FINAL_CUTOVER_PREFLIGHT_PROTOCOL.to_string(),
1243 production_cutover_ready: integration.ready
1244 && replacement_summary_production_cutover_ready
1245 && blocking_categories.is_empty(),
1246 integration_ready: integration.ready,
1247 replacement_summary_production_cutover_ready,
1248 startup_ready: category_readiness.startup_ready,
1249 route_coverage_ready: category_readiness.route_coverage_ready,
1250 graph_replacement_ready: category_readiness.graph_replacement_ready,
1251 search_projection_ready: category_readiness.search_projection_ready,
1252 storage_recovery_ready: category_readiness.storage_recovery_ready,
1253 background_qos_ready: category_readiness.background_qos_ready,
1254 blackbox_ready: category_readiness.blackbox_ready,
1255 library_only_ready: category_readiness.library_only_ready,
1256 check_count,
1257 ready_check_count,
1258 failed_check_count: check_count.saturating_sub(ready_check_count),
1259 next_action_count,
1260 next_action_names,
1261 blocking_categories,
1262 failed_checks: integration.failed_checks,
1263 failed_evidence_fields,
1264 blocker_codes: integration.blocker_codes,
1265 }
1266}
1267
1268struct FinalCutoverCategoryReadiness {
1269 startup_ready: bool,
1270 route_coverage_ready: bool,
1271 graph_replacement_ready: bool,
1272 search_projection_ready: bool,
1273 storage_recovery_ready: bool,
1274 background_qos_ready: bool,
1275 blackbox_ready: bool,
1276 library_only_ready: bool,
1277 replacement_summary_production_cutover_ready: bool,
1278}
1279
1280fn integration_check_group_ready(report: &IntegrationReadinessReport, names: &[&str]) -> bool {
1281 names.iter().all(|name| {
1282 report
1283 .checks
1284 .iter()
1285 .find(|check| check.name == *name)
1286 .is_some_and(|check| check.ready)
1287 })
1288}
1289
1290fn final_cutover_blocking_categories(readiness: &FinalCutoverCategoryReadiness) -> Vec<String> {
1291 [
1292 (FINAL_CATEGORY_STARTUP, readiness.startup_ready),
1293 (
1294 FINAL_CATEGORY_ROUTE_COVERAGE,
1295 readiness.route_coverage_ready,
1296 ),
1297 (
1298 FINAL_CATEGORY_GRAPH_REPLACEMENT,
1299 readiness.graph_replacement_ready,
1300 ),
1301 (
1302 FINAL_CATEGORY_SEARCH_PROJECTION,
1303 readiness.search_projection_ready,
1304 ),
1305 (
1306 FINAL_CATEGORY_STORAGE_RECOVERY,
1307 readiness.storage_recovery_ready,
1308 ),
1309 (
1310 FINAL_CATEGORY_BACKGROUND_QOS,
1311 readiness.background_qos_ready,
1312 ),
1313 (FINAL_CATEGORY_BLACKBOX, readiness.blackbox_ready),
1314 (FINAL_CATEGORY_LIBRARY_ONLY, readiness.library_only_ready),
1315 (
1316 FINAL_CATEGORY_REPLACEMENT_SUMMARY_CUTOVER,
1317 readiness.replacement_summary_production_cutover_ready,
1318 ),
1319 ]
1320 .into_iter()
1321 .filter_map(|(category, ready)| (!ready).then_some(category.to_string()))
1322 .collect()
1323}
1324
1325pub fn integration_readiness(bundle: &serde_json::Value) -> IntegrationReadinessReport {
1326 let blackbox_manifest = bundle
1327 .get("blackbox_manifest")
1328 .unwrap_or(&serde_json::Value::Null);
1329 let blackbox_readiness = blackbox_readiness_from_manifest_json(blackbox_manifest);
1330 let integration_bundle_protocol_readiness =
1331 integration_bundle_protocol_cutover_readiness(bundle);
1332 let replacement_summary_protocol_readiness =
1333 replacement_summary_protocol_cutover_readiness(bundle);
1334 let hawdb_submodule_readiness = hawdb_submodule_cutover_readiness(bundle);
1335 let legacy_coexistence_readiness = legacy_coexistence_cutover_readiness(bundle);
1336 let content_store_readiness = content_store_boundary_cutover_readiness(bundle);
1337 let previous_wrapper_readiness = previous_wrapper_preflight_cutover_readiness(bundle);
1338 let library_readiness = library_readiness_cutover_readiness(bundle);
1339 let cutover_controls = cutover_controls_readiness(bundle);
1340 let graph_replacement_readiness = graph_replacement_cutover_readiness(bundle);
1341 let query_family_readiness = query_family_replacement_cutover_readiness(bundle);
1342 let search_projection_readiness = search_projection_cutover_readiness(bundle);
1343 let search_candidate_readiness = search_candidate_cutover_readiness(bundle);
1344 let bounded_read_readiness = bounded_read_cutover_readiness(bundle);
1345 let bounded_read_alignment_readiness = bounded_read_alignment_cutover_readiness(bundle);
1346 let graph_route_readiness = graph_route_cutover_readiness(bundle);
1347 let graph_route_alignment_readiness = graph_route_alignment_cutover_readiness(bundle);
1348 let graph_route_parity_alignment_readiness =
1349 graph_route_parity_alignment_cutover_readiness(bundle);
1350 let route_ownership_readiness = route_ownership_cutover_readiness(bundle);
1351 let search_route_ownership_alignment_readiness =
1352 search_route_ownership_alignment_cutover_readiness(
1353 bundle,
1354 "replacement_summary_search_route_ownership_alignment",
1355 );
1356 let active_search_route_ownership_alignment_readiness =
1357 search_route_ownership_alignment_cutover_readiness(
1358 bundle,
1359 "replacement_summary_active_search_route_ownership_alignment",
1360 );
1361 let active_search_route_readiness_alignment_readiness =
1362 active_search_route_readiness_alignment_cutover_readiness(bundle);
1363 let query_runtime_readiness = query_runtime_preflight_cutover_readiness(bundle);
1364 let query_runtime_alignment_readiness =
1365 query_runtime_preflight_alignment_cutover_readiness(bundle);
1366 let storage_recovery_readiness = storage_recovery_cutover_readiness(bundle);
1367 let operations_readiness = operations_readiness_cutover_readiness(bundle);
1368 let background_maintenance_readiness = background_maintenance_cutover_readiness(bundle);
1369 let checks = vec![
1370 check_named_conditions(
1371 "integration_bundle_protocol",
1372 integration_bundle_protocol_cutover_conditions(&integration_bundle_protocol_readiness),
1373 Vec::new(),
1374 ),
1375 check_named_conditions(
1376 "replacement_summary_protocol",
1377 replacement_summary_protocol_cutover_conditions(
1378 &replacement_summary_protocol_readiness,
1379 ),
1380 Vec::new(),
1381 ),
1382 check_named_conditions(
1383 "hawdb_submodule",
1384 hawdb_submodule_cutover_conditions(&hawdb_submodule_readiness),
1385 hawdb_submodule_readiness.blocker_codes.clone(),
1386 ),
1387 check_named_conditions(
1388 "legacy_coexistence",
1389 legacy_coexistence_cutover_conditions(&legacy_coexistence_readiness),
1390 legacy_coexistence_readiness.blocker_codes.clone(),
1391 ),
1392 check_named_conditions(
1393 "content_store_boundary",
1394 content_store_boundary_cutover_conditions(&content_store_readiness),
1395 content_store_readiness.blocker_codes.clone(),
1396 ),
1397 check_named_conditions(
1398 "previous_wrapper_preflight",
1399 previous_wrapper_preflight_cutover_conditions(&previous_wrapper_readiness),
1400 previous_wrapper_readiness.blocker_codes.clone(),
1401 ),
1402 check_named_conditions(
1403 "graph_replacement_evidence",
1404 graph_replacement_cutover_conditions(&graph_replacement_readiness),
1405 graph_replacement_readiness.blocker_codes.clone(),
1406 ),
1407 check_named_conditions(
1408 "query_family_replacement_evidence",
1409 query_family_replacement_cutover_conditions(&query_family_readiness),
1410 query_family_readiness.blocker_codes.clone(),
1411 ),
1412 check_named_conditions(
1413 "search_projection_replacement_evidence",
1414 search_projection_cutover_conditions(&search_projection_readiness),
1415 search_projection_readiness.blocker_codes.clone(),
1416 ),
1417 check_named_conditions(
1418 "search_candidate_primary_evidence",
1419 search_candidate_cutover_conditions(&search_candidate_readiness),
1420 search_candidate_readiness.blocker_codes.clone(),
1421 ),
1422 check_named_conditions(
1423 "bounded_read_evidence",
1424 bounded_read_cutover_conditions(&bounded_read_readiness),
1425 bounded_read_readiness.blocker_codes.clone(),
1426 ),
1427 check_named_conditions(
1428 "bounded_read_evidence_alignment",
1429 bounded_read_alignment_cutover_conditions(&bounded_read_alignment_readiness),
1430 bounded_read_alignment_readiness.blocker_codes.clone(),
1431 ),
1432 check_named_conditions(
1433 "graph_route_readiness",
1434 graph_route_cutover_conditions(&graph_route_readiness),
1435 graph_route_readiness.blocker_codes.clone(),
1436 ),
1437 check_named_conditions(
1438 "graph_route_readiness_alignment",
1439 graph_route_alignment_cutover_conditions(&graph_route_alignment_readiness),
1440 graph_route_alignment_readiness.blocker_codes.clone(),
1441 ),
1442 check_named_conditions(
1443 "graph_route_parity_alignment",
1444 graph_route_parity_alignment_cutover_conditions(
1445 &graph_route_parity_alignment_readiness,
1446 ),
1447 graph_route_parity_alignment_readiness.blocker_codes.clone(),
1448 ),
1449 check_named_conditions(
1450 "route_ownership",
1451 route_ownership_cutover_conditions(&route_ownership_readiness),
1452 route_ownership_readiness.blocker_codes.clone(),
1453 ),
1454 check_named_conditions(
1455 "search_route_ownership_alignment",
1456 search_route_ownership_alignment_cutover_conditions(
1457 &search_route_ownership_alignment_readiness,
1458 "replacement_summary_search_route_ownership_alignment",
1459 ),
1460 search_route_ownership_alignment_readiness
1461 .blocker_codes
1462 .clone(),
1463 ),
1464 check_named_conditions(
1465 "active_search_route_ownership_alignment",
1466 search_route_ownership_alignment_cutover_conditions(
1467 &active_search_route_ownership_alignment_readiness,
1468 "replacement_summary_active_search_route_ownership_alignment",
1469 ),
1470 active_search_route_ownership_alignment_readiness
1471 .blocker_codes
1472 .clone(),
1473 ),
1474 check_named_conditions(
1475 "active_search_route_readiness_alignment",
1476 active_search_route_readiness_alignment_cutover_conditions(
1477 &active_search_route_readiness_alignment_readiness,
1478 ),
1479 active_search_route_readiness_alignment_readiness
1480 .blocker_codes
1481 .clone(),
1482 ),
1483 check_named_conditions(
1484 "query_runtime_preflight",
1485 query_runtime_preflight_cutover_conditions(&query_runtime_readiness),
1486 query_runtime_readiness.blocker_codes.clone(),
1487 ),
1488 check_named_conditions(
1489 "query_runtime_preflight_alignment",
1490 query_runtime_preflight_alignment_cutover_conditions(
1491 &query_runtime_alignment_readiness,
1492 ),
1493 query_runtime_alignment_readiness.blocker_codes.clone(),
1494 ),
1495 check_named_conditions(
1496 "library_readiness",
1497 library_readiness_cutover_conditions(&library_readiness),
1498 library_readiness.blocker_codes.clone(),
1499 ),
1500 check_named_conditions(
1501 "cutover_controls",
1502 cutover_controls_conditions(&cutover_controls),
1503 cutover_controls.blocker_codes.clone(),
1504 ),
1505 check_named_conditions(
1506 "background_maintenance_evidence",
1507 background_maintenance_cutover_conditions(&background_maintenance_readiness),
1508 background_maintenance_readiness.blocker_codes.clone(),
1509 ),
1510 check_named_conditions(
1511 "storage_recovery_evidence",
1512 storage_recovery_cutover_conditions(&storage_recovery_readiness),
1513 storage_recovery_readiness.blocker_codes.clone(),
1514 ),
1515 check_named_conditions(
1516 "operations_readiness",
1517 operations_readiness_cutover_conditions(&operations_readiness),
1518 operations_readiness.blocker_codes.clone(),
1519 ),
1520 check_named_conditions(
1521 "blackbox_redaction",
1522 blackbox_redaction_cutover_conditions(&blackbox_readiness),
1523 blackbox_readiness.blocker_codes.clone(),
1524 ),
1525 check_named_conditions(
1526 "blackbox_operational_evidence",
1527 blackbox_operational_cutover_conditions(&blackbox_readiness),
1528 blackbox_readiness.blocker_codes.clone(),
1529 ),
1530 ];
1531 let ready = checks.iter().all(|check| check.ready);
1532 let failed_checks = checks
1533 .iter()
1534 .filter(|check| !check.ready)
1535 .map(|check| check.name.clone())
1536 .collect::<Vec<_>>();
1537 let blocker_codes = checks
1538 .iter()
1539 .flat_map(|check| check.blocker_codes.iter().cloned())
1540 .collect::<std::collections::BTreeSet<_>>()
1541 .into_iter()
1542 .collect::<Vec<_>>();
1543 IntegrationReadinessReport {
1544 protocol: INTEGRATION_READINESS_PROTOCOL.to_string(),
1545 ready,
1546 failed_checks,
1547 checks,
1548 blocker_codes,
1549 next_actions: next_actions(
1550 ready,
1551 IntegrationGateReadiness {
1552 integration_bundle: &integration_bundle_protocol_readiness,
1553 replacement_summary_protocol: &replacement_summary_protocol_readiness,
1554 submodule: &hawdb_submodule_readiness,
1555 legacy_coexistence: &legacy_coexistence_readiness,
1556 content_store: &content_store_readiness,
1557 previous_wrapper: &previous_wrapper_readiness,
1558 library: &library_readiness,
1559 cutover_controls: &cutover_controls,
1560 graph_replacement: &graph_replacement_readiness,
1561 query_family: &query_family_readiness,
1562 search_projection: &search_projection_readiness,
1563 search_candidate: &search_candidate_readiness,
1564 bounded_read: &bounded_read_readiness,
1565 bounded_read_alignment: &bounded_read_alignment_readiness,
1566 graph_route: &graph_route_readiness,
1567 graph_route_alignment: &graph_route_alignment_readiness,
1568 graph_route_parity_alignment: &graph_route_parity_alignment_readiness,
1569 route_ownership: &route_ownership_readiness,
1570 search_route_ownership_alignment: &search_route_ownership_alignment_readiness,
1571 active_search_route_ownership_alignment:
1572 &active_search_route_ownership_alignment_readiness,
1573 active_search_route_readiness_alignment:
1574 &active_search_route_readiness_alignment_readiness,
1575 query_runtime: &query_runtime_readiness,
1576 query_runtime_alignment: &query_runtime_alignment_readiness,
1577 blackbox: &blackbox_readiness,
1578 storage_recovery: &storage_recovery_readiness,
1579 operations: &operations_readiness,
1580 background_maintenance: &background_maintenance_readiness,
1581 },
1582 ),
1583 }
1584}
1585
1586fn check_named_conditions(
1587 name: &'static str,
1588 conditions: impl IntoIterator<Item = (&'static str, bool)>,
1589 blocker_codes: Vec<String>,
1590) -> IntegrationCheckReport {
1591 let conditions = conditions.into_iter().collect::<Vec<_>>();
1592 let evidence_fields = conditions
1593 .iter()
1594 .map(|(field, _)| (*field).to_string())
1595 .collect::<Vec<_>>();
1596 let failed_evidence_fields = conditions
1597 .iter()
1598 .filter_map(|(field, ready)| (!*ready).then_some((*field).to_string()))
1599 .collect::<Vec<_>>();
1600 IntegrationCheckReport {
1601 name: name.to_string(),
1602 ready: failed_evidence_fields.is_empty(),
1603 evidence_fields,
1604 failed_evidence_fields,
1605 blocker_codes,
1606 }
1607}
1608
1609fn integration_bundle_protocol_cutover_conditions(
1610 readiness: &IntegrationBundleProtocolCutoverReadiness,
1611) -> Vec<(&'static str, bool)> {
1612 vec![("protocol", readiness.protocol_matches)]
1613}
1614
1615fn replacement_summary_protocol_cutover_conditions(
1616 readiness: &ReplacementSummaryProtocolCutoverReadiness,
1617) -> Vec<(&'static str, bool)> {
1618 vec![
1619 ("replacement_summary.protocol", readiness.protocol_matches),
1620 (
1621 "replacement_summary.replacement_boundaries.graph_layer",
1622 readiness.graph_layer_replacement_scope_ready,
1623 ),
1624 (
1625 "replacement_summary.replacement_boundaries.search_projection",
1626 readiness.search_projection_replacement_scope_ready,
1627 ),
1628 (
1629 "replacement_summary.replacement_boundaries.content_store",
1630 readiness.content_store_out_of_scope,
1631 ),
1632 (
1633 "replacement_summary.replacement_boundaries.large_blob_store",
1634 readiness.large_blob_store_out_of_scope,
1635 ),
1636 ]
1637}
1638
1639fn hawdb_submodule_cutover_conditions(
1640 readiness: &HawDBSubmoduleCutoverReadiness,
1641) -> Vec<(&'static str, bool)> {
1642 vec![
1643 ("submodule.present", readiness.present),
1644 ("submodule.path", readiness.path_present),
1645 ("submodule.commit", readiness.commit_present),
1646 ]
1647}
1648
1649fn legacy_coexistence_cutover_conditions(
1650 readiness: &LegacyCoexistenceCutoverReadiness,
1651) -> Vec<(&'static str, bool)> {
1652 vec![
1653 (
1654 "coexistence.old_database_retained",
1655 readiness.old_database_retained,
1656 ),
1657 ("coexistence.mode", readiness.mode_safe),
1658 (
1659 "coexistence.old_database_deleted",
1660 readiness.old_database_not_deleted,
1661 ),
1662 ]
1663}
1664
1665fn content_store_boundary_cutover_conditions(
1666 readiness: &ContentStoreBoundaryCutoverReadiness,
1667) -> Vec<(&'static str, bool)> {
1668 vec![
1669 ("content_store.present", readiness.present),
1670 ("content_store.engine", readiness.engine_sqlite),
1671 (
1672 "content_store.messages_available",
1673 readiness.messages_available,
1674 ),
1675 (
1676 "content_store.source_chunks_available",
1677 readiness.source_chunks_available,
1678 ),
1679 ]
1680}
1681
1682fn previous_wrapper_preflight_cutover_conditions(
1683 readiness: &PreviousWrapperPreflightCutoverReadiness,
1684) -> Vec<(&'static str, bool)> {
1685 vec![("previous_wrapper_preflight.ready", readiness.ready)]
1686}
1687
1688fn route_ownership_cutover_conditions(
1689 readiness: &RouteOwnershipCutoverReadiness,
1690) -> Vec<(&'static str, bool)> {
1691 vec![
1692 ("route_ownership.protocol", readiness.protocol_matches),
1693 ("route_ownership.ready", readiness.ready),
1694 (
1695 "route_ownership.production_cutover_ready",
1696 readiness.production_cutover_ready,
1697 ),
1698 (
1699 "route_ownership.require_all_hawdb",
1700 readiness.require_all_hawdb,
1701 ),
1702 (
1703 "route_ownership.required_route_count",
1704 readiness.required_route_count_matches,
1705 ),
1706 (
1707 "route_ownership.explicit_route_count",
1708 readiness.explicit_route_count_matches,
1709 ),
1710 (
1711 "route_ownership.hawdb_route_count",
1712 readiness.hawdb_route_count_matches,
1713 ),
1714 (
1715 "route_ownership.legacy_route_count",
1716 readiness.legacy_route_count_zero,
1717 ),
1718 (
1719 "route_ownership.missing_required_routes",
1720 readiness.missing_required_routes_empty,
1721 ),
1722 (
1723 "route_ownership.unknown_routes",
1724 readiness.unknown_routes_empty,
1725 ),
1726 (
1727 "route_ownership.duplicate_routes",
1728 readiness.duplicate_routes_empty,
1729 ),
1730 (
1731 "route_ownership.conflicting_routes",
1732 readiness.conflicting_routes_empty,
1733 ),
1734 (
1735 "route_ownership.hawdb_not_ready_routes",
1736 readiness.hawdb_not_ready_routes_empty,
1737 ),
1738 (
1739 "route_ownership.route_readiness_present",
1740 readiness.route_readiness_present,
1741 ),
1742 (
1743 "route_ownership.route_readiness_ready",
1744 readiness.route_readiness_ready,
1745 ),
1746 (
1747 "route_ownership.search_route_projection_evidence_present",
1748 readiness.search_route_projection_evidence_present,
1749 ),
1750 (
1751 "route_ownership.route_catalog_version",
1752 readiness.route_catalog_version_matches,
1753 ),
1754 (
1755 "route_ownership.route_catalog_digest",
1756 readiness.route_catalog_digest_matches,
1757 ),
1758 (
1759 "route_ownership.blocker_codes",
1760 readiness.blocker_codes_empty,
1761 ),
1762 ]
1763}
1764
1765fn blackbox_redaction_cutover_conditions(
1766 readiness: &BlackboxReadinessReport,
1767) -> Vec<(&'static str, bool)> {
1768 vec![
1769 ("blackbox_manifest.protocol", readiness.protocol_ready),
1770 (
1771 "blackbox_manifest.artifact_dir_present",
1772 readiness.artifact_dir_present,
1773 ),
1774 (
1775 "blackbox_manifest.artifact_count",
1776 readiness.artifact_count_present,
1777 ),
1778 ("blackbox_manifest.events_path", readiness.events_path_ready),
1779 (
1780 "blackbox_manifest.redaction.raw_query_text_copied",
1781 readiness.raw_query_text_redacted,
1782 ),
1783 (
1784 "blackbox_manifest.redaction.raw_parameters_copied",
1785 readiness.raw_parameters_redacted,
1786 ),
1787 (
1788 "blackbox_manifest.redaction.raw_artifact_payloads_copied",
1789 readiness.raw_artifact_payloads_redacted,
1790 ),
1791 (
1792 "blackbox_manifest.redaction.artifact_paths_are_relative",
1793 readiness.artifact_paths_relative,
1794 ),
1795 ]
1796}
1797
1798fn blackbox_operational_cutover_conditions(
1799 readiness: &BlackboxReadinessReport,
1800) -> Vec<(&'static str, bool)> {
1801 vec![
1802 (
1803 "blackbox_manifest.artifacts.slow-query-log.jsonl",
1804 readiness.slow_query_log_present,
1805 ),
1806 (
1807 "blackbox_manifest.artifacts.slow-query-log.jsonl.jsonl",
1808 readiness.slow_query_log_jsonl_summary_present,
1809 ),
1810 (
1811 "blackbox_manifest.artifacts.background-maintenance.json",
1812 readiness.background_maintenance_present,
1813 ),
1814 (
1815 "blackbox_manifest.artifacts.background-maintenance.json.background_qos",
1816 readiness.background_qos_summary_ready,
1817 ),
1818 ]
1819}
1820
1821struct IntegrationGateReadiness<'a> {
1822 integration_bundle: &'a IntegrationBundleProtocolCutoverReadiness,
1823 replacement_summary_protocol: &'a ReplacementSummaryProtocolCutoverReadiness,
1824 submodule: &'a HawDBSubmoduleCutoverReadiness,
1825 legacy_coexistence: &'a LegacyCoexistenceCutoverReadiness,
1826 content_store: &'a ContentStoreBoundaryCutoverReadiness,
1827 previous_wrapper: &'a PreviousWrapperPreflightCutoverReadiness,
1828 library: &'a LibraryReadinessCutoverReadiness,
1829 cutover_controls: &'a CutoverControlsReadiness,
1830 graph_replacement: &'a GraphReplacementCutoverReadiness,
1831 query_family: &'a QueryFamilyReplacementCutoverReadiness,
1832 search_projection: &'a SearchProjectionCutoverReadiness,
1833 search_candidate: &'a SearchCandidateCutoverReadiness,
1834 bounded_read: &'a BoundedReadCutoverReadiness,
1835 bounded_read_alignment: &'a BoundedReadAlignmentCutoverReadiness,
1836 graph_route: &'a GraphRouteCutoverReadiness,
1837 graph_route_alignment: &'a GraphRouteAlignmentCutoverReadiness,
1838 graph_route_parity_alignment: &'a GraphRouteParityAlignmentCutoverReadiness,
1839 route_ownership: &'a RouteOwnershipCutoverReadiness,
1840 search_route_ownership_alignment: &'a SearchRouteOwnershipAlignmentCutoverReadiness,
1841 active_search_route_ownership_alignment: &'a SearchRouteOwnershipAlignmentCutoverReadiness,
1842 active_search_route_readiness_alignment:
1843 &'a ActiveSearchRouteReadinessAlignmentCutoverReadiness,
1844 query_runtime: &'a QueryRuntimePreflightCutoverReadiness,
1845 query_runtime_alignment: &'a QueryRuntimePreflightAlignmentCutoverReadiness,
1846 blackbox: &'a BlackboxReadinessReport,
1847 storage_recovery: &'a StorageRecoveryCutoverReadiness,
1848 operations: &'a OperationsReadinessCutoverReadiness,
1849 background_maintenance: &'a BackgroundMaintenanceCutoverReadiness,
1850}
1851
1852fn next_actions(
1853 ready: bool,
1854 readiness: IntegrationGateReadiness<'_>,
1855) -> Vec<IntegrationNextAction> {
1856 if ready {
1857 return Vec::new();
1858 }
1859 let mut actions = Vec::new();
1860 if !readiness.integration_bundle.evidence_ready() {
1861 actions.push(next_action(
1862 "regenerate_hawdb_integration_bundle",
1863 "Nowledge Mem integration readiness requires the versioned integration bundle protocol",
1864 ["protocol"],
1865 ));
1866 }
1867 if !readiness.submodule.evidence_ready() {
1868 actions.push(next_action(
1869 "add_hawdb_submodule",
1870 "Nowledge Mem must depend on HawDB as a submodule instead of copying sources",
1871 ["submodule.present", "submodule.path", "submodule.commit"],
1872 ));
1873 }
1874 if !readiness.legacy_coexistence.evidence_ready() {
1875 actions.push(next_action(
1876 "enable_side_by_side_coexistence",
1877 "Kuzu/Ladybug and LanceDB must remain available while HawDB runs in shadow",
1878 [
1879 "coexistence.old_database_retained",
1880 "coexistence.mode",
1881 "coexistence.old_database_deleted",
1882 ],
1883 ));
1884 }
1885 if !readiness.content_store.evidence_ready() {
1886 actions.push(next_action(
1887 "attach_content_store_evidence",
1888 "messages and source chunks still come from content.db during replacement validation",
1889 [
1890 "content_store.present",
1891 "content_store.engine",
1892 "content_store.messages_available",
1893 "content_store.source_chunks_available",
1894 ],
1895 ));
1896 }
1897 if !readiness.previous_wrapper.evidence_ready() {
1898 actions.push(next_action(
1899 "run_previous_wrapper_preflight",
1900 "the previous-wrapper release bundle must pass before Mem cutover",
1901 ["previous_wrapper_preflight.ready"],
1902 ));
1903 }
1904 if !readiness.graph_replacement.evidence_ready() {
1905 actions.push(next_action(
1906 "produce_replacement_summary",
1907 "graph and search replacement evidence must be production-ready",
1908 [
1909 "replacement_summary.production_cutover_ready",
1910 "replacement_summary.blocking_categories",
1911 "replacement_summary.missing_evidence",
1912 ],
1913 ));
1914 }
1915 if !readiness.replacement_summary_protocol.evidence_ready() {
1916 actions.push(next_action(
1917 "produce_replacement_summary",
1918 "replacement summary must use the HawDB protocol and explicit replacement boundaries",
1919 [
1920 "replacement_summary.protocol",
1921 "replacement_summary.replacement_boundaries.graph_layer",
1922 "replacement_summary.replacement_boundaries.search_projection",
1923 "replacement_summary.replacement_boundaries.content_store",
1924 "replacement_summary.replacement_boundaries.large_blob_store",
1925 ],
1926 ));
1927 }
1928 if !readiness.query_family.evidence_ready() {
1929 actions.push(next_action(
1930 "close_required_query_families",
1931 "Nowledge Mem cutover requires explicit readiness for every required query family",
1932 [
1933 "replacement_summary.replacement_readiness_family_summary.required_query_families",
1934 "replacement_summary.replacement_readiness_family_summary.missing_required_query_families",
1935 "replacement_summary.replacement_readiness_family_summary.blocked_query_families",
1936 "replacement_summary.replacement_readiness_family_summary.min_replacement_readiness_per_million",
1937 ],
1938 ));
1939 }
1940 if !readiness.search_projection.evidence_ready() {
1941 actions.push(next_action(
1942 "attach_search_projection_replacement_evidence",
1943 "LanceDB replacement evidence must prove FTS, vector, incremental, predicate pushdown, compressed projection, and shadow parity",
1944 [
1945 "replacement_summary.search_projection_evidence.ready",
1946 "replacement_summary.search_projection_evidence.protocol",
1947 "replacement_summary.search_projection_evidence.fts_ready",
1948 "replacement_summary.search_projection_evidence.vector_ready",
1949 "replacement_summary.search_projection_evidence.document_identity_ready",
1950 "replacement_summary.search_projection_evidence.incremental_update_ready",
1951 "replacement_summary.search_projection_evidence.predicate_pushdown_ready",
1952 "replacement_summary.search_projection_evidence.production_filter_pruning_ready",
1953 "replacement_summary.search_projection_evidence.compressed_vector_projection_required",
1954 "replacement_summary.search_projection_evidence.compressed_vector_projection_ready",
1955 "replacement_summary.search_projection_shadow_evidence.protocol",
1956 "replacement_summary.search_projection_shadow_evidence.evidence_source",
1957 "replacement_summary.search_projection_shadow_evidence.ready",
1958 "replacement_summary.search_projection_shadow_evidence.document_count_parity",
1959 "replacement_summary.search_projection_shadow_evidence.document_identity_parity",
1960 "replacement_summary.search_projection_shadow_evidence.blocker_codes",
1961 ],
1962 ));
1963 }
1964 if !readiness.search_candidate.evidence_ready() {
1965 actions.push(next_action(
1966 "enable_hawdb_search_candidate_primary_reads",
1967 "LanceDB replacement must prove memory-hybrid candidate reads are served by HawDB before Mem cutover",
1968 [
1969 "search_candidate_shadow_evidence.protocol",
1970 "search_candidate_shadow_evidence.evidence_source",
1971 "search_candidate_shadow_evidence.route",
1972 "search_candidate_shadow_evidence.ready",
1973 "search_candidate_shadow_evidence.candidate_primary_engine",
1974 "search_candidate_shadow_evidence.request_count",
1975 "search_candidate_shadow_evidence.primary_candidate_count",
1976 "search_candidate_shadow_evidence.shadow_candidate_count",
1977 "search_candidate_shadow_evidence.matched_candidate_count",
1978 "search_candidate_shadow_evidence.primary_only_candidate_count",
1979 "search_candidate_shadow_evidence.row_count_parity",
1980 "search_candidate_shadow_evidence.text_retriever_ready",
1981 "search_candidate_shadow_evidence.vector_retriever_ready",
1982 "search_candidate_shadow_evidence.fts_top_k_overlap_ready",
1983 "search_candidate_shadow_evidence.vector_top_k_overlap_ready",
1984 "search_candidate_shadow_evidence.candidate_readiness.source_chunk_identity_ready",
1985 "search_candidate_shadow_evidence.candidate_readiness.fail_soft_observed",
1986 "search_candidate_shadow_evidence.candidate_readiness.projection_marker_status_visible",
1987 "search_candidate_shadow_evidence.candidate_readiness.projection_watermark_ready",
1988 "search_candidate_shadow_evidence.candidate_readiness.embedding_identity_ready",
1989 "search_candidate_shadow_evidence.candidate_identity.ready",
1990 "search_candidate_shadow_evidence.shadow_scan_filter_pushdown_ready",
1991 "search_candidate_shadow_evidence.shadow_scan_field_pruning_ready",
1992 "search_candidate_shadow_evidence.shadow_scan_field_summary_count",
1993 "search_candidate_shadow_evidence.filter_pushdown.ready",
1994 "search_candidate_shadow_evidence.filter_pushdown.field_summary_count",
1995 "search_candidate_shadow_evidence.filter_pushdown.missing_required_fields",
1996 "search_candidate_shadow_evidence.blocker_codes",
1997 ],
1998 ));
1999 }
2000 if !readiness.bounded_read.evidence_ready() {
2001 actions.push(next_action(
2002 "attach_bounded_read_profile",
2003 "HawDB read replacement must prove bounded execution before Mem cutover",
2004 [
2005 "replacement_summary.bounded_read_evidence.present",
2006 "replacement_summary.bounded_read_evidence.protocol",
2007 "replacement_summary.bounded_read_evidence.ready",
2008 "replacement_summary.bounded_read_evidence.mode",
2009 "replacement_summary.bounded_read_evidence.max_rows",
2010 "replacement_summary.bounded_read_evidence.execution_row_cap",
2011 "replacement_summary.bounded_read_evidence.estimated_payload_bytes",
2012 "replacement_summary.bounded_read_evidence.max_estimated_payload_bytes",
2013 "replacement_summary.bounded_read_evidence.payload_budget_exceeded",
2014 "replacement_summary.bounded_read_evidence.row_limit_enforced_before_output",
2015 "replacement_summary.bounded_read_evidence.operator_row_cap_enabled",
2016 "replacement_summary.bounded_read_evidence.blocking_operator_count",
2017 "replacement_summary.bounded_read_evidence.streaming",
2018 "replacement_summary.bounded_read_evidence.blocker_codes",
2019 ],
2020 ));
2021 }
2022 if !readiness.bounded_read_alignment.evidence_ready() {
2023 actions.push(next_action(
2024 "regenerate_bounded_read_alignment",
2025 "live bounded-read evidence must match the replacement summary before Mem cutover",
2026 [
2027 "bounded_read_evidence.ready",
2028 "replacement_summary_bounded_read_alignment.ready",
2029 "replacement_summary_bounded_read_alignment.evidence_ready",
2030 "replacement_summary_bounded_read_alignment.summary_ready",
2031 "replacement_summary_bounded_read_alignment.blocker_codes",
2032 ],
2033 ));
2034 }
2035 if !readiness.graph_route.evidence_ready() {
2036 actions.push(next_action(
2037 "attach_graph_route_readiness_evidence",
2038 "Nowledge Mem graph cutover requires route-level primary-read readiness evidence",
2039 [
2040 "graph_route_readiness.protocol",
2041 "graph_route_readiness.evidence_protocol",
2042 "graph_route_readiness.evidence_ready",
2043 "graph_route_readiness.route_count",
2044 "graph_route_readiness.required_route_count",
2045 "graph_route_readiness.route_coverage",
2046 "graph_route_readiness.missing_required_routes",
2047 "graph_route_readiness.query_runtime_route_count",
2048 "graph_route_readiness.query_runtime_report_count",
2049 "graph_route_readiness.query_runtime_plan_profile_counts",
2050 "graph_route_readiness.relationship_property_pruning_counts",
2051 "graph_route_readiness.missing_query_runtime_routes",
2052 "graph_route_readiness.route_query_runtime_ready",
2053 "graph_route_readiness.route_primary_ready",
2054 "graph_route_readiness.primary_ready_route_count",
2055 "graph_route_readiness.route_primary_blocker_codes",
2056 "graph_route_readiness.evidence_route_coverage_present",
2057 "graph_route_readiness.evidence_route_coverage_matches",
2058 "graph_route_readiness.evidence_route_coverage_blocker_codes",
2059 "graph_route_readiness.routes",
2060 ],
2061 ));
2062 }
2063 if !readiness.graph_route_alignment.evidence_ready() {
2064 actions.push(next_action(
2065 "regenerate_graph_route_readiness_alignment",
2066 "live graph route primary-read readiness must match the replacement summary before Mem cutover",
2067 [
2068 "replacement_summary_graph_route_alignment.ready",
2069 "replacement_summary_graph_route_alignment.evidence_protocol_matches",
2070 "replacement_summary_graph_route_alignment.evidence_ready",
2071 "replacement_summary_graph_route_alignment.evidence_route_primary_ready",
2072 "replacement_summary_graph_route_alignment.summary_route_primary_ready",
2073 "replacement_summary_graph_route_alignment.route_primary_ready_matches",
2074 "replacement_summary_graph_route_alignment.route_query_plan_evidence_ready_matches",
2075 "replacement_summary_graph_route_alignment.route_query_profile_evidence_ready_matches",
2076 "replacement_summary_graph_route_alignment.route_relationship_property_pruning_evidence_ready_matches",
2077 "replacement_summary_graph_route_alignment.relationship_property_pruning_required_count_matches",
2078 "replacement_summary_graph_route_alignment.relationship_property_pruning_report_count_matches",
2079 "replacement_summary_graph_route_alignment.primary_ready_routes_match",
2080 "replacement_summary_graph_route_alignment.blocker_codes",
2081 ],
2082 ));
2083 }
2084 if !readiness.graph_route_parity_alignment.evidence_ready() {
2085 actions.push(next_action(
2086 "attach_graph_route_parity_evidence",
2087 "Nowledge Mem graph cutover requires route-level shadow parity evidence for graph reads",
2088 [
2089 "graph_route_parity_alignment.ready",
2090 "graph_route_parity_alignment.required_route_count",
2091 "graph_route_parity_alignment.ready_route_count",
2092 "graph_route_parity_alignment.missing_routes",
2093 "graph_route_parity_alignment.not_ready_routes",
2094 "graph_route_parity_alignment.route_mismatch_routes",
2095 "graph_route_parity_alignment.protocol_mismatch_routes",
2096 "graph_route_parity_alignment.blocker_routes",
2097 ],
2098 ));
2099 }
2100 if !readiness.route_ownership.evidence_ready() {
2101 actions.push(next_action(
2102 "attach_route_ownership_evidence",
2103 "Nowledge Mem cutover requires every active read route to be owned by HawDB through the embedded library runtime",
2104 [
2105 "route_ownership.protocol",
2106 "route_ownership.ready",
2107 "route_ownership.production_cutover_ready",
2108 "route_ownership.require_all_hawdb",
2109 "route_ownership.required_route_count",
2110 "route_ownership.explicit_route_count",
2111 "route_ownership.hawdb_route_count",
2112 "route_ownership.legacy_route_count",
2113 "route_ownership.missing_required_routes",
2114 "route_ownership.unknown_routes",
2115 "route_ownership.duplicate_routes",
2116 "route_ownership.conflicting_routes",
2117 "route_ownership.hawdb_not_ready_routes",
2118 "route_ownership.route_readiness_present",
2119 "route_ownership.route_readiness_ready",
2120 "route_ownership.route_catalog_version",
2121 "route_ownership.route_catalog_digest",
2122 "route_ownership.blocker_codes",
2123 ],
2124 ));
2125 }
2126 if !readiness.search_route_ownership_alignment.evidence_ready() {
2127 actions.push(next_action(
2128 "regenerate_search_route_ownership_alignment",
2129 "live search projection route ownership must match the replacement summary before Mem cutover",
2130 [
2131 "search_route_ownership.ready",
2132 "search_route_ownership.production_cutover_ready",
2133 "replacement_summary.search_route_ownership.ready",
2134 "replacement_summary_search_route_ownership_alignment.ready",
2135 "replacement_summary_search_route_ownership_alignment.evidence_ready",
2136 "replacement_summary_search_route_ownership_alignment.summary_ready",
2137 "replacement_summary_search_route_ownership_alignment.lancedb_route_count_matches",
2138 "replacement_summary_search_route_ownership_alignment.lancedb_routes_matches",
2139 "replacement_summary_search_route_ownership_alignment.blocker_codes",
2140 ],
2141 ));
2142 }
2143 if !readiness
2144 .active_search_route_ownership_alignment
2145 .evidence_ready()
2146 {
2147 actions.push(next_action(
2148 "regenerate_active_search_route_ownership_alignment",
2149 "live active search route ownership must match the replacement summary before Mem cutover",
2150 [
2151 "active_search_route_ownership.ready",
2152 "active_search_route_ownership.production_cutover_ready",
2153 "replacement_summary.active_search_route_ownership.ready",
2154 "replacement_summary_active_search_route_ownership_alignment.ready",
2155 "replacement_summary_active_search_route_ownership_alignment.evidence_ready",
2156 "replacement_summary_active_search_route_ownership_alignment.summary_ready",
2157 "replacement_summary_active_search_route_ownership_alignment.lancedb_route_count_matches",
2158 "replacement_summary_active_search_route_ownership_alignment.lancedb_routes_matches",
2159 "replacement_summary_active_search_route_ownership_alignment.blocker_codes",
2160 ],
2161 ));
2162 }
2163 if !readiness
2164 .active_search_route_readiness_alignment
2165 .evidence_ready()
2166 {
2167 actions.push(next_action(
2168 "regenerate_active_search_route_readiness_alignment",
2169 "live active search route read evidence must match the replacement summary before Mem cutover",
2170 [
2171 "active_search_route_readiness.ready",
2172 "active_search_route_readiness.production_cutover_ready",
2173 "active_search_route_readiness.lancedb_handle_required_route_count",
2174 "active_search_route_readiness.lancedb_handle_required_routes",
2175 "active_search_route_readiness.embedding_identity_not_ready_routes",
2176 "active_search_route_readiness.zero_vector_semantics_not_ready_routes",
2177 "active_search_route_readiness.cjk_tokenization_not_ready_routes",
2178 "active_search_route_readiness.ranking_window_not_ready_routes",
2179 "active_search_route_readiness.fail_soft_reason_codes_not_ready_routes",
2180 "active_search_route_readiness.repair_rebuild_markers_not_ready_routes",
2181 "replacement_summary.active_search_route_readiness.ready",
2182 "replacement_summary_active_search_route_readiness_alignment.ready",
2183 "replacement_summary_active_search_route_readiness_alignment.evidence_present",
2184 "replacement_summary_active_search_route_readiness_alignment.summary_present",
2185 "replacement_summary_active_search_route_readiness_alignment.lancedb_handle_count_matches",
2186 "replacement_summary_active_search_route_readiness_alignment.lancedb_handle_routes_matches",
2187 "replacement_summary_active_search_route_readiness_alignment.embedding_identity_not_ready_routes_matches",
2188 "replacement_summary_active_search_route_readiness_alignment.zero_vector_semantics_not_ready_routes_matches",
2189 "replacement_summary_active_search_route_readiness_alignment.cjk_tokenization_not_ready_routes_matches",
2190 "replacement_summary_active_search_route_readiness_alignment.ranking_window_not_ready_routes_matches",
2191 "replacement_summary_active_search_route_readiness_alignment.fail_soft_reason_codes_not_ready_routes_matches",
2192 "replacement_summary_active_search_route_readiness_alignment.repair_rebuild_markers_not_ready_routes_matches",
2193 "replacement_summary_active_search_route_readiness_alignment.blocker_codes",
2194 ],
2195 ));
2196 }
2197 if !readiness.query_runtime.evidence_ready() {
2198 actions.push(next_action(
2199 "attach_query_runtime_preflight_evidence",
2200 "Nowledge Mem cutover requires read-only query runtime EXPLAIN ANALYZE preflight evidence",
2201 [
2202 "query_runtime_preflight.protocol",
2203 "query_runtime_preflight.ready",
2204 "query_runtime_preflight.database_opened",
2205 "query_runtime_preflight.redaction.ready",
2206 "query_runtime_preflight.redaction.rows_copied",
2207 "query_runtime_preflight.redaction.parameters_copied",
2208 "query_runtime_preflight.redaction.local_paths_copied",
2209 "query_runtime_preflight.redaction.raw_errors_copied",
2210 "query_runtime_preflight.probe_count",
2211 "query_runtime_preflight.passed_probe_count",
2212 "query_runtime_preflight.failed_probe_count",
2213 "query_runtime_preflight.route_coverage",
2214 "query_runtime_preflight.blocker_codes",
2215 "query_runtime_preflight.probes",
2216 ],
2217 ));
2218 }
2219 if !readiness.query_runtime_alignment.evidence_ready() {
2220 actions.push(next_action(
2221 "regenerate_query_runtime_preflight_alignment",
2222 "live query runtime preflight evidence must match the replacement summary before Mem cutover",
2223 [
2224 "query_runtime_preflight.ready",
2225 "replacement_summary.query_runtime_preflight.ready",
2226 "replacement_summary_query_runtime_alignment.ready",
2227 "replacement_summary_query_runtime_alignment.evidence_ready",
2228 "replacement_summary_query_runtime_alignment.summary_ready",
2229 "replacement_summary_query_runtime_alignment.covered_routes_matches",
2230 "replacement_summary_query_runtime_alignment.blocker_codes",
2231 ],
2232 ));
2233 }
2234 if !readiness.library.evidence_ready() {
2235 actions.push(next_action(
2236 "attach_library_readiness_evidence",
2237 "Nowledge Mem cutover requires the HawDB Rust library to open graph, search projection, and required evidence areas",
2238 [
2239 "library_readiness.protocol",
2240 "library_readiness.ready",
2241 "library_readiness.blocked_area_count",
2242 "library_readiness.open_report.graph_opened",
2243 "library_readiness.open_report.search_projection_opened",
2244 "library_readiness.readiness_by_area",
2245 ],
2246 ));
2247 }
2248 if !readiness.cutover_controls.evidence_ready() {
2249 actions.push(next_action(
2250 "attach_cutover_controls_evidence",
2251 "Nowledge Mem cutover requires host-owned graph/search read controls to select effective HawDB reads with dual writes and projection catch-up enabled",
2252 [
2253 "cutover_controls.protocol",
2254 "cutover_controls.ready",
2255 "cutover_controls.controls.graph_reads",
2256 "cutover_controls.graph.read_effective",
2257 "cutover_controls.production_status.graph.hawdb_cutover_effective",
2258 "cutover_controls.controls.search_reads",
2259 "cutover_controls.search.read_effective",
2260 "cutover_controls.production_status.search.hawdb_cutover_effective",
2261 "cutover_controls.work.dual_writes_enabled",
2262 "cutover_controls.work.projection_catch_up_enabled",
2263 "cutover_controls.work.initial_import_safe_for_read_cutover",
2264 "cutover_controls.blocker_codes",
2265 ],
2266 ));
2267 }
2268 if !readiness.blackbox.redaction_ready {
2269 actions.push(next_action(
2270 "attach_blackbox_redaction_report",
2271 "Nowledge Mem cutover requires redacted blackbox evidence before diagnostics can be retained",
2272 [
2273 "blackbox_manifest.protocol",
2274 "blackbox_manifest.artifact_dir_present",
2275 "blackbox_manifest.artifact_count",
2276 "blackbox_manifest.events_path",
2277 "blackbox_manifest.redaction.raw_query_text_copied",
2278 "blackbox_manifest.redaction.raw_parameters_copied",
2279 "blackbox_manifest.redaction.raw_artifact_payloads_copied",
2280 "blackbox_manifest.redaction.artifact_paths_are_relative",
2281 ],
2282 ));
2283 }
2284 if !readiness.blackbox.operational_evidence_ready {
2285 actions.push(next_action(
2286 "attach_blackbox_operational_evidence",
2287 "Nowledge Mem cutover requires blackbox slow-query and background QoS operational evidence",
2288 [
2289 "blackbox_manifest.artifacts.slow-query-log.jsonl",
2290 "blackbox_manifest.artifacts.slow-query-log.jsonl.jsonl",
2291 "blackbox_manifest.artifacts.background-maintenance.json",
2292 "blackbox_manifest.artifacts.background-maintenance.json.background_qos",
2293 ],
2294 ));
2295 }
2296 if !readiness.storage_recovery.evidence_ready() {
2297 actions.push(next_action(
2298 "attach_storage_recovery_report",
2299 "storage recovery evidence must prove durable bounded WAL replay before Mem cutover",
2300 [
2301 "replacement_summary.cutover_evidence.storage_recovery_required",
2302 "replacement_summary.cutover_evidence.storage_recovery_ready",
2303 "replacement_summary.cutover_evidence.storage_recovery_protocol_matches",
2304 "replacement_summary.cutover_evidence.storage_recovery_durable",
2305 "replacement_summary.cutover_evidence.storage_recovery_checkpoint_boundary_present",
2306 "replacement_summary.cutover_evidence.storage_recovery_wal_replay_bounded",
2307 "replacement_summary.cutover_evidence.storage_recovery_replay_boundary_consistent",
2308 "replacement_summary.cutover_evidence.storage_recovery_torn_tail_clean",
2309 "replacement_summary.cutover_evidence.storage_recovery_blocker_codes",
2310 ],
2311 ));
2312 }
2313 if !readiness.operations.evidence_ready() {
2314 actions.push(next_action(
2315 "attach_operations_readiness_report",
2316 "Nowledge Mem cutover requires the embedded HawDB library to expose ready lifecycle, recovery, slow-query, background, and projection freshness status",
2317 [
2318 "operations_readiness.protocol",
2319 "operations_readiness.present",
2320 "operations_readiness.ready",
2321 "operations_readiness.graph.open",
2322 "operations_readiness.graph.read_only",
2323 "operations_readiness.search_projection.open",
2324 "operations_readiness.search_projection.stale",
2325 "operations_readiness.storage_lifecycle.ready",
2326 "operations_readiness.storage_lifecycle.action",
2327 "operations_readiness.readiness.storage_recovery_ready",
2328 "operations_readiness.readiness.slow_query_ready",
2329 "operations_readiness.readiness.background_maintenance_ready",
2330 "operations_readiness.blocker_codes",
2331 ],
2332 ));
2333 }
2334 if !readiness.background_maintenance.evidence_ready() {
2335 actions.push(next_action(
2336 "attach_background_maintenance_report",
2337 "background maintenance QoS and search-projection graph-delta evidence must be ready before Mem cutover",
2338 [
2339 "replacement_summary.cutover_evidence.background_maintenance_required",
2340 "replacement_summary.cutover_evidence.background_maintenance_ready",
2341 "replacement_summary.cutover_evidence.background_maintenance_protocol_matches",
2342 "replacement_summary.cutover_evidence.background_maintenance_executable_search_projection_graph_delta_count",
2343 "replacement_summary.cutover_evidence.background_maintenance_admitted_search_projection_graph_delta_count",
2344 "replacement_summary.cutover_evidence.background_maintenance_deferred_search_projection_graph_delta_count",
2345 "replacement_summary.cutover_evidence.background_maintenance_rejected_search_projection_graph_delta_count",
2346 "replacement_summary.cutover_evidence.background_maintenance_executable_search_projection_graph_delta_operations",
2347 "replacement_summary.cutover_evidence.background_maintenance_admitted_search_projection_graph_delta_operations",
2348 "replacement_summary.cutover_evidence.background_maintenance_max_search_projection_graph_delta_complete_through_graph_commit_epoch",
2349 "replacement_summary.cutover_evidence.background_maintenance_foreground_admission_probe_ready",
2350 "replacement_summary.cutover_evidence.background_maintenance_memory_pressure_ready",
2351 "replacement_summary.cutover_evidence.background_maintenance_memory_budget_bytes",
2352 "replacement_summary.cutover_evidence.background_maintenance_estimated_memory_bytes",
2353 "replacement_summary.cutover_evidence.background_maintenance_blocker_codes",
2354 ],
2355 ));
2356 }
2357 actions
2358}
2359
2360fn next_action(
2361 action: &str,
2362 reason: &str,
2363 evidence_fields: impl IntoIterator<Item = &'static str>,
2364) -> IntegrationNextAction {
2365 IntegrationNextAction {
2366 action: action.to_string(),
2367 reason: reason.to_string(),
2368 evidence_fields: evidence_fields.into_iter().map(str::to_string).collect(),
2369 }
2370}
2371
2372fn read_json_file(path: &Path) -> Result<serde_json::Value> {
2373 let raw = std::fs::read_to_string(path).map_err(|_| {
2374 HawDBError::Execution(
2375 "failed to read Nowledge Mem integration bundle: io_error".to_string(),
2376 )
2377 })?;
2378 serde_json::from_str(&raw).map_err(|_| {
2379 HawDBError::Execution(
2380 "failed to parse Nowledge Mem integration bundle: invalid_json".to_string(),
2381 )
2382 })
2383}
2384
2385pub fn integration_bundle_protocol_cutover_readiness(
2386 bundle: &serde_json::Value,
2387) -> IntegrationBundleProtocolCutoverReadiness {
2388 IntegrationBundleProtocolCutoverReadiness {
2389 protocol_matches: str_path(bundle, &["protocol"])
2390 == Some(HAWDB_INTEGRATION_BUNDLE_PROTOCOL),
2391 }
2392}
2393
2394pub fn replacement_summary_protocol_cutover_readiness(
2395 bundle: &serde_json::Value,
2396) -> ReplacementSummaryProtocolCutoverReadiness {
2397 ReplacementSummaryProtocolCutoverReadiness {
2398 protocol_matches: str_path(bundle, &["replacement_summary", "protocol"])
2399 == Some(HAWDB_NOWLEDGE_REPLACEMENT_SUMMARY_PROTOCOL),
2400 graph_layer_replacement_scope_ready: replacement_boundary_matches(
2401 bundle,
2402 "graph_layer",
2403 GRAPH_LAYER_REPLACEMENT_SCOPE,
2404 "primary_replacement",
2405 ),
2406 search_projection_replacement_scope_ready: replacement_boundary_matches(
2407 bundle,
2408 "search_projection",
2409 SEARCH_PROJECTION_REPLACEMENT_SCOPE,
2410 "rebuildable_projection",
2411 ),
2412 content_store_out_of_scope: replacement_boundary_matches(
2413 bundle,
2414 "content_store",
2415 SQLITE_CONTENT_STORE_SCOPE,
2416 "external_out_of_scope",
2417 ),
2418 large_blob_store_out_of_scope: replacement_boundary_matches(
2419 bundle,
2420 "large_blob_store",
2421 LARGE_BLOB_VALUE_STORE_SCOPE,
2422 "external_out_of_scope",
2423 ),
2424 }
2425}
2426
2427fn replacement_boundary_matches(
2428 bundle: &serde_json::Value,
2429 boundary: &str,
2430 scope: &str,
2431 replacement_role: &str,
2432) -> bool {
2433 str_path(
2434 bundle,
2435 &[
2436 "replacement_summary",
2437 "replacement_boundaries",
2438 boundary,
2439 "scope",
2440 ],
2441 ) == Some(scope)
2442 && str_path(
2443 bundle,
2444 &[
2445 "replacement_summary",
2446 "replacement_boundaries",
2447 boundary,
2448 "replacement_role",
2449 ],
2450 ) == Some(replacement_role)
2451}
2452
2453pub fn hawdb_submodule_cutover_readiness(
2454 bundle: &serde_json::Value,
2455) -> HawDBSubmoduleCutoverReadiness {
2456 HawDBSubmoduleCutoverReadiness {
2457 present: bool_path(bundle, &["submodule", "present"]) == Some(true),
2458 path_present: non_empty_str_path(bundle, &["submodule", "path"]),
2459 commit_present: non_empty_str_path(bundle, &["submodule", "commit"]),
2460 blocker_codes: blocker_codes(bundle, &[&["submodule", "blocker_codes"][..]]),
2461 }
2462}
2463
2464pub fn legacy_coexistence_cutover_readiness(
2465 bundle: &serde_json::Value,
2466) -> LegacyCoexistenceCutoverReadiness {
2467 LegacyCoexistenceCutoverReadiness {
2468 old_database_retained: bool_path(bundle, &["coexistence", "old_database_retained"])
2469 == Some(true),
2470 mode_safe: coexistence_mode_is_safe(bundle),
2471 old_database_not_deleted: bool_path(bundle, &["coexistence", "old_database_deleted"])
2472 != Some(true),
2473 blocker_codes: blocker_codes(bundle, &[&["coexistence", "blocker_codes"][..]]),
2474 }
2475}
2476
2477pub fn content_store_boundary_cutover_readiness(
2478 bundle: &serde_json::Value,
2479) -> ContentStoreBoundaryCutoverReadiness {
2480 ContentStoreBoundaryCutoverReadiness {
2481 present: bool_path(bundle, &["content_store", "present"]) == Some(true),
2482 engine_sqlite: str_path(bundle, &["content_store", "engine"]) == Some("sqlite"),
2483 messages_available: bool_path(bundle, &["content_store", "messages_available"])
2484 == Some(true),
2485 source_chunks_available: bool_path(bundle, &["content_store", "source_chunks_available"])
2486 == Some(true),
2487 blocker_codes: blocker_codes(bundle, &[&["content_store", "blocker_codes"][..]]),
2488 }
2489}
2490
2491pub fn previous_wrapper_preflight_cutover_readiness(
2492 bundle: &serde_json::Value,
2493) -> PreviousWrapperPreflightCutoverReadiness {
2494 PreviousWrapperPreflightCutoverReadiness {
2495 ready: bool_path(bundle, &["previous_wrapper_preflight", "ready"]) == Some(true),
2496 blocker_codes: blocker_codes(
2497 bundle,
2498 &[
2499 &["previous_wrapper_preflight", "blocker_codes"][..],
2500 &["previous_wrapper_preflight", "failed_checks"][..],
2501 ],
2502 ),
2503 }
2504}
2505
2506pub fn route_ownership_cutover_readiness(
2507 bundle: &serde_json::Value,
2508) -> RouteOwnershipCutoverReadiness {
2509 let route_ownership =
2510 json_get_path(bundle, &["route_ownership"]).unwrap_or(&serde_json::Value::Null);
2511 let route_count_summary = route_ownership_count_summary(route_ownership);
2512 let search_route_hawdb_owned =
2513 route_ownership_hawdb_route_present(route_ownership, SEARCH_ROUTE);
2514 let search_route_projection_evidence_present =
2515 !search_route_hawdb_owned || search_projection_replacement_evidence_present(bundle);
2516 RouteOwnershipCutoverReadiness {
2517 protocol_matches: str_path(bundle, &["route_ownership", "protocol"])
2518 == Some(ROUTE_OWNERSHIP_PROTOCOL),
2519 ready: bool_path(bundle, &["route_ownership", "ready"]) == Some(true),
2520 production_cutover_ready: bool_path(
2521 bundle,
2522 &["route_ownership", "production_cutover_ready"],
2523 ) == Some(true),
2524 require_all_hawdb: bool_path(bundle, &["route_ownership", "require_all_hawdb"])
2525 == Some(true),
2526 required_route_count_matches: u64_path(
2527 bundle,
2528 &["route_ownership", "required_route_count"],
2529 ) == Some(REQUIRED_BOUNDED_READ_ROUTES.len() as u64),
2530 explicit_route_count_matches: u64_path(
2531 bundle,
2532 &["route_ownership", "explicit_route_count"],
2533 ) == Some(REQUIRED_BOUNDED_READ_ROUTES.len() as u64)
2534 && route_count_summary.explicit_required_route_count
2535 == REQUIRED_BOUNDED_READ_ROUTES.len(),
2536 hawdb_route_count_matches: u64_path(bundle, &["route_ownership", "hawdb_route_count"])
2537 == Some(REQUIRED_BOUNDED_READ_ROUTES.len() as u64)
2538 && route_count_summary.hawdb_route_count == REQUIRED_BOUNDED_READ_ROUTES.len(),
2539 legacy_route_count_zero: u64_path(bundle, &["route_ownership", "legacy_route_count"])
2540 == Some(0)
2541 && route_count_summary.legacy_route_count == 0,
2542 missing_required_routes_empty: string_array_path(
2543 bundle,
2544 &["route_ownership", "missing_required_routes"],
2545 )
2546 .is_empty(),
2547 unknown_routes_empty: string_array_path(bundle, &["route_ownership", "unknown_routes"])
2548 .is_empty(),
2549 duplicate_routes_empty: string_array_path(bundle, &["route_ownership", "duplicate_routes"])
2550 .is_empty(),
2551 conflicting_routes_empty: string_array_path(
2552 bundle,
2553 &["route_ownership", "conflicting_routes"],
2554 )
2555 .is_empty(),
2556 hawdb_not_ready_routes_empty: string_array_path(
2557 bundle,
2558 &["route_ownership", "hawdb_not_ready_routes"],
2559 )
2560 .is_empty(),
2561 route_readiness_present: bool_path(bundle, &["route_ownership", "route_readiness_present"])
2562 == Some(true),
2563 route_readiness_ready: bool_path(bundle, &["route_ownership", "route_readiness_ready"])
2564 == Some(true),
2565 search_route_projection_evidence_present,
2566 route_catalog_version_matches: str_path(
2567 bundle,
2568 &["route_ownership", "route_catalog_version"],
2569 ) == Some(GRAPH_READ_ROUTE_CATALOG_VERSION),
2570 route_catalog_digest_matches: str_path(
2571 bundle,
2572 &["route_ownership", "route_catalog_digest"],
2573 ) == Some(graph_read_route_catalog_digest().as_str()),
2574 blocker_codes_empty: string_array_path(bundle, &["route_ownership", "blocker_codes"])
2575 .is_empty(),
2576 blocker_codes: blocker_codes(bundle, &[&["route_ownership", "blocker_codes"][..]]),
2577 }
2578}
2579
2580fn route_ownership_hawdb_route_present(route_ownership: &serde_json::Value, route: &str) -> bool {
2581 route_ownership
2582 .get("routes")
2583 .and_then(serde_json::Value::as_array)
2584 .is_some_and(|routes| {
2585 routes.iter().any(|entry| {
2586 str_path(entry, &["route"]) == Some(route)
2587 && str_path(entry, &["read_engine"]) == Some("hawdb")
2588 })
2589 })
2590}
2591
2592fn search_projection_replacement_evidence_present(bundle: &serde_json::Value) -> bool {
2593 json_get_path(
2594 bundle,
2595 &["replacement_summary", "search_projection_evidence"],
2596 )
2597 .is_some()
2598 && json_get_path(
2599 bundle,
2600 &["replacement_summary", "search_projection_shadow_evidence"],
2601 )
2602 .is_some()
2603}
2604
2605pub fn search_route_ownership_alignment_cutover_readiness(
2606 bundle: &serde_json::Value,
2607 field: &'static str,
2608) -> SearchRouteOwnershipAlignmentCutoverReadiness {
2609 SearchRouteOwnershipAlignmentCutoverReadiness {
2610 ready: search_route_ownership_alignment_bool(bundle, field, "ready"),
2611 evidence_ready: search_route_ownership_alignment_bool(bundle, field, "evidence_present"),
2612 summary_ready: search_route_ownership_alignment_bool(bundle, field, "summary_present"),
2613 protocol_matches: search_route_ownership_alignment_bool(bundle, field, "protocol_matches"),
2614 readiness_matches: search_route_ownership_alignment_bool(bundle, field, "ready_matches"),
2615 production_cutover_ready_matches: search_route_ownership_alignment_bool(
2616 bundle,
2617 field,
2618 "production_cutover_ready_matches",
2619 ),
2620 require_all_hawdb_matches: search_route_ownership_alignment_bool(
2621 bundle,
2622 field,
2623 "require_all_hawdb_matches",
2624 ),
2625 required_route_count_matches: search_route_ownership_alignment_bool(
2626 bundle,
2627 field,
2628 "required_route_count_matches",
2629 ),
2630 explicit_route_count_matches: search_route_ownership_alignment_bool(
2631 bundle,
2632 field,
2633 "explicit_route_count_matches",
2634 ),
2635 hawdb_route_count_matches: search_route_ownership_alignment_bool(
2636 bundle,
2637 field,
2638 "hawdb_route_count_matches",
2639 ),
2640 lancedb_route_count_matches: search_route_ownership_alignment_bool(
2641 bundle,
2642 field,
2643 "lancedb_route_count_matches",
2644 ),
2645 missing_required_routes_matches: search_route_ownership_alignment_bool(
2646 bundle,
2647 field,
2648 "missing_required_routes_matches",
2649 ),
2650 lancedb_routes_matches: search_route_ownership_alignment_bool(
2651 bundle,
2652 field,
2653 "lancedb_routes_matches",
2654 ),
2655 blocker_codes_match: search_route_ownership_alignment_bool(
2656 bundle,
2657 field,
2658 "blocker_codes_match",
2659 ),
2660 blocker_codes: blocker_codes(bundle, &[&[field, "blocker_codes"][..]]),
2661 }
2662}
2663
2664fn search_route_ownership_alignment_bool(
2665 bundle: &serde_json::Value,
2666 field: &'static str,
2667 property: &'static str,
2668) -> bool {
2669 bool_path(bundle, &[field, property]) == Some(true)
2670}
2671
2672fn search_route_ownership_alignment_cutover_conditions(
2673 readiness: &SearchRouteOwnershipAlignmentCutoverReadiness,
2674 field: &'static str,
2675) -> Vec<(&'static str, bool)> {
2676 let fields = search_route_ownership_alignment_condition_fields(field);
2677 vec![
2678 (fields.ready, readiness.ready),
2679 (fields.evidence_ready, readiness.evidence_ready),
2680 (fields.summary_ready, readiness.summary_ready),
2681 (fields.protocol_matches, readiness.protocol_matches),
2682 (fields.readiness_matches, readiness.readiness_matches),
2683 (
2684 fields.production_cutover_ready_matches,
2685 readiness.production_cutover_ready_matches,
2686 ),
2687 (
2688 fields.require_all_hawdb_matches,
2689 readiness.require_all_hawdb_matches,
2690 ),
2691 (
2692 fields.required_route_count_matches,
2693 readiness.required_route_count_matches,
2694 ),
2695 (
2696 fields.explicit_route_count_matches,
2697 readiness.explicit_route_count_matches,
2698 ),
2699 (
2700 fields.hawdb_route_count_matches,
2701 readiness.hawdb_route_count_matches,
2702 ),
2703 (
2704 fields.lancedb_route_count_matches,
2705 readiness.lancedb_route_count_matches,
2706 ),
2707 (
2708 fields.missing_required_routes_matches,
2709 readiness.missing_required_routes_matches,
2710 ),
2711 (
2712 fields.lancedb_routes_matches,
2713 readiness.lancedb_routes_matches,
2714 ),
2715 (fields.blocker_codes_match, readiness.blocker_codes_match),
2716 ]
2717}
2718
2719struct SearchRouteOwnershipAlignmentConditionFields {
2720 ready: &'static str,
2721 evidence_ready: &'static str,
2722 summary_ready: &'static str,
2723 protocol_matches: &'static str,
2724 readiness_matches: &'static str,
2725 production_cutover_ready_matches: &'static str,
2726 require_all_hawdb_matches: &'static str,
2727 required_route_count_matches: &'static str,
2728 explicit_route_count_matches: &'static str,
2729 hawdb_route_count_matches: &'static str,
2730 lancedb_route_count_matches: &'static str,
2731 missing_required_routes_matches: &'static str,
2732 lancedb_routes_matches: &'static str,
2733 blocker_codes_match: &'static str,
2734}
2735
2736fn search_route_ownership_alignment_condition_fields(
2737 field: &'static str,
2738) -> SearchRouteOwnershipAlignmentConditionFields {
2739 match field {
2740 "replacement_summary_search_route_ownership_alignment" => {
2741 SearchRouteOwnershipAlignmentConditionFields {
2742 ready: "replacement_summary_search_route_ownership_alignment.ready",
2743 evidence_ready: "replacement_summary_search_route_ownership_alignment.evidence_present",
2744 summary_ready: "replacement_summary_search_route_ownership_alignment.summary_present",
2745 protocol_matches: "replacement_summary_search_route_ownership_alignment.protocol_matches",
2746 readiness_matches: "replacement_summary_search_route_ownership_alignment.ready_matches",
2747 production_cutover_ready_matches: "replacement_summary_search_route_ownership_alignment.production_cutover_ready_matches",
2748 require_all_hawdb_matches: "replacement_summary_search_route_ownership_alignment.require_all_hawdb_matches",
2749 required_route_count_matches: "replacement_summary_search_route_ownership_alignment.required_route_count_matches",
2750 explicit_route_count_matches: "replacement_summary_search_route_ownership_alignment.explicit_route_count_matches",
2751 hawdb_route_count_matches: "replacement_summary_search_route_ownership_alignment.hawdb_route_count_matches",
2752 lancedb_route_count_matches: "replacement_summary_search_route_ownership_alignment.lancedb_route_count_matches",
2753 missing_required_routes_matches: "replacement_summary_search_route_ownership_alignment.missing_required_routes_matches",
2754 lancedb_routes_matches: "replacement_summary_search_route_ownership_alignment.lancedb_routes_matches",
2755 blocker_codes_match: "replacement_summary_search_route_ownership_alignment.blocker_codes_match",
2756 }
2757 }
2758 "replacement_summary_active_search_route_ownership_alignment" => {
2759 SearchRouteOwnershipAlignmentConditionFields {
2760 ready: "replacement_summary_active_search_route_ownership_alignment.ready",
2761 evidence_ready: "replacement_summary_active_search_route_ownership_alignment.evidence_present",
2762 summary_ready: "replacement_summary_active_search_route_ownership_alignment.summary_present",
2763 protocol_matches: "replacement_summary_active_search_route_ownership_alignment.protocol_matches",
2764 readiness_matches: "replacement_summary_active_search_route_ownership_alignment.ready_matches",
2765 production_cutover_ready_matches: "replacement_summary_active_search_route_ownership_alignment.production_cutover_ready_matches",
2766 require_all_hawdb_matches: "replacement_summary_active_search_route_ownership_alignment.require_all_hawdb_matches",
2767 required_route_count_matches: "replacement_summary_active_search_route_ownership_alignment.required_route_count_matches",
2768 explicit_route_count_matches: "replacement_summary_active_search_route_ownership_alignment.explicit_route_count_matches",
2769 hawdb_route_count_matches: "replacement_summary_active_search_route_ownership_alignment.hawdb_route_count_matches",
2770 lancedb_route_count_matches: "replacement_summary_active_search_route_ownership_alignment.lancedb_route_count_matches",
2771 missing_required_routes_matches: "replacement_summary_active_search_route_ownership_alignment.missing_required_routes_matches",
2772 lancedb_routes_matches: "replacement_summary_active_search_route_ownership_alignment.lancedb_routes_matches",
2773 blocker_codes_match: "replacement_summary_active_search_route_ownership_alignment.blocker_codes_match",
2774 }
2775 }
2776 _ => SearchRouteOwnershipAlignmentConditionFields {
2777 ready: "unknown_search_route_ownership_alignment.ready",
2778 evidence_ready: "unknown_search_route_ownership_alignment.evidence_present",
2779 summary_ready: "unknown_search_route_ownership_alignment.summary_present",
2780 protocol_matches: "unknown_search_route_ownership_alignment.protocol_matches",
2781 readiness_matches: "unknown_search_route_ownership_alignment.ready_matches",
2782 production_cutover_ready_matches:
2783 "unknown_search_route_ownership_alignment.production_cutover_ready_matches",
2784 require_all_hawdb_matches:
2785 "unknown_search_route_ownership_alignment.require_all_hawdb_matches",
2786 required_route_count_matches:
2787 "unknown_search_route_ownership_alignment.required_route_count_matches",
2788 explicit_route_count_matches:
2789 "unknown_search_route_ownership_alignment.explicit_route_count_matches",
2790 hawdb_route_count_matches:
2791 "unknown_search_route_ownership_alignment.hawdb_route_count_matches",
2792 lancedb_route_count_matches:
2793 "unknown_search_route_ownership_alignment.lancedb_route_count_matches",
2794 missing_required_routes_matches:
2795 "unknown_search_route_ownership_alignment.missing_required_routes_matches",
2796 lancedb_routes_matches: "unknown_search_route_ownership_alignment.lancedb_routes_matches",
2797 blocker_codes_match: "unknown_search_route_ownership_alignment.blocker_codes_match",
2798 },
2799 }
2800}
2801
2802pub fn active_search_route_readiness_alignment_cutover_readiness(
2803 bundle: &serde_json::Value,
2804) -> ActiveSearchRouteReadinessAlignmentCutoverReadiness {
2805 const FIELD: &str = "replacement_summary_active_search_route_readiness_alignment";
2806 ActiveSearchRouteReadinessAlignmentCutoverReadiness {
2807 ready: bool_path(bundle, &[FIELD, "ready"]) == Some(true),
2808 evidence_ready: bool_path(bundle, &[FIELD, "evidence_present"]) == Some(true),
2809 summary_ready: bool_path(bundle, &[FIELD, "summary_present"]) == Some(true),
2810 protocol_matches: bool_path(bundle, &[FIELD, "protocol_matches"]) == Some(true),
2811 readiness_matches: bool_path(bundle, &[FIELD, "ready_matches"]) == Some(true),
2812 production_cutover_ready_matches: bool_path(
2813 bundle,
2814 &[FIELD, "production_cutover_ready_matches"],
2815 ) == Some(true),
2816 require_all_hawdb_matches: bool_path(bundle, &[FIELD, "require_all_hawdb_matches"])
2817 == Some(true),
2818 required_route_count_matches: bool_path(bundle, &[FIELD, "required_route_count_matches"])
2819 == Some(true),
2820 evidence_route_count_matches: bool_path(bundle, &[FIELD, "evidence_route_count_matches"])
2821 == Some(true),
2822 ready_route_count_matches: bool_path(bundle, &[FIELD, "ready_route_count_matches"])
2823 == Some(true),
2824 hawdb_route_count_matches: bool_path(bundle, &[FIELD, "hawdb_route_count_matches"])
2825 == Some(true),
2826 lancedb_handle_count_matches: bool_path(bundle, &[FIELD, "lancedb_handle_count_matches"])
2827 == Some(true),
2828 missing_required_routes_matches: bool_path(
2829 bundle,
2830 &[FIELD, "missing_required_routes_matches"],
2831 ) == Some(true),
2832 non_hawdb_routes_matches: bool_path(bundle, &[FIELD, "non_hawdb_routes_matches"])
2833 == Some(true),
2834 lancedb_handle_routes_matches: bool_path(bundle, &[FIELD, "lancedb_handle_routes_matches"])
2835 == Some(true),
2836 candidate_not_ready_routes_matches: bool_path(
2837 bundle,
2838 &[FIELD, "candidate_not_ready_routes_matches"],
2839 ) == Some(true),
2840 candidate_identity_not_ready_routes_matches: bool_path(
2841 bundle,
2842 &[FIELD, "candidate_identity_not_ready_routes_matches"],
2843 ) == Some(true),
2844 embedding_identity_not_ready_routes_matches: bool_path(
2845 bundle,
2846 &[FIELD, "embedding_identity_not_ready_routes_matches"],
2847 ) == Some(true),
2848 zero_vector_semantics_not_ready_routes_matches: bool_path(
2849 bundle,
2850 &[FIELD, "zero_vector_semantics_not_ready_routes_matches"],
2851 ) == Some(true),
2852 cjk_tokenization_not_ready_routes_matches: bool_path(
2853 bundle,
2854 &[FIELD, "cjk_tokenization_not_ready_routes_matches"],
2855 ) == Some(true),
2856 metadata_pushdown_not_ready_routes_matches: bool_path(
2857 bundle,
2858 &[FIELD, "metadata_pushdown_not_ready_routes_matches"],
2859 ) == Some(true),
2860 ranking_window_not_ready_routes_matches: bool_path(
2861 bundle,
2862 &[FIELD, "ranking_window_not_ready_routes_matches"],
2863 ) == Some(true),
2864 ranking_not_ready_routes_matches: bool_path(
2865 bundle,
2866 &[FIELD, "ranking_not_ready_routes_matches"],
2867 ) == Some(true),
2868 fail_soft_not_ready_routes_matches: bool_path(
2869 bundle,
2870 &[FIELD, "fail_soft_not_ready_routes_matches"],
2871 ) == Some(true),
2872 fail_soft_reason_codes_not_ready_routes_matches: bool_path(
2873 bundle,
2874 &[FIELD, "fail_soft_reason_codes_not_ready_routes_matches"],
2875 ) == Some(true),
2876 repair_rebuild_markers_not_ready_routes_matches: bool_path(
2877 bundle,
2878 &[FIELD, "repair_rebuild_markers_not_ready_routes_matches"],
2879 ) == Some(true),
2880 blocker_codes_match: bool_path(bundle, &[FIELD, "blocker_codes_match"]) == Some(true),
2881 blocker_codes: blocker_codes(bundle, &[&[FIELD, "blocker_codes"][..]]),
2882 }
2883}
2884
2885fn active_search_route_readiness_alignment_cutover_conditions(
2886 readiness: &ActiveSearchRouteReadinessAlignmentCutoverReadiness,
2887) -> Vec<(&'static str, bool)> {
2888 vec![
2889 (
2890 "replacement_summary_active_search_route_readiness_alignment.ready",
2891 readiness.ready,
2892 ),
2893 (
2894 "replacement_summary_active_search_route_readiness_alignment.evidence_present",
2895 readiness.evidence_ready,
2896 ),
2897 (
2898 "replacement_summary_active_search_route_readiness_alignment.summary_present",
2899 readiness.summary_ready,
2900 ),
2901 (
2902 "replacement_summary_active_search_route_readiness_alignment.protocol_matches",
2903 readiness.protocol_matches,
2904 ),
2905 (
2906 "replacement_summary_active_search_route_readiness_alignment.ready_matches",
2907 readiness.readiness_matches,
2908 ),
2909 (
2910 "replacement_summary_active_search_route_readiness_alignment.production_cutover_ready_matches",
2911 readiness.production_cutover_ready_matches,
2912 ),
2913 (
2914 "replacement_summary_active_search_route_readiness_alignment.require_all_hawdb_matches",
2915 readiness.require_all_hawdb_matches,
2916 ),
2917 (
2918 "replacement_summary_active_search_route_readiness_alignment.required_route_count_matches",
2919 readiness.required_route_count_matches,
2920 ),
2921 (
2922 "replacement_summary_active_search_route_readiness_alignment.evidence_route_count_matches",
2923 readiness.evidence_route_count_matches,
2924 ),
2925 (
2926 "replacement_summary_active_search_route_readiness_alignment.ready_route_count_matches",
2927 readiness.ready_route_count_matches,
2928 ),
2929 (
2930 "replacement_summary_active_search_route_readiness_alignment.hawdb_route_count_matches",
2931 readiness.hawdb_route_count_matches,
2932 ),
2933 (
2934 "replacement_summary_active_search_route_readiness_alignment.lancedb_handle_count_matches",
2935 readiness.lancedb_handle_count_matches,
2936 ),
2937 (
2938 "replacement_summary_active_search_route_readiness_alignment.missing_required_routes_matches",
2939 readiness.missing_required_routes_matches,
2940 ),
2941 (
2942 "replacement_summary_active_search_route_readiness_alignment.non_hawdb_routes_matches",
2943 readiness.non_hawdb_routes_matches,
2944 ),
2945 (
2946 "replacement_summary_active_search_route_readiness_alignment.lancedb_handle_routes_matches",
2947 readiness.lancedb_handle_routes_matches,
2948 ),
2949 (
2950 "replacement_summary_active_search_route_readiness_alignment.candidate_not_ready_routes_matches",
2951 readiness.candidate_not_ready_routes_matches,
2952 ),
2953 (
2954 "replacement_summary_active_search_route_readiness_alignment.candidate_identity_not_ready_routes_matches",
2955 readiness.candidate_identity_not_ready_routes_matches,
2956 ),
2957 (
2958 "replacement_summary_active_search_route_readiness_alignment.embedding_identity_not_ready_routes_matches",
2959 readiness.embedding_identity_not_ready_routes_matches,
2960 ),
2961 (
2962 "replacement_summary_active_search_route_readiness_alignment.zero_vector_semantics_not_ready_routes_matches",
2963 readiness.zero_vector_semantics_not_ready_routes_matches,
2964 ),
2965 (
2966 "replacement_summary_active_search_route_readiness_alignment.cjk_tokenization_not_ready_routes_matches",
2967 readiness.cjk_tokenization_not_ready_routes_matches,
2968 ),
2969 (
2970 "replacement_summary_active_search_route_readiness_alignment.metadata_pushdown_not_ready_routes_matches",
2971 readiness.metadata_pushdown_not_ready_routes_matches,
2972 ),
2973 (
2974 "replacement_summary_active_search_route_readiness_alignment.ranking_window_not_ready_routes_matches",
2975 readiness.ranking_window_not_ready_routes_matches,
2976 ),
2977 (
2978 "replacement_summary_active_search_route_readiness_alignment.ranking_not_ready_routes_matches",
2979 readiness.ranking_not_ready_routes_matches,
2980 ),
2981 (
2982 "replacement_summary_active_search_route_readiness_alignment.fail_soft_not_ready_routes_matches",
2983 readiness.fail_soft_not_ready_routes_matches,
2984 ),
2985 (
2986 "replacement_summary_active_search_route_readiness_alignment.fail_soft_reason_codes_not_ready_routes_matches",
2987 readiness.fail_soft_reason_codes_not_ready_routes_matches,
2988 ),
2989 (
2990 "replacement_summary_active_search_route_readiness_alignment.repair_rebuild_markers_not_ready_routes_matches",
2991 readiness.repair_rebuild_markers_not_ready_routes_matches,
2992 ),
2993 (
2994 "replacement_summary_active_search_route_readiness_alignment.blocker_codes_match",
2995 readiness.blocker_codes_match,
2996 ),
2997 ]
2998}
2999
3000#[derive(Debug, Default)]
3001struct RouteOwnershipCountSummary {
3002 explicit_required_route_count: usize,
3003 hawdb_route_count: usize,
3004 legacy_route_count: usize,
3005}
3006
3007fn route_ownership_count_summary(value: &serde_json::Value) -> RouteOwnershipCountSummary {
3008 let Some(routes) = value.get("routes").and_then(serde_json::Value::as_array) else {
3009 return RouteOwnershipCountSummary::default();
3010 };
3011 let required_routes = REQUIRED_BOUNDED_READ_ROUTES
3012 .iter()
3013 .copied()
3014 .collect::<BTreeSet<_>>();
3015 let mut explicit_required_routes = BTreeSet::new();
3016 let mut hawdb_routes = BTreeSet::new();
3017 let mut legacy_routes = BTreeSet::new();
3018 for route in routes {
3019 let Some(route_name) = str_path(route, &["route"]) else {
3020 continue;
3021 };
3022 if required_routes.contains(route_name) {
3023 explicit_required_routes.insert(route_name);
3024 }
3025 match str_path(route, &["read_engine"]) {
3026 Some("hawdb") if required_routes.contains(route_name) => {
3027 hawdb_routes.insert(route_name);
3028 }
3029 Some("legacy") if required_routes.contains(route_name) => {
3030 legacy_routes.insert(route_name);
3031 }
3032 _ => {}
3033 }
3034 }
3035 RouteOwnershipCountSummary {
3036 explicit_required_route_count: explicit_required_routes.len(),
3037 hawdb_route_count: hawdb_routes.len(),
3038 legacy_route_count: legacy_routes.len(),
3039 }
3040}
3041
3042fn coexistence_mode_is_safe(bundle: &serde_json::Value) -> bool {
3043 matches!(
3044 str_path(bundle, &["coexistence", "mode"]),
3045 Some("shadow") | Some("side_by_side")
3046 )
3047}
3048
3049fn blocker_codes(value: &serde_json::Value, paths: &[&[&str]]) -> Vec<String> {
3050 paths
3051 .iter()
3052 .flat_map(|path| string_array_path(value, path))
3053 .collect::<std::collections::BTreeSet<_>>()
3054 .into_iter()
3055 .collect()
3056}
3057
3058fn replacement_summary_required_query_families_present(bundle: &serde_json::Value) -> bool {
3059 let families = string_array_path(
3060 bundle,
3061 &[
3062 "replacement_summary",
3063 "replacement_readiness_family_summary",
3064 "required_query_families",
3065 ],
3066 );
3067 REQUIRED_NOWLEDGE_REPLACEMENT_QUERY_FAMILIES
3068 .iter()
3069 .all(|required| families.iter().any(|family| family == required))
3070}
3071
3072pub fn graph_replacement_cutover_readiness(
3073 bundle: &serde_json::Value,
3074) -> GraphReplacementCutoverReadiness {
3075 GraphReplacementCutoverReadiness {
3076 production_cutover_ready: bool_path(
3077 bundle,
3078 &["replacement_summary", "production_cutover_ready"],
3079 ) == Some(true),
3080 shadow_evidence_ready: bool_path(
3081 bundle,
3082 &["replacement_summary", "shadow_evidence", "ready"],
3083 ) == Some(true),
3084 dual_engine_evidence_present: bool_path(
3085 bundle,
3086 &["replacement_summary", "dual_engine_evidence", "present"],
3087 ) == Some(true),
3088 dual_engine_evidence_ready: bool_path(
3089 bundle,
3090 &["replacement_summary", "dual_engine_evidence", "ready"],
3091 ) == Some(true),
3092 dual_engine_evidence_consistent: bool_path(
3093 bundle,
3094 &["replacement_summary", "dual_engine_evidence", "consistent"],
3095 ) == Some(true),
3096 source_mutation_protocol_matches: str_path(
3097 bundle,
3098 &[
3099 "replacement_summary",
3100 "source_mutation_dual_write_readiness",
3101 "protocol",
3102 ],
3103 ) == Some(SOURCE_MUTATION_DUAL_WRITE_READINESS_PROTOCOL),
3104 source_mutation_ready: bool_path(
3105 bundle,
3106 &[
3107 "replacement_summary",
3108 "source_mutation_dual_write_readiness",
3109 "ready",
3110 ],
3111 ) == Some(true),
3112 source_mutation_required_family_count_matches: u64_path(
3113 bundle,
3114 &[
3115 "replacement_summary",
3116 "source_mutation_dual_write_readiness",
3117 "required_family_count",
3118 ],
3119 ) == Some(
3120 REQUIRED_SOURCE_MUTATION_FAMILIES.len() as u64,
3121 ),
3122 source_mutation_evidence_family_count_matches: u64_path(
3123 bundle,
3124 &[
3125 "replacement_summary",
3126 "source_mutation_dual_write_readiness",
3127 "evidence_family_count",
3128 ],
3129 ) == Some(
3130 REQUIRED_SOURCE_MUTATION_FAMILIES.len() as u64,
3131 ),
3132 source_mutation_ready_family_count_matches: u64_path(
3133 bundle,
3134 &[
3135 "replacement_summary",
3136 "source_mutation_dual_write_readiness",
3137 "ready_family_count",
3138 ],
3139 ) == Some(
3140 REQUIRED_SOURCE_MUTATION_FAMILIES.len() as u64,
3141 ),
3142 source_mutation_missing_required_families_empty: string_array_path(
3143 bundle,
3144 &[
3145 "replacement_summary",
3146 "source_mutation_dual_write_readiness",
3147 "missing_required_families",
3148 ],
3149 )
3150 .is_empty(),
3151 source_mutation_blocker_codes_empty: string_array_path(
3152 bundle,
3153 &[
3154 "replacement_summary",
3155 "source_mutation_dual_write_readiness",
3156 "blocker_codes",
3157 ],
3158 )
3159 .is_empty(),
3160 blocker_codes: blocker_codes(
3161 bundle,
3162 &[
3163 &["replacement_summary", "blocking_categories"][..],
3164 &["replacement_summary", "missing_evidence"][..],
3165 &[
3166 "replacement_summary",
3167 "dual_engine_evidence",
3168 "blocker_codes",
3169 ][..],
3170 &[
3171 "replacement_summary",
3172 "source_mutation_dual_write_readiness",
3173 "blocker_codes",
3174 ][..],
3175 ],
3176 ),
3177 }
3178}
3179
3180fn graph_replacement_cutover_conditions(
3181 readiness: &GraphReplacementCutoverReadiness,
3182) -> Vec<(&'static str, bool)> {
3183 vec![
3184 (
3185 "replacement_summary.production_cutover_ready",
3186 readiness.production_cutover_ready,
3187 ),
3188 (
3189 "replacement_summary.shadow_evidence.ready",
3190 readiness.shadow_evidence_ready,
3191 ),
3192 (
3193 "replacement_summary.dual_engine_evidence.present",
3194 readiness.dual_engine_evidence_present,
3195 ),
3196 (
3197 "replacement_summary.dual_engine_evidence.ready",
3198 readiness.dual_engine_evidence_ready,
3199 ),
3200 (
3201 "replacement_summary.dual_engine_evidence.consistent",
3202 readiness.dual_engine_evidence_consistent,
3203 ),
3204 (
3205 "replacement_summary.source_mutation_dual_write_readiness.protocol",
3206 readiness.source_mutation_protocol_matches,
3207 ),
3208 (
3209 "replacement_summary.source_mutation_dual_write_readiness.ready",
3210 readiness.source_mutation_ready,
3211 ),
3212 (
3213 "replacement_summary.source_mutation_dual_write_readiness.required_family_count",
3214 readiness.source_mutation_required_family_count_matches,
3215 ),
3216 (
3217 "replacement_summary.source_mutation_dual_write_readiness.evidence_family_count",
3218 readiness.source_mutation_evidence_family_count_matches,
3219 ),
3220 (
3221 "replacement_summary.source_mutation_dual_write_readiness.ready_family_count",
3222 readiness.source_mutation_ready_family_count_matches,
3223 ),
3224 (
3225 "replacement_summary.source_mutation_dual_write_readiness.missing_required_families",
3226 readiness.source_mutation_missing_required_families_empty,
3227 ),
3228 (
3229 "replacement_summary.source_mutation_dual_write_readiness.blocker_codes",
3230 readiness.source_mutation_blocker_codes_empty,
3231 ),
3232 ]
3233}
3234
3235pub fn query_family_replacement_cutover_readiness(
3236 bundle: &serde_json::Value,
3237) -> QueryFamilyReplacementCutoverReadiness {
3238 QueryFamilyReplacementCutoverReadiness {
3239 required_query_families_present: replacement_summary_required_query_families_present(
3240 bundle,
3241 ),
3242 missing_required_query_families_empty: string_array_path(
3243 bundle,
3244 &[
3245 "replacement_summary",
3246 "replacement_readiness_family_summary",
3247 "missing_required_query_families",
3248 ],
3249 )
3250 .is_empty(),
3251 blocked_query_families_empty: string_array_path(
3252 bundle,
3253 &[
3254 "replacement_summary",
3255 "replacement_readiness_family_summary",
3256 "blocked_query_families",
3257 ],
3258 )
3259 .is_empty(),
3260 min_replacement_readiness_full: u64_path(
3261 bundle,
3262 &[
3263 "replacement_summary",
3264 "replacement_readiness_family_summary",
3265 "min_replacement_readiness_per_million",
3266 ],
3267 ) == Some(1_000_000),
3268 blocker_codes: blocker_codes(
3269 bundle,
3270 &[
3271 &["replacement_summary", "blocking_categories"][..],
3272 &["replacement_summary", "missing_evidence"][..],
3273 ],
3274 ),
3275 }
3276}
3277
3278fn query_family_replacement_cutover_conditions(
3279 readiness: &QueryFamilyReplacementCutoverReadiness,
3280) -> Vec<(&'static str, bool)> {
3281 vec![
3282 (
3283 "replacement_summary.replacement_readiness_family_summary.required_query_families",
3284 readiness.required_query_families_present,
3285 ),
3286 (
3287 "replacement_summary.replacement_readiness_family_summary.missing_required_query_families",
3288 readiness.missing_required_query_families_empty,
3289 ),
3290 (
3291 "replacement_summary.replacement_readiness_family_summary.blocked_query_families",
3292 readiness.blocked_query_families_empty,
3293 ),
3294 (
3295 "replacement_summary.replacement_readiness_family_summary.min_replacement_readiness_per_million",
3296 readiness.min_replacement_readiness_full,
3297 ),
3298 ]
3299}
3300
3301pub fn search_projection_cutover_readiness(
3302 bundle: &serde_json::Value,
3303) -> SearchProjectionCutoverReadiness {
3304 let pushdown_path = &[
3305 "replacement_summary",
3306 "search_projection_shadow_evidence",
3307 "pushdown_evidence",
3308 ];
3309 SearchProjectionCutoverReadiness {
3310 evidence_protocol_matches: str_path(
3311 bundle,
3312 &[
3313 "replacement_summary",
3314 "search_projection_evidence",
3315 "protocol",
3316 ],
3317 ) == Some(HAWDB_NOWLEDGE_SEARCH_PROJECTION_EVIDENCE_PROTOCOL),
3318 evidence_ready: bool_path(
3319 bundle,
3320 &["replacement_summary", "search_projection_evidence", "ready"],
3321 ) == Some(true),
3322 fts_ready: bool_path(
3323 bundle,
3324 &[
3325 "replacement_summary",
3326 "search_projection_evidence",
3327 "fts_ready",
3328 ],
3329 ) == Some(true),
3330 vector_ready: bool_path(
3331 bundle,
3332 &[
3333 "replacement_summary",
3334 "search_projection_evidence",
3335 "vector_ready",
3336 ],
3337 ) == Some(true),
3338 document_identity_ready: bool_path(
3339 bundle,
3340 &[
3341 "replacement_summary",
3342 "search_projection_evidence",
3343 "document_identity_ready",
3344 ],
3345 ) == Some(true),
3346 incremental_update_ready: bool_path(
3347 bundle,
3348 &[
3349 "replacement_summary",
3350 "search_projection_evidence",
3351 "incremental_update_ready",
3352 ],
3353 ) == Some(true),
3354 predicate_pushdown_ready: bool_path(
3355 bundle,
3356 &[
3357 "replacement_summary",
3358 "search_projection_evidence",
3359 "predicate_pushdown_ready",
3360 ],
3361 ) == Some(true),
3362 production_filter_pruning_ready: bool_path(
3363 bundle,
3364 &[
3365 "replacement_summary",
3366 "search_projection_evidence",
3367 "production_filter_pruning_ready",
3368 ],
3369 ) == Some(true),
3370 compressed_vector_projection_required: bool_path(
3371 bundle,
3372 &[
3373 "replacement_summary",
3374 "search_projection_evidence",
3375 "compressed_vector_projection_required",
3376 ],
3377 ) == Some(true),
3378 compressed_vector_projection_ready: bool_path(
3379 bundle,
3380 &[
3381 "replacement_summary",
3382 "search_projection_evidence",
3383 "compressed_vector_projection_ready",
3384 ],
3385 ) == Some(true),
3386 shadow_present: bool_path(
3387 bundle,
3388 &[
3389 "replacement_summary",
3390 "search_projection_shadow_evidence",
3391 "present",
3392 ],
3393 ) == Some(true),
3394 shadow_protocol_matches: str_path(
3395 bundle,
3396 &[
3397 "replacement_summary",
3398 "search_projection_shadow_evidence",
3399 "protocol",
3400 ],
3401 ) == Some(
3402 HAWDB_NOWLEDGE_SEARCH_PROJECTION_SHADOW_EVIDENCE_PROTOCOL,
3403 ),
3404 shadow_evidence_source_matches: str_path(
3405 bundle,
3406 &[
3407 "replacement_summary",
3408 "search_projection_shadow_evidence",
3409 "evidence_source",
3410 ],
3411 ) == Some(HAWDB_SEARCH_PROJECTION_SHADOW_EVIDENCE_SOURCE),
3412 shadow_ready: bool_path(
3413 bundle,
3414 &[
3415 "replacement_summary",
3416 "search_projection_shadow_evidence",
3417 "ready",
3418 ],
3419 ) == Some(true),
3420 shadow_document_count_parity: bool_path(
3421 bundle,
3422 &[
3423 "replacement_summary",
3424 "search_projection_shadow_evidence",
3425 "document_count_parity",
3426 ],
3427 ) == Some(true),
3428 shadow_document_identity_parity: bool_path(
3429 bundle,
3430 &[
3431 "replacement_summary",
3432 "search_projection_shadow_evidence",
3433 "document_identity_parity",
3434 ],
3435 ) == Some(true),
3436 shadow_table_parity_ready: bool_path(
3437 bundle,
3438 &[
3439 "replacement_summary",
3440 "search_projection_shadow_evidence",
3441 "table_parity_ready",
3442 ],
3443 ) == Some(true),
3444 shadow_embedding_identity_parity: bool_path(
3445 bundle,
3446 &[
3447 "replacement_summary",
3448 "search_projection_shadow_evidence",
3449 "embedding_identity_parity",
3450 ],
3451 ) == Some(true),
3452 shadow_incremental_watermark_parity: bool_path(
3453 bundle,
3454 &[
3455 "replacement_summary",
3456 "search_projection_shadow_evidence",
3457 "incremental_watermark_parity",
3458 ],
3459 ) == Some(true),
3460 shadow_pushdown_ready: bool_path(
3461 bundle,
3462 &[
3463 "replacement_summary",
3464 "search_projection_shadow_evidence",
3465 "pushdown_evidence",
3466 "ready",
3467 ],
3468 ) == Some(true),
3469 shadow_descriptor_scan_filter_fields_ready: bool_path(
3470 bundle,
3471 &[
3472 "replacement_summary",
3473 "search_projection_shadow_evidence",
3474 "pushdown_evidence",
3475 "shadow_segment_descriptor_scan_filter_fields_ready",
3476 ],
3477 ) == Some(true),
3478 shadow_document_pruning_ready: bool_path(
3479 bundle,
3480 &[
3481 "replacement_summary",
3482 "search_projection_shadow_evidence",
3483 "pushdown_evidence",
3484 "shadow_segment_document_pruning_ready",
3485 ],
3486 ) == Some(true),
3487 shadow_pruning_candidate_count_ready:
3488 search_projection_segment_pruning_candidate_count_ready(bundle, pushdown_path),
3489 shadow_pruned_document_count_positive: search_projection_segment_pruning_count_is_positive(
3490 bundle,
3491 pushdown_path,
3492 "shadow_segment_pruned_document_count",
3493 ),
3494 shadow_scanned_document_count_positive: search_projection_segment_pruning_count_is_positive(
3495 bundle,
3496 pushdown_path,
3497 "shadow_segment_scanned_document_count",
3498 ),
3499 primary_scan_filter_fields_ready: search_projection_scan_filter_fields_cover_required(
3500 bundle,
3501 &[
3502 "replacement_summary",
3503 "search_projection_shadow_evidence",
3504 "pushdown_evidence",
3505 "primary_scan_filter_fields",
3506 ],
3507 ),
3508 shadow_scan_filter_fields_ready: search_projection_scan_filter_fields_cover_required(
3509 bundle,
3510 &[
3511 "replacement_summary",
3512 "search_projection_shadow_evidence",
3513 "pushdown_evidence",
3514 "shadow_scan_filter_fields",
3515 ],
3516 ),
3517 shadow_descriptor_field_summaries_ready:
3518 search_projection_segment_descriptor_summaries_cover_required(
3519 bundle,
3520 &[
3521 "replacement_summary",
3522 "search_projection_shadow_evidence",
3523 "pushdown_evidence",
3524 "shadow_segment_descriptor_field_summaries",
3525 ],
3526 ),
3527 blocker_codes: blocker_codes(
3528 bundle,
3529 &[
3530 &[
3531 "replacement_summary",
3532 "search_projection_evidence",
3533 "blocker_codes",
3534 ][..],
3535 &[
3536 "replacement_summary",
3537 "search_projection_shadow_evidence",
3538 "blocker_codes",
3539 ][..],
3540 ],
3541 ),
3542 }
3543}
3544
3545fn search_projection_cutover_conditions(
3546 readiness: &SearchProjectionCutoverReadiness,
3547) -> Vec<(&'static str, bool)> {
3548 vec![
3549 (
3550 "replacement_summary.search_projection_evidence.ready",
3551 readiness.evidence_ready,
3552 ),
3553 (
3554 "replacement_summary.search_projection_evidence.protocol",
3555 readiness.evidence_protocol_matches,
3556 ),
3557 (
3558 "replacement_summary.search_projection_evidence.fts_ready",
3559 readiness.fts_ready,
3560 ),
3561 (
3562 "replacement_summary.search_projection_evidence.vector_ready",
3563 readiness.vector_ready,
3564 ),
3565 (
3566 "replacement_summary.search_projection_evidence.document_identity_ready",
3567 readiness.document_identity_ready,
3568 ),
3569 (
3570 "replacement_summary.search_projection_evidence.incremental_update_ready",
3571 readiness.incremental_update_ready,
3572 ),
3573 (
3574 "replacement_summary.search_projection_evidence.predicate_pushdown_ready",
3575 readiness.predicate_pushdown_ready,
3576 ),
3577 (
3578 "replacement_summary.search_projection_evidence.production_filter_pruning_ready",
3579 readiness.production_filter_pruning_ready,
3580 ),
3581 (
3582 "replacement_summary.search_projection_evidence.compressed_vector_projection_required",
3583 readiness.compressed_vector_projection_required,
3584 ),
3585 (
3586 "replacement_summary.search_projection_evidence.compressed_vector_projection_ready",
3587 readiness.compressed_vector_projection_ready,
3588 ),
3589 (
3590 "replacement_summary.search_projection_shadow_evidence.present",
3591 readiness.shadow_present,
3592 ),
3593 (
3594 "replacement_summary.search_projection_shadow_evidence.protocol",
3595 readiness.shadow_protocol_matches,
3596 ),
3597 (
3598 "replacement_summary.search_projection_shadow_evidence.evidence_source",
3599 readiness.shadow_evidence_source_matches,
3600 ),
3601 (
3602 "replacement_summary.search_projection_shadow_evidence.ready",
3603 readiness.shadow_ready,
3604 ),
3605 (
3606 "replacement_summary.search_projection_shadow_evidence.document_count_parity",
3607 readiness.shadow_document_count_parity,
3608 ),
3609 (
3610 "replacement_summary.search_projection_shadow_evidence.document_identity_parity",
3611 readiness.shadow_document_identity_parity,
3612 ),
3613 (
3614 "replacement_summary.search_projection_shadow_evidence.table_parity_ready",
3615 readiness.shadow_table_parity_ready,
3616 ),
3617 (
3618 "replacement_summary.search_projection_shadow_evidence.embedding_identity_parity",
3619 readiness.shadow_embedding_identity_parity,
3620 ),
3621 (
3622 "replacement_summary.search_projection_shadow_evidence.incremental_watermark_parity",
3623 readiness.shadow_incremental_watermark_parity,
3624 ),
3625 (
3626 "replacement_summary.search_projection_shadow_evidence.pushdown_evidence.ready",
3627 readiness.shadow_pushdown_ready,
3628 ),
3629 (
3630 "replacement_summary.search_projection_shadow_evidence.pushdown_evidence.shadow_segment_descriptor_scan_filter_fields_ready",
3631 readiness.shadow_descriptor_scan_filter_fields_ready,
3632 ),
3633 (
3634 "replacement_summary.search_projection_shadow_evidence.pushdown_evidence.shadow_segment_document_pruning_ready",
3635 readiness.shadow_document_pruning_ready,
3636 ),
3637 (
3638 "replacement_summary.search_projection_shadow_evidence.pushdown_evidence.shadow_segment_pruning_candidate_document_count",
3639 readiness.shadow_pruning_candidate_count_ready,
3640 ),
3641 (
3642 "replacement_summary.search_projection_shadow_evidence.pushdown_evidence.shadow_segment_pruned_document_count",
3643 readiness.shadow_pruned_document_count_positive,
3644 ),
3645 (
3646 "replacement_summary.search_projection_shadow_evidence.pushdown_evidence.shadow_segment_scanned_document_count",
3647 readiness.shadow_scanned_document_count_positive,
3648 ),
3649 (
3650 "replacement_summary.search_projection_shadow_evidence.pushdown_evidence.primary_scan_filter_fields",
3651 readiness.primary_scan_filter_fields_ready,
3652 ),
3653 (
3654 "replacement_summary.search_projection_shadow_evidence.pushdown_evidence.shadow_scan_filter_fields",
3655 readiness.shadow_scan_filter_fields_ready,
3656 ),
3657 (
3658 "replacement_summary.search_projection_shadow_evidence.pushdown_evidence.shadow_segment_descriptor_field_summaries",
3659 readiness.shadow_descriptor_field_summaries_ready,
3660 ),
3661 ]
3662}
3663
3664pub fn search_candidate_cutover_readiness(
3665 bundle: &serde_json::Value,
3666) -> SearchCandidateCutoverReadiness {
3667 SearchCandidateCutoverReadiness {
3668 protocol_matches: str_path(bundle, &["search_candidate_shadow_evidence", "protocol"])
3669 == Some(SEARCH_CANDIDATE_SHADOW_EVIDENCE_PROTOCOL),
3670 evidence_source_matches: str_path(
3671 bundle,
3672 &["search_candidate_shadow_evidence", "evidence_source"],
3673 ) == Some(SEARCH_CANDIDATE_EVIDENCE_SOURCE),
3674 route_matches: str_path(bundle, &["search_candidate_shadow_evidence", "route"])
3675 == Some(SEARCH_CANDIDATE_EVIDENCE_ROUTE),
3676 ready: bool_path(bundle, &["search_candidate_shadow_evidence", "ready"]) == Some(true),
3677 primary_engine_matches: str_path(
3678 bundle,
3679 &[
3680 "search_candidate_shadow_evidence",
3681 "candidate_primary_engine",
3682 ],
3683 ) == Some(SEARCH_CANDIDATE_PRIMARY_ENGINE),
3684 candidate_count_parity: search_candidate_shadow_counts_ready(bundle),
3685 row_count_parity: bool_path(
3686 bundle,
3687 &["search_candidate_shadow_evidence", "row_count_parity"],
3688 ) == Some(true),
3689 text_retriever_ready: bool_path(
3690 bundle,
3691 &["search_candidate_shadow_evidence", "text_retriever_ready"],
3692 ) == Some(true),
3693 vector_retriever_ready: bool_path(
3694 bundle,
3695 &["search_candidate_shadow_evidence", "vector_retriever_ready"],
3696 ) == Some(true),
3697 fts_top_k_overlap_ready: bool_path(
3698 bundle,
3699 &[
3700 "search_candidate_shadow_evidence",
3701 "fts_top_k_overlap_ready",
3702 ],
3703 ) == Some(true),
3704 vector_top_k_overlap_ready: bool_path(
3705 bundle,
3706 &[
3707 "search_candidate_shadow_evidence",
3708 "vector_top_k_overlap_ready",
3709 ],
3710 ) == Some(true),
3711 source_chunk_identity_ready: bool_path(
3712 bundle,
3713 &[
3714 "search_candidate_shadow_evidence",
3715 "candidate_readiness",
3716 "source_chunk_identity_ready",
3717 ],
3718 ) == Some(true),
3719 fail_soft_observed: bool_path(
3720 bundle,
3721 &[
3722 "search_candidate_shadow_evidence",
3723 "candidate_readiness",
3724 "fail_soft_observed",
3725 ],
3726 ) == Some(true),
3727 projection_marker_status_visible: bool_path(
3728 bundle,
3729 &[
3730 "search_candidate_shadow_evidence",
3731 "candidate_readiness",
3732 "projection_marker_status_visible",
3733 ],
3734 ) == Some(true),
3735 projection_watermark_ready: bool_path(
3736 bundle,
3737 &[
3738 "search_candidate_shadow_evidence",
3739 "candidate_readiness",
3740 "projection_watermark_ready",
3741 ],
3742 ) == Some(true),
3743 embedding_identity_ready: bool_path(
3744 bundle,
3745 &[
3746 "search_candidate_shadow_evidence",
3747 "candidate_readiness",
3748 "embedding_identity_ready",
3749 ],
3750 ) == Some(true),
3751 candidate_identity_ready: bool_path(
3752 bundle,
3753 &[
3754 "search_candidate_shadow_evidence",
3755 "candidate_identity",
3756 "ready",
3757 ],
3758 ) == Some(true),
3759 filter_pushdown_ready: bool_path(
3760 bundle,
3761 &[
3762 "search_candidate_shadow_evidence",
3763 "filter_pushdown",
3764 "ready",
3765 ],
3766 ) == Some(true),
3767 filter_pushdown_field_summary_present: u64_path(
3768 bundle,
3769 &[
3770 "search_candidate_shadow_evidence",
3771 "filter_pushdown",
3772 "field_summary_count",
3773 ],
3774 )
3775 .is_some_and(|count| count > 0),
3776 filter_pushdown_required_fields_ready:
3777 search_candidate_filter_pushdown_required_fields_ready(bundle),
3778 shadow_scan_filter_pushdown_ready: bool_path(
3779 bundle,
3780 &[
3781 "search_candidate_shadow_evidence",
3782 "shadow_scan_filter_pushdown_ready",
3783 ],
3784 ) == Some(true),
3785 shadow_scan_field_pruning_ready: bool_path(
3786 bundle,
3787 &[
3788 "search_candidate_shadow_evidence",
3789 "shadow_scan_field_pruning_ready",
3790 ],
3791 ) == Some(true),
3792 shadow_scan_field_summary_present: u64_path(
3793 bundle,
3794 &[
3795 "search_candidate_shadow_evidence",
3796 "shadow_scan_field_summary_count",
3797 ],
3798 )
3799 .is_some_and(|count| count > 0),
3800 blocker_codes: blocker_codes(
3801 bundle,
3802 &[&["search_candidate_shadow_evidence", "blocker_codes"][..]],
3803 ),
3804 }
3805}
3806
3807fn search_candidate_cutover_conditions(
3808 readiness: &SearchCandidateCutoverReadiness,
3809) -> Vec<(&'static str, bool)> {
3810 vec![
3811 (
3812 "search_candidate_shadow_evidence.protocol",
3813 readiness.protocol_matches,
3814 ),
3815 (
3816 "search_candidate_shadow_evidence.evidence_source",
3817 readiness.evidence_source_matches,
3818 ),
3819 (
3820 "search_candidate_shadow_evidence.route",
3821 readiness.route_matches,
3822 ),
3823 ("search_candidate_shadow_evidence.ready", readiness.ready),
3824 (
3825 "search_candidate_shadow_evidence.candidate_primary_engine",
3826 readiness.primary_engine_matches,
3827 ),
3828 (
3829 "search_candidate_shadow_evidence.candidate_counts",
3830 readiness.candidate_count_parity,
3831 ),
3832 (
3833 "search_candidate_shadow_evidence.row_count_parity",
3834 readiness.row_count_parity,
3835 ),
3836 (
3837 "search_candidate_shadow_evidence.text_retriever_ready",
3838 readiness.text_retriever_ready,
3839 ),
3840 (
3841 "search_candidate_shadow_evidence.vector_retriever_ready",
3842 readiness.vector_retriever_ready,
3843 ),
3844 (
3845 "search_candidate_shadow_evidence.fts_top_k_overlap_ready",
3846 readiness.fts_top_k_overlap_ready,
3847 ),
3848 (
3849 "search_candidate_shadow_evidence.vector_top_k_overlap_ready",
3850 readiness.vector_top_k_overlap_ready,
3851 ),
3852 (
3853 "search_candidate_shadow_evidence.candidate_readiness.source_chunk_identity_ready",
3854 readiness.source_chunk_identity_ready,
3855 ),
3856 (
3857 "search_candidate_shadow_evidence.candidate_readiness.fail_soft_observed",
3858 readiness.fail_soft_observed,
3859 ),
3860 (
3861 "search_candidate_shadow_evidence.candidate_readiness.projection_marker_status_visible",
3862 readiness.projection_marker_status_visible,
3863 ),
3864 (
3865 "search_candidate_shadow_evidence.candidate_readiness.projection_watermark_ready",
3866 readiness.projection_watermark_ready,
3867 ),
3868 (
3869 "search_candidate_shadow_evidence.candidate_readiness.embedding_identity_ready",
3870 readiness.embedding_identity_ready,
3871 ),
3872 (
3873 "search_candidate_shadow_evidence.candidate_identity.ready",
3874 readiness.candidate_identity_ready,
3875 ),
3876 (
3877 "search_candidate_shadow_evidence.filter_pushdown.ready",
3878 readiness.filter_pushdown_ready,
3879 ),
3880 (
3881 "search_candidate_shadow_evidence.filter_pushdown.field_summary_count",
3882 readiness.filter_pushdown_field_summary_present,
3883 ),
3884 (
3885 "search_candidate_shadow_evidence.filter_pushdown.missing_required_fields",
3886 readiness.filter_pushdown_required_fields_ready,
3887 ),
3888 (
3889 "search_candidate_shadow_evidence.shadow_scan_filter_pushdown_ready",
3890 readiness.shadow_scan_filter_pushdown_ready,
3891 ),
3892 (
3893 "search_candidate_shadow_evidence.shadow_scan_field_pruning_ready",
3894 readiness.shadow_scan_field_pruning_ready,
3895 ),
3896 (
3897 "search_candidate_shadow_evidence.shadow_scan_field_summary_count",
3898 readiness.shadow_scan_field_summary_present,
3899 ),
3900 ]
3901}
3902
3903fn search_candidate_filter_pushdown_required_fields_ready(bundle: &serde_json::Value) -> bool {
3904 let path = &[
3905 "search_candidate_shadow_evidence",
3906 "filter_pushdown",
3907 "missing_required_fields",
3908 ];
3909 json_get_path(bundle, path).is_some_and(serde_json::Value::is_array)
3910 && string_array_path(bundle, path).is_empty()
3911}
3912
3913fn search_candidate_shadow_counts_ready(bundle: &serde_json::Value) -> bool {
3914 let request_count = u64_path(
3915 bundle,
3916 &["search_candidate_shadow_evidence", "request_count"],
3917 );
3918 let primary_candidate_count = u64_path(
3919 bundle,
3920 &[
3921 "search_candidate_shadow_evidence",
3922 "primary_candidate_count",
3923 ],
3924 );
3925 let shadow_candidate_count = u64_path(
3926 bundle,
3927 &["search_candidate_shadow_evidence", "shadow_candidate_count"],
3928 );
3929 let matched_candidate_count = u64_path(
3930 bundle,
3931 &[
3932 "search_candidate_shadow_evidence",
3933 "matched_candidate_count",
3934 ],
3935 );
3936 let primary_only_candidate_count = u64_path(
3937 bundle,
3938 &[
3939 "search_candidate_shadow_evidence",
3940 "primary_only_candidate_count",
3941 ],
3942 );
3943 request_count.is_some_and(|count| count > 0)
3944 && primary_candidate_count.is_some()
3945 && primary_candidate_count == shadow_candidate_count
3946 && matched_candidate_count == shadow_candidate_count
3947 && primary_only_candidate_count == Some(0)
3948}
3949
3950pub fn bounded_read_cutover_readiness(bundle: &serde_json::Value) -> BoundedReadCutoverReadiness {
3951 BoundedReadCutoverReadiness {
3952 present: bool_path(
3953 bundle,
3954 &["replacement_summary", "bounded_read_evidence", "present"],
3955 ) == Some(true),
3956 protocol_matches: str_path(
3957 bundle,
3958 &["replacement_summary", "bounded_read_evidence", "protocol"],
3959 ) == Some(HAWDB_BOUNDED_READ_EVIDENCE_PROTOCOL),
3960 ready: bool_path(
3961 bundle,
3962 &["replacement_summary", "bounded_read_evidence", "ready"],
3963 ) == Some(true),
3964 max_rows_present: u64_path(
3965 bundle,
3966 &["replacement_summary", "bounded_read_evidence", "max_rows"],
3967 )
3968 .is_some_and(|value| value > 0),
3969 mode_matches: str_path(
3970 bundle,
3971 &["replacement_summary", "bounded_read_evidence", "mode"],
3972 ) == Some("shadow_read_only"),
3973 execution_cap_matches: bounded_read_execution_cap_matches(bundle),
3974 estimated_payload_bytes_present: u64_path(
3975 bundle,
3976 &[
3977 "replacement_summary",
3978 "bounded_read_evidence",
3979 "estimated_payload_bytes",
3980 ],
3981 )
3982 .is_some(),
3983 max_estimated_payload_bytes_present: u64_path(
3984 bundle,
3985 &[
3986 "replacement_summary",
3987 "bounded_read_evidence",
3988 "max_estimated_payload_bytes",
3989 ],
3990 )
3991 .is_some_and(|value| value > 0),
3992 payload_budget_not_exceeded: bool_path(
3993 bundle,
3994 &[
3995 "replacement_summary",
3996 "bounded_read_evidence",
3997 "payload_budget_exceeded",
3998 ],
3999 ) == Some(false),
4000 row_limit_enforced_before_output: bool_path(
4001 bundle,
4002 &[
4003 "replacement_summary",
4004 "bounded_read_evidence",
4005 "row_limit_enforced_before_output",
4006 ],
4007 ) == Some(true),
4008 operator_row_cap_enabled: bool_path(
4009 bundle,
4010 &[
4011 "replacement_summary",
4012 "bounded_read_evidence",
4013 "operator_row_cap_enabled",
4014 ],
4015 ) == Some(true),
4016 blocking_operator_memory_reports_complete: bool_path(
4017 bundle,
4018 &[
4019 "replacement_summary",
4020 "bounded_read_evidence",
4021 "blocking_operator_memory_reports_complete",
4022 ],
4023 ) == Some(true),
4024 blocking_operator_memory_within_budget: bool_path(
4025 bundle,
4026 &[
4027 "replacement_summary",
4028 "bounded_read_evidence",
4029 "blocking_operator_memory_within_budget",
4030 ],
4031 ) == Some(true),
4032 spill_within_budget: bool_path(
4033 bundle,
4034 &[
4035 "replacement_summary",
4036 "bounded_read_evidence",
4037 "spill_within_budget",
4038 ],
4039 ) == Some(true),
4040 streaming_evidence_present: bool_path(
4041 bundle,
4042 &["replacement_summary", "bounded_read_evidence", "streaming"],
4043 )
4044 .is_some(),
4045 route_catalog_version_matches: str_path(
4046 bundle,
4047 &[
4048 "replacement_summary",
4049 "bounded_read_evidence",
4050 "route_catalog_version",
4051 ],
4052 ) == Some(GRAPH_READ_ROUTE_CATALOG_VERSION),
4053 route_catalog_digest_present: str_path(
4054 bundle,
4055 &[
4056 "replacement_summary",
4057 "bounded_read_evidence",
4058 "route_catalog_digest",
4059 ],
4060 )
4061 .is_some(),
4062 route_coverage_ready: bounded_read_route_coverage_ready(bundle),
4063 blocker_codes: blocker_codes(
4064 bundle,
4065 &[&[
4066 "replacement_summary",
4067 "bounded_read_evidence",
4068 "blocker_codes",
4069 ][..]],
4070 ),
4071 }
4072}
4073
4074fn bounded_read_cutover_conditions(
4075 readiness: &BoundedReadCutoverReadiness,
4076) -> Vec<(&'static str, bool)> {
4077 vec![
4078 (
4079 "replacement_summary.bounded_read_evidence.present",
4080 readiness.present,
4081 ),
4082 (
4083 "replacement_summary.bounded_read_evidence.protocol",
4084 readiness.protocol_matches,
4085 ),
4086 (
4087 "replacement_summary.bounded_read_evidence.ready",
4088 readiness.ready,
4089 ),
4090 (
4091 "replacement_summary.bounded_read_evidence.max_rows",
4092 readiness.max_rows_present,
4093 ),
4094 (
4095 "replacement_summary.bounded_read_evidence.mode",
4096 readiness.mode_matches,
4097 ),
4098 (
4099 "replacement_summary.bounded_read_evidence.execution_row_cap",
4100 readiness.execution_cap_matches,
4101 ),
4102 (
4103 "replacement_summary.bounded_read_evidence.estimated_payload_bytes",
4104 readiness.estimated_payload_bytes_present,
4105 ),
4106 (
4107 "replacement_summary.bounded_read_evidence.max_estimated_payload_bytes",
4108 readiness.max_estimated_payload_bytes_present,
4109 ),
4110 (
4111 "replacement_summary.bounded_read_evidence.payload_budget_exceeded",
4112 readiness.payload_budget_not_exceeded,
4113 ),
4114 (
4115 "replacement_summary.bounded_read_evidence.row_limit_enforced_before_output",
4116 readiness.row_limit_enforced_before_output,
4117 ),
4118 (
4119 "replacement_summary.bounded_read_evidence.operator_row_cap_enabled",
4120 readiness.operator_row_cap_enabled,
4121 ),
4122 (
4123 "replacement_summary.bounded_read_evidence.blocking_operator_memory_reports_complete",
4124 readiness.blocking_operator_memory_reports_complete,
4125 ),
4126 (
4127 "replacement_summary.bounded_read_evidence.blocking_operator_memory_within_budget",
4128 readiness.blocking_operator_memory_within_budget,
4129 ),
4130 (
4131 "replacement_summary.bounded_read_evidence.spill_within_budget",
4132 readiness.spill_within_budget,
4133 ),
4134 (
4135 "replacement_summary.bounded_read_evidence.streaming",
4136 readiness.streaming_evidence_present,
4137 ),
4138 (
4139 "replacement_summary.bounded_read_evidence.route_catalog_version",
4140 readiness.route_catalog_version_matches,
4141 ),
4142 (
4143 "replacement_summary.bounded_read_evidence.route_catalog_digest",
4144 readiness.route_catalog_digest_present,
4145 ),
4146 (
4147 "replacement_summary.bounded_read_evidence.covered_routes",
4148 readiness.route_coverage_ready,
4149 ),
4150 ]
4151}
4152
4153pub fn bounded_read_alignment_cutover_readiness(
4154 bundle: &serde_json::Value,
4155) -> BoundedReadAlignmentCutoverReadiness {
4156 BoundedReadAlignmentCutoverReadiness {
4157 evidence_ready: bool_path(bundle, &["bounded_read_evidence", "ready"]) == Some(true),
4158 ready: bool_path(
4159 bundle,
4160 &["replacement_summary_bounded_read_alignment", "ready"],
4161 ) == Some(true),
4162 alignment_evidence_ready: bool_path(
4163 bundle,
4164 &[
4165 "replacement_summary_bounded_read_alignment",
4166 "evidence_ready",
4167 ],
4168 ) == Some(true),
4169 summary_ready: bool_path(
4170 bundle,
4171 &[
4172 "replacement_summary_bounded_read_alignment",
4173 "summary_ready",
4174 ],
4175 ) == Some(true),
4176 protocol_matches: bool_path(
4177 bundle,
4178 &[
4179 "replacement_summary_bounded_read_alignment",
4180 "protocol_matches",
4181 ],
4182 ) == Some(true),
4183 readiness_matches: bool_path(
4184 bundle,
4185 &[
4186 "replacement_summary_bounded_read_alignment",
4187 "readiness_matches",
4188 ],
4189 ) == Some(true),
4190 mode_matches: bool_path(
4191 bundle,
4192 &["replacement_summary_bounded_read_alignment", "mode_matches"],
4193 ) == Some(true),
4194 max_rows_matches: bool_path(
4195 bundle,
4196 &[
4197 "replacement_summary_bounded_read_alignment",
4198 "max_rows_matches",
4199 ],
4200 ) == Some(true),
4201 estimated_payload_bytes_matches: bool_path(
4202 bundle,
4203 &[
4204 "replacement_summary_bounded_read_alignment",
4205 "estimated_payload_bytes_matches",
4206 ],
4207 ) == Some(true),
4208 max_estimated_payload_bytes_matches: bool_path(
4209 bundle,
4210 &[
4211 "replacement_summary_bounded_read_alignment",
4212 "max_estimated_payload_bytes_matches",
4213 ],
4214 ) == Some(true),
4215 payload_budget_exceeded_matches: bool_path(
4216 bundle,
4217 &[
4218 "replacement_summary_bounded_read_alignment",
4219 "payload_budget_exceeded_matches",
4220 ],
4221 ) == Some(true),
4222 streaming_matches: bool_path(
4223 bundle,
4224 &[
4225 "replacement_summary_bounded_read_alignment",
4226 "streaming_matches",
4227 ],
4228 ) == Some(true),
4229 covered_routes_matches: bool_path(
4230 bundle,
4231 &[
4232 "replacement_summary_bounded_read_alignment",
4233 "covered_routes_matches",
4234 ],
4235 ) == Some(true),
4236 evidence_route_catalog_version_ready: bool_path(
4237 bundle,
4238 &[
4239 "replacement_summary_bounded_read_alignment",
4240 "evidence_route_catalog_version_ready",
4241 ],
4242 ) == Some(true),
4243 summary_route_catalog_version_ready: bool_path(
4244 bundle,
4245 &[
4246 "replacement_summary_bounded_read_alignment",
4247 "summary_route_catalog_version_ready",
4248 ],
4249 ) == Some(true),
4250 evidence_route_catalog_digest_ready: bool_path(
4251 bundle,
4252 &[
4253 "replacement_summary_bounded_read_alignment",
4254 "evidence_route_catalog_digest_ready",
4255 ],
4256 ) == Some(true),
4257 summary_route_catalog_digest_ready: bool_path(
4258 bundle,
4259 &[
4260 "replacement_summary_bounded_read_alignment",
4261 "summary_route_catalog_digest_ready",
4262 ],
4263 ) == Some(true),
4264 route_catalog_version_matches: bool_path(
4265 bundle,
4266 &[
4267 "replacement_summary_bounded_read_alignment",
4268 "route_catalog_version_matches",
4269 ],
4270 ) == Some(true),
4271 route_catalog_digest_matches: bool_path(
4272 bundle,
4273 &[
4274 "replacement_summary_bounded_read_alignment",
4275 "route_catalog_digest_matches",
4276 ],
4277 ) == Some(true),
4278 blocker_codes: blocker_codes(
4279 bundle,
4280 &[
4281 &["bounded_read_evidence", "blocker_codes"][..],
4282 &[
4283 "replacement_summary_bounded_read_alignment",
4284 "blocker_codes",
4285 ][..],
4286 ],
4287 ),
4288 }
4289}
4290
4291fn bounded_read_alignment_cutover_conditions(
4292 readiness: &BoundedReadAlignmentCutoverReadiness,
4293) -> Vec<(&'static str, bool)> {
4294 vec![
4295 ("bounded_read_evidence.ready", readiness.evidence_ready),
4296 (
4297 "replacement_summary_bounded_read_alignment.ready",
4298 readiness.ready,
4299 ),
4300 (
4301 "replacement_summary_bounded_read_alignment.evidence_ready",
4302 readiness.alignment_evidence_ready,
4303 ),
4304 (
4305 "replacement_summary_bounded_read_alignment.summary_ready",
4306 readiness.summary_ready,
4307 ),
4308 (
4309 "replacement_summary_bounded_read_alignment.protocol_matches",
4310 readiness.protocol_matches,
4311 ),
4312 (
4313 "replacement_summary_bounded_read_alignment.readiness_matches",
4314 readiness.readiness_matches,
4315 ),
4316 (
4317 "replacement_summary_bounded_read_alignment.mode_matches",
4318 readiness.mode_matches,
4319 ),
4320 (
4321 "replacement_summary_bounded_read_alignment.max_rows_matches",
4322 readiness.max_rows_matches,
4323 ),
4324 (
4325 "replacement_summary_bounded_read_alignment.estimated_payload_bytes_matches",
4326 readiness.estimated_payload_bytes_matches,
4327 ),
4328 (
4329 "replacement_summary_bounded_read_alignment.max_estimated_payload_bytes_matches",
4330 readiness.max_estimated_payload_bytes_matches,
4331 ),
4332 (
4333 "replacement_summary_bounded_read_alignment.payload_budget_exceeded_matches",
4334 readiness.payload_budget_exceeded_matches,
4335 ),
4336 (
4337 "replacement_summary_bounded_read_alignment.streaming_matches",
4338 readiness.streaming_matches,
4339 ),
4340 (
4341 "replacement_summary_bounded_read_alignment.covered_routes_matches",
4342 readiness.covered_routes_matches,
4343 ),
4344 (
4345 "replacement_summary_bounded_read_alignment.evidence_route_catalog_version_ready",
4346 readiness.evidence_route_catalog_version_ready,
4347 ),
4348 (
4349 "replacement_summary_bounded_read_alignment.summary_route_catalog_version_ready",
4350 readiness.summary_route_catalog_version_ready,
4351 ),
4352 (
4353 "replacement_summary_bounded_read_alignment.evidence_route_catalog_digest_ready",
4354 readiness.evidence_route_catalog_digest_ready,
4355 ),
4356 (
4357 "replacement_summary_bounded_read_alignment.summary_route_catalog_digest_ready",
4358 readiness.summary_route_catalog_digest_ready,
4359 ),
4360 (
4361 "replacement_summary_bounded_read_alignment.route_catalog_version_matches",
4362 readiness.route_catalog_version_matches,
4363 ),
4364 (
4365 "replacement_summary_bounded_read_alignment.route_catalog_digest_matches",
4366 readiness.route_catalog_digest_matches,
4367 ),
4368 ]
4369}
4370
4371fn bounded_read_route_coverage_ready(bundle: &serde_json::Value) -> bool {
4372 let covered_routes = string_array_path(
4373 bundle,
4374 &[
4375 "replacement_summary",
4376 "bounded_read_evidence",
4377 "covered_routes",
4378 ],
4379 );
4380 REQUIRED_BOUNDED_READ_ROUTES
4381 .iter()
4382 .all(|route| covered_routes.iter().any(|covered| covered == route))
4383 && string_array_path(
4384 bundle,
4385 &[
4386 "replacement_summary",
4387 "bounded_read_evidence",
4388 "missing_covered_routes",
4389 ],
4390 )
4391 .is_empty()
4392}
4393
4394pub fn graph_route_cutover_readiness(bundle: &serde_json::Value) -> GraphRouteCutoverReadiness {
4395 GraphRouteCutoverReadiness {
4396 protocol_matches: graph_route_protocol_ready(bundle),
4397 evidence_protocol_matches: graph_route_evidence_protocol_ready(bundle),
4398 evidence_ready: graph_route_evidence_ready(bundle),
4399 route_count_present: u64_path(bundle, &["graph_route_readiness", "route_count"])
4400 .is_some_and(|value| value > 0),
4401 required_route_count_matches: graph_route_required_route_count_ready(bundle),
4402 route_coverage_ready: graph_route_readiness_coverage_ready(bundle),
4403 missing_required_routes_empty: graph_route_missing_required_routes_empty(bundle),
4404 query_runtime_route_count_matches: u64_path(
4405 bundle,
4406 &["graph_route_readiness", "query_runtime_route_count"],
4407 ) == Some(REQUIRED_BOUNDED_READ_ROUTES.len() as u64),
4408 query_runtime_report_count_ready: u64_path(
4409 bundle,
4410 &["graph_route_readiness", "query_runtime_report_count"],
4411 )
4412 .is_some_and(|value| value >= REQUIRED_BOUNDED_READ_ROUTES.len() as u64),
4413 query_plan_profile_summary_ready: graph_route_query_plan_profile_summary_ready(bundle),
4414 relationship_property_pruning_summary_ready:
4415 graph_route_relationship_property_pruning_summary_ready(bundle),
4416 missing_query_runtime_routes_empty: string_array_path_is_empty(
4417 bundle,
4418 &["graph_route_readiness", "missing_query_runtime_routes"],
4419 ),
4420 route_query_runtime_ready: graph_route_query_runtime_ready(bundle),
4421 route_primary_ready: graph_route_primary_ready(bundle),
4422 primary_ready_route_count_matches: graph_route_primary_ready_count_ready(bundle),
4423 route_primary_blocker_codes_empty: string_array_path(
4424 bundle,
4425 &["graph_route_readiness", "route_primary_blocker_codes"],
4426 )
4427 .is_empty(),
4428 evidence_route_coverage_present: graph_route_evidence_route_coverage_present(bundle),
4429 evidence_route_coverage_matches: graph_route_evidence_route_coverage_matches(bundle),
4430 evidence_route_coverage_blocker_codes_empty: string_array_path(
4431 bundle,
4432 &[
4433 "graph_route_readiness",
4434 "evidence_route_coverage_blocker_codes",
4435 ],
4436 )
4437 .is_empty(),
4438 route_query_profiles_ready: graph_route_query_profiles_ready(bundle),
4439 blocker_codes: blocker_codes(
4440 bundle,
4441 &[
4442 &["graph_route_readiness", "blocker_codes"][..],
4443 &["graph_route_readiness", "route_primary_blocker_codes"][..],
4444 &[
4445 "graph_route_readiness",
4446 "evidence_route_coverage_blocker_codes",
4447 ][..],
4448 ],
4449 ),
4450 }
4451}
4452
4453fn graph_route_cutover_conditions(
4454 readiness: &GraphRouteCutoverReadiness,
4455) -> Vec<(&'static str, bool)> {
4456 vec![
4457 ("graph_route_readiness.protocol", readiness.protocol_matches),
4458 (
4459 "graph_route_readiness.evidence_protocol",
4460 readiness.evidence_protocol_matches,
4461 ),
4462 (
4463 "graph_route_readiness.evidence_ready",
4464 readiness.evidence_ready,
4465 ),
4466 (
4467 "graph_route_readiness.route_count",
4468 readiness.route_count_present,
4469 ),
4470 (
4471 "graph_route_readiness.required_route_count",
4472 readiness.required_route_count_matches,
4473 ),
4474 (
4475 "graph_route_readiness.route_coverage",
4476 readiness.route_coverage_ready,
4477 ),
4478 (
4479 "graph_route_readiness.missing_required_routes",
4480 readiness.missing_required_routes_empty,
4481 ),
4482 (
4483 "graph_route_readiness.query_runtime_route_count",
4484 readiness.query_runtime_route_count_matches,
4485 ),
4486 (
4487 "graph_route_readiness.query_runtime_report_count",
4488 readiness.query_runtime_report_count_ready,
4489 ),
4490 (
4491 "graph_route_readiness.query_runtime_plan_profile_counts",
4492 readiness.query_plan_profile_summary_ready,
4493 ),
4494 (
4495 "graph_route_readiness.relationship_property_pruning_counts",
4496 readiness.relationship_property_pruning_summary_ready,
4497 ),
4498 (
4499 "graph_route_readiness.missing_query_runtime_routes",
4500 readiness.missing_query_runtime_routes_empty,
4501 ),
4502 (
4503 "graph_route_readiness.route_query_runtime_ready",
4504 readiness.route_query_runtime_ready,
4505 ),
4506 (
4507 "graph_route_readiness.route_primary_ready",
4508 readiness.route_primary_ready,
4509 ),
4510 (
4511 "graph_route_readiness.primary_ready_route_count",
4512 readiness.primary_ready_route_count_matches,
4513 ),
4514 (
4515 "graph_route_readiness.route_primary_blocker_codes",
4516 readiness.route_primary_blocker_codes_empty,
4517 ),
4518 (
4519 "graph_route_readiness.evidence_route_coverage_present",
4520 readiness.evidence_route_coverage_present,
4521 ),
4522 (
4523 "graph_route_readiness.evidence_route_coverage_matches",
4524 readiness.evidence_route_coverage_matches,
4525 ),
4526 (
4527 "graph_route_readiness.evidence_route_coverage_blocker_codes",
4528 readiness.evidence_route_coverage_blocker_codes_empty,
4529 ),
4530 (
4531 "graph_route_readiness.routes",
4532 readiness.route_query_profiles_ready,
4533 ),
4534 ]
4535}
4536
4537fn graph_route_readiness_summary(bundle: &serde_json::Value) -> GraphRouteReadinessSummary {
4538 let value =
4539 json_get_path(bundle, &["graph_route_readiness"]).unwrap_or(&serde_json::Value::Null);
4540 nowledge_graph_route_readiness_summary(value)
4541}
4542
4543fn graph_route_protocol_ready(bundle: &serde_json::Value) -> bool {
4544 graph_route_readiness_summary(bundle).protocol.as_deref()
4545 == Some(NMEM_GRAPH_ROUTE_READINESS_PROTOCOL)
4546}
4547
4548fn graph_route_evidence_protocol_ready(bundle: &serde_json::Value) -> bool {
4549 graph_route_readiness_summary(bundle)
4550 .evidence_protocol
4551 .as_deref()
4552 == Some(NMEM_GRAPH_ROUTE_EVIDENCE_PROTOCOL)
4553}
4554
4555fn graph_route_evidence_ready(bundle: &serde_json::Value) -> bool {
4556 graph_route_readiness_summary(bundle).evidence_ready == Some(true)
4557}
4558
4559fn graph_route_required_route_count_ready(bundle: &serde_json::Value) -> bool {
4560 graph_route_readiness_summary(bundle).required_route_count
4561 == Some(REQUIRED_BOUNDED_READ_ROUTES.len() as u64)
4562}
4563
4564fn graph_route_readiness_coverage_ready(bundle: &serde_json::Value) -> bool {
4565 let summary = graph_route_readiness_summary(bundle);
4566 summary.covered_route_count == Some(REQUIRED_BOUNDED_READ_ROUTES.len() as u64)
4567 && summary.missing_required_routes.is_empty()
4568 && summary.unknown_routes.is_empty()
4569 && summary.duplicate_routes.is_empty()
4570 && summary.route_coverage_ready == Some(true)
4571}
4572
4573fn graph_route_missing_required_routes_empty(bundle: &serde_json::Value) -> bool {
4574 graph_route_readiness_summary(bundle)
4575 .missing_required_routes
4576 .is_empty()
4577}
4578
4579fn graph_route_query_runtime_ready(bundle: &serde_json::Value) -> bool {
4580 graph_route_readiness_summary(bundle).route_query_runtime_ready == Some(true)
4581}
4582
4583fn graph_route_primary_ready(bundle: &serde_json::Value) -> bool {
4584 graph_route_readiness_summary(bundle).route_primary_ready == Some(true)
4585}
4586
4587fn graph_route_primary_ready_count_ready(bundle: &serde_json::Value) -> bool {
4588 graph_route_readiness_summary(bundle).primary_ready_route_count
4589 == Some(REQUIRED_BOUNDED_READ_ROUTES.len() as u64)
4590}
4591
4592fn graph_route_evidence_route_coverage_present(bundle: &serde_json::Value) -> bool {
4593 graph_route_readiness_summary(bundle).evidence_route_coverage_present == Some(true)
4594}
4595
4596fn graph_route_evidence_route_coverage_matches(bundle: &serde_json::Value) -> bool {
4597 graph_route_readiness_summary(bundle).evidence_route_coverage_matches == Some(true)
4598}
4599
4600fn graph_route_query_plan_profile_summary_ready(bundle: &serde_json::Value) -> bool {
4601 let report_count = u64_path(
4602 bundle,
4603 &["graph_route_readiness", "query_runtime_report_count"],
4604 );
4605 report_count.is_some_and(|value| value >= REQUIRED_BOUNDED_READ_ROUTES.len() as u64)
4606 && u64_path(
4607 bundle,
4608 &["graph_route_readiness", "query_runtime_plan_report_count"],
4609 ) == report_count
4610 && u64_path(
4611 bundle,
4612 &[
4613 "graph_route_readiness",
4614 "query_runtime_profile_report_count",
4615 ],
4616 ) == report_count
4617 && u64_path(
4618 bundle,
4619 &["graph_route_readiness", "query_runtime_failed_query_count"],
4620 ) == Some(0)
4621 && u64_path(
4622 bundle,
4623 &[
4624 "graph_route_readiness",
4625 "query_runtime_missing_plan_evidence_count",
4626 ],
4627 ) == Some(0)
4628 && u64_path(
4629 bundle,
4630 &[
4631 "graph_route_readiness",
4632 "query_runtime_missing_profile_evidence_count",
4633 ],
4634 ) == Some(0)
4635 && bool_path(
4636 bundle,
4637 &["graph_route_readiness", "route_query_plan_evidence_ready"],
4638 ) == Some(true)
4639 && bool_path(
4640 bundle,
4641 &[
4642 "graph_route_readiness",
4643 "route_query_profile_evidence_ready",
4644 ],
4645 ) == Some(true)
4646}
4647
4648fn graph_route_relationship_property_pruning_summary_ready(bundle: &serde_json::Value) -> bool {
4649 let Some(required_count) = u64_path(
4650 bundle,
4651 &[
4652 "graph_route_readiness",
4653 "relationship_property_pruning_required_count",
4654 ],
4655 ) else {
4656 return false;
4657 };
4658 u64_path(
4659 bundle,
4660 &[
4661 "graph_route_readiness",
4662 "relationship_property_pruning_report_count",
4663 ],
4664 ) == Some(required_count)
4665 && bool_path(
4666 bundle,
4667 &[
4668 "graph_route_readiness",
4669 "route_relationship_property_pruning_evidence_ready",
4670 ],
4671 ) == Some(true)
4672}
4673
4674fn graph_route_query_profiles_ready(bundle: &serde_json::Value) -> bool {
4675 let Some(routes) = json_get_path(bundle, &["graph_route_readiness", "routes"])
4676 .and_then(serde_json::Value::as_array)
4677 else {
4678 return false;
4679 };
4680 if routes.len() != REQUIRED_BOUNDED_READ_ROUTES.len() {
4681 return false;
4682 }
4683
4684 let mut observed_routes = BTreeSet::new();
4685 for route in routes {
4686 let Some(route_name) = str_path(route, &["route"]) else {
4687 return false;
4688 };
4689 if !REQUIRED_BOUNDED_READ_ROUTES.contains(&route_name) {
4690 return false;
4691 }
4692 if !observed_routes.insert(route_name) {
4693 return false;
4694 }
4695 if !graph_route_query_families_ready(route, route_name) {
4696 return false;
4697 }
4698 if bool_path(route, &["primary_ready"]) != Some(true)
4699 || bool_path(route, &["query_runtime_ready"]) != Some(true)
4700 || bool_path(route, &["query_plan_evidence_ready"]) != Some(true)
4701 || bool_path(route, &["query_profile_evidence_ready"]) != Some(true)
4702 || bool_path(route, &["relationship_property_pruning_evidence_ready"]) != Some(true)
4703 || !graph_route_shadow_compare_ready(route)
4704 || u64_path(route, &["query_report_count"]).is_none_or(|value| value == 0)
4705 {
4706 return false;
4707 }
4708 let Some(query_reports) =
4709 json_get_path(route, &["query_reports"]).and_then(serde_json::Value::as_array)
4710 else {
4711 return false;
4712 };
4713 if query_reports.is_empty()
4714 || u64_path(route, &["query_report_count"]) != Some(query_reports.len() as u64)
4715 || u64_path(route, &["query_runtime_report_count"]) != Some(query_reports.len() as u64)
4716 || u64_path(route, &["query_runtime_plan_report_count"])
4717 != Some(query_reports.len() as u64)
4718 || u64_path(route, &["query_runtime_profile_report_count"])
4719 != Some(query_reports.len() as u64)
4720 || u64_path(route, &["query_runtime_failed_query_count"]) != Some(0)
4721 || u64_path(route, &["query_runtime_missing_plan_evidence_count"]) != Some(0)
4722 || u64_path(route, &["query_runtime_missing_profile_evidence_count"]) != Some(0)
4723 || !graph_route_relationship_property_pruning_route_ready(route, query_reports)
4724 || !query_reports.iter().all(graph_route_query_report_ready)
4725 {
4726 return false;
4727 }
4728 }
4729
4730 REQUIRED_BOUNDED_READ_ROUTES
4731 .iter()
4732 .all(|route| observed_routes.contains(route))
4733}
4734
4735fn graph_route_relationship_property_pruning_route_ready(
4736 route: &serde_json::Value,
4737 query_reports: &[serde_json::Value],
4738) -> bool {
4739 let Some(required_count) = u64_path(route, &["relationship_property_pruning_required_count"])
4740 else {
4741 return false;
4742 };
4743 let Some(reported_count) = u64_path(route, &["relationship_property_pruning_report_count"])
4744 else {
4745 return false;
4746 };
4747 let actual_count = query_reports
4748 .iter()
4749 .filter(|report| graph_route_query_report_has_relationship_property_pruning(report))
4750 .count() as u64;
4751 reported_count == required_count
4752 && actual_count == reported_count
4753 && bool_path(route, &["relationship_property_pruning_evidence_ready"]) == Some(true)
4754}
4755
4756fn graph_route_query_families_ready(route: &serde_json::Value, route_name: &str) -> bool {
4757 let expected = required_query_families_for_route(route_name)
4758 .iter()
4759 .map(|family| (*family).to_string())
4760 .collect::<Vec<_>>();
4761 if string_array_path(route, &["required_query_families"]) != expected
4762 || string_array_path(route, &["computed_required_query_families"]) != expected
4763 || !string_array_path(route, &["query_family_blocker_codes"]).is_empty()
4764 {
4765 return false;
4766 }
4767 let Some(query_reports) =
4768 json_get_path(route, &["query_reports"]).and_then(serde_json::Value::as_array)
4769 else {
4770 return false;
4771 };
4772 if expected.is_empty() {
4773 return true;
4774 }
4775 query_reports.iter().any(|report| {
4776 str_path(report, &["query_family"])
4777 .is_some_and(|family| expected.iter().any(|expected| expected == family))
4778 })
4779}
4780
4781fn graph_route_shadow_compare_ready(route: &serde_json::Value) -> bool {
4782 bool_path(route, &["shadow_compare_ready"]) == Some(true)
4783 && str_path(route, &["shadow_compare_evidence_source"])
4784 == Some(ROUTE_PARITY_EVIDENCE_SOURCE)
4785 && str_path(route, &["shadow_compare", "source"]) == Some(ROUTE_PARITY_EVIDENCE_SOURCE)
4786 && bool_path(route, &["shadow_compare", "ready"]) == Some(true)
4787 && u64_path(route, &["shadow_compare", "matched_per_million"])
4788 == Some(ROUTE_PARITY_FULL_MATCH_PER_MILLION)
4789 && str_path(route, &["shadow_compare", "primary_engine"])
4790 .is_some_and(is_legacy_graph_engine)
4791 && str_path(route, &["shadow_compare", "shadow_engine"]) == Some("hawdb")
4792 && string_array_path(route, &["shadow_compare", "blocker_codes"]).is_empty()
4793 && string_array_path(route, &["shadow_compare", "computed_blocker_codes"]).is_empty()
4794}
4795
4796fn is_legacy_graph_engine(engine: &str) -> bool {
4797 matches!(engine, "kuzu" | "ladybug" | "kuzu/ladybug")
4798}
4799
4800fn graph_route_query_report_ready(report: &serde_json::Value) -> bool {
4801 non_empty_str_path(report, &["query_name"])
4802 && u64_path(report, &["query_index"]).is_some()
4803 && str_path(report, &["query_family"])
4804 .is_some_and(|family| REQUIRED_NOWLEDGE_REPLACEMENT_QUERY_FAMILIES.contains(&family))
4805 && str_path(report, &["protocol"]) == Some(HAWDB_QUERY_REPORT_PROTOCOL)
4806 && bool_path(report, &["ready"]) == Some(true)
4807 && string_array_path(report, &["blocker_codes"]).is_empty()
4808 && non_empty_str_path(report, &["statement_kind"])
4809 && matches!(
4810 str_path(report, &["execution_path"]),
4811 Some("fast_path" | "optimized_path")
4812 )
4813 && bool_path(report, &["fast_path_selected"]).is_some()
4814 && bool_path(report, &["slow_log_candidate"]).is_some()
4815 && bool_path(report, &["physical_plan_captured"]).is_some()
4816 && u64_path(report, &["elapsed_micros"]).is_some()
4817 && graph_route_query_report_physical_operators_present(report)
4818 && u64_path(report, &["optimizer_decision_count"]).is_some()
4819 && u64_path(report, &["optimizer_rule_event_count"]).is_some()
4820 && u64_path(report, &["scan_pruning_report_count"]).is_some()
4821 && graph_route_query_report_scan_pruning_present(report)
4822 && non_empty_str_path(report, &["plan_cache", "lookup"])
4823 && bool_path(report, &["plan_cache", "cacheable"]).is_some()
4824 && bool_path(report, &["plan_cache", "hit"]).is_some()
4825 && bool_path(report, &["plan_cache", "miss"]).is_some()
4826 && bool_path(report, &["plan_cache", "bypassed"]) == Some(false)
4827}
4828
4829fn graph_route_query_report_physical_operators_present(report: &serde_json::Value) -> bool {
4830 bool_path(report, &["physical_operator_counts_present"]) == Some(true)
4831 || json_get_path(report, &["physical_operator_counts"])
4832 .is_some_and(serde_json::Value::is_object)
4833}
4834
4835fn graph_route_query_report_scan_pruning_present(report: &serde_json::Value) -> bool {
4836 let Some(report_count) = u64_path(report, &["scan_pruning_report_count"]) else {
4837 return false;
4838 };
4839 let Some(reports) =
4840 json_get_path(report, &["scan_pruning_reports"]).and_then(serde_json::Value::as_array)
4841 else {
4842 return false;
4843 };
4844 report_count == reports.len() as u64
4845 && !reports.is_empty()
4846 && reports.iter().all(query_runtime_scan_pruning_report_ready)
4847}
4848
4849fn graph_route_query_report_has_relationship_property_pruning(report: &serde_json::Value) -> bool {
4850 json_get_path(report, &["scan_pruning_reports"])
4851 .and_then(serde_json::Value::as_array)
4852 .into_iter()
4853 .flatten()
4854 .any(|scan_report| {
4855 query_runtime_scan_pruning_report_ready(scan_report)
4856 && str_path(scan_report, &["target_kind"]) == Some("relationship")
4857 && str_path(scan_report, &["strategy", "kind"]) == Some("relationship_property")
4858 })
4859}
4860
4861pub fn graph_route_alignment_cutover_readiness(
4862 bundle: &serde_json::Value,
4863) -> GraphRouteAlignmentCutoverReadiness {
4864 GraphRouteAlignmentCutoverReadiness {
4865 ready: graph_route_alignment_bool(bundle, "ready"),
4866 evidence_protocol_matches: graph_route_alignment_bool(bundle, "evidence_protocol_matches"),
4867 evidence_ready: graph_route_alignment_bool(bundle, "evidence_ready"),
4868 evidence_route_primary_ready: graph_route_alignment_bool(
4869 bundle,
4870 "evidence_route_primary_ready",
4871 ),
4872 summary_route_primary_ready: graph_route_alignment_bool(
4873 bundle,
4874 "summary_route_primary_ready",
4875 ),
4876 route_primary_ready_matches: graph_route_alignment_bool(
4877 bundle,
4878 "route_primary_ready_matches",
4879 ),
4880 route_query_plan_evidence_ready_matches: graph_route_alignment_bool(
4881 bundle,
4882 "route_query_plan_evidence_ready_matches",
4883 ),
4884 route_query_profile_evidence_ready_matches: graph_route_alignment_bool(
4885 bundle,
4886 "route_query_profile_evidence_ready_matches",
4887 ),
4888 route_query_api_behavior_evidence_ready_matches: graph_route_alignment_bool(
4889 bundle,
4890 "route_query_api_behavior_evidence_ready_matches",
4891 ),
4892 route_relationship_property_pruning_evidence_ready_matches: graph_route_alignment_bool(
4893 bundle,
4894 "route_relationship_property_pruning_evidence_ready_matches",
4895 ),
4896 relationship_property_pruning_required_count_matches: graph_route_alignment_bool(
4897 bundle,
4898 "relationship_property_pruning_required_count_matches",
4899 ),
4900 relationship_property_pruning_report_count_matches: graph_route_alignment_bool(
4901 bundle,
4902 "relationship_property_pruning_report_count_matches",
4903 ),
4904 primary_ready_routes_match: graph_route_alignment_bool(
4905 bundle,
4906 "primary_ready_routes_match",
4907 ),
4908 evidence_required_routes_covered: graph_route_alignment_bool(
4909 bundle,
4910 "evidence_required_routes_covered",
4911 ),
4912 summary_required_routes_covered: graph_route_alignment_bool(
4913 bundle,
4914 "summary_required_routes_covered",
4915 ),
4916 evidence_route_catalog_version_ready: graph_route_alignment_bool(
4917 bundle,
4918 "evidence_route_catalog_version_ready",
4919 ),
4920 summary_route_catalog_version_ready: graph_route_alignment_bool(
4921 bundle,
4922 "summary_route_catalog_version_ready",
4923 ),
4924 evidence_route_catalog_digest_ready: graph_route_alignment_bool(
4925 bundle,
4926 "evidence_route_catalog_digest_ready",
4927 ),
4928 summary_route_catalog_digest_ready: graph_route_alignment_bool(
4929 bundle,
4930 "summary_route_catalog_digest_ready",
4931 ),
4932 route_catalog_version_matches: graph_route_alignment_bool(
4933 bundle,
4934 "route_catalog_version_matches",
4935 ),
4936 route_catalog_digest_matches: graph_route_alignment_bool(
4937 bundle,
4938 "route_catalog_digest_matches",
4939 ),
4940 blocker_codes: blocker_codes(
4941 bundle,
4942 &[&["replacement_summary_graph_route_alignment", "blocker_codes"][..]],
4943 ),
4944 }
4945}
4946
4947fn graph_route_alignment_bool(bundle: &serde_json::Value, field: &str) -> bool {
4948 bool_path(
4949 bundle,
4950 &["replacement_summary_graph_route_alignment", field],
4951 ) == Some(true)
4952}
4953
4954fn graph_route_alignment_cutover_conditions(
4955 readiness: &GraphRouteAlignmentCutoverReadiness,
4956) -> Vec<(&'static str, bool)> {
4957 vec![
4958 (
4959 "replacement_summary_graph_route_alignment.ready",
4960 readiness.ready,
4961 ),
4962 (
4963 "replacement_summary_graph_route_alignment.evidence_protocol_matches",
4964 readiness.evidence_protocol_matches,
4965 ),
4966 (
4967 "replacement_summary_graph_route_alignment.evidence_ready",
4968 readiness.evidence_ready,
4969 ),
4970 (
4971 "replacement_summary_graph_route_alignment.evidence_route_primary_ready",
4972 readiness.evidence_route_primary_ready,
4973 ),
4974 (
4975 "replacement_summary_graph_route_alignment.summary_route_primary_ready",
4976 readiness.summary_route_primary_ready,
4977 ),
4978 (
4979 "replacement_summary_graph_route_alignment.route_primary_ready_matches",
4980 readiness.route_primary_ready_matches,
4981 ),
4982 (
4983 "replacement_summary_graph_route_alignment.route_query_plan_evidence_ready_matches",
4984 readiness.route_query_plan_evidence_ready_matches,
4985 ),
4986 (
4987 "replacement_summary_graph_route_alignment.route_query_profile_evidence_ready_matches",
4988 readiness.route_query_profile_evidence_ready_matches,
4989 ),
4990 (
4991 "replacement_summary_graph_route_alignment.route_query_api_behavior_evidence_ready_matches",
4992 readiness.route_query_api_behavior_evidence_ready_matches,
4993 ),
4994 (
4995 "replacement_summary_graph_route_alignment.route_relationship_property_pruning_evidence_ready_matches",
4996 readiness.route_relationship_property_pruning_evidence_ready_matches,
4997 ),
4998 (
4999 "replacement_summary_graph_route_alignment.relationship_property_pruning_required_count_matches",
5000 readiness.relationship_property_pruning_required_count_matches,
5001 ),
5002 (
5003 "replacement_summary_graph_route_alignment.relationship_property_pruning_report_count_matches",
5004 readiness.relationship_property_pruning_report_count_matches,
5005 ),
5006 (
5007 "replacement_summary_graph_route_alignment.primary_ready_routes_match",
5008 readiness.primary_ready_routes_match,
5009 ),
5010 (
5011 "replacement_summary_graph_route_alignment.evidence_required_routes_covered",
5012 readiness.evidence_required_routes_covered,
5013 ),
5014 (
5015 "replacement_summary_graph_route_alignment.summary_required_routes_covered",
5016 readiness.summary_required_routes_covered,
5017 ),
5018 (
5019 "replacement_summary_graph_route_alignment.evidence_route_catalog_version_ready",
5020 readiness.evidence_route_catalog_version_ready,
5021 ),
5022 (
5023 "replacement_summary_graph_route_alignment.summary_route_catalog_version_ready",
5024 readiness.summary_route_catalog_version_ready,
5025 ),
5026 (
5027 "replacement_summary_graph_route_alignment.evidence_route_catalog_digest_ready",
5028 readiness.evidence_route_catalog_digest_ready,
5029 ),
5030 (
5031 "replacement_summary_graph_route_alignment.summary_route_catalog_digest_ready",
5032 readiness.summary_route_catalog_digest_ready,
5033 ),
5034 (
5035 "replacement_summary_graph_route_alignment.route_catalog_version_matches",
5036 readiness.route_catalog_version_matches,
5037 ),
5038 (
5039 "replacement_summary_graph_route_alignment.route_catalog_digest_matches",
5040 readiness.route_catalog_digest_matches,
5041 ),
5042 ]
5043}
5044
5045pub fn graph_route_parity_alignment_cutover_readiness(
5046 bundle: &serde_json::Value,
5047) -> GraphRouteParityAlignmentCutoverReadiness {
5048 let required_route_count = u64_path(
5049 bundle,
5050 &["graph_route_parity_alignment", "required_route_count"],
5051 );
5052 GraphRouteParityAlignmentCutoverReadiness {
5053 ready: bool_path(bundle, &["graph_route_parity_alignment", "ready"]) == Some(true),
5054 required_route_count_present: required_route_count.is_some_and(|value| value > 0),
5055 ready_route_count_matches: u64_path(
5056 bundle,
5057 &["graph_route_parity_alignment", "ready_route_count"],
5058 ) == required_route_count,
5059 missing_routes_empty: string_array_path(
5060 bundle,
5061 &["graph_route_parity_alignment", "missing_routes"],
5062 )
5063 .is_empty(),
5064 not_ready_routes_empty: string_array_path(
5065 bundle,
5066 &["graph_route_parity_alignment", "not_ready_routes"],
5067 )
5068 .is_empty(),
5069 route_mismatch_routes_empty: string_array_path(
5070 bundle,
5071 &["graph_route_parity_alignment", "route_mismatch_routes"],
5072 )
5073 .is_empty(),
5074 protocol_mismatch_routes_empty: string_array_path(
5075 bundle,
5076 &["graph_route_parity_alignment", "protocol_mismatch_routes"],
5077 )
5078 .is_empty(),
5079 blocker_routes_empty: string_array_path(
5080 bundle,
5081 &["graph_route_parity_alignment", "blocker_routes"],
5082 )
5083 .is_empty(),
5084 blocker_codes: blocker_codes(
5085 bundle,
5086 &[&["graph_route_parity_alignment", "blocker_codes"][..]],
5087 ),
5088 }
5089}
5090
5091fn graph_route_parity_alignment_cutover_conditions(
5092 readiness: &GraphRouteParityAlignmentCutoverReadiness,
5093) -> Vec<(&'static str, bool)> {
5094 vec![
5095 ("graph_route_parity_alignment.ready", readiness.ready),
5096 (
5097 "graph_route_parity_alignment.required_route_count",
5098 readiness.required_route_count_present,
5099 ),
5100 (
5101 "graph_route_parity_alignment.ready_route_count",
5102 readiness.ready_route_count_matches,
5103 ),
5104 (
5105 "graph_route_parity_alignment.missing_routes",
5106 readiness.missing_routes_empty,
5107 ),
5108 (
5109 "graph_route_parity_alignment.not_ready_routes",
5110 readiness.not_ready_routes_empty,
5111 ),
5112 (
5113 "graph_route_parity_alignment.route_mismatch_routes",
5114 readiness.route_mismatch_routes_empty,
5115 ),
5116 (
5117 "graph_route_parity_alignment.protocol_mismatch_routes",
5118 readiness.protocol_mismatch_routes_empty,
5119 ),
5120 (
5121 "graph_route_parity_alignment.blocker_routes",
5122 readiness.blocker_routes_empty,
5123 ),
5124 ]
5125}
5126
5127pub fn query_runtime_preflight_cutover_readiness(
5128 bundle: &serde_json::Value,
5129) -> QueryRuntimePreflightCutoverReadiness {
5130 QueryRuntimePreflightCutoverReadiness {
5131 protocol_matches: str_path(bundle, &["query_runtime_preflight", "protocol"])
5132 == Some(HAWDB_NOWLEDGE_QUERY_RUNTIME_PREFLIGHT_PROTOCOL),
5133 ready: bool_path(bundle, &["query_runtime_preflight", "ready"]) == Some(true),
5134 database_opened: bool_path(bundle, &["query_runtime_preflight", "database_opened"])
5135 == Some(true),
5136 redaction_ready: bool_path(bundle, &["query_runtime_preflight", "redaction", "ready"])
5137 == Some(true),
5138 rows_redacted: bool_path(
5139 bundle,
5140 &["query_runtime_preflight", "redaction", "rows_copied"],
5141 ) == Some(false),
5142 parameters_redacted: bool_path(
5143 bundle,
5144 &["query_runtime_preflight", "redaction", "parameters_copied"],
5145 ) == Some(false),
5146 local_paths_redacted: bool_path(
5147 bundle,
5148 &["query_runtime_preflight", "redaction", "local_paths_copied"],
5149 ) == Some(false),
5150 raw_errors_redacted: bool_path(
5151 bundle,
5152 &["query_runtime_preflight", "redaction", "raw_errors_copied"],
5153 ) == Some(false),
5154 probe_count_present: u64_path(bundle, &["query_runtime_preflight", "probe_count"])
5155 .is_some_and(|value| value > 0),
5156 probe_counts_match: query_runtime_preflight_counts_match(bundle),
5157 failed_probe_count_zero: u64_path(
5158 bundle,
5159 &["query_runtime_preflight", "failed_probe_count"],
5160 ) == Some(0),
5161 route_coverage_ready: query_runtime_preflight_route_coverage_ready(bundle),
5162 route_catalog_version_matches: str_path(
5163 bundle,
5164 &["query_runtime_preflight", "route_catalog_version"],
5165 ) == Some(GRAPH_READ_ROUTE_CATALOG_VERSION),
5166 route_catalog_digest_present: str_path(
5167 bundle,
5168 &["query_runtime_preflight", "route_catalog_digest"],
5169 )
5170 .is_some(),
5171 probe_details_ready: query_runtime_preflight_probe_details_ready(bundle),
5172 blocker_codes: blocker_codes(
5173 bundle,
5174 &[
5175 &["query_runtime_preflight", "blocker_codes"][..],
5176 &["query_runtime_preflight", "failed_checks"][..],
5177 &["query_runtime_preflight", "route_coverage_blocker_codes"][..],
5178 ],
5179 ),
5180 }
5181}
5182
5183fn query_runtime_preflight_cutover_conditions(
5184 readiness: &QueryRuntimePreflightCutoverReadiness,
5185) -> Vec<(&'static str, bool)> {
5186 vec![
5187 (
5188 "query_runtime_preflight.protocol",
5189 readiness.protocol_matches,
5190 ),
5191 ("query_runtime_preflight.ready", readiness.ready),
5192 (
5193 "query_runtime_preflight.database_opened",
5194 readiness.database_opened,
5195 ),
5196 (
5197 "query_runtime_preflight.redaction.ready",
5198 readiness.redaction_ready,
5199 ),
5200 (
5201 "query_runtime_preflight.redaction.rows_copied",
5202 readiness.rows_redacted,
5203 ),
5204 (
5205 "query_runtime_preflight.redaction.parameters_copied",
5206 readiness.parameters_redacted,
5207 ),
5208 (
5209 "query_runtime_preflight.redaction.local_paths_copied",
5210 readiness.local_paths_redacted,
5211 ),
5212 (
5213 "query_runtime_preflight.redaction.raw_errors_copied",
5214 readiness.raw_errors_redacted,
5215 ),
5216 (
5217 "query_runtime_preflight.probe_count",
5218 readiness.probe_count_present,
5219 ),
5220 (
5221 "query_runtime_preflight.passed_probe_count",
5222 readiness.probe_counts_match,
5223 ),
5224 (
5225 "query_runtime_preflight.failed_probe_count",
5226 readiness.failed_probe_count_zero,
5227 ),
5228 (
5229 "query_runtime_preflight.route_coverage",
5230 readiness.route_coverage_ready,
5231 ),
5232 (
5233 "query_runtime_preflight.route_catalog_version",
5234 readiness.route_catalog_version_matches,
5235 ),
5236 (
5237 "query_runtime_preflight.route_catalog_digest",
5238 readiness.route_catalog_digest_present,
5239 ),
5240 (
5241 "query_runtime_preflight.probes",
5242 readiness.probe_details_ready,
5243 ),
5244 ]
5245}
5246
5247fn query_runtime_preflight_counts_match(bundle: &serde_json::Value) -> bool {
5248 let probe_count = u64_path(bundle, &["query_runtime_preflight", "probe_count"]);
5249 let passed_probe_count = u64_path(bundle, &["query_runtime_preflight", "passed_probe_count"]);
5250 probe_count.is_some_and(|value| value > 0) && probe_count == passed_probe_count
5251}
5252
5253fn query_runtime_preflight_probe_details_ready(bundle: &serde_json::Value) -> bool {
5254 let Some(probes) = json_get_path(bundle, &["query_runtime_preflight", "probes"])
5255 .and_then(serde_json::Value::as_array)
5256 else {
5257 return false;
5258 };
5259 !probes.is_empty() && probes.iter().all(query_runtime_preflight_probe_ready)
5260}
5261
5262fn query_runtime_preflight_route_coverage_ready(bundle: &serde_json::Value) -> bool {
5263 let value = match json_get_path(bundle, &["query_runtime_preflight"]) {
5264 Some(value) => value,
5265 None => return false,
5266 };
5267 let Some(probes) = value
5268 .get("probes")
5269 .and_then(serde_json::Value::as_array)
5270 .filter(|probes| !probes.is_empty())
5271 else {
5272 return false;
5273 };
5274 let observed_routes = probes
5275 .iter()
5276 .filter_map(|probe| str_path(probe, &["route"]))
5277 .collect::<Vec<_>>();
5278 let observed_route_set = observed_routes.iter().copied().collect::<BTreeSet<_>>();
5279 let duplicate_routes = duplicate_routes(&observed_routes);
5280 let unknown_routes = observed_route_set
5281 .iter()
5282 .filter(|route| !REQUIRED_BOUNDED_READ_ROUTES.contains(route))
5283 .count();
5284 u64_path(value, &["required_route_count"]) == Some(REQUIRED_BOUNDED_READ_ROUTES.len() as u64)
5285 && u64_path(value, &["covered_route_count"])
5286 == Some(REQUIRED_BOUNDED_READ_ROUTES.len() as u64)
5287 && bool_path(value, &["required_routes_covered"]) == Some(true)
5288 && string_array_path(value, &["missing_required_routes"]).is_empty()
5289 && string_array_path(value, &["unknown_routes"]).is_empty()
5290 && string_array_path(value, &["duplicate_routes"]).is_empty()
5291 && str_path(value, &["route_catalog_version"]) == Some(GRAPH_READ_ROUTE_CATALOG_VERSION)
5292 && str_path(value, &["route_catalog_digest"])
5293 == Some(graph_read_route_catalog_digest().as_str())
5294 && bool_path(value, &["route_coverage_ready"]) == Some(true)
5295 && string_array_path(value, &["route_coverage_blocker_codes"]).is_empty()
5296 && unknown_routes == 0
5297 && duplicate_routes.is_empty()
5298 && REQUIRED_BOUNDED_READ_ROUTES
5299 .iter()
5300 .all(|route| observed_route_set.contains(route))
5301}
5302
5303fn duplicate_routes(routes: &[&str]) -> Vec<String> {
5304 let mut counts = BTreeMap::<&str, usize>::new();
5305 for route in routes {
5306 *counts.entry(*route).or_default() += 1;
5307 }
5308 counts
5309 .into_iter()
5310 .filter(|(_, count)| *count > 1)
5311 .map(|(route, _)| route.to_string())
5312 .collect()
5313}
5314
5315fn query_runtime_preflight_probe_ready(probe: &serde_json::Value) -> bool {
5316 query_runtime_preflight_probe_identity_ready(probe)
5317 && bool_path(probe, &["ready"]) == Some(true)
5318 && bool_path(probe, &["success"]) == Some(true)
5319 && non_empty_str_path(probe, &["selected_plan_fingerprint"])
5320 && u64_path(probe, &["output_row_count"]).is_some()
5321 && json_object_path_is_non_empty(probe, &["selected_plan_operator_counts"])
5322 && json_object_path_is_non_empty(probe, &["selected_plan_class_counts"])
5323 && u64_path(probe, &["optimizer_decision_count"]).is_some()
5324 && u64_path(probe, &["optimizer_rule_event_count"]).is_some()
5325 && query_runtime_preflight_probe_plan_cache_ready(probe)
5326 && query_runtime_preflight_probe_scan_pruning_ready(probe)
5327 && string_array_path(probe, &["blocker_codes"]).is_empty()
5328}
5329
5330fn query_runtime_preflight_probe_identity_ready(probe: &serde_json::Value) -> bool {
5331 str_path(probe, &["name"]).is_some_and(|name| {
5332 let name = name.trim();
5333 !name.is_empty() && name != "unnamed"
5334 }) && str_path(probe, &["route"])
5335 .is_some_and(|route| REQUIRED_BOUNDED_READ_ROUTES.contains(&route))
5336 && str_path(probe, &["query_family"])
5337 .is_some_and(|family| REQUIRED_NOWLEDGE_REPLACEMENT_QUERY_FAMILIES.contains(&family))
5338}
5339
5340fn query_runtime_preflight_probe_plan_cache_ready(probe: &serde_json::Value) -> bool {
5341 non_empty_str_path(probe, &["plan_cache_lookup"])
5342 && non_empty_str_path(probe, &["plan_cache", "lookup"])
5343 && bool_path(probe, &["plan_cache", "cacheable"]).is_some()
5344 && bool_path(probe, &["plan_cache", "hit"]).is_some()
5345 && bool_path(probe, &["plan_cache", "miss"]).is_some()
5346 && bool_path(probe, &["plan_cache", "bypassed"]) == Some(false)
5347}
5348
5349fn query_runtime_preflight_probe_scan_pruning_ready(probe: &serde_json::Value) -> bool {
5350 let Some(report_count) = u64_path(probe, &["execution_profile", "scan_pruning_report_count"])
5351 else {
5352 return false;
5353 };
5354 let Some(reports) = json_get_path(probe, &["execution_profile", "scan_pruning_reports"])
5355 .and_then(serde_json::Value::as_array)
5356 else {
5357 return false;
5358 };
5359 report_count == reports.len() as u64
5360 && u64_path(probe, &["execution_profile", "pruned_scan_count"]).is_some()
5361 && reports.iter().all(query_runtime_scan_pruning_report_ready)
5362}
5363
5364pub fn query_runtime_preflight_alignment_cutover_readiness(
5365 bundle: &serde_json::Value,
5366) -> QueryRuntimePreflightAlignmentCutoverReadiness {
5367 QueryRuntimePreflightAlignmentCutoverReadiness {
5368 ready: query_runtime_preflight_alignment_bool(bundle, "ready"),
5369 evidence_ready: query_runtime_preflight_alignment_bool(bundle, "evidence_ready"),
5370 summary_ready: query_runtime_preflight_alignment_bool(bundle, "summary_ready"),
5371 protocol_matches: query_runtime_preflight_alignment_bool(bundle, "protocol_matches"),
5372 readiness_matches: query_runtime_preflight_alignment_bool(bundle, "readiness_matches"),
5373 database_opened_matches: query_runtime_preflight_alignment_bool(
5374 bundle,
5375 "database_opened_matches",
5376 ),
5377 probe_count_matches: query_runtime_preflight_alignment_bool(bundle, "probe_count_matches"),
5378 passed_probe_count_matches: query_runtime_preflight_alignment_bool(
5379 bundle,
5380 "passed_probe_count_matches",
5381 ),
5382 failed_probe_count_matches: query_runtime_preflight_alignment_bool(
5383 bundle,
5384 "failed_probe_count_matches",
5385 ),
5386 required_route_count_matches: query_runtime_preflight_alignment_bool(
5387 bundle,
5388 "required_route_count_matches",
5389 ),
5390 covered_route_count_matches: query_runtime_preflight_alignment_bool(
5391 bundle,
5392 "covered_route_count_matches",
5393 ),
5394 covered_routes_matches: query_runtime_preflight_alignment_bool(
5395 bundle,
5396 "covered_routes_matches",
5397 ),
5398 required_routes_covered_matches: query_runtime_preflight_alignment_bool(
5399 bundle,
5400 "required_routes_covered_matches",
5401 ),
5402 route_coverage_ready_matches: query_runtime_preflight_alignment_bool(
5403 bundle,
5404 "route_coverage_ready_matches",
5405 ),
5406 evidence_route_catalog_version_ready: query_runtime_preflight_alignment_bool(
5407 bundle,
5408 "evidence_route_catalog_version_ready",
5409 ),
5410 summary_route_catalog_version_ready: query_runtime_preflight_alignment_bool(
5411 bundle,
5412 "summary_route_catalog_version_ready",
5413 ),
5414 evidence_route_catalog_digest_ready: query_runtime_preflight_alignment_bool(
5415 bundle,
5416 "evidence_route_catalog_digest_ready",
5417 ),
5418 summary_route_catalog_digest_ready: query_runtime_preflight_alignment_bool(
5419 bundle,
5420 "summary_route_catalog_digest_ready",
5421 ),
5422 route_catalog_version_matches: query_runtime_preflight_alignment_bool(
5423 bundle,
5424 "route_catalog_version_matches",
5425 ),
5426 route_catalog_digest_matches: query_runtime_preflight_alignment_bool(
5427 bundle,
5428 "route_catalog_digest_matches",
5429 ),
5430 blocker_codes: blocker_codes(
5431 bundle,
5432 &[
5433 &["query_runtime_preflight", "blocker_codes"][..],
5434 &[
5435 "replacement_summary",
5436 "query_runtime_preflight",
5437 "blocker_codes",
5438 ][..],
5439 &[
5440 "replacement_summary_query_runtime_alignment",
5441 "blocker_codes",
5442 ][..],
5443 ],
5444 ),
5445 }
5446}
5447
5448fn query_runtime_preflight_alignment_bool(bundle: &serde_json::Value, field: &str) -> bool {
5449 bool_path(
5450 bundle,
5451 &["replacement_summary_query_runtime_alignment", field],
5452 ) == Some(true)
5453}
5454
5455fn query_runtime_preflight_alignment_cutover_conditions(
5456 readiness: &QueryRuntimePreflightAlignmentCutoverReadiness,
5457) -> Vec<(&'static str, bool)> {
5458 vec![
5459 (
5460 "replacement_summary_query_runtime_alignment.ready",
5461 readiness.ready,
5462 ),
5463 (
5464 "replacement_summary_query_runtime_alignment.evidence_ready",
5465 readiness.evidence_ready,
5466 ),
5467 (
5468 "replacement_summary_query_runtime_alignment.summary_ready",
5469 readiness.summary_ready,
5470 ),
5471 (
5472 "replacement_summary_query_runtime_alignment.protocol_matches",
5473 readiness.protocol_matches,
5474 ),
5475 (
5476 "replacement_summary_query_runtime_alignment.readiness_matches",
5477 readiness.readiness_matches,
5478 ),
5479 (
5480 "replacement_summary_query_runtime_alignment.database_opened_matches",
5481 readiness.database_opened_matches,
5482 ),
5483 (
5484 "replacement_summary_query_runtime_alignment.probe_count_matches",
5485 readiness.probe_count_matches,
5486 ),
5487 (
5488 "replacement_summary_query_runtime_alignment.passed_probe_count_matches",
5489 readiness.passed_probe_count_matches,
5490 ),
5491 (
5492 "replacement_summary_query_runtime_alignment.failed_probe_count_matches",
5493 readiness.failed_probe_count_matches,
5494 ),
5495 (
5496 "replacement_summary_query_runtime_alignment.required_route_count_matches",
5497 readiness.required_route_count_matches,
5498 ),
5499 (
5500 "replacement_summary_query_runtime_alignment.covered_route_count_matches",
5501 readiness.covered_route_count_matches,
5502 ),
5503 (
5504 "replacement_summary_query_runtime_alignment.covered_routes_matches",
5505 readiness.covered_routes_matches,
5506 ),
5507 (
5508 "replacement_summary_query_runtime_alignment.required_routes_covered_matches",
5509 readiness.required_routes_covered_matches,
5510 ),
5511 (
5512 "replacement_summary_query_runtime_alignment.route_coverage_ready_matches",
5513 readiness.route_coverage_ready_matches,
5514 ),
5515 (
5516 "replacement_summary_query_runtime_alignment.evidence_route_catalog_version_ready",
5517 readiness.evidence_route_catalog_version_ready,
5518 ),
5519 (
5520 "replacement_summary_query_runtime_alignment.summary_route_catalog_version_ready",
5521 readiness.summary_route_catalog_version_ready,
5522 ),
5523 (
5524 "replacement_summary_query_runtime_alignment.evidence_route_catalog_digest_ready",
5525 readiness.evidence_route_catalog_digest_ready,
5526 ),
5527 (
5528 "replacement_summary_query_runtime_alignment.summary_route_catalog_digest_ready",
5529 readiness.summary_route_catalog_digest_ready,
5530 ),
5531 (
5532 "replacement_summary_query_runtime_alignment.route_catalog_version_matches",
5533 readiness.route_catalog_version_matches,
5534 ),
5535 (
5536 "replacement_summary_query_runtime_alignment.route_catalog_digest_matches",
5537 readiness.route_catalog_digest_matches,
5538 ),
5539 ]
5540}
5541
5542fn query_runtime_scan_pruning_report_ready(report: &serde_json::Value) -> bool {
5543 scan_pruning_target_kind_ready(report)
5544 && json_get_path(report, &["strategy"]).is_some_and(serde_json::Value::is_object)
5545 && bool_path(report, &["pruned"]).is_some()
5546 && bool_path(report, &["exact_empty"]).is_some()
5547 && u64_path(report, &["candidate_count_before_pruning"]).is_some()
5548 && u64_path(report, &["pruned_candidate_count"]).is_some()
5549 && u64_path(report, &["candidate_count_before_filter"]).is_some()
5550 && u64_path(report, &["output_count"]).is_some()
5551 && u64_path(report, &["filtered_out_count"]).is_some()
5552}
5553
5554fn scan_pruning_target_kind_ready(report: &serde_json::Value) -> bool {
5555 matches!(
5556 str_path(report, &["target_kind"]),
5557 Some("node" | "relationship")
5558 )
5559}
5560
5561pub fn library_readiness_cutover_readiness(
5562 bundle: &serde_json::Value,
5563) -> LibraryReadinessCutoverReadiness {
5564 LibraryReadinessCutoverReadiness {
5565 protocol_matches: str_path(bundle, &["library_readiness", "protocol"])
5566 == Some(LIBRARY_READINESS_PROTOCOL),
5567 present: bool_path(bundle, &["library_readiness", "present"]) == Some(true),
5568 ready: bool_path(bundle, &["library_readiness", "ready"]) == Some(true),
5569 production_path_ready: bool_path(
5570 bundle,
5571 &["library_readiness", "production_path", "ready"],
5572 ) == Some(true),
5573 production_path_in_process: bool_path(
5574 bundle,
5575 &["library_readiness", "production_path", "in_process"],
5576 ) == Some(true),
5577 production_path_cli_not_required: bool_path(
5578 bundle,
5579 &["library_readiness", "production_path", "cli_required"],
5580 ) == Some(false),
5581 production_path_env_control_plane_not_required: bool_path(
5582 bundle,
5583 &[
5584 "library_readiness",
5585 "production_path",
5586 "env_control_plane_required",
5587 ],
5588 ) == Some(false),
5589 production_path_spawned_helper_not_required: bool_path(
5590 bundle,
5591 &[
5592 "library_readiness",
5593 "production_path",
5594 "spawned_helper_required",
5595 ],
5596 ) == Some(false),
5597 ready_area_count_present: u64_path(bundle, &["library_readiness", "ready_area_count"])
5598 .is_some_and(|value| value > 0),
5599 blocked_area_count_zero: u64_path(bundle, &["library_readiness", "blocked_area_count"])
5600 == Some(0),
5601 redaction_ready: bool_path(bundle, &["library_readiness", "redaction", "ready"])
5602 == Some(true),
5603 query_text_redacted: bool_path(
5604 bundle,
5605 &["library_readiness", "redaction", "query_text_copied"],
5606 ) == Some(false),
5607 parameters_redacted: bool_path(
5608 bundle,
5609 &["library_readiness", "redaction", "parameters_copied"],
5610 ) == Some(false),
5611 local_paths_redacted: bool_path(
5612 bundle,
5613 &["library_readiness", "redaction", "local_paths_copied"],
5614 ) == Some(false),
5615 graph_opened: bool_path(
5616 bundle,
5617 &["library_readiness", "open_report", "graph_opened"],
5618 ) == Some(true),
5619 search_projection_opened: bool_path(
5620 bundle,
5621 &[
5622 "library_readiness",
5623 "open_report",
5624 "search_projection_opened",
5625 ],
5626 ) == Some(true),
5627 graph_ready: library_readiness_area_ready(bundle, "graph"),
5628 query_ready: library_readiness_area_ready(bundle, "query"),
5629 storage_ready: library_readiness_area_ready(bundle, "storage"),
5630 background_ready: library_readiness_area_ready(bundle, "background"),
5631 query_family_ready: library_readiness_area_ready(bundle, "query_family"),
5632 graph_route_ready: library_readiness_area_ready(bundle, "graph_route"),
5633 search_route_ownership_ready: library_readiness_area_ready(
5634 bundle,
5635 "search_route_ownership",
5636 ),
5637 search_projection_ready: library_readiness_area_ready(bundle, "search_projection"),
5638 search_projection_shadow_ready: library_readiness_area_ready(
5639 bundle,
5640 "search_projection_shadow",
5641 ),
5642 search_candidate_shadow_ready: library_readiness_area_ready(
5643 bundle,
5644 "search_candidate_shadow",
5645 ),
5646 workload_fixture_ready: library_readiness_area_ready(bundle, "workload_fixture"),
5647 production_resource_profile_ready: json_get_path(
5648 bundle,
5649 &["library_readiness", "production_resource_profile"],
5650 )
5651 .is_some_and(production_resource_profile_ready),
5652 blocker_codes: blocker_codes(
5653 bundle,
5654 &[
5655 &["library_readiness", "blocker_codes"][..],
5656 &[
5657 "library_readiness",
5658 "readiness_by_area",
5659 "graph",
5660 "blocker_codes",
5661 ][..],
5662 &[
5663 "library_readiness",
5664 "readiness_by_area",
5665 "query",
5666 "blocker_codes",
5667 ][..],
5668 &[
5669 "library_readiness",
5670 "readiness_by_area",
5671 "storage",
5672 "blocker_codes",
5673 ][..],
5674 &[
5675 "library_readiness",
5676 "readiness_by_area",
5677 "background",
5678 "blocker_codes",
5679 ][..],
5680 &[
5681 "library_readiness",
5682 "readiness_by_area",
5683 "query_family",
5684 "blocker_codes",
5685 ][..],
5686 &[
5687 "library_readiness",
5688 "readiness_by_area",
5689 "graph_route",
5690 "blocker_codes",
5691 ][..],
5692 &[
5693 "library_readiness",
5694 "readiness_by_area",
5695 "search_route_ownership",
5696 "blocker_codes",
5697 ][..],
5698 &[
5699 "library_readiness",
5700 "readiness_by_area",
5701 "search_projection",
5702 "blocker_codes",
5703 ][..],
5704 &[
5705 "library_readiness",
5706 "readiness_by_area",
5707 "search_projection_shadow",
5708 "blocker_codes",
5709 ][..],
5710 &[
5711 "library_readiness",
5712 "readiness_by_area",
5713 "search_candidate_shadow",
5714 "blocker_codes",
5715 ][..],
5716 &[
5717 "library_readiness",
5718 "readiness_by_area",
5719 "workload_fixture",
5720 "blocker_codes",
5721 ][..],
5722 ],
5723 ),
5724 }
5725}
5726
5727fn library_readiness_cutover_conditions(
5728 readiness: &LibraryReadinessCutoverReadiness,
5729) -> Vec<(&'static str, bool)> {
5730 vec![
5731 ("library_readiness.protocol", readiness.protocol_matches),
5732 ("library_readiness.present", readiness.present),
5733 ("library_readiness.ready", readiness.ready),
5734 (
5735 "library_readiness.production_path.ready",
5736 readiness.production_path_ready,
5737 ),
5738 (
5739 "library_readiness.production_path.in_process",
5740 readiness.production_path_in_process,
5741 ),
5742 (
5743 "library_readiness.production_path.cli_required",
5744 readiness.production_path_cli_not_required,
5745 ),
5746 (
5747 "library_readiness.production_path.env_control_plane_required",
5748 readiness.production_path_env_control_plane_not_required,
5749 ),
5750 (
5751 "library_readiness.production_path.spawned_helper_required",
5752 readiness.production_path_spawned_helper_not_required,
5753 ),
5754 (
5755 "library_readiness.ready_area_count",
5756 readiness.ready_area_count_present,
5757 ),
5758 (
5759 "library_readiness.blocked_area_count",
5760 readiness.blocked_area_count_zero,
5761 ),
5762 (
5763 "library_readiness.redaction.ready",
5764 readiness.redaction_ready,
5765 ),
5766 (
5767 "library_readiness.redaction.query_text_copied",
5768 readiness.query_text_redacted,
5769 ),
5770 (
5771 "library_readiness.redaction.parameters_copied",
5772 readiness.parameters_redacted,
5773 ),
5774 (
5775 "library_readiness.redaction.local_paths_copied",
5776 readiness.local_paths_redacted,
5777 ),
5778 (
5779 "library_readiness.open_report.graph_opened",
5780 readiness.graph_opened,
5781 ),
5782 (
5783 "library_readiness.open_report.search_projection_opened",
5784 readiness.search_projection_opened,
5785 ),
5786 (
5787 "library_readiness.readiness_by_area.graph.ready",
5788 readiness.graph_ready,
5789 ),
5790 (
5791 "library_readiness.readiness_by_area.query.ready",
5792 readiness.query_ready,
5793 ),
5794 (
5795 "library_readiness.readiness_by_area.storage.ready",
5796 readiness.storage_ready,
5797 ),
5798 (
5799 "library_readiness.readiness_by_area.background.ready",
5800 readiness.background_ready,
5801 ),
5802 (
5803 "library_readiness.readiness_by_area.query_family.ready",
5804 readiness.query_family_ready,
5805 ),
5806 (
5807 "library_readiness.readiness_by_area.graph_route.ready",
5808 readiness.graph_route_ready,
5809 ),
5810 (
5811 "library_readiness.readiness_by_area.search_route_ownership.ready",
5812 readiness.search_route_ownership_ready,
5813 ),
5814 (
5815 "library_readiness.readiness_by_area.search_projection.ready",
5816 readiness.search_projection_ready,
5817 ),
5818 (
5819 "library_readiness.readiness_by_area.search_projection_shadow.ready",
5820 readiness.search_projection_shadow_ready,
5821 ),
5822 (
5823 "library_readiness.readiness_by_area.search_candidate_shadow.ready",
5824 readiness.search_candidate_shadow_ready,
5825 ),
5826 (
5827 "library_readiness.readiness_by_area.workload_fixture.ready",
5828 readiness.workload_fixture_ready,
5829 ),
5830 (
5831 "library_readiness.production_resource_profile",
5832 readiness.production_resource_profile_ready,
5833 ),
5834 ]
5835}
5836
5837fn library_readiness_area_ready(bundle: &serde_json::Value, area: &str) -> bool {
5838 json_get_path(
5839 bundle,
5840 &["library_readiness", "readiness_by_area", area, "ready"],
5841 )
5842 .and_then(serde_json::Value::as_bool)
5843 == Some(true)
5844}
5845
5846pub fn cutover_controls_readiness(bundle: &serde_json::Value) -> CutoverControlsReadiness {
5847 let initial_import_enabled = bool_path(
5848 bundle,
5849 &["cutover_controls", "work", "initial_import_enabled"],
5850 ) == Some(true);
5851 let dual_writes_enabled =
5852 bool_path(bundle, &["cutover_controls", "work", "dual_writes_enabled"]) == Some(true);
5853 let initial_import_inactive_for_cutover = bool_path(
5854 bundle,
5855 &[
5856 "cutover_controls",
5857 "work",
5858 "initial_import_inactive_for_cutover",
5859 ],
5860 ) == Some(true);
5861 let initial_import_cutover_catch_up_ready = bool_path(
5862 bundle,
5863 &[
5864 "cutover_controls",
5865 "work",
5866 "initial_import_cutover_catch_up_ready",
5867 ],
5868 ) == Some(true);
5869 CutoverControlsReadiness {
5870 protocol_matches: str_path(bundle, &["cutover_controls", "protocol"])
5871 == Some(CUTOVER_CONTROLS_PROTOCOL),
5872 ready: bool_path(bundle, &["cutover_controls", "ready"]) == Some(true),
5873 graph_reads_hawdb: str_path(bundle, &["cutover_controls", "controls", "graph_reads"])
5874 == Some("hawdb"),
5875 graph_read_effective: bool_path(bundle, &["cutover_controls", "graph", "read_effective"])
5876 == Some(true),
5877 graph_production_status_effective: bool_path(
5878 bundle,
5879 &[
5880 "cutover_controls",
5881 "production_status",
5882 "graph",
5883 "hawdb_cutover_effective",
5884 ],
5885 ) == Some(true),
5886 search_reads_hawdb: str_path(bundle, &["cutover_controls", "controls", "search_reads"])
5887 == Some("hawdb"),
5888 search_read_effective: bool_path(bundle, &["cutover_controls", "search", "read_effective"])
5889 == Some(true),
5890 search_production_status_effective: bool_path(
5891 bundle,
5892 &[
5893 "cutover_controls",
5894 "production_status",
5895 "search",
5896 "hawdb_cutover_effective",
5897 ],
5898 ) == Some(true),
5899 dual_writes_enabled,
5900 projection_catch_up_enabled: bool_path(
5901 bundle,
5902 &["cutover_controls", "work", "projection_catch_up_enabled"],
5903 ) == Some(true),
5904 initial_import_safe: !initial_import_enabled || dual_writes_enabled,
5905 initial_import_inactive_for_cutover,
5906 initial_import_cutover_catch_up_ready,
5907 initial_import_safe_for_read_cutover: initial_import_inactive_for_cutover
5908 || initial_import_cutover_catch_up_ready,
5909 query_text_redacted: bool_path(
5910 bundle,
5911 &["cutover_controls", "redaction", "query_text_copied"],
5912 ) == Some(false),
5913 parameters_redacted: bool_path(
5914 bundle,
5915 &["cutover_controls", "redaction", "parameters_copied"],
5916 ) == Some(false),
5917 local_paths_redacted: bool_path(
5918 bundle,
5919 &["cutover_controls", "redaction", "local_paths_copied"],
5920 ) == Some(false),
5921 blocker_codes: blocker_codes(
5922 bundle,
5923 &[
5924 &["cutover_controls", "blocker_codes"][..],
5925 &["cutover_controls", "production_status", "blocker_codes"][..],
5926 ],
5927 ),
5928 }
5929}
5930
5931fn cutover_controls_conditions(readiness: &CutoverControlsReadiness) -> Vec<(&'static str, bool)> {
5932 vec![
5933 ("cutover_controls.protocol", readiness.protocol_matches),
5934 ("cutover_controls.ready", readiness.ready),
5935 (
5936 "cutover_controls.controls.graph_reads",
5937 readiness.graph_reads_hawdb,
5938 ),
5939 (
5940 "cutover_controls.graph.read_effective",
5941 readiness.graph_read_effective,
5942 ),
5943 (
5944 "cutover_controls.production_status.graph.hawdb_cutover_effective",
5945 readiness.graph_production_status_effective,
5946 ),
5947 (
5948 "cutover_controls.controls.search_reads",
5949 readiness.search_reads_hawdb,
5950 ),
5951 (
5952 "cutover_controls.search.read_effective",
5953 readiness.search_read_effective,
5954 ),
5955 (
5956 "cutover_controls.production_status.search.hawdb_cutover_effective",
5957 readiness.search_production_status_effective,
5958 ),
5959 (
5960 "cutover_controls.work.dual_writes_enabled",
5961 readiness.dual_writes_enabled,
5962 ),
5963 (
5964 "cutover_controls.work.projection_catch_up_enabled",
5965 readiness.projection_catch_up_enabled,
5966 ),
5967 (
5968 "cutover_controls.work.initial_import_enabled",
5969 readiness.initial_import_safe,
5970 ),
5971 (
5972 "cutover_controls.work.initial_import_safe_for_read_cutover",
5973 readiness.initial_import_safe_for_read_cutover,
5974 ),
5975 (
5976 "cutover_controls.redaction.query_text_copied",
5977 readiness.query_text_redacted,
5978 ),
5979 (
5980 "cutover_controls.redaction.parameters_copied",
5981 readiness.parameters_redacted,
5982 ),
5983 (
5984 "cutover_controls.redaction.local_paths_copied",
5985 readiness.local_paths_redacted,
5986 ),
5987 ]
5988}
5989
5990pub fn operations_readiness_cutover_readiness(
5991 bundle: &serde_json::Value,
5992) -> OperationsReadinessCutoverReadiness {
5993 OperationsReadinessCutoverReadiness {
5994 protocol_matches: str_path(bundle, &["operations_readiness", "protocol"])
5995 == Some(OPERATIONS_READINESS_PROTOCOL),
5996 present: bool_path(bundle, &["operations_readiness", "present"]) == Some(true),
5997 ready: bool_path(bundle, &["operations_readiness", "ready"]) == Some(true),
5998 graph_open: bool_path(bundle, &["operations_readiness", "graph", "open"]) == Some(true),
5999 graph_writable: bool_path(bundle, &["operations_readiness", "graph", "read_only"])
6000 == Some(false),
6001 search_projection_open: bool_path(
6002 bundle,
6003 &["operations_readiness", "search_projection", "open"],
6004 ) == Some(true),
6005 search_projection_not_stale: bool_path(
6006 bundle,
6007 &["operations_readiness", "search_projection", "stale"],
6008 ) == Some(false),
6009 storage_lifecycle_ready: bool_path(
6010 bundle,
6011 &["operations_readiness", "storage_lifecycle", "ready"],
6012 ) == Some(true),
6013 storage_lifecycle_action_ready: str_path(
6014 bundle,
6015 &["operations_readiness", "storage_lifecycle", "action"],
6016 ) == Some("ready"),
6017 storage_recovery_ready: bool_path(
6018 bundle,
6019 &[
6020 "operations_readiness",
6021 "readiness",
6022 "storage_recovery_ready",
6023 ],
6024 ) == Some(true),
6025 slow_query_ready: bool_path(
6026 bundle,
6027 &["operations_readiness", "readiness", "slow_query_ready"],
6028 ) == Some(true),
6029 background_maintenance_ready: bool_path(
6030 bundle,
6031 &[
6032 "operations_readiness",
6033 "readiness",
6034 "background_maintenance_ready",
6035 ],
6036 ) == Some(true),
6037 query_text_redacted: bool_path(
6038 bundle,
6039 &["operations_readiness", "redaction", "query_text_copied"],
6040 ) == Some(false),
6041 parameters_redacted: bool_path(
6042 bundle,
6043 &["operations_readiness", "redaction", "parameters_copied"],
6044 ) == Some(false),
6045 local_paths_redacted: bool_path(
6046 bundle,
6047 &["operations_readiness", "redaction", "local_paths_copied"],
6048 ) == Some(false),
6049 blocker_codes: blocker_codes(bundle, &[&["operations_readiness", "blocker_codes"][..]]),
6050 }
6051}
6052
6053fn operations_readiness_cutover_conditions(
6054 readiness: &OperationsReadinessCutoverReadiness,
6055) -> Vec<(&'static str, bool)> {
6056 vec![
6057 ("operations_readiness.protocol", readiness.protocol_matches),
6058 ("operations_readiness.present", readiness.present),
6059 ("operations_readiness.ready", readiness.ready),
6060 ("operations_readiness.graph.open", readiness.graph_open),
6061 (
6062 "operations_readiness.graph.read_only",
6063 readiness.graph_writable,
6064 ),
6065 (
6066 "operations_readiness.search_projection.open",
6067 readiness.search_projection_open,
6068 ),
6069 (
6070 "operations_readiness.search_projection.stale",
6071 readiness.search_projection_not_stale,
6072 ),
6073 (
6074 "operations_readiness.storage_lifecycle.ready",
6075 readiness.storage_lifecycle_ready,
6076 ),
6077 (
6078 "operations_readiness.storage_lifecycle.action",
6079 readiness.storage_lifecycle_action_ready,
6080 ),
6081 (
6082 "operations_readiness.readiness.storage_recovery_ready",
6083 readiness.storage_recovery_ready,
6084 ),
6085 (
6086 "operations_readiness.readiness.slow_query_ready",
6087 readiness.slow_query_ready,
6088 ),
6089 (
6090 "operations_readiness.readiness.background_maintenance_ready",
6091 readiness.background_maintenance_ready,
6092 ),
6093 (
6094 "operations_readiness.redaction.query_text_copied",
6095 readiness.query_text_redacted,
6096 ),
6097 (
6098 "operations_readiness.redaction.parameters_copied",
6099 readiness.parameters_redacted,
6100 ),
6101 (
6102 "operations_readiness.redaction.local_paths_copied",
6103 readiness.local_paths_redacted,
6104 ),
6105 ]
6106}
6107
6108pub fn storage_recovery_cutover_readiness(
6109 bundle: &serde_json::Value,
6110) -> StorageRecoveryCutoverReadiness {
6111 StorageRecoveryCutoverReadiness {
6112 required: bool_path(
6113 bundle,
6114 &[
6115 "replacement_summary",
6116 "cutover_evidence",
6117 "storage_recovery_required",
6118 ],
6119 ) == Some(true),
6120 ready: bool_path(
6121 bundle,
6122 &[
6123 "replacement_summary",
6124 "cutover_evidence",
6125 "storage_recovery_ready",
6126 ],
6127 ) == Some(true),
6128 protocol_matches: bool_path(
6129 bundle,
6130 &[
6131 "replacement_summary",
6132 "cutover_evidence",
6133 "storage_recovery_protocol_matches",
6134 ],
6135 ) == Some(true),
6136 durable: bool_path(
6137 bundle,
6138 &[
6139 "replacement_summary",
6140 "cutover_evidence",
6141 "storage_recovery_durable",
6142 ],
6143 ) == Some(true),
6144 checkpoint_boundary_present: bool_path(
6145 bundle,
6146 &[
6147 "replacement_summary",
6148 "cutover_evidence",
6149 "storage_recovery_checkpoint_boundary_present",
6150 ],
6151 ) == Some(true),
6152 wal_replay_bounded: bool_path(
6153 bundle,
6154 &[
6155 "replacement_summary",
6156 "cutover_evidence",
6157 "storage_recovery_wal_replay_bounded",
6158 ],
6159 ) == Some(true),
6160 replay_boundary_consistent: bool_path(
6161 bundle,
6162 &[
6163 "replacement_summary",
6164 "cutover_evidence",
6165 "storage_recovery_replay_boundary_consistent",
6166 ],
6167 ) == Some(true),
6168 torn_tail_clean: bool_path(
6169 bundle,
6170 &[
6171 "replacement_summary",
6172 "cutover_evidence",
6173 "storage_recovery_torn_tail_clean",
6174 ],
6175 ) == Some(true),
6176 blocker_codes: blocker_codes(
6177 bundle,
6178 &[
6179 &[
6180 "replacement_summary",
6181 "cutover_evidence",
6182 "storage_recovery_blocker_codes",
6183 ][..],
6184 &[
6185 "replacement_summary",
6186 "cutover_evidence",
6187 "storage_recovery_blockers",
6188 ][..],
6189 ],
6190 ),
6191 }
6192}
6193
6194fn storage_recovery_cutover_conditions(
6195 readiness: &StorageRecoveryCutoverReadiness,
6196) -> Vec<(&'static str, bool)> {
6197 vec![
6198 (
6199 "replacement_summary.cutover_evidence.storage_recovery_required",
6200 readiness.required,
6201 ),
6202 (
6203 "replacement_summary.cutover_evidence.storage_recovery_ready",
6204 readiness.ready,
6205 ),
6206 (
6207 "replacement_summary.cutover_evidence.storage_recovery_protocol_matches",
6208 readiness.protocol_matches,
6209 ),
6210 (
6211 "replacement_summary.cutover_evidence.storage_recovery_durable",
6212 readiness.durable,
6213 ),
6214 (
6215 "replacement_summary.cutover_evidence.storage_recovery_checkpoint_boundary_present",
6216 readiness.checkpoint_boundary_present,
6217 ),
6218 (
6219 "replacement_summary.cutover_evidence.storage_recovery_wal_replay_bounded",
6220 readiness.wal_replay_bounded,
6221 ),
6222 (
6223 "replacement_summary.cutover_evidence.storage_recovery_replay_boundary_consistent",
6224 readiness.replay_boundary_consistent,
6225 ),
6226 (
6227 "replacement_summary.cutover_evidence.storage_recovery_torn_tail_clean",
6228 readiness.torn_tail_clean,
6229 ),
6230 ]
6231}
6232
6233fn bounded_read_execution_cap_matches(bundle: &serde_json::Value) -> bool {
6234 let max_rows = u64_path(
6235 bundle,
6236 &["replacement_summary", "bounded_read_evidence", "max_rows"],
6237 );
6238 let execution_row_cap = u64_path(
6239 bundle,
6240 &[
6241 "replacement_summary",
6242 "bounded_read_evidence",
6243 "execution_row_cap",
6244 ],
6245 );
6246 max_rows.and_then(|value| value.checked_add(1)) == execution_row_cap
6247}
6248
6249pub fn background_maintenance_cutover_readiness(
6250 bundle: &serde_json::Value,
6251) -> BackgroundMaintenanceCutoverReadiness {
6252 BackgroundMaintenanceCutoverReadiness {
6253 required: bool_path(
6254 bundle,
6255 &[
6256 "replacement_summary",
6257 "cutover_evidence",
6258 "background_maintenance_required",
6259 ],
6260 ) == Some(true),
6261 ready: bool_path(
6262 bundle,
6263 &[
6264 "replacement_summary",
6265 "cutover_evidence",
6266 "background_maintenance_ready",
6267 ],
6268 ) == Some(true),
6269 protocol_matches: bool_path(
6270 bundle,
6271 &[
6272 "replacement_summary",
6273 "cutover_evidence",
6274 "background_maintenance_protocol_matches",
6275 ],
6276 ) == Some(true),
6277 executable_search_projection_graph_delta_count_present: u64_path(
6278 bundle,
6279 &[
6280 "replacement_summary",
6281 "cutover_evidence",
6282 "background_maintenance_executable_search_projection_graph_delta_count",
6283 ],
6284 )
6285 .is_some(),
6286 admitted_search_projection_graph_delta_count_present: u64_path(
6287 bundle,
6288 &[
6289 "replacement_summary",
6290 "cutover_evidence",
6291 "background_maintenance_admitted_search_projection_graph_delta_count",
6292 ],
6293 )
6294 .is_some(),
6295 deferred_search_projection_graph_delta_count_present: u64_path(
6296 bundle,
6297 &[
6298 "replacement_summary",
6299 "cutover_evidence",
6300 "background_maintenance_deferred_search_projection_graph_delta_count",
6301 ],
6302 )
6303 .is_some(),
6304 rejected_search_projection_graph_delta_count_present: u64_path(
6305 bundle,
6306 &[
6307 "replacement_summary",
6308 "cutover_evidence",
6309 "background_maintenance_rejected_search_projection_graph_delta_count",
6310 ],
6311 )
6312 .is_some(),
6313 executable_search_projection_graph_delta_operations_present: u64_path(
6314 bundle,
6315 &[
6316 "replacement_summary",
6317 "cutover_evidence",
6318 "background_maintenance_executable_search_projection_graph_delta_operations",
6319 ],
6320 )
6321 .is_some(),
6322 admitted_search_projection_graph_delta_operations_present: u64_path(
6323 bundle,
6324 &[
6325 "replacement_summary",
6326 "cutover_evidence",
6327 "background_maintenance_admitted_search_projection_graph_delta_operations",
6328 ],
6329 )
6330 .is_some(),
6331 max_search_projection_graph_delta_complete_through_graph_commit_epoch_present: u64_path(
6332 bundle,
6333 &[
6334 "replacement_summary",
6335 "cutover_evidence",
6336 "background_maintenance_max_search_projection_graph_delta_complete_through_graph_commit_epoch",
6337 ],
6338 )
6339 .is_some(),
6340 foreground_admission_probe_ready: bool_path(
6341 bundle,
6342 &[
6343 "replacement_summary",
6344 "cutover_evidence",
6345 "background_maintenance_foreground_admission_probe_ready",
6346 ],
6347 ) == Some(true),
6348 memory_pressure_ready: bool_path(
6349 bundle,
6350 &[
6351 "replacement_summary",
6352 "cutover_evidence",
6353 "background_maintenance_memory_pressure_ready",
6354 ],
6355 ) == Some(true),
6356 memory_budget_bytes_present: u64_path(
6357 bundle,
6358 &[
6359 "replacement_summary",
6360 "cutover_evidence",
6361 "background_maintenance_memory_budget_bytes",
6362 ],
6363 )
6364 .is_some(),
6365 estimated_memory_bytes_present: u64_path(
6366 bundle,
6367 &[
6368 "replacement_summary",
6369 "cutover_evidence",
6370 "background_maintenance_estimated_memory_bytes",
6371 ],
6372 )
6373 .is_some(),
6374 blocker_codes: blocker_codes(
6375 bundle,
6376 &[
6377 &[
6378 "replacement_summary",
6379 "cutover_evidence",
6380 "background_maintenance_blocker_codes",
6381 ][..],
6382 &[
6383 "replacement_summary",
6384 "cutover_evidence",
6385 "background_maintenance_blockers",
6386 ][..],
6387 ],
6388 ),
6389 }
6390}
6391
6392fn background_maintenance_cutover_conditions(
6393 readiness: &BackgroundMaintenanceCutoverReadiness,
6394) -> Vec<(&'static str, bool)> {
6395 vec![
6396 (
6397 "replacement_summary.cutover_evidence.background_maintenance_required",
6398 readiness.required,
6399 ),
6400 (
6401 "replacement_summary.cutover_evidence.background_maintenance_ready",
6402 readiness.ready,
6403 ),
6404 (
6405 "replacement_summary.cutover_evidence.background_maintenance_protocol_matches",
6406 readiness.protocol_matches,
6407 ),
6408 (
6409 "replacement_summary.cutover_evidence.background_maintenance_executable_search_projection_graph_delta_count",
6410 readiness.executable_search_projection_graph_delta_count_present,
6411 ),
6412 (
6413 "replacement_summary.cutover_evidence.background_maintenance_admitted_search_projection_graph_delta_count",
6414 readiness.admitted_search_projection_graph_delta_count_present,
6415 ),
6416 (
6417 "replacement_summary.cutover_evidence.background_maintenance_deferred_search_projection_graph_delta_count",
6418 readiness.deferred_search_projection_graph_delta_count_present,
6419 ),
6420 (
6421 "replacement_summary.cutover_evidence.background_maintenance_rejected_search_projection_graph_delta_count",
6422 readiness.rejected_search_projection_graph_delta_count_present,
6423 ),
6424 (
6425 "replacement_summary.cutover_evidence.background_maintenance_executable_search_projection_graph_delta_operations",
6426 readiness.executable_search_projection_graph_delta_operations_present,
6427 ),
6428 (
6429 "replacement_summary.cutover_evidence.background_maintenance_admitted_search_projection_graph_delta_operations",
6430 readiness.admitted_search_projection_graph_delta_operations_present,
6431 ),
6432 (
6433 "replacement_summary.cutover_evidence.background_maintenance_max_search_projection_graph_delta_complete_through_graph_commit_epoch",
6434 readiness.max_search_projection_graph_delta_complete_through_graph_commit_epoch_present,
6435 ),
6436 (
6437 "replacement_summary.cutover_evidence.background_maintenance_foreground_admission_probe_ready",
6438 readiness.foreground_admission_probe_ready,
6439 ),
6440 (
6441 "replacement_summary.cutover_evidence.background_maintenance_memory_pressure_ready",
6442 readiness.memory_pressure_ready,
6443 ),
6444 (
6445 "replacement_summary.cutover_evidence.background_maintenance_memory_budget_bytes",
6446 readiness.memory_budget_bytes_present,
6447 ),
6448 (
6449 "replacement_summary.cutover_evidence.background_maintenance_estimated_memory_bytes",
6450 readiness.estimated_memory_bytes_present,
6451 ),
6452 ]
6453}
6454
6455fn string_array_path(value: &serde_json::Value, path: &[&str]) -> Vec<String> {
6456 json_get_path(value, path)
6457 .and_then(serde_json::Value::as_array)
6458 .into_iter()
6459 .flatten()
6460 .filter_map(serde_json::Value::as_str)
6461 .map(str::to_string)
6462 .collect()
6463}
6464
6465fn string_array_path_is_empty(value: &serde_json::Value, path: &[&str]) -> bool {
6466 json_get_path(value, path)
6467 .and_then(serde_json::Value::as_array)
6468 .is_some_and(Vec::is_empty)
6469}
6470
6471fn search_projection_scan_filter_fields_cover_required(
6472 value: &serde_json::Value,
6473 path: &[&str],
6474) -> bool {
6475 let fields = string_array_path(value, path);
6476 NOWLEDGE_SEARCH_PROJECTION_SCAN_FILTER_FIELDS
6477 .iter()
6478 .all(|required| fields.iter().any(|field| field == required))
6479}
6480
6481fn search_projection_segment_descriptor_summaries_cover_required(
6482 value: &serde_json::Value,
6483 path: &[&str],
6484) -> bool {
6485 let Some(summaries) = json_get_path(value, path).and_then(serde_json::Value::as_array) else {
6486 return false;
6487 };
6488 if summaries.is_empty() {
6489 return false;
6490 }
6491 let fields = summaries
6492 .iter()
6493 .filter_map(|summary| str_path(summary, &["field"]))
6494 .collect::<BTreeSet<_>>();
6495 NOWLEDGE_SEARCH_PROJECTION_SCAN_FILTER_FIELDS
6496 .iter()
6497 .all(|required| fields.contains(required))
6498 && ["importance", "confidence"].iter().all(|field| {
6499 summaries.iter().any(|summary| {
6500 str_path(summary, &["field"]) == Some(*field)
6501 && bool_path(summary, &["numeric_range_summary_used"]) == Some(true)
6502 })
6503 })
6504 && ["created_at", "updated_at", "event_start", "event_end"]
6505 .iter()
6506 .all(|field| {
6507 summaries.iter().any(|summary| {
6508 str_path(summary, &["field"]) == Some(*field)
6509 && bool_path(summary, &["timestamp_range_summary_used"]) == Some(true)
6510 })
6511 })
6512 && summaries.iter().any(|summary| {
6513 str_path(summary, &["field"]) == Some("document_id")
6514 && bool_path(summary, &["unique_key_summary_used"]) == Some(true)
6515 && u64_path(summary, &["unique_key_summary_segment_count"])
6516 .is_some_and(|count| count > 0)
6517 })
6518}
6519
6520fn search_projection_segment_pruning_candidate_count_ready(
6521 value: &serde_json::Value,
6522 path: &[&str],
6523) -> bool {
6524 let mut candidate_path = path.to_vec();
6525 candidate_path.push("shadow_segment_pruning_candidate_document_count");
6526 let mut pruned_path = path.to_vec();
6527 pruned_path.push("shadow_segment_pruned_document_count");
6528 let mut scanned_path = path.to_vec();
6529 scanned_path.push("shadow_segment_scanned_document_count");
6530 matches!(
6531 (
6532 u64_path(value, &candidate_path),
6533 u64_path(value, &pruned_path),
6534 u64_path(value, &scanned_path),
6535 ),
6536 (Some(candidate), Some(pruned), Some(scanned))
6537 if candidate > 0 && pruned.checked_add(scanned) == Some(candidate)
6538 )
6539}
6540
6541fn search_projection_segment_pruning_count_is_positive(
6542 value: &serde_json::Value,
6543 path: &[&str],
6544 field: &str,
6545) -> bool {
6546 let mut count_path = path.to_vec();
6547 count_path.push(field);
6548 u64_path(value, &count_path).is_some_and(|count| count > 0)
6549}
6550
6551fn non_empty_str_path(value: &serde_json::Value, path: &[&str]) -> bool {
6552 str_path(value, path).is_some_and(|s| !s.trim().is_empty())
6553}
6554
6555fn json_object_path_is_non_empty(value: &serde_json::Value, path: &[&str]) -> bool {
6556 json_get_path(value, path)
6557 .and_then(serde_json::Value::as_object)
6558 .is_some_and(|object| !object.is_empty())
6559}
6560
6561fn bool_path(value: &serde_json::Value, path: &[&str]) -> Option<bool> {
6562 json_get_path(value, path).and_then(serde_json::Value::as_bool)
6563}
6564
6565fn u64_path(value: &serde_json::Value, path: &[&str]) -> Option<u64> {
6566 json_get_path(value, path).and_then(serde_json::Value::as_u64)
6567}
6568
6569fn str_path<'a>(value: &'a serde_json::Value, path: &[&str]) -> Option<&'a str> {
6570 json_get_path(value, path).and_then(serde_json::Value::as_str)
6571}
6572
6573fn json_get_path<'a>(value: &'a serde_json::Value, path: &[&str]) -> Option<&'a serde_json::Value> {
6574 let mut current = value;
6575 for key in path {
6576 current = current.get(*key)?;
6577 }
6578 Some(current)
6579}
6580
6581#[cfg(test)]
6582mod tests {
6583 use super::{
6584 integration_readiness_json, CUTOVER_CONTROLS_PROTOCOL,
6585 HAWDB_SEARCH_PROJECTION_SHADOW_EVIDENCE_SOURCE, OPERATIONS_READINESS_PROTOCOL,
6586 REQUIRED_SOURCE_MUTATION_FAMILIES, SOURCE_MUTATION_DUAL_WRITE_READINESS_PROTOCOL,
6587 };
6588 use hawdb_evidence::replacement_contract::{
6589 NOWLEDGE_SEARCH_PROJECTION_SCAN_FILTER_FIELDS, SEARCH_CANDIDATE_EVIDENCE_ROUTE,
6590 SEARCH_CANDIDATE_SHADOW_ENGINE, SEARCH_CANDIDATE_SHADOW_EVIDENCE_PROTOCOL,
6591 SEARCH_CANDIDATE_TRACE_EVIDENCE_SOURCE, SEARCH_CANDIDATE_TRACE_PRIMARY_ENGINE,
6592 SEARCH_CANDIDATE_TRACE_SHADOW_ENGINE,
6593 };
6594 use hawdb_route_ownership::graph::{
6595 graph_read_route_catalog_digest, graph_read_route_spec, graph_read_route_specs_json,
6596 route_ownership_all_hawdb, route_ownership_readiness, RouteOwnershipPolicy,
6597 RouteReadinessSummary, GRAPH_READ_ROUTE_CATALOG_VERSION, REQUIRED_BOUNDED_READ_ROUTES,
6598 };
6599 use hawdb_route_ownership::{
6600 active_search_route_ownership_all_hawdb, active_search_route_ownership_readiness,
6601 active_search_route_read_evidence_all_hawdb_ready, active_search_route_readiness,
6602 search_route_ownership_all_hawdb, search_route_ownership_readiness,
6603 SearchRouteOwnershipPolicy, REQUIRED_ACTIVE_SEARCH_ROUTES,
6604 };
6605 use hawdb_search::candidate_evidence::{
6606 search_candidate_shadow_evidence_json, SearchCandidateShadowAccumulator,
6607 };
6608 use std::path::PathBuf;
6609 use std::time::{SystemTime, UNIX_EPOCH};
6610
6611 #[test]
6612 fn reports_ready_when_mem_integration_evidence_is_complete() {
6613 let report = integration_readiness_json(&ready_bundle());
6614
6615 assert_eq!(report["ready"], true);
6616 assert_eq!(report["failed_checks"], serde_json::json!([]));
6617 assert_eq!(report["blocker_codes"], serde_json::json!([]));
6618 assert_eq!(report["next_actions"], serde_json::json!([]));
6619 }
6620
6621 #[test]
6622 fn integration_bundle_read_errors_are_redacted_by_default() {
6623 let secret_path = unique_test_path("integration-secret-path-do-not-emit")
6624 .join("missing-secret-bundle.json");
6625
6626 let error = super::read_json_file(&secret_path).unwrap_err().to_string();
6627
6628 assert_eq!(
6629 error,
6630 "execution error: failed to read Nowledge Mem integration bundle: io_error"
6631 );
6632 assert!(!error.contains("integration-secret-path-do-not-emit"));
6633 assert!(!error.contains("missing-secret-bundle"));
6634 }
6635
6636 #[test]
6637 fn integration_bundle_parse_errors_are_redacted_by_default() {
6638 let root = unique_test_path("integration-parse-redaction");
6639 std::fs::create_dir_all(&root).unwrap();
6640 let path = root.join("secret-bundle-path-do-not-emit.json");
6641 std::fs::write(
6642 &path,
6643 "{ \"secret\": \"bundle-parse-secret-do-not-emit\", \"unterminated\": ",
6644 )
6645 .unwrap();
6646
6647 let error = super::read_json_file(&path).unwrap_err().to_string();
6648
6649 assert_eq!(
6650 error,
6651 "execution error: failed to parse Nowledge Mem integration bundle: invalid_json"
6652 );
6653 assert!(!error.contains("secret-bundle-path-do-not-emit"));
6654 assert!(!error.contains("bundle-parse-secret-do-not-emit"));
6655 std::fs::remove_dir_all(root).unwrap();
6656 }
6657
6658 #[test]
6659 fn typed_integration_readiness_api_exposes_structured_gate() {
6660 let report = super::integration_readiness(&ready_bundle());
6661
6662 assert!(report.ready);
6663 assert_eq!(report.protocol, super::INTEGRATION_READINESS_PROTOCOL);
6664 assert!(report.failed_checks.is_empty());
6665 assert!(report.blocker_codes.is_empty());
6666 assert!(report.next_actions.is_empty());
6667 assert!(report.checks.iter().all(|check| check.ready));
6668 assert!(report
6669 .checks
6670 .iter()
6671 .any(|check| check.name == "query_runtime_preflight"));
6672 assert!(report
6673 .checks
6674 .iter()
6675 .any(|check| check.name == "blackbox_redaction"));
6676 assert!(report
6677 .checks
6678 .iter()
6679 .any(|check| check.name == "blackbox_operational_evidence"));
6680 assert_eq!(report.json()["ready"], true);
6681 }
6682
6683 #[test]
6684 fn requires_blackbox_redaction_manifest() {
6685 let mut bundle = ready_bundle();
6686 bundle.as_object_mut().unwrap().remove("blackbox_manifest");
6687
6688 let report = integration_readiness_json(&bundle);
6689
6690 assert_eq!(report["ready"], false);
6691 assert!(report["failed_checks"]
6692 .as_array()
6693 .unwrap()
6694 .iter()
6695 .any(|check| check == "blackbox_redaction"));
6696 let blackbox_check = report["checks"]
6697 .as_array()
6698 .unwrap()
6699 .iter()
6700 .find(|check| check["name"] == "blackbox_redaction")
6701 .unwrap();
6702 assert_eq!(
6703 blackbox_check["failed_evidence_fields"],
6704 serde_json::json!([
6705 "blackbox_manifest.protocol",
6706 "blackbox_manifest.artifact_dir_present",
6707 "blackbox_manifest.artifact_count",
6708 "blackbox_manifest.events_path",
6709 "blackbox_manifest.redaction.raw_query_text_copied",
6710 "blackbox_manifest.redaction.raw_parameters_copied",
6711 "blackbox_manifest.redaction.raw_artifact_payloads_copied",
6712 "blackbox_manifest.redaction.artifact_paths_are_relative"
6713 ])
6714 );
6715 assert!(report["next_actions"]
6716 .as_array()
6717 .unwrap()
6718 .iter()
6719 .any(|action| action["action"] == "attach_blackbox_redaction_report"));
6720 }
6721
6722 #[test]
6723 fn rejects_blackbox_manifest_that_copies_raw_query_text() {
6724 let mut bundle = ready_bundle();
6725 bundle["blackbox_manifest"]["redaction"]["raw_query_text_copied"] = serde_json::json!(true);
6726
6727 let report = integration_readiness_json(&bundle);
6728
6729 assert_eq!(report["ready"], false);
6730 let blackbox_check = report["checks"]
6731 .as_array()
6732 .unwrap()
6733 .iter()
6734 .find(|check| check["name"] == "blackbox_redaction")
6735 .unwrap();
6736 assert_eq!(
6737 blackbox_check["failed_evidence_fields"],
6738 serde_json::json!(["blackbox_manifest.redaction.raw_query_text_copied"])
6739 );
6740 }
6741
6742 #[test]
6743 fn requires_blackbox_slow_query_artifact_summary() {
6744 let mut bundle = ready_bundle();
6745 bundle["blackbox_manifest"]["artifacts"] =
6746 serde_json::json!([ready_blackbox_background_maintenance_artifact()]);
6747
6748 let report = integration_readiness_json(&bundle);
6749
6750 assert_eq!(report["ready"], false);
6751 let blackbox_check = report["checks"]
6752 .as_array()
6753 .unwrap()
6754 .iter()
6755 .find(|check| check["name"] == "blackbox_operational_evidence")
6756 .unwrap();
6757 assert_eq!(
6758 blackbox_check["failed_evidence_fields"],
6759 serde_json::json!([
6760 "blackbox_manifest.artifacts.slow-query-log.jsonl",
6761 "blackbox_manifest.artifacts.slow-query-log.jsonl.jsonl"
6762 ])
6763 );
6764 assert!(report["next_actions"]
6765 .as_array()
6766 .unwrap()
6767 .iter()
6768 .any(|action| action["action"] == "attach_blackbox_operational_evidence"));
6769 }
6770
6771 #[test]
6772 fn requires_blackbox_background_qos_summary() {
6773 let mut bundle = ready_bundle();
6774 bundle["blackbox_manifest"]["artifacts"] = serde_json::json!([
6775 ready_blackbox_slow_query_artifact(),
6776 {
6777 "name": "background-maintenance.json",
6778 "format": "json",
6779 "byte_len": 256,
6780 "checksum": 3,
6781 "json": {
6782 "parse_ready": true,
6783 "protocol": "hawdb-background-maintenance-report",
6784 "ready": true,
6785 "blocker_codes": []
6786 }
6787 }
6788 ]);
6789
6790 let report = integration_readiness_json(&bundle);
6791
6792 assert_eq!(report["ready"], false);
6793 let blackbox_check = report["checks"]
6794 .as_array()
6795 .unwrap()
6796 .iter()
6797 .find(|check| check["name"] == "blackbox_operational_evidence")
6798 .unwrap();
6799 assert_eq!(
6800 blackbox_check["failed_evidence_fields"],
6801 serde_json::json!([
6802 "blackbox_manifest.artifacts.background-maintenance.json.background_qos"
6803 ])
6804 );
6805 }
6806
6807 #[test]
6808 fn requires_blackbox_background_qos_memory_pressure_evidence() {
6809 let mut bundle = ready_bundle();
6810 let artifacts = bundle["blackbox_manifest"]["artifacts"]
6811 .as_array_mut()
6812 .unwrap();
6813 let background_artifact = artifacts
6814 .iter_mut()
6815 .find(|artifact| artifact["name"] == "background-maintenance.json")
6816 .unwrap();
6817 let background_qos = background_artifact["background_qos"]
6818 .as_object_mut()
6819 .unwrap();
6820 background_qos.remove("memory_pressure_ready");
6821 background_qos.remove("memory_budget_bytes");
6822 background_qos.remove("estimated_memory_bytes");
6823
6824 let report = integration_readiness_json(&bundle);
6825
6826 assert_eq!(report["ready"], false);
6827 assert_eq!(
6828 report["failed_checks"],
6829 serde_json::json!(["blackbox_operational_evidence"])
6830 );
6831 assert!(report["blocker_codes"]
6832 .as_array()
6833 .unwrap()
6834 .iter()
6835 .any(|code| code == "blackbox_background_qos_summary_missing"));
6836 let blackbox_check = report["checks"]
6837 .as_array()
6838 .unwrap()
6839 .iter()
6840 .find(|check| check["name"] == "blackbox_operational_evidence")
6841 .unwrap();
6842 assert_eq!(
6843 blackbox_check["failed_evidence_fields"],
6844 serde_json::json!([
6845 "blackbox_manifest.artifacts.background-maintenance.json.background_qos"
6846 ])
6847 );
6848 assert!(report["next_actions"]
6849 .as_array()
6850 .unwrap()
6851 .iter()
6852 .any(|action| action["action"] == "attach_blackbox_operational_evidence"));
6853 }
6854
6855 #[test]
6856 fn requires_versioned_integration_bundle_protocol() {
6857 let mut bundle = ready_bundle();
6858 bundle.as_object_mut().unwrap().remove("protocol");
6859
6860 let report = integration_readiness_json(&bundle);
6861
6862 assert_eq!(report["ready"], false);
6863 assert_eq!(
6864 report["failed_checks"],
6865 serde_json::json!(["integration_bundle_protocol"])
6866 );
6867 let protocol_check = report["checks"]
6868 .as_array()
6869 .unwrap()
6870 .iter()
6871 .find(|check| check["name"] == "integration_bundle_protocol")
6872 .unwrap();
6873 assert_eq!(
6874 protocol_check["failed_evidence_fields"],
6875 serde_json::json!(["protocol"])
6876 );
6877 assert!(report["next_actions"]
6878 .as_array()
6879 .unwrap()
6880 .iter()
6881 .any(|action| action["action"] == "regenerate_hawdb_integration_bundle"));
6882 }
6883
6884 #[test]
6885 fn requires_replacement_summary_protocol() {
6886 let mut bundle = ready_bundle();
6887 bundle["replacement_summary"]
6888 .as_object_mut()
6889 .unwrap()
6890 .remove("protocol");
6891
6892 let report = integration_readiness_json(&bundle);
6893
6894 assert_eq!(report["ready"], false);
6895 assert_eq!(
6896 report["failed_checks"],
6897 serde_json::json!(["replacement_summary_protocol"])
6898 );
6899 let summary_check = report["checks"]
6900 .as_array()
6901 .unwrap()
6902 .iter()
6903 .find(|check| check["name"] == "replacement_summary_protocol")
6904 .unwrap();
6905 assert_eq!(
6906 summary_check["failed_evidence_fields"],
6907 serde_json::json!(["replacement_summary.protocol"])
6908 );
6909 assert!(report["next_actions"]
6910 .as_array()
6911 .unwrap()
6912 .iter()
6913 .any(|action| action["action"] == "produce_replacement_summary"
6914 && action["evidence_fields"]
6915 .as_array()
6916 .unwrap()
6917 .iter()
6918 .any(|field| field == "replacement_summary.protocol")));
6919 }
6920
6921 #[test]
6922 fn fails_closed_without_submodule_and_coexistence() {
6923 let mut bundle = ready_bundle();
6924 bundle["submodule"]["present"] = serde_json::json!(false);
6925 bundle["submodule"]["commit"] = serde_json::json!("");
6926 bundle["coexistence"]["old_database_retained"] = serde_json::json!(false);
6927 bundle["coexistence"]["old_database_deleted"] = serde_json::json!(true);
6928 bundle["coexistence"]["mode"] = serde_json::json!("replace_in_place");
6929
6930 let report = integration_readiness_json(&bundle);
6931
6932 assert_eq!(report["ready"], false);
6933 assert_eq!(
6934 report["failed_checks"],
6935 serde_json::json!(["hawdb_submodule", "legacy_coexistence"])
6936 );
6937 assert!(report["next_actions"]
6938 .as_array()
6939 .unwrap()
6940 .iter()
6941 .any(|action| action["action"] == "add_hawdb_submodule"));
6942 assert!(report["next_actions"]
6943 .as_array()
6944 .unwrap()
6945 .iter()
6946 .any(|action| action["action"] == "enable_side_by_side_coexistence"));
6947 }
6948
6949 #[test]
6950 fn exposes_typed_protocol_cutover_readiness() {
6951 let mut bundle = ready_bundle();
6952
6953 let integration = super::integration_bundle_protocol_cutover_readiness(&bundle);
6954 let replacement = super::replacement_summary_protocol_cutover_readiness(&bundle);
6955 assert!(integration.evidence_ready());
6956 assert!(integration.protocol_matches);
6957 assert!(replacement.evidence_ready());
6958 assert!(replacement.protocol_matches);
6959 assert!(replacement.graph_layer_replacement_scope_ready);
6960 assert!(replacement.search_projection_replacement_scope_ready);
6961 assert!(replacement.content_store_out_of_scope);
6962 assert!(replacement.large_blob_store_out_of_scope);
6963
6964 bundle["protocol"] = serde_json::json!("legacy");
6965 bundle["replacement_summary"]["protocol"] = serde_json::json!("legacy");
6966 bundle["replacement_summary"]["replacement_boundaries"]["content_store"]
6967 ["replacement_role"] = serde_json::json!("primary_replacement");
6968 let integration = super::integration_bundle_protocol_cutover_readiness(&bundle);
6969 let replacement = super::replacement_summary_protocol_cutover_readiness(&bundle);
6970 assert!(!integration.evidence_ready());
6971 assert!(!replacement.evidence_ready());
6972 assert!(!replacement.protocol_matches);
6973 assert!(!replacement.content_store_out_of_scope);
6974 }
6975
6976 #[test]
6977 fn requires_replacement_summary_boundaries() {
6978 let mut bundle = ready_bundle();
6979 bundle["replacement_summary"]
6980 .as_object_mut()
6981 .unwrap()
6982 .remove("replacement_boundaries");
6983
6984 let report = integration_readiness_json(&bundle);
6985
6986 assert_eq!(report["ready"], false);
6987 assert_eq!(
6988 report["failed_checks"],
6989 serde_json::json!(["replacement_summary_protocol"])
6990 );
6991 let summary_check = report["checks"]
6992 .as_array()
6993 .unwrap()
6994 .iter()
6995 .find(|check| check["name"] == "replacement_summary_protocol")
6996 .unwrap();
6997 assert_eq!(
6998 summary_check["failed_evidence_fields"],
6999 serde_json::json!([
7000 "replacement_summary.replacement_boundaries.graph_layer",
7001 "replacement_summary.replacement_boundaries.search_projection",
7002 "replacement_summary.replacement_boundaries.content_store",
7003 "replacement_summary.replacement_boundaries.large_blob_store"
7004 ])
7005 );
7006 assert!(report["next_actions"]
7007 .as_array()
7008 .unwrap()
7009 .iter()
7010 .any(|action| action["action"] == "produce_replacement_summary"
7011 && action["evidence_fields"].as_array().unwrap().iter().any(
7012 |field| field == "replacement_summary.replacement_boundaries.content_store"
7013 )));
7014 }
7015
7016 #[test]
7017 fn exposes_typed_submodule_and_coexistence_cutover_readiness() {
7018 let mut bundle = ready_bundle();
7019 let submodule = super::hawdb_submodule_cutover_readiness(&bundle);
7020 let coexistence = super::legacy_coexistence_cutover_readiness(&bundle);
7021 assert!(submodule.evidence_ready());
7022 assert!(submodule.present);
7023 assert!(submodule.path_present);
7024 assert!(submodule.commit_present);
7025 assert!(coexistence.evidence_ready());
7026 assert!(coexistence.old_database_retained);
7027 assert!(coexistence.mode_safe);
7028 assert!(coexistence.old_database_not_deleted);
7029
7030 bundle["submodule"]["commit"] = serde_json::json!("");
7031 bundle["coexistence"]["mode"] = serde_json::json!("replace_in_place");
7032 bundle["coexistence"]["old_database_deleted"] = serde_json::json!(true);
7033 let submodule = super::hawdb_submodule_cutover_readiness(&bundle);
7034 let coexistence = super::legacy_coexistence_cutover_readiness(&bundle);
7035 assert!(!submodule.evidence_ready());
7036 assert!(submodule.present);
7037 assert!(submodule.path_present);
7038 assert!(!submodule.commit_present);
7039 assert!(!coexistence.evidence_ready());
7040 assert!(!coexistence.mode_safe);
7041 assert!(!coexistence.old_database_not_deleted);
7042 }
7043
7044 #[test]
7045 fn typed_content_store_boundary_rejects_missing_source_chunks() {
7046 let mut bundle = ready_bundle();
7047 let typed = super::content_store_boundary_cutover_readiness(&bundle);
7048 assert!(typed.evidence_ready());
7049 assert!(typed.present);
7050 assert!(typed.engine_sqlite);
7051 assert!(typed.messages_available);
7052 assert!(typed.source_chunks_available);
7053
7054 bundle["content_store"]["source_chunks_available"] = serde_json::json!(false);
7055 let typed = super::content_store_boundary_cutover_readiness(&bundle);
7056 assert!(!typed.evidence_ready());
7057 assert!(!typed.source_chunks_available);
7058
7059 let report = integration_readiness_json(&bundle);
7060 let check = report["checks"]
7061 .as_array()
7062 .unwrap()
7063 .iter()
7064 .find(|check| check["name"] == "content_store_boundary")
7065 .unwrap();
7066 assert_eq!(
7067 check["failed_evidence_fields"],
7068 serde_json::json!(["content_store.source_chunks_available"])
7069 );
7070 assert!(report["next_actions"]
7071 .as_array()
7072 .unwrap()
7073 .iter()
7074 .any(|action| action["action"] == "attach_content_store_evidence"));
7075 }
7076
7077 #[test]
7078 fn typed_previous_wrapper_preflight_collects_failed_checks_as_blockers() {
7079 let mut bundle = ready_bundle();
7080 bundle["previous_wrapper_preflight"]["ready"] = serde_json::json!(false);
7081 bundle["previous_wrapper_preflight"]["failed_checks"] =
7082 serde_json::json!(["route_inventory_missing"]);
7083
7084 let typed = super::previous_wrapper_preflight_cutover_readiness(&bundle);
7085 assert!(!typed.evidence_ready());
7086 assert_eq!(typed.blocker_codes, vec!["route_inventory_missing"]);
7087
7088 let report = integration_readiness_json(&bundle);
7089 let check = report["checks"]
7090 .as_array()
7091 .unwrap()
7092 .iter()
7093 .find(|check| check["name"] == "previous_wrapper_preflight")
7094 .unwrap();
7095 assert_eq!(
7096 check["failed_evidence_fields"],
7097 serde_json::json!(["previous_wrapper_preflight.ready"])
7098 );
7099 assert_eq!(
7100 check["blocker_codes"],
7101 serde_json::json!(["route_inventory_missing"])
7102 );
7103 assert!(report["next_actions"]
7104 .as_array()
7105 .unwrap()
7106 .iter()
7107 .any(|action| action["action"] == "run_previous_wrapper_preflight"));
7108 }
7109
7110 #[test]
7111 fn graph_replacement_requires_source_mutation_dual_write_readiness() {
7112 let mut bundle = ready_bundle();
7113 bundle["replacement_summary"]["production_cutover_ready"] = serde_json::json!(false);
7114 bundle["replacement_summary"]["source_mutation_dual_write_readiness"]["ready"] =
7115 serde_json::json!(false);
7116 bundle["replacement_summary"]["source_mutation_dual_write_readiness"]
7117 ["ready_family_count"] = serde_json::json!(REQUIRED_SOURCE_MUTATION_FAMILIES.len() - 1);
7118 bundle["replacement_summary"]["source_mutation_dual_write_readiness"]
7119 ["missing_required_families"] = serde_json::json!(["source_ingest_create"]);
7120 bundle["replacement_summary"]["source_mutation_dual_write_readiness"]["blocker_codes"] =
7121 serde_json::json!(["source_mutation_dual_write_missing_required_families"]);
7122 bundle["replacement_summary"]["blocking_categories"] =
7123 serde_json::json!(["source_mutation_dual_write_readiness"]);
7124 bundle["replacement_summary"]["missing_evidence"] =
7125 serde_json::json!(["source_mutation_dual_write_readiness_ready"]);
7126
7127 let typed = super::graph_replacement_cutover_readiness(&bundle);
7128 assert!(!typed.evidence_ready());
7129 assert!(!typed.production_cutover_ready);
7130 assert!(!typed.source_mutation_ready);
7131 assert!(!typed.source_mutation_ready_family_count_matches);
7132 assert!(!typed.source_mutation_missing_required_families_empty);
7133 assert_eq!(
7134 typed.blocker_codes,
7135 vec![
7136 "source_mutation_dual_write_missing_required_families".to_string(),
7137 "source_mutation_dual_write_readiness".to_string(),
7138 "source_mutation_dual_write_readiness_ready".to_string()
7139 ]
7140 );
7141
7142 let report = integration_readiness_json(&bundle);
7143 let check = report["checks"]
7144 .as_array()
7145 .unwrap()
7146 .iter()
7147 .find(|check| check["name"] == "graph_replacement_evidence")
7148 .unwrap();
7149 assert_eq!(check["ready"], false);
7150 assert!(
7151 check["failed_evidence_fields"]
7152 .as_array()
7153 .unwrap()
7154 .iter()
7155 .any(|field| field
7156 == "replacement_summary.source_mutation_dual_write_readiness.ready")
7157 );
7158 assert!(check["failed_evidence_fields"]
7159 .as_array()
7160 .unwrap()
7161 .iter()
7162 .any(|field| field
7163 == "replacement_summary.source_mutation_dual_write_readiness.ready_family_count"));
7164
7165 let final_report = super::final_cutover_preflight(&bundle);
7166 assert!(!final_report.production_cutover_ready);
7167 assert!(!final_report.graph_replacement_ready);
7168 assert!(final_report
7169 .blocking_categories
7170 .contains(&"graph_replacement".to_string()));
7171 }
7172
7173 #[test]
7174 fn typed_route_ownership_cutover_readiness_requires_all_hawdb_routes() {
7175 let mut bundle = ready_bundle();
7176 let typed = super::route_ownership_cutover_readiness(&bundle);
7177 assert!(typed.evidence_ready());
7178 assert!(typed.production_cutover_ready);
7179 assert!(typed.require_all_hawdb);
7180 assert!(typed.legacy_route_count_zero);
7181
7182 bundle["route_ownership"]["routes"][0]["read_engine"] = serde_json::json!("legacy");
7183 bundle["route_ownership"]["legacy_route_count"] = serde_json::json!(1);
7184 bundle["route_ownership"]["hawdb_route_count"] =
7185 serde_json::json!(REQUIRED_BOUNDED_READ_ROUTES.len() - 1);
7186 bundle["route_ownership"]["legacy_routes"] =
7187 serde_json::json!([REQUIRED_BOUNDED_READ_ROUTES[0]]);
7188 bundle["route_ownership"]["hawdb_routes"] =
7189 serde_json::json!(&REQUIRED_BOUNDED_READ_ROUTES[1..]);
7190 bundle["route_ownership"]["ready"] = serde_json::json!(false);
7191 bundle["route_ownership"]["production_cutover_ready"] = serde_json::json!(false);
7192 bundle["route_ownership"]["blocker_codes"] =
7193 serde_json::json!(["route_ownership_legacy_routes_remaining"]);
7194
7195 let typed = super::route_ownership_cutover_readiness(&bundle);
7196 assert!(!typed.evidence_ready());
7197 assert!(!typed.ready);
7198 assert!(!typed.production_cutover_ready);
7199 assert!(!typed.hawdb_route_count_matches);
7200 assert!(!typed.legacy_route_count_zero);
7201 assert_eq!(
7202 typed.blocker_codes,
7203 vec!["route_ownership_legacy_routes_remaining".to_string()]
7204 );
7205 }
7206
7207 #[test]
7208 fn route_ownership_rejects_hawdb_search_route_without_projection_evidence() {
7209 let mut bundle = ready_bundle();
7210 bundle["replacement_summary"]
7211 .as_object_mut()
7212 .unwrap()
7213 .remove("search_projection_evidence");
7214
7215 let typed = super::route_ownership_cutover_readiness(&bundle);
7216 assert!(!typed.evidence_ready());
7217 assert!(!typed.search_route_projection_evidence_present);
7218
7219 let report = integration_readiness_json(&bundle);
7220 let check = report["checks"]
7221 .as_array()
7222 .unwrap()
7223 .iter()
7224 .find(|check| check["name"] == "route_ownership")
7225 .unwrap();
7226 assert!(check["failed_evidence_fields"]
7227 .as_array()
7228 .unwrap()
7229 .iter()
7230 .any(|field| field == "route_ownership.search_route_projection_evidence_present"));
7231 }
7232
7233 #[test]
7234 fn integration_readiness_fails_closed_without_route_ownership() {
7235 let mut bundle = ready_bundle();
7236 bundle.as_object_mut().unwrap().remove("route_ownership");
7237
7238 let report = integration_readiness_json(&bundle);
7239
7240 assert_eq!(report["ready"], false);
7241 assert!(report["failed_checks"]
7242 .as_array()
7243 .unwrap()
7244 .iter()
7245 .any(|check| check == "route_ownership"));
7246 let check = report["checks"]
7247 .as_array()
7248 .unwrap()
7249 .iter()
7250 .find(|check| check["name"] == "route_ownership")
7251 .unwrap();
7252 assert_eq!(
7253 check["failed_evidence_fields"],
7254 serde_json::json!([
7255 "route_ownership.protocol",
7256 "route_ownership.ready",
7257 "route_ownership.production_cutover_ready",
7258 "route_ownership.require_all_hawdb",
7259 "route_ownership.required_route_count",
7260 "route_ownership.explicit_route_count",
7261 "route_ownership.hawdb_route_count",
7262 "route_ownership.legacy_route_count",
7263 "route_ownership.route_readiness_present",
7264 "route_ownership.route_readiness_ready",
7265 "route_ownership.route_catalog_version",
7266 "route_ownership.route_catalog_digest"
7267 ])
7268 );
7269 assert!(report["next_actions"]
7270 .as_array()
7271 .unwrap()
7272 .iter()
7273 .any(|action| action["action"] == "attach_route_ownership_evidence"));
7274 }
7275
7276 #[test]
7277 fn integration_readiness_blocks_active_search_reads_that_still_require_lancedb() {
7278 let mut bundle = ready_bundle();
7279 bundle["active_search_route_readiness"]["ready"] = serde_json::json!(false);
7280 bundle["active_search_route_readiness"]["production_cutover_ready"] =
7281 serde_json::json!(false);
7282 bundle["active_search_route_readiness"]["ready_route_count"] =
7283 serde_json::json!(REQUIRED_ACTIVE_SEARCH_ROUTES.len() - 1);
7284 bundle["active_search_route_readiness"]["lancedb_handle_required_route_count"] =
7285 serde_json::json!(1);
7286 bundle["active_search_route_readiness"]["lancedb_handle_required_routes"] =
7287 serde_json::json!([REQUIRED_ACTIVE_SEARCH_ROUTES[0]]);
7288 bundle["active_search_route_readiness"]["blocker_codes"] =
7289 serde_json::json!(["active_search_route_readiness_lancedb_handle_required"]);
7290 bundle["replacement_summary_active_search_route_readiness_alignment"]["ready"] =
7291 serde_json::json!(false);
7292 bundle["replacement_summary_active_search_route_readiness_alignment"]
7293 ["ready_route_count_matches"] = serde_json::json!(false);
7294 bundle["replacement_summary_active_search_route_readiness_alignment"]
7295 ["lancedb_handle_count_matches"] = serde_json::json!(false);
7296 bundle["replacement_summary_active_search_route_readiness_alignment"]
7297 ["lancedb_handle_routes_matches"] = serde_json::json!(false);
7298 bundle["replacement_summary_active_search_route_readiness_alignment"]
7299 ["blocker_codes_match"] = serde_json::json!(false);
7300 bundle["replacement_summary_active_search_route_readiness_alignment"]["blocker_codes"] =
7301 serde_json::json!([
7302 "active_search_route_readiness_ready_count_mismatch",
7303 "active_search_route_readiness_lancedb_handle_count_mismatch",
7304 "active_search_route_readiness_lancedb_handle_routes_mismatch",
7305 "active_search_route_readiness_blocker_codes_mismatch"
7306 ]);
7307
7308 let report = integration_readiness_json(&bundle);
7309
7310 assert_eq!(report["ready"], false);
7311 assert!(report["failed_checks"]
7312 .as_array()
7313 .unwrap()
7314 .iter()
7315 .any(|check| check == "active_search_route_readiness_alignment"));
7316 let check = report["checks"]
7317 .as_array()
7318 .unwrap()
7319 .iter()
7320 .find(|check| check["name"] == "active_search_route_readiness_alignment")
7321 .unwrap();
7322 assert!(check["failed_evidence_fields"]
7323 .as_array()
7324 .unwrap()
7325 .iter()
7326 .any(|field| field
7327 == "replacement_summary_active_search_route_readiness_alignment.lancedb_handle_count_matches"));
7328 assert!(
7329 report["next_actions"]
7330 .as_array()
7331 .unwrap()
7332 .iter()
7333 .any(|action| action["action"]
7334 == "regenerate_active_search_route_readiness_alignment")
7335 );
7336 }
7337
7338 #[test]
7339 fn final_cutover_preflight_fails_closed_on_legacy_route_ownership() {
7340 let mut bundle = ready_bundle();
7341 bundle["route_ownership"]["routes"][0]["read_engine"] = serde_json::json!("legacy");
7342 bundle["route_ownership"]["legacy_route_count"] = serde_json::json!(1);
7343 bundle["route_ownership"]["hawdb_route_count"] =
7344 serde_json::json!(REQUIRED_BOUNDED_READ_ROUTES.len() - 1);
7345 bundle["route_ownership"]["legacy_routes"] =
7346 serde_json::json!([REQUIRED_BOUNDED_READ_ROUTES[0]]);
7347 bundle["route_ownership"]["hawdb_routes"] =
7348 serde_json::json!(&REQUIRED_BOUNDED_READ_ROUTES[1..]);
7349 bundle["route_ownership"]["ready"] = serde_json::json!(false);
7350 bundle["route_ownership"]["production_cutover_ready"] = serde_json::json!(false);
7351 bundle["route_ownership"]["blocker_codes"] =
7352 serde_json::json!(["route_ownership_legacy_routes_remaining"]);
7353
7354 let report = super::final_cutover_preflight(&bundle);
7355
7356 assert!(!report.production_cutover_ready);
7357 assert!(!report.integration_ready);
7358 assert!(!report.route_coverage_ready);
7359 assert!(report
7360 .blocking_categories
7361 .contains(&"route_coverage".to_string()));
7362 assert!(report
7363 .failed_checks
7364 .contains(&"route_ownership".to_string()));
7365 assert!(report
7366 .next_action_names
7367 .contains(&"attach_route_ownership_evidence".to_string()));
7368 }
7369
7370 #[test]
7371 fn exposes_typed_final_cutover_preflight_report() {
7372 let bundle = ready_bundle();
7373
7374 let report = super::final_cutover_preflight(&bundle);
7375
7376 assert_eq!(report.protocol, super::FINAL_CUTOVER_PREFLIGHT_PROTOCOL);
7377 assert!(report.production_cutover_ready);
7378 assert!(report.integration_ready);
7379 assert!(report.replacement_summary_production_cutover_ready);
7380 assert!(report.startup_ready);
7381 assert!(report.route_coverage_ready);
7382 assert!(report.graph_replacement_ready);
7383 assert!(report.search_projection_ready);
7384 assert!(report.storage_recovery_ready);
7385 assert!(report.background_qos_ready);
7386 assert!(report.blackbox_ready);
7387 assert!(report.library_only_ready);
7388 assert!(report.check_count > 0);
7389 assert_eq!(report.ready_check_count, report.check_count);
7390 assert_eq!(report.failed_check_count, 0);
7391 assert_eq!(report.next_action_count, 0);
7392 assert!(report.next_action_names.is_empty());
7393 assert!(report.blocking_categories.is_empty());
7394 assert!(report.failed_checks.is_empty());
7395 assert!(report.failed_evidence_fields.is_empty());
7396 assert!(report.blocker_codes.is_empty());
7397
7398 let json = report.json();
7399 assert_eq!(json["production_cutover_ready"], true);
7400 assert_eq!(json["route_coverage_ready"], true);
7401 assert_eq!(json["blocking_categories"], serde_json::json!([]));
7402 assert!(json.get("checks").is_none());
7403 assert!(json.get("next_actions").is_none());
7404 }
7405
7406 #[test]
7407 fn final_cutover_preflight_fails_closed_on_missing_integration_evidence() {
7408 let mut bundle = ready_bundle();
7409 bundle["content_store"]["source_chunks_available"] = serde_json::json!(false);
7410
7411 let report = super::final_cutover_preflight(&bundle);
7412
7413 assert!(!report.production_cutover_ready);
7414 assert!(!report.integration_ready);
7415 assert!(report.replacement_summary_production_cutover_ready);
7416 assert!(!report.startup_ready);
7417 assert!(report.route_coverage_ready);
7418 assert!(report.blocking_categories.contains(&"startup".to_string()));
7419 assert_eq!(
7420 report.next_action_names,
7421 vec!["attach_content_store_evidence"]
7422 );
7423 assert!(report
7424 .failed_checks
7425 .contains(&"content_store_boundary".to_string()));
7426 assert!(report
7427 .failed_evidence_fields
7428 .contains(&"content_store.source_chunks_available".to_string()));
7429 assert_eq!(report.failed_check_count, 1);
7430 }
7431
7432 #[test]
7433 fn final_cutover_preflight_fails_closed_on_replacement_summary_cutover() {
7434 let mut bundle = ready_bundle();
7435 bundle["replacement_summary"]["production_cutover_ready"] = serde_json::json!(false);
7436 bundle["replacement_summary"]["blocking_categories"] =
7437 serde_json::json!(["graph_replacement"]);
7438
7439 let report = super::final_cutover_preflight(&bundle);
7440
7441 assert!(!report.production_cutover_ready);
7442 assert!(!report.integration_ready);
7443 assert!(!report.replacement_summary_production_cutover_ready);
7444 assert!(!report.graph_replacement_ready);
7445 assert!(report
7446 .blocking_categories
7447 .contains(&"graph_replacement".to_string()));
7448 assert!(report
7449 .blocking_categories
7450 .contains(&"replacement_summary_cutover".to_string()));
7451 assert!(report
7452 .failed_checks
7453 .contains(&"graph_replacement_evidence".to_string()));
7454 assert!(report
7455 .failed_evidence_fields
7456 .contains(&"replacement_summary.production_cutover_ready".to_string()));
7457 assert!(report
7458 .blocker_codes
7459 .contains(&"graph_replacement".to_string()));
7460 }
7461
7462 #[test]
7463 fn requires_search_projection_shadow_parity() {
7464 let mut bundle = ready_bundle();
7465 bundle["replacement_summary"]["search_projection_shadow_evidence"]["ready"] =
7466 serde_json::json!(false);
7467 bundle["replacement_summary"]["search_projection_shadow_evidence"]
7468 ["document_count_parity"] = serde_json::json!(false);
7469 bundle["replacement_summary"]["search_projection_shadow_evidence"]["blocker_codes"] =
7470 serde_json::json!(["document_count_mismatch"]);
7471
7472 let report = integration_readiness_json(&bundle);
7473
7474 assert_eq!(report["ready"], false);
7475 assert_eq!(
7476 report["failed_checks"],
7477 serde_json::json!(["search_projection_replacement_evidence"])
7478 );
7479 assert_eq!(
7480 report["blocker_codes"],
7481 serde_json::json!(["document_count_mismatch"])
7482 );
7483 let search_check = report["checks"]
7484 .as_array()
7485 .unwrap()
7486 .iter()
7487 .find(|check| check["name"] == "search_projection_replacement_evidence")
7488 .unwrap();
7489 assert_eq!(
7490 search_check["failed_evidence_fields"],
7491 serde_json::json!([
7492 "replacement_summary.search_projection_shadow_evidence.ready",
7493 "replacement_summary.search_projection_shadow_evidence.document_count_parity"
7494 ])
7495 );
7496 assert!(report["next_actions"]
7497 .as_array()
7498 .unwrap()
7499 .iter()
7500 .any(|action| action["action"] == "attach_search_projection_replacement_evidence"));
7501 }
7502
7503 #[test]
7504 fn exposes_typed_search_projection_cutover_readiness() {
7505 let bundle = ready_bundle();
7506
7507 let typed = super::search_projection_cutover_readiness(&bundle);
7508
7509 assert!(typed.evidence_ready());
7510 assert!(typed.evidence_protocol_matches);
7511 assert!(typed.shadow_protocol_matches);
7512 assert!(typed.shadow_evidence_source_matches);
7513 assert!(typed.shadow_pruning_candidate_count_ready);
7514 assert!(typed.primary_scan_filter_fields_ready);
7515 assert!(typed.shadow_scan_filter_fields_ready);
7516 assert!(typed.shadow_descriptor_field_summaries_ready);
7517 assert!(typed.blocker_codes.is_empty());
7518 }
7519
7520 #[test]
7521 fn typed_search_projection_cutover_recomputes_pushdown_fields() {
7522 let mut bundle = ready_bundle();
7523 bundle["replacement_summary"]["search_projection_shadow_evidence"]["ready"] =
7524 serde_json::json!(true);
7525 bundle["replacement_summary"]["search_projection_shadow_evidence"]["pushdown_evidence"]
7526 ["ready"] = serde_json::json!(true);
7527 bundle["replacement_summary"]["search_projection_shadow_evidence"]["pushdown_evidence"]
7528 ["primary_scan_filter_fields"] = serde_json::json!(["unit_type", "importance"]);
7529
7530 let typed = super::search_projection_cutover_readiness(&bundle);
7531
7532 assert!(!typed.evidence_ready());
7533 assert!(!typed.primary_scan_filter_fields_ready);
7534 }
7535
7536 #[test]
7537 fn typed_search_projection_cutover_requires_production_filter_pruning() {
7538 let mut bundle = ready_bundle();
7539 bundle["replacement_summary"]["search_projection_evidence"]["ready"] =
7540 serde_json::json!(true);
7541 bundle["replacement_summary"]["search_projection_evidence"]
7542 ["production_filter_pruning_ready"] = serde_json::json!(false);
7543
7544 let typed = super::search_projection_cutover_readiness(&bundle);
7545 let conditions = super::search_projection_cutover_conditions(&typed);
7546
7547 assert!(!typed.evidence_ready());
7548 assert!(!typed.production_filter_pruning_ready);
7549 assert!(conditions.iter().any(|(field, ready)| {
7550 *field
7551 == "replacement_summary.search_projection_evidence.production_filter_pruning_ready"
7552 && !*ready
7553 }));
7554 }
7555
7556 #[test]
7557 fn requires_search_projection_document_identity() {
7558 let mut bundle = ready_bundle();
7559 bundle["replacement_summary"]["search_projection_evidence"]["ready"] =
7560 serde_json::json!(false);
7561 bundle["replacement_summary"]["search_projection_evidence"]["document_identity_ready"] =
7562 serde_json::json!(false);
7563 bundle["replacement_summary"]["search_projection_evidence"]["blocker_codes"] =
7564 serde_json::json!(["document_identity_not_ready"]);
7565
7566 let report = integration_readiness_json(&bundle);
7567
7568 assert_eq!(report["ready"], false);
7569 assert_eq!(
7570 report["failed_checks"],
7571 serde_json::json!(["search_projection_replacement_evidence"])
7572 );
7573 assert_eq!(
7574 report["blocker_codes"],
7575 serde_json::json!(["document_identity_not_ready"])
7576 );
7577 let search_check = report["checks"]
7578 .as_array()
7579 .unwrap()
7580 .iter()
7581 .find(|check| check["name"] == "search_projection_replacement_evidence")
7582 .unwrap();
7583 assert_eq!(
7584 search_check["failed_evidence_fields"],
7585 serde_json::json!([
7586 "replacement_summary.search_projection_evidence.ready",
7587 "replacement_summary.search_projection_evidence.document_identity_ready"
7588 ])
7589 );
7590 }
7591
7592 #[test]
7593 fn requires_search_projection_shadow_document_identity_parity() {
7594 let mut bundle = ready_bundle();
7595 bundle["replacement_summary"]["search_projection_shadow_evidence"]["ready"] =
7596 serde_json::json!(false);
7597 bundle["replacement_summary"]["search_projection_shadow_evidence"]
7598 ["document_identity_parity"] = serde_json::json!(false);
7599 bundle["replacement_summary"]["search_projection_shadow_evidence"]["blocker_codes"] =
7600 serde_json::json!(["document_identity_mismatch"]);
7601
7602 let report = integration_readiness_json(&bundle);
7603
7604 assert_eq!(report["ready"], false);
7605 assert_eq!(
7606 report["failed_checks"],
7607 serde_json::json!(["search_projection_replacement_evidence"])
7608 );
7609 assert_eq!(
7610 report["blocker_codes"],
7611 serde_json::json!(["document_identity_mismatch"])
7612 );
7613 let search_check = report["checks"]
7614 .as_array()
7615 .unwrap()
7616 .iter()
7617 .find(|check| check["name"] == "search_projection_replacement_evidence")
7618 .unwrap();
7619 assert_eq!(
7620 search_check["failed_evidence_fields"],
7621 serde_json::json!([
7622 "replacement_summary.search_projection_shadow_evidence.ready",
7623 "replacement_summary.search_projection_shadow_evidence.document_identity_parity"
7624 ])
7625 );
7626 }
7627
7628 #[test]
7629 fn requires_hawdb_search_candidate_primary_engine() {
7630 let mut bundle = ready_bundle();
7631 bundle["search_candidate_shadow_evidence"]["candidate_primary_engine"] =
7632 serde_json::json!("lancedb");
7633
7634 let report = integration_readiness_json(&bundle);
7635
7636 assert_eq!(report["ready"], false);
7637 assert_eq!(
7638 report["failed_checks"],
7639 serde_json::json!(["search_candidate_primary_evidence"])
7640 );
7641 let candidate_check = report["checks"]
7642 .as_array()
7643 .unwrap()
7644 .iter()
7645 .find(|check| check["name"] == "search_candidate_primary_evidence")
7646 .unwrap();
7647 assert_eq!(
7648 candidate_check["failed_evidence_fields"],
7649 serde_json::json!(["search_candidate_shadow_evidence.candidate_primary_engine"])
7650 );
7651 assert!(report["next_actions"]
7652 .as_array()
7653 .unwrap()
7654 .iter()
7655 .any(|action| action["action"] == "enable_hawdb_search_candidate_primary_reads"));
7656 }
7657
7658 #[test]
7659 fn requires_search_candidate_shadow_count_parity() {
7660 let mut bundle = ready_bundle();
7661 bundle["search_candidate_shadow_evidence"]["ready"] = serde_json::json!(true);
7662 bundle["search_candidate_shadow_evidence"]["primary_candidate_count"] =
7663 serde_json::json!(3);
7664 bundle["search_candidate_shadow_evidence"]["shadow_candidate_count"] = serde_json::json!(3);
7665 bundle["search_candidate_shadow_evidence"]["matched_candidate_count"] =
7666 serde_json::json!(2);
7667 bundle["search_candidate_shadow_evidence"]["primary_only_candidate_count"] =
7668 serde_json::json!(1);
7669 bundle["search_candidate_shadow_evidence"]["blocker_codes"] =
7670 serde_json::json!(["search_candidate_mismatch"]);
7671
7672 let report = integration_readiness_json(&bundle);
7673
7674 assert_eq!(report["ready"], false);
7675 assert_eq!(
7676 report["failed_checks"],
7677 serde_json::json!(["search_candidate_primary_evidence"])
7678 );
7679 assert_eq!(
7680 report["blocker_codes"],
7681 serde_json::json!(["search_candidate_mismatch"])
7682 );
7683 let candidate_check = report["checks"]
7684 .as_array()
7685 .unwrap()
7686 .iter()
7687 .find(|check| check["name"] == "search_candidate_primary_evidence")
7688 .unwrap();
7689 assert_eq!(
7690 candidate_check["failed_evidence_fields"],
7691 serde_json::json!(["search_candidate_shadow_evidence.candidate_counts"])
7692 );
7693 }
7694
7695 #[test]
7696 fn requires_search_candidate_shadow_identity_parity() {
7697 let mut bundle = ready_bundle();
7698 bundle["search_candidate_shadow_evidence"]["ready"] = serde_json::json!(true);
7699 bundle["search_candidate_shadow_evidence"]["candidate_identity"]["ready"] =
7700 serde_json::json!(false);
7701 bundle["search_candidate_shadow_evidence"]["candidate_identity"]["parity"] =
7702 serde_json::json!(false);
7703 bundle["search_candidate_shadow_evidence"]["blocker_codes"] =
7704 serde_json::json!(["search_candidate_identity_mismatch"]);
7705
7706 let report = integration_readiness_json(&bundle);
7707
7708 assert_eq!(report["ready"], false);
7709 assert_eq!(
7710 report["failed_checks"],
7711 serde_json::json!(["search_candidate_primary_evidence"])
7712 );
7713 assert_eq!(
7714 report["blocker_codes"],
7715 serde_json::json!(["search_candidate_identity_mismatch"])
7716 );
7717 let candidate_check = report["checks"]
7718 .as_array()
7719 .unwrap()
7720 .iter()
7721 .find(|check| check["name"] == "search_candidate_primary_evidence")
7722 .unwrap();
7723 assert_eq!(
7724 candidate_check["failed_evidence_fields"],
7725 serde_json::json!(["search_candidate_shadow_evidence.candidate_identity.ready"])
7726 );
7727 }
7728
7729 #[test]
7730 fn requires_search_candidate_filter_pushdown_evidence() {
7731 let mut bundle = ready_bundle();
7732 bundle["search_candidate_shadow_evidence"]["ready"] = serde_json::json!(true);
7733 bundle["search_candidate_shadow_evidence"]["filter_pushdown"]["ready"] =
7734 serde_json::json!(false);
7735 bundle["search_candidate_shadow_evidence"]["filter_pushdown"]["field_summary_count"] =
7736 serde_json::json!(0);
7737 bundle["search_candidate_shadow_evidence"]["filter_pushdown"]["missing_required_fields"] =
7738 serde_json::json!(["unit_type"]);
7739 bundle["search_candidate_shadow_evidence"]["blocker_codes"] =
7740 serde_json::json!(["search_candidate_field_pruning_missing"]);
7741
7742 let report = integration_readiness_json(&bundle);
7743
7744 assert_eq!(report["ready"], false);
7745 assert_eq!(
7746 report["failed_checks"],
7747 serde_json::json!(["search_candidate_primary_evidence"])
7748 );
7749 assert_eq!(
7750 report["blocker_codes"],
7751 serde_json::json!(["search_candidate_field_pruning_missing"])
7752 );
7753 let candidate_check = report["checks"]
7754 .as_array()
7755 .unwrap()
7756 .iter()
7757 .find(|check| check["name"] == "search_candidate_primary_evidence")
7758 .unwrap();
7759 assert_eq!(
7760 candidate_check["failed_evidence_fields"],
7761 serde_json::json!([
7762 "search_candidate_shadow_evidence.filter_pushdown.ready",
7763 "search_candidate_shadow_evidence.filter_pushdown.field_summary_count",
7764 "search_candidate_shadow_evidence.filter_pushdown.missing_required_fields"
7765 ])
7766 );
7767 }
7768
7769 #[test]
7770 fn requires_search_candidate_shadow_scan_fields() {
7771 let mut bundle = ready_bundle();
7772 bundle["search_candidate_shadow_evidence"]["ready"] = serde_json::json!(true);
7773 bundle["search_candidate_shadow_evidence"]["row_count_parity"] = serde_json::json!(false);
7774 bundle["search_candidate_shadow_evidence"]["shadow_scan_filter_pushdown_ready"] =
7775 serde_json::json!(false);
7776 bundle["search_candidate_shadow_evidence"]["shadow_scan_field_pruning_ready"] =
7777 serde_json::json!(false);
7778 bundle["search_candidate_shadow_evidence"]["shadow_scan_field_summary_count"] =
7779 serde_json::json!(0);
7780
7781 let report = integration_readiness_json(&bundle);
7782
7783 assert_eq!(report["ready"], false);
7784 assert_eq!(
7785 report["failed_checks"],
7786 serde_json::json!(["search_candidate_primary_evidence"])
7787 );
7788 let candidate_check = report["checks"]
7789 .as_array()
7790 .unwrap()
7791 .iter()
7792 .find(|check| check["name"] == "search_candidate_primary_evidence")
7793 .unwrap();
7794 assert_eq!(
7795 candidate_check["failed_evidence_fields"],
7796 serde_json::json!([
7797 "search_candidate_shadow_evidence.row_count_parity",
7798 "search_candidate_shadow_evidence.shadow_scan_filter_pushdown_ready",
7799 "search_candidate_shadow_evidence.shadow_scan_field_pruning_ready",
7800 "search_candidate_shadow_evidence.shadow_scan_field_summary_count"
7801 ])
7802 );
7803 }
7804
7805 #[test]
7806 fn requires_search_candidate_retriever_leg_evidence() {
7807 let mut bundle = ready_bundle();
7808 bundle["search_candidate_shadow_evidence"]["ready"] = serde_json::json!(true);
7809 bundle["search_candidate_shadow_evidence"]["text_retriever_ready"] =
7810 serde_json::json!(false);
7811 bundle["search_candidate_shadow_evidence"]["vector_retriever_ready"] =
7812 serde_json::json!(false);
7813
7814 let report = integration_readiness_json(&bundle);
7815
7816 assert_eq!(report["ready"], false);
7817 assert_eq!(
7818 report["failed_checks"],
7819 serde_json::json!(["search_candidate_primary_evidence"])
7820 );
7821 let candidate_check = report["checks"]
7822 .as_array()
7823 .unwrap()
7824 .iter()
7825 .find(|check| check["name"] == "search_candidate_primary_evidence")
7826 .unwrap();
7827 assert_eq!(
7828 candidate_check["failed_evidence_fields"],
7829 serde_json::json!([
7830 "search_candidate_shadow_evidence.text_retriever_ready",
7831 "search_candidate_shadow_evidence.vector_retriever_ready"
7832 ])
7833 );
7834 }
7835
7836 #[test]
7837 fn requires_search_candidate_top_k_overlap_evidence() {
7838 let mut bundle = ready_bundle();
7839 bundle["search_candidate_shadow_evidence"]["ready"] = serde_json::json!(true);
7840 bundle["search_candidate_shadow_evidence"]["fts_top_k_overlap_ready"] =
7841 serde_json::json!(false);
7842 bundle["search_candidate_shadow_evidence"]["vector_top_k_overlap_ready"] =
7843 serde_json::json!(false);
7844
7845 let report = integration_readiness_json(&bundle);
7846
7847 assert_eq!(report["ready"], false);
7848 assert_eq!(
7849 report["failed_checks"],
7850 serde_json::json!(["search_candidate_primary_evidence"])
7851 );
7852 let candidate_check = report["checks"]
7853 .as_array()
7854 .unwrap()
7855 .iter()
7856 .find(|check| check["name"] == "search_candidate_primary_evidence")
7857 .unwrap();
7858 assert_eq!(
7859 candidate_check["failed_evidence_fields"],
7860 serde_json::json!([
7861 "search_candidate_shadow_evidence.fts_top_k_overlap_ready",
7862 "search_candidate_shadow_evidence.vector_top_k_overlap_ready"
7863 ])
7864 );
7865 }
7866
7867 #[test]
7868 fn requires_search_candidate_readiness_evidence() {
7869 let mut bundle = ready_bundle();
7870 bundle["search_candidate_shadow_evidence"]["ready"] = serde_json::json!(true);
7871 bundle["search_candidate_shadow_evidence"]["candidate_readiness"] = serde_json::json!({
7872 "source_chunk_identity_ready": false,
7873 "fail_soft_observed": false,
7874 "projection_marker_status_visible": false,
7875 "projection_watermark_ready": false,
7876 "embedding_identity_ready": false,
7877 });
7878
7879 let report = integration_readiness_json(&bundle);
7880
7881 assert_eq!(report["ready"], false);
7882 assert_eq!(
7883 report["failed_checks"],
7884 serde_json::json!(["search_candidate_primary_evidence"])
7885 );
7886 let candidate_check = report["checks"]
7887 .as_array()
7888 .unwrap()
7889 .iter()
7890 .find(|check| check["name"] == "search_candidate_primary_evidence")
7891 .unwrap();
7892 assert_eq!(
7893 candidate_check["failed_evidence_fields"],
7894 serde_json::json!([
7895 "search_candidate_shadow_evidence.candidate_readiness.source_chunk_identity_ready",
7896 "search_candidate_shadow_evidence.candidate_readiness.fail_soft_observed",
7897 "search_candidate_shadow_evidence.candidate_readiness.projection_marker_status_visible",
7898 "search_candidate_shadow_evidence.candidate_readiness.projection_watermark_ready",
7899 "search_candidate_shadow_evidence.candidate_readiness.embedding_identity_ready"
7900 ])
7901 );
7902 }
7903
7904 #[test]
7905 fn rejects_search_candidate_trace_evidence_for_library_readiness() {
7906 let mut bundle = ready_bundle();
7907 bundle["search_candidate_shadow_evidence"] = ready_search_candidate_trace_evidence();
7908
7909 let report = integration_readiness_json(&bundle);
7910
7911 assert_eq!(report["ready"], false);
7912 assert_eq!(
7913 report["failed_checks"],
7914 serde_json::json!(["search_candidate_primary_evidence"])
7915 );
7916 let candidate_check = report["checks"]
7917 .as_array()
7918 .unwrap()
7919 .iter()
7920 .find(|check| check["name"] == "search_candidate_primary_evidence")
7921 .unwrap();
7922 assert_eq!(
7923 candidate_check["failed_evidence_fields"],
7924 serde_json::json!([
7925 "search_candidate_shadow_evidence.evidence_source",
7926 "search_candidate_shadow_evidence.candidate_primary_engine",
7927 "search_candidate_shadow_evidence.candidate_counts",
7928 "search_candidate_shadow_evidence.text_retriever_ready",
7929 "search_candidate_shadow_evidence.vector_retriever_ready",
7930 "search_candidate_shadow_evidence.candidate_readiness.source_chunk_identity_ready",
7931 "search_candidate_shadow_evidence.candidate_readiness.fail_soft_observed",
7932 "search_candidate_shadow_evidence.candidate_readiness.projection_marker_status_visible",
7933 "search_candidate_shadow_evidence.candidate_readiness.projection_watermark_ready",
7934 "search_candidate_shadow_evidence.candidate_readiness.embedding_identity_ready",
7935 "search_candidate_shadow_evidence.candidate_identity.ready",
7936 "search_candidate_shadow_evidence.filter_pushdown.ready",
7937 "search_candidate_shadow_evidence.filter_pushdown.field_summary_count",
7938 "search_candidate_shadow_evidence.filter_pushdown.missing_required_fields"
7939 ])
7940 );
7941 }
7942
7943 #[test]
7944 fn exposes_typed_search_candidate_cutover_readiness() {
7945 let bundle = ready_bundle();
7946
7947 let typed = super::search_candidate_cutover_readiness(&bundle);
7948
7949 assert!(typed.evidence_ready());
7950 assert!(typed.protocol_matches);
7951 assert!(typed.evidence_source_matches);
7952 assert!(typed.route_matches);
7953 assert!(typed.primary_engine_matches);
7954 assert!(typed.candidate_count_parity);
7955 assert!(typed.row_count_parity);
7956 assert!(typed.text_retriever_ready);
7957 assert!(typed.vector_retriever_ready);
7958 assert!(typed.fts_top_k_overlap_ready);
7959 assert!(typed.vector_top_k_overlap_ready);
7960 assert!(typed.source_chunk_identity_ready);
7961 assert!(typed.fail_soft_observed);
7962 assert!(typed.projection_marker_status_visible);
7963 assert!(typed.projection_watermark_ready);
7964 assert!(typed.embedding_identity_ready);
7965 assert!(typed.candidate_identity_ready);
7966 assert!(typed.filter_pushdown_ready);
7967 assert!(typed.filter_pushdown_field_summary_present);
7968 assert!(typed.filter_pushdown_required_fields_ready);
7969 assert!(typed.blocker_codes.is_empty());
7970 }
7971
7972 #[test]
7973 fn typed_search_candidate_cutover_requires_rust_bridge_evidence() {
7974 let mut bundle = ready_bundle();
7975 bundle["search_candidate_shadow_evidence"] = ready_search_candidate_trace_evidence();
7976
7977 let typed = super::search_candidate_cutover_readiness(&bundle);
7978
7979 assert!(!typed.evidence_ready());
7980 assert!(!typed.evidence_source_matches);
7981 assert!(!typed.primary_engine_matches);
7982 assert!(!typed.candidate_count_parity);
7983 }
7984
7985 #[test]
7986 fn requires_search_candidate_shadow_evidence_presence() {
7987 let mut bundle = ready_bundle();
7988 bundle
7989 .as_object_mut()
7990 .unwrap()
7991 .remove("search_candidate_shadow_evidence");
7992
7993 let report = integration_readiness_json(&bundle);
7994
7995 assert_eq!(report["ready"], false);
7996 assert_eq!(
7997 report["failed_checks"],
7998 serde_json::json!(["search_candidate_primary_evidence"])
7999 );
8000 let candidate_check = report["checks"]
8001 .as_array()
8002 .unwrap()
8003 .iter()
8004 .find(|check| check["name"] == "search_candidate_primary_evidence")
8005 .unwrap();
8006 assert_eq!(
8007 candidate_check["failed_evidence_fields"],
8008 serde_json::json!([
8009 "search_candidate_shadow_evidence.protocol",
8010 "search_candidate_shadow_evidence.evidence_source",
8011 "search_candidate_shadow_evidence.route",
8012 "search_candidate_shadow_evidence.ready",
8013 "search_candidate_shadow_evidence.candidate_primary_engine",
8014 "search_candidate_shadow_evidence.candidate_counts",
8015 "search_candidate_shadow_evidence.row_count_parity",
8016 "search_candidate_shadow_evidence.text_retriever_ready",
8017 "search_candidate_shadow_evidence.vector_retriever_ready",
8018 "search_candidate_shadow_evidence.fts_top_k_overlap_ready",
8019 "search_candidate_shadow_evidence.vector_top_k_overlap_ready",
8020 "search_candidate_shadow_evidence.candidate_readiness.source_chunk_identity_ready",
8021 "search_candidate_shadow_evidence.candidate_readiness.fail_soft_observed",
8022 "search_candidate_shadow_evidence.candidate_readiness.projection_marker_status_visible",
8023 "search_candidate_shadow_evidence.candidate_readiness.projection_watermark_ready",
8024 "search_candidate_shadow_evidence.candidate_readiness.embedding_identity_ready",
8025 "search_candidate_shadow_evidence.candidate_identity.ready",
8026 "search_candidate_shadow_evidence.filter_pushdown.ready",
8027 "search_candidate_shadow_evidence.filter_pushdown.field_summary_count",
8028 "search_candidate_shadow_evidence.filter_pushdown.missing_required_fields",
8029 "search_candidate_shadow_evidence.shadow_scan_filter_pushdown_ready",
8030 "search_candidate_shadow_evidence.shadow_scan_field_pruning_ready",
8031 "search_candidate_shadow_evidence.shadow_scan_field_summary_count"
8032 ])
8033 );
8034 }
8035
8036 #[test]
8037 fn requires_search_candidate_shadow_evidence_source() {
8038 let mut bundle = ready_bundle();
8039 bundle["search_candidate_shadow_evidence"]["evidence_source"] =
8040 serde_json::json!("manual-json");
8041
8042 let report = integration_readiness_json(&bundle);
8043
8044 assert_eq!(report["ready"], false);
8045 assert_eq!(
8046 report["failed_checks"],
8047 serde_json::json!(["search_candidate_primary_evidence"])
8048 );
8049 let candidate_check = report["checks"]
8050 .as_array()
8051 .unwrap()
8052 .iter()
8053 .find(|check| check["name"] == "search_candidate_primary_evidence")
8054 .unwrap();
8055 assert_eq!(
8056 candidate_check["failed_evidence_fields"],
8057 serde_json::json!(["search_candidate_shadow_evidence.evidence_source"])
8058 );
8059 }
8060
8061 #[test]
8062 fn requires_search_candidate_shadow_evidence_route() {
8063 let mut bundle = ready_bundle();
8064 bundle["search_candidate_shadow_evidence"]["route"] = serde_json::json!("/manual");
8065
8066 let report = integration_readiness_json(&bundle);
8067
8068 assert_eq!(report["ready"], false);
8069 assert_eq!(
8070 report["failed_checks"],
8071 serde_json::json!(["search_candidate_primary_evidence"])
8072 );
8073 let candidate_check = report["checks"]
8074 .as_array()
8075 .unwrap()
8076 .iter()
8077 .find(|check| check["name"] == "search_candidate_primary_evidence")
8078 .unwrap();
8079 assert_eq!(
8080 candidate_check["failed_evidence_fields"],
8081 serde_json::json!(["search_candidate_shadow_evidence.route"])
8082 );
8083 }
8084
8085 #[test]
8086 fn requires_search_projection_shadow_descriptor_field_coverage() {
8087 let mut bundle = ready_bundle();
8088 bundle["replacement_summary"]["search_projection_shadow_evidence"]["pushdown_evidence"]
8089 ["ready"] = serde_json::json!(false);
8090 bundle["replacement_summary"]["search_projection_shadow_evidence"]["pushdown_evidence"]
8091 ["shadow_segment_descriptor_scan_filter_fields_ready"] = serde_json::json!(false);
8092 bundle["replacement_summary"]["search_projection_shadow_evidence"]["blocker_codes"] =
8093 serde_json::json!(["hawdb_search_projection_segment_descriptor_fields_missing"]);
8094
8095 let report = integration_readiness_json(&bundle);
8096
8097 assert_eq!(report["ready"], false);
8098 assert_eq!(
8099 report["failed_checks"],
8100 serde_json::json!(["search_projection_replacement_evidence"])
8101 );
8102 assert_eq!(
8103 report["blocker_codes"],
8104 serde_json::json!(["hawdb_search_projection_segment_descriptor_fields_missing"])
8105 );
8106 let search_check = report["checks"]
8107 .as_array()
8108 .unwrap()
8109 .iter()
8110 .find(|check| check["name"] == "search_projection_replacement_evidence")
8111 .unwrap();
8112 assert_eq!(
8113 search_check["failed_evidence_fields"],
8114 serde_json::json!([
8115 "replacement_summary.search_projection_shadow_evidence.pushdown_evidence.ready",
8116 "replacement_summary.search_projection_shadow_evidence.pushdown_evidence.shadow_segment_descriptor_scan_filter_fields_ready"
8117 ])
8118 );
8119 }
8120
8121 #[test]
8122 fn recomputes_search_projection_shadow_descriptor_field_coverage() {
8123 let mut bundle = ready_bundle();
8124 bundle["replacement_summary"]["search_projection_shadow_evidence"]["ready"] =
8125 serde_json::json!(true);
8126 bundle["replacement_summary"]["search_projection_shadow_evidence"]["pushdown_evidence"]
8127 ["ready"] = serde_json::json!(true);
8128 bundle["replacement_summary"]["search_projection_shadow_evidence"]["pushdown_evidence"]
8129 ["shadow_segment_descriptor_scan_filter_fields_ready"] = serde_json::json!(true);
8130 bundle["replacement_summary"]["search_projection_shadow_evidence"]["pushdown_evidence"]
8131 ["primary_scan_filter_fields"] = serde_json::json!(["unit_type", "importance"]);
8132 bundle["replacement_summary"]["search_projection_shadow_evidence"]["pushdown_evidence"]
8133 ["shadow_scan_filter_fields"] = serde_json::json!(["unit_type", "importance"]);
8134 bundle["replacement_summary"]["search_projection_shadow_evidence"]["pushdown_evidence"]
8135 ["shadow_segment_descriptor_field_summaries"] =
8136 serde_json::json!([{ "field": "unit_type" }, { "field": "importance" }]);
8137
8138 let report = integration_readiness_json(&bundle);
8139
8140 assert_eq!(report["ready"], false);
8141 assert_eq!(
8142 report["failed_checks"],
8143 serde_json::json!(["search_projection_replacement_evidence"])
8144 );
8145 let search_check = report["checks"]
8146 .as_array()
8147 .unwrap()
8148 .iter()
8149 .find(|check| check["name"] == "search_projection_replacement_evidence")
8150 .unwrap();
8151 assert_eq!(
8152 search_check["failed_evidence_fields"],
8153 serde_json::json!([
8154 "replacement_summary.search_projection_shadow_evidence.pushdown_evidence.primary_scan_filter_fields",
8155 "replacement_summary.search_projection_shadow_evidence.pushdown_evidence.shadow_scan_filter_fields",
8156 "replacement_summary.search_projection_shadow_evidence.pushdown_evidence.shadow_segment_descriptor_field_summaries"
8157 ])
8158 );
8159 }
8160
8161 #[test]
8162 fn recomputes_search_projection_shadow_descriptor_range_capabilities() {
8163 let mut bundle = ready_bundle();
8164 let summaries = bundle["replacement_summary"]["search_projection_shadow_evidence"]
8165 ["pushdown_evidence"]["shadow_segment_descriptor_field_summaries"]
8166 .as_array_mut()
8167 .unwrap();
8168 for summary in summaries {
8169 if summary["field"] == "importance" {
8170 summary["numeric_range_summary_used"] = serde_json::json!(false);
8171 }
8172 if summary["field"] == "created_at" {
8173 summary["timestamp_range_summary_used"] = serde_json::json!(false);
8174 }
8175 }
8176
8177 let report = integration_readiness_json(&bundle);
8178
8179 assert_eq!(report["ready"], false);
8180 assert_eq!(
8181 report["failed_checks"],
8182 serde_json::json!(["search_projection_replacement_evidence"])
8183 );
8184 let search_check = report["checks"]
8185 .as_array()
8186 .unwrap()
8187 .iter()
8188 .find(|check| check["name"] == "search_projection_replacement_evidence")
8189 .unwrap();
8190 assert_eq!(
8191 search_check["failed_evidence_fields"],
8192 serde_json::json!([
8193 "replacement_summary.search_projection_shadow_evidence.pushdown_evidence.shadow_segment_descriptor_field_summaries"
8194 ])
8195 );
8196 }
8197
8198 #[test]
8199 fn recomputes_search_projection_shadow_descriptor_unique_key_capability() {
8200 let mut bundle = ready_bundle();
8201 let summaries = bundle["replacement_summary"]["search_projection_shadow_evidence"]
8202 ["pushdown_evidence"]["shadow_segment_descriptor_field_summaries"]
8203 .as_array_mut()
8204 .unwrap();
8205 let document_id = summaries
8206 .iter_mut()
8207 .find(|summary| summary["field"] == "document_id")
8208 .unwrap();
8209 document_id["unique_key_summary_used"] = serde_json::json!(false);
8210
8211 let report = integration_readiness_json(&bundle);
8212
8213 assert_eq!(report["ready"], false);
8214 assert_eq!(
8215 report["failed_checks"],
8216 serde_json::json!(["search_projection_replacement_evidence"])
8217 );
8218 let search_check = report["checks"]
8219 .as_array()
8220 .unwrap()
8221 .iter()
8222 .find(|check| check["name"] == "search_projection_replacement_evidence")
8223 .unwrap();
8224 assert_eq!(
8225 search_check["failed_evidence_fields"],
8226 serde_json::json!([
8227 "replacement_summary.search_projection_shadow_evidence.pushdown_evidence.shadow_segment_descriptor_field_summaries"
8228 ])
8229 );
8230 }
8231
8232 #[test]
8233 fn recomputes_search_projection_shadow_document_pruning_counts() {
8234 let mut bundle = ready_bundle();
8235 bundle["replacement_summary"]["search_projection_shadow_evidence"]["pushdown_evidence"]
8236 ["shadow_segment_document_pruning_ready"] = serde_json::json!(true);
8237 bundle["replacement_summary"]["search_projection_shadow_evidence"]["pushdown_evidence"]
8238 ["shadow_segment_pruned_document_count"] = serde_json::json!(0);
8239
8240 let report = integration_readiness_json(&bundle);
8241
8242 assert_eq!(report["ready"], false);
8243 assert_eq!(
8244 report["failed_checks"],
8245 serde_json::json!(["search_projection_replacement_evidence"])
8246 );
8247 let search_check = report["checks"]
8248 .as_array()
8249 .unwrap()
8250 .iter()
8251 .find(|check| check["name"] == "search_projection_replacement_evidence")
8252 .unwrap();
8253 assert_eq!(
8254 search_check["failed_evidence_fields"],
8255 serde_json::json!([
8256 "replacement_summary.search_projection_shadow_evidence.pushdown_evidence.shadow_segment_pruning_candidate_document_count",
8257 "replacement_summary.search_projection_shadow_evidence.pushdown_evidence.shadow_segment_pruned_document_count"
8258 ])
8259 );
8260 }
8261
8262 #[test]
8263 fn requires_search_projection_shadow_evidence_source() {
8264 let mut bundle = ready_bundle();
8265 bundle["replacement_summary"]["search_projection_shadow_evidence"]["evidence_source"] =
8266 serde_json::json!("manual-json");
8267
8268 let report = integration_readiness_json(&bundle);
8269
8270 assert_eq!(report["ready"], false);
8271 assert_eq!(
8272 report["failed_checks"],
8273 serde_json::json!(["search_projection_replacement_evidence"])
8274 );
8275 let search_check = report["checks"]
8276 .as_array()
8277 .unwrap()
8278 .iter()
8279 .find(|check| check["name"] == "search_projection_replacement_evidence")
8280 .unwrap();
8281 assert_eq!(
8282 search_check["failed_evidence_fields"],
8283 serde_json::json!([
8284 "replacement_summary.search_projection_shadow_evidence.evidence_source"
8285 ])
8286 );
8287 }
8288
8289 #[test]
8290 fn requires_compressed_vector_projection_readiness() {
8291 let mut bundle = ready_bundle();
8292 bundle["replacement_summary"]["search_projection_evidence"]
8293 ["compressed_vector_projection_ready"] = serde_json::json!(false);
8294 bundle["replacement_summary"]["search_projection_evidence"]["blocker_codes"] =
8295 serde_json::json!(["compressed_vector_projection_not_ready"]);
8296
8297 let report = integration_readiness_json(&bundle);
8298
8299 assert_eq!(report["ready"], false);
8300 assert_eq!(
8301 report["failed_checks"],
8302 serde_json::json!(["search_projection_replacement_evidence"])
8303 );
8304 assert_eq!(
8305 report["blocker_codes"],
8306 serde_json::json!(["compressed_vector_projection_not_ready"])
8307 );
8308 let search_check = report["checks"]
8309 .as_array()
8310 .unwrap()
8311 .iter()
8312 .find(|check| check["name"] == "search_projection_replacement_evidence")
8313 .unwrap();
8314 assert_eq!(
8315 search_check["failed_evidence_fields"],
8316 serde_json::json!([
8317 "replacement_summary.search_projection_evidence.compressed_vector_projection_ready"
8318 ])
8319 );
8320 }
8321
8322 #[test]
8323 fn requires_search_projection_evidence_protocols() {
8324 let mut bundle = ready_bundle();
8325 bundle["replacement_summary"]["search_projection_evidence"]["protocol"] =
8326 serde_json::json!("handwritten");
8327 bundle["replacement_summary"]["search_projection_shadow_evidence"]["protocol"] =
8328 serde_json::json!("handwritten");
8329
8330 let report = integration_readiness_json(&bundle);
8331
8332 assert_eq!(report["ready"], false);
8333 assert_eq!(
8334 report["failed_checks"],
8335 serde_json::json!(["search_projection_replacement_evidence"])
8336 );
8337 let search_check = report["checks"]
8338 .as_array()
8339 .unwrap()
8340 .iter()
8341 .find(|check| check["name"] == "search_projection_replacement_evidence")
8342 .unwrap();
8343 assert_eq!(
8344 search_check["failed_evidence_fields"],
8345 serde_json::json!([
8346 "replacement_summary.search_projection_evidence.protocol",
8347 "replacement_summary.search_projection_shadow_evidence.protocol"
8348 ])
8349 );
8350 assert!(report["next_actions"]
8351 .as_array()
8352 .unwrap()
8353 .iter()
8354 .any(|action| {
8355 action["action"] == "attach_search_projection_replacement_evidence"
8356 && action["evidence_fields"]
8357 .as_array()
8358 .unwrap()
8359 .iter()
8360 .any(|field| {
8361 field == "replacement_summary.search_projection_evidence.protocol"
8362 })
8363 }));
8364 }
8365
8366 #[test]
8367 fn exposes_typed_graph_replacement_cutover_readiness() {
8368 let bundle = ready_bundle();
8369
8370 let typed = super::graph_replacement_cutover_readiness(&bundle);
8371
8372 assert!(typed.evidence_ready());
8373 assert!(typed.production_cutover_ready);
8374 assert!(typed.shadow_evidence_ready);
8375 assert!(typed.dual_engine_evidence_present);
8376 assert!(typed.dual_engine_evidence_ready);
8377 assert!(typed.dual_engine_evidence_consistent);
8378 assert!(typed.blocker_codes.is_empty());
8379 }
8380
8381 #[test]
8382 fn typed_graph_replacement_cutover_readiness_rejects_inconsistent_dual_engine() {
8383 let mut bundle = ready_bundle();
8384 bundle["replacement_summary"]["dual_engine_evidence"]["consistent"] =
8385 serde_json::json!(false);
8386 bundle["replacement_summary"]["dual_engine_evidence"]["blocker_codes"] =
8387 serde_json::json!(["dual_engine_inconsistent"]);
8388
8389 let typed = super::graph_replacement_cutover_readiness(&bundle);
8390
8391 assert!(!typed.evidence_ready());
8392 assert!(!typed.dual_engine_evidence_consistent);
8393 assert_eq!(
8394 typed.blocker_codes,
8395 vec!["dual_engine_inconsistent".to_string()]
8396 );
8397 }
8398
8399 #[test]
8400 fn exposes_typed_query_family_replacement_cutover_readiness() {
8401 let bundle = ready_bundle();
8402
8403 let typed = super::query_family_replacement_cutover_readiness(&bundle);
8404
8405 assert!(typed.evidence_ready());
8406 assert!(typed.required_query_families_present);
8407 assert!(typed.missing_required_query_families_empty);
8408 assert!(typed.blocked_query_families_empty);
8409 assert!(typed.min_replacement_readiness_full);
8410 assert!(typed.blocker_codes.is_empty());
8411 }
8412
8413 #[test]
8414 fn typed_query_family_replacement_cutover_readiness_rejects_missing_family() {
8415 let mut bundle = ready_bundle();
8416 bundle["replacement_summary"]["replacement_readiness_family_summary"]
8417 ["missing_required_query_families"] = serde_json::json!(["projected_graph"]);
8418 bundle["replacement_summary"]["missing_evidence"] =
8419 serde_json::json!(["query_family.projected_graph"]);
8420
8421 let typed = super::query_family_replacement_cutover_readiness(&bundle);
8422
8423 assert!(!typed.evidence_ready());
8424 assert!(!typed.missing_required_query_families_empty);
8425 assert_eq!(
8426 typed.blocker_codes,
8427 vec!["query_family.projected_graph".to_string()]
8428 );
8429 }
8430
8431 #[test]
8432 fn requires_explicit_required_query_family_readiness() {
8433 let mut bundle = ready_bundle();
8434 bundle["replacement_summary"]
8435 .as_object_mut()
8436 .unwrap()
8437 .remove("replacement_readiness_family_summary");
8438
8439 let report = integration_readiness_json(&bundle);
8440
8441 assert_eq!(report["ready"], false);
8442 assert_eq!(
8443 report["failed_checks"],
8444 serde_json::json!(["query_family_replacement_evidence"])
8445 );
8446 let family_check = report["checks"]
8447 .as_array()
8448 .unwrap()
8449 .iter()
8450 .find(|check| check["name"] == "query_family_replacement_evidence")
8451 .unwrap();
8452 assert_eq!(
8453 family_check["failed_evidence_fields"],
8454 serde_json::json!([
8455 "replacement_summary.replacement_readiness_family_summary.required_query_families",
8456 "replacement_summary.replacement_readiness_family_summary.min_replacement_readiness_per_million"
8457 ])
8458 );
8459 assert!(report["next_actions"]
8460 .as_array()
8461 .unwrap()
8462 .iter()
8463 .any(|action| action["action"] == "close_required_query_families"));
8464 }
8465
8466 #[test]
8467 fn rejects_missing_required_query_family_even_if_cutover_flag_is_true() {
8468 let mut bundle = ready_bundle();
8469 bundle["replacement_summary"]["replacement_readiness_family_summary"]
8470 ["missing_required_query_families"] = serde_json::json!(["projected_graph"]);
8471
8472 let report = integration_readiness_json(&bundle);
8473
8474 assert_eq!(report["ready"], false);
8475 assert_eq!(
8476 report["failed_checks"],
8477 serde_json::json!(["query_family_replacement_evidence"])
8478 );
8479 let family_check = report["checks"]
8480 .as_array()
8481 .unwrap()
8482 .iter()
8483 .find(|check| check["name"] == "query_family_replacement_evidence")
8484 .unwrap();
8485 assert_eq!(
8486 family_check["failed_evidence_fields"],
8487 serde_json::json!([
8488 "replacement_summary.replacement_readiness_family_summary.missing_required_query_families"
8489 ])
8490 );
8491 }
8492
8493 #[test]
8494 fn requires_bounded_read_evidence() {
8495 let mut bundle = ready_bundle();
8496 bundle["replacement_summary"]["bounded_read_evidence"]["ready"] = serde_json::json!(false);
8497 bundle["replacement_summary"]["bounded_read_evidence"]
8498 ["row_limit_enforced_before_output"] = serde_json::json!(false);
8499 bundle["replacement_summary"]["bounded_read_evidence"]["blocker_codes"] =
8500 serde_json::json!(["row_cap_not_enforced"]);
8501
8502 let report = integration_readiness_json(&bundle);
8503
8504 assert_eq!(report["ready"], false);
8505 assert_eq!(
8506 report["failed_checks"],
8507 serde_json::json!(["bounded_read_evidence"])
8508 );
8509 assert_eq!(
8510 report["blocker_codes"],
8511 serde_json::json!(["row_cap_not_enforced"])
8512 );
8513 let read_check = report["checks"]
8514 .as_array()
8515 .unwrap()
8516 .iter()
8517 .find(|check| check["name"] == "bounded_read_evidence")
8518 .unwrap();
8519 assert_eq!(
8520 read_check["failed_evidence_fields"],
8521 serde_json::json!([
8522 "replacement_summary.bounded_read_evidence.ready",
8523 "replacement_summary.bounded_read_evidence.row_limit_enforced_before_output"
8524 ])
8525 );
8526 assert!(report["next_actions"]
8527 .as_array()
8528 .unwrap()
8529 .iter()
8530 .any(|action| action["action"] == "attach_bounded_read_profile"));
8531 }
8532
8533 #[test]
8534 fn exposes_typed_bounded_read_cutover_readiness() {
8535 let bundle = ready_bundle();
8536
8537 let typed = super::bounded_read_cutover_readiness(&bundle);
8538
8539 assert!(typed.evidence_ready());
8540 assert!(typed.present);
8541 assert!(typed.protocol_matches);
8542 assert!(typed.max_rows_present);
8543 assert!(typed.execution_cap_matches);
8544 assert!(typed.estimated_payload_bytes_present);
8545 assert!(typed.max_estimated_payload_bytes_present);
8546 assert!(typed.payload_budget_not_exceeded);
8547 assert!(typed.row_limit_enforced_before_output);
8548 assert!(typed.operator_row_cap_enabled);
8549 assert!(typed.blocking_operator_memory_reports_complete);
8550 assert!(typed.blocking_operator_memory_within_budget);
8551 assert!(typed.spill_within_budget);
8552 assert!(typed.streaming_evidence_present);
8553 assert!(typed.route_catalog_version_matches);
8554 assert!(typed.route_catalog_digest_present);
8555 assert!(typed.route_coverage_ready);
8556 assert!(typed.blocker_codes.is_empty());
8557 }
8558
8559 #[test]
8560 fn typed_bounded_read_cutover_requires_route_coverage() {
8561 let mut bundle = ready_bundle();
8562 bundle["replacement_summary"]["bounded_read_evidence"]["covered_routes"] =
8563 serde_json::json!(["/graph/overview"]);
8564 bundle["replacement_summary"]["bounded_read_evidence"]["missing_covered_routes"] =
8565 serde_json::json!(["/graph/explore"]);
8566
8567 let typed = super::bounded_read_cutover_readiness(&bundle);
8568
8569 assert!(!typed.evidence_ready());
8570 assert!(!typed.route_coverage_ready);
8571 }
8572
8573 #[test]
8574 fn requires_bounded_read_payload_budget() {
8575 let mut bundle = ready_bundle();
8576 bundle["replacement_summary"]["bounded_read_evidence"]["ready"] = serde_json::json!(false);
8577 bundle["replacement_summary"]["bounded_read_evidence"]["estimated_payload_bytes"] =
8578 serde_json::json!(8192);
8579 bundle["replacement_summary"]["bounded_read_evidence"]["max_estimated_payload_bytes"] =
8580 serde_json::json!(4096);
8581 bundle["replacement_summary"]["bounded_read_evidence"]["payload_budget_exceeded"] =
8582 serde_json::json!(true);
8583 bundle["replacement_summary"]["bounded_read_evidence"]["blocker_codes"] =
8584 serde_json::json!(["payload_budget_exceeded"]);
8585
8586 let report = integration_readiness_json(&bundle);
8587
8588 assert_eq!(report["ready"], false);
8589 assert_eq!(
8590 report["failed_checks"],
8591 serde_json::json!(["bounded_read_evidence"])
8592 );
8593 assert_eq!(
8594 report["blocker_codes"],
8595 serde_json::json!(["payload_budget_exceeded"])
8596 );
8597 let read_check = report["checks"]
8598 .as_array()
8599 .unwrap()
8600 .iter()
8601 .find(|check| check["name"] == "bounded_read_evidence")
8602 .unwrap();
8603 assert_eq!(
8604 read_check["failed_evidence_fields"],
8605 serde_json::json!([
8606 "replacement_summary.bounded_read_evidence.ready",
8607 "replacement_summary.bounded_read_evidence.payload_budget_exceeded"
8608 ])
8609 );
8610 }
8611
8612 #[test]
8613 fn requires_bounded_read_route_coverage() {
8614 let mut bundle = ready_bundle();
8615 bundle["replacement_summary"]["bounded_read_evidence"]["covered_routes"] =
8616 serde_json::json!(["/graph/overview"]);
8617 bundle["replacement_summary"]["bounded_read_evidence"]["missing_covered_routes"] =
8618 serde_json::json!(["/graph/explore"]);
8619
8620 let report = integration_readiness_json(&bundle);
8621
8622 assert_eq!(report["ready"], false);
8623 assert_eq!(
8624 report["failed_checks"],
8625 serde_json::json!(["bounded_read_evidence"])
8626 );
8627 let read_check = report["checks"]
8628 .as_array()
8629 .unwrap()
8630 .iter()
8631 .find(|check| check["name"] == "bounded_read_evidence")
8632 .unwrap();
8633 assert_eq!(
8634 read_check["failed_evidence_fields"],
8635 serde_json::json!(["replacement_summary.bounded_read_evidence.covered_routes"])
8636 );
8637 }
8638
8639 #[test]
8640 fn rejects_stale_bounded_read_summary_when_live_evidence_is_not_ready() {
8641 let mut bundle = ready_bundle();
8642 bundle["bounded_read_evidence"]["ready"] = serde_json::json!(false);
8643 bundle["bounded_read_evidence"]["blocker_codes"] =
8644 serde_json::json!(["hawdb_shadow_runtime_not_open"]);
8645 bundle["replacement_summary_bounded_read_alignment"]["ready"] = serde_json::json!(false);
8646 bundle["replacement_summary_bounded_read_alignment"]["evidence_ready"] =
8647 serde_json::json!(false);
8648 bundle["replacement_summary_bounded_read_alignment"]["readiness_matches"] =
8649 serde_json::json!(false);
8650 bundle["replacement_summary_bounded_read_alignment"]["blocker_codes"] =
8651 serde_json::json!(["replacement_summary_bounded_read_evidence_mismatch"]);
8652
8653 let report = integration_readiness_json(&bundle);
8654
8655 assert_eq!(report["ready"], false);
8656 assert_eq!(
8657 report["failed_checks"],
8658 serde_json::json!(["bounded_read_evidence_alignment"])
8659 );
8660 assert_eq!(
8661 report["blocker_codes"],
8662 serde_json::json!([
8663 "hawdb_shadow_runtime_not_open",
8664 "replacement_summary_bounded_read_evidence_mismatch"
8665 ])
8666 );
8667 let alignment_check = report["checks"]
8668 .as_array()
8669 .unwrap()
8670 .iter()
8671 .find(|check| check["name"] == "bounded_read_evidence_alignment")
8672 .unwrap();
8673 assert_eq!(
8674 alignment_check["failed_evidence_fields"],
8675 serde_json::json!([
8676 "bounded_read_evidence.ready",
8677 "replacement_summary_bounded_read_alignment.ready",
8678 "replacement_summary_bounded_read_alignment.evidence_ready",
8679 "replacement_summary_bounded_read_alignment.readiness_matches"
8680 ])
8681 );
8682 assert!(report["next_actions"]
8683 .as_array()
8684 .unwrap()
8685 .iter()
8686 .any(|action| action["action"] == "regenerate_bounded_read_alignment"));
8687 }
8688
8689 #[test]
8690 fn exposes_typed_bounded_read_alignment_cutover_readiness() {
8691 let bundle = ready_bundle();
8692
8693 let typed = super::bounded_read_alignment_cutover_readiness(&bundle);
8694
8695 assert!(typed.evidence_ready());
8696 assert!(typed.ready);
8697 assert!(typed.alignment_evidence_ready);
8698 assert!(typed.summary_ready);
8699 assert!(typed.protocol_matches);
8700 assert!(typed.readiness_matches);
8701 assert!(typed.mode_matches);
8702 assert!(typed.max_rows_matches);
8703 assert!(typed.estimated_payload_bytes_matches);
8704 assert!(typed.max_estimated_payload_bytes_matches);
8705 assert!(typed.payload_budget_exceeded_matches);
8706 assert!(typed.streaming_matches);
8707 assert!(typed.covered_routes_matches);
8708 assert!(typed.evidence_route_catalog_version_ready);
8709 assert!(typed.summary_route_catalog_version_ready);
8710 assert!(typed.evidence_route_catalog_digest_ready);
8711 assert!(typed.summary_route_catalog_digest_ready);
8712 assert!(typed.route_catalog_version_matches);
8713 assert!(typed.route_catalog_digest_matches);
8714 assert!(typed.blocker_codes.is_empty());
8715 }
8716
8717 #[test]
8718 fn typed_bounded_read_alignment_detects_stale_route_coverage() {
8719 let mut bundle = ready_bundle();
8720 bundle["replacement_summary_bounded_read_alignment"]["ready"] = serde_json::json!(false);
8721 bundle["replacement_summary_bounded_read_alignment"]["covered_routes_matches"] =
8722 serde_json::json!(false);
8723 bundle["replacement_summary_bounded_read_alignment"]["blocker_codes"] =
8724 serde_json::json!(["replacement_summary_bounded_read_evidence_mismatch"]);
8725
8726 let typed = super::bounded_read_alignment_cutover_readiness(&bundle);
8727
8728 assert!(!typed.evidence_ready());
8729 assert!(!typed.ready);
8730 assert!(!typed.covered_routes_matches);
8731 assert_eq!(
8732 typed.blocker_codes,
8733 vec!["replacement_summary_bounded_read_evidence_mismatch".to_string()]
8734 );
8735 }
8736
8737 #[test]
8738 fn rejects_stale_bounded_read_summary_when_route_coverage_differs() {
8739 let mut bundle = ready_bundle();
8740 bundle["replacement_summary_bounded_read_alignment"]["ready"] = serde_json::json!(false);
8741 bundle["replacement_summary_bounded_read_alignment"]["covered_routes_matches"] =
8742 serde_json::json!(false);
8743 bundle["replacement_summary_bounded_read_alignment"]["blocker_codes"] =
8744 serde_json::json!(["replacement_summary_bounded_read_evidence_mismatch"]);
8745
8746 let report = integration_readiness_json(&bundle);
8747
8748 assert_eq!(report["ready"], false);
8749 assert_eq!(
8750 report["failed_checks"],
8751 serde_json::json!(["bounded_read_evidence_alignment"])
8752 );
8753 let alignment_check = report["checks"]
8754 .as_array()
8755 .unwrap()
8756 .iter()
8757 .find(|check| check["name"] == "bounded_read_evidence_alignment")
8758 .unwrap();
8759 assert_eq!(
8760 alignment_check["failed_evidence_fields"],
8761 serde_json::json!([
8762 "replacement_summary_bounded_read_alignment.ready",
8763 "replacement_summary_bounded_read_alignment.covered_routes_matches"
8764 ])
8765 );
8766 }
8767
8768 #[test]
8769 fn rejects_stale_bounded_read_summary_when_payload_budget_differs() {
8770 let mut bundle = ready_bundle();
8771 bundle["replacement_summary_bounded_read_alignment"]["ready"] = serde_json::json!(false);
8772 bundle["replacement_summary_bounded_read_alignment"]["estimated_payload_bytes_matches"] =
8773 serde_json::json!(false);
8774 bundle["replacement_summary_bounded_read_alignment"]["payload_budget_exceeded_matches"] =
8775 serde_json::json!(false);
8776 bundle["replacement_summary_bounded_read_alignment"]["blocker_codes"] =
8777 serde_json::json!([
8778 "bounded_read_estimated_payload_bytes_mismatch",
8779 "bounded_read_payload_budget_exceeded_mismatch"
8780 ]);
8781
8782 let report = integration_readiness_json(&bundle);
8783
8784 assert_eq!(report["ready"], false);
8785 assert_eq!(
8786 report["failed_checks"],
8787 serde_json::json!(["bounded_read_evidence_alignment"])
8788 );
8789 let alignment_check = report["checks"]
8790 .as_array()
8791 .unwrap()
8792 .iter()
8793 .find(|check| check["name"] == "bounded_read_evidence_alignment")
8794 .unwrap();
8795 assert_eq!(
8796 alignment_check["failed_evidence_fields"],
8797 serde_json::json!([
8798 "replacement_summary_bounded_read_alignment.ready",
8799 "replacement_summary_bounded_read_alignment.estimated_payload_bytes_matches",
8800 "replacement_summary_bounded_read_alignment.payload_budget_exceeded_matches"
8801 ])
8802 );
8803 }
8804
8805 #[test]
8806 fn rejects_inconsistent_bounded_read_summary_even_if_ready_flag_is_true() {
8807 let mut bundle = ready_bundle();
8808 bundle["replacement_summary"]["bounded_read_evidence"]["mode"] =
8809 serde_json::json!("writable_cutover");
8810 bundle["replacement_summary"]["bounded_read_evidence"]["execution_row_cap"] =
8811 serde_json::json!(512);
8812 bundle["replacement_summary"]["bounded_read_evidence"]["blocking_operator_count"] =
8813 serde_json::json!(1);
8814 bundle["replacement_summary"]["bounded_read_evidence"]["streaming"] =
8815 serde_json::json!(true);
8816 bundle["replacement_summary"]["bounded_read_evidence"]
8817 ["blocking_operator_memory_reports_complete"] = serde_json::json!(false);
8818 bundle["replacement_summary"]["bounded_read_evidence"]
8819 ["blocking_operator_memory_within_budget"] = serde_json::json!(false);
8820 bundle["replacement_summary"]["bounded_read_evidence"]["spill_within_budget"] =
8821 serde_json::json!(false);
8822
8823 let report = integration_readiness_json(&bundle);
8824
8825 assert_eq!(report["ready"], false);
8826 assert_eq!(
8827 report["failed_checks"],
8828 serde_json::json!(["bounded_read_evidence"])
8829 );
8830 let read_check = report["checks"]
8831 .as_array()
8832 .unwrap()
8833 .iter()
8834 .find(|check| check["name"] == "bounded_read_evidence")
8835 .unwrap();
8836 assert_eq!(
8837 read_check["failed_evidence_fields"],
8838 serde_json::json!([
8839 "replacement_summary.bounded_read_evidence.mode",
8840 "replacement_summary.bounded_read_evidence.execution_row_cap",
8841 "replacement_summary.bounded_read_evidence.blocking_operator_memory_reports_complete",
8842 "replacement_summary.bounded_read_evidence.blocking_operator_memory_within_budget",
8843 "replacement_summary.bounded_read_evidence.spill_within_budget"
8844 ])
8845 );
8846 assert!(report["next_actions"]
8847 .as_array()
8848 .unwrap()
8849 .iter()
8850 .any(|action| action["action"] == "attach_bounded_read_profile"));
8851 }
8852
8853 #[test]
8854 fn requires_bounded_read_evidence_protocol() {
8855 let mut bundle = ready_bundle();
8856 bundle["replacement_summary"]["bounded_read_evidence"]["protocol"] =
8857 serde_json::json!("handwritten");
8858
8859 let report = integration_readiness_json(&bundle);
8860
8861 assert_eq!(report["ready"], false);
8862 assert_eq!(
8863 report["failed_checks"],
8864 serde_json::json!(["bounded_read_evidence"])
8865 );
8866 let read_check = report["checks"]
8867 .as_array()
8868 .unwrap()
8869 .iter()
8870 .find(|check| check["name"] == "bounded_read_evidence")
8871 .unwrap();
8872 assert_eq!(
8873 read_check["failed_evidence_fields"],
8874 serde_json::json!(["replacement_summary.bounded_read_evidence.protocol"])
8875 );
8876 assert!(report["next_actions"]
8877 .as_array()
8878 .unwrap()
8879 .iter()
8880 .any(|action| {
8881 action["action"] == "attach_bounded_read_profile"
8882 && action["evidence_fields"]
8883 .as_array()
8884 .unwrap()
8885 .iter()
8886 .any(|field| field == "replacement_summary.bounded_read_evidence.protocol")
8887 }));
8888 }
8889
8890 #[test]
8891 fn requires_graph_route_readiness_evidence() {
8892 let mut bundle = ready_bundle();
8893 bundle
8894 .as_object_mut()
8895 .unwrap()
8896 .remove("graph_route_readiness");
8897
8898 let report = integration_readiness_json(&bundle);
8899
8900 assert_eq!(report["ready"], false);
8901 assert_eq!(
8902 report["failed_checks"],
8903 serde_json::json!(["graph_route_readiness"])
8904 );
8905 let route_check = report["checks"]
8906 .as_array()
8907 .unwrap()
8908 .iter()
8909 .find(|check| check["name"] == "graph_route_readiness")
8910 .unwrap();
8911 assert_eq!(
8912 route_check["failed_evidence_fields"],
8913 serde_json::json!([
8914 "graph_route_readiness.protocol",
8915 "graph_route_readiness.evidence_protocol",
8916 "graph_route_readiness.evidence_ready",
8917 "graph_route_readiness.route_count",
8918 "graph_route_readiness.required_route_count",
8919 "graph_route_readiness.route_coverage",
8920 "graph_route_readiness.missing_required_routes",
8921 "graph_route_readiness.query_runtime_route_count",
8922 "graph_route_readiness.query_runtime_report_count",
8923 "graph_route_readiness.query_runtime_plan_profile_counts",
8924 "graph_route_readiness.relationship_property_pruning_counts",
8925 "graph_route_readiness.missing_query_runtime_routes",
8926 "graph_route_readiness.route_query_runtime_ready",
8927 "graph_route_readiness.route_primary_ready",
8928 "graph_route_readiness.primary_ready_route_count",
8929 "graph_route_readiness.evidence_route_coverage_present",
8930 "graph_route_readiness.evidence_route_coverage_matches",
8931 "graph_route_readiness.routes"
8932 ])
8933 );
8934 assert!(report["next_actions"]
8935 .as_array()
8936 .unwrap()
8937 .iter()
8938 .any(|action| action["action"] == "attach_graph_route_readiness_evidence"));
8939 }
8940
8941 #[test]
8942 fn rejects_graph_route_readiness_without_route_coverage_envelope() {
8943 let mut bundle = ready_bundle();
8944 for field in [
8945 "covered_route_count",
8946 "covered_routes",
8947 "required_routes_covered",
8948 "unknown_routes",
8949 "duplicate_routes",
8950 "route_coverage_ready",
8951 "route_coverage_blocker_codes",
8952 "evidence_route_coverage_present",
8953 "evidence_route_coverage_matches",
8954 "evidence_route_coverage_blocker_codes",
8955 ] {
8956 bundle["graph_route_readiness"]
8957 .as_object_mut()
8958 .unwrap()
8959 .remove(field);
8960 }
8961
8962 let report = integration_readiness_json(&bundle);
8963
8964 assert_eq!(report["ready"], false);
8965 assert_eq!(
8966 report["failed_checks"],
8967 serde_json::json!(["graph_route_readiness"])
8968 );
8969 let route_check = report["checks"]
8970 .as_array()
8971 .unwrap()
8972 .iter()
8973 .find(|check| check["name"] == "graph_route_readiness")
8974 .unwrap();
8975 assert!(route_check["failed_evidence_fields"]
8976 .as_array()
8977 .unwrap()
8978 .iter()
8979 .any(|field| field == "graph_route_readiness.route_coverage"));
8980 assert!(route_check["failed_evidence_fields"]
8981 .as_array()
8982 .unwrap()
8983 .iter()
8984 .any(|field| field == "graph_route_readiness.evidence_route_coverage_present"));
8985 }
8986
8987 #[test]
8988 fn rejects_graph_route_readiness_with_stale_route_coverage_envelope() {
8989 let mut bundle = ready_bundle();
8990 bundle["graph_route_readiness"]["covered_routes"] = serde_json::json!(["/graph/overview"]);
8991 bundle["graph_route_readiness"]["covered_route_count"] = serde_json::json!(1);
8992 bundle["graph_route_readiness"]["evidence_route_coverage_matches"] =
8993 serde_json::json!(false);
8994 bundle["graph_route_readiness"]["evidence_route_coverage_blocker_codes"] =
8995 serde_json::json!(["route_coverage_evidence_mismatch"]);
8996 bundle["graph_route_readiness"]["route_primary_blocker_codes"] =
8997 serde_json::json!(["route_coverage_evidence_mismatch"]);
8998
8999 let report = integration_readiness_json(&bundle);
9000
9001 assert_eq!(report["ready"], false);
9002 assert_eq!(
9003 report["failed_checks"],
9004 serde_json::json!(["graph_route_readiness"])
9005 );
9006 let route_check = report["checks"]
9007 .as_array()
9008 .unwrap()
9009 .iter()
9010 .find(|check| check["name"] == "graph_route_readiness")
9011 .unwrap();
9012 assert!(route_check["blocker_codes"]
9013 .as_array()
9014 .unwrap()
9015 .iter()
9016 .any(|code| code == "route_coverage_evidence_mismatch"));
9017 assert!(route_check["failed_evidence_fields"]
9018 .as_array()
9019 .unwrap()
9020 .iter()
9021 .any(|field| field == "graph_route_readiness.route_coverage"));
9022 assert!(route_check["failed_evidence_fields"]
9023 .as_array()
9024 .unwrap()
9025 .iter()
9026 .any(|field| field == "graph_route_readiness.evidence_route_coverage_matches"));
9027 }
9028
9029 #[test]
9030 fn requires_query_runtime_preflight_evidence() {
9031 let mut bundle = ready_bundle();
9032 bundle
9033 .as_object_mut()
9034 .unwrap()
9035 .remove("query_runtime_preflight");
9036
9037 let report = integration_readiness_json(&bundle);
9038
9039 assert_eq!(report["ready"], false);
9040 assert_eq!(
9041 report["failed_checks"],
9042 serde_json::json!(["query_runtime_preflight"])
9043 );
9044 let check = report["checks"]
9045 .as_array()
9046 .unwrap()
9047 .iter()
9048 .find(|check| check["name"] == "query_runtime_preflight")
9049 .unwrap();
9050 assert_eq!(
9051 check["failed_evidence_fields"],
9052 serde_json::json!([
9053 "query_runtime_preflight.protocol",
9054 "query_runtime_preflight.ready",
9055 "query_runtime_preflight.database_opened",
9056 "query_runtime_preflight.redaction.ready",
9057 "query_runtime_preflight.redaction.rows_copied",
9058 "query_runtime_preflight.redaction.parameters_copied",
9059 "query_runtime_preflight.redaction.local_paths_copied",
9060 "query_runtime_preflight.redaction.raw_errors_copied",
9061 "query_runtime_preflight.probe_count",
9062 "query_runtime_preflight.passed_probe_count",
9063 "query_runtime_preflight.failed_probe_count",
9064 "query_runtime_preflight.route_coverage",
9065 "query_runtime_preflight.route_catalog_version",
9066 "query_runtime_preflight.route_catalog_digest",
9067 "query_runtime_preflight.probes"
9068 ])
9069 );
9070 assert!(report["next_actions"]
9071 .as_array()
9072 .unwrap()
9073 .iter()
9074 .any(|action| action["action"] == "attach_query_runtime_preflight_evidence"));
9075 }
9076
9077 #[test]
9078 fn exposes_typed_query_runtime_preflight_cutover_readiness() {
9079 let bundle = ready_bundle();
9080
9081 let typed = super::query_runtime_preflight_cutover_readiness(&bundle);
9082
9083 assert!(typed.evidence_ready());
9084 assert!(typed.protocol_matches);
9085 assert!(typed.ready);
9086 assert!(typed.database_opened);
9087 assert!(typed.redaction_ready);
9088 assert!(typed.rows_redacted);
9089 assert!(typed.parameters_redacted);
9090 assert!(typed.local_paths_redacted);
9091 assert!(typed.raw_errors_redacted);
9092 assert!(typed.probe_count_present);
9093 assert!(typed.probe_counts_match);
9094 assert!(typed.failed_probe_count_zero);
9095 assert!(typed.route_coverage_ready);
9096 assert!(typed.route_catalog_version_matches);
9097 assert!(typed.route_catalog_digest_present);
9098 assert!(typed.probe_details_ready);
9099 assert!(typed.blocker_codes.is_empty());
9100 }
9101
9102 #[test]
9103 fn typed_query_runtime_preflight_recomputes_probe_details() {
9104 let mut bundle = ready_bundle();
9105 bundle["query_runtime_preflight"]["probes"][0]
9106 .as_object_mut()
9107 .unwrap()
9108 .remove("selected_plan_fingerprint");
9109
9110 let typed = super::query_runtime_preflight_cutover_readiness(&bundle);
9111
9112 assert!(!typed.evidence_ready());
9113 assert!(!typed.probe_details_ready);
9114 }
9115
9116 #[test]
9117 fn rejects_query_runtime_preflight_that_copies_sensitive_fields() {
9118 let mut bundle = ready_bundle();
9119 bundle["query_runtime_preflight"]["redaction"]["ready"] = serde_json::json!(false);
9120 bundle["query_runtime_preflight"]["redaction"]["rows_copied"] = serde_json::json!(true);
9121 bundle["query_runtime_preflight"]["redaction"]["parameters_copied"] =
9122 serde_json::json!(true);
9123 bundle["query_runtime_preflight"]["redaction"]["local_paths_copied"] =
9124 serde_json::json!(true);
9125 bundle["query_runtime_preflight"]["redaction"]["raw_errors_copied"] =
9126 serde_json::json!(true);
9127
9128 let report = integration_readiness_json(&bundle);
9129 let typed = super::query_runtime_preflight_cutover_readiness(&bundle);
9130
9131 assert_eq!(report["ready"], false);
9132 assert_eq!(
9133 report["failed_checks"],
9134 serde_json::json!(["query_runtime_preflight"])
9135 );
9136 assert!(!typed.evidence_ready());
9137 assert!(!typed.redaction_ready);
9138 assert!(!typed.rows_redacted);
9139 assert!(!typed.parameters_redacted);
9140 assert!(!typed.local_paths_redacted);
9141 assert!(!typed.raw_errors_redacted);
9142 let check = report["checks"]
9143 .as_array()
9144 .unwrap()
9145 .iter()
9146 .find(|check| check["name"] == "query_runtime_preflight")
9147 .unwrap();
9148 assert_eq!(
9149 check["failed_evidence_fields"],
9150 serde_json::json!([
9151 "query_runtime_preflight.redaction.ready",
9152 "query_runtime_preflight.redaction.rows_copied",
9153 "query_runtime_preflight.redaction.parameters_copied",
9154 "query_runtime_preflight.redaction.local_paths_copied",
9155 "query_runtime_preflight.redaction.raw_errors_copied"
9156 ])
9157 );
9158 }
9159
9160 #[test]
9161 fn rejects_weak_query_runtime_preflight_even_if_ready_flag_is_true() {
9162 let mut bundle = ready_bundle();
9163 bundle["query_runtime_preflight"]["probes"][0]
9164 .as_object_mut()
9165 .unwrap()
9166 .remove("selected_plan_fingerprint");
9167
9168 let report = integration_readiness_json(&bundle);
9169
9170 assert_eq!(report["ready"], false);
9171 assert_eq!(
9172 report["failed_checks"],
9173 serde_json::json!(["query_runtime_preflight"])
9174 );
9175 let check = report["checks"]
9176 .as_array()
9177 .unwrap()
9178 .iter()
9179 .find(|check| check["name"] == "query_runtime_preflight")
9180 .unwrap();
9181 assert_eq!(
9182 check["failed_evidence_fields"],
9183 serde_json::json!(["query_runtime_preflight.probes"])
9184 );
9185 }
9186
9187 #[test]
9188 fn rejects_query_runtime_preflight_without_probe_identity() {
9189 let mut bundle = ready_bundle();
9190 bundle["query_runtime_preflight"]["probes"][0]
9191 .as_object_mut()
9192 .unwrap()
9193 .remove("query_family");
9194
9195 let report = integration_readiness_json(&bundle);
9196
9197 assert_eq!(report["ready"], false);
9198 assert_eq!(
9199 report["failed_checks"],
9200 serde_json::json!(["query_runtime_preflight"])
9201 );
9202 let query_check = report["checks"]
9203 .as_array()
9204 .unwrap()
9205 .iter()
9206 .find(|check| check["name"] == "query_runtime_preflight")
9207 .unwrap();
9208 assert_eq!(
9209 query_check["failed_evidence_fields"],
9210 serde_json::json!(["query_runtime_preflight.probes"])
9211 );
9212 }
9213
9214 #[test]
9215 fn rejects_query_runtime_preflight_without_scan_pruning_reports() {
9216 let mut bundle = ready_bundle();
9217 bundle["query_runtime_preflight"]["probes"][0]["execution_profile"]
9218 .as_object_mut()
9219 .unwrap()
9220 .remove("scan_pruning_reports");
9221
9222 let report = integration_readiness_json(&bundle);
9223
9224 assert_eq!(report["ready"], false);
9225 assert_eq!(
9226 report["failed_checks"],
9227 serde_json::json!(["query_runtime_preflight"])
9228 );
9229 let check = report["checks"]
9230 .as_array()
9231 .unwrap()
9232 .iter()
9233 .find(|check| check["name"] == "query_runtime_preflight")
9234 .unwrap();
9235 assert_eq!(
9236 check["failed_evidence_fields"],
9237 serde_json::json!(["query_runtime_preflight.probes"])
9238 );
9239 }
9240
9241 #[test]
9242 fn rejects_query_runtime_preflight_without_route_coverage() {
9243 let mut bundle = ready_bundle();
9244 bundle["query_runtime_preflight"]["probes"]
9245 .as_array_mut()
9246 .unwrap()
9247 .pop();
9248
9249 let report = integration_readiness_json(&bundle);
9250
9251 assert_eq!(report["ready"], false);
9252 assert_eq!(
9253 report["failed_checks"],
9254 serde_json::json!(["query_runtime_preflight"])
9255 );
9256 let check = report["checks"]
9257 .as_array()
9258 .unwrap()
9259 .iter()
9260 .find(|check| check["name"] == "query_runtime_preflight")
9261 .unwrap();
9262 assert_eq!(
9263 check["failed_evidence_fields"],
9264 serde_json::json!(["query_runtime_preflight.route_coverage"])
9265 );
9266 }
9267
9268 #[test]
9269 fn rejects_query_runtime_preflight_with_unknown_route() {
9270 let mut bundle = ready_bundle();
9271 let mut probe = bundle["query_runtime_preflight"]["probes"][0].clone();
9272 probe["route"] = serde_json::json!("/graph/stale-route");
9273 bundle["query_runtime_preflight"]["probes"]
9274 .as_array_mut()
9275 .unwrap()
9276 .push(probe);
9277 bundle["query_runtime_preflight"]["unknown_routes"] =
9278 serde_json::json!(["/graph/stale-route"]);
9279 bundle["query_runtime_preflight"]["route_coverage_ready"] = serde_json::json!(false);
9280 bundle["query_runtime_preflight"]["route_coverage_blocker_codes"] =
9281 serde_json::json!(["query_runtime_unknown_routes"]);
9282
9283 let report = integration_readiness_json(&bundle);
9284
9285 assert_eq!(report["ready"], false);
9286 assert_eq!(
9287 report["failed_checks"],
9288 serde_json::json!(["query_runtime_preflight"])
9289 );
9290 let check = report["checks"]
9291 .as_array()
9292 .unwrap()
9293 .iter()
9294 .find(|check| check["name"] == "query_runtime_preflight")
9295 .unwrap();
9296 assert_eq!(
9297 check["failed_evidence_fields"],
9298 serde_json::json!([
9299 "query_runtime_preflight.route_coverage",
9300 "query_runtime_preflight.probes"
9301 ])
9302 );
9303 assert!(check["blocker_codes"]
9304 .as_array()
9305 .unwrap()
9306 .iter()
9307 .any(|code| code == "query_runtime_unknown_routes"));
9308 }
9309
9310 #[test]
9311 fn rejects_query_runtime_preflight_with_duplicate_route() {
9312 let mut bundle = ready_bundle();
9313 let probe = bundle["query_runtime_preflight"]["probes"][0].clone();
9314 bundle["query_runtime_preflight"]["probes"]
9315 .as_array_mut()
9316 .unwrap()
9317 .push(probe);
9318 bundle["query_runtime_preflight"]["duplicate_routes"] =
9319 serde_json::json!([REQUIRED_BOUNDED_READ_ROUTES[0]]);
9320 bundle["query_runtime_preflight"]["route_coverage_ready"] = serde_json::json!(false);
9321 bundle["query_runtime_preflight"]["route_coverage_blocker_codes"] =
9322 serde_json::json!(["query_runtime_duplicate_routes"]);
9323
9324 let report = integration_readiness_json(&bundle);
9325
9326 assert_eq!(report["ready"], false);
9327 assert_eq!(
9328 report["failed_checks"],
9329 serde_json::json!(["query_runtime_preflight"])
9330 );
9331 let check = report["checks"]
9332 .as_array()
9333 .unwrap()
9334 .iter()
9335 .find(|check| check["name"] == "query_runtime_preflight")
9336 .unwrap();
9337 assert_eq!(
9338 check["failed_evidence_fields"],
9339 serde_json::json!(["query_runtime_preflight.route_coverage"])
9340 );
9341 assert!(check["blocker_codes"]
9342 .as_array()
9343 .unwrap()
9344 .iter()
9345 .any(|code| code == "query_runtime_duplicate_routes"));
9346 }
9347
9348 #[test]
9349 fn exposes_typed_query_runtime_preflight_alignment_cutover_readiness() {
9350 let bundle = ready_bundle();
9351
9352 let typed = super::query_runtime_preflight_alignment_cutover_readiness(&bundle);
9353
9354 assert!(typed.evidence_ready());
9355 assert!(typed.ready);
9356 assert!(typed.evidence_ready);
9357 assert!(typed.summary_ready);
9358 assert!(typed.protocol_matches);
9359 assert!(typed.readiness_matches);
9360 assert!(typed.database_opened_matches);
9361 assert!(typed.probe_count_matches);
9362 assert!(typed.passed_probe_count_matches);
9363 assert!(typed.failed_probe_count_matches);
9364 assert!(typed.required_route_count_matches);
9365 assert!(typed.covered_route_count_matches);
9366 assert!(typed.covered_routes_matches);
9367 assert!(typed.required_routes_covered_matches);
9368 assert!(typed.route_coverage_ready_matches);
9369 assert!(typed.evidence_route_catalog_version_ready);
9370 assert!(typed.summary_route_catalog_version_ready);
9371 assert!(typed.evidence_route_catalog_digest_ready);
9372 assert!(typed.summary_route_catalog_digest_ready);
9373 assert!(typed.route_catalog_version_matches);
9374 assert!(typed.route_catalog_digest_matches);
9375 assert!(typed.blocker_codes.is_empty());
9376 }
9377
9378 #[test]
9379 fn typed_query_runtime_preflight_alignment_detects_stale_route_coverage() {
9380 let mut bundle = ready_bundle();
9381 bundle["replacement_summary_query_runtime_alignment"]["ready"] = serde_json::json!(false);
9382 bundle["replacement_summary_query_runtime_alignment"]["covered_routes_matches"] =
9383 serde_json::json!(false);
9384 bundle["replacement_summary_query_runtime_alignment"]["blocker_codes"] =
9385 serde_json::json!(["query_runtime_preflight_covered_routes_mismatch"]);
9386
9387 let typed = super::query_runtime_preflight_alignment_cutover_readiness(&bundle);
9388
9389 assert!(!typed.evidence_ready());
9390 assert!(!typed.ready);
9391 assert!(!typed.covered_routes_matches);
9392 assert_eq!(
9393 typed.blocker_codes,
9394 vec!["query_runtime_preflight_covered_routes_mismatch".to_string()]
9395 );
9396 }
9397
9398 #[test]
9399 fn requires_query_runtime_preflight_alignment() {
9400 let mut bundle = ready_bundle();
9401 bundle
9402 .as_object_mut()
9403 .unwrap()
9404 .remove("replacement_summary_query_runtime_alignment");
9405
9406 let report = integration_readiness_json(&bundle);
9407
9408 assert_eq!(report["ready"], false);
9409 assert_eq!(
9410 report["failed_checks"],
9411 serde_json::json!(["query_runtime_preflight_alignment"])
9412 );
9413 let check = report["checks"]
9414 .as_array()
9415 .unwrap()
9416 .iter()
9417 .find(|check| check["name"] == "query_runtime_preflight_alignment")
9418 .unwrap();
9419 assert_eq!(
9420 check["failed_evidence_fields"],
9421 serde_json::json!([
9422 "replacement_summary_query_runtime_alignment.ready",
9423 "replacement_summary_query_runtime_alignment.evidence_ready",
9424 "replacement_summary_query_runtime_alignment.summary_ready",
9425 "replacement_summary_query_runtime_alignment.protocol_matches",
9426 "replacement_summary_query_runtime_alignment.readiness_matches",
9427 "replacement_summary_query_runtime_alignment.database_opened_matches",
9428 "replacement_summary_query_runtime_alignment.probe_count_matches",
9429 "replacement_summary_query_runtime_alignment.passed_probe_count_matches",
9430 "replacement_summary_query_runtime_alignment.failed_probe_count_matches",
9431 "replacement_summary_query_runtime_alignment.required_route_count_matches",
9432 "replacement_summary_query_runtime_alignment.covered_route_count_matches",
9433 "replacement_summary_query_runtime_alignment.covered_routes_matches",
9434 "replacement_summary_query_runtime_alignment.required_routes_covered_matches",
9435 "replacement_summary_query_runtime_alignment.route_coverage_ready_matches",
9436 "replacement_summary_query_runtime_alignment.evidence_route_catalog_version_ready",
9437 "replacement_summary_query_runtime_alignment.summary_route_catalog_version_ready",
9438 "replacement_summary_query_runtime_alignment.evidence_route_catalog_digest_ready",
9439 "replacement_summary_query_runtime_alignment.summary_route_catalog_digest_ready",
9440 "replacement_summary_query_runtime_alignment.route_catalog_version_matches",
9441 "replacement_summary_query_runtime_alignment.route_catalog_digest_matches"
9442 ])
9443 );
9444 assert!(report["next_actions"]
9445 .as_array()
9446 .unwrap()
9447 .iter()
9448 .any(|action| action["action"] == "regenerate_query_runtime_preflight_alignment"));
9449 }
9450
9451 #[test]
9452 fn rejects_stale_query_runtime_summary_when_route_coverage_differs() {
9453 let mut bundle = ready_bundle();
9454 bundle["replacement_summary_query_runtime_alignment"]["ready"] = serde_json::json!(false);
9455 bundle["replacement_summary_query_runtime_alignment"]["covered_routes_matches"] =
9456 serde_json::json!(false);
9457 bundle["replacement_summary_query_runtime_alignment"]["blocker_codes"] =
9458 serde_json::json!(["query_runtime_preflight_covered_routes_mismatch"]);
9459
9460 let report = integration_readiness_json(&bundle);
9461
9462 assert_eq!(report["ready"], false);
9463 assert_eq!(
9464 report["failed_checks"],
9465 serde_json::json!(["query_runtime_preflight_alignment"])
9466 );
9467 assert_eq!(
9468 report["blocker_codes"],
9469 serde_json::json!(["query_runtime_preflight_covered_routes_mismatch"])
9470 );
9471 let check = report["checks"]
9472 .as_array()
9473 .unwrap()
9474 .iter()
9475 .find(|check| check["name"] == "query_runtime_preflight_alignment")
9476 .unwrap();
9477 assert_eq!(
9478 check["failed_evidence_fields"],
9479 serde_json::json!([
9480 "replacement_summary_query_runtime_alignment.ready",
9481 "replacement_summary_query_runtime_alignment.covered_routes_matches"
9482 ])
9483 );
9484 }
9485
9486 #[test]
9487 fn rejects_weak_graph_route_query_profiles_even_if_summary_is_ready() {
9488 let mut bundle = ready_bundle();
9489 bundle["graph_route_readiness"]["routes"][0]["query_reports"][0]
9490 .as_object_mut()
9491 .unwrap()
9492 .remove("scan_pruning_reports");
9493
9494 let report = integration_readiness_json(&bundle);
9495
9496 assert_eq!(report["ready"], false);
9497 assert_eq!(
9498 report["failed_checks"],
9499 serde_json::json!(["graph_route_readiness"])
9500 );
9501 let route_check = report["checks"]
9502 .as_array()
9503 .unwrap()
9504 .iter()
9505 .find(|check| check["name"] == "graph_route_readiness")
9506 .unwrap();
9507 assert_eq!(
9508 route_check["failed_evidence_fields"],
9509 serde_json::json!(["graph_route_readiness.routes"])
9510 );
9511 assert!(report["next_actions"]
9512 .as_array()
9513 .unwrap()
9514 .iter()
9515 .any(|action| action["action"] == "attach_graph_route_readiness_evidence"));
9516 }
9517
9518 #[test]
9519 fn exposes_typed_graph_route_cutover_readiness() {
9520 let bundle = ready_bundle();
9521
9522 let typed = super::graph_route_cutover_readiness(&bundle);
9523
9524 assert!(typed.evidence_ready());
9525 assert!(typed.protocol_matches);
9526 assert!(typed.evidence_protocol_matches);
9527 assert!(typed.route_count_present);
9528 assert!(typed.required_route_count_matches);
9529 assert!(typed.route_coverage_ready);
9530 assert!(typed.query_runtime_route_count_matches);
9531 assert!(typed.query_runtime_report_count_ready);
9532 assert!(typed.query_plan_profile_summary_ready);
9533 assert!(typed.relationship_property_pruning_summary_ready);
9534 assert!(typed.route_query_runtime_ready);
9535 assert!(typed.route_primary_ready);
9536 assert!(typed.primary_ready_route_count_matches);
9537 assert!(typed.evidence_route_coverage_present);
9538 assert!(typed.evidence_route_coverage_matches);
9539 assert!(typed.route_query_profiles_ready);
9540 assert!(typed.blocker_codes.is_empty());
9541 }
9542
9543 #[test]
9544 fn typed_graph_route_cutover_recomputes_route_profile_details() {
9545 let mut bundle = ready_bundle();
9546 bundle["graph_route_readiness"]["routes"][0]["query_reports"][0]
9547 .as_object_mut()
9548 .unwrap()
9549 .remove("scan_pruning_reports");
9550
9551 let typed = super::graph_route_cutover_readiness(&bundle);
9552
9553 assert!(!typed.evidence_ready());
9554 assert!(!typed.route_query_profiles_ready);
9555 }
9556
9557 #[test]
9558 fn rejects_graph_route_readiness_without_plan_profile_summary_counts() {
9559 let mut bundle = ready_bundle();
9560 bundle["graph_route_readiness"]
9561 .as_object_mut()
9562 .unwrap()
9563 .remove("query_runtime_plan_report_count");
9564 bundle["graph_route_readiness"]["query_runtime_missing_profile_evidence_count"] =
9565 serde_json::json!(1);
9566 bundle["graph_route_readiness"]["route_query_profile_evidence_ready"] =
9567 serde_json::json!(false);
9568
9569 let report = integration_readiness_json(&bundle);
9570
9571 assert_eq!(report["ready"], false);
9572 assert_eq!(
9573 report["failed_checks"],
9574 serde_json::json!(["graph_route_readiness"])
9575 );
9576 let route_check = report["checks"]
9577 .as_array()
9578 .unwrap()
9579 .iter()
9580 .find(|check| check["name"] == "graph_route_readiness")
9581 .unwrap();
9582 assert_eq!(
9583 route_check["failed_evidence_fields"],
9584 serde_json::json!(["graph_route_readiness.query_runtime_plan_profile_counts"])
9585 );
9586 }
9587
9588 #[test]
9589 fn rejects_graph_route_readiness_without_relationship_property_pruning_counts() {
9590 let mut bundle = ready_bundle();
9591 bundle["graph_route_readiness"]
9592 .as_object_mut()
9593 .unwrap()
9594 .remove("relationship_property_pruning_required_count");
9595 bundle["graph_route_readiness"]["route_relationship_property_pruning_evidence_ready"] =
9596 serde_json::json!(false);
9597
9598 let report = integration_readiness_json(&bundle);
9599
9600 assert_eq!(report["ready"], false);
9601 assert_eq!(
9602 report["failed_checks"],
9603 serde_json::json!(["graph_route_readiness"])
9604 );
9605 let route_check = report["checks"]
9606 .as_array()
9607 .unwrap()
9608 .iter()
9609 .find(|check| check["name"] == "graph_route_readiness")
9610 .unwrap();
9611 assert_eq!(
9612 route_check["failed_evidence_fields"],
9613 serde_json::json!(["graph_route_readiness.relationship_property_pruning_counts"])
9614 );
9615 }
9616
9617 #[test]
9618 fn rejects_graph_route_query_profiles_with_only_scan_pruning_presence_flag() {
9619 let mut bundle = ready_bundle();
9620 bundle["graph_route_readiness"]["routes"][0]["query_reports"][0]
9621 .as_object_mut()
9622 .unwrap()
9623 .remove("scan_pruning_reports");
9624 bundle["graph_route_readiness"]["routes"][0]["query_reports"][0]
9625 ["scan_pruning_reports_present"] = serde_json::json!(true);
9626
9627 let report = integration_readiness_json(&bundle);
9628
9629 assert_eq!(report["ready"], false);
9630 assert_eq!(
9631 report["failed_checks"],
9632 serde_json::json!(["graph_route_readiness"])
9633 );
9634 let route_check = report["checks"]
9635 .as_array()
9636 .unwrap()
9637 .iter()
9638 .find(|check| check["name"] == "graph_route_readiness")
9639 .unwrap();
9640 assert_eq!(
9641 route_check["failed_evidence_fields"],
9642 serde_json::json!(["graph_route_readiness.routes"])
9643 );
9644 }
9645
9646 #[test]
9647 fn rejects_graph_route_relationship_pruning_with_legacy_record_kind_only() {
9648 let mut bundle = ready_bundle();
9649 bundle["graph_route_readiness"]["relationship_property_pruning_required_count"] =
9650 serde_json::json!(1);
9651 bundle["graph_route_readiness"]["relationship_property_pruning_report_count"] =
9652 serde_json::json!(1);
9653 bundle["graph_route_readiness"]["route_relationship_property_pruning_evidence_ready"] =
9654 serde_json::json!(true);
9655 bundle["graph_route_readiness"]["routes"][0]
9656 ["relationship_property_pruning_required_count"] = serde_json::json!(1);
9657 bundle["graph_route_readiness"]["routes"][0]
9658 ["relationship_property_pruning_report_count"] = serde_json::json!(1);
9659 bundle["graph_route_readiness"]["routes"][0]
9660 ["relationship_property_pruning_evidence_ready"] = serde_json::json!(true);
9661 bundle["graph_route_readiness"]["routes"][0]["query_reports"][0]["scan_pruning_reports"]
9662 [0]["record_kind"] = serde_json::json!("relationship");
9663 bundle["graph_route_readiness"]["routes"][0]["query_reports"][0]["scan_pruning_reports"]
9664 [0]["target_kind"] = serde_json::json!("node");
9665 bundle["graph_route_readiness"]["routes"][0]["query_reports"][0]["scan_pruning_reports"]
9666 [0]["strategy"] = serde_json::json!({
9667 "kind": "relationship_property",
9668 "property": "type"
9669 });
9670
9671 let report = integration_readiness_json(&bundle);
9672
9673 assert_eq!(report["ready"], false);
9674 assert_eq!(
9675 report["failed_checks"],
9676 serde_json::json!(["graph_route_readiness"])
9677 );
9678 let route_check = report["checks"]
9679 .as_array()
9680 .unwrap()
9681 .iter()
9682 .find(|check| check["name"] == "graph_route_readiness")
9683 .unwrap();
9684 assert_eq!(
9685 route_check["failed_evidence_fields"],
9686 serde_json::json!(["graph_route_readiness.routes"])
9687 );
9688 }
9689
9690 #[test]
9691 fn rejects_graph_route_query_profiles_without_query_identity() {
9692 let mut bundle = ready_bundle();
9693 bundle["graph_route_readiness"]["routes"][0]["query_reports"][0]
9694 .as_object_mut()
9695 .unwrap()
9696 .remove("query_name");
9697
9698 let report = integration_readiness_json(&bundle);
9699
9700 assert_eq!(report["ready"], false);
9701 assert_eq!(
9702 report["failed_checks"],
9703 serde_json::json!(["graph_route_readiness"])
9704 );
9705 let route_check = report["checks"]
9706 .as_array()
9707 .unwrap()
9708 .iter()
9709 .find(|check| check["name"] == "graph_route_readiness")
9710 .unwrap();
9711 assert_eq!(
9712 route_check["failed_evidence_fields"],
9713 serde_json::json!(["graph_route_readiness.routes"])
9714 );
9715 }
9716
9717 #[test]
9718 fn rejects_graph_route_profiles_without_required_query_family_evidence() {
9719 let mut bundle = ready_bundle();
9720 bundle["graph_route_readiness"]["routes"][0]
9721 .as_object_mut()
9722 .unwrap()
9723 .remove("required_query_families");
9724
9725 let report = integration_readiness_json(&bundle);
9726
9727 assert_eq!(report["ready"], false);
9728 assert_eq!(
9729 report["failed_checks"],
9730 serde_json::json!(["graph_route_readiness"])
9731 );
9732 let route_check = report["checks"]
9733 .as_array()
9734 .unwrap()
9735 .iter()
9736 .find(|check| check["name"] == "graph_route_readiness")
9737 .unwrap();
9738 assert_eq!(
9739 route_check["failed_evidence_fields"],
9740 serde_json::json!(["graph_route_readiness.routes"])
9741 );
9742 }
9743
9744 #[test]
9745 fn rejects_graph_route_profiles_when_query_family_does_not_match_route() {
9746 let mut bundle = ready_bundle();
9747 let route = bundle["graph_route_readiness"]["routes"]
9748 .as_array_mut()
9749 .unwrap()
9750 .iter_mut()
9751 .find(|route| route["route"] == "/graph/shortest-path")
9752 .unwrap();
9753 route["query_reports"][0]["query_family"] = serde_json::json!("memory_lookup");
9754
9755 let report = integration_readiness_json(&bundle);
9756
9757 assert_eq!(report["ready"], false);
9758 assert_eq!(
9759 report["failed_checks"],
9760 serde_json::json!(["graph_route_readiness"])
9761 );
9762 let route_check = report["checks"]
9763 .as_array()
9764 .unwrap()
9765 .iter()
9766 .find(|check| check["name"] == "graph_route_readiness")
9767 .unwrap();
9768 assert_eq!(
9769 route_check["failed_evidence_fields"],
9770 serde_json::json!(["graph_route_readiness.routes"])
9771 );
9772 }
9773
9774 #[test]
9775 fn rejects_graph_route_profiles_without_route_parity_source() {
9776 let mut bundle = ready_bundle();
9777 bundle["graph_route_readiness"]["routes"][0]
9778 .as_object_mut()
9779 .unwrap()
9780 .remove("shadow_compare_evidence_source");
9781
9782 let report = integration_readiness_json(&bundle);
9783
9784 assert_eq!(report["ready"], false);
9785 assert_eq!(
9786 report["failed_checks"],
9787 serde_json::json!(["graph_route_readiness"])
9788 );
9789 let route_check = report["checks"]
9790 .as_array()
9791 .unwrap()
9792 .iter()
9793 .find(|check| check["name"] == "graph_route_readiness")
9794 .unwrap();
9795 assert_eq!(
9796 route_check["failed_evidence_fields"],
9797 serde_json::json!(["graph_route_readiness.routes"])
9798 );
9799 }
9800
9801 #[test]
9802 fn rejects_graph_route_profiles_with_weak_route_parity_detail() {
9803 let mut bundle = ready_bundle();
9804 bundle["graph_route_readiness"]["routes"][0]["shadow_compare"]["matched_per_million"] =
9805 serde_json::json!(999999);
9806 bundle["graph_route_readiness"]["routes"][0]["shadow_compare"]["primary_engine"] =
9807 serde_json::json!("hawdb");
9808
9809 let report = integration_readiness_json(&bundle);
9810
9811 assert_eq!(report["ready"], false);
9812 assert_eq!(
9813 report["failed_checks"],
9814 serde_json::json!(["graph_route_readiness"])
9815 );
9816 let route_check = report["checks"]
9817 .as_array()
9818 .unwrap()
9819 .iter()
9820 .find(|check| check["name"] == "graph_route_readiness")
9821 .unwrap();
9822 assert_eq!(
9823 route_check["failed_evidence_fields"],
9824 serde_json::json!(["graph_route_readiness.routes"])
9825 );
9826 }
9827
9828 #[test]
9829 fn rejects_graph_route_readiness_without_primary_route_coverage() {
9830 let mut bundle = ready_bundle();
9831 bundle["graph_route_readiness"]["route_primary_ready"] = serde_json::json!(false);
9832 bundle["graph_route_readiness"]["primary_ready_route_count"] = serde_json::json!(13);
9833 bundle["graph_route_readiness"]["route_primary_blocker_codes"] =
9834 serde_json::json!(["graph_route_primary_not_enabled"]);
9835
9836 let report = integration_readiness_json(&bundle);
9837
9838 assert_eq!(report["ready"], false);
9839 assert_eq!(
9840 report["failed_checks"],
9841 serde_json::json!(["graph_route_readiness"])
9842 );
9843 assert_eq!(
9844 report["blocker_codes"],
9845 serde_json::json!(["graph_route_primary_not_enabled"])
9846 );
9847 let route_check = report["checks"]
9848 .as_array()
9849 .unwrap()
9850 .iter()
9851 .find(|check| check["name"] == "graph_route_readiness")
9852 .unwrap();
9853 assert_eq!(
9854 route_check["failed_evidence_fields"],
9855 serde_json::json!([
9856 "graph_route_readiness.route_primary_ready",
9857 "graph_route_readiness.primary_ready_route_count",
9858 "graph_route_readiness.route_primary_blocker_codes"
9859 ])
9860 );
9861 }
9862
9863 #[test]
9864 fn requires_graph_route_readiness_protocol() {
9865 let mut bundle = ready_bundle();
9866 bundle["graph_route_readiness"]["protocol"] = serde_json::json!("handwritten");
9867
9868 let report = integration_readiness_json(&bundle);
9869
9870 assert_eq!(report["ready"], false);
9871 assert_eq!(
9872 report["failed_checks"],
9873 serde_json::json!(["graph_route_readiness"])
9874 );
9875 let route_check = report["checks"]
9876 .as_array()
9877 .unwrap()
9878 .iter()
9879 .find(|check| check["name"] == "graph_route_readiness")
9880 .unwrap();
9881 assert_eq!(
9882 route_check["failed_evidence_fields"],
9883 serde_json::json!(["graph_route_readiness.protocol"])
9884 );
9885 }
9886
9887 #[test]
9888 fn requires_graph_route_readiness_evidence_protocol() {
9889 let mut bundle = ready_bundle();
9890 bundle["graph_route_readiness"]["evidence_protocol"] = serde_json::json!("handwritten");
9891
9892 let report = integration_readiness_json(&bundle);
9893
9894 assert_eq!(report["ready"], false);
9895 assert_eq!(
9896 report["failed_checks"],
9897 serde_json::json!(["graph_route_readiness"])
9898 );
9899 let route_check = report["checks"]
9900 .as_array()
9901 .unwrap()
9902 .iter()
9903 .find(|check| check["name"] == "graph_route_readiness")
9904 .unwrap();
9905 assert_eq!(
9906 route_check["failed_evidence_fields"],
9907 serde_json::json!(["graph_route_readiness.evidence_protocol"])
9908 );
9909 }
9910
9911 #[test]
9912 fn rejects_graph_route_readiness_when_route_evidence_is_not_ready() {
9913 let mut bundle = ready_bundle();
9914 bundle["graph_route_readiness"]["evidence_ready"] = serde_json::json!(false);
9915 bundle["graph_route_readiness"]["route_primary_blocker_codes"] =
9916 serde_json::json!(["graph_route_evidence_not_ready"]);
9917
9918 let report = integration_readiness_json(&bundle);
9919
9920 assert_eq!(report["ready"], false);
9921 assert_eq!(
9922 report["failed_checks"],
9923 serde_json::json!(["graph_route_readiness"])
9924 );
9925 assert_eq!(
9926 report["blocker_codes"],
9927 serde_json::json!(["graph_route_evidence_not_ready"])
9928 );
9929 let route_check = report["checks"]
9930 .as_array()
9931 .unwrap()
9932 .iter()
9933 .find(|check| check["name"] == "graph_route_readiness")
9934 .unwrap();
9935 assert_eq!(
9936 route_check["failed_evidence_fields"],
9937 serde_json::json!([
9938 "graph_route_readiness.evidence_ready",
9939 "graph_route_readiness.route_primary_blocker_codes"
9940 ])
9941 );
9942 }
9943
9944 #[test]
9945 fn rejects_stale_graph_route_readiness_summary() {
9946 let mut bundle = ready_bundle();
9947 bundle["replacement_summary_graph_route_alignment"]["ready"] = serde_json::json!(false);
9948 bundle["replacement_summary_graph_route_alignment"]["summary_route_primary_ready"] =
9949 serde_json::json!(false);
9950 bundle["replacement_summary_graph_route_alignment"]["route_primary_ready_matches"] =
9951 serde_json::json!(false);
9952 bundle["replacement_summary_graph_route_alignment"]["primary_ready_routes_match"] =
9953 serde_json::json!(false);
9954 bundle["replacement_summary_graph_route_alignment"]["blocker_codes"] =
9955 serde_json::json!(["replacement_summary_graph_route_readiness_mismatch"]);
9956
9957 let report = integration_readiness_json(&bundle);
9958
9959 assert_eq!(report["ready"], false);
9960 assert_eq!(
9961 report["failed_checks"],
9962 serde_json::json!(["graph_route_readiness_alignment"])
9963 );
9964 assert_eq!(
9965 report["blocker_codes"],
9966 serde_json::json!(["replacement_summary_graph_route_readiness_mismatch"])
9967 );
9968 let alignment_check = report["checks"]
9969 .as_array()
9970 .unwrap()
9971 .iter()
9972 .find(|check| check["name"] == "graph_route_readiness_alignment")
9973 .unwrap();
9974 assert_eq!(
9975 alignment_check["failed_evidence_fields"],
9976 serde_json::json!([
9977 "replacement_summary_graph_route_alignment.ready",
9978 "replacement_summary_graph_route_alignment.summary_route_primary_ready",
9979 "replacement_summary_graph_route_alignment.route_primary_ready_matches",
9980 "replacement_summary_graph_route_alignment.primary_ready_routes_match"
9981 ])
9982 );
9983 assert!(report["next_actions"]
9984 .as_array()
9985 .unwrap()
9986 .iter()
9987 .any(|action| action["action"] == "regenerate_graph_route_readiness_alignment"));
9988 }
9989
9990 #[test]
9991 fn rejects_graph_route_alignment_without_api_behavior_evidence() {
9992 let mut bundle = ready_bundle();
9993 bundle["replacement_summary_graph_route_alignment"]["ready"] = serde_json::json!(false);
9994 bundle["replacement_summary_graph_route_alignment"]
9995 ["route_query_api_behavior_evidence_ready_matches"] = serde_json::json!(false);
9996 bundle["replacement_summary_graph_route_alignment"]["blocker_codes"] =
9997 serde_json::json!(["graph_route_query_api_behavior_evidence_mismatch"]);
9998
9999 let report = integration_readiness_json(&bundle);
10000
10001 assert_eq!(report["ready"], false);
10002 assert_eq!(
10003 report["failed_checks"],
10004 serde_json::json!(["graph_route_readiness_alignment"])
10005 );
10006 let alignment_check = report["checks"]
10007 .as_array()
10008 .unwrap()
10009 .iter()
10010 .find(|check| check["name"] == "graph_route_readiness_alignment")
10011 .unwrap();
10012 assert_eq!(
10013 alignment_check["failed_evidence_fields"],
10014 serde_json::json!([
10015 "replacement_summary_graph_route_alignment.ready",
10016 "replacement_summary_graph_route_alignment.route_query_api_behavior_evidence_ready_matches"
10017 ])
10018 );
10019 assert_eq!(
10020 report["blocker_codes"],
10021 serde_json::json!(["graph_route_query_api_behavior_evidence_mismatch"])
10022 );
10023 }
10024
10025 #[test]
10026 fn rejects_graph_route_alignment_without_route_evidence_envelope() {
10027 let mut bundle = ready_bundle();
10028 bundle["replacement_summary_graph_route_alignment"]["ready"] = serde_json::json!(false);
10029 bundle["replacement_summary_graph_route_alignment"]["evidence_ready"] =
10030 serde_json::json!(false);
10031 bundle["replacement_summary_graph_route_alignment"]["evidence_protocol_matches"] =
10032 serde_json::json!(false);
10033 bundle["replacement_summary_graph_route_alignment"]["blocker_codes"] = serde_json::json!([
10034 "graph_route_evidence_not_ready",
10035 "graph_route_evidence_protocol_mismatch"
10036 ]);
10037
10038 let report = integration_readiness_json(&bundle);
10039
10040 assert_eq!(report["ready"], false);
10041 assert_eq!(
10042 report["failed_checks"],
10043 serde_json::json!(["graph_route_readiness_alignment"])
10044 );
10045 assert_eq!(
10046 report["blocker_codes"],
10047 serde_json::json!([
10048 "graph_route_evidence_not_ready",
10049 "graph_route_evidence_protocol_mismatch"
10050 ])
10051 );
10052 let alignment_check = report["checks"]
10053 .as_array()
10054 .unwrap()
10055 .iter()
10056 .find(|check| check["name"] == "graph_route_readiness_alignment")
10057 .unwrap();
10058 assert_eq!(
10059 alignment_check["failed_evidence_fields"],
10060 serde_json::json!([
10061 "replacement_summary_graph_route_alignment.ready",
10062 "replacement_summary_graph_route_alignment.evidence_protocol_matches",
10063 "replacement_summary_graph_route_alignment.evidence_ready"
10064 ])
10065 );
10066 }
10067
10068 #[test]
10069 fn exposes_typed_graph_route_alignment_cutover_readiness() {
10070 let bundle = ready_bundle();
10071
10072 let typed = super::graph_route_alignment_cutover_readiness(&bundle);
10073
10074 assert!(typed.evidence_ready());
10075 assert!(typed.ready);
10076 assert!(typed.evidence_protocol_matches);
10077 assert!(typed.evidence_ready);
10078 assert!(typed.evidence_route_primary_ready);
10079 assert!(typed.summary_route_primary_ready);
10080 assert!(typed.route_primary_ready_matches);
10081 assert!(typed.route_query_plan_evidence_ready_matches);
10082 assert!(typed.route_query_profile_evidence_ready_matches);
10083 assert!(typed.route_query_api_behavior_evidence_ready_matches);
10084 assert!(typed.route_relationship_property_pruning_evidence_ready_matches);
10085 assert!(typed.relationship_property_pruning_required_count_matches);
10086 assert!(typed.relationship_property_pruning_report_count_matches);
10087 assert!(typed.primary_ready_routes_match);
10088 assert!(typed.evidence_required_routes_covered);
10089 assert!(typed.summary_required_routes_covered);
10090 assert!(typed.evidence_route_catalog_version_ready);
10091 assert!(typed.summary_route_catalog_version_ready);
10092 assert!(typed.evidence_route_catalog_digest_ready);
10093 assert!(typed.summary_route_catalog_digest_ready);
10094 assert!(typed.route_catalog_version_matches);
10095 assert!(typed.route_catalog_digest_matches);
10096 assert!(typed.blocker_codes.is_empty());
10097 }
10098
10099 #[test]
10100 fn typed_graph_route_alignment_detects_stale_route_catalog_metadata() {
10101 let mut bundle = ready_bundle();
10102 bundle["replacement_summary_graph_route_alignment"]["ready"] = serde_json::json!(false);
10103 bundle["replacement_summary_graph_route_alignment"]["route_catalog_digest_matches"] =
10104 serde_json::json!(false);
10105 bundle["replacement_summary_graph_route_alignment"]["blocker_codes"] =
10106 serde_json::json!(["graph_route_catalog_digest_mismatch"]);
10107
10108 let typed = super::graph_route_alignment_cutover_readiness(&bundle);
10109
10110 assert!(!typed.evidence_ready());
10111 assert!(!typed.ready);
10112 assert!(!typed.route_catalog_digest_matches);
10113 assert_eq!(
10114 typed.blocker_codes,
10115 vec!["graph_route_catalog_digest_mismatch".to_string()]
10116 );
10117 }
10118
10119 #[test]
10120 fn requires_graph_route_parity_alignment() {
10121 let mut bundle = ready_bundle();
10122 bundle["graph_route_parity_alignment"]["ready"] = serde_json::json!(false);
10123 bundle["graph_route_parity_alignment"]["ready_route_count"] = serde_json::json!(17);
10124 bundle["graph_route_parity_alignment"]["missing_routes"] =
10125 serde_json::json!(["agent_evolves"]);
10126 bundle["graph_route_parity_alignment"]["observed_blocker_codes"] =
10127 serde_json::json!(["agent_evolves_parity_evidence_missing"]);
10128 bundle["graph_route_parity_alignment"]["blocker_codes"] =
10129 serde_json::json!(["graph_route_parity_evidence_missing"]);
10130
10131 let report = integration_readiness_json(&bundle);
10132
10133 assert_eq!(report["ready"], false);
10134 assert_eq!(
10135 report["failed_checks"],
10136 serde_json::json!(["graph_route_parity_alignment"])
10137 );
10138 assert_eq!(
10139 report["blocker_codes"],
10140 serde_json::json!(["graph_route_parity_evidence_missing"])
10141 );
10142 let check = report["checks"]
10143 .as_array()
10144 .unwrap()
10145 .iter()
10146 .find(|check| check["name"] == "graph_route_parity_alignment")
10147 .unwrap();
10148 assert_eq!(
10149 check["failed_evidence_fields"],
10150 serde_json::json!([
10151 "graph_route_parity_alignment.ready",
10152 "graph_route_parity_alignment.ready_route_count",
10153 "graph_route_parity_alignment.missing_routes"
10154 ])
10155 );
10156 assert!(report["next_actions"]
10157 .as_array()
10158 .unwrap()
10159 .iter()
10160 .any(|action| action["action"] == "attach_graph_route_parity_evidence"));
10161 }
10162
10163 #[test]
10164 fn exposes_typed_graph_route_parity_alignment_cutover_readiness() {
10165 let bundle = ready_bundle();
10166
10167 let typed = super::graph_route_parity_alignment_cutover_readiness(&bundle);
10168
10169 assert!(typed.evidence_ready());
10170 assert!(typed.ready);
10171 assert!(typed.required_route_count_present);
10172 assert!(typed.ready_route_count_matches);
10173 assert!(typed.missing_routes_empty);
10174 assert!(typed.not_ready_routes_empty);
10175 assert!(typed.route_mismatch_routes_empty);
10176 assert!(typed.protocol_mismatch_routes_empty);
10177 assert!(typed.blocker_routes_empty);
10178 assert!(typed.blocker_codes.is_empty());
10179 }
10180
10181 #[test]
10182 fn typed_graph_route_parity_alignment_detects_missing_routes() {
10183 let mut bundle = ready_bundle();
10184 bundle["graph_route_parity_alignment"]["ready"] = serde_json::json!(false);
10185 bundle["graph_route_parity_alignment"]["ready_route_count"] = serde_json::json!(17);
10186 bundle["graph_route_parity_alignment"]["missing_routes"] =
10187 serde_json::json!(["agent_evolves"]);
10188 bundle["graph_route_parity_alignment"]["blocker_codes"] =
10189 serde_json::json!(["graph_route_parity_evidence_missing"]);
10190
10191 let typed = super::graph_route_parity_alignment_cutover_readiness(&bundle);
10192
10193 assert!(!typed.evidence_ready());
10194 assert!(!typed.ready);
10195 assert!(!typed.ready_route_count_matches);
10196 assert!(!typed.missing_routes_empty);
10197 assert_eq!(
10198 typed.blocker_codes,
10199 vec!["graph_route_parity_evidence_missing".to_string()]
10200 );
10201 }
10202
10203 #[test]
10204 fn requires_library_readiness_evidence() {
10205 let mut bundle = ready_bundle();
10206 bundle.as_object_mut().unwrap().remove("library_readiness");
10207
10208 let typed = super::library_readiness_cutover_readiness(&bundle);
10209 assert!(!typed.evidence_ready());
10210 assert!(!typed.protocol_matches);
10211 assert!(!typed.present);
10212 assert!(!typed.ready);
10213 assert!(!typed.graph_ready);
10214 assert!(typed.blocker_codes.is_empty());
10215
10216 let report = integration_readiness_json(&bundle);
10217
10218 assert_eq!(report["ready"], false);
10219 assert_eq!(
10220 report["failed_checks"],
10221 serde_json::json!(["library_readiness"])
10222 );
10223 let library_check = report["checks"]
10224 .as_array()
10225 .unwrap()
10226 .iter()
10227 .find(|check| check["name"] == "library_readiness")
10228 .unwrap();
10229 assert_eq!(
10230 library_check["failed_evidence_fields"],
10231 serde_json::json!([
10232 "library_readiness.protocol",
10233 "library_readiness.present",
10234 "library_readiness.ready",
10235 "library_readiness.production_path.ready",
10236 "library_readiness.production_path.in_process",
10237 "library_readiness.production_path.cli_required",
10238 "library_readiness.production_path.env_control_plane_required",
10239 "library_readiness.production_path.spawned_helper_required",
10240 "library_readiness.ready_area_count",
10241 "library_readiness.blocked_area_count",
10242 "library_readiness.redaction.ready",
10243 "library_readiness.redaction.query_text_copied",
10244 "library_readiness.redaction.parameters_copied",
10245 "library_readiness.redaction.local_paths_copied",
10246 "library_readiness.open_report.graph_opened",
10247 "library_readiness.open_report.search_projection_opened",
10248 "library_readiness.readiness_by_area.graph.ready",
10249 "library_readiness.readiness_by_area.query.ready",
10250 "library_readiness.readiness_by_area.storage.ready",
10251 "library_readiness.readiness_by_area.background.ready",
10252 "library_readiness.readiness_by_area.query_family.ready",
10253 "library_readiness.readiness_by_area.graph_route.ready",
10254 "library_readiness.readiness_by_area.search_route_ownership.ready",
10255 "library_readiness.readiness_by_area.search_projection.ready",
10256 "library_readiness.readiness_by_area.search_projection_shadow.ready",
10257 "library_readiness.readiness_by_area.search_candidate_shadow.ready",
10258 "library_readiness.readiness_by_area.workload_fixture.ready",
10259 "library_readiness.production_resource_profile"
10260 ])
10261 );
10262 assert!(report["next_actions"]
10263 .as_array()
10264 .unwrap()
10265 .iter()
10266 .any(|action| action["action"] == "attach_library_readiness_evidence"));
10267 }
10268
10269 #[test]
10270 fn rejects_library_readiness_with_over_budget_production_resource_profile() {
10271 let mut bundle = ready_bundle();
10272 bundle["library_readiness"]["production_resource_profile"]["execution"]
10273 ["steady_resident_bytes"] = serde_json::json!(536870913u64);
10274
10275 let typed = super::library_readiness_cutover_readiness(&bundle);
10276
10277 assert!(!typed.evidence_ready());
10278 assert!(!typed.production_resource_profile_ready);
10279 let report = integration_readiness_json(&bundle);
10280 let library_check = report["checks"]
10281 .as_array()
10282 .unwrap()
10283 .iter()
10284 .find(|check| check["name"] == "library_readiness")
10285 .unwrap();
10286 assert_eq!(report["ready"], false);
10287 assert_eq!(
10288 library_check["failed_evidence_fields"],
10289 serde_json::json!(["library_readiness.production_resource_profile"])
10290 );
10291 }
10292
10293 #[test]
10294 fn rejects_blocked_library_readiness_area() {
10295 let mut bundle = ready_bundle();
10296 bundle["library_readiness"]["ready"] = serde_json::json!(false);
10297 bundle["library_readiness"]["blocked_area_count"] = serde_json::json!(1);
10298 bundle["library_readiness"]["blocker_codes"] =
10299 serde_json::json!(["search_projection_not_ready"]);
10300 bundle["library_readiness"]["readiness_by_area"]["search_projection"]["ready"] =
10301 serde_json::json!(false);
10302 bundle["library_readiness"]["readiness_by_area"]["search_projection"]["blocker_codes"] =
10303 serde_json::json!(["search_projection_probe_missing"]);
10304
10305 let typed = super::library_readiness_cutover_readiness(&bundle);
10306 assert!(!typed.evidence_ready());
10307 assert!(typed.protocol_matches);
10308 assert!(typed.present);
10309 assert!(!typed.ready);
10310 assert!(!typed.blocked_area_count_zero);
10311 assert!(!typed.search_projection_ready);
10312 assert_eq!(
10313 typed.blocker_codes,
10314 vec![
10315 "search_projection_not_ready".to_string(),
10316 "search_projection_probe_missing".to_string()
10317 ]
10318 );
10319
10320 let report = integration_readiness_json(&bundle);
10321
10322 assert_eq!(report["ready"], false);
10323 assert_eq!(
10324 report["failed_checks"],
10325 serde_json::json!(["library_readiness"])
10326 );
10327 assert_eq!(
10328 report["blocker_codes"],
10329 serde_json::json!([
10330 "search_projection_not_ready",
10331 "search_projection_probe_missing"
10332 ])
10333 );
10334 let library_check = report["checks"]
10335 .as_array()
10336 .unwrap()
10337 .iter()
10338 .find(|check| check["name"] == "library_readiness")
10339 .unwrap();
10340 assert_eq!(
10341 library_check["failed_evidence_fields"],
10342 serde_json::json!([
10343 "library_readiness.ready",
10344 "library_readiness.blocked_area_count",
10345 "library_readiness.readiness_by_area.search_projection.ready"
10346 ])
10347 );
10348 }
10349
10350 #[test]
10351 fn rejects_library_readiness_that_requires_cli_on_production_path() {
10352 let mut bundle = ready_bundle();
10353 bundle["library_readiness"]["ready"] = serde_json::json!(false);
10354 bundle["library_readiness"]["production_path"]["ready"] = serde_json::json!(false);
10355 bundle["library_readiness"]["production_path"]["cli_required"] = serde_json::json!(true);
10356 bundle["library_readiness"]["production_path"]["spawned_helper_required"] =
10357 serde_json::json!(true);
10358 bundle["library_readiness"]["blocker_codes"] =
10359 serde_json::json!(["library_production_path_not_embedded"]);
10360
10361 let typed = super::library_readiness_cutover_readiness(&bundle);
10362 assert!(!typed.evidence_ready());
10363 assert!(typed.protocol_matches);
10364 assert!(typed.present);
10365 assert!(!typed.ready);
10366 assert!(!typed.production_path_ready);
10367 assert!(!typed.production_path_cli_not_required);
10368 assert!(!typed.production_path_spawned_helper_not_required);
10369 assert_eq!(
10370 typed.blocker_codes,
10371 vec!["library_production_path_not_embedded".to_string()]
10372 );
10373
10374 let report = integration_readiness_json(&bundle);
10375
10376 assert_eq!(report["ready"], false);
10377 assert_eq!(
10378 report["failed_checks"],
10379 serde_json::json!(["library_readiness"])
10380 );
10381 let check = report["checks"]
10382 .as_array()
10383 .unwrap()
10384 .iter()
10385 .find(|check| check["name"] == "library_readiness")
10386 .unwrap();
10387 assert_eq!(
10388 check["failed_evidence_fields"],
10389 serde_json::json!([
10390 "library_readiness.ready",
10391 "library_readiness.production_path.ready",
10392 "library_readiness.production_path.cli_required",
10393 "library_readiness.production_path.spawned_helper_required"
10394 ])
10395 );
10396 }
10397
10398 #[test]
10399 fn typed_library_readiness_requires_production_path_contract() {
10400 let mut bundle = ready_bundle();
10401 bundle["library_readiness"]
10402 .as_object_mut()
10403 .unwrap()
10404 .remove("production_path");
10405
10406 let typed = super::library_readiness_cutover_readiness(&bundle);
10407
10408 assert!(!typed.evidence_ready());
10409 assert!(!typed.production_path_ready);
10410 assert!(!typed.production_path_in_process);
10411 assert!(!typed.production_path_cli_not_required);
10412 assert!(!typed.production_path_env_control_plane_not_required);
10413 assert!(!typed.production_path_spawned_helper_not_required);
10414 }
10415
10416 #[test]
10417 fn requires_cutover_controls_evidence() {
10418 let mut bundle = ready_bundle();
10419 bundle.as_object_mut().unwrap().remove("cutover_controls");
10420
10421 let typed = super::cutover_controls_readiness(&bundle);
10422 assert!(!typed.evidence_ready());
10423 assert!(!typed.protocol_matches);
10424 assert!(!typed.ready);
10425 assert!(!typed.graph_reads_hawdb);
10426 assert!(!typed.search_reads_hawdb);
10427
10428 let report = integration_readiness_json(&bundle);
10429
10430 assert_eq!(report["ready"], false);
10431 assert_eq!(
10432 report["failed_checks"],
10433 serde_json::json!(["cutover_controls"])
10434 );
10435 let check = report["checks"]
10436 .as_array()
10437 .unwrap()
10438 .iter()
10439 .find(|check| check["name"] == "cutover_controls")
10440 .unwrap();
10441 assert_eq!(
10442 check["failed_evidence_fields"],
10443 serde_json::json!([
10444 "cutover_controls.protocol",
10445 "cutover_controls.ready",
10446 "cutover_controls.controls.graph_reads",
10447 "cutover_controls.graph.read_effective",
10448 "cutover_controls.production_status.graph.hawdb_cutover_effective",
10449 "cutover_controls.controls.search_reads",
10450 "cutover_controls.search.read_effective",
10451 "cutover_controls.production_status.search.hawdb_cutover_effective",
10452 "cutover_controls.work.dual_writes_enabled",
10453 "cutover_controls.work.projection_catch_up_enabled",
10454 "cutover_controls.work.initial_import_safe_for_read_cutover",
10455 "cutover_controls.redaction.query_text_copied",
10456 "cutover_controls.redaction.parameters_copied",
10457 "cutover_controls.redaction.local_paths_copied"
10458 ])
10459 );
10460 assert!(report["next_actions"]
10461 .as_array()
10462 .unwrap()
10463 .iter()
10464 .any(|action| action["action"] == "attach_cutover_controls_evidence"));
10465 }
10466
10467 #[test]
10468 fn cutover_controls_reject_legacy_or_ineffective_hawdb_reads() {
10469 let mut bundle = ready_bundle();
10470 bundle["cutover_controls"]["ready"] = serde_json::json!(false);
10471 bundle["cutover_controls"]["controls"]["graph_reads"] = serde_json::json!("legacy");
10472 bundle["cutover_controls"]["graph"]["read_effective"] = serde_json::json!(false);
10473 bundle["cutover_controls"]["production_status"]["graph"]["hawdb_cutover_effective"] =
10474 serde_json::json!(false);
10475 bundle["cutover_controls"]["work"]["projection_catch_up_enabled"] =
10476 serde_json::json!(false);
10477 bundle["cutover_controls"]["blocker_codes"] = serde_json::json!([
10478 "graph_read_selected_hawdb_but_not_effective",
10479 "search_read_selected_hawdb_without_projection_catch_up"
10480 ]);
10481
10482 let typed = super::cutover_controls_readiness(&bundle);
10483 assert!(!typed.evidence_ready());
10484 assert!(typed.protocol_matches);
10485 assert!(!typed.ready);
10486 assert!(!typed.graph_reads_hawdb);
10487 assert!(!typed.graph_read_effective);
10488 assert!(!typed.graph_production_status_effective);
10489 assert!(!typed.projection_catch_up_enabled);
10490 assert_eq!(
10491 typed.blocker_codes,
10492 vec![
10493 "graph_read_selected_hawdb_but_not_effective".to_string(),
10494 "search_read_selected_hawdb_without_projection_catch_up".to_string()
10495 ]
10496 );
10497
10498 let report = integration_readiness_json(&bundle);
10499 let check = report["checks"]
10500 .as_array()
10501 .unwrap()
10502 .iter()
10503 .find(|check| check["name"] == "cutover_controls")
10504 .unwrap();
10505
10506 assert_eq!(report["ready"], false);
10507 assert_eq!(
10508 report["failed_checks"],
10509 serde_json::json!(["cutover_controls"])
10510 );
10511 assert_eq!(
10512 check["failed_evidence_fields"],
10513 serde_json::json!([
10514 "cutover_controls.ready",
10515 "cutover_controls.controls.graph_reads",
10516 "cutover_controls.graph.read_effective",
10517 "cutover_controls.production_status.graph.hawdb_cutover_effective",
10518 "cutover_controls.work.projection_catch_up_enabled"
10519 ])
10520 );
10521 }
10522
10523 #[test]
10524 fn cutover_controls_reject_active_initial_import_for_read_cutover() {
10525 let mut bundle = ready_bundle();
10526 bundle["cutover_controls"]["ready"] = serde_json::json!(false);
10527 bundle["cutover_controls"]["controls"]["initial_import"] = serde_json::json!("enabled");
10528 bundle["cutover_controls"]["work"]["initial_import_enabled"] = serde_json::json!(true);
10529 bundle["cutover_controls"]["work"]["initial_import_inactive_for_cutover"] =
10530 serde_json::json!(false);
10531 bundle["cutover_controls"]["blocker_codes"] =
10532 serde_json::json!(["initial_import_active_blocks_read_cutover"]);
10533
10534 let typed = super::cutover_controls_readiness(&bundle);
10535 assert!(!typed.evidence_ready());
10536 assert!(typed.dual_writes_enabled);
10537 assert!(typed.initial_import_safe);
10538 assert!(!typed.initial_import_inactive_for_cutover);
10539 assert!(!typed.initial_import_cutover_catch_up_ready);
10540 assert!(!typed.initial_import_safe_for_read_cutover);
10541 assert_eq!(
10542 typed.blocker_codes,
10543 vec!["initial_import_active_blocks_read_cutover".to_string()]
10544 );
10545
10546 let report = integration_readiness_json(&bundle);
10547 let check = report["checks"]
10548 .as_array()
10549 .unwrap()
10550 .iter()
10551 .find(|check| check["name"] == "cutover_controls")
10552 .unwrap();
10553
10554 assert_eq!(report["ready"], false);
10555 assert_eq!(
10556 report["failed_checks"],
10557 serde_json::json!(["cutover_controls"])
10558 );
10559 assert_eq!(
10560 check["failed_evidence_fields"],
10561 serde_json::json!([
10562 "cutover_controls.ready",
10563 "cutover_controls.work.initial_import_safe_for_read_cutover"
10564 ])
10565 );
10566 assert_eq!(
10567 check["blocker_codes"],
10568 serde_json::json!(["initial_import_active_blocks_read_cutover"])
10569 );
10570 }
10571
10572 #[test]
10573 fn cutover_controls_accept_active_initial_import_with_catch_up_proof() {
10574 let mut bundle = ready_bundle();
10575 bundle["cutover_controls"]["controls"]["initial_import"] = serde_json::json!("enabled");
10576 bundle["cutover_controls"]["work"]["initial_import_enabled"] = serde_json::json!(true);
10577 bundle["cutover_controls"]["work"]["initial_import_inactive_for_cutover"] =
10578 serde_json::json!(false);
10579 bundle["cutover_controls"]["work"]["initial_import_cutover_catch_up_ready"] =
10580 serde_json::json!(true);
10581 bundle["cutover_controls"]["work"]["initial_import_safe_for_read_cutover"] =
10582 serde_json::json!(true);
10583
10584 let typed = super::cutover_controls_readiness(&bundle);
10585 assert!(typed.evidence_ready());
10586 assert!(typed.initial_import_safe);
10587 assert!(!typed.initial_import_inactive_for_cutover);
10588 assert!(typed.initial_import_cutover_catch_up_ready);
10589 assert!(typed.initial_import_safe_for_read_cutover);
10590
10591 let report = integration_readiness_json(&bundle);
10592 assert_eq!(report["ready"], true);
10593 }
10594
10595 #[test]
10596 fn requires_operations_readiness_evidence() {
10597 let mut bundle = ready_bundle();
10598 bundle
10599 .as_object_mut()
10600 .unwrap()
10601 .remove("operations_readiness");
10602
10603 let typed = super::operations_readiness_cutover_readiness(&bundle);
10604 assert!(!typed.evidence_ready());
10605 assert!(!typed.protocol_matches);
10606 assert!(!typed.present);
10607 assert!(!typed.ready);
10608 assert!(!typed.graph_open);
10609
10610 let report = integration_readiness_json(&bundle);
10611
10612 assert_eq!(report["ready"], false);
10613 assert_eq!(
10614 report["failed_checks"],
10615 serde_json::json!(["operations_readiness"])
10616 );
10617 assert_eq!(report["blocking_categories"], serde_json::Value::Null);
10618 let check = report["checks"]
10619 .as_array()
10620 .unwrap()
10621 .iter()
10622 .find(|check| check["name"] == "operations_readiness")
10623 .unwrap();
10624 assert_eq!(
10625 check["failed_evidence_fields"],
10626 serde_json::json!([
10627 "operations_readiness.protocol",
10628 "operations_readiness.present",
10629 "operations_readiness.ready",
10630 "operations_readiness.graph.open",
10631 "operations_readiness.graph.read_only",
10632 "operations_readiness.search_projection.open",
10633 "operations_readiness.search_projection.stale",
10634 "operations_readiness.storage_lifecycle.ready",
10635 "operations_readiness.storage_lifecycle.action",
10636 "operations_readiness.readiness.storage_recovery_ready",
10637 "operations_readiness.readiness.slow_query_ready",
10638 "operations_readiness.readiness.background_maintenance_ready",
10639 "operations_readiness.redaction.query_text_copied",
10640 "operations_readiness.redaction.parameters_copied",
10641 "operations_readiness.redaction.local_paths_copied"
10642 ])
10643 );
10644 assert!(report["next_actions"]
10645 .as_array()
10646 .unwrap()
10647 .iter()
10648 .any(|action| action["action"] == "attach_operations_readiness_report"));
10649 }
10650
10651 #[test]
10652 fn operations_readiness_blocks_stale_projection_and_recovery_actions() {
10653 let mut bundle = ready_bundle();
10654 bundle["operations_readiness"]["ready"] = serde_json::json!(false);
10655 bundle["operations_readiness"]["search_projection"]["stale"] = serde_json::json!(true);
10656 bundle["operations_readiness"]["storage_lifecycle"]["ready"] = serde_json::json!(false);
10657 bundle["operations_readiness"]["storage_lifecycle"]["action"] =
10658 serde_json::json!("run_checkpoint");
10659 bundle["operations_readiness"]["readiness"]["storage_recovery_ready"] =
10660 serde_json::json!(false);
10661 bundle["operations_readiness"]["blocker_codes"] =
10662 serde_json::json!(["storage_recovery_not_ready", "search_projection_stale"]);
10663
10664 let typed = super::operations_readiness_cutover_readiness(&bundle);
10665 assert!(!typed.evidence_ready());
10666 assert!(typed.protocol_matches);
10667 assert!(typed.present);
10668 assert!(!typed.ready);
10669 assert!(!typed.search_projection_not_stale);
10670 assert!(!typed.storage_lifecycle_ready);
10671 assert!(!typed.storage_lifecycle_action_ready);
10672 assert!(!typed.storage_recovery_ready);
10673 assert_eq!(
10674 typed.blocker_codes,
10675 vec![
10676 "search_projection_stale".to_string(),
10677 "storage_recovery_not_ready".to_string()
10678 ]
10679 );
10680
10681 let preflight = super::final_cutover_preflight(&bundle);
10682 assert!(!preflight.production_cutover_ready);
10683 assert!(!preflight.storage_recovery_ready);
10684 assert!(preflight
10685 .failed_checks
10686 .contains(&"operations_readiness".to_string()));
10687 assert!(preflight
10688 .blocking_categories
10689 .contains(&"storage_recovery".to_string()));
10690 }
10691
10692 #[test]
10693 fn rejects_library_readiness_that_copies_sensitive_fields() {
10694 let mut bundle = ready_bundle();
10695 bundle["library_readiness"]["ready"] = serde_json::json!(false);
10696 bundle["library_readiness"]["redaction"]["ready"] = serde_json::json!(false);
10697 bundle["library_readiness"]["redaction"]["query_text_copied"] = serde_json::json!(true);
10698 bundle["library_readiness"]["redaction"]["parameters_copied"] = serde_json::json!(true);
10699 bundle["library_readiness"]["redaction"]["local_paths_copied"] = serde_json::json!(true);
10700 bundle["library_readiness"]["blocker_codes"] =
10701 serde_json::json!(["library_readiness_redaction_not_ready"]);
10702
10703 let typed = super::library_readiness_cutover_readiness(&bundle);
10704 assert!(!typed.evidence_ready());
10705 assert!(!typed.redaction_ready);
10706 assert!(!typed.query_text_redacted);
10707 assert!(!typed.parameters_redacted);
10708 assert!(!typed.local_paths_redacted);
10709
10710 let report = integration_readiness_json(&bundle);
10711
10712 assert_eq!(report["ready"], false);
10713 assert_eq!(
10714 report["failed_checks"],
10715 serde_json::json!(["library_readiness"])
10716 );
10717 assert_eq!(
10718 report["blocker_codes"],
10719 serde_json::json!(["library_readiness_redaction_not_ready"])
10720 );
10721 let library_check = report["checks"]
10722 .as_array()
10723 .unwrap()
10724 .iter()
10725 .find(|check| check["name"] == "library_readiness")
10726 .unwrap();
10727 assert_eq!(
10728 library_check["failed_evidence_fields"],
10729 serde_json::json!([
10730 "library_readiness.ready",
10731 "library_readiness.redaction.ready",
10732 "library_readiness.redaction.query_text_copied",
10733 "library_readiness.redaction.parameters_copied",
10734 "library_readiness.redaction.local_paths_copied"
10735 ])
10736 );
10737 }
10738
10739 #[test]
10740 fn rejects_blocked_library_graph_route_readiness_area() {
10741 let mut bundle = ready_bundle();
10742 bundle["library_readiness"]["ready"] = serde_json::json!(false);
10743 bundle["library_readiness"]["ready_area_count"] = serde_json::json!(8);
10744 bundle["library_readiness"]["blocked_area_count"] = serde_json::json!(1);
10745 bundle["library_readiness"]["blocker_codes"] =
10746 serde_json::json!(["graph_route_readiness_not_ready"]);
10747 bundle["library_readiness"]["readiness_by_area"]["graph_route"]["ready"] =
10748 serde_json::json!(false);
10749 bundle["library_readiness"]["readiness_by_area"]["graph_route"]["blocker_codes"] =
10750 serde_json::json!(["graph_route_readiness_missing"]);
10751
10752 let typed = super::library_readiness_cutover_readiness(&bundle);
10753 assert!(!typed.evidence_ready());
10754 assert!(typed.protocol_matches);
10755 assert!(typed.present);
10756 assert!(!typed.ready);
10757 assert!(!typed.blocked_area_count_zero);
10758 assert!(!typed.graph_route_ready);
10759 assert_eq!(
10760 typed.blocker_codes,
10761 vec![
10762 "graph_route_readiness_missing".to_string(),
10763 "graph_route_readiness_not_ready".to_string()
10764 ]
10765 );
10766
10767 let report = integration_readiness_json(&bundle);
10768
10769 assert_eq!(report["ready"], false);
10770 assert_eq!(
10771 report["failed_checks"],
10772 serde_json::json!(["library_readiness"])
10773 );
10774 assert_eq!(
10775 report["blocker_codes"],
10776 serde_json::json!([
10777 "graph_route_readiness_missing",
10778 "graph_route_readiness_not_ready"
10779 ])
10780 );
10781 let library_check = report["checks"]
10782 .as_array()
10783 .unwrap()
10784 .iter()
10785 .find(|check| check["name"] == "library_readiness")
10786 .unwrap();
10787 assert_eq!(
10788 library_check["failed_evidence_fields"],
10789 serde_json::json!([
10790 "library_readiness.ready",
10791 "library_readiness.blocked_area_count",
10792 "library_readiness.readiness_by_area.graph_route.ready"
10793 ])
10794 );
10795 }
10796
10797 #[test]
10798 fn rejects_blocked_library_search_route_ownership_area() {
10799 let mut bundle = ready_bundle();
10800 bundle["library_readiness"]["ready"] = serde_json::json!(false);
10801 bundle["library_readiness"]["ready_area_count"] = serde_json::json!(10);
10802 bundle["library_readiness"]["blocked_area_count"] = serde_json::json!(1);
10803 bundle["library_readiness"]["blocker_codes"] =
10804 serde_json::json!(["search_route_ownership_not_ready"]);
10805 bundle["library_readiness"]["search_route_ownership"]["ready"] = serde_json::json!(false);
10806 bundle["library_readiness"]["search_route_ownership"]["production_cutover_ready"] =
10807 serde_json::json!(false);
10808 bundle["library_readiness"]["search_route_ownership"]["lancedb_route_count"] =
10809 serde_json::json!(1);
10810 bundle["library_readiness"]["search_route_ownership"]["lancedb_routes"] =
10811 serde_json::json!(["memory"]);
10812 bundle["library_readiness"]["search_route_ownership"]["blocker_codes"] =
10813 serde_json::json!(["search_routes_still_lancedb"]);
10814 bundle["library_readiness"]["readiness_by_area"]["search_route_ownership"]["ready"] =
10815 serde_json::json!(false);
10816 bundle["library_readiness"]["readiness_by_area"]["search_route_ownership"]
10817 ["blocker_codes"] = serde_json::json!(["search_routes_still_lancedb"]);
10818
10819 let typed = super::library_readiness_cutover_readiness(&bundle);
10820 assert!(!typed.evidence_ready());
10821 assert!(!typed.ready);
10822 assert!(!typed.blocked_area_count_zero);
10823 assert!(!typed.search_route_ownership_ready);
10824 assert_eq!(
10825 typed.blocker_codes,
10826 vec![
10827 "search_route_ownership_not_ready".to_string(),
10828 "search_routes_still_lancedb".to_string()
10829 ]
10830 );
10831
10832 let report = integration_readiness_json(&bundle);
10833
10834 assert_eq!(report["ready"], false);
10835 assert_eq!(
10836 report["failed_checks"],
10837 serde_json::json!(["library_readiness"])
10838 );
10839 assert_eq!(
10840 report["blocker_codes"],
10841 serde_json::json!([
10842 "search_route_ownership_not_ready",
10843 "search_routes_still_lancedb"
10844 ])
10845 );
10846 let library_check = report["checks"]
10847 .as_array()
10848 .unwrap()
10849 .iter()
10850 .find(|check| check["name"] == "library_readiness")
10851 .unwrap();
10852 assert_eq!(
10853 library_check["failed_evidence_fields"],
10854 serde_json::json!([
10855 "library_readiness.ready",
10856 "library_readiness.blocked_area_count",
10857 "library_readiness.readiness_by_area.search_route_ownership.ready"
10858 ])
10859 );
10860 }
10861
10862 #[test]
10863 fn rejects_blocked_library_workload_fixture_readiness_area() {
10864 let mut bundle = ready_bundle();
10865 bundle["library_readiness"]["ready"] = serde_json::json!(false);
10866 bundle["library_readiness"]["ready_area_count"] = serde_json::json!(10);
10867 bundle["library_readiness"]["blocked_area_count"] = serde_json::json!(1);
10868 bundle["library_readiness"]["blocker_codes"] =
10869 serde_json::json!(["workload_fixture_evidence_not_ready"]);
10870 bundle["library_readiness"]["readiness_by_area"]["workload_fixture"]["ready"] =
10871 serde_json::json!(false);
10872 bundle["library_readiness"]["readiness_by_area"]["workload_fixture"]["blocker_codes"] =
10873 serde_json::json!(["workload_fixture_search_metadata_not_ready"]);
10874
10875 let typed = super::library_readiness_cutover_readiness(&bundle);
10876 assert!(!typed.evidence_ready());
10877 assert!(typed.protocol_matches);
10878 assert!(typed.present);
10879 assert!(!typed.ready);
10880 assert!(!typed.blocked_area_count_zero);
10881 assert!(!typed.workload_fixture_ready);
10882 assert_eq!(
10883 typed.blocker_codes,
10884 vec![
10885 "workload_fixture_evidence_not_ready".to_string(),
10886 "workload_fixture_search_metadata_not_ready".to_string()
10887 ]
10888 );
10889
10890 let report = integration_readiness_json(&bundle);
10891
10892 assert_eq!(report["ready"], false);
10893 assert_eq!(
10894 report["failed_checks"],
10895 serde_json::json!(["library_readiness"])
10896 );
10897 assert_eq!(
10898 report["blocker_codes"],
10899 serde_json::json!([
10900 "workload_fixture_evidence_not_ready",
10901 "workload_fixture_search_metadata_not_ready"
10902 ])
10903 );
10904 let library_check = report["checks"]
10905 .as_array()
10906 .unwrap()
10907 .iter()
10908 .find(|check| check["name"] == "library_readiness")
10909 .unwrap();
10910 assert_eq!(
10911 library_check["failed_evidence_fields"],
10912 serde_json::json!([
10913 "library_readiness.ready",
10914 "library_readiness.blocked_area_count",
10915 "library_readiness.readiness_by_area.workload_fixture.ready"
10916 ])
10917 );
10918 }
10919
10920 #[test]
10921 fn requires_background_maintenance_evidence() {
10922 let mut bundle = ready_bundle();
10923 bundle["replacement_summary"]["cutover_evidence"]["background_maintenance_ready"] =
10924 serde_json::json!(false);
10925 bundle["replacement_summary"]["cutover_evidence"]
10926 ["background_maintenance_protocol_matches"] = serde_json::json!(false);
10927 bundle["replacement_summary"]["cutover_evidence"]
10928 ["background_maintenance_admitted_search_projection_graph_delta_count"] =
10929 serde_json::Value::Null;
10930 bundle["replacement_summary"]["cutover_evidence"]["background_maintenance_blocker_codes"] =
10931 serde_json::json!(["background_disabled"]);
10932
10933 let typed = super::background_maintenance_cutover_readiness(&bundle);
10934 assert!(!typed.evidence_ready());
10935 assert!(typed.required);
10936 assert!(!typed.ready);
10937 assert!(!typed.protocol_matches);
10938 assert!(typed.executable_search_projection_graph_delta_count_present);
10939 assert!(!typed.admitted_search_projection_graph_delta_count_present);
10940 assert_eq!(typed.blocker_codes, vec!["background_disabled".to_string()]);
10941
10942 let report = integration_readiness_json(&bundle);
10943
10944 assert_eq!(report["ready"], false);
10945 assert_eq!(
10946 report["failed_checks"],
10947 serde_json::json!(["background_maintenance_evidence"])
10948 );
10949 assert_eq!(
10950 report["blocker_codes"],
10951 serde_json::json!(["background_disabled"])
10952 );
10953 let maintenance_check = report["checks"]
10954 .as_array()
10955 .unwrap()
10956 .iter()
10957 .find(|check| check["name"] == "background_maintenance_evidence")
10958 .unwrap();
10959 assert_eq!(
10960 maintenance_check["failed_evidence_fields"],
10961 serde_json::json!([
10962 "replacement_summary.cutover_evidence.background_maintenance_ready",
10963 "replacement_summary.cutover_evidence.background_maintenance_protocol_matches",
10964 "replacement_summary.cutover_evidence.background_maintenance_admitted_search_projection_graph_delta_count"
10965 ])
10966 );
10967 assert!(report["next_actions"]
10968 .as_array()
10969 .unwrap()
10970 .iter()
10971 .any(|action| action["action"] == "attach_background_maintenance_report"));
10972 }
10973
10974 #[test]
10975 fn rejects_incomplete_background_maintenance_graph_delta_summary() {
10976 let mut bundle = ready_bundle();
10977 bundle["replacement_summary"]["cutover_evidence"]
10978 ["background_maintenance_deferred_search_projection_graph_delta_count"] =
10979 serde_json::Value::Null;
10980 bundle["replacement_summary"]["cutover_evidence"]
10981 ["background_maintenance_rejected_search_projection_graph_delta_count"] =
10982 serde_json::Value::Null;
10983 bundle["replacement_summary"]["cutover_evidence"]["background_maintenance_max_search_projection_graph_delta_complete_through_graph_commit_epoch"] =
10984 serde_json::Value::Null;
10985
10986 let typed = super::background_maintenance_cutover_readiness(&bundle);
10987 assert!(!typed.evidence_ready());
10988 assert!(typed.required);
10989 assert!(typed.ready);
10990 assert!(typed.protocol_matches);
10991 assert!(!typed.deferred_search_projection_graph_delta_count_present);
10992 assert!(!typed.rejected_search_projection_graph_delta_count_present);
10993 assert!(
10994 !typed.max_search_projection_graph_delta_complete_through_graph_commit_epoch_present
10995 );
10996 assert!(typed.memory_pressure_ready);
10997 assert!(typed.memory_budget_bytes_present);
10998 assert!(typed.estimated_memory_bytes_present);
10999
11000 let report = integration_readiness_json(&bundle);
11001
11002 assert_eq!(report["ready"], false);
11003 assert_eq!(
11004 report["failed_checks"],
11005 serde_json::json!(["background_maintenance_evidence"])
11006 );
11007 let maintenance_check = report["checks"]
11008 .as_array()
11009 .unwrap()
11010 .iter()
11011 .find(|check| check["name"] == "background_maintenance_evidence")
11012 .unwrap();
11013 assert_eq!(
11014 maintenance_check["failed_evidence_fields"],
11015 serde_json::json!([
11016 "replacement_summary.cutover_evidence.background_maintenance_deferred_search_projection_graph_delta_count",
11017 "replacement_summary.cutover_evidence.background_maintenance_rejected_search_projection_graph_delta_count",
11018 "replacement_summary.cutover_evidence.background_maintenance_max_search_projection_graph_delta_complete_through_graph_commit_epoch"
11019 ])
11020 );
11021 assert!(report["next_actions"]
11022 .as_array()
11023 .unwrap()
11024 .iter()
11025 .any(|action| action["action"] == "attach_background_maintenance_report"));
11026 }
11027
11028 #[test]
11029 fn rejects_missing_background_maintenance_memory_pressure_summary() {
11030 let mut bundle = ready_bundle();
11031 bundle["replacement_summary"]["cutover_evidence"]
11032 ["background_maintenance_memory_pressure_ready"] = serde_json::Value::Null;
11033 bundle["replacement_summary"]["cutover_evidence"]
11034 ["background_maintenance_memory_budget_bytes"] = serde_json::Value::Null;
11035 bundle["replacement_summary"]["cutover_evidence"]
11036 ["background_maintenance_estimated_memory_bytes"] = serde_json::Value::Null;
11037
11038 let typed = super::background_maintenance_cutover_readiness(&bundle);
11039 assert!(!typed.evidence_ready());
11040 assert!(typed.required);
11041 assert!(typed.ready);
11042 assert!(typed.protocol_matches);
11043 assert!(!typed.memory_pressure_ready);
11044 assert!(!typed.memory_budget_bytes_present);
11045 assert!(!typed.estimated_memory_bytes_present);
11046
11047 let report = integration_readiness_json(&bundle);
11048
11049 assert_eq!(report["ready"], false);
11050 assert_eq!(
11051 report["failed_checks"],
11052 serde_json::json!(["background_maintenance_evidence"])
11053 );
11054 let maintenance_check = report["checks"]
11055 .as_array()
11056 .unwrap()
11057 .iter()
11058 .find(|check| check["name"] == "background_maintenance_evidence")
11059 .unwrap();
11060 assert_eq!(
11061 maintenance_check["failed_evidence_fields"],
11062 serde_json::json!([
11063 "replacement_summary.cutover_evidence.background_maintenance_memory_pressure_ready",
11064 "replacement_summary.cutover_evidence.background_maintenance_memory_budget_bytes",
11065 "replacement_summary.cutover_evidence.background_maintenance_estimated_memory_bytes"
11066 ])
11067 );
11068 assert!(report["next_actions"]
11069 .as_array()
11070 .unwrap()
11071 .iter()
11072 .any(|action| action["action"] == "attach_background_maintenance_report"));
11073 }
11074
11075 #[test]
11076 fn requires_storage_recovery_evidence() {
11077 let mut bundle = ready_bundle();
11078 bundle["replacement_summary"]["cutover_evidence"]["storage_recovery_ready"] =
11079 serde_json::json!(false);
11080 bundle["replacement_summary"]["cutover_evidence"]["storage_recovery_wal_replay_bounded"] =
11081 serde_json::json!(false);
11082 bundle["replacement_summary"]["cutover_evidence"]["storage_recovery_blocker_codes"] =
11083 serde_json::json!(["wal_replay_unbounded"]);
11084
11085 let typed = super::storage_recovery_cutover_readiness(&bundle);
11086 assert!(!typed.evidence_ready());
11087 assert!(typed.required);
11088 assert!(!typed.ready);
11089 assert!(!typed.wal_replay_bounded);
11090 assert_eq!(
11091 typed.blocker_codes,
11092 vec!["wal_replay_unbounded".to_string()]
11093 );
11094
11095 let report = integration_readiness_json(&bundle);
11096
11097 assert_eq!(report["ready"], false);
11098 assert_eq!(
11099 report["failed_checks"],
11100 serde_json::json!(["storage_recovery_evidence"])
11101 );
11102 assert_eq!(
11103 report["blocker_codes"],
11104 serde_json::json!(["wal_replay_unbounded"])
11105 );
11106 let storage_check = report["checks"]
11107 .as_array()
11108 .unwrap()
11109 .iter()
11110 .find(|check| check["name"] == "storage_recovery_evidence")
11111 .unwrap();
11112 assert_eq!(
11113 storage_check["failed_evidence_fields"],
11114 serde_json::json!([
11115 "replacement_summary.cutover_evidence.storage_recovery_ready",
11116 "replacement_summary.cutover_evidence.storage_recovery_wal_replay_bounded"
11117 ])
11118 );
11119 assert!(report["next_actions"]
11120 .as_array()
11121 .unwrap()
11122 .iter()
11123 .any(|action| action["action"] == "attach_storage_recovery_report"));
11124 }
11125
11126 #[test]
11127 fn rejects_inconsistent_storage_recovery_summary_even_if_ready_flag_is_true() {
11128 let mut bundle = ready_bundle();
11129 bundle["replacement_summary"]["cutover_evidence"]["storage_recovery_durable"] =
11130 serde_json::json!(false);
11131 bundle["replacement_summary"]["cutover_evidence"]
11132 ["storage_recovery_checkpoint_boundary_present"] = serde_json::json!(false);
11133 bundle["replacement_summary"]["cutover_evidence"]
11134 ["storage_recovery_replay_boundary_consistent"] = serde_json::json!(false);
11135 bundle["replacement_summary"]["cutover_evidence"]["storage_recovery_torn_tail_clean"] =
11136 serde_json::json!(false);
11137
11138 let typed = super::storage_recovery_cutover_readiness(&bundle);
11139 assert!(!typed.evidence_ready());
11140 assert!(typed.ready);
11141 assert!(!typed.durable);
11142 assert!(!typed.checkpoint_boundary_present);
11143 assert!(!typed.replay_boundary_consistent);
11144 assert!(!typed.torn_tail_clean);
11145
11146 let report = integration_readiness_json(&bundle);
11147
11148 assert_eq!(report["ready"], false);
11149 assert_eq!(
11150 report["failed_checks"],
11151 serde_json::json!(["storage_recovery_evidence"])
11152 );
11153 let storage_check = report["checks"]
11154 .as_array()
11155 .unwrap()
11156 .iter()
11157 .find(|check| check["name"] == "storage_recovery_evidence")
11158 .unwrap();
11159 assert_eq!(
11160 storage_check["failed_evidence_fields"],
11161 serde_json::json!([
11162 "replacement_summary.cutover_evidence.storage_recovery_durable",
11163 "replacement_summary.cutover_evidence.storage_recovery_checkpoint_boundary_present",
11164 "replacement_summary.cutover_evidence.storage_recovery_replay_boundary_consistent",
11165 "replacement_summary.cutover_evidence.storage_recovery_torn_tail_clean"
11166 ])
11167 );
11168 assert!(report["next_actions"]
11169 .as_array()
11170 .unwrap()
11171 .iter()
11172 .any(|action| action["action"] == "attach_storage_recovery_report"));
11173 }
11174
11175 fn ready_bundle() -> serde_json::Value {
11176 let mut bundle = serde_json::json!({
11177 "protocol": "nowledge-mem-hawdb-integration-bundle",
11178 "submodule": {
11179 "present": true,
11180 "path": "vendor/hawdb",
11181 "commit": "46f8bfb",
11182 "blocker_codes": []
11183 },
11184 "coexistence": {
11185 "old_database_retained": true,
11186 "old_database_deleted": false,
11187 "mode": "shadow",
11188 "blocker_codes": []
11189 },
11190 "content_store": {
11191 "present": true,
11192 "engine": "sqlite",
11193 "messages_available": true,
11194 "source_chunks_available": true,
11195 "blocker_codes": []
11196 },
11197 "previous_wrapper_preflight": {
11198 "ready": true,
11199 "blocker_codes": [],
11200 "failed_checks": []
11201 },
11202 "bounded_read_evidence": {
11203 "protocol": "hawdb-nowledge-mem-bounded-read-evidence-v2",
11204 "ready": true,
11205 "mode": "shadow_read_only",
11206 "max_rows": 512,
11207 "execution_row_cap": 513,
11208 "estimated_payload_bytes": 128,
11209 "max_estimated_payload_bytes": 4194304,
11210 "payload_budget_exceeded": false,
11211 "row_limit_enforced_before_output": true,
11212 "operator_row_cap_enabled": true,
11213 "blocking_operator_count": 0,
11214 "blocking_operator_memory_reports_complete": true,
11215 "blocking_operator_memory_within_budget": true,
11216 "spill_within_budget": true,
11217 "streaming": false,
11218 "covered_routes": REQUIRED_BOUNDED_READ_ROUTES,
11219 "route_catalog_version": GRAPH_READ_ROUTE_CATALOG_VERSION,
11220 "route_catalog_digest": graph_read_route_catalog_digest(),
11221 "blocker_codes": []
11222 },
11223 "replacement_summary_bounded_read_alignment": {
11224 "ready": true,
11225 "evidence_present": true,
11226 "summary_present": true,
11227 "evidence_ready": true,
11228 "summary_ready": true,
11229 "protocol_matches": true,
11230 "readiness_matches": true,
11231 "mode_matches": true,
11232 "max_rows_matches": true,
11233 "estimated_payload_bytes_matches": true,
11234 "max_estimated_payload_bytes_matches": true,
11235 "payload_budget_exceeded_matches": true,
11236 "streaming_matches": true,
11237 "covered_routes_matches": true,
11238 "evidence_route_catalog_version_ready": true,
11239 "summary_route_catalog_version_ready": true,
11240 "evidence_route_catalog_digest_ready": true,
11241 "summary_route_catalog_digest_ready": true,
11242 "route_catalog_version_matches": true,
11243 "route_catalog_digest_matches": true,
11244 "blocker_codes": []
11245 },
11246 "replacement_summary": {
11247 "protocol": "hawdb-nowledge-replacement-summary",
11248 "production_cutover_ready": true,
11249 "blocking_categories": [],
11250 "missing_evidence": [],
11251 "shadow_evidence": {
11252 "ready": true
11253 },
11254 "dual_engine_evidence": {
11255 "present": true,
11256 "ready": true,
11257 "consistent": true
11258 },
11259 "replacement_readiness_family_summary": {
11260 "total_count": 5,
11261 "ready_count": 5,
11262 "blocked_count": 0,
11263 "omitted_count": 0,
11264 "min_replacement_readiness_per_million": 1_000_000,
11265 "blocked_query_families": [],
11266 "required_query_families": [
11267 "memory_lookup",
11268 "graph_traversal",
11269 "projected_graph",
11270 "label_stats_read",
11271 "search_projection"
11272 ],
11273 "missing_required_query_families": []
11274 },
11275 "search_projection_evidence": {
11276 "protocol": "hawdb-nowledge-search-projection-evidence",
11277 "ready": true,
11278 "fts_ready": true,
11279 "vector_ready": true,
11280 "document_identity_ready": true,
11281 "incremental_update_ready": true,
11282 "predicate_pushdown_ready": true,
11283 "production_filter_pruning_ready": true,
11284 "compressed_vector_projection_required": true,
11285 "compressed_vector_projection_ready": true,
11286 "blocker_codes": []
11287 },
11288 "search_projection_shadow_evidence": {
11289 "protocol": "hawdb-nowledge-search-projection-shadow-evidence",
11290 "evidence_source": HAWDB_SEARCH_PROJECTION_SHADOW_EVIDENCE_SOURCE,
11291 "present": true,
11292 "ready": true,
11293 "document_count_parity": true,
11294 "document_identity_parity": true,
11295 "table_parity_ready": true,
11296 "embedding_identity_parity": true,
11297 "incremental_watermark_parity": true,
11298 "pushdown_evidence": {
11299 "ready": true,
11300 "shadow_segment_descriptor_scan_filter_fields_ready": true,
11301 "shadow_segment_document_pruning_ready": true,
11302 "shadow_segment_pruning_candidate_document_count": 4,
11303 "shadow_segment_pruned_document_count": 2,
11304 "shadow_segment_scanned_document_count": 2,
11305 "primary_scan_filter_fields": scan_filter_fields_json(),
11306 "shadow_scan_filter_fields": scan_filter_fields_json(),
11307 "shadow_segment_descriptor_field_summaries": scan_filter_field_summaries_json()
11308 },
11309 "blocker_codes": []
11310 },
11311 "bounded_read_evidence": {
11312 "protocol": "hawdb-nowledge-mem-bounded-read-evidence-v2",
11313 "present": true,
11314 "ready": true,
11315 "mode": "shadow_read_only",
11316 "max_rows": 512,
11317 "execution_row_cap": 513,
11318 "estimated_payload_bytes": 128,
11319 "max_estimated_payload_bytes": 4194304,
11320 "payload_budget_exceeded": false,
11321 "row_limit_enforced_before_output": true,
11322 "operator_row_cap_enabled": true,
11323 "blocking_operator_count": 0,
11324 "blocking_operator_memory_reports_complete": true,
11325 "blocking_operator_memory_within_budget": true,
11326 "spill_within_budget": true,
11327 "streaming": false,
11328 "covered_routes": REQUIRED_BOUNDED_READ_ROUTES,
11329 "missing_covered_routes": [],
11330 "route_catalog_version": GRAPH_READ_ROUTE_CATALOG_VERSION,
11331 "route_catalog_digest": graph_read_route_catalog_digest(),
11332 "blocker_codes": []
11333 },
11334 "cutover_evidence": {
11335 "storage_recovery_required": true,
11336 "storage_recovery_ready": true,
11337 "storage_recovery_protocol_matches": true,
11338 "storage_recovery_durable": true,
11339 "storage_recovery_checkpoint_boundary_present": true,
11340 "storage_recovery_wal_replay_bounded": true,
11341 "storage_recovery_torn_tail_clean": true,
11342 "storage_recovery_blocker_codes": [],
11343 "storage_recovery_blockers": [],
11344 "background_maintenance_required": true,
11345 "background_maintenance_ready": true,
11346 "background_maintenance_protocol_matches": true,
11347 "background_maintenance_executable_search_projection_graph_delta_count": 1,
11348 "background_maintenance_admitted_search_projection_graph_delta_count": 1,
11349 "background_maintenance_deferred_search_projection_graph_delta_count": 0,
11350 "background_maintenance_rejected_search_projection_graph_delta_count": 0,
11351 "background_maintenance_executable_search_projection_graph_delta_operations": 2,
11352 "background_maintenance_admitted_search_projection_graph_delta_operations": 2,
11353 "background_maintenance_max_search_projection_graph_delta_complete_through_graph_commit_epoch": 7,
11354 "background_maintenance_blocker_codes": [],
11355 "background_maintenance_blockers": []
11356 }
11357 }
11358 });
11359 bundle["replacement_summary"]["source_mutation_dual_write_readiness"] =
11360 ready_source_mutation_dual_write_readiness();
11361 bundle["replacement_summary"]["cutover_evidence"]
11362 ["storage_recovery_replay_boundary_consistent"] = serde_json::json!(true);
11363 bundle["replacement_summary"]["replacement_boundaries"] = serde_json::json!({
11364 "graph_layer": {
11365 "scope": "kuzu_ladybug_graph_layer",
11366 "replacement_role": "primary_replacement",
11367 "storage_owner": "hawdb"
11368 },
11369 "search_projection": {
11370 "scope": "lancedb_search_projection",
11371 "replacement_role": "rebuildable_projection",
11372 "storage_owner": "hawdb"
11373 },
11374 "content_store": {
11375 "scope": "sqlite_content_store",
11376 "replacement_role": "external_out_of_scope",
11377 "storage_owner": "nowledge_mem"
11378 },
11379 "large_blob_store": {
11380 "scope": "large_blob_value_store",
11381 "replacement_role": "external_out_of_scope",
11382 "storage_owner": "nowledge_mem"
11383 }
11384 });
11385 bundle["replacement_summary"]["cutover_evidence"]
11386 ["storage_recovery_replay_boundary_consistent"] = serde_json::json!(true);
11387 bundle["replacement_summary"]["cutover_evidence"]
11388 ["background_maintenance_foreground_admission_probe_ready"] = serde_json::json!(true);
11389 bundle["replacement_summary"]["cutover_evidence"]
11390 ["background_maintenance_foreground_admission_probe_admission"] =
11391 serde_json::json!("admit");
11392 bundle["replacement_summary"]["cutover_evidence"]
11393 ["background_maintenance_memory_pressure_ready"] = serde_json::json!(true);
11394 bundle["replacement_summary"]["cutover_evidence"]
11395 ["background_maintenance_memory_budget_bytes"] = serde_json::json!(4096);
11396 bundle["replacement_summary"]["cutover_evidence"]
11397 ["background_maintenance_estimated_memory_bytes"] = serde_json::json!(1024);
11398 bundle["replacement_summary"]["query_runtime_preflight"] = ready_query_runtime_summary();
11399 bundle["replacement_summary_graph_route_alignment"] = serde_json::json!({
11400 "ready": true,
11401 "evidence_present": true,
11402 "summary_present": true,
11403 "protocol_matches": true,
11404 "evidence_protocol_matches": true,
11405 "evidence_ready": true,
11406 "evidence_route_primary_ready": true,
11407 "summary_route_primary_ready": true,
11408 "route_primary_ready_matches": true,
11409 "evidence_route_query_plan_evidence_ready": true,
11410 "summary_route_query_plan_evidence_ready": true,
11411 "route_query_plan_evidence_ready_matches": true,
11412 "evidence_route_query_profile_evidence_ready": true,
11413 "summary_route_query_profile_evidence_ready": true,
11414 "route_query_profile_evidence_ready_matches": true,
11415 "evidence_route_query_api_behavior_evidence_ready": true,
11416 "summary_route_query_api_behavior_evidence_ready": true,
11417 "route_query_api_behavior_evidence_ready_matches": true,
11418 "evidence_route_relationship_property_pruning_evidence_ready": true,
11419 "summary_route_relationship_property_pruning_evidence_ready": true,
11420 "route_relationship_property_pruning_evidence_ready_matches": true,
11421 "evidence_relationship_property_pruning_required_count": 0,
11422 "summary_relationship_property_pruning_required_count": 0,
11423 "relationship_property_pruning_required_count_matches": true,
11424 "evidence_relationship_property_pruning_report_count": 0,
11425 "summary_relationship_property_pruning_report_count": 0,
11426 "relationship_property_pruning_report_count_matches": true,
11427 "evidence_route_catalog_metadata_ready": true,
11428 "summary_route_catalog_metadata_ready": true,
11429 "route_catalog_metadata_ready_matches": true,
11430 "evidence_route_catalog_version_ready": true,
11431 "summary_route_catalog_version_ready": true,
11432 "evidence_route_catalog_digest_ready": true,
11433 "summary_route_catalog_digest_ready": true,
11434 "route_catalog_version_matches": true,
11435 "route_catalog_digest_matches": true,
11436 "primary_ready_routes_match": true,
11437 "evidence_required_routes_covered": true,
11438 "summary_required_routes_covered": true,
11439 "blocker_codes": []
11440 });
11441 bundle["replacement_summary_query_runtime_alignment"] = serde_json::json!({
11442 "ready": true,
11443 "evidence_present": true,
11444 "summary_present": true,
11445 "evidence_ready": true,
11446 "summary_ready": true,
11447 "protocol_matches": true,
11448 "readiness_matches": true,
11449 "database_opened_matches": true,
11450 "probe_count_matches": true,
11451 "passed_probe_count_matches": true,
11452 "failed_probe_count_matches": true,
11453 "required_route_count_matches": true,
11454 "covered_route_count_matches": true,
11455 "covered_routes_matches": true,
11456 "required_routes_covered_matches": true,
11457 "route_coverage_ready_matches": true,
11458 "evidence_route_catalog_version_ready": true,
11459 "summary_route_catalog_version_ready": true,
11460 "evidence_route_catalog_digest_ready": true,
11461 "summary_route_catalog_digest_ready": true,
11462 "route_catalog_version_matches": true,
11463 "route_catalog_digest_matches": true,
11464 "evidence_covered_routes": REQUIRED_BOUNDED_READ_ROUTES,
11465 "summary_covered_routes": REQUIRED_BOUNDED_READ_ROUTES,
11466 "blocker_codes": []
11467 });
11468 bundle["graph_route_readiness"] = serde_json::json!({
11469 "protocol": "nmem-graph-route-readiness-v1",
11470 "evidence_protocol": "nmem-graph-route-evidence-v1",
11471 "evidence_ready": true,
11472 "route_count": REQUIRED_BOUNDED_READ_ROUTES.len(),
11473 "required_route_count": REQUIRED_BOUNDED_READ_ROUTES.len(),
11474 "covered_route_count": REQUIRED_BOUNDED_READ_ROUTES.len(),
11475 "covered_routes": REQUIRED_BOUNDED_READ_ROUTES,
11476 "missing_required_routes": [],
11477 "required_routes_covered": true,
11478 "unknown_routes": [],
11479 "duplicate_routes": [],
11480 "route_catalog_version": GRAPH_READ_ROUTE_CATALOG_VERSION,
11481 "route_catalog_digest": graph_read_route_catalog_digest(),
11482 "route_coverage_ready": true,
11483 "route_coverage_blocker_codes": [],
11484 "evidence_route_coverage_present": true,
11485 "evidence_route_coverage_matches": true,
11486 "evidence_route_coverage_blocker_codes": [],
11487 "shadow_compare_route_count": REQUIRED_BOUNDED_READ_ROUTES.len(),
11488 "primary_ready_route_count": REQUIRED_BOUNDED_READ_ROUTES.len(),
11489 "query_runtime_route_count": REQUIRED_BOUNDED_READ_ROUTES.len(),
11490 "query_runtime_report_count": REQUIRED_BOUNDED_READ_ROUTES.len(),
11491 "query_runtime_plan_report_count": REQUIRED_BOUNDED_READ_ROUTES.len(),
11492 "query_runtime_profile_report_count": REQUIRED_BOUNDED_READ_ROUTES.len(),
11493 "query_runtime_api_behavior_report_count": REQUIRED_BOUNDED_READ_ROUTES.len(),
11494 "query_runtime_failed_query_count": 0,
11495 "query_runtime_missing_plan_evidence_count": 0,
11496 "query_runtime_missing_profile_evidence_count": 0,
11497 "relationship_property_pruning_required_count": 0,
11498 "relationship_property_pruning_report_count": 0,
11499 "missing_query_runtime_routes": [],
11500 "route_query_runtime_ready": true,
11501 "route_query_plan_evidence_ready": true,
11502 "route_query_profile_evidence_ready": true,
11503 "route_query_api_behavior_evidence_ready": true,
11504 "route_relationship_property_pruning_evidence_ready": true,
11505 "route_primary_ready": true,
11506 "route_primary_blocker_codes": [],
11507 "route_catalog": graph_read_route_specs_json(),
11508 "routes": ready_graph_route_profile_routes()
11509 });
11510 bundle["route_ownership"] = ready_route_ownership();
11511 bundle["search_route_ownership"] = ready_search_route_ownership();
11512 bundle["active_search_route_ownership"] = ready_active_search_route_ownership();
11513 bundle["active_search_route_readiness"] = ready_active_search_route_readiness();
11514 bundle["replacement_summary"]["search_route_ownership"] = ready_search_route_ownership();
11515 bundle["replacement_summary"]["active_search_route_ownership"] =
11516 ready_active_search_route_ownership();
11517 bundle["replacement_summary"]["active_search_route_readiness"] =
11518 ready_active_search_route_readiness();
11519 bundle["replacement_summary_search_route_ownership_alignment"] =
11520 ready_search_route_ownership_alignment();
11521 bundle["replacement_summary_active_search_route_ownership_alignment"] =
11522 ready_search_route_ownership_alignment();
11523 bundle["replacement_summary_active_search_route_readiness_alignment"] =
11524 ready_active_search_route_readiness_alignment();
11525 bundle["graph_route_parity_alignment"] = serde_json::json!({
11526 "ready": true,
11527 "required_route_count": REQUIRED_BOUNDED_READ_ROUTES.len(),
11528 "ready_route_count": REQUIRED_BOUNDED_READ_ROUTES.len(),
11529 "ready_routes": [
11530 "augmentation_state",
11531 "pagerank_plan",
11532 "overview",
11533 "graph_search",
11534 "explore",
11535 "expand",
11536 "live_preview",
11537 "live_preview_node",
11538 "node_details",
11539 "source_detail",
11540 "orphans",
11541 "shortest_path",
11542 "community_members",
11543 "community_subgraph",
11544 "community_recent_memories",
11545 "related_communities",
11546 "graph_analysis",
11547 "agent_evolves"
11548 ],
11549 "missing_routes": [],
11550 "not_ready_routes": [],
11551 "route_mismatch_routes": [],
11552 "protocol_mismatch_routes": [],
11553 "blocker_routes": [],
11554 "observed_blocker_codes": [],
11555 "blocker_codes": []
11556 });
11557 bundle["query_runtime_preflight"] = serde_json::json!({
11558 "protocol": "hawdb-nowledge-query-runtime-preflight-v1",
11559 "ready": true,
11560 "database_opened": true,
11561 "redaction": {
11562 "ready": true,
11563 "rows_copied": false,
11564 "parameters_copied": false,
11565 "local_paths_copied": false,
11566 "raw_errors_copied": false
11567 },
11568 "probe_count": REQUIRED_BOUNDED_READ_ROUTES.len(),
11569 "passed_probe_count": REQUIRED_BOUNDED_READ_ROUTES.len(),
11570 "failed_probe_count": 0,
11571 "required_route_count": REQUIRED_BOUNDED_READ_ROUTES.len(),
11572 "covered_route_count": REQUIRED_BOUNDED_READ_ROUTES.len(),
11573 "covered_routes": REQUIRED_BOUNDED_READ_ROUTES,
11574 "missing_required_routes": [],
11575 "required_routes_covered": true,
11576 "unknown_routes": [],
11577 "duplicate_routes": [],
11578 "route_catalog_version": GRAPH_READ_ROUTE_CATALOG_VERSION,
11579 "route_catalog_digest": graph_read_route_catalog_digest(),
11580 "route_coverage_ready": true,
11581 "route_coverage_blocker_codes": [],
11582 "blocker_codes": [],
11583 "probes": ready_query_runtime_preflight_probes()
11584 });
11585 let mut search_candidate_evidence = SearchCandidateShadowAccumulator::new();
11586 search_candidate_evidence.record_compare_candidate_ids(
11587 &["mem_1", "mem_2", "mem_3"],
11588 &["mem_1", "mem_2", "mem_3"],
11589 );
11590 search_candidate_evidence.record_filter_pushdown_fields(
11591 1,
11592 NOWLEDGE_SEARCH_PROJECTION_SCAN_FILTER_FIELDS
11593 .iter()
11594 .copied(),
11595 );
11596 bundle["search_candidate_shadow_evidence"] =
11597 search_candidate_shadow_evidence_json(&search_candidate_evidence.evidence());
11598 bundle["search_candidate_shadow_evidence"]["text_retriever_ready"] =
11599 serde_json::json!(true);
11600 bundle["search_candidate_shadow_evidence"]["vector_retriever_ready"] =
11601 serde_json::json!(true);
11602 bundle["search_candidate_shadow_evidence"]["retriever_leg_candidate_counts"] = serde_json::json!({
11603 "text": 3,
11604 "vector": 3,
11605 });
11606 bundle["search_candidate_shadow_evidence"]["fts_top_k_overlap_ready"] =
11607 serde_json::json!(true);
11608 bundle["search_candidate_shadow_evidence"]["vector_top_k_overlap_ready"] =
11609 serde_json::json!(true);
11610 bundle["search_candidate_shadow_evidence"]["top_k_overlap_observed"] = serde_json::json!({
11611 "fts": true,
11612 "vector": true,
11613 });
11614 bundle["search_candidate_shadow_evidence"]["candidate_readiness"] = serde_json::json!({
11615 "source_chunk_identity_ready": true,
11616 "fail_soft_observed": true,
11617 "projection_marker_status_visible": true,
11618 "projection_watermark_ready": true,
11619 "embedding_identity_ready": true,
11620 });
11621 bundle["library_readiness"] = ready_library_readiness();
11622 bundle["cutover_controls"] = ready_cutover_controls();
11623 bundle["operations_readiness"] = ready_operations_readiness();
11624 bundle["blackbox_manifest"] = ready_blackbox_manifest();
11625 bundle
11626 }
11627
11628 fn scan_filter_fields_json() -> serde_json::Value {
11629 serde_json::json!(NOWLEDGE_SEARCH_PROJECTION_SCAN_FILTER_FIELDS)
11630 }
11631
11632 fn ready_search_candidate_trace_evidence() -> serde_json::Value {
11633 serde_json::json!({
11634 "protocol": SEARCH_CANDIDATE_SHADOW_EVIDENCE_PROTOCOL,
11635 "route": SEARCH_CANDIDATE_EVIDENCE_ROUTE,
11636 "evidence_source": SEARCH_CANDIDATE_TRACE_EVIDENCE_SOURCE,
11637 "present": true,
11638 "ready": true,
11639 "reported_ready": true,
11640 "engine": SEARCH_CANDIDATE_SHADOW_ENGINE,
11641 "primary_engine": SEARCH_CANDIDATE_TRACE_PRIMARY_ENGINE,
11642 "shadow_engine": SEARCH_CANDIDATE_TRACE_SHADOW_ENGINE,
11643 "row_count_parity": true,
11644 "vector_top_k_overlap_ready": true,
11645 "fts_top_k_overlap_ready": true,
11646 "shadow_scan_present": true,
11647 "shadow_scan_filter_pushdown_ready": true,
11648 "shadow_scan_field_pruning_ready": true,
11649 "shadow_scan_field_summary_count": NOWLEDGE_SEARCH_PROJECTION_SCAN_FILTER_FIELDS.len(),
11650 "shadow_scan_input_predicate_count": NOWLEDGE_SEARCH_PROJECTION_SCAN_FILTER_FIELDS.len(),
11651 "shadow_scan_pushed_predicate_count": NOWLEDGE_SEARCH_PROJECTION_SCAN_FILTER_FIELDS.len(),
11652 "shadow_scan_residual_predicate_count": 0,
11653 "shadow_scan_filtered_out_count": 4,
11654 "shadow_scan_pruned_document_count": 2,
11655 "shadow_scan_scanned_document_count": 2,
11656 "shadow_scan_parse_error": null,
11657 "shadow_scan_unsatisfiable": false,
11658 "blocker_codes": []
11659 })
11660 }
11661
11662 fn scan_filter_field_summaries_json() -> serde_json::Value {
11663 serde_json::json!(NOWLEDGE_SEARCH_PROJECTION_SCAN_FILTER_FIELDS
11664 .iter()
11665 .copied()
11666 .chain(std::iter::once("document_id"))
11667 .map(|field| {
11668 serde_json::json!({
11669 "field": field,
11670 "segment_count": 1,
11671 "present_document_count": 1,
11672 "value_summary_used": true,
11673 "value_summary_segment_count": 1,
11674 "numeric_range_summary_used": matches!(field, "importance" | "confidence"),
11675 "numeric_range_segment_count": usize::from(matches!(
11676 field,
11677 "importance" | "confidence"
11678 )),
11679 "timestamp_range_summary_used": matches!(
11680 field,
11681 "created_at" | "updated_at" | "event_start" | "event_end"
11682 ),
11683 "timestamp_range_segment_count": usize::from(matches!(
11684 field,
11685 "created_at" | "updated_at" | "event_start" | "event_end"
11686 )),
11687 "unique_key_summary_used": field == "document_id",
11688 "unique_key_summary_segment_count": usize::from(field == "document_id"),
11689 })
11690 })
11691 .collect::<Vec<_>>())
11692 }
11693
11694 fn ready_route_ownership() -> serde_json::Value {
11695 route_ownership_readiness(
11696 &route_ownership_all_hawdb(),
11697 Some(&ready_route_readiness_summary()),
11698 RouteOwnershipPolicy::production_cutover(),
11699 )
11700 .json()
11701 }
11702
11703 fn ready_search_route_ownership() -> serde_json::Value {
11704 search_route_ownership_readiness(
11705 &search_route_ownership_all_hawdb(),
11706 SearchRouteOwnershipPolicy::production_cutover(),
11707 )
11708 .json()
11709 }
11710
11711 fn ready_active_search_route_ownership() -> serde_json::Value {
11712 active_search_route_ownership_readiness(
11713 &active_search_route_ownership_all_hawdb(),
11714 SearchRouteOwnershipPolicy::production_cutover(),
11715 )
11716 .json()
11717 }
11718
11719 fn ready_active_search_route_readiness() -> serde_json::Value {
11720 active_search_route_readiness(
11721 &active_search_route_read_evidence_all_hawdb_ready(),
11722 SearchRouteOwnershipPolicy::production_cutover(),
11723 )
11724 .json()
11725 }
11726
11727 fn ready_search_route_ownership_alignment() -> serde_json::Value {
11728 serde_json::json!({
11729 "ready": true,
11730 "evidence_present": true,
11731 "summary_present": true,
11732 "protocol_matches": true,
11733 "ready_matches": true,
11734 "production_cutover_ready_matches": true,
11735 "require_all_hawdb_matches": true,
11736 "required_route_count_matches": true,
11737 "explicit_route_count_matches": true,
11738 "hawdb_route_count_matches": true,
11739 "lancedb_route_count_matches": true,
11740 "missing_required_routes_matches": true,
11741 "lancedb_routes_matches": true,
11742 "blocker_codes_match": true,
11743 "evidence_lancedb_routes": [],
11744 "summary_lancedb_routes": [],
11745 "blocker_codes": []
11746 })
11747 }
11748
11749 fn ready_active_search_route_readiness_alignment() -> serde_json::Value {
11750 serde_json::json!({
11751 "ready": true,
11752 "evidence_present": true,
11753 "summary_present": true,
11754 "protocol_matches": true,
11755 "ready_matches": true,
11756 "production_cutover_ready_matches": true,
11757 "require_all_hawdb_matches": true,
11758 "required_route_count_matches": true,
11759 "evidence_route_count_matches": true,
11760 "ready_route_count_matches": true,
11761 "hawdb_route_count_matches": true,
11762 "lancedb_handle_count_matches": true,
11763 "missing_required_routes_matches": true,
11764 "non_hawdb_routes_matches": true,
11765 "lancedb_handle_routes_matches": true,
11766 "candidate_not_ready_routes_matches": true,
11767 "candidate_identity_not_ready_routes_matches": true,
11768 "embedding_identity_not_ready_routes_matches": true,
11769 "zero_vector_semantics_not_ready_routes_matches": true,
11770 "cjk_tokenization_not_ready_routes_matches": true,
11771 "metadata_pushdown_not_ready_routes_matches": true,
11772 "ranking_window_not_ready_routes_matches": true,
11773 "ranking_not_ready_routes_matches": true,
11774 "fail_soft_not_ready_routes_matches": true,
11775 "fail_soft_reason_codes_not_ready_routes_matches": true,
11776 "repair_rebuild_markers_not_ready_routes_matches": true,
11777 "blocker_codes_match": true,
11778 "evidence_lancedb_handle_required_routes": [],
11779 "summary_lancedb_handle_required_routes": [],
11780 "blocker_codes": []
11781 })
11782 }
11783
11784 fn ready_route_readiness_summary() -> RouteReadinessSummary {
11785 RouteReadinessSummary {
11786 route_primary_ready: true,
11787 primary_ready_routes: REQUIRED_BOUNDED_READ_ROUTES
11788 .iter()
11789 .map(|route| (*route).to_string())
11790 .collect(),
11791 route_query_plan_evidence_ready: true,
11792 route_query_profile_evidence_ready: true,
11793 route_query_api_behavior_evidence_ready: true,
11794 relationship_property_pruning_required_count: 0,
11795 relationship_property_pruning_report_count: 0,
11796 route_relationship_property_pruning_evidence_ready: true,
11797 }
11798 }
11799
11800 fn ready_graph_route_profile_routes() -> Vec<serde_json::Value> {
11801 REQUIRED_BOUNDED_READ_ROUTES
11802 .iter()
11803 .map(|route| {
11804 let required_query_families =
11805 hawdb_route_ownership::graph::required_query_families_for_route(route);
11806 let query_family = required_query_families
11807 .first()
11808 .copied()
11809 .unwrap_or("memory_lookup");
11810 let spec = graph_read_route_spec(route).unwrap();
11811 serde_json::json!({
11812 "route": route,
11813 "owner": spec.owner.as_str(),
11814 "required_evidence_kind": spec.required_evidence_kind.as_str(),
11815 "stale_on_catalog_change": spec.stale_on_catalog_change,
11816 "shadow_compare_ready": true,
11817 "shadow_compare_evidence_source": "route_parity_evidence",
11818 "shadow_compare": {
11819 "source": "route_parity_evidence",
11820 "ready": true,
11821 "matched_per_million": 1000000,
11822 "primary_engine": "kuzu",
11823 "shadow_engine": "hawdb",
11824 "blocker_codes": [],
11825 "computed_blocker_codes": []
11826 },
11827 "primary_ready": true,
11828 "required_query_families": required_query_families,
11829 "computed_required_query_families": required_query_families,
11830 "query_family_blocker_codes": [],
11831 "query_runtime_ready": true,
11832 "query_report_count": 1,
11833 "query_runtime_report_count": 1,
11834 "query_runtime_plan_report_count": 1,
11835 "query_runtime_profile_report_count": 1,
11836 "query_runtime_failed_query_count": 0,
11837 "query_runtime_missing_plan_evidence_count": 0,
11838 "query_runtime_missing_profile_evidence_count": 0,
11839 "relationship_property_pruning_required_count": 0,
11840 "relationship_property_pruning_report_count": 0,
11841 "relationship_property_pruning_evidence_ready": true,
11842 "query_plan_evidence_ready": true,
11843 "query_profile_evidence_ready": true,
11844 "query_reports": [ready_graph_route_query_report(query_family)],
11845 "blocker_codes": []
11846 })
11847 })
11848 .collect()
11849 }
11850
11851 fn ready_query_runtime_preflight_probes() -> Vec<serde_json::Value> {
11852 REQUIRED_BOUNDED_READ_ROUTES
11853 .iter()
11854 .map(|route| {
11855 serde_json::json!({
11856 "name": format!("probe:{route}"),
11857 "route": route,
11858 "query_family": "memory_lookup",
11859 "ready": true,
11860 "success": true,
11861 "output_row_count": 1,
11862 "selected_plan_fingerprint": "IndexNodeSeek(1:m:6:Memory)",
11863 "selected_plan_operator_counts": {
11864 "IndexNodeSeek": 1,
11865 "ProjectExec": 1
11866 },
11867 "selected_plan_class_counts": {
11868 "access": 1,
11869 "relational": 1
11870 },
11871 "optimizer_decision_count": 2,
11872 "optimizer_rule_event_count": 1,
11873 "plan_cache_lookup": "miss",
11874 "plan_cache": {
11875 "lookup": "miss",
11876 "bypass_reason": null,
11877 "cacheable": true,
11878 "hit": false,
11879 "miss": true,
11880 "bypassed": false
11881 },
11882 "execution_profile": {
11883 "scan_pruning_report_count": 1,
11884 "pruned_scan_count": 1,
11885 "scan_pruning_reports": [
11886 {
11887 "target_kind": "node",
11888 "label_id": 1,
11889 "rel_type_id": null,
11890 "strategy": {
11891 "kind": "property_eq",
11892 "property": "id"
11893 },
11894 "pruned": true,
11895 "exact_empty": false,
11896 "candidate_count_before_pruning": 2,
11897 "pruned_candidate_count": 1,
11898 "candidate_count_before_filter": 1,
11899 "output_count": 1,
11900 "filtered_out_count": 0
11901 }
11902 ]
11903 },
11904 "blocker_codes": []
11905 })
11906 })
11907 .collect()
11908 }
11909
11910 fn ready_query_runtime_summary() -> serde_json::Value {
11911 serde_json::json!({
11912 "protocol": "hawdb-nowledge-query-runtime-preflight-v1",
11913 "present": true,
11914 "ready": true,
11915 "database_opened": true,
11916 "redaction": {
11917 "ready": true,
11918 "rows_copied": false,
11919 "parameters_copied": false,
11920 "local_paths_copied": false,
11921 "raw_errors_copied": false
11922 },
11923 "probe_count": REQUIRED_BOUNDED_READ_ROUTES.len(),
11924 "passed_probe_count": REQUIRED_BOUNDED_READ_ROUTES.len(),
11925 "failed_probe_count": 0,
11926 "required_route_count": REQUIRED_BOUNDED_READ_ROUTES.len(),
11927 "covered_route_count": REQUIRED_BOUNDED_READ_ROUTES.len(),
11928 "covered_routes": REQUIRED_BOUNDED_READ_ROUTES,
11929 "required_covered_routes": REQUIRED_BOUNDED_READ_ROUTES,
11930 "missing_required_routes": [],
11931 "required_routes_covered": true,
11932 "unknown_routes": [],
11933 "duplicate_routes": [],
11934 "route_coverage_ready": true,
11935 "route_coverage_blocker_codes": [],
11936 "probe_details_ready": true,
11937 "blocker_codes": []
11938 })
11939 }
11940
11941 fn ready_source_mutation_dual_write_readiness() -> serde_json::Value {
11942 serde_json::json!({
11943 "protocol": SOURCE_MUTATION_DUAL_WRITE_READINESS_PROTOCOL,
11944 "ready": true,
11945 "required_family_count": REQUIRED_SOURCE_MUTATION_FAMILIES.len(),
11946 "evidence_family_count": REQUIRED_SOURCE_MUTATION_FAMILIES.len(),
11947 "ready_family_count": REQUIRED_SOURCE_MUTATION_FAMILIES.len(),
11948 "missing_required_families": [],
11949 "unknown_families": [],
11950 "duplicate_families": [],
11951 "blocker_codes": []
11952 })
11953 }
11954
11955 fn ready_graph_route_query_report(query_family: &str) -> serde_json::Value {
11956 serde_json::json!({
11957 "query_name": "overview-memory-lookup",
11958 "query_index": 0,
11959 "query_family": query_family,
11960 "protocol": "hawdb-nowledge-mem-query-report-v1",
11961 "statement_kind": "match_return",
11962 "execution_path": "fast_path",
11963 "fast_path_selected": true,
11964 "slow_log_candidate": false,
11965 "physical_plan_captured": false,
11966 "elapsed_micros": 12,
11967 "physical_operator_counts_present": true,
11968 "optimizer_decision_count": 2,
11969 "optimizer_rule_event_count": 1,
11970 "scan_pruning_report_count": 1,
11971 "scan_pruning_reports_present": true,
11972 "scan_pruning_reports": [
11973 {
11974 "target_kind": "node",
11975 "label_id": 1,
11976 "rel_type_id": null,
11977 "strategy": {
11978 "kind": "property_eq",
11979 "property": "id"
11980 },
11981 "pruned": true,
11982 "exact_empty": false,
11983 "candidate_count_before_pruning": 2,
11984 "pruned_candidate_count": 1,
11985 "candidate_count_before_filter": 1,
11986 "output_count": 1,
11987 "filtered_out_count": 0
11988 }
11989 ],
11990 "plan_cache_lookup": "miss",
11991 "plan_cache": {
11992 "lookup": "miss",
11993 "cacheable": true,
11994 "hit": false,
11995 "miss": true,
11996 "bypassed": false
11997 },
11998 "ready": true,
11999 "blocker_codes": []
12000 })
12001 }
12002
12003 fn ready_library_readiness() -> serde_json::Value {
12004 serde_json::json!({
12005 "protocol": "hawdb-nowledge-mem-library-readiness-v1",
12006 "present": true,
12007 "ready": true,
12008 "mode": "shadow_read_only",
12009 "ready_area_count": 11,
12010 "blocked_area_count": 0,
12011 "blocker_codes": [],
12012 "redaction": {
12013 "ready": true,
12014 "query_text_copied": false,
12015 "parameters_copied": false,
12016 "local_paths_copied": false
12017 },
12018 "production_path": {
12019 "ready": true,
12020 "in_process": true,
12021 "cli_required": false,
12022 "env_control_plane_required": false,
12023 "spawned_helper_required": false
12024 },
12025 "open_report": {
12026 "protocol": "hawdb-nowledge-mem-open-report",
12027 "mode": "shadow_read_only",
12028 "graph_configured": true,
12029 "search_projection_configured": true,
12030 "compressed_vector_search_mode": "disabled",
12031 "graph_opened": true,
12032 "search_projection_opened": true
12033 },
12034 "graph": {
12035 "open": true,
12036 "mode": "shadow_read_only",
12037 "read_only": true
12038 },
12039 "readiness_by_area": {
12040 "graph": {
12041 "ready": true,
12042 "blocker_codes": []
12043 },
12044 "query": {
12045 "ready": true,
12046 "blocker_codes": []
12047 },
12048 "storage": {
12049 "ready": true,
12050 "blocker_codes": []
12051 },
12052 "background": {
12053 "ready": true,
12054 "blocker_codes": []
12055 },
12056 "query_family": {
12057 "ready": true,
12058 "blocker_codes": []
12059 },
12060 "graph_route": {
12061 "ready": true,
12062 "blocker_codes": []
12063 },
12064 "search_route_ownership": {
12065 "ready": true,
12066 "blocker_codes": []
12067 },
12068 "search_projection": {
12069 "ready": true,
12070 "blocker_codes": []
12071 },
12072 "search_projection_shadow": {
12073 "ready": true,
12074 "blocker_codes": []
12075 },
12076 "search_candidate_shadow": {
12077 "ready": true,
12078 "blocker_codes": []
12079 },
12080 "workload_fixture": {
12081 "ready": true,
12082 "blocker_codes": []
12083 }
12084 },
12085 "bounded_read_evidence": {
12086 "ready": true,
12087 "blocker_codes": []
12088 },
12089 "search_route_ownership": ready_search_route_ownership(),
12090 "active_search_route_ownership": ready_active_search_route_ownership(),
12091 "query_family_evidence": {
12092 "ready": true,
12093 "blocker_codes": []
12094 },
12095 "storage_recovery": {
12096 "ready": true,
12097 "blocker_codes": []
12098 },
12099 "background_maintenance": {
12100 "blocker_codes": []
12101 },
12102 "production_resource_profile": ready_production_resource_profile(),
12103 "search_projection_evidence": {
12104 "ready": true,
12105 "blocker_codes": []
12106 },
12107 "search_projection_shadow_evidence": {
12108 "ready": true,
12109 "blocker_codes": []
12110 }
12111 })
12112 }
12113
12114 fn ready_production_resource_profile() -> serde_json::Value {
12115 serde_json::json!({
12116 "protocol": hawdb_evidence::resource_profile::STORAGE_RESOURCE_PROFILE_PROTOCOL,
12117 "protocol_version": 2,
12118 "present": true,
12119 "resource_ready": true,
12120 "ready": true,
12121 "blocker_codes": [],
12122 "evidence_binding": {
12123 "identity": production_identity(),
12124 "generated_at_unix_seconds": 1
12125 },
12126 "expected_identity": production_identity(),
12127 "canonical_graph_commit_epoch": 42,
12128 "identity_matches_expected": true,
12129 "limits": {
12130 "min_canonical_artifact_bytes": 536870912u64,
12131 "max_steady_resident_bytes": 536870912u64,
12132 "max_peak_resident_bytes": 805306368u64,
12133 "max_total_page_faults": 1010,
12134 "max_minor_page_faults": 1000,
12135 "max_major_page_faults": 10,
12136 "max_intermediate_rows": 1000,
12137 "max_intermediate_payload_bytes": 1048576,
12138 "max_output_rows": 100,
12139 "max_output_payload_bytes": 1048576,
12140 "require_fully_streamed": true
12141 },
12142 "storage": {
12143 "durable": true,
12144 "out_of_core": true,
12145 "canonical_artifact_bytes": 1073741824u64,
12146 "canonical_exceeds_cache": true,
12147 "segment_cache_capacity_bytes": 67108864,
12148 "segment_cache_resident_bytes_after": 33554432,
12149 "delta_within_budget": true
12150 },
12151 "execution": {
12152 "fully_streamed": true,
12153 "start_resident_bytes": 251658240,
12154 "start_peak_resident_bytes": 377487360,
12155 "steady_resident_bytes": 268435456,
12156 "peak_resident_bytes": 402653184,
12157 "steady_resident_growth_bytes": 16777216,
12158 "lifetime_peak_resident_growth_bytes": 25165824,
12159 "total_page_faults": 100,
12160 "minor_page_faults": 100,
12161 "major_page_faults": 0,
12162 "metric_capabilities": {
12163 "resident_memory": true,
12164 "total_page_faults": true,
12165 "split_page_faults": true
12166 },
12167 "intermediate_rows": 200,
12168 "intermediate_payload_bytes": 524288,
12169 "output_rows": 100,
12170 "output_payload_bytes": 262144
12171 }
12172 })
12173 }
12174
12175 fn production_identity() -> serde_json::Value {
12176 serde_json::json!({
12177 "source_revision": "test-revision",
12178 "rust_toolchain": "test-toolchain",
12179 "target_os": "linux",
12180 "target_arch": "x86_64",
12181 "enabled_features": ["full-text-search", "vector-search"],
12182 "durable_format_version": 1,
12183 "schema_version": 1,
12184 "configuration_digest": "test-config",
12185 "deployment_profile": "production-replica",
12186 "dataset_fingerprint": "test-dataset",
12187 "canonical_graph_commit_epoch": 42,
12188 "policy_version": hawdb_evidence::PRODUCTION_QUALIFICATION_POLICY_VERSION
12189 })
12190 }
12191
12192 fn ready_cutover_controls() -> serde_json::Value {
12193 serde_json::json!({
12194 "protocol": CUTOVER_CONTROLS_PROTOCOL,
12195 "ready": true,
12196 "controls": {
12197 "graph_reads": "hawdb",
12198 "search_reads": "hawdb",
12199 "dual_writes": "enabled",
12200 "initial_import": "disabled",
12201 "projection_catch_up": "enabled"
12202 },
12203 "graph": {
12204 "read_selected_hawdb": true,
12205 "read_effective": true
12206 },
12207 "search": {
12208 "read_selected_hawdb": true,
12209 "read_effective": true
12210 },
12211 "work": {
12212 "dual_writes_enabled": true,
12213 "initial_import_enabled": false,
12214 "initial_import_inactive_for_cutover": true,
12215 "initial_import_cutover_catch_up_ready": false,
12216 "initial_import_safe_for_read_cutover": true,
12217 "projection_catch_up_enabled": true
12218 },
12219 "blocker_codes": [],
12220 "production_status": {
12221 "graph": {
12222 "hawdb_cutover_effective": true
12223 },
12224 "search": {
12225 "hawdb_cutover_effective": true
12226 },
12227 "blocker_codes": []
12228 },
12229 "redaction": {
12230 "query_text_copied": false,
12231 "parameters_copied": false,
12232 "local_paths_copied": false
12233 }
12234 })
12235 }
12236
12237 fn ready_operations_readiness() -> serde_json::Value {
12238 serde_json::json!({
12239 "protocol": OPERATIONS_READINESS_PROTOCOL,
12240 "present": true,
12241 "ready": true,
12242 "graph": {
12243 "open": true,
12244 "read_only": false,
12245 "commit_epoch": 7
12246 },
12247 "search_projection": {
12248 "open": true,
12249 "commit_lag": 0,
12250 "stale": false
12251 },
12252 "storage_lifecycle": {
12253 "ready": true,
12254 "action": "ready"
12255 },
12256 "readiness": {
12257 "storage_lifecycle_ready": true,
12258 "storage_recovery_ready": true,
12259 "slow_query_ready": true,
12260 "background_maintenance_ready": true
12261 },
12262 "blocker_codes": [],
12263 "redaction": {
12264 "query_text_copied": false,
12265 "parameters_copied": false,
12266 "local_paths_copied": false
12267 }
12268 })
12269 }
12270
12271 fn ready_blackbox_manifest() -> serde_json::Value {
12272 serde_json::json!({
12273 "protocol": "hawdb-blackbox-report-v1",
12274 "protocol_version": 1,
12275 "run_id": "integration-ready",
12276 "run_status": "completed",
12277 "exit_code": 0,
12278 "generated_unix_seconds": 1,
12279 "artifact_dir_present": true,
12280 "artifact_count": 3,
12281 "events_path": "events.jsonl",
12282 "artifacts": [
12283 ready_blackbox_slow_query_artifact(),
12284 ready_blackbox_background_maintenance_artifact(),
12285 {
12286 "name": "replacement-summary.json",
12287 "format": "json",
12288 "byte_len": 256,
12289 "checksum": 1,
12290 "json": {
12291 "parse_ready": true,
12292 "protocol": "hawdb-nowledge-replacement-summary",
12293 "ready": true,
12294 "blocker_codes": [],
12295 "blocking_categories": [],
12296 "failed_checks": [],
12297 "missing_evidence": [],
12298 "production_cutover_ready": true,
12299 "production_replacement_per_million": 1000000
12300 }
12301 }
12302 ],
12303 "redaction": {
12304 "raw_query_text_copied": false,
12305 "raw_parameters_copied": false,
12306 "raw_artifact_payloads_copied": false,
12307 "artifact_paths_are_relative": true
12308 }
12309 })
12310 }
12311
12312 fn ready_blackbox_slow_query_artifact() -> serde_json::Value {
12313 serde_json::json!({
12314 "name": "slow-query-log.jsonl",
12315 "format": "jsonl",
12316 "byte_len": 0,
12317 "checksum": 0,
12318 "jsonl": {
12319 "line_count": 0,
12320 "nonempty_line_count": 0
12321 }
12322 })
12323 }
12324
12325 fn ready_blackbox_background_maintenance_artifact() -> serde_json::Value {
12326 serde_json::json!({
12327 "name": "background-maintenance.json",
12328 "format": "json",
12329 "byte_len": 256,
12330 "checksum": 2,
12331 "json": {
12332 "parse_ready": true,
12333 "protocol": "hawdb-background-maintenance-report",
12334 "ready": true,
12335 "blocker_codes": []
12336 },
12337 "background_qos": {
12338 "protocol": "hawdb-background-maintenance-report",
12339 "ready": true,
12340 "total_candidates": 1,
12341 "admitted_count": 1,
12342 "deferred_count": 0,
12343 "rejected_count": 0,
12344 "executable_search_projection_graph_delta_count": 1,
12345 "admitted_search_projection_graph_delta_count": 1,
12346 "deferred_search_projection_graph_delta_count": 0,
12347 "rejected_search_projection_graph_delta_count": 0,
12348 "executable_search_projection_graph_delta_operations": 2,
12349 "admitted_search_projection_graph_delta_operations": 2,
12350 "max_search_projection_graph_delta_complete_through_graph_commit_epoch": 7,
12351 "memory_pressure_ready": true,
12352 "memory_budget_bytes": 4096,
12353 "estimated_memory_bytes": 1024,
12354 "blocker_codes": []
12355 }
12356 })
12357 }
12358
12359 fn unique_test_path(name: &str) -> PathBuf {
12360 let nanos = SystemTime::now()
12361 .duration_since(UNIX_EPOCH)
12362 .unwrap()
12363 .as_nanos();
12364 std::env::temp_dir().join(format!("hawdb-{name}-{nanos}"))
12365 }
12366}