Skip to content

[DO NOT MERGE]: HSM Sync Engine#69

Open
dtkav wants to merge 590 commits into
mainfrom
merge-hsm
Open

[DO NOT MERGE]: HSM Sync Engine#69
dtkav wants to merge 590 commits into
mainfrom
merge-hsm

Conversation

@dtkav
Copy link
Copy Markdown
Member

@dtkav dtkav commented Feb 19, 2026

No description provided.

@dtkav dtkav force-pushed the merge-hsm branch 2 times, most recently from 27a8e65 to 4554f5d Compare April 2, 2026 04:10
@dtkav dtkav force-pushed the merge-hsm branch 3 times, most recently from 70ef805 to 69aa55e Compare April 11, 2026 09:27
@dtkav dtkav force-pushed the merge-hsm branch 4 times, most recently from c3e08d6 to 139bf8c Compare April 21, 2026 00:36
dtkav added 6 commits April 21, 2026 17:05
initializeWithContent returns false when content was enrolled by the
editor (race between uploadDoc and acquireLock). The file still needs
syncing and publishing to the syncStore for cross-vault propagation.

Also clears pendingUpload in deleteFile.
classifyUpdate deduplicates via tracked state vectors, making the
user-based filter redundant. The server can also mislabel the user
on the event, making user-based filtering unreliable.
@dtkav dtkav force-pushed the merge-hsm branch 2 times, most recently from 696e3e4 to 173702c Compare April 25, 2026 08:25
dtkav and others added 12 commits April 25, 2026 23:31
initializeFromRemote now only enrolls CRDT bytes and sets the state
vector. LCA is the caller's responsibility via the new setLCA method.
downloadDoc calls setLCA after flushing to disk. GUID remap does not
set LCA (disk may differ from remote).
baseStart/baseEnd from diff3 are token indices, not line numbers.
The line-map lookup produced wrong positions. String search for
oursContent in localContent is reliable for unique hunk text.
Mark .system3-announcement-banner and .system3-announcement as :global()
since they target elements outside the Svelte component scope.
Replace @media prefers-color-scheme blocks with color-mix() using
Obsidian theme variables. Fixes diff colors when OS and Obsidian
theme modes differ.
Canvas created an IndexeddbPersistence but never called destroy() on
it, leaking the IDB connection. Match the SharedFolder teardown
pattern: destroy persistence and capture the async flush with
awaitOnReload.
Forward-slash separators in transformIgnorePatterns and transform
keys don't match Windows backslash paths. Use [\\/] to match both.
PromiseTracker maintains both a map of pending promises (per-instance)
and a module-level ring buffer of the last 100 settled promises. The
ring buffer survives plugin reload so completed promises from a prior
instance stay inspectable after disable+GC.

Tracked entries carry an optional owner tag. The plugin's tracker uses
plugin:<instanceId> as its default owner so retained Live shells can be
correlated with the lifecycle promises that captured them.

Wired up lifecycle hooks:
- the plugin onload() itself is tracked as plugin:onload:<instanceId>
- awaitOnReload() accepts an optional label and the hsmStore teardown
  uses it, surfacing stuck unload work with the instance id

In non-debug builds track() is a passthrough - no map entries, no .then()
chain, no overhead.

Exposed via __relayDebug.getPendingPromises() and getRecentPromises().
Call sites for trackPromise() will be added in a follow-up commit.
The sync flag was only set to true and never cleared. On reconnection,
stale `true` was observed and dependent code treated a freshly-reopened
connection as already-synced, leading to races where data was read
before the new sync completed.

Clear on explicit disconnect() and on any provider state transition
away from "connected".
…d matches

setMeta unconditionally cleared pendingUpload[vpath] if the path had any
pending entry — even when the incoming meta described a different document
at that path (GUID remap case). This could drop the pending-upload tracking
for the local doc whose upload had not yet completed.

Clear only when pendingUpload's stored guid matches the incoming meta.id.
…t promises

Two related issues in the sync and download queues:

- Queued items whose doc was destroyed sat in the queue indefinitely.
  Evict them at the top of processSyncQueue / processDownloadQueue,
  reject their completion callbacks with "Document destroyed", and
  drop the inProgress entries.

- Duplicate enqueue calls created new pending promises every time, with
  no way to await work already in flight. Track the original Promise
  per guid in new syncPromises / downloadPromises maps so repeated
  enqueue calls share it. Clear the map on resolve/reject and on
  destroy.
@dtkav dtkav force-pushed the main branch 2 times, most recently from ba684d2 to c1362e9 Compare May 20, 2026 21:30
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.

3 participants