Skip to content

feat: adapt TimeLimit schema to query-lib Attribute and Index VOs - #124

Open
abnegate wants to merge 29 commits into
mainfrom
feat-query-lib
Open

abnegate wants to merge 29 commits into
mainfrom
feat-query-lib

Conversation

@abnegate

@abnegate abnegate commented Aug 21, 2026

Copy link
Copy Markdown
Member

Adapts the TimeLimit schema to the query-lib Attribute and Index value objects.

Why this approach

Query-lib createCollection() takes a Collection value object only, so the TimeLimit adapter now builds new Collection(id:, attributes:, indexes:) from the typed factories (Attribute::string(), Index::unique(), …) with ColumnType / IndexType rather than Database::VAR_* strings.

The column set is unchanged: key / time / count, a unique (key, time) and an index on time.

utopia-php/database is pinned to dev-feat-query-lib as 7.0.0 with caret ranges (^, not *), and the lock is re-pinned to that branch's head whenever it moves.

Chain

Landing order, bottom up:

  1. utopia-php/database#823 — the query-lib migration itself
  2. utopia-php/abuse#124, utopia-php/migration#222, utopia-php/monorepo#206 — the schema call sites in the libraries (audit moved to the monorepo, so feat: adapt audit schema to query-lib Attribute and Index VOs audit#133 is closed in favour of monorepo#206)
  3. appwrite/appwrite#11649
  4. appwrite-labs/cloud#5410

The three framework PRs once stacked on #823 — #947 (ORM), #948 (repositories and seeding), #949 (migration runner and schema differ) — are closed and are not part of this train.

Verified

  • Linter, CodeQL, Tests (8.5) and Benchmarks all green on this head
  • Greptile 5/5, no unresolved threads
  • Pint on the Collection wrap, PHPStan --level max src tests clean

Not verified

  • tests/Abuse/Appwrite/TablesDBTest.php does not run — it needs APPWRITE_* CI secrets this repository does not have
  • The utopia-php/database dependency is still a branch pin. It becomes a released tag only once #823 merges, and this PR should not land before that.

@greptile-apps

greptile-apps Bot commented Aug 21, 2026

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

The PR appears safe to merge, with no new actionable regression introduced since the previous review.

Summary

This PR migrates the TimeLimit collection schema to query-lib value objects and aligns the package with the corresponding database branch.

  • Constructs the collection from typed Attribute, Index, and Collection objects.
  • Raises the supported PHP floor to 8.5 and updates CI and container configuration accordingly.
  • Pins the query-lib database branch and refreshes its transitive dependency lock.
  • Adds Appwrite TablesDB fixture, cleanup, and discovery coverage.
  • The only change since the previous review advances the locked database branch commit.

Reviews (30) · Last reviewed commit: "chore(deps): re-pin database to the curr..."

Comment thread composer.json
utopia-php/database feat-query-lib (and Appwrite/Cloud) require PHP >=8.5. Advertising >=8.4.1 made Composer reject the graph for 8.4 consumers while CI only passed 8.4 via ignore-platform-reqs.
@abnegate

Copy link
Copy Markdown
Member Author

@greptile-apps review

Schema setup with a known column or index type now uses
Attribute::string() / Index::key() instead of the generic
constructors plus ColumnType / IndexType.
Asterisk wildcards on utopia-php packages are replaced with
equivalent caret constraints so Composer ranges stay consistent.
Keep composer.json and composer.lock in sync so `composer validate`
passes, and pin utopia-php/database to the current query-lib HEAD.
@abnegate

Copy link
Copy Markdown
Member Author

@greptileai review

@abnegate

Copy link
Copy Markdown
Member Author

@greptile-apps review

Force re-review of HEAD 99414ff. Description updated for factories and caret lock refresh.

Database::createCollection no longer accepts a string id.
Database feat-query-lib now requires query ^0.5 after nested joins.
@abnegate

Copy link
Copy Markdown
Member Author

@greptile-apps review

