Skip to content

Migrate to TemplateString from Spine Base#303

Merged
alexander-yevsyukov merged 37 commits into
masterfrom
migrate-to-template-string-from-base
May 16, 2026
Merged

Migrate to TemplateString from Spine Base#303
alexander-yevsyukov merged 37 commits into
masterfrom
migrate-to-template-string-from-base

Conversation

@alexander-yevsyukov
Copy link
Copy Markdown
Collaborator

@alexander-yevsyukov alexander-yevsyukov commented May 15, 2026

This PR migrates Validation to use TemplateString and Placeholder from Spine Base. This is the next step in improving the extensibility of working with placeholders in libraries that extend Validation.

The build was extended with the temporary tasks that patch the code generated for Protobuf types in jvm-runtime and context modules. The code replaces references to io.spine.validation.TemplateString and associated types to those belonging to the io.spine.string package from Base.

Migrate `TemplateString` Protobuf message, the `Placeholder` interface,
and the general-purpose template string extensions from `jvm-runtime`
to the `io.spine.string` package in the `base` module.

Validation-specific extensions (`withField`, `withCompanion`, `withRegex`)
stay here.

Follow-up: the upstream `core-jvm-compiler-plugin` still emits
`io.spine.validation.TemplateString.newBuilder()` into generated Java
for `:context`'s own option messages. Republishing the compiler plugin
against the new base is required to unblock `:context:compileJava`.
Copilot AI review requested due to automatic review settings May 15, 2026 18:07
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Migrates the validation library from its internal TemplateString/Placeholder types to the equivalents now provided by Spine Base (io.spine.string.TemplateString, io.spine.string.Placeholder). The rename of the runtime placeholder enum from ErrorPlaceholder to StandardPlaceholder is applied across model, generators, runtime, tests, and docs. A new (currently disabled) :tests:time module is added as a placeholder for future Spine Time integration tests, and the relevant Spine Base/Time/CoreJvmCompiler dependency versions are bumped.

Changes:

  • Replace internal io.spine.validation.TemplateString / format / formatUnsafe / extractPlaceholders / checkPlaceholdersHasValue with the io.spine.string equivalents from Spine Base; delete the now-superseded error_message.proto, TemplateStringExtsSpec, and the deprecated context-side ErrorPlaceholder.
  • Rename ErrorPlaceholderStandardPlaceholder (implementing io.spine.string.Placeholder), keep a deprecated RuntimeErrorPlaceholder typealias, and propagate Map<Placeholder, Expression<String>> signatures through generators and the SetOnce constraint builder.
  • Add the new :tests:time module (build script, proto definitions, fixtures, assertions, and @Disabled Timestamp/Temporal (when) specs), bump Base to SNAPSHOT.388, Time to SNAPSHOT.240, CoreJvmCompiler dogfooding to SNAPSHOT.064, and refresh the dependency report.

Reviewed changes

Copilot reviewed 69 out of 69 changed files in this pull request and generated no comments.

