Commit graph

31 commits

Author SHA1 Message Date
Claude
34c48743d0
Fix execute_processing_script to support list comprehensions
The exec() function was using empty globals dict which prevented list
comprehensions from accessing variables in the local scope. Changed to
use the same dict for both globals and locals to properly support
comprehensions in processing scripts.

Fixes battleship game flow tests that use list comprehensions.
2025-11-10 19:58:29 +00:00
Claude
39e39e80f1
Fix flake8 F824 errors - remove unused global declarations
Remove unnecessary global declarations for MODEL_CLIENT_MAP that are never reassigned
2025-11-10 19:39:36 +00:00
Claude
22db7a9a8a
Run black formatter on all Python files
Format code according to black style guidelines for consistency
2025-11-10 19:37:05 +00:00
Claude
653c72020c
Fix progressive hints in CLI simulator for first failed attempt
Removed "attempts > 0" check in research/guarded_ai.py that prevented
hints from showing on the first attempt. Matches the fix made to
activity.py for consistent behavior across web app and CLI simulator.
2025-11-10 17:02:56 +00:00
Claude
bd779e06fa
Fix SPEC.yaml validation and refactor guarded_ai.py for v2.0 consistency
SPEC.yaml fixes:
- Comment out orphaned example code blocks that broke YAML parsing
- Convert progressive hints and dynamic question examples to comments
- Add placeholder keys to maintain valid YAML structure
- All examples now documented but non-executable (reference only)
- Validates with 0 errors

guarded_ai.py refactor (CLI simulator now uses v2.0 features):
- Import activity_utils.py for consistency with activity.py
- Use check_conditions() for advanced metadata conditions (gte, lt, contains, etc.)
- Use filter_content_blocks() for template rendering and conditional blocks
- Use render_template() for dynamic question text with {{variables}}
- Use resolve_conditional_navigation() for if/elif/else navigation
- Use select_weighted_random() for weighted random selection
- Use get_progressive_hint() for progressive hints system
- Create template contexts with built-in variables (current_attempt, etc.)

Benefits:
- Single source of truth for v2.0 logic (activity_utils.py)
- CLI simulator now tests all v2.0 features
- Maintainability: changes to features only need updates in one place
- Consistency: web app and CLI behave identically

All changes validated and tested.
2025-11-10 15:19:50 +00:00
002e64b6c1 Add random bucket support and comprehensive YAML specification
Random Bucket System:
- Probabilistic events that trigger alongside user responses
- Random rolls before categorization to prevent AI bias
- Multiple random events can trigger simultaneously
- User bucket processed first, random events layer on top
- Metadata accumulates across all transitions
- Last transition's navigation wins

Implementation:
- activity.py: Core random bucket rolling logic
- activity_yaml_validator.py: Validation for random_buckets config
- research/guarded_ai.py: CLI simulator with random event display
- tests/unit/test_random_buckets.py: 22 comprehensive tests (all passing)

Fashion Empire Enhancement:
- activity40-fashion-empire-backrooms.yaml: Added random events to 4 zones
  - fashion_emergency (5%): Urgent crises testing leadership
  - creative_opportunity (10%): Breakthroughs rewarding innovation
  - surprise_client (5%): VIP visitors recognizing reputation
- Random events enhance gameplay without hijacking user intent

Documentation:
- research/SPEC.yaml: Complete YAML specification with verbose comments
  - All metadata operations (string concat, numeric ops, random)
  - Random buckets with flow explanation
  - Feedback prompts (multi-agent system)
  - Processing scripts (pre_script, processing_script)
  - Model overrides (classifier_model, feedback_model)
  - Termination patterns and best practices
  - Validation rules and examples

New Activities:
- activity-nuclear-power-plant-ai.yaml: Nuclear reactor control simulation
- activity-submarine-simulation.yaml: Deep sea exploration
- activity-unwaste-factory.yaml: Recycling facility management

Testing:
 All 22 random bucket tests passing
 YAML validation passing for all activities
 Deterministic triple-trigger test (100% probability)
2025-11-10 08:57:14 -05:00
Claude
fd78927e7c
Fix MODEL_X references to use dynamic model registry
When MODEL_X references (MODEL_0, MODEL_1, etc.) are used, the code now
properly looks up actual model names from the dynamic registry (MODEL_CLIENT_MAP)
instead of hardcoding "model" or requiring MODEL_NAME_X environment variables.

