> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bedrock.cv/llms.txt
> Use this file to discover all available pages before exploring further.

# Revision Comparison

> Compare drawing revisions and inspect changes.

## User Prompt

> "Compare the latest arch set with the previous revision and show me what changed."

## Tool Call Sequence

<Steps>
  <Step title="Find the architectural drawings">
    **Call:** `Query`

    ```json theme={null}
    {
      "entity": "sheet",
      "project_id": "proj_oak",
      "discipline": "A",
      "search": "arch"
    }
    ```

    **Response:**

    ```json theme={null}
    {
      "count": 12,
      "items": [
        {
          "id": "sh_a101_b",
          "sheet_number": "A-101",
          "title": "FIRST FLOOR PLAN",
          "discipline": "A",
          "drawing": { "id": "dr_arch_b", "name": "Arch Set Rev B" },
          "uri": "storage://sheets/sh_a101_b/image.png",
          "blocks": [
            { "id": "blk_a101_plan_b", "type": "Plan", "identifier": "1", "name": "FIRST FLOOR PLAN", "description": "...", "uri": "...", "relations": [
              { "relation_type": "similar_to", "target": { "entity_type": "block", "id": "blk_a101_plan_a", "type": "Plan", "sheet_number": "A-101", "drawing_name": "Arch Set Rev A" } }
            ]}
          ]
        },
        {
          "id": "sh_a101_a",
          "sheet_number": "A-101",
          "title": "FIRST FLOOR PLAN",
          "discipline": "A",
          "drawing": { "id": "dr_arch_a", "name": "Arch Set Rev A" },
          "uri": "storage://sheets/sh_a101_a/image.png",
          "blocks": [ "..." ]
        }
      ]
    }
    ```

    **What the agent learns:** There are two architectural drawings -- "Arch Set Rev A" (`dr_arch_a`) and "Arch Set Rev B" (`dr_arch_b`). The agent identifies these as the two revisions to compare.
  </Step>

  <Step title="Trigger the comparison">
    **Call:** `Compare`

    ```json theme={null}
    {
      "project_id": "proj_oak",
      "drawing_a_id": "dr_arch_a",
      "drawing_b_id": "dr_arch_b"
    }
    ```

    **Response:**

    ```json theme={null}
    {
      "job_id": "job_cmp_01",
      "status": "queued"
    }
    ```

    **What the agent learns:** The comparison job is queued. The agent needs to poll for completion.
  </Step>

  <Step title="Poll for completion">
    **Call:** `PollJob`

    ```json theme={null}
    {
      "job_id": "job_cmp_01"
    }
    ```

    **Response:**

    ```json theme={null}
    {
      "id": "job_cmp_01",
      "status": "completed",
      "progress": { "completed": 8, "total": 8 },
      "result": {
        "overlays": [
          {
            "id": "ov_01",
            "block_a": { "type": "Plan", "sheet_number": "A-101", "drawing_name": "Arch Set Rev A" },
            "block_b": { "type": "Plan", "sheet_number": "A-101", "drawing_name": "Arch Set Rev B" },
            "score": 0.82,
            "uri": "storage://overlays/ov_01/composite.png"
          },
          {
            "id": "ov_02",
            "block_a": { "type": "Plan", "sheet_number": "A-102", "drawing_name": "Arch Set Rev A" },
            "block_b": { "type": "Plan", "sheet_number": "A-102", "drawing_name": "Arch Set Rev B" },
            "score": 0.97,
            "uri": "storage://overlays/ov_02/composite.png"
          }
        ]
      }
    }
    ```

    **What the agent learns:** 8 sheet pairs were compared. A-101 has a score of 0.82 (significant changes), while A-102 has 0.97 (minimal changes). The agent focuses on A-101 first.
  </Step>

  <Step title="Get detailed changes for the most-changed sheet">
    **Call:** `Query`

    ```json theme={null}
    {
      "entity": "block",
      "project_id": "proj_oak",
      "id": "blk_a101_plan_b",
      "include": ["overlays", "changes"]
    }
    ```

    **Response:**

    ```json theme={null}
    {
      "count": 1,
      "items": [
        {
          "id": "blk_a101_plan_b",
          "type": "Plan",
          "identifier": "1",
          "name": "FIRST FLOOR PLAN",
          "uri": "storage://blocks/blk_a101_plan_b/image.png",
          "confidence": 0.96,
          "sheet": { "id": "sh_a101_b", "sheet_number": "A-101", "discipline": "A" },
          "drawing": { "id": "dr_arch_b", "name": "Arch Set Rev B" },
          "relations": [],
          "overlays": [
            {
              "id": "ov_01",
              "score": 0.82,
              "uri": "storage://overlays/ov_01/composite.png",
              "addition_uri": "storage://overlays/ov_01/additions.png",
              "deletion_uri": "storage://overlays/ov_01/deletions.png",
              "paired_block": {
                "id": "blk_a101_plan_a",
                "type": "Plan",
                "sheet_number": "A-101",
                "drawing_name": "Arch Set Rev A"
              },
              "changes": [
                { "description": "New wall added between Room 102 and 103 at grid B-3", "bounds": { "xmin": 380, "ymin": 500, "xmax": 420, "ymax": 650 } },
                { "description": "Door 104 relocated from south wall to east wall of Room 102", "bounds": { "xmin": 300, "ymin": 540, "xmax": 350, "ymax": 590 } },
                { "description": "Room 103 label changed from STORAGE to IT CLOSET", "bounds": { "xmin": 400, "ymin": 550, "xmax": 450, "ymax": 580 } }
              ]
            }
          ]
        }
      ]
    }
    ```

    **What the agent learns:** Three specific changes on A-101: a new wall, a relocated door, and a renamed room. Each has a bounding box for spatial context.
  </Step>

  <Step title="Get the overlay image">
    **Call:** `ViewImage`

    ```json theme={null}
    {
      "uri": "storage://overlays/ov_01/composite.png"
    }
    ```

    **Response:**

    ```json theme={null}
    {
      "url": "https://cdn.bedrock.cv/signed/ov_01.png?token=...",
      "expires_in": 900
    }
    ```

    **What the agent learns:** The overlay image is ready to display to the user.
  </Step>
</Steps>

## Agent Response

> I compared **Arch Set Rev A** with **Arch Set Rev B** across 8 sheet pairs. Here are the results:
>
> **A-101 (First Floor Plan)** had the most changes (score: 0.82):
>
> 1. **New wall** added between Room 102 and 103 at grid B-3
>
> 2. **Door 104** relocated from south wall to east wall of Room 102
>
> 3. **Room 103** renamed from STORAGE to IT CLOSET
>
> **A-102 (Second Floor Plan)** had minimal changes (score: 0.97).
>
> Would you like me to drill into any specific change or check the other sheets?

## Summary

| Metric        | Value                                                                                                                                                                       |
| ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Tool calls    | **5**                                                                                                                                                                       |
| Tools used    | `Query` (sheet) > `Compare` > `PollJob` > `Query` (block) > `ViewImage`                                                                                                     |
| Key technique | The agent sorts overlays by score to prioritize sheets with the most changes. The async `Compare` > `PollJob` pattern lets the agent report progress while processing runs. |
