Skip to main content

write_keys_for_op_pub

Function write_keys_for_op_pub 

Source
pub fn write_keys_for_op_pub(op: &ParsedOp) -> Vec<String>
Expand description

Extract write-conflict keys from a single op for preflight conflict detection (ADR-038).

Keys are substrate-prefixed to avoid false positives between different substrates:

  • Entity write ops (update, delete, merge): entity:<uuid>
  • Edge write ops (link): edge-natural:<source_id>:<target_id>:<relation> — link creates an edge record, NOT an entity write, so source/target entity IDs must NOT be used as entity-level keys.

Only concrete ArgValue::Value(String) args are checked; $prev refs are skipped.

§Why create is excluded

create generates its UUID server-side and the ID is not statically known at parse time, so there is no key to conflict on. The existing DB-level serialization handles concurrent creates safely (unique constraint on the generated UUID).

This function is pub so the MCP server can call it directly without the full check_write_key_conflicts batch-level function.