Changes:
- app.py: Look up models from MODEL_CLIENT_MAP for the specified endpoint
- guarded_ai.py: Query endpoints for actual model names at initialization
- guarded_ai.py: Use dynamic registry for MODEL_X lookups

This fixes the "model not found" error when using activities with MODEL_X
references like activity37.
2025-11-08 19:58:21 +00:00
Claude
0f06772afb
Fix critical model name issue and validator warning
Critical fix for guarded_ai.py:
- Add MODEL_NAME_{n} environment variable support
- Fixes hard-coded "model" string that breaks Azure OpenAI and other endpoints
- Falls back to "model" if MODEL_NAME_{n} not specified
- Some endpoints require actual deployment name in model parameter

Validator improvement:
- Allow feedback_prompts as alternative to feedback_tokens_for_ai
- Prevents false warning when using metadata_feedback_filter with new prompt system

Documentation:
- Added MODEL_NAME_{n} examples to CLAUDE.md
- Documented that Azure and similar endpoints need this variable

All 8 activities validated: 0 errors, 0 warnings
2025-11-08 19:38:15 +00:00
Claude
c51b2c7900
Update guarded_ai.py to support classifier_model and feedback_model
Changes:
- Enhanced get_openai_client_and_model() to support MODEL_X references
- Added model parameter (default "MODEL_1") to all AI functions:
  - categorize_response()
  - generate_ai_feedback()
  - provide_feedback()
  - provide_feedback_prompts()
  - translate_text()
- Updated simulate_activity() to:
  - Read classifier_model and feedback_model from YAML
  - Support step-level model overrides
  - Pass appropriate models to classifier vs feedback functions

This ensures the CLI simulation tool matches the production activity.py behavior.
2025-11-08 19:23:29 +00:00
f90df2ae57 modified: activity_yaml_validator.py
modified:   app.py
	modified:   research/activity29-battleship.yaml
	modified:   research/activity29-testship.yaml
	modified:   research/guarded_ai.py
	modified:   tests/functional/test_activity_flows.py
	modified:   tests/functional/test_battleship_pre_script.py
	modified:   tests/functional/test_guarded_ai.py
	modified:   tests/unit/test_activity_yaml_validator.py
	modified:   tests/unit/test_app_feedback.py
	modified:   tests/unit/test_guarded_ai.py
2025-08-11 12:39:42 -04:00
d4d697db59 Implement per-prompt metadata filtering and fix battleship feedback system
Major improvements to battleship game feedback accuracy and user experience:

## New Multi-Prompt Feedback System
- Replaced single feedback with 3 specialized prompts: Shot Report, Ship Status, Game Over
- Each prompt has individual metadata filtering to see only relevant data
- Shot Report only sees hit/miss data, Ship Status only sees ship destruction data
- Added STFU token system to suppress empty messages (filtered out automatically)

## Technical Implementation
- Added per-prompt metadata_filter support in YAML structure
- Updated app.py and guarded_ai.py to handle prompt-specific filtering
- Legacy single-prompt system still works with transition-level filtering
- Added comprehensive test suite for feedback system validation

## User Experience Fixes
- Fixed TTS queue blocking JavaScript execution (async promises instead of await)
- Ship Status now correctly reports who destroyed which ship (role confusion fixed)
- Game Over only appears when game actually ends (no more random messages)
- Maintained dramatic storytelling while ensuring factual accuracy

## Battleship-Specific Improvements
- Ship destruction messages only appear when ships actually sink
- Clear separation of concerns: hits/misses vs ship destruction vs game over
- Eliminated false positive ship destruction reports
- Fixed role reversal where wrong player got credit for destruction

The battleship narrator now provides accurate, contextual feedback while preserving the dramatic naval warfare atmosphere.
2025-08-11 11:39:49 -04:00
1b44c2d66b Integrate comprehensive testing framework with Makefile
- Added unit tests for YAML loading and parsing functionality
- Created integration tests for multiple activity files validation
- Implemented functional tests for complete activity workflows
- Added battleship pre_script functionality tests
- Integrated all test types into comprehensive Makefile
- Fixed CLI validator test with proper failing fixture
- Applied black formatting to all Python files
- Removed problematic hardcoded targets from Makefile
- Added proper venv dependency management

