Skip to content

chore: absorb validators into packages/validators - #13897

Merged
ChiragAgg5k merged 982 commits into
mainfrom
chore/absorb-validators
Sep 25, 2026
Merged

ChiragAgg5k merged 982 commits into
mainfrom
chore/absorb-validators

Conversation

@ChiragAgg5k

@ChiragAgg5k ChiragAgg5k commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

Summary

This moves utopia-php/validators into packages/validators, so Appwrite loads it directly. It's the first package of wave 1 in #13828 and follows the playbook in rfc/monorepo.md. It comes in three commits, plus a merge of main:

  1. Add 'packages/validators/' from commit 'f0a08bd8…': subtree import from the mirror with full history. The mirror head is the 1.0.1 commit Appwrite already locks, so the code Appwrite runs doesn't change.
  2. chore(validators): mirror plumbing: mirror.yml now points at this repository's mirror-redirect, and the README banner points here instead of utopia-php/monorepo. The package had no banned files or hoisted QA tooling to strip.
  3. refactor: load validators from packages/:
    • Adds the root autoload and replace entries, drops the utopia-php/validators: ^1.0 require line, and removes the package from the lock. Ten still-vendored packages require utopia-php/validators, and replace now satisfies them.

    • Bare Utopia\ prefix. The package keeps declaring Utopia\ → src/, because Utopia\Validator (the base class) and Utopia\PHPStan\DisallowAssertEqualsExtension live at the namespace root. Renaming those is step B (phase 6), not this PR. It's the first absorbed package with the bare prefix, so bin/monorepo learns about it:

      • A new BARE list (validators => Validator) names the packages allowed to declare Utopia\, plus the segment their tests use. validate accepts Utopia\ → src/ for those packages only.
      • autoload writes the bare prefix as a directory list ("Utopia\\": ["packages/validators/src"]), probed last. It also no longer copies a list-valued entry through untouched, which would have duplicated packages/ paths on every regeneration.
      • validate now fails on any class under packages/ that more than one PSR-4 directory can load. It checks against the root map and, when vendor/ is installed, against every vendored package. That's where the bare prefix is still shared with http, console and di. The RFC already promised this check, but it wasn't implemented. Before composer update --lock removed the vendored copy, the check flagged all 31 validators classes. It's clean now.
      • At runtime, Utopia\Validator, Utopia\Validator\* and Utopia\PHPStan\* resolve to packages/validators/src, while Utopia\Http\*, Utopia\Console and Utopia\DI\* still resolve to vendor/. Composer's generated map lists packages/validators/src first under Utopia\, ahead of the three vendored directories.
    • Step A of the standard shape:

      • src/ is already flat under the bare prefix (src/Validator.php, src/Validator/*, src/PHPStan/*), so nothing moves.
      • tests/Validator/* moves up to tests/. Tests move from Utopia\Validator (the same namespace as the classes under test) to Utopia\Validator\Tests and Utopia\Validator\Tests\JSON, with explicit imports and a matching autoload-dev entry.
      • LICENSE.md becomes LICENSE, and phpunit.xml and rector.php match the sibling packages. Rector leaves src alone and removed one empty setUp() from a test. The only changes to src against the imported 1.0.1 are Pint's (empty constructor bodies and fn ( spacing).
    • phpstan.neon used to include ../../phpstan.neon, which validate rejects, so it's now standalone at level max over src and tests. It keeps registering the package's own DisallowAssertEqualsExtension. A phpstan-baseline.neon holds 75 findings, because the monorepo analysed this package at level 5:

      • 48 in src: unvalued array parameters and casts from mixed, mostly in Globstar, Domain, URL, Contains and WhiteList.
      • 27 in the tests: nullable validator fixtures in AssocTest and URLTest.

      The RFC's phase 8 burn-down list now includes them.

    • rfc/monorepo.md documents BARE next to the root autoload description.

There's nothing to hoist, since the package requires only PHP.

main (with the locale absorb, #13888) is merged in, not rebased, so the subtree history is intact. composer.json and composer.lock were resolved by taking main's and re-running bin/monorepo autoload and composer update --lock.

Validation

  • bin/monorepo validate: all packages valid, including the new duplicate-class check against the installed vendor/
  • bin/monorepo check validators: Rector, Pint and PHPStan level max (with baseline) pass
  • bin/monorepo test validators: 185 tests / 1,084 assertions (there's no e2e tier)
  • vendor/bin/phpunit --testsuite packages --filter 'Utopia\\Validator\\Tests': the same 185 tests / 1,084 assertions pass under the root autoloader
  • vendor/bin/phpunit tests/unit on the host: 1,312 tests, with 21 environmental failures (the Imagick woff2 font delegate, maxminddb, an empty JWT signing key, and a DNS lookup). The same 21 fail on main with the vendored 1.0.1 on this host, and none of them involve validators. CI runs the suite in the container
  • Root PHPStan (on the host) passes on Teams/Http/Teams/Create.php, Functions/Http/Functions/Create.php, Network/Validator/Origin.php and other Appwrite files that extend or use Utopia\Validator
  • composer validate --no-check-publish: valid (the only warning is the existing platform exact-version one)
  • composer update --lock, after the merge of main: the lock diff only removes utopia-php/validators 1.0.1 and updates the content hash
  • bin/monorepo split validators --dry-run: ff51aff7, which fast-forwards from the mirror head f0a08bd8, and its tree matches packages/validators
  • git diff --check, and Pint over the whole repository

Merge and follow-up

Merge with a merge commit. A squash drops the git-subtree-* annotation and orphans the package from its mirror.

The utopia-php/validators mirror already has the canonical main ruleset (id 17509374), with the split app as an always-bypass actor, so the absorb ran with --skip-ruleset.

After merge:

  • Confirm Split pushes to utopia-php/validators.
  • Remove packages/validators from utopia-php/monorepo. console, servers, http, queue, database, domains, dns, emails, storage and audit there still require utopia-php/validators from Packagist, and the mirror keeps serving it.
  • Triage the open PRs:
  • Phase 6 (step B) note: once Utopia\Validator moves to Utopia\Validator\Validator, validate's spelling rule (<Ns> lowercased equals the package name) rejects Validator for validators. Step B needs either an exception or a decision on that rule, alongside removing the BARE entry.

🤖 Generated with Claude Code

Meldiron and others added 13 commits July 14, 2026 13:55
docs: enforce documentation style with Vale
docs: centralize CODE_OF_CONDUCT and CONTRIBUTING at the monorepo root
feat(validators): add JSON object and array shape validators
feat(validators): add Identifier validator
…lank

validators: require non-blank text values
feat(validators): add FCM service account validator
fix(validators): Assoc declares an object, not an array
chore: stop committing package lock files
…385984da73d'

git-subtree-dir: packages/validators
git-subtree-mainline: b866958
git-subtree-split: f0a08bd
@ChiragAgg5k ChiragAgg5k added the absorb History-preserving package absorption; merge commit required label Sep 24, 2026
@greptile-apps

greptile-apps Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

[High risk] Moves validators package into monorepo structure.

The PR does not yet appear ready to merge because explicit repository requirements on tests and regular expressions remain unsatisfied.

Fix All in Claude CodeFindings

  1. P2 Tests mirror description wording ▶
  2. P2 Tests mirror private error strings. ▶
  3. P2 License link is broken. ▶
  4. P2 Development commands check the root. ▶
  5. P2 Regular expression violates repository guidance. ▶
Fix with agent prompt
### Issue 1
packages/validators/tests/ArrayListTest.php:19
**Tests mirror description wording.** These tests hard-code complete descriptions, including the nested validator’s wording. The JSON shape tests do the same. This violates the repository directive to test observable behavior rather than mirror source text: a wording change would fail the suite even if the validators accepted and rejected exactly the same values. This requirement must be satisfied before merging.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

### Issue 2
packages/validators/tests/JSON/FCMTest.php:63-65
These assertions repeat the validator’s private field-purpose text and error-message template; the other FCM cases repeat more error strings. Rewording an error without changing which credentials are accepted would fail the tests. The repository requires tests of observable behavior, not assertions that mirror source code or configuration. This requirement must be satisfied before merging.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

### Issue 3
packages/validators/README.md:undefined-87
The imported license is named `LICENSE`, but this link points to `LICENSE.md`, so readers following it reach a missing page.

```suggestion
This project is released under the [MIT License](LICENSE).
```

### Issue 4
packages/validators/README.md:80-85
`composer check` and `composer test` run the root project’s checks and tests, not the validators package checks described here. The root PHPStan paths omit `packages/validators`, so a contributor following these instructions can miss package errors. Document the package-specific commands instead.

```suggestion
Run the validators checks and tests from the project root:

```bash
bin/monorepo check validators
bin/monorepo test validators
```
```

### Issue 5
packages/validators/src/Validator/Identifier.php:undefined-38
This identifier check adds `preg_match()` without explaining why string or character functions cannot be used. The repository instruction says not to add regular expressions unless alternatives cannot work and the reason is explained in the PR. The same pattern appears in `Phone` and `HexColor`, among other imported validators. This requirement must be satisfied before merging.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

The PR imports validators as an in-tree package, replaces its Composer dependency with root autoloading, and extends monorepo validation for the shared bare Utopia\ prefix.

  • Package checks, tests, and mirror plumbing are added for the absorbed library.
  • Some imported tests assert exact generated descriptions rather than validation outcomes.

Reviews (4) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..."

Comment on lines +63 to +65
$this->assertSame(
"FCM service account JSON must include a non-empty '{$field}' field, which {$purpose}.",
$validator->getDescription(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Tests mirror private error strings. These assertions repeat the validator’s private field-purpose text and error-message template; the other FCM cases repeat more error strings. Rewording an error without changing which credentials are accepted would fail the tests. The repository requires tests of observable behavior, not assertions that mirror source code or configuration. This requirement must be satisfied before merging.

Context Used: Call out and harshly judge implementation-coupled tests. We don't mirror source code, configuration, or version pins in assertions. We test observable behavior; use linters for syntax and schema checks. (source)

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/validators/tests/JSON/FCMTest.php
Line: 63-65

Comment:
**Tests mirror private error strings.** These assertions repeat the validator’s private field-purpose text and error-message template; the other FCM cases repeat more error strings. Rewording an error without changing which credentials are accepted would fail the tests. The repository requires tests of observable behavior, not assertions that mirror source code or configuration. This requirement must be satisfied before merging.

**Context Used:** Call out and harshly judge implementation-coupled tests. We don't mirror source code, configuration, or version pins in assertions. We test observable behavior; use linters for syntax and schema checks. ([source](https://app.greptile.com/review/custom-context?memory=instruction-0))

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Fix in Claude Code Fix in Codex

composer test
```

This project is released under the [MIT License](LICENSE.md).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 License link is broken. The imported license is named LICENSE, but this link points to LICENSE.md, so readers following it reach a missing page.

Suggested change
This project is released under the [MIT License](LICENSE.md).
This project is released under the [MIT License](LICENSE).
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/validators/README.md
Line: 87

Comment:
**License link is broken.** The imported license is named `LICENSE`, but this link points to `LICENSE.md`, so readers following it reach a missing page.

```suggestion
This project is released under the [MIT License](LICENSE).
```

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Claude Code Fix in Codex

Comment on lines +80 to +85
Run the static analysis and test suites from the project root:

```bash
composer check
composer test
```

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Development commands check the root. composer check and composer test run the root project’s checks and tests, not the validators package checks described here. The root PHPStan paths omit packages/validators, so a contributor following these instructions can miss package errors. Document the package-specific commands instead.

Suggested change
Run the static analysis and test suites from the project root:
```bash
composer check
composer test
```
Run the validators checks and tests from the project root:
```bash
bin/monorepo check validators
bin/monorepo test validators

<details><summary>Prompt To Fix With AI</summary>

`````markdown
This is a comment left during a code review.
Path: packages/validators/README.md
Line: 80-85

Comment:
**Development commands check the root.** `composer check` and `composer test` run the root project’s checks and tests, not the validators package checks described here. The root PHPStan paths omit `packages/validators`, so a contributor following these instructions can miss package errors. Document the package-specific commands instead.

```suggestion
Run the validators checks and tests from the project root:

```bash
bin/monorepo check validators
bin/monorepo test validators

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Claude Code Fix in Codex

@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → chore/absorb-validators (after).

Metric Before After Change
🚀 Requests/sec 198.91 203.6 ⚪ +2.4%
⏱️ Latency P50 86.76 ms 85.93 ms ⚪ -1%
⏱️ Latency P95 205.17 ms 196.39 ms ⚪ -4.3%
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.93 196.39 12,768 203.6 -8.78
Account 156.95 274.4 672 11.19 -112.77
TablesDB 83.01 152 6,944 112.73 -7.26
Storage 80.26 178.66 3,360 56.37 +9.52
Functions 121.2 237.89 1,792 30.72 -11.14

Top API waits (after)

API request Max wait (ms)
storage.files.create 440.87
functions.create 432.94
account.name.update 426.79
functions.variables.update 424.02
account.prefs.update 348.13

#[\Override]
public function isValid(mixed $value): bool
{
return parent::isValid($value) && preg_match('/^[A-Za-z_]\w*$/D', (string) $value) === 1;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Regular expression violates repository guidance. This identifier check adds preg_match() without explaining why string or character functions cannot be used. The repository instruction says not to add regular expressions unless alternatives cannot work and the reason is explained in the PR. The same pattern appears in Phone and HexColor, among other imported validators. This requirement must be satisfied before merging.

Context Used: AGENTS.md (source)

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/validators/src/Validator/Identifier.php
Line: 38

Comment:
**Regular expression violates repository guidance.** This identifier check adds `preg_match()` without explaining why string or character functions cannot be used. The repository instruction says not to add regular expressions unless alternatives cannot work and the reason is explained in the PR. The same pattern appears in `Phone` and `HexColor`, among other imported validators. This requirement must be satisfied before merging.

**Context Used:** AGENTS.md ([source](https://github.com/appwrite/appwrite/blob/main/AGENTS.md))

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Fix in Claude Code Fix in Codex

{
$arrayList = new ArrayList(new Integer());
$this->assertFalse($arrayList->isValid(['text']));
$this->assertSame('Value must a valid array and Value must be a valid signed 32-bit integer between -2,147,483,648 and 2,147,483,647', $arrayList->getDescription());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Tests mirror description wording. These tests hard-code complete descriptions, including the nested validator’s wording. The JSON shape tests do the same. This violates the repository directive to test observable behavior rather than mirror source text: a wording change would fail the suite even if the validators accepted and rejected exactly the same values. This requirement must be satisfied before merging.

Context Used: Call out and harshly judge implementation-coupled tests. We don't mirror source code, configuration, or version pins in assertions. We test observable behavior; use linters for syntax and schema checks. (source)

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/validators/tests/ArrayListTest.php
Line: 19

Comment:
**Tests mirror description wording.** These tests hard-code complete descriptions, including the nested validator’s wording. The JSON shape tests do the same. This violates the repository directive to test observable behavior rather than mirror source text: a wording change would fail the suite even if the validators accepted and rejected exactly the same values. This requirement must be satisfied before merging.

**Context Used:** Call out and harshly judge implementation-coupled tests. We don't mirror source code, configuration, or version pins in assertions. We test observable behavior; use linters for syntax and schema checks. ([source](https://app.greptile.com/review/custom-context?memory=instruction-0))

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Fix in Claude Code Fix in Codex

@ChiragAgg5k
ChiragAgg5k merged commit 9058296 into main Sep 25, 2026
207 of 210 checks passed
@ChiragAgg5k
ChiragAgg5k deleted the chore/absorb-validators branch September 25, 2026 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

absorb History-preserving package absorption; merge commit required

Projects

None yet

Development

Successfully merging this pull request may close these issues.