@duraxis/core 0.2.2 → 0.4.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # @duraxis/core changelog
2
2
 
3
+ ## 0.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - a4bed1c: Harden bounded production pilots with hierarchical resource admission, query and transaction deadlines, tracked pending I/O, bounded materialization, weighted caches, incremental listings and journal replay, and verified single-owner garbage collection.
8
+
9
+ Breaking pre-1.0 changes: Core requires bounded-read adapter capabilities; resource limits now reject oversized work; destructive S3 GC fails closed; encrypted expiring v3 cursors replace signed database cursors. Restart pagination and provision stable encryption keys. Tenant context checks strengthen application isolation but do not authorize raw storage access.
10
+
11
+ Add conservative commit reconciliation and bounded atomic idempotency receipts without callback retries. Preserve manifest CAS, physical persistence formats and migration checksum identities. See docs/PRODUCTION-HARDENING.md for defaults, deployment constraints, receipt retention and remaining index/FK accounting limitations.
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies [a4bed1c]
16
+ - @duraxis/storage@0.2.0
17
+
18
+ ## 0.3.0
19
+
20
+ ### Minor Changes
21
+
22
+ - eb56e40: Add transactional collection alteration/removal, final-schema validation, schema-aware index rebuilding, and protected subsystem metadata. Add standalone ORM schema export and opt-in strict managed validation. Introduce the migration runtime and CLI with snapshots, schema comparison, atomic history, conservative rollback, baseline adoption, and recovery-aware publication. Document deployment sequencing and transaction memory limits.
23
+
3
24
  ## 0.2.2
4
25
 
5
26
  ### Patch Changes
package/README.md CHANGED
@@ -49,4 +49,31 @@ O pacote depende somente de `@duraxis/storage` em runtime. Drivers são instalad
49
49
  separadamente. `@duraxis/orm` adiciona entidades e repositórios sobre esta API.
50
50
 
51
51
  Duraxis ainda está em `0.x`. As garantias efetivas dependem do driver; não há coordenação
52
- distribuída, e o formato persistido pode evoluir. Requer Node.js 22.12+.
52
+ distribuída, e o formato persistido pode evoluir. Requer Node.js 24.15.0+.
53
+
54
+ ## Transactional schema evolution
55
+
56
+ Transactions expose `getCollectionDefinitions()`, `alterCollection(name,
57
+ definition)`, `dropCollection(name)`, and streaming `scanCollection(name)`.
58
+ Catalog changes are visible to subsequent transaction operations. Replacement
59
+ validates existing and pending documents against the final schema, including
60
+ foreign keys; indexes rebuild when indexed field definitions change. Collection
61
+ drops remove logical records and index roots while captured snapshots retain
62
+ visibility. Physical deletion remains the garbage collector's responsibility.
63
+ A dropped collection cannot be recreated in the same transaction.
64
+
65
+ Trusted subsystems can use `getMetadata(namespace)` and `putMetadata(namespace,
66
+ bytes)` for protected transactional metadata. Ordinary raw-key writes still
67
+ reject reserved namespaces. This is an explicit internal extension mechanism,
68
+ not access control against code with direct storage access. Metadata uses existing
69
+ primary-tree entries and format-1 manifests. Older Core versions cannot perform
70
+ all full-tree operations on databases containing these new reserved entries;
71
+ upgrade Core before adopting migrations and do not downgrade migrated databases.
72
+
73
+ Affected-schema validation stages final records in memory. Streaming reads do not
74
+ bound transaction memory, and schema-mutated index queries may scan and sort.
75
+ For versioned evolution use [`@duraxis/migrations`](../migrations/README.md).
76
+
77
+ ## Production resource and lifecycle limits
78
+
79
+ See the [production hardening guide](../../docs/PRODUCTION-HARDENING.md) for bounded defaults, cancellation, verified maintenance, tenant trust boundaries, encrypted cursors, upgrade instructions and remaining pilot limitations. Core rejects storage adapters without bounded-read capability; destructive shared-storage garbage collection is unsupported.
@@ -4,9 +4,11 @@ import { StorageKeyManager } from "../security/storage-key-manager.js";
4
4
  export declare class CommitCoordinator {
5
5
  private readonly storage;
6
6
  private readonly keys;
7
+ private readonly coordinationStorage;
7
8
  private readonly primary;
8
9
  private readonly secondary;
9
10
  private readonly foreignKeys;
10
- constructor(storage: StorageDriver, keys?: StorageKeyManager);
11
+ constructor(storage: StorageDriver, keys?: StorageKeyManager, coordinationStorage?: StorageDriver);
11
12
  commit(transaction: Transaction): Promise<void>;
13
+ private publish;
12
14
  }
