Skip to content

chore: absorb detector into packages/detector - #13891

Merged
ChiragAgg5k merged 122 commits into
mainfrom
chore/absorb-detector
Sep 24, 2026
Merged

ChiragAgg5k merged 122 commits into
mainfrom
chore/absorb-detector

Conversation

@ChiragAgg5k

@ChiragAgg5k ChiragAgg5k commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

Summary

This moves utopia-php/detector into packages/detector, so Appwrite loads it directly. It is part of wave 1 in #13828 and follows the playbook in rfc/monorepo.md. detector was a standalone repository and was never in utopia-php/monorepo, so this PR runs the full playbook: a new mirror.yml, the README banner, and a new ruleset on the mirror. It comes in six commits:

  1. Add 'packages/detector/' from commit '22171ed5…': subtree import from utopia-php/detector with full history. The mirror head is the 0.2.8 tag Appwrite already locks, so the code Appwrite runs doesn't change.
  2. chore(detector): mirror plumbing: mirror.yml replaces the repository's tests, linter and codeql-analysis workflows, and the README gets the read-only mirror banner. absorb also removed pint.json and the package's composer.lock (and added composer.lock to .gitignore), dropped the Pint, PHPStan and PHPUnit require-dev entries, and dropped the lint, format and check scripts.
  3. refactor: load detector from packages/:
    • Adds the root autoload and replace entries, drops the utopia-php/detector require line, and removes the package from the lock. Nothing else changes in the lock.
    • Step A of the standard shape. src/ was already flat. tests/unit/DetectorTest.php moves up to tests/, and the test namespace changes from the bare Utopia\Tests to Utopia\Detector\Tests, with a matching autoload-dev entry. The old entry pointed at a tests/Detector/ directory that doesn't exist. docs/add-new-adapter.md now points at the new test path.
    • phpstan.neon is now standalone at level max over src and tests. The package used to be checked at level 8. No baseline is needed: src passes as it is. The 17 findings were all in the tests: ?-> calls and is_null() guards on values PHPUnit's assertNotNull() had already narrowed, and an assertNotNull() on Rendering::detect(), which never returns null. I removed them.
    • Adds a standalone rector.php (PHP sets plus type declarations, the same as openapi). Commit 6 reverts the src/ changes Rector made here.
    • phpunit.xml moves to the PHPUnit 12 schema, and composer test is now plain phpunit.
    • Pint formatting.
  4. test(detector): run the suite under PHPUnit 12: the suite was written for PHPUnit 9 and didn't run under the root toolchain. @dataProvider annotations become #[DataProvider] attributes, the nine providers become static, and testFrameworkEdgeCases' $packageFile parameter is renamed to $package to match its provider's keys, because PHPUnit 12 passes string keys as named arguments.
  5. docs(detector): strip trailing whitespace from the adapter guide: one line in the upstream docs failed git diff --check.
  6. refactor(detector): keep src as released; skip the rector rules that rewrote it: an absorb only moves code, so src/ is now byte-identical to the imported 0.2.8. rector.php skips the rules that rewrote it, the same way balancer's does: ClassPropertyAssignToConstructorPromotionRector, ReadOnlyPropertyRector, ClosureToArrowFunctionRector, ClosureReturnTypeRector, AddArrowFunctionReturnTypeRector, AddArrowFunctionParamArrayWhereDimFetchRector, AddArrayFunctionClosureParamTypeRector and AddClosureParamTypeForArrayMapRector. Only the tests change.

There's nothing to hoist. The package requires only PHP, ext-json and ext-yaml, and the root require already has both extensions. Appwrite uses the package in Deployment/Detection.php and in VCS/Http/Installations/Repositories/{XList,Detections/Create}.php.

Validation

  • bin/monorepo validate: all packages valid
  • bin/monorepo check detector: Rector, Pint, and PHPStan level max pass, with no baseline
  • bin/monorepo test detector: 122 tests / 303 assertions
  • vendor/bin/phpunit --testsuite packages --filter 'Utopia\\Detector': 122 tests / 303 assertions pass under the root autoloader
  • Root PHPStan on the 3 Appwrite files that use Utopia\Detector, run on the host: no errors
  • Utopia\Detector\Detector\Framework resolves to packages/detector/src from the root autoloader
  • composer validate --no-check-publish: valid. The only warning is the existing utopia-php/platform exact-version one
  • composer update --lock: 1 removal (utopia-php/detector 0.2.8), no other changes
  • bin/monorepo split detector --dry-run: 35ed642e, which fast-forwards from the mirror head 22171ed5
  • git diff --check

Merge and follow-up

Warning

Merge with a merge commit, not a squash. A squash drops the git-subtree-* annotation, and the mirror then rejects the split.

