Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

drive the push envelope's strip/pending/withhold lifecycle off one extension table (#6844)

[._.]/ Adam Eivy994749d3175b
diff --git a/server/services/sharing/peerSyncPush.js b/server/services/sharing/peerSyncPush.js
index af5828228f..57b242a742 100644
--- a/server/services/sharing/peerSyncPush.js
+++ b/server/services/sharing/peerSyncPush.js
@@ -44,6 +44,8 @@ import {
PUSH_TIMEOUT_MS,
ERR_SCHEMA_VERSION_AHEAD,
PEER_SUBSCRIBABLE_KINDS,
+ ENVELOPE_EXTENSIONS,
+ ENVELOPE_PENDING_KEYS,
} from './peerSyncShared.js';
import { isStr, isNonBlankStr } from '../../lib/textUtils.js';
@@ -123,25 +125,8 @@ export async function pushRecordToPeer(sub, options = {}) {
const payload = await buildPushPayload(sub, ourInstanceId);
if (!payload) return { pushed: false, reason: 'record-not-found' };
- // No-op short-circuit: don't re-push bytes we already pushed. Hash the
- // FULL logical payload (record + bundled issues + linked collection +
- // asset manifest) — not just the record — so an issue-only edit, an
- // asset-only re-render, a collection-only item add, or a new image
- // landing under the same series still propagates instead of collapsing
- // to "unchanged" because the parent series didn't move.
- // sourceInstanceId is intentionally excluded: it's an envelope field, not
- // a content field, and hashing it would force a re-push every time we
- // bumped instance metadata.
- const hash = simplePayloadHash({
- record: payload.record,
- issues: payload.issues ?? null,
- linkedCollection: payload.linkedCollection ?? null,
- linkedTrack: payload.linkedTrack ?? null,
- manuscriptReview: payload.manuscriptReview ?? null,
- reverseOutline: payload.reverseOutline ?? null,
- assetManifest: payload.assetManifest ?? [],
- draftBodyManifest: payload.draftBodyManifest ?? [],
- });
+ // No-op short-circuit: don't re-push bytes we already pushed.
+ const hash = pushPayloadHash(payload);
if (sub.lastPushedHash && sub.lastPushedHash === hash) {
return { pushed: false, reason: 'unchanged', hash };
}
@@ -178,87 +163,39 @@ export async function pushRecordToPeer(sub, options = {}) {
});
};
let res = await postPayload(payload);
- // Set when the older-peer retry below strips `manuscriptReview`: the retry
- // succeeds with the review removed, so saving the full-payload hash would
- // make the next push short-circuit as `unchanged` and never deliver the
- // review once that peer upgrades. Withhold the hash (like reviewSyncPending)
- // so the next cycle re-sends.
- let reviewStrippedForLegacyPeer = false;
- // Same as reviewStrippedForLegacyPeer, for the bundled reverse-outline doc —
- // a pre-#1348 peer's strict series schema rejects the `reverseOutline` key, so
- // the retry strips it and we withhold the hash to re-send once it upgrades.
- let outlineStrippedForLegacyPeer = false;
- // Same as the two flags above, for the #1858 bundled linked-track record — a
- // pre-feature peer's strict musicVideoProject push schema rejects the
- // `linkedTrack` key, so the retry strips it and we withhold the hash to
- // re-send once it upgrades (the track has no independent cycle for a
- // musicVideoProjects-only subscriber).
- let trackStrippedForLegacyPeer = false;
- // MIXED-VERSION COMPAT: an older receiver's push schema is still `.strict()`
- // without a `portosMeta` field, so it 400-rejects our envelope at Zod
- // validation BEFORE its schema-version gate code (which doesn't exist on
- // that version anyway) can run. Detect that specific rejection — Zod emits
- // "Unrecognized key(s) in object: 'portosMeta'" — and retry once without
- // the envelope so the push lands on the older peer. The older peer can't
- // see schemaVersions, but until the user upgrades it that's the
- // best-effort behavior we want (vs. permanently stranded pushes). Once
- // they upgrade, the next push round naturally re-includes `portosMeta`.
- // `catalogBundle` (catalog-federation push enrichment) is a second new
- // top-level key an even-newer-than-version-gate-but-pre-catalog peer's strict
- // schema also rejects. `manuscriptReview` (the bundled "Finish the draft"
- // review doc) is a third — a pre-feature peer's series push schema is still
- // `.strict()` without it, so it 400-rejects a review-bearing series push and
- // would strand the series + issues. This retry is exactly what makes the
- // review's "degrades gracefully on older peers" contract hold (see
- // schemaVersions.js): strip the unknown key the older peer can't parse so the
- // record/issues still land; the review reaches it once it upgrades. Strip
- // whichever key(s) the receiver actually named — surgically, so a peer that
- // supports `portosMeta` but not `catalogBundle`/`manuscriptReview` keeps its
- // version-gate handshake. Zod `.strict()` lists all unrecognized keys in one
- // issue, so a single retry covers all of them.
- // A 400 from the receiver is Zod rejecting our envelope BEFORE its schema-version
- // gate (the 409 path below) runs. Parse the body ONCE and route on which part it
- // couldn't accept — two distinct mixed-version cases share this block:
+ // ENVELOPE_EXTENSIONS rows the receiver's `.strict()` schema rejected and
+ // this push retried without. Empty when the first POST was accepted; the
+ // sidecar rows among them are what `resolvePushWatermarks` counts as still
+ // owed to this peer.
+ let stripped = [];
+ // A 400 from the receiver is Zod rejecting our envelope BEFORE its schema-
+ // version gate (the 409 path below) runs. Parse the body ONCE and route on
+ // which part it couldn't accept — two distinct mixed-version cases share it:
if (res && res.status === 400) {
- const errBody = await res.clone().json().catch(() => null);
- const isValidationError = errBody?.code === 'VALIDATION_ERROR';
- const details = Array.isArray(errBody?.context?.details) ? errBody.context.details : [];
- const mentions = (key) => details.some((d) => new RegExp(key).test(`${d?.path || ''} ${d?.message || ''}`));
- if (
- isValidationError
- && (payload.portosMeta || payload.catalogBundle || payload.manuscriptReview || payload.reverseOutline || payload.linkedTrack)
- && (mentions('portosMeta') || mentions('catalogBundle') || mentions('manuscriptReview') || mentions('reverseOutline') || mentions('linkedTrack'))
- ) {
+ const rejection = await classifyEnvelopeRejection(res, payload);
+ if (rejection.stripped.length > 0) {
// (1) UNKNOWN ENVELOPE KEY — the peer recognizes the record `kind` but its
// `.strict()` schema predates a newer top-level key we sent. Strip whichever
// key(s) it named and retry so the record/issues still land; the stripped
// feature reaches it once it upgrades (the re-push re-includes the key).
+ stripped = rejection.stripped;
const legacyPayload = { ...payload };
- const stripped = [];
- if (mentions('portosMeta') && 'portosMeta' in legacyPayload) { delete legacyPayload.portosMeta; stripped.push('portosMeta'); }
- if (mentions('catalogBundle') && 'catalogBundle' in legacyPayload) { delete legacyPayload.catalogBundle; stripped.push('catalogBundle'); }
- if (mentions('manuscriptReview') && 'manuscriptReview' in legacyPayload) { delete legacyPayload.manuscriptReview; stripped.push('manuscriptReview'); reviewStrippedForLegacyPeer = true; }
- if (mentions('reverseOutline') && 'reverseOutline' in legacyPayload) { delete legacyPayload.reverseOutline; stripped.push('reverseOutline'); outlineStrippedForLegacyPeer = true; }
- if (mentions('linkedTrack') && 'linkedTrack' in legacyPayload) { delete legacyPayload.linkedTrack; stripped.push('linkedTrack'); trackStrippedForLegacyPeer = true; }
+ for (const { key } of stripped) delete legacyPayload[key];
console.log(
- `ℹ️ peerSync: ${peer.name || peer.instanceId} rejected newer envelope key(s) ${stripped.join(', ')} — retrying push without them`,
+ `ℹ️ peerSync: ${peer.name || peer.instanceId} rejected newer envelope key(s) ${stripped.map((e) => e.key).join(', ')} — retrying push without them`,
);
res = await postPayload(legacyPayload);
- } else if (isValidationError && details.some((d) => d?.path === 'kind' && /discriminator|enum/i.test(d?.message || ''))) {
+ } else if (rejection.unknownKind) {
// (2) UNKNOWN RECORD KIND → schema-version block (NOT a bare http-400 retry).
- // When we introduce a NEW federated record kind (authors did this;
- // mediaCollection had the same gap when it landed), a peer on an older PortOS
- // whose `peerSyncPushSchema` discriminated union has no arm for that `kind`
- // rejects the push at the discriminator — so unlike case (1) there's no
- // smuggled key to drop: the record KIND itself is what the peer can't parse,
- // and retrying changes nothing. Treat it like the 409: persist an empty-gap
- // `peer-pre-feature` block so the SchemaGapBadge surfaces "peer needs to update
- // PortOS to sync <kind>" and the edit-push cooldown engages, instead of letting
- // the sub churn as a bare `http-400` the UI never explains. The block clears on
- // the next successful push once the peer upgrades (same recovery as the 409
- // path). The signal is a `kind`-path discriminator/enum error — a value WE
- // always send as a valid literal, so the only reason a receiver faults on
- // `kind` is that its schema doesn't know this record kind yet.
+ // The receiver's `peerSyncPushSchema` discriminated union has no arm for
+ // this `kind` (authors did this; mediaCollection had the same gap when it
+ // landed), so unlike case (1) there is no smuggled key to drop and
+ // retrying changes nothing. Treat it like the 409: persist an empty-gap
+ // `peer-pre-feature` block so the SchemaGapBadge surfaces "peer needs to
+ // update PortOS to sync <kind>" and the edit-push cooldown engages,
+ // instead of letting the sub churn as a bare `http-400` the UI never
+ // explains. The block clears on the next successful push once the peer
+ // upgrades (same recovery as the 409 path).
await persistSchemaVersionBlock(sub.id, { reason: 'peer-pre-feature' });
console.warn(
`⚠️ peerSync: ${peer.name || peer.instanceId} rejected push — its PortOS doesn't recognize the ` +
@@ -337,23 +274,11 @@ export async function pushRecordToPeer(sub, options = {}) {
// next `unchanged` short-circuit and the prose body stranded).
const missingCount = (Array.isArray(body?.missingAssets) ? body.missingAssets.length : 0)
+ (Array.isArray(body?.missingDraftBodies) ? body.missingDraftBodies.length : 0);
- // REVIEW-STRANDED GUARD: the receiver merged the record/issues (returned 2xx)
- // but its bundled manuscript-review merge threw. Withhold lastPushedHash like
- // the missing-assets case so the next push cycle re-sends the review instead
- // of short-circuiting on `unchanged` — the review has no independent
- // reconciliation path, so a saved hash here would strand the update.
- const reviewSyncPending = body?.reviewSyncPending === true || reviewStrippedForLegacyPeer;
- // OUTLINE-STRANDED GUARD: same as the review above — the receiver merged the
- // record/issues but its bundled reverse-outline merge threw (or we stripped
- // the key for a pre-#1348 peer). The outline has no independent reconciliation
- // path, so withhold lastPushedHash to re-send next cycle.
- const outlineSyncPending = body?.outlineSyncPending === true || outlineStrippedForLegacyPeer;
- // TRACK-STRANDED GUARD: same as the review/outline guards — the receiver merged
- // the project (returned 2xx) but its bundled linked-track merge threw, OR we
- // stripped the key for a pre-#1858 peer. The track has no independent
- // reconciliation path for a musicVideoProjects-only subscriber, so withhold
- // lastPushedHash to re-send next cycle.
- const trackSyncPending = body?.trackSyncPending === true || trackStrippedForLegacyPeer;
+ // SIDECAR-STRANDED GUARD: `resolvePushWatermarks` folds the receiver's
+ // ENVELOPE_EXTENSIONS pending flags and this push's own legacy strips into
+ // the same decision — a bundled doc the receiver doesn't hold yet withholds
+ // lastPushedHash exactly like the missing-assets case above.
+ const { pushedHash, legacyStrippedHash, trackSyncPending } = resolvePushWatermarks({ hash, missingCount, stripped, body });
// This push landed (receiver returned 2xx). Stamp the per-record confirmed-
// delivery water-mark so tombstoneGc won't prune THIS record's tombstone
// until its delete-push has been confirmed — even if a later push for a
@@ -387,21 +312,7 @@ export async function pushRecordToPeer(sub, options = {}) {
const trackBundleConfirmed = sub.recordKind === 'musicVideoProject'
&& !trackSyncPending
&& (!trackOwed || Boolean(payload.linkedTrack));
- // #3928: separate the two reasons a bundled doc is still pending. A
- // RECEIVER-reported pending (its bundled merge threw) is transient — the
- // next cycle must genuinely re-push, so it gets no water-mark. A
- // SENDER-side strip for a legacy peer is stable — the peer will reject the
- // key again until it upgrades, so record the full-payload hash in
- // `lastPushedLegacyHash` and let an unchanged record short-circuit above
- // instead of looping a 400 + retry pair every cycle. Missing assets/bodies
- // also stay un-water-marked: the receiver is still pulling and needs a
- // fresh manifest each cycle.
- const receiverReportedPending = body?.reviewSyncPending === true
- || body?.outlineSyncPending === true
- || body?.trackSyncPending === true;
- const strippedForLegacyPeer = reviewStrippedForLegacyPeer || outlineStrippedForLegacyPeer || trackStrippedForLegacyPeer;
- const legacyStrippedHash = (strippedForLegacyPeer && missingCount === 0 && !receiverReportedPending) ? hash : null;
- await persistPushSuccess(sub.id, (missingCount > 0 || reviewSyncPending || outlineSyncPending || trackSyncPending) ? null : hash, {
+ await persistPushSuccess(sub.id, pushedHash, {
confirmedAtMs: Date.now(),
trackBundleConfirmed,
legacyStrippedHash,
@@ -455,6 +366,84 @@ export async function pushRecordToPeer(sub, options = {}) {
};
}
+/**
+ * Classify a receiver's 400 against the envelope we sent. A 400 is Zod
+ * rejecting the envelope BEFORE the receiver's schema-version gate can run
+ * (that gate answers 409), and two mixed-version cases share it:
+ *
+ * `stripped` — the ENVELOPE_EXTENSIONS rows the receiver named as
+ * unrecognized keys AND this payload carries. Its `.strict()`
+ * schema predates them (a pre-version-gate peer has no
+ * `portosMeta` field, a pre-catalog peer no `catalogBundle`,
+ * a pre-feature peer none of the sidecar docs), so the
+ * caller retries once without exactly those keys. Zod lists
+ * every unrecognized key in one issue, so a single retry
+ * covers them all — and stripping only the keys it NAMED
+ * keeps a peer that supports `portosMeta` but not
+ * `catalogBundle` on its version-gate handshake. Until the
+ * user upgrades that peer this best-effort landing beats a
+ * permanently stranded push; the next push round after the
+ * upgrade naturally re-includes the key.
+ * `unknownKind` — the receiver faulted on the `kind` discriminator itself:
+ * its push schema has no arm for this record kind, so there
+ * is no key to drop and a retry changes nothing; the caller
+ * persists a `peer-pre-feature` block instead. `kind` is a
+ * value WE always send as a valid literal, so the only reason
+ * a receiver faults on it is that its schema doesn't know
+ * this kind yet.
+ *
+ * Anything else — not a VALIDATION_ERROR, or one naming fields we can't
+ * strip — is a plain http-400 for the caller to report.
+ */
+async function classifyEnvelopeRejection(res, payload) {
+ const errBody = await res.clone().json().catch(() => null);
+ if (errBody?.code !== 'VALIDATION_ERROR') return { stripped: [], unknownKind: false };
+ const details = Array.isArray(errBody.context?.details) ? errBody.context.details : [];
+ const mentions = (key) => details.some((d) => new RegExp(key).test(`${d?.path || ''} ${d?.message || ''}`));
+ const stripped = ENVELOPE_EXTENSIONS.filter((e) => e.key in payload && mentions(e.key));
+ const unknownKind = stripped.length === 0
+ && details.some((d) => d?.path === 'kind' && /discriminator|enum/i.test(d?.message || ''));
+ return { stripped, unknownKind };
+}
+
+/**
+ * The hash-withholding contract for a push that landed (receiver returned
+ * 2xx), stated once for every ENVELOPE_EXTENSIONS row (#6844).
+ *
+ * `pushedHash` becomes `lastPushedHash`, the `unchanged` short-circuit's
+ * water-mark, so it is saved ONLY when the receiver now holds everything this
+ * push carried: no asset or draft body still to pull (`missingCount`), no
+ * sidecar doc the receiver reported as failed (`body[pendingKey]`), and no
+ * sidecar doc this push stripped for a legacy peer. Saving it in any of those
+ * states would make the next cycle short-circuit and strand the piece that
+ * never arrived — the sidecar docs have no independent reconciliation path.
+ *
+ * #3928 separates the two reasons a sidecar is pending. A RECEIVER-reported
+ * failure is transient — the next cycle must genuinely re-push, so it gets no
+ * water-mark at all. A SENDER-side strip is stable — the peer rejects the key
+ * again until it upgrades — so `legacyStrippedHash` records the full-payload
+ * hash delivered in stripped form and an unchanged record short-circuits as
+ * `unchanged-legacy-stripped` instead of looping a 400 + retry pair every
+ * cycle. Missing assets/bodies stay un-water-marked either way: the receiver
+ * is still pulling and needs a fresh manifest each cycle.
+ *
+ * A stripped row with `pendingKey: null` (`portosMeta`, `catalogBundle`) is
+ * reconciled by its own cycle, so it never counts as pending here.
+ */
+function resolvePushWatermarks({ hash, missingCount, stripped, body }) {
+ const strippedPending = new Set(stripped.map((e) => e.pendingKey).filter(Boolean));
+ const receiverReportedPending = ENVELOPE_EXTENSIONS.some((e) => e.pendingKey && body?.[e.pendingKey] === true);
+ const anyPending = strippedPending.size > 0 || receiverReportedPending;
+ const trackPendingKey = ENVELOPE_PENDING_KEYS.linkedTrack;
+ return {
+ pushedHash: (missingCount > 0 || anyPending) ? null : hash,
+ legacyStrippedHash: (strippedPending.size > 0 && missingCount === 0 && !receiverReportedPending) ? hash : null,
+ // #1922's bundled-track GC floor still needs the linked track's OWN state
+ // (see `trackBundleConfirmed` at the call site).
+ trackSyncPending: strippedPending.has(trackPendingKey) || body?.[trackPendingKey] === true,
+ };
+}
+
async function persistPushSuccess(subId, hash, { confirmedAtMs = Date.now(), trackBundleConfirmed = false, legacyStrippedHash = null } = {}) {
await withStateLock(async () => {
const state = await readState();
@@ -775,6 +764,28 @@ async function buildCatalogBundleForRef(refKind, refId) {
return { ingredients, refs };
}
+/**
+ * Hash the FULL logical payload — record + bundled issues + linked collection
+ * + sidecar docs + asset/body manifests — not just the record, so an
+ * issue-only edit, an asset-only re-render, a collection-only item add, or a
+ * new image landing under the same series still propagates instead of
+ * collapsing to `unchanged` because the parent record didn't move.
+ * `sourceInstanceId` and `portosMeta` are envelope fields, not content, and
+ * hashing them would force a re-push every time we bumped instance metadata.
+ */
+function pushPayloadHash(payload) {
+ return simplePayloadHash({
+ record: payload.record,
+ issues: payload.issues ?? null,
+ linkedCollection: payload.linkedCollection ?? null,
+ linkedTrack: payload.linkedTrack ?? null,
+ manuscriptReview: payload.manuscriptReview ?? null,
+ reverseOutline: payload.reverseOutline ?? null,
+ assetManifest: payload.assetManifest ?? [],
+ draftBodyManifest: payload.draftBodyManifest ?? [],
+ });
+}
+
// Tiny stable-string hash for the push short-circuit. NOT a cryptographic
// hash — we just need "is this the same record we last pushed". Collisions
// at this size mean we MIGHT skip a real edit, but the snapshot sync would
diff --git a/server/services/sharing/peerSyncReceive.js b/server/services/sharing/peerSyncReceive.js
index 85e45b09e2..9c7c7f55cb 100644
--- a/server/services/sharing/peerSyncReceive.js
+++ b/server/services/sharing/peerSyncReceive.js
@@ -38,6 +38,7 @@ import {
ERR_VALIDATION,
ERR_SCHEMA_VERSION_AHEAD,
PEER_SUBSCRIBABLE_KINDS,
+ ENVELOPE_PENDING_KEYS,
} from './peerSyncShared.js';
import { isStr, isNonBlankStr } from '../../lib/textUtils.js';
@@ -246,17 +247,18 @@ export async function applyIncomingPush(payload) {
// the merge fns fall back to `{ via:'sync', peerId:null }` and the
// attribution is lost).
const source = { via: 'peer-push', peerId: sourceInstanceId };
- // Set true when a bundled manuscript-review merge throws — returned to the
- // sender so it withholds lastPushedHash and retries (the review has no other
- // reconciliation path; see the merge block below).
- let reviewSyncPending = false;
- // Same contract as reviewSyncPending, for the bundled reverse-outline doc.
- let outlineSyncPending = false;
- // Same contract again, for the #1858 bundled linked-track record: a
- // musicVideoProjects-only subscriber has NO independent `tracks` sync cycle,
- // so a swallowed merge failure would strand the record the receiver needs to
- // render. Signal so the sender withholds lastPushedHash and re-sends.
- let trackSyncPending = false;
+ // ENVELOPE_EXTENSIONS pending flags to echo to the sender: each is a bundled
+ // sidecar doc whose merge threw AFTER the record itself merged. None of the
+ // sidecars — the review, the outline, or the #1858 linked track a
+ // musicVideoProjects-only subscriber has no `tracks` cycle for — has an
+ // independent reconciliation path, so the sender withholds lastPushedHash
+ // on the flag and re-sends next cycle; a swallowed failure behind a saved
+ // hash would strand the doc. The record push itself never fails on these.
+ const pending = new Set();
+ const markPending = (key) => (err) => {
+ console.log(`⚠️ peerSync: ${key} merge failed: ${err.message}`);
+ pending.add(ENVELOPE_PENDING_KEYS[key]);
+ };
// #1922: true only once the bundled linkedTrack merge actually RAN and
// succeeded — gates whether `linkedTrack` may contribute to
// `ackedDeletesUpTo` below. Stays false on every skip path (mismatched id,
@@ -300,10 +302,7 @@ export async function applyIncomingPush(payload) {
// Dynamic import keeps the arcPlanner graph off peerSync's load path.
if (!localEphemeral && record.deleted !== true && isPlainObject(manuscriptReview)) {
const { mergeReviewFromSync } = await import('../pipeline/manuscriptReview.js');
- await mergeReviewFromSync(record.id, manuscriptReview).catch((err) => {
- console.log(`⚠️ peerSync: manuscriptReview merge failed: ${err.message}`);
- reviewSyncPending = true;
- });
+ await mergeReviewFromSync(record.id, manuscriptReview).catch(markPending('manuscriptReview'));
}
// Merge the bundled reverse-outline sibling doc, whole-doc LWW on
// generatedAt. Same ephemeral/tombstone guards + pending-signal contract as
@@ -312,10 +311,7 @@ export async function applyIncomingPush(payload) {
// cycle. Dynamic import keeps the arcPlanner graph off peerSync's load path.
if (!localEphemeral && record.deleted !== true && isPlainObject(reverseOutline)) {
const { mergeOutlineFromSync } = await import('../pipeline/reverseOutline.js');
- await mergeOutlineFromSync(record.id, reverseOutline).catch((err) => {
- console.log(`⚠️ peerSync: reverseOutline merge failed: ${err.message}`);
- outlineSyncPending = true;
- });
+ await mergeOutlineFromSync(record.id, reverseOutline).catch(markPending('reverseOutline'));
}
} else if (kind === 'writersRoomWork') {
// Did the receiver accept the remote work (insert / remote-won LWW)? This
@@ -338,10 +334,7 @@ export async function applyIncomingPush(payload) {
&& linkedTrack.id === record.trackId) {
await RECORD_KINDS.track.merge([linkedTrack], { source }).then(() => {
linkedTrackApplied = true;
- }).catch((err) => {
- console.log(`⚠️ peerSync: linkedTrack merge failed: ${err.message}`);
- trackSyncPending = true;
- });
+ }).catch(markPending('linkedTrack'));
}
}
@@ -484,9 +477,9 @@ export async function applyIncomingPush(payload) {
...(missingDraftBodies.length > 0 ? { missingDraftBodies } : {}),
reverseSubscriptionCreated,
ackedDeletesUpTo,
- ...(reviewSyncPending ? { reviewSyncPending: true } : {}),
- ...(outlineSyncPending ? { outlineSyncPending: true } : {}),
- ...(trackSyncPending ? { trackSyncPending: true } : {}),
+ // One `<pendingKey>: true` per sidecar doc whose merge threw, keyed off the
+ // same ENVELOPE_EXTENSIONS table the sender reads them back from.
+ ...Object.fromEntries([...pending].map((k) => [k, true])),
};
}
diff --git a/server/services/sharing/peerSyncShared.js b/server/services/sharing/peerSyncShared.js
index 94669eb7fd..37aac83311 100644
--- a/server/services/sharing/peerSyncShared.js
+++ b/server/services/sharing/peerSyncShared.js
@@ -51,10 +51,18 @@ export const PEER_SUBSCRIBABLE_KINDS = Object.freeze(['universe', 'series', 'med
* fails until every row has a carrier on both sides.
*/
export const ENVELOPE_EXTENSIONS = Object.freeze([
+ // The schema-version handshake (`buildPortosMeta`); a pre-version-gate
+ // receiver's strict schema has no field for it.
Object.freeze({ key: 'portosMeta', pendingKey: null }),
+ // Catalog-federation enrichment riding a universe push; a peer newer than
+ // the version gate but older than catalog federation rejects it.
Object.freeze({ key: 'catalogBundle', pendingKey: null }),
+ // The "Finish the draft" manuscript-review doc riding a series push.
Object.freeze({ key: 'manuscriptReview', pendingKey: 'reviewSyncPending' }),
+ // The scene-by-scene reverse outline riding a series push (#1348).
Object.freeze({ key: 'reverseOutline', pendingKey: 'outlineSyncPending' }),
+ // The linked track record riding a musicVideoProject push (#1858) — a
+ // musicVideoProjects-only subscriber has no `tracks` cycle to fall back on.
Object.freeze({ key: 'linkedTrack', pendingKey: 'trackSyncPending' }),
]);