Skip to content

Coder

coder — mvp.coder

Cluster: Uncategorised | Type: component | MCP Tools: None

Overview

Public API

CoderProblemTypeError(ValueError)

The LLM did not produce a usable, registry-known problem-type decision.

ProblemTypeDecision

Validated framework problem-type decision for one task.

Field Type Default
problem_type str required
candidate_types list[str] field(default_factory=list)
rationale str ''
signals list[str] field(default_factory=list)
confidence float 0.0
degraded bool False
raw_response str ''

LLMCoderProblemClassifierRuntime

Provider-neutral problem-type runtime backed by G6's LLM caller.

Constructor:

Parameter Type Default
llm LLMCaller \| None None

Methods:

classify(task: str, language: str, known_types: Any, candidate_types: list[str] | None = None, prompt: str = '') -> ProblemTypeDecision

Pick the best registry-known problem type for task via the LLM.

CoderProblemClassifierPlanner

Runtime-first problem-type facade with a deterministic keyword floor.

Constructor:

Parameter Type Default
runtime LLMCoderProblemClassifierRuntime \| None None

Methods:

plan(task: str, language: str, registry: Any) -> ProblemTypeDecision

CoderAgenticSkill

Field Type Default
name str required
pattern_slug str required
description str required
executable bool required
mechanism str required
capabilities tuple[str, ...] required
triggers tuple[str, ...] required
risk_notes tuple[str, ...] required

Methods:

compact() -> dict[str, Any]

CoderAgenticSkillCatalog

Maps each applied pattern slug to a coder agentic-leg skill record.

Methods:

list_skills() -> list[CoderAgenticSkill]

executable_skills() -> list[CoderAgenticSkill]

get(slug: str) -> CoderAgenticSkill | None

CalibrationReport

Field Type Default
model_id str required
language str required
tier_results list[TierResult] field(default_factory=list)
grade_results list[GradeResult] field(default_factory=list)
recommended_grade TemplateGrade TemplateGrade.SLOT_FILL
max_tier_passed int -1
framework_success dict[str, float] field(default_factory=dict)

Methods:

to_dict() -> dict[str, Any]

ModelCalibrator

Calibrates model performance across curriculum tiers and template grades.

Field Type Default
llm LLMProvider required
curriculum Curriculum field(default_factory=Curriculum)

Methods:

calibrate(model_id: str, language: str = 'python', max_tier: int = 4, max_problems_per_tier: int = 5) -> Result[CalibrationReport]

Run full calibration for a model across tiers.

calibrate_tier(model_id: str, tier: int, language: str = 'python', max_problems: int = 5) -> Result[TierResult]

Calibrate a single tier.

update_state(state: CoderState, report: CalibrationReport) -> CoderState

Update CoderState with calibration results.

record_problem_result(state: CoderState, problem: CurriculumProblem, passed: bool, confidence: float) -> None

Record a single problem attempt in competence tracking.

ChecklistEngine

Generates and verifies code quality checklists.

Constructor:

Parameter Type Default
extension_dir Path \| None None

Methods:

checklist_types() -> list[str]

generate_checklist(spec: TaskSpec | None = None, task_type: str = 'general') -> list[ChecklistItem]

Generate a checklist for a task type, augmented with spec constraints.

verify_item(item: ChecklistItem, code: str, language: str = 'python') -> Result[ChecklistResult]

Verify a single checklist item against code.

verify_all(checklist: list[ChecklistItem], code: str, language: str = 'python') -> Result[ChecklistReport]

Verify all checklist items and return a report.

register_checklist(task_type: str, items: list[ChecklistItem]) -> None

Register or extend a checklist for a task type.

CodeVerifier

Verifies generated code through multiple independent checks.

Constructor:

Parameter Type Default
checklist_engine ChecklistEngine \| None None

Methods:

verify(code: str, spec: TaskSpec | None = None, language: str = 'python', task_type: str = 'general', gold_tests: str | None = None) -> Result[CodeCandidate]

Run all verification steps and return an updated CodeCandidate.

verify_candidate(candidate: CodeCandidate, spec: TaskSpec | None = None, language: str = 'python', task_type: str = 'general', gold_tests: str | None = None) -> Result[CodeCandidate]

Verify an existing candidate (updates it in-place).

CoderAgentAdapter

