Skip to main content

Mongodb Datastore

@jamesakeech/mongodb-datastorev2026.09.11.1· 1d agoMODELSWORKFLOWSDATASTORES
01README

MongoDB datastore for shared Swamp repositories: namespace-aware sync, managed configuration refresh, atomic remote control plane, distributed locks and content-addressed storage. Fork of @keeb/mongodb-datastore with a companion maintenance model and workflow. Requires a MongoDB replica set.

02Release Notes

First James A. Keech Collective fork of @keeb/mongodb-datastore.

Adds namespace-aware synchronization, managed configuration refresh, and an atomic MongoDB control plane for shared swamp serve instances. Fixes namespaced scoped pulls so serialized writers retain distinct output versions. Preserves namespace dirty journals and lazy hydration state, and protects newer peer data during first-push reconciliation. Rejects ambiguous tenant collection names.

Retains the upstream MIT license and maintenance model/workflow. Swamp core managed model.edit propagation and data.get resolution issues remain outside this extension. Passive runtime queries on another server also remain stale because core does not request runtime refresh when selective pulls are honored. Partition/failover safety is not established by these compatibility tests.

03Models1
@jamesakeech/mongodb-datastore/maintenancev2026.09.11.1maintenance.ts

Global Arguments

ArgumentTypeDescription
uristringMongoDB URI for the cluster backing the datastore (no auth baked in)
usernamestringMongoDB username
passwordstringMongoDB password — supply a vault reference, never a literal
databasestringDatabase shared by all tenants/repos
tenantIdstringTenant identifier; the collection prefix is t_<tenantId>_r_<namespace>
fn inventory(namespaces: array)
Snapshot every namespace in the cluster: live paths, tombstones, blob count, allocated vs reusable bytes, and how long since the last write. Fans out over all namespaces in one execution.
ArgumentTypeDescription
namespacesarrayNamespaces to inspect; empty means every namespace found
fn sweep(namespaces: array, dryRun: boolean, graceMinutes: number, tombstoneDays: number, skipBlobs: boolean, activeIdleHours: number)
Prune tombstones past their grace window and delete blobs no live path references. Fans out over namespaces in one execution. Refuses to sweep blobs in a namespace written recently whose blobs predate the createdAt field, since nothing can distinguish an in-flight push there.
ArgumentTypeDescription
namespacesarrayNamespaces to sweep; empty means every namespace found
dryRunbooleanReport without deleting. Defaults true — opt in to deletion.
graceMinutesnumberSpare blobs created within this many minutes (in-flight pushes)
tombstoneDaysnumberSpare tombstones deleted within this many days. Must exceed the longest gap between any peer's syncs, or a dormant peer resurrects deleted files.
skipBlobsbooleanPrune tombstones only, leaving bytes for a maintenance window
activeIdleHoursnumberA namespace written more recently than this counts as active; its blobs are swept only if they carry createdAt
fn compact(namespaces: array, minReusableMb: number)
Return freed space to the filesystem. Deleting documents only moves space to WiredTiger's free list, so a swept cluster still reports its old size until this runs. Uses force:true, which is required on a replica-set primary and slows concurrent operations — schedule it.
ArgumentTypeDescription
namespacesarrayNamespaces to compact; empty means every namespace found
minReusableMbnumberSkip collections holding less reusable space than this

Resources

inventory(infinite)— Per-namespace size and activity snapshot for the datastore cluster
sweep(infinite)— Result of a tombstone + orphaned-blob sweep
compaction(infinite)— Storage returned to the filesystem by a compact pass. bytesReclaimed is a lower bound — storageSize lags WiredTiger's checkpoint, so a pass that freed space may report 0.
04Workflows1
@jamesakeech/datastore-maintenance75098440-81dd-44e9-9515-5a46f67aca0c

Reclaim space in a MongoDB-backed swamp datastore: snapshot every namespace, prune tombstones past grace and blobs no live path references, then return the freed space to the filesystem. Requires a @jamesakeech/mongodb-datastore/maintenance instance named datastoreMaintenance.

reclaimInventory, sweep, then compact — each step fans out over all namespaces
1.inventorydatastoreMaintenance.inventory— Snapshot per-namespace live paths, tombstones, blob counts, and allocated vs reusable bytes. Runs first so the sweep's effect is measurable against a recorded baseline.
2.sweepdatastoreMaintenance.sweep— Prune tombstones older than the grace window and delete blobs no live path references. dryRun is false here; the method itself still refuses to sweep blobs in a namespace that is actively written and whose blobs predate the createdAt field.
3.compactdatastoreMaintenance.compact— Return freed space to the filesystem. Deleting documents only moves it to WiredTiger's free list, so without this the cluster still reports its pre-sweep size. Depends on sweep because there is nothing to reclaim until the sweep has produced free blocks.
05Datastores1
MongoDBconfigurable
@jamesakeech/mongodb-datastoremongodb/mod.ts

Stores swamp runtime coordination and datastore bytes in MongoDB — distributed locks with TTL + heartbeat + nonce fencing, plus manifest + content-addressed blob sync of the datastore tier between local cache and MongoDB. Blobs over 15MB are transparently chunked across multiple docs so they fit under MongoDB's 16MB BSON limit. Scoped by tenant + repo namespace. Requires MongoDB 4.0+ running as a replica set.

06Stats
B
85 / 100
Downloads
0
Archive size
791.2 KB
  • Has README or module doc2/2earned
  • README has a code example1/1earned
  • README is substantive1/1earned
  • Most symbols documented1/1earned
  • No slow types (deprecated)1/1earned
  • Dependencies pass trust audit2/2earned
  • Has description1/1earned
  • Platform support declared (or universal)2/2earned
  • License declared1/1earned
  • Verified public repository0/2missing
07Platforms
08Labels