Skip to content

Conversation

@Gozala
Copy link
Contributor

@Gozala Gozala commented Jul 10, 2025

Define interfaces per https://linear.app/common-tools/issue/CT-561


Summary by cubic

Added interfaces to support storage subscription capabilities, allowing clients to subscribe to storage notifications for commit, revert, load, pull, and sync events as required by Linear issue CT-561. Also updated related type names for consistency.

@Gozala Gozala requested a review from ubik2 July 15, 2025 17:05
@Gozala Gozala merged commit 1e951e3 into main Jul 15, 2025
7 checks passed
@Gozala Gozala deleted the feat/storage-observer branch July 15, 2025 19:08
// We also update heap so it holds latest record
if (fact) {
this.heap.merge([fact], Replica.update);
this.heap.merge([fact], Replica.put);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's unlikely that we were missing the fact in our heap, so update would usually have the same behavior, but this is more correct (put).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually encountered it in one of the added tests.

const freshFacts = revisions.filter((revision) =>
this.pendingNurseryChanges.get(toKey(revision))?.size ?? 0 === 0
);
this.nursery.merge(freshFacts, Nursery.delete);
Copy link
Contributor

@ubik2 ubik2 Jul 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor issue going from delete on freshFacts to evict on all facts here.
Imagine a counter, where the user presses +,+,-

  • send 1 -- counter shows 1
  • recieve 1
  • send 2 -- counter shows 2
  • send 3 -- counter shows 3
  • send 2 -- counter shows 2
  • receive 2 (the first one)
    • evict: removes from nursery, since they are the same - counter still shows 2
    • freshFacts/delete: doesn't remove from nursery, since it's not fresh - counter still shows 2
  • receive 3
    • evict: thinks it's new - counter goes back to 3 (incorrect)
    • freshFacts/delete: doesn't remove from nursery, since it's not fresh - counter still shows 2
  • receive 2 (second one)
    • evict: thinks it's new - counter goes back to 2 (correct now)
    • freshFacts/delete: removes from nursery, since there's no longer any pending - counter still shows 2

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

evict: removes from nursery, since they are the same - counter still shows 2

It will not because cause will be different so equality check will not pass.

Copy link
Contributor Author

@Gozala Gozala Jul 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably have a test for this scenario though

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right! Thanks

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does still have an issue with two clients and rapid clicks. The evict version leads to a conflict storm where we go up and down in a loop, while the delete version stabilizes.
I'll investigate more to determine why.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants