# DIS MASTER COPY — VERSION MANIFEST
## Versioning System for the BPHEN/DIS

### Purpose
This manifest tracks every version of the DIS code. Each version is a complete, deployable Cloudflare Worker file. If an upgrade causes problems, JU can revert to any previous version by deploying that file via Wrangler.

### How to Revert
1. Copy the desired version file from this directory
2. Replace the production worker file: `cp DIS_vX.X.X.js /workspace/ida-live-audit/deploy-worker-v2/ida-archive-worker.js`
3. Deploy: `cd /workspace/ida-live-audit/deploy-worker-v2 && CLOUDFLARE_API_TOKEN=$TOKEN npx wrangler deploy`
4. Verify at https://ida.bphen.us

---

## VERSION HISTORY

### DIS_BASE_v3.1.0_pre_upgrade.js
- **Date:** August 31, 2026 (pre-session baseline)
- **Lines:** 3,902
- **Status:** BASE MASTER — the clean, basic system before any SuperNinja upgrades
- **Tool Architecture:** 4 tools (search_archive [text-only, limit 5], web_search, list_project_folders, append_project_note)
- **maxTurns:** 5
- **System Prompt:** Minimal — instructs Ida to search archive first, use web_search for supplemental research, no metadata field methodology
- **UI:** Pre-round5 sidebar (no terminal footer copy/save buttons)
- **PENS in System Prompt:** YES (the embedding issue is present in the base)
- **When to use this version:** When JU wants to revert to the absolute basics — the system as it was before SuperNinja's involvement. This is the "clean DIS" baseline.

### DIS_v3.1.1_ida_tool_upgrade.js
- **Date:** August 31, 2026
- **Lines:** 4,304
- **Status:** SUPERSEDED by v3.1.2 (was production, now archived)
- **Deployed version ID:** 42b38069-d487-442d-b463-859c9db76706
- **Changes from BASE:**
  1. search_archive upgraded with metadata field filtering (primary_cycle, source_type, phenomenon, era, date_from, date_to) + rich results (full metadata per record, limit 10 max 30)
  2. cycle_distribution tool added (groups records by date, counts per cycle)
  3. detect_transitions tool added (sliding-window cycle dominance shift detection)
  4. maxTurns increased from 5 to 12
  5. TERMINAL_SYSTEM_PROMPT rewritten with metadata field query methodology + tool descriptions + LIVE-first default + warning against text-searching for cycle terms
  6. terminalStepLabel updated to include cycle_distribution and detect_transitions labels
  7. Round5 sidebar UI improvements (terminal footer with copy/save buttons, scrollbar styling)
- **Tool Architecture:** 6 tools (search_archive [metadata fields, limit 10], cycle_distribution, detect_transitions, web_search, list_project_folders, append_project_note)
- **maxTurns:** 12
- **PENS in System Prompt:** YES (PENS was still embedded in this version)
- **When to use this version:** Reference only. This was the first SuperNinja upgrade. If v3.1.2 causes problems, revert to this version (note: PENS will be back).

### DIS_v3.1.2_pens_removed.js
- **Date:** August 31, 2026
- **Lines:** 4,025
- **Status:** ARCHIVED (superseded by v3.1.3)
- **Deployed version ID:** 00023f23-a208-45ef-8676-f49effb545f0
- **Front-end deploy ID:** 02c043d2-c877-491c-a4d5-44186e23d7c8
- **Changes from v3.1.1:**
  1. **PENS removed from IDA_SYSTEM_PROMPT** — "PENS methodology studies" removed from Ida's identity description. Ida now reviews "archive records and workspace notes" (not "archive records, PENS methodology studies, and workspace notes").
  2. **PENS API route removed** — `/api/pens/methodology` and `/api/pens/methodology/training/{id}` endpoints no longer exist. The route handler `handlePens()` has been deleted.
  3. **PENS API functions removed** — `pensMethodology()`, `validPensAnalysisId()`, `pensTrainingAnalysis()`, `handlePens()` deleted (~100 lines, ~4KB).
  4. **PENS UI functions removed** — `pensMessage()`, `pensButton()`, `pensHeader()`, `promptPensStudy()`, `openPensStudy()`, `renderPensMethodology()`, `openPensMethodology()` deleted (~174 lines, ~7.7KB).
  5. **PENS_FOLDER_NAME constant removed** — `"PENS Methodology"` folder constant deleted.
  6. **createProjectFolder fixed** — Removed the `isSystem` check that opened the PENS folder via `openPensMethodology()`.
  7. **renderProjectFolders fixed** — Removed the line that appended the PENS folder to the workspace sidebar.
  8. **App descriptions updated** — Drive app description and app launcher description updated to remove PENS references.
  9. **Front-end PENS removed** — PENS Methodology folder div removed from `index.html` workspace sidebar; `pens` entry removed from `FOLDER_SEED` in `main-navy.js`.
- **Tool Architecture:** 6 tools (unchanged from v3.1.1 — search_archive, cycle_distribution, detect_transitions, web_search, list_project_folders, append_project_note)
- **maxTurns:** 12 (unchanged)
- **PENS in System Prompt:** NO — PENS has been completely removed from the DIS
- **PENS analyses saved:** All 6 PENS training analyses + methodology catalog extracted and saved to `/workspace/pens_extracted/` before removal
- **When to use this version:** Reference only. PENS was removed from the DIS in this version. Superseded by v3.1.3 which adds the PENS Records app and Media Player app.

### DIS_v3.1.3_apps_updated.js ← ARCHIVED (superseded by v3.1.4)
- **Date:** August 31, 2026
- **Lines:** 4,122
- **Status:** ARCHIVED (superseded by v3.1.4)
- **Deployed version ID:** 2d046b4e-82ea-4c44-bb8c-96b41a78aa81
- **SHA-256:** 0d488c99b07c9ccbff5907c6d0b53bef5943ab682d6dc7abd9170fec4d0c97b2
- **Changes from v3.1.2:**
  1. **Private Workspace app renamed** → "Perceptual Epistemology Notation System™" (tile label) / "Supabase PENS Records" (tile subtitle). This is JU's PENS analysis application.
  2. **openDeskNotice drive copy updated** → title="PENS RECORDS", subtitle="Supabase PENS Records", new description explaining the PENS app and the DIS-only archive rule.
  3. **New Media Player app added** → "Media Player" (tile label) / "Analytical Viewing" (tile subtitle). A generic video/audio player with URL input and file picker.
  4. **Application count updated** → "6 AVAILABLE" → "7 AVAILABLE"
  5. **New 'play' icon** added to deskIcon SVG registry (triangle polygon).
  6. **New openMediaPlayer() function** → interactive window with `<video>` and `<audio>` elements, URL input field, file picker button, auto-detect media type (video vs audio by file extension or MIME type), native HTML5 controls.
  7. **New CSS** for media player window (stage, video, audio, placeholder, input row, buttons).
  8. **Click handler updated** → media app routes to `openMediaPlayer()`.
- **Tool Architecture:** 6 tools (unchanged — search_archive, cycle_distribution, detect_transitions, web_search, list_project_folders, append_project_note)
- **maxTurns:** 12 (unchanged)
- **App Launcher:** 7 apps (Text Editor, PENS Records, Email, Calendar, Notes, BPHEN Archive™, Media Player)
- **Save Rules:** Archive = DIS-only (Ida sole writer). PENS Records = JU's analyses. Everything on Supabase.
- **When to use this version:** Reference only. The app launcher was updated with JU's PENS Records application and a new Media Player application. Superseded by v3.1.4 which redesigns the left sidebar pop-out windows.

---

### DIS_v3.1.4_popout_redesign.js ← CURRENT PRODUCTION
- **Date:** September 1, 2026
- **Lines:** 4,290
- **Status:** CURRENTLY DEPLOYED (production)
- **SHA-256:** 4500b6a070a64f2064f0699f3c46305fea4a1d56be0f69b2a618c58fdff1d69d
- **Changes from v3.1.3:**
  1. **`applyReaderFrame()` modified** → accepts a `sizeProfile` parameter ("terminal", "standard", "slim", or default). Sets per-pop-out widths: terminal=860px, standard=520px, slim=380px. Also cleans up stale pop-down menus and stale terminal footers on each open.
  2. **`installUniversalOverlayActions()` modified** → removed the minimize (−) button entirely. Creates only the gold "⋯" pop-down trigger + ✕ close button.
  3. **New `installPopdownMenu(overlay, items)` function** → creates a dropdown menu inside `.uni-overlay-actions`. Items support `{ label, onClick, danger, detailed, icon, desc, divider }`. Detailed items (terminal) show icon + label + description. Simple items (SUBMIT/RESET) are uppercase, bold. Danger items are red. Menu positioned at `right:30px;top:100%`. Click-outside-to-close handler included.
  4. **TERMINAL pop-out** → title is now `<span>TERMINAL</span>` (icon removed), `applyReaderFrame(..., "terminal")`, console height 420px (was 340px), no footer. Pop-down has 5 detailed options: Copy Session, Save to Notes, Re-run Task, Expand View, Print.
  5. **QUICK TASK pop-out** → title `<span>QUICK TASK</span>`, `applyReaderFrame(..., "standard")`, metadata text removed, big SEND button removed. Just a textarea with a SUBMIT/RESET pop-down.
  6. **NEW THREAD pop-out** → title `<span>NEW THREAD</span>`, `applyReaderFrame(..., "standard")`, big CREATE THREAD button removed. THREAD TITLE field + PROJECT FOLDER dropdown with a SUBMIT/RESET pop-down.
  7. **PROJECT FOLDERS pop-out** → title `<span>PROJECT FOLDERS</span>`, `applyReaderFrame(..., "slim")`, simplified to create-only mode (manage mode — rename/delete folders — removed). Owner verification gate preserved but uses pop-down SUBMIT instead of a big button. Folder management will eventually live in the Utility Tab.
  8. **UTILITY TAB pop-out** → deferred per JU. Not modified in this version.
  9. **`renderTerminalFooter()`** still exists as dead code but is no longer called.
- **Tool Architecture:** 6 tools (unchanged — search_archive, cycle_distribution, detect_transitions, web_search, list_project_folders, append_project_note)
- **maxTurns:** 12 (unchanged)
- **App Launcher:** 7 apps (unchanged — Text Editor, PENS Records, Email, Calendar, Notes, BPHEN Archive™, Media Player)
- **Save Rules:** Archive = DIS-only (Ida sole writer). PENS Records = JU's analyses. Everything on Supabase. (unchanged)
- **When to use this version:** This is the current production version. The left sidebar pop-out windows have been redesigned per JU's approved v4 FINAL design — universal style with gold trim, function-based sizing, no title icons, left-aligned content, and pop-down action menus instead of big stretched buttons.

---

## PENS EXTRACTION (Preserved Before Removal)

Before removing PENS from the DIS, all PENS content was extracted from Supabase and saved to `/workspace/pens_extracted/`:

| File | Description |
|------|-------------|
| `PENS_METHODOLOGY_CATALOG.json` | Full methodology catalog (framework: writing method, universal sections, glossary, special section rules) |
| `JVA-20251023-LIQD_*` | "Liquidation as Integration: How Access Replaced Ownership" |
| `JVA-20251025-LDWT_*` | "Leader-Waiting: Passivity Dressed as Respect" (has special sections) |
| `JVA-20260201-WJCC_*` | "White Jesus and the Cosmic Contradiction" |
| `JVA-20260209-BYBF_*` | "Beyond Black Faces: How the Budget Kept the Teeth" (has special sections) |
| `JVA-20260518-EPCT_*` | "Epistemology and the Permission Called Truth" |
| `JVA-20260531-ARKC_*` | "The Archive Kept the Chain: How Records Mistook Custody for..." |

Each analysis has both a `_full.json` (complete Supabase record) and `_study_text.txt` (plain text of the analysis). See `EXTRACTION_INDEX.md` for SHA-256 hashes and details.

---

## STORAGE LOCATIONS

The master copy is saved in TWO places for redundancy:

### 1. Supabase (Database Storage)
- Table: `bphen_dis_master_versions` — append-only version registry (immutable by design)
- Table: `ida_workspace_notes` — documentation and workspace notes
- Purpose: Persistent database storage, queryable, version-controlled

### 2. Cloudflare Pages (Documentation Site)
- Project: `bphen-dis-master-copy` — URL: `https://bphen-dis-master-copy.pages.dev`
- Contains: Conceptual docs, code docs, version manifest, versioned JS files, front-end docs
- Purpose: Redundant storage outside Supabase, accessible via URL, human-readable

### 3. Local Workspace (Working Copies)
- `/workspace/dis_master_copy/` — all documentation + version files + front-end files
- `/workspace/ida-live-audit/deploy-worker-v2/` — the active working copy for deployment
- `/workspace/pens_extracted/` — PENS content preserved before removal

---

## WHAT CONSTITUTES A "VERSION"

A new version is created when ANY of the following changes:
1. Ida's tool architecture changes (tools added, removed, or modified)
2. Ida's system prompt changes (IDA_SYSTEM_PROMPT or TERMINAL_SYSTEM_PROMPT)
3. maxTurns changes
4. API endpoints change (added, removed, or modified)
5. Supabase table schema changes
6. Authentication changes
7. Significant UI changes
8. PENS or methodology framework changes

A new version is NOT created for:
- Minor CSS/styling tweaks
- Text label changes
- Bug fixes that don't change functionality
- Performance optimizations

Each version file must pass `node --check` validation before being saved as a master copy.

---

## GOING FORWARD (JU's Directive)

> "Every update must also update the master copy on both sites — Cloudflare and Supabase — from now on, until it becomes done."

Every future DIS update will:
1. Create a new versioned JS file in `/workspace/dis_master_copy/versions/`
2. Update this VERSION_MANIFEST.md with the new version entry
3. Insert a new record in Supabase `bphen_dis_master_versions`
4. Update the Cloudflare Pages master copy site (`bphen-dis-master-copy.pages.dev`)
5. Deploy the updated worker to Cloudflare
6. Deploy the updated front-end to `bphen-dis.pages.dev` (if front-end changes)
