nemo_gym.atif_reverification

View as Markdown

Strict ATIF projection for external rollout reverification.

The adapter validates a deliberately bounded canonical ATIF v1.7 subset, joins each trajectory to an explicit materialized Gym task, and constructs the Responses-shaped payload used by Gym’s existing stateless verifier path.

Provider-native payloads and producer-private status records carried in extra are producer evidence, not part of the ATIF interchange contract. Exporters own their projection into the canonical fields consumed here.

Module Contents

Classes

NameDescription
AtifProjectionErrorRaised when an ATIF trajectory cannot be projected without changing what is scored.
AtifReverifyManifestEntryExplicit join between one external trajectory and one Gym rollout.
LoadedAtifTrajectoryA validated trajectory together with immutable source provenance.
ProjectedAtifVerifyPayloadVerifier payload plus provenance that must survive result persistence.

Functions

NameDescription
_apply_materialized_request_context-
_created_at-
_has_multimodal_content-
_item_id-
_model_name-
_observation_outputProject both standard ATIF content and Relay’s structured result extension.
_optional_nonnegative_count-
_reject_nonfinite_json_numbers-
_reject_unsupported_training_metadata-
_relay_usage_detailsAggregate optional Relay token details without turning unknown values into zero.
_step_has_usage_counts-
_text_parts-
_trajectory_content_sha256Hash semantic ATIF content without ignored producer metadata.
_trajectory_identity_seed-
_usage-
_validate_declared_gym_source_identity-
_validate_projected_output_ids-
_validate_supported_trajectory-
atif_trajectory_to_responseProject one complete text-only ATIF v1.7 trajectory into a Gym response.
build_atif_verify_payloadReplace a materialized task’s native response with its ATIF projection.
index_materialized_inputsIndex materialized tasks without guessing identity from row order.
load_atif_manifestLoad an explicit trajectory-to-rollout manifest from JSONL.
load_atif_trajectoryRead and validate one ATIF document without involving the Relay runtime.
project_atif_manifest_entriesProject a one-to-one manifest while rejecting ambiguous batch joins.
project_atif_manifest_entryResolve one manifest entry without relying on filenames or session IDs.

Data

_RESPONSE_REQUEST_FIELDS

API

class nemo_gym.atif_reverification.AtifProjectionError()

Bases: ConfigError

Raised when an ATIF trajectory cannot be projected without changing what is scored.

class nemo_gym.atif_reverification.AtifReverifyManifestEntry()

Bases: BaseModel

Explicit join between one external trajectory and one Gym rollout.

expected_sha256
str | None = Field(default=None, pattern='^[0-9a-f]{64}$')
model_config
= ConfigDict(extra='forbid', populate_by_name=True)
rollout_index
int
task_index
int = Field(alias='_ng_task_index', ge=0, strict=True)
trajectory_path
Path
class nemo_gym.atif_reverification.LoadedAtifTrajectory(
source_path: pathlib.Path,
source_sha256: str
)
Dataclass

A validated trajectory together with immutable source provenance.

source_path
Path
source_sha256
str
trajectory
AtifTrajectoryV1_7
class nemo_gym.atif_reverification.ProjectedAtifVerifyPayload(
payload: dict[str, typing.Any],
trajectory_id: str | None,
session_id: str | None,
source_path: pathlib.Path,
source_sha256: str,
trajectory_content_sha256: str,
task_index: int,
rollout_index: int,
schema_version: str,
projection_status: typing.Literal['complete'] = 'complete'
)
Dataclass

Verifier payload plus provenance that must survive result persistence.

projection_status="complete" means Gym built the bounded scoring payload without guessing or dropping a field this adapter maps. It does not claim a full-fidelity conversion of the ATIF document or producer metadata in extra; the source hashes preserve that provenance.

