Repository navigation
Add SubjectMetadataController - #61
Conversation
|
Update: The permission controller has been merged, and we're not going to implement |
8e3db4a to
04bad9b
Compare
2339f04 to
1e22d47
Compare
6c6562d to
5c059b0
Compare
dac2e7b to
33ea7e2
Compare
6321637 to
828cf30
Compare
21edcf9 to
30cfa77
Compare
32353db to
21eb94c
Compare
5c059b0 to
0f95120
Compare
8484b4e to
9356a65
Compare
6a08b84 to
9d9ac05
Compare
0b67125 to
fe2ef0e
Compare
9d9ac05 to
c81ae20
Compare
9506ac7 to
ad34223
Compare
c81ae20 to
59ec623
Compare
fcc2062 to
4df1d36
Compare
7a16930 to
b05fd11
Compare
b05fd11 to
c79e82e
Compare
c79e82e to
ec614c6
Compare
| .values() | ||
| .next().value; | ||
|
|
||
| this.subjectsEncounteredSinceStartup.delete(cachedOrigin); |
There was a problem hiding this comment.
So wait.... we're removing the origin from this list, even if we want to preserve the metadata? Why would we let these two data sets get out of sync like that?
There was a problem hiding this comment.
I see that the existing subject metadata controller works basically the same way, and it seems like a bug there as well.
There was a problem hiding this comment.
No, this is intentional. If a subject encountered since startup has permissions, the current implementation essentially says "screw it, if permissions are ever removed for this subject, we'll let the next subsequent call to trimMetadataState remove it". That'll likely occur at the next reboot of the extension, and that should be good enough for our purposes.
There was a problem hiding this comment.
But why keep it around indefinitely if we don't need to? I don't see the advantage to doing this.
If we keep these two collections in sync, and only remove from the set when we remove the actual metadata, we can be confident that the trimming will work correctly and remove any excess metadata without associated permissions. As things stand now it could grow unbounded until the next reset.
There was a problem hiding this comment.
As things stand now it could grow unbounded until the next reset.
Yes, but since it's been working like this for ~two years, we can be confident that it doesn't grow out of control in practice. The next reset will be no later than the next update, and our update frequency is if anything going to increase as opposed to decrease. As for users that don't update or restart their browsers, I think that's out of scope.
If if we were to implement your suggestion, unbounded growth is still theoretically possible since we never delete metadata for subjects with permissions under any circumstance.
But why keep it around indefinitely if we don't need to? I don't see the advantage to doing this.
There are advantages, though! In your suggested implementation, we would have to iterate over the entire since-startup set if it's larger than the cache limit, check the permissions of each subject, and delete the first one we find without permissions. The unlucky case here is that the user adds permissions to every subject they encounter. In that case, there will eventually be a computational cost to performing this iteration every time the user visits a new website.
In addition, changing how this work can result in a degraded user experience. Consider again the case where the user adds permissions to every subject under your suggested implementation. Let's say, after hitting the cache limit, they visit a new website. By the time we receive a permissions request from that website, its metadata will have been deleted. The only way to add metadata for it and any subsequent new websites would be to accept the request (without metadata) and refresh the page.
This brings me to the final advantage, which is that improving the existing implementation is more complicated than it seems, and probably not worth our time given that the existing implementation demonstrably works in practice. I think the real solution to this problem is to be able to request metadata on demand, which requires the series of changes to json-rpc-engine we've discussed in the past.
There was a problem hiding this comment.
Consider again the case where the user adds permissions to every subject under your suggested implementation. Let's say, after hitting the cache limit, they visit a new website. By the time we receive a permissions request from that website, its metadata will have been deleted. The only way to add metadata for it and any subsequent new websites would be to accept the request (without metadata) and refresh the page.
Ok, fair enough, that makes sense. I still don't like the idea of letting it grow unbounded, and I do not accept the last two years as evidence that this isn't a problem (that does not follow). But you are right that my suggestion is bad and this is more complicated than I thought.
Could we at least rename the variable though? I expected subjectsEncounteredSinceStartup to be the subjects encountered since startup, and was very surprised to find that it was not that at all. Maybe something like subjectsWithoutPermissionsEcounteredSinceStartup? It's absurdly long but it's clear at least. Or subjectsEncounteredWithoutPermissions, since "since startup" is implied as this can't be persisted.
…oller.ts Co-authored-by: Mark Stacey <markjstacey@gmail.com>
7373a36 to
7a5aa3d
Compare
ec6a216 to
62a6af4
Compare
The extension permission metadata functionality is currently housed within its local permissions controller. This PR extracts this functionality into a new "subject" (previously known as "domain") metadata controller, per the extension implementation.