Files
pig/docs/learn-scripts.md
T
claude f0173440e4
CI / verify (push) Successful in 7m6s
CI / publish (push) Has been skipped
Put Piggy on Prime Agent, and let it write to the book
Piggy was a hand-rolled OpenAI tool loop. It is now a Prime Agent session —
Prime Intellect's own harness, embedded as a Node library — answering from
PIG's tools and, for the first time, able to put information into the CRM
rather than only read it out.

The harness is a coding agent, so the first job was taking the coding agent
away from it. `noTools: 'all'` plus an explicit allowlist leaves the model
with PIG's ten `pig_*` tools and no bash, no filesystem, no IPython. That
holds under attack: a hostile extension, a skill and a settings file planted
in the agent's own directory, then `setActiveToolsByName` called with every
built-in, still leaves ten tools, all ours. Both lines are load-bearing —
`noTools` alone registers nothing, and the allowlist is what admits our own.

Writing is gated rather than assumed. A change is proposed, not made: the
tool returns a description, the transcript renders a diff card, and nothing
reaches the database until someone presses Apply. Contracts, commitments,
allocations and compliance always stop for a human whatever the mode. Every
write runs through `executeMutation` as the calling user, so their
capabilities and the audit trail apply exactly as they would to a human's.

Four things about the SDK are wrong in its own documentation and cost a
debugging cycle each: models.json does not resolve an env var name for
`apiKey`, it sends the literal string; there is no built-in prime-inference
provider in 0.84.1; a ResourceLoader you pass in is never reloaded for you;
and the stock system prompt is a coding-assistant prompt that must be
replaced — but replacing it also silently removes the tool list, because the
harness only renders that section when it owns the prompt. AGENTS.md records
all four.

The expensive one was thinking level. The harness defaults to `medium`, and
nemotron spent an entire 4,096-token budget reasoning and returned an empty
answer. `low` was worse; `off` omits the parameter so the endpoint's default
wins. An explicit `reasoning_effort: none` via `thinkingLevelMap` took a turn
from 6,195 output tokens to 149.

And a turn is now bounded. The harness loop is `while (true)` with no
iteration cap; a runaway on a frontier model would have eaten the credit it
is supposed to report on. Ceilings on model calls and tokens, enforced both
through the harness hook and independently from the event stream, plus a
per-user daily spend limit — and the ledger now records spend on turns that
fail, which it previously discarded.

Signing in lands on /piggy, which is a workspace: conversations down one
side, the agent in the middle, what it did and what it cost beside it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-14 05:26:28 -07:00

