name: development-implement-team
description: Team Leader implementation execution for the shared development workflows.
subworkflow:
  callable: true
  visibility: internal
  returns:
    - need_replan
  params:
    implementation_pool:
      type: facet_pool_ref
      default: coding-facets
    implementation_companions:
      type: companion_ref[]
      default: []
    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: implement
    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
facet_pools:
  coding-facets:
    uses: coding-facets
  takt-coding-facets:
    uses: takt-coding-facets
initial_step: implement
steps:
  - name: implement
    capabilities:
      - edit
      - enable-skills
    tags:
      - coding
      - coding-leader
    uses: development-core-implement
    instruction:
      - development-team-with-reports
      - development-implementation-completion
    companion:
      $param: implementation_companions
    with:
      development_policy:
        $param: development_policy
      development_knowledge:
        $param: development_knowledge
      implementation_instruction: development-team-with-reports
      scope_report_format:
        $param: scope_report_format
    team_leader:
      max_concurrency: 2
      initial_max_parts: 2
      fail_on_part_error: false
      part_tags:
        - coding
        - coding-part
      part_persona: coder
      part_edit: true
      part_permission_mode: edit
    rules:
      - condition: The required implementation was performed and its mandatory verification is complete (pre-existing failures and out-of-scope work that are neither causally related to this change nor mandatory for this task do not block completion; an incomplete label in the report alone does not justify returning it)
        next: COMPLETE
      - condition: No implementation change is needed for this task and mandatory verification is complete (report-only work; excludes any required work that has not been performed)
        next: COMPLETE
      - condition: The accepted plan is valid, but implementation, cause investigation, or mandatory verification remains incomplete and a concrete remediation is executable within the current plan (an unexecuted, failed, or unverified report alone does not require replanning)
        next: reimplement
      - condition: The accepted plan's premises, scope, method, or verification capability is defective; changing the plan would enable concrete project-local work, and leaving it unchanged prevents the requirement from being executed or verified (unexecuted, failed, unresolved, or unsupported work alone does not qualify; external-only work is excluded)
        return: need_replan
      - condition: No mandatory work can be executed under the current plan or remediation, and evidence confirms that only an external action or external answer remains, or provides a basis to believe the conditions are incompatible. Report the external constraint and unmet obligations, and pass the final continuation, replanning, or stopping decision to the planning step (choose the user-input route only when a user-input option is available and its answer would unblock the work)
        return: need_replan
      - condition: User input is required
        next: implement
        requires_user_input: true
        interactive_only: true
  - name: reimplement
    capabilities:
      - edit
      - enable-skills
    tags:
      - coding
      - coding-leader
    uses: development-core-implement
    instruction:
      - team-leader-implement
      - $param: reimplementation_instruction
      - development-implementation-completion
    companion:
      $param: implementation_companions
    with:
      development_policy:
        $param: development_policy
      development_knowledge:
        $param: development_knowledge
      implementation_instruction:
        $param: reimplementation_instruction
      scope_report_format:
        $param: scope_report_format
    team_leader:
      max_concurrency: 2
      initial_max_parts: 2
      fail_on_part_error: false
      part_tags:
        - coding
        - coding-part
      part_persona: coder
      part_edit: true
      part_permission_mode: edit
    rules:
      - condition: The missing implementation or cause investigation was completed and mandatory verification is complete (unrelated pre-existing failures and out-of-scope work do not block completion)
        next: COMPLETE
      - condition: No implementation change was needed and the previously unexecuted mandatory verification is complete (report-only work; excludes any required work that has not been performed)
        next: COMPLETE
      - condition: Implementation, cause investigation, or mandatory verification remains incomplete after remediation (including when the accepted plan is still valid, except when available user input can resolve it). Report the remaining gaps with evidence and pass the continuation decision to the planning step
        return: need_replan
      - condition: The accepted plan's premises, scope, method, or verification capability is defective; changing the plan would enable concrete project-local work, and leaving it unchanged prevents the requirement from being executed or verified (unexecuted, failed, unresolved, or unsupported work alone does not qualify; external-only work is excluded)
        return: need_replan
      - condition: No mandatory work can be executed under the current plan or remediation, and evidence confirms that only an external action or external answer remains, or provides a basis to believe the conditions are incompatible. Report the external constraint and unmet obligations, and pass the final continuation, replanning, or stopping decision to the planning step (choose the user-input route only when a user-input option is available and its answer would unblock the work)
        return: need_replan
      - condition: User input is required
        next: reimplement
        requires_user_input: true
        interactive_only: true
