Add storage stack modules and track them in git

The modules workspace previously ignored every path matching `storage-*`,
which kept all Hypercore, Hyperbee, Hyperdrive, and Autobase packages out
of version control. Narrow .gitignore to test-artifact patterns only so
production category trees are committed.

Storage packages (23 total):
- storage-hypercore (7): replicator, seed-policy, fork-picker, merkle-sync,
  priority-fetch, bitfield-scheduler, audit-chain
- storage-hyperbee (5): batch-write, diff-follow, range-watch,
  secondary-index, tombstone-gc
- storage-hyperdrive (6): entry-catalog, gc-sweep, mirror-sync, mount-bridge,
  version-snapshot, watch-notify
- storage-autobase (5): fork-choice, view-sync, writer-lease, indexer-bus,
  light-writer

Implementation highlights:
- Shared attach/gossip helpers in _shared/storage-gossip-base.js
- P2P modules use Protomux gossip via p2p-bare; local planners omit swarm
- Recent deepen pass: priority queues, batch caps, audit export/import,
  watch/notify aliases on range-watch, fork/view lease helpers, etc.
- Per-package README, docs/api.md, docs/architecture.md, tests, examples

Also update modules/README.md doc hub links for the full storage stack
(hypercore, hyperbee, hyperdrive, autobase).

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
Raven Scott
2026-05-21 00:17:51 -04:00
co-authored by Cursor
parent b10507b060
commit a11e22badc
214 changed files with 57132 additions and 5 deletions
@@ -0,0 +1,120 @@
# API: hyper-p2p-bee-tombstone-gc
**Protocol:** `bee-tombstone-gc/v1`
**Export:** `HyperP2PBeeTombstoneGc`
## Overview
Soft-delete tombstones with time-based `gcSweep`; pair with `hyper-p2p-temporal-index` when retention policies are time-ordered.
## Constructor
```js
const mod = new HyperP2PBeeTombstoneGc(opts)
```
| Option | Type | Default | Description |
|--------|------|---------|-------------|
| `bee` | object \| null | null | Attached bee instance (`attach()` also supported) |
## Methods
### `attach(…)`
- **Returns:** module-specific (see implementation)
- **Throws:** — (none in method body)
### `tombstone(…)`
- **Returns:** module-specific (see implementation)
- **Throws:**
- `Error: key required`
### `gcSweep(…)`
- **Returns:** module-specific (see implementation)
- **Throws:**
- `Error: olderThanMs must be non-negative`
### `listTombstones(…)`
- **Returns:** module-specific (see implementation)
- **Throws:** — (none in method body)
### `restore(…)`
- **Returns:** module-specific (see implementation)
- **Throws:** — (none in method body)
### `pendingTombstones(…)`
- **Returns:** module-specific (see implementation)
- **Throws:** — (none in method body)
### `getStats(…)`
- **Returns:** module-specific (see implementation)
- **Throws:** — (none in method body)
### `ready(…)`
- **Returns:** module-specific (see implementation)
- **Throws:** — (none in method body)
### `close(…)`
- **Returns:** module-specific (see implementation)
- **Throws:** — (none in method body)
## Events
| Event | Payload |
|-------|---------|
| `tombstone` | `{ key }` |
| `sweep` | `{ removed }` |
| `restore` | `{ key }` |
| `closed` | no payload |
## getStats()
Returns `{ ...this._stats, protocol }` plus module-specific counters (pending queues, registry sizes, gossip in/out when P2P).
Local modules report hot-path counters only; P2P modules include gossip traffic when `topic` is set.
## Errors
Stable message substrings: see [`../../_shared/ERROR_CODES.md`](../../_shared/ERROR_CODES.md).
Validation helpers may throw `ValidationError` (e.g. `peer is required`, `path is required`).
### Documented `throw new Error(...)` strings
- `key required`
- `olderThanMs must be non-negative`
## P2P
Library-only: no swarm join. `ready()` resolves immediately.
`getStats().protocol` still reports the module protocol id for logging.
## Testing
```bash
npm install && npm test
```
## Common flows
1. `tombstone(key, meta)` — mark pending delete.
2. `gcSweep(olderThanMs)` — purge expired tombstones.
3. `restore(key)` — cancel tombstone before sweep.
@@ -0,0 +1,26 @@
# Architecture: hyper-p2p-bee-tombstone-gc
**Protocol:** `bee-tombstone-gc/v1` · **P2P:** no
## Role
Soft-delete registry: mark keys tombstoned, sweep after `olderThanMs`, optional `restore`.
## State
`Map<key, { at, meta }>`
## Methods
| Method | Effect |
|--------|--------|
| `tombstone(key, meta?)` | Mark deleted |
| `isTombstoned(key)` | Query |
| `gcSweep(olderThanMs)` | Remove stale entries |
| `listTombstones` / `restore` | Admin |
## Events
`tombstone`, `sweep`, `restore`, `closed`
Run physical `bee.del` in your app after sweep returns keys.