Skip to content

fix(sdk): portable $defs/semver end-anchor (#1766) - #1767

Merged
FabioLeitao merged 1 commit into
mainfrom
fix/1766-plugin-contract-semver-anchor
Aug 26, 2026
Merged

FabioLeitao merged 1 commit into
mainfrom
fix/1766-plugin-contract-semver-anchor

Conversation

@FabioLeitao

Copy link
Copy Markdown
Collaborator

Summary

  • Align $defs/semver in docs/sdk/PLUGIN_CONTRACT.schema.json (ADR-0086) with ECMA-262: replace final $ with (?![\s\S]) so Python jsonschema (re.search) and JS ajv reject the same strings.
  • Add test_semver_rejects_trailing_newline_on_python_jsonschema in tests/test_plugin_sdk_contract.py (validator Python). "1.0.0" and "1.2.3-alpha.1" remain valid; "1.0.0\n" and "1.0.0 " raise ValidationError.
  • Negative proof before commit: with the old $ pattern the new test failed (DID NOT RAISE ValidationError). After the anchor change it passed.
  • Schema $ scan: grep -o '"pattern": *"[^"]*\$"' docs/sdk/PLUGIN_CONTRACT.schema.json matched only $defs/semver. No other patterns in this file needed the same fix.

Closes #1766

Test plan

  • ./scripts/quick-test.sh --path tests/test_plugin_sdk_contract.py --keyword trailing_newline failed on old $ (negative proof)
  • Same file + full module passed after the pattern change
  • ./scripts/check-all.sh OK on this branch

JSON Schema pattern is ECMA-262; Python re.search treated `$` as
allowing a trailing newline. Use `(?![\s\S])` so `"1.0.0\n"` is
rejected by jsonschema as well as ajv.

Refs: #1766
@strix-security

strix-security Bot commented Aug 26, 2026 •

Copy link
Copy Markdown

Strix Security Review

No security issues found.

Updated for b9e1769.


Reviewed by Strix
Re-run review · Configure security review settings

@greptile-apps

greptile-apps Bot commented Aug 26, 2026

Copy link
Copy Markdown

Greptile Summary

The PR makes the SDK contract’s semver end anchor consistent across Python jsonschema and ECMA-262 validators.

  • Replaces the permissive final $ with (?![\s\S]).
  • Adds regression coverage for valid semver values and trailing newline or space rejection.

Confidence Score: 5/5

The PR appears safe to merge with no actionable correctness, compatibility, or security issue identified.

The schema’s five semver references inherit the corrected pattern, and the current Python validation targets support the new assertion while the regression test covers the behavior being fixed.

Important Files Changed

Filename Overview
docs/sdk/PLUGIN_CONTRACT.schema.json Tightens the shared semver definition with an end-of-input assertion supported by the repository’s current validators.
tests/test_plugin_sdk_contract.py Adds focused regression coverage demonstrating that valid versions pass while trailing newline and space inputs fail.

Reviews (1): Last reviewed commit: "fix(sdk): portable $defs/semver end-anch..." | Re-trigger Greptile

@FabioLeitao
FabioLeitao merged commit 84866c7 into main Aug 26, 2026
23 checks passed
@FabioLeitao
FabioLeitao deleted the fix/1766-plugin-contract-semver-anchor branch August 26, 2026 11:41
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.

fix(schema): $defs/semver da ADR-0086 decide diferente em Python e JS — jsonschema aceita "1.0.0\n", ajv rejeita

1 participant