name: development-core
description: Shared development flow with planning, testing, implementation, peer review, adjudicated repair, and a final requirement check.
all_steps:
  rules:
    - ref: findings-handling
      position: before_instruction
    - ref: plain-terminology
      position: before_instruction

subworkflow:
  callable: true
  visibility: internal
  params:
    implementation_pool:
      type: facet_pool_ref
      default: coding-facets
    implementation_workflow:
      type: workflow_ref
      default: development-implement
    remediation_workflow:
      type: workflow_ref
      default: development-remediation
    implementation_companions:
      type: companion_ref[]
      default: []
    reviewer_suite:
      type: workflow_ref
      default: peer-review-suite-base
    peer_review_workflow:
      type: workflow_ref
      default: peer-review
    plan_policy:
      type: facet_ref[]
      facet_kind: policy
      default:
        - design-planning
    plan_knowledge:
      type: facet_ref[]
      facet_kind: knowledge
      default:
        - architecture
        - task-decomposition
    plan_instruction:
      type: facet_ref
      facet_kind: instruction
      default: plan
    plan_report_format:
      type: facet_ref
      facet_kind: report_format
      default: plan
    replan_instruction:
      type: facet_ref
      facet_kind: instruction
      default: replan-implementation
    testing_policy:
      type: facet_ref[]
      facet_kind: policy
      default:
        - coding
        - testing
    testing_knowledge:
      type: facet_ref[]
      facet_kind: knowledge
      default:
        - architecture
        - unit-testing
        - e2e-testing
    testing_instruction:
      type: facet_ref
      facet_kind: instruction
      default: write-tests-first
    testing_report_format:
      type: facet_ref
      facet_kind: report_format
      default: test-report
    development_policy:
      type: facet_ref[]
      facet_kind: policy
      default:
        - coding
        - testing
        - ai-antipattern
    development_knowledge:
      type: facet_ref[]
      facet_kind: knowledge
      default:
        - architecture
        - implementation-semantics
    implementation_instruction:
      type: facet_ref
      facet_kind: instruction
      default: development-implement-with-reports
    reimplementation_instruction:
      type: facet_ref
      facet_kind: instruction
      default: development-reimplement-with-reports
    scope_report_format:
      type: facet_ref
      facet_kind: report_format
      default: coder-scope
    review_policy_additions:
      type: facet_ref[]
      facet_kind: policy
      default: []
    review_policy:
      type: facet_ref[]
      facet_kind: policy
      default:
        - coding
        - testing
        - review
    review_knowledge:
      type: facet_ref[]
      facet_kind: knowledge
      default:
        - architecture
        - unit-testing
        - e2e-testing
    security_review_knowledge_additions:
      type: facet_ref[]
      facet_kind: knowledge
      default: []
    security_review_pool:
      type: facet_pool_ref
      default: security-review-facets
    fix_plan_instruction:
      type: facet_ref
      facet_kind: instruction
      default: fix-plan-from-review-resolution
    fix_replan_instruction:
      type: facet_ref
      facet_kind: instruction
      default: fix-replan
    fix_verification_replan_instruction:
      type: facet_ref
      facet_kind: instruction
      default: verification-replan
    fix_plan_report_format:
      type: facet_ref
      facet_kind: report_format
      default: fix-plan
    final_gate_instruction:
      type: facet_ref
      facet_kind: instruction
      default: supervise-review-resolution
initial_step: plan

facet_pools:
  coding-facets:
    uses: coding-facets
  takt-coding-facets:
    uses: takt-coding-facets
  security-review-facets:
    uses: security-review-facets
  takt-security-review-facets:
    uses: takt-security-review-facets

