Skip to content

chore: absorb schedule into packages/schedule - #13887

Merged
loks0n merged 13 commits into
mainfrom
chore/absorb-schedule
Sep 25, 2026
Merged

loks0n merged 13 commits into
mainfrom
chore/absorb-schedule

Conversation

@ChiragAgg5k

@ChiragAgg5k ChiragAgg5k commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

Summary

This moves utopia-php/schedule into packages/schedule, so Appwrite loads it directly. It is wave 1 of #13828, follows the playbook in rfc/monorepo.md, and comes in four commits:

  1. Add 'packages/schedule/' from commit 'fd284166…': subtree import from the mirror with full history. The mirror head is the 0.3.0 tag Appwrite already locks, so the schedule tasks run the same code.
  2. chore(schedule): mirror plumbing: mirror.yml now points here, the README gets the mirror banner, and absorb strips phpunit/phpunit from require-dev (hoisted to the root).
  3. refactor: load schedule from packages/:
    • Adds the root autoload and replace entries, drops the utopia-php/schedule: ^0.3.0 require line, and removes the package from the lock.
    • Step A of the standard shape:
      • src/ was already flat.
      • Tests move from the bare Utopia\Tests namespace to Utopia\Schedule\Tests, with a matching autoload-dev entry.
      • tests/RedisStoreTest.php moves to tests/E2E/ (namespace Utopia\Schedule\Tests\E2E, importing the SnapshotSource fixture), and phpunit.xml now excludes tests/E2E and tests/bench from the unit suite, matching the root packages suite.
    • phpstan.neon used to include the monorepo root config and rector.php required the monorepo root rector.php; validate rejects the first and the second no longer resolves. Both are now standalone. PHPStan runs at level max over src and tests and passes with no baseline. rector.php matches smtp's standalone config.
    • Pint formatting (braces_position, function_declaration, new_with_parentheses, class_definition).
  4. chore(schedule): drop rectorPreset so Rector stops annotating source with test classes: the mirror's rector.php enabled rectorPreset, which added a @see \Utopia\Schedule\Tests\SchedulerTest annotation to Scheduler. 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 in packages/; cron parsing is implemented in-house (Trigger\Cron), not through dragonmantank/cron-expression.

Net: +148 / −183 across commits 2 to 4.

Validation

  • bin/monorepo validate: all packages valid
  • bin/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 from docker-compose.yml
  • vendor/bin/phpunit --testsuite packages --filter 'Utopia\\Schedule': 96 tests / 245 assertions under the root autoloader, with E2E excluded
  • vendor/bin/phpunit tests/unit/Schedule: 4 tests pass
  • Root PHPStan (host) on src/Appwrite/Schedule, Tasks/ScheduleFunctions.php, Tasks/ScheduleExecutions.php, Tasks/ScheduleMessages.php, Tasks/StatsResources.php and Task/Validator/Cron.php: no errors
  • Utopia\Schedule\Scheduler resolves to packages/schedule/src from the root autoloader
  • composer update --lock: the lock diff removes only utopia-php/schedule (plus the content hash)
  • composer validate --no-check-publish: valid (existing warnings only)
  • composer lint: passes
  • bin/monorepo split schedule --dry-run: db700e1b, which fast-forwards from the mirror head fd284166 (3 commits)
  • git diff --check

Merge and follow-up

Merge with a merge commit.

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

After merge: confirm Split pushes to utopia-php/schedule. Then remove packages/schedule from utopia-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/schedule there. 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 against packages/schedule in this repository (the test file paths change: tests/RedisStoreTest.php is now tests/E2E/RedisStoreTest.php, and the test namespace is Utopia\Schedule\Tests), then closed on the monorepo.

🤖 Generated with Claude Code

Related: #13828

loks0n and others added 8 commits August 18, 2026 16:49
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
…3a3cf9868'

git-subtree-dir: packages/schedule
git-subtree-mainline: b866958
git-subtree-split: fd28416
@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 schedule library from external dependency into monorepo.

