diff --git a/packages/code/src/checkpoint-directory.test.ts b/packages/code/src/checkpoint-directory.test.ts index a5a8f1a5..fd5e80b8 100644 --- a/packages/code/src/checkpoint-directory.test.ts +++ b/packages/code/src/checkpoint-directory.test.ts @@ -58,8 +58,9 @@ async function supportedFixture(t: TestContext): Promise { async function assertReusable(path: string): Promise { assert.equal( - await withCheckpointDirectory(path, admit, async fd => { - const pinned = await stat(fd, { bigint: true }); + await withCheckpointDirectory(path, admit, async (fd, handle) => { + assert.equal(fd, `/proc/self/fd/${handle.fd}`); + const pinned = await handle.stat({ bigint: true }); const current = await stat(path, { bigint: true }); assert.equal(pinned.dev, current.dev); assert.equal(pinned.ino, current.ino); diff --git a/packages/code/src/checkpoint-directory.ts b/packages/code/src/checkpoint-directory.ts index f4748057..d3690776 100644 --- a/packages/code/src/checkpoint-directory.ts +++ b/packages/code/src/checkpoint-directory.ts @@ -183,14 +183,14 @@ async function revalidate( * trusted Linux procfs and mount administration. Ownership, inode checks and * flock are not isolation from the worker UID, privileged actors or aliases; * the mandatory verifier supplies admission and pins the grant set. - * The operation gets a borrowed descriptor path, valid only until it settles; - * use it only in this process, and do not expose it to untrusted code, retain it, - * or duplicate its descriptor. + * The operation gets a borrowed descriptor path and handle, valid only until + * it settles. Await all operations on them and never expose, close, retain or + * duplicate the handle; this reservation owns it and its lock. */ export async function withCheckpointDirectory( path: string, verifyIsolation: VerifyIsolation, - operation: (descriptorPath: string) => Promise + operation: (descriptorPath: string, handle: FileHandle) => Promise ): Promise { if (process.platform !== 'linux' || process.geteuid === undefined) { throw new Error('Checkpoint directory reservation requires Linux'); @@ -224,7 +224,7 @@ export async function withCheckpointDirectory( ); try { await revalidate(handle, directory, parts, uid); - return await operation(descriptor(handle)); + return await operation(descriptor(handle), handle); } finally { await release(); } diff --git a/packages/code/src/checkpoint-retention-codec.test.ts b/packages/code/src/checkpoint-retention-codec.test.ts new file mode 100644 index 00000000..7c5bcc6b --- /dev/null +++ b/packages/code/src/checkpoint-retention-codec.test.ts @@ -0,0 +1,244 @@ +import assert from 'node:assert/strict'; +import { test } from 'node:test'; +import { + decodeRetention, + encodeRetention, +} from './checkpoint-retention-codec.js'; +import { emptyRetention, transitionRetention } from './checkpoint-retention.js'; + +type Command = Parameters[1]; + +const lane = 'a'.repeat(64); +const other = 'b'.repeat(64); +const max = Number.MAX_SAFE_INTEGER; + +const ref = (sequence: number, id = lane) => ({ lane: id, sequence }); +const reserve = (expectedSequence: number, id = lane): Command => ({ + kind: 'reserve', + lane: id, + expectedSequence, + bytes: 4, + now: 0, + expiresAt: 10, +}); + +function fixture() { + let state = emptyRetention(); + const commands: Command[] = [ + { kind: 'enroll', lane }, + { kind: 'enroll', lane: other }, + reserve(0), + { kind: 'promote', ref: ref(1), expectedVerified: null, now: 1 }, + reserve(1), + { kind: 'discard', ref: ref(2) }, + reserve(2), + reserve(0, other), + { kind: 'discard', ref: ref(1, other) }, + { kind: 'reclaimed', ref: ref(1, other) }, + ]; + for (const command of commands) { + const result = transitionRetention(state, command); + assert.equal(result.status, 'applied'); + state = result.state; + } + return state; +} + +function wire() { + return { + version: 1, + lanes: Array.from(fixture().lanes, ([key, entry]) => ({ key, entry })), + garbage: [{ ref: ref(2), bytes: 4 }], + artifacts: 3, + bytes: 12, + }; +} + +function pack(value: ReturnType): Buffer { + return Buffer.from( + JSON.stringify({ + ...value, + lanes: value.lanes.map(({ key, entry }) => [key, entry]), + }) + ); +} + +test('round-trips the versioned root set, including cleared lane counters and current pointers', () => { + for (const state of [emptyRetention(), fixture()]) { + const bytes = encodeRetention(state); + const decoded = decodeRetention(bytes); + assert.deepEqual(decoded, state); + assert.deepEqual(encodeRetention(decoded), bytes); + } + assert.deepEqual(pack(wire()), encodeRetention(fixture())); + assert.equal( + transitionRetention(decodeRetention(pack(wire())), reserve(0, other)) + .status, + 'conflict' + ); +}); + +test('round-trips a full catalog at the lane, charge, byte and sequence ceilings', () => { + const bytes = 512 * 1024 * 1024; + const lanes = new Map( + Array.from({ length: 256 }, (_, index) => { + const id = index.toString(16).padStart(64, '0'); + return [ + id, + { + sequence: max, + pending: { + ref: ref(max, id), + bytes: bytes / 256, + expiresAt: max, + }, + verified: null, + }, + ] as const; + }) + ); + const state = { lanes, garbage: [], bytes, artifacts: 256 }; + assert.deepEqual(decodeRetention(encodeRetention(state)), state); +}); + +test('rejects malformed, ambiguous and unknown wire data', () => { + const good = pack(wire()).toString(); + for (const bad of [ + Buffer.alloc(0), + Buffer.alloc(128 * 1024 + 1, 32), + Buffer.from([0xff]), + Buffer.from('null'), + Buffer.from('[]'), + Buffer.from('{}'), + Buffer.from(good.slice(0, -1)), + Buffer.from(good.replace('"version":1', '"version":2')), + Buffer.from(good.replace('"version":1', '"version":1,"version":1')), + Buffer.from(good.replace('"sequence":3', '"sequence":3,"sequence":3')), + Buffer.from(good.replace('"sequence":3', '"sequence":"3"')), + Buffer.from(good.replace('"ref":', '"extra":true,"ref":')), + Buffer.from(good.replace('"verified":null', '"unknown":null')), + Buffer.from(good.replace('"artifacts":3,', '')), + Buffer.from(good.replace('"bytes":12', '"bytes":12,"unknown":0')), + ]) + assert.throws( + () => decodeRetention(bad), + /Invalid checkpoint retention payload/ + ); +}); + +const cases: Record) => void> = { + 'duplicate lanes': v => v.lanes.push(v.lanes[0]), + 'too many lanes': v => { + v.lanes = Array(257).fill(v.lanes[0]); + }, + 'invalid lane identity': v => { + v.lanes[0].key = 'x'.repeat(64); + }, + 'future garbage': v => { + v.garbage[0].ref.sequence = 4; + }, + 'unowned garbage': v => { + v.garbage[0].ref.lane = 'c'.repeat(64); + }, + 'duplicate garbage': v => { + v.garbage.push(v.garbage[0]); + v.artifacts++; + v.bytes += 4; + }, + 'too much garbage': v => { + v.garbage = Array(257).fill(v.garbage[0]); + }, + 'garbage aliasing verified': v => { + v.garbage[0].ref.sequence = 1; + }, + 'garbage aliasing pending': v => { + v.garbage[0].ref.sequence = 3; + }, + 'zero charge': v => { + v.garbage[0].bytes = 0; + }, + 'fractional charge': v => { + v.garbage[0].bytes = 4.5; + }, + 'oversized charge': v => { + v.garbage[0].bytes = 512 * 1024 * 1024 + 1; + }, + 'zero ref sequence': v => { + v.garbage[0].ref.sequence = 0; + }, + 'unsafe sequence counter': v => { + v.lanes[0].entry = { ...v.lanes[0].entry, sequence: max + 1 }; + }, + 'negative sequence counter': v => { + v.lanes[1].entry = { ...v.lanes[1].entry, sequence: -1 }; + }, + 'stale pending pointer': v => { + v.lanes[0].entry = { ...v.lanes[0].entry, sequence: 4 }; + }, + 'wrong-lane pending pointer': v => { + v.lanes[0].entry = { + ...v.lanes[0].entry, + pending: { ref: ref(3, other), bytes: 4, expiresAt: 10 }, + }; + }, + 'impossible pending expiry': v => { + v.lanes[0].entry = { + ...v.lanes[0].entry, + pending: { ref: ref(3), bytes: 4, expiresAt: 0 }, + }; + }, + 'future verified pointer': v => { + v.lanes[0].entry = { + ...v.lanes[0].entry, + verified: { ref: ref(4), bytes: 4 }, + }; + }, + 'wrong-lane verified pointer': v => { + v.lanes[0].entry = { + ...v.lanes[0].entry, + verified: { ref: ref(1, other), bytes: 4 }, + }; + }, + 'verified aliases pending': v => { + v.lanes[0].entry = { + ...v.lanes[0].entry, + verified: { ref: ref(3), bytes: 4 }, + }; + }, + 'undercharged bytes': v => { + v.bytes--; + }, + 'overcharged bytes': v => { + v.bytes++; + }, + 'over-budget bytes': v => { + v.bytes = 512 * 1024 * 1024 + 1; + }, + 'undercounted artifacts': v => { + v.artifacts--; + }, + 'overcounted artifacts': v => { + v.artifacts++; + }, + 'over-budget artifact count': v => { + v.artifacts = 257; + }, +}; + +for (const [name, corrupt] of Object.entries(cases)) { + test(`rejects ${name}`, () => { + const value = wire(); + corrupt(value); + assert.throws( + () => decodeRetention(pack(value)), + /Invalid checkpoint retention payload/ + ); + }); +} + +test('refuses to serialize inconsistent state', () => { + assert.throws( + () => encodeRetention({ ...fixture(), bytes: 0 }), + /Invalid checkpoint retention payload/ + ); +}); diff --git a/packages/code/src/checkpoint-retention-codec.ts b/packages/code/src/checkpoint-retention-codec.ts new file mode 100644 index 00000000..6ec3c236 --- /dev/null +++ b/packages/code/src/checkpoint-retention-codec.ts @@ -0,0 +1,158 @@ +import type { Artifact, Lane, State } from './checkpoint-retention.js'; + +import { + isLane, + maxArtifacts, + maxBytes, + maxLanes, +} from './checkpoint-retention.js'; + +// At most 256 lane records and 256 charged artifacts with fixed-width IDs +// and safe integers. Leave slack above the largest v1 encoding, below the catalog cap. +const limit = 128 * 1024; +const version = 1; + +function invalid(): never { + throw new Error('Invalid checkpoint retention payload'); +} + +function record( + value: unknown, + keys: readonly string[] +): Record { + if (typeof value !== 'object' || value === null || Array.isArray(value)) + invalid(); + if ( + Object.keys(value).length !== keys.length || + !keys.every(key => Object.hasOwn(value, key)) + ) + invalid(); + return value as Record; +} + +function list(value: unknown, max: number): readonly unknown[] { + if (!Array.isArray(value) || value.length > max) invalid(); + return value; +} + +function integer( + value: unknown, + min: number, + max = Number.MAX_SAFE_INTEGER +): number { + if ( + typeof value !== 'number' || + !Number.isSafeInteger(value) || + value < min || + value > max || + Object.is(value, -0) + ) + invalid(); + return value; +} + +function wire(state: State) { + return { + version, + lanes: [...state.lanes], + garbage: state.garbage, + artifacts: state.artifacts, + bytes: state.bytes, + }; +} + +function validate(value: unknown): State { + const root = record(value, [ + 'version', + 'lanes', + 'garbage', + 'artifacts', + 'bytes', + ]); + if (root.version !== version) invalid(); + const artifacts = integer(root.artifacts, 0, maxArtifacts); + const bytes = integer(root.bytes, 0, maxBytes); + const lanes = new Map(); + const charged = new Set(); + let total = 0; + function charge( + entry: Record, + expected?: string + ): Artifact { + const { lane, sequence } = record(entry.ref, ['lane', 'sequence']); + if (!isLane(lane) || (expected !== undefined && lane !== expected)) + invalid(); + const seq = integer(sequence, 1); + const size = integer(entry.bytes, 1, maxBytes); + const key = `${lane}:${seq}`; + if ( + charged.has(key) || + charged.size >= artifacts || + size > bytes - total + ) + invalid(); + charged.add(key); + total += size; + return { ref: { lane, sequence: seq }, bytes: size }; + } + + for (const pair of list(root.lanes, maxLanes)) { + const [lane, item] = list(pair, 2); + if (!isLane(lane) || lanes.has(lane)) invalid(); + const entry = record(item, ['sequence', 'pending', 'verified']); + const sequence = integer(entry.sequence, 0); + const verified = + entry.verified === null + ? null + : charge(record(entry.verified, ['ref', 'bytes']), lane); + const candidate = + entry.pending === null + ? null + : record(entry.pending, ['ref', 'bytes', 'expiresAt']); + const pending = candidate && { + ...charge(candidate, lane), + expiresAt: integer(candidate.expiresAt, 1), + }; + if ( + (pending && pending.ref.sequence !== sequence) || + (verified && verified.ref.sequence > sequence) + ) + invalid(); + lanes.set(lane, { sequence, pending, verified }); + } + + const garbage = list(root.garbage, maxArtifacts).map(item => { + const entry = charge(record(item, ['ref', 'bytes'])); + const lane = lanes.get(entry.ref.lane); + if (!lane || entry.ref.sequence > lane.sequence) invalid(); + return entry; + }); + if (charged.size !== artifacts || total !== bytes) invalid(); + return { lanes, garbage, artifacts, bytes }; +} + +function serialize(state: State): Buffer { + return Buffer.from(JSON.stringify(wire(state))); +} + +export function encodeRetention(state: State): Buffer { + if (state.lanes.size > maxLanes) invalid(); + const payload = serialize(validate(wire(state))); + if (payload.length > limit) invalid(); + return payload; +} + +export function decodeRetention(payload: Buffer): State { + if (!payload.length || payload.length > limit) invalid(); + let value: unknown; + try { + value = JSON.parse(payload.toString('utf8')); + } catch { + invalid(); + } + const state = validate(value); + // Byte equality enforces the v1 wire spelling and rejects duplicate fields + // and malformed UTF-8 that JSON.parse could otherwise normalize. + if (!serialize(state).equals(payload)) invalid(); + return state; +} diff --git a/packages/code/src/checkpoint-retention-store.test.ts b/packages/code/src/checkpoint-retention-store.test.ts new file mode 100644 index 00000000..0d3ab884 --- /dev/null +++ b/packages/code/src/checkpoint-retention-store.test.ts @@ -0,0 +1,197 @@ +import assert from 'node:assert/strict'; +import { constants } from 'node:fs'; +import { + mkdtemp, + open, + readFile, + readdir, + rm, + stat, + unlink, +} from 'node:fs/promises'; +import { tmpdir } from 'node:os'; +import { join } from 'node:path'; +import { test } from 'node:test'; +import type { TestContext } from 'node:test'; +import type { FileHandle } from 'node:fs/promises'; + +import { + applyRetentionStore, + initializeRetentionStore, + readRetentionStore, +} from './checkpoint-retention-store.js'; +import { emptyRetention } from './checkpoint-retention.js'; +import { CheckpointCatalog } from './checkpoint-catalog.js'; +import { tryLockDescriptor } from './process-lock.js'; + +const options = { skip: process.platform !== 'linux' }; +const lane = 'a'.repeat(64); +const ref = (sequence: number) => ({ lane, sequence }); +const enroll = { kind: 'enroll', lane } as const; +const reserve = (expectedSequence: number) => + ({ + kind: 'reserve', + lane, + expectedSequence, + bytes: 4, + now: 0, + expiresAt: 10, + } as const); +const promote = (sequence: number) => + ({ + kind: 'promote', + ref: ref(sequence), + expectedVerified: sequence === 1 ? null : ref(sequence - 1), + now: 1, + } as const); + +async function fixture(t: TestContext) { + const dir = await mkdtemp(join(tmpdir(), 'checkpoint-retention-')); + t.after(() => rm(dir, { recursive: true, force: true })); + // Use real flock without a production grant verifier or mount admission. + async function lease( + operation: (root: FileHandle) => Promise + ): Promise { + const root = await open( + dir, + constants.O_RDONLY | constants.O_DIRECTORY | constants.O_NOFOLLOW + ); + try { + assert.equal(await tryLockDescriptor(root.fd), true); + return await operation(root); + } finally { + await root.close(); + } + } + return { dir, file: join(dir, 'catalog'), lease }; +} + +test( + 'reopens durable metadata and atomically replaces the verified pointer and garbage root', + options, + async t => { + const { dir, file, lease } = await fixture(t); + const apply = (command: Parameters[1]) => + lease(root => applyRetentionStore(root, command)); + await lease(initializeRetentionStore); + assert.deepEqual(await lease(readRetentionStore), emptyRetention()); + for (const command of [enroll, reserve(0), promote(1), reserve(1)]) { + assert.equal(await apply(command), 'applied'); + } + const before = await lease(readRetentionStore); + const inode = (await stat(file)).ino; + assert.equal(await apply(reserve(2)), 'conflict'); + assert.equal((await stat(file)).ino, inode); + assert.equal(await apply(promote(2)), 'applied'); + assert.notEqual((await stat(file)).ino, inode); + const after = await lease(readRetentionStore); + assert.deepEqual(after.lanes.get(lane), { + sequence: 2, + pending: null, + verified: { ref: ref(2), bytes: 4 }, + }); + assert.deepEqual(after.garbage, [{ ref: ref(1), bytes: 4 }]); + assert.equal(after.bytes, before.bytes); + assert.equal(after.artifacts, before.artifacts); + const committed = (await stat(file)).ino; + assert.equal(await apply(promote(2)), 'already-current'); + assert.equal((await stat(file)).ino, committed); + assert.deepEqual(await readdir(dir), ['catalog']); + } +); + +test( + 'rejects missing and semantically corrupt catalogs without initializing or replacing them', + options, + async t => { + const { dir, file, lease } = await fixture(t); + await assert.rejects( + lease(root => applyRetentionStore(root, enroll)), + { code: 'ENOENT' } + ); + assert.deepEqual(await readdir(dir), []); + await lease(async root => { + await CheckpointCatalog.initialize( + root, + Buffer.from( + '{"version":1,"lanes":[],"garbage":[],"artifacts":1,"bytes":1}' + ) + ); + }); + const bytes = await readFile(file); + await assert.rejects( + lease(readRetentionStore), + /Invalid checkpoint retention payload/ + ); + await assert.rejects( + lease(root => applyRetentionStore(root, enroll)), + /Invalid checkpoint retention payload/ + ); + await assert.rejects(lease(initializeRetentionStore), /already exists/); + assert.deepEqual(await readFile(file), bytes); + await unlink(file); + assert.deepEqual(await readdir(dir), []); + } +); + +test( + 'rejects concurrent work on the same leased handle and refuses charge release', + options, + async t => { + const { file, lease } = await fixture(t); + await lease(async root => { + await initializeRetentionStore(root); + const first = applyRetentionStore(root, enroll); + await assert.rejects( + applyRetentionStore(root, enroll), + /unavailable/ + ); + assert.equal(await first, 'applied'); + assert.equal( + await applyRetentionStore(root, reserve(0)), + 'applied' + ); + assert.equal( + await applyRetentionStore(root, { + kind: 'discard', + ref: ref(1), + }), + 'applied' + ); + const before = await readFile(file); + await assert.rejects( + // @ts-expect-error The dark store must not acknowledge reclamation. + applyRetentionStore(root, { kind: 'reclaimed', ref: ref(1) }), + /Invalid checkpoint retention store command/ + ); + assert.deepEqual(await readFile(file), before); + assert.equal((await readRetentionStore(root)).bytes, 4); + }); + } +); + +test( + 'does not acknowledge ambiguous replacement and requires a fresh lease for reopen', + options, + async t => { + const { lease } = await fixture(t); + await lease(initializeRetentionStore); + await lease(async root => { + const sync = root.sync.bind(root); + let calls = 0; + t.mock.method(root, 'sync', async () => { + if (++calls === 2) + throw new Error('injected directory sync failure'); + await sync(); + }); + await assert.rejects( + applyRetentionStore(root, enroll), + /injected directory sync failure/ + ); + await assert.rejects(readRetentionStore(root), /unavailable/); + assert.equal(calls, 2); + }); + const state = await lease(readRetentionStore); + assert.equal(state.lanes.get(lane)?.sequence, 0); + } +); diff --git a/packages/code/src/checkpoint-retention-store.ts b/packages/code/src/checkpoint-retention-store.ts new file mode 100644 index 00000000..fea99c48 --- /dev/null +++ b/packages/code/src/checkpoint-retention-store.ts @@ -0,0 +1,84 @@ +import type { FileHandle } from 'node:fs/promises'; + +import { + decodeRetention, + encodeRetention, +} from './checkpoint-retention-codec.js'; +import { emptyRetention, transitionRetention } from './checkpoint-retention.js'; +import { CheckpointCatalog } from './checkpoint-catalog.js'; + +type Command = Exclude< + Parameters[1], + { kind: 'reclaimed' } +>; +type Status = ReturnType['status']; + +const active = new WeakSet(); + +/** + * Use only with the original handle borrowed from withCheckpointDirectory. + * Await the operation before releasing the lease; any other catalog access + * must honor that lease. Do not retry inside a lease after a storage failure. + */ +async function use( + root: FileHandle, + operation: () => Promise +): Promise { + if (active.has(root)) + throw new Error('Checkpoint retention store unavailable'); + active.add(root); + // On failure leave this borrowed handle unavailable for the rest of its + // lease. Recovery must start from a fresh handle and a validated reopen. + const result = await operation(); + active.delete(root); + return result; +} + +/** Only for an independently known new store; never a reopen fallback. */ +export function initializeRetentionStore(root: FileHandle): Promise { + return use(root, async () => { + await CheckpointCatalog.initialize( + root, + encodeRetention(emptyRetention()) + ); + }); +} + +/** Returns a metadata snapshot, not an artifact pin or authority. */ +export function readRetentionStore(root: FileHandle) { + return use(root, async () => { + const catalog = await CheckpointCatalog.open(root); + return decodeRetention(await catalog.read()); + }); +} + +/** + * Dark bookkeeping only. Live authority, durable bytes and fresh proof must + * be joined under the commit fence before wiring promotion into the runtime. + * The input is a trusted internal command; no operation releases charges. + */ +export async function applyRetentionStore( + root: FileHandle, + command: Command +): Promise { + const requested = structuredClone(command); + switch (requested.kind) { + case 'enroll': + case 'reserve': + case 'promote': + case 'discard': + break; + default: + throw new Error('Invalid checkpoint retention store command'); + } + return use(root, async () => { + const catalog = await CheckpointCatalog.open(root); + const result = transitionRetention( + decodeRetention(await catalog.read()), + requested + ); + if (result.status === 'applied') + await catalog.replace(encodeRetention(result.state)); + return result.status; + }); +} diff --git a/packages/code/src/checkpoint-retention.ts b/packages/code/src/checkpoint-retention.ts index 2a09bcca..86eaf2e6 100644 --- a/packages/code/src/checkpoint-retention.ts +++ b/packages/code/src/checkpoint-retention.ts @@ -1,17 +1,17 @@ -const maxLanes = 256; -const maxArtifacts = 256; -const maxBytes = 512 * 1024 * 1024; +export const maxLanes = 256; +export const maxArtifacts = 256; +export const maxBytes = 512 * 1024 * 1024; const incarnation = /^[0-9a-f]{64}$/; type Ref = Readonly<{ lane: string; sequence: number }>; -type Artifact = Readonly<{ ref: Ref; bytes: number }>; +export type Artifact = Readonly<{ ref: Ref; bytes: number }>; type Pending = Artifact & Readonly<{ expiresAt: number }>; -type Lane = Readonly<{ +export type Lane = Readonly<{ sequence: number; pending: Pending | null; verified: Artifact | null; }>; -type State = Readonly<{ +export type State = Readonly<{ lanes: ReadonlyMap; garbage: readonly Artifact[]; artifacts: number; @@ -48,6 +48,14 @@ function same(left: Ref | null, right: Ref | null): boolean { return left.lane === right.lane && left.sequence === right.sequence; } +export function isLane(value: unknown): value is string { + return ( + typeof value === 'string' && + value.length === 64 && + incarnation.test(value) + ); +} + function time(value: number): boolean { return Number.isSafeInteger(value) && value >= 0; } @@ -92,8 +100,7 @@ export function transitionRetention( }; if (command.kind === 'enroll') { - if (lane.length !== 64 || !incarnation.test(lane)) - return reject('invalid'); + if (!isLane(lane)) return reject('invalid'); if (current) return reject('conflict'); if (state.lanes.size >= maxLanes) return reject('full'); return update({ sequence: 0, pending: null, verified: null });