@githolon/runtime 0.110.0 → 0.111.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/RUNTIME-SOURCES.sha256 +5 -5
- package/dist/nomos-native-runtime.js +146 -123
- package/dist/nomos-runner.js +159 -142
- package/package.json +1 -1
- package/runner/node-entry.mjs +146 -123
package/dist/nomos-runner.js
CHANGED
|
@@ -19623,6 +19623,15 @@
|
|
|
19623
19623
|
}
|
|
19624
19624
|
if (result.stillAhead || result.pushFailed || result.directOfferDeferred || result.reconnectRequired) {
|
|
19625
19625
|
if (result.directOfferDeferred) {
|
|
19626
|
+
if (!result.reconnectRequired) {
|
|
19627
|
+
__privateGet(this, _desk).transition(result.workspace, {
|
|
19628
|
+
case: ReplicaFollowEventKind.Failed,
|
|
19629
|
+
nowUnixMillis,
|
|
19630
|
+
failure: "remote workspace opening; retrying",
|
|
19631
|
+
retryWithinMillis: 5e3
|
|
19632
|
+
});
|
|
19633
|
+
return delayUntilDue(__privateGet(this, _desk).get(result.workspace), nowUnixMillis);
|
|
19634
|
+
}
|
|
19626
19635
|
__privateGet(this, _desk).transition(result.workspace, {
|
|
19627
19636
|
case: ReplicaFollowEventKind.DependencyDeferred,
|
|
19628
19637
|
nowUnixMillis,
|
|
@@ -21619,6 +21628,34 @@
|
|
|
21619
21628
|
init_shims();
|
|
21620
21629
|
var CUSTODY_OFFER_MEDIA_TYPE = "application/vnd.nomos.custody-offer-batch+protobuf";
|
|
21621
21630
|
var CUSTODY_OFFER_RESULT_MEDIA_TYPE = "application/vnd.nomos.custody-offer-result+protobuf";
|
|
21631
|
+
function settleCustodyOfferExchange(awaiting, response) {
|
|
21632
|
+
if (response.status === 202 && response.contentType?.includes("application/json")) {
|
|
21633
|
+
try {
|
|
21634
|
+
const pending = JSON.parse(new TextDecoder().decode(response.body));
|
|
21635
|
+
if (pending?.retryable === true && typeof pending.preparing === "string") {
|
|
21636
|
+
return { case: "maintenance", kind: pending.preparing };
|
|
21637
|
+
}
|
|
21638
|
+
} catch {
|
|
21639
|
+
}
|
|
21640
|
+
}
|
|
21641
|
+
if (!response.contentType?.includes(CUSTODY_OFFER_RESULT_MEDIA_TYPE)) {
|
|
21642
|
+
return {
|
|
21643
|
+
case: "unexpected",
|
|
21644
|
+
status: response.status,
|
|
21645
|
+
...response.contentType === void 0 ? {} : { contentType: response.contentType }
|
|
21646
|
+
};
|
|
21647
|
+
}
|
|
21648
|
+
const verdict = decodeCustodyOffer(response.body, awaiting.requestId);
|
|
21649
|
+
const receipt = custodyOfferReceipt(awaiting.requestId, verdict);
|
|
21650
|
+
switch (verdict.case) {
|
|
21651
|
+
case "admission":
|
|
21652
|
+
return { case: "admission", value: verdict.value, receipt, status: response.status };
|
|
21653
|
+
case "failure":
|
|
21654
|
+
return { case: "failure", value: verdict.value, receipt, status: response.status };
|
|
21655
|
+
case "blocked":
|
|
21656
|
+
return { case: "blocked", value: verdict.value, receipt, status: response.status };
|
|
21657
|
+
}
|
|
21658
|
+
}
|
|
21622
21659
|
function encodeInlineCustodyOffer(args) {
|
|
21623
21660
|
return toBinary(CustodyOfferBatchRequestSchema, create(CustodyOfferBatchRequestSchema, {
|
|
21624
21661
|
protocolVersion: 2,
|
|
@@ -21745,6 +21782,7 @@
|
|
|
21745
21782
|
var PLACEMENT_REF3 = "refs/nomos/placement";
|
|
21746
21783
|
var LAW_PRODUCTS_MEDIA_TYPE = "application/vnd.nomos.export-law-products-response+protobuf";
|
|
21747
21784
|
var WorkspaceSyncPhase = Object.freeze({
|
|
21785
|
+
Idle: "idle",
|
|
21748
21786
|
Probe: "probe",
|
|
21749
21787
|
Offer: "offer",
|
|
21750
21788
|
Lease: "lease",
|
|
@@ -21754,7 +21792,6 @@
|
|
|
21754
21792
|
Done: "done"
|
|
21755
21793
|
});
|
|
21756
21794
|
var trackedMain = "refs/remotes/nomos/main";
|
|
21757
|
-
var NO_COMMON_BASE = "this replica holds local history with no frontier its upstream ever confirmed; convergence needs a common admitted base \u2014 drop the local copy to refetch it, or re-discover a provider holding this lineage";
|
|
21758
21795
|
var deferredRemote = "refs/remotes/nomos/deferred";
|
|
21759
21796
|
var deferredLocal = "refs/nomos/sync-deferred-local";
|
|
21760
21797
|
var judgedThisLifetime = /* @__PURE__ */ new Map();
|
|
@@ -21766,7 +21803,7 @@
|
|
|
21766
21803
|
const finished = clock.monotonicNanoseconds();
|
|
21767
21804
|
return finished >= started ? Number(finished - started) / 1e6 : 0;
|
|
21768
21805
|
};
|
|
21769
|
-
var _kernel16, _credentials4, _clock13, _mount, _binding, _route2, _rediscover, _reroute,
|
|
21806
|
+
var _kernel16, _credentials4, _clock13, _mount, _binding, _route2, _rediscover, _reroute, _discoveredFrontier, _observePlacement, _recheckPlacement, _directoryAnswered, _placementFetched, _leased, _command2, _requestId4, _started, _state, _localHead, _offerHead, _previousHead, _pushMillis, _pushBytes, _desiredHead, _returnedPackHead, _candidateDurable, _admissionSummary, _offerReceipt, _pushError, _current3, _lastReceiptEffectId2, _lastStep2, _probeOnly, _establishedBase, _receiveState, _completeHistory, _lawProductsImported, _shallowMounted, _fetchedLawProducts, _beforeConverge, _needsReconciliation, _offerAfterConverge, _rebaseFrom, _rebases, _parkedLocal, _replaceLocalHead, _repairMissingCommit, _WorkspaceSyncWork_instances, openRound_fn, offerOrReconcile_fn, establishBase_fn, missingTrackedBase_fn, holdsLocalWork_fn, pullBeforeOffer_fn, leaseEffect_fn, beginOffer_fn, acceptOffer_fn, acceptLease_fn, placementFrontier_fn, placementOnly_fn, acceptDiscovery_fn, providerCustody_fn, beginMainFetch_fn, acceptFetch_fn, mountFetched_fn, lawProductsAlongside_fn, acceptLawProducts_fn, providerCustodyMounted_fn, importLawProducts_fn, converge_fn2, unrelatedLineageRefusal_fn, replaceLocal_fn, converged_fn, offerAfterRebase_fn, preservedCopy_fn, alreadyJudged_fn, rememberJudgment_fn, forgetJudgment_fn, present_fn, finishOfferOutcome_fn, transportFailure_fn, remember_fn4, finish_fn2, cloudBase_fn, offerEndpoint_fn, workspaceEndpoint_fn, authToken_fn;
|
|
21770
21807
|
var WorkspaceSyncWork = class {
|
|
21771
21808
|
constructor(args) {
|
|
21772
21809
|
__privateAdd(this, _WorkspaceSyncWork_instances);
|
|
@@ -21781,7 +21818,6 @@
|
|
|
21781
21818
|
__privateAdd(this, _rediscover);
|
|
21782
21819
|
/** The route the directory's answer yields, recomputed once that answer is observed. */
|
|
21783
21820
|
__privateAdd(this, _reroute);
|
|
21784
|
-
__privateAdd(this, _placementFetch);
|
|
21785
21821
|
__privateAdd(this, _discoveredFrontier);
|
|
21786
21822
|
__privateAdd(this, _observePlacement);
|
|
21787
21823
|
/** Ask the directory for the provider's current placement frontier this round although a
|
|
@@ -21790,19 +21826,14 @@
|
|
|
21790
21826
|
__privateAdd(this, _directoryAnswered);
|
|
21791
21827
|
__privateAdd(this, _placementFetched);
|
|
21792
21828
|
/** A round which converged without leasing, finishing once placement alone is fetched. */
|
|
21793
|
-
__privateAdd(this, _afterPlacement);
|
|
21794
21829
|
__privateAdd(this, _leased, false);
|
|
21795
|
-
__privateAdd(this, _lease);
|
|
21796
21830
|
__privateAdd(this, _command2);
|
|
21797
21831
|
__privateAdd(this, _requestId4);
|
|
21798
21832
|
__privateAdd(this, _started);
|
|
21799
|
-
__privateAdd(this,
|
|
21833
|
+
__privateAdd(this, _state, { phase: WorkspaceSyncPhase.Idle });
|
|
21800
21834
|
__privateAdd(this, _localHead);
|
|
21801
21835
|
__privateAdd(this, _offerHead);
|
|
21802
21836
|
__privateAdd(this, _previousHead);
|
|
21803
|
-
__privateAdd(this, _fetchStarted);
|
|
21804
|
-
__privateAdd(this, _offerStarted);
|
|
21805
|
-
__privateAdd(this, _offerRequestId);
|
|
21806
21837
|
__privateAdd(this, _pushMillis, 0);
|
|
21807
21838
|
__privateAdd(this, _pushBytes, 0n);
|
|
21808
21839
|
__privateAdd(this, _desiredHead);
|
|
@@ -21896,7 +21927,7 @@
|
|
|
21896
21927
|
throw new Error(`replica '${__privateGet(this, _binding).replicaId}' has no custody remote`);
|
|
21897
21928
|
}
|
|
21898
21929
|
if (__privateGet(this, _rediscover) || __privateGet(this, _recheckPlacement) || !__privateGet(this, _route2)?.placementObserved && !__privateGet(this, _route2)?.placementFrontier && !__privateGet(this, _kernel16).resolveRef(__privateGet(this, _mount), __privateGet(this, _requestId4), PLACEMENT_REF3)) {
|
|
21899
|
-
__privateSet(this,
|
|
21930
|
+
__privateSet(this, _state, { phase: WorkspaceSyncPhase.Discover });
|
|
21900
21931
|
return __privateMethod(this, _WorkspaceSyncWork_instances, remember_fn4).call(this, {
|
|
21901
21932
|
case: "pending",
|
|
21902
21933
|
value: create(CorrespondencePendingSchema, {
|
|
@@ -21930,24 +21961,26 @@
|
|
|
21930
21961
|
`workspace sync '${this.workId}' expected effect '${expected}', received '${receipt.effectId}'`
|
|
21931
21962
|
);
|
|
21932
21963
|
}
|
|
21964
|
+
const state = __privateGet(this, _state);
|
|
21933
21965
|
const previousReceipt = __privateGet(this, _lastReceiptEffectId2);
|
|
21934
21966
|
__privateSet(this, _lastReceiptEffectId2, receipt.effectId);
|
|
21935
21967
|
try {
|
|
21936
21968
|
if (receipt.outcome.case === "failure") {
|
|
21937
|
-
if (
|
|
21969
|
+
if (state.phase === WorkspaceSyncPhase.Discover) return __privateMethod(this, _WorkspaceSyncWork_instances, openRound_fn).call(this);
|
|
21938
21970
|
return __privateMethod(this, _WorkspaceSyncWork_instances, transportFailure_fn).call(this, receipt.outcome.value.message, receipt.outcome.value.reason === PeerEffectFailureReason.OFFLINE);
|
|
21939
21971
|
}
|
|
21940
|
-
if (
|
|
21941
|
-
|
|
21942
|
-
|
|
21943
|
-
if (
|
|
21944
|
-
|
|
21945
|
-
|
|
21972
|
+
if (state.phase === WorkspaceSyncPhase.Offer || state.phase === WorkspaceSyncPhase.Probe) {
|
|
21973
|
+
return __privateMethod(this, _WorkspaceSyncWork_instances, acceptOffer_fn).call(this, receipt, state);
|
|
21974
|
+
}
|
|
21975
|
+
if (state.phase === WorkspaceSyncPhase.Lease) return __privateMethod(this, _WorkspaceSyncWork_instances, acceptLease_fn).call(this, receipt, state);
|
|
21976
|
+
if (state.phase === WorkspaceSyncPhase.Discover) return __privateMethod(this, _WorkspaceSyncWork_instances, acceptDiscovery_fn).call(this, receipt);
|
|
21977
|
+
if (state.phase === WorkspaceSyncPhase.Placement) {
|
|
21978
|
+
state.transfer.accept(receipt);
|
|
21946
21979
|
(_a = __privateGet(this, _placementFetched)) == null ? void 0 : _a.call(this);
|
|
21947
|
-
if (
|
|
21948
|
-
return __privateMethod(this, _WorkspaceSyncWork_instances, beginMainFetch_fn).call(this,
|
|
21980
|
+
if (state.afterPlacement) return __privateMethod(this, _WorkspaceSyncWork_instances, finish_fn2).call(this, state.afterPlacement);
|
|
21981
|
+
return __privateMethod(this, _WorkspaceSyncWork_instances, beginMainFetch_fn).call(this, state.lease);
|
|
21949
21982
|
}
|
|
21950
|
-
if (
|
|
21983
|
+
if (state.phase === WorkspaceSyncPhase.Fetch) return __privateMethod(this, _WorkspaceSyncWork_instances, acceptFetch_fn).call(this, receipt, state);
|
|
21951
21984
|
throw new Error(`workspace sync '${this.workId}' is already complete`);
|
|
21952
21985
|
} catch (error) {
|
|
21953
21986
|
__privateSet(this, _lastReceiptEffectId2, previousReceipt);
|
|
@@ -21963,25 +21996,19 @@
|
|
|
21963
21996
|
_route2 = new WeakMap();
|
|
21964
21997
|
_rediscover = new WeakMap();
|
|
21965
21998
|
_reroute = new WeakMap();
|
|
21966
|
-
_placementFetch = new WeakMap();
|
|
21967
21999
|
_discoveredFrontier = new WeakMap();
|
|
21968
22000
|
_observePlacement = new WeakMap();
|
|
21969
22001
|
_recheckPlacement = new WeakMap();
|
|
21970
22002
|
_directoryAnswered = new WeakMap();
|
|
21971
22003
|
_placementFetched = new WeakMap();
|
|
21972
|
-
_afterPlacement = new WeakMap();
|
|
21973
22004
|
_leased = new WeakMap();
|
|
21974
|
-
_lease = new WeakMap();
|
|
21975
22005
|
_command2 = new WeakMap();
|
|
21976
22006
|
_requestId4 = new WeakMap();
|
|
21977
22007
|
_started = new WeakMap();
|
|
21978
|
-
|
|
22008
|
+
_state = new WeakMap();
|
|
21979
22009
|
_localHead = new WeakMap();
|
|
21980
22010
|
_offerHead = new WeakMap();
|
|
21981
22011
|
_previousHead = new WeakMap();
|
|
21982
|
-
_fetchStarted = new WeakMap();
|
|
21983
|
-
_offerStarted = new WeakMap();
|
|
21984
|
-
_offerRequestId = new WeakMap();
|
|
21985
22012
|
_pushMillis = new WeakMap();
|
|
21986
22013
|
_pushBytes = new WeakMap();
|
|
21987
22014
|
_desiredHead = new WeakMap();
|
|
@@ -22012,13 +22039,13 @@
|
|
|
22012
22039
|
openRound_fn = function() {
|
|
22013
22040
|
if (__privateGet(this, _receiveState) || __privateGet(this, _replaceLocalHead) !== void 0) return __privateMethod(this, _WorkspaceSyncWork_instances, leaseEffect_fn).call(this);
|
|
22014
22041
|
if (!__privateGet(this, _localHead)) return __privateMethod(this, _WorkspaceSyncWork_instances, leaseEffect_fn).call(this);
|
|
22015
|
-
|
|
22042
|
+
const requestId = `${__privateGet(this, _binding).replicaId}:${__privateGet(this, _requestId4)}:${this.workId}:frontier`;
|
|
22016
22043
|
return __privateMethod(this, _WorkspaceSyncWork_instances, beginOffer_fn).call(this, encodeInlineCustodyOffer({
|
|
22017
22044
|
session: __privateGet(this, _binding).replicaId,
|
|
22018
|
-
requestId
|
|
22045
|
+
requestId,
|
|
22019
22046
|
observedHead: __privateGet(this, _localHead),
|
|
22020
22047
|
intents: []
|
|
22021
|
-
}), true);
|
|
22048
|
+
}), { case: "awaiting", requestId }, true);
|
|
22022
22049
|
};
|
|
22023
22050
|
offerOrReconcile_fn = function() {
|
|
22024
22051
|
if (__privateGet(this, _command2).admit && __privateGet(this, _localHead) && __privateGet(this, _localHead) !== __privateGet(this, _previousHead)) {
|
|
@@ -22039,13 +22066,13 @@
|
|
|
22039
22066
|
throw new Error(`kernel did not classify transport for intent '${unspecified.intentId}'`);
|
|
22040
22067
|
}
|
|
22041
22068
|
if (suffix.length > 0) {
|
|
22042
|
-
|
|
22043
|
-
|
|
22069
|
+
const requestId2 = `${__privateGet(this, _binding).replicaId}:${__privateGet(this, _requestId4)}:${this.workId}`;
|
|
22070
|
+
const startedAt = __privateGet(this, _clock13).monotonicNanoseconds();
|
|
22044
22071
|
__privateSet(this, _offerAfterConverge, true);
|
|
22045
22072
|
__privateSet(this, _rebaseFrom, __privateGet(this, _previousHead));
|
|
22046
22073
|
return __privateMethod(this, _WorkspaceSyncWork_instances, beginOffer_fn).call(this, encodeInlineCustodyOffer({
|
|
22047
22074
|
session: __privateGet(this, _binding).replicaId,
|
|
22048
|
-
requestId:
|
|
22075
|
+
requestId: requestId2,
|
|
22049
22076
|
...__privateGet(this, _previousHead) === void 0 ? {} : { baseHead: __privateGet(this, _previousHead) },
|
|
22050
22077
|
observedHead: __privateGet(this, _localHead),
|
|
22051
22078
|
intents: suffix,
|
|
@@ -22056,51 +22083,26 @@
|
|
|
22056
22083
|
__privateGet(this, _previousHead)
|
|
22057
22084
|
) : void 0,
|
|
22058
22085
|
fastForwardOnly: true
|
|
22059
|
-
}));
|
|
22086
|
+
}), { case: "awaiting", requestId: requestId2, startedAt });
|
|
22060
22087
|
}
|
|
22061
22088
|
}
|
|
22062
|
-
|
|
22089
|
+
const requestId = `${__privateGet(this, _binding).replicaId}:${__privateGet(this, _requestId4)}:${this.workId}:reconcile`;
|
|
22063
22090
|
return __privateMethod(this, _WorkspaceSyncWork_instances, beginOffer_fn).call(this, encodeInlineCustodyOffer({
|
|
22064
22091
|
session: __privateGet(this, _binding).replicaId,
|
|
22065
|
-
requestId
|
|
22092
|
+
requestId,
|
|
22066
22093
|
baseHead: __privateGet(this, _previousHead),
|
|
22067
22094
|
observedHead: __privateGet(this, _localHead),
|
|
22068
22095
|
intents: []
|
|
22069
|
-
}));
|
|
22096
|
+
}), { case: "awaiting", requestId });
|
|
22070
22097
|
};
|
|
22071
22098
|
/**
|
|
22072
|
-
*
|
|
22073
|
-
*
|
|
22074
|
-
*
|
|
22075
|
-
*
|
|
22076
|
-
* state ("a non-empty live ledger requires a common admitted base"), so every step after the
|
|
22077
|
-
* O(1) frontier probe is wasted work — and it is not cheap waste: the fetch negotiates with
|
|
22078
|
-
* no `have` (a full-history pack), and the dependency planner decodes EVERY intent from
|
|
22079
|
-
* genesis and inspects every change, once per round. That is O(history) per follow round,
|
|
22080
|
-
* repeated at every retry, for a round that can only end in a refusal.
|
|
22081
|
-
*
|
|
22082
|
-
* The one base this round can establish costs nothing and is established before this is
|
|
22083
|
-
* asked: an upstream holding exactly this replica's head (the probe's answer) converges it
|
|
22084
|
-
* and records the tracking frontier. Anything else needs the local copy to be dropped and
|
|
22085
|
-
* refetched (an application decision, which preserves the copy), or a re-discovery that
|
|
22086
|
-
* names a provider holding this lineage. Both are reported, at O(1), as this failure.
|
|
22087
|
-
*/
|
|
22088
|
-
/**
|
|
22089
|
-
* Establish this round's base when none is tracked, without walking any history it can avoid.
|
|
22090
|
-
*
|
|
22091
|
-
* The upstream just named its own frontier. If that commit is in THIS replica's lineage, it is
|
|
22092
|
-
* a common admitted base by definition — both sides hold it — and adopting it turns the round
|
|
22093
|
-
* into an ordinary fast-forward: the offer carries only the suffix above it, the fetch can name
|
|
22094
|
-
* it as a truthful `have`, and convergence has the base the kernel requires. One commit walk
|
|
22095
|
-
* (no change decoding, no pack, no network) decides it.
|
|
22096
|
-
*
|
|
22097
|
-
* If it is not in this replica's lineage, no base exists to establish and the round is refused
|
|
22098
|
-
* (#noCommonBase) before it leases, fetches or plans anything.
|
|
22099
|
-
*
|
|
22100
|
-
* A kernel without the commit walk cannot be asked, so it keeps the previous behaviour.
|
|
22099
|
+
* Establish a cheap base when the provider's current tip is in our local chain.
|
|
22100
|
+
* A negative answer means the base is unknown: both sides may have advanced from
|
|
22101
|
+
* an earlier shared commit. Acquire the candidate and let the kernel discover
|
|
22102
|
+
* and judge that history. A tracking bookmark is not an admission prerequisite.
|
|
22101
22103
|
*/
|
|
22102
22104
|
establishBase_fn = function(upstreamHead) {
|
|
22103
|
-
if (!__privateMethod(this, _WorkspaceSyncWork_instances,
|
|
22105
|
+
if (!__privateMethod(this, _WorkspaceSyncWork_instances, missingTrackedBase_fn).call(this) || !__privateGet(this, _kernel16).historySummary) return true;
|
|
22104
22106
|
const summary = __privateGet(this, _kernel16).historySummary(__privateGet(this, _mount), __privateGet(this, _requestId4), upstreamHead, __privateGet(this, _localHead));
|
|
22105
22107
|
if (!summary.reachedBase) return false;
|
|
22106
22108
|
__privateSet(this, _previousHead, upstreamHead);
|
|
@@ -22110,26 +22112,9 @@
|
|
|
22110
22112
|
}
|
|
22111
22113
|
return true;
|
|
22112
22114
|
};
|
|
22113
|
-
|
|
22115
|
+
missingTrackedBase_fn = function() {
|
|
22114
22116
|
return __privateGet(this, _previousHead) === void 0 && __privateGet(this, _localHead) !== void 0 && __privateGet(this, _replaceLocalHead) === void 0;
|
|
22115
22117
|
};
|
|
22116
|
-
noCommonBaseResult_fn = function() {
|
|
22117
|
-
return __privateMethod(this, _WorkspaceSyncWork_instances, finish_fn2).call(this, create(SyncWorkspaceResponseSchema, {
|
|
22118
|
-
workspace: __privateGet(this, _mount).workspace,
|
|
22119
|
-
...__privateGet(this, _localHead) === void 0 ? {} : { currentHead: __privateGet(this, _localHead) },
|
|
22120
|
-
stillAhead: true,
|
|
22121
|
-
...__privateGet(this, _offerReceipt) === void 0 ? {} : { offerReceipt: __privateGet(this, _offerReceipt) },
|
|
22122
|
-
pushError: create(RuntimeTransportFailureSchema, {
|
|
22123
|
-
endpoint: __privateMethod(this, _WorkspaceSyncWork_instances, offerEndpoint_fn).call(this),
|
|
22124
|
-
status: 409,
|
|
22125
|
-
refused: true,
|
|
22126
|
-
message: NO_COMMON_BASE
|
|
22127
|
-
}),
|
|
22128
|
-
timings: create(SyncPhaseTimingsSchema, {
|
|
22129
|
-
convergeMillis: elapsedMillis(__privateGet(this, _clock13), __privateGet(this, _started))
|
|
22130
|
-
})
|
|
22131
|
-
}));
|
|
22132
|
-
};
|
|
22133
22118
|
holdsLocalWork_fn = function() {
|
|
22134
22119
|
return __privateGet(this, _command2).admit && !!__privateGet(this, _localHead) && __privateGet(this, _localHead) !== __privateGet(this, _previousHead);
|
|
22135
22120
|
};
|
|
@@ -22137,18 +22122,18 @@
|
|
|
22137
22122
|
pullBeforeOffer_fn = function() {
|
|
22138
22123
|
__privateSet(this, _offerAfterConverge, true);
|
|
22139
22124
|
__privateSet(this, _rebaseFrom, __privateGet(this, _previousHead));
|
|
22140
|
-
|
|
22125
|
+
const requestId = `${__privateGet(this, _binding).replicaId}:${__privateGet(this, _requestId4)}:${this.workId}:pull-${__privateGet(this, _rebases)}`;
|
|
22141
22126
|
return __privateMethod(this, _WorkspaceSyncWork_instances, beginOffer_fn).call(this, encodeInlineCustodyOffer({
|
|
22142
22127
|
session: __privateGet(this, _binding).replicaId,
|
|
22143
|
-
requestId
|
|
22128
|
+
requestId,
|
|
22144
22129
|
...__privateGet(this, _previousHead) === void 0 ? {} : { baseHead: __privateGet(this, _previousHead) },
|
|
22145
22130
|
observedHead: __privateGet(this, _localHead),
|
|
22146
22131
|
intents: []
|
|
22147
|
-
}));
|
|
22132
|
+
}), { case: "awaiting", requestId });
|
|
22148
22133
|
};
|
|
22149
|
-
leaseEffect_fn = function() {
|
|
22134
|
+
leaseEffect_fn = function(afterPlacement) {
|
|
22150
22135
|
const token = __privateMethod(this, _WorkspaceSyncWork_instances, authToken_fn).call(this);
|
|
22151
|
-
__privateSet(this,
|
|
22136
|
+
__privateSet(this, _state, { phase: WorkspaceSyncPhase.Lease, ...afterPlacement ? { afterPlacement } : {} });
|
|
22152
22137
|
return __privateMethod(this, _WorkspaceSyncWork_instances, remember_fn4).call(this, {
|
|
22153
22138
|
case: "pending",
|
|
22154
22139
|
value: create(CorrespondencePendingSchema, {
|
|
@@ -22166,8 +22151,9 @@
|
|
|
22166
22151
|
})
|
|
22167
22152
|
});
|
|
22168
22153
|
};
|
|
22169
|
-
beginOffer_fn = function(body, probe = false) {
|
|
22170
|
-
|
|
22154
|
+
beginOffer_fn = function(body, exchange, probe = false) {
|
|
22155
|
+
const phase = probe ? WorkspaceSyncPhase.Probe : WorkspaceSyncPhase.Offer;
|
|
22156
|
+
__privateSet(this, _state, { phase, exchange });
|
|
22171
22157
|
const token = __privateMethod(this, _WorkspaceSyncWork_instances, authToken_fn).call(this);
|
|
22172
22158
|
__privateSet(this, _pushBytes, __privateGet(this, _pushBytes) + BigInt(body.byteLength));
|
|
22173
22159
|
return __privateMethod(this, _WorkspaceSyncWork_instances, remember_fn4).call(this, {
|
|
@@ -22177,7 +22163,7 @@
|
|
|
22177
22163
|
effect: {
|
|
22178
22164
|
case: "http",
|
|
22179
22165
|
value: create(PeerHttpEffectSchema, {
|
|
22180
|
-
effectId: `${this.workId}:${
|
|
22166
|
+
effectId: `${this.workId}:${phase}`,
|
|
22181
22167
|
method: PeerHttpMethod.POST,
|
|
22182
22168
|
url: __privateMethod(this, _WorkspaceSyncWork_instances, offerEndpoint_fn).call(this),
|
|
22183
22169
|
contentType: CUSTODY_OFFER_MEDIA_TYPE,
|
|
@@ -22194,28 +22180,30 @@
|
|
|
22194
22180
|
})
|
|
22195
22181
|
});
|
|
22196
22182
|
};
|
|
22197
|
-
acceptOffer_fn = function(receipt) {
|
|
22198
|
-
|
|
22183
|
+
acceptOffer_fn = function(receipt, state) {
|
|
22184
|
+
const exchange = state.exchange;
|
|
22185
|
+
__privateSet(this, _pushMillis, exchange.startedAt === void 0 ? 0 : elapsedMillis(__privateGet(this, _clock13), exchange.startedAt));
|
|
22199
22186
|
if (receipt.outcome.case !== "response") {
|
|
22200
22187
|
throw new Error("platform returned the wrong receipt for a custody offer");
|
|
22201
22188
|
}
|
|
22202
|
-
const
|
|
22203
|
-
if (
|
|
22189
|
+
const outcome = settleCustodyOfferExchange(exchange, receipt.outcome.value);
|
|
22190
|
+
if (outcome.case === "maintenance") {
|
|
22191
|
+
return __privateMethod(this, _WorkspaceSyncWork_instances, finishOfferOutcome_fn).call(this, true, false);
|
|
22192
|
+
}
|
|
22193
|
+
if (outcome.case === "unexpected") {
|
|
22204
22194
|
__privateSet(this, _pushError, create(RuntimeTransportFailureSchema, {
|
|
22205
22195
|
endpoint: __privateMethod(this, _WorkspaceSyncWork_instances, offerEndpoint_fn).call(this),
|
|
22206
|
-
status:
|
|
22196
|
+
status: outcome.status,
|
|
22207
22197
|
refused: false,
|
|
22208
|
-
message: `Sync received an unexpected server response (HTTP ${
|
|
22198
|
+
message: `Sync received an unexpected server response (HTTP ${outcome.status}; ${outcome.contentType || "no content type"}). No custody receipt was returned.`
|
|
22209
22199
|
}));
|
|
22210
22200
|
return __privateMethod(this, _WorkspaceSyncWork_instances, finishOfferOutcome_fn).call(this, false);
|
|
22211
22201
|
}
|
|
22212
|
-
|
|
22213
|
-
const outcome = decodeCustodyOffer(response.body, __privateGet(this, _offerRequestId));
|
|
22214
|
-
__privateSet(this, _offerReceipt, custodyOfferReceipt(__privateGet(this, _offerRequestId), outcome));
|
|
22202
|
+
__privateSet(this, _offerReceipt, outcome.receipt);
|
|
22215
22203
|
if (outcome.case === "failure") {
|
|
22216
22204
|
__privateSet(this, _pushError, create(RuntimeTransportFailureSchema, {
|
|
22217
22205
|
endpoint: __privateMethod(this, _WorkspaceSyncWork_instances, offerEndpoint_fn).call(this),
|
|
22218
|
-
status:
|
|
22206
|
+
status: outcome.status,
|
|
22219
22207
|
refused: false,
|
|
22220
22208
|
message: `${outcome.value.code}: ${outcome.value.message}`
|
|
22221
22209
|
}));
|
|
@@ -22224,12 +22212,12 @@
|
|
|
22224
22212
|
if (outcome.case === "blocked") {
|
|
22225
22213
|
return __privateMethod(this, _WorkspaceSyncWork_instances, finishOfferOutcome_fn).call(this, true);
|
|
22226
22214
|
}
|
|
22227
|
-
if (
|
|
22215
|
+
if (outcome.status < 200 || outcome.status >= 300) {
|
|
22228
22216
|
__privateSet(this, _pushError, create(RuntimeTransportFailureSchema, {
|
|
22229
22217
|
endpoint: __privateMethod(this, _WorkspaceSyncWork_instances, offerEndpoint_fn).call(this),
|
|
22230
|
-
status:
|
|
22231
|
-
refused:
|
|
22232
|
-
message: `custody offer returned an admission verdict with HTTP ${
|
|
22218
|
+
status: outcome.status,
|
|
22219
|
+
refused: outcome.status === 422,
|
|
22220
|
+
message: `custody offer returned an admission verdict with HTTP ${outcome.status}`
|
|
22233
22221
|
}));
|
|
22234
22222
|
return __privateMethod(this, _WorkspaceSyncWork_instances, finishOfferOutcome_fn).call(this, false);
|
|
22235
22223
|
}
|
|
@@ -22237,8 +22225,7 @@
|
|
|
22237
22225
|
__privateSet(this, _desiredHead, admission.main || void 0);
|
|
22238
22226
|
if (!__privateGet(this, _desiredHead)) return __privateMethod(this, _WorkspaceSyncWork_instances, transportFailure_fn).call(this, "resident peer returned no admitted frontier", false);
|
|
22239
22227
|
__privateSet(this, _candidateDurable, admission.sealedMain === __privateGet(this, _desiredHead));
|
|
22240
|
-
if (
|
|
22241
|
-
if (!__privateMethod(this, _WorkspaceSyncWork_instances, establishBase_fn).call(this, __privateGet(this, _desiredHead))) return __privateMethod(this, _WorkspaceSyncWork_instances, noCommonBaseResult_fn).call(this);
|
|
22228
|
+
if (state.phase === WorkspaceSyncPhase.Probe && __privateGet(this, _desiredHead) !== __privateGet(this, _localHead)) {
|
|
22242
22229
|
if (__privateMethod(this, _WorkspaceSyncWork_instances, alreadyJudged_fn).call(this, __privateGet(this, _desiredHead))) {
|
|
22243
22230
|
return __privateMethod(this, _WorkspaceSyncWork_instances, finish_fn2).call(this, create(SyncWorkspaceResponseSchema, {
|
|
22244
22231
|
workspace: __privateGet(this, _mount).workspace,
|
|
@@ -22250,6 +22237,22 @@
|
|
|
22250
22237
|
offerReceipt: __privateGet(this, _offerReceipt)
|
|
22251
22238
|
}));
|
|
22252
22239
|
}
|
|
22240
|
+
if (!__privateMethod(this, _WorkspaceSyncWork_instances, establishBase_fn).call(this, __privateGet(this, _desiredHead))) {
|
|
22241
|
+
__privateSet(this, _offerAfterConverge, __privateGet(this, _command2).admit);
|
|
22242
|
+
__privateSet(this, _rebaseFrom, void 0);
|
|
22243
|
+
return __privateMethod(this, _WorkspaceSyncWork_instances, leaseEffect_fn).call(this);
|
|
22244
|
+
}
|
|
22245
|
+
if (__privateGet(this, _establishedBase) && !__privateGet(this, _candidateDurable) && __privateGet(this, _kernel16).resolveRef(__privateGet(this, _mount), __privateGet(this, _requestId4), trackedMain) === void 0) {
|
|
22246
|
+
return __privateMethod(this, _WorkspaceSyncWork_instances, finish_fn2).call(this, create(SyncWorkspaceResponseSchema, {
|
|
22247
|
+
workspace: __privateGet(this, _mount).workspace,
|
|
22248
|
+
currentHead: __privateGet(this, _localHead),
|
|
22249
|
+
previousHead: __privateGet(this, _previousHead),
|
|
22250
|
+
stillAhead: true,
|
|
22251
|
+
directOfferDeferred: true,
|
|
22252
|
+
reconnectRequired: false,
|
|
22253
|
+
offerReceipt: __privateGet(this, _offerReceipt)
|
|
22254
|
+
}));
|
|
22255
|
+
}
|
|
22253
22256
|
if (__privateGet(this, _probeOnly)) {
|
|
22254
22257
|
__privateSet(this, _needsReconciliation, true);
|
|
22255
22258
|
return __privateMethod(this, _WorkspaceSyncWork_instances, finish_fn2).call(this, create(SyncWorkspaceResponseSchema, {
|
|
@@ -22295,11 +22298,11 @@
|
|
|
22295
22298
|
return __privateMethod(this, _WorkspaceSyncWork_instances, converge_fn2).call(this, __privateGet(this, _desiredHead), admission.resultPack.byteLength, 0);
|
|
22296
22299
|
}
|
|
22297
22300
|
if (__privateGet(this, _desiredHead) === __privateGet(this, _previousHead)) return __privateMethod(this, _WorkspaceSyncWork_instances, converge_fn2).call(this, __privateGet(this, _desiredHead), 0, 0);
|
|
22298
|
-
|
|
22301
|
+
__privateMethod(this, _WorkspaceSyncWork_instances, establishBase_fn).call(this, __privateGet(this, _desiredHead));
|
|
22299
22302
|
if (admission.recoveryRequired !== false) return __privateMethod(this, _WorkspaceSyncWork_instances, leaseEffect_fn).call(this);
|
|
22300
22303
|
return __privateMethod(this, _WorkspaceSyncWork_instances, transportFailure_fn).call(this, "resident peer supplied neither the missing delta nor a history gap", false);
|
|
22301
22304
|
};
|
|
22302
|
-
acceptLease_fn = function(receipt) {
|
|
22305
|
+
acceptLease_fn = function(receipt, state) {
|
|
22303
22306
|
if (receipt.outcome.case !== "response") {
|
|
22304
22307
|
throw new Error("platform returned the wrong receipt for a Git read lease");
|
|
22305
22308
|
}
|
|
@@ -22311,21 +22314,25 @@
|
|
|
22311
22314
|
__privateSet(this, _leased, true);
|
|
22312
22315
|
const frontier = __privateMethod(this, _WorkspaceSyncWork_instances, placementFrontier_fn).call(this);
|
|
22313
22316
|
if (frontier) {
|
|
22314
|
-
|
|
22317
|
+
const transfer = new PlacementFetch(
|
|
22315
22318
|
__privateGet(this, _kernel16),
|
|
22316
22319
|
__privateGet(this, _mount),
|
|
22317
22320
|
__privateGet(this, _requestId4),
|
|
22318
22321
|
this.workId,
|
|
22319
22322
|
frontier
|
|
22320
|
-
)
|
|
22321
|
-
const pending =
|
|
22323
|
+
);
|
|
22324
|
+
const pending = transfer.start(lease);
|
|
22322
22325
|
if (pending) {
|
|
22323
|
-
__privateSet(this,
|
|
22324
|
-
|
|
22326
|
+
__privateSet(this, _state, {
|
|
22327
|
+
phase: WorkspaceSyncPhase.Placement,
|
|
22328
|
+
transfer,
|
|
22329
|
+
lease,
|
|
22330
|
+
...state.afterPlacement ? { afterPlacement: state.afterPlacement } : {}
|
|
22331
|
+
});
|
|
22325
22332
|
return __privateMethod(this, _WorkspaceSyncWork_instances, remember_fn4).call(this, { case: "pending", value: pending });
|
|
22326
22333
|
}
|
|
22327
22334
|
}
|
|
22328
|
-
if (
|
|
22335
|
+
if (state.afterPlacement) return __privateMethod(this, _WorkspaceSyncWork_instances, finish_fn2).call(this, state.afterPlacement);
|
|
22329
22336
|
return __privateMethod(this, _WorkspaceSyncWork_instances, beginMainFetch_fn).call(this, lease);
|
|
22330
22337
|
};
|
|
22331
22338
|
/** The provider's placement frontier as this round knows it: what the directory named in this
|
|
@@ -22345,8 +22352,7 @@
|
|
|
22345
22352
|
if (!new PlacementFetch(__privateGet(this, _kernel16), __privateGet(this, _mount), __privateGet(this, _requestId4), this.workId, frontier).wanted()) {
|
|
22346
22353
|
return void 0;
|
|
22347
22354
|
}
|
|
22348
|
-
|
|
22349
|
-
return __privateMethod(this, _WorkspaceSyncWork_instances, leaseEffect_fn).call(this);
|
|
22355
|
+
return __privateMethod(this, _WorkspaceSyncWork_instances, leaseEffect_fn).call(this, presented);
|
|
22350
22356
|
};
|
|
22351
22357
|
acceptDiscovery_fn = function(receipt) {
|
|
22352
22358
|
var _a, _b;
|
|
@@ -22371,9 +22377,11 @@
|
|
|
22371
22377
|
return __privateGet(this, _replaceLocalHead) !== void 0 || __privateGet(this, _localHead) === void 0 && __privateGet(this, _previousHead) === void 0;
|
|
22372
22378
|
};
|
|
22373
22379
|
beginMainFetch_fn = function(lease) {
|
|
22374
|
-
__privateSet(this, _phase2, WorkspaceSyncPhase.Fetch);
|
|
22375
22380
|
const lawProducts = __privateMethod(this, _WorkspaceSyncWork_instances, lawProductsAlongside_fn).call(this);
|
|
22376
|
-
__privateSet(this,
|
|
22381
|
+
__privateSet(this, _state, {
|
|
22382
|
+
phase: WorkspaceSyncPhase.Fetch,
|
|
22383
|
+
startedAt: __privateGet(this, _clock13).monotonicNanoseconds()
|
|
22384
|
+
});
|
|
22377
22385
|
const haves = __privateGet(this, _replaceLocalHead) !== void 0 ? __privateGet(this, _repairMissingCommit) ? [] : [__privateGet(this, _kernel16).resolveRef(__privateGet(this, _mount), __privateGet(this, _requestId4), deferredRemote)].filter(
|
|
22378
22386
|
(head) => !!head
|
|
22379
22387
|
) : [...new Set([
|
|
@@ -22404,7 +22412,7 @@
|
|
|
22404
22412
|
})
|
|
22405
22413
|
});
|
|
22406
22414
|
};
|
|
22407
|
-
acceptFetch_fn = function(receipt) {
|
|
22415
|
+
acceptFetch_fn = function(receipt, state) {
|
|
22408
22416
|
if (receipt.outcome.case !== "gitFetch") {
|
|
22409
22417
|
throw new Error("platform returned the wrong receipt for a Git object fetch");
|
|
22410
22418
|
}
|
|
@@ -22414,7 +22422,7 @@
|
|
|
22414
22422
|
if (fetched.pack.byteLength > 0) {
|
|
22415
22423
|
__privateGet(this, _kernel16).applyPack(__privateGet(this, _mount), __privateGet(this, _requestId4), fetched.pack, fetched.head, fetched.shallow);
|
|
22416
22424
|
}
|
|
22417
|
-
const prefetchMillis =
|
|
22425
|
+
const prefetchMillis = elapsedMillis(__privateGet(this, _clock13), state.startedAt);
|
|
22418
22426
|
const candidateHead = __privateGet(this, _receiveState) ? __privateGet(this, _kernel16).resolveStatePosition?.(__privateGet(this, _mount), __privateGet(this, _requestId4), fetched.head, __privateGet(this, _receiveState)) : fetched.head;
|
|
22419
22427
|
if (!candidateHead) {
|
|
22420
22428
|
return __privateMethod(this, _WorkspaceSyncWork_instances, finish_fn2).call(this, create(SyncWorkspaceResponseSchema, {
|
|
@@ -22504,7 +22512,7 @@
|
|
|
22504
22512
|
};
|
|
22505
22513
|
converge_fn2 = function(candidateHead, receivedBytes, prefetchMillis) {
|
|
22506
22514
|
var _a;
|
|
22507
|
-
|
|
22515
|
+
__privateMethod(this, _WorkspaceSyncWork_instances, establishBase_fn).call(this, candidateHead);
|
|
22508
22516
|
(_a = __privateGet(this, _beforeConverge)) == null ? void 0 : _a.call(this, candidateHead, __privateGet(this, _previousHead));
|
|
22509
22517
|
const convergeStarted = __privateGet(this, _clock13).monotonicNanoseconds();
|
|
22510
22518
|
let judged;
|
|
@@ -22739,11 +22747,11 @@
|
|
|
22739
22747
|
pushBytes: __privateGet(this, _pushBytes),
|
|
22740
22748
|
pullBytes: BigInt(receivedBytes),
|
|
22741
22749
|
serverMillis: __privateGet(this, _admissionSummary)?.serverMillis ?? 0,
|
|
22742
|
-
offerInPush: __privateGet(this,
|
|
22750
|
+
offerInPush: __privateGet(this, _pushBytes) > 0n
|
|
22743
22751
|
})
|
|
22744
22752
|
});
|
|
22745
22753
|
};
|
|
22746
|
-
finishOfferOutcome_fn = function(blocked) {
|
|
22754
|
+
finishOfferOutcome_fn = function(blocked, reconnectRequired = true) {
|
|
22747
22755
|
return __privateMethod(this, _WorkspaceSyncWork_instances, finish_fn2).call(this, create(SyncWorkspaceResponseSchema, {
|
|
22748
22756
|
workspace: __privateGet(this, _mount).workspace,
|
|
22749
22757
|
previousHead: __privateGet(this, _previousHead),
|
|
@@ -22751,7 +22759,7 @@
|
|
|
22751
22759
|
admitted: BigInt(__privateGet(this, _admissionSummary)?.admittedIntentIds.length ?? 0),
|
|
22752
22760
|
refused: BigInt((__privateGet(this, _admissionSummary)?.refusedMessages.length ?? 0) + __privateGet(this, _parkedLocal)),
|
|
22753
22761
|
deferred: BigInt(__privateGet(this, _admissionSummary) ? __privateGet(this, _admissionSummary).blockedMessages.length + __privateGet(this, _admissionSummary).deadLetteredMessages.length + __privateGet(this, _admissionSummary).quarantinedMessages.length + __privateGet(this, _admissionSummary).deferredMessages.length : blocked ? 1 : 0),
|
|
22754
|
-
reconnectRequired
|
|
22762
|
+
reconnectRequired,
|
|
22755
22763
|
stillAhead: __privateGet(this, _localHead) !== __privateGet(this, _previousHead),
|
|
22756
22764
|
directOfferDeferred: blocked,
|
|
22757
22765
|
offerReceipt: __privateGet(this, _offerReceipt),
|
|
@@ -22765,15 +22773,16 @@
|
|
|
22765
22773
|
}));
|
|
22766
22774
|
};
|
|
22767
22775
|
transportFailure_fn = function(message, offline, status = -1) {
|
|
22768
|
-
const
|
|
22776
|
+
const state = __privateGet(this, _state);
|
|
22777
|
+
const pushFailed = state.phase === WorkspaceSyncPhase.Offer;
|
|
22769
22778
|
const failedEndpoint = __privateMethod(this, _WorkspaceSyncWork_instances, offerEndpoint_fn).call(this);
|
|
22770
22779
|
const failure = create(RuntimeTransportFailureSchema, {
|
|
22771
22780
|
endpoint: pushFailed ? failedEndpoint : __privateGet(this, _binding).cloud ?? "",
|
|
22772
22781
|
status,
|
|
22773
22782
|
message
|
|
22774
22783
|
});
|
|
22775
|
-
if (
|
|
22776
|
-
__privateSet(this, _pushMillis,
|
|
22784
|
+
if (state.phase === WorkspaceSyncPhase.Offer) {
|
|
22785
|
+
__privateSet(this, _pushMillis, state.exchange.startedAt === void 0 ? 0 : elapsedMillis(__privateGet(this, _clock13), state.exchange.startedAt));
|
|
22777
22786
|
__privateSet(this, _pushError, failure);
|
|
22778
22787
|
}
|
|
22779
22788
|
return __privateMethod(this, _WorkspaceSyncWork_instances, finish_fn2).call(this, create(SyncWorkspaceResponseSchema, {
|
|
@@ -22790,7 +22799,7 @@
|
|
|
22790
22799
|
pushMillis: __privateGet(this, _pushMillis),
|
|
22791
22800
|
pushBytes: __privateGet(this, _pushBytes),
|
|
22792
22801
|
prefetchMillis: elapsedMillis(__privateGet(this, _clock13), __privateGet(this, _started)),
|
|
22793
|
-
offerInPush: __privateGet(this,
|
|
22802
|
+
offerInPush: __privateGet(this, _pushBytes) > 0n
|
|
22794
22803
|
})
|
|
22795
22804
|
}));
|
|
22796
22805
|
};
|
|
@@ -22800,7 +22809,7 @@
|
|
|
22800
22809
|
return step;
|
|
22801
22810
|
};
|
|
22802
22811
|
finish_fn2 = function(value) {
|
|
22803
|
-
__privateSet(this,
|
|
22812
|
+
__privateSet(this, _state, { phase: WorkspaceSyncPhase.Done });
|
|
22804
22813
|
__privateSet(this, _current3, void 0);
|
|
22805
22814
|
return __privateMethod(this, _WorkspaceSyncWork_instances, remember_fn4).call(this, { case: "synced", value });
|
|
22806
22815
|
};
|
|
@@ -23226,7 +23235,7 @@
|
|
|
23226
23235
|
millis: 150,
|
|
23227
23236
|
quanta: 64
|
|
23228
23237
|
});
|
|
23229
|
-
var _command3, _source3, _target2, _checkpointSecret, _clock15, _kernel17, _requestId5,
|
|
23238
|
+
var _command3, _source3, _target2, _checkpointSecret, _clock15, _kernel17, _requestId5, _phase2, _offers, _attempted2, _delivered, _refused, _retryable, _lastRetry, _recipientRefused, _activeOffer, _nextDueAtMillis, _appliedThisTurn, _preparationPending, _targetHead, _sourceOutcomeRecorded, _budget, _turnStartedMillis, _quanta, _WorkspaceEffectDelivery_instances, retry_fn2, outboxCall_fn, acceptOutbox_fn, acceptApply_fn, nextApplyOrDone_fn;
|
|
23230
23239
|
var WorkspaceEffectDelivery = class {
|
|
23231
23240
|
constructor(args) {
|
|
23232
23241
|
__privateAdd(this, _WorkspaceEffectDelivery_instances);
|
|
@@ -23237,7 +23246,7 @@
|
|
|
23237
23246
|
__privateAdd(this, _clock15);
|
|
23238
23247
|
__privateAdd(this, _kernel17);
|
|
23239
23248
|
__privateAdd(this, _requestId5);
|
|
23240
|
-
__privateAdd(this,
|
|
23249
|
+
__privateAdd(this, _phase2, WorkspaceEffectDeliveryPhase.Start);
|
|
23241
23250
|
__privateAdd(this, _offers, []);
|
|
23242
23251
|
__privateAdd(this, _attempted2, 0n);
|
|
23243
23252
|
__privateAdd(this, _delivered, 0n);
|
|
@@ -23272,17 +23281,17 @@
|
|
|
23272
23281
|
return __privateGet(this, _recipientRefused);
|
|
23273
23282
|
}
|
|
23274
23283
|
next(response, settlement) {
|
|
23275
|
-
if (__privateGet(this,
|
|
23284
|
+
if (__privateGet(this, _phase2) === WorkspaceEffectDeliveryPhase.Start) {
|
|
23276
23285
|
if (response !== void 0) throw new Error("delivery received a response before its outbox call");
|
|
23277
23286
|
__privateSet(this, _turnStartedMillis, __privateGet(this, _clock15).currentMillis());
|
|
23278
23287
|
return __privateMethod(this, _WorkspaceEffectDelivery_instances, outboxCall_fn).call(this);
|
|
23279
23288
|
}
|
|
23280
|
-
if (__privateGet(this,
|
|
23289
|
+
if (__privateGet(this, _phase2) === WorkspaceEffectDeliveryPhase.Outbox) {
|
|
23281
23290
|
if (!response) throw new Error("delivery requires the source outbox response");
|
|
23282
23291
|
if (__privateMethod(this, _WorkspaceEffectDelivery_instances, acceptOutbox_fn).call(this, response)) return __privateMethod(this, _WorkspaceEffectDelivery_instances, outboxCall_fn).call(this);
|
|
23283
23292
|
return __privateMethod(this, _WorkspaceEffectDelivery_instances, nextApplyOrDone_fn).call(this);
|
|
23284
23293
|
}
|
|
23285
|
-
if (__privateGet(this,
|
|
23294
|
+
if (__privateGet(this, _phase2) === WorkspaceEffectDeliveryPhase.Apply) {
|
|
23286
23295
|
if (!response) throw new Error("delivery requires the target admission response");
|
|
23287
23296
|
__privateMethod(this, _WorkspaceEffectDelivery_instances, acceptApply_fn).call(this, response, settlement);
|
|
23288
23297
|
return __privateMethod(this, _WorkspaceEffectDelivery_instances, nextApplyOrDone_fn).call(this);
|
|
@@ -23297,7 +23306,7 @@
|
|
|
23297
23306
|
_clock15 = new WeakMap();
|
|
23298
23307
|
_kernel17 = new WeakMap();
|
|
23299
23308
|
_requestId5 = new WeakMap();
|
|
23300
|
-
|
|
23309
|
+
_phase2 = new WeakMap();
|
|
23301
23310
|
_offers = new WeakMap();
|
|
23302
23311
|
_attempted2 = new WeakMap();
|
|
23303
23312
|
_delivered = new WeakMap();
|
|
@@ -23320,7 +23329,7 @@
|
|
|
23320
23329
|
__privateSet(this, _lastRetry, { reason, detail: detail.slice(0, RETRY_DETAIL_CHARACTERS) });
|
|
23321
23330
|
};
|
|
23322
23331
|
outboxCall_fn = function() {
|
|
23323
|
-
__privateSet(this,
|
|
23332
|
+
__privateSet(this, _phase2, WorkspaceEffectDeliveryPhase.Outbox);
|
|
23324
23333
|
return {
|
|
23325
23334
|
case: "call",
|
|
23326
23335
|
value: {
|
|
@@ -23362,13 +23371,13 @@
|
|
|
23362
23371
|
}
|
|
23363
23372
|
__privateSet(this, _nextDueAtMillis, now);
|
|
23364
23373
|
__privateSet(this, _preparationPending, true);
|
|
23365
|
-
__privateSet(this,
|
|
23374
|
+
__privateSet(this, _phase2, WorkspaceEffectDeliveryPhase.Apply);
|
|
23366
23375
|
return false;
|
|
23367
23376
|
}
|
|
23368
23377
|
__privateSet(this, _offers, response.outcome.value.offers.filter(
|
|
23369
23378
|
(offer) => offer.route.case === "workspaceRoute" && offer.route.value.workspace === __privateGet(this, _target2).workspace && (__privateGet(this, _command3).sourceCommit === void 0 || offer.sourceCommit === __privateGet(this, _command3).sourceCommit)
|
|
23370
23379
|
));
|
|
23371
|
-
__privateSet(this,
|
|
23380
|
+
__privateSet(this, _phase2, WorkspaceEffectDeliveryPhase.Apply);
|
|
23372
23381
|
return false;
|
|
23373
23382
|
};
|
|
23374
23383
|
acceptApply_fn = function(response, settlement) {
|
|
@@ -23460,7 +23469,7 @@
|
|
|
23460
23469
|
}
|
|
23461
23470
|
};
|
|
23462
23471
|
}
|
|
23463
|
-
__privateSet(this,
|
|
23472
|
+
__privateSet(this, _phase2, WorkspaceEffectDeliveryPhase.Done);
|
|
23464
23473
|
return {
|
|
23465
23474
|
case: "done",
|
|
23466
23475
|
value: create(WorkspaceEffectsDeliveredSchema, {
|
|
@@ -25068,13 +25077,21 @@
|
|
|
25068
25077
|
};
|
|
25069
25078
|
observeSyncResult_fn = function(requestId, workId2, result) {
|
|
25070
25079
|
const timings = result.timings;
|
|
25080
|
+
const receipt = result.offerReceipt?.outcome;
|
|
25081
|
+
const admission = receipt?.case === "admission" ? receipt.value : void 0;
|
|
25071
25082
|
__privateGet(this, _events4).instant("peer.follow.sync-result", {
|
|
25072
25083
|
request: create(RuntimeRequestSchema, { protocolVersion: 2, requestId }),
|
|
25073
25084
|
workspace: result.workspace
|
|
25074
25085
|
}, {
|
|
25075
25086
|
"sync.workId": workId2,
|
|
25076
25087
|
...result.currentHead ? { "sync.head": result.currentHead } : {},
|
|
25088
|
+
...result.previousHead ? { "sync.previousHead": result.previousHead } : {},
|
|
25089
|
+
...admission?.main ? { "sync.providerHead": admission.main } : {},
|
|
25090
|
+
...admission?.sealedMain ? { "sync.sealedHead": admission.sealedMain } : {},
|
|
25077
25091
|
"sync.stillAhead": result.stillAhead,
|
|
25092
|
+
"sync.reconnectRequired": result.reconnectRequired,
|
|
25093
|
+
"sync.refused": result.refused,
|
|
25094
|
+
"sync.deferred": result.deferred,
|
|
25078
25095
|
"sync.directOfferDeferred": result.directOfferDeferred,
|
|
25079
25096
|
"sync.offline": result.offline,
|
|
25080
25097
|
...timings ? {
|