add_relation
Add a typed semantic relation between two ontology nodes, appending it to the corresponding frontmatter key and attaching a one-line rationale when provided.
Instructions
Add a semantic relation between two nodes. Appends to the matching frontmatter graph key (domains / capabilities / elements / dependencies / relates / contains / describes); domain sets the source node's inline parent domain. The relation type picks which key receives the entry. A new depends_on relation requires a nonblank why; an already-existing edge remains an idempotent read even if legacy data has no rationale. R11: optional expected_mtime — pass the source-side mtime from a prior get_concept so concurrent external edits throw VaultConflictError. Invalid relation type is rejected before endpoint slug resolution with a closest-value hint and structured valueName / receivedValue / suggestion / allowedValues repair fields in structuredContent, with no changed, alreadyExists, or postWriteMaintenance write metadata. Changed writes return compact postWriteMaintenance (maintenance_plan) with count-safe byPhase / bySeverity / byKind queue buckets, action score, executable proposedAction, and current-page nextExecutableAction / nextReviewAction pointers so agents can immediately see graph cleanup / relation suggestions after the edge lands. For multiple already-approved semantic edges use add_relations({relations: [...]}) (batch, idempotent, max 50). infer_imports.moduleEdges require exact-evidence review, a semantic rationale, and human approval first.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| to | Yes | Target slug. | |
| why | No | One-line rationale for this relation ("A leans on B because ..."). Stored in the SAME frontmatter write as the ref (relation_notes map) — write it whenever you know the reason; a graph edge without a why is a mind-map line, not an ontology claim. | |
| from | Yes | Source slug. | |
| type | Yes | Relation type. | |
| expected_mtime | No | Optional conflict guard for the source slug. If the source mtimeMs differs at write time, the call throws. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ok | Yes | ||
| to | Yes | ||
| key | No | ||
| from | Yes | ||
| type | Yes | ||
| changed | No | ||
| alreadyExists | No | ||
| postWriteMaintenance | No | Compact maintenance_plan summary for post-write follow-up. Bucket maps describe the remaining queue after the write. |