name: strategic_review
description: "Crimson Leaf 24-hour strategic review -- mission assessment, portfolio evaluation, gap identification, and escalation."
debug: true
model: power
sections:
  - agent
  - project
  - history
  - participants
  - participants_prompt
  - rag
  - message
  - instructions
builders:
  message: |
    *** PORTFOLIO REPORT ***
    {steps[0].text}
steps:
  - type: tool
    action: get_portfolio_report
    output_key: portfolio_data

  - type: tool
    action: git_read_file
    params:
      path: "agents/edgar/mission.md"
    output_key: mission_data
    optional: false

  - type: tool
    action: git_read_file
    params:
      path: "agents/edgar/strategic_log.md"
    output_key: strategic_log_data
    optional: true

  - type: tool
    action: git_read_file
    params:
      path: "agents/edgar/logs/latest.md"
    output_key: latest_log_entry
    optional: true

  - type: tool
    action: git_read_file
    params:
      path: "deliverables/proposals/index.md"
    output_key: prior_proposals_index
    optional: true

  - type: think
    max_tokens: 8000
    rotate_participants: true
    loop:
      max_iterations: 3
    hint: |
      You are {agent.name}, participating in the Crimson Leaf Holdings strategic review.
      This is round {task.iteration} of the board session.

      The portfolio report is above.

      === MISSION CHARTER ===
      {mission_data}

      === STRATEGIC LOG (Master) ===
      {strategic_log_data}

      === LAST CYCLE ENTRY ===
      {latest_log_entry}

      === PRIOR PROPOSALS (all proposals ever submitted) ===
      {prior_proposals_index}
      ===

      Analyze from YOUR perspective:

      - If you are Edgar (The Operator): Focus on execution health and metrics only.
        Are companies executing? Are we moving toward the mission success criteria?
        Report: CLP chapter velocity, CLM campaign status, adjudication pass rates,
        and total_spend_usd_30d from the portfolio report. If cost is up vs last cycle,
        flag it. If cost_per_polished_chapter_usd_30d > $0.50, flag it.
        DO NOT discuss what company to propose -- proposals are handled by a separate
        gate after this debate. The mission charter already defines what gaps exist
        and what companies are authorized. Your job here is execution reporting.

      - If you are Orion (The Visionary): Focus on EXECUTION opportunities only.
        What should we be doing better with EXISTING companies and templates?
        Are we leaving value on the table with CLP or CLM? What is underperforming?
        DO NOT propose new companies -- that is outside the scope of this debate.

      - If you are Sloane (The Dealmaker): Focus on marketing, visibility, revenue.
        Are we selling? Does anyone know we exist? What channels are we missing?
        What could CLM do better right now for the books we already have?

      Build on previous speakers' points. Disagree if you must -- this is a board debate.

      When genuine consensus is reached across all perspectives, include exactly:
      consensus_reached: true
      If debate should continue, do NOT include that line.

  - type: think
    max_tokens: 6000
    agent: first_available
    output_key: strategic_brief
    hint: |
      Synthesize the boardroom transcript into a STRATEGIC BRIEF for David.

      Structure:
      1. EXECUTIVE SUMMARY -- one paragraph on portfolio health and mission progress
      2. MISSION GAP AUDIT -- assess each gap from the mission charter. Is Gap 3 (KDP
         pipeline) now the top priority since Gap 1 (CLO) is resolved? Has revenue
         arrived yet? Cite total_royalty_usd_30d from the portfolio report if available.
      3. CRITICAL ISSUES -- things needing immediate attention (include cost overruns:
         if total_spend_usd_30d > $20.00 or cost_per_polished_chapter > $0.50, flag it)
      4. OPPORTUNITIES -- ranked by priority
      5. ACTION ITEMS -- specific tasks for David:
         "David, [verb]: [details]"
      6. NEXT REVIEW -- focus for the next 24-hour review

      Keep it actionable. David is one person -- prioritize ruthlessly.

      DO NOT include any PROPOSAL_NEEDED or CLM_DISPATCH lines in this brief.
      Those decisions are handled by dedicated gate steps after this brief.
      This brief is purely about execution health and what David should focus on.

      MARKETING DISPATCH ASSESSMENT:
      A book "needs marketing" if crimson_leaf_marketing shows no active campaign for it.
      Only dispatch to CLM for books that EXIST in Crimson Leaf Publishing (Cypress Bend,
      Crimson Vows, or The Binding Thread). Do NOT dispatch for hallucinated book titles.
      At the end of your brief, include:
      CLM_DISPATCH: <book-project-slug if a real completed book needs CLM campaign, or "none">

      === STRATEGIC LOG ===
      {strategic_log_data}

      === LAST CYCLE ENTRY ===
      {latest_log_entry}

  - type: think
    max_tokens: 100
    output_key: proposal_project_slug
    hint: |
      Ignore the board debate above. Read ONLY the strategic log below.

      === STRATEGIC LOG ===
      {strategic_log_data}
      ===

      Rule: If the log says "READY TO PROPOSE" for any gap, output: incubation
      If the log says "AWAITING DAVID'S APPROVAL" or "REJECTED" for all gaps, output: none
      If the log has no clear status, output: none

      Output ONLY one word: incubation OR none. No explanation. No punctuation.

  - type: think
    max_tokens: 800
    output_key: proposal_brief
    hint: |
      Gate: if {proposal_project_slug} is "none", output exactly: none

      If the gate passes, you are writing a task brief for Crimson Leaf Operations (CLO).
      This is the company brief that will be sent to the company_proposal pipeline.
      Do NOT use anything from the board debate above -- that was about execution, not proposals.
      Do NOT rename the company. Do NOT propose anything else.

      === MISSION CHARTER (authoritative source for company definition) ===
      {mission_data}

      === PRIOR PROPOSALS (all rejected -- you must not repeat these) ===
      {prior_proposals_index}
      ===

      THE COMPANY TO PROPOSE: Crimson Leaf Operations (CLO)
      This is a FIXED requirement -- not a suggestion. CLO is the only company
      authorized as GAP 1 in the mission charter.

      CLO is:
        - An INTERNAL operations and accounting subsidiary
        - Its purpose: give Edgar (and David) financial visibility into API costs,
          revenue, and margins across all subsidiaries
        - It generates weekly P&L reports, tracks cost-per-task, surfaces burn rate
        - It does NOT interact with external clients, authors, or customers
        - It is NOT a storefront, agency, or services business

      Write the task brief. Include:
      - Company name: Crimson Leaf Operations
      - Slug: crimson_leaf_operations
      - The gap it fills: Edgar has zero financial visibility right now
      - What CLO does specifically: cost tracking, P&L, margin visibility
      - Why now: 30 more days of blind spending
      - What it is NOT (to prevent the proposal template from going off-rails)
      - 90-day success criteria: weekly P&L in #general, cost-per-chapter visible

      Output ONLY the brief text. No labels. No preamble. No "Here is the brief:".

  - type: tool
    action: enqueue_strategy
    optional: true
    params:
      company_slug: "crimson_leaf"
      project_slug: "{proposal_project_slug}"
      task_type: "company_proposal"
      content: "{proposal_brief}"
      agent_name: "edgar"

  - type: think
    max_tokens: 100
    output_key: clm_dispatch_slug
    hint: |
      Read the CLM_DISPATCH line from the strategic brief above.
      Map the book slug to the CLM project slug as follows:
        cypress-bend    -> book-marketing-agency
        crimson-vows    -> book-marketing-agency
        binding-thread  -> book-marketing-agency
        none            -> none
      Output ONLY the mapped slug. No explanation. No extra text.

  - type: think
    max_tokens: 600
    output_key: clm_dispatch_message
    hint: |
      Read the CLM_DISPATCH line from the strategic brief above.
      The book identified is one of: cypress-bend, crimson-vows, binding-thread, or none.

      If the book is "none" or {clm_dispatch_slug} is "none", output exactly: none

      Otherwise write a marketing campaign request. Include:
      - Book title and genre (use the CLM_DISPATCH value to identify it)
      - The manuscript is complete in Crimson Leaf Publishing Gitea repo
      - Request: full marketing campaign (strategy, social, email, press release, ad copy)
      - Urgency: book has no active campaign and needs revenue generation

      Book reference:
      - cypress-bend: "Cypress Bend" contemporary romance, audience adult women 25-45
      - crimson-vows: "Crimson Vows" paranormal romance, audience adult women 25-40
      - binding-thread: "The Binding Thread" fantasy romance, audience adult women 20-40

      Output ONLY the message text. No preamble.

  - type: tool
    action: enqueue_strategy
    optional: true
    params:
      company_slug: "crimson_leaf_marketing"
      project_slug: "{clm_dispatch_slug}"
      task_type: "marketing_campaign"
      content: "{clm_dispatch_message}"

  - type: think
    max_tokens: 600
    output_key: log_entry
    hint: |
      Write a brief summary of THIS CYCLE'S strategic review to record in the log.
      This entry will be loaded next cycle so Edgar remembers what was decided.

      Format:
      ## Cycle Entry: Task {task.id}

      ### Board Consensus
      [One sentence: what did the board agree on?]

      ### Gap Status
      GAP 1 (CLO): [submitted/deferred/awaiting David/no change -- ONE of these]
      GAP 2 (CLR): [status]
      GAP 3 (KDP): [status]

      ### Proposal Decision
      [ONE of:]
      SUBMITTED: [company-slug] -- task enqueued to incubation this cycle
      DEFERRED: [reason]
      NONE: [reason]

      ### CLM Dispatch
      [ONE of:]
      DISPATCHED: [book-project-slug]
      NONE

      ### Next Focus
      [One sentence]

      Keep it factual. Use only what happened in this cycle.
      Do NOT invent history. Do NOT summarize old entries.
      Output ONLY the entry text above.

  - type: document
    source_step: log_entry
    dest_path: "agents/edgar/logs/latest.md"
    commit_msg: "log: strategic review cycle {task.id}"

  - type: reply
    target: channel
    channel_name: "crimson_leaf:live-feed"

adjudication:
  enabled: false