The PR is not ready to merge while the outstanding repository requirements and standalone test setup remain unaddressed.

Fix All in Claude CodeFindings

  1. P2 Tests pin implementation details ▶
  2. P2 Imported parser uses regular expressions ▶
  3. P2 Standalone test commands lack PHPUnit ▶
  4. P2 Unprefixed test environment variables ▶
  5. P2 Handler example manages spans ▶
Fix with agent prompt
### Issue 1
packages/schedule/tests/E2E/RedisStoreTest.php:undefined-153
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.

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/schedule/src/Trigger/Cron.php:undefined-294
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.

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/schedule/composer.json:42-44
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.

### Issue 4
packages/schedule/phpunit.xml:25-26
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.

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 5
packages/schedule/README.md:undefined-277
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.

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

This PR imports utopia-php/schedule into packages/schedule and switches Appwrite’s Composer autoloading from the locked package to the in-tree copy.

  • Adds package-local test, analysis, and mirror configuration.
  • Preserves the scheduler implementation while reorganizing its tests into unit and Redis E2E suites.

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

// 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));

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 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!

Fix in Claude Code Fix in Codex

return ['LW', 0, 0];
}

if (preg_match('/^l-(\d+)$/', $part, $matches) === 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 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!

Fix in Claude Code Fix in Codex

Comment on lines +42 to +44
"test": "phpunit --testsuite unit",
"bench": "php tests/bench/run.php",
"test:e2e": "phpunit --testsuite e2e"

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 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.

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

Metric Before After Change
🚀 Requests/sec 186.62 191.45 ⚪ +2.6%
⏱️ Latency P50 92.19 ms 89.91 ms ⚪ -2.5%
⏱️ Latency P95 218.95 ms 212.26 ms ⚪ -3.1%
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 89.91 212.26 12,198 191.45 -6.68
Account 171.75 323.44 642 10.66 -95.22
TablesDB 87.31 168.44 6,634 107.11 +1.09
Storage 81.3 186.61 3,210 53.45 -3.55
Functions 127.96 251.42 1,712 29.01 -11.7

Top API waits (after)

API request Max wait (ms)
account.name.update 456.4
tablesdb.rows.create 448.48
functions.create 429.63
storage.files.update 398.68
account.prefs.update 368.83

Comment on lines +25 to +26
<env name="REDIS_HOST" value="127.0.0.1"/>
<env name="REDIS_PORT" value="16385"/>

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 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!

Fix in Claude Code Fix in Codex


$scheduler->run(function (array $occurrences) use ($queue): void {
foreach ($occurrences as $occurrence) {
Span::init('schedule.enqueue');

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 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!

Fix in Claude Code Fix in Codex

@loks0n loks0n self-assigned this Sep 25, 2026
@loks0n

loks0n commented Sep 25, 2026

Copy link
Copy Markdown
Member

Taking this over from @ChiragAgg5k.

  • Merged main again to clear the composer.lock conflict (the di absorb landed). Relocked; the lock diff against main still removes only utopia-php/schedule. bin/monorepo validate passes.
  • The previous Functions E2E failure (testEventTrigger) was a 500 from the orchestrator on POST /v1/jobs during the build. That's infra and has nothing to do with schedule.
  • Greptile's P2s (regex in Trigger\Cron, unprefixed REDIS_* in package tests, README span example, test style) are all about upstream code. This PR is a pure move, so they're out of scope here. phpunit leaving require-dev follows the standard absorb shape, same as smtp.

@loks0n

loks0n commented Sep 25, 2026

Copy link
Copy Markdown
Member

Decision: utopia-php/monorepo#312 stays out of this PR. It gets re-opened against packages/schedule here after merge.

@loks0n
loks0n merged commit e11a2e1 into main Sep 25, 2026
49 checks passed
@loks0n

loks0n commented Sep 25, 2026

Copy link
Copy Markdown
Member

Removal on the monorepo side: utopia-php/monorepo#353 (draft until this merges and Split pushes to the mirror).

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.

2 participants