================================================================================
COLLABTUNES MASTER DEPLOYMENT SEQUENCE
Version: 1.0 | Date: 5_13_26 | Status: AUTHORITATIVE
Owner: Mixed Claude / Tom
Purpose: Exact order of operations from repo intake to deployment-ready signoff.
         Follow this sequence in order. Do not skip steps.
         Each gate must PASS before next phase begins.
================================================================================

SEQUENCE OVERVIEW
─────────────────
PHASE 0  →  Environment Setup
PHASE 1  →  Repo Intake (SGC-2)
PHASE 2  →  Live Site Intake (SGC-1)
PHASE 3  →  Cross-System Audit
PHASE 4  →  Blocker Review + Triage
PHASE 5  →  Canon Verification
PHASE 6  →  Packaging + Checkpoints
PHASE 7  →  Deployment Readiness Signoff

Total estimated time (first run): 3–5 hours
Total estimated time (subsequent runs): 1–2 hours

================================================================================
PHASE 0 — ENVIRONMENT SETUP
================================================================================
Estimated time: 15 min

STEP 0.1  Verify SGC installation
──────────────────────────────────
Action:   cd 15_GATHERING_TOOLS && python tests/run_stage1_tests.py
Expected: 5/5 modules PASS
If FAIL:  Stop. Fix foundation before proceeding.

STEP 0.2  Verify SGC-1 tests
─────────────────────────────
Action:   python tests/test_sgc1_modules.py &&
          python tests/test_sgc1_integration_dry_run.py
Expected: 38/38 + 21/21 PASS
If FAIL:  Stop. Fix before proceeding.

STEP 0.3  Verify SGC-2 tests
─────────────────────────────
Action:   python tests/test_sgc2_all.py
Expected: 42/42 PASS
If FAIL:  Stop. Fix before proceeding.

STEP 0.4  Locate required input files
───────────────────────────────────────
Confirm each file exists and path is known:
  [ ] MASTER_URL_AUTHORITY_REGISTRY (latest VOL)     → path: _______________
  [ ] FINAL_NAVIGATION_AUTHORITY_MAP                 → path: _______________
  [ ] MASTER_CONTENT_RATINGS_INDEX (latest VOL)      → path: _______________
  [ ] FINAL_CANON_AUTHORITY_REGISTRY                 → path: _______________
  [ ] mood_settings_ratings_explicit (all 34 albums) → path: _______________

STEP 0.5  Pre-flight ZIP checkpoint
──────────────────────────────────────
Action:   Create pre-run backup ZIP of current repo state
Filename: {N}_ZIP_COLLABTUNES_PRE_DEPLOYMENT_RUN_BASELINE_{DATE}.zip
Save to:  13_SOURCE_ZIPS/
Purpose:  Rollback point if anything goes wrong

PHASE 0 GATE: [ ] All tests pass | [ ] All input files located | [ ] Baseline ZIP created

================================================================================
PHASE 1 — REPO INTAKE (SGC-2)
================================================================================
Estimated time: 20–40 min depending on repo size

STEP 1.1  SGC-2 DRY RUN
─────────────────────────
Action:
  python -m sgc2.sgc2_main \
    --mode DRY_RUN \
    --root {COLLABTUNES_PROJECT_ROOT} \
    --output-dir ./outputs/ \
    --log-dir ./logs/

Review dry run report:
  [ ] File count is expected (no missing folders)
  [ ] Sensitive files listed correctly (not opened)
  [ ] ZIP count matches expected
  [ ] TXT count matches expected
  [ ] No unexpected errors in report

If dry run report shows problems: resolve before proceeding to live run.

STEP 1.2  SGC-2 LIVE RUN
──────────────────────────
Action:
  python -m sgc2.sgc2_main \
    --mode LIVE_RUN \
    --root {COLLABTUNES_PROJECT_ROOT} \
    --output-dir ./outputs/ \
    --log-dir ./logs/

Confirm gate: type 'yes' at confirmation prompt

STEP 1.3  Verify SGC-2 outputs
────────────────────────────────
  [ ] SGC2_REPO_INVENTORY_{run_id}.json — exists, non-zero
  [ ] SGC2_REPO_INVENTORY_{run_id}_SUMMARY.txt — exists, non-zero
  [ ] SGC2_RUN_MANIFEST_{run_id}.txt — exists
  [ ] REPO_INTEGRITY_VERIFIED in run log
  [ ] SENSITIVE_FILES_CLEAN in run log
  [ ] Checkpoint files: START, PHASE1, PHASE3, PHASE6, COMPLETE

