Skip to content

design: feature-gated write-mode#678

Open
cdoan1 wants to merge 3 commits into
openshift-online:mainfrom
cdoan1:ROSAENG-61570-design
Open

design: feature-gated write-mode#678
cdoan1 wants to merge 3 commits into
openshift-online:mainfrom
cdoan1:ROSAENG-61570-design

Conversation

@cdoan1

@cdoan1 cdoan1 commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

doc design for feature-gated write-mode from just visibility

Summary by CodeRabbit

  • Documentation
    • Added a new design proposal for feature-gated write-mode behavior.
    • Describes per-feature-set write-mode overrides, including marker syntax and examples.
    • Covers backward-compatibility guidance and planned validation/testing scenarios for different feature enablement outcomes.

cdoan1 and others added 2 commits July 9, 2026 09:28
Add design document for extending the marker system to support
feature-set-specific write-mode overrides. This enables gradual
rollout of customer control over sensitive fields by allowing
different write modes (mutable/immutable/service-set) per feature
set (Default/TechPreview/DevPreview).

Addresses use cases like making etcd config service-set for
production but mutable for TechPreview customers.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@openshift-ci

openshift-ci Bot commented Jul 9, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign adamminter for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

This PR adds a design document for feature-gate-aware write-mode overrides, including marker syntax, FieldMeta shape changes, implementation phases, and migration guidance. No code or exported entities change.

Changes

Design Proposal

Layer / File(s) Summary
Feature-gated write-mode design document
docs/design/feature-gated-write-mode-design.md
Defines the marker syntax, proposes FeatureGateAwareWriteModes on FieldMeta, outlines parsing/registry/validation/test phases, and includes migration notes, examples, alternatives, and open questions.

Estimated code review effort: 1 (Trivial) | ~5 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately summarizes the main change: a design doc for feature-gated write-mode.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
docs/design/feature-gated-write-mode-design.md (1)

1-9: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Reframe this as an ADR.

