Repository navigation
feat!: typed external facts and per-command HTTP edges - #347
Merged
Merged
Conversation
The reference app's identity path wrote `auth_users` twice: the scrape
upserted the row directly and also published the event a hand-written
projector (dispatching on `name.contains("deactivated")`) applied
again. It also hand-wrote HTTP routes with a copied
`session_from_headers` that put every request header into the session.
- `publish_external(source, event)` on the causal command context and
commit builder publishes a typed fact whose identity is its external
source. It commits with the ledger receipt and carries its causation,
so `projection!` projects it like an aggregate event. `AUTH_USERS` is
now declared with `projection!` and a mutation program, like TODOS.
- `Service::with_http_command(command, edge)` exposes one command at
`POST /{command}`. The edge authenticates from headers and body and
returns the command id, input, session and principal; nothing else
from the request reaches the command. `command_router` mounts only
exposed commands, and `command_gateway_routes` sends every command
path to the service, so an unexposed one is a 404, never the UI.
- `RepositoryError::DuplicateOutboxMessageInBatch` is renamed
`DuplicateOutboxMessage`: one message id repeated in a batch or
already committed.
Deleted from e2e-ui and e2e-celld: `project_auth_user`, the direct
`auth_users` upsert, `publish.rs`, the hand-written ingress and scrape
routes, `session_from_headers` and the closed-route loop.
BREAKING CHANGE: `DuplicateOutboxMessageInBatch` is renamed; the two
Zitadel commands answer the wait-path shape (`{payload, receipt}`).
Implements [[tasks/v5-review-28]]
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
patrickleet
changed the base branch from
refactor/v5-review-27c-test-binaries
to
v5
November 25, 2026 05:51
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Task 28 stage A (identity without workarounds), covering review 13 findings #3, #9, #10 and #11. Stacked on #346.
Framework
publish_external(source, event), onCausalCommandContextandCausalCommitBuilder, publishes a typed fact from an external source: a provider webhook, a reconciliation, anything that isn't an aggregate transition.RepositoryError::DuplicateOutboxMessage.projection!over the event projects it like an aggregate event.Service::with_http_command(command, edge)exposes one command atPOST /{command}.nullwhen the body is empty; malformed JSON is a 400 before the edge runs).HttpCommandDispatch { command_id, input, session, principal }. The command runs through the normal ledgereddispatch_causal_with_receipt. No request header reaches the command unless the edge puts it in the session.{payload, receipt}, or{code, error}with the error's status.microsvc::command_router(service)mounts only the exposed command paths.routerbuilds on it.Service::command_gateway_routes(binding)gives the service binding an exact route for every command path. An unexposed command is a 404 from the service and can never fall through to the UI.RepositoryError::DuplicateOutboxMessageInBatch→DuplicateOutboxMessage, covering an id repeated within a batch or already committed.Demos (e2e-ui and e2e-celld)
AUTH_USERSis declared withprojection!over a newZitadelUserProfileevent and aSaveAuthUsermutation program, like TODOS.publish_external.project_auth_userprojector, which dispatched onname.contains("deactivated");auth_usersupsert (the dual write);publish.rs;session_from_headers, and the loop that registered "closed" routes.command_routeralso sits behind the internal-secret layer, and the CI red-team 401 still holds.load: or_createfor todo create and force-archive) and feat: domain services + read model transactions + bus.send/listen #10 (Routes::for_stores;AuthDepsis no longer= ChatDeps).Behaviour change: the scrape no longer writes
auth_usersdirectly. The projection writes the rows after bus delivery, the same as the ingress path already did.Tests
tests/services/microsvc/transport_http_edge.rs:x-user-id/x-rolesheaders being ignored;auth_usersrow with statusdeactivated.Verification (local)
cargo check --workspace --all-targets --all-features: passes.cargo check -p distributed --tests --no-default-features: passes, and each of the 19 features alone passes.scripts/check-wasm32-domains.shpasses, and the 5 celld workers andexamples/game/cellspass.cargo test -p distributed --all-features: 2,190 passed, 0 failed.make test-local: 2,865 passed, 0 failed.cargo test --workspace: 98 passed.make ci-offline: the Rust suites pass, UI tests pass 16/16, no generated drift.cargo test --workspace: 31 passed.distributed build tests/e2e-celldshows no drift.Not done
command_router; only the CI red-team step checks it.CausalDispatchError::Internal, not a dedicated variant.