fermilink.optimize.source_analysis module

Prompt templates and output extraction for goal-driven source analysis.

Goal mode runs two preparatory agent turns before the optimisation loop:

  1. Source analysis – the agent reads the target package source code guided by the goal specification and outputs a structured JSON analysis of the API surface, output quantities, configuration parameters, discovered test cases, threading model, and build system.

  2. Benchmark generation – the agent takes the analysis plus the goal and writes benchmark.yaml and benchmark_runner.py to the autogen directory following FermiLink’s benchmark contract.

Both turns use temporary_optimize_agents for workspace-instruction scoping and _run_exec_chat_turn for execution.

fermilink.optimize.source_analysis.build_benchmark_generation_agents_md(*, goal_rel, analysis_rel, autogen_rel)[source]

AGENTS.md for the benchmark-generation agent turn.

The agent reads the goal and analysis, writes benchmark.yaml and benchmark_runner.py to the autogen directory.

Parameters:
  • goal_rel (str)

  • analysis_rel (str)

  • autogen_rel (str)

Return type:

str

fermilink.optimize.source_analysis.build_benchmark_generation_prompt(*, goal_spec, goal_rel, analysis, analysis_rel, language, runner_template, benchmark_template, autogen_benchmark_rel, autogen_runner_rel, controller_timeout_seconds=None)[source]

Build the prompt for the benchmark-generation agent turn.

The agent uses the source analysis and goal to generate both benchmark.yaml and benchmark_runner.py that conform to the FermiLink benchmark contract.

Parameters:
  • goal_spec (dict[str, Any])

  • goal_rel (str)

  • analysis (dict[str, Any])

  • analysis_rel (str)

  • language (str)

  • runner_template (str)

  • benchmark_template (str)

  • autogen_benchmark_rel (str)

  • autogen_runner_rel (str)

  • controller_timeout_seconds (int | None)

Return type:

str

fermilink.optimize.source_analysis.build_source_analysis_agents_md(*, goal_rel, autogen_rel)[source]

AGENTS.md for the source-analysis agent turn.

The agent may read any file in the repo but may only write to the autogen directory.

Parameters:
  • goal_rel (str)

  • autogen_rel (str)

Return type:

str

fermilink.optimize.source_analysis.build_source_analysis_prompt(*, goal_spec, goal_rel, language, tracked_file_summary)[source]

Build the prompt for the source-analysis agent turn.

The agent reads the repo source code and produces a structured JSON analysis of the target package suitable for benchmark generation.

Parameters:
  • goal_spec (dict[str, Any])

  • goal_rel (str)

  • language (str)

  • tracked_file_summary (str)

Return type:

str

fermilink.optimize.source_analysis.extract_analysis_summary(text)[source]

Extract a human-readable analysis summary from assistant text.

Parameters:

text (str)

Return type:

str | None

fermilink.optimize.source_analysis.extract_benchmark_yaml(text)[source]

Extract the generated benchmark YAML from assistant text.

Parameters:

text (str)

Return type:

str | None

fermilink.optimize.source_analysis.extract_review_notes(text)[source]

Extract review-recommended notes from assistant text.

Parameters:

text (str)

Return type:

str | None

fermilink.optimize.source_analysis.extract_runner_script(text)[source]

Extract the generated benchmark runner script from assistant text.

Parameters:

text (str)

Return type:

str | None

fermilink.optimize.source_analysis.extract_source_analysis(text)[source]

Extract structured JSON source-analysis from assistant text.

Parameters:

text (str)

Return type:

dict[str, Any] | None