Skip to content

refactor(trajectory): move the trajectory modules into nemo_gym/trajectory - #5209

Merged
ananthsub merged 1 commit into
mainfrom
ananthsub/layout-trajectory
Oct 30, 2026
Merged

ananthsub merged 1 commit into
mainfrom
ananthsub/layout-trajectory

Conversation

@ananthsub

@ananthsub ananthsub commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

What and why

Moves the trajectory data model into a new nemo_gym/trajectory/ package: the records of what happened in a rollout (rollout_observability.py, renamed trajectory_record.py) and the ATIF export and import modules. Agents, the rollout collector, and evaluation all read these records, so they sit low in the order, above client/.

Where this PR sits

The stack lands bottom-up; each PR's base is the branch of the PR before it, so each diff shows only that PR's change.

flowchart LR
  compat["#5167<br/>Old import paths<br/>keep working"]
  linter["#5168<br/>import-linter<br/>layer contract"]
  prep["#5169<br/>Remove path and<br/>name couplings"]
  config["#5189<br/>Move config/"]
  utils["#5195<br/>Move utils/"]
  core["#5203<br/>Move core/"]
  client["#5206<br/>Move client/,<br/>start telemetry/"]
  trajectory["#5209<br/>Move trajectory/"]
  verification["#5210<br/>Move verification/"]
  metrics["#5211<br/>Move metrics/"]
  artifacts["#5212<br/>Move artifacts/"]
  srmods["#5214<br/>Move server_runtime/<br/>modules"]
  su["#5215<br/>Split server_utils"]
  model["#5224<br/>Move models/<br/>modules"]
  modelbase["#5225<br/>Split model<br/>call capture"]
  agents["#5228<br/>Move agents/"]
  data["#5229<br/>Move data/"]
  harbor["#5230<br/>Split the<br/>Harbor task CLI"]
  rollouts["#5231<br/>Move rollouts/"]
  rsplit["#5232<br/>Split the<br/>rollout collector"]
  testing["#5233<br/>Dissolve testing/"]
  orch["#5234<br/>Move orchestration/<br/>modules"]
  sup["#5235<br/>Split the<br/>server supervisor"]
  eval["#5244<br/>Move eval/"]
  env["#5298<br/>Move environment/<br/>registries"]
  cli["#5300<br/>Retire the<br/>cli_setup_command shim"]
  docs["#5385<br/>Describe the<br/>package layout"]
  owners["next<br/>CODEOWNERS:<br/>per-package groups"]
  remove["0.10.0<br/>Remove the<br/>old paths"]
  compat --> linter
  linter --> prep
  prep --> config
  config --> utils
  utils --> core
  core --> client
  client --> trajectory
  trajectory --> verification
  verification --> metrics
  metrics --> artifacts
  artifacts --> srmods
  srmods --> su
  su --> model
  model --> modelbase
  modelbase --> agents
  agents --> data
  data --> harbor
  harbor --> rollouts
  rollouts --> rsplit
  rsplit --> testing
  testing --> orch
  orch --> sup
  sup --> eval
  eval --> env
  env --> cli
  cli --> docs
  docs --> owners
  owners --> remove
  classDef this fill:#fde68a,stroke:#b45309,stroke-width:2px,color:#1f2937
  classDef later fill:#f3f4f6,stroke:#9ca3af,color:#4b5563,stroke-dasharray: 4 3
  class trajectory this
  class owners,remove later
Loading

Where the package sits

flowchart TD
  cli["cli/"]
  eval["eval/"]
  environment["environment/"]
  testing["testing/"]
  orchestration["orchestration/"]
  rollouts["rollouts/"]
  data["data/"]
  agents["agents/"]
  model["models/"]
  server_runtime["server_runtime/"]
  artifacts["artifacts/"]
  metrics["metrics/"]
  verification["verification/"]
  trajectory["trajectory/"]
  sandbox["sandbox/"]
  client["client/"]
  telemetry["telemetry/"]
  core["core/"]
  utils["utils/"]
  config["config/"]
  cli --> eval
  cli --> environment
  cli --> orchestration
  eval --> rollouts
  environment --> data
  testing --> rollouts
  orchestration --> data
  rollouts --> data
  rollouts --> agents
  rollouts --> model
  data --> server_runtime
  data --> artifacts
  agents --> server_runtime
  model --> server_runtime
  server_runtime --> metrics
  server_runtime --> verification
  server_runtime --> trajectory
  artifacts --> trajectory
  artifacts --> utils
  metrics --> utils
  verification --> sandbox
  trajectory --> core
  sandbox --> client
  client --> telemetry
  client --> utils
  telemetry --> core
  core --> config
  utils --> config
  classDef this fill:#fde68a,stroke:#b45309,stroke-width:2px,color:#1f2937
  classDef done fill:#d1fae5,stroke:#047857,color:#1f2937
  classDef todo fill:#f3f4f6,stroke:#9ca3af,color:#4b5563
  class trajectory this
  class config,utils,core,telemetry,client done
  class cli,eval,environment,testing,orchestration,rollouts,data,agents,model,server_runtime,artifacts,metrics,verification,sandbox todo
