Skip to content

feat(cli): add driver configuration schema discovery - #1071

Open
kirkbrauer wants to merge 2 commits into
mainfrom
cli-driver-schema-review
Open

feat(cli): add driver configuration schema discovery#1071
kirkbrauer wants to merge 2 commits into
mainfrom
cli-driver-schema-review

Conversation

@kirkbrauer

@kirkbrauer kirkbrauer commented Sep 5, 2026

Copy link
Copy Markdown
Member

Summary

Add jmp driver schema [NAMES...] [-o json|yaml|name] for environment-aware exporter configuration editing. It reports locally installed driver config keys, types, required fields, referenced definitions, client class paths, and package metadata without instantiating drivers or opening a lease itself.

Contract and review fixes

  • JSON/YAML return {drivers: [...]}; tables and name output are also supported.
  • Driver loading/schema errors are per-entry. Failed JSON Schema generation retains best-effort dataclass constructor keys, with error set.
  • Keep Python-level import/schema-hook output on stderr rather than tolerating prefixes before JSON.
  • Preserve nested definitions and handle recursive schemas whose root is a $ref.
  • Exclude common Driver fields and runtime-only (init=False) fields from config keys.
  • Reject unknown filters before loading, including mixed valid/invalid requests; only selected drivers are loaded.
  • Replace environment-dependent/vacuous tests with hermetic entry-point fixtures and direct stdout parsing.
  • Document that imports and metadata/schema hooks execute trusted local package code; discovery is not a sandbox.

The VS Code extension keeps this API behind a dedicated default-off experimentalDriverSchemas flag in addition to its general experimental CLI opt-in. Static YAML schemas and manual allow-list entry remain available without it.

Validation

  • make pkg-test-jumpstarter-cli-driver: 22 passed
  • make pkg-test-jumpstarter-cli: 257 passed
  • make lint-fix: passed
  • make pkg-ty-jumpstarter-cli-driver: passed
  • Local installed-driver smoke: TcpNetwork and Xcp produce typed schemas; Qemu produces constructor keys plus its expected unsupported-type warning. Stdout parses directly as JSON.
  • Extension: 227 unit tests, 73 integration tests, type-check and lint pass.

AI generated, human reviewed

Reports the config keys each installed driver accepts, as JSON Schema
derived from the driver class itself, so tooling can complete and
validate the `config:` block of an exporter config against the drivers
actually installed in the environment.

Fields common to every Driver (uuid, children, log_level, ...) are not
part of a driver's own config and are excluded. A driver that fails to
import is reported with its error rather than sinking the listing, and
one whose field types pydantic cannot model still reports its key names
and required-ness, recovered from the dataclass — 61 of the 67 drivers
installed here yield usable keys.

Signed-off-by: Kirk Brauer <kirkebrauer@gmail.com>
Keep Python-level discovery chatter on stderr, resolve recursive root definitions, exclude non-constructor fields, and reject every unknown requested name before loading. Replace installed-driver-dependent tests with hermetic CLI coverage, fix type-checking, and document the best-effort schema contract and import trust boundary.

Assisted-by: Pi:gpt-6-astra
Signed-off-by: Kirk Brauer <kirkebrauer@gmail.com>
@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Next included review available in 43 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: e70b96f9-8a22-44a5-86e4-caad25fc2014

📥 Commits

Reviewing files that changed from the base of the PR and between ca3b483 and d3f67c7.

📒 Files selected for processing (4)
  • python/packages/jumpstarter-cli-driver/README.md
  • python/packages/jumpstarter-cli-driver/jumpstarter_cli_driver/__init__.py
  • python/packages/jumpstarter-cli-driver/jumpstarter_cli_driver/driver.py
  • python/packages/jumpstarter-cli-driver/jumpstarter_cli_driver/schema_test.py

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

entry.description = _first_docstring_line(cls)
entry.client = _client_class_path(cls)
try:
schema = TypeAdapter(cls).json_schema()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

so it seems that it would fail generating for qemu, becasue it has a TemporaryDirectory field

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Oh yeah, that might be an issue...I will take a look, when testing, it did seem to work OK for most drivers, but I wasn't able to try them all, maybe I can make an audit script

@kirkbrauer
kirkbrauer enabled auto-merge September 8, 2026 17:12
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.

2 participants