abnegate and others added 2 commits August 26, 2026 19:47
The branch requires query "^0.4 || ^0.5" while the database branch it
depends on moved to "0.6.*". Composer cannot satisfy both, and audit's
branch is on 0.6 as well, so anything requiring abuse and audit together --
appwrite does -- cannot resolve either.

CI has not been showing this because the committed lock still pins a
database commit from before that bump, so nothing has re-resolved. Running
composer update against the current branch head fails outright:

  utopia-php/database dev-feat-query-lib requires utopia-php/query 0.6.*
  -> found utopia-php/query[0.6.0] but it conflicts with your root
     composer.json require (^0.4 || ^0.5).

The lock now tracks the database branch head rather than a commit two
constraint changes behind it.

Nothing in src or tests touches the parts of the query API that changed
between 0.5 and 0.6. phpstan at level max and pint are both clean, and the
suite returns exactly the same counts before and after the bump on the same
containers -- 113 tests, 54 errors, 2 failures, 39 skipped, all of them the
uninitialised local redis cluster rather than anything this changes.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
utopia-php/database#823 moved its ORM, repository/seeder and migration-runner
layers into stacked PRs, so its branch head moved. Nothing here referenced any
of them.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Comment thread tests/Abuse/DiscoveryTest.php Outdated
The guard exists because loading the backend file from the fixture test hid
every backend case from PHPUnit's own scan. Pinning the ten method names and
the fixture's case count made a rename or an added test fail a check about
discovery, so the assertions mirrored the suite instead of describing it.

Verified the guard still bites: hoisting the require_once in
TablesDBFixtureTest back to file scope fails on the missing class key.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@abnegate

abnegate commented Sep 9, 2026

Copy link
Copy Markdown
Member Author

@greptileai review

database's feat-query-lib merged main (1ea2f35), which raised
utopia-php/validators to ^1.0. The lock was still on a137475 with
validators 0.6.0, so CI here was proving the branch against a base
the rest of the train no longer uses.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Comment thread tests/Abuse/Appwrite/TablesDBFixtureTest.php
abnegate and others added 8 commits September 11, 2026 04:36
Picks up the read-replica write-hook sync and the schema-bound aggregate
validators, so CI here proves this branch against the base the rest of
the train now uses.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Picks up the main merge on the database branch.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Picks up the required-change fix for attribute updates.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The database adapter now calls alterColumnNullable(), which 0.6.0 does
not have, so an attribute update that changes required fataled.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…ated

The assertion pinned the `abuse-` prefix and the 24-hex encoding that
`bin2hex(random_bytes(12))` happens to produce, so renaming the fixture
database would have failed a test that is about lifecycle, not naming.
Comparing the created id against the deleted id checks the same thing and
is strictly stronger: it proves the fixture deleted its own database and
left the foreign one alone.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
utopia-php/database#823 gained a join-alias validator fix after this lock
was written, so CI here was still resolving an older commit of the branch
it depends on.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@greptile-apps

greptile-apps Bot commented Sep 22, 2026

Copy link
Copy Markdown

Comments Outside Diff

These findings sit on lines the diff does not cover, so they could not be posted inline. Each one leaves this list once its file changes.

  • P2 Schema Test Mirrors Implementation tests/Abuse/Appwrite/TablesDBTest.php:88

    This test duplicates the complete TimeLimit schema in its assertions, including the column count, names, types, sizes, constraints, index types, and index columns defined in Database.php. It therefore fails on legitimate schema refactors even when abuse-limiting behavior remains correct. This violates the repository directive not to mirror source code or schema configuration in assertions; that requirement must be satisfied before merging by testing observable behavior instead.

    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!

Jake Barnby and others added 2 commits September 22, 2026 17:44
utopia-php/database#823 gained two library fixes after the last re-pin --
the negative document cache no longer survives an epoch rotation, and
stddev/variance are pinned to the population statistic -- so CI here was
resolving a commit that predates both.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Picks up the collection-metadata invalidation fix -- a cached _metadata
entry could outlive its own invalidation under tenant per document --
along with the document version column and compare-and-set removal.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.

1 participant