cosmotron_mcp.server¶
bootstrap_session ¶
bootstrap_session(data_dir: str, user_task: str, force_new: bool = False, survey: str | None = None, resume: bool = False, fresh_confirmed: bool = False, session_dir: str | None = None) -> dict
Create the session directory and write session_context.json deterministically.
Scans data_dir for the catalogue (first-level .fits/.hdf5/.csv) and an optional DATA_DESCRIPTION.md, then resolves pipeline_config from the user task by pure-Python regex parsing (authority: user > scb > profile > data_description > default) and writes the validated session_context.json. No LLM chooses pipeline parameters.
Pass survey to match a declarative catalogue-type profile (by canonical
name or alias, e.g. survey="glass"). A matched profile supplies default
pipeline params (recorded with provenance source "profile") and column
conventions later honoured by ingest_to_session. An unknown/omitted survey
falls back to fully dynamic resolution + detection.
Full-sky data (declared in the task or DATA_DESCRIPTION.md) forces apodise_mask=False and apodisation_scale=None; the write step rejects any inconsistent combination.
Default = ALWAYS a new session. Every call auto-creates a fresh workspace/{date}{stem}/ (or workspace/{date}_02/ etc. if one already exists for today), regardless of any prior session for this data_dir. Re-using a session is the exception, not the default.
Reuse is explicit-only: pass session_dir=<path> (or embed a
session_dir: <path> line in user_task — the tool parses it; the
explicit param wins if both are given) naming an EXISTING session
directory. That exact session is then resumed verbatim (its pinned
pipeline_config is kept; plan.json is deleted so the orchestrator
re-plans). If the named path has no session_context.json, the tool
returns session_dir_not_found=True and creates NOTHING — it never
silently creates a session at an unrecognised path or falls back to a
fresh one.
force_new/resume/fresh_confirmed remain accepted for backward
compatibility with older callers/tests, but only matter when an explicit
session_dir (param or task line) is present. A PARTIAL session (an
in-flight bootstrap of THIS task that stopped at an unresolved
nside / probe / role-conflict clarification) is transparently reused on
the clarification retry so one task never spawns several workspace
folders — this anti-churn is unrelated to user-facing session reuse.
bootstrap_session is registry-agnostic. It never asks whether a
catalogue matches a registered dataset; that decision is a data-ingest
concern and lives in ingest_to_session, which opens its own
file-backed registry-<basename> gate (options: candidate dataset ids
+ "register-new" + "ignore") when the description hash matches an
existing dataset, and a registration-<basename> gate (options:
"register" + "ignore") after standardising a previously unseen
dataset. Both gates are closed by authorise_gate (permission: ask
picker). No registry state is inherited across independent user tasks
because none is stored at bootstrap time.
Spin / probe: spin is 0 (galaxy density) unless the task DECLARES otherwise —
spin=2, probe=shear (or probe=galaxy_shear), or a ## probes:
block (per-probe overrides of spin/lmax/lmin/galaxy_bias/mask_path/sigma_e;
nside is global and may NOT appear there). Spin is NEVER inferred from prose
like "cosmic shear".
Correlation selection: a ## correlations: section pins which pairs to
compute — all (default), auto, adjacent: N, or
pairs: [[0,1],[lens0,src1]]. Stored in pipeline_config.pairs and applied
consistently to the spectra, covariance, and SACC steps (early subset — the
covariance is only built for the selected pairs). If the task prose implies shear but nothing is declared,
the tool returns probe_unresolved: True + probe_hint — ask the user
for an explicit probe=/spin=. Note: the CURRENT_SESSION pointer IS
written even in this case (so the clarification retry reuses the same
partial directory instead of forking a new one), but get_active_session
refuses to serve a session until bootstrap_complete is set — so no
other caller can pick up this partial session in the meantime.
Returns a dict with: session_dir, catalogue_path, pipeline_config, pipeline_config_provenance, required_plots, nside_unresolved, probe_unresolved, catalogue_role_conflict, and (when an explicit session_dir names a path with no session_context.json) session_dir_not_found=True. When nside_unresolved is True the user task did not specify nside (no default) — ask the user, never guess.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data_dir
|
str
|
Directory holding the raw catalogue and any ancillary
files (masks, n(z), |
required |
user_task
|
str
|
The user's task text, verbatim — parsed deterministically
for pipeline_config and the structured |
required |
force_new
|
bool
|
Legacy no-op on the default (new-session) path; only
interacts with an explicit |
False
|
survey
|
str | None
|
Catalogue-type profile name/alias to apply (e.g.
|
None
|
resume
|
bool
|
Legacy alias for reusing the session named by |
False
|
fresh_confirmed
|
bool
|
Legacy no-op; kept for backward compatibility. |
False
|
session_dir
|
str | None
|
Path to an EXISTING session directory to resume verbatim. This is the ONLY way a run reuses a prior session — omit it (the default) to always start fresh. |
None
|
Returns:
| Type | Description |
|---|---|
dict
|
|
dict
|
|
dict
|
|
dict
|
|
dict
|
names a path with no session_context.json) |
Source code in cosmotron_mcp/server.py
2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 | |
get_active_session ¶
Return the currently active session directory and its pipeline_config.
Reads workspace/CURRENT_SESSION (written by bootstrap_session) and returns the authoritative session_dir + pipeline_config from session_context.json.
RECOVERY TOOL ONLY — use it mid-run when you already know a session was
bootstrapped THIS run and you merely lost track of its path (never guess
or pick the most recent workspace/ subdirectory by hand). On a brand-new
task do NOT call this before @session_bootstrapper/bootstrap_session
has actually run and returned a session_dir: CURRENT_SESSION is a
cross-conversation file left over from whatever ran last (including an
unrelated or cancelled prior run) — calling this first silently hands you
a stale session instead of the fresh one the task asked for.
bootstrap_session writes the CURRENT_SESSION pointer as soon as it
picks a directory — including when it then stops at an unresolved
clarification (nside/probe/role-conflict) — so that a clarification
retry lands back in the same partial session (anti-churn). This tool
refuses to serve such a partial session (bootstrap_complete not
yet True in session_context.json): resolving the clarification
is @session_bootstrapper's job, not a recovery caller's.
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If no session has been bootstrapped yet, or the pointed-at session is still partial (bootstrap did not finish). |
Returns:
| Type | Description |
|---|---|
dict
|
|
dict
|
|
Source code in cosmotron_mcp/server.py
find_dataset ¶
Find registered datasets matching a data directory's DATA_DESCRIPTION.md or a name.
Candidates for the user to confirm before reuse.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data_dir
|
str | None
|
Match by this directory's |
None
|
name
|
str | None
|
Match by dataset name. |
None
|
Returns:
| Type | Description |
|---|---|
dict
|
|
Source code in cosmotron_mcp/server.py
list_datasets ¶
List all registered datasets in the persistent L1 registry.
Returns:
| Type | Description |
|---|---|
dict
|
``{"datasets": [{dataset_id, name, version, probe, survey, n_bins, |
dict
|
n_objects, locations, created_at}, ...]} |
dict
|
machines that hold this dataset's products ( |
dict
|
store; a site name = a cluster copy from |
dict
|
|
Source code in cosmotron_mcp/server.py
get_dataset ¶
Full record for one registered dataset (the agent-facing equivalent of
cosmotron-data-registry show).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset_id
|
str
|
The dataset id (e.g. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
``{dataset_id, name, version, probe, survey, coordinate_convention, |
dict
|
source_data_dir, description_hash, z_edges, column_map, stats, |
dict
|
products, locations, created_at} |
dict
|
id isn't registered. |
dict
|
products physically lives ( |
dict
|
that lives only on a cluster must be pulled |
dict
|
( |