Loading

An arrow means "imports"; each package imports only packages below it. Yellow: created by this PR. Green: created by an earlier PR in the stack. Grey: still to come.

What moves

Whole modules, unchanged:

Old path New path
nemo_gym/rollout_observability.py nemo_gym/trajectory/trajectory_record.py
nemo_gym/atif_export.py nemo_gym/trajectory/atif_export.py
nemo_gym/atif_reverification.py nemo_gym/trajectory/atif_reverification.py
nemo_gym/atif_json.py nemo_gym/trajectory/atif_json.py
nemo_gym/atif_v1_7.py nemo_gym/trajectory/atif_v1_7.py

How to review

One commit. Its changes:

  1. Renames, with no content changes.
  2. Everything else:
    • The moves are recorded in MOVED_MODULES in nemo_gym/_moved_paths.py.
    • In-repo references are rewritten by scripts/migrate_imports.py.
    • The contract's trajectory layer becomes the nemo_gym.trajectory package.
    • fern/docs.yml redirects the old library reference pages to the new ones.
    • The contract keeps one exception here, renamed: trajectory_record.py imports ModelCallRecord for type annotations only, from observability.model_calls. refactor(rollouts): move rollout collection and health into nemo_gym/rollouts #5231 moves ModelCallRecord into trajectory/, which removes it.
  3. Tests: the trajectory record and ATIF tests move into tests/unit_tests/trajectory/, with the two ATIF fixtures they read. The rollout reverification tests read those fixtures from the new place.

Public API

Every layout package that exists after this PR has a lazy public API in its __init__.py: the names non-test code outside nemo_gym/ imports from it (servers, benchmarks, scripts, and code samples in docs and skills), each served from the submodule that defines it on first use. Code outside nemo_gym/ and its tests (servers and their tests, benchmarks, scripts, and docs) imports those names from nemo_gym.<package>, so later moves inside a package leave it alone. Code inside nemo_gym/, and the library's tests under tests/, import from the module that defines each name, so the import-linter contract sees every dependency and a test reads what it patches. A patch target names the module the code under test looks the name up in. AGENTS.md states the rule.

Validation

  • pytest -n 16 tests/unit_tests, also with -W error for the moved paths. The only failures are environment-specific and unrelated to the move: this machine's hostname resolves to 127.0.1.1, which the sandbox host check refuses (the Harbor run summary tests and the benchmark listing test), and two Docker PTY tests.
  • lint-imports.
  • pre-commit run on the changed files.
  • Server and agent tests run in CI.

Rollout evidence: N/A. The modules move unchanged.

Compatibility

  • Old paths work until 0.10.0, with one warning each, and give the same module objects.
  • Open branches: run python scripts/migrate_imports.py <paths>.

Issue

Part of #5166.

@ananthsub
ananthsub added this pull request to stack #5170 October 28, 2026 18:48
@copy-pr-bot

copy-pr-bot Bot commented Oct 28, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@ananthsub ananthsub changed the title ananthsub/layout trajectory refactor(trajectory): move the trajectory modules into nemo_gym/trajectory Oct 28, 2026
@ananthsub
ananthsub requested a review from yaoyu-33 October 28, 2026 18:50
@ananthsub ananthsub added feature New capabilities, enhancements, or enablement work area:core Shared APIs, servers, telemetry, health, and registries needs-review PR is ready for code review and waiting on a reviewer labels Oct 28, 2026
@ananthsub
ananthsub marked this pull request as ready for review October 28, 2026 18:50
@ananthsub
ananthsub requested a review from a team as a code owner October 28, 2026 18:50
@nemo-automation-bot
nemo-automation-bot Bot requested review from a team October 28, 2026 18:51
@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

@ananthsub
ananthsub force-pushed the ananthsub/layout-trajectory branch from 16caed2 to e35f4bb Compare October 28, 2026 21:23
@ananthsub
ananthsub force-pushed the ananthsub/layout-trajectory branch from e35f4bb to 7b92bf2 Compare October 28, 2026 21:56
@ananthsub
ananthsub force-pushed the ananthsub/layout-trajectory branch from 7b92bf2 to bf80261 Compare October 28, 2026 23:10
@ananthsub
ananthsub force-pushed the ananthsub/layout-trajectory branch from bf80261 to e3cf2fd Compare October 29, 2026 00:54

@yaoyu-33 yaoyu-33 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for keeping this move strictly mechanical again; it made it easy to check. We found no blockers or risks, only two small docs notes inline.

What this PR does. It moves the trajectory data model into a new nemo_gym/trajectory package unchanged: rollout_observability.py (renamed trajectory_record.py) and the four ATIF modules. It gives the package a lazy public API, records the moves in _moved_paths.py, points the import-linter trajectory layer at the package, and redirects the old library-reference pages.

