Skip to content

Conversation

@joshua-zivkovic
Copy link

@joshua-zivkovic joshua-zivkovic commented Jan 7, 2026

Towards #2069

This PR changes the approach to how buildstream handles source provenance information, moving from a hard coded implementation of attributes (which buildstream core needs to know nothing about) to a more generic, user defined approach where buildstream only needs to carry the values to the next step.

Users can now define their projects allowed set of source provenance attributes using the source_provenance_fields key in the project.conf. Where attributes are used in source provenance but not defined in the project.conf, buildstream will refuse attribute and throw an error informing the user that the attribute is not present in the project.conf

Currently there is no limitation on these values since neither plugins nor buildstream sbom are yet using this approach so there is no defined set of attributes plugins and users should refer to but this will soon be added to buildstream-sbom as it will depend on what buildstream-sbom supports for SPDX generation.

@joshua-zivkovic joshua-zivkovic force-pushed the JZ/source-provenance branch 3 times, most recently from d18f672 to 6894c4f Compare January 8, 2026 14:13
Comment on lines 932 to 939
def load_source_provenance(self, node: MappingNode) -> None:
raise ImplError("Source plugin '{}' does not implement load_source_provenance()".format(self.get_kind()))

def get_source_provenance(self) -> SourceProvenance:
raise ImplError("Source plugin '{}' does not implement get_source_provenance()".format(self.get_kind()))

def set_source_provenance(self, source_provenance: SourceProvenance):
raise ImplError("Source plugin '{}' does not implement set_source_provenance()".format(self.get_kind()))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To retain backward compatibility, we can't require source plugins to implement these methods. I.e., we need (trivial) default implementations for any method that is called unconditionally by the core. API documentation will be required as well, of course.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's easy enough if we just go with a "do nothing" implementation

def set_source_provenance(self, source_provenance: SourceProvenance):
raise ImplError("Source plugin '{}' does not implement set_source_provenance()".format(self.get_kind()))

def track(self, *, previous_sources_dir: Optional[str] = None) -> (SourceRef, SourceProvenance):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to find a way to allow returning a SourceProvenance without breaking API.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, that might be more difficult to work out. I'll see if I can work something sensible out

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now I've gone with combining the old and new return signatures (https://github.com/apache/buildstream/pull/2099/files#diff-48200ef302e5d841cce81834e8879a65e59db922a22605b9d7fa16b4dd5c7067R941) and added some logic to unpackage it appropriately (https://github.com/apache/buildstream/pull/2099/files#diff-48200ef302e5d841cce81834e8879a65e59db922a22605b9d7fa16b4dd5c7067R1811). I believe that's all that's required to not break the API here

@joshua-zivkovic joshua-zivkovic force-pushed the JZ/source-provenance branch 2 times, most recently from 0453ec5 to 81eb24a Compare January 9, 2026 11:34
This allows multi-source source plugins to provide this information per
source rather than as a singular top level.

This is done by adding a `provenance_node` parameter to
`create_source_info()` that when specified overrides the use of the
source's top level source provenance info.

Co-authored-by: Joshua Zivkovic <joshua.zivkovic@codethink.co.uk>
@joshua-zivkovic joshua-zivkovic force-pushed the JZ/source-provenance branch 2 times, most recently from bb44761 to e9491c3 Compare January 12, 2026 15:01
Remove harcoded SPDX attributes and make them be generic instead.
Project allowed attributes are configured via the project config,
these supported values a determined by buildstream-sbom's support

Co-authored-by: Jürg Billeter <j@bitron.ch>
Co-authored-by: Joshua Zivkovic <joshuazivkovic@codethink.co.uk>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants