The Terminal prompt I started with: cd /Users/kirkmasden/Desktop/AppSheetAnalysis/
kirkmasden@Kirks-MacBook-Pro AppSheetAnalysis % source venv/bin/activate
(venv) kirkmasden@Kirks-MacBook-Pro AppSheetAnalysis % python appsheet_parser_and_orphan_detector-main/master_parser_and_orphan_detector.py "MyApp_Data/Application Documentation.html"

============================================================
        đŸ› ī¸  AppSheet HTML Documentation Parser  
                     and Orphan Detector      🔍
============================================================

   Project director: Kirk Masden
   Chief coder: Claude Opus 4

   Input directory: /Users/kirkmasden/Desktop/AppSheetAnalysis/MyApp_Data
   Output directory: /Users/kirkmasden/Desktop/AppSheetAnalysis/20250907_124504_MyApp_Data_parse
   Time: 2025-09-07 12:45:04

============================================================
  PHASE 1: Parsing Tables and Slices
============================================================

📊 Extracting data sources...
  ✓ Found 16 tables (9 regular, 1 system, 6 process)

  📊 Complete Table Summary:

  📁 Regular Tables: 9 (1,104 columns total)
     ├─ Archive: 84 columns
     ├─ Kankaku: 172 columns
     ├─ Options: 73 columns
     ├─ Overall: 125 columns
     ├─ Progress: 168 columns
     ├─ Seminar: 41 columns
     ├─ Settings: 189 columns
     ├─ Stats: 237 columns
     ├─ Welcome: 15 columns

  📁 System Table: 1 (15 columns total)
     └─ _Per User Settings: 15 columns

  📁 Process Tables: 6 (1,104 columns total)
     ├─ Handle updated Kankaku record Process Table: 173 columns
     ├─ Process for Language change Bot Process Table: 192 columns
     ├─ Switch Enum Output: 189 columns
     ├─ Switch cram language Output: 189 columns
     ├─ Switch size language Output: 189 columns
     └─ trigger update Output: 172 columns

  📊 Total number of columns: 2,223 ✓
  📊 Total number of tables: 16 ✓
  📋 Loaded 62 slice-to-table mappings
  ✅ Slices saved to: appsheet_slices.csv

  📊 Regular tables to be analyzed (system and process tables excluded):

  📁 Number of tables: 9
   ├─ Archive (6 slices)
      ├─ Archive 1: 15 actions, 84 columns
      ├─ Archive 1DW: 2 actions, 50 columns
      ├─ Archive 2WD: 2 actions, 50 columns
      ├─ Archive table 2: 1 action, 53 columns
      ├─ Archive table 3: 1 action, 51 columns
      └─ Graph: 1 action, 84 columns
   ├─ Kankaku (9 slices)
      ├─ All Cards for menu: 24 actions, 108 columns
      ├─ Card stats: 1 action, 92 columns
      ├─ Card stats 2: 0 actions, 51 columns
      ├─ D to W: 9 actions, 56 columns
      ├─ Definition: 25 actions, 63 columns
      ├─ Finished cards: 0 actions, 92 columns
      ├─ Todays Cards: 11 actions, 152 columns
      ├─ W to D: 17 actions, 61 columns
      └─ Word: 21 actions, 65 columns
   ├─ Options (4 slices)
      ├─ Add menu 1: 28 actions, 73 columns
      ├─ Archive index: 5 actions, 42 columns
      ├─ Browse Archive: 9 actions, 44 columns
      └─ Seminar 2: 15 actions, 73 columns
   ├─ Overall (1 slice)
      └─ Overall slice: 1 action, 56 columns
   ├─ Progress (1 slice)
      └─ Last in progress: 1 action, 168 columns
   ├─ Seminar (2 slices)
      ├─ Seminar slice: 20 actions, 41 columns
      └─ Seminar slice all: 13 actions, 41 columns
   ├─ Settings (27 slices)
      ├─ Cram: 10 actions, 95 columns
      ├─ Cram 2: 8 actions, 189 columns
      ├─ DWend: 2 actions, 66 columns
      ├─ Dictionary: 9 actions, 85 columns
      ├─ Dictionary list: 9 actions, 85 columns
      ├─ Error: 8 actions, 189 columns
      ├─ Error 2: 1 action, 189 columns
      ├─ Help: 6 actions, 189 columns
      ├─ Language flag: 3 actions, 69 columns
      ├─ ListNoCards: 2 actions, 64 columns
      ├─ Mail: 1 action, 189 columns
      ├─ Movie list: 13 actions, 97 columns
      ├─ NoCards: 1 action, 69 columns
      ├─ NoCardsCram: 1 action, 69 columns
      ├─ NoDtoW: 1 action, 189 columns
      ├─ NoWtoD: 1 action, 189 columns
      ├─ Number to add: 1 action, 66 columns
      ├─ Position: 1 action, 61 columns
      ├─ Schedule: 4 actions, 113 columns
      ├─ Session slice: 13 actions, 74 columns
      ├─ Settings import: 3 actions, 71 columns
      ├─ System language: 1 action, 189 columns
      ├─ Time zone: 1 action, 100 columns
      ├─ WDend: 2 actions, 68 columns
      ├─ Web cards: 1 action, 189 columns
      ├─ Word size: 1 action, 64 columns
      └─ YouGlish: 9 actions, 85 columns
   ├─ Stats (6 slices)
      ├─ Card statistics: 2 actions, 19 columns
      ├─ Dictionaries: 188 actions, 237 columns
      ├─ Stats Explanation: 0 actions, 237 columns
      ├─ Stats index: 1 action, 19 columns
      ├─ Stats index J: 1 action, 19 columns
      └─ Stats setsumei: 0 actions, 50 columns
   └─ Welcome (6 slices)
      ├─ Good job images: 1 action, 15 columns
      ├─ Hang in there images: 1 action, 15 columns
      ├─ Hello: 1 action, 15 columns
      ├─ Misc images: 1 action, 15 columns
      ├─ Morning: 1 action, 15 columns
      └─ Welcome slice: 4 actions, 15 columns

  📊 Total number of slices: 62
  📊 Total number of columns in regular tables: 1,104

