Synchronized contexts
A receiving Vox application can read and calculate on drafts, releases and experiments owned by another application.
For the team workflow, see Keeping systems in step.
A content model can be split across Vox applications: a PIM authors categories, a CMS authors category pages and manages the content releases, and a delivery application publishes both to a website. Each entity type is authored in one application only, and the others receive it as an external entity, see Share entities between Vox applications. Context synchronization lets the receivers read, calculate on and project the source's drafts and content releases, and its values at application contexts, eg experiments, too, without authoring them. Every application can then preview the others' work, and the delivery application can publish the combined preview, with relations resolved across sources.
| Application | Authors | Receives |
|---|---|---|
| PIM | Category, its own releases | CategoryContentPage |
| CMS | CategoryContentPage, its own releases | Category |
| Delivery | Nothing | Both entity types and the CMS's releases |
One authority for releases
The content releases and each context type have one authority: they're either owned by the application or
synchronized from exactly one source, VoxAuthoringModel.ReleaseAuthority for the releases. An application that
authors content has releases of its own; applications that work on one campaign each create a release with the same
id, see Releases with the same id. An application that authors nothing, eg a delivery
application, can bind the releases of exactly one source with Releases<TRelease>(), and then has none of its own.
There's no mapping of ids. The draft is one scope, so scope=draft reads the drafts of every source and the local
ones.
Authoring stays local. An external entity's cells at a draft, release or experiment are its source's data: they're never edited, merged, restored or scheduled where they're received, and a receiver never merges a member, also when its source deletes it. A received release is read-only: an application that receives the CMS's releases can preview them, but can't save its own entities in them. To work on the same campaign, an application creates a release of its own with the same id, see Releases with the same id.
Configuring a receiver
Context synchronization is configured per source, on its own and without UseAuthoring:
builder.AddVox(options => options
.UseContextSynchronization(sync => sync
.Consume("pim", pim => pim
.Drafts()
.Entities<Category>())
.Consume("cms", cms => cms
.Drafts()
.Releases<CmsRelease>()
.Entities<Variant>()
.Entities<CategoryContentPage>())));
Drafts()receives the drafts of the source, and gives the model the draft scope if authoring doesn't.Releases<TRelease>()binds an external entity type as the content releases, and gives the model the release scopes. The type implementsIVoxContentRelease, the release descriptor that the ownedVoxContentReleaseimplements too, so Vox reads the status and openness of a release the same way whichever application manages it. A type generated from the source's contract ofVoxContentReleaseimplements it. The application then has no releases of its own: callauthoring.WithoutContentReleases()if it authors other content.Entities<TEntity>()receives an external entity type, with its cells in the source's drafts and releases: itsHasAuthoringDatabecomes true, so they're stored, read and calculated on like local ones, whileIsAuthoredstays false. An external context type, eg the variants of the source's experiments, is received like any other entity type, with its traits configured like the source's, egoptions.ConfigureContextType<Variant>(type => type.Concurrent(variant => variant.Experiment)). Its cells are received with the entities' cells at the keys of the context types the source's subscription chooses.
Startup rejects an external release type together with releases of the application's own, two sources of releases
or of one context type, and a supplied type that isn't external or isn't synchronized from the source. The external entity types with cells, and the context entity types, are stored by a
provider with the ContextCells capability, eg Entity Framework.
A consuming application needs normal calculation and projection processing, but no publisher, merger, restore processor or release scheduler, and it has none.
What the source sends
The source opts a raw snapshot subscription in to contextual content by choosing application context types in
SidecarContextTypes, eg ["Language", "Variant"], and to the authoring scopes with includeDrafts and
includeReleases. Including drafts or releases needs the permission to preview them. Its snapshots,
vox-entity-snapshot/v9, then carry:
cells: the published cells at the keys of the chosen context types, eg{Language=sv}and{Variant=hero-b}, with the existence of the entity there, and a cell at{}that says whether it's published, so an entity that only exists in drafts or releases is sent rather than deleted;contextTypes: the context typescellsis complete for, so the receiver removes what's no longer there, eg after an experiment is promoted;authoring: an authoring envelope with a layer per scope that changes the entity, egdraft,release:autumnandrelease-draft:autumn, each with the whole entity at the baseline, the cells of the chosen context types that the scope changes, the keys it removes, its existence, and the incarnation of its release;authoringScopes: the kinds of scopesauthoringis complete for, so the receiver removes a layer that's no longer there, eg after a draft is reverted or published, or a release is published or deleted;relations: besides the published links of the index-backed relations ofrelationCoverage, the links that the cells of the chosen context types and the scopes add and hide, at their addresses, egpublished|Language=svordraft, which replace the receiver's links there, see Share entities between Vox apps;- the revision of the entity, see below, and the incarnations of the experiment members its keys have.
The source records a change event for every edit of a draft, a release or an experiment, which only the subscriptions that opted in to its scope and the context types of its key get. Other subscriptions and the search index get published changes only. A resynchronization sends the entities that only exist in drafts or releases, and the deletions of the releases and context members that were deleted, so a receiver that missed a deletion retires the member.
Source conflict state, audit, publication records and schedules are never sent.
Ordering and atomic import
A snapshot carries a revision that changes with everything it exports, also with a draft edit that leaves the published version and time unchanged. It's increased in the transaction of every change of an entity with cells and read consistently with the snapshot, so a newer revision never labels older content. The receiver keeps the revision of each stream of each source, a stream being a subscription, and ignores a snapshot it already has or is past, also after the entity was deleted, so duplicates, reordered and late deliveries change nothing.
Every snapshot is imported in one transaction: the external entity, its cells, its existence cells and its stream's revision, and the changes that make what depends on them recalculate at the keys they changed. A failure leaves the previous revision intact, and the delivery is retried. The import replaces only the source's synchronized fields within the scope of the snapshot, so local enrichments, local calculated results and the cells delivered by another stream are kept. Two streams can't deliver the same context type of an entity.
A cell of a member that hasn't arrived yet is kept, and resolves once it arrives: the arrival of a release or an
experiment variant, or a change of it, eg of its status, recalculates what's derived from the entities with cells at its
keys. What happens to a cell of a context type the receiver doesn't have is a setting of the subscription,
UnknownContextTypes, carried on its snapshots:
Dropleaves the cell out, as before.Holddoesn't import the snapshot: its delivery fails and is retried until the receiver has the context type, so nothing is lost while it catches up with a new context type of the source.
Retired members
A release or member deleted at its source, eg a published or deleted release or a promoted experiment variant, arrives
as the deletion of the external entity, which deletes every cell in the release's scopes or keyed by the member. A promoted variant's values arrive as
published snapshots of the entities it changed. Every deleted release and context member is kept as a retired member, with
its incarnation, so a late snapshot, a queued calculation or a resynchronization can't bring its cells back. A member that's
created again with the same id, eg an experiment variant named hero-b again, is a new incarnation, and the cells of
the earlier one are dropped.
Validating the source's traits
A receiver resolves the source's contexts with its own traits, which must be the source's: restriction,
selection kind, portability, concurrency, the stacking order of the shared context types, and the fallbacks, groups
and criteria of the members. Drafts and releases aren't in the manifest: their scopes and ancestry are fixed, and the
source's authoring descriptor tells which it has. Send the source's
manifest, GET api/contexts/manifest?includeRestricted=true there, to the receiver, signed like snapshots:
POST /vox/api/entity-sync/cms/manifest
X-Vox-Signature: sha256=...
It returns the differences as a validation problem, or 204 when the traits agree. A snapshot built with another manifest
revision than the one validated last is logged as a warning. The source's authoring descriptor,
GET api/contexts/authoring/descriptor there, is validated the same way with POST /vox/api/entity-sync/cms/authoring:
drafts or releases the receiver takes from the source must be there, and releases it binds must be the source's own.
IVoxContextSourceManifestValidator validates both in .NET.
Reading, calculating and projecting
The external entities' drafts, releases and contextual cells resolve like local ones: scope=draft reads the drafts
of every source and the local ones, scope=release:autumn the CMS's release, and the application contexts are
resolved within the scope, eg scope=draft&context=language:sv. Relations across sources resolve in the same scope,
so the delivery application's calculation of a page's heading from its category reads the PIM's draft of the category
and the CMS's draft of the page in the draft. Local calculated fields vary by scope and key when they depend on
contextual content; they stay derived values, and are calculated again when an import changes what they read.
A durable projection publication enumerates the scopes of external entity types only by explicit opt-in, as it does for
local ones, eg [VoxEntityProjectionPublication(IncludeDrafts = true, IncludeReleases = true)], so a delivery model
with only external types publishes a combined preview.
Query and search keep filtering by published values. There's no contextual search index for preview.
Preview permissions
Reading the drafts works with vox:Preview:Drafts, and the releases with vox:Preview:Releases, which need no
permission to edit, publish or manage them; a draft within a release needs both. A restricted application context type
works with its preview permission, vox:Preview:{ContextType}. Grant them to the API clients and users of a delivery
application that only previews. They apply to scope= and context=, API client defaults, the restricted manifest,
which only has the restricted context types the caller may select, subscription configuration, exports, relation
traversal and projection endpoints. Responses in an authoring scope or a restricted context stay private and out of
shared caches.
The admin offers the received drafts and releases, with the release preview banner, and the received experiments, and shows external entities read-only in them. The Releases page lists synchronized releases read-only, with their status.
Eventual consistency
Each application imports atomically, but there's no transaction across databases. While a change travels from its source to a delivery application, eg a CMS page whose draft refers to a PIM category's new draft, the delivery application can show one source's new version next to the other's old one. That interval lasts until both snapshots have arrived and the calculations and projections that depend on them have run; it's usually seconds, and longer while a source or a transport is unavailable. A preview converges once everything has arrived.
Releases with the same id
Applications that work on one campaign each create a content release with the same id, eg the PIM and the CMS each
create autumn, and each publishes, schedules, reverts and deletes its own. A receiver keeps a source's changes at
release:autumn when it has a release autumn itself, so the CMS previews the PIM's categories in its autumn and the
PIM previews the CMS's pages in its own. The source's subscription includes releases (includeReleases), which needs the
permission to preview them. A change at a release id the receiver doesn't have is dropped, and arrives again with the
entity's next snapshot or a resynchronization once the release exists. To go live together, the teams give both
releases the same schedule; Vox doesn't coordinate the publications. See
Content releases.
Delivery has no releases of its own, so it receives one application's releases, eg the CMS's, and keeps every source's
changes at the ids it has: its autumn shows the CMS's page and the PIM's category together, and its projections can
publish that combined preview. It follows the lifecycle of the application it takes releases from:
- A release only the PIM has, eg
pim-assortment-cleanup, isn't previewable in delivery. - When the CMS publishes
autumnbefore the PIM, delivery'sautumnis closed, so the PIM's changes still in it aren't calculated there any more. They're removed when the PIM publishes, and its published categories arrive as usual. - When the CMS deletes
autumn, delivery deletes everything in it, the PIM's changes included, and a late snapshot doesn't bring them back.
An experiment of the source needs no releases: an application has values of its own entities at the variants it receives, and promotes them itself, see Contexts.