Pass a runtime context to additional context resolvers

What does this MR do and why?

A foundational flow builds its extra context from the resource only, such as the merge request. The Business Logic Security Scan also needs the project, the goal and the branch the run checks out, so today it builds its context in a separate code path.

This MR gives every flow's context resolver a small runtime context that carries the project, the resource, the goal and that branch. The existing flows still read only the resource, so what they send does not change.

References

  • Prepares !263674 (merged), which moves the BL security scan context onto this.

Screenshots or screen recordings

Not applicable. There is no UI change.

How to set up and validate locally

The context that the flows send stays the same. To see this with Code Review:

  1. In GDK, make sure Code Review Flow is on for gitlab-duo/test.

  2. Create a merge request in gitlab-duo/test, and assign the Duo Code Review bot as a reviewer.

  3. Open the CI job of the review session. In a Rails console, read the Code Review envelope that the job got:

    build = Ci::Build.find(<job_id>)
    context = Gitlab::Json.parse(build.variables.to_hash['DUO_WORKFLOW_ADDITIONAL_CONTEXT_CONTENT'])
    context.find { |c| c['Category'] == 'agent_platform_code_review_context' }

    Its content has duo_code_review_bot_name set to the review bot's username, the same as on master.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Merge request reports

Loading
Loading