# Flask PP Migration Agents

Specialized Claude Code agents for automating Flask microservice integrating Permissions Platform (PP) authorization.

## What This Does

Automates the PP integration process for Flask services - from dependency installation to final commits. Replaces manual multi-step migration with a single orchestrated workflow.

## Quick Start

**Single Command Migration**:
```
Use flask-pp-migration-orchestrator agent in Claude Code
```

The orchestrator will automatically:
1. Analyze your codebase structure
2. Run config agent to install dependencies and setup OwsClient
3. Run standalone agent to add authorization checks to all handlers
4. Execute tests to verify everything works
5. Prompt you for commit messages and push changes

## Individual Agents

For manual control, use agents separately:

- **`flask-pp-migration-config-specialist`** - Dependencies + OwsClient setup
- **`flask-pp-migration-standalone-specialist`** - Add standalone authorization checks + utilities
- **`flask-pp-migration-tracker`** - Track migration progress across services

## What Gets Automated

### Phase 1: Infrastructure Setup
- Adds `owsclient` and `python-pdp-sdk` dependencies 
- Configures OwsClient and authorization backend in api.py
- Updates `flask_request.setup()` with PP settings

### Phase 2: Authorization Migration
- Adds `flask_request.verify_rules_access_standalone(request)` to all Flask handlers
- Creates `utils/authorization.py` with convenience functions
- Generates comprehensive unit tests

### Phase 3: Validation & Commits
- Runs test suite (`make test`, `make ci_test`, etc.)
- Validates lint passes
- Creates atomic commits with your approval
- Pushes to remote repository

## Pipeline Flow

```
Discovery → Config Agent → Standalone Agent → Test Verification → Commit Changes
```

**Fail-Fast**: Each checkpoint must pass before proceeding. Pipeline stops immediately on any failure.

## Requirements

- Flask microservice with existing `flask_request.setup()`
- Git repository with clean working directory
- Makefile with test commands (typically `test`, `ci_test`, `test_unit`, or `ci_test_unit`)

## Result

Your Flask service will have:
- PP authorization on all endpoints
- Backward compatibility maintained
- Full test coverage for new authorization utilities
- Clean git history with atomic commits
- Ready for production deployment

## Supported Patterns

Works with common Flask patterns:
- `@app.route` decorators
- `@bp.route` blueprint routes  
- Class-based handlers
- Function-based handlers
- Custom route decorators

Automatically skips health check endpoints and follows existing code conventions.