@@ -474,23 +474,33 @@ def _dolt_evidence_block(
474474def _capture_dolt_state (
475475 connection : Any , * , profile_name : str , audit_relations : set [str ],
476476) -> dict [str , Any ] | None :
477- """Capture the Dolt working-set identity without mutating it."""
478- del audit_relations
477+ """Capture and classify the Dolt working set without mutating it."""
478+ audit_relations = { str ( name ) for name in audit_relations }
479479 if profile_name != "dolt" :
480480 return None
481481 identity = connection .exec_driver_sql (
482482 "SELECT DATABASE() AS database_name, ACTIVE_BRANCH() AS active_branch, "
483483 "DOLT_HASHOF('HEAD') AS head_hash"
484484 ).mappings ().one ()
485+ status_rows = connection .exec_driver_sql (
486+ "SELECT table_name, staged, status FROM dolt_status "
487+ "ORDER BY table_name, staged, status"
488+ ).mappings ().all ()
485489 state = {
486490 "database" : str (identity ["database_name" ]).strip (),
487491 "active_branch" : str (identity ["active_branch" ]).strip (),
488492 "head" : str (identity ["head_hash" ]).strip (),
489493 "status" : _dolt_evidence_block (
490- connection .exec_driver_sql (
491- "SELECT table_name, staged, status FROM dolt_status "
492- "ORDER BY table_name, staged, status"
493- ).mappings ().all (),
494+ status_rows , expected_keys = ("table_name" , "staged" , "status" ),
495+ ),
496+ "diff_summaries" : {},
497+ }
498+ unrelated = {
499+ "status" : _dolt_evidence_block (
500+ (
501+ row for row in status_rows
502+ if str (dict (row ).get ("table_name" ) or "" ) not in audit_relations
503+ ),
494504 expected_keys = ("table_name" , "staged" , "status" ),
495505 ),
496506 "diff_summaries" : {},
@@ -500,18 +510,33 @@ def _capture_dolt_state(
500510 ("head_to_staged" , "HEAD" , "STAGED" ),
501511 ("staged_to_working" , "STAGED" , "WORKING" ),
502512 ):
513+ rows = connection .exec_driver_sql (
514+ "SELECT from_table_name, to_table_name, diff_type, "
515+ "data_change, schema_change "
516+ f"FROM DOLT_DIFF_SUMMARY('{ left } ', '{ right } ') "
517+ "ORDER BY from_table_name, to_table_name, diff_type"
518+ ).mappings ().all ()
519+ expected_keys = (
520+ "from_table_name" , "to_table_name" , "diff_type" ,
521+ "data_change" , "schema_change" ,
522+ )
503523 state ["diff_summaries" ][label ] = _dolt_evidence_block (
504- connection .exec_driver_sql (
505- "SELECT from_table_name, to_table_name, diff_type, "
506- "data_change, schema_change "
507- f"FROM DOLT_DIFF_SUMMARY('{ left } ', '{ right } ') "
508- "ORDER BY from_table_name, to_table_name, diff_type"
509- ).mappings ().all (),
510- expected_keys = (
511- "from_table_name" , "to_table_name" , "diff_type" ,
512- "data_change" , "schema_change" ,
524+ rows , expected_keys = expected_keys ,
525+ )
526+ unrelated ["diff_summaries" ][label ] = _dolt_evidence_block (
527+ (
528+ row for row in rows
529+ if not {
530+ str (value ) for value in (
531+ dict (row ).get ("from_table_name" ),
532+ dict (row ).get ("to_table_name" ),
533+ ) if value
534+ } <= audit_relations
513535 ),
536+ expected_keys = expected_keys ,
514537 )
538+ state ["unrelated_working_set" ] = unrelated
539+ state ["unrelated_sha256" ] = _canonical_sha256 (unrelated )
515540 state ["snapshot_sha256" ] = _canonical_sha256 (state )
516541 return state
517542
@@ -545,9 +570,11 @@ def _require_dolt_success_identity(
545570 return
546571 if before is None or after is None or any (
547572 before [key ] != after [key ] for key in ("database" , "active_branch" , "head" )
548- ):
573+ ) or (
574+ "unrelated_sha256" in before or "unrelated_sha256" in after
575+ ) and before .get ("unrelated_sha256" ) != after .get ("unrelated_sha256" ):
549576 raise UnsupportedOperationError (
550- f"Dolt database/branch/HEAD changed during { phase } ."
577+ f"Dolt identity or unrelated working-set state changed during { phase } ."
551578 )
552579
553580
@@ -676,10 +703,7 @@ def initialize_wide_catalog(
676703 )
677704 engine = create_engine (database_url )
678705 normative = normative_catalog (MetaData ())
679- audit_relations = {
680- normative .fidelity_event .name ,
681- normative .operation .name ,
682- }
706+ audit_relations = {table .name for table in normative .all ()}
683707 with _bound_catalog_transaction (
684708 engine = engine , profile_name = profile .name , active = active ,
685709 audit_relations = audit_relations , phase = "catalog initialization" ,
@@ -780,10 +804,7 @@ def create_wide_dataset(
780804 )
781805 engine = create_engine (database_url )
782806 normative = normative_catalog (MetaData ())
783- audit_relations = {
784- normative .fidelity_event .name ,
785- normative .operation .name ,
786- }
807+ audit_relations = {table .name for table in normative .all ()}
787808 with _bound_catalog_transaction (
788809 engine = engine , profile_name = profile .name , active = active_connection ,
789810 audit_relations = audit_relations , phase = "catalog initialization" ,
@@ -851,7 +872,7 @@ def create_wide_dataset(
851872 namespace_owned = True
852873 with _bound_catalog_transaction (
853874 engine = engine , profile_name = profile .name , active = active_connection ,
854- audit_relations = audit_relations , phase = "import" ,
875+ audit_relations = { * audit_relations , data_table . name } , phase = "import" ,
855876 ) as connection :
856877 if connection .execute (
857878 select (normative .dataset .c .dataset_id ).where (or_ (
0 commit comments