@@ -1,3 +1,5 @@
1
+ import type { CursorKeyring } from "../query/model/cursor.js";
2
+ import { type ResourceLimits, type ResourceScope } from "../resources/resource-manager.js";
1
3
  import type { StorageDriver } from "@duraxis/storage";
2
4
  import { Transaction } from "../transactions/transaction.js";
3
5
  import type { SnapshotReader } from "../snapshots/snapshot-reader.js";
@@ -12,6 +14,12 @@ export interface DuraxisDatabaseOptions {
12
14
  readonly storage: StorageDriver;
13
15
  readonly namespace?: string;
14
16
  readonly cursorSigningKey?: Uint8Array;
17
+ readonly resources?: Partial<ResourceLimits>;
18
+ readonly cursorEncryption?: CursorKeyring;
19
+ readonly accessScope?: {
20
+ readonly tenant: string;
21
+ readonly currentTenant: () => string | undefined;
22
+ };
15
23
  }
16
24
  export interface CollectionRow {
17
25
  readonly id: string;
@@ -27,25 +35,45 @@ export interface DuraxisMetrics {
27
35
  readonly queryDurationMs: number;
28
36
  readonly garbageCollections: number;
29
37
  readonly garbageCollectionDurationMs: number;
38
+ readonly resources: ReturnType<ResourceScope["metrics"]>;
30
39
  readonly storage?: ReturnType<NonNullable<StorageDriver["getMetrics"]>>;
31
40
  }
32
41
  export declare class DuraxisDatabase {
42
+ readonly resourceLimits: Readonly<ResourceLimits>;
43
+ readonly resources: ResourceScope;
44
+ private readonly cursorEncryption?;
45
+ private readonly accessScope?;
33
46
  private readonly storage;
34
47
  private readonly keys;
35
- private readonly coordinator;
36
- private readonly recovery;
37
- private readonly primary;
38
- private readonly secondary;
39
48
  private readonly cursorSigningKey;
40
49
  private readonly planner;
41
50
  private readonly planCompiler;
42
51
  private readonly metrics;
43
52
  private readonly active;
53
+ private readonly owners;
54
+ private readonly operations;
55
+ private closePromise?;
56
+ private readonly cleanupFailures;
57
+ private readonly outcomes;
58
+ private readonly drainWaiters;
44
59
  private maintenance;
45
60
  private pendingSnapshotAcquisitions;
46
61
  private closed;
47
62
  constructor(options: DuraxisDatabaseOptions);
63
+ get namespace(): string;
64
+ static forTenant(options: Omit<DuraxisDatabaseOptions, "namespace" | "accessScope"> & {
65
+ readonly tenant: string;
66
+ readonly currentTenant: () => string | undefined;
67
+ }): DuraxisDatabase;
68
+ private assertAccess;
48
69
  transaction<T>(callback: (tx: Transaction) => Promise<T> | T): Promise<T>;
70
+ private rememberOutcome;
71
+ resolveCommitOutcome(id: string): Promise<"COMMITTED" | "NOT_COMMITTED" | "UNKNOWN">;
72
+ transactionOnce<T>(operationId: string, callback: (tx: Transaction) => Promise<T> | T): Promise<{
73
+ readonly applied: boolean;
74
+ readonly transactionId: string;
75
+ readonly result?: T;
76
+ }>;
49
77
  snapshot<T>(callback: (reader: SnapshotReader) => Promise<T> | T): Promise<T>;
50
78
  defineCollection(schema: CollectionDefinition): Promise<void>;
51
79
  defineCollections(schemas: readonly CollectionDefinition[]): Promise<void>;
@@ -57,6 +85,10 @@ export declare class DuraxisDatabase {
57
85
  queryPage(query: LogicalQuery, options?: QueryExecutorOptions): Promise<QueryPage>;
58
86
  queryPage(query: LogicalQuery, source: QueryOperator, options?: QueryExecutorOptions): Promise<QueryPage>;
59
87
  queryAll(query: LogicalQuery, options?: QueryExecutorOptions): Promise<readonly QueryRow[]>;
88
+ createMaterializationBudget<T>(): {
89
+ add(value: T): void;
90
+ close(): void;
91
+ };
60
92
  explain(query: LogicalQuery): Promise<ExplainResult>;
61
93
  executePlan(query: LogicalQuery, plan: PhysicalPlan, options?: QueryExecutorOptions): AsyncIterable<QueryRow>;
62
94
  getDocument(collection: string, id: string): Promise<DocumentRecord | null>;
@@ -64,7 +96,6 @@ export declare class DuraxisDatabase {
64
96
  scanCollection(collection: string, limit?: number): Promise<CollectionRow[]>;
65
97
  getCommitStatus(transactionId: string): Promise<import("../recovery/recovery-manager.js").CommitStatus>;
66
98
  verifyHistory(): Promise<number>;
67
- /** Starts a new verifiable commit-history chain without changing data roots. */
68
99
  checkpointHistory(): Promise<string>;
69
100
  verifyIntegrity(): Promise<{
70
101
  objects: number;
@@ -73,6 +104,8 @@ export declare class DuraxisDatabase {
73
104
  commits: number;
74
105
  }>;
75
106
  collectGarbage(storage: StorageDriver, options?: GarbageCollectionOptions): Promise<GarbageCollectionReport>;
107
+ private finishSnapshot;
108
+ private queryContext;
76
109
  private releaseSnapshot;
77
110
  private queryOptions;
78
111
  private bindSignal;
@@ -81,6 +114,7 @@ export declare class DuraxisDatabase {
81
114
  getMetrics(): DuraxisMetrics;
82
115
  close(options?: {
83
116
  readonly closeStorage?: boolean;
117
+ readonly timeoutMs?: number;
84
118
  }): Promise<void>;
85
119
  private createSnapshot;
86
120
  }
@@ -1,3 +1,4 @@
1
+ import { ResourceScope } from "../resources/resource-manager.js";
1
2
  import type { StorageDriver } from "@duraxis/storage";
2
3
  import { type Snapshot } from "../commit/manifest.js";
3
4
  import { StorageKeyManager } from "../security/storage-key-manager.js";
@@ -9,6 +10,8 @@ export interface GarbageCollectionOptions {
9
10
  readonly batchSize?: number;
10
11
  readonly signal?: AbortSignal;
11
12
  readonly continueOnError?: boolean;
13
+ readonly maxMarkBytes?: number;
14
+ readonly maxReferences?: number;
12
15
  }
13
16
  export interface GarbageCollectionReport {
14
17
  readonly scanned: number;
@@ -26,6 +29,7 @@ export declare class GarbageCollector {
26
29
  private readonly keys;
27
30
  private readonly activeSnapshots;
28
31
  private readonly scanner;
29
- constructor(storage: StorageDriver, keys: StorageKeyManager, activeSnapshots: () => readonly Snapshot[], scanner?: ReachabilityScanner);
32
+ private readonly resourceParent;
33
+ constructor(storage: StorageDriver, keys: StorageKeyManager, activeSnapshots: () => readonly Snapshot[], scanner?: ReachabilityScanner, resourceParent?: ResourceScope);
30
34
  collect(options?: GarbageCollectionOptions): Promise<GarbageCollectionReport>;
31
35
  }
@@ -1,13 +1,18 @@
1
1
  import type { StorageDriver } from "@duraxis/storage";
2
2
  import type { Snapshot } from "../commit/manifest.js";
3
3
  import { StorageKeyManager } from "../security/storage-key-manager.js";
4
+ export interface ReachabilityOptions {
5
+ readonly maxReferences?: number;
6
+ readonly maxBytes?: number;
7
+ readonly signal?: AbortSignal;
8
+ }
4
9
  export interface ReachabilityScanner {
5
- scan(snapshot: Snapshot): Promise<ReadonlySet<string>>;
10
+ scan(snapshot: Snapshot, options?: ReachabilityOptions): Promise<ReadonlySet<string>>;
6
11
  }
7
12
  export declare class ManifestReachabilityScanner implements ReachabilityScanner {
8
13
  private readonly keys;
9
14
  private readonly nodes;
10
15
  private readonly primary;
11
16
  constructor(keys: StorageKeyManager, storage: StorageDriver);
12
- scan(snapshot: Snapshot): Promise<ReadonlySet<string>>;
17
+ scan(snapshot: Snapshot, options?: ReachabilityOptions): Promise<ReadonlySet<string>>;
13
18
  }
@@ -0,0 +1,10 @@
1
+ import type { StorageDriver } from "@duraxis/storage";
2
+ import type { Snapshot } from "../commit/manifest.js";
3
+ interface Coordination {
4
+ active: number;
5
+ maintenance: boolean;
6
+ snapshots: Set<Snapshot>;
7
+ }
8
+ export declare function storageCoordination(storage: StorageDriver): Coordination;
9
+ export declare function coordinateCommit<T>(storage: StorageDriver, maximum: number, action: () => Promise<T>): Promise<T>;
10
+ export {};