Domain Models¶
hachimoku’s domain models are defined in the hachimoku.models package.
All models are Pydantic v2-based, providing type validation and strict validation (extra fields forbidden).
Severity¶
An enumeration that represents the severity of review issues in four levels.
Value |
Description |
|---|---|
Critical |
Critical issue. Must be fixed |
Important |
Important issue. Fix recommended |
Suggestion |
Improvement suggestion |
Nitpick |
Minor remark |
Order: Critical > Important > Suggestion > Nitpick
In the severity field of ReviewIssue, input is accepted case-insensitively ("critical", "CRITICAL", "Critical" are all valid).
ToolCategory¶
An enumeration (StrEnum) that defines the types of tools permitted for agents. Consists of four read-only categories.
Value |
String Value |
Description |
|---|---|---|
|
|
Git read operations (diff, log, show, status, etc.) |
|
|
GitHub CLI read operations (pr view, issue view, etc.) |
|
|
File read operations (read, ls, etc.) |
|
|
Web content fetch operations |
from hachimoku.models import ToolCategory
cat = ToolCategory.GIT_READ
assert cat == "git_read"
FileLocation¶
Represents the location within a file where a review issue was detected.
Field |
Type |
Constraint |
|---|---|---|
|
|
Non-empty |
|
|
1 or greater |
from hachimoku.models import FileLocation
loc = FileLocation(file_path="src/main.py", line_number=42)
ReviewIssue¶
A unified representation of issues detected by each agent.
Field |
Type |
Required |
Constraint |
|---|---|---|---|
|
|
Yes |
Non-empty |
|
|
Yes |
Case-insensitive |
|
|
Yes |
Non-empty |
|
|
No |
Default |
|
|
No |
Default |
|
|
No |
Default |
from hachimoku.models import ReviewIssue, Severity
issue = ReviewIssue(
agent_name="code-reviewer",
severity=Severity.IMPORTANT,
description="Unused variable detected",
suggestion="Remove the variable or use it",
)
CostInfo¶
Records token consumption and cost for LLM execution.
Field |
Type |
Constraint |
|---|---|---|
|
|
0 or greater |
|
|
0 or greater |
|
|
Default |
AgentResult¶
A discriminated union representing the execution result of a single agent.
One of the following four types is automatically selected based on the status field value.
AgentSuccess¶
Field |
Type |
Required |
Constraint |
|---|---|---|---|
|
|
Yes |
Fixed value |
|
|
Yes |
Non-empty |
|
|
Yes |
Empty list allowed |
|
|
No |
Default |
|
|
Yes |
Positive value (0 not allowed) |
|
|
No |
Default |
AgentTruncated¶
Holds partial results when the maximum number of turns is reached. Treated as a valid result (same as AgentSuccess) when calculating ReviewSummary.
Field |
Type |
Required |
Constraint |
|---|---|---|---|
|
|
Yes |
Fixed value |
|
|
Yes |
Non-empty |
|
|
Yes |
Empty list allowed |
|
|
No |
Default |
|
|
Yes |
Positive value (0 not allowed) |
|
|
Yes |
Positive value (0 not allowed) |
AgentError¶
Field |
Type |
Required |
Constraint |
|---|---|---|---|
|
|
Yes |
Fixed value |
|
|
Yes |
Non-empty |
|
|
Yes |
Non-empty |
|
|
No |
CLI process exit code. Default |
|
|
No |
Structured error type. Non-empty. Default |
|
|
No |
Standard error output. Default |
AgentTimeout¶
Field |
Type |
Required |
Constraint |
|---|---|---|---|
|
|
Yes |
Fixed value |
|
|
Yes |
Non-empty |
|
|
Yes |
Positive value (0 not allowed) |
Deserialization Example¶
from pydantic import TypeAdapter
from hachimoku.models import AgentResult, AgentSuccess
adapter = TypeAdapter(AgentResult)
# Type is automatically selected by the status field
result = adapter.validate_python({
"status": "success",
"agent_name": "code-reviewer",
"issues": [],
"elapsed_time": 2.5,
})
assert isinstance(result, AgentSuccess)
ReviewSummary¶
An overall summary of review results.
Field |
Type |
Required |
Constraint |
|---|---|---|---|
|
|
Yes |
0 or greater |
|
|
Yes |
|
|
|
Yes |
0.0 or greater |
|
|
No |
Default |
|
|
No |
Default |
Priority¶
An enumeration that represents the priority of recommended actions in three levels. A separate concept from Severity (issue severity), used in RecommendedAction.
Value |
Description |
|---|---|
|
High priority |
|
Medium priority |
|
Low priority |
RecommendedAction¶
Recommended actions generated by the aggregation agent.
Field |
Type |
Required |
Constraint |
|---|---|---|---|
|
|
Yes |
Non-empty |
|
|
Yes |
- |
Contradiction¶
Detected contradiction between agents. Recorded when different agents give conflicting recommendations about the same code location or topic.
Field |
Type |
Required |
Constraint |
|---|---|---|---|
|
|
Yes |
Non-empty |
|
|
Yes |
Agent names involved in the contradiction |
|
|
No |
Default |
QualityFilteredIssue¶
Issue removed by the output quality gate. Records the original issue summary and the reason for filtering.
Field |
Type |
Required |
Constraint |
|---|---|---|---|
|
|
Yes |
Original agent name |
|
|
Yes |
Non-empty |
|
|
Yes |
Non-empty. Filtering reason |
AggregatedReport¶
Structured output from the LLM-based aggregation agent. Includes deduplicated issues, positive feedback, recommended actions, failed agent information, detected contradictions, and quality-filtered issues.
Field |
Type |
Required |
Constraint |
|---|---|---|---|
|
|
Yes |
Empty list allowed. Deduplicated and merged |
|
|
Yes |
Empty list allowed |
|
|
Yes |
Empty list allowed |
|
|
Yes |
Failed agent names. Empty list allowed |
|
|
Yes |
0.0 to 10.0 |
|
|
No |
Default empty list. Detected contradictions |
|
|
No |
Default empty list. Quality-gated issues |
ReviewReport¶
A report aggregating results from all agents.
Field |
Type |
Required |
Constraint |
|---|---|---|---|
|
|
Yes |
Empty list allowed |
|
|
Yes |
- |
|
|
No |
Default empty tuple |
|
|
No |
Default |
|
|
No |
Default |
load_errors holds errors that occurred during agent definition loading.
A report can be generated with empty results even if all agents fail.
aggregated is the result of LLM-based aggregation (Step 9.5). It is None when aggregation is disabled or fails; on failure, aggregation_error is set with error information.
from hachimoku.models import ReviewReport, ReviewSummary
report = ReviewReport(
results=[],
summary=ReviewSummary(
total_issues=0,
max_severity=None,
total_elapsed_time=0.0,
),
)
Review History Records¶
Record models for persisting review results in JSONL format.
Defined as a discriminated union where the type is automatically selected by the review_mode field value.
CommitHash¶
A type alias for Git commit hashes. Constrained to a 40-character lowercase hexadecimal string.
from hachimoku.models import CommitHash
from pydantic import TypeAdapter
adapter = TypeAdapter(CommitHash)
hash_value = adapter.validate_python("a" * 40) # Valid
DiffReviewRecord¶
Review history record for diff mode.
Field |
Type |
Required |
Constraint |
|---|---|---|---|
|
|
Yes |
Fixed value |
|
|
Yes |
40-character lowercase hex |
|
|
Yes |
Non-empty |
|
|
Yes |
- |
|
|
Yes |
- |
|
|
Yes |
- |
PRReviewRecord¶
Review history record for PR mode.
Field |
Type |
Required |
Constraint |
|---|---|---|---|
|
|
Yes |
Fixed value |
|
|
Yes |
40-character lowercase hex |
|
|
Yes |
1 or greater |
|
|
Yes |
Non-empty |
|
|
Yes |
- |
|
|
Yes |
- |
|
|
Yes |
- |
FileReviewRecord¶
Review history record for file mode.
Field |
Type |
Required |
Constraint |
|---|---|---|---|
|
|
Yes |
Fixed value |
|
|
Yes |
At least 1 element, each non-empty |
|
|
Yes |
- |
|
|
Yes |
Absolute path |
|
|
Yes |
- |
|
|
Yes |
- |
Deserialization Example¶
from pydantic import TypeAdapter
from hachimoku.models import ReviewHistoryRecord, DiffReviewRecord
adapter = TypeAdapter(ReviewHistoryRecord)
# Type is automatically selected by the review_mode field
record = adapter.validate_python({
"review_mode": "diff",
"commit_hash": "a" * 40,
"branch_name": "feature/example",
"reviewed_at": "2026-01-01T00:00:00",
"results": [],
"summary": {
"total_issues": 0,
"max_severity": None,
"total_elapsed_time": 0.0,
},
})
assert isinstance(record, DiffReviewRecord)
Output Schemas¶
Schemas that define the output format of agents. All schemas inherit from BaseAgentOutput and share the common attribute issues: list[ReviewIssue].
BaseAgentOutput¶
The common base model for all output schemas.
Field |
Type |
Required |
Constraint |
|---|---|---|---|
|
|
Yes |
Empty list allowed |
ScoredIssues¶
An output schema combining a numerical score with review issues. Used by code-reviewer, among others.
Field |
Type |
Required |
Constraint |
|---|---|---|---|
|
|
Yes |
Empty list allowed |
|
|
Yes |
0.0 to 10.0 inclusive |
from hachimoku.models import ScoredIssues, ReviewIssue, Severity
scored = ScoredIssues(
issues=[
ReviewIssue(
agent_name="code-reviewer",
severity=Severity.IMPORTANT,
description="Missing error handling",
),
],
overall_score=7.5,
)
SeverityClassified¶
An output schema with issue lists classified by severity. Used by silent-failure-hunter, among others.
The issues field is automatically derived from the four classification lists. Only the four classification lists need to be specified at input.
Field |
Type |
Required |
Constraint |
|---|---|---|---|
|
|
Yes |
- |
|
|
Yes |
- |
|
|
Yes |
- |
|
|
Yes |
- |
|
|
- |
Auto-derived (read-only) |
from hachimoku.models import SeverityClassified, ReviewIssue, Severity
classified = SeverityClassified(
critical_issues=[
ReviewIssue(
agent_name="silent-failure-hunter",
severity=Severity.CRITICAL,
description="Silent exception swallowed",
),
],
important_issues=[],
suggestion_issues=[],
nitpick_issues=[],
)
# issues is auto-derived from the concatenation of the four lists
assert len(classified.issues) == 1
TestGapAssessment¶
An output schema for evaluating test coverage gaps. Used by pr-test-analyzer.
Field |
Type |
Required |
Constraint |
|---|---|---|---|
|
|
Yes |
Empty list allowed |
|
|
Yes |
Empty list allowed |
|
|
Yes |
- |
CoverageGap has the following fields.
Field |
Type |
Required |
Constraint |
|---|---|---|---|
|
|
Yes |
Non-empty |
|
|
Yes |
Non-empty |
|
|
Yes |
- |
MultiDimensionalAnalysis¶
An output schema that scores across multiple evaluation dimensions. Used by type-design-analyzer.
Field |
Type |
Required |
Constraint |
|---|---|---|---|
|
|
Yes |
Empty list allowed |
|
|
Yes |
Empty list allowed |
DimensionScore has the following fields.
Field |
Type |
Required |
Constraint |
|---|---|---|---|
|
|
Yes |
Non-empty |
|
|
Yes |
0.0 to 10.0 inclusive |
|
|
Yes |
Non-empty |
CategoryClassification¶
An output schema that classifies issues by category. Used by comment-analyzer.
Field |
Type |
Required |
Constraint |
|---|---|---|---|
|
|
Yes |
Empty list allowed |
|
|
Yes |
Empty dict allowed |
ImprovementSuggestions¶
An output schema that provides a list of specific improvement suggestions. Used by code-simplifier.
Field |
Type |
Required |
Constraint |
|---|---|---|---|
|
|
Yes |
Empty list allowed |
|
|
Yes |
Empty list allowed |
ImprovementItem has the following fields.
Field |
Type |
Required |
Constraint |
|---|---|---|---|
|
|
Yes |
Non-empty |
|
|
Yes |
Non-empty |
|
|
Yes |
- |
|
|
No |
Default |
SCHEMA_REGISTRY¶
A registry that resolves schema names to their corresponding schema classes. Used to identify schemas from the output_schema field in agent definition files.
Registered schemas:
Name |
Schema Class |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
from hachimoku.models import get_schema, ScoredIssues
schema_cls = get_schema("scored_issues")
assert schema_cls is ScoredIssues
Specifying an unregistered schema name raises SchemaNotFoundError. New schemas can be added with register_schema, and registering a duplicate name raises DuplicateSchemaError.