Skip to content

Latest commit

Β 

History

History
89 lines (74 loc) Β· 4.76 KB

ARCHITECTURE.md

File metadata and controls

89 lines (74 loc) Β· 4.76 KB

Architecture

Murphy File Organization (murphy/)

murphy/
β”œβ”€β”€ __init__.py              # Package exports and version
β”œβ”€β”€ __main__.py              # python -m murphy entry point
β”œβ”€β”€ config.py                # Shared configuration constants
β”œβ”€β”€ llm.py                   # Multi-provider LLM factory (OpenAI, Google, Anthropic, etc.)
β”œβ”€β”€ models.py                # Pydantic models (TestPlan, TestResult, JudgeVerdict, etc.)
β”œβ”€β”€ prompts.py               # All LLM prompt text
β”œβ”€β”€ evaluate.py              # Backward-compatible re-exports
β”‚
β”œβ”€β”€ core/                    # Pipeline phases
β”‚   β”œβ”€β”€ analysis.py          #   Phase 1: feature discovery via browser agent
β”‚   β”œβ”€β”€ generation.py        #   Phase 2: test plan generation (feature-based + exploration-first)
β”‚   β”œβ”€β”€ execution.py         #   Phase 3: test execution (sequential + parallel)
β”‚   β”œβ”€β”€ judge.py             #   LLM judge for pass/fail verdicts
β”‚   β”œβ”€β”€ quality.py           #   Test plan quality validation and retry logic
β”‚   β”œβ”€β”€ summary.py           #   Results classification and report building
β”‚   └── pipeline.py          #   Orchestrates phases for the REST API
β”‚
β”œβ”€β”€ io/                      # File I/O and reporting
β”‚   β”œβ”€β”€ features_io.py       #   Read/write features markdown
β”‚   β”œβ”€β”€ test_plan_io.py      #   Read/write YAML test plans
β”‚   β”œβ”€β”€ report.py            #   Report generation orchestrator
β”‚   β”œβ”€β”€ report_json.py       #   JSON report output
β”‚   β”œβ”€β”€ report_markdown.py   #   Markdown report output
β”‚   β”œβ”€β”€ report_helpers.py    #   Metrics, formatting, fix suggestions
β”‚   β”œβ”€β”€ fixtures.py          #   Dummy upload files for test scenarios
β”‚   └── regen_report.py      #   Regenerate markdown from existing JSON
β”‚
β”œβ”€β”€ api/                     # CLI, REST API, and web UI
β”‚   β”œβ”€β”€ cli.py               #   CLI entry point and orchestration
β”‚   β”œβ”€β”€ rest.py              #   FastAPI REST server
β”‚   β”œβ”€β”€ server.py            #   Interactive web UI (aiohttp)
β”‚   β”œβ”€β”€ auth.py              #   Auth detection and manual login flow
β”‚   β”œβ”€β”€ jobs.py              #   Job dispatch, concurrency, webhooks
β”‚   β”œβ”€β”€ request_models.py    #   API request/response schemas
β”‚   └── templates.py         #   HTML rendering for web UI
β”‚
└── browser/                 # Browser session helpers
    β”œβ”€β”€ actions.py           #   Custom agent actions (domain access, DOM refresh)
    β”œβ”€β”€ session_utils.py     #   Session stabilization and lifecycle
    └── patches.py           #   Monkey-patches for schema resolution

REST API (murphy-api)

Murphy exposes a REST API via FastAPI for programmatic evaluation. Start with murphy-api.

Endpoints

Method Path Description
GET /health Health check
POST /analyze Website analysis (feature discovery)
POST /generate-plan Test plan generation from analysis
POST /execute Test execution from plan
POST /evaluate Combined explore + plan generation
GET /jobs/{job_id} Job status polling (supports long-poll via ?poll=N)

Execution modes

Every POST endpoint supports three modes:

  1. Synchronous (default) β€” blocks until completion, returns 200 with result
  2. Async + webhook (webhook_url set) β€” returns 202 with job_id, POSTs result to the webhook URL on completion
  3. Async + polling ("async": true) β€” returns 202 with job_id, poll /jobs/{job_id} for result

Authentication is via X-API-Key header when MURPHY_API_KEY is set. Concurrent jobs are limited by MURPHY_MAX_CONCURRENT_JOBS (default: 2).

Browser-Use Engine (browser_use/)

Browser-Use is vendored from upstream with local patches. It provides LLM-driven browser automation via CDP (Chrome DevTools Protocol).

Murphy uses these browser-use components:

Component Murphy usage
Agent Runs analysis exploration, test execution, and goal-directed browsing
BrowserSession Managed in murphy/browser/session_utils.py for lifecycle, tab control, and CDP recovery
BrowserProfile Configured for headless mode, session pooling, and auth persistence
Tools Extended with custom actions in murphy/browser/actions.py (domain access, DOM refresh)
AgentHistoryList Consumed by the judge (murphy/core/judge.py) for evidence extraction

For Murphy-specific patches to browser-use, see BROWSER_USE_MODIFICATIONS.md. For browser-use's own architecture, see the upstream repo.