2026-03-14 15:20:30 +00:00
|
|
|
# Project Hints for smartstorage
|
2025-11-23 22:12:29 +00:00
|
|
|
|
2026-03-14 15:20:30 +00:00
|
|
|
## Current State (v6.0.0)
|
2026-02-13 13:59:44 +00:00
|
|
|
|
2026-03-14 15:20:30 +00:00
|
|
|
- **Rust-powered S3-compatible storage server** via `@push.rocks/smartrust` IPC bridge
|
2026-02-13 13:59:44 +00:00
|
|
|
- High-performance: streaming I/O, zero-copy, backpressure, range seek
|
2026-03-14 15:20:30 +00:00
|
|
|
- TypeScript is thin IPC wrapper; all HTTP/storage/routing in Rust binary `ruststorage`
|
2026-02-13 13:59:44 +00:00
|
|
|
- Full S3 compatibility: PUT, GET, HEAD, DELETE for objects and buckets
|
|
|
|
|
- Multipart upload support (streaming, no OOM)
|
2026-02-17 16:28:50 +00:00
|
|
|
- **Real AWS SigV4 authentication** (cryptographic signature verification)
|
|
|
|
|
- **Bucket policies** (AWS/MinIO-compatible JSON policies, public access support)
|
2026-02-13 13:59:44 +00:00
|
|
|
- CORS support
|
|
|
|
|
- ListBuckets, ListObjects (v1/v2), CopyObject
|
2026-04-19 11:57:28 +00:00
|
|
|
- Runtime bucket summaries and storage stats via the Rust bridge (no S3 list scans)
|
|
|
|
|
- Cluster health introspection via the Rust bridge (node membership, local drive probes, quorum, healing state)
|
|
|
|
|
- Runtime credential listing and atomic replacement via the Rust bridge
|
2026-02-13 13:59:44 +00:00
|
|
|
|
|
|
|
|
## Architecture
|
|
|
|
|
|
|
|
|
|
### Rust Binary (`rust/src/`)
|
|
|
|
|
- `main.rs` - Clap CLI, management mode entry
|
2026-02-17 16:28:50 +00:00
|
|
|
- `config.rs` - Serde config structs matching TS interfaces (includes `region`)
|
2026-02-13 13:59:44 +00:00
|
|
|
- `management.rs` - IPC loop (newline-delimited JSON over stdin/stdout)
|
2026-03-14 15:20:30 +00:00
|
|
|
- `server.rs` - hyper 1.x HTTP server, routing, CORS, auth+policy pipeline, all S3-compatible handlers
|
2026-02-17 16:28:50 +00:00
|
|
|
- `storage.rs` - FileStore: filesystem-backed storage, multipart manager, `.policies/` dir
|
2026-04-19 11:57:28 +00:00
|
|
|
- `storage.rs` also owns the runtime stats cache and standalone storage scans used by the bridge stats API
|
2026-03-14 15:20:30 +00:00
|
|
|
- `xml_response.rs` - S3-compatible XML response builders
|
|
|
|
|
- `error.rs` - StorageError codes with HTTP status mapping
|
2026-02-17 16:28:50 +00:00
|
|
|
- `auth.rs` - AWS SigV4 signature verification (HMAC-SHA256, clock skew, constant-time compare)
|
2026-03-14 15:20:30 +00:00
|
|
|
- `action.rs` - StorageAction enum + request-to-IAM-action resolver + RequestContext
|
2026-02-17 16:28:50 +00:00
|
|
|
- `policy.rs` - BucketPolicy model, evaluation engine (Deny > Allow > NoOpinion), PolicyStore (RwLock cache + disk)
|
2026-02-13 13:59:44 +00:00
|
|
|
|
|
|
|
|
### TypeScript Bridge (`ts/`)
|
2026-03-14 15:20:30 +00:00
|
|
|
- `ts/index.ts` - SmartStorage class with RustBridge<TRustStorageCommands>
|
2026-02-13 13:59:44 +00:00
|
|
|
- `ts/plugins.ts` - path, smartpath, RustBridge, tsclass
|
|
|
|
|
- `ts/paths.ts` - packageDir, bucketsDir defaults
|
|
|
|
|
|
|
|
|
|
### IPC Commands
|
|
|
|
|
| Command | Params | Action |
|
|
|
|
|
|---------|--------|--------|
|
2026-03-14 15:20:30 +00:00
|
|
|
| `start` | `{ config: ISmartStorageConfig }` | Init storage + HTTP server |
|
2026-02-13 13:59:44 +00:00
|
|
|
| `stop` | `{}` | Graceful shutdown |
|
|
|
|
|
| `createBucket` | `{ name: string }` | Create bucket directory |
|
2026-04-19 11:57:28 +00:00
|
|
|
| `getStorageStats` | `{}` | Return cached bucket/global runtime stats + storage location capacity snapshots |
|
|
|
|
|
| `listBucketSummaries` | `{}` | Return cached per-bucket runtime summaries |
|
|
|
|
|
| `listCredentials` | `{}` | Return the active runtime auth credential set |
|
|
|
|
|
| `replaceCredentials` | `{ credentials: IStorageCredential[] }` | Atomically replace the runtime auth credential set |
|
|
|
|
|
| `getClusterHealth` | `{}` | Return runtime cluster health or `{ enabled: false }` in standalone mode |
|
2026-02-13 13:59:44 +00:00
|
|
|
|
2026-03-14 15:20:30 +00:00
|
|
|
### Storage Layout
|
|
|
|
|
- Objects: `{root}/{bucket}/{key}._storage_object`
|
|
|
|
|
- Metadata: `{root}/{bucket}/{key}._storage_object.metadata.json`
|
|
|
|
|
- MD5: `{root}/{bucket}/{key}._storage_object.md5`
|
2026-02-13 13:59:44 +00:00
|
|
|
- Multipart: `{root}/.multipart/{upload_id}/part-{N}`
|
2026-02-17 16:28:50 +00:00
|
|
|
- Policies: `{root}/.policies/{bucket}.policy.json`
|
2026-02-13 13:59:44 +00:00
|
|
|
|
|
|
|
|
## Build
|
|
|
|
|
|
2026-04-19 12:22:53 +00:00
|
|
|
- `pnpm build` runs `tsrust && tsbuild tsfolders --allowimplicitany`
|
2026-03-14 15:20:30 +00:00
|
|
|
- `tsrust` compiles Rust to `dist_rust/ruststorage`
|
2026-04-19 12:22:53 +00:00
|
|
|
- Targets: linux_amd64, linux_arm64 (configured in .smartconfig.json)
|
2025-11-23 22:12:29 +00:00
|
|
|
|
|
|
|
|
## Dependencies
|
|
|
|
|
|
2026-02-13 13:59:44 +00:00
|
|
|
- `@push.rocks/smartrust` - RustBridge IPC bridge
|
2025-11-23 22:12:29 +00:00
|
|
|
- `@push.rocks/smartpath` - Path utilities
|
2026-02-13 13:59:44 +00:00
|
|
|
- `@tsclass/tsclass` - IS3Descriptor type
|
|
|
|
|
- `@git.zone/tsrust` (devDep) - Rust cross-compilation
|
2025-11-23 22:12:29 +00:00
|
|
|
|
2026-02-13 13:59:44 +00:00
|
|
|
## Testing
|
2025-11-23 22:12:29 +00:00
|
|
|
|
2026-04-19 11:57:28 +00:00
|
|
|
- `test/test.aws-sdk.node.ts` - AWS SDK v3 compatibility + runtime stats + standalone cluster health coverage (19 tests, auth disabled, port 3337)
|
|
|
|
|
- `test/test.credentials.node.ts` - runtime credential rotation coverage (10 tests, auth enabled, port 3349)
|
|
|
|
|
- `test/test.cluster-health.node.ts` - single-node cluster health coverage (4 tests, S3 port 3348, QUIC port 4348)
|
2026-02-17 16:28:50 +00:00
|
|
|
- `test/test.auth.node.ts` - Auth + bucket policy integration (20 tests, auth enabled, port 3344)
|
|
|
|
|
- `test/test.policy-crud.node.ts` - Policy API CRUD + validation edge cases (17 tests, port 3345)
|
|
|
|
|
- `test/test.policy-eval.node.ts` - Policy evaluation: principals, actions, resources, deny-vs-allow (22 tests, port 3346)
|
|
|
|
|
- `test/test.policy-actions.node.ts` - Per-action policy enforcement (15 tests, port 3347)
|
2026-02-13 13:59:44 +00:00
|
|
|
- `test/test.ts` - SmartBucket integration (3 tests)
|
|
|
|
|
- Run: `pnpm test` or `tstest test/test.aws-sdk.node.ts --verbose`
|