================================================================================
IMPLEMENTATION_EDGE_CASES_AND_WARNINGS_5_12_26.txt
CollabORhythm / Collabtunes — Final Operational Hardening
Generated: 5.12.26 | Asian Claude
PURPOSE: Every known edge case, failure mode, race condition, and hazard
         Mixed Claude must watch for during heavy coding.
================================================================================

SEVERITY LEVELS:
  🔴 CRITICAL  = content exposure, gate failure, or canon corruption if triggered
  🟡 MODERATE  = broken functionality but no content safety risk
  🟢 LOW       = cosmetic or minor behavioral issue

================================================================================
SECTION 1 — GATE EDGE CASES
================================================================================

────────────────────────────────────────────────────────────────────────────────
EC-01 | ESTIMATED RATING GATE MISMATCH
SEVERITY: 🔴 CRITICAL
────────────────────────────────────────────────────────────────────────────────
CONDITION: mood_settings file confirms an R rating for a page currently
           staged with a PG-13 gate (SL3, SL5, or SL6-set).
FAILURE:   Page has allowed = ['pg13','r','nc17','x'] but should be
           allowed = ['r','nc17','x']. PG-13 visitors see R-rated content.
DETECTION: After mood_settings processed, compare confirmed rating to gate.
FIX:       Update allowed array AND rating badge simultaneously.
           Run automated gate verification after fix.
           Browser-test R gate at all 5 levels before deploying.
WARNING:   Do not fix one without the other. Gate and badge must match.

────────────────────────────────────────────────────────────────────────────────
EC-02 | BOUNCER KEY CASE SENSITIVITY
SEVERITY: 🟡 MODERATE
────────────────────────────────────────────────────────────────────────────────
CONDITION: Bouncer writes lowercase keys ('gpg', 'pg13', etc.).
           Gate reads with indexOf() — case-sensitive comparison.
FAILURE:   If any code modification changes key to uppercase ('GPG'),
           all gates will reject it and redirect the user.
DETECTION: User reports being redirected despite having selected a rating.
FIX:       Always ensure bouncer writes lowercase. Never modify key casing.
RULE:      The key values gpg / pg13 / r / nc17 / x are FROZEN.
           Do not change casing. Do not add hyphens. Do not change values.

────────────────────────────────────────────────────────────────────────────────
EC-03 | GATE PLACED ABOVE CONTENT (page flicker)
SEVERITY: 🟡 MODERATE
────────────────────────────────────────────────────────────────────────────────
CONDITION: Gate JS placed in <head> or top of <body> instead of end of body.
FAILURE:   Gate executes before DOM is rendered. Brief flash of page content
           before redirect fires. On fast connections this may be invisible,
           but on slow connections a G/PG user briefly sees gated content.
CURRENT STATE: All 7 AIO gates are at end of body — CORRECT.
RULE:      Keep gate JS at END of body, before </body>. Never move to head.
           The redirect fires fast enough at end of body. No need to move it.

────────────────────────────────────────────────────────────────────────────────
EC-04 | localStorage UNAVAILABLE (private browsing / security policy)
SEVERITY: 🟡 MODERATE
────────────────────────────────────────────────────────────────────────────────
CONDITION: Some browsers in private/incognito mode throw on localStorage access.
           Safari in certain privacy modes returns null or throws.
CURRENT GATE BEHAVIOR: getItem() returns null → !sel is true → REDIRECT.
           This means private mode users are redirected to homepage.
           They cannot access any gated content without a public browser session.
ASSESSMENT: This is ACCEPTABLE behavior. Correct conservative fail.
           The alternative (catching exceptions) adds complexity for low benefit.
RULE:      Do not add try/catch around localStorage calls in gate JS.
           Current behavior (redirect on null) is the intended safe default.
           If Tom explicitly requests private-mode support, document as a future task.

