@push.rocks/smartdb 2.5.9 → 2.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@push.rocks/smartdb",
3
- "version": "2.5.9",
3
+ "version": "2.6.2",
4
4
  "private": false,
5
5
  "description": "A MongoDB-compatible embedded database server with wire protocol support, backed by a high-performance Rust engine.",
6
6
  "exports": {
package/readme.md CHANGED
@@ -44,38 +44,38 @@ SmartDB uses a **sidecar binary** pattern — TypeScript handles lifecycle, Rust
44
44
 
45
45
  ```
46
46
  ┌──────────────────────────────────────────────────────────────┐
47
- │ Your Application
48
- │ (TypeScript / Node.js)
49
- ┌─────────────────┐ ┌───────────────────────────┐
50
- │ │ SmartdbServer │────▶│ RustDbBridge (IPC) │
51
- │ │ or LocalSmartDb │ │ @push.rocks/smartrust │
52
- └─────────────────┘ └───────────┬───────────────┘
53
- └──────────────────────────────────────┼───────────────────────┘
54
- │ spawn + JSON IPC
55
-
47
+ │ Your Application
48
+ │ (TypeScript / Node.js)
49
+ ┌──────────────────┐ ┌───────────────────────────┐
50
+ │ │ SmartdbServer │─────▶│ RustDbBridge (IPC) │
51
+ │ │ or LocalSmartDb │ │ @push.rocks/smartrust │
52
+ └──────────────────┘ └───────────┬───────────────┘
53
+ └────────────────────────────────────────┼─────────────────────┘
54
+ │ spawn + JSON IPC
55
+
56
56
  ┌──────────────────────────────────────────────────────────────┐
57
- │ rustdb binary 🦀
57
+ │ rustdb binary
58
58
  │ │
59
- │ ┌──────────────┐ ┌──────────────┐ ┌───────────────┐
60
- │ │ Wire Protocol│→ │Command Router│→ │ Handlers │
61
- │ │ (OP_MSG) │ │ (40+ cmds) │ │ Find,Insert.. │
62
- │ └──────────────┘ └──────────────┘ └───────┬───────┘
63
-
64
- │ ┌─────────┐ ┌────────┐ ┌───────────┐ ┌──────┴──────┐
65
- │ │ Query │ │ Update │ │Aggregation│ │ Index │
66
- │ │ Matcher │ │ Engine │ │ Engine │ │ Engine │
67
- │ └─────────┘ └────────┘ └───────────┘ └─────────────┘
59
+ │ ┌──────────────┐ ┌──────────────┐ ┌───────────────┐
60
+ │ │ Wire Protocol│→ │Command Router│→ │ Handlers │
61
+ │ │ (OP_MSG) │ │ (40+ cmds) │ │ Find,Insert.. │
62
+ │ └──────────────┘ └──────────────┘ └───────┬───────┘
63
+
64
+ │ ┌─────────┐ ┌────────┐ ┌───────────┐ ┌──────┴──────┐
65
+ │ │ Query │ │ Update │ │Aggregation│ │ Index │
66
+ │ │ Matcher │ │ Engine │ │ Engine │ │ Engine │
67
+ │ └─────────┘ └────────┘ └───────────┘ └─────────────┘
68
68
  │ │
69
- │ ┌──────────────────┐ ┌──────────────────┐ ┌──────────┐
70
- │ │ MemoryStorage │ │ FileStorage │ │ OpLog │
71
- │ └──────────────────┘ └──────────────────┘ └──────────┘
69
+ │ ┌──────────────────┐ ┌──────────────────┐ ┌──────────┐
70
+ │ │ MemoryStorage │ │ FileStorage │ │ OpLog │
71
+ │ └──────────────────┘ └──────────────────┘ └──────────┘
72
72
  └──────────────────────────────────────────────────────────────┘
73
73
 
74
74
  │ TCP / Unix Socket (wire protocol)
75
75
 
76
76
  ┌─────────────┴────────────────────────────────────────────────┐
77
- │ MongoClient (mongodb npm driver)
78
- │ Connects directly to Rust binary
77
+ │ MongoClient (mongodb npm driver)
78
+ │ Connects directly to Rust binary
79
79
  └──────────────────────────────────────────────────────────────┘
80
80
  ```
81
81
 
@@ -429,6 +429,8 @@ await collection.dropIndex('email_1');
429
429
  await collection.dropIndexes(); // drop all except _id
430
430
  ```
431
431
 
432
+ > 🛡️ **Unique indexes are enforced at the engine level.** Duplicate values are rejected with a `DuplicateKey` error (code 11000) *before* the document is written to disk — on `insertOne`, `updateOne`, `findAndModify`, and upserts. Index definitions are persisted to `indexes.json` and automatically restored on restart.
433
+
432
434
  ### Database & Admin
433
435
 
434
436
  ```typescript
@@ -497,6 +499,39 @@ The Rust engine is organized as a Cargo workspace with 8 focused crates:
497
499
 
498
500
  Cross-compiled for `linux_amd64` and `linux_arm64` via [@git.zone/tsrust](https://www.npmjs.com/package/@git.zone/tsrust).
499
501
 
502
+ ### Storage Engine Reliability 🔒
503
+
504
+ The Bitcask-style file storage engine includes several reliability features:
505
+
506
+ - **Write-ahead log (WAL)** — every write is logged before being applied, with crash recovery on restart
507
+ - **CRC32 checksums** — every record is integrity-checked on read
508
+ - **Automatic compaction** — dead records are reclaimed when they exceed 50% of file size, runs on startup and after every write
509
+ - **Hint file staleness detection** — the hint file records the data file size at write time; if data.rdb changed since (e.g. crash after a delete), the engine falls back to a full scan to ensure tombstones are not lost
510
+ - **Stale socket cleanup** — orphaned `/tmp/smartdb-*.sock` files from crashed instances are automatically cleaned up on startup
511
+
512
+ ### Data Integrity CLI 🔍
513
+
514
+ The Rust binary includes an offline integrity checker:
515
+
516
+ ```bash
517
+ # Check all collections in a data directory
518
+ ./dist_rust/rustdb_linux_amd64 --validate-data /path/to/data
519
+
520
+ # Output:
521
+ # === SmartDB Data Integrity Report ===
522
+ #
523
+ # Database: mydb
524
+ # Collection: users
525
+ # Header: OK
526
+ # Records: 1,234 (1,200 live, 34 tombstones)
527
+ # Data size: 2.1 MB
528
+ # Duplicates: 0
529
+ # CRC errors: 0
530
+ # Hint file: OK
531
+ ```
532
+
533
+ Checks file headers, record CRC32 checksums, duplicate `_id` entries, and hint file consistency. Exit code 1 if any errors are found.
534
+
500
535
  ---
501
536
 
502
537
  ## Testing Example
@@ -541,7 +576,7 @@ export default tap.start();
541
576
 
542
577
  ## License and Legal Information
543
578
 
544
- This repository contains open-source code licensed under the MIT License. A copy of the license can be found in the [LICENSE](./LICENSE) file.
579
+ This repository contains open-source code licensed under the MIT License. A copy of the license can be found in the [license](./license) file.
545
580
 
546
581
  **Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
547
582
 
@@ -3,6 +3,6 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@push.rocks/smartdb',
6
- version: '2.5.9',
6
+ version: '2.6.2',
7
7
  description: 'A MongoDB-compatible embedded database server with wire protocol support, backed by a high-performance Rust engine.'
8
8
  }