docs/design/** is supposed to use ADR format, but this reads more like a proposal summary. Please add explicit Context / Decision / Consequences sections so the chosen syntax and rollout trade-offs are easy to review and maintain.

As per path instructions, docs/design/**: Review design decisions for ADR format compliance. Ensure decisions are well-justified and align with the regional architecture goals.

🤖 Prompt for 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.

In `@docs/design/feature-gated-write-mode-design.md` around lines 1 - 9, Reframe
the document headed by Feature-Gated Write-Mode Control into ADR format instead
of a proposal summary. Update the top-level structure in this design doc to
include explicit Context, Decision, and Consequences sections, and move the
current problem statement and review details into the appropriate ADR sections.
Keep the description centered on the chosen syntax and rollout trade-offs so the
decision is easy to review and maintain.

Source: Path instructions

🤖 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 `@docs/design/feature-gated-write-mode-design.md`:
- Around line 110-119: The parser loop that builds gatedModes from
writeModeGatedPattern currently overwrites earlier entries when the same
featureSet appears more than once, which makes comment order affect the result.
Update the parsing logic around the gatedModes map population to detect
duplicate featureSet keys and return a parse error instead of assigning the
later WriteMode, then only assign meta.GatedWriteModes when the collected
entries are unique.
- Around line 174-201: The proposed validator test matrix only covers Default
and TechPreview, so it does not verify the documented base-mode fallback for an
unspecified feature set. Update TestValidator_GatedWriteMode in the
feature-gated write mode design tests to include a DevPreview or equivalent
non-overridden FeatureSet case for spec.etcd, and assert the expected write
behavior there. Keep the existing ServiceSet/Default and TechPreview coverage,
but add this fallback case so the validator logic cannot accidentally inherit
the wrong override.

---

Nitpick comments:
In `@docs/design/feature-gated-write-mode-design.md`:
- Around line 1-9: Reframe the document headed by Feature-Gated Write-Mode
Control into ADR format instead of a proposal summary. Update the top-level
structure in this design doc to include explicit Context, Decision, and
Consequences sections, and move the current problem statement and review details
into the appropriate ADR sections. Keep the description centered on the chosen
syntax and rollout trade-offs so the decision is easy to review and maintain.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: dd287bc9-fcda-48f9-b10c-256d2f737a0b

📥 Commits

Reviewing files that changed from the base of the PR and between 942b09d and f16b4da.

📒 Files selected for processing (1)
  • docs/design/feature-gated-write-mode-design.md

Comment thread docs/design/feature-gated-write-mode-design.md Outdated
Comment thread docs/design/feature-gated-write-mode-design.md
cdoan1 pushed a commit to cdoan1/hyperfleet-api-codegen that referenced this pull request Jul 9, 2026
Incorporated feedback from ROSAENG-61570 Jira comments and Slack discussion:

**Key Changes:**

1. **Marker Syntax** - Changed from bracket syntax to OpenShift multi-argument pattern:
   - Before: `+hyperfleet:write-mode[FeatureSetName]=mutable`
   - After: `+hyperfleet:validation:FeatureGateAwareWriteMode:featureGate="GateName",writeMode="mutable"`
   - Follows existing patterns: FeatureGateAwareEnum, FeatureGateAwareXValidation

2. **Primary Use Case** - Clarified that write-mode control works independently of feature gating:
   - GA fields (no FeatureGate marker) can use it for customer-tier control
   - Example: Standard customers get immutable, Premium customers get mutable
   - Not limited to fields behind feature gates

3. **Data Model** - Changed from map to slice:
   - Before: `GatedWriteModes map[string]WriteMode`
   - After: `FeatureGateAwareWriteModes []FeatureGateWriteMode`
   - Preserves marker order, supports empty-string default

4. **Validation Logic** - Updated to check customer's enabled feature gates:
   - Request needs `EnabledFeatureGates []string` field
   - Validation checks if specific gate is enabled for customer
   - Priority: specific gate match > default ("") > base WriteMode

**New Examples:**
- GA field with customer-tier control (no FeatureGate required)
- Progressive write-mode rollout for gated fields
- Multiple gate-based overrides

**Feedback Source:**
- Jira: https://redhat.atlassian.net/browse/ROSAENG-61570
- Slack: https://redhat-internal.slack.com/archives/C0A819QK7M5/p1783585582976459
- PR reference: openshift-online/rosa-hyperfleet#678

**Open Questions:**
- Marker namespace choice
- Multiple-gate priority behavior
- Customer gate enablement mechanism

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Major revisions based on Slack/Jira feedback:

- Change marker syntax from bracket notation to follow OpenShift
  conventions: +hyperfleet:validation:FeatureGateAwareWriteMode
- Clarify primary use case: GA fields with customer-tier control,
  not just gated fields
- Update data model to use list of FeatureGateWriteMode instead of map
- Add validation logic for checking customer's enabled feature gates
- Include detailed feedback section documenting design evolution
- Add more comprehensive examples covering GA and gated fields

References OpenShift patterns: FeatureGateAwareEnum and
FeatureGateAwareXValidation for multi-argument marker syntax.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
docs/design/feature-gated-write-mode-design.md (1)

183-189: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Keep the generated overrides ordered end-to-end.

map[string]string drops declaration order and conflicts with the earlier list-based FeatureGateAwareWriteModes model. That makes precedence depend on serialization rather than the marker order the spec promises.

Suggested shape
-    GatedWriteModes map[string]string  // NEW
+    GatedWriteModes []FeatureGateWriteMode
🤖 Prompt for 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.

In `@docs/design/feature-gated-write-mode-design.md` around lines 183 - 189, The
new GatedWriteModes field on templateField should preserve marker order instead
of using a map, because map[string]string loses declaration order and breaks the
intended precedence from FeatureGateAwareWriteModes. Update the templateField
shape and any related generation logic to use an ordered list or slice-based
structure, and make sure the code that builds and consumes GatedWriteModes in
the feature-gated write mode flow keeps overrides in the same end-to-end order
as the source markers.
🤖 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 `@docs/design/feature-gated-write-mode-design.md`:
- Around line 401-403: Define a deterministic precedence rule for multiple
enabled gates in the feature-gated write-mode design, instead of selecting the
first specific match in source order. Update the multi-gate behavior guidance in
the design doc to state an explicit priority based on write-mode specificity or
permissiveness, and reference the write-mode selection logic consistently so
reordering annotations cannot change the outcome.
- Around line 414-417: The customer gate enablement section currently presents
an explicit Platform API request parameter as a viable option, but gate
membership must be derived server-side from trusted auth or subscription state.
Update the design in the “Customer gate enablement” discussion to remove or
clearly reject Option C, and emphasize using the request auth/authorization
context or subscription lookup as the source of truth in the relevant design
section.

---

Outside diff comments:
In `@docs/design/feature-gated-write-mode-design.md`:
- Around line 183-189: The new GatedWriteModes field on templateField should
preserve marker order instead of using a map, because map[string]string loses
declaration order and breaks the intended precedence from
FeatureGateAwareWriteModes. Update the templateField shape and any related
generation logic to use an ordered list or slice-based structure, and make sure
the code that builds and consumes GatedWriteModes in the feature-gated write
mode flow keeps overrides in the same end-to-end order as the source markers.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 2a82349b-ef75-4318-ad35-1fcbf80d027e

📥 Commits

Reviewing files that changed from the base of the PR and between f16b4da and c3135ec.

📒 Files selected for processing (1)
  • docs/design/feature-gated-write-mode-design.md

Comment on lines +401 to +403
2. **Multiple gate behavior**: If a customer has multiple gates enabled, which write-mode wins?
- **Recommendation**: First specific match in marker order (earliest in source code)
- **Alternative**: Most permissive (mutable > immutable > service-set)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Pin down multi-gate precedence.

“First specific match in source order” makes the effective write-mode change when annotations are reordered or reformatted. Please define a deterministic precedence rule instead of relying on comment order.

🤖 Prompt for 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.

In `@docs/design/feature-gated-write-mode-design.md` around lines 401 - 403,
Define a deterministic precedence rule for multiple enabled gates in the
feature-gated write-mode design, instead of selecting the first specific match
in source order. Update the multi-gate behavior guidance in the design doc to
state an explicit priority based on write-mode specificity or permissiveness,
and reference the write-mode selection logic consistently so reordering
annotations cannot change the outcome.

Comment on lines +414 to +417
6. **Customer gate enablement**: How do we determine which gates are enabled for a customer at runtime?
- **Option A**: Lookup from database based on subscription tier
- **Option B**: Include in request authentication/authorization context
- **Option C**: Explicit parameter in Platform API request

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

sed -n '390,440p' docs/design/feature-gated-write-mode-design.md

Repository: openshift-online/rosa-hyperfleet

Length of output: 3096


🏁 Script executed:

sed -n '404,430p' docs/design/feature-gated-write-mode-design.md

Repository: openshift-online/rosa-hyperfleet

Length of output: 1846


🏁 Script executed:

rg -n "Option C|gate membership|subscription tier|authentication/authorization context|request parameter" docs/design/feature-gated-write-mode-design.md

Repository: openshift-online/rosa-hyperfleet

Length of output: 524


🏁 Script executed:

sed -n '368,420p' docs/design/feature-gated-write-mode-design.md

Repository: openshift-online/rosa-hyperfleet

Length of output: 2622


Keep gate membership server-side
Option C should not be used as-is: if enabled gates come from a request parameter, callers can self-assert entitlement and bypass write-mode checks. Derive gate membership from trusted auth/subscription state instead.

🤖 Prompt for 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.

In `@docs/design/feature-gated-write-mode-design.md` around lines 414 - 417, The
customer gate enablement section currently presents an explicit Platform API
request parameter as a viable option, but gate membership must be derived
server-side from trusted auth or subscription state. Update the design in the
“Customer gate enablement” discussion to remove or clearly reject Option C, and
emphasize using the request auth/authorization context or subscription lookup as
the source of truth in the relevant design section.

// Override: mutable when MyPremiumFeature gate is enabled
// +hyperfleet:write-mode=immutable
// +hyperfleet:validation:FeatureGateAwareWriteMode:featureGate="",writeMode="immutable"
// +hyperfleet:validation:FeatureGateAwareWriteMode:featureGate="MyPremiumFeature",writeMode="mutable"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

featureGate is a tag/label/flag that is linked with the AWS account level, right?

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.

2 participants