name: planning
description: "Crimson Leaf executive planning -- boardroom deliberation, structured task breakdown, child task dispatch."
debug: true
system: agent_prompt
participant_prompt:
  - "= identity.md"
agent_prompt:
  - "= identity.md"
sections:
  - agent
  - project
  - history
  - rag
  - participants
  - participants_prompt
  - roster
  - templates
  - message
  - instructions
steps:
  - type: think
    rotate_participants: true
    loop:
      max_iterations: 3
    hint: |
      You are {agent.name}. This is round {task.iteration} of the Crimson Leaf planning session.
      The executive board is breaking down this initiative into a concrete work plan.

      Write YOUR perspective from your area of expertise:
        - What work streams or tasks need to exist?
        - What order must they happen in? What depends on what?
        - Which agents from the TEAM ROSTER are best suited to each piece?
        - What risks, gaps, or open questions do you see?
        - What do you agree or disagree with from prior planning rounds?

      CRIMSON LEAF CONTEXT:
      Crimson Leaf is a holding company and incubator. It does NOT produce consumer deliverables.
      Valid work for CL includes: market research, corporate architecture, executive recruitment,
      portfolio governance, charter design, template authoring, and company incubation.

      Reference these TASK TYPES when recommending work:
        hire_agent                   -- recruit a new agent to the CL roster
        write_template               -- create or refine a PAE-Lang template
        write_charter                -- draft a formal constitutional charter for a new Tenant
        create_company               -- incubate a new sovereign Tenant (full Genesis Protocol)
        market_intelligence          -- Orion scans for niche opportunities and portfolio gaps
        portfolio_architectural_review -- Aris reviews the full Tenant portfolio for coherence
        audit_tenant                 -- Sloane red-teams a Tenant's operational health
        charter_audit                -- Valerius checks a Tenant charter for constitutional drift
        financial_audit              -- Vance audits Genesis Fund health and per-Tenant ROI
        capital_allocation_audit     -- Vance reviews capital allocation discipline
        retire_tenant                -- Sloane/Vance executes Tenant dormancy or dissolution
        adjudicate_tenant            -- constitutional adjudication of a Genesis action or output
        quick                        -- short single-step response or analysis

      CRITICAL DISPATCH RULES:
      - Do NOT create planning or boardroom sub-tasks. You ARE the planning step.
        All deliberation happens HERE in this session, not as child tasks.
      - Produce ONLY actionable leaf tasks using the task types listed above.
      - For company creation: emit ONE create_company task with ALL details in the description.
        Do NOT split charter design, CEO recruitment, and company creation into separate tasks.
        The create_company template handles the full flow internally.

      SEQUENCING RULE:
      - adjudicate_tenant and create_company tasks MUST wait for all prior research tasks.
        They cannot run until market_intelligence, portfolio_architectural_review, and
        write_charter are all complete. This MUST be expressed using depends_on in the task list.

      Be specific about agent assignments -- use EXACT names from the TEAM ROSTER.

      When the group has genuinely agreed on a complete plan, include exactly:
      "consensus_reached: true"
      If the plan still has gaps or unresolved assignments, do NOT include that line.

  - type: think
    agent: first_available
    hint: |
      Structure the team's agreed plan into a precise task list.
      IMPORTANT: Do NOT re-deliberate or reconsider what was agreed above.
      Your only job is to serialize the decisions into clean task records.

      For each task:
        - task_name: short, specific
        - description: full detail -- enough that the assigned agent can execute without asking.
          CRITICAL: Include the ORIGINAL OPERATOR REQUEST verbatim in every child description
          so downstream agents know what was actually asked for. Start with
          "ORIGINAL REQUEST: <exact text>" followed by specific instructions.
        - agents: EXACT name(s) from TEAM ROSTER
        - task_type: MUST be one of the valid template names listed below
        - priority: 1 (critical) to 5 (nice-to-have)
        - depends_on: list of task_name values this task must wait for before it can start.
          Use the EXACT task_name strings of the blocking tasks.
          Omit this field entirely if this task has no blockers.

      Order tasks correctly -- blockers before dependents.
      No ambiguous assignments. No placeholder names.

      VALID TASK TYPES (use ONLY these exact strings):
        hire_agent, write_template, write_charter, create_company,
        market_intelligence, portfolio_architectural_review,
        audit_tenant, charter_audit, financial_audit, capital_allocation_audit,
        retire_tenant, adjudicate_tenant, quick

      MANDATORY SEQUENCING RULES:
      - adjudicate_tenant MUST have depends_on listing ALL research/charter tasks.
        Valerius cannot adjudicate without completed research and a charter.
        Example: depends_on: ["Market Intelligence", "Portfolio Architectural Review", "Write Charter"]
      - create_company MUST have depends_on that includes the adjudicate_tenant task.
        A company must NOT be created until adjudication passes.
        Example: depends_on: ["Adjudicate Tenant"]
      - Do NOT emit planning or boardroom tasks. Deliberation already happened above.

  - type: package
    packet_type: PlanningResponsePacket
    schema:
      tasks:
        - task_name: "string -- short descriptive name"
          description: "string -- full instructions for the assigned agent"
          agents:
            - "string -- EXACT agent name from TEAM ROSTER"
          task_type: "string -- MUST be a template name from the valid list"
          priority: "integer 1 (critical) to 5 (nice-to-have)"
          depends_on:
            - "string -- exact task_name of a blocking task (omit this field if no dependencies)"
    insert_children: true

  - type: close
    rag_update: false

adjudication:
  enabled: false