Task Contract v2 — Ingesting a Pre-Computed Plan (Skip Planning)
AIFactory can skip its entire spec + planning pipeline when an upstream system (PFactory) hands it a complete, signed Task Contract v2. This is the fast-path: the analysis was already done and governed upstream, so AIFactory goes straight to the wave executor.
Canonical contract: Factory RFC-0002 · JSON Schema:
apis/task-contract.schema.json. For the full set of task options when not using the fast-path, see Task Lifecycle.
1. What the contract carries
A superset of implementation_plan.json with two upstream-computed blocks plus a
signature envelope:
- WHAT — the plan (
feature,workflow_type,phases[].subtasks[]withdepends_on,files_to_create/modify,verification),final_acceptance,required_commands. - HOW —
execution:model/provider,phase_models,phase_thinking,parallel,workers,review_tier,agents/subagents,skills,skip_planning. - VERIFY —
tfactory:lanes,frameworks,endpoints,coverage_target,mutation_scope,security_scope,ac_to_code_map(carried through to TFactory). - TRUST —
approval:approved_by,approval_timestamp,plan_contract_version,signature(HMAC-SHA256). - ENVIRONMENT —
environment(RFC-0005): the per-task toolchain manifest (language,toolchain,system_packages,build_commands,verify_commands,serve_command,provisioning.method=nix,network,proof.verify). AIFactory builds in this env so build and verify cannot drift — see Nix Reproducible Build. - ACCESS —
access(RFC-0007): discovered auth requirements for any external resource the tests must reach (broker refs only, never secrets).
2. How AIFactory ingests it
POST /api/tasks/from-plan (apps/web-server/server/routes/execution.py)
→ trusted_plan.ingest_trusted_plan (apps/backend/trusted_plan.py):
- Verify signature — HMAC over the canonical contract + approval metadata,
keyed by
AIFACTORY_TRUSTED_PLAN_KEY_<AUTHORITY>(the authority =approved_by). - Verify completeness —
feature,workflow_type, non-emptyphases, unique subtask ids, file footprints, validdepends_on(no unknown deps, no cycles). - Install — write
implementation_plan.json, mark the spec review-approved, record provenance, and (whenproject_diris supplied) seed the plan'srequired_commandsinto the security allowlist. - Apply the execution profile —
execution.model/phase_models/phase_thinking→phase_config;parallel/workers→task_metadata;review_tier→ the gate. Withskip_planning: truethe build goes straight to the wave executor — no planner session.
On failure it returns HTTP 422 with reasons; the caller can fall back to the
normal create-and-run path.
3. Handover to TFactory
When the build completes, AIFactory carries the tfactory block into the spec/
context it hands to TFactory, so TFactory builds its test_plan.json from
declared lanes/frameworks/endpoints/scope instead of inferring them. Status
flows back via the RFC-0001 completion-event envelope keyed by correlation_key;
TFactory failures return through the existing QA-fixer handback path.
4. Backward compatibility
The contract is additive. A contract_version: "1" plan (no execution/
tfactory) still verifies and installs; a v2 contract without those blocks
behaves like v1 plus richer correlation. The legacy requirements.json +
create-and-run path is unchanged. v2 with all blocks is the full skip-planning,
no-guessing fast-path.
5. Status
The contract schema and RFC are merged (Factory RFC-0002). Wiring the full
execution + tfactory ingest into trusted_plan is tracked by the AIFactory
epic "Ingest Task Contract v2 (skip planning)".