uchrom.auto_discovery¶
Multi-omics auto-discovery helpers for ChromData.
- class uchrom.auto_discovery.AnalysisCodeResult(analysis_code: str, agent_records: list[BackendAgentRecord] = <factory>, extra_cells: list[dict[str, ~typing.Any]]=<factory>, artifact_manifest: list[dict[str, ~typing.Any]]=<factory>, warnings: list[str] = <factory>, notes: list[str] = <factory>)[source]¶
Bases:
objectStructured analysis code returned by a backend.
- agent_records: list[BackendAgentRecord]¶
- class uchrom.auto_discovery.BackendAgentRecord(agent_name: str, role: str, prompt_path: str, content: Any)[source]¶
Bases:
objectAudit record for one backend invocation.
- class uchrom.auto_discovery.BackendCapabilities(structured_output: bool, file_workspace: bool, prompt_via_stdin: bool, streaming: bool, native_skill_loading: bool = False, resume: bool = False, owns_notebook_lifecycle: bool = False)[source]¶
Bases:
objectCapabilities reported by an auto-discovery backend.
- class uchrom.auto_discovery.BackendDetection(backend_id: str, executable_path: str | None, version: str | None = None, available: bool = False, auth_state: str = 'unknown', error: str | None = None, cli_flags: Mapping[str, bool]=<factory>)[source]¶
Bases:
objectBest-effort local CLI detection result.
- exception uchrom.auto_discovery.BackendError(message: str, *, category: str, retryable: bool)[source]¶
Bases:
RuntimeErrorA classified backend failure.
categoryis one ofbackend_unavailable(missing/exited binary or an auth failure that a retry will not fix),failed(ran but exited non-zero for another reason),bad_output(ran but produced output that could not be parsed), ortimeout.retryabletells the run loop whether a transient retry is worthwhile.
- class uchrom.auto_discovery.CLISpec(backend_id: str, display_name: str, executable: str, build_command: Any, stream_format: str, run_environment: Any = <function _default_run_environment>, fallback_bins: tuple[str, ...]=(), capability_probe: Mapping[str, str]=<factory>)[source]¶
Bases:
objectData describing one stdin-driven coding-agent CLI backend.
Per-CLI differences are expressed as data here rather than as subclass overrides, mirroring open-design’s data-driven adapter model: the generic
CLIBackendconsumes a spec and the core never branches on backend id.
- class uchrom.auto_discovery.ClaimRefreshResult(mode: str, claims_path: str | None, retrieval_log_path: str, n_claims: int, source_paths: list[str], notes: list[str])[source]¶
Bases:
objectSummary of one claim-refresh pass.
- class uchrom.auto_discovery.DiscoveryDirection(direction_id: str, direction_type: str, priority: float, title: str, prompt: str, rationale: str, target_facets: dict[str, ~typing.Any]=<factory>, parent_idea_ids: list[str] = <factory>, evidence_basis: list[dict[str, ~typing.Any]]=<factory>, novelty_notes: list[str] = <factory>, constraints: list[str] = <factory>)[source]¶
Bases:
objectA graph-derived search direction for the next idea-agent batch.
- class uchrom.auto_discovery.DiscoveryEnrichmentConfig(fasta: str | Path | None = None, sequence_features: list[str] | None = None, gtf: str | Path | None = None, annotation_features: list[str] | None = None, promoter_window: tuple[int, int]=(-2000, 500), structures: list[str] = <factory>, project_existing_structure: bool = False, chroms: list[str] | None = None, device: str = 'auto', peak_tracks: list[str] = <factory>, peak_control_tracks: list[str] = <factory>, peak_method: str = 'auto', peak_agg: str = 'mean', peak_threshold: float | None = None, peak_quantile: float = 0.95, peak_cutoff: float | None = None, peak_min_length: int = 200, peak_max_gap: int = 30, peak_qvalue: float | None = 0.05, peak_pvalue: float | None = None, peak_genome_size: float | None = None, peak_small_local_window_bins: int = 10, peak_large_local_window_bins: int = 100, peak_fragment_size_bins: int = 1, peak_min_width_bins: int = 1, peak_max_gap_bins: int = 0, peak_signal_scale: float = 1.0, peak_control_scale: float | None = None, peak_negative: str = 'clip', peak_nolambda: bool = False, project: bool = True, overwrite: bool = False, hash_sources: bool = True, verbose: bool = False)[source]¶
Bases:
objectOptional feature-enrichment inputs for an auto-discovery run.
- uchrom.auto_discovery.DiscoveryFrontier¶
alias of
DiscoveryDirection
- class uchrom.auto_discovery.DiscoveryIdea(idea_title: str, biological_hypothesis: str, computable_parameter: str, analysis_plan: str, modalities: list[str], idea_markdown: str = '', cell_types: list[str] = <factory>, required_fields: list[str] = <factory>, validation_checks: list[str] = <factory>, expected_direction: str = '', complexity: int = 3, idea_id: str = '', metadata: dict[str, ~typing.Any] = <factory>)[source]¶
Bases:
objectA computable multi-omics discovery idea.
- class uchrom.auto_discovery.DiscoveryRunConfig(h5cd_path: str | Path, output_dir: str | Path, max_ideas: int = 12, accepted_idea_target: int | None = None, max_generation_attempts: int = 3, ideas_path: str | Path | None = None, max_complexity: int = 5, idea_source: str = 'pantheon', code_source: str = 'pantheon', model: str | None = None, reasoning_effort: str | None = None, llm_timeout: int = 420, idea_agent_count: int = 3, notebook_agent_concurrency: int = 3, generate_schematic_image: bool = False, schematic_image_model: str | None = None, schematic_image_model_args: dict[str, ~typing.Any] | None=None, execute: bool = True, stop_on_error: bool = False, store_schema: bool = False, dataset_name: str | None = None, enrichment: dict[str, ~typing.Any] | None=None, prior_graph_path: str | Path | None = None, direction_context_path: str | Path | None = None, frontier_context_path: str | Path | None = None, claims_paths: list[str | Path] = <factory>)[source]¶
Bases:
objectConfiguration for a local auto-discovery run.
- class uchrom.auto_discovery.DiscoveryRunResult(output_dir: str, n_generated: int, n_accepted: int, n_executed: int, n_verified: int, report_path: str, ideas_path: str, reviews_path: str, results_path: str, notebooks: list[str] = <factory>, agent_records_path: str | None = None, graph_path: str | None = None, graph_summary_path: str | None = None, graph_html_path: str | None = None, directions_path: str | None = None, direction_summary_path: str | None = None, enriched_h5cd_path: str | None = None, enrichment_summary_path: str | None = None)[source]¶
Bases:
objectSummary of an auto-discovery run.
- class uchrom.auto_discovery.EvidenceConclusion(notebook_status: str, hypothesis_status: str, direction_status: str, p_value: float | None, effect_size: float | None, summary: str)[source]¶
Bases:
objectHuman-readable evidence classification for one explored idea.
- class uchrom.auto_discovery.IdeaGraph(graph_id: str = 'idea_graph', nodes: dict[str, dict[str, ~typing.Any]]=<factory>, edges: list[dict[str, ~typing.Any]]=<factory>)[source]¶
Bases:
objectA JSON-serializable graph of discovery ideas and evidence.
- add_edge(source: str, relation: str, target: str, **attrs: Any) dict[str, Any][source]¶
Add a typed edge unless the same edge already exists.
- class uchrom.auto_discovery.IdeaReview(accepted: bool, errors: list[str] = <factory>, warnings: list[str] = <factory>, missing_fields: list[str] = <factory>)[source]¶
Bases:
objectResult of reviewing an idea against a discovery schema.
- class uchrom.auto_discovery.IterativeDiscoveryConfig(h5cd_path: str | Path, output_dir: str | Path, iterations: int = 2, ideas_per_iteration: int = 20, max_generation_attempts: int = 3, seed_run_dirs: list[str | Path] = <factory>, max_complexity: int = 5, idea_source: str = 'pantheon', code_source: str = 'pantheon', model: str | None = None, reasoning_effort: str | None = None, llm_timeout: int = 900, idea_agent_count: int = 4, notebook_agent_concurrency: int = 4, generate_schematic_image: bool = True, schematic_image_model: str | None = None, schematic_image_model_args: dict[str, ~typing.Any] | None=None, execute: bool = True, store_schema: bool = False, dataset_name: str | None = None, enrichment: dict[str, ~typing.Any] | None=None, knowledge_mode: str = 'knowledge_guided', claims_paths: list[str | Path] = <factory>)[source]¶
Bases:
objectConfiguration for repeated auto-discovery iterations.
- class uchrom.auto_discovery.IterativeDiscoveryResult(output_dir: str, run_dirs: list[str], iteration_results: list[~uchrom.auto_discovery.runner.DiscoveryRunResult], graph_path: str, graph_summary_path: str, directions_path: str, direction_summary_path: str, html_path: str, claim_refresh_results: list[~uchrom.auto_discovery.claims.ClaimRefreshResult] = <factory>)[source]¶
Bases:
objectSummary of a multi-iteration auto-discovery run.
- claim_refresh_results: list[ClaimRefreshResult]¶
- iteration_results: list[DiscoveryRunResult]¶
- uchrom.auto_discovery.allowed_required_fields(schema: Mapping[str, Any], *, max_items: int) list[str][source]¶
Return schema field paths that agents may use in
required_fields.
- uchrom.auto_discovery.analysis_output_schema() dict[str, Any][source]¶
Return the structured-output schema for analysis-code backends.
- uchrom.auto_discovery.build_analysis_prompt(*, idea_path: Path, schema_path: Path, context_path: Path, h5cd_path: Path, output_dir: Path) str[source]¶
Build the structured analysis-code prompt used by CLI backends.
- uchrom.auto_discovery.build_discovery_schema(cdata, *, dataset_name: str | None = None, include_linked_adata: bool = True, max_catalog_items: int = 500) dict[str, Any][source]¶
Build an agent-readable schema from a
ChromDataobject.The returned dict is JSON-serializable and can be persisted via
pack_schema()undercd.uns['auto_discovery_schema'].
- uchrom.auto_discovery.build_idea_graph_from_run(run_dir: str | Path, *, graph_id: str | None = None, claims_paths: list[str | Path] | None = None) IdeaGraph[source]¶
Build an
IdeaGraphfrom a completed auto-discovery run.The function reads
ideas.jsonl,reviews.jsonl, andresults.jsonlwhen present. Missing files are tolerated so interrupted runs can still produce partial graph snapshots.
- uchrom.auto_discovery.build_idea_graph_from_runs(run_dirs: list[str | Path], *, graph_id: str = 'iterative_idea_graph', claims_paths: list[str | Path] | None = None) IdeaGraph[source]¶
Build one graph by merging several auto-discovery runs.
- uchrom.auto_discovery.build_idea_prompt(schema: Mapping[str, Any], *, max_ideas: int, prior_graph_path: str | Path | None = None, direction_context_path: str | Path | None = None) str[source]¶
Build the structured idea-generation prompt used by CLI backends.
- uchrom.auto_discovery.build_required_fields_prompt_block(schema: Mapping[str, Any], *, max_items: int = 80) str[source]¶
Build the legacy required-field guardrails shared by all idea backends.
- uchrom.auto_discovery.classify_hypothesis_evidence(idea: DiscoveryIdea | Mapping[str, Any], verification: Mapping[str, Any] | None, *, alpha: float = 0.05) EvidenceConclusion[source]¶
Classify whether a verified notebook supports the biological hypothesis.
verification.status == "pass"means U-Chrom could rerun the notebook and validate required fields, finite outputs, and an explicit statistical test. This function separately classifies the hypothesis evidence from p-value and effect direction so “verified” is not confused with “biologically true”.
- uchrom.auto_discovery.create_exploration_notebook(idea: DiscoveryIdea | Mapping[str, Any], output_path: str | Path, *, h5cd_path: str | Path | None = None, run_output_dir: str | Path | None = None, analysis_code: str | None = None, verification_code: str | None = None, kernel_name: str = 'python3') Path[source]¶
Create a standard exploration notebook for one idea.
The code agent is expected to edit and execute this notebook freely. The scaffold only defines the audit trail and verification contract.
- uchrom.auto_discovery.directions_to_agent_context(directions: list[DiscoveryDirection]) str[source]¶
Render directions as a Markdown prompt block for idea agents.
- uchrom.auto_discovery.enrich_for_discovery(cdata, config: DiscoveryEnrichmentConfig | dict[str, Any] | None = None, **kwargs) dict[str, Any][source]¶
Apply configured enrichment steps to
cdatain place and summarize them.
- uchrom.auto_discovery.execute_notebook_python(notebook_path: str | Path, *, stop_on_error: bool = False) dict[str, Any][source]¶
Execute Python code cells in a notebook JSON file.
This lightweight executor is intentionally small: it keeps a shared Python namespace across code cells, captures stdout/stderr/error text, writes outputs back into the notebook, and returns the final namespace entries commonly used by the auto-discovery runner. It is meant for deterministic smoke tests; Pantheon/Jupyter can still execute the same notebooks in richer interactive runs.
- uchrom.auto_discovery.frontiers_to_agent_context(frontiers: list[DiscoveryDirection]) str[source]¶
Legacy alias for
directions_to_agent_context().
- async uchrom.auto_discovery.generate_pantheon_ideas(schema: Mapping[str, Any], *, output_dir: str | Path, max_ideas: int, model: str | None = None, timeout: int = 420, idea_agent_count: int = 3, prior_graph_path: str | Path | None = None, direction_context_path: str | Path | None = None, frontier_context_path: str | Path | None = None) tuple[list[DiscoveryIdea], list[PantheonAgentRecord]][source]¶
Generate ideas by running multiple Pantheon idea agents in parallel.
Each idea agent receives only a file-access toolset. The schema and prompt are written to disk, and agents are instructed to read those files before returning DiscoveryIdea-compatible JSON.
- uchrom.auto_discovery.get_backend(backend_id: str) DiscoveryBackend[source]¶
Return a registered backend or raise a user-facing error.
- uchrom.auto_discovery.graph_summary_markdown(graph: IdeaGraph) str[source]¶
Render a compact Markdown summary for humans and agents.
- uchrom.auto_discovery.idea_output_schema(*, max_ideas: int | None = None) dict[str, Any][source]¶
Return the structured-output schema for idea-generation backends.
- uchrom.auto_discovery.idea_signature(idea: DiscoveryIdea | Mapping[str, Any]) dict[str, Any][source]¶
Return structured facets used for novelty and coverage review.
- uchrom.auto_discovery.idea_to_markdown(idea: DiscoveryIdea | Mapping[str, Any]) str[source]¶
Return a readable Markdown brief for a discovery idea.
- uchrom.auto_discovery.infer_parameter_family(idea: DiscoveryIdea | Mapping[str, Any]) str[source]¶
Infer a coarse parameter family from idea text.
- uchrom.auto_discovery.ingest_literature_claims(graph: IdeaGraph, claims_path: str | Path) int[source]¶
Ingest browser-agent literature claims into an
IdeaGraph.claims_pathis a JSONL file. Rows may containclaim_id,claimorclaim_text,source/source_title,url,doi,pmid,entities/genes,cell_types,markers,modalities,supports_idea_ids,contradicts_idea_ids, andrelated_idea_ids. Extra keys are kept on the claim node for auditability.
- uchrom.auto_discovery.load_idea_graph(path: str | Path) IdeaGraph[source]¶
Load an
IdeaGraphpreviously written withwrite_json.
- uchrom.auto_discovery.pack_schema(schema: Mapping[str, Any]) dict[str, str][source]¶
Pack a schema as an HDF5-friendly
unsentry.
- uchrom.auto_discovery.plan_discovery_directions(graph: IdeaGraph, schema: Mapping[str, Any], *, max_directions: int = 8, min_priority: float = 0.0) list[DiscoveryDirection][source]¶
Plan graph-aware directions for the next auto-discovery iteration.
The planner reads tested idea signatures, hypothesis evidence, and schema catalogs. It then proposes flexible search directions rather than fixed hard-coded buckets. The direction prompts tell idea agents what evidence to build on or what coverage gaps to fill, while still allowing free-form idea generation and notebook exploration.
- uchrom.auto_discovery.plan_discovery_frontiers(graph: IdeaGraph, schema: Mapping[str, Any], *, max_frontiers: int = 8, min_priority: float = 0.0) list[DiscoveryDirection][source]¶
Legacy alias for
plan_discovery_directions().
- uchrom.auto_discovery.refresh_literature_claims_for_iteration(*, run_dir: str | Path, schema: Mapping[str, Any], seed_claim_paths: Sequence[str | Path] | None = None, mode: str = 'knowledge_guided') ClaimRefreshResult[source]¶
Materialize per-iteration literature/user claims.
knowledge_guidedkeeps the run closed to network access and only normalizes existing source-backed claim caches plus h5cd references and user annotations.browser_refreshcurrently records that a network refresh was requested, then falls back to the same cached behavior; this keeps the iterative orchestrator ready for a real browser worker without silently inventing literature claims.
- uchrom.auto_discovery.register_backend(backend: DiscoveryBackend) None[source]¶
Register or replace one backend adapter.
- uchrom.auto_discovery.review_idea_against_schema(idea: DiscoveryIdea | Mapping[str, Any], schema: Mapping[str, Any], *, min_complexity: int = 1, max_complexity: int = 5) IdeaReview[source]¶
Check whether an idea is compatible with a discovery schema.
- uchrom.auto_discovery.run_auto_discovery(config: DiscoveryRunConfig | dict[str, Any]) DiscoveryRunResult[source]¶
Run schema → idea → notebook → verification for one
.h5cd.
- uchrom.auto_discovery.run_iterative_auto_discovery(config: IterativeDiscoveryConfig | dict[str, Any]) IterativeDiscoveryResult[source]¶
Run several graph-guided discovery iterations.
Each iteration runs
ideas_per_iterationideas. Before iteration 2 and later, the orchestrator builds a cumulative idea graph from seed and prior iteration runs, plans direction prompts, and passes those artifacts to the idea agents.
- async uchrom.auto_discovery.run_pantheon_notebook_agents(ideas: Sequence[DiscoveryIdea], *, schema: Mapping[str, Any], h5cd_path: str | Path, output_dir: str | Path, notebooks_dir: str | Path, model: str | None = None, timeout: int = 420, concurrency: int = 3, generate_schematic_image: bool = False, schematic_image_model: str | None = None, schematic_image_model_args: Mapping[str, Any] | None = None) list[PantheonAgentRecord][source]¶
Run notebook exploration agents in parallel for accepted ideas.
The caller is responsible for creating scaffold notebooks first. Each Pantheon notebook agent receives file-access and notebook toolsets, edits its assigned notebook, executes exploration cells, and returns a JSON status summary.
- uchrom.auto_discovery.schema_to_agent_context(schema: Mapping[str, Any], *, max_items: int = 40) str[source]¶
Render a compact, prompt-ready schema summary.
- uchrom.auto_discovery.schematic_coverage_for_run(run_dir: str | Path, *, verified_only: bool = True, max_images: int | None = None) dict[str, Any][source]¶
Return graphical-abstract coverage for a completed discovery run.
- uchrom.auto_discovery.structured_conclusion_markdown(idea: DiscoveryIdea | Mapping[str, Any], verification: Mapping[str, Any] | None) str[source]¶
Build the standard final interpretation Markdown for a notebook.
- uchrom.auto_discovery.unpack_schema(raw: Any) dict[str, Any][source]¶
Unpack a schema from
cd.uns['auto_discovery_schema'].
- uchrom.auto_discovery.unregister_backend(backend_id: str) None[source]¶
Remove a backend adapter if it is registered.
- uchrom.auto_discovery.upsert_structured_conclusion(notebook_path: str | Path, idea: DiscoveryIdea | Mapping[str, Any], verification: Mapping[str, Any] | None) Path[source]¶
Insert or replace the notebook’s final interpretation with standard text.
- uchrom.auto_discovery.validate_discovery_schema(schema: Mapping[str, Any], cdata=None) list[str][source]¶
Return validation issues for a discovery schema.
- uchrom.auto_discovery.write_direction_artifacts(directions: list[DiscoveryDirection], output_dir: str | Path, *, json_name: str = 'next_directions.json', markdown_name: str = 'next_directions.md', directory_name: str = 'directions') dict[str, str][source]¶
Write direction JSON and Markdown artifacts into
output_dir.
- uchrom.auto_discovery.write_frontier_artifacts(frontiers: list[DiscoveryDirection], output_dir: str | Path, *, json_name: str = 'next_frontiers.json', markdown_name: str = 'next_frontiers.md') dict[str, str][source]¶
Legacy writer that preserves the historical artifact keys and path.
- uchrom.auto_discovery.write_idea_graph_artifacts(graph: IdeaGraph, output_dir: str | Path, *, json_name: str = 'idea_graph.json', summary_name: str = 'graph_summary.md') dict[str, str][source]¶
Write graph JSON and Markdown summary into a run artifact directory.
- uchrom.auto_discovery.write_idea_graph_html(graph: IdeaGraph | str | Path, output_path: str | Path, *, title: str = 'U-Chrom Idea Graph', notebook_base_url: str | None = None) Path[source]¶
Write a self-contained Vue-powered interactive idea-graph viewer.
Schema¶
Agent-readable discovery schema for uchrom.core.ChromData.
The schema is intentionally stored inside cd.uns as a JSON payload so
it round-trips through .h5cd without requiring a new HDF5 layout.
- uchrom.auto_discovery.schema.build_discovery_schema(cdata, *, dataset_name: str | None = None, include_linked_adata: bool = True, max_catalog_items: int = 500) dict[str, Any][source]¶
Build an agent-readable schema from a
ChromDataobject.The returned dict is JSON-serializable and can be persisted via
pack_schema()undercd.uns['auto_discovery_schema'].
- uchrom.auto_discovery.schema.pack_schema(schema: Mapping[str, Any]) dict[str, str][source]¶
Pack a schema as an HDF5-friendly
unsentry.
- uchrom.auto_discovery.schema.schema_to_agent_context(schema: Mapping[str, Any], *, max_items: int = 40) str[source]¶
Render a compact, prompt-ready schema summary.
Ideas¶
Idea records and schema-based review for auto-discovery.
- class uchrom.auto_discovery.ideas.DiscoveryIdea(idea_title: str, biological_hypothesis: str, computable_parameter: str, analysis_plan: str, modalities: list[str], idea_markdown: str = '', cell_types: list[str] = <factory>, required_fields: list[str] = <factory>, validation_checks: list[str] = <factory>, expected_direction: str = '', complexity: int = 3, idea_id: str = '', metadata: dict[str, ~typing.Any] = <factory>)[source]¶
Bases:
objectA computable multi-omics discovery idea.
- class uchrom.auto_discovery.ideas.IdeaReview(accepted: bool, errors: list[str] = <factory>, warnings: list[str] = <factory>, missing_fields: list[str] = <factory>)[source]¶
Bases:
objectResult of reviewing an idea against a discovery schema.
Prompt contracts¶
Provider-agnostic prompt builders for U-Chrom auto-discovery.
- uchrom.auto_discovery.llm.allowed_required_fields(schema: Mapping[str, Any], *, max_items: int) list[str][source]¶
Return schema field paths that agents may use in
required_fields.
- uchrom.auto_discovery.llm.analysis_output_schema() dict[str, Any][source]¶
Return the structured-output schema for analysis-code backends.
- uchrom.auto_discovery.llm.build_analysis_prompt(*, idea_path: Path, schema_path: Path, context_path: Path, h5cd_path: Path, output_dir: Path) str[source]¶
Build the structured analysis-code prompt used by CLI backends.
- uchrom.auto_discovery.llm.build_idea_prompt(schema: Mapping[str, Any], *, max_ideas: int, prior_graph_path: str | Path | None = None, direction_context_path: str | Path | None = None) str[source]¶
Build the structured idea-generation prompt used by CLI backends.
Backend adapters¶
Backend adapters for U-Chrom auto-discovery.
Backends may use CLI agents and scratch files internally, but the runner owns the final notebook lifecycle. Adapter outputs are normalized into structured Python objects that the runner can audit, write, execute, and verify.
- class uchrom.auto_discovery.backends.AnalysisCodeResult(analysis_code: str, agent_records: list[BackendAgentRecord] = <factory>, extra_cells: list[dict[str, ~typing.Any]]=<factory>, artifact_manifest: list[dict[str, ~typing.Any]]=<factory>, warnings: list[str] = <factory>, notes: list[str] = <factory>)[source]¶
Bases:
objectStructured analysis code returned by a backend.
- agent_records: list[BackendAgentRecord]¶
- class uchrom.auto_discovery.backends.BackendAgentRecord(agent_name: str, role: str, prompt_path: str, content: Any)[source]¶
Bases:
objectAudit record for one backend invocation.
- class uchrom.auto_discovery.backends.BackendCapabilities(structured_output: bool, file_workspace: bool, prompt_via_stdin: bool, streaming: bool, native_skill_loading: bool = False, resume: bool = False, owns_notebook_lifecycle: bool = False)[source]¶
Bases:
objectCapabilities reported by an auto-discovery backend.
- class uchrom.auto_discovery.backends.BackendDetection(backend_id: str, executable_path: str | None, version: str | None = None, available: bool = False, auth_state: str = 'unknown', error: str | None = None, cli_flags: Mapping[str, bool]=<factory>)[source]¶
Bases:
objectBest-effort local CLI detection result.
- exception uchrom.auto_discovery.backends.BackendError(message: str, *, category: str, retryable: bool)[source]¶
Bases:
RuntimeErrorA classified backend failure.
categoryis one ofbackend_unavailable(missing/exited binary or an auth failure that a retry will not fix),failed(ran but exited non-zero for another reason),bad_output(ran but produced output that could not be parsed), ortimeout.retryabletells the run loop whether a transient retry is worthwhile.
- class uchrom.auto_discovery.backends.CLIBackend(spec: CLISpec)[source]¶
Bases:
objectGeneric adapter for stdin-driven coding-agent CLIs, driven by a spec.
- capabilities() BackendCapabilities[source]¶
- detect() BackendDetection[source]¶
- generate_analysis_code(idea: DiscoveryIdea, schema: Mapping[str, Any], *, output_dir: str | Path, h5cd_path: str | Path, model: str | None = None, reasoning_effort: str | None = None, timeout: int = 420) AnalysisCodeResult[source]¶
- generate_ideas(schema: Mapping[str, Any], *, output_dir: str | Path, max_ideas: int, model: str | None = None, reasoning_effort: str | None = None, timeout: int = 420, idea_agent_count: int = 1, prior_graph_path: str | Path | None = None, direction_context_path: str | Path | None = None) tuple[list[DiscoveryIdea], list[BackendAgentRecord]][source]¶
- class uchrom.auto_discovery.backends.CLISpec(backend_id: str, display_name: str, executable: str, build_command: Any, stream_format: str, run_environment: Any = <function _default_run_environment>, fallback_bins: tuple[str, ...]=(), capability_probe: Mapping[str, str]=<factory>)[source]¶
Bases:
objectData describing one stdin-driven coding-agent CLI backend.
Per-CLI differences are expressed as data here rather than as subclass overrides, mirroring open-design’s data-driven adapter model: the generic
CLIBackendconsumes a spec and the core never branches on backend id.
- class uchrom.auto_discovery.backends.ClaudeBackend[source]¶
Bases:
CLIBackendClaude Code CLI adapter (thin spec-backed wrapper).
- class uchrom.auto_discovery.backends.CodexBackend[source]¶
Bases:
CLIBackendCodex CLI adapter (thin spec-backed wrapper).
- class uchrom.auto_discovery.backends.DiscoveryBackend(*args, **kwargs)[source]¶
Bases:
ProtocolProtocol implemented by all auto-discovery backends.
- capabilities() BackendCapabilities[source]¶
- detect() BackendDetection[source]¶
- generate_analysis_code(idea: DiscoveryIdea, schema: Mapping[str, Any], *, output_dir: str | Path, h5cd_path: str | Path, model: str | None = None, reasoning_effort: str | None = None, timeout: int = 420) AnalysisCodeResult[source]¶
- generate_ideas(schema: Mapping[str, Any], *, output_dir: str | Path, max_ideas: int, model: str | None = None, reasoning_effort: str | None = None, timeout: int = 420, idea_agent_count: int = 1, prior_graph_path: str | Path | None = None, direction_context_path: str | Path | None = None) tuple[list[DiscoveryIdea], list[BackendAgentRecord]][source]¶
- class uchrom.auto_discovery.backends.PantheonBackend[source]¶
Bases:
objectAdapter around the existing Pantheon implementation.
- backend_id = 'pantheon'¶
- capabilities() BackendCapabilities[source]¶
- detect() BackendDetection[source]¶
- display_name = 'PantheonOS'¶
- generate_analysis_code(idea: DiscoveryIdea, schema: Mapping[str, Any], **kwargs: Any) AnalysisCodeResult[source]¶
- uchrom.auto_discovery.backends.extract_structured_json(text: str) dict[str, Any][source]¶
Extract the first structured JSON object from backend text.
- uchrom.auto_discovery.backends.get_backend(backend_id: str) DiscoveryBackend[source]¶
Return a registered backend or raise a user-facing error.
- uchrom.auto_discovery.backends.register_backend(backend: DiscoveryBackend) None[source]¶
Register or replace one backend adapter.
Notebooks¶
Notebook scaffolding for auto-discovery idea exploration.
- uchrom.auto_discovery.notebooks.create_exploration_notebook(idea: DiscoveryIdea | Mapping[str, Any], output_path: str | Path, *, h5cd_path: str | Path | None = None, run_output_dir: str | Path | None = None, analysis_code: str | None = None, verification_code: str | None = None, kernel_name: str = 'python3') Path[source]¶
Create a standard exploration notebook for one idea.
The code agent is expected to edit and execute this notebook freely. The scaffold only defines the audit trail and verification contract.
- uchrom.auto_discovery.notebooks.execute_notebook_python(notebook_path: str | Path, *, stop_on_error: bool = False) dict[str, Any][source]¶
Execute Python code cells in a notebook JSON file.
This lightweight executor is intentionally small: it keeps a shared Python namespace across code cells, captures stdout/stderr/error text, writes outputs back into the notebook, and returns the final namespace entries commonly used by the auto-discovery runner. It is meant for deterministic smoke tests; Pantheon/Jupyter can still execute the same notebooks in richer interactive runs.
Idea graph¶
Lightweight idea graph for iterative auto-discovery.
The graph is intentionally stored as plain JSON-friendly nodes and edges so it can be written to run directories without adding a hard graph dependency. It is the shared memory layer between discovery iterations: ideas, reviews, notebook runs, evidence, data facets, and source priors are represented as typed nodes with explicit relationships.
- class uchrom.auto_discovery.graph.IdeaGraph(graph_id: str = 'idea_graph', nodes: dict[str, dict[str, ~typing.Any]]=<factory>, edges: list[dict[str, ~typing.Any]]=<factory>)[source]¶
Bases:
objectA JSON-serializable graph of discovery ideas and evidence.
- add_edge(source: str, relation: str, target: str, **attrs: Any) dict[str, Any][source]¶
Add a typed edge unless the same edge already exists.
- uchrom.auto_discovery.graph.build_idea_graph_from_run(run_dir: str | Path, *, graph_id: str | None = None, claims_paths: list[str | Path] | None = None) IdeaGraph[source]¶
Build an
IdeaGraphfrom a completed auto-discovery run.The function reads
ideas.jsonl,reviews.jsonl, andresults.jsonlwhen present. Missing files are tolerated so interrupted runs can still produce partial graph snapshots.
- uchrom.auto_discovery.graph.build_idea_graph_from_runs(run_dirs: list[str | Path], *, graph_id: str = 'iterative_idea_graph', claims_paths: list[str | Path] | None = None) IdeaGraph[source]¶
Build one graph by merging several auto-discovery runs.
- uchrom.auto_discovery.graph.graph_summary_markdown(graph: IdeaGraph) str[source]¶
Render a compact Markdown summary for humans and agents.
- uchrom.auto_discovery.graph.idea_signature(idea: DiscoveryIdea | Mapping[str, Any]) dict[str, Any][source]¶
Return structured facets used for novelty and coverage review.
- uchrom.auto_discovery.graph.infer_parameter_family(idea: DiscoveryIdea | Mapping[str, Any]) str[source]¶
Infer a coarse parameter family from idea text.
- uchrom.auto_discovery.graph.ingest_literature_claims(graph: IdeaGraph, claims_path: str | Path) int[source]¶
Ingest browser-agent literature claims into an
IdeaGraph.claims_pathis a JSONL file. Rows may containclaim_id,claimorclaim_text,source/source_title,url,doi,pmid,entities/genes,cell_types,markers,modalities,supports_idea_ids,contradicts_idea_ids, andrelated_idea_ids. Extra keys are kept on the claim node for auditability.
Iterative follow-up directions¶
The module name keeps the original internal term frontier for API
compatibility, while the graph viewer presents these records as follow-up
directions.
Backward-compatible aliases for the renamed direction planner.
- uchrom.auto_discovery.frontier.frontiers_to_agent_context(frontiers: list[DiscoveryDirection]) str[source]¶
Legacy alias for
directions_to_agent_context().
Iterative orchestration¶
Multi-iteration orchestration for U-Chrom auto-discovery.
- class uchrom.auto_discovery.iterative.IterativeDiscoveryConfig(h5cd_path: str | Path, output_dir: str | Path, iterations: int = 2, ideas_per_iteration: int = 20, max_generation_attempts: int = 3, seed_run_dirs: list[str | Path] = <factory>, max_complexity: int = 5, idea_source: str = 'pantheon', code_source: str = 'pantheon', model: str | None = None, reasoning_effort: str | None = None, llm_timeout: int = 900, idea_agent_count: int = 4, notebook_agent_concurrency: int = 4, generate_schematic_image: bool = True, schematic_image_model: str | None = None, schematic_image_model_args: dict[str, ~typing.Any] | None=None, execute: bool = True, store_schema: bool = False, dataset_name: str | None = None, enrichment: dict[str, ~typing.Any] | None=None, knowledge_mode: str = 'knowledge_guided', claims_paths: list[str | Path] = <factory>)[source]¶
Bases:
objectConfiguration for repeated auto-discovery iterations.
- class uchrom.auto_discovery.iterative.IterativeDiscoveryResult(output_dir: str, run_dirs: list[str], iteration_results: list[~uchrom.auto_discovery.runner.DiscoveryRunResult], graph_path: str, graph_summary_path: str, directions_path: str, direction_summary_path: str, html_path: str, claim_refresh_results: list[~uchrom.auto_discovery.claims.ClaimRefreshResult] = <factory>)[source]¶
Bases:
objectSummary of a multi-iteration auto-discovery run.
- claim_refresh_results: list[ClaimRefreshResult]¶
- iteration_results: list[DiscoveryRunResult]¶
- uchrom.auto_discovery.iterative.run_iterative_auto_discovery(config: IterativeDiscoveryConfig | dict[str, Any]) IterativeDiscoveryResult[source]¶
Run several graph-guided discovery iterations.
Each iteration runs
ideas_per_iterationideas. Before iteration 2 and later, the orchestrator builds a cumulative idea graph from seed and prior iteration runs, plans direction prompts, and passes those artifacts to the idea agents.
Graph visualization¶
HTML visualization entrypoint for U-Chrom idea graphs.
Runner¶
Runnable auto-discovery pipeline for ChromData.
- class uchrom.auto_discovery.runner.DiscoveryRunConfig(h5cd_path: str | Path, output_dir: str | Path, max_ideas: int = 12, accepted_idea_target: int | None = None, max_generation_attempts: int = 3, ideas_path: str | Path | None = None, max_complexity: int = 5, idea_source: str = 'pantheon', code_source: str = 'pantheon', model: str | None = None, reasoning_effort: str | None = None, llm_timeout: int = 420, idea_agent_count: int = 3, notebook_agent_concurrency: int = 3, generate_schematic_image: bool = False, schematic_image_model: str | None = None, schematic_image_model_args: dict[str, ~typing.Any] | None=None, execute: bool = True, stop_on_error: bool = False, store_schema: bool = False, dataset_name: str | None = None, enrichment: dict[str, ~typing.Any] | None=None, prior_graph_path: str | Path | None = None, direction_context_path: str | Path | None = None, frontier_context_path: str | Path | None = None, claims_paths: list[str | Path] = <factory>)[source]¶
Bases:
objectConfiguration for a local auto-discovery run.
- class uchrom.auto_discovery.runner.DiscoveryRunResult(output_dir: str, n_generated: int, n_accepted: int, n_executed: int, n_verified: int, report_path: str, ideas_path: str, reviews_path: str, results_path: str, notebooks: list[str] = <factory>, agent_records_path: str | None = None, graph_path: str | None = None, graph_summary_path: str | None = None, graph_html_path: str | None = None, directions_path: str | None = None, direction_summary_path: str | None = None, enriched_h5cd_path: str | None = None, enrichment_summary_path: str | None = None)[source]¶
Bases:
objectSummary of an auto-discovery run.
- uchrom.auto_discovery.runner.run_auto_discovery(config: DiscoveryRunConfig | dict[str, Any]) DiscoveryRunResult[source]¶
Run schema → idea → notebook → verification for one
.h5cd.
PantheonOS backend¶
PantheonOS-backed auto-discovery orchestration.
- class uchrom.auto_discovery.pantheon.PantheonAgentRecord(agent_name: str, role: str, prompt_path: str, content: Any)[source]¶
Bases:
objectAudit record for one Pantheon agent call.
- class uchrom.auto_discovery.pantheon.PantheonSchematicRecord(idea_id: str, notebook: str, prompt_path: str, image_path: str | None, status: str, model: str | None = None, attempt: int = 1, visual_qa: Any = None, error: str | None = None)[source]¶
Bases:
objectAudit record for one post-hoc Pantheon schematic generation.
- async uchrom.auto_discovery.pantheon.generate_pantheon_ideas(schema: Mapping[str, Any], *, output_dir: str | Path, max_ideas: int, model: str | None = None, timeout: int = 420, idea_agent_count: int = 3, prior_graph_path: str | Path | None = None, direction_context_path: str | Path | None = None, frontier_context_path: str | Path | None = None) tuple[list[DiscoveryIdea], list[PantheonAgentRecord]][source]¶
Generate ideas by running multiple Pantheon idea agents in parallel.
Each idea agent receives only a file-access toolset. The schema and prompt are written to disk, and agents are instructed to read those files before returning DiscoveryIdea-compatible JSON.
- async uchrom.auto_discovery.pantheon.generate_pantheon_schematic_images_for_run(run_dir: str | Path, *, model: str | None = None, model_args: Mapping[str, Any] | None = None, timeout: int = 420, concurrency: int = 1, max_images: int | None = None, verified_only: bool = True, force: bool = False, visual_qa: bool = False, retries: int = 2, strict: bool = False) list[PantheonSchematicRecord][source]¶
Generate and insert graphical abstracts for a completed discovery run.
This is intentionally separate from notebook execution. Image generation is slow and provider-dependent, so completed/verified notebooks can be exported quickly first and then decorated with generated schematics in a bounded pass.
- async uchrom.auto_discovery.pantheon.run_pantheon_notebook_agents(ideas: Sequence[DiscoveryIdea], *, schema: Mapping[str, Any], h5cd_path: str | Path, output_dir: str | Path, notebooks_dir: str | Path, model: str | None = None, timeout: int = 420, concurrency: int = 3, generate_schematic_image: bool = False, schematic_image_model: str | None = None, schematic_image_model_args: Mapping[str, Any] | None = None) list[PantheonAgentRecord][source]¶
Run notebook exploration agents in parallel for accepted ideas.
The caller is responsible for creating scaffold notebooks first. Each Pantheon notebook agent receives file-access and notebook toolsets, edits its assigned notebook, executes exploration cells, and returns a JSON status summary.