feat(integration): prepaid billing, engine UI, credits console, direct tasks, v2 final

- Prepaid credit system: org wallet, debit on usage, chat gate, admin credit console
- Engine UI: /manager, /tasks, /tasks/[id], /workforce, /dashboard, /traces pages
- Direct task creation (HTTP POST /tasks, MCP tasks_create) at pending_manager_review
- Pause/resume/cancel/answer actions in engine API and UI
- Employee cap (7 per org default), review pipeline guard (active reviewer required)
- Scheduler: wide window prevents org starvation; archived employees excluded from cap
- Tenant isolation: project-id cross-org 404, engine never uses another tenant's sandbox
- Order route fix: manager built with pipeline states + employee profiles
- Contract extension: ModelGrantPort.get_org_policy with DefaultOrgPolicy
- Engine event types in @agy/contracts (task.step, task.gate, run.log, run.tool, team.changed)
- api-engine.ts typed client; api-credit.ts client
- Alembic migration c4d5e6f7a8b9: prepaid credit + engine UI tables
- 859 tests passed, 1 skipped; ruff/mypy/tsc/eslint/vitest all green

Refs: PLAN-v2.md §9 (T1–T43), todo-v2-final.md
This commit is contained in:
mjalmoudy94
2026-10-14 23:19:05 +03:30
parent fef5a9deab
commit d532929189
117 changed files with 13119 additions and 640 deletions
+29
View File
@@ -0,0 +1,29 @@
"""Test helpers for the prepaid credit ledger.
Prepaid billing means an organization needs credit before engine work runs, so
tests that exercise that work fund the organization first. ``fund_org`` writes
the credit through the same repository the platform owner's endpoints use, so
the wallet and its history are written the real way.
"""
from __future__ import annotations
from sqlalchemy.ext.asyncio import async_sessionmaker
from app.domain.billing.models import CreditKind, CreditTransaction
from app.infrastructure.repositories.credit import CreditLedgerRepository
async def fund_org(
session_factory: async_sessionmaker, organization_id: str, amount: float = 100.0
) -> CreditTransaction:
"""Credit an organization's wallet by ``amount`` as a labelled adjustment."""
async with session_factory() as session:
transaction = await CreditLedgerRepository(session).apply(
organization_id=organization_id,
amount=amount,
kind=CreditKind.ADJUSTMENT,
reason="test funding",
)
await session.commit()
return transaction