STEP 1.4  Review SGC-2 summary — flags section
────────────────────────────────────────────────
Open SGC2_REPO_INVENTORY_{run_id}_SUMMARY.txt and check:
  [ ] CRITICAL flags count = 0 (or document each)
  [ ] MISSING_MANIFEST ZIPs — list them: ______________________
  [ ] MISPLACED_FILE flags — list them: ______________________
  [ ] AMBIGUOUS_VERSION flags — list them: ______________________
  [ ] Missing expected folders — list them: ______________________

STEP 1.5  Review dependency chain assessment
─────────────────────────────────────────────
From summary, record chain statuses:
  CHAIN_A_RATING_GATE:      [ ] COMPLETE  [ ] MISSING  [ ] BLOCKED
  CHAIN_B_AIO_GENERATOR:    [ ] COMPLETE  [ ] MISSING  [ ] BLOCKED
  CHAIN_C_NAV_INTEGRITY:    [ ] COMPLETE  [ ] MISSING  [ ] BLOCKED
  CHAIN_D_CROSSLINKS:       [ ] COMPLETE  [ ] MISSING  [ ] BLOCKED
  CHAIN_E_DEFAMATION:       [ ] COMPLETE  [ ] MISSING  [ ] BLOCKED

If any chain is BLOCKED: create blocker entries before Phase 5.

STEP 1.6  Review generator input assessment
────────────────────────────────────────────
  mood_settings:                  [ ] READY  [ ] MISSING  [ ] LOW_AUTHORITY
  MASTER_CONTENT_RATINGS_INDEX:   [ ] READY  [ ] MISSING  [ ] LOW_AUTHORITY
  FINAL_CANON_AUTHORITY_REGISTRY: [ ] READY  [ ] MISSING  [ ] LOW_AUTHORITY
  MASTER_URL_AUTHORITY_REGISTRY:  [ ] READY  [ ] MISSING  [ ] LOW_AUTHORITY
  HTML_TESTER_FIXED_COLOR:        [ ] READY  [ ] MISSING  [ ] LOW_AUTHORITY

CRITICAL_MISSING inputs block generator. Resolve in Phase 5.

PHASE 1 GATE: [ ] SGC-2 complete | [ ] No ABORT errors | [ ] All flags reviewed

================================================================================
PHASE 2 — LIVE SITE INTAKE (SGC-1)
================================================================================
Estimated time: 30–90 min depending on site size and rate limiting

STEP 2.1  SGC-1 DRY RUN
─────────────────────────
Action:
  python -m sgc1.sgc1_main \
    --mode DRY_RUN \
    --seed-file {path/to/MASTER_URL_AUTHORITY_REGISTRY.txt} \
    --nav-file {path/to/FINAL_NAVIGATION_AUTHORITY_MAP.txt} \
    --output-dir ./outputs/ \
    --log-dir ./logs/

Review dry run report:
  [ ] Crawl queue count is expected
  [ ] Seed file parsed without errors
  [ ] Nav file parsed without errors
  [ ] No unexpected skipped URLs

STEP 2.2  SGC-1 LIVE RUN
──────────────────────────
Action:
  python -m sgc1.sgc1_main \
    --mode LIVE_RUN \
    --seed-file {path/to/MASTER_URL_AUTHORITY_REGISTRY.txt} \
    --nav-file {path/to/FINAL_NAVIGATION_AUTHORITY_MAP.txt} \
    --output-dir ./outputs/ \
    --log-dir ./logs/ \
    --max-pages 250

Confirm gate: type 'yes' at confirmation prompt

Note: Run takes ~30-90 min. Rate limit is 1.5s/request. Do not interrupt.
If run aborts mid-way: use --resume {checkpoint_path} to continue.

STEP 2.3  Verify SGC-1 outputs
────────────────────────────────
  [ ] SGC1_LIVE_SITE_SNAPSHOT_{run_id}.json — exists, non-zero
  [ ] SGC1_LIVE_SITE_SNAPSHOT_{run_id}_SUMMARY.txt — exists, non-zero
  [ ] SGC1_RUN_MANIFEST_{run_id}.txt — exists
  [ ] SITE_INTEGRITY_VERIFIED in run log
  [ ] Checkpoint files: START, PHASE2, PHASE4, COMPLETE

STEP 2.4  Review SGC-1 summary — key metrics
──────────────────────────────────────────────
Open SGC1_LIVE_SITE_SNAPSHOT_{run_id}_SUMMARY.txt and record:
  Total URLs processed:    ___
  Live pages (HTTP 200):   ___
  Broken / non-200:        ___
  Conflicts found:         ___
  Flags raised:            ___
  GATE_MISSING flags:      ___    ← must be 0 for deployment
  ORPHAN_URL flags:        ___
  STATUS_MISMATCH flags:   ___
  CHAPTER_DRIFT items:     ___

STEP 2.5  Extract and review critical flags
────────────────────────────────────────────
From JSON output, extract all items where:
  "flags" contains "GATE_MISSING"   → document in blocker registry
  "flags" contains "ORPHAN"         → verify intentional
  "http_status" != 200              → verify expected or document
  "conflict_type" == "CHAPTER_DRIFT"→ enter in canon triage

PHASE 2 GATE: [ ] SGC-1 complete | [ ] No ABORT errors | [ ] GATE_MISSING count recorded

================================================================================
PHASE 3 — CROSS-SYSTEM AUDIT
================================================================================
Estimated time: 30–60 min

STEP 3.1  Open Deployment Readiness Audit Template
────────────────────────────────────────────────────
File: COLLABTUNES_DEPLOYMENT_READINESS_AUDIT_TEMPLATE_5_13_26.txt
Copy and rename: COLLABTUNES_DEPLOYMENT_AUDIT_{CYCLE_ID}_{DATE}.txt
Save to: 10_QA/

STEP 3.2  Complete audit Section 1 — Broken Links
───────────────────────────────────────────────────
Source: SGC-1 JSON output → items where http_status ≠ 200
Action: Pull list, fill in Section 1 of audit template
Target: Zero unexpected broken links on LIVE-marked pages

STEP 3.3  Complete audit Section 2 — Missing Pages
────────────────────────────────────────────────────
Source: Cross-reference SGC-1 output against MASTER_URL_AUTHORITY_REGISTRY
Target: All LIVE-marked pages return 200

STEP 3.4  Complete audit Sections 3-4 — Anchors
──────────────────────────────────────────────────
Manual check required for:
  [ ] 128-nav page — all section anchors unique
  [ ] Switchboard — all quicklink anchors resolve
  [ ] Any AIO page with fast-scroll — top/mid/bot anchors present

STEP 3.5  Complete audit Sections 5-6 — Ratings + Metadata
─────────────────────────────────────────────────────────────
Source: SGC-1 JSON + MASTER_CONTENT_RATINGS_INDEX
  [ ] No live AIO page has rating=PENDING
  [ ] No live AIO page has gate=UNKNOWN
  [ ] All 34 collections have at least one rating entry

STEP 3.6  Complete audit Sections 7-8 — Canon + Placeholders
──────────────────────────────────────────────────────────────
  [ ] All known conflicts entered (CC-LW, CC-CH18, CC-YT-URL)
  [ ] All PENDING pages confirmed intentional placeholders

STEP 3.7  Complete audit Section 9 — Gate Integrity (MANDATORY)
─────────────────────────────────────────────────────────────────
Action: Count all GATE_MISSING flags from SGC-1 output
Target: ZERO GATE_MISSING on R, NC-17, X rated pages
If count > 0: DEPLOYMENT IS BLOCKED. Enter BLOCK-L entries in registry.

PHASE 3 GATE: [ ] Audit template fully completed | [ ] Section 9 = PASS

================================================================================
PHASE 4 — BLOCKER REVIEW + TRIAGE
================================================================================
Estimated time: 20–45 min

STEP 4.1  Update blocker registry
───────────────────────────────────
File: COLLABTUNES_BLOCKER_REGISTRY_{DATE}.txt
Action:
  [ ] Review all OPEN blockers — still open or can be closed?
  [ ] Add new blockers found in Phase 3 audit
  [ ] Confirm status of TOM_REQUIRED blockers with Tom
  [ ] Mark any RESOLVED blockers with resolution date

STEP 4.2  Triage critical blockers
────────────────────────────────────
For each CRITICAL + BLOCKS_DEPLOYMENT blocker:
  [ ] BLOCK-L01 (HGIH gate) — resolved? [ ] YES  [ ] NO
  [ ] BLOCK-L02 (Quick Guide gate) — resolved? [ ] YES  [ ] NO
  [ ] BLOCK-L03 (Full Texts gate) — resolved? [ ] YES  [ ] NO
  [ ] Any new CRITICAL blockers from this cycle?