============================================================
  PHASE 2: Parsing Columns
============================================================

  📂 Loading slice mapping from appsheet_slices.csv
  ✅ Loaded 62 slice mappings
  📊 Extracting columns...
  🔍 Scanning for system-generated tables...
  ✅ Found 7 system-generated tables to filter
      - Handle updated Kankaku record Process Table
      - Process for Language change Bot Process Table
      - Switch Enum Output
      - Switch cram language Output
      - Switch size language Output
      - _Per User Settings
      - trigger update Output
  âš ī¸  System-generated tables filtered from results:
      - Handle updated Kankaku record Process Table
      - Process for Language change Bot Process Table
      - Switch Enum Output
      - Switch cram language Output
      - Switch size language Output
      - _Per User Settings
      - trigger update Output
    Total: 1104 columns across 9 tables (7 system-generated tables filtered)
  ✅ Columns saved to: appsheet_columns.csv

============================================================
  PHASE 3: Parsing Format Rules
============================================================

  📂 Loading slice mapping from appsheet_slices.csv
  ✅ Loaded 62 slice mappings
🎨 Extracting format rules...
  ✓ Found 121 format rules

  📊 Format Rules Summary:
    Archive: 5 rules
    Kankaku: 21 rules
    Options: 3 rules
    Overall: 4 rules
    Progress: 3 rules
    Seminar: 10 rules
    Settings: 26 rules
    Stats: 49 rules

    Total formatting targets:
      Columns: 296
      Actions: 104
    âš ī¸  Disabled rules: 2
  ✅ Format rules saved to: appsheet_format_rules.csv

============================================================
  PHASE 4: Parsing Actions
============================================================

  📂 Loading slice mapping from appsheet_slices.csv
  ✅ Loaded 62 slice mappings
⚡ Extracting actions...

  📂 Loading system action data from actions.txt
  📊 Found 581 actions in text file (96 system-generated)

  âš ī¸  WARNING: Duplicate action names detected!

  Found duplicate action names in your app:
    â€ĸ "View Ref (System) (in table: Options)" appears 2 times

  ISSUE: When actions share the same name, we cannot reliably determine
  which is system-generated and which is user-created. This prevents
  accurate orphan detection for these actions.

  RECOMMENDATION: Rename the user-created action(s) to have unique names.
  (Note: System-generated action names cannot be changed)

  How would you like to proceed?
    1) Exit and fix the issue
       - Edit your app in AppSheet to rename the user-created action(s)
       - Generate fresh HTML and text files
       - Run the analysis again
    2) Continue with limitations
       - Duplicate-named actions will be marked as "Unsure" status
       - These actions will be excluded from orphan detection
       - All other orphan detection will proceed normally

  Choice (1/2): 2

  Continuing with limitations...

  âš ī¸  Warning: The following action names contain multiple consecutive spaces:
    â€ĸ View Ref (Card import)  J
    â€ĸ goodreads  toggle 1
    â€ĸ goodreads  toggle 2
    â€ĸ BrainyQuite  toggle 1
    â€ĸ BrainyQuite  toggle 2
    Consider renaming them in AppSheet to avoid confusion.


  📊 Actions Summary:

    Total actions found: 581
      User-created: 484
      System-generated: 95
      Unsure (duplicates): 2

    By category:
      Delete: 7
      Edit: 6
      Execute a group of actions: 53
      Execute an action on a set of rows: 55
      Go to a website: 143
      Make a new record: 2
      Navigate: 143
      Write: 172
  ✅ Actions saved to: appsheet_actions.csv

