Repository navigation
feat(harbor): job-level Compose overlay, MCP entries and prompt template (M30) - #4863
Conversation
|
/ok to test a338b16 |
a338b16 to
a78e40f
Compare
|
/ok to test a78e40f |
a78e40f to
6264b5d
Compare
|
/ok to test 6264b5d |
|
/ok to test dd0bc45 |
|
/ok to test fd0e0ae |
|
/ok to test f599aee |
|
/ok to test 70a3914 |
ffrujeri
left a comment
There was a problem hiding this comment.
Thanks for the thorough follow-ups. I rechecked all ten earlier threads against 70a3914 and each fix is in place with a covering test; the focused suites pass locally. Required CI is green; the only red check is the non-blocking kilocode conformance probe. One open question is about trust: task-supplied variables and services can currently override operator-owned values in the job-level overlay. It would be good to either change the precedence or document it before this lands.
|
/ok to test 9161c61 |
|
/ok to test 6866650 |
|
/ok to test 4c3b0f5 |
|
/ok to test 3de0d68 |
|
/ok to test 5effc9d |
|
Rechecked The image replacement, scalar The cleared-entrypoint reproduction also passes. My remaining concern is the startup user/directory difference described in that thread. |
|
/ok to test 2620d78 |
|
/ok to test f419385 |
|
/ok to test 9ea1b8f |
|
/ok to test 11e9a05 |
|
/ok to test e2df80a |
|
/ok to test 19ff5a5 |
|
/ok to test 13713d9 |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/40534927560 |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/40540771458 |
…ate (M30)
The run config can attach services and tools to every task of a run without
touching the tasks, as Harbor's job config does with `extra_docker_compose`,
`agents[].mcp_servers` and an agent's `prompt_template_path`. One block of the
Harbor environment server's configuration, `compose_overlay`, holds the three:
- `files`: Compose files merged, in order, onto every task's Compose document
after the task's own file, the way Compose merges `-f` files (mappings key by
key, sequences appended with the keyed ones unique on their key, environment
and labels as mappings, depends_on and networks as mappings, command,
entrypoint and healthcheck.test replaced whole, a key written with no value
keeping the earlier file's value, `!reset` removing an earlier attribute or
one environment variable and `!override` replacing instead of merging). Each
file is interpolated with the task's variables; its relative paths resolve
against the Compose project directory, the task's environment folder, as
Compose resolves every -f file's and Harbor's --project-directory names it
(never against the overlay file's own folder): its env_file entries (any
readable file, the overlay being the operator's) are made absolute against it
before the merge, its bind sources are left to the volume planner, which
resolves them against the same folder as the task's, and the env files of the
merged document are read once after it with the merged environment winning,
as Compose reads them. A task that declares only an image gets Harbor's
one-service group (`main`) first. The merged document goes through the same
field check, volume planner and image resolution as a task's file, and must
keep a services mapping; anything the group cannot run is reported naming the
task's Compose file and the overlay files merged onto it, since the service
or field may come from any of them; an overlay error names the field's path
and the value's kind, or the YAML error's line and column, never a value,
since overlay files carry the deployment's keys. The overlay's services start with the
task's group and stop with it. Prepare reads the same block from the
configuration the command names, records the overlay's images with the tasks'
and checks the merge per task; a server run with an overlay the dataset was
not prepared with (no record of an image, or a record of another platform or
record version, by prepare's own reuse rule), or whose merged document the
deployment cannot run (the seed runs every check prepare ran: the field
check, the volume planner, the services the task's artifacts and collect
hooks name present in the merged document, no extra_hosts on a sidecar whose
recorded image runs as a non-root user), is refused at seed, terminally, with
the reason prepare gives. The merged document is private per episode.
- `mcp_servers`: merged by name with the task's `[[environment.mcp_servers]]`
as Harbor's trial merges the job's with the task's (the overlay's entry
replaces a task entry of the same name); the merged list reaches the harness
in /tmp/.nemo-gym/task.json and in the one grant list of its session seed (an
overlay entry that cannot be granted, an `sse` one, is warned about once per
run, a task's own at every seed as before).
- `prompt_template`: a Jinja file with `{{ instruction }}`, read and compiled
once when the block is read, rendered with StrictUndefined around the
instruction of the episode's first turn before anything is provisioned, so
the harness, the first turn's transcript and a single-turn result carry the
rendered instruction (a multi-step result records the last turn's params);
the rendered turn is sent with the row's own keys only. Later turns are sent
as written (parked).
No task file changes. Documented in the server README and the Harbor tasks
page; the shipped harbor.yaml names the block.
Signed-off-by: Adil Asif <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
/ok to test 0678258 |
yuhezhang-ai
left a comment
There was a problem hiding this comment.
Approving 0678258329d88e30ec525d5b3d4fbb6d5e227968 with one explicit, non-blocking follow-up. The startup user/directory bug remains reproducible and still needs a fix. This approval accepts that work in a follow-up PR; it does not mark the issue resolved.
Adding job-level Compose files to an image-only task can change the user and working directory used by its startup script:
- With
RUN useradd -m app,USER app, andWORKDIR /home/app/work, the script starts asappin/home/app/workwithout the job overlay, but asrootin the base image's/srvwith it. - With
[agent].user = "other", a separate case changes the startup user fromapptoother.
This can break initialization, file ownership, and relative paths. Subsequent agent commands use the intended user and directory. The new exposure requires opting into the job-level Compose files, so I am treating this as a scoped follow-up rather than holding this PR. The reproduction and earlier discussion are in #4863 (comment).
Work still required in the follow-up:
- Preserve the task's effective startup user and directory after setup completes, or explicitly reject unsupported combinations before running the task.
- Add regression coverage comparing startup with and without job overlays for both cases above, while preserving directory ownership during setup.
- Document the limitation for users and link the follow-up issue or PR in the existing thread. Tasks whose initialization depends on these settings need the fix or explicit rejection before relying on this feature.
Validation at this head: 191 focused checks passed, including the original review reproductions. The two additional startup comparisons still fail through the real adapter with fake providers; no live containers were launched for those comparisons. The other earlier findings are addressed. Main CI and the unit/server suites pass; the explicitly non-blocking Kilocode conformance check remains red.
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/40609233979 |
Summary
Job-level Compose overlay for the Harbor environment server (RFC row M30): the run config names extra Compose
files, MCP server entries and a prompt template, the way Harbor's job config names
extra_docker_compose,agents[].mcp_serversand an agent'sprompt_template_path. The overlay is merged onto every task's Composegroup at prepare and at seed, a task that declares only an image gets Harbor's one-service group first, the
overlay's MCP entries reach the harness merged by name with the task's own, and the template is rendered around
the instruction of the episode's first turn. No task file changes; swapping the block swaps the backend (the
memory team's Redis and Hindsight stacks were the acceptance).
What changes
nemo_gym/tasks/harbor/compose_overlay.py(new): thecompose_overlayblock model (files,mcp_servers,prompt_template, every path checked when the block is read, as Harbor refuses a missing extra Compose file);a YAML loader for Compose's
!resetand!overridetags;merge_compose, which merges a later file onto thedocument the way compose-go merges
-ffiles (mappings key by key; sequences appended,ports,volumes,expose,cap_add,env_file, ... unique on their key with the later entry winning;environment,labels,extra_hosts,sysctls,build.argsas mappings in either written form;depends_onand aservice's
networksas mappings;command,entrypoint,healthcheck.testreplaced whole; a key writtenwith no value keeps the earlier file's value, as compose-go keeps it;
!resetremoves the attribute or oneenvironment variable,
!overridereplaces instead of merging; top-levelx-*dropped as Compose ignoresthem); per-file interpolation that keeps the markers; each file's relative paths resolved against the Compose
project directory, the task's
environmentfolder, as Compose resolves every-ffile's and Harbor's--project-directorynames it, never against the overlay file's own folder (itsenv_fileentries, anyreadable file since the overlay is the operator's, made absolute against it before the merge; its bind sources
left to the volume planner, which resolves them against the same folder as the task's), the env
files of the merged document read once after it with the merged
environmentwinning, as Compose reads them(
compose_variables.resolve_env_files/env_file_paths,inline_env_files(document, None, ...)); overlayerrors that name a field's path and the value's type, or a YAML error's line and column, never a value;
synthesized_group()(mainalone) for image-only tasks;merged_mcp_serverswith Harbor'strial.pyrule (task entries first, a job entry replaces a task entry ofthe same name);
compile_prompt_template/render_compiled_template/wrap_first_instructionmirroringHarbor's
utils/templating.py(Jinja2,StrictUndefined,{{ instruction }}required), the block compilingits template once when it is read and rendering the compiled one per episode (
render_instruction).nemo_gym/tasks/harbor/image_configs.py:load_compose_document(task, overlay=...)merges the overlay filesafter the task's file with the same variables (and the deployment's
compose_variablesat seed), or onto thesynthesized group when the task has no Compose file, and refuses a merged document without a
servicesmapping;
record_compose_images(..., overlay=...)records the overlay's images (and an image-only task's own,now
mainof a group) with the tasks'. A field, bind source or service the group cannot run is reportednaming the task's Compose file and the overlay files merged onto it (
compose_source), since it may come fromany of them.
nemo_gym/tasks/harbor/cli.py:compose_overlay_from_overridesreadsharbor_environment_server.environment_servers.harbor.compose_overlayfrom the configuration the command names(like
builds:and the provider blocks);prepare_target,validate_target,run_targetandrun_imagestake it, so prepare checks the merge per task and lists the overlay's images for pre-pulling.
environment_servers/harbor/app.py,sandboxes.py,session.py: thecompose_overlayconfig field; atask is a Compose group when it ships a file or the overlay names files (
_uses_compose); the seed'sprecheck,
_compose_documentand the private per-episode document (an overlay carries the operator'svalues) take the overlay, and the precheck refuses terminally (422) a group whose images prepare did not
record for this deployment (
_check_compose_images: nocompose-images.json, or a merged service whoseentry is missing or not reusable by prepare's own rule,
image_configs.reusable_record: another platform oran old record version; the usual signs of a dataset prepared without this block or on another architecture,
named in the reason) and a merged document the deployment cannot run
(
_check_compose_group: every check prepare ran, factored out of_compose_document: the field check, thevolume planner, the services the task's
artifactsand[[verifier.collect]]hooks name present in the mergeddocument (
image_configs.check_task_compose_services, new, run by prepare too: an overlaykafka: !resetagainst a hook in
kafkaused to pass prepare and both prechecks and fail inside the group's start) and noextra_hostson a sidecar whose recorded image runs as a non-root user(
image_configs.check_task_sidecar_extra_hosts, the record file the seed already read handed in), so an overlaychanged since prepare fails with prepare's reason instead of being retried every episode); the merged MCP list
(
_task_mcp_servers) is what/tmp/.nemo-gym/task.json,the
task_mcp_grantsgrant list and thesupports_task_tool_contextrefusal use (an overlay entry that cannotbe granted, an
sseone, is warned about once per run by name, a task's own at every seed as before);_with_prompt_templaterenders the template around the first turn's user message before anything is provisioned, so the harness,
the first turn's ATIF transcript and a single-turn result carry the rendered instruction (a multi-step
result records the last turn's params, as the M34 record does; a template that does not render is a
terminal seed failure with no sandbox; the rendered turn is sent with the row's own keys only, since the
template round trip dumps the set fields); one INFO line per episode names the merged group's services and MCP
names (the servers log at WARNING by default).
configs/harbor.yamldocuments the block;requirements.txtaddsjinja2>=3.1(already vettedin the
rayextra; the import is lazy, so harnesses that import the module need no Jinja).Parked (noted in the README): wrapping every turn of a multi-step task with the template, and recording each
turn's
responses_create_paramson the turn result so a multi-step rollout shows the rendered first turn; Composesecrets:(the adapter has none, so the memory team's Redis stack needs a third glue file that resets the secret and sets
the variable instead;
configs:likewise);build:on an overlay service.Test plan
tests/unit_tests/test_harbor_compose_overlay.py(39): the memory team's shape merged onto amulti-service task group and onto an image-only task; mapping, sequence, keyed-sequence,
command,depends_on/networks,extra_hosts/labelsrules;!reset(and setting the key again later), aper-variable
!resetthrough two overlay files, a bare re-declaration keeping the earlier value,!override; host substitution per file with defaults and:?; markers kept through interpolation; YAMLshape errors; MCP merge by name with Harbor's order; the block's validation; template rendering, the
missing-
instructionandStrictUndefinedrefusals, first-user-message wrapping;load_compose_documentwith and without a task file, overlay
env_fileand bind sources resolved against the project directory (anoverlay's
./api.envis the task'senvironment/api.env, a same-named file beside the overlay not read;./confand a long-syntax
source: confuploaded from the task'senvironment/, a../that leaves the task a foreignsource,
~the home directory, a bare name a named volume, a missing./conf"which the task folder does notcontain"); shape and YAML errors naming the path and the kind, never a secret-looking value; env files read once after the merge with
the merged
environmentwinning,env_file: !reset []/!override/ append on the task's list,environment: !override [...]replacing, an overlayenv_fileanywhere (absolute, or relative leaving the task)read and a task's escaping one refused;
record_compose_images,run_imagesandprepare_targetrecording the overlay's images; aprivilegedfield, asecrets:block, abuild:, a foreign bind source and a relative one the task lacks in an overlay skipping the taskwith a reason that names the overlay files (and the task's file when it has one);
services: !resetrefusedwith a reason; an overlay that resets a service the task's collect hook runs in skipped naming the overlay files
and the service (and a task's own file lacking a hook's service skipped naming that file); the block compiling its template once (no file read per render, an edit not seen until the
block is read again);
compose_overlay_from_overridesthrough a--configfile with the block swapped byone value.
environment_servers/harbor/tests/test_compose_overlay.py(21): an image-only task resolves tomainplus the overlay's services with
!reset, the extra network and the named volume honoured; the episodeseeds the group and stops it; the merged document stays private; overlay MCP entries merged with the task's
in
task.jsonand the grant list (overlay wins on a name,ssestays in the context file); overlay-only MCPentries refuse a harness without
supports_task_tool_context; the template wraps the first turn of asingle-turn and of a three-step task only, the posted bodies carrying the rows' own keys with the rendered
content (the latter's result recording the last turn's params as written);
a template that does not render fails before any sandbox; an overlay image prepare did not record, a record of
another platform or an old record version, or no record file at all, is a terminal seed refusal naming the
services (and what was recorded) before any group starts; an overlay field the group cannot run, a foreign bind
source no
volume_sourcesentry maps, a relative bind source the task folder lacks, a removedservicesmapping and
extra_hostson the non-root overlay sidecar are terminal seed refusals naming the overlay file,with no group started, each with the reason prepare's
skippedrecords for the same overlay; an overlay thatresets the service a collect hook runs in is refused the same way with prepare's exact reason; a job-level
sseentry is warned about once over three episodes while the task's own
sseentry is warned about at each.environment_servers/harbor/tests -k "not partial_eval and not buildah and not validate_ and not real_image":430 passed (409 on the base + 21 new);
responses_api_agents/harbor_oracle_agent/tests: 22 passed; thetouched core unit test files together (
test_harbor_compose_*,test_harbor_image_*,test_harbor_validation): 268 passed (plus the twotest_harbor_validationtests that read a localenv.yaml, unrelated);ruff check,ruff format --check,pre-commit run --filesclean.gym dataset validateof MemoryArenaBundledShopping0000-baking-item-0(six steps) onOpenSandbox with the oracle, the memory team's Redis overlay (
sse) attached, then the same command with++memory_backend=hindsight(their Hindsight overlay,streamable-http). See REPORT.md in the group folder.🤖 Generated with Claude Code