capdag 1.266.66 → 1.306.150
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/capdag.js +21 -0
- package/capdag.test.js +36 -0
- package/package.json +1 -1
package/capdag.js
CHANGED
|
@@ -5707,6 +5707,27 @@ class RegistryVerdict {
|
|
|
5707
5707
|
return registryVerdictPermitsAttachment(this.state);
|
|
5708
5708
|
}
|
|
5709
5709
|
|
|
5710
|
+
/**
|
|
5711
|
+
* WHETHER TWO VERDICTS SAY THE SAME THING ABOUT THE REGISTRY.
|
|
5712
|
+
*
|
|
5713
|
+
* Not a deep-equality check. A verdict carries `checked_at_unix_seconds`,
|
|
5714
|
+
* which is provenance about the CHECK and not about the registry — so a
|
|
5715
|
+
* consumer asking "did this change?" by comparing whole verdicts is told yes
|
|
5716
|
+
* on every re-check, forever. Both desktop clients asked exactly that to
|
|
5717
|
+
* decide whether to re-run cartridge discovery, and the answer drove a loop
|
|
5718
|
+
* that left the engine discovering cartridges and never reaching ready.
|
|
5719
|
+
*/
|
|
5720
|
+
statesTheSameAs(other) {
|
|
5721
|
+
if (!(other instanceof RegistryVerdict)) {
|
|
5722
|
+
throw new Error('statesTheSameAs compares two registry verdicts');
|
|
5723
|
+
}
|
|
5724
|
+
return this.registry_url === other.registry_url
|
|
5725
|
+
&& this.state === other.state
|
|
5726
|
+
&& this.detail === other.detail
|
|
5727
|
+
&& this.http_status === other.http_status
|
|
5728
|
+
&& this.chain_failure === other.chain_failure;
|
|
5729
|
+
}
|
|
5730
|
+
|
|
5710
5731
|
toJSON() {
|
|
5711
5732
|
return {
|
|
5712
5733
|
registry_url: this.registry_url,
|
package/capdag.test.js
CHANGED
|
@@ -7472,6 +7472,7 @@ async function runTests() {
|
|
|
7472
7472
|
runTest('TEST8153: trust_failures_never_transient', test8153_trustFailuresAreNeverTransient);
|
|
7473
7473
|
runTest('TEST8154: contradictory_verdicts_refused', test8154_contradictoryVerdictsAreRefused);
|
|
7474
7474
|
runTest('TEST8159: remedy_follows_from_state', test8159_theRemedyFollowsFromTheState);
|
|
7475
|
+
runTest('TEST8162: a_verdict_says_the_same_thing_at_a_different_time', test8162_aVerdictSaysTheSameThingAtADifferentTime);
|
|
7475
7476
|
runTest('TEST8155: registry_verdict_wire_round_trip', test8155_registryVerdictWireRoundTrip);
|
|
7476
7477
|
runTest('TEST8157: signature_formats_from_library', test8157_signatureFormatDiscriminatorsComeFromTheLibrary);
|
|
7477
7478
|
runTest('TEST8158: attachment_kinds_separate_situations', test8158_attachmentKindsSeparateTheirSituations);
|
|
@@ -7824,6 +7825,41 @@ function test8153_trustFailuresAreNeverTransient() {
|
|
|
7824
7825
|
assert(!registryVerdictIsTrustFailure(RegistryVerdictState.OFFLINE));
|
|
7825
7826
|
}
|
|
7826
7827
|
|
|
7828
|
+
/** TEST8162: WHEN IS A VERDICT NEWS? Both desktop clients re-verify their
|
|
7829
|
+
* registries after every discovery round and re-run discovery when the
|
|
7830
|
+
* verdicts "changed". Change had to mean "the registry said something
|
|
7831
|
+
* different", and comparing whole verdicts cannot mean that: they carry the
|
|
7832
|
+
* moment of the check, so the same answer taken a second later is a different
|
|
7833
|
+
* value. That is the loop that left an engine discovering cartridges forever. */
|
|
7834
|
+
function test8162_aVerdictSaysTheSameThingAtADifferentTime() {
|
|
7835
|
+
const earlier = RegistryVerdict.verified('https://r.example', 1756000000);
|
|
7836
|
+
const later = RegistryVerdict.verified('https://r.example', 1756000931);
|
|
7837
|
+
assert(
|
|
7838
|
+
JSON.stringify(earlier.toJSON()) !== JSON.stringify(later.toJSON()),
|
|
7839
|
+
'they are not the same value — one is a later check',
|
|
7840
|
+
);
|
|
7841
|
+
assert(earlier.statesTheSameAs(later), 'but they say the same thing about the registry');
|
|
7842
|
+
|
|
7843
|
+
for (const differing of [
|
|
7844
|
+
RegistryVerdict.stated('https://r.example', RegistryVerdictState.UNREACHABLE, 'connection timed out', 1756000000),
|
|
7845
|
+
RegistryVerdict.httpError('https://r.example', 503, 'the registry answered HTTP 503', 1756000000),
|
|
7846
|
+
RegistryVerdict.chainFailed('https://r.example', ChainFailureReason.MANIFEST_SIGNATURE_INVALID, 'signature does not verify', 1756000000),
|
|
7847
|
+
RegistryVerdict.verified('https://other.example/manifest', 1756000000),
|
|
7848
|
+
]) {
|
|
7849
|
+
assert(!earlier.statesTheSameAs(differing), `${differing.state} is a different statement about the registry`);
|
|
7850
|
+
}
|
|
7851
|
+
|
|
7852
|
+
// 404 and 503 are different situations with different remedies.
|
|
7853
|
+
assert(
|
|
7854
|
+
!RegistryVerdict.httpError('https://r.example', 404, 'the registry answered HTTP 404', 1756000000)
|
|
7855
|
+
.statesTheSameAs(RegistryVerdict.httpError('https://r.example', 503, 'the registry answered HTTP 503', 1756000000)),
|
|
7856
|
+
'404 and 503 are different situations with different remedies',
|
|
7857
|
+
);
|
|
7858
|
+
|
|
7859
|
+
assertRefuses(() => earlier.statesTheSameAs({ state: 'verified' }),
|
|
7860
|
+
/compares two registry verdicts/, 'a bare object is not a verdict');
|
|
7861
|
+
}
|
|
7862
|
+
|
|
7827
7863
|
/** TEST8159: the remedy follows from the state, and "check the network" is
|
|
7828
7864
|
* reachable from exactly one state. That sentence used to be appended to every
|
|
7829
7865
|
* held-cartridge message whatever the cause, which is how a signature format a
|
package/package.json
CHANGED