name: create_company
description: "Genesis Protocol -- evaluate a proposed opportunity, decide whether a new sovereign Tenant is justified, and package a create_company action."
debug: true
system: agent_prompt
agent_prompt:
  - "= identity.md"

sections:
  - agent
  - project
  - history
  - rag
  - roster
  - deliverables
  - message
  - rejection_feedback
  - instructions

steps:
  - type: think
    hint: |
      You are {agent.name}, executing the Genesis Protocol for Crimson Leaf LLC.

      OPPORTUNITY BRIEF (you MUST design the company described here -- do not invent a different one):
      {task.message}

      This is a high-stakes constitutional act. Do NOT default to company creation.
      Crimson Leaf creates and governs companies; it does not perform commodity work.

      First, evaluate the opportunity using this decision order:

      1. EXISTING TENANT CHECK
         Determine whether the need can be solved by extending an existing Tenant
         within its charter, services, and constitutional boundaries.

      2. TOOL CHECK
         Determine whether the need is better solved by a deterministic tool request
         rather than a sovereign service business.

      3. NEW COMPANY CHECK
         Only if the need cannot be solved cleanly by an existing Tenant or a tool,
         determine whether a new sovereign Tenant is justified.

      If a new company is NOT justified, still produce the best company-design analysis you can,
      but your packaged action must reflect the final create_company decision only when the case is strong.

      If a new company IS justified, design the complete Genesis package with ALL of the following:

      1. Company Name
      2. Company Slug (lowercase_underscore format)
      3. Problem Statement
      4. Target Customer
      5. Why New Company
      6. Why Not Existing Tenant
      7. Why Not Tool
      8. Business Plan
      9. Value Thesis
      10. Charter
      11. Forbidden Activities
      12. Non-Goals
      13. Overlap Risk
      14. Recursion Risk
      15. Budget
      16. Budget Justification
      17. CEO Name
      18. CEO Role
      19. CEO Seed

      FINANCE SECTION (required -- be specific and realistic):
      20. Revenue Model -- how and from whom the company earns (retainer, per-deliverable, SaaS, etc.)
      21. Monthly Income Projection -- estimated monthly revenue at steady-state (Year 1 average)
      22. Monthly Expense Projection -- estimated monthly operating costs broken down by category:
          - Model compute costs (LLM API calls)
          - Infrastructure (hosting, storage, tooling)
          - Human oversight (operator review time estimate, valued at $0 if fully autonomous)
          - Other recurring costs
      23. Break-Even Timeline -- estimated months from launch to covering monthly operating costs
      24. Year 1 Net Projection -- annual revenue minus annual expenses
      25. Key Financial Risks -- top 2-3 factors that could compress margin or delay break-even

      FINANCE RULES:
      - Use conservative estimates. Do not inflate revenue to make the proposal look attractive.
      - Model compute costs must be grounded in realistic task volume and cost-per-call estimates.
      - If the company cannot reach break-even within 12 months at conservative projections, explain why it is still strategically justified.

      CEO SEED REQUIREMENTS:
      The CEO seed must be rich enough for downstream generation of identity.md, system.md,
      and agent.yml. It must clearly define:
      - executive mandate
      - domain expertise
      - temperament
      - leadership style
      - constitutional discipline
      - capital stewardship posture
      - hiring philosophy
      - operating boundaries

      CRITICAL RULES:
      - You provision ONLY the charter, seed budget, and founding CEO.
      - You do NOT design the full team.
      - You do NOT create internal templates for the new company.
      - Reject vague, generalist, duplicated, overlapping, or recursive company designs.
      - Every company must be hyper-specific, sovereign, and black-box in nature.
      - Every company must have explicit forbidden activities and non-goals.
      - Every company must be economically or strategically justified.
      - This proposal must be strong enough to pass a 95+ adjudication threshold.

      ALIGNMENT CHECK: Before finalizing, re-read the OPERATOR'S ORIGINAL REQUEST above.
      Your company charter, focus area, and CEO must directly serve what was requested.
      If your design drifts from the original request, the adjudicator will reject it.

  - type: document
    filename: "{task.id}_genesis_proposal.md"
    primary_deliverable: true
    hint: |
      Write the complete proposal document as your primary output.

      At the very end of your document, after all sections, append this EXACT block
      with no modifications except filling in the company_slug you designed:

      <!-- PROPOSAL_META
      {
        "task_id": "{task.id}",
        "iteration": 0,
        "version": "0.1",
        "company_slug": "REPLACE_WITH_YOUR_SLUG",
        "max_iterations": 10,
        "refined_by": [],
        "history": ["{task.id} (v0.1 - genesis)"]
      }
      PROPOSAL_META -->

  - type: package
    packet_type: IntakeResponse
    hint: |
      Convert the approved Genesis design into a strict JSON payload.

      Output exactly ONE action object inside actions.
      The action type must be create_company.
      Be specific, constitutional, and directly executable.
      Do not include prose outside the JSON structure.
    schema:
      actions:
        - type: create_company
          company_name: "string -- formal company name"
          company_slug: "string -- lowercase_underscore slug"
          problem_statement: "string -- precise market or internal capability gap being solved"
          target_customer: "string -- the primary buyer, client, or internal requester"
          why_new_company: "string -- why a new sovereign Tenant is justified"
          why_not_existing_tenant: "string -- why existing Tenants cannot solve this cleanly within charter"
          why_not_tool: "string -- why a deterministic tool is insufficient"
          business_plan: "string -- the exact product or service model"
          value_thesis: "string -- how the company creates measurable value"
          charter: "string -- constitutional operating boundaries for the Tenant"
          forbidden_activities: "string -- activities explicitly prohibited to this company"
          non_goals: "string -- explicitly out-of-scope items"
          overlap_risk: "string -- duplication or cannibalization risk and mitigation"
          recursion_risk: "string -- circular delegation risk and why the design remains stable"
          budget: "integer -- seed capital in credits"
          budget_justification: "string -- why this funding level is appropriate"
          ceo_name: "string -- name of the founding CEO"
          ceo_role: "string -- formal title of the founding CEO"
          ceo_seed: "string -- detailed executive seed for downstream identity generation"
          revenue_model: "string -- how the company earns revenue (retainer, per-deliverable, SaaS, etc.)"
          monthly_income_projection: "string -- estimated monthly revenue at steady-state (Year 1 average) with basis"
          monthly_expense_projection: "string -- monthly operating cost breakdown: model compute, infrastructure, oversight, other"
          break_even_timeline: "string -- estimated months from launch to covering monthly operating costs"
          year1_net_projection: "string -- annual revenue minus annual expenses with assumptions stated"
          key_financial_risks: "string -- top 2-3 factors that could compress margin or delay break-even"

  - type: close
    rag_update: true

adjudication:
  enabled: true
  pass_threshold: 95
  deliverable_type: coordination
  criteria:
    constitutional_alignment:
      weight: 20
      description: "Proposal stays within Crimson Leaf charter and governance boundaries"
    request_alignment:
      weight: 15
      description: "Company charter and focus directly match the ORIGINAL OPERATOR REQUEST. Score 0 if the company drifts into a different domain than what was requested."
    niche_specificity:
      weight: 15
      description: "Company is sharply focused, non-generalist, and clearly differentiated"
    strategic_justification:
      weight: 10
      description: "Strong case for why a new company should exist at all"
    portfolio_coherence:
      weight: 10
      description: "Avoids overlap, cannibalization, and architectural sprawl"
    financial_projections:
      weight: 10
      description: "Income and expense projections are specific, grounded, and internally consistent. Break-even timeline and Year 1 net are present with stated assumptions."
    financial_viability:
      weight: 5
      description: "Budget and value thesis are disciplined and credible"
    ceo_alignment:
      weight: 10
      description: "Founding CEO seed matches the company mandate and constitutional role"
    structural_safety:
      weight: 5
      description: "Design avoids recursion, dependency loops, and unstable operating models"
