发布

  • [OPIK-6454] [BE] feat: add sequential prompt version numbers (#6789)

    frostbyte_neo 发布于 2026-05-20 14:34:00 +00:00

    • [OPIK-6454] [BE] feat: add sequential prompt version numbers

    Introduces a read-only version_number field on prompt versions ("v1",
    "v2", ...) and exposes it via the prompt REST API. Generation uses
    MAX(version_number) + 1 scoped to non-mask versions and is serialized
    per (workspace, prompt) via a unified prompt-version lock that also
    covers environment promotion. Masks keep version_number NULL; the
    unique index (workspace_id, prompt_id, version_number) tolerates
    multiple NULLs.

    • Adds liquibase migration 000073 with column + unique index, no
      backfill of existing rows (per ticket scope).
    • Exposes version_number in PromptVersion DTO and in every JSON_OBJECT
      builder (findById latest/requested, findByIds, findByCommit).
    • Adds GET /v1/private/prompts/{promptId}/versions/by-number/{versionNumber}.
    • Extends POST /v1/private/prompts/versions/retrieve with an optional
      version_number, mutually exclusive with commit and environment
      (validated on the DTO via @AssertTrue).
    • Unifies PROMPT_ENV_PROMOTE_LOCK and version-number lock into a single
      PROMPT_VERSION_LOCK keyed by workspace+prompt.
    • Adds integration tests covering sequential numbering, mask
      exclusion, by-number lookup, retrieve-by-number, mutual-exclusion
      validation, and version-number assignment on restore.

    Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com

    • fix(prompts): address PR feedback on sequential version numbers
    • Force version_number to null for MASK versions before saving to avoid leakage from incoming requests and unique-index conflicts
    • Assert sequential version_number pattern and uniqueness in prompt versions listing tests
    • Add trailing blank line to migration 000073 per migrations convention

    Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com

    • Address comment
    下载附件