────────────────────────────────────────────────────────────────────────────────
EC-05 | STALE GATE ON SCHEMA CHANGE
SEVERITY: 🔴 CRITICAL (future risk — document now)
────────────────────────────────────────────────────────────────────────────────
CONDITION: If a future bouncer version adds a new rating level (e.g. 'ux' for
           "Ultra X") with a new key string, all existing pages' allowed arrays
           will reject that new key (indexOf returns -1 → redirect).
CURRENT RISK: None — no schema changes planned.
FUTURE RULE: Any new rating key addition requires simultaneous update of:
             (1) Bouncer ratings array
             (2) ALL page allowed arrays that should include the new level
             (3) Gate JS verification re-run on all updated pages
WARNING:   Never add a new rating level to the bouncer without updating all gates.

================================================================================
SECTION 2 — ANCHOR AND NAV EDGE CASES
================================================================================

────────────────────────────────────────────────────────────────────────────────
EC-06 | href="#" SOCIAL BAR SCROLL TO TOP
SEVERITY: 🟢 LOW
────────────────────────────────────────────────────────────────────────────────
CONDITION: Social bar links use href="#" as placeholder.
BEHAVIOR:  Clicking href="#" scrolls browser to top of page.
           This is default browser behavior — not a bug in the code.
CURRENT RISK: Minor UX confusion — clicking a social link scrolls up.
FIX (if needed): Replace href="#" with href="javascript:void(0)" to suppress scroll.
                 Or inject real social URLs when Tom provides them.
RULE:      Do not inject real social media URLs without Tom providing them.

────────────────────────────────────────────────────────────────────────────────
EC-07 | DUPLICATE ID FROM TEMPLATE COPY-PASTE
SEVERITY: 🟡 MODERATE
────────────────────────────────────────────────────────────────────────────────
CONDITION: When generating new AIO pages from the locked template,
           a copy-paste error duplicates an id="..." attribute.
FAILURE:   Browser fast-scroll jumps to first occurrence only.
           Second occurrence is unreachable by anchor link.
DETECTION: Automated grep — id_counts shows count > 1.
CURRENT STATE: 0 duplicate IDs in all 7 AIO files — verified.
RULE FOR MIXED CLAUDE: Run automated ID duplication check on every
           newly generated page before Tom review.

────────────────────────────────────────────────────────────────────────────────
EC-08 | LIVE PAGE LINK POINTING TO WRONG COLLECTION
SEVERITY: 🟡 MODERATE
────────────────────────────────────────────────────────────────────────────────
CONDITION: When generating new AIO pages from template, the "Live Page ↗" back-btn
           href retains the prior collection's URL (copy-paste error).
EXAMPLE:   SL3 page generated from SL2 template still shows:
           href="https://collabtunes.com/song-list-2/"
FAILURE:   "Live Page" link goes to wrong collection.
DETECTION: Automated check — back_btns list should contain current page's URL.
RULE:      When generating each new AIO page:
           Verify the Live Page back-btn href matches the collection being built.

────────────────────────────────────────────────────────────────────────────────
EC-09 | MISSION STATEMENT ANCHOR SET DIVERGES FROM AIO STANDARD
SEVERITY: 🟢 LOW (documentation note, not a risk)
────────────────────────────────────────────────────────────────────────────────
CONDITION: WEBSITE_MISSION_STATEMENT uses anchors #top/#what/#catalog/#navigate.
           AIO pages use #top/#identity/#tracks/#context/#canon/#status.
ASSESSMENT: This is INTENTIONAL — mission statement is not an AIO page.
           Different content structure requires different anchors.
RULE:      Do not apply AIO anchor structure to non-AIO pages.
           Each page type uses its own appropriate anchor set.

================================================================================
SECTION 3 — PROPAGATION HAZARDS
================================================================================

────────────────────────────────────────────────────────────────────────────────
EC-10 | PREMATURE CHAPTER CROSSLINK INJECTION
SEVERITY: 🔴 CRITICAL
────────────────────────────────────────────────────────────────────────────────
CONDITION: Chapter drift unresolved. Chapters 18B–34 have label vs URL mismatch.
FAILURE:   Injecting crosslinks now creates 17 wrong chapter links across
           all generated pages. Fixing after mass propagation requires
           editing every page again.