============================================================
  PHASE 5: Parsing Views
============================================================

đŸ‘ī¸  Extracting views...
  📂 Loading slice mapping from appsheet_slices.csv
  ✅ Loaded 62 slice mappings
  📂 Loading actions mapping from appsheet_actions.csv
  ✅ Loaded 565 action mappings
  📂 Loading columns data from appsheet_columns.csv
  ✅ Loaded column data for 9 tables
  📂 Loading actions data from appsheet_actions.csv
  ✅ Loaded action data for 9 tables
  📊 Found 205 view headers in HTML
  📂 Loading view mappings from views1.txt and views2.txt
  📊 Found views1.txt (169 views) and views2.txt (256 views)
  ✅ Identified views2.txt as containing system views
  ✅ Found 87 system views and 169 user views
  ✓ Found 205 views

  📊 Views Summary:
    Primary: 27 views
    Menu: 14 views
    Ref: 164 views

    System status:
      System views: 73
      User views: 132

    By type:
      dashboard: 2
      deck: 9
      detail: 142
      form: 39
      table: 13
  ✅ Views saved to: appsheet_views.csv

============================================================
  PHASE 6: Parsing Navigation Targets
============================================================

  📂 Loading actions from appsheet_actions.csv
  ✅ Loaded 581 actions
     ├─ Navigation actions: 143
     ├─ Group actions: 53
     └─ Other actions skipped: 385
        ├─ External URLs: 143
        ├─ Data modifications: 185
        └─ Other types: 57

  đŸŽ¯ Extracting navigation targets...
  ✓ Processing 196 actions (143 navigation + 53 group)

  âš ī¸  Found 1 unparseable navigation expression

  📊 Navigation Targets Extracted:

    Navigation targets: 310
      ├─ Direct (#control=, #page=): 31
      ├─ LINKTOVIEW: 174
      └─ LINKTOROW: 53

    💡 Note: Actions with IFS/IF conditions generate multiple targets
       (one per branch), so targets may be greater than actions

    Unparseable expressions: 1
      ├─ Unknown pattern: 1

    Group actions recorded: 53

    Context conditions detected: 208
      ├─ View-based (CONTEXT("View")): 205
      ├─ ViewType-based: 3
      └─ Table-based: 0

  ✅ Navigation targets saved to: action_targets.csv
  âš ī¸  Unparseable expressions saved to: action_targets_unparseable.csv

============================================================
  PHASE 7: Generating Navigation Edges
============================================================

  📂 Loading required data files...
  ✓ Loaded 310 navigation targets
  ✓ Loaded 205 views
  ✓ Loaded 565 actions
  ✓ Loaded columns for 9 tables
  ✓ Loaded 62 slices
  đŸŽ¯ Generating navigation edges...

  ✅ Wrote 657 navigation edges to navigation_edges.csv

  📊 Edge Generation Statistics:
     ├─ Views processed: 205
     ├─ Actions checked: 6009
     ├─ Group actions expanded: 257
     ├─ Edges created: 657
     ├─ Edges blocked by conditions: 7450
     └─ Edges blocked by visibility: 1482

============================================================
  Parsing complete!
============================================================

📊 Summary of data to be analyzed:
   ✅ Data Sources: 71 total
      ├─ Tables: 9
      └─ Slices: 62
   ✅ Columns: 1,104 total
      ├─ Physical: 248
      └─ Virtual: 856
   ✅ Format rules: 121
   ✅ Actions: 581 total
      ├─ System-generated: 95
      ├─ User-created: 484
      └─ Unknown (not in actions.txt): 2
   ✅ Views: 205 total
      ├─ System-generated: 73
      └─ User-created: 132
   ✅ Navigation targets: 310

============================================================
📊 Starting orphan detection...
============================================================

============================================================
  PHASE 8: View Orphan Detection
============================================================

🔍 Starting View Orphan Detection...
  📂 Directory: 20250907_124504_MyApp_Data_parse

  ✔ Validating required files...

  📊 Extracting views...
  ✔ Found 205 total views
    System-generated: 73
    User-created: 132

  📊 Loading additional data:
  Loaded column data for 9 tables

  🔍 Searching for potential user view orphans...
  Loading navigation edges from navigation_edges.csv...
    ✓ Loaded 657 navigation edges
    ✓ Graph contains 170 source views
    ✓ Identified 41 root views (primary + menu)
    ✓ Found 136 reachable views from 41 roots
  🔍 Searching for unused system views...
  Loading navigation edges from navigation_edges.csv...
    ✓ Loaded 657 navigation edges
    ✓ Graph contains 170 source views
    ✓ Identified 41 root views (primary + menu)
    ✓ Found 136 reachable views from 41 roots

  💾 Writing results...
    ✔ Potential user orphan views written to: potential_view_orphans.csv
    ✔ Unused system views written to: unused_system_views.csv

  📊 View Orphan Detection Summary:
    Total views analyzed: 205
    System-generated views: 73
    User-created views: 132

    âš ī¸  Potential user view orphans found: 9
      Reason Breakdown:
        - Detail view not reachable from any root view: 3 views
        - Ref view not reachable from any root view: 6 views

    â„šī¸  Unused system views found: 63
      Reason Breakdown:
        - System detail view not reachable from any root view: 27 views
        - System ref view not reachable from any root view: 36 views

      Note: System views cannot be deleted but are tracked
      for accurate orphan detection in actions and columns.

============================================================
  PHASE 9: Virtual Column Orphan Detection
============================================================

  ✓ Loaded 63 unused system views to exclude
🔍 Starting Virtual Column Orphan Detection...
  📂 Directory: 20250907_124504_MyApp_Data_parse

  ✓ Validating required files...

  📊 Loading unused system views...
  ✓ Loaded 63 unused system views to exclude

  📊 Extracting virtual columns...
  ✓ Found 856 virtual columns

  🔍 Searching for potential orphans...
    Processing: 100/856 virtual columns...
    Processing: 200/856 virtual columns...
    Processing: 300/856 virtual columns...
    Processing: 400/856 virtual columns...
    Processing: 500/856 virtual columns...
    Processing: 600/856 virtual columns...
    Processing: 700/856 virtual columns...
    Processing: 800/856 virtual columns...

  💾 Writing results...
    ✓ Results written to: potential_virtual_column_orphans.csv

  📊 Orphan Detection Summary:
    Total virtual columns analyzed: 856
    System-generated REF_ROWS columns: 18
    Label columns (UI display): 2
    User-created virtual columns: 836

    âš ī¸  Potential orphans found: 70

  ✅ Results saved to: potential_virtual_column_orphans.csv

============================================================
  PHASE 10: Action Orphan Detection
============================================================

  ✓ Loaded 63 unused system views to exclude
  â„šī¸ No bot_actions.txt file found - bot detection disabled
🔍 Starting Action Orphan Detection...
  📂 Directory: 20250907_124504_MyApp_Data_parse

  ✓ Validating required files...

  📊 Loading unused system views...
  ✓ Loaded 63 unused system views to exclude

  📊 Extracting actions...
  ✓ Found 581 total actions

  🔍 Searching for potential orphans...
  ✓ Loaded 205 views for visibility checking

  💾 Writing results...
    ✓ Results written to: potential_action_orphans.csv

  📊 Action Orphan Detection Summary:
    Total actions analyzed: 581
    System-generated actions: 95 (excluded)
    Actions with status marked 'Unsure': 2 (excluded)
    User-created actions: 484

    âš ī¸  Potential orphans found: 23

    Orphan breakdown by type:
      Standard orphans (can be deleted): 21
      Unreachable in sequence (DO NOT delete directly): 2

    Table breakdown of potential orphans:
     - Archive: 1
       â€ĸ Move to main data (card import) 3
     - Kankaku: 10
       â€ĸ View Ref (D to W Link to card stats) 3
       â€ĸ WD to session stats
       â€ĸ DW card stats V DW Set aside
       â€ĸ WD card stats V WD Set aside
       â€ĸ Go to card stats 3
       ... and 5 more
     - Options: 5
       â€ĸ Go to finished table (Options)
       â€ĸ Go to Browse archive (Options)
       â€ĸ View Ref (Card import)
       â€ĸ View Ref (Card import)  J
       â€ĸ Go to empty message J
     - Seminar: 1
       â€ĸ Move to main data (card import) 2
     - Settings: 6
       â€ĸ Go to Cram setting (settings)
       â€ĸ Activate when cram is on âš ī¸ UNREACHABLE
         Listed but unreachable in:
           "Cram onoff switch"
           "Cram onoff switch 2"
       â€ĸ Activate when cram is off âš ī¸ UNREACHABLE
         Listed but unreachable in:
           "Cram onoff switch"
           "Cram onoff switch 2"
       â€ĸ Go to options menu
       â€ĸ Seminar all enum switch trigger
       ... and 1 more

    💡 Note: Actions used exclusively by bots could not be detected.
       To exclude bot-used actions, create a bot_actions.txt file
       listing one action name per line in the parse directory.

  âš ī¸ IMPORTANT: Unreachable actions require special handling!
    In order to avoid disconcerting error messages, unreachable actions
    should be removed from group actions that hold them (shown above)
    before deletion is attempted.

============================================================
  PHASE 11: Format Rule Orphan Detection
============================================================

🔍 Starting Format Rule Orphan Detection...
  📂 Directory: 20250907_124504_MyApp_Data_parse

  ✓ Validating required files...

  📊 Loading data...
  ✓ Found 121 format rules

  🔍 Searching for potential orphans...

  💾 Writing results...
    ✓ Results written to: potential_format_rule_orphans.csv

  📊 Format Rule Orphan Detection Summary:
    Total format rules analyzed: 121
    Disabled rules (excluded): 2
    Active rules checked: 119

    âš ī¸  Potential orphans found: 5

  Table breakdown of potential orphans:
     - Kankaku: 3
       â€ĸ Card stats
       â€ĸ Card stats 2
       â€ĸ Cram 2
     - Settings: 1
       â€ĸ Header size 2
     - Stats: 1
       â€ĸ New Format Rule

  ✅ Results saved to: potential_format_rule_orphans.csv

============================================================
  PHASE 12: Slice Orphan Detection
============================================================

🔍 Starting Slice Orphan Detection...
  📂 Directory: 20250907_124504_MyApp_Data_parse

  ✓ Validating required files...

  📊 Extracting slices...
  ✓ Found 62 slices

  🔍 Searching for potential orphans...
    Checking view data sources...
    Checking action references...
    Checking column formula references...
    Checking format rule references...

  💾 Writing results...
    ✓ Results written to: potential_slice_orphans.csv

  📊 Slice Orphan Detection Summary:
    Total slices analyzed: 62

    âš ī¸  Potential orphans found: 5

    Table breakdown of potential orphans:
      - Archive: 2
        â€ĸ Archive 1DW
        â€ĸ Archive 2WD
      - Kankaku: 1
        â€ĸ Card stats 2
      - Overall: 1
        â€ĸ Overall slice
      - Stats: 1
        â€ĸ Stats setsumei

  ✅ Results saved to: potential_slice_orphans.csv

============================================================
  PHASE 13: Phantom View Reference Detection
============================================================

🔍 Starting Phantom View Reference Detection...
  📂 Directory: ./20250907_124504_MyApp_Data_parse

  ✔ Validating required files...
  
  ✔ Found 205 known views
  ✔ Using pre-parsed action targets from action_targets.csv
  ✔ Scanning 581 action only_if conditions
  ✔ Scanning 1104 Columns
  ✔ Scanning 205 Views
  ✔ Scanning 121 Format Rules
  
  📊 Total expressions analyzed: 1887

  💾 Writing results...
  
  âš ī¸  Found 9 expressions with phantom references
  ✅ Results saved to: potential_phantom_view_references.csv
  
  📊 Unique phantom views found (sorted by frequency):
       2x Card import
       2x Options menu view J
       1x D to W Card Stats
       1x Card Import
       1x Add menu 2
       1x Add menu 2 J
       1x Archive menu
       1x All Cards
       1x Card stats 3

============================================================
  Orphan detection complete!
============================================================

📊 Summary of potential orphans found:
   âš ī¸  Virtual columns: 70
   âš ī¸  Actions: 23
   âš ī¸  Views: 9
   âš ī¸  Format rules: 5
   âš ī¸  Slices: 5
   âš ī¸  Phantom view references: 9

   📊 Total potential orphans: 121

   📁 Results saved to: 20250907_124504_MyApp_Data_parse


✨ Analysis complete! Your AppSheet app structure has been fully analyzed.


======================================================================
PARSING AND ORPHAN DETECTION COMPLETE
======================================================================

Would you like to explore dependencies now? (y/n):