Date: 2026-04-19 Status: Draft Deciders: pelikhan, Copilot
The pkg/workflow package accumulated near-duplicate expression-detection helpers across multiple files (dispatch_repository_validation.go, shell.go, safe_outputs_validation.go, templatables.go). Each file defined its own local boolean helpers for checking GitHub Actions ${{ ... }} expressions, with subtly different semantics (permissive marker checks vs. full containment checks vs. whole-string checks). Separately, pkg/cli maintained its own local version variable and an init() synchronization path that had to be manually kept in sync with the canonical version state in pkg/workflow. Both patterns violated the single-source-of-truth principle and created silent divergence risks.
We will centralize the three expression-detection predicates (hasExpressionMarker, containsExpression, isExpression) into pkg/workflow/expression_patterns.go and remove all per-file duplicates. We will also remove the local version variable and init() in pkg/cli/version.go, making cli.GetVersion() and cli.SetVersionInfo() thin delegators to the canonical workflow.GetVersion() / workflow.SetVersion() functions. Both changes enforce a single source of truth within their respective domains, eliminating the risk of semantic drift between helper copies.
Each file could retain its own inline helper, and a custom linter or grep-based CI check could be added to flag divergence. This approach avoids touching call sites and keeps the helpers co-located with their consumers. It was rejected because linting checks would detect drift only after it happens rather than preventing it structurally, and the helpers are small enough that centralization adds no meaningful indirection.
A new package (e.g., pkg/expressionutil) could expose the helpers, providing a fully independent import path. This was considered for its explicit package boundary, but rejected because the helpers are only used within pkg/workflow call sites, making an external package an overengineered abstraction. Keeping the helpers unexported (hasExpressionMarker, containsExpression, isExpression) in expression_patterns.go preserves encapsulation without adding an unnecessary dependency edge.
The pkg/cli version variable could have been kept but annotated with comments requiring manual sync with workflow.GetVersion(). This was rejected because documentation alone cannot enforce invariants. The actual synchronization logic (init() and local version variable) was already causing confusion; removing the indirection entirely is safer and simpler.
- Expression-check semantics are defined once; all call sites share the same behavior, eliminating silent divergence.
- Version state has a single owner (
pkg/workflow); the CLI layer is a transparent pass-through with no independent state to maintain. - Reduced surface area for future contributors who previously had to know which file's helper was the "correct" one.
- Test coverage can now target the helpers directly in
expression_patterns_test.goinstead of being spread across consumer tests.
- All call sites in
pkg/workflowmust be updated when helper semantics change; there is no local override capability per file. - The
expression_patterns.gofile is already large (regex patterns + helper functions); additional consolidation could make it a maintenance hotspot.
pkg/clibecomes a thin delegation layer with no independent business logic for version management; callers ofcli.GetVersion()andcli.SetVersionInfo()are unaffected at the API level.- New tests (
expression_patterns_test.go,version_test.go) were added to cover the consolidated logic and the delegation contract.
The key words MUST, MUST NOT, REQUIRED, SHALL, SHALL NOT, SHOULD, SHOULD NOT, RECOMMENDED, MAY, and OPTIONAL in this section are to be interpreted as described in RFC 2119.
- All GitHub Actions expression-detection predicates used within
pkg/workflowMUST be defined inpkg/workflow/expression_patterns.go. - Individual
pkg/workflowsource files MUST NOT define their own local boolean helpers that check for${{or}}patterns. - The three canonical helpers MUST provide the following distinct semantics:
hasExpressionMarker(s string) bool— returnstrueifscontains the substring${{(permissive, partial-expression check).containsExpression(s string) bool— returnstrueifscontains a complete non-empty expression (a${{followed by at least one character before}}).isExpression(s string) bool— returnstrueif the entire stringsis a single expression (starts with${{and ends with}}).
- Callers MUST select the helper whose semantics match their intent; using
hasExpressionMarkerwherecontainsExpressionorisExpressionis needed (or vice versa) constitutes non-conformance. - New expression-detection predicates SHOULD be added to
expression_patterns.gorather than introduced inline in consumer files.
pkg/cliMUST NOT maintain its own local version variable or aninit()function that synchronizes version state frompkg/workflow.cli.GetVersion()MUST delegate directly toworkflow.GetVersion()with no local caching or transformation.cli.SetVersionInfo(v string)MUST delegate directly toworkflow.SetVersion(v)with no local storage.- All version state MUST be owned exclusively by
pkg/workflow;pkg/cliMAY expose wrapper functions for backwards-compatible API surface but MUST NOT shadow or duplicate the underlying state.
An implementation is considered conformant with this ADR if it satisfies all MUST and MUST NOT requirements above. Failure to meet any MUST or MUST NOT requirement — in particular, defining expression-detection helpers outside expression_patterns.go or maintaining independent version state in pkg/cli — constitutes non-conformance.
This is a DRAFT ADR generated by the Design Decision Gate workflow. The PR author must review, complete, and finalize this document before the PR can merge.