9 Commits

Author SHA1 Message Date
Z. Cliffe Schreuders
87fae7cb07 refactor: Simplify unlock loading UI dramatically
User correctly pointed out the loading UI was over-engineered.

## Simplifications:

### Before (over-complicated):
- Complex timeline management
- Success/failure flash effects (green/red)
- Spinner alternatives
- Stored references on sprites
- Timeline cleanup logic
- ~150 lines of code

### After (simple):
- startThrob(sprite) - Blue tint + pulsing alpha
- stopThrob(sprite) - Kill tweens, reset
- ~20 lines of code

## Why This Works:

1. **Door sprites get removed anyway** when they open
2. **Container items transition** to next state automatically
3. **Game already shows alerts** for success/error
4. **Only need feedback** during the ~100-300ms API call

## API Changes:

- showUnlockLoading() → startThrob()
- clearUnlockLoading() → stopThrob()
- No success/failure parameter needed
- No stored references to clean up

## Result:

From 150+ lines down to ~30 lines total.
Same UX, much simpler implementation.

User feedback: "Just set the door or item to throb, and remove when
the loading finishes (the door sprite is removed anyway), and if it's
a container, just follow the unlock with a removal of the animation."
2025-11-20 15:37:38 +00:00
Z. Cliffe Schreuders
266bc7a7ca docs: Clarify CSRF token handling for Hacktivity integration
User correctly noted that Hacktivity's application layout already includes
csrf_meta_tags, so we don't need to add them again.

## Changes:

### Section 9.3.1: Layout Strategy
- Split into Option A (Hacktivity layout - recommended) and Option B (standalone)
- **Option A (Recommended):** Read from existing meta tag
  - Uses Hacktivity's csrf_meta_tags (already present in layout)
  - No duplicate meta tags needed
  - Reads via: document.querySelector('meta[name="csrf-token"]')?.content
- **Option B:** Standalone layout
  - For when engine needs separate layout
  - Must add <%= csrf_meta_tags %> to engine layout
  - Can use <%= form_authenticity_token %> directly

### Section 9.3.3: Token Reading Logic
- Updated config.js to try multiple sources:
  1. window.breakEscapeConfig.csrfToken (if explicitly set)
  2. meta[name="csrf-token"] tag (from Hacktivity layout)
- Better error messages showing all sources checked
- Logs which source provided the token

### Section 9.3.5: Issue #2 Solution
- Updated to reference the fallback logic in 9.3.3
- Added debugging console commands
- Shows how to check all meta tags

## Key Points:

