{
  "contract": "algal.organism.v1",
  "key": "organism:refine-inner",
  "name": "Polish a draft once",
  "budgets": {
    "maxAgentCalls": 16,
    "maxContextBytes": 65536,
    "maxDepth": 4,
    "maxOutputBytes": 65536,
    "maxSteps": 256,
    "maxWork": 1000000
  },
  "cells": [
    {
      "id": "in",
      "kind": "input",
      "outputs": {
        "draft": {
          "type": "text"
        }
      }
    },
    {
      "id": "editor",
      "kind": "agent",
      "prompt": "Improve the draft: tighten, clarify, keep the voice.",
      "view": {
        "inputs": "*"
      },
      "output": {
        "kind": "text"
      },
      "inputs": {
        "draft": {
          "type": "text"
        }
      }
    },
    {
      "id": "critic",
      "kind": "classifier",
      "prompt": "Is this draft ready to ship?",
      "view": {
        "inputs": "*"
      },
      "output": {
        "kind": "choice",
        "labels": [
          "revise",
          "ship"
        ]
      },
      "inputs": {
        "draft": {
          "type": "text"
        }
      }
    }
  ],
  "edges": [
    {
      "from": {
        "cell": "in",
        "port": "draft"
      },
      "to": {
        "cell": "editor",
        "port": "draft"
      }
    },
    {
      "from": {
        "cell": "editor",
        "port": "out"
      },
      "to": {
        "cell": "critic",
        "port": "draft"
      }
    }
  ],
  "note": "One round of the evaluator-optimizer loop: an editor agent rewrites the draft, a critic classifier decides ship-or-revise.",
  "interface": {
    "inputs": {
      "draft": {
        "cell": "in",
        "port": "draft"
      }
    },
    "outputs": {
      "draft": {
        "cell": "editor",
        "port": "out"
      },
      "verdict": {
        "cell": "critic",
        "port": "out"
      }
    }
  }
}