Wraps MicroLoop as AgentFn for learning layer compatibility.

Constructor:

Parameter Type Default
llm LLMProvider required
model_id str '27b_local'
language str 'python'
confidence_threshold float 0.3
gold_tests str \| None None
grade_override TemplateGrade \| None None
candidate_n int 1
debate_rounds int 1
self_test_refine bool False
self_test_rounds int 4
self_test_patience int 2

SubtaskNode

Field Type Default
description str required
language str required
children list[SubtaskNode] field(default_factory=list)
result MicroLoopResult \| None None
retries int 0
error str ''

Methods:

is_leaf() -> bool

succeeded() -> bool

CoderBlock(AIBlock[CoderInput, CoderOutput, CoderState])

Self-contained coding agent orchestrator.

Field Type Default
name str 'g6_coder'
state CoderState \| None field(default=None)
llm LLMProvider \| None None
framework_registry FrameworkRegistry field(default_factory=FrameworkRegistry)
template_library TemplateLibrary field(default_factory=TemplateLibrary)
checklist_engine ChecklistEngine field(default_factory=ChecklistEngine)
model_override str \| None None
gold_tests str \| None None

Methods:

infer(data: CoderInput) -> Result[CoderOutput]

Main entry point. Orchestrates full coding pipeline.

CoderFailureClassifier

Satisfies the learning layer's FailureClassifier protocol.

Methods:

classify(result: TaskResult) -> FailureAnalysis

CoderT3Trainer

Orchestrates T3 OODA learning for the coder micro-loop.

Field Type Default
llm LLMProvider required
model_id str '27b_local'
language str 'python'
max_tier int 2
max_cycles int 5
confidence_threshold float 0.3
db_path Path \| None None
candidate_n int 1
debate_rounds int 1

Methods:

train(dataset: Dataset | None = None, coder_state: CoderState | None = None) -> TrainingReport

CoderDiagnosis

Diagnosis specific to a coder failure.

Field Type Default
problem_id str required
failure_class CoderFailureClass required
description str required
suggested_action str required
confidence float required

CoderAuditFn

Callable that audits the coder by running calibration problems.

Field Type Default
llm LLMProvider required
model_id str '27b_local'
curriculum Curriculum field(default_factory=Curriculum)
max_tier int 1
max_problems_per_tier int 3

Curriculum

Problem bank with tier-based sequencing and extensibility.

Constructor:

Parameter Type Default
extension_dir Path \| None None

Methods:

get_problem(problem_id: str) -> Result[CurriculumProblem]

list_problems(tier: int | None = None, language: str | None = None, framework: str | None = None) -> list[CurriculumProblem]

problems_for_tier(tier: int, language: str = 'python') -> list[CurriculumProblem]

next_problems(competence: dict[str, float], language: str = 'python', count: int = 3) -> list[CurriculumProblem]

Select the next problems based on current competence.

problem_count() -> int

tier_counts() -> dict[int, int]

add_problem(problem: CurriculumProblem) -> None

remove_problem(problem_id: str) -> bool

FrameworkRegistry

Registry of framework stacks indexed by problem type and language.

Constructor:

Parameter Type Default
extension_dir Path \| None None

Methods:

problem_types() -> list[str]

stack_count() -> int

classify_problem(task: str, language: str) -> list[str]

Classify a task description into problem types using keyword matching.

get_stack(problem_type: str, language: str) -> Result[FrameworkStack]

Look up the framework stack for a problem type and language.

resolve_stack(task: str, language: str) -> Result[FrameworkStack]

Classify a task and return the best-matching framework stack.

register_stack(problem_type: str, stack: FrameworkStack) -> None

Register a new or override an existing framework stack.

check_availability(stack: FrameworkStack) -> Result[bool]

Check whether a framework's primary package is installed locally.

discover_novel(task: str, language: str) -> Result[list[FrameworkStack]]

Fallback: use ctx_library_mapper to search for relevant libraries.

list_stacks(language: str | None = None) -> list[tuple[str, FrameworkStack]]

List all registered stacks, optionally filtered by language.

StepTrace

Field Type Default
step str required
input_summary str ''
output_summary str ''
success bool True
error str ''

Methods:

to_dict() -> dict[str, Any]

MicroLoopResult

