{
  "node": {
    "id": "block:native-exclusive-merge",
    "type": "Block",
    "label": "Exclusive action merge",
    "properties": {
      "id": "native-exclusive-merge",
      "name": "Exclusive action merge",
      "kind": "studio",
      "summary": "Accepts one explicitly active branch at a sample, holds its prior value when none is active, and rejects competing writers.",
      "behavior": "Accepts one explicitly active branch at a sample, holds its prior value when none is active, and rejects competing writers. Trial evaluations read the held output without mutating state.",
      "ports": [
        {
          "name": "in0",
          "direction": "input",
          "unit": "—",
          "description": "Branch 1 value; real scalar."
        },
        {
          "name": "in1",
          "direction": "input",
          "unit": "—",
          "description": "Branch 2 value; real scalar."
        },
        {
          "name": "in2",
          "direction": "input",
          "unit": "—",
          "description": "Branch 1 active; bool scalar."
        },
        {
          "name": "in3",
          "direction": "input",
          "unit": "—",
          "description": "Branch 2 active; bool scalar."
        },
        {
          "name": "out0",
          "direction": "output",
          "unit": "—",
          "description": "Merged value; real scalar."
        },
        {
          "name": "out1",
          "direction": "output",
          "unit": "—",
          "description": "Accepted branch (0 means held); u32 scalar."
        }
      ],
      "parameters": [
        {
          "key": "sampleTimeS",
          "label": "Sample period",
          "unit": "s",
          "default": 1,
          "description": "Positive period between accepted updates; outputs hold between updates."
        },
        {
          "key": "tables[0]",
          "label": "Initial held output",
          "unit": "—",
          "default": [
            0
          ],
          "description": "Output held before the first accepted update, with one value per output lane."
        },
        {
          "key": "params[0]",
          "label": "Branch count",
          "unit": "—",
          "default": 2,
          "min": 2,
          "max": 16,
          "description": "Number of data branches and matching Boolean ownership flags."
        }
      ],
      "equations": [
        "Exactly one active branch i: held value ← branch[i]; accepted branch ← i + 1",
        "No active branch: retain held value; accepted branch ← 0",
        "More than one active branch: reject the sample without committing state"
      ],
      "example": {
        "title": "Exclusive action merge worked example",
        "text": "Branch values are 2 and 5. Only branch 2 is active, so the accepted value is 5 and its owner index is 2.",
        "url": "https://design.lemonergy.com/cosim.html?example=block-native-exclusive-merge",
        "label": "Open Studio example",
        "inputs": [
          {
            "port": "in0",
            "label": "Branch 1 value",
            "value": 2,
            "unit": "—"
          },
          {
            "port": "in1",
            "label": "Branch 2 value",
            "value": 5,
            "unit": "—"
          },
          {
            "port": "in2",
            "label": "Branch 1 active",
            "value": 0,
            "unit": "—"
          },
          {
            "port": "in3",
            "label": "Branch 2 active",
            "value": 1,
            "unit": "—"
          }
        ],
        "checks": [
          {
            "port": "out0",
            "label": "Merged value",
            "atS": 0,
            "value": 5,
            "unit": "—",
            "tolerance": 1e-08
          },
          {
            "port": "out1",
            "label": "Accepted branch (0 means held)",
            "atS": 0,
            "value": 2,
            "unit": "—",
            "tolerance": 1e-08
          }
        ]
      },
      "limits": [
        "2–16 explicitly declared, identically typed branches. Boolean action flags supply ownership; ownership is not inferred from an arbitrary source subsystem.",
        "All inputs are validated even when inactive. Branches should share the declared sample clock. A conflict stops the run instead of choosing a writer by connection order."
      ],
      "references": [
        "control-statecharts"
      ],
      "availability": {
        "status": "released",
        "label": "Available in Lemonergy Studio",
        "detail": "The bundled example is available in the production release verified on 28 October 2026. The parameters and examples here are synthetic teaching fixtures, not a characterized cell or a validated operating limit."
      },
      "evidence": [
        "docs/glossary/native-block-verification.json"
      ],
      "sourceRepository": "Lemonergy Studio public contract",
      "sourceRevision": "verification-2026-10-27",
      "caseIds": [
        "native-native-exclusive-merge"
      ],
      "exampleTraces": [
        {
          "id": "native-exclusive-merge",
          "url": "https://lemonergy.com/learn/glossary/api/traces/native-exclusive-merge.json?v=798285c12154",
          "title": "Exclusive action merge recorded example",
          "exampleId": "block-native-exclusive-merge",
          "source": "Executed synthetic Lemonergy Studio example",
          "recordedOn": "2026-10-28",
          "points": 3,
          "channels": 2,
          "omittedChannels": 0,
          "interpolation": "step",
          "solver": {
            "method": "dormand-prince-45",
            "reason": "no-continuous-states"
          }
        }
      ],
      "type": "native-exclusive-merge",
      "implementationId": "native-exclusive-merge",
      "url": "https://lemonergy.com/learn/glossary/blocks/native-exclusive-merge/",
      "documentationUrl": "https://lemonergy.com/learn/glossary/blocks/native-exclusive-merge/",
      "sourceFile": "block-library.json",
      "reviewed": "2026-10-27",
      "releaseEvidence": {
        "environment": "production",
        "status": "verified",
        "revision": "e76cadfc203e15eb41f3478d8b1044a5b851953d",
        "verifiedOn": "2026-10-28",
        "exampleUrls": [
          "https://design.lemonergy.com/cosim.html?example=block-native-exclusive-merge"
        ]
      }
    }
  },
  "incoming": [
    {
      "id": "edge:usesBlock/native-native-exclusive-merge/0",
      "type": "usesBlock",
      "source": "workflow:native-native-exclusive-merge",
      "target": "block:native-exclusive-merge",
      "properties": {
        "sourceFile": "wiki-blocks.json",
        "position": 0,
        "name": "Exclusive action merge",
        "type": "native-exclusive-merge",
        "role": "Accepts one explicitly active branch at a sample, holds its prior value when none is active, and rejects competing writers. Trial evaluations read the held output without mutating state.",
        "settings": [
          "Use the block reference for settings and connections.",
          "Bundled example verified on the production release of 28 October 2026."
        ]
      }
    }
  ],
  "outgoing": [
    {
      "id": "edge:cites/block:native-exclusive-merge/reference:control-statecharts",
      "type": "cites",
      "source": "block:native-exclusive-merge",
      "target": "reference:control-statecharts",
      "properties": {
        "sourceFile": "block-library.json",
        "scope": "Scientific or mathematical background; implementation scope is stated by the block contract"
      }
    }
  ],
  "neighbors": [
    {
      "id": "workflow:native-native-exclusive-merge",
      "type": "Workflow",
      "label": "Exclusive action merge worked example",
      "properties": {
        "id": "native-native-exclusive-merge",
        "title": "Exclusive action merge worked example",
        "kind": "studio",
        "summary": "Accepts one explicitly active branch at a sample, holds its prior value when none is active, and rejects competing writers.",
        "steps": [
          "Review the interface, units and model limits.",
          "Open the Studio example and run its bundled model.",
          "Compare outputs with the numerical checks; change one input and run again."
        ],
        "example": "Branch values are 2 and 5. Only branch 2 is active, so the accepted value is 5 and its owner index is 2.",
        "observe": "Inspect the output channels and checks on the block reference page.",
        "limits": "2–16 explicitly declared, identically typed branches. Boolean action flags supply ownership; ownership is not inferred from an arbitrary source subsystem. All inputs are validated even when inactive. Branches should share the declared sample clock. A conflict stops the run instead of choosing a writer by connection order.",
        "url": "https://design.lemonergy.com/cosim.html?example=block-native-exclusive-merge",
        "label": "Open Studio example",
        "evidence": [
          "docs/glossary/native-block-verification.json"
        ]
      }
    },
    {
      "id": "reference:control-statecharts",
      "type": "Reference",
      "label": "Statecharts: A visual formalism for complex systems",
      "properties": {
        "title": "Statecharts: A visual formalism for complex systems",
        "authors": [
          "David Harel"
        ],
        "year": 1987,
        "doi": "10.1016/0167-6423(87)90035-9",
        "url": "https://www.weizmann.ac.il/math/harel/sites/math.harel/files/users/user50/Statecharts.pdf",
        "type": "Research article",
        "scope": "Background on explicit states and events. Lemonergy bounded control blocks are not a complete Statecharts implementation.",
        "accessed": "2026-10-27",
        "publisher": "Science of Computer Programming, 8(3), 231–274"
      }
    }
  ]
}
