oc_chat
Loading...
Searching...
No Matches
link_check Namespace Reference

Functions

 _n (p)
 _generated (fp)
 bucket (fp)
 _clean (t)
 _is_md_ref (t)
 _resolve (target, d)
 _walk_md ()
 main ()

Variables

 REPO = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
list SCAN_ROOTS = ["oc_chat", "tools"]
list EXEMPT
list CONTEXT
 _md_link = re.compile(r'\‍[[^\‍]]*\‍]\‍(([^)\s]+)')
 _code_span = re.compile(r'`([^`\n]+)`')

Detailed Description

Repo-wide stale-link checker for Markdown docs (OC_Chat maintenance tool).

Scans every ``.md`` file under the repo, extracts ``[](...)`` links and backtick
path code-spans, resolves each against the filesystem, and reports DEAD file
references. The output is filtered so the noise (illustrative example paths,
forward-refs to not-yet-authored TARGET files, generated views, preserved
receipts, frozen golden fixtures) is separated from genuine broken navigation.

The high-signal section ("A") is: markdown ``[](...)`` nav-links in *active*
docs whose target no longer exists but whose basename exists *elsewhere* (i.e.
the target moved) — with the new location. Those are the actionable stale links.

Usage:  python tools/link_check.py

Origin: written 2026-07-04 to sweep for stale links after the Plan-142 archival
(the archival moved 17 plan files to plans/completed/ and left dead references
in lint config, specs, and cross-links). Caught 3 partial-scope misses that
several scoped greps had missed; kept as a reusable check.

TODO(oct-migration): this checker is generic, not OC_Chat-specific. Migrate it
into the `oct` linter as a repo-wide ``stale_links`` check when the monorepo
lands, respecting the exempt buckets below (receipts / old / archive /
completed / generated views / golden fixtures). Kept here meanwhile.

Function Documentation

◆ _clean()

link_check._clean ( t)
protected

Definition at line 70 of file link_check.py.

Here is the caller graph for this function:

◆ _generated()

link_check._generated ( fp)
protected

Definition at line 53 of file link_check.py.

Here is the caller graph for this function:

◆ _is_md_ref()

link_check._is_md_ref ( t)
protected

Definition at line 75 of file link_check.py.

Here is the caller graph for this function:

◆ _n()

link_check._n ( p)
protected

Definition at line 32 of file link_check.py.

◆ _resolve()

link_check._resolve ( target,
d )
protected

Definition at line 83 of file link_check.py.

Here is the caller graph for this function:

◆ _walk_md()

link_check._walk_md ( )
protected

Definition at line 87 of file link_check.py.

Here is the caller graph for this function:

◆ bucket()

link_check.bucket ( fp)

Definition at line 58 of file link_check.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

link_check.main ( )

Definition at line 100 of file link_check.py.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ _code_span

link_check._code_span = re.compile(r'`([^`\n]+)`')
protected

Definition at line 67 of file link_check.py.

◆ _md_link

link_check._md_link = re.compile(r'\‍[[^\‍]]*\‍]\‍(([^)\s]+)')
protected

Definition at line 66 of file link_check.py.

◆ CONTEXT

list link_check.CONTEXT
Initial value:
1= [_n(s) for s in [
2 "/docs/Ollama/", "/LLM-API-support/", "/best-practices/", "/benchmarks/",
3 "/architecture/memory/", "/architecture/roadmap-render/", "/architecture/agent_runtime/",
4 "/architecture/security/", "/version-semantics/", "/process/", "/option_c_specs/",
5 "/docs/research/", "/docs/audits/", # dated research/audit snapshots -> archived versions
6]]

Definition at line 45 of file link_check.py.

◆ EXEMPT

list link_check.EXEMPT
Initial value:
1= [_n(s) for s in [
2 "historical-archive-DO-NOT-DELETE", "/old/", "/reviews/", "/reports/reports/",
3 "DESIGN_DECISIONS_2026-06-08", "report-phase2", "/completed/",
4 "/golden/", # frozen render-oracle fixtures — must byte-match; fix the source, not these
5]]

Definition at line 38 of file link_check.py.

◆ REPO

link_check.REPO = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

Definition at line 28 of file link_check.py.

◆ SCAN_ROOTS

list link_check.SCAN_ROOTS = ["oc_chat", "tools"]

Definition at line 29 of file link_check.py.