Skip to content

feat(plugin-api): export the configuration, build, and run surfaces - #2148

Open
DABH wants to merge 3 commits into
NVIDIA:developfrom
DABH:plugin-api-runtime-exports
Open

feat(plugin-api): export the configuration, build, and run surfaces#2148
DABH wants to merge 3 commits into
NVIDIA:developfrom
DABH:plugin-api-runtime-exports

Conversation

@DABH

@DABH DABH commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Description

Third-party plugin packages are asked to import plugin-authoring symbols only from the stable nat.plugin_api facade (per docs/source/extend/third-party-plugins.md). However, plugins that programmatically load, build, or drive workflows — front ends, execution instrumentation, and test harnesses — currently have to import implementation modules for every step of that flow:

  • Config (nat.data_models.config) plus load_config, PluginTypes, and discover_and_register_plugins (nat.runtime.loader) to discover installed plugins and produce a validated configuration object.
  • WorkflowBuilder (nat.builder.workflow_builder) to build the configured workflow.
  • Runner (nat.runtime.runner) and ExporterManager (nat.observability.exporter_manager) to drive a run the same way Workflow.run does.

On top of that, the built Workflow keeps its entry function private (self._entry_fn), so a caller that wants to construct a Runner for it, or introspect the workflow's input and output contracts, has to reach into a private attribute.

This change is purely additive:

  • Re-export the symbols above through nat.plugin_api and extend __all__.
  • Add a public read-only entry_fn property to Workflow with a docstring; internal call sites are unchanged.
  • Pin the new symbols in EXPECTED_PLUGIN_API_EXPORTS.
  • Add a consumer-style test that, importing only from nat.plugin_api, registers a function, loads a minimal config, builds it with WorkflowBuilder, reads workflow.entry_fn, and drives a run with Runner, sourcing the exporter manager from the built workflow's public read-only exporter_manager property the same way Workflow.run does, so the demonstrated pattern preserves configured telemetry exporters.
  • Document the new surface in docs/source/extend/plugin-api.md: two new surface-review rows ("Configuration loading and plugin discovery" and "Workflow build and run", both proposed as provisional public, matching the promotion tier of the runtime context access row), a new public-surface bullet, and a reworked WorkflowBuilder note in the private-modules section. The runtime context access row no longer lists exporter management as unpromoted, and the builder-type row no longer describes concrete builders as implementation details — it now points at the "Workflow build and run" row, which also tells callers constructing a Runner directly to source the exporter manager from the built workflow.

Workflow.run remains the simplest way to execute a built workflow. Runner and ExporterManager are exported for callers that need to own the run scope — for example supplying their own ContextState or instrumenting the runner lifecycle — and ExporterManager is the declared type of both the built workflow's public exporter_manager property and Runner's required exporter_manager parameter, so driving a run through the facade needs it importable.

register_front_end and the front-end hosting contract remain deferred; this PR only promotes the objects needed to load a configuration, build it, and drive runs.

No tracking issue exists for this yet; happy to file one if the team prefers.

Testing

  • uv run pytest packages/nvidia_nat_core/tests/nat/test_plugin_api.py — 8 passed (includes the new consumer-style test).
  • uv run pytest packages/nvidia_nat_core/tests/nat/builder packages/nvidia_nat_core/tests/nat/runtime packages/nvidia_nat_core/tests/nat/middleware packages/nvidia_nat_core/tests/nat/observability — 1341 passed.
  • uv run pytest packages/nvidia_nat_core/tests --ignore=packages/nvidia_nat_core/tests/eval/test_eval_callbacks.py --ignore=packages/nvidia_nat_core/tests/nat/finetuning/interfaces/test_trajectory_builder.py — 2585 passed, 236 skipped. The two ignored modules import the eval plugin extra (not installed locally) and fail to collect identically on the base branch.
  • uv run pre-commit run yapf --files <touched files> and uv run pre-commit run ruff-check --files <touched files>, uv run python ci/scripts/copyright.py --verify-apache-v2, vale and the markdown-link-check hook on the touched Markdown file, and uv run python ci/scripts/path_checks.py all pass.

By Submitting this PR I confirm:

  • I am familiar with the Contributing Guidelines.
  • We require that all contributors "sign-off" on their commits. This certifies that the contribution is your original work, or you have rights to submit it under the same license, or a compatible license.
    • Any contribution which contains commits that are not Signed-Off will not be accepted.
  • When the PR is ready for review, new or existing tests cover these changes.
  • When the PR is ready for review, the documentation is up to date with these changes.

Summary by CodeRabbit

  • New Features

    • Expanded the public plugin API with configuration loading, plugin discovery, workflow building and execution, and exporter management.
    • Added read-only access to a workflow’s entry function for execution and contract inspection.
    • Added public access to workflow builders, runtime utilities, and exporter management.
  • Documentation

    • Clarified provisional API surfaces, usage constraints, and recommended imports for programmatic workflow construction.
  • Tests

    • Added coverage for discovering plugins, loading configuration, building and running workflows, and accessing workflow metadata.

Third-party plugins that build workflows or drive runs (front ends,
execution instrumentation, test harnesses) currently have to import
implementation modules for that flow, contradicting the guidance that
external plugin packages import only from nat.plugin_api.

- Re-export Config, load_config, PluginTypes,
  discover_and_register_plugins, WorkflowBuilder, Runner, and
  ExporterManager through nat.plugin_api and extend __all__.
- Add a public read-only entry_fn property to Workflow so callers can
  reach the entry Function without touching private attributes.
- Pin the new exports in EXPECTED_PLUGIN_API_EXPORTS and add a
  consumer-style test that loads a config, builds it with
  WorkflowBuilder, reads workflow.entry_fn, and drives a run with
  Runner using facade imports alone.
- Document the new provisional surface rows in
  docs/source/extend/plugin-api.md.

Signed-off-by: David Hyde <DABH@users.noreply.github.com>
@copy-pr-bot

copy-pr-bot Bot commented Jul 28, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: c0bbbf7f-7746-48b7-ab31-9c835c3b3a27

📥 Commits

Reviewing files that changed from the base of the PR and between 7469aaa and 4fbbfa1.

📒 Files selected for processing (3)
  • docs/source/extend/plugin-api.md
  • packages/nvidia_nat_core/src/nat/builder/workflow.py
  • packages/nvidia_nat_core/tests/nat/test_plugin_api.py
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/nvidia_nat_core/src/nat/builder/workflow.py
  • packages/nvidia_nat_core/tests/nat/test_plugin_api.py
  • docs/source/extend/plugin-api.md

Walkthrough

The plugin API now exports workflow, runtime, configuration, discovery, and exporter interfaces. Workflow.entry_fn provides read-only access to the entry function. Documentation and an integration test cover the public build-and-run lifecycle.

Changes

Plugin API surface

Layer / File(s) Summary
Public API exports
packages/nvidia_nat_core/src/nat/plugin_api/__init__.py, packages/nvidia_nat_core/tests/nat/test_plugin_api.py
The public module exports workflow, configuration, exporter, runtime, and plugin discovery symbols. Tests verify the export contract.
Workflow runtime access and validation
packages/nvidia_nat_core/src/nat/builder/workflow.py, packages/nvidia_nat_core/tests/nat/test_plugin_api.py
Workflow.entry_fn provides typed read-only access to the entry function. An integration test discovers plugins, loads configuration, builds a workflow, checks entry_fn and exporter_manager, and runs it through Runner.
Plugin API documentation
docs/source/extend/plugin-api.md
The documentation identifies provisional public surfaces and describes the WorkflowBuilder lifecycle and public import path.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Test as Public API test
  participant Discovery as discover_and_register_plugins
  participant Config as load_config
  participant Builder as WorkflowBuilder
  participant Workflow as Workflow
  participant Runner
  Test->>Discovery: discover configuration plugins
  Test->>Config: load workflow configuration
  Test->>Builder: build configured workflow
  Builder-->>Workflow: return built workflow
  Test->>Workflow: read entry_fn and exporter_manager
  Test->>Runner: execute workflow
  Runner->>Workflow: invoke entry function
  Workflow-->>Runner: return transformed result
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise, descriptive, uses imperative mood, and accurately summarizes the exported plugin API surfaces.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@DABH
DABH marked this pull request as ready for review August 5, 2026 22:25
@DABH
DABH requested a review from a team as a code owner August 5, 2026 22:25

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
packages/nvidia_nat_core/src/nat/builder/workflow.py (1)

83-89: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a Google-style Returns: section.

Workflow.entry_fn returns a Function, but the public API docstring does not document the return value. Add a Returns: section.

As per coding guidelines, “Provide Google-style docstrings for every public module, class, function and CLI command.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/nvidia_nat_core/src/nat/builder/workflow.py` around lines 83 - 89,
Add a Google-style Returns section to the public Workflow.entry_fn docstring,
documenting that it returns the workflow’s entry Function used to dispatch each
run. Keep the existing read-only guidance unchanged.

Source: Coding guidelines

packages/nvidia_nat_core/tests/nat/test_plugin_api.py (1)

550-550: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a type annotation for tmp_path.

Annotate tmp_path as Path. This keeps the new test compatible with the required type-checking standard.

As per coding guidelines, “All public APIs require Python 3.11+ type hints on parameters and return values.” As per path instructions, “Python methods should use type hints for all parameters.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/nvidia_nat_core/tests/nat/test_plugin_api.py` at line 550, Update
the test_consumer_style_config_build_and_run function signature to annotate
tmp_path with Path, using the existing pathlib import or adding it if needed;
preserve the test’s behavior and annotate only the requested parameter.

Sources: Coding guidelines, Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/source/extend/plugin-api.md`:
- Line 107: Rewrite the possessive phrase in the “Workflow build and run” table
entry, replacing “the built workflow’s read-only exporter_manager property” with
“the read-only exporter_manager property of the built workflow” while preserving
the surrounding guidance.

---

Nitpick comments:
In `@packages/nvidia_nat_core/src/nat/builder/workflow.py`:
- Around line 83-89: Add a Google-style Returns section to the public
Workflow.entry_fn docstring, documenting that it returns the workflow’s entry
Function used to dispatch each run. Keep the existing read-only guidance
unchanged.

In `@packages/nvidia_nat_core/tests/nat/test_plugin_api.py`:
- Line 550: Update the test_consumer_style_config_build_and_run function
signature to annotate tmp_path with Path, using the existing pathlib import or
adding it if needed; preserve the test’s behavior and annotate only the
requested parameter.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 422c5d0b-3754-4fcf-9e90-f48bc470ecd1

📥 Commits

Reviewing files that changed from the base of the PR and between 2618705 and 7469aaa.

📒 Files selected for processing (4)
  • docs/source/extend/plugin-api.md
  • packages/nvidia_nat_core/src/nat/builder/workflow.py
  • packages/nvidia_nat_core/src/nat/plugin_api/__init__.py
  • packages/nvidia_nat_core/tests/nat/test_plugin_api.py

Comment thread docs/source/extend/plugin-api.md Outdated
…sive phrasing

Address review feedback: add a Google-style Returns section to the
Workflow.entry_fn docstring, annotate the tmp_path parameter of the
consumer-style end-to-end test with Path, and rewrite the possessive
phrase for the built workflow in the plugin API surface table.

Signed-off-by: David Hyde <DABH@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant