fermilink.optimize.goal module

Parse goal.md into a structured optimization goal specification.

Goal mode lets users describe optimization intent in natural-language markdown instead of authoring a benchmark YAML contract and runner script by hand. This module parses the structured markdown into a dict that the source-analysis / benchmark-generation pipeline can consume.

fermilink.optimize.goal.is_goal_markdown(text)[source]

Return True when text looks like a goal-structured markdown file.

Detection is based on the presence of at least two known goal-section headings. This intentionally stays loose so that users can omit optional sections while still triggering goal mode.

Parameters:

text (str)

Return type:

bool

fermilink.optimize.goal.parse_goal(text)[source]

Parse a goal markdown document into a structured specification.

Returns a dict with the following keys (all strings or lists of strings; missing sections default to empty):

  • raw_text – the original markdown

  • package – package identifier (first line of ## Package)

  • target – free-text optimization target description

  • editable_scope – list of file-path globs the agent may edit

  • performance_metric – description of the metric to optimise

  • correctness_constraints – list of correctness requirements

  • workloads – list of representative workload descriptions

  • language – optional language hint (python, cpp, fortran, …)

  • notes – optional free-form notes

  • build_commands – optional build/install commands from code blocks

Parameters:

text (str)

Return type:

dict[str, Any]