215 lines
14 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Learn — video scripts
Five ~30-second platform-track walkthroughs for the Prime Intellect GTM team.
Each one becomes a `learn_resources` row on the `platform` track: the **title**
and **summary** below are that row's `title` and `summary`, and the **slug** is
the capture filename.
Everything asserted in these scripts was checked against the page component,
the route handler and a running instance on `http://127.0.0.1:8925` seeded with
the demo book. Nothing is described that the product does not do.
## Constraints these scripts are written to
The audio is Chatterbox TTS in Karti's cloned voice, sped to 1.20x. Measured on
that service: ~2.83 words/sec at 1.0x, ~3.4 words/sec at 1.20x. A 30-second
finished clip is therefore **95105 words total**, opener and closer included.
Every script opens with exactly `Hi team, check out this feature we worked on:`
(9 words) and closes with exactly `thanks for watching!` (3 words). Word counts
below are for the full narration block, opener and closer included.
## Why these five
A GTM team at a company that buys GPU capacity and resells it needs, in order:
the number the business turns on, the dates that can cost it money, the join it
does all day, the way its existing book gets into the tool, and the boundary of
the agent sitting next to all of it.
1. **Overview and margin** — the only question a generic CRM cannot answer, and
the one product argument that has to land verbatim: cost is charged against
the full commitment.
2. **The quarterly calendar** — renewals and closes, plus export authorisations
and compliance artefacts, which exist nowhere else in the product and whose
expiry is a legal event rather than a commercial one.
3. **Capacity to allocations** — the load-bearing join. Every figure in scripts
one and two is downstream of it, so a seller who cannot do this cannot use
the product.
4. **Importing** — nobody adopts a CRM they cannot get their book into. This is
the first ten minutes of every deployment.
5. **Piggy** — a GTM team will be asked "can it do X". The useful video is the
one that draws the line, because the answer to "can it write to the CRM" is
now *yes, with your approval*, and being vague about which half applies in
front of a customer is expensive.
Deliberately not filmed: `/growth`, `/demand`, `/supply`, `/contracts`,
`/facts`. They are good pages, but each is either a conventional pipeline board
a GTM team already understands or an internal review queue.
---
## 1. Overview and the margin question
- **Slug:** `overview-and-margin`
- **Title:** Overview and the margin question
- **Summary:** Which contracted capacity is sold, at what margin, and what is idle right now — and why cost is charged against the full commitment.
- **Word count:** 102
```narration
Hi team, check out this feature we worked on: The Overview opens on gross margin, sold ratio and idle capacity, not deal counts. Underneath, every commitment you're paying for and not selling, ranked by what the idle hours cost, with the break-even price for the rest of the block. The important bit: cost is charged against the full commitment, not just the hours that sold, because unsold hours are already paid for. Margin shows the same ledger per block, with cost per GPU-hour and break-even for each one. If a block reads cost covered, further sales are pure upside. thanks for watching!
```
**Shot list**
| ~sec | Route | On screen |
|---|---|---|
| 04 | `/` | Full page at the top. The four stat tiles: Gross margin, Sold ratio, Idle capacity, Open deals. |
| 48 | `/` | Slow zoom on the Sold ratio and Idle capacity tiles — "4.9M of 6.2M GPU-hrs sold", "1.3M hrs bought and unsold". |
| 816 | `/` | The warning card "Capacity you are paying for and not selling", scrolling the ranked rows. Pause on the row reading "break even above $0.76/GPU-hr". |
| 1622 | `/` | The "The book" card: Revenue, Cost of committed capacity, Gross margin, and the footnote about the full commitment. Hold on the footnote. |
| 2227 | `/margin` | Navigate. Header stats, then the "By commitment" table — Sold, Sellable, Sold ratio, Cost/hr, Break even. |
| 2730 | `/margin` | Hold on a row whose Break even column reads "Cost covered". |
---
## 2. The quarterly calendar
- **Slug:** `quarterly-calendar`
- **Title:** The quarterly calendar
- **Summary:** What closes, what renews, what expires and when capacity lands — with export authorisations and compliance artefacts at the top.
- **Word count:** 98
```narration
Hi team, check out this feature we worked on: The Calendar is a quarter at a time, one lane per kind. Bars are spans, diamonds are points, so you read what overlaps what in one pass. Top of the page is licence to operate: export authorisations and compliance artefacts, because an expired authorisation converts lawful business into unlawful business. Below that, weighted pipeline, deals closing, renewals whose notice date lands this quarter, obligations due, and every capacity window. The agenda underneath is the same events as a tappable list, and it works on a phone. thanks for watching!
```
**Shot list**
| ~sec | Route | On screen |
|---|---|---|
| 04 | `/calendar` | Top of the page, quarter label visible in the heading. Step once with the next-quarter arrow and back, to show the navigator. |
| 410 | `/calendar` | The Quarter timeline card. Scroll its pane sideways so the lanes and the July/August/September header move. |
| 1017 | `/calendar` | The "Licence to operate" card. Hold on the export-authorisation row and its "in 45d" countdown. |
| 1723 | `/calendar` | The five stat tiles: Weighted pipeline, Deals closing, Renewals, Obligations due, Authorisations expiring. |
| 2327 | `/calendar` | The Agenda, scrolling through a day group — allocation windows and capacity windows with their values and Running badges. |
| 2730 | `/calendar` | Same page at 393px wide, agenda in view, to show the phone layout. |
---
## 3. Capacity to allocations
- **Slug:** `capacity-to-allocations`
- **Title:** Capacity to allocations
- **Summary:** Joining a commitment you bought to a deal you sold — the availability book, the matcher, and the allocation the ledger is built on.
- **Word count:** 96
```narration
Hi team, check out this feature we worked on: Capacity has two tabs. Availability shows every block we hold: how much is sold, how much is held, how much is still sellable, our cost, and the break-even price. Match a requirement takes what the customer wants, GPU type, count, dates, a price ceiling, and scores the blocks we already own, with the reasoning written out. Allocate joins that commitment to a demand deal. The server re-checks the window and live holds when you save. That join is the row margin is computed from. thanks for watching!
```
**Shot list**
| ~sec | Route | On screen |
|---|---|---|
| 04 | `/capacity` | Availability tab. The card grid; hold on one card's sold/held bar and the "hrs sellable" figure. |
| 49 | `/capacity` | Same card's Cost and Break even rows, then the "Allocate or hold" button. |
| 913 | `/capacity` | Switch to "Match a requirement". The empty form. |
| 1318 | `/capacity` | Type `H100_80GB`, 64 GPUs, leave high-speed interconnect ticked, press "Find capacity". |
| 1823 | `/capacity` | The result cards: the fit percentage badge and the rationale lines, e.g. "Exact GPU match" and "Infiniband fabric meets the training requirement". |
| 2328 | `/capacity` | Press "Allocate this capacity". The Reserve capacity sheet opens — commitment, demand deal, GPU-hours, sell price, and the "Quote vs break even" line reacting as a price is typed. |
| 2830 | `/capacity` | Hold on the "Create allocation" button and the note that saving re-checks the window and live holds. |
---
## 4. Importing your book
- **Slug:** `importing-your-book`
- **Title:** Importing your book
- **Summary:** Getting off the spreadsheet — CSV, Excel, Notion or a bounded Google Sheets range, with a dry run you review before anything is written.
- **Word count:** 103
```narration
Hi team, check out this feature we worked on: Import gets you off the spreadsheet. Pick what you're importing: accounts, contacts, demand deals or supply deals. Then a CSV or Excel file, a Notion database, or a bounded Google Sheets range, read-only, with the token encrypted on the server. PIG guesses the column mapping, you pick a stable source key, then run a dry run. You see every create, every update and every error before anything is written. Fix the errors, commit, and it goes in atomically. Re-import with the same key column later and it updates the same records. thanks for watching!
```
**Shot list**
| ~sec | Route | On screen |
|---|---|---|
| 04 | `/imports` | Top of the page and the four entity cards. Click Accounts. |
| 49 | `/imports` | The "1. Choose source" card. Click across File, Notion, Google Sheets so all three are seen; land on Google Sheets and hold on the "Read only" badge and the encrypted-token line. |
| 913 | `/imports` | Back on File. Choose a CSV; the "Parsed" badge, the file name, and the row and column counts appear. |
| 1319 | `/imports` | "2. Map source columns". Hold on the "Stable source key" select and its note that repeated imports update the same record. Scroll the mapped field list. |
| 1924 | `/imports` | Press "Run dry-run preview". The "3. Review the exact plan" card with the create / update / errors badges. |
| 2428 | `/imports` | Scroll the preview table — the Decision column, and a row carrying a validation error. |
| 2830 | `/imports` | Press "Commit reviewed import"; the confirmation line reporting rows created and updated. |
---
## 5. Piggy, and where the line is
- **Slug:** `piggy-and-its-boundary`
- **Title:** Piggy, and where the line is
- **Summary:** The agent reads through scoped PIG tools, has no shell, filesystem or browser, and writes only what you approve — as you, under your own permissions.
- **Word count:** 108
```narration
Hi team, check out this feature we worked on: Piggy is docked on every page. Ask it about the book and it answers through scoped PIG tools, one per page: margin on Margin, idle capacity on Capacity. It gets aggregates, not the raw ledger, so it quotes rather than recomputes. It can also change records now — but on Ask first, every change arrives as a card showing the old value and the new one, and nothing is saved until you press Apply. It writes as you, under your permissions, so it can never reach further than you can. No shell, no filesystem, no browser. thanks for watching!
```
**Shot list**
| ~sec | Route | On screen |
|---|---|---|
| 04 | `/piggy` | The workspace, on the "Ask first" segment of the mode control. The line under the hero: "Piggy reads your PIG records through scoped tools, with no shell, filesystem or browser." |
| 48 | `/margin` | Open the dock from the header while standing on Margin, so the dock is visibly attached to the page. |
| 815 | `/margin` | Ask "how is the book doing". Show the tool step appearing in the transcript, then the answer quoting the same figures the page shows. |
| 1520 | `/capacity` | Move to Capacity, ask "what is idle and what does it cost". Show the different tool name in the transcript. |
| 2026 | `/demand` | Ask Piggy to log a call on a deal. Hold on the approval card — the field rows with the previous value beside the new one — then press **Apply** and show the badge settle to "Applied". |
| 2630 | `/piggy` | The mode control open, showing all three sentences: "Piggy answers from your CRM and is offered no tool that could change it" / "Piggy proposes each change and nothing is saved until you press Apply" / "Piggy makes changes to your CRM itself, without asking first." |
**Do not film Auto mode making a change.** The point of the video is the
approval step; a clip of an agent writing unattended is the clip that gets
quoted back.
---
## Verification notes
Kept so the next person does not re-derive them.
- Overview stat tiles, the idle-alert card and the full-commitment footnote:
`apps/web/src/pages/Overview.tsx`; data from `GET /api/dashboard`.
- Margin table columns and the "Cost covered" / "Sold out" break-even
treatment: `apps/web/src/pages/Margin.tsx`; `GET /api/capacity/margin`.
- Calendar lane ordering, the compliance card and the five totals:
`apps/web/src/pages/Calendar.tsx`. The thirteen event kinds are
`CALENDAR_EVENT_KINDS` in `packages/core/src/calendar.ts`.
- Availability figures, the matcher form and its rationale strings:
`apps/web/src/pages/Capacity.tsx`; `POST /api/capacity/match` returns
`score` plus a `rationale` array. The reserve sheet, the "Quote vs break
even" line and the server re-check on save:
`apps/web/src/components/AllocationSheet.tsx`.
- Import entities, mapping, dry run and atomic commit:
`apps/web/src/pages/Imports.tsx`. Accepted file types are `.csv` and
`.xlsx`. Google Sheets is read-only with server-side encrypted tokens and a
bounded A1 range: `apps/web/src/components/GoogleSheetsSource.tsx`.
- Piggy's page tools are one per route — `pig_get_margin_summary`,
`pig_get_idle_capacity`, `pig_get_pipeline`, `pig_get_calendar_ahead`,
`pig_get_workspace_summary` — mapped in `apps/piggy/src/page-routes.ts` and
implemented in `apps/piggy/src/page-tools.ts`. The focused record tool
`pig_get_record` takes no id and reads only the record in context; a record
that is *not* in context is reachable by name through `pig_search_records`
and `pig_get_record_by_id` (`apps/piggy/src/chat-tools.ts`), so "it cannot
look at another record" is no longer true and must not be said on camera.
Results are aggregated because a chat turn has a bounded output budget
(`PIGGY_AGENT_MAX_TOKENS`, 4096 by default, reasoning included).
- The five write tools are `pig_log_activity`, `pig_create_contact`,
`pig_create_task`, `pig_update_deal_stage` and `pig_update_record_fields`
(`apps/piggy/src/write-tools.ts`). None of them can change money, ownership
or a contract; the always-confirm kinds are in
`packages/core/src/piggy-protocol.ts`.
- **Caveat for whoever schedules these:** `learn.ts` is not mounted in
`apps/api/src/app.ts`, so `/api/learn/*` currently answers 404 and these rows
cannot be created yet. See AGENTS.md §8.