Row multiplication, unmatched keys and uniqueness violations before a table join

$0.005 USDC per call · Developer and security · POST /api/v1/join-cardinality · Id join-cardinality

Takes the join keys of two tables (every row's key, or distinct keys with row counts) and computes the exact output row count of an inner, left, right or full equi-join with SQL NULL semantics, the observed cardinality (one-to-one, one-to-many, many-to-one, many-to-many), the keys that multiply rows the most, unmatched keys on each side and the first duplicate row when a side was assumed unique. It also flags keys that match only after loose coercion (7 vs "7", "007" vs 7, trailing spaces, case), which silently join nothing in a typed engine. For agents about to merge, enrich or deduplicate tables. It sees only the keys you send: it does not read data, and it cannot know whether a composite key is complete.

What you get

Catches fan-out, silent row loss and key-type mismatches before the join runs. 20,000 keys per side per $0.005 call.

Call it

Send the JSON body below to https://agents.writerslogic.com/api/v1/join-cardinality. An unpaid request answers 402 with the price and how to pay; a request that fails with a 5xx status is not charged.

curl -i -X POST https://agents.writerslogic.com/api/v1/join-cardinality \
  -H 'content-type: application/json' \
  -d '{"left":{"keys":[1,2,3,3,null,"007"]},"right":{"keys":[1,3,3,4,"7"," 1"]},"joinType":"left","expect":{"rightUnique":true,"noRowMultiplication":true}}'

Input

FieldTypeRequiredDescription
leftobjectyes
rightobjectyes
joinTypestring; one of "inner", "left", "right", "full"yes
expectobjectno
normalizeobjectnoNormalization your pipeline applies to string keys before joining.

Example request body

{
  "left": {
    "keys": [
      1,
      2,
      3,
      3,
      null,
      "007"
    ]
  },
  "right": {
    "keys": [
      1,
      3,
      3,
      4,
      "7",
      " 1"
    ]
  },
  "joinType": "left",
  "expect": {
    "rightUnique": true,
    "noRowMultiplication": true
  }
}

Result

The response is { "data": ..., "_provenance": ... }. data carries these fields; _provenance is a signed W3C Verifiable Credential with a C2PA-style manifest, checked free at POST /api/v1/verify-provenance.

FieldTypeRequiredDescription
statusstring; one of "pass", "fail", "unknown", "unsupported"nopass: every rule held. fail: a rule was violated (see witnesses). unknown: the input lacks the evidence to decide. unsupported: outside what this engine covers. Missing evidence is never a pass.
leftobjectno
rightobjectno
observedCardinalitystring; one of "one-to-one", "one-to-many", "many-to-one", "many-to-many"no
outputRowsobjectno
multiplicationFactorone ofno
unmatchedobjectno
fanOutarray<object>no
coercionHazardsarray<object>no
witnessesarray<object>no
versionsobjectnoEvery semantic dependency of this answer (engine, tables and their as-of dates, tokenizer, calendar, rounding profile).
limitsarray<string>no
deterministicbooleannoAlways true: pure code, no model.

Pay and connect

Available through: x402 (USDC on Base), MCP. MCP clients reach it through the data-contract-kit package.

Machine-readable