CLI and Configuration

Commands, modular defaults, task manifests, profiles, evaluation, and resource-control presets.

1. Command surface

The package entry point is scienceflow = scienceflow.cli:main. The Click group loads repository and working-directory environment files and installs process-group cleanup handlers before dispatching a command.

CommandPurposeImplementation
prepPrepare a flat workspace dataset. It runs the data-preparation agent by default; --link-only exposes input entries as symlinks.solver/data_prep.py, solver/lnr/prep_fs.py
runRun the REPL-native long-horizon solver. The current supported type is lnr.core/orchestrator.py, solver/lnr/solver.py
replRun an interactive ScienceAgent session from explicit paths or a single-task manifest, with optional automatic first turn.core/orchestrator.py
parallelLaunch manifest tasks with bounded concurrency and per-task CPU/GPU environment isolation.core/parallel_runner.py
monitorRender a Rich dashboard from one task log directory or a parallel manifest.ui/monitor/
monitor-traceBuild a self-refreshing HTML trend view from a parallel manifest.ui/monitor_trace/
resource-summaryAggregate one or more resource_events.jsonl files as a table or JSON.resource_runtime/unified_store.py
replay-prepareCopy a saved LNR run into an isolated replay directory and truncate memory to a selected pending tool call.solver/lnr/replay_prepare.py

2. Configuration model

scienceflow/config/default.yaml is a small include file. Stable defaults are split by responsibility under scienceflow/config/defaults/, and LNR defaults are further split under defaults/lnr/.

Config
├── agent       # code and feedback model settings, routing, price metadata
├── exec        # debug and task CPU/GPU lists
├── workspace   # input root, task root, task identity, tracing
├── repl        # interactive profile, step budget, workspace Git behavior
├── tool        # sandbox, tool concurrency, output and memory limits
├── lnr         # workers, stages, ESTRA, folding, snapshots, resources, merge
├── evaluator   # candidate, metric, backend, command environment, event logs
├── gate        # trusted Gate policy and configurable parameters
└── profile_overrides

Configuration is represented by dataclasses in config/settings.py. A run starts from the default include graph or a custom overlay, then applies task profile and explicit manifest/CLI overrides. Task packages remain authoritative for their artifact, metric, evaluator, and Gate declarations.

3. Current default behavior

SettingDefaultMeaning
lnr.wall_clock_budget_sec3600One-hour task budget unless the manifest overrides it.
lnr.max_steps500Maximum LLM/tool rounds for a worker session.
lnr.num_workers1One persistent worker by default.
lnr.omp_threads_cap8Maximum OpenMP threads assigned to each worker CPU slice.
lnr.estra_enabledtrueEnable evidence-based continue, redirect, and previous-stage restoration decisions.
lnr.stage_memory_folding_enabledtrueFold old stage cards into persistent summaries when the stage-memory view exceeds its budget.
lnr.resource_control_moderesource_smart_llmEnable the full resource runtime, admission LLM, arbiter LLM, owning-agent advisory, queue, and GPU sharing.
evaluator.task_profile / backendauto / autoResolve the effective profile and evaluator from a registered task package.
evaluator.stage_source_modeprimaryUse the Gate outcome as the sole Stage-admission decision.
repl.repl_profile / repl_tool_presetlite / bash_writeUse the compact REPL prompt and write files through bash rather than legacy write/edit tools.

4. Manifest shape

max_concurrent: 1
time_limit: 3900
resume: false

lnr:
  wall_clock_budget_sec: 3600
  num_workers: 2
  omp_threads_cap: 8
  resource_control_mode: resource_smart_llm

defaults:
  config: scienceflow/config/default.yaml
  workspace_base: /path/to/runs

tasks:
  - exp_id: nomad2018-predict-transparent-conductors
    run_id: nomad-example
    input_data_dir: /path/to/task/data
    cpu_list: "0-15"
    gpu_list: cpu
    lnr:
      seed: 2222
      resource_gpu_pool: []

ParallelRunner resolves a task workspace from explicit task fields or workspace_base/run_id/exp_id, applies task-level CPU/GPU boundaries, and passes the structured configuration patch to the child process. The maintained examples are in scripts/lnr.yaml, scripts/repl.yaml, scripts/prep.yaml, and scripts/lnr_two_tasks.yaml.

5. Evaluator and Gate configuration

The evaluator defaults are intentionally task-neutral. At runtime, TaskPackageSpec resolves the effective profile, candidate path, artifact kind, metric name and direction, evaluator entry point, and timeout from tasks/**/task.yaml.

FieldCurrent role
evaluator.backendauto resolves registered tasks to task_package. artifact_command remains available for command-template integration.
evaluator.candidateDefines a workspace-relative artifact path, kind, scan mode, and optional SHA requirement for command-based evaluation.
evaluator.metricDefines the metric name, direction, parser fields, and whether selection requires a known direction.
evaluator.commandDefines the evaluator command, isolated Python/environment path, working directory, timeout, environment variables, and output tails.
evaluator.query_budget_scopeSelects a task-wide or worker-local evaluator query budget.
evaluator.stop_on_query_budget_exhaustedStops research after an accepted evaluation uses the final available query.
evaluator.expose_wall_clock_remaining_secAdds the current task time budget to evaluator feedback when enabled.
gate.policySelects a trusted registered Gate policy. Runtime configuration may tune permitted parameters but cannot disable core invariants.
The built-in default policy requires validation, candidate readiness, a finite primary metric, required direction metadata, and sufficient metric validity. The opt-in optimization_feasibility policy adds a constraint-violation bound.

The optional scienceflow/config/sci_modeling_bench.yaml profile combines worker-local query budgets with runtime context, structured Stage commits, agent-generated EDA summaries, and best-Stage finalization.

6. Resource-control presets

ModeExpanded behavior
offDisables the resource runtime, review state, queue, arbiter, advisory, observation, and sharing.
resource_smart_policyEnables deterministic runtime, queue, review state, and policy arbiter without admission LLM, owning-agent advisory, or GPU sharing.
resource_smart_llmEnables the complete control plane, including admission LLM, LLM arbiter, owning-agent advisory, and GPU sharing.

Expert fields can override individual switches after selecting a coarse mode. The canonical expansion lives in scienceflow/config/resource_modes.py.