Show a summary per file
File Description
jvm-runtime/src/main/proto/spine/validation/error_message.proto Removed; TemplateString now sourced from spine/string/template_string.proto.
jvm-runtime/src/main/proto/spine/validation/validation_error.proto Switches ConstraintViolation.message to spine.string.TemplateString and updates the Java helper class reference.
jvm-runtime/src/main/kotlin/io/spine/validation/StandardPlaceholder.kt Renames the enum, makes it implement Placeholder, updates the deprecated typealias.
jvm-runtime/src/main/kotlin/io/spine/validation/TemplateStringExts.kt Drops local format/formatUnsafe/extractPlaceholders/checkPlaceholdersHasValue; keeps validation-specific builder helpers.
jvm-runtime/src/main/kotlin/io/spine/validation/{TimestampValidator,DetectedViolation,ValidatorRegistry}.kt Re-imports TemplateString/templateString and StandardPlaceholder from new locations.
jvm-runtime/src/main/java/io/spine/validation/ViolationText.java Imports format from io.spine.string.TemplateStrings.
jvm-runtime/src/test/kotlin/io/spine/validation/TemplateStringExtsSpec.kt Removed (functionality moved to Spine Base).
jvm-runtime/src/test/kotlin/io/spine/validation/{ValidatorRegistrySpec,given/TemplateStrings}.kt Updated imports.
context/src/main/kotlin/io/spine/tools/validation/ErrorPlaceholder.kt Removed deprecated context-side enum.
context/src/main/kotlin/io/spine/tools/validation/ErrorPlaceholders.kt Switches signatures to Set<Placeholder> and uses extractPlaceholders from Spine Base.
context/src/main/kotlin/io/spine/tools/validation/option/{ChoiceOption,DistinctOption,GoesOption,PatternOption,RequireOption,SetOnceOption,required/RequiredOption}.kt Update imports to StandardPlaceholder.
context/src/main/kotlin/io/spine/tools/validation/bound/{MaxOption,MinOption,RangeOption}.kt Same StandardPlaceholder import update.
java/src/main/kotlin/io/spine/tools/validation/java/expression/{TemplateStrings,ConstraintViolations,ClassNames}.kt Switch to Placeholder/TemplateString from io.spine.string; remove deprecated overload accepting context-side ErrorPlaceholder.
java/src/main/kotlin/io/spine/tools/validation/java/generate/{ValidatorGenerator,option/*Generator,option/bound/*Generator}.kt Use Placeholder typed maps and StandardPlaceholder constants.
java/src/main/kotlin/io/spine/tools/validation/java/setonce/SetOnceConstraintViolation.kt Same migration to Placeholder/StandardPlaceholder.
tests/consumer/build.gradle.kts Wraps duplicate :tests:extensions dependency declaration with a suppression.
tests/consumer/src/test/kotlin/.../{ErrorMessageSpec,MinRuleITest,PatternRuleITest,RequiredRuleITest,ValidateRuleITest}.kt Import format/formatUnsafe from io.spine.string.
tests/runtime/src/test/kotlin/io/spine/validation/option/ChoiceSpec.kt Same format import update.
tests/validating/src/testFixtures/.../Assertions.kt and src/test/kotlin/.../{NumberConstraintsITest,RequireITest,ChoiceITest,goes/GoesViolationITest,setonce/SetOnceViolationITest}.kt Update imports to io.spine.string helpers and StandardPlaceholder.
tests/validator/src/main/kotlin/.../{EarphonesValidator,TheOnlyTimeValid}.kt Use TemplateString/templateString from io.spine.string.
tests/vanilla/src/test/kotlin/.../IsRequiredSpec.kt Update format import.
settings.gradle.kts Includes the new :tests:time subproject.
tests/time/build.gradle.kts New build script wiring io.spine.time plugin and validation compiler plugins.
tests/time/src/test/proto/spine/test/validation/time/when.proto New proto fixtures with (when) PAST/FUTURE messages for both Protobuf Timestamp and Spine LocalDateTime.
tests/time/src/test/kotlin/.../{Assertions,Fixtures,TimestampWhenSpec,TemporalWhenSpec}.kt New test helpers and @Disabled specs awaiting Spine Time migration to the new Placeholder API.
docs/content/docs/validation/developer/{validation-model,runtime-library,adding-a-built-in-option}.md Update documentation references from ErrorPlaceholder to StandardPlaceholder/Placeholder.
docs/dependencies/{pom.xml,dependencies.md} Refresh dependency manifest and license report (adds spine-time-java, version bumps, new validation-time module section).
buildSrc/src/main/kotlin/io/spine/dependency/local/{Base,Time,CoreJvmCompiler}.kt Bump Spine Base, Time, and CoreJvmCompiler dogfooding versions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ba82d5448a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread jvm-runtime/src/main/kotlin/io/spine/validation/StandardPlaceholder.kt Outdated
Copy link
Copy Markdown

Copilot AI commented May 15, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/graphql
    • Triggering command: /usr/bin/gh gh issue create --repo SpineEventEngine/validation --title Enable tests in tests/timeonce Spine Time migrates toPlaceholderAPI --body TheTimestampWhenSpecandTemporalWhenSpectests in thetests/timemodule are currently disabled with@disabledannotations because they depend on Spine Time supporting the newio.spine.string.Placeholder API introduced in the TemplateString mig (http block)
    • Triggering command: /usr/bin/gh gh auth status (http block)
    • Triggering command: /usr/bin/curl curl -s -X POST REDACTED -H Authorization: ****** -H Content-Type: application/json -d {&#34;query&#34;:&#34;mutation { __typename }&#34;} (http block)
  • https://api.github.com/repos/SpineEventEngine/validation/issues
    • Triggering command: /usr/bin/gh gh api -X POST /repos/SpineEventEngine/validation/issues --field title=Enable tests in tests/timeonce Spine Time migrates toPlaceholderAPI --field body=TheTimestampWhenSpecandTemporalWhenSpectests in thetests/time module are currently disabled. (http block)
  • https://api.github.com/zen
    • Triggering command: /usr/bin/curl curl -s REDACTED (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI review requested due to automatic review settings May 15, 2026 22:38
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 81 out of 82 changed files in this pull request and generated 2 comments.

Comment thread buildSrc/src/main/kotlin/PatchGeneratedTemplateString.kt
Comment thread buildSrc/src/main/kotlin/PatchGeneratedTemplateString.kt
Copy link
Copy Markdown
Collaborator

@armiol armiol left a comment

Choose a reason for hiding this comment

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

@alexander-yevsyukov LGTM once the checks pass.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 81 out of 82 changed files in this pull request and generated 1 comment.

Copilot AI review requested due to automatic review settings May 16, 2026 15:57
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 83 out of 84 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings May 16, 2026 17:38
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 84 out of 85 changed files in this pull request and generated no new comments.

@alexander-yevsyukov alexander-yevsyukov merged commit e05904c into master May 16, 2026
9 checks passed
@alexander-yevsyukov alexander-yevsyukov deleted the migrate-to-template-string-from-base branch May 16, 2026 17:49
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.

4 participants