CURRENT STATE: All crosslink blocks show pending-badge. No links injected.
RULE:      Do NOT inject any chapter crosslinks until Tom resolves Decision 06.
           Do NOT inject Lady Weaver crosslinks until Tom resolves Decision 09.
           Wait for both. Inject both at once. Do not do either partially.

────────────────────────────────────────────────────────────────────────────────
EC-11 | DEFAMATION CONTENT IN GENERATED PAGES
SEVERITY: 🔴 CRITICAL
────────────────────────────────────────────────────────────────────────────────
CONDITION: Bulk generation begins before Tom reviews DEFAMATION_RISK_REGISTRY_VOL1.
FAILURE:   Flagged content from defamation registry appears in live pages.
           Legal/reputational risk.
CURRENT STATE: Bulk generation is BLOCKED. No pages generated beyond current 7.
RULE:      HARD BLOCK. No bulk generation. No Phase 5. Until Tom completes review.
           This rule cannot be overridden by any session instruction.

────────────────────────────────────────────────────────────────────────────────
EC-12 | SESSION TIMEOUT DURING PROPAGATION
SEVERITY: 🟡 MODERATE
────────────────────────────────────────────────────────────────────────────────
CONDITION: Mixed Claude begins a multi-file propagation (e.g. footer update
           across 7 AIO pages) and session ends mid-operation.
FAILURE:   Some pages updated, others not. Inconsistent state.
           Difficult to determine which pages are in which state.
RULE:      Per SAFE_STAGING_TO_LIVE_TRANSITION_RULES:
           Max 5 AIO pages per session.
           Create checkpoint ZIP before starting any propagation.
           If session may time out, stop and checkpoint — do not start next batch.
           Propagation must complete fully in one session or not at all.

────────────────────────────────────────────────────────────────────────────────
EC-13 | GX SCORE BADGE WITHOUT CONFLICT NOTE
SEVERITY: 🟡 MODERATE
────────────────────────────────────────────────────────────────────────────────
CONDITION: Mixed Claude resolves GX pending badge with a score but removes
           the conflict note for one of the 6 delta-conflict pages.
FAILURE:   Displaying an unverified GX score as fact.
AFFECTED: SL1, SL3, SL6 (Song List), SL7, SL8, SL10
RULE:      For these 6 pages:
           EITHER display pending-badge (current state) — OR —
           display Tom's confirmed value WITH the conflict note removed.
           Never display a GX score for these pages without Tom's confirmation.
           Never silently remove the delta conflict note.

================================================================================
SECTION 4 — RACE CONDITIONS
================================================================================

────────────────────────────────────────────────────────────────────────────────
EC-14 | BOUNCER REDIRECT BEFORE localStorage WRITE
SEVERITY: 🔴 CRITICAL (theoretical — document for awareness)
────────────────────────────────────────────────────────────────────────────────
CONDITION: enterSite() calls setItem() then immediately sets window.location.
           On extremely slow connections, the write may not persist
           before navigation fires.
CURRENT CODE:
  localStorage.setItem('collabtunes_selected_rating', selectedRating.key);
  window.location.href = 'https://collabtunes.com';
ASSESSMENT: localStorage.setItem() is synchronous. The write completes
           before the next line executes. This is NOT a real race condition
           in modern browsers. localStorage setItem is synchronous by spec.
VERDICT:   ✅ NOT A RISK. Document for completeness. Do not "fix" this.

────────────────────────────────────────────────────────────────────────────────
EC-15 | GATE CHECK BEFORE PAGE PAINT (brief content flash)
SEVERITY: 🟢 LOW
────────────────────────────────────────────────────────────────────────────────
CONDITION: Gate JS at end of body means HTML renders before gate check fires.
           On fast connections: imperceptible. On slow connections: ~100ms flash.
