Files
mjalmoudy94 d532929189 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
2026-10-14 23:19:05 +03:30

37 lines
1.2 KiB
Python

"""A pre-v2 task: a plain ``tasks`` row with no ``task_pipeline_state``.
Every task made since the engine owns direct tasks gets a pipeline state, so HTTP
``POST /tasks`` and MCP ``tasks_create`` no longer create one of these (decision D-D).
Tasks created before that have no state and still run through the legacy one-shot path
(``WorkforceService.start_run``). Tests of that path create their task with this helper.
"""
from __future__ import annotations
from sqlalchemy.ext.asyncio import async_sessionmaker
from app.infrastructure.db.models import TaskRow
async def legacy_task(
session_factory: async_sessionmaker,
organization_id: str,
created_by_user_id: str,
*,
title: str = "کار قدیمی",
project_id: str | None = None,
assigned_employee_id: str | None = None,
) -> str:
"""Insert one task with no pipeline state and return its id."""
async with session_factory() as session:
row = TaskRow(
organization_id=organization_id,
project_id=project_id,
title=title,
assigned_employee_id=assigned_employee_id,
created_by_user_id=created_by_user_id,
)
session.add(row)
await session.commit()
return row.id