# WritersLogic Join Cardinality Analyzer

> WritersLogic Join Cardinality Analyzer is a paid API for AI agents from agents.writerslogic.com, paid per call via x402, $0.005/call, status unknown (last checked 2026-11-19).

Computes exact join output row counts, cardinality type, unmatched keys, and type-coercion hazards for two tables given their join keys.

## Facts

- Endpoint: POST https://agents.writerslogic.com/api/v1/join-cardinality?utm_source=zero.xyz
- Price: $0.005/call
- Payment: x402
- Status: unknown
- Last checked: 2026-11-19
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/writerslogic-join-cardinality-analyzer-186b0c01
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_-Z--gjrR3IsQ24_zHErxN

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability writerslogic-join-cardinality-analyzer-186b0c01 -d '<json body>'
```

Example prompt: Before I merge my orders table with my customers table on customer_id, can you check the join cardinality? Here are the left keys: [101, 102, 103, 102] and right keys: [101, 102, 104] — I expect left unique and every left row matched, using an inner join.

## When to prefer this

Use this endpoint when an AI agent needs to predict or validate the output of an equi-join before executing it, especially when row explosion, referential integrity, or type coercion bugs are a concern. It is preferable over running the actual join when the data volume is large, the join is expensive, or the agent needs to surface issues (unmatched keys, duplicate keys, coercion hazards) to a human before proceeding. It is not a substitute for a SQL engine and cannot read actual table data — only key distributions supplied by the caller.

## Known failure modes

- Exceeds key array limit (20,000 rows or 5,000 distinct counts) — request rejected
- Both keys and counts supplied simultaneously for same side — ambiguous input error
- Composite key arrays contain mismatched component counts across rows — schema error
- maxOutputRows expectation violated — returns violation detail rather than silent pass
- Null keys in keys array handled as SQL NULLs (never match) — may surprise caller expecting null equality
- Cannot detect incomplete composite keys — caller must ensure all key components are included

## How this service works

Pay-per-call agents settled in USDC on Base via x402. Every response carries a signed provenance envelope.

## Output

Returns the exact output row count for the requested join type (inner, left, right, full), the observed cardinality label (one-to-one, one-to-many, many-to-one, many-to-many), the keys contributing the most row multiplication, lists of unmatched keys on each side, any violated expectations (uniqueness, full match coverage, row count ceiling), and a list of key pairs that match only under loose coercion (type, case, whitespace) but would silently fail in a strictly typed SQL engine.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "left": {
   "type": "object",
   "properties": {
    "keys": {
     "type": "array",
     "items": {
      "description": "One row's join key: a string, number or boolean, null for SQL NULL, or an array of those for a composite key."
     },
     "maxItems": 20000,
     "description": "Join key of every row, in table order."
    },
    "counts": {
     "type": "array",
     "items": {
      "type": "object",
      "required": [
       "key",
       "count"
      ],
      "properties": {
       "key": {
        "description": "A join key (scalar, null, or array for composite)."
       },
       "count": {
        "type": "integer",
        "maximum": 1000000,
        "minimum": 1
       }
      },
      "additionalProperties": false
     },
     "maxItems": 5000,
     "description": "Key summary: how many rows carry each distinct key."
    },
    "nullRows": {
     "type": "integer",
     "maximum": 1000000,
     "minimum": 0,
     "description": "With counts: rows whose key is NULL."
    }
   },
   "additionalProperties": false
  },
  "right": {
   "type": "object",
   "properties": {
    "keys": {
     "type": "array",
     "items": {
      "description": "One row's join key: a string, number or boolean, null for SQL NULL, or an array of those for a composite key."
     },
     "maxItems": 20000,
     "description": "Join key of every row, in table order."
    },
    "counts": {
     "type": "array",
     "items": {
      "type": "object",
      "required": [
       "key",
       "count"
      ],
      "properties": {
       "key": {
        "description": "A join key (scalar, null, or array for composite)."
       },
       "count": {
        "type": "integer",
        "maximum": 1000000,
        "minimum": 1
       }
      },
      "additionalProperties": false
     },
     "maxItems": 5000,
     "description": "Key summary: how many rows carry each distinct key."
    },
    "nullRows": {
     "type": "integer",
     "maximum": 1000000,
     "minimum": 0,
     "description": "With counts: rows whose key is NULL."
    }
   },
   "additionalProperties": false
  },
  "expect": {
   "type": "object",
   "properties": {
    "leftUnique": {
     "type": "boolean",
     "description": "Left keys (non-NULL) must be distinct."
    },
    "rightUnique": {
     "type": "boolean",
     "description": "Right keys (non-NULL) must be distinct."
    },
    "maxOutputRows": {
     "type": "integer",
     "maximum": 90000000000000
… (truncated)
```

## Response schema (JSON Schema)

```json
{
 "type": "json"
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/writerslogic-join-cardinality-analyzer-186b0c01/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from agents.writerslogic.com](https://www.zero.xyz/host/agents.writerslogic.com/llms.txt)
