@@ -57,6 +57,7 @@ class ColibriProvider:
5757 setup_path : Path
5858 build_cwd : Path
5959 build_argv : tuple [str , ...]
60+ build_compatibility : dict [str , str ] | None
6061 validation_steps : tuple [dict [str , Any ], ...]
6162 plan_args : tuple [str , ...]
6263 doctor_args : tuple [str , ...]
@@ -145,6 +146,51 @@ def load_colibri_catalog(
145146 isinstance (item , str ) and item for item in build_argv
146147 ):
147148 raise ColibriCatalogError ("Colibri build argv is invalid" )
149+ build_compatibility = raw .get ("build_compatibility" )
150+ normalized_compatibility : dict [str , str ] | None = None
151+ if build_compatibility is not None :
152+ if not isinstance (build_compatibility , dict ):
153+ raise ColibriCatalogError (
154+ "Colibri build compatibility must be an object"
155+ )
156+ compatibility_id = str (build_compatibility .get ("id" ) or "" )
157+ compatibility_commit = str (
158+ build_compatibility .get ("source_commit" ) or ""
159+ )
160+ compatibility_path = str (build_compatibility .get ("path" ) or "" )
161+ compatibility_before = str (build_compatibility .get ("before" ) or "" )
162+ compatibility_after = str (build_compatibility .get ("after" ) or "" )
163+ if not re .fullmatch (
164+ r"[a-z0-9][a-z0-9.-]*" , compatibility_id
165+ ):
166+ raise ColibriCatalogError (
167+ "Colibri build compatibility id is invalid"
168+ )
169+ if not re .fullmatch (r"[0-9a-f]{40}" , compatibility_commit ):
170+ raise ColibriCatalogError (
171+ "Colibri build compatibility commit must be pinned"
172+ )
173+ _safe_relative (
174+ source_root ,
175+ compatibility_path ,
176+ "build_compatibility.path" ,
177+ )
178+ if (
179+ not compatibility_before
180+ or not compatibility_after
181+ or compatibility_before == compatibility_after
182+ ):
183+ raise ColibriCatalogError (
184+ "Colibri build compatibility replacement is invalid"
185+ )
186+ normalized_compatibility = {
187+ "id" : compatibility_id ,
188+ "source_commit" : compatibility_commit ,
189+ "path" : compatibility_path ,
190+ "before" : compatibility_before ,
191+ "after" : compatibility_after ,
192+ "reason" : str (build_compatibility .get ("reason" ) or "" ),
193+ }
148194 model_variants = raw .get ("model_variants" )
149195 if not isinstance (model_variants , list ) or not model_variants :
150196 raise ColibriCatalogError ("Colibri model variants are required" )
@@ -284,6 +330,7 @@ def load_colibri_catalog(
284330 source_root , raw ["build_cwd" ], "build_cwd"
285331 ),
286332 build_argv = tuple (build_argv ),
333+ build_compatibility = normalized_compatibility ,
287334 validation_steps = tuple (normalized_validation ),
288335 plan_args = tuple (str (item ) for item in raw .get ("plan_args" ) or []),
289336 doctor_args = tuple (
@@ -337,6 +384,9 @@ def _git(provider: ColibriProvider) -> dict[str, Any]:
337384 "commit" : None ,
338385 "origin" : None ,
339386 "dirty" : False ,
387+ "dirty_paths" : [],
388+ "unexpected_dirty" : False ,
389+ "unexpected_dirty_paths" : [],
340390 "minimum_commit_present" : False ,
341391 "upstream_commit" : None ,
342392 "ahead" : 0 ,
@@ -371,17 +421,43 @@ def _git(provider: ColibriProvider) -> dict[str, Any]:
371421 ).split ()
372422 if len (counts ) == 2 and all (item .isdigit () for item in counts ):
373423 ahead , behind = (int (item ) for item in counts )
374- dirty = bool (
375- _run (
424+ try :
425+ status_result = subprocess . run (
376426 [
377427 "git" ,
378428 "-C" ,
379429 str (root ),
380430 "status" ,
381- "--porcelain" ,
431+ "--porcelain=v1 " ,
382432 "--untracked-files=all" ,
383- ]
433+ ],
434+ capture_output = True ,
435+ text = True ,
436+ check = False ,
437+ timeout = 8 ,
384438 )
439+ status = (
440+ status_result .stdout if status_result .returncode == 0 else ""
441+ )
442+ except (OSError , subprocess .TimeoutExpired ):
443+ status = ""
444+ dirty_paths = []
445+ for line in status .splitlines ():
446+ value = line [3 :] if len (line ) > 3 else ""
447+ if " -> " in value :
448+ value = value .rsplit (" -> " , 1 )[- 1 ]
449+ if value :
450+ dirty_paths .append (value .strip ('"' ))
451+ expected_dirty_paths = {
452+ str (provider .engine_path .relative_to (provider .source_root )),
453+ str (
454+ (provider .build_cwd / ".ulysses-build.json" ).relative_to (
455+ provider .source_root
456+ )
457+ ),
458+ }
459+ unexpected_dirty_paths = sorted (
460+ set (dirty_paths ) - expected_dirty_paths
385461 )
386462 minimum_present = True
387463 if provider .minimum_commit :
@@ -410,7 +486,10 @@ def _git(provider: ColibriProvider) -> dict[str, Any]:
410486 "branch" : branch or None ,
411487 "commit" : commit or None ,
412488 "origin" : origin or None ,
413- "dirty" : dirty ,
489+ "dirty" : bool (dirty_paths ),
490+ "dirty_paths" : sorted (set (dirty_paths )),
491+ "unexpected_dirty" : bool (unexpected_dirty_paths ),
492+ "unexpected_dirty_paths" : unexpected_dirty_paths ,
414493 "minimum_commit_present" : minimum_present ,
415494 "upstream_commit" : upstream_commit or None ,
416495 "ahead" : ahead ,
@@ -651,6 +730,8 @@ def _validate_build_manifest(
651730 source_commit : str | None ,
652731 build_config : str ,
653732) -> tuple [bool , list [str ]]:
733+ from src .ulysses_colibri_build import compatibility_manifest
734+
654735 if not isinstance (manifest , dict ):
655736 return False , ["build manifest is missing or unreadable" ]
656737 expected = {
@@ -660,6 +741,7 @@ def _validate_build_manifest(
660741 "source_branch" : provider .source_branch ,
661742 "source_commit" : source_commit ,
662743 "build_argv" : list (provider .build_argv ),
744+ "build_compatibility" : compatibility_manifest (provider ),
663745 "validation_steps" : list (provider .validation_steps ),
664746 "build_config" : build_config or None ,
665747 "engine_path" : str (provider .engine_path ),
@@ -742,13 +824,26 @@ def observe_colibri_provider(provider: ColibriProvider) -> dict[str, Any]:
742824 source_ready = provenance_ready and bool (git ["current" ])
743825 built = provider .engine_path .is_file ()
744826 cuda_built = built and ("CUDA=1" in build_config or "CUDA=ON" in build_config )
827+ required_build_flags = [
828+ item
829+ for item in provider .build_argv
830+ if item in {"CUDA=1" , "CUDA=ON" , "IOURING=1" }
831+ ]
832+ missing_build_flags = [
833+ item for item in required_build_flags if item not in build_config
834+ ]
745835 manifest_valid , manifest_reasons = _validate_build_manifest (
746836 provider ,
747837 build_manifest ,
748838 source_commit = git .get ("commit" ),
749839 build_config = build_config ,
750840 )
751- build_ready = built and cuda_built and manifest_valid
841+ build_ready = (
842+ built
843+ and cuda_built
844+ and not missing_build_flags
845+ and manifest_valid
846+ )
752847 prerequisites = _build_prerequisites (provider )
753848 running = health is not None and provider .model_id in served_ids
754849 collision = port_open and health is None
@@ -774,13 +869,24 @@ def observe_colibri_provider(provider: ColibriProvider) -> dict[str, Any]:
774869 ),
775870 }
776871 )
777- if git .get ("dirty " ):
872+ if git .get ("unexpected_dirty " ):
778873 findings .append (
779874 {
780875 "code" : f"{ provider .provider_id } .source_dirty" ,
781876 "severity" : "warning" ,
782877 "summary" : "Colibri source contains local changes." ,
783- "evidence" : str (provider .source_root ),
878+ "evidence" : ", " .join (
879+ git .get ("unexpected_dirty_paths" ) or [str (provider .source_root )]
880+ ),
881+ }
882+ )
883+ elif git .get ("dirty" ):
884+ findings .append (
885+ {
886+ "code" : f"{ provider .provider_id } .build_output_modified" ,
887+ "severity" : "info" ,
888+ "summary" : "Tracked upstream engine contains the local CUDA build." ,
889+ "evidence" : ", " .join (git .get ("dirty_paths" ) or []),
784890 }
785891 )
786892 if git ["present" ] and (git .get ("ahead" ) or git .get ("behind" )):
@@ -826,6 +932,15 @@ def observe_colibri_provider(provider: ColibriProvider) -> dict[str, Any]:
826932 "evidence" : "; " .join (manifest_reasons ),
827933 }
828934 )
935+ if built and missing_build_flags :
936+ findings .append (
937+ {
938+ "code" : f"{ provider .provider_id } .build_flags_missing" ,
939+ "severity" : "error" ,
940+ "summary" : "Colibri build is missing required native features." ,
941+ "evidence" : ", " .join (missing_build_flags ),
942+ }
943+ )
829944 if not prerequisites ["ready" ]:
830945 findings .append (
831946 {
@@ -865,6 +980,8 @@ def observe_colibri_provider(provider: ColibriProvider) -> dict[str, Any]:
865980 "cuda_built" : cuda_built ,
866981 "ready" : build_ready ,
867982 "build_config" : build_config or None ,
983+ "required_flags" : required_build_flags ,
984+ "missing_flags" : missing_build_flags ,
868985 "cwd" : str (provider .build_cwd ),
869986 "argv" : list (provider .build_argv ),
870987 "manifest_path" : str (manifest_path ),
0 commit comments