Skip to content

feat: template success/failure conditions in verification specs from dispatch context#884

Merged
adityachoudhari26 merged 3 commits intomainfrom
claude/issue-876-20260328-2109
Mar 29, 2026
Merged

feat: template success/failure conditions in verification specs from dispatch context#884
adityachoudhari26 merged 3 commits intomainfrom
claude/issue-876-20260328-2109

Conversation

@adityachoudhari26
Copy link
Copy Markdown
Member

@adityachoudhari26 adityachoudhari26 commented Mar 29, 2026

resolves #876

Summary by CodeRabbit

  • New Features

    • Verification metric success and failure conditions now support template variable rendering using dispatch context (e.g., {{ .resource.name }}, {{ .environment.name }}). Dispatch now applies templating to verification specs before proceeding and surfaces templating errors.
  • Tests

    • Added unit tests covering templating behavior, nil/empty cases, and failure-condition handling.

github-actions bot and others added 2 commits March 28, 2026 21:14
…dispatch context

Applies Go template rendering to SuccessCondition and FailureCondition
fields in VerificationMetricSpec before verifications are created,
using the job's DispatchContext as template data. This allows conditions
like `result.json.name == "{{ .resource.name }}"` to reference release
target attributes at dispatch time.

Closes #876

Co-authored-by: Aditya Choudhari <adityachoudhari26@users.noreply.github.com>
@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ adityachoudhari26
❌ github-actions[bot]
You have signed the CLA already but the status is still pending? Let us recheck it.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 29, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 9ffc485c-faea-4ad3-a70a-3a2ff6f40ac8

📥 Commits

Reviewing files that changed from the base of the PR and between b3168c1 and 37b3529.

📒 Files selected for processing (2)
  • apps/workspace-engine/svc/controllers/jobdispatch/reconcile_test.go
  • apps/workspace-engine/svc/controllers/jobdispatch/verification/template.go
✅ Files skipped from review due to trivial changes (1)
  • apps/workspace-engine/svc/controllers/jobdispatch/verification/template.go

📝 Walkthrough

Walkthrough

Added templating of verification metric spec conditions: reconciliation now templates each spec's SuccessCondition and optional FailureCondition using DispatchContext data before dispatch; template errors are returned early.

Changes

Cohort / File(s) Summary
Templating Implementation
apps/workspace-engine/svc/controllers/jobdispatch/verification/template.go, apps/workspace-engine/svc/controllers/jobdispatch/verification/template_test.go
New TemplateSpecs function that renders Go templates found in SuccessCondition and FailureCondition using dispatchCtx.Map(). Includes renderString helper and tests covering templating, nil dispatch context, nil/empty specs, and nil failure condition.
Reconciliation Integration
apps/workspace-engine/svc/controllers/jobdispatch/reconcile.go, apps/workspace-engine/svc/controllers/jobdispatch/reconcile_test.go
Calls verification.TemplateSpecs after merging/deduplicating policySpecs and agentSpecs; reconciliation returns early on templating errors. Added test validating template rendering of {{ .resource.name }} from DispatchContext.

Sequence Diagram(s)

sequenceDiagram
    participant Reconciler as Reconciler
    participant Template as verification.TemplateSpecs
    participant Dispatcher as Job Dispatcher / Setter

    Reconciler->>Reconciler: merge & dedupe specs
    Reconciler->>Template: TemplateSpecs(specs, dispatchCtx)
    alt templating succeeds
        Template-->>Reconciler: rendered specs
        Reconciler->>Dispatcher: CreateVerifications(rendered specs)
    else templating fails
        Template-->>Reconciler: error
        Reconciler-->>Reconciler: return early with error
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I stitch conditions with a twitch of my paw,
Templates unfurl where the dispatch context saw.
Names and envs bloom from placeholders small,
Verifications sing once the renderings fall. 🎋

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title clearly and concisely describes the main change: adding template support for success/failure conditions in verification specs using dispatch context data.
Linked Issues check ✅ Passed The PR implements the core requirement from issue #876: verification specs now support templatable success and failure conditions that can reference release-target-specific attributes (via dispatch context) at dispatch time.
Out of Scope Changes check ✅ Passed All changes directly support the templating feature: the new TemplateSpecs function, integration in Reconcile, and comprehensive test coverage with no unrelated modifications.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/issue-876-20260328-2109

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@adityachoudhari26 adityachoudhari26 merged commit 801d39d into main Mar 29, 2026
9 of 10 checks passed
@adityachoudhari26 adityachoudhari26 deleted the claude/issue-876-20260328-2109 branch March 29, 2026 19:02
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.

support templatable success and failure conditions for verification spec

2 participants