Add conditional rule logic for first-time contributors
Summary
Add conditional rule logic to Watchflow to apply stricter checks for first-time contributors. First-time contributors (users with no prior merged PRs) often need additional scrutiny, but applying the same rules to all contributors can create friction for newcomers.
Motivation
- First-time contributors may not be familiar with project conventions
- Additional validation (tests, docs, changelog) helps maintain quality
- Stricter rules for newcomers reduces risk of unexpected issues
- However, over-restricting can discourage contributions
Proposed Solution
Add conditional logic to the rule engine that allows rules to be applied only when certain conditions are met. For example:
Use Cases
-
First-time contributor checks
rules: - name: Require Changelog condition: contributor.is_first_time - name: Require Tests condition: contributor.pr_count == 0 - name: Require Description condition: contributor.pr_count < 3 -
File-pattern based rules
- Only require tests for sensitive paths (e.g.,
src/auth/) for external contributors
- Only require tests for sensitive paths (e.g.,
-
Team-specific rules
- Only apply certain checks for external collaborators
- Relaxed rules for core team members
Proposed Implementation
Add a condition field to rules in rules.yaml:
rules:
- name: Require Changelog
condition: contributor.pr_count == 0 or files.match("src/auth/**")
parameters:
changelog_required: true
Available Conditions
contributor.pr_count— Number of merged PRs by the contributorcontributor.is_first_time— Shorthand forcontributor.pr_count == 0contributor.trusted— User has merged PRs or is a CODEOWNERfiles.match(pattern)— Changed files match glob patternrisk.level— PR risk assessment level
Technical Approach
- Add a
contributorcontext to the evaluation pipeline - Parse
conditionin rules.yaml as an expression - Evaluate condition before applying the rule
- If condition is false, skip the rule (log at debug level)
Benefits
- Flexibility — Tailor rules to contributor experience level
- Lower barrier — First-time contributors know exactly what's expected
- Reduced friction — Core team members don't get blocked by basic requirements
References
- GitHub's first-time contributor indicator: https://docs.github.com/en/pull-requests/committing-changes-to-your-project/creating-and-working-with-webhooks/pulling-external-changes
- Related: Watchflow's
/reviewersand/riskcommands that already assess contributor history
Hey @dkargatzis, I'd love to take this on.
This is a substantial feature, so I'd like to break it into incremental PRs rather than one large delivery:
PR 1 (v1) — Structured when: block with named predicates
when:
contributor: first_time # or trusted, or pr_count_below: 3
files_match: "src/auth/**"
No expression parser — just named predicates that cover the issue's core use cases.
Deliverables:
ContributorContextfetched in the enricher viaGET /search/issues?q=is:pr+author:X+is:merged+repo:owner/repo(cached per evaluation)when:block on the rule model + loader- Rule engine skips the rule when
whenevaluates false - Unit tests for each predicate and the skip path
PR 2 — Expression parser
- Replace the structured
when:block with a proper expression evaluator supportingand/or/==/</> - Security-safe (no arbitrary
eval), probably a small recursive descent parser - Enables:
condition: contributor.pr_count < 3 and files.match("src/auth/**")
PR 3 — Extended predicates
risk.levelcondition tied to existing/riskcommandcontributor.rolefor team-specific rules (CODEOWNER, collaborator, external)- Composite use cases from the issue (team-specific rules, file-pattern + contributor combos)
Two questions before I start:
- Does the structured
when:approach work for v1, or do you want the expression parser from the start? - Is the search API acceptable for PR count, or would you prefer a persistent store?
Hey @codesensei-tushar, great breakdown! Love the incremental approach.
Answers to your questions:
-
Structured
when:for v1 — keeps it simple and covers the main use cases. We can add expression parser in v2 once the foundation is solid. -
Search API for v1 — acceptable for the MVP. We can add a persistent store later if the search API becomes a bottleneck. Persistence will be a Warestack Enterprise ready feature (Redis, Postgres, Pgvector are already part of our core stack).
One suggestion for PR 1:
Add a reason field to the skip log so it's clear why a rule was skipped:
DEBUG Rule "Require Changelog" skipped: contributor is not first-time
Approved to start. Let me know when you open the first PR.
Btw, are you open to a quick sync to discuss the feature in more detail? Always good to align early.
Side note on persistence: We're keeping Watchflow's self-hosted setup minimal (no mandatory persistence layer) to keep it easy to deploy. If you have ideas on how to bundle everything together for users who want persistence, I'd be happy to discuss — could be a good architecture conversation.
Thanks @dkargatzis — all clear. PR 1 will open it soon with the reason field included. As you said, we can layer in persistence if the Search API becomes a bottleneck the codebase already has a TTL cache pattern that'd be a natural first step.
Would love to sync — happy to work around your schedule. The persistence architecture discussion would be a great learning experience for me, especially around how the self-hosted and enterprise sides connect. Looking forward to it.
@codesensei-tushar book a time slot that works best for you - looking forward to discussing further, shaping the direction of Watchflow, and potentially getting you involved with Warestack!