Merge gitea/main into the Motion branch

Motion was written against a base five commits behind main, so the
integration is the interesting part of this commit:

- The migration is renumbered 0014 -> 0015. Main shipped
  0014_piggy_conversations, and two migrations sharing an index is a
  journal that applies one of them.
- The seed-idempotency gate keeps main's all-tables diff rather than the
  motion_templates counter this branch added; the general check subsumes
  the specific one.
- Nav gains a Motion group alongside main's new Workspace group, and
  Piggy keeps the mark main gave it.
- Stat keeps main's container-scaled figure, which already carries the
  min-w-0 this branch added for the same reason.
- Piggy's page labels keep main's refusal wording for the four pages with
  no tool of their own, and gain the three Motion routes.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-08-17 18:30:45 -07:00
149 changed files with 37440 additions and 3502 deletions
+22 -3
View File
@@ -46,8 +46,9 @@
* always run in; sections depend on ids the earlier ones return.
*/
import { quarterBoundsFor } from '@pig/core';
import { sql } from 'drizzle-orm';
import { createDatabase, type Database } from '../../client';
import { users } from '../../schema/index';
import { capacityCommitments, demandDeals, supplyDeals, users } from '../../schema/index';
import { seedSupplyActivities } from './activities';
import { seedFacts } from './agent';
import { seedCalendar } from './calendar';
@@ -182,14 +183,32 @@ export async function seedDemo(context: DemoContext): Promise<void> {
const facts = await seedFacts(context);
console.log(' 5 capacity commitments (4 live, 1 lapsed), with sites, MSAs and negotiated SLAs');
/*
* Counted, not asserted. These lines were hardcoded when the book was split
* into modules, and they drifted the moment the seed grew: the summary
* claimed 12 demand deals and 5 commitments against a database holding 13
* and 6. A seed that misreports what it wrote teaches an operator to
* distrust the only feedback the command gives them.
*/
const [written] = await context.db
.select({
commitments: sql<number>`(select count(*)::int from ${capacityCommitments})`,
demandDeals: sql<number>`(select count(*)::int from ${demandDeals})`,
supplyDeals: sql<number>`(select count(*)::int from ${supplyDeals})`,
demandStages: sql<number>`(select count(distinct stage)::int from ${demandDeals})`,
})
.from(sql`(select 1) as one`);
const book = written ?? { commitments: 0, demandDeals: 0, supplyDeals: 0, demandStages: 0 };
console.log(` ${book.commitments} capacity commitments, with sites, MSAs and negotiated SLAs`);
console.log(` ${facts.total} agent-derived facts (${facts.added} new) — 2 applied, 4 awaiting review`);
console.log(
` ${facts.tasks} agent tasks and ${facts.runs} Piggy runs, ${facts.actions} idempotency-keyed actions, ` +
`${(facts.costMicroCents / 1_000_000).toFixed(4)} cents of model spend`,
);
console.log(
' 12 demand deals across all ten stages — 2 won, 1 lost, 1 expansion off a closed parent — and 8 supply deals',
` ${book.demandDeals} demand deals across ${book.demandStages} stages — including a won parent with its ` +
`expansion child, and a loss with a reason — and ${book.supplyDeals} supply deals`,
);
console.log(' Allocations including one unconverted hold and internal research burn');
console.log(