Rule: Zero CRITICAL + BLOCKS_DEPLOYMENT = prerequisite for Phase 7 signoff.

STEP 4.3  Document accepted-risk blockers
───────────────────────────────────────────
For any blocker marked ACCEPTED_RISK:
  [ ] Written justification provided
  [ ] Tom has reviewed and agreed
  [ ] DEPLOYMENT_IMPACT = COSMETIC or DEGRADES_FUNCTION (not BLOCKS_DEPLOYMENT)

PHASE 4 GATE: [ ] Registry updated | [ ] Critical blockers triaged | [ ] Tom sign-off on accepted risks

================================================================================
PHASE 5 — CANON VERIFICATION
================================================================================
Estimated time: 30–60 min

STEP 5.1  Ratings canon check
───────────────────────────────
Source: MASTER_CONTENT_RATINGS_INDEX + SGC-1 ratings output
  [ ] All 34 collections have confirmed ratings (no PENDING, no CONFLICT)
  [ ] mood_settings file matches ratings index for all 34
  [ ] No rating contradicts body badge detected by SGC-1

STEP 5.2  URL canon check
───────────────────────────
Source: MASTER_URL_AUTHORITY_REGISTRY + SGC-1 http_status output
  [ ] All LIVE-marked pages return HTTP 200
  [ ] All BROKEN-marked pages return non-200
  [ ] No duplicate slugs (outside known documented conflicts)
  [ ] Lady Weaver conflict (BLOCK-H04) — status: _______________
  [ ] Chapter 18 drift (BLOCK-H02) — status: _______________
  [ ] YouTube URL collision (BLOCK-M01) — status: _______________

STEP 5.3  Navigation canon check
──────────────────────────────────
Source: FINAL_NAVIGATION_AUTHORITY_MAP + SGC-1 nav_sources output
  [ ] All expected nav sources loaded (homepage, 128-nav, quicklinks)
  [ ] Chapter drift map reviewed — all known drifts documented
  [ ] No new chapter drift items beyond already-registered blockers

STEP 5.4  Naming canon check
──────────────────────────────
Source: SGC-2 naming violations output
  [ ] Zero BANNED_FILENAME items in production folders
  [ ] All production files have date stamps
  [ ] All version-superseded files marked REFERENCE or DEPRECATED
  [ ] No AMBIGUOUS_VERSION flags on generator input files

STEP 5.5  Generator input final check
───────────────────────────────────────
Run through GENERATOR_INPUT_REQUIREMENTS checklist for all 5 required inputs.
All 5 must be GREEN before proceeding to packaging.
  [ ] mood_settings: READY + AUTHORITATIVE
  [ ] MASTER_CONTENT_RATINGS_INDEX: READY + AUTHORITATIVE
  [ ] FINAL_CANON_AUTHORITY_REGISTRY: READY + LOCKED/AUTHORITATIVE
  [ ] MASTER_URL_AUTHORITY_REGISTRY: READY + AUTHORITATIVE
  [ ] HTML_TESTER_FIXED_COLOR: READY + AUTHORITATIVE

PHASE 5 GATE: [ ] All canon checks pass | [ ] All 5 generator inputs READY

================================================================================
PHASE 6 — PACKAGING + CHECKPOINTS
================================================================================
Estimated time: 20–30 min

STEP 6.1  Archive SGC run outputs
───────────────────────────────────
Move to 01_LIVE_CAPTURE/ (or timestamped subfolder):
  [ ] SGC1_LIVE_SITE_SNAPSHOT_{run_id}.json
  [ ] SGC1_LIVE_SITE_SNAPSHOT_{run_id}_SUMMARY.txt
  [ ] SGC1_RUN_MANIFEST_{run_id}.txt
  [ ] SGC2_REPO_INVENTORY_{run_id}.json
  [ ] SGC2_REPO_INVENTORY_{run_id}_SUMMARY.txt
  [ ] SGC2_RUN_MANIFEST_{run_id}.txt

Move logs to archive:
  [ ] All checkpoint files for this run → 13_SOURCE_ZIPS/ or logs archive

