Build the agent-native compute CRM platform
CI / verify (push) Successful in 3m6s

This commit is contained in:
2026-08-13 01:39:01 -07:00
parent bfd2f8d95a
commit 853bde2265
160 changed files with 61812 additions and 483 deletions
+50 -20
View File
@@ -35,6 +35,7 @@
* is more useful than one that opens on a loss, which reads as a broken
* product rather than an under-utilised book.
*/
import { ALLOCATION_STATUSES, type AllocationStatus } from '@pig/core';
import { and, eq, like, or } from 'drizzle-orm';
import { createDatabase } from '../client';
import {
@@ -47,6 +48,7 @@ import {
contracts,
contractObligations,
demandDeals,
type NewAllocation,
sites,
slaTerms,
supplyDeals,
@@ -59,6 +61,10 @@ const day = 86_400_000;
const now = Date.now();
const at = (days: number) => new Date(now + days * day);
function isAllocationStatus(value: string): value is AllocationStatus {
return (ALLOCATION_STATUSES as readonly string[]).includes(value);
}
/** GPU-hours for a block, allowing for a maintenance/ramp haircut. */
const hours = (gpus: number, days: number, efficiency = 0.94) =>
String(Math.round(gpus * 24 * days * efficiency));
@@ -153,7 +159,12 @@ const DEMAND = [
},
request: { gpuType: 'H200', gpuCount: 256, fastFabric: true, maxPriceCents: 285 },
// Draws from the CoreWeave block.
allocation: { supplier: 'coreweave.com', share: 0.76, priceCents: 271, status: 'active' },
allocation: {
supplier: 'coreweave.com',
share: 0.76,
priceCents: 271,
status: 'active',
},
},
{
account: `${PREFIX}Verity Health AI`,
@@ -178,7 +189,12 @@ const DEMAND = [
allowedRegions: ['eu-north', 'eu-west'],
certifications: ['ISO 27001', 'SOC 2 Type II'],
},
allocation: { supplier: 'nebius.com', share: 0.55, priceCents: 249, status: 'committed' },
allocation: {
supplier: 'nebius.com',
share: 0.55,
priceCents: 249,
status: 'committed',
},
},
{
account: `${PREFIX}Northwind Robotics`,
@@ -195,7 +211,12 @@ const DEMAND = [
dpaExecuted: true,
},
request: { gpuType: 'B200', gpuCount: 32, fastFabric: true, maxPriceCents: 460 },
allocation: { supplier: 'crusoe.ai', share: 0.74, priceCents: 441, status: 'active' },
allocation: {
supplier: 'crusoe.ai',
share: 0.74,
priceCents: 441,
status: 'active',
},
},
{
account: `${PREFIX}Tessellate Labs`,
@@ -215,7 +236,13 @@ const DEMAND = [
// A HOLD, not a sale. The deal has not closed, so this reserves capacity
// without counting as revenue — the distinction the capacity view exists
// to make visible.
allocation: { supplier: 'runpod.io', share: 0.55, priceCents: 168, status: 'planned', holdDays: 12 },
allocation: {
supplier: 'runpod.io',
share: 0.55,
priceCents: 168,
status: 'planned',
holdDays: 12,
},
},
{
account: `${PREFIX}Aurelian Systems`,
@@ -554,7 +581,10 @@ async function seedDemo() {
.limit(1);
if (commitment) {
await db.insert(allocations).values({
if (!isAllocationStatus(d.allocation.status)) {
throw new Error(`Invalid demo allocation status: ${d.allocation.status}`);
}
const allocationRow = {
capacityCommitmentId: commitmentId,
demandDealId: deal.id,
gpuHours: String(
@@ -568,7 +598,8 @@ async function seedDemo() {
priority: d.allocation.status === 'planned' ? 100 : 10,
holdExpiresAt: d.allocation.holdDays ? at(d.allocation.holdDays) : null,
notes: d.account,
});
} satisfies NewAllocation;
await db.insert(allocations).values(allocationRow);
}
}
}
@@ -613,20 +644,19 @@ async function seedDemo() {
.limit(1);
if (commitment && !existingResearch) {
await db
.insert(allocations)
.values({
capacityCommitmentId: coreweave,
internalTeam: 'research',
gpuHours: String(Math.round(Number(commitment.totalGpuHours) * 0.08)),
pricePerGpuHourCents: 0,
startsAt: commitment.startsAt,
endsAt: commitment.endsAt,
status: 'active',
guaranteeType: 'internal',
priority: 200,
notes: RESEARCH_NOTE,
});
const researchAllocationRow = {
capacityCommitmentId: coreweave,
internalTeam: 'research',
gpuHours: String(Math.round(Number(commitment.totalGpuHours) * 0.08)),
pricePerGpuHourCents: 0,
startsAt: commitment.startsAt,
endsAt: commitment.endsAt,
status: 'active',
guaranteeType: 'internal',
priority: 200,
notes: RESEARCH_NOTE,
} satisfies NewAllocation;
await db.insert(allocations).values(researchAllocationRow);
}
}