diff --git a/benchmark/results/perf_owned_metadata_fallback_20261005/receiving.json b/benchmark/results/perf_owned_metadata_fallback_20261005/receiving.json new file mode 100644 index 0000000000..4a1cc56423 --- /dev/null +++ b/benchmark/results/perf_owned_metadata_fallback_20261005/receiving.json @@ -0,0 +1,43 @@ +{ + "state": "TERMINAL_PASS_PARITY_NO_END_TO_END_GAIN_ESTABLISHED", + "source_head": "8bb40a7463b6a2467639f3fec1a010e46792c073", + "candidate_scope": "source_metadata.py only; owned no-op component support and ordered literal namespace", + "ordinary": { + "baseline": { + "ExampleIlluminationCorrection_Example3": { + "compile_seconds": 0.23293828964233398, + "execute_seconds": 0.2601172924041748, + "total_seconds": 0.5862254430539906 + }, + "cp_tutorial_3d_monolayer": { + "compile_seconds": 0.5136797428131104, + "execute_seconds": 3.7792391777038574, + "total_seconds": 4.465305561665446 + } + }, + "candidate": { + "ExampleIlluminationCorrection_Example3": { + "compile_seconds": 0.23083734512329102, + "execute_seconds": 0.25908708572387695, + "total_seconds": 0.5919077293947339 + }, + "cp_tutorial_3d_monolayer": { + "compile_seconds": 0.5079293251037598, + "execute_seconds": 4.038333892822266, + "total_seconds": 4.701046504080296 + } + } + }, + "science": "4/4 strict comparisons PASS against retained qualified native, matching existing authoritative headless pipeline patches", + "limits": [ + "One ordinary pair, not a variability estimate or causal regression attribution.", + "Server/registry/kernel startup excluded.", + "Candidate 3D processing-contract union rose about289ms while server execution rose259ms; no end-to-end improvement observed.", + "13-cohort metadata-only replay saves10.270ms; no extrapolation to entire pipeline." + ], + "post_receiving_main_sync": { + "base": "2bd9fa473", + "change": "Spreadsheet source-provenance export fix #734; no source_metadata.py changes", + "validation": "44 existing spreadsheet export controls PASS after merge; no repeated pipeline observation" + } +} diff --git a/openhcs/core/source_metadata.py b/openhcs/core/source_metadata.py index dcca01fbc3..4a330990cb 100644 --- a/openhcs/core/source_metadata.py +++ b/openhcs/core/source_metadata.py @@ -223,20 +223,30 @@ def provenance_identity_items( lambda: tuple((key, repr(value)) for key, value in cls.identity_items(metadata)), ) - @classmethod + @staticmethod def literal_value( - cls, metadata: SourceMetadataMapping, key: str + metadata: SourceMetadataMapping, key: str ) -> SourceMetadataScalar: + if isinstance(metadata, SourceMetadataFields): + return metadata._literal_value(key) + return SourceMetadataFields._literal_value(metadata, key) + + def _literal_value(self, key: str) -> SourceMetadataScalar: # Preserve the existing lookup's role-validation order even when the # requested literal could be read without the original metadata role. - scalars = cls.scalar_items(metadata) - original = cls.original_items(metadata) + scalars = SourceMetadataFields.scalar_items(self) + original = SourceMetadataFields.original_items(self) for fields in (original, scalars): for candidate_key, value in fields: if str(candidate_key) == key and value is not None: return value return None + @property + def _admitted_components_complete(self) -> bool: + """Whether retained, already demanded views cover every component slot.""" + return False + @classmethod def literal_field_types( cls, metadata_records: Iterable[SourceMetadataMapping] @@ -386,7 +396,13 @@ def with_missing_from( ) -> SourceMetadataMapping: merged: dict[str, SourceMetadataValue] | None = None current = metadata - for component in AllComponents: + components = ( + () + if isinstance(metadata, SourceMetadataFields) + and metadata._admitted_components_complete + else AllComponents + ) + for component in components: if cls.component_value(current, component) is not None: continue value = cls.component_value(fallback, component) @@ -523,6 +539,28 @@ def _derived_view( self._views[key] = derive() return self._views[key] + @property + def _admitted_components_complete(self) -> bool: + return self._cacheable and all( + self._views.get(component) is not None for component in AllComponents + ) + + def _literal_value(self, key: str) -> SourceMetadataScalar: + if not self._cacheable: + return super()._literal_value(key) + + def project() -> dict[str, SourceMetadataScalar]: + scalars = SourceMetadataFields.scalar_items(self) + original = SourceMetadataFields.original_items(self) + values: dict[str, SourceMetadataScalar] = {} + for fields in (original, scalars): + for name, value in fields: + if value is not None: + values.setdefault(str(name), value) + return values + + return self._derived_view("literal_values", project).get(key) + def _readonly_snapshot(self) -> SourceMetadataMapping: return self