utopia-php/detector had no rulesets, so absorb created the canonical main ruleset (id 23943482). It blocks deletion and non-fast-forward pushes and requires a PR, and the split app (4016286) is an always-bypass actor.

After merge: confirm Split pushes to utopia-php/detector. Then triage what's still open on the mirror. None of it was carried over here:

🤖 Generated with Claude Code

Meldiron and others added 18 commits July 1, 2026 16:00
Chore: Expose ssr files list to be public
nuxt generate writes .output/public and symlinks dist to it. There is no
output directory without the leading dot, so consumers that build a path
from this value get one that never exists.

Every other framework here returns a directory its build really writes,
and Appwrite's own frameworks config has the same entry with the dot.
fix: return .output as the Nuxt output directory
Adds a Jaspr detection adapter so Jaspr sites are recognised when
importing a repository.

Jaspr projects are Dart projects, so they share pubspec.yaml and
pubspec.lock with Flutter and cannot be told apart by filename alone.
Detection therefore keys off the `jaspr` dependency in the manifest,
which required teaching the package matcher to read YAML manifests as
well as package.json.

Adapter detection reads the `jaspr.mode` key from pubspec.yaml:
`mode: static` maps to static, anything else to ssr.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Jaspr now extends Flutter, so the two share the pubspec markers and the
detector's specificity tie-break picks Flutter for a pubspec that names
neither framework, whatever order the options were registered in. Flutter
claims the flutter package and Jaspr the jaspr ones, so either wins on its
own dependencies.

Package matching accepts quoted and flow-mapping YAML keys, adapter
detection parses the jaspr mapping in either YAML style and maps client
mode to static, and a jaspr server build is recognised as SSR from its
compiled app executable.

Build command is now `jaspr build`, matching the jaspr adapter merged in
#13710 and the CLI preinstalled in the open-runtimes
flutter runtime.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
A commented out dependency no longer counts as a package match: keys must
sit at the start of a line or inside a flow mapping, and comments are
stripped first. Adapter detection strips comments the same way, including
one trailing the `jaspr:` key itself, and reads `mode` from the direct
children of the jaspr mapping rather than the first `mode:` anywhere in it.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Package matching and jaspr mode detection were each doing their own
comment stripping and key matching, and each missed cases the other
handled. Both now go through Utopia\Detector\Yaml, which leaves a `#`
inside a quoted value alone, and splits a flow mapping on its own commas
so nested collections and multiline mappings read correctly.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
A quoted scalar opens only at a value boundary, so the apostrophe in
`description: Don't` no longer starts one and a comment after it is
stripped again. Closing is escape aware: doubled quotes inside a single
quoted scalar and backslash escaped quotes inside a double quoted one
stay inside the value.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
`path: &local 'packages # local'` left the anchor name as the last
character before the quote, so the value read as plain text and its hash
was stripped as a comment, taking a real dependency with it. Anchors,
aliases and tags are now read as their own token and leave the value
boundary standing.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Replaces the hand written Yaml helper with ext-json and ext-yaml.
Package matching now reads dependency sections out of a parsed manifest
instead of searching the raw text, and the jaspr adapter reads
jaspr.mode off the parsed tree instead of a regex.

Appwrite, the only consumer, already requires ext-yaml.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The detector reads dependency names itself, and Jaspr calls yaml_parse
directly since a pubspec is always YAML. Drops src/Manifest.php.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
feat: add Jaspr framework detection
…30f933aae'

git-subtree-dir: packages/detector
git-subtree-mainline: b866958
git-subtree-split: 22171ed
@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: 5/5

The PR appears safe to merge on the reviewed changes, though the four earlier documentation and test-quality findings remain unresolved.

Fix All in Claude CodeFindings

  1. P2 Quickstart cannot run ▶
  2. P2 Example test cannot run ▶
  3. P2 Test pins configuration details ▶
  4. P2 Contribution steps target old repository ▶
Fix with agent prompt
### Issue 1
packages/detector/README.md:undefined-35
The example passes `$files` to `Packager`, whose constructor takes no arguments. The later detector constructors also have different signatures, and none of the detectors receive inputs through `addInput()`. Even after correcting the constructors, the first `getName()` call would fail because detection returns null. The missing option-class imports and nonexistent `Static` class create further failures for readers copying the example.

### Issue 2
packages/detector/docs/add-new-adapter.md:undefined-111
This test requires arguments but has no `#[DataProvider]` attribute, and the provider shown below it is not static. A contributor following the guide gets a test that cannot execute under the package’s PHPUnit setup. Show the attribute and static-provider pattern used by the actual suite.

