Resolves the one conflict in app/controllers/api/account.php: main made
the account-create `name` parameter nullable while this branch injects
the breach validator into the same action, so the signature now carries
both.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
A server that has not been told which breach service to ask should ask
nobody, rather than call the public Have I Been Pwned API on its own:
`_APP_PWNED_PASSWORDS_DSN` now defaults to `none://localhost`. The
policy stays enabled by default per project, but it protects nothing
until an operator points the DSN at a service, which the variable
description now says first.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
`_APP_PWNED_PASSWORDS_DSN=none://localhost` picks a validator that never
asks anyone and accepts every password, for a server that must not or
cannot reach a breach service, such as an air-gapped installation. Unlike
`mock`, it is allowed in production: it is an operator's explicit choice,
not a test fixture. Projects can still switch the policy on, but it
protects nothing until the server is pointed at a real service.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Moves the caching into the abstract validator as a `remember()` helper,
so it is written once rather than per subclass, and gives the Appwrite
validator the cache it was missing.
Each subclass still chooses its own key, because what is worth
remembering differs: Have I Been Pwned caches a whole range of hashes per
prefix, the Appwrite service caches a single answer per password. Nothing
is stored when the lookup throws, so an outage is retried rather than
remembered.
The Appwrite key is an HMAC of the password under the secret the service
already shares, not a bare hash, so a cache dump cannot be cracked back
into user passwords.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Drops `isEnabled()`, `checksSessions()` and `blocksUsers()`. Each call
site now reads `auths.passwordPwned` from the project itself, the way the
personal data and history checks already read theirs, and repeats the
defaults rather than sharing them.
The validator no longer carries policy at all, so it takes no policy
argument and the request resource no longer depends on the project. What
is left is a validator that answers one question: has this password been
exposed in a breach.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Review feedback: `Appwrite\Auth\Pwned` was a second hierarchy wrapped by a
validator whose `isValid()` nothing called, and every call site reached
for `check()` instead. That is not how validators are used here.
`PasswordPwned` is now abstract, with one subclass per service, the same
shape as `OAuth2` and its providers. The request resource hands back the
right subclass and call sites use `isValid()` like they already do for
`PersonalData` and `PasswordHistory`.
The tri-state for the `passwordPwned` user attribute did not need a
method of its own after all. A call site knows whether the policy is
enabled, so null comes from not asking rather than from a return value.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Replaces `_APP_PWNED_PASSWORDS_ADAPTER` and `_APP_PWNED_PASSWORDS_ENDPOINT`
with a single `_APP_PWNED_PASSWORDS_DSN`, following how storage, logging
and the database connections are configured. The scheme picks the
adapter and the rest carries whatever that adapter needs.
- `hibp://localhost` reads no details, like `local://localhost` does for
storage.
- `appwrite://SECRET@HOST[:PORT][/PATH][?tls=true]` carries the host and
the JWT secret the service shares, so the secret is no longer borrowed
from `_APP_OPENSSL_KEY_V1`. The path defaults to `v1/detection`.
- `mock://localhost` is new. It reports a fixed list of passwords as
breached without leaving the process, and is refused on a production
server because it would report every real password as safe.
The test stack now uses the mock adapter, which lets the mock range route
in `app/controllers/mock.php` go away. E2E covers the policy, the adapter
unit tests cover each protocol.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The breach lookup moves out of the validator and behind an adapter, so a
server can choose who answers the question.
- `hibp` keeps the current behaviour: the public Have I Been Pwned range
API with k-anonymity, sending only the first five characters of the
SHA-1 hash and caching ranges per prefix.
- `appwrite` talks to an Appwrite Pwned service
(https://github.com/appwrite-labs/pwned), which answers for a whole
password. The password travels inside a short-lived JWT signed with
`_APP_OPENSSL_KEY_V1`, so it is only appropriate for a service on your
own network, and in exchange the service caches and can front a
detector of its own choosing.
`_APP_PWNED_PASSWORDS_ADAPTER` picks the adapter and defaults to `hibp`.
`_APP_PWNED_PASSWORDS_ENDPOINT` now defaults to empty and falls back to
whichever address the chosen adapter ships with. An unknown adapter name
fails loudly at request time rather than quietly falling back.
`PasswordPwned` keeps the policy decisions and delegates the lookup, so
its unit test no longer needs an HTTP double. Each adapter has its own
test next to it.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Extends the `password-pwned` policy with options, all optional on update
and preserving the others when omitted:
- `forceReset` (default false): when true, signing in with a breached
password fails with `user_password_reset_required` until it is reset.
- `failClosed` (default true): reject the password with the new
`general_pwned_passwords_unavailable` (503) when the breach service
cannot be reached; when false the check is skipped.
- `threshold` (default 1): minimum breach count before rejection.
- `endpoint` (default empty): project-level range API endpoint, falling
back to `_APP_PWNED_PASSWORDS_ENDPOINT`, then the public service.
Validated as a public http(s) URL like webhook URLs.
The validator is now built from the policy and registered as the
`pwnedPasswords` request resource, caching range responses per prefix
and endpoint for an hour through the cache library.
Anonymous accounts setting their first password through the email or
phone update endpoints now go through the same policies as account
creation: strength, dictionary, personal data, pwned, and history.
Existing passwords are only verified, never re-validated.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Remove the dev key routes, model, query validator, scopes, CORS header,
spec security scheme, and the request/realtime handling that let a dev
key bypass abuse limits, CSRF, and origin/redirect validation.
Drop the devKeys collection and project attribute from the platform
schema; V25 deletes both from existing installs.
The default OAuth2 success and failure URLs are built on the console URL,
and the callback validates them against the allowed hostnames. A console
served on its own host was missing from that list, so the default redirects
were rejected.
#13630 emptied the logs collection set but kept the database and the
`getLogsDB` plumbing around it. Nothing in this repo reads that database:
`Deletes` takes `callable $getLogsDB` and never dereferences it, and the
collection set it was created from is empty.
Remove the resource from all four containers (request, worker message, CLI
and the shared `resources.php`), `Factory::logs()`, the `logs` pool and
`_APP_CONNECTIONS_DB_LOGS`, the empty collection set, and the boot-time
`createDatabase()` call in `http.php`. The logs set was also merged into the
collection lookup in `Queries\Base`; dropping the key there too.
Boot no longer pings and creates a second database before the platform one.
`_APP_CONNECTIONS_DB_LOGS` was never in `.env`, `docker-compose.yml` or
`app/config/variables.php`, so self-hosted installs left it unset and the
pool fell back to the main `_APP_DB_HOST`. What they are left with is an
empty `logsV1__metadata` table in the `appwrite` schema, which nothing
reads; no migration is warranted for it.
Every error handler built a Utopia\Logger\Log by hand and pushed it to a
third-party provider over utopia-php/fetch. That path leaks the curl handle,
its socket and an eventfd until PHP's cycle collector runs (utopia-php/logger#52),
fetch is archived, and every span already carries the same error. Errors now
flow through Utopia\Span: handlers call Span::add() for the attributes they
used to tag, set the throwable on the current span, and app/init/span.php
adds the utopia-php/span Sentry exporter when _APP_LOGGING_CONFIG holds a
sentry:// DSN. Client errors are marked error.publish=false so only server
failures are exported, matching the old publish rules.
Removed: the logger and realtimeLogger registry entries, the log/logger
container resources, the Log parameter on workers, proxy rules and the
embeddings endpoint, _APP_LOGGING_PROVIDER, _APP_LOGGING_CONFIG_REALTIME and
the _APP_EXPERIMENT_LOGGING_* variables. LogOwl, Raygun and AppSignal are
no longer supported; Sentry is the only exporter.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01D9ybk4YF5Q5L2xQzqhqdCT
#13443 fixed self-hosted builds on S3 by having the Jobs worker copy the
finished artifact off the builds volume onto the device in a new
Deployments::store(), which Cloud then had to override with a no-op: one
decision (where build output lands) split across two overridable methods
that had to agree.
Instead the storage strategy follows the builds device. Local keeps the
shared volume; a remote device gets the s3:// upload/download artifacts
Cloud already runs, signed by the orchestrator's S3_* credentials, so the
job delivers the artifact itself and the worker only checks buildPath.
buildPath()/cachePath() are the device's paths, which keys them under the
bucket on path-style stores such as MinIO and is unchanged on the local
and virtual-host devices. store() and the device constructor parameter go
away, so Cloud's Deployments and factories compile unchanged.
The jobs-based build system writes the artifact onto the shared builds volume, but the Jobs worker, the executor and the download endpoint all read the deployment's buildPath through the configured storage device. With _APP_STORAGE_DEVICE=s3 the artifact never reached S3, so every build failed with "Build produced no output artifact". With an S3-compatible endpoint (MinIO, etc.) the stored buildPath was also wrong: the device folds the bucket into its root, so the plain volume path pointed at a bucket named "storage".
The deployment now stores the device path as its buildPath (unchanged for the local device), and the Jobs worker moves the artifact off the volume onto a remote device before checking readiness. The separate-profile jobs worker also receives the storage variables it needs to build that device.
Geo lookups are their own domain, not a Locale concern. GeoRecord stays
in Appwrite\Locale since it renders locale-aware names.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Mirror the cloud Geo\Client shape: a PSR-18 client over pooled Swoole
coroutine connections with reuse, created once per worker and injected
as 'geoClient'. The Geo service now only validates, caches, and builds
records; a null client (empty _APP_GEO_ENDPOINT) disables lookups.
Cloud can drop its own copy and reuse this class.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The geoRecord DI resource resolved on every API request via the usage
and router init hooks, costing a synchronous call to the geo service
(3s timeout) per request with no caching.
Replace it with a Geo service injected as 'geo': callers fetch a
GeoRecord on demand with $geo->get($ip), backed by a fixed-size
Swoole\Table created before the server forks, so lookups are shared
across all HTTP workers and each IP is fetched once.
Also drop the dead 'geodb' container resource.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* feat: add self-hosted usage service
* fix: make usage stack CI-ready
* fix: mark usage setup image buildable
* fix: gate Appwrite on usage schema setup
* test: initialize usage project before API keys
* fix: prevent usage ingestion from starving workers
* refactor: set up the usage schema at boot, not in a one-shot container
Every other schema in self-hosted Appwrite is created at boot by
app/http.php -- platform DB, project DB, shared-tables metadata, bucket
collections -- with a retry ladder and an already-exists skip. Usage was
the only one with its own container, and Cloud has no equivalent: there
an operator runs the setup script by hand against the migration endpoint.
Gating `appwrite` on `service_completed_successfully` also meant an
unhealthy ClickHouse stopped the API from starting at all, which lets
analytics storage take down the core API. The gating was inconsistent
too: only the dev override waited on the one-shot, so in the shipped
compose it was an orphan sitting at Exited (0), which reads as a failure.
Call Connection::setup() from the existing boot block instead. It retries
on the same 15x2s ladder as the databases above so a cold start wins the
race against ClickHouse, then gives up with a warning rather than
blocking boot. Reads and ingestion already gate on Connection::isReady(),
so both stay correct while the schema is missing.
Keep bin/usage-setup and the CLI task -- they repair a dropped table
without a restart, the closest analogue to Cloud's manual script -- and
put its retry on the same ladder.
* refactor(usage): open the read endpoints for edition-specific policy
Cloud has to enforce plan history limits, the premium geo addon, and its
affiliate metric carve-out on the same two endpoints, and today it does
that by keeping a full copy of both actions. The copies have already
drifted behind this branch's gauge fixes, so the duplication is actively
losing correctness rather than merely costing lines.
Make the upstream actions subclassable instead:
- widen the dimension/filter/interval constants and the query helpers from
private to protected
- read them through `static::` so an override actually takes effect --
`self::` binds to the defining class and would silently ignore Cloud
- inject a `usagePolicy` object the actions consult before querying. The
self-hosted implementation allows everything, since self-hosted has no
plans, addons, or reseller namespaces. Cloud binds a subclass that
carries the checks its endpoints do today.
The policy is injected rather than hung off the action because actions are
shared across coroutines, so per-request state cannot live on `$this`.
Also fold `country` filters through Context::normalizeCountry() on the way
in. Writes have always stored the column lowercased, readers did not fold
the filter, and ClickHouse compares case-sensitively -- so
`equal("country", ["US"])` returned an empty series. Both sides now share
one rule, with a unit test pinning them together.
* chore: ignore the .pi scratch directory
* docs(usage): explain the realtime concurrency constants
Cloud carried these two constants with the rationale attached; upstream
now owns them, so bring the reasoning along rather than leaving bare
values here and a duplicate definition there.
* refactor(usage): extract realtime concurrency sampling into a library
Cloud's stats-resources task carries a near-verbatim copy of this fold --
same method names, same three constants, same values -- so the two editions
each own an arithmetic they should agree on. They had already diverged:
Cloud opens its first window at `_APP_STATS_RESOURCES_INTERVAL` unfloored,
so an interval below the 300s bucket size yields a window that closes
before any whole bucket has elapsed and samples nothing at all.
Subclassing does not work here: this task injects `usageConnection`, which
Cloud's container does not define, and inject() is positional and cannot be
dropped by a subclass. The fold is a well-defined domain concept and takes
only a Usage instance, so it becomes Appwrite\Usage\Concurrency and both
editions call it.
Task drops 157 -> 63 lines. The flooring fix lives in the shared code, with
a unit test that fails on the old unfloored behaviour.
* ci: run the Usage e2e suite
The suite was added with the endpoints but never wired into the E2E
matrix, so it has not run in CI once -- the endpoints were only ever
covered by whatever ran locally.
ClickHouse is in the default compose profile, so `compose up --wait`
already starts it; the job needs no other setup. Marked functional so
paratest parallelizes the single class per method, matching the other
one-class suites.
* fix(usage): resolve the PHPStan failures on the boot setup and test fake
Two real defects the project-wide scan caught:
- app/http.php annotated $usageConnection with an aliased class name that
PHPStan would not resolve in that docblock, so isEnabled() and setup()
were both calls on an unknown type. Use the fully-qualified name and drop
the now-unused alias.
- the test fake bound $queued by reference before checking isset(), which
created the array key as a side effect and made the guard always true.
Read through the key instead and shift in place.
Also return the Context setters to `static` rather than `self`, so a
subclass can chain them. Cloud adds a team dimension on top of this class
and chains its own setter after a dozen inherited ones; with `self` the
chain degrades to the base type halfway through and the subclass method is
unreachable. That is what kept Cloud's copy of every setter alive.
* refactor(usage): own the usage workers and tasks in the Usage module
Three of the five _APP_EDITION checks this branch added were the wrong
mechanism for what they were guarding.
The one in Platform\Appwrite was simply dead: Cloud composes Core() plus
its own modules through Appwrite\Cloud\Platform\Appwrite and never
instantiates this class, so the guard could not fire there.
The two in the shared Core services were load-bearing but env-dependent.
Cloud registers its own stats-usage and stats-resources, and Core is added
first, so without a guard getWorkerAction() would hand Cloud the generic
worker instead of its billing-aware one -- silently, and only when
_APP_EDITION happened to be unset.
Move both registrations into the Usage module's own Services/Workers.php
and Services/Tasks.php, which is where Databases and Functions already keep
theirs. Cloud never registers that module, so the collision cannot occur
regardless of environment. Verified with _APP_EDITION unset: Cloud drops
from three duplicated usage actions to none, and usage-setup is no longer
registered there at all, which matches Cloud provisioning its schema
out-of-band.
The remaining two guards stay, for reasons that are not registration:
Deletes would begin purging Cloud's usage rows on project deletion, and
Schedule would run a second usage loop alongside Cloud's own scheduler.
* chore(usage): drop the new unit tests and widen the usage constraint
Removes the unit tests this branch introduced. The e2e suite covers the
usage endpoints, and tests/unit/Usage/Fakes/Adapter.php only existed to
serve them.
Also allow utopia-php/usage ^0.14.0 rather than pinning 0.14.0 exactly, so
patch releases come in without a lock edit. The lock still resolves 0.14.0;
only its content hash changed.
RegistrationTest keeps its Usage service entry -- that is not new coverage,
it is the existing duplicate-worker assertion following the registration
move.
* refactor(usage): split the policy hook into three assertions
Cloud's merged entitlement work asserts access, geo dimensions and history
at three different points, and it has to: access is checked before the
request is parsed so an unauthorised caller is refused rather than told
whether their query was valid, while the geo gate needs the parsed filters
and the history check needs the resolved window.
A single assert() could only run after parsing, which turned that 401 into a
400. Match the three-call shape so Cloud can inherit the query unchanged.
Gauges asserts history only, as Cloud's does -- it has no geo dimensions and
no metric carve-out.
* style(usage): type the concurrency constants
Cloud's version of this class, merged in appwrite-labs/cloud#5399, typed
these; keep that when the two converge here.
* chore: ship console 0.6.0 with self-hosted usage
vibes 0.6.0 includes appwrite/vibes#155, which enables the usage screens
against the endpoints this branch adds. Older console builds have no UI for
them.
* fix(usage): expire readiness cache and purge team project tenants
ClickHouse readiness was cached forever after the first success, so later
outages were treated as healthy and usage writes were dropped. Team-owned
project deletes also never reached the tenant purge path.
* feat(usage): emit unified per-resource storage gauges on self-hosted
The self-hosted stats-resources worker only counted rows, so the console's
storage charts — which read the unified `storage` gauge Cloud writes per
bucket, database, function, and site — stayed empty. Port Cloud's
collectUnifiedStorage projection: per-resource storage bytes plus the
files/collections/documents/deployments/builds companions and project
totals, with explicit service/resourceType/resourceId tags.
Flat dimensioned gauge aggregates also returned time: null, which crashes
the console's top-resources parser; the window end now stands in, matching
the flat max-aggregate precedent.
* chore: ship console 0.6.1
* fix(usage): purge tenants before the delete removes their mapping
Team deletion removed the platform project records inside the action and
purged ClickHouse afterwards, but retries reconstruct tenant sequences
from those records — a purge failure after the delete left the tenants
unrecoverable. Purge first, so a failure fails the message while a retry
can still resolve the mapping, and sweep again after the delete for rows
that landed in between (best-effort, logged). A purge returning false now
also fails the message instead of being silently acknowledged.
* fix(usage): land review typing, errors, and static hooks
Type the request usage context, split disabled vs schema-not-ready
catalog errors, and late-bind overridable interval constants.
Co-authored-by: Chirag Aggarwal <chiragaggarwal5k@gmail.com>
* fix(usage): span the swallowed post-delete tenant sweep
Keep the best-effort Console::error, and add Span attributes so a
failed sweep is visible on the worker span, not only stdout.
Co-authored-by: Chirag Aggarwal <chiragaggarwal5k@gmail.com>
---------
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
getDocument() is declared as returning Document, so the sessionActive()
calls in the JWT auth paths tripped PHPStan's method.notFound. The users
collection is mapped to User via setDocumentType(), matching the
annotations already on the cookie-path lookups above.
JWT auth only checked that the session still existed on the user
document, so tokens remained valid after session timeout. Align JWT
validation with sessionVerify by requiring a non-expired session.
Co-authored-by: Cursor <cursoragent@cursor.com>
When _APP_LOCALE was set to a partial locale (e.g. fr), Locale fallback
matched that same incomplete set, so missing email keys rendered as
{{emails.*}} instead of English. Keep instance default from _APP_LOCALE
but always fall back to en, which is the complete translation catalog.
Co-authored-by: Chirag Aggarwal <chiragaggarwal5k@gmail.com>
Builds have run on the open-runtimes jobs-service for a while
(_APP_BUILDS_BACKEND=orchestrator); this removes the switch and the executor
build path behind it.
- Merge `Deployment\Backend` and `Backend\Orchestrator` into a single
`Deployment\Deployments` service and delete `Backend\Executor`.
- The Builds worker's backend check becomes an unconditional hand-off to the
jobs-service, which leaves everything after it unreachable: the executor
create/log coroutines, tarball packing, adapter detection, activation and
fan-out are all deleted. The worker keeps only the template-into-repo git
push (a git *write* the artifact system has no primitive for), after which
the Jobs worker owns the deployment's lifecycle.
- Route createFunction's deprecated `template*` params through
`createFromRef()` — the worker's non-VCS branch was their only build path.
Share the template ref-range resolution the three template callers need as
`Compute\Base::resolveTemplateRef()`.
- Drop the now always-true `instanceof Orchestrator` branch from the deployment
status endpoints, and `Executor::createRuntime()`/`getLogs()`.
Behaviour note: template-into-repo builds no longer enforce a source size
limit, matching plain VCS builds since they moved to the jobs-service.
Verified with composer lint, composer analyze, tests/unit, and the full
Functions and Sites e2e suites.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Removing the per-document usage emission left $usage captured but unused in the
getDatabasesDB factory closure, which PHPStan flags (Checks CI failure). Drop it
from the closure param, the inner use(), and the DI dependency list.
Document counts and per-collection storage are produced by the StatsResources
full-count as ClickHouse gauges broken down by resourceId/resourceType, so the
per-event emission (METRIC_DOCUMENTS + METRIC_DATABASE_ID_COLLECTION_ID_DOCUMENTS
template) from the database usage listeners is redundant. Remove the
emitDocumentsUsage closure + its listeners and the documents switch case,
along with the now-unused database-type prefix helper.
The per-project count/storage metrics (teams/users/databases/collections/
documents/buckets/files/filesStorage/functions/sites/deployments/
deploymentsStorage) are produced by StatsResources as ClickHouse gauges keyed
by resourceId, and StatsUsage already skips them from the event write path.
Emitting them again from the database usage listener + CSV migration only fed
the deprecated MySQL path (and dead addReduce cleanup). Drop those emits; keep
sessions, the nested per-collection documents metric, and the resourceType-level
deployment metrics (event-sourced, not gauge-owned).
Backend selection moves into a deploymentsFactory DI resource
((Database, Document) => Backend); the request-scoped 'deployments' is
the factory applied to the request's own project, and webhook handlers
build a correctly-bound Backend per tenant inside their fan-out loop —
one webhook reaches many projects, each with its own database.
Deletes forProject()/final constructors (downstream can extend
constructors again) and the webhook trait's nullable Backend + executor
fallback: webhook site builds and all Gitea builds now route through the
Backend, honoring _APP_BUILDS_BACKEND, with deactivateOthers applied
like every other entrypoint.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Teaches the deployment Backend abstraction's orchestrator path about sites
and removes the transitional /v1/sites gate, so _APP_BUILDS_BACKEND covers
both resource types:
- Orchestrator::payload() branches on resource collection: buildRuntime/v5,
site memory minimums, APPWRITE_SITE_* variables, collection-based presigned
source URL and meta.resourceType, and a normalized subdir (./x tarball
paths previously extracted nothing).
- Site builds emit a JSON build manifest (build.sh, open-runtimes 0.13.6+),
read back post-job as an artifact callback; the Jobs worker joins readiness
on exit + complete + manifest and runs SSR/static adapter detection over
the file listing, replacing the executor's log-separator hack.
- Jobs worker finalization generalized by resourceType: activation, branch
preview rules (shared with the Builds worker via Compute\Base), screenshots,
latest-deployment pointer, events, and commit-status URLs.
- Sites entrypoints route through the deployments Backend: VCS redeploys use
presigned tarballs, templates resolve wildcard tags to createFromRef,
duplicates re-fetch remote sources, cancel goes through Backend::cancel(),
and the sites download endpoint accepts presigned source tokens.
- Duplicate endpoints (sites + functions) set activate explicitly: the
source deployment's flag is unset by deactivateOthers() once anything
newer builds, so inheriting it skipped activation on repeat duplicates.
- Fixes Sites/Http/Sites/Update.php stamping resourceType 'functions' on
site deployments via redeployVcsFunction.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Backend says what the abstraction is — a swappable build-dispatch
backend — and Orchestrator names the jobs-service strategy after the
system it talks to, freeing 'Jobs' for the worker that consumes its
callbacks.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Consolidates the scattered deployment-creation and build-dispatch logic across
HTTP actions (manual upload, duplicate, template, VCS webhook, VCS reconnect)
into a single Appwrite\Service\Deployments abstraction, with Executor and
Jobs implementations selected per-request by _APP_BUILDS_BACKEND. Sites are
now forced onto the executor implementation regardless of that env var, since
the jobs-service payload builder is function-shaped.
- upload() for chunked-upload bookkeeping (no build), createFromUpload()/
createFromRef()/createFromUrl() for the three real build-source shapes,
delete() for best-effort cancel — replaces duplicated permissions/
resourceId-triplet construction and deactivate-others logic at every call
site.
- Appwrite\Compute\Job merged into Deployments\Jobs; its output/cache
handling is now an overridable storage() extension point (late-static-bound)
so a fork can swap the shared-volume strategy for upload/download artifacts
without touching payload construction.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Adds an alternative, stateless build backend for manual-upload function
deployments using the open-runtimes jobs-service (orchestrator) instead of
the executor.
The build runs as a stateless job: source, output, and the package-manager
build cache all cross the boundary via the jobs-service artifacts system
(presigned download/upload), and progress arrives as CloudEvents callbacks
handled by a new worker-jobs. createDeployment submits the job in the request
flow; the executor path is untouched for every other build trigger.
- Orchestrator\Jobs: thin jobs-service HTTP client (POST /v1/jobs)
- Appwrite\Compute\Job: builds the job payload (image, command, env, artifacts)
- Appwrite\Deployment\Token: signed presign tokens (source/output/cache)
- Functions/Http/Deployments/Archive: token-authed output + cache upload (PUT)
- Functions/Http/Jobs/Event: HMAC-verified CloudEvents callback ingress
- Functions/Workers/Jobs: applies log/exit callbacks under a per-deployment
lock; on completion fires the deployment.update fan-out (webhooks +
event-functions + realtime) and refreshes latestDeployment*, mirroring the
executor Builds worker
- Deployments/Download/Get: presigned source + build-cache download
- Build cache via OPEN_RUNTIMES_BUILD_* dir overrides: pure artifacts, no shell
bridge (per-function npm/yarn/pnpm cache reused across builds)
- DI/queue wiring, docker services (orchestrator-jobs, worker-jobs), test-build.sh
Verified end-to-end: deploy -> ready -> activated -> executes (200); cache
miss -> save -> hit; latestDeploymentStatus + webhook/function fan-out fire.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Remove orphaned MaxMind asset app/assets/dbip/dbip-country-lite-2026-06.mmdb
(no longer referenced after switch to the geo service).
- Store session countryCode lowercase again to preserve the pre-geo-service
API value; /v1/locale and x-appwrite-country-code headers stay uppercase as before.
- Restore console denylist fail-open behavior: a missing/unknown geo lookup ("--")
is allowed through to the membership check, matching pre-geo-service behavior.
Remove the now-unused lookupSucceeded plumbing from GeoRecord and getGeoForIp.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Swoole workers reuse the singleton getGeoForIp closure across all
requests. Capturing the Locale reference at first resolution would
lock every subsequent request to the first request's language, and the
per-worker $cache grew unbounded for the life of the process.
Pass Locale into the closure invocation instead of closing over it, and
rely on the per-request geoRecord resource to cache within a request.
Distinguish "geo service returned a well-formed response with unknown
country" from "geo service could not be reached". The former is normal
for private and documentation IPs and must not block console traffic;
the latter is the security concern F5 called out, where an operator
cannot prove the caller sits outside the denied set.
Track lookup success on GeoRecord and only fail-closed when the service
did not respond successfully. This restores the auth flow for local
development and CI test IPs while still refusing access when geo is
misconfigured or offline against a configured denylist.
Restructure GeoRecord + getGeoForIp so the cached record holds raw geo data
and locale-translated country/continent names resolve lazily against the
current request locale. Extract the full session field set from the geo
service response (latitude/longitude/timeZone/weatherCode/postalCode/
autonomousSystem*/connection*/isp) via dedicated getters so account.php
callsites stop relying on ad-hoc getAttribute() lookups.
Normalize country/continent codes to uppercase before the EU check so the
lookup no longer depends on the geo API and locale-eu.php happening to
agree on case.
Add an isEmpty() override so geo-fencing guards in general.php and
Executions/Create.php actually key off "geo data is available" instead of
"the ArrayObject has any elements", which was always true.
Every emitter that used to bake a resourceInternalId (function, site,
webhook, deployment, database, bucket) into the metric-name string now
sets that dim on the Context. On CE the setters are no-ops; on cloud
they populate dedicated schema columns so the underlying row carries
the dimension without a per-ID template.
Files touched: RequestCompleted/ExecutionCompleted listener, Builds and
Webhooks workers, Screenshots disabledMetrics list, Functions execution
create, Migrations resource-import counters, and the shared request
init that fans out per-collection database events.