Designing governance layers
I'm gearing up to create a governance layer that spans across services. First, I’ll structure the design with elements like naming conventions and a metadata schema. I'll also need to consider the lifecycle of flags, approval workflows, rollout analytics, and a kill switch for orchestration.
It's essential to mention architecture choices such as a central flag service and roles. I plan to include guidelines, examples, and implementation steps while ensuring that everything works smoothly in a multi-tenant environment. I’ll write this out in markdown, aiming for a moderately detailed explanation.
1) Goals & non-goals
Goals
- Consistent, searchable, non-colliding feature flags across many services and teams.
- Guardrails: approvals, audits, safe rollout patterns, and fast kill-switches.
- Observability: who changed what, what it impacted, and when to remove flags.
- Developer ergonomics: simple SDK usage, clear docs, and minimal runtime overhead.
Non-goals
- Replacing product experimentation platforms (A/B testing, statistical analysis) unless explicitly desired.
- Centralizing business logic; flags should gate existing behavior, not implement it.
2) Governance architecture (recommended baseline)
Components
-
Flag Registry (central service + UI)
- Source of truth for flag definitions, metadata, owners, approvals, and lifecycle state.
- Stores immutable audit history (append-only event log).
-
Evaluation Plane
- Option A: Central evaluation (SDK calls registry at runtime)
Simple but adds latency/availability coupling.
- Option B (recommended): Edge/local evaluation
Services/clients fetch signed flag “snapshots” (JSON) periodically; SDK evaluates locally.
- Very low latency, resilient during registry outages.
- Rollouts still controlled centrally via snapshot generation.
-
Policy/Approval Engine
- Enforces rules (who can create/modify/enable; required approvals; change windows; risk tiers).
-
Telemetry Pipeline
- Emits flag exposure + decision + context (redacted/hashed) to analytics/observability stack.
-
Kill-switch Orchestrator
- A “break glass” path that overrides normal workflows with an emergency policy.
Data model (minimum metadata)
Each flag should store:
key (unique), description (behavioral), owner_team, repo_links, service_scope
created_by, created_at, last_modified_by, last_modified_at
lifecycle_state: proposed | active | deprecated | retired
flag_type: release | ops | experiment | permission | kill_switch
default_value + allowed values (boolean, enum, int)
targeting_rules (segments), rollout_plan (phases), risk_tier
approvers (groups), jira/ticket, oncall_runbook_link
expiry_date (required), cleanup_owner, cleanup_pr_link (when retiring)
slo_impacting (yes/no), data_sensitive (yes/no)
3) Naming conventions (globally consistent)
Key format (recommended)
<org>.<domain>.<service>.<area>.<flag-name>
Rules
- Lowercase, dot-separated namespaces; hyphenated leaf name.
- Avoid “temp”, “test”, “new” without context.
- Prefer behavioral names over implementation names.
Examples
acme.checkout.payments.use-v2-authorize-flow
acme.search.ranking.enable-llm-rerank
acme.platform.auth.kill-switch-jwks-refresh (explicit kill-switch)
Prefixes / suffixes by intent
enable-* for boolean gating of a new behavior
use-* for switching between implementations
limit-* for throttle/guard rails (often integer/percentage)
kill-switch-* reserved for emergency disable controls
- Avoid service-internal abbreviations in shared domains (use glossary if unavoidable)
Tagging conventions
Tags drive policy and discovery:
tier:0|1|2 (production criticality)
type:release|ops|experiment|kill_switch
pii:false|true
runtime:server|client|edge
owner:<team-slug>
4) Approval workflows (risk-based, auditable)
Roles (RBAC)
- Owner: team responsible for behavior and cleanup.
- Maintainer: can edit targeting/rollout in their domain.
- Approver: required sign-off for high-risk actions.
- SRE/Platform: emergency override authority.
Risk tiers & required approvals
Tier 0 (highest risk): auth, payments, data deletion, security controls
- Requires: owner + SRE + security (if data/security impact)
- Change window: optional restriction (e.g., business hours)
- Mandatory staged rollout + automated rollback criteria
Tier 1: core user flows, high traffic APIs
- Requires: owner + service lead or oncall
Tier 2: low-risk internal tooling
- Requires: owner only (or lightweight review)
Workflow states
- Proposed
- Key + description + default + expiry + owner + rollout plan required.
- Approved
- Policy engine verifies approvals, tests, and dependency checks.
- Active
- Can be targeted/rolled out per plan.
- Deprecated
- Flag is “frozen”; no new targeting; cleanup in progress.
- Retired
- Removed from code and registry (or kept as tombstone to prevent reuse).
Guardrails (high value)
- Mandatory expiry (e.g., 30–90 days default; extensions require justification).
- Two-person rule for enabling to >X% on Tier 0/Tier 1.
- Separation of duties: creators can’t approve their own Tier 0 promotions.
- Change batching: restrict multiple unrelated flags in a single change.
Integration points
- ChatOps:
/flag enable acme.checkout... 5% triggers workflow + audit log.
- CI checks:
- Prevent new flags without owner/expiry/runbook link.
- Prevent deletion of flags still “active” in registry.
- Ticketing: automatic JIRA creation for Tier 0 flags and for expiry reminders.
5) Rollout analytics (measure and decide)
What to log (minimal and privacy-safe)
At evaluation time (server-side) emit:
flag_key, variant/value, reason (default/rule/override)
service, env, build_version
request_id/trace id for correlation
subject (hashed user id or cohort id), optional segment identifiers
- Sample rate controls for high-traffic endpoints
Dashboards (standardized)
For each flag:
- Exposure: counts by variant over time, by service/env/region
- Health metrics overlay:
- error rate, latency p95/p99, saturation, downstream failures
- business KPIs if available (conversion, checkout completion, etc.)
- Change annotations: every flag update appears as an event on graphs
- Cohort comparison (if doing experiments): variant metrics
Automated rollout controls
- Progressive delivery: 1% → 5% → 25% → 50% → 100%
- Automated halt/rollback if:
- error rate increases above threshold for N minutes
- latency regressions exceed threshold
- key business KPI drops beyond threshold (optional; needs careful design)
- Require explicit approval to continue after a halt for Tier 0.
6) Kill-switch orchestration (fast, safe, consistent)
Kill-switch types
- Local kill-switch: disables a feature within one service.
- Coordinated kill-switch: disables behavior across multiple services simultaneously.
- Dependency kill-switch: disables calls to a downstream dependency (fallback mode).
Orchestrator design
- Emergency override channel (“break glass”):
- Separate permission set (SRE/incident commanders).
- Minimal UI + ChatOps command + API.
- Propagation target:
- Push-based invalidation (webhook to snapshot CDN) + clients poll as fallback.
- Max propagation SLA (e.g., 30–60 seconds).
- Consistency rules:
- For coordinated switches, define a single “source” flag and map per-service derived flags (or a shared namespace) to avoid partial disable.
- Support “global override” that supersedes normal targeting rules.
Incident playbook integration
- Each Tier 0 flag must link a runbook:
- symptoms, dashboards, rollback steps, owners, safe defaults
- Post-incident: automatically open cleanup tasks to avoid permanent “emergency flags”.
7) Developer education (make the safe path the easy path)
Required training (lightweight)
- 30-minute onboarding module covering:
- how to name flags, set expiry, choose type/tier
- how to implement flag checks safely (idempotent, side-effects)
- how to do progressive rollouts and verify via dashboards
- how to remove flags (and why)
“Golden paths” (templates)
- Code templates for common languages:
- boolean gate with default
- multi-variant switch
- safe fallback with timeout
- Service checklist:
- metrics emitted, trace annotation, sampling configuration
- safe default behavior if flag service unavailable
Code review rubric
- No flag should:
- guard critical side-effects without idempotency/rollback plan
- change data schema without migration plan
- persist variant-dependent data without forward/backward compatibility
8) Documentation upkeep (prevent drift)
Docs as part of the registry
Registry auto-generates docs pages per flag from metadata:
- purpose, owner, rollout plan, runbook link, expiry
- current status and configuration history
- impacted services and references (grep/AST-based indexing)
Lifecycle enforcement
- Weekly expiry digest to owners + team leads.
- Auto-transition to Deprecated when expired (config locked except rollback/disable).
- “Remove by” SLAs:
- Release flags: remove within 2–4 weeks after 100%
- Ops/kill switches: review quarterly; remove if obsolete
Keeping references accurate
- Repo scanners update:
- list of services importing each flag
- stale flags (defined but unused) and “ghost flags” (used but not registered)
- CI fails if:
- a flag is used but not in registry
- a retired flag still exists in code
9) Minimal policy set (quick start)
- All flags must have: owner team, description, type, tier, default value, expiry date.
- Tier 0 requires: staged rollout, SRE approval to exceed 10%, runbook link.
- Any change to targeting in prod requires: audit log entry + change annotation.
- Kill-switches must propagate within 60 seconds and override all other rules.
- Flags hitting 100% must be removed within 30 days (exceptions require documented approval).
10) Implementation roadmap (practical sequencing)
- Phase 1: Registry + SDK + naming + basic RBAC + audit log.
- Phase 2: Progressive rollout UI + metrics emission + dashboards + annotations.
- Phase 3: Policy engine (tier-based approvals) + CI enforcement + repo scanning.
- Phase 4: Kill-switch orchestrator (break glass), propagation SLA, incident integration.
- Phase 5: Auto-expiry, deprecation locks, doc auto-generation, cleanup SLAs.
If you share your environment constraints (languages, deployment model, existing tools like LaunchDarkly/Unleash/homegrown, data/PII policies, and whether you need client-side flags), I can tailor this into a concrete schema, RBAC matrix, and example workflows (including exact approval rules and rollout thresholds).