refactor(policies): expose project context via input.chainloop_metadata#3100
Open
migmartri wants to merge 1 commit intochainloop-dev:mainfrom
Open
refactor(policies): expose project context via input.chainloop_metadata#3100migmartri wants to merge 1 commit intochainloop-dev:mainfrom
migmartri wants to merge 1 commit intochainloop-dev:mainfrom
Conversation
Replaces the bctx.Context-based propagation introduced in chainloop-dev#3094 with an input-level injection: the rego engine now merges project_name / project_version_name into input.chainloop_metadata at evaluation time, so policy authors can read them from input and forward them as operands to chainloop.* built-ins. The previous context-based plumbing had no consumers — built-ins receive operands and context but do not read input directly, and the EE built-ins that will consume project scope are expected to take it as part of their request payload. Exposing the values on input is the simpler contract: authors see and pass the values explicitly, mirroring how chainloop.discover already reads input.chainloop_metadata.digest. Refs chainloop-dev#3090 Assisted-by: Claude Code Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces the
bctx.Context-based project context plumbing introduced in #3094 with input-level injection. The rego engine now mergesproject_name/project_version_nameintoinput.chainloop_metadataat evaluation time, so policy authors can read them from input and forward them as operands tochainloop.*built-ins:The previous
bctx.Contextmechanism had no consumers in the codebase — built-ins receive operands plus context but do not readinput, and the EE built-ins that will consume project scope take it as part of their request payload. Exposing the values oninputis the simpler contract: authors see and pass the values explicitly, mirroring howchainloop.discoveralready readsinput.chainloop_metadata.digest.The public API (
engine.WithProjectContext,policies.WithProjectContext, crafter wiring, and thechainloop policy develop eval--project/--project-versionflags) is unchanged. Existing keys oninput.chainloop_metadata(e.g. the intoto descriptor populated for materials) are preserved.Refs #3090
Test plan
go test ./pkg/policies/...(370 tests)chainloop policy develop eval --policy <p> --material <m> --kind <k> --project demo --project-version v1.2.3and confirm a policy readinginput.chainloop_metadata.project_namesees the value alongside the existing material descriptor fields