---
title: "Detect edges between facts and the Constitution using LLM"
method: POST
path: "/pots/{pot_id}/edges/detect"
tags: ["edges", "edges"]
---

# Detect edges between facts and the Constitution using LLM

`POST /pots/{pot_id}/edges/detect`

Analyse the supplied facts against the POT's Constitutional axioms to detect **typed epistemic edges** — `SUPPORTS`, `CONTRADICTS`, `REFINES`, `DERIVES_FROM`, `IS_PART_OF` — using an LLM with structured output. Each edge carries a confidence-weighted relationship that drives downstream POT Score propagation.

**Scope of this endpoint:** detection runs across `facts_to_analyze × constitution_facts` (the workhorse mode that catches contradictions against canonical truths). It does NOT currently run fact↔fact detection among the supplied facts themselves — that's a separate, on-demand operation (see roadmap M16 for batch intra-fact detection).

**Request shape:**
- `fact_ids` — facts to evaluate against the Constitution (required).
- `include_constitution=true` (default) — load and pair against the POT's axioms. Setting `false` results in zero pairs analysed.
- `auto_save=true` — persist detected edges (deduplicated by `(pot_id, from_id, to_id, type)`) and trigger POT Score propagation.
- `min_weight` (default `0.2`) — filter low-confidence detections.

**Cost model:** roughly `len(fact_ids) × len(constitution_facts)` LLM pair-evaluations (linear in the number of axioms — Constitutions are typically 3–10 facts, so this is cheap).

**Contradictions are flagged, never auto-resolved.** Detected `CONTRADICTS` edges land in the curator review queue with priority based on what was contradicted (Constitution = critical; high-score fact = high; standard = normal).

## Path parameters

- `pot_id` string, uuid, required

## Request body

- EdgeDetectRequest — Request for edge detection endpoint. MSP Context: M9 - Edge Detection Backend Migration
  - `fact_ids` string[], required — Fact IDs to analyze for relationships
  - `include_constitution` boolean — Include constitution axioms in analysis
  - `auto_save` boolean — Persist detected edges automatically
  - `min_weight` number — Minimum weight threshold for edges
  - `batch_size` integer — Facts per batch LLM call for edge detection. Overrides server default (edge_detection_batch_size setting).

## Response `200`

Edges detected; included in the response with metadata

- EdgeDetectResponse — Response from edge detection endpoint.
  - `edges` DetectedEdgeResponse[], required
    - `from_id` string, uuid, required
    - `to_id` string, uuid, required
    - `type` 'supports' | 'contradicts' | 'resolved_contradiction' | 'refines' | 'derives_from' | 'is_part_of' | 'extends' | 'cites' | 'related_to', required — Types of semantic relationships between facts. M7 uses a simplified subset. Full taxonomy in edge-types.md will be implemented in M8+ when GraphRAG is introduced.
    - `weight` number, required
    - `rationale` string, required
    - `direction` string, required
  - `metadata` EdgeDetectMetadata, required — Metadata about edge detection run.
    - `pairs_analyzed` integer, required
    - `edges_found` integer, required
    - `edges_saved` integer
    - `edges_updated` integer
    - `duration_ms` integer, required
    - `model` string, required

## Other responses

- `404` — POT or one of the supplied facts not found
- `422` — Validation error
- `502` — LLM error (timeout, rate limit, invalid response)

---

[API](https://skmtc.dev/scipot/apis/scipot-core-api.md) · [All operations](https://skmtc.dev/scipot/apis/scipot-core-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/scipot/scipot-core-api/revisions/e8712e9ffeae/schema)
