@gusto/baerly-storage 0.1.2 → 0.3.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/LICENSE +202 -0
- package/NOTICE +29 -0
- package/README.md +108 -44
- package/dist/API.md +192 -121
- package/dist/CHANGELOG.md +144 -0
- package/dist/THIRD-PARTY-LICENSES.txt +312 -0
- package/dist/{app-config-C0Bbw_Z6.d.ts → app-config-BIzyAKzy.d.ts} +14 -2
- package/dist/app-config.d.ts +1 -1
- package/dist/auth.d.ts +1 -1
- package/dist/auth.js +288 -288
- package/dist/auth.js.map +1 -1
- package/dist/baerly.js +10 -10
- package/dist/baerly.js.map +1 -1
- package/dist/bytes-BXdamO3L.js.map +1 -1
- package/dist/{client-DYZfoZb9.d.ts → client-BJXF3XJA.d.ts} +10 -10
- package/dist/client-react.d.ts +76 -85
- package/dist/client-react.js +95 -53
- package/dist/client-react.js.map +1 -1
- package/dist/client.d.ts +3 -3
- package/dist/client.js.map +1 -1
- package/dist/{cloudflare-CINJPKCW.js → cloudflare-Cn2ibODt.js} +178 -2
- package/dist/cloudflare-Cn2ibODt.js.map +1 -0
- package/dist/cloudflare.d.ts +4 -4
- package/dist/cloudflare.js +10 -11
- package/dist/cloudflare.js.map +1 -1
- package/dist/{subcommand-DZcHcsYp.js → config-CGyBopy3.js} +643 -439
- package/dist/config-CGyBopy3.js.map +1 -0
- package/dist/context-DRZ3tZ5l.js.map +1 -1
- package/dist/{cost-CQt1YRkA.js → cost-BZ_MDBmn.js} +6 -4
- package/dist/cost-BZ_MDBmn.js.map +1 -0
- package/dist/{current-json-C-EyJqs0.js → current-json-DsN7FNY1.js} +47 -13
- package/dist/current-json-DsN7FNY1.js.map +1 -0
- package/dist/{db-BM3y2JQw.d.ts → db-CCT6tDfY.d.ts} +26 -108
- package/dist/{deploy-CrAbfgCq.js → deploy-BKKyGlSJ.js} +11 -4
- package/dist/deploy-BKKyGlSJ.js.map +1 -0
- package/dist/dev-vite.d.ts +5 -5
- package/dist/dev-vite.js +5 -5
- package/dist/dev-vite.js.map +1 -1
- package/dist/dev.d.ts +1 -1
- package/dist/dev.js +1 -1
- package/dist/{doctor-Db-hzPmE.js → doctor-BVU4GNXN.js} +13 -132
- package/dist/doctor-BVU4GNXN.js.map +1 -0
- package/dist/{dump-BYA55NLP.js → dump-DPEAKub6.js} +5 -3
- package/dist/dump-DPEAKub6.js.map +1 -0
- package/dist/errors-DOdL95kK.js.map +1 -1
- package/dist/{export-Bhbz90-z.js → export-BcuCLFFe.js} +6 -4
- package/dist/{export-Bhbz90-z.js.map → export-BcuCLFFe.js.map} +1 -1
- package/dist/{fsck-CPPZWt9p.js → fsck-RXgLOaJG.js} +23 -11
- package/dist/fsck-RXgLOaJG.js.map +1 -0
- package/dist/{http-Cw8p6y5b.js → http-Bd4byR4n.js} +45 -61
- package/dist/http-Bd4byR4n.js.map +1 -0
- package/dist/http.d.ts +15 -15
- package/dist/http.js +1 -1
- package/dist/{index-cUY-36AN.d.ts → index-BDceQQi-.d.ts} +20 -4
- package/dist/{index-C3JAH1Yo.d.ts → index-Cmsxx-ZN.d.ts} +9 -9
- package/dist/{index-DSvwEUeF.d.ts → index-DW7GT6M2.d.ts} +50 -42
- package/dist/{index-DwDTWPSU.d.ts → index-DnBGSeuU.d.ts} +10 -7
- package/dist/index.d.ts +6 -6
- package/dist/index.js +4 -4
- package/dist/{indexes-DAu2AkTW.d.ts → indexes-Cx7uMXm0.d.ts} +2 -2
- package/dist/{inspect-Bdbzvi-_.js → inspect-DhI49PSi.js} +16 -8
- package/dist/inspect-DhI49PSi.js.map +1 -0
- package/dist/{snapshot-SS8USDUF.js → log-tail-DXeDkWEp.js} +154 -83
- package/dist/log-tail-DXeDkWEp.js.map +1 -0
- package/dist/{maintenance-BRrThz8V.d.ts → maintenance-BkhUr72A.d.ts} +91 -26
- package/dist/{maintenance-ClzBC1Vv.js → maintenance-CWBQpZ2y.js} +368 -161
- package/dist/maintenance-CWBQpZ2y.js.map +1 -0
- package/dist/{maintenance-BvOv6BMM.js → maintenance-C_KSkVjd.js} +204 -82
- package/dist/maintenance-C_KSkVjd.js.map +1 -0
- package/dist/maintenance.d.ts +3 -2
- package/dist/maintenance.js +3 -2
- package/dist/node.d.ts +13 -8
- package/dist/node.js +1 -1
- package/dist/normalize-XWY25_sG.js.map +1 -1
- package/dist/{observability-CpOiEN0k.js → observability-BYd-RzEx.js} +63 -55
- package/dist/observability-BYd-RzEx.js.map +1 -0
- package/dist/observability.d.ts +3 -3
- package/dist/observability.js +1 -1
- package/dist/{plan-DOTl21vq.js → plan-DIu_B6fy.js} +7 -4
- package/dist/plan-DIu_B6fy.js.map +1 -0
- package/dist/{query-BmiQy328.js → query-sQNO5vU_.js} +1071 -1099
- package/dist/query-sQNO5vU_.js.map +1 -0
- package/dist/{rebuild-index-DC_nR6wP.js → rebuild-index-DP4CqSSs.js} +5 -4
- package/dist/rebuild-index-DP4CqSSs.js.map +1 -0
- package/dist/{restore-C6IcmLeA.js → restore-DpQYef6r.js} +362 -328
- package/dist/restore-DpQYef6r.js.map +1 -0
- package/dist/shared-secret-BJdSwpgw.js.map +1 -1
- package/dist/{src-QQ7jDeL2.js → src-CWpkSbvJ.js} +40 -20
- package/dist/src-CWpkSbvJ.js.map +1 -0
- package/dist/{src-DU1sCMlr.js → src-D24wDpzR.js} +269 -258
- package/dist/src-D24wDpzR.js.map +1 -0
- package/dist/{src-zhEAmmF7.js → src-Db4-qVtM.js} +36 -96
- package/dist/src-Db4-qVtM.js.map +1 -0
- package/dist/subcommand-CP9NY2J4.js +159 -0
- package/dist/subcommand-CP9NY2J4.js.map +1 -0
- package/dist/{usage-CLjirdD-.js → usage-CTfDq9HR.js} +3 -3
- package/dist/{usage-CLjirdD-.js.map → usage-CTfDq9HR.js.map} +1 -1
- package/dist/{validate-DCq_0DIn.js → validate-DtljsCh1.js} +51 -51
- package/dist/{validate-DCq_0DIn.js.map → validate-DtljsCh1.js.map} +1 -1
- package/package.json +42 -31
- package/dist/cloudflare-CINJPKCW.js.map +0 -1
- package/dist/config-DVfDGyw1.js +0 -278
- package/dist/config-DVfDGyw1.js.map +0 -1
- package/dist/cost-CQt1YRkA.js.map +0 -1
- package/dist/current-json-C-EyJqs0.js.map +0 -1
- package/dist/deploy-CrAbfgCq.js.map +0 -1
- package/dist/doctor-Db-hzPmE.js.map +0 -1
- package/dist/dump-BYA55NLP.js.map +0 -1
- package/dist/fsck-CPPZWt9p.js.map +0 -1
- package/dist/http-Cw8p6y5b.js.map +0 -1
- package/dist/inspect-Bdbzvi-_.js.map +0 -1
- package/dist/maintenance-BvOv6BMM.js.map +0 -1
- package/dist/maintenance-ClzBC1Vv.js.map +0 -1
- package/dist/observability-CpOiEN0k.js.map +0 -1
- package/dist/plan-DOTl21vq.js.map +0 -1
- package/dist/query-BmiQy328.js.map +0 -1
- package/dist/rebuild-index-DC_nR6wP.js.map +0 -1
- package/dist/restore-C6IcmLeA.js.map +0 -1
- package/dist/snapshot-SS8USDUF.js.map +0 -1
- package/dist/src-DU1sCMlr.js.map +0 -1
- package/dist/src-QQ7jDeL2.js.map +0 -1
- package/dist/src-zhEAmmF7.js.map +0 -1
- package/dist/subcommand-DZcHcsYp.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { d as IndexDefinition, f as DocumentData, n as BaerlyAppConfig, r as BaerlyConfig, u as SchemaValidator } from "./app-config-
|
|
2
|
-
import { h as Storage, n as LogEntry, r as Verifier } from "./index-
|
|
1
|
+
import { d as IndexDefinition, f as DocumentData, n as BaerlyAppConfig, r as BaerlyConfig, u as SchemaValidator } from "./app-config-BIzyAKzy.js";
|
|
2
|
+
import { h as Storage, n as LogEntry, r as Verifier } from "./index-DW7GT6M2.js";
|
|
3
3
|
//#region packages/server/src/config.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Flatten `BaerlyConfig.collections` into the per-collection
|
|
@@ -142,5 +142,21 @@ declare const walkLogRange: (storage: Storage, logPrefix: string, fromSeq: numbe
|
|
|
142
142
|
signal?: AbortSignal;
|
|
143
143
|
}) => Promise<LogEntry[]>;
|
|
144
144
|
//#endregion
|
|
145
|
-
|
|
146
|
-
|
|
145
|
+
//#region packages/server/src/log-tail.d.ts
|
|
146
|
+
/**
|
|
147
|
+
* Discover the true committed tail and fold entries in `[hint, tail)`.
|
|
148
|
+
* `tail` is the first empty seq (>= hint); `entries` are the
|
|
149
|
+
* LogEntries in `[hint, tail)` in seq order. `cap` bounds the walk;
|
|
150
|
+
* exhausting it THROWS `Internal` (never silently truncates) — see
|
|
151
|
+
* the cap-exhaustion comment below.
|
|
152
|
+
*/
|
|
153
|
+
declare const probeTailFrom: (storage: Storage, logPrefix: string, hint: number, opts?: {
|
|
154
|
+
signal?: AbortSignal;
|
|
155
|
+
cap?: number;
|
|
156
|
+
}) => Promise<{
|
|
157
|
+
tail: number;
|
|
158
|
+
entries: LogEntry[];
|
|
159
|
+
}>;
|
|
160
|
+
//#endregion
|
|
161
|
+
export { loadSnapshotAsMap as a, collectionsToMaps as c, encodeSnapshotBody as i, walkLogRange as n, snapshotKey as o, SnapshotBody as r, resolveVerifier as s, probeTailFrom as t };
|
|
162
|
+
//# sourceMappingURL=index-BDceQQi-.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { h as Storage, t as MetricsRecorder } from "./index-
|
|
2
|
-
import { a as MaintenanceDispatch } from "./maintenance-
|
|
1
|
+
import { h as Storage, t as MetricsRecorder } from "./index-DW7GT6M2.js";
|
|
2
|
+
import { a as MaintenanceDispatch } from "./maintenance-BkhUr72A.js";
|
|
3
3
|
|
|
4
4
|
//#region packages/server/src/observability/recorder.d.ts
|
|
5
5
|
/** One observation row, kept in insertion order. */
|
|
@@ -85,7 +85,7 @@ interface ObservabilityContext {
|
|
|
85
85
|
* adapter (NOT `Db.create`) so the inherently-per-request
|
|
86
86
|
* `dispatch = ctx.waitUntil` and the env-var-derived caps ride the
|
|
87
87
|
* same scope the kernel write-tick reads from. The {@link Writer}
|
|
88
|
-
* consults `getCurrentContext()?.maintenance` at the post-
|
|
88
|
+
* consults `getCurrentContext()?.maintenance` at the post-commit
|
|
89
89
|
* dispatch point. Absent ⇒ inline dispatch + CF-free-safe caps.
|
|
90
90
|
*/
|
|
91
91
|
readonly maintenance?: MaintenanceDispatch;
|
|
@@ -133,7 +133,7 @@ declare const runWithContext: <T>(ctx: ObservabilityContext, fn: () => T | Promi
|
|
|
133
133
|
/** Returns the currently-active context, or `undefined` outside one. */
|
|
134
134
|
declare const getCurrentContext: () => ObservabilityContext | undefined;
|
|
135
135
|
//#endregion
|
|
136
|
-
//#region node_modules/.pnpm/@logtape+logtape@2.1.
|
|
136
|
+
//#region node_modules/.pnpm/@logtape+logtape@2.1.3/node_modules/@logtape/logtape/dist/level.d.ts
|
|
137
137
|
//#region src/level.d.ts
|
|
138
138
|
declare const logLevels: readonly ["trace", "debug", "info", "warning", "error", "fatal"];
|
|
139
139
|
/**
|
|
@@ -147,7 +147,7 @@ type LogLevel = typeof logLevels[number];
|
|
|
147
147
|
* @since 1.0.0
|
|
148
148
|
*/
|
|
149
149
|
//#endregion
|
|
150
|
-
//#region node_modules/.pnpm/@logtape+logtape@2.1.
|
|
150
|
+
//#region node_modules/.pnpm/@logtape+logtape@2.1.3/node_modules/@logtape/logtape/dist/record.d.ts
|
|
151
151
|
//#region src/record.d.ts
|
|
152
152
|
/**
|
|
153
153
|
* A log record.
|
|
@@ -193,7 +193,7 @@ interface LogRecord {
|
|
|
193
193
|
} //# sourceMappingURL=record.d.ts.map
|
|
194
194
|
//#endregion
|
|
195
195
|
//#endregion
|
|
196
|
-
//#region node_modules/.pnpm/@logtape+logtape@2.1.
|
|
196
|
+
//#region node_modules/.pnpm/@logtape+logtape@2.1.3/node_modules/@logtape/logtape/dist/sink.d.ts
|
|
197
197
|
//#region src/sink.d.ts
|
|
198
198
|
/**
|
|
199
199
|
* A sink is a function that accepts a log record and prints it somewhere.
|
|
@@ -215,7 +215,7 @@ type Sink = (record: LogRecord) => void;
|
|
|
215
215
|
* @since 1.0.0
|
|
216
216
|
*/
|
|
217
217
|
//#endregion
|
|
218
|
-
//#region node_modules/.pnpm/@logtape+logtape@2.1.
|
|
218
|
+
//#region node_modules/.pnpm/@logtape+logtape@2.1.3/node_modules/@logtape/logtape/dist/logger.d.ts
|
|
219
219
|
/**
|
|
220
220
|
* A logger interface. It provides methods to log messages at different
|
|
221
221
|
* severity levels.
|
|
@@ -1465,5 +1465,5 @@ declare const observableStorage: (inner: Storage) => Storage;
|
|
|
1465
1465
|
type Outcome = "read" | "committed" | "conflict" | "error";
|
|
1466
1466
|
declare const deriveOutcome: (method: string, status: number, error?: unknown) => Outcome;
|
|
1467
1467
|
//#endregion
|
|
1468
|
-
export {
|
|
1469
|
-
//# sourceMappingURL=index-
|
|
1468
|
+
export { ObservabilityContextInit as _, flushCanonicalLine as a, runWithContext as b, CATEGORY as c, ObservabilityConfig as d, configureObservability as f, ObservabilityContext as g, LogRecord as h, FlushCanonicalLineOptions as i, CategoryName as l, Sink as m, deriveOutcome as n, flushUnauthorizedAndRespond as o, getLogger as p, observableStorage as r, withHttpObservability as s, Outcome as t, FriendlyLogLevel as u, createObservabilityContext as v, getCurrentContext as y };
|
|
1469
|
+
//# sourceMappingURL=index-Cmsxx-ZN.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { f as DocumentData, m as JSONValue, p as DocumentValue } from "./app-config-
|
|
1
|
+
import { f as DocumentData, m as JSONValue, p as DocumentValue } from "./app-config-BIzyAKzy.js";
|
|
2
2
|
//#region packages/protocol/src/storage/types.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* Object-storage abstraction. The protocol kernel writes through
|
|
@@ -123,11 +123,11 @@ interface StorageListEntry {
|
|
|
123
123
|
/**
|
|
124
124
|
* Per-collection control object. CAS-protected. One per
|
|
125
125
|
* `(tenant, collection)` key — for example
|
|
126
|
-
* `<tenant>/<collection>/current.json`. The compactor swaps
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
126
|
+
* `<tenant>/<collection>/current.json`. The compactor swaps snapshot
|
|
127
|
+
* generations by CAS-writing this object; the Writer reads it on every
|
|
128
|
+
* commit to find the snapshot pointer and a non-authoritative
|
|
129
|
+
* tail-probe floor. The numbered log create mints the next integer
|
|
130
|
+
* `seq`; no commit-path code CAS-advances `current.json`.
|
|
131
131
|
*
|
|
132
132
|
* The schema is forward-compatible: adding a new optional field is
|
|
133
133
|
* non-breaking. Renaming or removing a field requires bumping
|
|
@@ -136,11 +136,11 @@ interface StorageListEntry {
|
|
|
136
136
|
*/
|
|
137
137
|
interface CurrentJson {
|
|
138
138
|
/**
|
|
139
|
-
* Schema version. Today: `
|
|
139
|
+
* Schema version. Today: `3`. Bump on any breaking change to
|
|
140
140
|
* field semantics; readers must reject unknown major versions
|
|
141
141
|
* with `BaerlyError{code:"InvalidResponse"}`.
|
|
142
142
|
*/
|
|
143
|
-
schema_version:
|
|
143
|
+
schema_version: 3;
|
|
144
144
|
/**
|
|
145
145
|
* Pointer to the current snapshot generation. `null` before the
|
|
146
146
|
* first compaction has produced a snapshot — readers fall back
|
|
@@ -149,23 +149,24 @@ interface CurrentJson {
|
|
|
149
149
|
*/
|
|
150
150
|
snapshot: string | null;
|
|
151
151
|
/**
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
*
|
|
152
|
+
* Non-authoritative monotone lower bound on the committed log tail.
|
|
153
|
+
* The authoritative tail is discovered by forward-probe (log-tail.ts);
|
|
154
|
+
* never trust this as the head. Durable advancement is owned by
|
|
155
|
+
* compaction folds, write-tick tail refreshes, and explicit
|
|
156
|
+
* operator/import paths; ordinary writer commits do not refresh it.
|
|
156
157
|
*/
|
|
157
|
-
|
|
158
|
+
tail_hint: number;
|
|
158
159
|
/**
|
|
159
160
|
* Lowest live log sequence number. Entries with `seq < log_seq_start`
|
|
160
161
|
* have been folded into the snapshot at {@link snapshot} (or, if
|
|
161
162
|
* `snapshot === null`, have been dropped because the collection was
|
|
162
|
-
* truncated). Readers walk `[log_seq_start,
|
|
163
|
+
* truncated). Readers walk `[log_seq_start, tail_hint)`. Always
|
|
163
164
|
* present on disk — fresh `current.json` writes via
|
|
164
165
|
* {@link createCurrentJson} set this to `0`; the compactor advances
|
|
165
166
|
* it on every fold.
|
|
166
167
|
*
|
|
167
168
|
* Invariants the compactor maintains:
|
|
168
|
-
* - `0 <= log_seq_start <=
|
|
169
|
+
* - `0 <= log_seq_start <= tail_hint`
|
|
169
170
|
* - `log_seq_start` advances monotonically (never decreases)
|
|
170
171
|
* - `log_seq_start > 0` implies `snapshot !== null` (the snapshot
|
|
171
172
|
* covers `[0, log_seq_start)`)
|
|
@@ -175,19 +176,27 @@ interface CurrentJson {
|
|
|
175
176
|
* Embedded write-fence epoch. See {@link WriterFence}.
|
|
176
177
|
*/
|
|
177
178
|
writer_fence: WriterFence;
|
|
178
|
-
/** EXACT byte size of the live log tail [log_seq_start, next_seq). Maintained exactly
|
|
179
|
-
* by the full-fence CAS on BOTH paths: each write adds its log bytes; a successful
|
|
180
|
-
* fold (which proves no concurrent write) resets to 0 from a known-empty tail. */
|
|
181
|
-
tail_bytes: number;
|
|
182
179
|
/** Byte size of the snapshot pointed to by `snapshot`. */
|
|
183
180
|
snapshot_bytes: number;
|
|
184
|
-
/**
|
|
185
|
-
*
|
|
181
|
+
/**
|
|
182
|
+
* Row count of the snapshot (= compactor `base.size`, free). With
|
|
183
|
+
* `tail_hint - log_seq_start` (trusted tail entries) this gives the
|
|
184
|
+
* fold's entry count for the ENTRY ceiling `E`. Seeded 0.
|
|
185
|
+
*/
|
|
186
186
|
snapshot_rows: number;
|
|
187
|
-
/**
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
*
|
|
187
|
+
/**
|
|
188
|
+
* Optional compactor-stamped mean folded-entry byte size. Maintenance
|
|
189
|
+
* derives live-tail bytes as `entry_count × mean_entry_bytes` without
|
|
190
|
+
* an exact stored counter; absent until first fold.
|
|
191
|
+
*/
|
|
192
|
+
mean_entry_bytes?: number;
|
|
193
|
+
/**
|
|
194
|
+
* Baseline for rate-limiting the graduation defer-warn off SHARED
|
|
195
|
+
* durable state, not per-isolate memory. The warn fires when the
|
|
196
|
+
* observed/probed tail minus `last_warned_seq` reaches
|
|
197
|
+
* MAINTENANCE_WARN_INTERVAL_WRITES, and that firing CASes
|
|
198
|
+
* `last_warned_seq` to the observed/probed tail. Absent → 0.
|
|
199
|
+
*/
|
|
191
200
|
last_warned_seq?: number;
|
|
192
201
|
}
|
|
193
202
|
/**
|
|
@@ -195,23 +204,24 @@ interface CurrentJson {
|
|
|
195
204
|
* monotonically-bumped `epoch` is the only safety-critical field —
|
|
196
205
|
* `owner` is informational and may be missing in older records;
|
|
197
206
|
* `claimed_at` is the server response date at claim time, NOT the
|
|
198
|
-
* local clock; `lease_until` is reserved for manual rotation and
|
|
199
|
-
*
|
|
207
|
+
* local clock; `lease_until` is reserved for manual rotation and is not
|
|
208
|
+
* consumed by the current kernel. Log entries are not stamped with this
|
|
209
|
+
* epoch; the fence is dormant authority metadata, not a reader replay
|
|
210
|
+
* filter.
|
|
200
211
|
*
|
|
201
212
|
* Borrowed from FoundationDB's `recoveryCount` on cstate, IsleDB's
|
|
202
213
|
* `writer_fence` on `manifest/CURRENT`, and TigerBeetle's VSR view
|
|
203
|
-
* number.
|
|
204
|
-
*
|
|
205
|
-
*
|
|
214
|
+
* number. In the earlier two-write commit design, every commit checked
|
|
215
|
+
* the epoch before continuing under `current.json` authority. Under
|
|
216
|
+
* single-write commit no production path reads or writes the fence.
|
|
206
217
|
*/
|
|
207
218
|
interface WriterFence {
|
|
208
219
|
/**
|
|
209
220
|
* Monotonic unsigned integer. Bumped only by an explicit
|
|
210
221
|
* {@link claimWriter} call — do NOT bump on every cold start, do
|
|
211
|
-
* NOT bump on every commit.
|
|
212
|
-
*
|
|
213
|
-
*
|
|
214
|
-
* is `< current.writer_fence.epoch`.
|
|
222
|
+
* NOT bump on every commit. Under single-write commit this is retained
|
|
223
|
+
* as an explicit admin/testing primitive only; no production commit
|
|
224
|
+
* path claims or verifies the fence.
|
|
215
225
|
*/
|
|
216
226
|
epoch: number;
|
|
217
227
|
/**
|
|
@@ -672,7 +682,7 @@ type BaerlyErrorCode = /** Caller-provided config or input is invalid (bad bucke
|
|
|
672
682
|
* declared `SchemaValidator` (via `Db.create({ collections })`) and
|
|
673
683
|
* the bound schema rejects the doc. In the schema-rejection case the
|
|
674
684
|
* error carries an `issues` array describing each failure. HTTP layer
|
|
675
|
-
* maps this to
|
|
685
|
+
* maps this to 400.
|
|
676
686
|
*/
|
|
677
687
|
| "SchemaError"
|
|
678
688
|
/**
|
|
@@ -985,11 +995,9 @@ interface LogEntry {
|
|
|
985
995
|
/** Insert / Update / Delete. */
|
|
986
996
|
op: "I" | "U" | "D";
|
|
987
997
|
/**
|
|
988
|
-
* Collection name — the pgoutput RELATION analogue. Today
|
|
989
|
-
*
|
|
990
|
-
*
|
|
991
|
-
* `ref.bucket` for flat keys with no separator. The table API
|
|
992
|
-
* makes collections first-class.
|
|
998
|
+
* Collection name — the pgoutput RELATION analogue. Today this is
|
|
999
|
+
* the collection bound to the `current.json` whose `tail_hint` minted
|
|
1000
|
+
* the entry. The table API makes collections first-class.
|
|
993
1001
|
*/
|
|
994
1002
|
collection: string;
|
|
995
1003
|
/**
|
|
@@ -1041,7 +1049,7 @@ interface LogEntry {
|
|
|
1041
1049
|
* stdout (one JSON object per HTTP request).
|
|
1042
1050
|
*
|
|
1043
1051
|
* **Naming convention** matches the load-bearing metrics:
|
|
1044
|
-
* - `db.write.class_a_ops_per_logical_write` — histogram (p99 alert
|
|
1052
|
+
* - `db.write.class_a_ops_per_logical_write` — histogram (recommend p99 alert ~5; not gated).
|
|
1045
1053
|
* Includes one Class A op per index PUT + index DELETE emitted
|
|
1046
1054
|
* in the commit's fence. Idle-reader cost is unchanged.
|
|
1047
1055
|
* - `db.r2.put.412_total` — counter (CAS conflict / If-Match-or-None-Match loss)
|
|
@@ -1071,4 +1079,4 @@ interface MetricsRecorder {
|
|
|
1071
1079
|
}
|
|
1072
1080
|
//#endregion
|
|
1073
1081
|
export { StorageGetResult as _, MemoryStorage as a, StoragePutResult as b, Collection as c, Query as d, PredicateArg as f, StorageGetOptions as g, Storage as h, VerifierResult as i, OrderSpec as l, CurrentJsonRead as m, LogEntry as n, BaerlyError as o, CurrentJson as p, Verifier as r, BaerlyErrorCode as s, MetricsRecorder as t, Predicate as u, StorageListEntry as v, StoragePutOptions as y };
|
|
1074
|
-
//# sourceMappingURL=index-
|
|
1082
|
+
//# sourceMappingURL=index-DW7GT6M2.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as StorageGetResult, b as StoragePutResult, g as StorageGetOptions, h as Storage, v as StorageListEntry, y as StoragePutOptions } from "./index-
|
|
1
|
+
import { _ as StorageGetResult, b as StoragePutResult, g as StorageGetOptions, h as Storage, v as StorageListEntry, y as StoragePutOptions } from "./index-DW7GT6M2.js";
|
|
2
2
|
|
|
3
3
|
//#region packages/dev/src/dev-landing.d.ts
|
|
4
4
|
/**
|
|
@@ -83,11 +83,14 @@ interface LocalFsStorageOptions {
|
|
|
83
83
|
* makes this adapter useful for fixture-based tests.
|
|
84
84
|
*
|
|
85
85
|
* Writes are atomic via `writeFile(temp) + rename(final)`; readers
|
|
86
|
-
* never see a partially-written file.
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
86
|
+
* never see a partially-written file.
|
|
87
|
+
*
|
|
88
|
+
* `ifNoneMatch:"*"` uses a same-dir temp + `link(2)` (atomic exclusive
|
|
89
|
+
* create; `EEXIST` ⇒ key exists) so concurrent creates have exactly one
|
|
90
|
+
* winner. Same-dir avoids `EXDEV`; temp+`link` over `open(…,"wx")` keeps
|
|
91
|
+
* a partially-written new key invisible to a concurrent reader. `ifMatch`
|
|
92
|
+
* keeps the `rename` path (in-process TOCTOU only; cross-process
|
|
93
|
+
* contention uses the S3 / Minio `If-Match` path).
|
|
91
94
|
*
|
|
92
95
|
* Node-only — imports `node:fs`, `node:path`, `node:crypto`. Lives in
|
|
93
96
|
* `@baerly/dev` because the protocol kernel is pure-modules / no I/O
|
|
@@ -109,4 +112,4 @@ declare class LocalFsStorage implements Storage {
|
|
|
109
112
|
}
|
|
110
113
|
//#endregion
|
|
111
114
|
export { renderDevLanding as a, DevLandingOptions as i, LocalFsStorageOptions as n, ensureTable as r, LocalFsStorage as t };
|
|
112
|
-
//# sourceMappingURL=index-
|
|
115
|
+
//# sourceMappingURL=index-DnBGSeuU.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as CollectionNames, c as defineConfig, d as IndexDefinition, f as DocumentData, i as CollectionDefinition, l as SchemaIssue, n as BaerlyAppConfig, o as RowOf, r as BaerlyConfig, s as UnboundConfig, u as SchemaValidator } from "./app-config-
|
|
2
|
-
import { _ as StorageGetResult, a as MemoryStorage, b as StoragePutResult, c as Collection, d as Query, h as Storage, i as VerifierResult, o as BaerlyError, r as Verifier, s as BaerlyErrorCode, v as StorageListEntry } from "./index-
|
|
3
|
-
import { t as allIndexKeysFor } from "./indexes-
|
|
4
|
-
import { a as
|
|
5
|
-
import { n as validateOrThrow, t as Db } from "./db-
|
|
6
|
-
export { type BaerlyAppConfig, type BaerlyConfig, BaerlyError, type BaerlyErrorCode, type Collection, type CollectionDefinition, type CollectionNames, Db, type DocumentData, type IndexDefinition, MemoryStorage, type Query, type RowOf, type SchemaIssue, type SchemaValidator, type SnapshotBody, type Storage, type StorageGetResult, type StorageListEntry, type StoragePutResult, type UnboundConfig, type Verifier, type VerifierResult, allIndexKeysFor, collectionsToMaps, defineConfig, encodeSnapshotBody, loadSnapshotAsMap, resolveVerifier, snapshotKey, validateOrThrow, walkLogRange };
|
|
1
|
+
import { a as CollectionNames, c as defineConfig, d as IndexDefinition, f as DocumentData, i as CollectionDefinition, l as SchemaIssue, n as BaerlyAppConfig, o as RowOf, r as BaerlyConfig, s as UnboundConfig, u as SchemaValidator } from "./app-config-BIzyAKzy.js";
|
|
2
|
+
import { _ as StorageGetResult, a as MemoryStorage, b as StoragePutResult, c as Collection, d as Query, h as Storage, i as VerifierResult, o as BaerlyError, r as Verifier, s as BaerlyErrorCode, v as StorageListEntry } from "./index-DW7GT6M2.js";
|
|
3
|
+
import { t as allIndexKeysFor } from "./indexes-Cx7uMXm0.js";
|
|
4
|
+
import { a as loadSnapshotAsMap, c as collectionsToMaps, i as encodeSnapshotBody, n as walkLogRange, o as snapshotKey, r as SnapshotBody, s as resolveVerifier, t as probeTailFrom } from "./index-BDceQQi-.js";
|
|
5
|
+
import { n as validateOrThrow, t as Db } from "./db-CCT6tDfY.js";
|
|
6
|
+
export { type BaerlyAppConfig, type BaerlyConfig, BaerlyError, type BaerlyErrorCode, type Collection, type CollectionDefinition, type CollectionNames, Db, type DocumentData, type IndexDefinition, MemoryStorage, type Query, type RowOf, type SchemaIssue, type SchemaValidator, type SnapshotBody, type Storage, type StorageGetResult, type StorageListEntry, type StoragePutResult, type UnboundConfig, type Verifier, type VerifierResult, allIndexKeysFor, collectionsToMaps, defineConfig, encodeSnapshotBody, loadSnapshotAsMap, probeTailFrom, resolveVerifier, snapshotKey, validateOrThrow, walkLogRange };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineConfig } from "./app-config.js";
|
|
2
2
|
import { t as BaerlyError } from "./errors-DOdL95kK.js";
|
|
3
|
-
import {
|
|
4
|
-
import { o as validateOrThrow } from "./query-
|
|
5
|
-
import { i as MemoryStorage, n as resolveVerifier, r as collectionsToMaps, t as Db } from "./src-
|
|
6
|
-
export { BaerlyError, Db, MemoryStorage, allIndexKeysFor, collectionsToMaps, defineConfig, encodeSnapshotBody, loadSnapshotAsMap, resolveVerifier, snapshotKey, validateOrThrow, walkLogRange };
|
|
3
|
+
import { S as probeTailFrom, _ as encodeSnapshotBody, m as allIndexKeysFor, p as walkLogRange, v as loadSnapshotAsMap, y as snapshotKey } from "./maintenance-CWBQpZ2y.js";
|
|
4
|
+
import { o as validateOrThrow } from "./query-sQNO5vU_.js";
|
|
5
|
+
import { i as MemoryStorage, n as resolveVerifier, r as collectionsToMaps, t as Db } from "./src-Db4-qVtM.js";
|
|
6
|
+
export { BaerlyError, Db, MemoryStorage, allIndexKeysFor, collectionsToMaps, defineConfig, encodeSnapshotBody, loadSnapshotAsMap, probeTailFrom, resolveVerifier, snapshotKey, validateOrThrow, walkLogRange };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as IndexDefinition, f as DocumentData } from "./app-config-
|
|
1
|
+
import { d as IndexDefinition, f as DocumentData } from "./app-config-BIzyAKzy.js";
|
|
2
2
|
//#region packages/server/src/indexes.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* Compute the full index-key set a single doc produces under every
|
|
@@ -19,4 +19,4 @@ import { d as IndexDefinition, f as DocumentData } from "./app-config-C0Bbw_Z6.j
|
|
|
19
19
|
declare const allIndexKeysFor: (logPrefix: string, defs: ReadonlyArray<IndexDefinition>, body: DocumentData | undefined, docId: string) => string[];
|
|
20
20
|
//#endregion
|
|
21
21
|
export { allIndexKeysFor as t };
|
|
22
|
-
//# sourceMappingURL=indexes-
|
|
22
|
+
//# sourceMappingURL=indexes-Cx7uMXm0.d.ts.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { n as loadCollectionIndexes } from "./config-
|
|
2
|
-
import {
|
|
3
|
-
import { n as parseBucketUri, t as defineBaerlySubcommand } from "./subcommand-DZcHcsYp.js";
|
|
1
|
+
import { n as loadCollectionIndexes, r as parseBucketUri } from "./config-CGyBopy3.js";
|
|
2
|
+
import { h as readCurrentJson, n as probeTailFrom } from "./log-tail-DXeDkWEp.js";
|
|
4
3
|
import { i as isJsonMode, o as BaerlyError, r as emitSuccess } from "./baerly.js";
|
|
5
|
-
import { n as loadMaterialisedView } from "./plan-
|
|
4
|
+
import { n as loadMaterialisedView } from "./plan-DIu_B6fy.js";
|
|
5
|
+
import { n as defineBaerlySubcommand, t as assertCollectionArg } from "./subcommand-CP9NY2J4.js";
|
|
6
6
|
//#region src/inspect.ts
|
|
7
7
|
const INSPECT_ARGS = {
|
|
8
8
|
bucket: {
|
|
@@ -57,10 +57,13 @@ const renderText = (r, collection) => {
|
|
|
57
57
|
lines.push(`baerly inspect ${collection}`);
|
|
58
58
|
lines.push(` current.json: ${r.currentJsonKey}`);
|
|
59
59
|
lines.push(` schema_version: ${r.schema_version}`);
|
|
60
|
-
lines.push(`
|
|
60
|
+
lines.push(` tail_hint (stored): ${r.tail_hint}`);
|
|
61
|
+
lines.push(` discovered_tail: ${r.discovered_tail}`);
|
|
61
62
|
lines.push(` log_seq_start: ${r.log_seq_start}`);
|
|
62
63
|
lines.push(` live_log_tail: ${r.live_log_tail}`);
|
|
63
64
|
lines.push(` snapshot: ${r.snapshot ?? "(none)"}`);
|
|
65
|
+
lines.push(` snapshot_bytes: ${r.snapshot_bytes}`);
|
|
66
|
+
lines.push(` snapshot_rows: ${r.snapshot_rows}`);
|
|
64
67
|
lines.push(` writer_fence: epoch=${r.writer_fence.epoch} owner=${JSON.stringify(r.writer_fence.owner)} claimed_at=${JSON.stringify(r.writer_fence.claimed_at)}`);
|
|
65
68
|
lines.push(` materialised_rows: ${r.materialised_rows}`);
|
|
66
69
|
if (r.indexes.length > 0) {
|
|
@@ -81,12 +84,14 @@ const bundle = defineBaerlySubcommand({
|
|
|
81
84
|
app: args.app,
|
|
82
85
|
tenant: args.tenant
|
|
83
86
|
});
|
|
87
|
+
assertCollectionArg(args.collection, "baerly inspect");
|
|
84
88
|
const collectionPrefix = `${bucket.keyPrefix}app/${app}/tenant/${tenant}/manifests/${args.collection}`;
|
|
85
89
|
const currentJsonKey = `${collectionPrefix}/current.json`;
|
|
86
90
|
const read = await readCurrentJson(bucket.storage, currentJsonKey);
|
|
87
91
|
if (read === null) throw new BaerlyError("InvalidConfig", `baerly inspect: current.json not found at ${currentJsonKey}`);
|
|
88
92
|
const cur = read.json;
|
|
89
93
|
const log_seq_start = cur.log_seq_start ?? 0;
|
|
94
|
+
const discoveredTail = (await probeTailFrom(bucket.storage, collectionPrefix, Math.max(log_seq_start, cur.tail_hint))).tail;
|
|
90
95
|
const errors = [];
|
|
91
96
|
let materialisedRows = 0;
|
|
92
97
|
try {
|
|
@@ -121,10 +126,13 @@ const bundle = defineBaerlySubcommand({
|
|
|
121
126
|
const result = {
|
|
122
127
|
currentJsonKey,
|
|
123
128
|
schema_version: cur.schema_version,
|
|
124
|
-
|
|
129
|
+
tail_hint: cur.tail_hint,
|
|
130
|
+
discovered_tail: discoveredTail,
|
|
125
131
|
log_seq_start,
|
|
126
|
-
live_log_tail:
|
|
132
|
+
live_log_tail: discoveredTail - log_seq_start,
|
|
127
133
|
snapshot: cur.snapshot,
|
|
134
|
+
snapshot_bytes: cur.snapshot_bytes,
|
|
135
|
+
snapshot_rows: cur.snapshot_rows,
|
|
128
136
|
writer_fence: cur.writer_fence,
|
|
129
137
|
materialised_rows: materialisedRows,
|
|
130
138
|
indexes,
|
|
@@ -145,4 +153,4 @@ bundle.run;
|
|
|
145
153
|
//#endregion
|
|
146
154
|
export { inspect };
|
|
147
155
|
|
|
148
|
-
//# sourceMappingURL=inspect-
|
|
156
|
+
//# sourceMappingURL=inspect-DhI49PSi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inspect-DhI49PSi.js","names":[],"sources":["../packages/cli/src/inspect.ts"],"sourcesContent":["/**\n * `baerly inspect` — read-only summary for one collection.\n *\n * Args:\n * --bucket Required. Bucket URI.\n * --app Required (or via baerly.config.ts).\n * --tenant Required (or via baerly.config.ts).\n * --collection Required. Collection name.\n * --config Optional path to baerly.config.{js,mjs,json} for index info.\n * --json JSON envelope.\n *\n * Reports, per-collection:\n * - currentJsonKey path.\n * - schema_version, tail_hint, log_seq_start (default 0).\n * - live_log_tail (= tail_hint - log_seq_start).\n * - snapshot key (or null).\n * - snapshot_bytes / snapshot_rows (the fold-ceiling inputs C / E\n * are compared against; see graduation.md).\n * - writer_fence (epoch, owner, claimed_at).\n * - materialised row count (via export/loadMaterialisedView).\n * - per-declared-index key count (when --config supplied).\n * - well-formed status: \"ok\" or \"error\" with an `errors` array.\n *\n * For projected monthly Class A / $ trajectories, use\n * `baerly cost --bucket=<uri> --collection=<name>` — the projection\n * used to live as a footer here but moved to its own verb so inspect\n * stays a glance command (no GET-storm over the trailing log sample).\n *\n * Cost shape:\n * 1 GET current.json\n * + 1 GET snapshot (if any)\n * + N GETs log tail (= tail_hint - log_seq_start)\n * + K LISTs (one per declared index, when --config supplied)\n * + 1 LIST snapshot/ prefix (orphan detection)\n *\n * Never mutates anything.\n *\n * Exit codes:\n * 0 — inspection ran (status may be \"ok\" or \"error\"; both exit 0).\n * 1 — InvalidConfig (bad bucket URI, missing args, unknown flag).\n * 2 — Storage / Network error.\n * 3 — Protocol invariant (Conflict / Internal / InvalidResponse).\n */\n\nimport { type ArgsDef } from \"citty\";\nimport { BaerlyError, readCurrentJson, type CurrentJson, type Storage } from \"@baerly/protocol\";\nimport { probeTailFrom } from \"@baerly/server\";\nimport { loadMaterialisedView } from \"./export/index.ts\";\nimport { loadCollectionIndexes } from \"./config.ts\";\nimport { parseBucketUri } from \"./bucket-uri.ts\";\nimport { emitSuccess, isJsonMode } from \"./output.ts\";\nimport { assertCollectionArg, defineBaerlySubcommand } from \"./subcommand.ts\";\n\nconst INSPECT_ARGS = {\n bucket: {\n type: \"string\",\n required: true,\n description: \"Bucket URI (s3://<bucket>[/<prefix>], file:///<abs>, memory://<bucket>)\",\n valueHint: \"bucket-uri\",\n },\n app: {\n type: \"string\",\n required: false,\n description: \"Application name segment (defaults to baerly.config.ts).\",\n valueHint: \"app\",\n },\n tenant: {\n type: \"string\",\n required: false,\n description: \"Tenant name segment (defaults to baerly.config.ts).\",\n valueHint: \"tenant\",\n },\n collection: {\n type: \"string\",\n required: true,\n description: \"Collection name.\",\n valueHint: \"name\",\n },\n config: {\n type: \"string\",\n required: false,\n description:\n \"Path to baerly.config.{js,mjs,json}; pulls declared indexes for key-count probes.\",\n valueHint: \"path\",\n },\n json: {\n type: \"boolean\",\n description: \"Emit a structured JSON envelope to stdout (success) or stderr (error)\",\n },\n} as const satisfies ArgsDef;\n\nconst countListEntries = async (\n storage: Storage,\n prefix: string,\n): Promise<{ count: number; keys: string[] }> => {\n let count = 0;\n const keys: string[] = [];\n for await (const entry of storage.list(prefix)) {\n count++;\n keys.push(entry.key);\n }\n return { count, keys };\n};\n\ninterface InspectResult {\n currentJsonKey: string;\n schema_version: number;\n /** The stored, compactor-advanced lower-bound hint (`current.json.tail_hint`). */\n tail_hint: number;\n /** The TRUE committed tail, discovered by forward-probe past `tail_hint`. */\n discovered_tail: number;\n log_seq_start: number;\n live_log_tail: number;\n snapshot: string | null;\n snapshot_bytes: number;\n snapshot_rows: number;\n writer_fence: CurrentJson[\"writer_fence\"];\n materialised_rows: number;\n indexes: { name: string; count: number }[];\n status: \"ok\" | \"error\";\n errors: string[];\n}\n\nconst renderText = (r: InspectResult, collection: string): string => {\n const lines: string[] = [];\n lines.push(`baerly inspect ${collection}`);\n lines.push(` current.json: ${r.currentJsonKey}`);\n lines.push(` schema_version: ${r.schema_version}`);\n lines.push(` tail_hint (stored): ${r.tail_hint}`);\n lines.push(` discovered_tail: ${r.discovered_tail}`);\n lines.push(` log_seq_start: ${r.log_seq_start}`);\n lines.push(` live_log_tail: ${r.live_log_tail}`);\n lines.push(` snapshot: ${r.snapshot ?? \"(none)\"}`);\n lines.push(` snapshot_bytes: ${r.snapshot_bytes}`);\n lines.push(` snapshot_rows: ${r.snapshot_rows}`);\n lines.push(\n ` writer_fence: epoch=${r.writer_fence.epoch} owner=${JSON.stringify(r.writer_fence.owner)} claimed_at=${JSON.stringify(r.writer_fence.claimed_at)}`,\n );\n lines.push(` materialised_rows: ${r.materialised_rows}`);\n if (r.indexes.length > 0) {\n const formatted = r.indexes.map((i) => `${i.name} (count=${i.count})`).join(\", \");\n lines.push(` indexes: ${formatted}`);\n } else {\n lines.push(` indexes: (none declared)`);\n }\n lines.push(` status: ${r.status}`);\n if (r.errors.length > 0) {\n for (const e of r.errors) {\n lines.push(` error: ${e}`);\n }\n }\n return lines.join(\"\\n\") + \"\\n\";\n};\n\nconst bundle = defineBaerlySubcommand({\n name: \"inspect\",\n meta: {\n description: \"Read-only summary of one collection's snapshot + log state.\",\n },\n args: INSPECT_ARGS,\n handler: async (args, ctx) => {\n const bucket = await parseBucketUri(args.bucket);\n const { app, tenant } = await ctx.resolveAppTenant({ app: args.app, tenant: args.tenant });\n assertCollectionArg(args.collection, \"baerly inspect\");\n const collectionPrefix = `${bucket.keyPrefix}app/${app}/tenant/${tenant}/manifests/${args.collection}`;\n const currentJsonKey = `${collectionPrefix}/current.json`;\n\n const read = await readCurrentJson(bucket.storage, currentJsonKey);\n if (read === null) {\n throw new BaerlyError(\n \"InvalidConfig\",\n `baerly inspect: current.json not found at ${currentJsonKey}`,\n );\n }\n const cur = read.json;\n const log_seq_start = cur.log_seq_start ?? 0;\n // Discover the TRUE tail by forward-probe — under single-write commit\n // the stored `tail_hint` is only a lower bound (compactor-advanced),\n // so an accurate operator summary must probe past it.\n const tailProbe = await probeTailFrom(\n bucket.storage,\n collectionPrefix,\n Math.max(log_seq_start, cur.tail_hint),\n );\n const discoveredTail = tailProbe.tail;\n\n const errors: string[] = [];\n let materialisedRows = 0;\n try {\n const view = await loadMaterialisedView({\n storage: bucket.storage,\n currentJsonKey,\n collection: args.collection,\n });\n materialisedRows = view?.size ?? 0;\n } catch (error) {\n if (error instanceof BaerlyError) {\n errors.push(`${error.code}: ${error.message}`);\n } else {\n errors.push((error as Error).message);\n }\n }\n\n // Orphan-snapshot detection: list every file under <collectionPrefix>/snapshot/\n // and flag anything that isn't the currently-pointed-at snapshot.\n try {\n const snapshotPrefix = `${collectionPrefix}/snapshot/`;\n const { keys } = await countListEntries(bucket.storage, snapshotPrefix);\n for (const k of keys) {\n if (cur.snapshot !== k) {\n errors.push(`orphan snapshot: ${k}`);\n }\n }\n } catch (error) {\n if (error instanceof BaerlyError) {\n errors.push(`${error.code}: ${error.message}`);\n }\n }\n\n const indexes: { name: string; count: number }[] = [];\n if (typeof args.config === \"string\" && args.config.length > 0) {\n const defs = await loadCollectionIndexes(args.config, args.collection, \"baerly inspect\");\n for (const def of defs) {\n const prefix = `${collectionPrefix}/index/${def.name}/`;\n const { count } = await countListEntries(bucket.storage, prefix);\n indexes.push({ name: def.name, count });\n }\n }\n\n const result: InspectResult = {\n currentJsonKey,\n schema_version: cur.schema_version,\n tail_hint: cur.tail_hint,\n discovered_tail: discoveredTail,\n log_seq_start,\n live_log_tail: discoveredTail - log_seq_start,\n snapshot: cur.snapshot,\n snapshot_bytes: cur.snapshot_bytes,\n snapshot_rows: cur.snapshot_rows,\n writer_fence: cur.writer_fence,\n materialised_rows: materialisedRows,\n indexes,\n status: errors.length === 0 ? \"ok\" : \"error\",\n errors,\n };\n\n if (isJsonMode()) {\n emitSuccess({ command: \"inspect\", ...result });\n } else {\n process.stdout.write(renderText(result, args.collection));\n }\n return 0;\n },\n});\n\n/** citty `defineCommand` block for `baerly inspect`. */\nexport const inspect = bundle.cmd;\n\n/**\n * Programmatic entry used by tests. Bypasses citty's `run` wrapper\n * (which would call `process.exit` and kill vitest) and returns the\n * integer exit code directly.\n */\nexport const runInspect = bundle.run;\n"],"mappings":";;;;;;AAqDA,MAAM,eAAe;CACnB,QAAQ;EACN,MAAM;EACN,UAAU;EACV,aAAa;EACb,WAAW;CACb;CACA,KAAK;EACH,MAAM;EACN,UAAU;EACV,aAAa;EACb,WAAW;CACb;CACA,QAAQ;EACN,MAAM;EACN,UAAU;EACV,aAAa;EACb,WAAW;CACb;CACA,YAAY;EACV,MAAM;EACN,UAAU;EACV,aAAa;EACb,WAAW;CACb;CACA,QAAQ;EACN,MAAM;EACN,UAAU;EACV,aACE;EACF,WAAW;CAC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