Skip to content

fix(harbor): validate schema_version in adapt and stamp it in export - #584

Open
ayushnangia wants to merge 3 commits into
hud-evals:mainfrom
ayushnangia:fix/harbor-schema-version-validation
Open

fix(harbor): validate schema_version in adapt and stamp it in export#584
ayushnangia wants to merge 3 commits into
hud-evals:mainfrom
ayushnangia:fix/harbor-schema-version-validation

Conversation

@ayushnangia

@ayushnangia ayushnangia commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Summary

The Harbor interop's own fidelity promise has a hole in it: export() writes a top-level version = "1.0" into the generated task.toml, but the adapter parses a field named schema_version — so the stamped version is invisible to validation, and a task declaring any unknown schema_version adapts silently with whatever semantics this build happens to implement. A task authored against a future or foreign schema should fail adaptation loudly (the same contract as the other invalid-task paths), not adapt wrong.

Changes

  • hud/integrations/harbor/adapt.py: new HARBOR_SCHEMA_VERSION = "1.0"; adapt() raises ValueError ("declares unsupported Harbor schema ...") when a task's schema_version is present and differs. Absent stays accepted (unversioned tasks are the historical export shape).
  • hud/integrations/harbor/export.py: generated task.toml now stamps schema_version = "1.0" alongside the existing version key, so round-tripped tasks validate against the exact contract they were written by.

Validation

  • New tests in hud/integrations/harbor/tests/test_contract.py: unknown schema fails loudly · supported schema adapts · absent schema still adapts.
  • pytest hud/integrations/harbor/tests65 passed, 0 failed; full suite (hud/tests + capabilities + patches) → 136 passed.

Scope note

Public surface untouched (__all__ stays ["adapt", "export"] per the contract test). This is the schema half of version pinning; if maintainers want task-side pinning (task.toml requiring a HUD version range), that's a follow-up feature and I have the spec sketched.


Note

Low Risk
Localized Harbor integration validation and export metadata; backward compatible for tasks without schema_version.

Overview
Closes a Harbor interop gap where export() only wrote version = "1.0" while adapt() reads schema_version, so exported tasks were unversioned for adaptation and foreign schemas could adapt silently.

adapt() now enforces HARBOR_SCHEMA_VERSION ("1.0"): if task.toml sets a different schema_version, adaptation raises ValueError with an explicit unsupported-schema message. Missing schema_version still adapts for legacy/unversioned tasks.

export() stamps schema_version = "1.0" in generated task.toml (alongside version) so HUD-exported Harbor folders round-trip under the same contract.

Contract tests cover unknown schema (fail), supported schema (adapt), and absent schema (still adapt).

Reviewed by Cursor Bugbot for commit df31867. Bugbot is set up for automated code reviews on this repo. Configure here.

The exported task.toml carries a top-level 'version' key, but the
adapter parses 'schema_version' — so the stamped version was invisible
to validation and a task declaring any unknown schema_version adapted
silently with wrong semantics. Define HARBOR_SCHEMA_VERSION, fail
adaptation loudly for unsupported values, and stamp the field in export
so round-tripped tasks validate against the same contract.
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