Test coverage includes:
- Unit: YAML loading, validator functionality
- Integration: Cross-file validation, metadata operations
- Functional: End-to-end activity flows, pre_script execution
- All 30 activity files validated and tested
2025-08-10 19:38:50 -04:00
df54e6b4aa conditionally run processing_script
modified:   app.py
	modified:   research/activity22-odds-or-evens.yaml
	modified:   research/activity24-math-plot.yaml
	modified:   research/activity27-tic-tac-toe.yaml
	modified:   research/guarded_ai.py
2024-08-24 14:31:46 -04:00
14dd105d03 woot upgraded guarded to support odds-or-evens game.
modified:   ../app.py
	new file:   activity22-odds-or-evens.yaml
	modified:   guarded_ai.py
2024-08-11 08:43:47 -04:00
2609ff993d limited_effort should not be treated as correct.
modified:   app.py
	modified:   research/guarded_ai.py
2024-08-10 17:23:04 -04:00
f5df195e9b black and also set_language isn't "correct" anymore.
so it doesn't move the student on.

	modified:   app.py
	modified:   migrations/env.py
	modified:   migrations/versions/190d5ef26e20_add_token_count_to_message.py
	modified:   migrations/versions/a9e886c56482_create_room_table.py
	modified:   migrations/versions/d737de68d6fa_add_metadata_field_to_activitystate.py
	modified:   research/activity21.yaml
	modified:   research/guarded_ai.py
2024-08-10 17:00:52 -04:00
058b0161df allow increment to go backward with n-1 and also support any int c for the
increment or decrement.

	modified:   ../app.py
	modified:   guarded_ai.py
2024-08-10 15:00:28 -04:00
e3d3bf0303 n+1 in yaml to accumulate integers.
modified:   ../app.py
	new file:   activity20-n-plus-1.yaml
	modified:   guarded_ai.py
2024-08-10 14:39:37 -04:00
87faba6379 modified: guarded_ai.py 2024-08-10 13:40:22 -04:00
4f7caffe17 guarded_ai.py can also play rock-paper-scissors.yaml 2024-08-10 13:36:31 -04:00
3b8309a432 all languages translation to simulated gaurded_ai
modified:   guarded_ai.py
2024-08-09 08:41:46 -04:00
3b542285f6 counts_as_attempt implemented and we caught up guarded_ai to have
metadata

	modified:   app.py
	modified:   research/guarded_ai.py
2024-08-08 08:59:20 -04:00
ade6bfed18 fix guarded_ai feedback issue 2024-07-31 17:15:07 -04:00
9f3c5fb3a7 hcanges per rabbit feedback
modified:   app.py
	modified:   research/guarded_ai.py
2024-07-29 06:34:05 -04:00
dd13bce82b
Update research/guarded_ai.py
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
2024-07-29 06:17:48 -04:00
aa783ded70 modified: guarded_ai.py 2024-07-28 20:53:00 -04:00
684f3df38e fix defect/regression with linear activities
modified:   guarded_ai.py
2024-07-28 11:59:40 -04:00
7e7b226fb1 print content blocks and skip the llm logic if no question in step.
modified:   research/guarded_ai.py
2024-07-28 11:28:44 -04:00
cfa5d77a42 Allowing for non-linear progression depending on buckets category
new field in the transitions is next_section_and_step which is optional
and defaults to None but also can be "section_3:step_1"

	modified:   app.py
	new file:   research/activity0.yaml
	new file:   research/activity13-choose-adventure.yaml
	modified:   research/guarded_ai.py
2024-07-28 10:36:09 -04:00
5583e34e51 prompt engineering.
modified:   research/guarded_ai.py
2024-07-27 12:22:51 -04:00
15ac4fa015 algo for guarding AI on rails.
new file:   research/activity.yaml
	new file:   research/activity10.yaml
	new file:   research/activity11.yaml
	new file:   research/activity12.yaml
	new file:   research/activity2.yaml
	new file:   research/activity3.yaml
	new file:   research/activity4.yaml
	new file:   research/activity5.yaml
	new file:   research/activity6.yaml
	new file:   research/activity7.yaml
	new file:   research/activity8.yaml
	new file:   research/activity9.yaml
	new file:   research/guarded_ai.py
2024-07-27 08:57:44 -04:00