Field Type Default
candidate CodeCandidate required
spec TaskSpec \| None required
grounding GroundingContext required
trace list[StepTrace] required
framework_used str ''
agentic_evidence dict[str, Any] field(default_factory=dict)

Methods:

to_output_dict() -> dict[str, Any]

MicroLoop

7-step verified micro-loop for single-task code generation.

Field Type Default
llm LLMProvider required
model_id str '27b_local'
framework_registry FrameworkRegistry field(default_factory=FrameworkRegistry)
template_library TemplateLibrary field(default_factory=TemplateLibrary)
checklist_engine ChecklistEngine field(default_factory=ChecklistEngine)
code_verifier CodeVerifier \| None None
candidate_n int 1
debate_rounds int 1
grade_override TemplateGrade \| None None
self_test_refine bool False
self_test_rounds int 4
self_test_patience int 2
gold_retry bool False
gold_retry_rounds int 2
problem_classifier_planner Any None

Methods:

run(task_description: str, language: str = 'python', exemplars: list[dict[str, Any]] | None = None, gold_tests: str | None = None) -> Result[MicroLoopResult]

Execute the full 7-step micro-loop.

CoderPatternRuntime

Stateless executable mechanism for the advisory pattern guard.

Methods:

review_problem_type(decision: Any, known_types: Any = ()) -> CoderPatternReview

Advisory human-review flag for a grounded problem-type decision.

CurriculumTier(IntEnum)

TemplateGrade(IntEnum)

VerifyMethod(IntEnum)

FrameworkStack

Field Type Default
language str required
primary str required
deps list[str] required
template_ref str required
install str required
doc_url str ''

TaskSpec

Field Type Default
inputs str required
outputs str required
constraints tuple[str, ...] required
edge_cases tuple[str, ...] required
language str required
framework_stack str \| None None
checklist_type str \| None None

ChecklistItem

Field Type Default
description str required
verify_method VerifyMethod required
pattern str ''
predicate_expr str ''

ChecklistResult

Field Type Default
item ChecklistItem required
passed bool required
detail str ''

ChecklistReport

Field Type Default
items list[ChecklistResult] required

Methods:

pass_rate() -> float

all_passed() -> bool

failed_items() -> list[ChecklistResult]

CodeCandidate

Field Type Default
source str required
ast_valid bool False
lint_score float 0.0
type_check_score float 1.0
test_pass_rate float 0.0
debate_score float 0.0
cegis_verified bool False
checklist_pass_rate float 0.0
self_test_pass_rate float 0.0
overall_confidence float 0.0
degraded bool False
degradation_reason str ''
verification_evidence dict[str, Any] field(default_factory=lambda: {'gold_tests_run': False, 'sandbox_available': False, 'confidence': 0.0})

Methods:

compute_confidence() -> float

GroundingContext

Field Type Default
exemplars list[dict[str, Any]] required
source_chunks list[str] required
framework FrameworkStack \| None None
template str \| None None
token_budget int 1500

CoderInput(BaseModel)

Field Type Default
task str required
language str 'python'
context_files list[str] Field(default_factory=list)
constraints list[str] Field(default_factory=list)
model_override str \| None None

CoderOutput(BaseModel)

Field Type Default
code str required
tests str ''
verification dict[str, Any] Field(default_factory=dict)
trace list[dict[str, Any]] Field(default_factory=list)
frameworks_used list[str] Field(default_factory=list)
tier_used int 0
template_grade_used int 0
review_status Literal['verified', 'human_action_required', 'evidence_insufficient', 'experimental'] 'experimental'
verification_evidence dict[str, Any] Field(default_factory=lambda: {'gold_tests_run': False, 'sandbox_available': False, 'confidence': 0.0})
degraded bool True
degradation_reason str 'verification_evidence_missing'
completion_state Literal['verified', 'qualified-draft', 'blocked-escalated'] 'qualified-draft'
warning_card dict[str, Any] Field(default_factory=lambda: {'not_verified': ['verification_evidence_missing'], 'recommended_next_step': 'Run verifier-backed tests before promotion.'})
evidence dict[str, Any] Field(default_factory=dict)
request_id str ''
task_id str ''
run_id str ''
agentic_evidence dict[str, Any] Field(default_factory=dict)

CoderState

Field Type Default
current_tier int 0
template_grade TemplateGrade TemplateGrade.SLOT_FILL
competence dict[str, float] field(default_factory=dict)
session_history list[dict[str, Any]] field(default_factory=list)
model_id str ''
w_eff_tokens int 800

CurriculumProblem(BaseModel)

Field Type Default
problem_id str required
tier int required
language str required
description str required
gold_code str ''
gold_tests str ''
gold_trace str ''
framework_stack str \| None None
verification dict[str, Any] Field(default_factory=dict)

TemplateLibrary

Manages graduated code templates for framework-assisted code generation.

Constructor:

Parameter Type Default
extension_dir Path \| None None

Methods:

template_refs() -> list[str]

get_template(template_ref: str, grade: TemplateGrade) -> Result[str]

Return the raw template string for a given ref and grade.

render(template_ref: str, grade: TemplateGrade, spec: TaskSpec | None = None, task_description: str = '', exemplar: str = '') -> Result[str]

Render a template with spec values interpolated.

render_for_stack(stack: FrameworkStack, grade: TemplateGrade, spec: TaskSpec | None = None, task_description: str = '', exemplar: str = '') -> Result[str]

Convenience: render using a FrameworkStack's template_ref.

register_template(template_ref: str, grade: TemplateGrade, template: str) -> None

Register or override a template.

TestExecutionResult

Field Type Default
passed int 0
failed int 0
errors list[str] field(default_factory=list)
output str ''
supported bool True
reason str ''
execution_id str ''
started_at str ''
duration_s float 0.0
command str ''
sandbox str ''

Methods:

pass_rate() -> float

total() -> int

TestExecutor

Executes generated code + test cases in an isolated sandbox.

Constructor:

Parameter Type Default
timeout int 30
python_cmd str 'python'

Methods:

execute(code: str, tests: str, language: str = 'python') -> Result[TestExecutionResult]

Run tests against code in a sandboxed subprocess.

VisualDesignLibrary

Library of pre-built, verified visual component templates.

Constructor:

Parameter Type Default
extension_dir Path \| None None

Methods:

component_names() -> list[str]

list_components(language: str | None = None, framework: str | None = None) -> list[dict[str, str]]

List available visual components with metadata.

get_template(component_name: str, grade: TemplateGrade) -> Result[str]

Get the template string for a component at a given grade.

render(component_name: str, grade: TemplateGrade, task_description: str = '', exemplar: str = '', customisations: dict[str, str] | None = None) -> Result[str]

Render a visual component template with substitutions.

classify_visual_task(task: str) -> list[str]

Classify a task into matching visual component names.

register_component(name: str, data: dict[str, Any]) -> None

Register or override a visual component.

Functions

summarize_coder_agentic_evidence(planner: Any | None = None, enabled: bool = True, suppression_reason: str = '') -> dict[str, Any] | None

Build the exported agentic-evidence record for a grounded classification.

agentic_planner_enabled(default_enabled: bool) -> bool

Decide whether the agentic problem-type planner should be used.

validate_problem_type_decision(decision: ProblemTypeDecision, known_types: Any) -> None

FAIL-CLOSED structural-validity ceiling for a problem-type decision.

deterministic_problem_classification(task: str, language: str, registry: Any) -> ProblemTypeDecision

Floor: the REAL keyword taxonomy from framework_registry.classify_problem.

get_agentic_skill_catalog() -> CoderAgenticSkillCatalog

classify_coder_failure(problem_id: str, passed: bool, confidence: float, error: str, framework_used: str, trace: list[dict[str, Any]] | None = None) -> CoderDiagnosis

Classify a coder problem result into a failure category.

coder_improve_fn(state: CoderState, failure_class: str, suggested_action: str) -> tuple[bool, str]

Apply a coder-specific improvement strategy to CoderState.

applied_agentic_patterns() -> list[dict[str, Any]]

Return compact metadata for coder-applied patterns.

list_patterns() -> dict[str, Any]

Component-level list_patterns op for coder.

transfer_theories(theories: list[Any], state: CoderState, strength_threshold: float = 0.8, skill_export_dir: Path | None = None) -> TransferReport

Transfer strong theories into permanent coder configuration.

build_prompt_addendum(theories: list[TransferredTheory]) -> str

Build a prompt addendum string from transferred theories.