Skip to main content

harn_stdlib/
lib.rs

1//! Canonical embedded Harn standard library source catalog.
2//!
3//! This crate intentionally contains only static source strings so runtime and
4//! static tooling crates can share the same stdlib modules without depending on
5//! each other.
6
7#[derive(Debug, Clone, Copy, PartialEq, Eq)]
8pub struct StdlibSource {
9    pub module: &'static str,
10    pub source: &'static str,
11}
12
13#[derive(Debug, Clone, Copy, PartialEq, Eq)]
14pub struct StdlibPromptAsset {
15    pub path: &'static str,
16    pub source: &'static str,
17}
18
19#[derive(Debug, Clone, PartialEq, Eq)]
20pub struct StdlibPublicFunction {
21    pub name: String,
22    pub signature: String,
23    pub required_params: usize,
24    pub total_params: usize,
25    pub variadic: bool,
26    pub doc: Option<String>,
27}
28
29#[derive(Debug, Clone, PartialEq, Eq)]
30pub struct StdlibEntrypointModule {
31    pub import_path: String,
32    pub category: String,
33}
34
35pub const STDLIB_SOURCES: &[StdlibSource] = &[
36    StdlibSource {
37        module: "text",
38        source: include_str!("stdlib/stdlib_text.harn"),
39    },
40    StdlibSource {
41        module: "collections",
42        source: include_str!("stdlib/stdlib_collections.harn"),
43    },
44    StdlibSource {
45        module: "math",
46        source: include_str!("stdlib/stdlib_math.harn"),
47    },
48    StdlibSource {
49        module: "path",
50        source: include_str!("stdlib/stdlib_path.harn"),
51    },
52    StdlibSource {
53        module: "json",
54        source: include_str!("stdlib/stdlib_json.harn"),
55    },
56    StdlibSource {
57        module: "tools",
58        source: include_str!("stdlib/stdlib_tools.harn"),
59    },
60    StdlibSource {
61        module: "graphql",
62        source: include_str!("stdlib/stdlib_graphql.harn"),
63    },
64    StdlibSource {
65        module: "schema",
66        source: include_str!("stdlib/stdlib_schema.harn"),
67    },
68    StdlibSource {
69        module: "testing",
70        source: include_str!("stdlib/stdlib_testing.harn"),
71    },
72    StdlibSource {
73        module: "files",
74        source: include_str!("stdlib/stdlib_files.harn"),
75    },
76    StdlibSource {
77        module: "vision",
78        source: include_str!("stdlib/stdlib_vision.harn"),
79    },
80    StdlibSource {
81        module: "context",
82        source: include_str!("stdlib/stdlib_context.harn"),
83    },
84    StdlibSource {
85        module: "runtime",
86        source: include_str!("stdlib/stdlib_runtime.harn"),
87    },
88    StdlibSource {
89        module: "review",
90        source: include_str!("stdlib/stdlib_review.harn"),
91    },
92    StdlibSource {
93        module: "experiments",
94        source: include_str!("stdlib/stdlib_experiments.harn"),
95    },
96    StdlibSource {
97        module: "project",
98        source: include_str!("stdlib/stdlib_project.harn"),
99    },
100    StdlibSource {
101        module: "prompt_library",
102        source: include_str!("stdlib/stdlib_prompt_library.harn"),
103    },
104    StdlibSource {
105        module: "async",
106        source: include_str!("stdlib/stdlib_async.harn"),
107    },
108    StdlibSource {
109        module: "agents",
110        source: include_str!("stdlib/stdlib_agents.harn"),
111    },
112    StdlibSource {
113        module: "agent/prompts",
114        source: include_str!("stdlib/agent/prompts.harn"),
115    },
116    StdlibSource {
117        module: "llm/media",
118        source: include_str!("stdlib/llm/media.harn"),
119    },
120    StdlibSource {
121        module: "agent/options",
122        source: include_str!("stdlib/agent/options.harn"),
123    },
124    StdlibSource {
125        module: "agent/events",
126        source: include_str!("stdlib/agent/events.harn"),
127    },
128    StdlibSource {
129        module: "agent/primitives",
130        source: include_str!("stdlib/agent/primitives.harn"),
131    },
132    StdlibSource {
133        module: "agent/loop",
134        source: include_str!("stdlib/agent/loop.harn"),
135    },
136    StdlibSource {
137        module: "agent/tool_search",
138        source: include_str!("stdlib/agent/tool_search.harn"),
139    },
140    StdlibSource {
141        module: "agent/turn",
142        source: include_str!("stdlib/agent/turn.harn"),
143    },
144    StdlibSource {
145        module: "agent/workers",
146        source: include_str!("stdlib/agent/workers.harn"),
147    },
148    StdlibSource {
149        module: "agent/state",
150        source: include_str!("stdlib/agent/state.harn"),
151    },
152    StdlibSource {
153        module: "agent/skills",
154        source: include_str!("stdlib/agent/skills.harn"),
155    },
156    StdlibSource {
157        module: "agent/autocompact",
158        source: include_str!("stdlib/agent/autocompact.harn"),
159    },
160    StdlibSource {
161        module: "agent/mcp",
162        source: include_str!("stdlib/agent/mcp.harn"),
163    },
164    StdlibSource {
165        module: "agent/host_tools",
166        source: include_str!("stdlib/agent/host_tools.harn"),
167    },
168    StdlibSource {
169        module: "agent/budget",
170        source: include_str!("stdlib/agent/budget.harn"),
171    },
172    StdlibSource {
173        module: "agent/daemon",
174        source: include_str!("stdlib/agent/daemon.harn"),
175    },
176    StdlibSource {
177        module: "agent/preflight",
178        source: include_str!("stdlib/agent/preflight.harn"),
179    },
180    StdlibSource {
181        module: "agent/postturn",
182        source: include_str!("stdlib/agent/postturn.harn"),
183    },
184    StdlibSource {
185        module: "agent/judge",
186        source: include_str!("stdlib/agent/judge.harn"),
187    },
188    StdlibSource {
189        module: "agent_state",
190        source: include_str!("stdlib/stdlib_agent_state.harn"),
191    },
192    StdlibSource {
193        module: "memory",
194        source: include_str!("stdlib/stdlib_memory.harn"),
195    },
196    StdlibSource {
197        module: "postgres",
198        source: include_str!("stdlib/stdlib_postgres.harn"),
199    },
200    StdlibSource {
201        module: "checkpoint",
202        source: include_str!("stdlib/stdlib_checkpoint.harn"),
203    },
204    StdlibSource {
205        module: "host",
206        source: include_str!("stdlib/stdlib_host.harn"),
207    },
208    StdlibSource {
209        module: "git",
210        source: include_str!("stdlib/stdlib_git.harn"),
211    },
212    StdlibSource {
213        module: "hitl",
214        source: include_str!("stdlib/stdlib_hitl.harn"),
215    },
216    StdlibSource {
217        module: "trust",
218        source: include_str!("stdlib/stdlib_trust.harn"),
219    },
220    StdlibSource {
221        module: "corrections",
222        source: include_str!("stdlib/stdlib_corrections.harn"),
223    },
224    StdlibSource {
225        module: "plan",
226        source: include_str!("stdlib/stdlib_plan.harn"),
227    },
228    StdlibSource {
229        module: "waitpoints",
230        source: include_str!("stdlib/stdlib_waitpoints.harn"),
231    },
232    StdlibSource {
233        module: "waitpoint",
234        source: include_str!("stdlib/stdlib_waitpoint.harn"),
235    },
236    StdlibSource {
237        module: "monitors",
238        source: include_str!("stdlib/stdlib_monitors.harn"),
239    },
240    StdlibSource {
241        module: "worktree",
242        source: include_str!("stdlib/stdlib_worktree.harn"),
243    },
244    StdlibSource {
245        module: "acp",
246        source: include_str!("stdlib/stdlib_acp.harn"),
247    },
248    StdlibSource {
249        module: "triggers",
250        source: include_str!("stdlib/stdlib_triggers.harn"),
251    },
252    StdlibSource {
253        module: "handoffs",
254        source: include_str!("stdlib/stdlib_handoffs.harn"),
255    },
256    StdlibSource {
257        module: "personas/prelude",
258        source: include_str!("stdlib/stdlib_personas_prelude.harn"),
259    },
260    StdlibSource {
261        module: "connectors/shared",
262        source: include_str!("stdlib/stdlib_connectors_shared.harn"),
263    },
264    StdlibSource {
265        module: "connectors/github",
266        source: include_str!("stdlib/stdlib_connectors_github.harn"),
267    },
268    StdlibSource {
269        module: "connectors/linear",
270        source: include_str!("stdlib/stdlib_connectors_linear.harn"),
271    },
272    StdlibSource {
273        module: "connectors/notion",
274        source: include_str!("stdlib/stdlib_connectors_notion.harn"),
275    },
276    StdlibSource {
277        module: "connectors/slack",
278        source: include_str!("stdlib/stdlib_connectors_slack.harn"),
279    },
280    StdlibSource {
281        module: "workflow/prompts",
282        source: include_str!("stdlib/workflow/prompts.harn"),
283    },
284    StdlibSource {
285        module: "workflow/context",
286        source: include_str!("stdlib/workflow/context.harn"),
287    },
288    StdlibSource {
289        module: "workflow/options",
290        source: include_str!("stdlib/workflow/options.harn"),
291    },
292    StdlibSource {
293        module: "workflow/checkpoints",
294        source: include_str!("stdlib/workflow/checkpoints.harn"),
295    },
296    StdlibSource {
297        module: "workflow/stage",
298        source: include_str!("stdlib/workflow/stage.harn"),
299    },
300    StdlibSource {
301        module: "workflow/map",
302        source: include_str!("stdlib/workflow/map.harn"),
303    },
304    StdlibSource {
305        module: "workflow/schedule",
306        source: include_str!("stdlib/workflow/schedule.harn"),
307    },
308    StdlibSource {
309        module: "workflow/execute",
310        source: include_str!("stdlib/workflow/execute.harn"),
311    },
312];
313
314pub const STDLIB_PROMPT_ASSETS: &[StdlibPromptAsset] = &[
315    StdlibPromptAsset {
316        path: "agent/prompts/tool_contract_text.harn.prompt",
317        source: include_str!("stdlib/agent/prompts/tool_contract_text.harn.prompt"),
318    },
319    StdlibPromptAsset {
320        path: "agent/prompts/tool_contract_native.harn.prompt",
321        source: include_str!("stdlib/agent/prompts/tool_contract_native.harn.prompt"),
322    },
323    StdlibPromptAsset {
324        path: "agent/prompts/tool_contract_text_response_protocol.harn.prompt",
325        source: include_str!(
326            "stdlib/agent/prompts/tool_contract_text_response_protocol.harn.prompt"
327        ),
328    },
329    StdlibPromptAsset {
330        path: "agent/prompts/tool_contract_action_native.harn.prompt",
331        source: include_str!("stdlib/agent/prompts/tool_contract_action_native.harn.prompt"),
332    },
333    StdlibPromptAsset {
334        path: "agent/prompts/tool_contract_action_text.harn.prompt",
335        source: include_str!("stdlib/agent/prompts/tool_contract_action_text.harn.prompt"),
336    },
337    StdlibPromptAsset {
338        path: "agent/prompts/tool_contract_task_ledger.harn.prompt",
339        source: include_str!("stdlib/agent/prompts/tool_contract_task_ledger.harn.prompt"),
340    },
341    StdlibPromptAsset {
342        path: "agent/prompts/tool_contract_deferred_tools.harn.prompt",
343        source: include_str!("stdlib/agent/prompts/tool_contract_deferred_tools.harn.prompt"),
344    },
345    StdlibPromptAsset {
346        path: "agent/prompts/deferred_tool_listing.harn.prompt",
347        source: include_str!("stdlib/agent/prompts/deferred_tool_listing.harn.prompt"),
348    },
349    StdlibPromptAsset {
350        path: "agent/prompts/action_turn_nudge.harn.prompt",
351        source: include_str!("stdlib/agent/prompts/action_turn_nudge.harn.prompt"),
352    },
353    StdlibPromptAsset {
354        path: "agent/prompts/agent_turn_preamble.harn.prompt",
355        source: include_str!("stdlib/agent/prompts/agent_turn_preamble.harn.prompt"),
356    },
357    StdlibPromptAsset {
358        path: "agent/prompts/default_nudge.harn.prompt",
359        source: include_str!("stdlib/agent/prompts/default_nudge.harn.prompt"),
360    },
361    StdlibPromptAsset {
362        path: "agent/prompts/loop_until_done_system.harn.prompt",
363        source: include_str!("stdlib/agent/prompts/loop_until_done_system.harn.prompt"),
364    },
365    StdlibPromptAsset {
366        path: "agent/prompts/completion_judge_default.harn.prompt",
367        source: include_str!("stdlib/agent/prompts/completion_judge_default.harn.prompt"),
368    },
369    StdlibPromptAsset {
370        path: "agent/prompts/completion_judge_feedback_fallback.harn.prompt",
371        source: include_str!("stdlib/agent/prompts/completion_judge_feedback_fallback.harn.prompt"),
372    },
373    StdlibPromptAsset {
374        path: "agent/prompts/completion_judge_user.harn.prompt",
375        source: include_str!("stdlib/agent/prompts/completion_judge_user.harn.prompt"),
376    },
377    StdlibPromptAsset {
378        path: "agent/prompts/parse_guidance.harn.prompt",
379        source: include_str!("stdlib/agent/prompts/parse_guidance.harn.prompt"),
380    },
381    StdlibPromptAsset {
382        path: "agent/prompts/protocol_violation_feedback.harn.prompt",
383        source: include_str!("stdlib/agent/prompts/protocol_violation_feedback.harn.prompt"),
384    },
385    StdlibPromptAsset {
386        path: "agent/prompts/native_tool_contract_feedback.harn.prompt",
387        source: include_str!("stdlib/agent/prompts/native_tool_contract_feedback.harn.prompt"),
388    },
389    StdlibPromptAsset {
390        path: "agent/prompts/verification_gate_feedback.harn.prompt",
391        source: include_str!("stdlib/agent/prompts/verification_gate_feedback.harn.prompt"),
392    },
393    StdlibPromptAsset {
394        path: "agent/prompts/action_required_feedback.harn.prompt",
395        source: include_str!("stdlib/agent/prompts/action_required_feedback.harn.prompt"),
396    },
397    StdlibPromptAsset {
398        path: "agent/prompts/daemon_watch_feedback.harn.prompt",
399        source: include_str!("stdlib/agent/prompts/daemon_watch_feedback.harn.prompt"),
400    },
401    StdlibPromptAsset {
402        path: "agent/prompts/daemon_timer_feedback.harn.prompt",
403        source: include_str!("stdlib/agent/prompts/daemon_timer_feedback.harn.prompt"),
404    },
405    StdlibPromptAsset {
406        path: "llm/prompts/completion_fallback_system.harn.prompt",
407        source: include_str!("stdlib/llm/prompts/completion_fallback_system.harn.prompt"),
408    },
409    StdlibPromptAsset {
410        path: "llm/prompts/completion_fallback_user.harn.prompt",
411        source: include_str!("stdlib/llm/prompts/completion_fallback_user.harn.prompt"),
412    },
413    StdlibPromptAsset {
414        path: "llm/prompts/transcript_summarize_user.harn.prompt",
415        source: include_str!("stdlib/llm/prompts/transcript_summarize_user.harn.prompt"),
416    },
417    StdlibPromptAsset {
418        path: "llm/prompts/structural_chain_of_draft.harn.prompt",
419        source: include_str!("stdlib/llm/prompts/structural_chain_of_draft.harn.prompt"),
420    },
421    StdlibPromptAsset {
422        path: "llm/prompts/schema_recover_repair.harn.prompt",
423        source: include_str!("stdlib/llm/prompts/schema_recover_repair.harn.prompt"),
424    },
425    StdlibPromptAsset {
426        path: "llm/prompts/structured_envelope_schema_contract.harn.prompt",
427        source: include_str!("stdlib/llm/prompts/structured_envelope_schema_contract.harn.prompt"),
428    },
429    StdlibPromptAsset {
430        path: "llm/prompts/structured_envelope_repair.harn.prompt",
431        source: include_str!("stdlib/llm/prompts/structured_envelope_repair.harn.prompt"),
432    },
433    StdlibPromptAsset {
434        path: "workflow/prompts/stage.harn.prompt",
435        source: include_str!("stdlib/workflow/prompts/stage.harn.prompt"),
436    },
437    StdlibPromptAsset {
438        path: "workflow/prompts/verification_context_intro.harn.prompt",
439        source: include_str!("stdlib/workflow/prompts/verification_context_intro.harn.prompt"),
440    },
441    StdlibPromptAsset {
442        path: "orchestration/prompts/compaction_summary.harn.prompt",
443        source: include_str!("stdlib/orchestration/prompts/compaction_summary.harn.prompt"),
444    },
445];
446
447pub fn get_stdlib_source(module: &str) -> Option<&'static str> {
448    STDLIB_SOURCES
449        .iter()
450        .find_map(|entry| (entry.module == module).then_some(entry.source))
451}
452
453pub fn get_stdlib_prompt_asset(path: &str) -> Option<&'static str> {
454    let path = path.strip_prefix("std/").unwrap_or(path);
455    STDLIB_PROMPT_ASSETS
456        .iter()
457        .find_map(|entry| (entry.path == path).then_some(entry.source))
458}
459
460pub fn public_functions_for_module(module: &str) -> Vec<StdlibPublicFunction> {
461    let Some(source) = get_stdlib_source(module) else {
462        return Vec::new();
463    };
464    public_functions_from_source(source)
465}
466
467pub fn entrypoint_modules() -> Vec<StdlibEntrypointModule> {
468    STDLIB_SOURCES
469        .iter()
470        .filter_map(|entry| {
471            entrypoint_category_from_source(entry.source).map(|category| StdlibEntrypointModule {
472                import_path: format!("std/{}", entry.module),
473                category,
474            })
475        })
476        .collect()
477}
478
479fn entrypoint_category_from_source(source: &str) -> Option<String> {
480    for line in source.lines() {
481        let line = line.trim();
482        if line.is_empty() {
483            continue;
484        }
485        if let Some(category) = line.strip_prefix("// @harn-entrypoint-category ") {
486            let category = category.trim();
487            return (!category.is_empty()).then(|| category.to_string());
488        }
489        if !line.starts_with("//") {
490            return None;
491        }
492    }
493    None
494}
495
496fn public_functions_from_source(source: &str) -> Vec<StdlibPublicFunction> {
497    let mut out = Vec::new();
498    let mut doc: Option<String> = None;
499    let lines = source.lines().collect::<Vec<_>>();
500    let mut index = 0usize;
501    while index < lines.len() {
502        let line = lines[index].trim();
503        if line.starts_with("/**") {
504            let (parsed, next) = parse_harndoc(&lines, index);
505            doc = parsed;
506            index = next;
507            continue;
508        }
509        if let Some(function) = parse_public_function_line(line, doc.take()) {
510            out.push(function);
511        } else if !line.is_empty() && !line.starts_with("//") {
512            doc = None;
513        }
514        index += 1;
515    }
516    out
517}
518
519fn parse_harndoc(lines: &[&str], start: usize) -> (Option<String>, usize) {
520    let mut parts = Vec::new();
521    let mut index = start;
522    while index < lines.len() {
523        let mut line = lines[index].trim();
524        if index == start {
525            line = line.trim_start_matches("/**").trim();
526        }
527        let done = line.ends_with("*/");
528        line = line.trim_end_matches("*/").trim();
529        line = line.trim_start_matches('*').trim();
530        if !line.is_empty() {
531            parts.push(line.to_string());
532        }
533        index += 1;
534        if done {
535            break;
536        }
537    }
538    let text = parts.join("\n").trim().to_string();
539    ((!text.is_empty()).then_some(text), index)
540}
541
542fn parse_public_function_line(line: &str, doc: Option<String>) -> Option<StdlibPublicFunction> {
543    let rest = line.strip_prefix("pub fn ")?.trim();
544    let name_end = rest.find('(')?;
545    let name = rest[..name_end].trim();
546    if name.is_empty() {
547        return None;
548    }
549    let params_start = name_end + 1;
550    let params_len = matching_paren_len(&rest[params_start..])?;
551    let params = &rest[params_start..params_start + params_len];
552    let after = rest[params_start + params_len + 1..].trim();
553    let return_type = after
554        .strip_prefix("->")
555        .and_then(|tail| tail.split('{').next())
556        .map(str::trim)
557        .filter(|value| !value.is_empty());
558    let signature = match return_type {
559        Some(ret) => format!("{name}({params}) -> {ret}"),
560        None => format!("{name}({params})"),
561    };
562    let param_parts = split_top_level_params(params);
563    let total_params = param_parts
564        .iter()
565        .filter(|param| !param.trim().is_empty())
566        .count();
567    let variadic = param_parts
568        .iter()
569        .any(|param| param.trim_start().starts_with("..."));
570    let required_params = param_parts
571        .iter()
572        .filter(|param| {
573            let param = param.trim();
574            !param.is_empty() && !param.contains('=') && !param.starts_with("...")
575        })
576        .count();
577    Some(StdlibPublicFunction {
578        name: name.to_string(),
579        signature,
580        required_params,
581        total_params,
582        variadic,
583        doc,
584    })
585}
586
587fn matching_paren_len(input: &str) -> Option<usize> {
588    let mut depth = 1usize;
589    for (offset, ch) in input.char_indices() {
590        match ch {
591            '(' | '[' | '{' => depth += 1,
592            ')' => {
593                depth = depth.saturating_sub(1);
594                if depth == 0 {
595                    return Some(offset);
596                }
597            }
598            ']' | '}' => depth = depth.saturating_sub(1),
599            _ => {}
600        }
601    }
602    None
603}
604
605fn split_top_level_params(params: &str) -> Vec<&str> {
606    let mut out = Vec::new();
607    let mut depth = 0isize;
608    let mut start = 0usize;
609    for (offset, ch) in params.char_indices() {
610        match ch {
611            '(' | '[' | '{' => depth += 1,
612            ')' | ']' | '}' => depth -= 1,
613            ',' if depth == 0 => {
614                out.push(&params[start..offset]);
615                start = offset + 1;
616            }
617            _ => {}
618        }
619    }
620    out.push(&params[start..]);
621    out
622}
623
624#[cfg(test)]
625mod tests {
626    use std::collections::BTreeSet;
627
628    use super::{
629        entrypoint_modules, get_stdlib_prompt_asset, get_stdlib_source,
630        public_functions_for_module, STDLIB_PROMPT_ASSETS, STDLIB_SOURCES,
631    };
632
633    #[test]
634    fn stdlib_sources_are_non_empty() {
635        for entry in STDLIB_SOURCES {
636            assert!(
637                !entry.source.trim().is_empty(),
638                "{} should have non-empty source",
639                entry.module
640            );
641        }
642    }
643
644    #[test]
645    fn stdlib_source_names_are_unique() {
646        let mut names = BTreeSet::new();
647        for entry in STDLIB_SOURCES {
648            assert!(names.insert(entry.module), "duplicate {}", entry.module);
649        }
650    }
651
652    #[test]
653    fn stdlib_prompt_assets_are_non_empty() {
654        for entry in STDLIB_PROMPT_ASSETS {
655            assert!(
656                !entry.source.trim().is_empty(),
657                "{} should have non-empty prompt asset source",
658                entry.path
659            );
660        }
661    }
662
663    #[test]
664    fn stdlib_prompt_asset_paths_are_unique() {
665        let mut paths = BTreeSet::new();
666        for entry in STDLIB_PROMPT_ASSETS {
667            assert!(paths.insert(entry.path), "duplicate {}", entry.path);
668        }
669    }
670
671    #[test]
672    fn key_stdlib_modules_resolve() {
673        for module in [
674            "context",
675            "waitpoint",
676            "personas/prelude",
677            "agent/host_tools",
678            "connectors/shared",
679            "connectors/github",
680            "connectors/linear",
681            "connectors/notion",
682            "connectors/slack",
683        ] {
684            assert!(
685                get_stdlib_source(module).is_some(),
686                "std/{module} should resolve"
687            );
688        }
689    }
690
691    #[test]
692    fn key_stdlib_prompt_assets_resolve() {
693        for path in [
694            "std/agent/prompts/tool_contract_text.harn.prompt",
695            "std/agent/prompts/action_turn_nudge.harn.prompt",
696            "std/agent/prompts/completion_judge_default.harn.prompt",
697            "std/workflow/prompts/stage.harn.prompt",
698            "std/orchestration/prompts/compaction_summary.harn.prompt",
699        ] {
700            assert!(
701                get_stdlib_prompt_asset(path).is_some(),
702                "{path} should resolve"
703            );
704        }
705    }
706
707    #[test]
708    fn public_function_catalog_derives_signatures_from_harn_source() {
709        let exports = public_functions_for_module("workflow/execute");
710        assert_eq!(exports.len(), 1);
711        assert_eq!(exports[0].name, "workflow_execute");
712        assert_eq!(
713            exports[0].signature,
714            "workflow_execute(task, graph, artifacts = nil, options = nil)"
715        );
716        assert_eq!(exports[0].required_params, 2);
717        assert_eq!(exports[0].total_params, 4);
718    }
719
720    #[test]
721    fn harn_entrypoint_catalog_is_declared_by_stdlib_sources() {
722        let modules = entrypoint_modules();
723        let entries = modules
724            .iter()
725            .map(|module| (module.import_path.as_str(), module.category.as_str()))
726            .collect::<BTreeSet<_>>();
727        for entry in [
728            ("std/agent/loop", "agent.stdlib"),
729            ("std/agent/turn", "agent.stdlib"),
730            ("std/agent/primitives", "agent.stdlib"),
731            ("std/workflow/execute", "workflow.stdlib"),
732        ] {
733            assert!(entries.contains(&entry), "{entry:?} should be declared");
734        }
735    }
736}