STEP 6.2  Create stabilization checkpoint ZIP
───────────────────────────────────────────────
ZIP the current stable state of all canon folders:
  Include: 02_CANON/, 03_RATINGS/, 05_URL_MAPS/, 06_NAV_STABILIZATION/
  Filename: {N}_TXT_COLLABTUNES_CANON_STABILIZATION_CHECKPOINT_{DATE}.zip
  Manifest: ZIP_MANIFEST_CANON_STABILIZATION_CHECKPOINT_{DATE}.txt
  Save to:  13_SOURCE_ZIPS/
  [ ] ZIP created with manifest inside
  [ ] File count in filename matches actual count

STEP 6.3  Create QA output package
────────────────────────────────────
  Include: 10_QA/ audit outputs from this cycle
  Filename: {N}_TXT_COLLABTUNES_QA_OUTPUTS_{CYCLE_ID}_{DATE}.zip
  Save to:  13_SOURCE_ZIPS/
  [ ] ZIP created

STEP 6.4  Update 12_MANIFESTS/
────────────────────────────────
  [ ] Create/update manifest for each ZIP created in this phase
  [ ] Manifests are in 12_MANIFESTS/ not inside the ZIPs (ZIPs also have them)
  [ ] All manifests are dated and VOL-stamped

STEP 6.5  Clean outputs/ and logs/
────────────────────────────────────
  [ ] ./outputs/ is empty or contains only current-cycle outputs
  [ ] ./logs/ is clean (old runs archived)
  [ ] No temp files in any production folder

PHASE 6 GATE: [ ] All outputs archived | [ ] Checkpoint ZIPs created | [ ] Manifests current

================================================================================
PHASE 7 — DEPLOYMENT READINESS SIGNOFF
================================================================================
Estimated time: 15 min

STEP 7.1  Final gate check
───────────────────────────
All of the following must be TRUE:
  [ ] Phases 0–6 complete (all gates passed)
  [ ] Audit Section 9 (gate integrity) = PASS
  [ ] Zero CRITICAL + BLOCKS_DEPLOYMENT blockers open
  [ ] All 5 generator inputs at AUTHORITATIVE or LOCKED
  [ ] Canon verification Phase 5 all green
  [ ] No GATE_MISSING flags on R+ pages

STEP 7.2  Tom review + approval
─────────────────────────────────
  [ ] Tom has reviewed the deployment audit report
  [ ] Tom has reviewed all ACCEPTED_RISK blockers
  [ ] Tom has signed off on any TOM_REQUIRED decisions made
  [ ] Tom has approved generator input list

STEP 7.3  Create deployment package
────────────────────────────────────
  Include: All generator inputs + deployment docs
  Filename: {N}_ZIP_COLLABTUNES_DEPLOYMENT_PACKAGE_{VERSION}_{DATE}.zip
  Save to:  07_DEPLOYMENT/
  [ ] Deployment package ZIP created
  [ ] Manifest inside ZIP is complete
  [ ] Rollback ZIP exists in 07_DEPLOYMENT/

STEP 7.4  Final signoff entry
───────────────────────────────
Record in this document and in the checklist:

Cycle ID:               ___________________
Signed off by:          ___________________
Date:                   ___________________
SGC-1 Run ID:           ___________________
SGC-2 Run ID:           ___________________
Total blockers open:    ___________________
Critical blockers:      0  (required)
Deployment package:     ___________________

DEPLOYMENT STATUS:  [ ] READY  [ ] BLOCKED  [ ] CONDITIONAL

================================================================================
QUICK REFERENCE — COMMAND SEQUENCE
================================================================================

# Phase 0: verify
cd 15_GATHERING_TOOLS
python tests/run_stage1_tests.py

# Phase 1: repo intake
python -m sgc2.sgc2_main --mode DRY_RUN --root {ROOT} --output-dir ./outputs/ --log-dir ./logs/
python -m sgc2.sgc2_main --mode LIVE_RUN --root {ROOT} --output-dir ./outputs/ --log-dir ./logs/

# Phase 2: live site
python -m sgc1.sgc1_main --mode DRY_RUN --seed-file {SEED} --nav-file {NAV} --output-dir ./outputs/ --log-dir ./logs/
python -m sgc1.sgc1_main --mode LIVE_RUN --seed-file {SEED} --nav-file {NAV} --output-dir ./outputs/ --log-dir ./logs/ --max-pages 250

# Or run both in sequence:
python run_both.py --mode DRY_RUN --root {ROOT} --seed-file {SEED} --nav-file {NAV}
python run_both.py --mode LIVE_RUN --root {ROOT} --seed-file {SEED} --nav-file {NAV}

================================================================================
END COLLABTUNES MASTER DEPLOYMENT SEQUENCE
================================================================================
