name: development-implement-dynamic
description: Dynamic-facet 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: 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
facet_pools:
  coding-facets:
    uses: coding-facets
  takt-coding-facets:
    uses: takt-coding-facets
initial_step: implement
steps:
  - name: implement
    capabilities:
      - edit
    uses: development-core-implement
    instruction:
      - $param: implementation_instruction
      - development-implementation-completion
    with:
      development_policy:
        $param: development_policy
      development_knowledge:
        $param: development_knowledge
      implementation_instruction:
        $param: implementation_instruction
      scope_report_format:
        $param: scope_report_format
    dynamic_facets:
      pool:
        $param: implementation_pool
    companion:
      $param: implementation_companions
    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, implementation, cause investigation, or mandatory verification is incomplete, and concrete work necessary for this task is executable within the current plan (a method that failed under the same constraint is not new work without a result-affecting difference and evidence that the constraint can be removed or bypassed; 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 and no concrete project-scoped work would become possible by changing the plan, while verification remains unproven because of an environmental constraint, an indispensable external action or answer remains, or there is evidence that the conditions are incompatible (except when available user input can unblock the work). Preserve attempted evidence, constraints, and unmet obligations, and pass the independent-review handoff, continuation, or stopping decision to the planning step
        return: need_replan
      - condition: User input is required
        next: implement
        requires_user_input: true
        interactive_only: true
  - name: reimplement
    capabilities:
      - edit
    uses: development-core-implement
    instruction:
      - $param: reimplementation_instruction
      - development-implementation-completion
    with:
      development_policy:
        $param: development_policy
      development_knowledge:
        $param: development_knowledge
      implementation_instruction:
        $param: reimplementation_instruction
      scope_report_format:
        $param: scope_report_format
    dynamic_facets:
      pool:
        $param: implementation_pool
    companion:
      $param: implementation_companions
    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: The accepted plan is valid, but implementation, cause investigation, or mandatory verification remains incomplete after remediation, and untried work necessary for this task is executable within the project (except when available user input can resolve it). Report attempted methods, conditions, results, evidence, constraints, and the substantive difference of the next work; 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 and no concrete project-scoped work would become possible by changing the plan, while verification remains unproven because of an environmental constraint, an indispensable external action or answer remains, or there is evidence that the conditions are incompatible (except when available user input can unblock the work). Preserve attempted evidence, constraints, and unmet obligations, and pass the independent-review handoff, continuation, or stopping decision to the planning step
        return: need_replan
      - condition: User input is required
        next: reimplement
        requires_user_input: true
        interactive_only: true
