Skip to content

feat: scaffold OpenFeature Go SDK feature-flag support#146

Merged
devantler merged 2 commits into
mainfrom
claude/openfeature-scaffold
Jul 6, 2026
Merged

feat: scaffold OpenFeature Go SDK feature-flag support#146
devantler merged 2 commits into
mainfrom
claude/openfeature-scaffold

Conversation

@devantler

Copy link
Copy Markdown
Contributor

🤖 Generated by the Daily AI Assistant

Why

The Go template ships no feature-flag scaffolding, so every service generated from it starts without a standard way to land features behind a flag — the opposite of the portfolio-wide feature-flag-first delivery direction.

What

Wires the portable OpenFeature Go SDK as the standard flag API in a small, replaceable pkg/featureflag package: an example feature gated default-off, with tests covering both states. Ships with an in-memory provider so it works out of the box; a real service swaps in flagd or a managed backend without touching call sites. AGENTS.md documents the convention and the mandatory flag lifecycle (release flags are removed after rollout). Dependency footprint stays minimal.

Fixes #145
Part of devantler-tech/monorepo#2059

Wire the portable OpenFeature Go SDK (v1.17.2, GA) in pkg/featureflag as
the standard runtime flag API so services generated from the template can
land every feature behind a flag, default-off, per the feature-flag-first
delivery convention. Ships the in-memory provider (example evaluates with
no backend; swap for flagd/a managed backend in a real service), one
example flag gating a sample path, and a table-driven test asserting both
states plus the missing-flag default-off safety. AGENTS.md documents the
convention + mandatory flag lifecycle; the SDK is the single allowance in
depguard's strict allow-list, the rest of the non-test scaffold stays
stdlib-only.

Fixes #145
Part of devantler-tech/monorepo#2059

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This pull request adds a feature-flag-first scaffold for Go templates. It introduces pkg/featureflag with an OpenFeature in-memory provider, a client constructor, a boolean helper that defaults off on missing or failed evaluations, and an example feature branch. It also updates go.mod and .golangci.yml for the OpenFeature SDK, adds table-driven tests for enabled, disabled, and absent flags, and documents the convention in AGENTS.md and README.md.

Changes

Related issues: #145

Suggested labels: enhancement, dependencies, documentation

Suggested reviewers: devantler

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant ExampleFeature
  participant Enabled
  participant OpenFeatureClient
  participant InMemoryProvider

  Caller->>ExampleFeature: ExampleFeature(ctx, client)
  ExampleFeature->>Enabled: Enabled(ctx, client, ExampleFlag)
  Enabled->>OpenFeatureClient: Boolean(ctx, ExampleFlag, false, ...)
  OpenFeatureClient->>InMemoryProvider: evaluate flag
  InMemoryProvider-->>OpenFeatureClient: variant value
  OpenFeatureClient-->>Enabled: boolean result
  Enabled-->>ExampleFeature: true/false
  ExampleFeature-->>Caller: "new feature output" or "default output"
Loading

Poem
A rabbit hops with flags in tow,
Default off, but ready to grow.


Caution

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

  • Ignore

❌ Failed checks (1 error)

Check name Status Explanation Resolution
Linked Issues check ❌ Error Most requirements are met, but #145 also asks for a flagd provider stub, which is not present in the changes. Add a flagd provider stub aligned with the platform layer, or document and implement the issue's provider requirement explicitly.
✅ Passed checks (4 passed)
Check name Status Explanation
Out of Scope Changes check ✅ Passed The changes stay focused on feature-flag scaffolding, docs, and dependency setup with no clear unrelated additions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title clearly matches the main change: scaffolding OpenFeature-based feature-flag support.
Description check ✅ Passed The description is directly related to the changeset and accurately explains the feature-flag scaffold and docs updates.

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