steps:
  - name: plan
    capabilities:
      - readonly
    uses: development-core-plan
    with:
      plan_policy:
        $param: plan_policy
      plan_knowledge:
        $param: plan_knowledge
      plan_instruction:
        $param: plan_instruction
      plan_report_format:
        $param: plan_report_format
    rules:
      - condition: Requirements are clear and implementation is feasible
        next: write_tests
      - condition: The user is asking a question rather than requesting implementation
        next: COMPLETE
      - condition: Requirements are unclear or information is insufficient
        next: ABORT

  - name: replan
    description: Assess implementation and verification gaps and constraints, and decide whether to continue implementation, proceed to independent review, or stop.
    input_reports:
      from_step: peer-review
      reports:
        - review-resolution.md
      optional_if_unrun: true
    tags:
      - plan
    edit: false
    capabilities: readonly
    persona: planner
    policy:
      - process-deviation
      - contract-change
      - applicable-inputs
      - $param: plan_policy
    knowledge:
      $param: plan_knowledge
    instruction:
      $param: replan_instruction
    output_contracts:
      report:
        - name: plan.md
          format:
            $param: plan_report_format
    rules:
      - condition: >-
          Without waiting for user input or an external action, an untried, project-executable code change, test change,
          cause investigation, or valid verification method necessary for an unmet requirement or accepted contract of
          this task has been defined together with its execution conditions. This includes mandatory verification that
          has not yet run but can run now. A method that failed under the same constraint is not untried without a
          result-affecting difference in input, environment, or method and evidence that the constraint can be removed
          or bypassed. Unrelated work is excluded.
        next: implement
      - condition: >-
          All of the following apply to this task's requirements and acceptance criteria.
          (1) Concrete implementation and available project-scoped verification evidence support what can be assessed
          within the project.
          (2) No unresolved implementation defect, untouched mandatory work, or executable new project-scoped work remains.
          (3) Mandatory verification is complete, or only verification that cannot be proved because of an environmental
          constraint remains unverified, with its attempted evidence, constraint, and explicit external verification
          obligation retained for independent review.
          (4) This is not a case already judged BLOCKED by the latest independent review for the same implementation,
          evidence, and external constraint with no subsequent result-affecting change.
          Do not call unverified work successful or finally complete. Unrelated pre-existing issues and incomplete report
          labels alone do not block review.
        next: peer-review
      - condition: >-
          Either of the following applies.
          (1) The latest independent review already judged the same current implementation, evidence, and external
          constraint BLOCKED, with no subsequent result-affecting change or executable new project-scoped work.
          Retain the unverified mandatory external check and required action or answer as a wait.
          (2) The conditions for independent review above are not met, and either only an indispensable external action
          or answer that project-scoped work cannot resolve remains for a mandatory condition, or confirmed evidence
          shows the requirements are incompatible. An unverified or failed report alone is insufficient.
        next: ABORT

  - name: write_tests
    capabilities:
      - edit
    uses: development-core-write-tests
    with:
      testing_policy:
        $param: testing_policy
      testing_knowledge:
        $param: testing_knowledge
      testing_instruction:
        $param: testing_instruction
      testing_report_format:
        $param: testing_report_format
    rules:
      - condition: Test work is complete
        next: implement
      - condition: Necessary tests cannot be created until after implementation
        next: implement
      - condition: Test creation cannot proceed
        next: plan
      - condition: User input is required for a clarification
        next: write_tests
        requires_user_input: true
        interactive_only: true

  - name: implement
    description: Implement the plan and run required verification, addressing gaps or reporting the need to replan.
    kind: workflow_call
    call:
      $param: implementation_workflow
    args:
      implementation_pool:
        $param: implementation_pool
      implementation_companions:
        $param: implementation_companions
      development_policy:
        $param: development_policy
      development_knowledge:
        $param: development_knowledge
      implementation_instruction:
        $param: implementation_instruction
      reimplementation_instruction:
        $param: reimplementation_instruction
      scope_report_format:
        $param: scope_report_format
    rules:
      - condition: COMPLETE
        next: peer-review
      - condition: need_replan
        next: replan
      - condition: ABORT
        next: replan

  - name: peer-review
    description: Adjudicate specialist review findings, fix and verify them, then assess requirement fulfillment to decide whether to complete or replan.
    kind: workflow_call
    call:
      $param: peer_review_workflow
    args:
      reviewer_suite:
        $param: reviewer_suite
      review_policy_additions:
        $param: review_policy_additions
      review_knowledge_additions:
        $param: review_knowledge
      security_review_knowledge_additions:
        $param: security_review_knowledge_additions
      security_review_pool:
        $param: security_review_pool
      fix_companions:
        $param: implementation_companions
      remediation_workflow:
        $param: remediation_workflow
      fix_pool:
        $param: implementation_pool
      plan_policy:
        $param: review_policy
      fix_policy:
        $param: development_policy
      fix_knowledge:
        $param: development_knowledge
      verification_knowledge:
        $param: review_knowledge
      verification_policy:
        $param: review_policy
      final_gate_policy:
        $param: review_policy
      fix_plan_instruction:
        $param: fix_plan_instruction
      fix_replan_instruction:
        $param: fix_replan_instruction
      fix_verification_replan_instruction:
        $param: fix_verification_replan_instruction
      fix_plan_report_format:
        $param: fix_plan_report_format
      final_gate_instruction:
        $param: final_gate_instruction
    rules:
      - condition: COMPLETE
        next: COMPLETE
      - condition: need_replan
        next: replan
      - condition: ABORT
        next: ABORT