### Issue 3
packages/detector/tests/DetectorTest.php:undefined-1107
This assertion checks that an internal configuration-file list contains a literal filename instead of testing detection behavior. The repository’s testing directive says not to mirror configuration in assertions and to test observable behavior; similar list checks appear in the SvelteKit and Remix tests. 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 4
packages/detector/CONTRIBUTING.md:undefined-45
The guide tells readers to branch from `master` and submit a PR through the detector repository, but the README now identifies that repository as a read-only mirror and directs development to `appwrite/appwrite`. Following these steps sends contributors to the wrong workflow; update the branch and PR instructions for the new development location.

---

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

Summary

This PR absorbs Utopia Detector into packages/detector, loads it through the root autoloader, and adds package mirror and test tooling.

  • The detector source is moved into the package while the root Composer lock drops the external dependency.
  • Four earlier documentation and test-quality findings remain open; no distinct new finding was established from changes since the previous review.

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


// Initialise Packager Detection
$files = ['bun.lockb', 'fly.toml', 'package.json', 'remix.config.js'];
$detector = new Packager($files);

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 Quickstart cannot run The example passes $files to Packager, whose constructor takes no arguments. The later detector constructors also have different signatures, and none of the detectors receive inputs through addInput(). Even after correcting the constructors, the first getName() call would fail because detection returns null. The missing option-class imports and nonexistent Static class create further failures for readers copying the example.

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/detector/README.md
Line: 35

Comment:
**Quickstart cannot run** The example passes `$files` to `Packager`, whose constructor takes no arguments. The later detector constructors also have different signatures, and none of the detectors receive inputs through `addInput()`. Even after correcting the constructors, the first `getName()` call would fail because detection returns null. The missing option-class imports and nonexistent `Static` class create further failures for readers copying the example.

---

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

Add tests for your new detector and detection class in `tests/DetectorTest.php`. Here's an example:

```php
public function testYourDetector(array $files, ?string $expectedName): void

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 Example test cannot run This test requires arguments but has no #[DataProvider] attribute, and the provider shown below it is not static. A contributor following the guide gets a test that cannot execute under the package’s PHPUnit setup. Show the attribute and static-provider pattern used by the actual suite.

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/detector/docs/add-new-adapter.md
Line: 111

Comment:
**Example test cannot run** This test requires arguments but has no `#[DataProvider]` attribute, and the provider shown below it is not static. A contributor following the guide gets a test that cannot execute under the package’s PHPUnit setup. Show the attribute and static-provider pattern used by the actual suite.

---

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


public function testJasprConfigFiles(): void
{
$this->assertContains('pubspec.yaml', (new Jaspr())->getConfigFiles());

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 Test pins configuration details This assertion checks that an internal configuration-file list contains a literal filename instead of testing detection behavior. The repository’s testing directive says not to mirror configuration in assertions and to test observable behavior; similar list checks appear in the SvelteKit and Remix tests. 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/detector/tests/DetectorTest.php
Line: 1107

Comment:
**Test pins configuration details** This assertion checks that an internal configuration-file list contains a literal filename instead of testing detection behavior. The repository’s testing directive says not to mirror configuration in assertions and to test observable behavior; similar list checks appear in the SvelteKit and Remix tests. 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

$ git pull
```

2. Create new branch from `master` like: `doc-548-submit-a-pull-request-section-to-contribution-guide`

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 Contribution steps target old repository The guide tells readers to branch from master and submit a PR through the detector repository, but the README now identifies that repository as a read-only mirror and directs development to appwrite/appwrite. Following these steps sends contributors to the wrong workflow; update the branch and PR instructions for the new development location.

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/detector/CONTRIBUTING.md
Line: 45

Comment:
**Contribution steps target old repository** The guide tells readers to branch from `master` and submit a PR through the detector repository, but the README now identifies that repository as a read-only mirror and directs development to `appwrite/appwrite`. Following these steps sends contributors to the wrong workflow; update the branch and PR instructions for the new development location.

---

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-detector (after).

Metric Before After Change
🚀 Requests/sec 201.91 206.2 ⚪ +2.1%
⏱️ Latency P50 84.95 ms 84.05 ms ⚪ -1.1%
⏱️ Latency P95 203.68 ms 194.82 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 84.05 194.82 12,825 206.2 -8.86
Account 161.56 294.83 675 11.18 -49.73
TablesDB 80.39 149.88 6,975 114.13 -3.52
Storage 79.61 178.22 3,375 56.91 +9.78
Functions 119.65 227.31 1,800 30.91 -23.86

Top API waits (after)

API request Max wait (ms)
account.prefs.update 448.15
account.name.update 427.18
storage.buckets.create 420.91
functions.variables.update 419.58
functions.create 367.52

@ChiragAgg5k
ChiragAgg5k merged commit 19fb43c into main Sep 24, 2026
67 checks passed
@ChiragAgg5k
ChiragAgg5k deleted the chore/absorb-detector branch September 24, 2026 15:19
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.

8 participants