All Research Tracks
R07 · Web-Native & Modern Applications

Optimistic Concurrency with Client-Side Merge Functions

Offline-first architectures and collaborative editing require conflict resolution beyond simple last-write-wins. By extending SkeinQL with client-supplied merge functions executed in WebAssembly sandboxes, SkeinDB bridges web-native consistency with application-specific conflict resolution — similar to CRDTs but with more flexibility and expressiveness.

Research Proposal — Mapped to backlog in docs/RESEARCH_BACKLOG.md

🔬 What's Novel

🔧 Technical Approach

Phase 1 — Conflict Model

Formalize conflict detection using MVCC + dependency tracking. Model write-write conflicts on same key, read-write dependency violations, and constraint violations as distinct conflict types.

Phase 2 — Merge API

SkeinQL extensions for per-table default merge, per-column merge, and type-specific merge (counters, sets, text). Merge functions receive conflicting versions and produce a resolved version.

Phase 3 — Wasm Integration

Execute merge functions in WebAssembly sandbox with minimal capabilities: read conflicting values and produce output only. No side effects, deterministic execution, bounded time.

Phase 4 — Offline Support

Client-side SDK queuing writes during offline periods. Each write includes expected ETag. On reconnection, the server detects conflicts and invokes registered merge functions.

🧪 Hypotheses

H1

Many real-world write conflicts can be resolved automatically by domain-semantic merge functions without user intervention.

H2

Dependency tracking can identify conflicting writes and invoke merge functions without application-level conflict detection logic.

H3

Wasm merge functions provide sufficient expressiveness for real-world conflict resolution while maintaining security isolation.

🔗 SkeinDB Integration

Wasm Runtime
MVCC Engine
ETag Validators
Dependency Tracking
SkeinQL RPC

📚 Key References