Class ReviewAgent
java.lang.Object
com.tnsai.quality.security.harness.ReviewAgent
- All Implemented Interfaces:
ReviewAgentSpi
Default
ReviewAgentSpi backed by an LLMClient (TNS-291).
Builds a structured prompt that includes the file path, the matchers
that flagged the file during scan, and the file content. Asks the LLM
to emit a JSON array of findings whose shape matches
ReviewFinding. Parses the response, tags every finding with
the agent's id (matcher = "agent:<agent-id>" and
agentBackend = <agent-id>) and returns the list.
Output schema (the prompt asks the LLM for):
[
{
"id": "stable-finding-id",
"cwe": "CWE-89",
"severity": "HIGH",
"startLine": 10, "endLine": 12,
"title": "...",
"description": "...",
"evidence": "code snippet",
"mitigation": "fix suggestion (optional)"
}
]
If no findings, the LLM returns []. Malformed or partial
JSON yields an empty list and a WARN log — the AgentRun's
error field captures what went wrong.
- Since:
- 0.10.0 (TNS-291)
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.tnsai.quality.security.harness.ReviewAgentSpi
ReviewAgentSpi.ReviewContext -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ReviewAgentclaudeOpus(com.tnsai.llm.LLMClient llmClient) Convenience factory — id"claude-opus", version derived fromLLMClient.getModel().static ReviewAgentgpt(com.tnsai.llm.LLMClient llmClient) Convenience factory — id"gpt", version from the LLM client's model.id()Stable id, e.g.runOnFile(FileRecord file, ReviewAgentSpi.ReviewContext ctx) Run the agent onfileand return any findings.version()Backend version / model identifier.
-
Constructor Details
-
ReviewAgent
- Parameters:
id- stable agent id (used inAgentRun.agentId())version- model / agent version (used for cache invalidation)llmClient- backing LLM provider
-
-
Method Details
-
claudeOpus
Convenience factory — id"claude-opus", version derived fromLLMClient.getModel(). -
gpt
Convenience factory — id"gpt", version from the LLM client's model. -
id
Description copied from interface:ReviewAgentSpiStable id, e.g."claude-opus-4-7". Used inAgentRun.agentId().- Specified by:
idin interfaceReviewAgentSpi
-
version
Description copied from interface:ReviewAgentSpiBackend version / model identifier. Stored on eachAgentRunso the state store can detect when cached results are stale (e.g. model upgrade invalidates prior runs).- Specified by:
versionin interfaceReviewAgentSpi
-
runOnFile
Description copied from interface:ReviewAgentSpiRun the agent onfileand return any findings.Implementations:
- MUST NOT mutate
file; they receive an immutable record. - MUST emit findings whose
fileequalsfile.path(). - SHOULD emit a stable
finding id(typicallyagent-id + "-" + cwe + "-" + line) so re-runs deduplicate cleanly. - SHOULD record the agent backend in
ReviewFinding.agentBackend()for downstream filtering. - MAY return an empty list — "agent saw nothing" is a valid outcome.
- Specified by:
runOnFilein interfaceReviewAgentSpi
- MUST NOT mutate
-