Skip to content

armgit / ECC

Public Imported from GitHub
0

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

fix(governance): handle documented parser forms

Seekers200151a0ba9ec677
diff --git a/.agents/skills/docs-governance/scripts/audit-docs.py b/.agents/skills/docs-governance/scripts/audit-docs.py
index ce254ee7b..65af06a8d 100644
--- a/.agents/skills/docs-governance/scripts/audit-docs.py
+++ b/.agents/skills/docs-governance/scripts/audit-docs.py
@@ -432,7 +432,7 @@ def check_log(
def parse_adr_status(text: str) -> str | None:
patterns = (
- r"(?im)^(?:[-*]\s+)?(?:\*\*(?:status|\u72b6\u6001)\*\*|(?:status|\u72b6\u6001))\s*[:\uFF1A]\s*`?([a-z]+)`?\s*$",
+ r"(?im)^(?:[-*]\s+)?(?:\*\*(?:status|\u72b6\u6001)\*\*|(?:status|\u72b6\u6001))\s*[:\uFF1A]\s*`?([a-z]+)`?(?:\s+by\s+ADR-\d+)?\s*$",
r"(?im)^##\s+(?:status|\u72b6\u6001)\s*\n+\s*`?([a-z]+)`?\s*$",
)
for pattern in patterns:
diff --git a/.agents/skills/docs-governance/scripts/markdown_links.py b/.agents/skills/docs-governance/scripts/markdown_links.py
index 098145421..a7b9ed63e 100644
--- a/.agents/skills/docs-governance/scripts/markdown_links.py
+++ b/.agents/skills/docs-governance/scripts/markdown_links.py
@@ -85,38 +85,23 @@ def inline_link_targets(text: str) -> list[str]:
index += 1
continue
start = match.end()
- candidate_index = index + 1
if start < len(text) and text[start] == "<":
- end = start + 1
- while end < len(text):
- if (
- candidate_index < len(matches)
- and end == matches[candidate_index].start()
- ):
- index = candidate_index
- break
- if text[end] == ">":
- targets.append(text[start : end + 1])
- cursor = end + 1
- index = candidate_index
- break
- end += 1
- else:
- break
- continue
+ end = text.find(">", start + 1)
+ if end != -1:
+ targets.append(text[start : end + 1])
+ cursor = end + 1
+ index += 1
+ continue
+ index += 1
+ if index < len(matches):
+ continue
+ break
depth = 0
quote: str | None = None
escaped = False
- end = start
- while end < len(text):
- if (
- candidate_index < len(matches)
- and end == matches[candidate_index].start()
- ):
- if quote is None:
- index = candidate_index
- break
- candidate_index += 1
+ closed = False
+ saw_closing = False
+ for end in range(start, len(text)):
character = text[end]
if quote is not None:
if escaped:
@@ -125,23 +110,25 @@ def inline_link_targets(text: str) -> list[str]:
escaped = True
elif character == quote:
quote = None
- end += 1
continue
if character in {"'", '"'}:
quote = character
- end += 1
continue
if character == "(":
depth += 1
elif character == ")":
+ saw_closing = True
if depth == 0:
targets.append(text[start:end])
cursor = end + 1
- index = candidate_index
+ closed = True
break
depth -= 1
- end += 1
- else:
+ if closed:
+ index += 1
+ continue
+ index += 1
+ if not saw_closing or index >= len(matches):
break
return targets
diff --git a/skills/docs-governance/scripts/audit-docs.py b/skills/docs-governance/scripts/audit-docs.py
index ce254ee7b..65af06a8d 100644
--- a/skills/docs-governance/scripts/audit-docs.py
+++ b/skills/docs-governance/scripts/audit-docs.py
@@ -432,7 +432,7 @@ def check_log(
def parse_adr_status(text: str) -> str | None:
patterns = (
- r"(?im)^(?:[-*]\s+)?(?:\*\*(?:status|\u72b6\u6001)\*\*|(?:status|\u72b6\u6001))\s*[:\uFF1A]\s*`?([a-z]+)`?\s*$",
+ r"(?im)^(?:[-*]\s+)?(?:\*\*(?:status|\u72b6\u6001)\*\*|(?:status|\u72b6\u6001))\s*[:\uFF1A]\s*`?([a-z]+)`?(?:\s+by\s+ADR-\d+)?\s*$",
r"(?im)^##\s+(?:status|\u72b6\u6001)\s*\n+\s*`?([a-z]+)`?\s*$",
)
for pattern in patterns:
diff --git a/skills/docs-governance/scripts/markdown_links.py b/skills/docs-governance/scripts/markdown_links.py
index 098145421..a7b9ed63e 100644
--- a/skills/docs-governance/scripts/markdown_links.py
+++ b/skills/docs-governance/scripts/markdown_links.py
@@ -85,38 +85,23 @@ def inline_link_targets(text: str) -> list[str]:
index += 1
continue
start = match.end()
- candidate_index = index + 1
if start < len(text) and text[start] == "<":
- end = start + 1
- while end < len(text):
- if (
- candidate_index < len(matches)
- and end == matches[candidate_index].start()
- ):
- index = candidate_index
- break
- if text[end] == ">":
- targets.append(text[start : end + 1])
- cursor = end + 1
- index = candidate_index
- break
- end += 1
- else:
- break
- continue
+ end = text.find(">", start + 1)
+ if end != -1:
+ targets.append(text[start : end + 1])
+ cursor = end + 1
+ index += 1
+ continue
+ index += 1
+ if index < len(matches):
+ continue
+ break
depth = 0
quote: str | None = None
escaped = False
- end = start
- while end < len(text):
- if (
- candidate_index < len(matches)
- and end == matches[candidate_index].start()
- ):
- if quote is None:
- index = candidate_index
- break
- candidate_index += 1
+ closed = False
+ saw_closing = False
+ for end in range(start, len(text)):
character = text[end]
if quote is not None:
if escaped:
@@ -125,23 +110,25 @@ def inline_link_targets(text: str) -> list[str]:
escaped = True
elif character == quote:
quote = None
- end += 1
continue
if character in {"'", '"'}:
quote = character
- end += 1
continue
if character == "(":
depth += 1
elif character == ")":
+ saw_closing = True
if depth == 0:
targets.append(text[start:end])
cursor = end + 1
- index = candidate_index
+ closed = True
break
depth -= 1
- end += 1
- else:
+ if closed:
+ index += 1
+ continue
+ index += 1
+ if not saw_closing or index >= len(matches):
break
return targets
diff --git a/tests/test_docs_governance_audit.py b/tests/test_docs_governance_audit.py
index cd56e1d05..dfdf4587d 100644
--- a/tests/test_docs_governance_audit.py
+++ b/tests/test_docs_governance_audit.py
@@ -271,6 +271,17 @@ def test_artifact_scope_ignores_link_like_text_in_title(project: Path) -> None:
assert result.returncode == 0, result.stdout
+def test_artifact_scope_accepts_link_shaped_destination_text(project: Path) -> None:
+ target = project / "guide[ref](v1).md"
+ target.write_text("# Guide\n", encoding="utf-8")
+ (project / "index.md").write_text(
+ "[plain](guide[ref](v1).md)\n[wrapped](<guide[ref](v1).md>)\n",
+ encoding="utf-8",
+ )
+ result = run_audit(project, "artifacts")
+ assert result.returncode == 0, result.stdout
+
+
def test_artifact_scope_checks_angle_wrapped_destination_with_title(
project: Path,
) -> None:
@@ -348,6 +359,19 @@ def test_adr_scope_accepts_documented_bold_status_metadata(project: Path) -> Non
assert result.returncode == 0, result.stdout
+def test_adr_scope_accepts_superseded_status_with_successor(project: Path) -> None:
+ adr_dir = project / "docs" / "adr"
+ adr_dir.mkdir(parents=True)
+ (adr_dir / "README.md").write_text(
+ "[decision](0001-storage.md)\n", encoding="utf-8"
+ )
+ (adr_dir / "0001-storage.md").write_text(
+ "# ADR-0001\n\n**Status**: superseded by ADR-0002\n", encoding="utf-8"
+ )
+ result = run_audit(project, "adr")
+ assert result.returncode == 0, result.stdout
+
+
def test_adr_scope_audits_common_adr_prefixed_filenames(project: Path) -> None:
adr_dir = project / "docs" / "adr"
adr_dir.mkdir(parents=True)