payload
dict[str, Any]
projection_status
Literal['complete'] = 'complete'
rollout_index
int
schema_version
str
session_id
str | None
source_path
Path
source_sha256
str
task_index
int
trajectory_content_sha256
str
trajectory_id
str | None
nemo_gym.atif_reverification._apply_materialized_request_context(
materialized_input: typing.Mapping[str, typing.Any]
nemo_gym.atif_reverification._created_at(
agent_steps: list[typing.Any]
) -> float
nemo_gym.atif_reverification._has_multimodal_content(
) -> bool
nemo_gym.atif_reverification._item_id(
components: str = ()
) -> str
nemo_gym.atif_reverification._model_name(
) -> str
nemo_gym.atif_reverification._observation_output(
result: typing.Any,
field_name: str
) -> str | openai.types.responses.response_function_call_output_item_list_param.ResponseFunctionCallOutputItemListParam

Project both standard ATIF content and Relay’s structured result extension.

nemo_gym.atif_reverification._optional_nonnegative_count(
namespace: typing.Mapping[str, typing.Any],
field_name: str,
step_id: int
) -> int | None
nemo_gym.atif_reverification._reject_nonfinite_json_numbers(
value: typing.Any,
field_name: str
) -> None
nemo_gym.atif_reverification._reject_unsupported_training_metadata(
step: typing.Any
) -> None
nemo_gym.atif_reverification._relay_usage_details(
agent_steps: list[typing.Any]
) -> tuple[int | None, int | None]

Aggregate optional Relay token details without turning unknown values into zero.

nemo_gym.atif_reverification._step_has_usage_counts(
step: typing.Any
) -> bool
nemo_gym.atif_reverification._text_parts(
value: typing.Any,
field_name: str
) -> list[str]
nemo_gym.atif_reverification._trajectory_content_sha256(
) -> str

Hash semantic ATIF content without ignored producer metadata.

Provider payloads and status records carried in extra do not affect the projected verifier response. Exclude them from the content identity so they cannot perturb generated response or item IDs when trajectory_id is absent. Retain the few extension fields that this adapter consumes.

nemo_gym.atif_reverification._trajectory_identity_seed(
) -> str
nemo_gym.atif_reverification._usage(
nemo_gym.atif_reverification._validate_declared_gym_source_identity(
manifest_key: tuple[int, int]
) -> None
nemo_gym.atif_reverification._validate_projected_output_ids(
output: list[typing.Any]
) -> None
nemo_gym.atif_reverification._validate_supported_trajectory(
) -> None
nemo_gym.atif_reverification.atif_trajectory_to_response(

Project one complete text-only ATIF v1.7 trajectory into a Gym response.

nemo_gym.atif_reverification.build_atif_verify_payload(
materialized_input: dict[str, typing.Any],
) -> dict[str, typing.Any]

Replace a materialized task’s native response with its ATIF projection.

The materialized task remains authoritative for the system/user input, verifier metadata, agent routing, and rollout correlation. ATIF contributes only the response produced by the external agent.

nemo_gym.atif_reverification.index_materialized_inputs(
rows: typing.Iterable[typing.Mapping[str, typing.Any]]
) -> dict[tuple[int, int], dict[str, typing.Any]]

Index materialized tasks without guessing identity from row order.

nemo_gym.atif_reverification.load_atif_manifest(
path: pathlib.Path

Load an explicit trajectory-to-rollout manifest from JSONL.

nemo_gym.atif_reverification.load_atif_trajectory(
path: pathlib.Path

Read and validate one ATIF document without involving the Relay runtime.

nemo_gym.atif_reverification.project_atif_manifest_entries(
materialized_inputs: typing.Mapping[tuple[int, int], typing.Mapping[str, typing.Any]],
manifest_directory: pathlib.Path

Project a one-to-one manifest while rejecting ambiguous batch joins.

nemo_gym.atif_reverification.project_atif_manifest_entry(
materialized_inputs: typing.Mapping[tuple[int, int], typing.Mapping[str, typing.Any]],
manifest_directory: pathlib.Path

Resolve one manifest entry without relying on filenames or session IDs.

nemo_gym.atif_reverification._RESPONSE_REQUEST_FIELDS = frozenset({'background', 'instructions', 'max_output_tokens', 'max_tool_calls', ...