Skip to content

Adapt Library Synthesizer

adapt_library_synthesizer — synthesize library implementations from research papers.

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

Overview

Synthesises Python library implementations directly from research paper descriptions or algorithm specifications. Parses paper text or URLs to extract algorithm structure, then generates implementation code and test scaffolding.

When to use:

  • Rapidly prototyping novel algorithms described in papers
  • Bootstrapping a new G6 component from academic research
  • Generating implementation stubs and test scaffolding for algorithms not yet in PyPI

Example:

from mvp.adapt_library_synthesizer import AdaptLibrarySynthesizerBlock, SynthesizerInput

block = AdaptLibrarySynthesizerBlock(name="lib_synth")
result = block.infer(SynthesizerInput(
    algorithm_name="CEGIS",
    paper_text="Counter-Example Guided Inductive Synthesis iteratively...",
))
# result.ok → True; result.value → SynthesizerOutput with implementation, test_code

Works well with: meta_programming, cegis, component_creator

Public API

LibrarySynthesizerDecisionError(ValueError)

The LLM did not produce a usable, validated algorithm-spec recommendation.

LLMSpecExtractionRuntime

Provider-neutral algorithm-spec extraction runtime over G6's LLM caller.

Constructor:

Parameter Type Default
llm LLMCaller \| None None

Methods:

recommend(paper_text: str, algorithm_name: str = '') -> Result[dict]

SpecExtractionPlanner

Runtime-first facade with the deterministic regex floor as honest fallback.

Constructor:

Parameter Type Default
runtime SpecExtractionRuntime \| None None
config Any None

Methods:

recommend_spec(paper_text: str, algorithm_name: str = '') -> AlgorithmSpec

AlgorithmSpec(BaseModel)

Field Type Default
name str ''
inputs list[str] Field(default_factory=list)
outputs list[str] Field(default_factory=list)
steps list[str] Field(default_factory=list)
invariants list[str] Field(default_factory=list)
complexity str ''
hyperparameters dict Field(default_factory=dict)

SynthesizerInput(BaseModel)

Field Type Default
op Literal['synthesize', 'synthesise', 'info'] 'synthesize'
paper_url str ''
paper_text str ''
algorithm_name str ''

SynthesizerOutput(BaseModel)

Field Type Default
algorithm_spec dict Field(default_factory=dict)
implementation str ''
test_code str ''
status Literal['success', 'failed', 'partial'] 'success'
degraded bool False
degradation_reason str ''
completion_state Literal['verified', 'qualified-draft', 'blocked-escalated'] 'qualified-draft'
warning_card dict Field(default_factory=dict)
evidence list[dict] Field(default_factory=list)
request_id str ''
run_id str ''
task_id str ''
review_status Literal['unreviewed', 'expert_review_required', 'approved', 'rejected'] 'unreviewed'

AdaptLibrarySynthesizerBlock(AIBlock[SynthesizerInput, SynthesizerOutput, None])

Field Type Default
name str 'adapt_library_synthesizer'
resource_bounds ResourceBounds \| None None
usage ResourceUsage field(default_factory=ResourceUsage)

Methods:

infer(data: SynthesizerInput) -> Result[SynthesizerOutput]

MCPLibrarySynthesizerRecord(BaseModel)

Field Type Default
id str ''
record_type str ''
key str ''
value str ''
tags list[str] Field(default_factory=list)
timestamp str ''
metadata dict[str, Any] Field(default_factory=dict)

MCPLibrarySynthesizerInput(BaseModel)

Field Type Default
op LibrarySynthesizerOp required
paper_id str ''
paper_url str ''
paper_text str ''
title str ''
spec_id str ''
algorithm_name str ''
impl_id str ''
source_code str ''
language str 'python'
test_type str ''
test_code str ''
examples_json str ''
properties_json str ''
report_id str ''
claims_json str ''
config_key str ''
config_value str ''
reviewer str ''
review_decision Literal['approve', 'reject', ''] ''
limit int 50
offset int 0
backend str ''
native_action str ''
request_id str ''
task_id str ''
run_id str ''

MCPLibrarySynthesizerOutput(BaseModel)

Field Type Default
op str ''
key str ''
value str ''
found bool False
count int 0
records list[MCPLibrarySynthesizerRecord] Field(default_factory=list)
content str ''
scores list[float] Field(default_factory=list)
message str ''
metadata dict[str, Any] Field(default_factory=dict)
degraded bool False
degradation_reason str ''
capability_status str 'available'
completion_state Literal['verified', 'qualified-draft', 'blocked-escalated'] 'qualified-draft'
warning_card dict[str, Any] Field(default_factory=dict)
evidence list[dict[str, Any]] Field(default_factory=list)
request_id str ''
task_id str ''
run_id str ''
review_status Literal['unreviewed', 'expert_review_required', 'approved', 'rejected'] 'unreviewed'
reviewer str ''

LibrarySynthesizerStore

SQLite-backed store for the adapt_library_synthesizer MCP sub-package.

Constructor:

Parameter Type Default
db_path str ':memory:'

Methods:

add_paper(url: str = '', title: str = '', content: str = '', source: str = '') -> str

get_paper(paper_id: str) -> dict[str, Any] | None

list_papers(limit: int = 50, offset: int = 0) -> list[dict[str, Any]]

count_papers() -> int

add_spec(paper_id: str = '', name: str = '', inputs: list[str] | None = None, outputs: list[str] | None = None, steps: list[str] | None = None, invariants: list[str] | None = None, complexity: str = '', hyperparameters: dict | None = None) -> str

get_spec(spec_id: str) -> dict[str, Any] | None

list_specs(limit: int = 50, offset: int = 0) -> list[dict[str, Any]]

find_spec_by_name(name: str) -> dict[str, Any] | None

add_implementation(spec_id: str = '', source_code: str = '', language: str = 'python', quality_tier: str = 'template', validated: bool = False, validation_errors: str = '') -> str

get_implementation(impl_id: str) -> dict[str, Any] | None

get_implementation_by_spec(spec_id: str) -> dict[str, Any] | None

update_implementation(impl_id: str, source_code: str = '', validated: bool | None = None, validation_errors: str = '') -> None

add_test_result(impl_id: str = '', test_type: str = '', passed: int = 0, failed: int = 0, errors: list[str] | None = None) -> str

get_test_results(impl_id: str) -> list[dict[str, Any]]

add_report(spec_id: str = '', impl_id: str = '', status: str = '', files: list[str] | None = None, discrepancies: list[str] | None = None) -> str

get_report(report_id: str) -> dict[str, Any] | None

list_reports(limit: int = 50, offset: int = 0) -> list[dict[str, Any]]

count_all() -> dict[str, int]

get_config() -> SynthesizerConfig

Read stored config overrides and apply to defaults.

set_config_key(key: str, value: str) -> None

Upsert a single config key.

reset_config() -> None

Delete all config rows, reverting to defaults.

AdaptLibrarySynthesizerMCPBlock(AIBlock[MCPLibrarySynthesizerInput, MCPLibrarySynthesizerOutput, dict])

Field Type Default
name str 'adapt_library_synthesizer_mcp'
db_path str field(default_factory=lambda: _DEFAULT_DB)

Methods:

store() -> LibrarySynthesizerStore

infer(data: MCPLibrarySynthesizerInput) -> Result[MCPLibrarySynthesizerOutput]

Functions

agentic_planner_enabled(default_enabled: bool = True) -> bool

Decide whether the agentic spec-extraction planner should be used.

validate_spec_recommendation(rec: dict) -> dict

Reject any spec recommendation outside the canonical shape / Tier-1 bounds.

extract_spec_floor(paper_text: str, algorithm_name: str = '') -> AlgorithmSpec

Deterministic regex spec extractor (the honest floor).

MCP Tools

Operation Source
fetch_paper library_synthesizer_mcp
extract_algorithm library_synthesizer_mcp
extract_benchmarks library_synthesizer_mcp
extract_datasets library_synthesizer_mcp
parse_spec library_synthesizer_mcp
generate_implementation library_synthesizer_mcp
validate_syntax library_synthesizer_mcp
validate_types library_synthesizer_mcp
refine_implementation library_synthesizer_mcp
check_implementation_quality library_synthesizer_mcp
get_implementation library_synthesizer_mcp
generate_tests_from_examples library_synthesizer_mcp
generate_tests_from_properties library_synthesizer_mcp
generate_edge_case_tests library_synthesizer_mcp
run_tests library_synthesizer_mcp
get_test_results library_synthesizer_mcp
create_report library_synthesizer_mcp
get_report library_synthesizer_mcp
list_reports library_synthesizer_mcp
compare_to_paper_claims library_synthesizer_mcp
export_report library_synthesizer_mcp
deep_compare library_synthesizer_mcp
list_specs library_synthesizer_mcp
get_spec library_synthesizer_mcp
retry_synthesis library_synthesizer_mcp
set_llm_config library_synthesizer_mcp
library_synthesizer_info library_synthesizer_mcp
list_patterns library_synthesizer_mcp
native_capability_info library_synthesizer_mcp
native_paper_fetch_preview library_synthesizer_mcp
native_code_source_trace library_synthesizer_mcp
native_pytest_validate library_synthesizer_mcp
native_storage_inspect library_synthesizer_mcp
approve library_synthesizer_mcp
reject library_synthesizer_mcp
`` library_synthesizer_mcp
unreviewed library_synthesizer_mcp
expert_review_required library_synthesizer_mcp
approved library_synthesizer_mcp
rejected library_synthesizer_mcp