Skip to content

fix: replace compound x-mapping with constrained unions - #13577

Merged
ChiragAgg5k merged 5 commits into
mainfrom
clo-4377-compound-schemas
Sep 9, 2026
Merged

ChiragAgg5k merged 5 commits into
mainfrom
clo-4377-compound-schemas

Conversation

@ChiragAgg5k

@ChiragAgg5k ChiragAgg5k commented Sep 9, 2026 •

Copy link
Copy Markdown
Member

Summary

Producer change for CLO-4377, following merged sdk-generator#1894 and released SDK-generator 5.0.0.

The consumer was admin-merged as 8ea7dcd534718ca6acf14be8b4ae10dfc5c9c1fc after all 59 checks passed and Greptile reached 5/5 with zero unresolved threads on reviewed head 137960eca041d842e5bccd8e70fea1564e7b0bec. The merge tree matches that head. GitHub and Packagist both publish 5.0.0 from this merge.

Update Appwrite's dev dependency from appwrite/sdk-generator: ^4.0 to ^5.0; the lock moves 4.9.0 → 5.0.0 and OpenAPI 0.2.1 → 0.2.4. No other package versions changed. OpenAPI ^0.2.4 is also a direct runtime dependency: Format uses its Composition enum rather than composition-name strings. The lock moves OpenAPI into production packages without changing its version. The broader changes since generator 4.9.0 must also be considered in the eventual Cloud artifact/delta review; the earlier compound-only comparison does not cover that full dependency jump.

Replace compound discriminator x-mapping with standard constrained anyOf branches. Apply the same union builder to response unions and model-property/item unions. Keep ordinary valid single-property discriminators and unconstrained unions unchanged.

Before:

oneOf:
  - $ref: '#/components/schemas/columnString'
  - $ref: '#/components/schemas/columnEmail'
discriminator:
  propertyName: type
  mapping:
    string: '#/components/schemas/columnEmail'
  x-mapping:
    '#/components/schemas/columnString': {type: string}
    '#/components/schemas/columnEmail': {type: string, format: email}

After:

anyOf:
  - allOf:
      - $ref: '#/components/schemas/columnString'
      - type: object
        required: [type]
        properties:
          type: {enum: [string]}
  - allOf:
      - $ref: '#/components/schemas/columnEmail'
      - type: object
        required: [type, format]
        properties:
          type: {enum: [string]}
          format: {enum: [email]}

Broad String overlaps Email/Enum/URL/IP, so these must be inclusive anyOf alternatives, not exclusive oneOf. There is no lossy compound discriminator or synthetic public model. Referenced models are unchanged; conditions become required singleton-enum constraints. SDK selection remains most-specific-first in the consumer.

Verification

  • vendor/bin/phpunit tests/unit/SDK/Specification/FormatTest.php: 42 tests / 248 assertions passed. At the owner's request, the added tests are reduced to one focused String/Email overlap test. It parses the emitted document and verifies inclusive composition, absent compound discriminator, model identities and selection conditions. No added data provider or separate discriminator test remains.
  • composer lint src/Appwrite/SDK/Specification/Format.php src/Appwrite/SDK/Specification/Format/OpenAPI3.php tests/unit/SDK/Specification/FormatTest.php: passed.
  • composer refactor:check tests/unit/SDK/Specification/FormatTest.php: passed.
  • vendor/bin/phpstan analyse src/Appwrite/SDK/Specification/Format.php src/Appwrite/SDK/Specification/Format/OpenAPI3.php --memory-limit=1G: passed.
  • git diff --check: passed.
  • Enum refactor: the actual producer-emitted fixture document is byte-identical before/after adopting Composition. Full configured Rector and targeted PHPStan pass.
  • Regression check: restoring pre-change producer files makes the compound-union tests fail; restored implementation passes.
  • Cross-repository check: OpenAPI 0.2.4 parsed an actual locally emitted fixture document and recognized all four response/list-item constrained unions, each with 18 references.
  • Released generator: 87 tests / 1,132 assertions / 4 existing skips, and PHP mock-API e2e 1 test / 148 assertions. Runtime calls check overlapping specialization, broad fallback, invalid selection fields and ignored x-mapping; generated-source assertions were removed during review. Candidate specs generated with the no-x-mapping reader match saved pre-removal output for 17 targets. That broad comparison uses a local transformation of pinned canonical specs, not a full Cloud build of this producer; details are in the generator PR.
  • After the dependency update, reran the 42 producer tests and all targeted lint/Rector/PHPStan checks successfully. composer validate --no-check-publish passes. The installed released generator 5.0.0 successfully generated a PHP SDK from an actual producer-emitted fixture document; every generated PHP source file passes php -l. Dependencies were installed locally with --ignore-platform-reqs --no-scripts --no-plugins; this is not full-stack runtime verification.

Backend/schema output only; screenshots are not applicable.

Remaining merge/publication gates

The owner explicitly requested no x-mapping fallback in the generator and support scoped to the string conditions currently needed in appwrite/specs. The generator PR removes that reader entirely. Published old compound specs therefore require coordinated migration; they are not claimed compatible with the new reader.

  • Generator consumer reviewed, all 59 CI checks passed, merged and released as 5.0.0; release availability verified.
  • Update Appwrite's generator dependency/lock and verify the installed release against locally emitted fixture specs.
  • Verify deployed Vibes support and coordinate consumer upgrades before merging this producer switch.
  • Run Cloud push=false generation and inspect the actual artifacts/delta before canonical publication.
  • Obtain separate approval to publish canonical specs and coordinate the generator upgrade.

OpenAPI 0.2.4 and SDK-generator 5.0.0 are released; Vibes support is merged separately. This PR does not directly edit appwrite/specs, publish specs, deploy the generator to Cloud, or release Appwrite. Unrelated strict full-document validation failures remain deferred, not passing. No full Cloud generation, deployed-consumer, or all-language runtime claim is made here.

@github-actions

github-actions Bot commented Sep 9, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → clo-4377-compound-schemas (after).

Metric Before After Change
🚀 Requests/sec 203.45 202.9 ⚪ -0.3%
⏱️ Latency P50 84.72 ms 85.88 ms ⚪ +1.4%
⏱️ Latency P95 202.55 ms 201.24 ms ⚪ -0.6%
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 85.88 201.24 12,597 202.9 -1.31
Account 170.05 317.09 663 10.98 -19.18
TablesDB 82.71 151.52 6,851 111.61 -0.5
Storage 78.94 171.56 3,315 56.14 -2.97
Functions 128.31 248.85 1,768 30.69 -8.47

Top API waits (after)

API request Max wait (ms)
account.name.update 500.5
functions.create 426.27
account.prefs.update 407.24
functions.delete 401.64
functions.variables.update 398.15

@ChiragAgg5k
ChiragAgg5k marked this pull request as ready for review September 9, 2026 12:24
@greptile-apps

greptile-apps Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge, with no outstanding correctness, security, or repository-rule violations identified.

Summary

  • Builds constrained anyOf branches from referenced schemas and singleton-enum conditions.
  • Reuses the union builder for response, property, and list-item unions while preserving ordinary discriminators.
  • Uses the OpenAPI package’s Composition enum for composition names.
  • Replaces the implementation-coupled inventory test with a focused parsed-schema behavior test.

@ChiragAgg5k
ChiragAgg5k merged commit 44fb7c6 into main Sep 9, 2026
45 of 46 checks passed
@ChiragAgg5k ChiragAgg5k mentioned this pull request Sep 10, 2026
2 of 4 tasks
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.

2 participants