frontierlab

    A MoonBit algorithm trace protocol and offline HTML/SVG visualization kit.

    algorithm
    trace
    visualization
    education
    svg
    html
    Download zip
    Author
    Version
    0.5.0
    License
    MIT
    Last updated
    4 months ago
    Downloads
    214

    #FrontierLab

    A MoonBit Algorithm Trace & Visualization Kit — record why an algorithm changes, then replay what changed.

    CI Mooncakes

    Insertion sortUnion-FindA* frontier
    Insertion sort traceUnion-Find traceA star trace

    #中文

    FrontierLab 不是另一个算法合集,也不是通用绘图库。它为 MoonBit 算法提供统一的语义事件 + 场景快照协议:算法记录 Compare、Swap、Visit、Union、Relax 等事件,同时提交这一刻的序列、集合、图或网格状态;渲染器再把记录导出为可离线播放的 HTML、确定性 SVG 或 JSON。

    #为什么值得用

    • 任意步骤随机跳转,不需要从头重放事件。
    • 事件保留“为什么变化”,场景保留“应该画什么”。
    • 生成的 HTML 不依赖 CDN、Node.js、服务器或浏览器插件。
    • 稳定实体 ID 让元素在交换、合并和寻路过程中仍可追踪。
    • analyze() 可在渲染前统计事件、目标引用、对象规模和完成状态。
    • 原有 BFS、Dijkstra、A*、ASCII/SVG API 完整保留。

    #五分钟体验

    无需安装即可打开在线 Playground,拖入或粘贴 schema-v1 JSON,完成校验、质量诊断、分析、回放和 SVG 导出。所有处理均在浏览器本地完成。

    moon check --target all moon test # 生成可交互的单文件 HTML moon run cmd/main -- demo insertion-sort --format html --output insertion-sort.html moon run cmd/main -- demo union-find --format html --output union-find.html moon run cmd/main -- demo pathfinding --format html --output pathfinding.html # 也可以输出 SVG 或 JSON;使用 - 输出到标准输出 moon run cmd/main -- demo pathfinding --format svg --output pathfinding.svg moon run cmd/main -- demo insertion-sort --format json --output trace.json moon run cmd/main -- analyze trace.json moon run cmd/main -- validate trace.json moon run cmd/main -- render trace.json --format html --output replay.html # 生成完全离线的 Trace Playground moon run cmd/main -- playground --output playground.html

    浏览器直接打开生成的 HTML,即可使用播放、暂停、时间轴、速度控制以及左右方向键。

    #把任意算法接入可视化

    test {
    let initial = @frontierlab.Scene::new(objects=[
    @frontierlab.Sequence(@frontierlab.SequenceState::new(
    id="values",
    label="My algorithm",
    items=[
    @frontierlab.SequenceItem::new(id="a", value="3"),
    @frontierlab.SequenceItem::new(id="b", value="1"),
    ],
    )),
    ])
    let recorder = @frontierlab.TraceBuilder::new(
    title="Tiny trace",
    algorithm="my-algorithm",
    initial_scene=initial,
    )
    recorder.record(
    event=@frontierlab.Compare([
    @frontierlab.TargetRef::entity("values", "a"),
    @frontierlab.TargetRef::entity("values", "b"),
    ]),
    scene=initial,
    annotation=@frontierlab.Annotation::new(
    title="Compare",
    body="Compare the two stable entity ids.",
    ),
    )
    let html = @frontierlab.render_trace_html(recorder.finish())
    assert_true(html.contains("Tiny trace"))
    }

    完整接入方式见 docs/INTEGRATION.md。

    #渲染前分析 trace

    test {
    let trace = @frontierlab.insertion_sort_trace([3, 1, 2])
    let stats = trace.analyze()
    assert_eq(stats.event_count("compare"), 3)
    assert_eq(stats.event_count("swap"), 2)
    assert_true(stats.completed)
    assert_true(trace.summary_report().contains("Insertion Sort"))
    }

    #内置能力

    • AlgorithmTrace / AlgorithmTraceStep:版本化 trace 文档与不可变步骤快照。
    • TargetRef:使用对象 ID + 可选实体 ID,消除跨对象同名实体歧义。
    • encode_json / decode_json / validate:稳定 schema-v1 双向协议与完整验证。
    • TraceEvent:初始化、比较、交换、访问、更新、合并、松弛、完成及自定义事件。
    • SceneObject:Sequence、Sets、Graph、Grid。
    • Highlight / Annotation:统一视觉角色、教学说明和伪代码行号。
    • render_trace_html:自包含、响应式、支持深浅主题的交互播放器。
    • render_trace_playground:自包含的 trace 导入、校验、分析、回放与 SVG 导出工作台。
    • render_trace_svg / render_trace_svg_frames:单帧与批量确定性 SVG。
    • TraceStats / EventCount / ObjectUsage / TargetUsage:事件统计、对象规模和目标引用分析。
    • insertion_sort_trace / union_find_trace:可复用算法适配器,不只是内置 demo。
    • search_trace_to_algorithm_trace:原有路径搜索 trace 的兼容适配器。

    #旗舰示例

    moon run examples/insertion_sort > insertion-sort.html moon run examples/union_find > union-find.html moon run examples/pathfinding_trace > pathfinding.html # 原有教学示例仍可运行 moon run examples/maze_bfs moon run examples/weighted_astar moon run examples/compare

    #与相邻项目的区别

    • 绘图库解决“如何画”;FrontierLab 定义“算法过程如何记录和解释”。
    • 图算法库解决“如何计算”;FrontierLab 不要求算法属于图领域。
    • 性能 tracing 记录耗时和调用区间;FrontierLab 记录 compare、swap、union、relax 等教学语义。
    • 可视化页面只是消费者;AlgorithmTrace JSON 可继续接入课程、IDE、评测平台或视频生成工具。

    #English

    FrontierLab records algorithm semantics and complete visual scenes in MoonBit. An algorithm emits events such as Compare, Swap, Union, or Relax and snapshots a sequence, set, graph, or grid. The same trace can then become an offline interactive HTML player, deterministic SVG frames, or portable JSON.

    The original pathfinding APIs remain compatible. BFS, Dijkstra, and A* now serve as a flagship adapter alongside insertion sort and Union-Find.

    #Public API map

    • Build: TraceBuilder::new, record, finish
    • Model: AlgorithmTrace, TraceEvent, Scene, SceneObject
    • Visual state: SequenceState, SetState, GraphState, GridState
    • Explain: Highlight, HighlightRole, Annotation
    • Export: render_trace_html, render_trace_svg, render_trace_svg_frames
    • Playground: render_trace_playground
    • Analyze: AlgorithmTrace::analyze, summary_report, event_counts, target_usage
    • Adapt: insertion_sort_trace, union_find_trace, search_trace_to_algorithm_trace

    #Development and release readiness

    moon check --target all --deny-warn moon build --target all --deny-warn moon fmt --check moon info git diff --exit-code moon test --target all --deny-warn

    moon fmt --deny-warn and moon info --deny-warn are not valid MoonBit commands in the current documented toolchain. CI therefore uses moon fmt --check and moon info && git diff --exit-code as the reviewable equivalents.

    The repository includes CI, generated interfaces, executable examples, an offline trace playground, a Pages deployment workflow, schema fixtures, an MIT license, contribution guidance, and mooncakes publishing metadata.

    #Documentation

    #License

    MIT

    TraceError

    pub(all) suberror TraceError {
    JsonSyntax(String)
    UnsupportedSchema(String)
    DuplicateId(String)
    DanglingReference(TargetRef)
    InvalidGraph(String)
    InvalidGrid(String)
    InvalidStep(String)
    DuplicateSummaryKey(String)
    AlreadyCompleted
    LimitExceeded(String)
    } derive(Eq,
    Debug
    )

    impl Show for TraceError

    TraceError::message

    fn TraceError::message(self : TraceError) -> String

    AlgorithmReport

    pub struct AlgorithmReport {
    algorithm : String
    reachable : Bool
    visited_count : Int
    path_length : Int
    total_cost : Int
    } derive(Eq, ToJson,
    Debug
    )

    AlgorithmReport::from_result

    fn AlgorithmReport::from_result(algorithm : String, result : PathResult) -> AlgorithmReport

    AlgorithmTrace

    pub struct AlgorithmTrace {
    schema_version : String
    title : String
    algorithm : String
    description : String
    initial_scene : Scene
    steps : Array[AlgorithmTraceStep]
    summary : Array[TraceAttribute]
    } derive(Eq, ToJson,
    Debug
    )

    AlgorithmTrace::analysis_markdown

    fn AlgorithmTrace::analysis_markdown(self : AlgorithmTrace, target_limit? : Int) -> String

    AlgorithmTrace::analyze

    AlgorithmTrace::decode_json

    fn AlgorithmTrace::decode_json(input : StringView) -> AlgorithmTrace raise TraceError

    Decode and validate the stable FrontierLab schema-v1 wire format.

    AlgorithmTrace::encode_json

    fn AlgorithmTrace::encode_json(self : AlgorithmTrace) -> String

    Encode the stable FrontierLab schema-v1 wire format.

    AlgorithmTrace::event_counts

    fn AlgorithmTrace::event_counts(self : AlgorithmTrace) -> Array[EventCount]

    AlgorithmTrace::has_lint_errors

    fn AlgorithmTrace::has_lint_errors(self : AlgorithmTrace) -> Bool

    AlgorithmTrace::has_lint_warnings

    fn AlgorithmTrace::has_lint_warnings(self : AlgorithmTrace) -> Bool

    AlgorithmTrace::lint

    Run non-throwing quality checks that complement AlgorithmTrace::validate.

    AlgorithmTrace::lint_count

    fn AlgorithmTrace::lint_count(self : AlgorithmTrace, severity : TraceLintSeverity) -> Int

    AlgorithmTrace::lint_markdown

    fn AlgorithmTrace::lint_markdown(self : AlgorithmTrace) -> String

    AlgorithmTrace::lint_report

    fn AlgorithmTrace::lint_report(self : AlgorithmTrace) -> String

    AlgorithmTrace::object_usage

    fn AlgorithmTrace::object_usage(self : AlgorithmTrace) -> Array[ObjectUsage]

    AlgorithmTrace::summary_report

    fn AlgorithmTrace::summary_report(self : AlgorithmTrace) -> String

    AlgorithmTrace::target_usage

    fn AlgorithmTrace::target_usage(self : AlgorithmTrace) -> Array[TargetUsage]

    AlgorithmTrace::timeline

    AlgorithmTrace::timeline_report

    fn AlgorithmTrace::timeline_report(self : AlgorithmTrace) -> String

    AlgorithmTrace::timeline_table

    fn AlgorithmTrace::timeline_table(self : AlgorithmTrace) -> String

    AlgorithmTrace::to_json_string

    fn AlgorithmTrace::to_json_string(self : AlgorithmTrace) -> String

    AlgorithmTrace::validate

    fn AlgorithmTrace::validate(self : AlgorithmTrace, options? : TraceOptions) -> Unit raise TraceError

    AlgorithmTraceStep

    pub struct AlgorithmTraceStep {
    index : Int
    event : TraceEvent
    scene : Scene
    annotation : Annotation?
    } derive(Eq, ToJson,
    Debug
    )

    Annotation

    pub struct Annotation {
    title : String
    body : String
    pseudocode_line : Int?
    } derive(Eq, ToJson,
    Debug
    )

    Annotation::new

    fn Annotation::new(title~ : String, body~ : String, pseudocode_line? : Int) -> Annotation

    CompareReport

    pub struct CompareReport {
    entries : Array[AlgorithmReport]
    } derive(Eq, ToJson,
    Debug
    )

    CostEntry

    pub struct CostEntry {
    position : Position
    cost : Int
    } derive(Eq, ToJson,
    Debug
    )

    CostEntry::new

    fn CostEntry::new(position~ : Position, cost~ : Int) -> CostEntry

    EventCount

    pub struct EventCount {
    name : String
    count : Int
    first_step : Int
    last_step : Int
    } derive(Eq, ToJson,
    Debug
    )

    A counted event kind in an AlgorithmTrace.

    EventCount::new

    fn EventCount::new(name~ : String, count? : Int, first_step? : Int, last_step? : Int) -> EventCount

    GraphEdge

    pub struct GraphEdge {
    id : String
    from : String
    to : String
    label : String
    directed : Bool
    } derive(Eq, ToJson,
    Debug
    )

    GraphEdge::new

    fn GraphEdge::new(id~ : String, from~ : String, to~ : String, label? : String, directed? : Bool) -> GraphEdge

    GraphNode

    pub struct GraphNode {
    id : String
    label : String
    } derive(Eq, ToJson,
    Debug
    )

    GraphNode::new

    fn GraphNode::new(id~ : String, label~ : String) -> GraphNode

    GraphState

    pub struct GraphState {
    id : String
    label : String
    nodes : Array[GraphNode]
    edges : Array[GraphEdge]
    } derive(Eq, ToJson,
    Debug
    )

    GraphState::new

    fn GraphState::new(id~ : String, label~ : String, nodes~ : Array[GraphNode], edges~ : Array[GraphEdge]) -> GraphState raise TraceError

    GridCellState

    pub struct GridCellState {
    id : String
    x : Int
    y : Int
    label : String
    blocked : Bool
    } derive(Eq, ToJson,
    Debug
    )

    GridCellState::new

    fn GridCellState::new(id~ : String, x~ : Int, y~ : Int, label? : String, blocked? : Bool) -> GridCellState

    GridMap

    pub struct GridMap {
    width : Int
    height : Int
    obstacles : Array[Position]
    weights : Array[WeightedCell]
    } derive(Eq, ToJson,
    Debug
    )

    GridMap::contains

    fn GridMap::contains(self : GridMap, position : Position) -> Bool

    GridMap::is_obstacle

    fn GridMap::is_obstacle(self : GridMap, position : Position) -> Bool

    GridMap::is_walkable

    fn GridMap::is_walkable(self : GridMap, position : Position) -> Bool

    GridMap::neighbors

    fn GridMap::neighbors(self : GridMap, position : Position, rule : MoveRule) -> Array[Position]

    GridMap::new

    fn GridMap::new(width~ : Int, height~ : Int) -> GridMap raise

    GridMap::weight_at

    fn GridMap::weight_at(self : GridMap, position : Position) -> Int

    GridMap::with_obstacle

    fn GridMap::with_obstacle(self : GridMap, position : Position) -> GridMap raise

    GridMap::with_weight

    fn GridMap::with_weight(self : GridMap, position : Position, weight : Int) -> GridMap raise

    GridState

    pub struct GridState {
    id : String
    label : String
    width : Int
    height : Int
    cells : Array[GridCellState]
    } derive(Eq, ToJson,
    Debug
    )

    GridState::new

    fn GridState::new(id~ : String, label~ : String, width~ : Int, height~ : Int, cells~ : Array[GridCellState]) -> GridState raise TraceError

    Heuristic

    pub(all) enum Heuristic {
    Manhattan
    Chebyshev
    Zero
    } derive(Eq, ToJson,
    Debug
    )

    Highlight

    pub struct Highlight {
    target : TargetRef
    role : HighlightRole
    } derive(Eq, ToJson,
    Debug
    )

    Highlight::new

    fn Highlight::new(target~ : TargetRef, role~ : HighlightRole) -> Highlight

    HighlightRole

    pub(all) enum HighlightRole {
    Current
    Candidate
    Compared
    Changed
    Visited
    Frontier
    Result
    Error
    } derive(Eq, ToJson,
    Debug
    )

    MoveRule

    pub(all) enum MoveRule {
    FourDirections
    EightDirections
    } derive(Eq, ToJson,
    Debug
    )

    ObjectUsage

    pub struct ObjectUsage {
    object_id : String
    object_kind : String
    appearances : Int
    max_entities : Int
    first_step : Int
    last_step : Int
    } derive(Eq, ToJson,
    Debug
    )

    Object-level usage collected across the initial scene and every step scene.

    ObjectUsage::new

    fn ObjectUsage::new(object_id~ : String, object_kind~ : String, appearances? : Int, max_entities? : Int, first_step? : Int, last_step? : Int) -> ObjectUsage

    pub struct ParentLink {
    child : Position
    parent : Position
    } derive(Eq, ToJson,
    Debug
    )

    ParentLink::new

    fn ParentLink::new(child~ : Position, parent~ : Position) -> ParentLink

    PathResult

    pub struct PathResult {
    reachable : Bool
    path : Array[Position]
    cost : Int
    visited_count : Int
    } derive(Eq, ToJson,
    Debug
    )

    PathResult::found

    fn PathResult::found(path~ : Array[Position], cost~ : Int, visited_count~ : Int) -> PathResult

    PathResult::not_found

    fn PathResult::not_found(visited_count~ : Int) -> PathResult

    Position

    pub struct Position {
    x : Int
    y : Int
    } derive(Eq, ToJson,
    Debug
    )

    Position::new

    fn Position::new(x~ : Int, y~ : Int) -> Position

    Scene

    pub struct Scene {
    objects : Array[SceneObject]
    highlights : Array[Highlight]
    } derive(Eq, ToJson,
    Debug
    )

    Scene::new

    fn Scene::new(objects~ : Array[SceneObject], highlights? : Array[Highlight]) -> Scene raise TraceError

    SceneObject

    pub(all) enum SceneObject {
    Sequence(SequenceState)
    Sets(SetState)
    Graph(GraphState)
    Grid(GridState)
    } derive(Eq, ToJson,
    Debug
    )

    SearchTrace

    pub struct SearchTrace {
    result : PathResult
    steps : Array[TraceStep]
    } derive(Eq, ToJson,
    Debug
    )

    SearchTrace::new

    fn SearchTrace::new(result~ : PathResult, steps~ : Array[TraceStep]) -> SearchTrace

    SequenceItem

    pub struct SequenceItem {
    id : String
    value : String
    } derive(Eq, ToJson,
    Debug
    )

    SequenceItem::new

    fn SequenceItem::new(id~ : String, value~ : String) -> SequenceItem

    SequenceState

    pub struct SequenceState {
    id : String
    label : String
    items : Array[SequenceItem]
    } derive(Eq, ToJson,
    Debug
    )

    SequenceState::new

    fn SequenceState::new(id~ : String, label~ : String, items~ : Array[SequenceItem]) -> SequenceState

    SetGroup

    pub struct SetGroup {
    id : String
    label : String
    members : Array[String]
    } derive(Eq, ToJson,
    Debug
    )

    SetGroup::new

    fn SetGroup::new(id~ : String, label~ : String, members~ : Array[String]) -> SetGroup

    SetState

    pub struct SetState {
    id : String
    label : String
    groups : Array[SetGroup]
    } derive(Eq, ToJson,
    Debug
    )

    SetState::new

    fn SetState::new(id~ : String, label~ : String, groups~ : Array[SetGroup]) -> SetState

    SortTraceItem

    pub struct SortTraceItem {
    id : String
    value : Int
    label : String
    } derive(Eq, ToJson,
    Debug
    )

    One stable value in a sortable sequence trace.

    SortTraceItem::new

    fn SortTraceItem::new(id~ : String, value~ : Int, label? : String) -> SortTraceItem

    TargetRef

    pub struct TargetRef {
    object_id : String
    entity_id : String?
    } derive(Eq, ToJson,
    Debug
    ,
    FromJson
    )

    A scoped reference to either a scene object or one entity inside it.

    TargetRef::entity

    fn TargetRef::entity(object_id : String, entity_id : String) -> TargetRef

    TargetRef::object

    fn TargetRef::object(object_id : String) -> TargetRef

    TargetUsage

    pub struct TargetUsage {
    object_id : String
    entity_id : String?
    references : Int
    event_references : Int
    highlight_references : Int
    first_step : Int
    last_step : Int
    event_names : Array[String]
    highlight_roles : Array[String]
    } derive(Eq, ToJson,
    Debug
    )

    Target-level references observed in semantic events and visual highlights.

    TargetUsage::new

    fn TargetUsage::new(object_id~ : String, entity_id? : String, references? : Int, event_references? : Int, highlight_references? : Int, first_step? : Int, last_step? : Int, event_names? : Array[String], highlight_roles? : Array[String]) -> TargetUsage

    TraceAttribute

    pub struct TraceAttribute {
    key : String
    value : String
    } derive(Eq, ToJson,
    Debug
    )

    A stable key/value attribute used by custom events and summaries.

    TraceAttribute::new

    fn TraceAttribute::new(key~ : String, value~ : String) -> TraceAttribute

    TraceBuilder

    pub struct TraceBuilder {
    title : String
    algorithm : String
    description : String
    initial_scene : Scene
    steps : Array[AlgorithmTraceStep]
    options : TraceOptions
    completed : Bool
    } derive(
    Debug
    )

    Mutable recorder that stores immutable scene snapshots.

    TraceBuilder::finish

    fn TraceBuilder::finish(self : TraceBuilder, summary? : Array[TraceAttribute]) -> AlgorithmTrace raise TraceError

    TraceBuilder::new

    fn TraceBuilder::new(title~ : String, algorithm~ : String, description? : String, initial_scene~ : Scene, options? : TraceOptions) -> TraceBuilder raise TraceError

    TraceBuilder::record

    fn TraceBuilder::record(self : TraceBuilder, event~ : TraceEvent, scene~ : Scene, annotation? : Annotation) -> Unit raise TraceError

    TraceEvent

    pub(all) enum TraceEvent {
    Initialize
    Compare(Array[TargetRef])
    Swap(TargetRef, TargetRef)
    Visit(TargetRef)
    Update(TargetRef, String)
    Union(TargetRef, TargetRef)
    Relax(TargetRef, TargetRef, String)
    Complete
    Custom(String, Array[TraceAttribute])
    } derive(Eq, ToJson,
    Debug
    )

    The semantic reason why an algorithm produced a new scene.

    TraceLintIssue

    pub struct TraceLintIssue {
    severity : TraceLintSeverity
    code : String
    message : String
    step : Int
    } derive(Eq, ToJson,
    Debug
    )

    A non-throwing quality observation for a trace document.

    TraceLintIssue::is_error

    fn TraceLintIssue::is_error(self : TraceLintIssue) -> Bool

    TraceLintIssue::is_info

    fn TraceLintIssue::is_info(self : TraceLintIssue) -> Bool

    TraceLintIssue::is_warning

    fn TraceLintIssue::is_warning(self : TraceLintIssue) -> Bool

    TraceLintIssue::line

    fn TraceLintIssue::line(self : TraceLintIssue) -> String

    TraceLintIssue::markdown_row

    fn TraceLintIssue::markdown_row(self : TraceLintIssue) -> String

    TraceLintIssue::new

    fn TraceLintIssue::new(severity~ : TraceLintSeverity, code~ : String, message~ : String, step? : Int) -> TraceLintIssue

    TraceLintIssue::severity_name

    fn TraceLintIssue::severity_name(self : TraceLintIssue) -> String

    TraceLintSeverity

    pub(all) enum TraceLintSeverity {
    Info
    Warning
    Error
    } derive(Eq, ToJson,
    Debug
    )

    Severity for lightweight trace quality checks.

    TraceOptions

    pub struct TraceOptions {
    max_steps : Int
    max_entities_per_scene : Int
    } derive(Eq, ToJson,
    Debug
    ,
    FromJson
    )

    TraceOptions::default

    fn TraceOptions::default() -> TraceOptions

    TraceOptions::new

    fn TraceOptions::new(max_steps? : Int, max_entities_per_scene? : Int) -> TraceOptions raise TraceError

    TraceStats

    pub struct TraceStats {
    title : String
    algorithm : String
    step_count : Int
    completed : Bool
    event_counts : Array[EventCount]
    object_usage : Array[ObjectUsage]
    target_usage : Array[TargetUsage]
    initial_object_count : Int
    max_objects_per_scene : Int
    max_entities_per_scene : Int
    summary_count : Int
    annotation_count : Int
    custom_event_count : Int
    highlight_count : Int
    } derive(Eq, ToJson,
    Debug
    )

    Summary of a full trace document, suitable for docs, CLI output, or CI smoke checks before rendering.

    TraceStats::event_count

    fn TraceStats::event_count(self : TraceStats, name : String) -> Int

    TraceStats::event_table

    fn TraceStats::event_table(self : TraceStats) -> String

    Render the event section of TraceStats as a Markdown table.

    TraceStats::object_count

    fn TraceStats::object_count(self : TraceStats, object_id : String) -> Int

    TraceStats::object_table

    fn TraceStats::object_table(self : TraceStats) -> String

    Render the object section of TraceStats as a Markdown table.

    TraceStats::summary_report

    fn TraceStats::summary_report(self : TraceStats) -> String

    TraceStats::target_count

    fn TraceStats::target_count(self : TraceStats, object_id : String, entity_id? : String) -> Int

    TraceStats::target_table

    fn TraceStats::target_table(self : TraceStats, limit? : Int) -> String

    Render the most referenced targets as a Markdown table.

    TraceStats::to_markdown

    fn TraceStats::to_markdown(self : TraceStats, target_limit? : Int) -> String

    Render the full analysis as Markdown for READMEs, reports, and CI artifacts.

    TraceStats::top_targets

    fn TraceStats::top_targets(self : TraceStats, limit? : Int) -> Array[TargetUsage]

    TraceStep

    pub struct TraceStep {
    current : Position?
    frontier : Array[Position]
    visited : Array[Position]
    cost : Array[CostEntry]
    parent : Array[ParentLink]
    } derive(Eq, ToJson,
    Debug
    )

    TraceStep::new

    fn TraceStep::new(current~ : Position?, frontier~ : Array[Position], visited~ : Array[Position], cost~ : Array[CostEntry], parent~ : Array[ParentLink]) -> TraceStep

    TraceTimelineEntry

    pub struct TraceTimelineEntry {
    step : Int
    event_name : String
    target_count : Int
    object_count : Int
    entity_count : Int
    highlight_count : Int
    annotation_title : String
    completed : Bool
    } derive(Eq, ToJson,
    Debug
    )

    A compact row describing one renderable point in a trace timeline.

    TraceTimelineEntry::label

    fn TraceTimelineEntry::label(self : TraceTimelineEntry) -> String

    TraceTimelineEntry::markdown_row

    fn TraceTimelineEntry::markdown_row(self : TraceTimelineEntry) -> String

    TraceTimelineEntry::new

    fn TraceTimelineEntry::new(step~ : Int, event_name~ : String, target_count~ : Int, object_count~ : Int, entity_count~ : Int, highlight_count~ : Int, annotation_title? : String, completed? : Bool) -> TraceTimelineEntry

    UnionOperation

    pub struct UnionOperation {
    left : Int
    right : Int
    label : String
    } derive(Eq, ToJson,
    Debug
    )

    One union operation for the Union-Find trace adapter.

    UnionOperation::new

    fn UnionOperation::new(left~ : Int, right~ : Int, label? : String) -> UnionOperation

    WeightedCell

    type WeightedCell derive(Eq, ToJson,
    Debug
    )

    astar

    fn astar(grid : GridMap, start~ : Position, goal~ : Position, rule? : MoveRule, heuristic? : Heuristic) -> PathResult raise

    astar_trace

    fn astar_trace(grid : GridMap, start~ : Position, goal~ : Position, rule? : MoveRule, heuristic? : Heuristic) -> SearchTrace raise

    bfs

    fn bfs(grid : GridMap, start~ : Position, goal~ : Position, rule? : MoveRule) -> PathResult raise

    bfs_trace

    fn bfs_trace(grid : GridMap, start~ : Position, goal~ : Position, rule? : MoveRule) -> SearchTrace raise

    compare_algorithms

    fn compare_algorithms(grid : GridMap, start~ : Position, goal~ : Position, rule? : MoveRule, heuristic? : Heuristic) -> CompareReport raise

    dijkstra

    fn dijkstra(grid : GridMap, start~ : Position, goal~ : Position, rule? : MoveRule) -> PathResult raise

    dijkstra_trace

    fn dijkstra_trace(grid : GridMap, start~ : Position, goal~ : Position, rule? : MoveRule) -> SearchTrace raise

    export_ascii

    fn export_ascii(grid : GridMap, start~ : Position, goal~ : Position, trace? : SearchTrace) -> String

    export_svg

    fn export_svg(grid : GridMap, start~ : Position, goal~ : Position, trace? : SearchTrace, cell_size? : Int) -> String

    heuristic_distance

    fn heuristic_distance(kind : Heuristic, from : Position, to : Position) -> Int

    insertion_sort_demo_trace

    fn insertion_sort_demo_trace(values : Array[Int]) -> AlgorithmTrace raise

    Build the insertion-sort trace used by the bundled demo and CLI.

    insertion_sort_items_trace

    fn insertion_sort_items_trace(items : Array[SortTraceItem], title? : String, object_id? : String, label? : String) -> AlgorithmTrace raise TraceError

    Build an insertion-sort trace while preserving caller-provided stable item ids. Stable ids make animated swaps and external annotations deterministic.

    insertion_sort_trace

    fn insertion_sort_trace(values : Array[Int], title? : String, object_id? : String, label? : String) -> AlgorithmTrace raise TraceError

    Build a reusable insertion-sort trace from plain integer values.

    pathfinding_demo_trace

    fn pathfinding_demo_trace() -> AlgorithmTrace raise

    Build the A* flagship trace used by the bundled demo and CLI.

    project_name

    let project_name : String

    Human-readable project name.

    render_trace_html

    fn render_trace_html(trace : AlgorithmTrace) -> String

    Render a trace as a self-contained offline HTML player.

    render_trace_playground

    fn render_trace_playground() -> String raise TraceError

    Render a self-contained offline playground for importing, validating, analyzing, replaying, and exporting schema-v1 trace documents.

    render_trace_svg

    fn render_trace_svg(trace : AlgorithmTrace, step? : Int, width? : Int) -> String raise

    Render one trace frame as a deterministic, standalone SVG document.

    render_trace_svg_frames

    fn render_trace_svg_frames(trace : AlgorithmTrace, width? : Int) -> Array[String] raise

    Render every recorded step. An empty trace yields its initial scene.

    search_trace_to_algorithm_trace

    fn search_trace_to_algorithm_trace(grid : GridMap, start~ : Position, goal~ : Position, algorithm~ : String, trace~ : SearchTrace) -> AlgorithmTrace raise

    Convert a legacy path-search trace into the generic visualization protocol.

    union_find_demo_trace

    fn union_find_demo_trace() -> AlgorithmTrace raise

    Build the Union-Find trace used by the bundled demo and CLI.

    union_find_trace

    fn union_find_trace(size : Int, operations : Array[UnionOperation], title? : String, object_id? : String, label? : String, compress_paths? : Bool) -> AlgorithmTrace raise TraceError

    Build a reusable Union-Find trace from a size and an ordered operation list.