The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.
fix(governance): bound incomplete link scans
Seekers2001162bff9438b1
diff --git a/.agents/skills/docs-governance/scripts/markdown_links.py b/.agents/skills/docs-governance/scripts/markdown_links.pyindex cc4c77ec2..213f9b4f7 100644--- a/.agents/skills/docs-governance/scripts/markdown_links.py+++ b/.agents/skills/docs-governance/scripts/markdown_links.py@@ -81,10 +81,12 @@ def inline_link_targets(text: str) -> list[str]:end = text.find(">", start + 1)if end != -1:targets.append(text[start : end + 1])- continue+ continue+ breakdepth = 0quote: str | None = Noneescaped = False+ closed = Falsefor end in range(start, len(text)):character = text[end]if quote is not None:@@ -103,8 +105,11 @@ def inline_link_targets(text: str) -> list[str]:elif character == ")":if depth == 0:targets.append(text[start:end])+ closed = Truebreakdepth -= 1+ if not closed:+ breakreturn targetsdiff --git a/skills/docs-governance/scripts/markdown_links.py b/skills/docs-governance/scripts/markdown_links.pyindex cc4c77ec2..213f9b4f7 100644--- a/skills/docs-governance/scripts/markdown_links.py+++ b/skills/docs-governance/scripts/markdown_links.py@@ -81,10 +81,12 @@ def inline_link_targets(text: str) -> list[str]:end = text.find(">", start + 1)if end != -1:targets.append(text[start : end + 1])- continue+ continue+ breakdepth = 0quote: str | None = Noneescaped = False+ closed = Falsefor end in range(start, len(text)):character = text[end]if quote is not None:@@ -103,8 +105,11 @@ def inline_link_targets(text: str) -> list[str]:elif character == ")":if depth == 0:targets.append(text[start:end])+ closed = Truebreakdepth -= 1+ if not closed:+ breakreturn targetsdiff --git a/tests/test_docs_governance_audit.py b/tests/test_docs_governance_audit.pyindex e50ab9f67..df17467ce 100644--- a/tests/test_docs_governance_audit.py+++ b/tests/test_docs_governance_audit.py@@ -16,12 +16,15 @@ def project(tmp_path: Path) -> Path:return tmp_path-def run_audit(project: Path, scope: str) -> subprocess.CompletedProcess[str]:+def run_audit(+ project: Path, scope: str, *, timeout: float | None = None+) -> subprocess.CompletedProcess[str]:return subprocess.run([sys.executable, str(SCRIPT), "--root", str(project), "--scope", scope],text=True,capture_output=True,check=False,+ timeout=timeout,)@@ -209,6 +212,14 @@ def test_artifact_scope_ignores_optional_markdown_link_titles(project: Path) ->assert result.returncode == 0, result.stdout+def test_artifact_scope_handles_many_unclosed_inline_links_linearly(+ project: Path,+) -> None:+ (project / "guide.md").write_text("[link](" * 10_000, encoding="utf-8")+ result = run_audit(project, "artifacts", timeout=2)+ assert result.returncode == 0, result.stdout++def test_artifact_scope_ignores_links_inside_code_examples(project: Path) -> None:(project / "guide.md").write_text("`[inline](missing-inline.md)`\n\n```md\n[fenced](missing-fenced.md)\n```\n",