NextStatNextStat

Physics Assistant Demo

A fully reproducible end-to-end workflow that demonstrates NextStat as an AI oracle: ingest .root histograms, build a HistFactory workspace, run an anomaly scan, compute discovery p-values and upper limits, and export plot-ready artifacts.

What It Does

  • Ingests .root histograms via NextStat's native ROOT reader
  • Builds a HistFactory workspace from observed data + signal/background templates
  • Proposes an anomaly scan across mass windows
  • Computes discovery p-values (p₀, Z₀) and CLs upper limits
  • Exports JSON plot artifacts + optional PNG renders

Transport Modes

ModeDescriptionRequirements
LocalAll tools in-process via Python bindingsNextStat wheel installed
ServerStatistical tools over HTTP, ROOT ingest stays localnextstat-server running
DockerAgent container + nextstat-server via docker composeDocker only

Running the Demo

Local Mode

# from repo root:
PYTHONPATH=bindings/ns-py/python python demos/physics_assistant/run_demo.py \
  --transport local \
  --out-dir demos/physics_assistant/out/local \
  --render

Server Mode

# Start the server first:
nextstat serve --port 3742

# Then run the demo:
export NEXTSTAT_SERVER_URL=http://127.0.0.1:3742
PYTHONPATH=bindings/ns-py/python python demos/physics_assistant/run_demo.py \
  --transport server \
  --out-dir demos/physics_assistant/out/server

Docker Mode

docker compose -f demos/physics_assistant/env/docker/docker-compose.yml up --build

Outputs written to demos/physics_assistant/env/docker/out/ on the host.

Output Artifacts

FileDescription
demo_result.jsonMain result bundle (validated by schema)
tool_calls.jsonOrdered tool-call log (requests + tool_result.v1 envelopes)
nominal_workspace.jsonNominal model workspace
best_anomaly_workspace.jsonBest window from anomaly scan
anomaly_scan_plot_data.jsonPlot-ready arrays (JSON)
plots/*.pngOptional PNGs (when --render is enabled)

Design Note: Why Ingest Is Always Local

The inference server does not expose nextstat_read_root_histogram by design — file I/O is a security surface. The demo exercises server mode fully by shipping only workspace_json to the server for inference calls.