---
title: "debug_code_change"
description: "Safely diagnose and fix a bug/regression in a codebase."
canonical: "https://acs.synapti.ai/workflows/debug-code-change/"
last_updated: "2026-11-16T03:28:14Z"
---

# Safely diagnose and fix a bug/regression in a codebase.

Generated from [schemas/workflow_catalog.yaml](https://github.com/synaptiai/agent-capability-standard/blob/main/schemas/workflow_catalog.yaml) at commit 18c38b74ac21.

- Workflow id: `debug_code_change`
- Risk: medium
- Catalog: reference workflows
- Declares Standard 1.1.0
- Steps: 11

**Figure: Steps of debug_code_change: 11 steps, checkpoint at step 7, rollback at step 10.** Read top to bottom: step 8 makes the change after the checkpoint at step 7; steps 8, 9 and 10 have gates; steps 1, 8 and 9 say what to do on failure; and the highest step risk is high, at step 8.

| # | Capability | Layer | Role | Gates | On failure | Reads from | Risk |
| --- | --- | --- | --- | --- | --- | --- | --- |
| 1 | `observe` | PERCEIVE |  |  | request_more_context |  | low |
| 2 | `search` | PERCEIVE |  |  |  |  | low |
| 3 | `attribute` | MODEL |  |  |  |  | low |
| 4 | `constrain` | VERIFY | verify |  |  |  | low |
| 5 | `critique` | REASON |  |  |  | 3 | low |
| 6 | `plan` | REASON |  |  |  | 1, 2, 3, 5 | low |
| 7 | `checkpoint` | VERIFY | checkpoint |  |  |  | medium |
| 8 | `execute` | EXECUTE | mutating | skip | rollback | 6 | high |
| 9 | `verify` | VERIFY | verify | skip | rollback | 8 | medium |
| 10 | `rollback` | VERIFY | rollback | skip |  | 7, 9 | medium |
| 11 | `audit` | VERIFY |  |  |  | 3, 6, 8, 9, 10 | medium |

## Inputs

**Figure: Inputs of debug_code_change.** 4 inputs, 1 required (filled pin) and 3 optional (outlined pin), with 5 named fields inside them.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `bug` | object | Yes | The failure to diagnose and fix |
| `bug.component` | string | No |  |
| `bug.symptom` | string | No |  |
| `bug.fix_command` | string | No |  |
| `user_input` | object | No |  |
| `user_input.domain` | string | No |  |
| `user_input.constraints` | object | No |  |
| `previous_world_state` | object | No |  |
| `world_state_out` | object | No |  |

## Steps

1. [`observe`](https://acs.synapti.ai/capabilities/observe/index.md): Observe failing behavior, logs, and relevant code paths. Stores `observe_out`. (risk low)
2. [`search`](https://acs.synapti.ai/capabilities/search/index.md): Find related code, configs, and error patterns. Stores `search_out`. (risk low)
3. [`attribute`](https://acs.synapti.ai/capabilities/attribute/index.md): Build dependency graph and identify causal relationships around failing component. Stores `attribute_out`. (risk low)
4. [`constrain`](https://acs.synapti.ai/capabilities/constrain/index.md): Define invariants/spec expectations for the component. Stores `constrain_out`. (risk low)
5. [`critique`](https://acs.synapti.ai/capabilities/critique/index.md): List likely failure modes + edge cases. Stores `critique_out`. (risk low)
6. [`plan`](https://acs.synapti.ai/capabilities/plan/index.md): Produce minimal fix plan with checkpoints. Stores `plan_out`. (risk low)
7. [`checkpoint`](https://acs.synapti.ai/capabilities/checkpoint/index.md): Create checkpoint before mutation. Stores `checkpoint_out`. (risk medium, changes state)
8. [`execute`](https://acs.synapti.ai/capabilities/execute/index.md): Apply the fix with the bug's fix command, run the tests, and produce a diff summary. Stores `execute_out`. (risk high, changes state, needs a checkpoint before it, needs approval)
   - Gate: when `${plan_out.steps} == []`, skip: The fix plan has no steps, so no fix is applied; the run goes on to the audit.
9. [`verify`](https://acs.synapti.ai/capabilities/verify/index.md): Run targeted verification and return PASS/FAIL. Stores `verify_out`. (risk medium)
   - Gate: when `${execute_out} == null`, skip: No fix was applied, so there is nothing to verify.
10. [`rollback`](https://acs.synapti.ai/capabilities/rollback/index.md): If verify FAIL, revert safely. Stores `rollback_out`. (risk medium, changes state, needs a checkpoint before it)
   - Gate: when `${verify_out} == null || ${verify_out.passed} == true`, skip: No fix was applied, or the fix passed verification. No rollback needed.
11. [`audit`](https://acs.synapti.ai/capabilities/audit/index.md): Record what changed and why, and whether it was rolled back. Stores `audit_out`. (risk medium)

## Data flow

**Figure: Which step reads which stored output.** 6 steps read the output of earlier steps, 14 reads in all; step 11 (audit) reads the most, from 5 steps.

- Step 5 reads from step 3.
- Step 6 reads from steps 1, 2, 3 and 5.
- Step 8 reads from step 6.
- Step 9 reads from step 8.
- Step 10 reads from steps 7 and 9.
- Step 11 reads from steps 3, 6, 8, 9 and 10.

## Risk

**Figure: Risk of debug_code_change: declared medium; highest step risk high, at step 8 (execute).** The catalog declares medium; the highest step risk is high; the computed risk is high.

- Step 1 (`observe`): low
- Step 2 (`search`): low
- Step 3 (`attribute`): low
- Step 4 (`constrain`): low
- Step 5 (`critique`): low
- Step 6 (`plan`): low
- Step 7 (`checkpoint`): medium
- Step 8 (`execute`): high
- Step 9 (`verify`): medium
- Step 10 (`rollback`): medium
- Step 11 (`audit`): medium

## Success criteria

- Bug fixed or root cause isolated
- Verification PASS
- Audit trail produced

## Related

- Composed skill: [debug-workflow](https://acs.synapti.ai/guides/skills/debug-workflow/index.md)

## Validate it

```sh
python tools/validate_workflows.py --catalog schemas/workflow_catalog.yaml
```

## Workflow YAML

```yaml
debug_code_change:
  goal: Safely diagnose and fix a bug/regression in a codebase.
  risk: medium
  steps:
  - capability: observe
    purpose: Observe failing behavior, logs, and relevant code paths.
    risk: low
    mutation: false
    requires_checkpoint: false
    requires_approval: false
    timeout: null
    retry: null
    store_as: observe_out
    input_bindings:
      target: "${bug.component}"
    failure_modes:
    - condition: No relevant signals found
      when: "${observe_out.observation} == {}"
      action: request_more_context
      recovery: Ask for reproduction steps or additional artifacts.
  - capability: search
    purpose: Find related code, configs, and error patterns.
    risk: low
    mutation: false
    requires_checkpoint: false
    requires_approval: false
    timeout: null
    retry: null
    store_as: search_out
    input_bindings:
      query: "${bug.symptom}"
    failure_modes: []
  - capability: attribute
    purpose: Build dependency graph and identify causal relationships around failing component.
    domain: dependencies
    risk: low
    mutation: false
    requires_checkpoint: false
    requires_approval: false
    timeout: null
    retry: null
    store_as: attribute_out
    input_bindings:
      effect: "${bug.symptom}"
    failure_modes: []
  - capability: constrain
    purpose: Define invariants/spec expectations for the component.
    risk: low
    mutation: false
    requires_checkpoint: false
    requires_approval: false
    timeout: null
    retry: null
    store_as: constrain_out
    input_bindings:
      target: "${bug.component}"
      constraints: ["existing_tests_pass", "public_interfaces_unchanged"]
    failure_modes: []
  - capability: critique
    purpose: List likely failure modes + edge cases.
    risk: low
    mutation: false
    requires_checkpoint: false
    requires_approval: false
    timeout: null
    retry: null
    store_as: critique_out
    input_bindings:
      target: "${attribute_out.causes: array<object>}"
    failure_modes: []
  - capability: plan
    purpose: Produce minimal fix plan with checkpoints.
    risk: low
    mutation: false
    requires_checkpoint: false
    requires_approval: false
    timeout: null
    retry: null
    store_as: plan_out
    input_bindings:
      goal: "Fix ${bug.symptom} in ${bug.component}"
      constraints: "${user_input.constraints}"
      context:
        observation: "${observe_out.observation}"
        related_code: "${search_out.results: array<object>}"
        causes: "${attribute_out.causes: array<object>}"
        failure_modes: "${critique_out.issues: array<object>}"
        suggestions: "${critique_out.suggestions: array<object>}"
    failure_modes: []
  - capability: checkpoint
    purpose: Create checkpoint before mutation.
    risk: medium
    mutation: true
    requires_checkpoint: false
    requires_approval: false
    timeout: null
    retry: null
    store_as: checkpoint_out
    input_bindings:
      scope: "${bug.component}"
    failure_modes: []
  - capability: execute
    purpose: Apply the fix with the bug's fix command, run the tests, and produce a diff summary.
    risk: high
    mutation: true
    requires_checkpoint: true
    requires_approval: true
    timeout: 5m
    retry: null
    store_as: execute_out
    input_bindings:
      code: "${bug.fix_command}"
    gates:
    - when: ${plan_out.steps} == []
      action: skip
      message: The fix plan has no steps, so no fix is applied; the run goes on to the audit.
    failure_modes:
    - condition: The fix command failed or timed out
      on_error: [R401, R402]
      action: rollback
      recovery: Roll back to the checkpoint taken before the fix; the run then ends with the execute step's error, and the audit step does not run; the run record the host keeps (STANDARD v1.2 §5.19.8) records the failure.
  - capability: verify
    purpose: Run targeted verification and return PASS/FAIL.
    risk: medium
    mutation: false
    requires_checkpoint: false
    requires_approval: false
    timeout: 5m
    retry:
      max: 3
      backoff: exponential
    store_as: verify_out
    input_bindings:
      target:
        component: "${bug.component}"
        execution: "${execute_out}"
      conditions: ["tests_pass", "symptom_resolved", "public_interfaces_unchanged"]
    gates:
    - when: ${execute_out} == null
      action: skip
      message: No fix was applied, so there is nothing to verify.
    # A FAIL verdict is handled by the rollback step below, not by a failure
    # mode: verify itself succeeded, and the run goes on to roll back and audit.
    failure_modes:
    - condition: Verification could not run (timed out or failed after its retries)
      on_error: [R401, R402]
      action: rollback
      recovery: Roll back the unverified fix to the checkpoint; the run then ends with the verify step's error, and the audit step does not run; the run record the host keeps (STANDARD v1.2 §5.19.8) records the failure.
  - capability: rollback
    purpose: If verify FAIL, revert safely.
    risk: medium
    mutation: true
    requires_checkpoint: false
    requires_approval: false
    timeout: null
    retry: null
    store_as: rollback_out
    input_bindings:
      checkpoint_id: "${checkpoint_out.checkpoint_id}"
    failure_modes: []
    gates:
    - when: ${verify_out} == null || ${verify_out.passed} == true
      action: skip
      message: No fix was applied, or the fix passed verification. No rollback needed.
  - capability: audit
    purpose: Record what changed and why, and whether it was rolled back.
    risk: medium
    mutation: false
    requires_checkpoint: false
    requires_approval: false
    timeout: null
    retry: null
    store_as: audit_out
    input_bindings:
      event:
        type: "debug_code_change"
        component: "${bug.component}"
        causes: "${attribute_out.causes: array<object>}"
        plan: "${plan_out.steps: array<object>}"
        exit_code: "${execute_out.exit_code}"
        verified: "${verify_out.passed}"
        rolled_back: "${rollback_out.restored}"
    failure_modes: []
  success:
  - Bug fixed or root cause isolated
  - Verification PASS
  - Audit trail produced
  risk_propagation:
    strategy: max_step_risk
    computed_risk: high
  data_flow:
    pattern: step_outputs_are_addressable
    rule: Each step output is stored under store_as and may be referenced by later steps.
  inputs:
    bug:
      type: object
      required: true
      description: The failure to diagnose and fix
      properties:
        component:
          type: string
        symptom:
          type: string
        fix_command:
          type: string
    user_input:
      type: object
      properties:
        domain:
          type: string
        constraints:
          type: object
    previous_world_state:
      type: object
      ref: schemas/world_state_schema.yaml#/world_state
    world_state_out:
      type: object
      ref: schemas/world_state_schema.yaml#/world_state
```
