================================================================================
COLLABTUNES DEPLOYMENT INCIDENT RESPONSE FLOWCHART
Date: 5_13_26 | Status: AUTHORITATIVE
War-room style. IF → THEN → ACTION. No debate.
================================================================================

================================================================================
START HERE — INCIDENT DETECTED
================================================================================

Something is wrong during or after deployment.
Answer: WHAT TYPE OF INCIDENT?

  ├─► GATE FAILURE ──────────────────────────────────────────────► [G]
  ├─► BROKEN DEPLOY / SITE DOWN ─────────────────────────────────► [B]
  ├─► ANCHOR CORRUPTION ──────────────────────────────────────────► [A]
  ├─► MISSING MANIFEST ───────────────────────────────────────────► [M]
  ├─► UNSAFE CONTENT LEAK ────────────────────────────────────────► [U]
  ├─► BAD PACKAGE DETECTED ───────────────────────────────────────► [P]
  └─► ROLLBACK TRIGGER (any reason) ─────────────────────────────► [R]

================================================================================
[G] GATE FAILURE
================================================================================

IF   R/NC-17/X page is live with no gate
THEN → STOP ALL DEPLOYMENT ACTIVITY NOW
     → Alert Tom immediately
     → Do not wait for investigation — act first
ACTION:
  1. Pull the affected page offline if possible
  2. Create BLOCK-L entry in BLOCKER_REGISTRY
  3. Go to [R] ROLLBACK if page cannot be pulled immediately
  4. Fix gate (see FAILURE_PATTERN G4 in pattern index)
  5. Verify fix: visit page without session — gate must appear before content
  6. Bypass test: press Back then Forward — gate must reappear
  7. PASS? → Re-deploy page only | FAIL? → Stay offline, escalate to Tom

IF   Gate fires but content flashes before gate appears
THEN → Do not roll back — page is gated, just slow
ACTION:
  1. Move gate script to <head>
  2. Add CSS: content hidden by default, gate reveals it
  3. Verify: no flash on hard refresh
  4. Log as BLOCK-L MODERATE

IF   Gate appears but wrong tier (R gate on NC-17 page)
THEN → Warn Tom, do not block deployment unless content is exposed
ACTION:
  1. Fix page metadata CONTENT_RATING field
  2. Verify gate logic reads from metadata
  3. Re-deploy affected page
  4. Log in blocker registry

================================================================================
[B] BROKEN DEPLOY / SITE DOWN
================================================================================

IF   Deployment completed and site returns 500 or is unreachable
THEN → Go to [R] ROLLBACK immediately
     → Do not investigate cause before rolling back
     → Restore first, diagnose second

IF   Deployment completed and specific pages return 404
THEN → Check: was slug changed in this deployment?
  YES slug changed → Update links to new slug OR add 301 redirect
  NO slug unchanged → Check: was file deleted accidentally?
    YES deleted → Restore from rollback ZIP (targeted restore, not full rollback)
    NO not deleted → Check server path/routing config

IF   Deployment completed but CSS/JS broken (page renders without styles)
THEN → Check: were asset paths changed in this deployment?
  YES → Restore old asset paths or update references
  NO  → Clear CDN cache / force refresh, recheck
     → If still broken: targeted [R] ROLLBACK of asset files only

================================================================================
[A] ANCHOR CORRUPTION
================================================================================

IF   Fast-scroll stops working after deployment
THEN → Check: does id="top" exist on affected page?
  NO  → Add missing anchor, redeploy page
  YES → Check: is there a duplicate id="top" on the page?
    YES duplicate → Remove duplicate, redeploy
    NO  → Check: is fast-scroll JS still loading?
      NO  → Re-add script tag, redeploy
      YES → Check JS console for errors, fix error, redeploy

IF   128-nav section link jumps to wrong section after deployment
THEN → Duplicate anchor ID introduced in this deployment
ACTION:
  1. Search page HTML for duplicate id values
  2. Rename second occurrence
  3. Update all links to renamed anchor
  4. Redeploy page
  5. Verify: click every section link, confirm correct scroll target

IF   Back button goes to wrong page after deployment
THEN → Check: was parent page URL changed in this deployment?
  YES → Update back button href to new canonical URL
  NO  → Check: is back button using JS history?
    YES → Verify popstate handler is intact
    NO  → Hard-code correct href, redeploy

================================================================================
[M] MISSING MANIFEST
================================================================================

IF   SGC-2 flags a ZIP with no manifest (MISSING_MANIFEST)
THEN → Is this ZIP in a production folder?
  YES production → Create manifest immediately before any other use of that ZIP
  NO  staging    → Log as LOW, create manifest before promotion

IF   Deployment package ZIP has no manifest
THEN → Do not use this package for deployment
ACTION:
  1. Open ZIP, list contents
  2. Create ZIP_MANIFEST_{DESCRIPTION}_{DATE}.txt
  3. Add manifest to ZIP (create new ZIP with manifest included)
  4. Update filename with correct file count
  5. Proceed with corrected package

IF   Manifest exists but does not match ZIP contents (MANIFEST_MISMATCH)
THEN → Do not use this package
ACTION:
  1. List actual ZIP contents
  2. Compare against manifest CONTAINS: section
  3. Determine which is correct: ZIP contents or manifest expectation
  4. If ZIP is missing files: re-add files, update manifest
  5. If manifest lists wrong files: correct manifest, update date
  6. Create new ZIP with corrected manifest

================================================================================
[U] UNSAFE CONTENT LEAK
================================================================================

IF   R/NC-17/X content is confirmed publicly accessible without gate
THEN → THIS IS THE HIGHEST PRIORITY INCIDENT
     → Everything else stops
ACTION:
  1. Pull page offline immediately (if possible)
  2. Alert Tom — right now, not after investigation
  3. Document: which page, what rating, how long exposed, how discovered
  4. Go to [R] ROLLBACK if page cannot be pulled
  5. Do not redeploy until gate is verified working (see [G])
  6. After resolution: full gate audit of all R+ pages before any new deploy

IF   Sensitive internal file (DEFAMATION_RISK_REGISTRY, CREATOR_INTERVIEW_TRANSCRIPT)
     is found in a public-facing package or output
THEN → Remove from package immediately
     → Alert Tom
     → Audit how it got there (SGC opened it? Manual error?)
     → If SGC SENSITIVE_OPENED flag raised: investigate immediately
     → Create new clean package without sensitive file
     → Verify no cached version is accessible

================================================================================
[P] BAD PACKAGE DETECTED
================================================================================

IF   Package ZIP is corrupt (BadZipFile error)
THEN → Do not use this package
ACTION:
  1. Restore from prior checkpoint ZIP in 13_SOURCE_ZIPS/
  2. Log CORRUPT_ZIP in blocker registry
  3. Investigate: was file truncated during transfer?
  4. Re-create package from source if no prior checkpoint

IF   Package contains files at WORKING authority (not AUTHORITATIVE)
THEN → Do not use for deployment
ACTION:
  1. Identify which files are WORKING
  2. Elevate to AUTHORITATIVE: Tom review → new VOL → new date stamp
  3. Re-package with elevated files
  4. Verify all inputs are AUTHORITATIVE or LOCKED before generator run

IF   Package filename does not match file count or contains banned words
THEN → Rename before using (not a hard stop, but fix immediately)
     → Correct format: {COUNT}_{TYPES}_{CATEGORY}_{DESCRIPTION}_{DATE}.zip

================================================================================
[R] ROLLBACK TRIGGER
================================================================================

WHEN TO TRIGGER ROLLBACK:
  → Site is down or returning 500
  → Gate failure cannot be fixed in < 30 min
  → Unsafe content leak is live
  → Canon file was overwritten accidentally
  → Any CRITICAL incident that cannot be patched in place

ROLLBACK LEVELS — USE LOWEST LEVEL THAT FIXES THE PROBLEM:

  LEVEL 1 (current session):
    Source: SESSION_CHECKPOINT ZIP from this session
    Use:    Restore only the files that changed this session
    Action: Extract specific files, overwrite current, verify

  LEVEL 2 (full cycle):
    Source: STABILIZATION_CHECKPOINT from last complete cycle
    Use:    Current cycle's changes are all bad
    Action: Restore canon folders from checkpoint, re-run SGC

  LEVEL 3 (pre-run baseline):
    Source: PRE_RUN_BASELINE ZIP
    Use:    SGC run corrupted outputs
    Action: Clear /outputs/, restore from baseline, re-run

  LEVEL 4 (nuclear — Tom must authorize):
    Source: PRE_DEPLOYMENT_BACKUP ZIP
    Use:    Live site is broken, nothing else works
    Action: Restore all production files, redeploy from restored state
    RULE:   Do not execute Level 4 without Tom's explicit go-ahead

POST-ROLLBACK REQUIRED ACTIONS:
  [ ] Verify rollback worked (spot-check affected pages)
  [ ] Document what caused the incident in BLOCKER_REGISTRY
  [ ] Do not re-deploy until root cause is found and fixed
  [ ] Create new checkpoint after fix is applied
  [ ] Tom notified of Level 3 or Level 4 rollback — always

================================================================================
END DEPLOYMENT INCIDENT RESPONSE FLOWCHART
================================================================================
