From be53622caa3f7d3254a4eea19a995d660bf26635 Mon Sep 17 00:00:00 2001 From: CoderDeltaLAN Date: Tue, 16 Jun 2026 15:25:50 +0100 Subject: [PATCH] fix: cover runtime LLM API governance patterns --- src/agent_rules_kit/governance.py | 11 +++++++++++ tests/test_governance.py | 16 +++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/agent_rules_kit/governance.py b/src/agent_rules_kit/governance.py index b32cccc..36c6621 100644 --- a/src/agent_rules_kit/governance.py +++ b/src/agent_rules_kit/governance.py @@ -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" diff --git a/tests/test_governance.py b/tests/test_governance.py index 510c614..f877a5a 100644 --- a/tests/test_governance.py +++ b/tests/test_governance.py @@ -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", @@ -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: @@ -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.",