What we checked

  • Moves. trajectory_record.py, atif_json.py, atif_v1_7.py and both ATIF fixtures are byte-identical renames. atif_export.py, atif_reverification.py and the three moved tests differ only in their imports. Of the 123 changed Python files, 121 differ only in imports; the other two are _moved_paths.py and the fixture path in test_rollout_reverification.py.
  • Imports. All 397 rewritten import sites bind the same objects as before. The 18 names in nemo_gym.trajectory's _PUBLIC_API are exactly the names that code outside the library imports. lint-imports keeps the contract (17 ignored imports, with the trajectory_record -> observability.model_calls exception renamed), and the trajectory modules import only config, core and each other.
  • Old paths. All five old module paths give the same module object with one warning each, and every name import_surface.json records for them resolves to the identical object. Objects pickled under the old module paths unpickle to the same classes.
  • Formats. ATIF export, transcript_to_atif, the reverification payloads, TrajectoryRecord JSON and the model JSON schemas are byte-identical between base and head; nothing writes a module path into output. Committed pre-move ng_trajectory rows still validate.
  • Sandboxes. nooa_agent/sandbox_entrypoint.py is the only changed file that imports nemo_gym inside a sandbox. The NOOA runtime ships the current checkout's nemo_gym/**/*.py, keyed by a content fingerprint, so it needs no old-path fallback. No uploaded runner that can meet a prebuilt gym_source bundle imports a trajectory module.
  • Wiring. The ten redirects (unversioned and /:version/), the CODEOWNERS suggestion and packaging are in order. No workflow path filter or harness_conformance/ci.py rule names the old files.
  • Tests. pytest tests/unit_tests -n 8 with the moved-path DeprecationWarnings turned into errors passed 12,433 tests and raised none. Each local failure either also fails at the base (optional dependencies missing from the dev venv, Docker, macOS SSL) or was a timing failure under load that passed when re-run alone. Every touched server and agent passes in CI in its own venv.

CI. The red checks are not from this change. Unit tests / Test fails on the same 13 test IDs as #5206: 11 Harbor tests on a Docker Hub HTTP 429 for ubuntu:24.04, and the 2 telemetry tests described below. Server suite (shard 3) fails in responses_api_models/openai_model as on #5206, and the kilocode harness-conformance failure is the same model_error scenario as on #5206 and #5203.

PR description. The Compatibility note about logger names has nothing to apply to here: none of the five modules creates a logger.

For other PRs in the stack (not blocking this one)

  • #5206: tests/unit_tests/telemetry/test_propagation.py:280 patches nemo_gym.utils.server_process.get_nemo_gym_fastapi_num_workers, but nemo_gym/client/http_client.py binds that name directly, so the patch never reaches the client. That is why test_lazy_client_initialization_failure_is_inside_the_client_span[False/True] fail in CI ("Cannot connect to host 127.0.0.1:80"). telemetry/test_connection_pool.py:98 uses the same target, so its workers=4 cases run with one worker. Patching nemo_gym.client.http_client.get_nemo_gym_fastapi_num_workers fixes both. The AGENTS.md rule that a patch target "names the module that defines the name" may be worth rewording to the module the code under test looks the name up in.
  • #5206: .agents/skills/add-harness/SKILL.md:186, three observability pages (distributed-tracing.mdx, metrics.mdx, span-groups.mdx) and nemo_gym/telemetry/README.md still name server_utils.request().
  • #5167: from nemo_gym import <moved module> attributes its DeprecationWarning to nemo_gym/__init__.py, so the default filters hide it in scripts; import nemo_gym.<old path> warns at the caller's line. Adding the nemo_gym/__init__ frame to _SKIP_FILE_PREFIXES fixes it.

Comment thread nemo_gym/_moved_paths.py Resolved
yaoyu-33
yaoyu-33 previously approved these changes Oct 30, 2026

@yaoyu-33 yaoyu-33 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving at c18e37e1cb27, the commit we reviewed. The two inline docs notes are non-blocking. The red checks are the failures shared with #5206 that the review summary describes: the Harbor Docker Hub 429s, the two telemetry tests from #5206, openai_model in server shard 3, and the kilocode conformance scenario.

…ctory

rollout_observability.py becomes trajectory/trajectory_record.py, and
the four ATIF modules move as they are.

Record the five moves in MOVED_MODULES, rewrite in-repo references with
scripts/migrate_imports.py, make the contract's trajectory layer the
nemo_gym.trajectory package, and redirect the old library reference
pages in fern/docs.yml.

The ATIF fixtures move with them; the rollout reverification tests read
them from the new place.

Regenerate the public API of each layout package that exists here from
what non-test code outside nemo_gym imports, and point code outside
nemo_gym, tests included, at nemo_gym.<package>.

Signed-off-by: Ananth Subramaniam <[email protected]>

This branch was previously deployed

1 inactive deployment
public — b5ede812 Deployed Oct 30, 2026 by copy-pr-bot[bot] via release / finalize / notify #8761
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:core Shared APIs, servers, telemetry, health, and registries feature New capabilities, enhancements, or enablement work ready-to-merge PR is approved, current, and waiting for final CI or merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants