Task: Validate internal Concepts links and automatically update content

Validate internal Concepts links and automatically update content

27.08.2026haih agent

Add broken link detection in Concepts content and a shared helper that automatically updates links upon create/update.

Context

Architectural source of truth: Human-readable URI system in haih-agent maintains address stability and SEO signals.

Currently, the URIs of the Concepts themselves are already normalized and can be safely changed via 301, but the integrity of links inside content is not guaranteed. As a result, broken internal links have already appeared in some AI-generated Concepts.

What needs to be done

1. Concepts validation resolver for broken links

Add an administrative GraphQL resolver that analyzes Concepts content and finds links to non-existent internal URIs.

A similar implementation already exists in another project — first, find and reuse/adapt the existing approach rather than writing the algorithm from scratch.

The resolver must at least be able to:

  • check a single Concept;
  • check a set/all Concepts;
  • extract internal Markdown/HTML/custom-tag links leading to site routes;
  • distinguish an existing URI from a broken one;
  • return the Concept, source href, and error reason;
  • where possible, distinguish between a completely missing route and a URI with a known redirect/canonical replacement.

2. Shared helper for Concept create/update

Extract link processing into a reusable helper and integrate it into Concept creation and updating.

Before saving content, the helper must:

  1. parse internal links;
  2. check them against current routes/Concept URIs;
  3. if a link points to a known old URI with an unambiguous canonical/redirect — automatically replace the href with the current URI;
  4. not modify external URLs;
  5. not make ambiguous fixes silently;
  6. preserve Markdown and allowed custom tags structure.

The goal is for the AI and the user to be able to reference a Concept by a known address, while the system itself keeps internal linking up to date.

Why this matters

In the new haih-agent/fi1osof.ru model, the Concepts graph is the information core itself. A broken link is not just a page UX defect, but a rupture in the semantic graph.

Automatic validation is required for:

  • SEO and crawlability;
  • preserving PageRank/internal-link signals;
  • correct user navigation;
  • reliable AI operation when following Concept links;
  • safe bulk modification of human-readable URLs (ЧПУ);
  • preventing technical debt accumulation under AI-managed content.

Acceptance Criteria

  • An admin resolver exists for checking single and multiple Concepts for broken internal links.
  • The implementation from another project has been studied first and reused where possible.
  • The resolver returns specific Concept + href + problem type.
  • Concept create/update goes through the shared internal link processing helper.
  • Known old URIs are automatically replaced with current canonical URIs when the mapping is unambiguous.
  • External links are not rewritten.
  • Ambiguous/unknown links are not fixed by guessing.
  • Tests are added for valid link, 404, redirect/canonical replacement, multiple links, external link, and custom-tag/Markdown content.
  • Existing Concepts can be bulk-checked to generate a report for subsequent fixing.

Ворклоги

Progress: Server-side validation and normalization of Concept content implemented

The main part of the task was implemented in commit: https://github.com/haih-net/agent/commit/5d2a3c1

Added:

  • validateConcepts mutation to search for broken internal links;
  • link check integration into createConcept and updateConcept;
  • buildValidUrisSet() for the set of valid URIs;
  • validateInternalLinks() with Markdown/MDX AST parsing and auto-fix support;
  • normalizeMarkdownContent() to normalize MDX/Markdown before saving;
  • skill documentation for validateConcepts;
  • write: true is available only to sudo users, regular users only receive the validation result and fix the links manually.

Thus, the server is now starting to ensure the integrity of AI-managed Concept content, rather than relying solely on the correctness of the text created by the user or agent.

Architectural context is documented in Concept: Sistema chelovekoponyatnyh URI v haih-agent sohranyaet stabilnost adresov i SEO-signaly.

The neighboring commit 8afc203 refactors ConceptItem: list-view starts relying on intro/description, and the technical type is removed from the main public representation of Concept. This is not the main part of the task, but it aligns with the direction where system classification is separated from semantic public content.

Commit: https://github.com/haih-net/agent/commit/8afc203