-  Hacktivity layout csrf_meta_tags are reused (don't duplicate)
-  Fallback chain ensures token found from either source
-  Clear guidance for both integration scenarios
-  Better debugging when token is missing

This aligns with Rails best practices and Hacktivity's existing setup.
2025-11-20 15:37:38 +00:00
Z. Cliffe Schreuders
cece95cd7f feat: Add critical implementation details based on review
Based on comprehensive codebase review, enhanced implementation plans with:

## Phase 3 Updates (Scenario Conversion):
- Complete bash script to convert all 26 scenarios to ERB structure
- Explicit list of 3 main scenarios (ceo_exfil, cybok_heist, biometric_breach)
- List of 23 test/demo scenarios for development
- Instructions to rename .json to .erb (actual ERB code added later in Phase 4)
- Preserves git history with mv commands
- Both automated script and manual alternatives provided

## Phase 9 Updates (CSRF Token Handling):
NEW Section 9.3: "Setup CSRF Token Injection"
- Critical security implementation for Rails CSRF protection
- Complete view template with <%= form_authenticity_token %>
- JavaScript config injection via window.breakEscapeConfig
- CSRF token validation and error handling
- Browser console testing procedures
- 5 common CSRF issues with solutions
- Fallback to meta tag if config missing
- Development vs production considerations

## Phase 9 Updates (Async Unlock with Loading UI):
ENHANCED Section 9.5: "Update Unlock Validation with Loading UI"
- New file: unlock-loading-ui.js with Phaser.js throbbing tint effect
- showUnlockLoading(): Blue pulsing animation during server validation
- clearUnlockLoading(): Green flash on success, red flash on failure
- Alternative spinner implementation provided
- Complete unlockTarget() rewrite with async/await server validation
- Loading UI shows during API call (~100-300ms)
- Graceful error handling with user feedback
- Updates for ALL lock types: pin, password, key, lockpick, biometric, bluetooth, RFID
- Minigame callback updates to pass attempt and method to server
- Testing mode fallback (DISABLE_SERVER_VALIDATION)
- Preserves all existing unlock logic after server validation

## Key Features:
- Addresses 2 critical risks from review (CSRF tokens, async validation)
- Solves scenario conversion gap (26 files → ERB structure)
- Maintains backward compatibility during migration
- Comprehensive troubleshooting guidance
- Production-ready security implementation

Total additions: ~600 lines of detailed implementation guidance
2025-11-20 15:37:38 +00:00
Z. Cliffe Schreuders
d2e3524b6b docs: Add comprehensive migration review (review1)
Complete codebase review against Rails Engine migration plans:

EXECUTIVE_SUMMARY.md (7KB, 243 lines):
- Overall assessment: READY FOR MIGRATION (95% confidence)
- Timeline: 10-12 weeks, ~64 hours total effort
- Zero blocking issues identified
- Key metrics and risk assessment
- Go/No-Go checklist

COMPREHENSIVE_REVIEW.md (47KB, 1,676 lines):
- Detailed current state analysis (95+ JS files, 800MB assets)
- Gap analysis with specific file references
- Risk matrix: 2 critical, 4 high, 3 medium (all mitigatable)
- Phase-by-phase recommendations with code examples
- Complete testing strategy
- Implementation checklists

Key Findings:
- Minimal client changes needed (~100 lines across 4 files)
- No architectural conflicts with current code
- All existing code well-organized and modular
- Clear path forward with realistic timeline

Recommendation: PROCEED WITH MIGRATION
2025-11-20 15:37:38 +00:00
Z. Cliffe Schreuders
5d22db5f69 docs: Add API reference and testing guide
Complete documentation for:
- 04_API_REFERENCE.md: All 9 API endpoints with examples
- 05_TESTING_GUIDE.md: Minitest strategy with fixtures and tests

These complete the documentation set along with the Hacktivity integration guide.
2025-11-20 15:37:38 +00:00
Z. Cliffe Schreuders
6e912eecec docs: Add Hacktivity integration guide (Phase 12)
Complete step-by-step guide for mounting BreakEscape engine in Hacktivity:
- Gemfile and bundle installation
- Route mounting at /break_escape
- Database migration installation
- User model compatibility verification
- Static asset configuration
- Session and CSRF setup
- Content Security Policy (CSP) configuration
- Testing integration
- Deployment to staging
- Troubleshooting guide
- Verification checklist
- Performance monitoring
- Rollback plan

This completes the full documentation set (7 files, ~140KB total)
2025-11-20 15:37:37 +00:00
Z. Cliffe Schreuders
48c9669925 docs: Add comprehensive README with navigation and quick start
- Complete documentation structure guide
- Quick start instructions
- Phase checklist for progress tracking
- Architecture summary with diagrams
- Troubleshooting section
- Philosophy and success criteria
- Technology stack overview
- Before/after comparison

Documentation set complete: 5 core files, fully self-contained
2025-11-20 15:37:37 +00:00
Z. Cliffe Schreuders
95ef8c654d docs: Add complete implementation plan (Phases 1-12)
Part 1 (Phases 1-6):
- Rails Engine setup with explicit commands
- Move files with mv (preserve git history)
- Create ERB scenario templates
- Database migrations and models
- Seed data (metadata only)
- Controllers with JIT Ink compilation

Part 2 (Phases 7-12):
- Pundit authorization policies
- Mission and game views
- Client API integration
- Comprehensive test suite
- Standalone mode support
- Final integration and deployment

Total: 78 hours, 12 phases, completely actionable with explicit bash/rails commands
2025-11-20 15:37:37 +00:00
Z. Cliffe Schreuders
27bd4e9760 docs: Add simplified 2-table schema (missions + games)
Added comprehensive planning docs:
- 00_OVERVIEW.md: Project aims, philosophy, all decisions
- 01_ARCHITECTURE.md: Complete technical design
- 02_DATABASE_SCHEMA.md: Full schema reference with examples

Key simplifications:
- 2 tables instead of 3-4
- Files on filesystem, metadata in database
- JIT Ink compilation
- Per-instance scenario generation via ERB
- Polymorphic player (User/DemoUser)
- Session-based auth
- Minimal client changes (<5%)

Next: Implementation plan with step-by-step TODO list
2025-11-20 15:37:37 +00:00