Runbook: Org Model v2.3 — Phase 2 Cutover (Dev)
Parent tracker: #570 · HLD: #556 · LLD: #560 §10.2 · Task issue: #692 · Milestone: Wave J+K — Phase 2 Cutover + Legacy Drop (#11)
This runbook is the procedure; the founder is the operator. The runbook does not automate flag flips on the founder's behalf. Every flag below is flipped by hand by the founder in dev, one at a time, with explicit verification between each flip.
0. Prod flip authority
Prod flip authority: TBD. Revisit this section when the first prod tenant onboards. Until then, every flag-flip step below is dev only. Do not copy this runbook into a prod change ticket without replacing this section with the approved prod authority.
1. What this runbook covers
Four feature flags that move the platform from Phase 1 (dual-write
running, reads still from legacy pillars / teams /
team_memberships) to Phase 2 (reads swing to the Org Model v2.3
mirror tables, the new services go live):
| # | Flag | Effect when flipped to true | LLD reference |
|---|---|---|---|
| 1 | dual_write_org_units | Already true throughout Phase 1. Off-switch for the K.2 schema drop — must remain true until Phase 3 decision. | §10.1 |
| 2 | read_from_org_units | MemberService + TenantService swing reads from team_memberships / teams / pillars to org_units / org_unit_memberships. J.2 shim activation. | §10.2 step 1 |
| 3 | cascade_4layer | GovernanceService Check() uses the 4-layer cascade (platform → org → org_unit walk → member) instead of the legacy 3-layer path. | §10.2 step 4 |
| 4 | new_services_enabled | OrgUnitService, RbacService, ConflictService endpoints start serving traffic at the gateway. | §10.2 step 5 |
The flip order is not arbitrary. Each flag depends on the one above it landing cleanly (see §5 below).
2. Who flips what
- Dev: the founder flips every flag personally via the procedure in §6. Agents never flip flags on the founder's behalf. If an agent is asked to automate or script the flip, the request is out of scope and must be escalated back to the founder.
- Prod: TBD — see §0.
3. Pre-flight checks (before flag 1)
Run all of these before flipping any flag. Any failure is a hard stop.
3.1 7-day zero-delta gate
The reconciliation reports in
docs/runbooks/org-v23-reconciliation-reports/ must show seven
consecutive daily gates of PASS ending on today's (UTC) report. The
most recent report must include the banner:
✅ 7-day zero-delta gate: MET. Phase 2 cutover is unblocked from the reconciliation side.
# Confirm the banner is present in today's file.
grep -l "7-day zero-delta gate: MET" \
docs/runbooks/org-v23-reconciliation-reports/$(date -u +%Y-%m-%d).md
If the file does not exist or the banner is missing, stop. Wait
for the CI baseline run, or run cmd/reconcile-report manually
against a live DB. Document why the gate missed (e.g. the reconciler
was paused, drift was observed) in the tracking issue (#570) before
retrying.
3.2 Live drift metric is zero
# kubectl port-forward to the reconciler's metrics endpoint, then:
curl -s localhost:9119/metrics | grep '^dualwrite_open_drift '
Expected: every series reports 0. A non-zero value means the
reconciler detected drift in the current pass — do not flip any
flag until that series returns to zero for at least one full
detect interval (RECONCILER_DETECT_INTERVAL, default 1h).
3.3 No open DualwriteDriftPersisting / DualwriteReconcilerStalled alerts
Check Grafana (Org Model dashboard) or Alertmanager directly. Any open critical-severity dualwrite alert is a hard stop.
3.4 Backend track is merged
Issues #686–#690
(the backend track that lands the flag plumbing, the
TenantService.ListTeams shim, and the 4-layer cascade switch) must
all be merged and deployed to the dev cluster. Confirm via:
gh api repos/upsquad-ai/upsquad-core/milestones/11 \
--jq '.open_issues, .closed_issues'
4. Rollback lever (applies to every step below)
Each flag has a single atomic off-switch: flip it back to false.
Data is preserved because dual_write_org_units stays true
throughout Phase 2 — the mirror tables continue to receive writes,
and legacy reads continue to work the moment the read-swing flag is
flipped back.
Rollback = flip the just-flipped flag back to false, in the exact
reverse order you flipped it. Verify §7 checks rebound
green. Record what you observed in #570.
Rollback is not possible after Phase 3 (legacy tables dropped). Phase 3 is a separate runbook — do not start it from this document.
5. Flag flip order (dev)
The LLD §10.2 order is mandatory. Each step has a gate the founder checks before moving on.
┌─ Pre-flight §3 passes ─┐
│ │
▼ │
Step 1: read_from_org_units = true (§6.1, verify §7.1)
│ │
▼ │
Step 2: deploy TenantService.ListTeams shim (already landed via
│ backend track #686–#690; confirm via §7.2)
│ │
▼ │
Step 3: portal smoke tests (§7.3)
│ │
▼ │
Step 4: cascade_4layer = true (§6.2, verify §7.4)
│ │
▼ │
Step 5: new_services_enabled = true (§6.3, verify §7.5)
│ │
▼ │
Post-flip soak §8
dual_write_org_units is not flipped in this runbook. It stays
true and is only flipped false as the final off-switch in Phase 3
(covered by Wave K, separate runbook).
6. Procedure — flag flips
The founder executes these commands personally. Agents may help prepare the commands, but the flip itself is a manual act to preserve operator accountability for the change.
6.1 read_from_org_units → true
-
Pre-flip checklist:
- §3 pre-flight checks all green.
- Current time falls within the agreed change window.
- You (founder) have a shell open against the dev cluster.
-
The command — exact invocation depends on the flag surface landed by the backend track. The flag is tenant-scoped but for dev we flip it platform-wide via the global key:
# Flag store is Redis (precedent: internal/context/versioning/featureflag.go).# Global key pattern: ff:orgv23:read_from_org_units:globalkubectl -n platform exec deploy/redis -- \redis-cli SET ff:orgv23:read_from_org_units:global trueIf the backend track landed a different flag surface (e.g. a GUC or a ConfigMap), replace the command above with whatever the backend PRs documented in their merge description. Confirm the flag surface with
@backend-smebefore flipping — do not guess. -
Verification: see §7.1.
-
If §7.1 fails: flip back with
kubectl -n platform exec deploy/redis -- \redis-cli SET ff:orgv23:read_from_org_units:global false
6.2 cascade_4layer → true
- Gated on §7.1 and §7.3 green.
- Command:
kubectl -n platform exec deploy/redis -- \redis-cli SET ff:orgv23:cascade_4layer:global true
- Verification: §7.4.
- Rollback: set to
falsevia the same key. Rollback criterion from the LLD:GovernanceService.Checkp95 > 7 ms for > 5 min.
6.3 new_services_enabled → true
- Gated on §7.4 green.
- Command:
kubectl -n platform exec deploy/redis -- \redis-cli SET ff:orgv23:new_services_enabled:global true
- Verification: §7.5.
- Rollback: set to
false. Gateway routes for the new services return 404 again (expected).