Rebuild Piggy's interface, and give the demo book a business to describe
CI / verify (push) Successful in 4m57s
CI / publish (push) Has been skipped

Piggy answered in raw markdown, threw away every tool result it streamed,
and fought the reader's scroll on every token. The three surfaces that
made it worth having — what it read, how it reasoned, what it cost — were
all on the wire and none of them reached the screen.

The transcript is now composed of five parts under components/piggy:
answers render through streamdown, the container sticks to the bottom
without pinning the reader there, tool steps say what they read and link
to the record, and each turn carries its model and token count. Three
lifecycle bugs went with them: Stop left a permanent spinner, a truncated
stream was indistinguishable from thinking, and a failed send destroyed
the message it failed to send.

Underneath, the inference path grew timeouts, jittered retries on 429 and
5xx, tolerance of the malformed frames a 30B model emits, and an
agent_runs row per turn so chat spend is observable. The system prompt now
states that a field ending in Cents is cents — without it nemotron renders
costPerGpuHourCents: 189 as "$189 per GPU-hour", which is a 100x error on
the most scrutinised number in the room.

The demo book was arithmetically incoherent: every deal's value
contradicted its own allocation revenue by up to 3.6x, nothing had ever
closed, no customer had any paper, and the marketplace was empty. Deal
value is now derived from the allocation, the book clears 5.3% across five
blocks with one deliberately underwater, and the renewal, compliance and
agent-provenance machinery finally has rows to act on. A --clear that
deleted every obligation, SLA term and capacity request in the database
regardless of origin is scoped to the demo's own ids.

Around that: accounts have a detail page, ⌘K searches the book, Settings
can mint the API keys it always claimed to, and deploy.sh actually ships
the agent instead of silently skipping its compose profile.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
claude
2026-08-14 00:33:41 -07:00
parent 76e3caa1cb
commit 99d165b5e5
81 changed files with 21780 additions and 2250 deletions
+99 -12
View File
@@ -15,9 +15,12 @@
* commitment, two allocations against it, and therefore a real margin
* number and a real idle-capacity alert on the dashboard.
*
* The example is clearly labelled. Nobody should mistake it for real business.
* The example is clearly labelled, and the company buying is invented. Real
* named companies appear here only with a source; commercial terms attached to
* one would be a fabricated record about someone else's business. The same rule
* `demo.ts` states, obeyed here too.
*/
import { eq } from 'drizzle-orm';
import { and, eq, ne } from 'drizzle-orm';
import { createDatabase } from '../client';
import {
accounts,
@@ -214,6 +217,12 @@ async function seed() {
// Illustrative only, and labelled as such. It exists so the dashboard has a
// real margin figure and a real idle-capacity alert on first run, rather
// than empty states that make the product look like it does nothing.
//
// The supplier is real and its block is illustrative; the buyer is invented
// outright. Naming a real company as the counterparty to an invented ACV with
// MSA and DPA flagged executed is a fabricated commercial record about that
// company, which no amount of an `EXAMPLE — ` prefix on the neighbouring rows
// makes acceptable.
const [supplier] = await db
.select({ id: accounts.id })
.from(accounts)
@@ -227,6 +236,10 @@ async function seed() {
.where(eq(capacityCommitments.name, EXAMPLE_COMMITMENT))
.limit(1);
// Before anything is created: repair the databases that already carry the
// example booked against a real company.
await rehomeExampleDeal();
if (supplier && !existingExample) {
const start = new Date();
const end = new Date(start.getTime() + 180 * 86_400_000);
@@ -259,18 +272,14 @@ async function seed() {
.returning();
if (commitment) {
const [customer] = await db
.select({ id: accounts.id })
.from(accounts)
.where(eq(accounts.name, 'Ramp'))
.limit(1);
const customerId = await ensureExampleCustomer();
if (customer) {
if (customerId) {
const [deal] = await db
.insert(demandDeals)
.values({
accountId: customer.id,
name: 'EXAMPLE — post-training cluster',
accountId: customerId,
name: EXAMPLE_DEAL,
productLine: 'compute_reserved',
stage: 'deployment',
acvCents: 340_000_00,
@@ -323,8 +332,9 @@ async function seed() {
});
console.log(
' Worked example seeded: 1 commitment, 2 allocations (one of them internal ' +
'research burn), ~+10% margin with 20% still idle.',
` Worked example seeded against ${EXAMPLE_CUSTOMER} (fictional): 1 commitment, ` +
'2 allocations (one of them internal research burn), ~+10% margin with 20% ' +
'still idle.',
);
}
}
@@ -379,6 +389,83 @@ async function seed() {
console.log('\nDone. No email addresses were seeded or inferred.');
}
// -------------------------------------------------- the example's counterparty
const EXAMPLE_CUSTOMER = 'EXAMPLE — Fenwick Labs';
const EXAMPLE_DEAL = 'EXAMPLE — post-training cluster';
/**
* The invented company the worked example is sold to.
*
* An existence check rather than `onConflictDoNothing()`, for the same reason
* as the customer references above: this account deliberately has no domain —
* it is not a real company and must never be mistaken for one — and `domain`
* is the only unique index on `accounts`, so a conflict clause would have
* nothing to fire on and every run would add another Fenwick Labs.
*/
async function ensureExampleCustomer(): Promise<string | undefined> {
const [existing] = await db
.select({ id: accounts.id })
.from(accounts)
.where(eq(accounts.name, EXAMPLE_CUSTOMER))
.limit(1);
if (existing) return existing.id;
const [created] = await db
.insert(accounts)
.values({
name: EXAMPLE_CUSTOMER,
side: 'demand',
customerSegment: 'applied_ai_startup',
country: 'United States',
description:
'Fictional company, invented so the worked example has a buyer. Not a ' +
'customer, not a real business, and safe to delete along with the example.',
source: 'seed',
confidence: 'confirmed',
})
.returning();
return created?.id;
}
/**
* Move the example deal off whatever account an older seed attached it to.
*
* This example used to be booked against Ramp — a real company, seeded from a
* public reference on primeintellect.ai — complete with an invented ACV and
* both MSA and DPA flagged executed. Fixing the insert is not enough on its
* own: the worked-example section is skipped entirely whenever the commitment
* already exists, so a database seeded before the fix would keep it, and
* `pnpm db:demo -- --clear` never touched it because that only matches the
* `DEMO — ` prefix.
*
* Moved rather than deleted. The allocations hang off the deal, and they are
* what give the dashboard its margin figure and its idle-capacity alert; the
* problem was only ever which account the row pointed at.
*/
async function rehomeExampleDeal(): Promise<void> {
const [present] = await db
.select({ id: demandDeals.id })
.from(demandDeals)
.where(eq(demandDeals.name, EXAMPLE_DEAL))
.limit(1);
if (!present) return;
const customerId = await ensureExampleCustomer();
if (!customerId) return;
const moved = await db
.update(demandDeals)
.set({ accountId: customerId })
.where(and(eq(demandDeals.name, EXAMPLE_DEAL), ne(demandDeals.accountId, customerId)))
.returning({ id: demandDeals.id });
if (moved.length > 0) {
console.log(` Worked example moved off a real company and onto ${EXAMPLE_CUSTOMER}.`);
}
}
seed()
.then(() => process.exit(0))
.catch((error) => {