# Open Source Contribution — Apicurio Registry (Apicurio/apicurio-registry) — PR #10724

> Author: Lokesh Ram Chand, software engineer in Hyderabad. Portfolio: https://lokeshrc.me

## Overview

| Field | Details |
|---|---|
| Project | Apicurio Registry |
| Repository | apicurio-registry |
| Repository URL | https://github.com/Apicurio/apicurio-registry |
| Organization | Apicurio (Red Hat-backed, Apache-licensed open-source project) |
| Contribution Type | Bug fix — direct follow-up to a reviewer-raised, deliberately deferred item from an earlier merged PR (#10017) |
| Role | External/community contributor (self-assigned the linked issue via `/assign-me`; explicitly self-assigned reviewers via `/assign`; not a listed project MEMBER) |
| Start Date | 2026-10-27 (issue filed and PR opened the same day) |
| End Date | 2026-11-03 (PR merged, issue closed) |
| Status | **Merged** ✅ — shipped in milestone **3.4.0** |
| Primary Language(s) | Java |
| Technologies / Frameworks | Quarkus, Jackson (`ObjectMapper`, JSON deserialization), JUnit 5, REST Assured (`@QuarkusTest` black-box endpoint tests), Maven (multi-module reactor), SonarCloud, GitHub Actions (custom "Verify → Decide → Verification Gate" pipeline), an automated ownership/interest-weighted reviewer-assignment bot, GitHub Copilot automated PR review |
| Area | AI/agent subsystem — prompt template rendering and schema-style variable validation (`io.apicurio.registry.agents.services.PromptRenderingService`) |

---

## Project Context

### What the Project Is

Apicurio Registry is an Apache License 2.0, Red-Hat-backed open-source **API and schema registry**: it stores and manages schemas (Avro, Protobuf, JSON Schema, GraphQL, etc.) and API definitions (OpenAPI, AsyncAPI, etc.), with artifact versioning, content-validation rules, compatibility checking, and a client ecosystem (Java/Go/Python SDKs, Kafka SerDes, a Maven plugin, a CLI, and a Kubernetes operator). At the time of this record the repository has **949 stars** and **652 forks**, was created **2019-07-16**, and remains under very active, daily development.

**Tech stack by volume.** Java dominates the codebase (~13.5 MB of source) via a large multi-module Maven reactor, with a substantial TypeScript/HTML/CSS/JS presence for the separate npm/Vite-built web UI, plus Python and Go source for the Python and Go SDKs, Shell/Makefile/Dockerfile build tooling, Handlebars templates, Open Policy Agent (Rego) policy files, and a small amount of PL/pgSQL for Postgres-specific storage code.

**Build system.** The project requires **JDK 21+** to build (the build tooling itself, e.g. Checkstyle, needs a Java 21+ runtime), while client-facing artifacts (SDKs, SerDes, the Maven plugin) still target Java 17 bytecode; only the server (`app`, `authz`) and the Kubernetes operator target Java 21 at runtime. A **three-tier build system** (`-Dlocal` / default / `-Dfull`) lets contributors build only the slice of the ~60–70-module reactor they need, from a fast "core server + SDK + serializers" local build up to a full CI/release build including the MCP server, Go SDK, and operator. The Java SDK is code-generated from the OpenAPI spec via Microsoft's Kiota generator; the Go and Python SDKs generate their own clients independently, each pinned to its own, currently-different, Kiota version.

**Storage architecture.** Since version 3.0 the project ships a **single artifact that can run any of four storage variants**, chosen at runtime via `apicurio.storage.kind` / `APICURIO_STORAGE_KIND`: **In-Memory** (the dev-mode default), **SQL** (with the RDBMS dialect — PostgreSQL, MySQL, or the community-maintained SQL Server dialect — picked via `APICURIO_STORAGE_SQL_KIND`), **KafkaSQL** (event-sourced, replicated through a Kafka topic), and two *experimental* variants gated behind `APICURIO_FEATURES_EXPERIMENTAL_ENABLED=true`: **GitOps** and **Kubernetes ConfigMap**. Storage implementations live under `app/src/main/java/io/apicurio/registry/storage/impl/`, and any non-variant-specific change there must, per project convention, be validated across all four variants.

**REST API.** The registry's functionality is exposed at `/apis/registry/v3/`, implemented under `app/src/.../rest/v3/impl/`, with response DTOs explicitly shared between the server and the generated Java SDK. The project's hard rule that API responses must never leak internal state (stack traces, raw exception text, internal class names) applies project-wide.

**The "agents" subsystem.** A newer, actively growing area of the codebase (`io.apicurio.registry.agents.*` in `app`, plus `schema-util/agents`) layers AI/agent-facing capabilities on top of the core registry: A2A support, MCP tool definitions and an MCP Registry, an "AI Catalog," agent-resource-descriptor (ARD) work, and — the area both of my merged PRs touch — **prompt template rendering**: a feature that lets a caller define a reusable, parameterized LLM prompt with typed, schema-validated variables (string/integer/number/boolean/array/object), each with an optional `default` and optional constraints (`minimum`/`maximum`/`enum`), then render it by substituting caller-supplied values over declared defaults and validating the merged result. Core registry code is architecturally forbidden from referencing the agents package directly — any interaction must go through `io.apicurio.registry.extensions` — and an ArchUnit test, `AgentsBoundaryTest`, fails the build if that boundary is crossed. A notable API design choice visible throughout this feature: a structural validation failure on a rendered prompt is **not** surfaced as an HTTP error status. The render endpoint still returns **HTTP 200** with the rendered text *and* a structured `validationErrors` array describing exactly which variable failed and why — validation failures are data in the response body, not transport-level errors.

**Review-routing automation.** Beyond the "Verify → Decide → Verification Gate" CI pipeline and SonarCloud quality gating already visible on earlier PRs, this PR surfaced another piece of the project's process tooling directly: an **automated, weighted reviewer-assignment bot**. On PR open, it computes a per-maintainer score from file/area ownership (weight 0.55), stated topical interest (weight 0.30), whether the maintainer authored the linked issue (weight 0.15), and current review load over the trailing 30 days, then posts the scored table and auto-assigns the top candidate. On this PR it independently landed on `carlesarnal` (score 0.67, driven entirely by `area/sdk` ownership) ahead of `EricWittmann` and `jsenko` (0.12 each) — matching, and reinforcing, the two maintainers I had already explicitly tagged by hand.

**Code style and commit conventions.** Unchanged from the rest of the project: a tiered `.checkstyle/checkstyle.xml` (a small error-severity tier that fails the build; a larger warning-severity "staged" tier of real conventions not yet fully satisfied by the existing codebase), Conventional Commits (`type(scope): description (#PR)`), and mandatory DCO sign-off on every commit.

### My Contribution Context

This PR is a **direct, tracked follow-up** to my earlier merged PR, #10017. During that PR's review, the maintainer (`jsenko`) raised an optional item, **O1**: a `default` of `5.0` for a `type: integer` prompt variable was by then correctly coerced and accepted, but a *caller-supplied* value of `7.0` for that same variable was still rejected — the two code paths disagreed. I explicitly deferred O1 to a follow-up issue at the time rather than widen #10017's scope. This PR, and its linked issue #10723, is that follow-up, delivered exactly as promised.

### Relevant Component

- `app/src/main/java/io/apicurio/registry/agents/services/PromptRenderingService.java` — same service as #10017; this PR adds `coerceSuppliedVariables()` and a shared `coerceWholeNumberForInteger()` helper, and makes `validateEnum()` type-aware.
- `app/src/test/java/io/apicurio/registry/agents/services/PromptRenderingServiceTest.java` — unit-level regression tests (direct Java object construction).
- `app/src/test/java/io/apicurio/registry/noprofile/rest/v3/PromptRenderTest.java` — **new in this PR**: true black-box REST endpoint tests (`@QuarkusTest` + REST Assured) that exercise the fix through a real HTTP request body and Jackson's own JSON deserialization, not just direct Java object construction.

---

# Contributions

## Contribution 1 — Fix integer-typed prompt variables rejecting a caller-supplied whole-number decimal, and matching decimal enum entries

**Type:** Bug fix (direct continuation of a previously deferred review item) + a second, review-discovered sub-bug fix (decimal `enum` matching) + REST-layer test coverage added in response to review
**Status:** Merged into `main`, milestone 3.4.0
**Date:** Opened 2026-10-27 · Merged 2026-11-03 (≈ 1 week end-to-end — notably faster than #10017's 7-week wait, largely because the same maintainer already had full context)

### Problem

PR #10017 fixed `type: integer` prompt variables whose *schema default* was written as a whole-number decimal (`default: 5.0`). It deliberately did **not** touch caller-supplied values, because that was flagged as a separate, out-of-scope concern (O1) during that PR's review. The result, confirmed with a `@QuarkusTest` against the real REST endpoint on `main` before I started this fix:

| `max_results` supplied | HTTP | `rendered` | `validationErrors` |
|---|---|---|---|
| omitted (default `5.0`) | 200 | `Limit: 5` | `[]` |
| `7` | 200 | `Limit: 7` | `[]` |
| `7.0` | 200 | `Limit: 7.0` | `Type mismatch: expected integer but got number` |
| `7.5` | 200 | `Limit: 7.5` | `Type mismatch: expected integer but got number` (correct) |

A caller-supplied `7.0` — a perfectly ordinary way for a JSON client to serialize a whole number — was rejected with the exact same spurious error #10017 had already eliminated for defaults. Worse, it was rendered with a stray `.0` even while being flagged as invalid, an inconsistent combination.

### My Work

1. Filed **issue #10723**, explicitly framed as the tracked follow-up to #10017's O1, with a reproduction table captured directly from a `@QuarkusTest` run against the real endpoint on current `main`.
2. Self-assigned the issue via `/assign-me`.
3. Opened **PR #10724** the same day, and **explicitly self-assigned both relevant reviewers** (`/assign @carlesarnal @jsenko`) — the maintainer who had reviewed the originating PR, plus the area-owning maintainer — and posted a comment giving them the full back-reference to #10017's O1 so neither needed to re-derive context.
4. Fixed a second, related bug that GitHub Copilot's review caught: a whole-number decimal `enum` entry (`enum: [5.0, 7.0]`) didn't match a coerced caller-supplied value, because the comparison was done on un-normalized string forms.
5. Added genuine REST-endpoint-level test coverage (not just unit tests) after Copilot correctly pointed out that the existing tests only ever constructed `Double` objects directly in Java and never exercised the real JSON-to-`Double` deserialization path a live HTTP request actually takes.
6. Kept the branch current with minimal friction — at one point a maintainer (`carlesarnal`) pushed a merge-from-`main` commit directly onto my branch, which only works if "Allow edits from maintainers" is enabled on the PR.

### Technical Implementation

**The core fix — sharing the coercion logic.** #10017's `convertDefaultValue()` contained the whole-number-to-`Long` coercion inline. This PR extracted that logic into a standalone, reusable helper:

```java
private Object coerceWholeNumberForInteger(Object value, String declaredType) {
    if (TYPE_INTEGER.equals(declaredType) && value instanceof Double doubleValue
            && doubleValue == Math.rint(doubleValue)
            && doubleValue >= Long.MIN_VALUE && doubleValue < LONG_RANGE_UPPER_BOUND_EXCLUSIVE) {
        return doubleValue.longValue();
    }
    return value;
}
```

`convertDefaultValue()` now simply delegates to it, and a new method applies the same helper to caller-supplied values **before** validation runs:

```java
private Map<String, Object> coerceSuppliedVariables(Map<String, Object> variables,
        JsonNode variablesSchema) {
    if (variablesSchema.isMissingNode() || !variablesSchema.isObject()) {
        return variables;
    }
    Map<String, Object> coerced = null;
    for (Map.Entry<String, Object> entry : variables.entrySet()) {
        if (!(entry.getValue() instanceof Double)) {
            continue;
        }
        String declaredType = variablesSchema.path(entry.getKey()).path("type").asText(TYPE_STRING);
        Object converted = coerceWholeNumberForInteger(entry.getValue(), declaredType);
        if (converted != entry.getValue()) {
            if (coerced == null) {
                coerced = new HashMap<>(variables);
            }
            coerced.put(entry.getKey(), converted);
        }
    }
    return coerced != null ? coerced : variables;
}
```

This is called from `render()` right after the variable schema is extracted, before `validateVariables()` runs. Two deliberate, defensive properties stand out: it short-circuits immediately for any variable whose value isn't a `Double` (zero overhead for the common string/boolean/array/object cases), and it **never mutates the caller's own map** — a copy is created lazily, only the first time an actual coercion is needed, via the `coerced == null` check. This matters because the caller-supplied map's concrete type isn't under this method's control; the regression tests deliberately pass in `Map.of("max_results", 7.0)` — Java's genuinely immutable map — specifically so that any attempt to mutate the original in place would throw `UnsupportedOperationException` and fail the test immediately. The maintainer's review explicitly called this detail out as verified evidence, not just an assumption.

**The second bug — decimal `enum` entries didn't match coerced values.** A schema declaring `enum: [5.0, 7.0]` for a `type: integer` variable still rejected a supplied `7.0`, because once the supplied value was coerced to `Long(7)`, the pre-existing `validateEnum()` method compared its string form (`"7"`) against the enum entry's **raw, un-coerced** text (`"7.0"`) — a plain string mismatch, even though both values are semantically the same integer. GitHub Copilot's review caught this directly ("Normalize numeric enum values before integer comparison"), and I fixed it by making `validateEnum()` type-aware:

```java
private RenderValidationError validateEnum(String varName, Object value, JsonNode enumNode,
        String declaredType) {
    String strValue = String.valueOf(value);
    for (JsonNode enumValue : enumNode) {
        String enumText = enumValue.isFloatingPointNumber()
            ? String.valueOf(coerceWholeNumberForInteger(enumValue.doubleValue(), declaredType))
            : enumValue.asText();
        if (enumText.equals(strValue)) {
            return null; // Valid
        }
    }
    ...
}
```

Each floating-point enum entry is now run through the *same* `coerceWholeNumberForInteger` helper before being stringified for comparison, so `7.0` as an enum entry normalizes to `"7"` exactly the way a supplied `7.0` value does — keeping the enum-matching path symmetric with the value-coercion path, rather than leaving a second, more subtle inconsistency behind the one this PR had just fixed. Because the coercion is gated on `declaredType`, `number`-typed variables are completely unaffected: `String.valueOf(Double)` on a `number`-typed enum entry produces the exact same text as before.

**Precision point — reaffirmed, not re-litigated.** Copilot's review also re-raised, in effectively identical form, the `2^53` floating-point-precision concern it had already raised (and which the maintainer and I had already resolved by explicit, documented agreement) on PR #10017 — i.e., that a decimal literal above `2^53` loses exact precision before this code ever runs. I did not change the implementation for it here either, for the same reason as before: fixing it would mean parsing every float in every template as `BigDecimal` (`DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS`), a change far wider than this scoped fix, for a case a real prompt template is exceedingly unlikely to ever hit. The maintainer's final approval explicitly endorsed carrying that same decision forward rather than re-opening the debate: *"On the precision point you declined: I agree with your reasoning... the default path from #10017 behaves the same way."*

**REST-layer test coverage — added in direct response to review.** Copilot's second review pass correctly observed that every one of my new unit tests called `renderingService.render(...)` with a Java `Map.of("max_results", 7.0)` — i.e., a `Double` object built directly in test code — which proves the *service logic* is correct given a `Double`, but never proves that a real HTTP JSON request body actually produces a `Double` the same way. I closed that gap with two genuine black-box REST tests in `PromptRenderTest.java`, using REST Assured against a real running `@QuarkusTest` instance: one posts a literal JSON body `{"variables": {"max_results": 7.0}}` against a freshly created `PROMPT_TEMPLATE` artifact and asserts the HTTP response body directly (`statusCode(200)`, `body("rendered", equalTo("Limit: 7"))`, `body("validationErrors", hasSize(0))`); the other does the same with `7.5` and asserts the expected single validation error. These tests pin down the one step none of the unit tests could: that Jackson parsing a real request body's `7.0` literal into a `Double` is exactly the trigger condition `coerceSuppliedVariables` is designed to handle.

**Tests added, in total:** six new unit tests in `PromptRenderingServiceTest.java` (+120 lines) — whole-number supplied value accepted; whole-number supplied value matching a decimal `enum`; a supplied value correctly rejected for not matching a decimal `enum`; a fractional supplied value still rejected; an out-of-range supplied value still rejected; a `number`-typed variable unaffected — plus two full REST-endpoint tests in `PromptRenderTest.java` (+71 lines), added specifically in response to Copilot's coverage finding.

### Technologies / Concepts

Java 21, Jackson `ObjectMapper`/JSON deserialization, IEEE 754 double-precision floating point and its exact-representability limits (carried over directly from #10017's bounds-check reasoning), defensive copy-on-write collection handling, `Map.of()`'s immutability as an implicit test oracle, JSON-Schema-adjacent `enum` validation semantics, REST Assured black-box HTTP testing against a `@QuarkusTest` instance, Conventional Commits, DCO sign-off, GitHub's "allow edits from maintainers" collaboration feature, and an ownership/interest/load-weighted automated reviewer-assignment system.

### Result

Merged into `main` on 2026-11-03, shipped in milestone **3.4.0** alongside its predecessor, #10017. Net diff: **+245 / −6** lines across three files (`PromptRenderingService.java` +54/−6, `PromptRenderingServiceTest.java` +120/0, `PromptRenderTest.java` +71/0). SonarCloud's Quality Gate passed with **zero new issues** — a cleaner result than #10017's single flagged literal-duplication finding.

### Impact

Caller-supplied values and schema defaults for `type: integer` prompt variables now behave identically with respect to whole-number decimal literals: `7.0` supplied by a caller renders as `7` with no validation error, exactly as a default of `5.0` already did after #10017. Decimal `enum` entries (`enum: [5.0, 7.0]`) now correctly match a coerced supplied value instead of silently rejecting a value that is, numerically, exactly one of the allowed choices. The asymmetry explicitly flagged as a known gap in #10017's review is fully closed.

### Pull Request

https://github.com/Apicurio/apicurio-registry/pull/10724 — "fix(rest): accept whole-number decimal values supplied for integer prompt variables"

### Issue

https://github.com/Apicurio/apicurio-registry/issues/10723 — "fix(rest): integer-typed prompt template variable rejects a caller-supplied whole-number decimal (e.g. 7.0)" (filed and self-assigned by me, 2026-10-27; approved by `jsenko` as "the follow-up to my O1 on #10017"; closed on merge, 2026-11-03)

### Commit(s)

Three substantive work commits, interleaved with three merge commits (one of them, notably, pushed directly by a maintainer rather than by me):
1. `7502fe26` — `fix(rest): accept whole-number decimal values supplied for integer prompt variables` (2026-10-27) — the core fix; `Fixes #10723`.
2. `e9ec5656` — `fix(rest): match decimal enum entries for integer prompt variables` (2026-10-28) — fixes the decimal-`enum`-matching bug Copilot's first review surfaced, a few hours after that review landed.
3. `3de37bf6` — `test(rest): add endpoint coverage for integer prompt variable coercion` (2026-11-03) — adds the two REST-layer tests Copilot's second review asked for.

### Review / Discussion

- **GitHub Copilot (automated reviewer), 2026-10-28** — Two Medium-severity findings: (1) "Normalize numeric enum values before integer comparison" — a genuine bug, fixed the same day (`e9ec5656`); (2) "Preserve decimal precision for exact integer validation" — the same `2^53` concern already resolved on #10017; reaffirmed rather than changed.
- **GitHub Copilot, 2026-11-02** — Marked both prior findings resolved; raised one new Medium-severity finding: "Add endpoint coverage for deserialized dynamic variables" — correctly identifying that the unit tests never exercised real JSON deserialization. Closed via `3de37bf6`.
- **`jsenko` (project MEMBER), 2026-11-03, APPROVED** — An explicitly read-only review ("Checked. By reading. I haven't run the tests.") that nonetheless itemized exactly what was verified by inspection: that both code paths (defaults, supplied values) now share one bounds-checked helper so `1e20`/`7.5` are still rejected and `number` variables are untouched; that the caller's map is never mutated, with the `Map.of()` tests cited as the evidence that would catch a regression; that the `enum` coercion is scoped to `integer` variables only, leaving `number`-typed enum comparisons byte-for-byte unchanged; explicit agreement with my decision not to address the precision point, citing consistency with #10017's own default-path behavior; and confirmation that the final commit added only the two REST tests, reusing existing test helpers and imports (a lower-risk, easily-reviewed change). The approval also noted CI state precisely: Quick Check had passed on the final commit, and the full verification suite would start with this approval.
- **`jsenko`, separately, 2026-11-03** — approved the *linked issue* #10723 directly with a one-line comment confirming it as the tracked follow-up to his own O1 from #10017, closing the loop on a promise made six weeks earlier.
- **CI note:** the full verification suite initially reported failure twice against the same final commit hash; both were correctly traced to a single known-flaky, entirely unrelated test (`RegistryMojoWithAutoReferencesTest.autoRegisterAvroWithReferences`, part of the Maven-plugin/Avro-reference integration suite) that passed on automatic retry — not a defect in this change.

---

# Technical Depth

## Architecture / System Understanding

This PR deepens the same architectural area as #10017: the agents subsystem's prompt-rendering pipeline, where a caller-supplied value map is merged against schema-declared defaults, then validated against each variable's declared type/constraints, before the template is textually rendered. The key architectural insight this PR embodies is that **the same coercion rule must be applied at every point numeric values enter the validation pipeline** — not just at the default-filling step (#10017), but at the caller-supplied-value step (this PR's core fix) and at the `enum`-comparison step (this PR's second fix). Treating those as three independent call sites, rather than three expressions of a single shared rule, is exactly what produced the original bug and its two discovered sub-bugs; the fix's structural shape — one shared, bounds-checked helper called from all three places — is the correct response to that insight.

## Important Components

- `PromptRenderingService.render()` — now calls `coerceSuppliedVariables()` immediately after extracting the variable schema and before any validation runs, so validation always sees already-normalized values.
- `coerceWholeNumberForInteger()` — the single source of truth for "is this `Double` actually a whole number representable as a `Long`," shared by `convertDefaultValue()`, `coerceSuppliedVariables()`, and `validateEnum()`.
- `PromptRenderTest` (REST v3 test package) — a genuine black-box contract test suite that creates a real `PROMPT_TEMPLATE` artifact and exercises the actual `/registry/v3/.../render` HTTP endpoint, as opposed to `PromptRenderingServiceTest`'s direct, in-process unit tests of the service class.

## APIs / Interfaces

The externally relevant contract, extended by this PR: a caller-supplied value for an `integer`-typed prompt variable, written as a whole-number decimal in a JSON request body (`7.0`), must now be treated identically to the same value written without a decimal point (`7`) or declared as a schema default (`5.0`) — rendered without a trailing `.0`, matched correctly against any decimal `enum` constraint, and reported as HTTP 200 with an empty `validationErrors` array, consistent with the project's existing "validation failures are response data, not HTTP errors" design.

## Data Structures / Algorithms

The central algorithm — a bounds-checked whole-number test on an IEEE 754 `double` before narrowing to `long` — is unchanged from #10017; this PR's contribution is almost entirely about **where** that algorithm is invoked and how it interacts with two different data structures: a caller-supplied `Map<String, Object>` (which must be treated as potentially immutable and therefore copy-on-write rather than mutated in place) and a Jackson `JsonNode` array (`enum`), whose floating-point entries must be normalized through the identical coercion before being compared as strings.

## Distributed Systems Concepts

As with #10017, this fix lives entirely in request-time validation logic and is independent of which of the four storage variants (in-memory, SQL, KafkaSQL, GitOps, Kubernetes ConfigMap) is configured, so no cross-variant validation was required for this change.

## Performance Considerations

`coerceSuppliedVariables()` is written to add essentially zero overhead to the common case: it iterates the supplied map once, skips any non-`Double` value immediately via an `instanceof` check, and only ever allocates a new `HashMap` copy if at least one value actually needs coercion — meaning a request with no decimal-literal integer variables (the overwhelming majority of real traffic) pays only the cost of one cheap type check per supplied variable.

## Testing

The test suite for this PR is notably broader than #10017's in kind, not just in count: it adds not only more unit-level assertions-on-specific-values tests (consistent with the project's testing conventions), but also the first genuine REST-endpoint-level tests for this exact bug class, closing a real verification gap (unit tests proving service logic correct given a `Double`, versus endpoint tests proving the HTTP/JSON layer actually produces that `Double` from a real request body) that an automated reviewer, not a human, was the one to catch.

---

# Engineering Decisions

## Decision 1 — Extract one shared coercion helper instead of duplicating the whole-number check

Rather than re-implementing the whole-number-to-`Long` check inline at the new caller-value call site (the way #10017 had implemented it inline for defaults), I refactored it into a single private helper, `coerceWholeNumberForInteger`, used by all three call sites this PR and its predecessor touch. This guarantees the three code paths can never again silently drift apart in behavior — which is precisely the class of bug both this PR's core fix and its `enum` sub-fix exist to close.

## Decision 2 — Never mutate the caller-supplied map; copy only on actual change

Because the supplied-variables map arrives from outside this method's control (and may be backed by an immutable collection, as the regression tests deliberately verify with `Map.of()`), the coercion step creates a defensive copy lazily, only the first time a value genuinely needs to change, rather than copying unconditionally or mutating in place. This is a small decision with an outsized payoff in reviewer confidence — the maintainer cited this exact detail, and the test design that proves it, as part of what let him approve by reading alone.

## Decision 3 — Fix the decimal-`enum`-matching bug in this PR rather than deferring it like O1

Unlike O1 on #10017 (caller-supplied coercion), which I deliberately deferred to a separate tracked issue because it was a logically distinct code path, the decimal-`enum` bug Copilot surfaced here is a **direct, necessary consequence** of this PR's own change: once supplied values are coerced, any schema using decimal `enum` literals *must* also be updated, or the coercion fix itself introduces a new (if narrower) inconsistency. Judging that distinction correctly — what's tightly coupled to the change at hand versus what's merely adjacent — is itself an engineering decision, and the two PRs make for a clean before/after comparison of applying the same judgment call to two superficially similar situations with different right answers.

## Decision 4 — Add real REST-endpoint tests instead of only satisfying the reviewer bot's literal ask

Copilot's finding could have been "satisfied" with a cosmetic change (e.g. constructing the `Double` via some Jackson call inside the existing unit test file without actually using HTTP). Instead, I added full `@QuarkusTest` + REST Assured endpoint tests that create a real artifact and POST a real JSON body through the real render endpoint — closing the actual verification gap (JSON deserialization producing the right Java type) rather than just the letter of the reviewer's comment.

---

# Challenges

## Challenge 1 — A second, review-discovered bug in the exact area the fix touched

Fixing the caller-value coercion path exposed a previously-dormant inconsistency in `enum` matching that nothing in the existing test suite had ever triggered (because no previous caller value had ever been coerced before reaching `validateEnum`).

### How I Solved It

I accepted Copilot's finding as in-scope (unlike O1 on the previous PR) because it was a direct, inseparable consequence of the very change I was making, and fixed it the same day by threading the variable's declared type into `validateEnum()` so decimal `enum` entries get normalized through the same shared helper before comparison.

### What I Learned

Introducing a coercion step anywhere in a validation pipeline requires auditing every *other* place in that pipeline that compares against the pre-coercion representation — `enum` matching, in this case — rather than assuming the coercion is self-contained to the one call site it was written for.

## Challenge 2 — Proving the fix actually works through real JSON deserialization, not just in-process Java objects

My own regression tests, like #10017's before them, constructed `Double` values directly in Java code. That's sufficient to prove the service's internal logic is correct given a `Double`, but it is not sufficient to prove the fix actually fires for a real HTTP client sending `7.0` in a JSON body — a distinction an automated reviewer caught that I hadn't initially closed myself.

### How I Solved It

I added two new tests in the REST v3 test package that create a real artifact via the REST API and POST a literal JSON request body through the actual HTTP render endpoint, asserting on the raw JSON response — a different, stronger kind of test than anything either PR had included before.

### What I Learned

A unit test that constructs the "input" type directly in code can quietly assume away the exact integration point a bug actually lives at. For a fix whose root cause is specifically about *how a serialization format deserializes a literal*, at least one test needs to go through that real serialization path, not just the in-memory Java representation it's presumed to produce.

## Challenge 3 — Distinguishing CI noise from real regressions under a tight merge-gate failure report

The full verification suite reported failure twice against my final commit, which could easily have been mistaken for a real regression introduced by the new tests.

### How I Solved It

I checked the linked workflow run rather than reacting defensively, confirmed the failing test (`RegistryMojoWithAutoReferencesTest.autoRegisterAvroWithReferences`, an unrelated Maven-plugin/Avro-reference integration test) had nothing to do with prompt rendering, and let the suite's own automatic retry mechanism carry it to green — consistent with the project's documented policy of reporting unrelated flaky-test failures separately rather than chasing them inside an unrelated PR.

### What I Learned

A failed "full verification suite" notification on a long, shared CI pipeline is not automatically a signal about your own change; checking the specific failing test against your diff's actual surface area before reacting saves time and avoids chasing a phantom regression.

---

# Collaboration

## Maintainer / Contributor Interaction

I closed the loop on a promise made during a previous PR's review: #10017's O1 became a filed, self-assigned issue (#10723), approved by the same maintainer who originally raised it, and delivered as a scoped, independent PR. I also proactively self-assigned both relevant reviewers via the repo's `/assign` bot command on open, rather than waiting for the automated assignment bot or relying on informal @-mentions alone — and the automated, ownership-weighted reviewer-assignment bot independently corroborated that choice by landing on the same two maintainers.

## Code Review

Two automated Copilot review passes (one catching a genuine bug — the `enum` normalization gap — and one catching a genuine test-coverage gap — missing REST-level coverage) plus one human maintainer review (`jsenko`), who was explicit and specific about his review method: a read-only review with no test execution, backed by itemized reasoning for each claim rather than a blanket "looks good."

## Design Discussions

The precision-point discussion from #10017 (O3) carried forward cleanly into this PR without needing to be re-argued: Copilot re-raised essentially the same concern, and both the maintainer and I referred back to the earlier, already-settled reasoning rather than re-opening the debate — a sign that a well-documented engineering decision, once made and recorded in a PR thread, can be productively reused across related PRs instead of re-litigated.

## Collaboration Skills Demonstrated

Following through on a deferred commitment from a previous review without being reminded; correctly distinguishing "in scope because it's coupled to this exact change" (the `enum` bug) from "out of scope, track separately" (the earlier O1 decision it stemmed from) in two different but related situations; responding to an automated reviewer's coverage gap with a substantively better test rather than a minimal appeasement; and reading a CI failure carefully enough to correctly attribute it to unrelated flakiness rather than either panicking or ignoring it.

---

# Outcomes

## Code

Merged into `main`; net diff **+245 / −6** lines across `PromptRenderingService.java` (+54/−6), `PromptRenderingServiceTest.java` (+120/0), and the newly touched `PromptRenderTest.java` (+71/0); part of release milestone **3.4.0**, alongside its predecessor #10017.

## Project Impact

Closes the exact asymmetry #10017's review explicitly flagged and deferred (O1): caller-supplied values and schema defaults for `type: integer` prompt variables now share one bounds-checked coercion rule, and a related, previously undiscovered `enum`-matching inconsistency is closed in the same pass. SonarCloud's Quality Gate passed cleanly, with zero new issues — an improvement over #10017's one flagged finding.

## User / Developer Impact

A JSON API client calling the render endpoint with a whole-number decimal value (`7.0`) for an `integer`-typed prompt variable — the way many JSON serializers naturally represent whole numbers — now gets the response it should always have gotten: a clean render with no false validation error, consistent with how the same variable's own declared default already behaved after #10017.

## Recognition

Approved and merged by the same project MEMBER who had reviewed and approved #10017, with an explicitly itemized, evidence-based approval comment, and the linked issue separately approved by that same maintainer as confirmation that a review commitment he made six weeks earlier had been fully honored.

---

# Skills Demonstrated

## Programming

Java 21; shared/extracted helper design to prevent logic drift across multiple call sites; defensive, copy-on-write handling of a potentially-immutable caller-supplied collection; Jackson `JsonNode` / `ObjectMapper` JSON deserialization semantics; REST Assured-based black-box HTTP testing against a live `@QuarkusTest` instance.

## Software Engineering

Following a cross-PR commitment through to completion; correctly scoping a review-discovered sub-bug as in-PR versus a separate, previously-deferred concern as out-of-PR; recognizing and closing a specific unit-test-vs-integration-test verification gap rather than only satisfying a reviewer's literal wording; triaging a CI failure correctly as unrelated flakiness rather than reacting defensively.

## Systems

Understanding a multi-step validation pipeline (default-filling, caller-value coercion, type validation, `enum` validation) well enough to recognize that a single shared invariant needed to be enforced consistently across three different call sites, not re-derived independently at each one.

## Distributed Systems

Confirmed, consistent with the previous PR, that this class of fix lives entirely in request-time validation logic independent of the configured storage backend, so no cross-storage-variant testing was required — correctly scoping testing effort to where the risk actually lives.

## Infrastructure / Cloud

Direct exposure to an automated, weighted reviewer-assignment system (ownership/interest/issue-authorship/load scoring) as a piece of the project's CI/process infrastructure, on top of the already-familiar SonarCloud quality gating and multi-stage "Verify → Decide → Verification Gate" pipeline; practical use of GitHub's "allow edits from maintainers" feature to let a maintainer push directly to a contributor branch.

## Open Source

A complete "defer, track, deliver" open-source contribution cycle: a review item explicitly deferred in one PR, turned into a properly filed and approved follow-up issue, and delivered as an independently reviewed, independently merged PR six weeks later — demonstrating that scope discipline in one PR doesn't mean a legitimate concern gets lost, only that it gets tracked and delivered on its own schedule.

---

# Evidence

| Evidence | URL / Reference | Description |
|---|---|---|
| Repository | https://github.com/Apicurio/apicurio-registry | Apicurio Registry — Apache-2.0 API/schema registry, 949★ / 652 forks |
| Pull Request | https://github.com/Apicurio/apicurio-registry/pull/10724 | "fix(rest): accept whole-number decimal values supplied for integer prompt variables" — merged |
| Issue | https://github.com/Apicurio/apicurio-registry/issues/10723 | Follow-up issue to #10017's O1, filed and self-assigned by me — closed on merge |
| Prior PR | https://github.com/Apicurio/apicurio-registry/pull/10017 | The originating PR whose review (O1) this PR directly follows up on |
| Commit | `7502fe26` | Core fix commit — `Fixes #10723` |
| Commit | `e9ec5656` | Decimal-`enum`-matching fix, in response to Copilot review |
| Commit | `3de37bf6` | REST-endpoint test coverage, in response to Copilot review |
| Merge commit | `mergedAt: 2026-11-03T15:24:18Z` | Final merge into `main` |
| Release | Milestone `3.4.0` | Target release for both the PR and the linked issue, same milestone as #10017 |

---

# Key Technical Keywords

Jackson, `ObjectMapper`, JSON deserialization, IEEE 754 double-precision floating point, type coercion, shared-helper extraction, copy-on-write collection handling, immutable `Map.of()` as a test oracle, JSON-Schema-adjacent `enum` validation, REST Assured, `@QuarkusTest` black-box endpoint testing, SonarCloud static analysis, GitHub Copilot automated code review, weighted reviewer-assignment automation, Conventional Commits, DCO (Developer Certificate of Origin), Apache 2.0 license, Apicurio Registry, Quarkus, AI/agent prompt templates, Maven multi-module reactor, GitHub Actions CI, ArchUnit architectural boundary testing.

---

# Related Work

- **PR #10017** — the originating fix (whole-number decimal coercion for prompt-variable *defaults*) whose review explicitly deferred the exact gap this PR closes (reviewer item O1).
- **Issue #10016** — the original root-cause issue behind #10017, two steps upstream of this PR.
- **Issue #10723 / this PR, #10724** — the tracked, approved, and delivered follow-up to O1, closing the default-vs-supplied-value asymmetry and the related decimal-`enum`-matching gap discovered along the way.
- **Tried & Rejected list** (project discussion #8364) — `USE_BIG_DECIMAL_FOR_FLOATS` as a parser-wide fix for the `2^53` precision edge case was re-considered and re-declined here, consistent with the reasoning already recorded against #10017.

---

# Timeline

| Date | Event |
|---|---|
| 2026-10-27 04:11 | Issue #10723 filed as the explicit tracked follow-up to #10017's O1; self-assigned via `/assign-me` |
| 2026-10-27 04:18 | Core fix committed (`7502fe26`) |
| 2026-10-27 04:20 | PR #10724 opened, `Closes #10723` |
| 2026-10-27 04:22 | Reviewers explicitly self-assigned via `/assign @carlesarnal @jsenko` |
| 2026-10-27 04:23 | Comment posted referencing #10017's O1 directly, asking `jsenko` to review and approve the issue |
| 2026-10-27 04:24 | Automated reviewer-assignment bot independently scores and assigns `carlesarnal` (0.67, `area/sdk` ownership) over `EricWittmann`/`jsenko` (0.12 each) |
| 2026-10-27 12:21 | Branch merged with `main` |
| 2026-10-28 09:34 | Copilot review #1: two Medium findings — decimal `enum` normalization (real bug) and decimal precision above `2^53` (already-settled discussion) |
| 2026-10-28 11:35 | Decimal-`enum`-matching bug fixed (`e9ec5656`) |
| 2026-10-28 11:39 | Branch merged with `main` |
| 2026-11-02 09:54 | Maintainer `carlesarnal` pushes a merge-from-`main` commit directly to the branch (maintainer-edit access) |
| 2026-11-02 09:58 | Copilot review #2: both prior findings marked resolved; one new finding — missing REST-endpoint test coverage |
| 2026-11-03 10:09 | REST-endpoint test coverage added (`3de37bf6`) |
| 2026-11-03 10:14 | SonarCloud Quality Gate passes, zero new issues |
| 2026-11-03 12:54 | `jsenko` approves the PR with a detailed, explicitly read-only review |
| 2026-11-03 12:55 | Full verification suite starts; first (flaky, unrelated) failure notice posted |
| 2026-11-03 13:07 | `jsenko` separately approves issue #10723 as the confirmed follow-up to his own O1 |
| 2026-11-03 13:51–14:10 | Second failure notice and flaky-test-retry summary for the same unrelated test, then green |
| 2026-11-03 15:24 | PR #10724 merged into `main`; issue #10723 closed; shipped in milestone 3.4.0 |

---

# Notes

- This record was reconstructed directly from the live GitHub PR (#10724), its linked issue (#10723), its full commit history, its diff, and its review/comment threads, cross-referenced against the predecessor PR (#10017) and its own review thread (the source of the O1 item this PR resolves) — not from memory or assumption. All dates, commit hashes, test counts, and quoted error/strings are taken verbatim from those sources as of 2026-11-03.
- This record also resolves a piece of forward-looking speculation left open in the companion record for PR #10017: that record noted a local branch, `fix/prompt-render-integer-supplied-decimal`, with a commit titled "test(rest): add endpoint coverage for integer prompt variable coercion," and flagged it as apparent follow-up work *in progress*. That branch and that exact commit (`3de37bf6`) are, in fact, part of this PR, #10724 — now fully merged, not merely in progress.