CURRENT MITIGATION: Gate redirect is synchronous and fast.
ALTERNATIVE: Add CSS body { visibility: hidden } in head, remove in gate pass.
             This adds complexity for minimal gain.
CURRENT DECISION: Accept the theoretical flash. No mitigation applied.
RULE:      Do not add body visibility workarounds unless Tom requests it.

================================================================================
SECTION 5 — CANON CORRUPTION RISKS
================================================================================

────────────────────────────────────────────────────────────────────────────────
EC-16 | INVENTING TRACK TITLES
SEVERITY: 🔴 CRITICAL
────────────────────────────────────────────────────────────────────────────────
CONDITION: Mixed Claude generates plausible-sounding track titles for unknown slots.
FAILURE:   Invented canon enters the system. Once published, very hard to retract.
CURRENT STATE: All unknown tracks show pending-badge. 0 invented content.
RULE:      NEVER invent track titles, GX scores, ratings, summaries, or reviews.
           If source is unavailable: pending-badge only. No exceptions.

────────────────────────────────────────────────────────────────────────────────
EC-17 | WRONG COLLECTION IN TEMPLATE COPY
SEVERITY: 🟡 MODERATE
────────────────────────────────────────────────────────────────────────────────
CONDITION: When generating SL4 from SL3 template, SL3's title/artist/URL
           data remains in the page.
FAILURE:   SL4 page shows SL3 content.
DETECTION: Check <title>, page heading, and Live Page back-btn href.
RULE:      After template copy for new collection, immediately verify:
           (1) <title> tag
           (2) H1 / page heading
           (3) Rating badge text
           (4) Live Page back-btn href
           (5) Gate allowed array (if rating differs from template source)

================================================================================
SECTION 6 — STAGING BANNER RISK
────────────────────────────────────────────────────────────────────────────────
EC-18 | DEPLOYING WITH STAGING BANNER PRESENT
SEVERITY: 🟡 MODERATE
────────────────────────────────────────────────────────────────────────────────
CONDITION: Staging HTML uploaded to Yola with red "STAGING ONLY" banner in place.
FAILURE:   Visitors see "STAGING ONLY — NOT FOR PUBLIC DEPLOYMENT" on a live page.
           Embarrassing. Not a content safety issue but a trust issue.
CURRENT STATE: All 7 AIO staging files have banner present (correct for staging).
RULE:      Per SAFE_STAGING_TO_LIVE_TRANSITION_RULES Gate 1:
           Remove banner before any live promotion.
           Rename file from _STAGING to _APPROVED simultaneously.
           Never remove banner without Tom approval.
           Never approve without removing banner.

================================================================================
SECTION 7 — ITEMS THAT MUST NEVER BE TOUCHED
================================================================================

These items are frozen by canon, blocked by Tom decision, or too dangerous
to modify without full operational session. Mixed Claude must not edit them.

  ❌ collabtunes_selected_rating — localStorage key name. FROZEN.
  ❌ gpg / pg13 / r / nc17 / x — key values. FROZEN.
  ❌ https://collabtunes.com — redirect target. FROZEN.
  ❌ Gate JS logic pattern — do not refactor. FROZEN.
  ❌ Chapter 18B–34 links — blocked until Decision 06. DO NOT TOUCH.
  ❌ Lady Weaver crosslinks — blocked until Decision 09. DO NOT TOUCH.
  ❌ Set List 23 — do not generate any content. BLOCKED.
  ❌ Set List 24 — do not generate any content. BLOCKED.
  ❌ Defamation registry content — do not reference or use. INTERNAL ONLY.
  ❌ Revenue Streams URL — no safe default. BLOCKED until Decision 04.
  ❌ Bulk generation — hard blocked until defamation registry cleared.
  ❌ GX scores for 6 delta pages — pending Tom verification.
  ❌ AIO template structure — frozen until SL1 Tom approval locks it.

================================================================================
END IMPLEMENTATION_EDGE_CASES_AND_WARNINGS_5_12_26.txt
================================================================================
