testing-opportunity-loop

Tests the opportunity dispatch and refill API pipeline end-to-end including sqlite state and revenue packets.

1|3|Updated Mar 9, 2026
One-click install
npx skills add https://github.com/AIKAGRYA/dharma_swarm --skill testing-opportunity-loop-aikagrya
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: testing-opportunity-loop
Source: https://github.com/AIKAGRYA/dharma_swarm/tree/main/.agents/skills/testing-opportunity-loop
Command: npx skills add https://github.com/AIKAGRYA/dharma_swarm --skill testing-opportunity-loop-aikagrya

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Verifying that the Authority and Revenue loop actually works requires more than checking HTTP 200 responses — you need proof that all six pipeline stages ran, durable task claims and delegation runs landed in sqlite, and the revenue packet contains coherent economics. This Skill provides a repeatable end-to-end verification procedure for the opportunity dispatch/refill pipeline. ## Core Features & Use Cases - End-to-end API verification: Exercises the stages, dispatch, and refill endpoints and validates exact stage ordering, success flags, and economic arithmetic (net value equals estimated value minus provider cost). - Durable state inspection: Queries the runtime sqlite database via Python's sqlite3 module to confirm task claims and delegation runs were persisted per dispatch call. - Quarantine and governance checks: Tests quarantine mode via DHARMA_RESEARCH_BACKEND and runs pre-commit hooks to confirm governance passes. - Use Case: After modifying the opportunity dispatcher, run this procedure against an isolated DHARMA_STATE_DIR to produce a structured PASS/FAIL verdict covering pytest, endpoints, sqlite rows, revenue packets, quarantine behavior, and pre-commit hooks. ## Quick Start Run the opportunity loop end-to-end test against a local uvicorn server with an isolated DHARMA_STATE_DIR and report the verdict.

Frequently Asked Questions about testing-opportunity-loop

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I test the opportunity dispatch and refill API endpoints?▼

Start the uvicorn server on port 8420, then POST to /api/opportunities/dispatch and /api/opportunities/refill with a JSON body containing id, title, and type. Verify the results array has exactly six successful stages with non-empty task_id, claim_id, and run_id values.

How do I verify durable sqlite state after API dispatch calls?▼

Use Python's sqlite3 module to connect to the runtime.db inside your isolated DHARMA_STATE_DIR and count rows in task_claims and delegation_runs. Expect at least six claims and six runs per dispatch call, filtered by your test opportunity id.

Why should I use an isolated DHARMA_STATE_DIR for testing?▼

An isolated state dir keeps assertions exact and prevents pollution of the real ~/.dharma state. Set DHARMA_STATE_DIR to a local path like .e2e_state/opportunity-loop and never commit that directory or any runtime receipts.

How do I test quarantine mode for the deep_research stage?▼

Set DHARMA_RESEARCH_BACKEND=quarantine on the uvicorn server process, not the curl client, then POST a refill. Expect the deep_research stage to show status quarantined with quarantined true while all other stages complete and overall success stays true.

Why is an HTTP 200 response not enough to pass the opportunity loop test?▼

The loop touches real revenue logic, so a 200 only proves the endpoint responded. You must also confirm durable sqlite rows exist, the revenue packet was written with the opportunity id, and net value equals estimated value minus provider cost.

Should I assert exact provider cost values in refill tests?▼

No, pricing constants change over time so exact figures like a remembered 0.23 will break tests. Assert that total_provider_cost_usd is present, numeric, and greater than zero, and that the net-value arithmetic holds.