coderabbitai[bot]
coderabbitai Bot previously requested changes Jul 6, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@AGENTS.md`:
- Around line 93-105: The feature-flag guidance only documents the OpenFeature
path and is missing the CLI-only exception for lightweight static boolean flags.
Update the AGENTS.md guidance near the feature-flag section to explicitly
mention the cobra Hidden / --experimental route, and clarify that templates
needing only static CLI gating should use that dependency-free approach instead
of the OpenFeature SDK. Refer to the feature-flag-first delivery section and its
package guidance so the exception is clearly tied to the existing flag policy.

In `@README.md`:
- Line 12: The README feature-flag bullet only mentions the OpenFeature SDK
flow; update that bullet to also mention the non-SDK Cobra path using the Hidden
or --experimental option so readers understand when a generated CLI can stay
dependency-free. Keep the existing Feature-flag-first entry in the README, but
expand its wording to cover both the pkg/featureflag/OpenFeature approach and
the cobra Hidden/--experimental alternative.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 62ba90e6-d6cd-47cf-83e3-81f91a9b978a

📥 Commits

Reviewing files that changed from the base of the PR and between f06c9c1 and 3417964.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (6)
  • .golangci.yml
  • AGENTS.md
  • README.md
  • go.mod
  • pkg/featureflag/featureflag.go
  • pkg/featureflag/featureflag_test.go
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • devantler-tech/actions (auto-detected)
📜 Review details
⏰ Context from checks skipped due to timeout. (1)
  • GitHub Check: zizmor
🧰 Additional context used
📓 Path-based instructions (3)
{go.mod,.github/workflows/copilot-setup-steps.yml,README.md}

📄 CodeRabbit inference engine (AGENTS.md)

Do not hard-code a second Go version elsewhere; copilot-setup-steps.yml must read the version from go.mod, and the README should refer to go.mod instead of duplicating the floor.

Files:

  • README.md
  • go.mod
pkg/featureflag/**/*.go

📄 CodeRabbit inference engine (AGENTS.md)

New features should be guarded behind pkg/featureflag.Enabled, default to the old path when the flag is off or errors, and include table-driven tests covering both enabled and disabled states.

Files:

  • pkg/featureflag/featureflag_test.go
  • pkg/featureflag/featureflag.go
go.mod

📄 CodeRabbit inference engine (AGENTS.md)

Keep the Go minimum version in go.mod as the single source of truth, and raise it only when a shared tooling requirement or security/EOL reason forces it.

Files:

  • go.mod
🔇 Additional comments (7)
.golangci.yml (1)

38-41: LGTM!

pkg/featureflag/featureflag.go (4)

1-32: LGTM!


40-57: LGTM!


59-70: LGTM!


72-89: LGTM!

pkg/featureflag/featureflag_test.go (1)

1-52: LGTM! Table-driven subtests correctly cover enabled, disabled, and absent-flag default-off states, and per-subtest unique domain names avoid provider registration collisions under t.Parallel().

go.mod (1)

4-10: 🗄️ Data Integrity & Integration

Check the go directive against the new SDK’s Go 1.24 floor. github.com/open-feature/go-sdk v1.17.2 requires Go 1.24, so go.mod should still be the single source of truth for the minimum supported version.

Comment thread AGENTS.md
Comment thread README.md Outdated
Address CodeRabbit: issue #145 asks for CLI experimental-flag guidance too.
Document that the OpenFeature SDK is for services needing runtime evaluation,
while a generated CLI should stay dependency-free by gating experimental
commands behind cobra Hidden + an --experimental opt-in, reaching for the SDK
only when richer evaluation is needed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@devantler

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

🤖 Generated by the Daily AI Assistant

@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown

@devantler I'll review the changes now.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@devantler devantler marked this pull request as ready for review July 6, 2026 22:14
@devantler devantler requested a review from a team as a code owner July 6, 2026 22:14
@devantler devantler dismissed coderabbitai[bot]’s stale review July 6, 2026 23:14

Superseded: every requested change was addressed in a80f196 (concrete memprovider return + un-inlined error + CLI experimental-flag guidance in AGENTS.md/README) and all review threads are resolved. CodeRabbit's subsequent reviews on the current head are COMMENTED-only with no new change requests. Dismissing this stale review from commit 3417964.

@devantler devantler merged commit ae2af32 into main Jul 6, 2026
10 checks passed
@devantler devantler deleted the claude/openfeature-scaffold branch July 6, 2026 23:15
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.

feat: scaffold OpenFeature Go SDK feature-flag support (+ CLI experimental-flag guidance)

1 participant