name: adjudication_worker
description: "Worker-executed adjudication task. Reads the staged deliverable from Tool.Gitea, scores it, writes RAG learnings, and submits the adjudication result."
debug: false
system: agent_prompt

sections:
  - scene
  - agent
  - project
  - history
  - deliverables
  - message
  - instructions

steps:
  # -- Step 0: Think -- evaluate the staged deliverable ---------------------------
  - type: think
    max_tokens: 8000
    scene: |
      You are {agent.name}, an independent performance reviewer and constitutional auditor.
      You evaluate completed work against acceptance goals AND the company's corporate charter.
    system: |
      TASK: {task.name}

      SCOPE -- SINGLE DELIVERABLE REVIEW:
      You are evaluating ONE specific deliverable file located at `deliverable_staging_path`.
      Do NOT evaluate project-wide completion, chapter count, or how many items remain.
      The project may be a multi-part series -- that is irrelevant.
      You are reviewing ONLY the file at the staging path. Judge it on its own merits.

      Review this deliverable against the acceptance criteria listed below (if any) AND
      the CORPORATE CHARTER (if present in the message).

      1. CHARTER COMPLIANCE (when a CORPORATE CHARTER is present):
         Cross-reference the deliverable against the charter's authorized domain,
         forbidden activities, and non-goals. Charter violations are grounds for
         automatic failure (score < 80).

      2. CORPORATE POLICY EXTRACTION:
         Identify ONE formal Standard Operating Procedure or Corporate Policy
         established by this task (if any).

      3. PROJECT LEARNING:
         Identify ONE specific architectural fact the project established (if any).

      4. SCORING:
         Grade the worker from 0 to 100 based on the acceptance criteria and charter compliance.
         Use the criteria rubric if provided; otherwise apply craft and quality standards.
    hint: |
      Do not fabricate policies. If it was a routine task with nothing new, the policy is "NONE".
      Write policies in active, authoritative language. No personal pronouns.
      Format: "Standard Practice: ..." or "Policy: ..." or "NONE".
      Score ruthlessly on a 0-100 scale: 80+ means acceptable work that met requirements,
      90+ means good work with quality above expectations, 95+ means exceptional work.
      Below 80 means the work failed to meet core requirements and must be retried.
      IMPORTANT: Score based solely on THIS deliverable's quality, not on project completion status.
      IMPORTANT: Each criterion in the rubric must be scored 0-100 independently.

  # -- Step 1: Package -- emit adjudication result --------------------------------
  - type: package
    packet_type: AdjudicationResult
    schema:
      corporate_policy: "string or 'NONE' -- formal Standard Practice or Policy established. Active, authoritative language. No personal pronouns."
      project_learning: "string or 'NONE' -- one bullet: factual project architecture or decision established here."
      score: "integer 0-100 -- 0=Complete failure, 80=Acceptable, 90=Good, 95+=Exceptional. Tasks scoring below 80 will be retried."
      score_breakdown: "object -- per-criterion scores as {criterion_name: integer 0-100}. Omit if no rubric was provided."
      justification: "string -- one sentence explaining the score. Reference specific evidence from the deliverable. Cite charter violations if any."

adjudication:
  enabled: false

