Repository navigation
chore: absorb schedule into packages/schedule - #13887
Conversation
feat(schedule): add utopia-php/schedule, a scheduler that cannot silently skip a run
feat(schedule)!: deliver each occurrence when it falls due, and make coverage answerable
fix(schedule): an id that looks like a number survives the schedule map
feat(schedule): the cron trigger speaks the Quartz day extensions
feat(schedule): pass the rejected row to the error handler
…with test classes
|
| // A TTL here would take the watermark with it when the lease ran | ||
| // out, and the next leader would start from "now", skipping | ||
| // everything in the gap. | ||
| $this->assertSame(-1, $this->redis->ttl($this->key)); |
There was a problem hiding this comment.
Tests pin implementation details The
-1 TTL assertion checks Redis configuration instead of whether a successor retains the watermark and delivers missed work. ReconcileTest.php and ReliabilityTest.php likewise assert exact make() call counts. The repository requires tests to check observable behavior, not implementation details or configuration; this requirement must be met 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/schedule/tests/E2E/RedisStoreTest.php
Line: 153
Comment:
**Tests pin implementation details** The `-1` TTL assertion checks Redis configuration instead of whether a successor retains the watermark and delivers missed work. `ReconcileTest.php` and `ReliabilityTest.php` likewise assert exact `make()` call counts. The repository requires tests to check observable behavior, not implementation details or configuration; this requirement must be met 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!
| return ['LW', 0, 0]; | ||
| } | ||
|
|
||
| if (preg_match('/^l-(\d+)$/', $part, $matches) === 1) { |
There was a problem hiding this comment.
Imported parser uses regular expressions This cron parser adds
preg_match here and in the nearby day-field rules. The repository guide says not to add regular expressions: use string functions or an existing validator, and explain in the PR if an exception is necessary. This requirement must be addressed before merging.
Context Used: AGENTS.md (source)
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/schedule/src/Trigger/Cron.php
Line: 294
Comment:
**Imported parser uses regular expressions** This cron parser adds `preg_match` here and in the nearby day-field rules. The repository guide says not to add regular expressions: use string functions or an existing validator, and explain in the PR if an exception is necessary. This requirement must be addressed 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!
| "test": "phpunit --testsuite unit", | ||
| "bench": "php tests/bench/run.php", | ||
| "test:e2e": "phpunit --testsuite e2e" |
There was a problem hiding this comment.
Standalone test commands lack PHPUnit These scripts still invoke
phpunit, but the package no longer declares it as a development dependency. If someone follows the README after a clean standalone mirror install without a global PHPUnit, composer test and composer test:e2e cannot run. The monorepo runner supplies PHPUnit separately; clarify the standalone setup or make the published scripts executable.
Knowledge Base Used: Reusable platform packages
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/schedule/composer.json
Line: 42-44
Comment:
**Standalone test commands lack PHPUnit** These scripts still invoke `phpunit`, but the package no longer declares it as a development dependency. If someone follows the README after a clean standalone mirror install without a global PHPUnit, `composer test` and `composer test:e2e` cannot run. The monorepo runner supplies PHPUnit separately; clarify the standalone setup or make the published scripts executable.
**Knowledge Base Used:** [Reusable platform packages](https://app.greptile.com/appwrite/-/custom-context/knowledge-base/appwrite/appwrite/-/docs/reusable-platform-packages.md)
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
# Conflicts: # composer.lock
# Conflicts: # composer.lock
| <env name="REDIS_HOST" value="127.0.0.1"/> | ||
| <env name="REDIS_PORT" value="16385"/> |
There was a problem hiding this comment.
Unprefixed test environment variables The new test configuration defines
REDIS_HOST and REDIS_PORT, which RedisStoreTest.php reads. The repository requires environment variables to use the _APP_ prefix. Update the configuration and the test together to satisfy this requirement before merging.
Context Used: AGENTS.md (source)
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/schedule/phpunit.xml
Line: 25-26
Comment:
**Unprefixed test environment variables** The new test configuration defines `REDIS_HOST` and `REDIS_PORT`, which `RedisStoreTest.php` reads. The repository requires environment variables to use the `_APP_` prefix. Update the configuration and the test together to satisfy this requirement 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!
|
|
||
| $scheduler->run(function (array $occurrences) use ($queue): void { | ||
| foreach ($occurrences as $occurrence) { | ||
| Span::init('schedule.enqueue'); |
There was a problem hiding this comment.
Handler example manages spans The tracing example starts a span here and finishes it inside the dispatch handler. The repository’s tracing directive permits
Span::add in handlers but prohibits span lifecycle calls there. Revise the example to satisfy that requirement before merging.
Context Used: AGENTS.md (source)
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/schedule/README.md
Line: 277
Comment:
**Handler example manages spans** The tracing example starts a span here and finishes it inside the dispatch handler. The repository’s tracing directive permits `Span::add` in handlers but prohibits span lifecycle calls there. Revise the example to satisfy that requirement 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!
# Conflicts: # composer.lock
# Conflicts: # composer.lock
|
Taking this over from @ChiragAgg5k.
|
|
Decision: utopia-php/monorepo#312 stays out of this PR. It gets re-opened against |
|
Removal on the monorepo side: utopia-php/monorepo#353 (draft until this merges and Split pushes to the mirror). |
Summary
This moves
utopia-php/scheduleintopackages/schedule, so Appwrite loads it directly. It is wave 1 of #13828, follows the playbook inrfc/monorepo.md, and comes in four commits:Add 'packages/schedule/' from commit 'fd284166…': subtree import from the mirror with full history. The mirror head is the0.3.0tag Appwrite already locks, so the schedule tasks run the same code.chore(schedule): mirror plumbing:mirror.ymlnow points here, the README gets the mirror banner, andabsorbstripsphpunit/phpunitfromrequire-dev(hoisted to the root).refactor: load schedule from packages/:replaceentries, drops theutopia-php/schedule: ^0.3.0require line, and removes the package from the lock.src/was already flat.Utopia\Testsnamespace toUtopia\Schedule\Tests, with a matchingautoload-deventry.tests/RedisStoreTest.phpmoves totests/E2E/(namespaceUtopia\Schedule\Tests\E2E, importing theSnapshotSourcefixture), andphpunit.xmlnow excludestests/E2Eandtests/benchfrom the unit suite, matching the rootpackagessuite.phpstan.neonused to include the monorepo root config andrector.phprequired the monorepo rootrector.php;validaterejects the first and the second no longer resolves. Both are now standalone. PHPStan runs at level max oversrcandtestsand passes with no baseline.rector.phpmatches smtp's standalone config.braces_position,function_declaration,new_with_parentheses,class_definition).chore(schedule): drop rectorPreset so Rector stops annotating source with test classes: the mirror'srector.phpenabledrectorPreset, which added a@see \Utopia\Schedule\Tests\SchedulerTestannotation toScheduler. As in the smtp absorb (chore: absorb smtp into packages/smtp #13829), the set is dropped and the annotation reverted.There's nothing to hoist. The package requires only PHP and
utopia-php/telemetry, which is already inpackages/; cron parsing is implemented in-house (Trigger\Cron), not throughdragonmantank/cron-expression.Net: +148 / −183 across commits 2 to 4.
Validation
bin/monorepo validate: all packages validbin/monorepo check schedule: Rector, Pint and PHPStan level max pass (no baseline)bin/monorepo test schedule: unit 96 tests / 245 assertions; e2e 9 tests / 80 assertions against Redis fromdocker-compose.ymlvendor/bin/phpunit --testsuite packages --filter 'Utopia\\Schedule': 96 tests / 245 assertions under the root autoloader, with E2E excludedvendor/bin/phpunit tests/unit/Schedule: 4 tests passsrc/Appwrite/Schedule,Tasks/ScheduleFunctions.php,Tasks/ScheduleExecutions.php,Tasks/ScheduleMessages.php,Tasks/StatsResources.phpandTask/Validator/Cron.php: no errorsUtopia\Schedule\Schedulerresolves topackages/schedule/srcfrom the root autoloadercomposer update --lock: the lock diff removes onlyutopia-php/schedule(plus the content hash)composer validate --no-check-publish: valid (existing warnings only)composer lint: passesbin/monorepo split schedule --dry-run:db700e1b, which fast-forwards from the mirror headfd284166(3 commits)git diff --checkMerge and follow-up
Merge with a merge commit.
The
utopia-php/schedulemirror already has the canonicalmainruleset (id20997966), with the split app as an always-bypass actor, so the absorb ran with--skip-ruleset.After merge: confirm
Splitpushes toutopia-php/schedule. Then removepackages/schedulefromutopia-php/monorepo. The mirror has no open PRs.Needs a decision: utopia-php/monorepo#312 (loks0n, fix(schedule): warm followers before leadership handoff) is still open against
packages/schedulethere. It adds follower pre-warming,isReady()and a takeover rebase, with new tests. It is not ported here, to keep this PR a pure move. Once this merges it should be re-opened againstpackages/schedulein this repository (the test file paths change:tests/RedisStoreTest.phpis nowtests/E2E/RedisStoreTest.php, and the test namespace isUtopia\Schedule\Tests), then closed on the monorepo.🤖 Generated with Claude Code
Related: #13828