Preserve learning and size verified bundles

This commit is contained in:
Theodore Song
2026-08-21 23:20:09 -04:00
parent 5e4355b850
commit c52368dc9e
8 changed files with 119 additions and 58 deletions
+1 -1
View File
@@ -128,7 +128,7 @@ async function main() {
const branch = process.env.RUNTIME_BRANCH || "runtime-state";
const pathname = process.env.RUNTIME_STATE_PATH || "runtime/state.json";
const arenaUrl = (process.env.ARENA_URL || "https://polymarket-site-eta.vercel.app").replace(/\/$/, "");
const expectedBuild = Number(required("EXPECTED_BUILD", "115"));
const expectedBuild = Number(required("EXPECTED_BUILD", "116"));
await ensureRuntimeBranch(repository, branch);
const prior = await readRuntimeFile(repository, branch, pathname);
if (prior.snapshot) validateRuntimeSnapshot(prior.snapshot, 0, { allowIncomplete: true });
+6 -2
View File
@@ -10,7 +10,7 @@ const resolutionAudit = JSON.parse(fs.readFileSync(new URL("../research/resoluti
const sportsContestAudit = JSON.parse(fs.readFileSync(new URL("../research/sports-contest-no-exploration-audit.json", import.meta.url), "utf8"));
const build = Number(index.match(/const BUILD_VERSION = (\d+);/)?.[1]);
assert.equal(build, 115);
assert.equal(build, 116);
assert.deepEqual([...ALLOWED_RUNTIME_KEYS].sort(), ["pma_agents_v2", "pma_suggestions_v5"]);
assert.match(index, /function collectPublicRuntimeItems\(\)/);
assert.match(index, /const PUBLIC_RUNTIME_KEYS=Object\.freeze\(\[AGENTS_KEY,SUG_KEY\]\)/);
@@ -40,7 +40,7 @@ assert.match(api, /Buffer\.from\(file\.content/);
assert.match(api, /searchParams\.set\("runtime", `\$\{Date\.now\(\)\}/);
assert.match(workflow, /cron: "2,7,12,17,22,27,32,37,42,47,52,57 \* \* \* \*"/);
assert.match(workflow, /contents: write/);
assert.match(workflow, /EXPECTED_BUILD: "115"/);
assert.match(workflow, /EXPECTED_BUILD: "116"/);
assert.match(workflow, /actions: write/);
assert.match(workflow, /cancel-in-progress: false/);
assert.match(workflow, /next=\$\(\( \(now \/ 300 \+ 1\) \* 300 \+ 15 \)\)/);
@@ -54,6 +54,10 @@ assert.match(index, /const BUNDLE_DEPTH_CANDIDATE_LIMIT=60;/);
assert.match(index, /bundleRequiresDepthVerification:true/);
assert.match(index, /bundleRequiresClobFeeVerification:true/);
assert.match(index, /function bundleExecutableLeg\(book,units,feeSchedule\)/);
assert.match(index, /function maximizeBundleExecution\(candidate,books,minimumUnits\)/);
assert.match(index, /const BUNDLE_MAX_VERIFIED_NOTIONAL=400;/);
assert.match(index, /sizesToLargestVerifiedProfitableFill:/);
assert.match(index, /stopsSizingAtShallowestBundleLeg:/);
assert.match(index, /!s\.depth_verified\|\|!s\.fees_verified\|\|s\.verification_status!=="executable"/);
assert.match(runner, /MAX_STATE_BYTES = 900_000/);
assert.equal(resolutionAudit.strategy, "resolution-window-no-50-55-forward-shadow-v3");
+25 -1
View File
@@ -1,12 +1,15 @@
import assert from "node:assert/strict";
import { databaseConnectionDiagnostics, databaseUrl, databaseUrls, normalizeDatabaseUrl } from "../lib/db.js";
import { compactAgentState, compactSuggestion, providerErrorCode, sanitizeGithubRuntimeState } from "../api/state.js";
import { compactAgentState, compactSuggestion, cycleVersion, providerErrorCode, sanitizeGithubRuntimeState } from "../api/state.js";
assert.equal(normalizeDatabaseUrl("psql 'postgresql://user:pass@example.test/db?sslmode=require'"),
"postgresql://user:pass@example.test/db?sslmode=require");
assert.equal(normalizeDatabaseUrl('"postgres://user:pass@example.test/db"'), "postgres://user:pass@example.test/db");
assert.equal(normalizeDatabaseUrl("DATABASE_URL=postgresql://user:pass@example.test/db"),
"postgresql://user:pass@example.test/db");
assert.equal(cycleVersion("2026-08-21T20|v59"), 59);
assert.equal(cycleVersion("2026-08-21T20:05|s62"), 62);
assert.equal(cycleVersion("2026-08-21T20:05"), 0);
const originalDatabaseUrl = process.env.DATABASE_URL;
const originalNeonUrl = process.env.NEON_DATABASE_URL;
@@ -32,6 +35,9 @@ const compacted = compactSuggestion({
entry_candidate: true, adaptive_promotion: false, requires_live: true, bundle_id: "bundle:1:yes",
bundle_side: "YES", bundle_logic: "threshold-dominance", bundle_cost_per_unit: 0.95, bundle_payout_per_unit: 1,
bundle_net_profit_per_unit: 0.05, bundle_legs: [{ market_id: "1", side: "YES" }],
fees_enabled: false, fee_schedule: { rate: 0, exponent: 1, takerOnly: true },
depth_verified: true, fees_verified: true, fee_model: "verified-market-specific", execution_model: "live-order-book-vwap",
execution_units: 250, execution_notional: 237.5, verification_status: "executable", promoted_for_agents: ["value"],
});
assert.equal(compacted.signal_type, "bundle-arb");
assert.equal(compacted.entry_candidate, true);
@@ -39,6 +45,10 @@ assert.equal(compacted.requires_live, true);
assert.equal(compacted.bundle_side, "YES");
assert.equal(compacted.bundle_logic, "threshold-dominance");
assert.equal(compacted.bundle_legs.length, 1);
assert.equal(compacted.fee_schedule.rate, 0);
assert.equal(compacted.execution_units, 250);
assert.equal(compacted.verification_status, "executable");
assert.deepEqual(compacted.promoted_for_agents, ["value"]);
const compactedShock = compactSuggestion({
market_id: "shock:1", event_key: "event:1", side: "NO", signal_type: "shock-fade-shadow",
@@ -64,6 +74,20 @@ assert.equal(compactedState.signal_ledger.expired_ungraded, 7);
assert.equal(compactedState.agents.reversal.shock_fade_shadows[0].shock_strategy_version, 3);
assert.equal(compactedState.agents.reversal.shock_fade_outcomes[0].net_return, 0.08);
const ledgerOrder = compactAgentState({
agents: {},
signal_ledger: {
pending: Array.from({ length: 650 }, (_, i) => ({ key: `pending-${i}` })),
outcomes: Array.from({ length: 1050 }, (_, i) => ({ key: `outcome-${i}` })),
},
}).signal_ledger;
assert.equal(ledgerOrder.pending.length, 600);
assert.equal(ledgerOrder.pending[0].key, "pending-0");
assert.equal(ledgerOrder.pending.at(-1).key, "pending-599");
assert.equal(ledgerOrder.outcomes.length, 1000);
assert.equal(ledgerOrder.outcomes[0].key, "outcome-50");
assert.equal(ledgerOrder.outcomes.at(-1).key, "outcome-1049");
const publicAgents = Object.fromEntries([
"value", "momentum", "favorite", "longshot", "diversifier", "catalyst", "reversal", "breakout", "tailalpha", "conviction",
].map(id => [id, { cash: 10000, positions: [], closed: [], history: [], snapshots: [] }]));