You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 48ee020
Browse filesBrowse the repository at this point in the historyBrowse files
hzq
committed
Page and retry legacy platform settlement
Bound startup reconciliation, verify account and run evidence before charging, and retry storage failures from the durable unsettled hold. Preserve repayment order within an account with unreadable legacy evidence.
Copy file name to clipboardExpand all lines: src/gateway/platform-db.ts
+4-1Lines changed: 4 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -70,6 +70,7 @@ CREATE TABLE IF NOT EXISTS platform_code_uses(code_id TEXT NOT NULL,account_id T
70
70
CREATE TABLE IF NOT EXISTS platform_ledger(id INTEGER PRIMARY KEY AUTOINCREMENT,owner TEXT NOT NULL,account_id TEXT NOT NULL,kind TEXT NOT NULL,amount INTEGER NOT NULL,balance_after INTEGER NOT NULL,run_id TEXT UNIQUE,agent TEXT,tokens INTEGER NOT NULL DEFAULT 0,status TEXT,note TEXT,payload TEXT NOT NULL,created_at INTEGER NOT NULL);
71
71
CREATE INDEX IF NOT EXISTS platform_ledger_account ON platform_ledger(account_id,id);
72
72
CREATE INDEX IF NOT EXISTS platform_ledger_time ON platform_ledger(owner,created_at);
73
+
CREATE INDEX IF NOT EXISTS platform_unsettled_runs ON platform_ledger(owner,id) WHERE kind='run' AND status='in_progress';
73
74
CREATE TABLE IF NOT EXISTS platform_references(owner TEXT NOT NULL,reference TEXT NOT NULL,entry_id INTEGER NOT NULL UNIQUE,created_at INTEGER NOT NULL,PRIMARY KEY(owner,reference));
74
75
CREATE TABLE IF NOT EXISTS platform_reset_codes(account_id TEXT PRIMARY KEY,owner TEXT NOT NULL,hash TEXT NOT NULL,expires_at INTEGER NOT NULL,created_at INTEGER NOT NULL);
75
76
CREATE TABLE IF NOT EXISTS platform_rate_limits(bucket TEXT NOT NULL,key TEXT NOT NULL,window_start INTEGER NOT NULL,count INTEGER NOT NULL,expires_at INTEGER NOT NULL,PRIMARY KEY(bucket,key));
@@ -81,10 +82,12 @@ CREATE TABLE IF NOT EXISTS platform_verification_secrets(owner TEXT PRIMARY KEY,
81
82
/** Runs `fn` in one IMMEDIATE transaction (or inside the caller's, if one is open). */
0 commit comments