// claude-symphony Debate System Configuration
// All stages use Claude sub-agent multi-agent debate instead of external AI models.
// Hybrid dynamic rounds (2-5): independent production → cross-review → optional rebuttal → synthesis.
{
  "debate": {
    "enabled": true,
    "description": "Claude multi-agent debate system for all pipeline stages",
    "version": "1.0.0",

    // ── Intensity Profiles ──────────────────────────────────────────────
    "intensity_profiles": {
      "full": {
        "min_rounds": 3,
        "max_rounds": 5,
        "agent_count": 3,
        "base_task_calls": 7,
        "max_task_calls": 13,
        "description": "Full debate with independent production, cross-review, optional rebuttal rounds, and synthesis"
      },
      "standard": {
        "min_rounds": 2,
        "max_rounds": 4,
        "agent_count": 3,
        "base_task_calls": 4,
        "max_task_calls": 10,
        "description": "Standard debate with independent production, optional cross-review, and synthesis"
      },
      "light": {
        "min_rounds": 2,
        "max_rounds": 3,
        "agent_count": 2,
        "base_task_calls": 3,
        "max_task_calls": 5,
        "description": "Light debate with independent production and synthesis only"
      }
    },

    // ── Dynamic Round Extension ─────────────────────────────────────────
    "dynamic_rounds": {
      "contention_threshold": 0.5,
      "description": "Synthesizer evaluates contention score (0.0-1.0) after each review round",
      "extension_criteria": [
        "Explicit disagreement on core conclusions between agents",
        "Unresolved rebuttals remaining from previous round",
        "Conflicting approaches each with valid supporting evidence"
      ],
      "on_max_rounds_reached": {
        "action": "force_synthesis",
        "strategy": "majority_vote_with_minority_opinion_recorded"
      }
    },

    // ── Per-Stage Debate Roles ──────────────────────────────────────────
    "stage_roles": {
      "01-brainstorm": {
        "execution_mode": "debate",
        "intensity": "full",
        "default_model": "reasoning",
        "roles": [
          {
            "name": "Visionary",
            "model": "reasoning",
            "directive": "Generate bold, boundary-pushing ideas. Think laterally and explore unconventional approaches. What if there were no constraints? Propose 10+ innovative feature ideas that competitors would not consider."
          },
          {
            "name": "Skeptic",
            "model": "balanced",
            "directive": "Challenge every idea for feasibility, technical risk, and user value. Identify hidden assumptions, potential failure modes, and scope risks. Rate each idea on a 1-5 feasibility scale with justification."
          },
          {
            "name": "Integrator",
            "model": "balanced",
            "directive": "Find connections between disparate ideas. Synthesize themes, identify synergies, and propose combinations that create emergent value. Map ideas to user needs and market gaps."
          }
        ]
      },
      "02-research": {
        "execution_mode": "debate",
        "intensity": "standard",
        "default_model": "balanced",
        "roles": [
          {
            "name": "Deep Diver",
            "model": "balanced",
            "directive": "Conduct thorough technical investigation. Evaluate libraries, frameworks, and tools with benchmarks and evidence. Provide detailed comparison tables with quantified metrics."
          },
          {
            "name": "Contrarian",
            "model": "balanced",
            "directive": "Challenge mainstream technology choices. Advocate for alternative approaches, lesser-known tools, or unconventional architectures. Identify risks in popular choices that others overlook."
          },
          {
            "name": "Synthesizer",
            "model": "balanced",
            "directive": "Discover patterns across research findings. Identify where different sources agree and diverge. Create a unified technology recommendation with clear rationale."
          }
        ]
      },
      "03-planning": {
        "execution_mode": "debate",
        "intensity": "full",
        "default_model": "reasoning",
        "roles": [
          {
            "name": "Architect",
            "model": "reasoning",
            "directive": "Design the system architecture for scalability, maintainability, and performance. Define module boundaries, data flow, and communication patterns. Provide architectural decision records."
          },
          {
            "name": "Risk Analyst",
            "model": "reasoning",
            "directive": "Identify failure modes, bottlenecks, and technical debt risks in the proposed architecture. Stress-test the design against edge cases, scale scenarios, and technology changes."
          },
          {
            "name": "Pragmatist",
            "model": "balanced",
            "directive": "Evaluate the architecture against real-world constraints: timeline, team size, budget, and complexity. Propose simplifications without sacrificing core requirements. Focus on what ships."
          }
        ]
      },
      "04-ui-ux": {
        "execution_mode": "debate",
        "intensity": "full",
        "default_model": "balanced",
        "timebox_minutes": 30,
        "decision_owner": "UX Designer",
        "roles": [
          {
            "name": "UX Designer",
            "model": "balanced",
            "directive": "Design from the user's perspective. Map user journeys, create wireframes, define design system. Prioritize accessibility (WCAG 2.1 AA). Ensure all designs follow UI/UX conventions from Stage 03 conventions.md."
          },
          {
            "name": "UI Critic",
            "model": "reasoning",
            "directive": "Challenge every design decision for usability, consistency, and convention compliance. Identify potential UX friction, inconsistent patterns, and accessibility gaps. Verify alignment with Stage 03 conventions."
          },
          {
            "name": "Dev Feasibility",
            "model": "fast",
            "directive": "Evaluate designs for technical feasibility. Identify implementation complexity, performance implications, and component reusability. Flag designs that would be difficult to build within the tech stack chosen in Stage 03."
          }
        ]
      },
      "05-task-management": {
        "execution_mode": "sequential",
        "intensity": "light",
        "default_model": "fast",
        "steps": [
          {
            "name": "Decomposer",
            "model": "fast",
            "directive": "Break down the project plan into granular, actionable tasks. Each task should have clear acceptance criteria and dependencies. Aim for 1-day task granularity. Write tasks.md and implementation_order.md to stage outputs using Write tool.",
            "output": "stages/05-task-management/outputs/ (tasks.md, implementation_order.md)"
          }
        ]
      },
      "06-implementation": {
        "execution_mode": "sequential",
        "code_producing": true,
        "default_model": "balanced",
        "steps": [
          {
            "name": "Coder",
            "model": "balanced",
            "directive": "Scaffold the project and write source code. Include a filepath comment at the top of each code block. You MUST create a project manifest (package.json, *.csproj, pyproject.toml, Cargo.toml, go.mod, etc.) as appropriate. Use the Write tool to create real files in the project root. Do NOT just write markdown — produce actual source files.",
            "output": "Source code files in project root + state/debate/06-implementation/step1/Coder.md (list of files created)"
          },
          {
            "name": "Reviewer",
            "model": "reasoning",
            "directive": "Read the actual source files created by Coder using the Read tool. Review for bugs, security vulnerabilities, performance issues, and architecture violations. Report issues with filepath:line_number format.",
            "input": "Coder's output (source files + file list)",
            "output": "state/debate/06-implementation/step2/Reviewer.md"
          },
          {
            "name": "CoderFix",
            "model": "balanced",
            "directive": "Apply Reviewer's feedback by modifying the actual source files. Use Edit/Write tools to update real files in the project root. Do NOT just describe fixes — apply them.",
            "input": "Reviewer's review",
            "output": "Updated source files + state/debate/06-implementation/step3/CoderFix.md"
          },
          {
            "name": "Tester",
            "model": "balanced",
            "directive": "Read the source code and write test files using the Write tool. Then run build and test commands using Bash. Report build/test results. If tests fail, document the failures.",
            "input": "Updated source files",
            "output": "Test files in project root + state/debate/06-implementation/step4/Tester.md (test results)"
          }
        ]
      },
      "07-qa": {
        "execution_mode": "debate",
        "code_producing": true,
        "intensity": "full",
        "default_model": "balanced",
        "roles": [
          {
            "name": "Security Auditor",
            "model": "reasoning",
            "directive": "Audit the codebase for OWASP Top 10 vulnerabilities. Check for XSS, injection, insecure data storage, and authentication weaknesses. Provide severity ratings and remediation steps."
          },
          {
            "name": "Accessibility Inspector",
            "model": "balanced",
            "directive": "Verify WCAG 2.1 AA compliance. Check keyboard navigation, screen reader support, color contrast, and responsive behavior. Test with assistive technology patterns."
          },
          {
            "name": "Edge Case Hunter",
            "model": "balanced",
            "directive": "Systematically explore boundary conditions, unusual input combinations, and error scenarios. Test resource exhaustion, concurrent operations, and state corruption paths."
          }
        ]
      },
      "08-deployment": {
        "execution_mode": "sequential",
        "intensity": "light",
        "default_model": "fast",
        "steps": [
          {
            "name": "ConfigWriter",
            "model": "fast",
            "directive": "Design CI/CD pipeline, configure hosting, and set up deployment automation. Use the Write tool to create actual config files (Dockerfile, CI/CD YAML, deployment scripts). Write deployment guide to stage outputs.",
            "output": "Config files + stages/08-deployment/outputs/deployment_guide.md"
          }
        ]
      }
    },

    // ── Graceful Degradation ────────────────────────────────────────────
    "graceful_degradation": {
      "min_successful_agents": 1,
      "on_total_failure": "single_agent_fallback",
      "on_token_overflow": "compress_previous_round_outputs",
      "on_agent_failure_in_extra_round": "continue_with_remaining_agents"
    },

    // ── Output Paths ────────────────────────────────────────────────────
    "output_paths": {
      "base_dir": "state/debate",
      "round1_pattern": "state/debate/<stage-id>/round1/<role-name>.md",
      "round2_pattern": "state/debate/<stage-id>/round2/<role-name>_review.md",
      "roundN_pattern": "state/debate/<stage-id>/roundN/<role-name>_rebuttal.md",
      "final_pattern": "stages/<stage-id>/outputs/"
    },

    // ── Synthesis Rules ─────────────────────────────────────────────────
    "synthesis_rules": {
      "consensus_items": "Include with high confidence (all agents agree)",
      "majority_items": "Include with note of dissent (2/3 agree)",
      "contradictory_items": "Select better-supported position, document reasoning",
      "unique_contributions": "Evaluate on quality and include if valuable",
      "required_output_section": "## Debate Notes",
      "code_stage_synthesis": {
        "must_write_files_to_project_root": true,
        "must_run_build": true,
        "must_run_tests": true,
        "min_source_files": 5
      }
    },

    // ── Sequential Mode ───────────────────────────────────────────────
    "sequential_mode": {
      "description": "Role-based sequential execution. Each step's output becomes the next step's input.",
      "max_fix_cycles": 3,
      "fail_on_build_error": true,
      "fail_on_test_error": true
    }
  }
}
