Knowledge Graph Relation Extraction
Mission
For one relation_code, research authoritative sources, compare against existing database triples, and return review-ready relation candidates. Default behavior is read-only research and structured output; do not publish data directly.
The skill supports two primary modes. Each mode may run in phases so the backend can batch long-running work safely:
verify_existing_only: verify existing triples only. Returnupdate_candidates,conflicts, andunchanged_examples; do not discover or return new triples. Usephase=planto plan batches when requested, andphase=batchto verify only the suppliedrelation_ids.discover_missing: discover missing triples only. Usephase=estimateto estimate volume and recommend a run policy without returning candidates. Usephase=batchto returnnew_candidatesthat are absent from bothpublishedandpending_review;update_candidates,conflicts, andunchanged_examplesmust be empty in this mode.
Required References
Read these before running:
../reference/database-api.md../reference/output-schema.md../reference/quality-gate.md../reference/workflow-validation.md../reference/relation-types/{relation_code}.md
Workflow
Confirm relation type exists and is active.
- Query
ai_data.nba_ko_relation_types. - Query entity rules from
ai_data.nba_ko_relation_type_rules. - Stop if the relation is missing, inactive, blacklisted, or entity rules differ from the relation reference.
- Query
Load existing instances.
- Query
ai_data.nba_ko_relationswhereis_deleted = 0andrelation_type = {relation_code}. - Treat
publishedandpending_reviewrows as existing baseline. - Use source name, relation type, target name, and entity ids when available for duplicate checks.
- Treat
relation_type + source_entity_name + target_entity_nameas the unique relation identity. - Do not treat different seasons, dates, agreement periods, tenures, or statuses as separate relation identities.
- Query existing
ai_data.nba_ko_entity_tagsfor all source and target entity types allowed by the relation rules. - Before returning any candidate, match both endpoint entities against existing entity tags by exact name, alias, and external id when available.
- If an endpoint entity is missing, keep the candidate but mark that endpoint as
needs_create; do not silently assume it already exists. - If the input includes
missing_entity_registry, treat it as the canonical naming context for missing entities from prior batches. - When a missing endpoint matches an item in
missing_entity_registryby entity type, canonical name, or alias, reuse that item'smissing_entity_keyandcanonical_name.
- Query
Read relation-specific reference.
- Follow the scope, exclusions, target entities, preferred sources, and evidence rules in
reference/relation-types/{relation_code}.md. - If the reference contains
Acquisition Workflow, execute that workflow first. - If the reference contains
Estimate Workflow, execute it duringdiscover_missing phase=estimate. - If the reference contains
Verify Workflow, execute it duringverify_existing_only phase=batch. - If the reference contains
Run Policy, use it when recommending batch size, max batches, and scope notes. - Use the generic web search workflow only as fallback or for cross-checking.
- Follow the scope, exclusions, target entities, preferred sources, and evidence rules in
Execute the selected mode.
- For
verify_existing_only phase=plan, summarize the existing relation count and recommend a stable batch plan; do not return candidates. - For
verify_existing_only phase=batch, verify only the inputrelation_ids, check whether each fact is still valid, and check whetherdescription,properties,source_url,original_sources, or entity ids need improvement. - For
discover_missing phase=estimate, estimate the total candidate universe, existing baseline count, missing count, validation evidence, and recommended run policy; do not return candidates. - For
discover_missing phase=batch, build a source-driven candidate universe from the relation-specific acquisition workflow, diff it against existingpublishedandpending_reviewtriples, and return only missing triples up tomax_candidates. - If
discover_missinguses an exhaustively enumerable source, set coverage assource_exhaustive; otherwise set coverage aspartial. - If no specific workflow exists, use generic official-source web search, but never claim exhaustive coverage.
- Capture URL, title, snippet, and retrieval date for every claim.
- For
Build candidates and diffs.
- In
discover_missing phase=batch,new_candidatesare valid triples not present in existing baseline. - In
discover_missing phase=batch, return at most one candidate per unique relation identity. - If multiple source rows share the same unique relation identity but differ by time or attributes, merge them into
properties.historyand setproperties.currentto the latest/current/main slice. - In
discover_missing phase=batch, summarize unique missing endpoint entities in rootmissing_entities. - In
verify_existing_only phase=batch,update_candidatesare existing triples whose properties,properties.history, description, evidence, or entity ids need improvement. - In
verify_existing_only phase=batch,conflictsare existing triples contradicted by stronger evidence or requiring human resolution. unchangedcontains existing triples verified with no action needed.- In
discover_missing, do not returnupdate_candidates,conflicts, orunchanged_examples; existing-row observations may only be summarized inself_check.notesorcoverage.notes. - Do not put the same triple in both
new_candidatesandupdate_candidates.
- In
Self-check.
- Validate entity types.
- Validate whether each endpoint entity already exists.
- Check duplicate triples.
- Verify source credibility.
- Confirm the evidence actually supports the relation.
- Ensure no high-frequency or out-of-scope relation slipped in.
Return only the structured output.
- Use the JSON format in
output-schema.md. - If nothing changes, return an empty candidate list with a clear summary.
- Always include
phasewhen the input includesphase.
- Use the JSON format in
Guardrails
- Never mark output as
published. - Do not invent facts from model memory.
- Do not use vague sources without a URL.
- Do not use a relation if the evidence only implies it weakly.
- Do not create duplicate triples that already exist in
publishedorpending_review. - Do not create multiple candidates for the same
relation_type + source_entity_name + target_entity_name; aggregate property slices instead. - Do not include time slices, seasons, dates, agreement periods, event ids, or property values in
dedupe_key. discover_missing phase=estimatemust not return candidates; it is for volume estimate and run policy only.discover_missing phase=batchmust respectmax_candidateswhen provided.- In
discover_missing, skip existing triples instead of returning them as updates. - In
discover_missing, never returnconflicts; conflicts are only valid inverify_existing_only. - In
discover_missing, never returnunchanged_examples; unchanged examples are only valid inverify_existing_only. verify_existing_only phase=batchmust verify only the suppliedrelation_idswhen they are present.- In
verify_existing_only, do not returnnew_candidates. - For large relation types,
discover_missingmay intentionally cover only popular players, popular teams, heavily reported facts, or highest Q&A value facts. Clearly state this inestimate.scope_noteandcoverage.notes; do not claim full historical coverage. - Estimate counts must be strictly cross-checked with authoritative sources, existing database unique counts, and relation-specific sanity bounds or secondary sources when available.
- If no new triples are found, explain whether the empty result is source-exhaustive or only this run's search found nothing.
- Do not hide missing endpoint entities; report them explicitly in candidate
entity_resolution. - Keep missing entity names consistent across a batch and across batches by using
missing_entity_registry. - Add new missing entity instances to root
missing_entitieswith stablemissing_entity_key,entity_type,canonical_name, and aliases. - Use
properties.currentplusproperties.historyfor historical or time-sliced facts that belong to one relationship. - In
verify_existing_only, useupdate_candidates.proposed_patch.properties.historyto add missing property slices to an existing relationship. - If source quality is weak, put the item in
conflictsorneeds_review, notnew_candidates.