{
  "mapping": "rules",
  "version": 1,
  "updated": "2026-11-07",
  "updated_by": "asset-interchange (first draft, for Setup to edit)",
  "about": "Which Jira event or state creates or updates which i3 record, and back. Rules are evaluated in priority order (higher first), then by id. All matching rules apply; two that write different values to one field stop the message.",
  "source": {
    "cite": "asset-interchange: first draft from the plan (stellarview/docs/plans/mission-studio-interchange-collector.md), 7 November 2026",
    "read": "2026-11-07"
  },
  "maps": {
    "priority_jira_to_interchange": {
      "Highest": "highest",
      "High": "high",
      "Medium": "medium",
      "Low": "low",
      "Lowest": "low"
    }
  },
  "items": [
    {
      "id": "approved-to-i3",
      "about": "A person approves the request for work in Jira: the work order goes to i3.",
      "direction": "jira_to_i3",
      "enabled": true,
      "priority": 10,
      "when": {
        "from": "jira",
        "kind": "jira.issue.transitioned",
        "to_status": "Approved for work",
        "by_person": true
      },
      "do": [
        {
          "action": "i3.create_work_order",
          "fields": {
            "task": "$.summary",
            "priority": {
              "map": "priority_jira_to_interchange",
              "from": "$.priority"
            },
            "jira_key": "$.key"
          }
        },
        {
          "action": "jira.comment",
          "text": "Work order {i3_number} sent to Simplify i3 ({i3_label}), approved by {by}."
        }
      ],
      "source": {
        "cite": "7 November 2026: tickets and work orders process from Jira into i3, and i3 events come back into Jira; RFP 2027-006 section 1.1: the owner's systems stay the systems of record",
        "read": "2026-11-07"
      }
    },
    {
      "id": "asset-edit-to-i3",
      "about": "An asset edited in Jira Assets would be written to i3.",
      "direction": "jira_to_i3",
      "enabled": false,
      "disabled_why": "i3 is the system of record for assets (RFP 2027-006 section 1.1). Enable only with the Authority's agreement.",
      "priority": 0,
      "when": {
        "from": "jira",
        "kind": "jira.asset.updated"
      },
      "do": [
        {
          "action": "i3.upsert_asset",
          "fields": {
            "asset_id": "$.asset_tag"
          }
        }
      ],
      "source": {
        "cite": "7 November 2026: tickets and work orders process from Jira into i3, and i3 events come back into Jira; RFP 2027-006 section 1.1: the owner's systems stay the systems of record",
        "read": "2026-11-07"
      }
    },
    {
      "id": "i3-completed",
      "about": "i3 completes the work order: Jira is told and resolved, the asset updated, and the AI asked to summarise. A person still accepts.",
      "direction": "i3_to_jira",
      "enabled": true,
      "priority": 10,
      "when": {
        "from": "i3",
        "kind": "cmms.work_order.completed",
        "linked": "issue"
      },
      "do": [
        {
          "action": "jira.comment",
          "text": "Simplify i3 reports work order {record_id} complete ({i3_label}): {remedy}. Waiting for a person to accept."
        },
        {
          "action": "jira.transition",
          "to_status": "Resolved"
        },
        {
          "action": "jira.update_asset",
          "fields": {
            "Last work order": "$.record_id"
          }
        },
        {
          "action": "ai.request",
          "tasks": [
            "summarise",
            "suggest_asset",
            "suggest_work_order"
          ]
        }
      ],
      "source": {
        "cite": "7 November 2026: tickets and work orders process from Jira into i3, and i3 events come back into Jira; RFP 2027-006 section 1.1: the owner's systems stay the systems of record",
        "read": "2026-11-07"
      }
    },
    {
      "id": "i3-status",
      "direction": "i3_to_jira",
      "enabled": true,
      "priority": 10,
      "when": {
        "from": "i3",
        "kind": "cmms.work_order.status_changed",
        "linked": "issue"
      },
      "do": [
        {
          "action": "jira.comment",
          "text": "Simplify i3: work order {record_id} is now {to} ({i3_label})."
        }
      ],
      "source": {
        "cite": "7 November 2026: tickets and work orders process from Jira into i3, and i3 events come back into Jira; RFP 2027-006 section 1.1: the owner's systems stay the systems of record",
        "read": "2026-11-07"
      }
    },
    {
      "id": "i3-inspection-failed",
      "direction": "i3_to_jira",
      "enabled": true,
      "priority": 10,
      "when": {
        "from": "i3",
        "kind": "cmms.inspection.failed"
      },
      "do": [
        {
          "action": "jira.create_issue",
          "fields": {
            "summary": {
              "template": "Inspection failed in Simplify i3: {item}"
            }
          }
        },
        {
          "action": "ai.request",
          "tasks": [
            "summarise",
            "suggest_asset",
            "suggest_work_order"
          ]
        }
      ],
      "source": {
        "cite": "7 November 2026: tickets and work orders process from Jira into i3, and i3 events come back into Jira; RFP 2027-006 section 1.1: the owner's systems stay the systems of record",
        "read": "2026-11-07"
      }
    },
    {
      "id": "i3-asset-changed",
      "about": "i3 is the system of record: its asset changes are copied to Jira Assets.",
      "direction": "i3_to_jira",
      "enabled": true,
      "priority": 10,
      "when": {
        "from": "i3",
        "kind": "cmms.asset.changed"
      },
      "do": [
        {
          "action": "jira.update_asset",
          "fields": {
            "Last event": {
              "const": "cmms.asset.changed"
            }
          }
        }
      ],
      "source": {
        "cite": "7 November 2026: tickets and work orders process from Jira into i3, and i3 events come back into Jira; RFP 2027-006 section 1.1: the owner's systems stay the systems of record",
        "read": "2026-11-07"
      }
    },
    {
      "id": "accepted-close",
      "about": "A person accepts the result: Jira closes, and i3 is told.",
      "direction": "jira_to_jira",
      "enabled": true,
      "priority": 10,
      "when": {
        "from": "person",
        "kind": "hub.accepted"
      },
      "do": [
        {
          "action": "jira.transition",
          "to_status": "Closed"
        },
        {
          "action": "jira.comment",
          "text": "Accepted by {by}."
        },
        {
          "action": "i3.update_work_order",
          "fields": {
            "state": {
              "const": "closed"
            }
          }
        }
      ],
      "source": {
        "cite": "7 November 2026: tickets and work orders process from Jira into i3, and i3 events come back into Jira; RFP 2027-006 section 1.1: the owner's systems stay the systems of record",
        "read": "2026-11-07"
      }
    }
  ]
}
