feat(channel): port couch account channel client from obsidian#16
Merged
Conversation
Transport-agnostic CouchDB replicator (fetch + FileStore + persistence injected): content-addressed doc model, resumable paged pull, token mint/cache, host resolution. Byte-compatible with the obsidian plugin's wire model. Adds 41 tests. Bumps 0.2.0 -> 0.3.0.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Ports the shipped, adversarially-hardened couch sync channel client from the Obsidian plugin (
agentage/obsidian-sync) intomemory-coreas a transport-agnosticsrc/channel/module, so the CLI daemon (and later VS Code) reuse the exact replicator the plugin ships.The wire behavior is a faithful port - the doc model stays byte-compatible with the plugin so the server bridge reassembles either client's writes. Only the runtime edges are adapted to injected seams (no Obsidian, no
node:fs, no HTTP lib).Module (
src/channel/)couch-doc.tsh:<hash>+ filef:<path>docs)couch-token.tsCouchTokenClient- mint/cache the couch JWT, re-mint 60s before expiry,invalidate()couch-state.tsCouchStatePersistencecouch-sync.tsCouchSync- paged pull / bulk push / delete over an injectedFileStore+fetchresolve-host.ts/.well-known/agentage-syncparser +channelForVault(degrades to git)http.tsFetchLikeseam (a host injectsglobalThis.fetch)Injected edges (only deviations from the plugin)
Vault/TFile->FileStore { listMarkdown, read, write, remove }(vault-relative POSIX).requestUrl-> injectedFetchLike.saveData->CouchStatePersistence { load, save }(CLI = JSON file);createCouchState()awaits the async load.window.setTimeoutsuppress-clear -> globalsetTimeout().unref()(isomorphic).Core wire behavior unchanged: missing leaf on pull throws and aborts the page (cursor not advanced), no-op push skips the network,
_bulk_docs {new_edits:false}+PUT f:<path>, 401 -> re-mint + retry once, pending-push queue.Tests
41 new tests (145 total, all green). Includes a byte-for-byte doc-model lock with literal leaf ids/revs cross-checked against the plugin's own test vectors, plus the hardening cases (missing-leaf abort, paged cursor persist, zero-fetch no-op push, rejected-push-not-cached, queue flush, 401 retry, channel degradation).
Release
Bumps
0.2.0 -> 0.3.0(additive minor). Publishes on squash-merge to master via thechore(release)subject.