Sync Source Follows Publication

A package can move from one repository to another. The registry then lists it from the new repository straight away. But a partition that syncs the package through {package}/_GitSync keeps naming the repository it was first wired to, and nothing used to move it. Only a person running a Store/Provision could do it, because SystemInstall.WireSync rewrites repositoryUrl and subdirectory when it reconciles an existing package.

What it cost

Crm moved from its own repository (since archived) into the plugins repository, and the registry published it from there. On the company instance Crm/_GitSync still named the archived repository, and three things followed:

Every webhook the instance received also listed the archived repository under "matched NONE … Compared against: …".

The rule

The unattended update lane (PackageUpdateReconciler, policy Auto) checks a sync-owned package before it holds it (SyncSourceFollowsPublication). It re-points {partition}/_GitSync from the old repository R1 to the publication repository R2 only when all four of these hold:

  1. The registry serves the package with a hosted repository R2 (PackageManifest.RepositoryUrl).
  2. The partition's primary _GitSync imports content (it is not export-only) from a repository other than R2 at the package's folder.
  3. The registry's listing names R1 for no package. If the registry also lists R1 — a fork it serves, or the publication's own repository at another folder — somebody chose that source on purpose, and it is never touched.
  4. R1 is shown to be the package's former publication. Either the install record says the package was installed from R1, or GitHub reports R1 archived. A custom source with neither is unrelated to the move, and it is left alone. The log line says that a Store/Provision moves it.

A package on Notify or pinned is not re-pointed. An administrator who chose not to update automatically is not moved behind their back.

Three more cases are never re-pointed unattended:

Every read the check makes (the config, and GitHub's archived flag) is bounded at 15 s. An unanswered read decides nothing.

The write

The write is the same one a provision makes. It runs as System on the typed GitHubSyncConfig and sets repositoryUrl and subdirectory to the publication's values. Every other field is kept (branch, direction, two-way, ignore rules), with one exception: lastSyncCommitSha and lastAttemptedCommitSha name commits of R1 and mean nothing in R2, so they are cleared. The next sealed import of R2 is therefore a first import. Pruning still requires provenance, so content the repository never wrote, such as a CRM's own records, is never pruned.

The rule is decided again inside the write, against the config as it stands. If a person or a provision moved the config in the meantime, their change wins. Once the config names R2, rule 2 no longer holds, so a second pass writes nothing. The re-point is logged at Warning as [SyncFollowsPublication] … RE-POINTED …, naming both repositories and the evidence. A source that is left alone is logged at Information with the reason.

How it converges

  1. Update pass: _GitSync is re-pointed, and the record stays held for now.
  2. The next sealed import of the new repository (the sealed publication reconciler on a seal of R2, or the boot reconcile) lands the new version.
  3. The next update pass finds that the sync delivered the candidate's hash (PartitionContentOwnership.SyncDelivered). The install record adopts the new version and its module lands.

Pinned by SyncSourceFollowsPublicationRuleTest (every arm of the rule) and AMovedPackagesSyncSourceFollowsItsPublicationTest (real GitSync import plus real update lane: a package moved off an archived repository is re-pointed and then updates from 4.2.0 to 4.3.0, and a custom source is left exactly as it was).