feat(#2885): agents-kt-detekt module + ToolBodyForbiddenApis rule#119
Merged
Conversation
Epic #2882 (Pillar 1, static layer). New :agents-kt-detekt module ships custom
detekt rules that gate tool executor bodies.
- ToolBodyForbiddenApis: flags raw outside-world APIs (java.io.File, java.net.URL/
HttpURLConnection, ProcessBuilder/Runtime.exec, Class.forName, Unsafe, Socket)
used INSIDE a tool `executor { }` lambda — a tool must reach fs/net/env only
through the forthcoming closed ToolEnvironment ABI (#2883), so every action is
policy-gated and audited. Suppressible with @Suppress + reviewed reason.
- AgentsKtRuleSetProvider + META-INF/services registration (ruleset id `agents-kt`).
- Wired into the project's own detekt via detektPlugins(project(":agents-kt-detekt"))
+ detekt.yml; scoped to MAIN source (test fixtures legitimately exercise tools).
Main source is clean — the framework's tools don't touch raw I/O in executors.
- Honest limit (documented): syntactic (callee-name match, no FQN resolution);
reflection/aliasing/transitive state are Pillar-3 residual.
new detekt-api/detekt-test deps trusted in gradle/verification-metadata.xml
(updateVerificationMetadata task extended to exercise the module's classpaths).
4 detekt-test cases (flags File-in-executor, flags ProcessBuilder+URL, ignores the
same APIs outside an executor, honors @Suppress). Wired into testAll. CHANGELOG.
Full ./gradlew build green (suite + detekt with the rule live).
…-body-rule # Conflicts: # CHANGELOG.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Slice 2 of epic #2882 (capability ABI + audit ledger) — Pillar 1 static layer. New
:agents-kt-detektmodule + the first custom rule. TDD.ToolBodyForbiddenApis
Flags raw outside-world APIs (
java.io.File,java.net.URL/HttpURLConnection,ProcessBuilder/Runtime.exec,Class.forName,Unsafe,Socket) used inside a toolexecutor { }body — a tool must reach fs/net/env only through the forthcoming closedToolEnvironmentABI (#2883), so every action is policy-gated and audited. Suppressible with@Suppress("ToolBodyForbiddenApis")+ a reviewed reason.AgentsKtRuleSetProvider+META-INF/servicesregistration (ruleset idagents-kt).detektPlugins(project(":agents-kt-detekt"))+detekt.yml, scoped to main source (test fixtures legitimately exercise tools). Main source is clean — the framework's tools don't touch raw I/O in executors.Setup
New
detekt-api/detekt-testdeps trusted ingradle/verification-metadata.xml; theupdateVerificationMetadatatask was extended to exercise the new module's classpaths. Added all 14 transitive artifacts (detekt-test pulls junit 5.10.2 + kotlin-scripting + coroutines).Tests (4)
flags File-in-executor · flags ProcessBuilder+URL (exactly 2) · ignores the same APIs outside an executor · honors
@Suppress. Wired intotestAll.Verified: full
./gradlew buildgreen (suite + detekt with the rule live).#2884capability extractor builds on this module next.🤖 Generated with Claude Code