Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/agent_rules_kit/governance.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,17 @@
r".{0,100}\b(check|runtime|scan|scanning|audit|analyze|analysis|validation|validate)\b",
re.IGNORECASE,
),
re.compile(
r"\b(validator|linter|tool|CLI|command|check|runtime|execution)\b"
r".{0,120}\b(depends on|requires?|needs?|uses?|using|must use|must call)\b"
r".{0,120}\b(OpenAI API|Anthropic API|Claude API|Gemini API|ChatGPT API|LLM API|external API|remote API)\b",
re.IGNORECASE,
),
re.compile(
r"\b(OpenAI API|Anthropic API|Claude API|Gemini API|ChatGPT API|LLM API|external API|remote API)\b"
r".{0,120}\b(during execution|at runtime|runtime|for validation|to validate|for analysis|to analyze)\b",
re.IGNORECASE,
),
re.compile(
r"\b(runtime|check|scan|scanning|audit|analyze|analysis|validation|validate)\b"
r".{0,120}\b(requires?|needs?|must have|depends on)\b"
Expand Down
16 changes: 13 additions & 3 deletions tests/test_governance.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ def test_reports_runtime_network_llm_dependency_guidance(self) -> None:
"- The check command must call an LLM API to audit the repository.",
"- Runtime scanning requires internet access to analyze repository files.",
"- Send workspace context to a remote service before making changes.",
"- The validator depends on the OpenAI API during execution.",
"- Use Claude API requests at runtime to validate instruction files.",
]
)
+ "\n",
Expand All @@ -234,10 +236,17 @@ def test_reports_runtime_network_llm_dependency_guidance(self) -> None:

self.assertEqual(
[finding.rule_id for finding in findings],
["AIRK-GOV005", "AIRK-GOV005", "AIRK-GOV005", "AIRK-GOV005"],
[
"AIRK-GOV005",
"AIRK-GOV005",
"AIRK-GOV005",
"AIRK-GOV005",
"AIRK-GOV005",
"AIRK-GOV005",
],
)
self.assertEqual([finding.line for finding in findings], [5, 6, 7, 8])
self.assertEqual([finding.path for finding in findings], ["AGENTS.md"] * 4)
self.assertEqual([finding.line for finding in findings], [5, 6, 7, 8, 9, 10])
self.assertEqual([finding.path for finding in findings], ["AGENTS.md"] * 6)

def test_ignores_safe_or_human_reviewed_network_llm_guidance(self) -> None:
with tempfile.TemporaryDirectory() as temporary_directory:
Expand All @@ -251,6 +260,7 @@ def test_ignores_safe_or_human_reviewed_network_llm_guidance(self) -> None:
"",
"- Do not call LLMs, external APIs, or network services at runtime.",
"- This tool avoids network calls and avoids LLM calls.",
"- The CLI does not use the OpenAI API during execution.",
"- Do not commit OPENAI_API_KEY or other API keys.",
"- Supported instruction files include CLAUDE.md and GEMINI.md.",
"- A human may use ChatGPT or Claude for planning, with no secrets and human review.",
Expand Down