First versions open with the owner's own words, and the try-it check follows his exact steps (GST-3608) (#4759)

When we hand someone the first version of something, the approval page
and the try-it message now open with their own quoted requests, each
marked "does it" or a lettered choice.

Before they're asked to try it, gstack-first-use has an agent from
another model family follow the exact numbered steps on their real
setup, and holds the message until no step is broken, wrong or needs a
lookup.

Nothing to do: this changes /autoplan's first-version gate,
gstack-first-use and the guides that point to it.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Review-Finding: p1/red-team#1 reader=red-team
Review-Finding: p1/red-team#2 reader=red-team
Review-Finding: p1/red-team#3 reader=red-team
Review-Finding: p1/specialist-batched#1 reader=testing
Review-Finding: p2/outside-voice#1 reader=outside-voice
Review-Finding: p3/red-team#1 reader=red-team
Review-Finding: gsta825-ship2/p1/outside-voice#2 reader=outside-voice
Review-Finding: gsta825-ship2/p1/outside-voice#3 reader=outside-voice
Review-Finding: p1/specialist-batched#1 reader=state-machines
This commit is contained in:
Garry Tanandcapy-ai[bot] authored and GitHub committed 2026-11-24 02:26:57 +00:00
1 parent 40986b7c76
commit e78a1bfe32
38 files changed
+1126 -342

No files matched your search

+152 -11
View File
@@ -26,7 +26,8 @@ import { confirmBlock, openEarlier, settledIds } from '../lib/autoplan-confirm';
import { buildTasks } from '../lib/autoplan-export';
import { exportPublic } from '../lib/autoplan-public';
import * as crypto from 'node:crypto';
import { cutDrops, parseCuts, parseDayOne, parseOwnerWords, ownerWordsLine } from '../lib/autoplan-owner-text';
import { cutDrops, parseCuts, parseDayOne, parseOwnerWords, ownerWordsLine, renderOwnerPage } from '../lib/autoplan-owner-text';
import { detectScope, RESULT_FORMAT } from '../lib/autoplan-prompts';
import { ownerWords, redactOwnerWords } from '../lib/autoplan-owner-words';
import { consensusRecord, parseReviewResult, reconcile } from '../lib/autoplan-reconcile';
import { decisionSeverity } from '../lib/autoplan-revise';
@@ -62,7 +63,7 @@ const planText = (o: { owner?: string | null; dayOne?: boolean } = {}) => [
'### Units', '', 'U1 the live lane. U2 the transcript. U3 the before-meeting card. U4 the promise review screen.', '',
'## Review record', ''].join('\n');
type Row = Partial<FindingRow> & { id: string; severity: FindingRow['severity']; title: string; user_challenge?: boolean; changes?: string; owner_quote?: number; resolves?: string };
type Row = Partial<FindingRow> & { id: string; severity: FindingRow['severity']; title: string; user_challenge?: boolean; changes?: string; owner_quote?: number; narrows_quote?: number; resolves?: string };
const row = (phase: string, voice: 'native' | 'outside', r: Row): FindingRow => ({ schema_version: 1, run: RUN, phase, voice, disposition: 'open', ...r } as FindingRow);
/** Round 1 of the CEO phase: the build-order and promise-scope challenges that round 2 never repeated. */
@@ -137,17 +138,22 @@ describe('replay: a reviewed app plan whose product challenges were hidden', ()
expect(list.items.find(i => i.id === 'p1')!.recommended).toBe('b');
});
test('day one: the assumed row is an owner question, the cut that drops the Today screen is lettered, the rest are one item', () => {
test('day one: the assumed row is an owner question; on a first version every cut is lettered and a quote with no line is asked about', () => {
expect(byClass(list, 'day_one').map(i => i.title)).toEqual(['Day one: the plan assumes you will do "reviews the promises made in a meeting" (daily); is that right?']);
expect(byClass(list, 'cut').map(i => i.title)).toEqual(['Cut: No Today screen in the first build: notifications only']);
expect(byClass(list, 'cuts').map(i => i.title)).toEqual(['2 other cuts: No Android build; No shared team calendars']);
expect(byClass(list, 'cut').map(i => [i.title, i.why])).toEqual([
['Cut: No Today screen in the first build: notifications only', 'this cut drops something on the day-one page'],
['Cut: No Android build', 'on a first version every cut is your decision, one letter each'],
['Cut: No shared team calendars', 'on a first version every cut is your decision, one letter each']]);
expect(byClass(list, 'cuts')).toEqual([]);
expect(byClass(list, 'owner_words').map(i => [i.title, i.recommended])).toEqual([['1 of your quoted messages has no time or no line saying what this version does with it: “I want to remember what I promised people after every meeting” (missing a line (does it or choice))', 'a']]);
expect(list.first_version).toBe(true);
expect(list.owner_words).toMatchObject({ status: 'ok', quotes: [{ n: 1, verified: false }] });
});
test('lettered-item counts (recorded for the PR): 3 proposals, 3 day-one items, 1 High finding', () => {
test('lettered-item counts (recorded for the PR): 3 proposals, 1 day-one question, 3 cuts, 1 owner-words line, 1 High finding', () => {
expect(byClass(list, 'proposal').length).toBe(3);
expect(byClass(list, 'finding').length).toBe(1);
expect(lettered(list)).toBe(7);
expect(lettered(list)).toBe(9);
});
});
@@ -161,7 +167,7 @@ describe('negative controls', () => {
expect(d1.options[0]!.text).toBe('keep your direction');
expect(byClass(list, 'confirm_direction')).toEqual([]);
expect(byClass(list, 'proposal').length).toBe(2);
expect(lettered(list)).toBe(7);
expect(lettered(list)).toBe(9);
});
test("(b) no Owner's words section: today's keep-direction default stays, plus one confirm-direction item", () => {
@@ -174,7 +180,8 @@ describe('negative controls', () => {
expect(confirm.length).toBe(1);
expect(confirm[0]!.title).toContain(kept.map(i => i.id).join(', '));
expect(list.owner_words).toBeUndefined();
expect(lettered(list)).toBe(8);
expect(byClass(list, 'owner_words').map(i => i.title)).toEqual(['This is a first version, but the plan quotes none of your messages that ask for it']);
expect(lettered(list)).toBe(10);
});
test('(c) a round-1 challenge the revision fixed (resolves) or the owner answered does not resurface', () => {
@@ -184,7 +191,7 @@ describe('negative controls', () => {
expect(covering(list, `${RUN}-ceo-native-18`)).toBeUndefined();
expect(openEarlier(state, 'ceo', [...round2({ resolved: true }).native])).toEqual([]);
expect(byClass(list, 'proposal').length).toBe(1);
expect(lettered(list)).toBe(5);
expect(lettered(list)).toBe(7);
});
test('a later round staying silent never closes a challenge, and a lean run carries nothing', () => {
@@ -267,7 +274,7 @@ describe('owner_quote downgrade, the day-one page requirement and the cost line'
test('a changed cut list or challenge list gets a new origin, so an earlier answer is asked again instead of carried', () => {
const origin = (list: GateList, cls: string) => byClass(list, cls)[0]!.origin;
const cuts = (extra: string) => planText().replace('- No shared team calendars\n', `- No shared team calendars\n${extra}`);
const cuts = (extra: string) => planText({ dayOne: false }).replace('### Units', "### What it won't do yet\n\n- No Android build\n- No shared team calendars\n\n### Units").replace('- No shared team calendars\n', `- No shared team calendars\n${extra}`);
const before = buildGate(makeRun('cuts-before', { plan: cuts(''), round2: round2(), round1: false }), 1);
const after = buildGate(makeRun('cuts-after', { plan: cuts('- No web dashboard\n'), round2: round2(), round1: false }), 1);
expect(origin(after, 'cuts')).not.toBe(origin(before, 'cuts'));
@@ -433,3 +440,137 @@ describe('parsers, render and redaction', () => {
expect(out.text).not.toContain('promised people');
});
});
describe('first versions: the owner page quotes the owner and letters what it leaves out (GST-3608)', () => {
const CASE4 = [
"### Owner's words", '',
'- The owner, 2026-11-19 10:04Z: "making it really good two-way is awesome also. being able to send and receive." → does it',
'- The owner, 2026-11-19 10:06Z: "contacts are awesome. notes are awesome too." → choice; size: one day; leave out: notes need a second helper permission',
].join('\n');
const plan = (owner: string, cuts = '- It never writes to your Contacts: writes keep going through the iCloud route\n- No Android build\n') => [
'# Contacts for the agent (synthetic, the shape of a real first version)', '', '## Implementation plan', '', owner, '',
'### Day one', '', '| action | frequency | source | feature | route | first build | check |', '|---|---|---|---|---|---|---|',
'| asks the agent who someone is | daily | owner words 1 | Contact lookup | chat | build 1 | the agent answers from the address book |', '',
"### What it won't do yet", '', cuts, '## Review record', ''].join('\n');
const narrowing = (o: { quote?: number } = {}) => ({
native: [row('ceo', 'native', { id: `${RUN}-ceo-r2-native-1`, severity: 'High', title: 'Read-only contacts does less than the two-way the owner asked for', changes: 'scope', resolution: 'make contacts read and write', ...(o.quote ? { narrows_quote: o.quote } : {}) } as Row)],
outside: [] as FindingRow[],
});
test('the parser reads each line and keeps an arrow inside the quote', () => {
const w = parseOwnerWords(CASE4 + '\n- The owner, 2026-11-20 08:00Z: "a -> b → c in the quote" -> does it');
expect(w.status).toBe('ok');
expect(w.quotes.map(q => [q.text, q.line])).toEqual([
['making it really good two-way is awesome also. being able to send and receive.', { kind: 'does' }],
['contacts are awesome. notes are awesome too.', { kind: 'choice', size: 'one day', leave_out: 'notes need a second helper permission' }],
['a -> b → c in the quote', { kind: 'does' }],
]);
expect(parseOwnerWords('### Owner\'s words\n\n- The owner, day 0: "x"').quotes[0]!.line).toBeUndefined();
});
test('case 4: a read-only cut that shares no words with "two-way", flagged by a reviewer, becomes one choice recommending build', () => {
const list = buildGate(makeRun('case4', { plan: plan(CASE4), round2: narrowing({ quote: 1 }), round1: false, ui: false }), 1);
const choices = byClass(list, 'owner_choice');
expect(choices.map(i => [i.title, i.recommended])).toEqual([
['Your words (2026-11-19 10:04Z): “making it really good two-way is awesome also. being able to send and receive.”, which this version doesn\'t fully do', 'a'],
['Your words (2026-11-19 10:06Z): “contacts are awesome. notes are awesome too.”, which this version doesn\'t fully do', 'b'],
]);
expect(choices[0]!.why).toBe('a reviewer (native) says the plan narrows it: Read-only contacts does less than the two-way the owner asked for');
expect(choices[0]!.options.map(o => o.text)).toEqual(['build it in this version (size not stated)', 'leave it out for now']);
expect(choices[1]!.recommended_basis).toBe("the plan's reason to leave it out: notes need a second helper permission");
expect(choices[1]!.cost).toBe('a adds about one day to this version and reopens ceo and eng once the plan is revised');
expect(covering(list, `${RUN}-ceo-r2-native-1`)).toBeUndefined();
expect(byClass(list, 'cut').map(i => i.title)).toEqual(['Cut: It never writes to your Contacts: writes keep going through the iCloud route', 'Cut: No Android build']);
expect(rec(list)[choices[0]!.id]).toBe('a');
});
test('without the reviewer finding, the same read-only cut is still its own letter on a first version, never a grouped "other cuts" line', () => {
const list = buildGate(makeRun('case4-quiet', { plan: plan(CASE4), round2: narrowing(), round1: false, ui: false }), 1);
expect(byClass(list, 'cuts')).toEqual([]);
expect(byClass(list, 'cut').length).toBe(2);
});
test('a cut that names a quoted line is that quote\'s build-it choice, exactly one item, and leaves the "won\'t do yet" list', () => {
const cuts = '- No notes: contacts awesome, notes awesome too later\n- No Android build\n';
const state = makeRun('cut-quote', { plan: plan(CASE4, cuts), round2: narrowing(), round1: false, ui: false });
const list = buildGate(state, 1);
const notes = byClass(list, 'owner_choice').filter(i => i.title.includes('notes are awesome'));
expect(notes).toHaveLength(1);
expect(notes[0]!.why).toBe('the plan\'s line for it says this version doesn\'t do it yet; the plan cuts it: "No notes: contacts awesome, notes awesome too later"');
expect(byClass(list, 'cut').map(i => i.title)).toEqual(['Cut: No Android build']);
const page = renderOwnerPage(fs.readFileSync(state.active_plan, 'utf8'), list.owner_words?.quotes, { firstVersion: true }).join('\n');
expect(page).toContain('### Your words this plan follows');
expect(page.indexOf('### Your words this plan follows')).toBeLessThan(page.indexOf('### Day one'));
expect(page).toContain('“contacts are awesome. notes are awesome too.” (not found in your recorded replies) → not in this version yet: a lettered choice below');
expect(page).toContain("### What it won't do yet\n\n- No Android build\n");
expect(page).not.toContain('- No notes');
expect(page).toContain('(gstack-first-use)');
expect(renderOwnerPage(fs.readFileSync(state.active_plan, 'utf8'), list.owner_words?.quotes, { firstVersion: false }).join('\n')).not.toContain('(gstack-first-use)');
});
test('a High finding that narrows a quote recommends build over the plan\'s leave-out reason, and only build settles it', () => {
const list = buildGate(makeRun('high-narrow', { plan: plan(CASE4), round2: narrowing({ quote: 2 }), round1: false, ui: false }), 1);
const notes = byClass(list, 'owner_choice').find(i => i.title.includes('notes are awesome'))!;
expect(notes.recommended).toBe('a');
expect(notes.recommended_basis).toBe('your own words asked for it, and a High finding says the plan falls short of them');
expect(notes.origin!.split('|')[1]!.split('+')).toContain(`${RUN}-ceo-r2-native-1`);
expect(notes.origin!.endsWith('|finding')).toBe(true);
});
describe("the default reply never changes or overrides an owner line, whatever kind of finding touches it", () => {
type Kind = { name: string; native: Row[]; outside?: Row[] };
const finding = (voice: 'native' | 'outside', quote: number, severity: FindingRow['severity'] = 'High') =>
({ id: `${RUN}-ceo-r2-${voice}-1`, severity, title: 'Read-only contacts does less than what the owner asked for', changes: 'scope', resolution: 'make contacts read and write', narrows_quote: quote } as Row);
const KINDS: Kind[] = [
{ name: 'narrows a does-it quote', native: [finding('native', 1)] },
{ name: 'narrows an open choice quote (High)', native: [finding('native', 2)] },
{ name: 'narrows an open choice quote (Medium)', native: [finding('native', 2, 'Medium')] },
{ name: 'a paired finding: both on a does-it quote', native: [finding('native', 1)], outside: [finding('outside', 1)] },
];
test.each(KINDS.map(k => [k.name, k] as const))('%s', (_, kind) => {
const state = makeRun(`rec-${kind.name.replace(/\W+/g, '-')}`, { plan: plan(CASE4), round2: { native: kind.native.map(r => row('ceo', 'native', r)), outside: (kind.outside ?? []).map(r => row('ceo', 'outside', r)) }, round1: false, ui: false });
const list = buildGate(state, 1);
const chosen = rec(list);
const quotes = parseOwnerWords(CASE4).quotes;
for (const r of [...kind.native, ...(kind.outside ?? [])]) {
const q = quotes.find(x => x.n === r.narrows_quote)!;
const items = list.items.filter(i => i.title.includes(r.id) || (i.item_class === 'owner_choice' && i.title.includes(q.text)));
expect(items.length, `${r.id} reaches the gate`).toBeGreaterThan(0);
for (const item of items) {
expect(item.item_class, `${r.id}: never a plain proposal`).not.toBe('proposal');
expect(item.why ?? '').not.toContain('no quoted owner line says otherwise');
const option = item.options.find(o => o.key === (chosen[item.id] ?? item.recommended))!;
if (item.item_class === 'owner_choice' && (r.severity === 'High' || r.severity === 'Critical' || q.line?.kind === 'does')) expect([item.id, option.text.startsWith('build it')], `${r.id}: the default builds what was asked`).toEqual([item.id, true]);
}
}
});
});
test('--first-version makes a plan with no Day one section a first version; a plain backend plan stays as it was', () => {
const noDay = plan(CASE4).replace(/### Day one[\s\S]*?\n\n### What/, '### What');
const flagged = makeRun('fv-flag', { plan: noDay, round2: narrowing(), round1: false, ui: false });
(flagged.scope as any).first_version = true;
expect(buildGate(flagged, 1).first_version).toBe(true);
const plain = buildGate(makeRun('fv-none', { plan: noDay.replace(/ → [^\n]*/g, ''), round2: narrowing(), round1: false, ui: false }), 1);
expect(plain.first_version).toBeUndefined();
expect(byClass(plain, 'owner_words')).toEqual([]);
expect(byClass(plain, 'cuts').map(i => i.title)).toEqual(['2 other cuts: It never writes to your Contacts: writes keep going through the iCloud route; No Android build']);
});
test('--first-version reaches the run scope from the CLI flag and from the plan\'s scope marker', () => {
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'fv-scope-'));
const bare = path.join(dir, 'bare.md'), marked = path.join(dir, 'marked.md');
fs.writeFileSync(bare, '# A plan\n\n## Implementation plan\n\n- Edit lib/x.ts\n\n## Review record\n');
fs.writeFileSync(marked, '<!-- gstack-autoplan-scope: --first-version -->\n' + fs.readFileSync(bare, 'utf8'));
expect(detectScope(bare, dir, { firstVersion: true }).first_version).toBe(true);
expect(detectScope(marked, dir, {}).first_version).toBe(true);
expect(detectScope(bare, dir, {}).first_version).toBeUndefined();
fs.rmSync(dir, { recursive: true, force: true });
});
test('the reviewer prompt asks for narrows_quote and the reconciler keeps it', () => {
expect(RESULT_FORMAT('eng', SHA, '/x')).toContain('"narrows_quote": <n>');
const parsed = parseReviewResult('INPUT: eng ' + SHA + '\n\n```gstack-findings\n{"id":"F1","severity":"High","title":"t","changes":"scope","narrows_quote":2}\n```\n');
expect(JSON.stringify(parsed)).toContain('"narrows_quote":2');
});
});
+16 -1
View File
@@ -8,7 +8,8 @@
import { describe, expect, test } from 'bun:test';
import * as fs from 'node:fs';
import * as path from 'node:path';
import { MIN_TOKENS, OWNER_WORDS_MARK as MARK, WINDOW, dropOwnerFields, ownerIndex, ownerSpans, redactOwnerWords } from '../lib/autoplan-owner-words';
import * as os from 'node:os';
import { MIN_TOKENS, OWNER_WORDS_MARK as MARK, WINDOW, dropOwnerFields, ownerIndex, ownerSpans, ownerWords, redactOwnerWords } from '../lib/autoplan-owner-words';
const LONG = 'Keep the backoff cap at thirty seconds and log every retry attempt so we can see it.';
const quoted = (text: string, ...replies: string[]) => { const o = ownerIndex(replies.map(r => ({ text: r }))); return ownerSpans(text, o).map(([s, e]) => text.slice(s, e)); };
@@ -161,6 +162,20 @@ describe('redactOwnerWords', () => {
});
});
describe('ownerWords over a run directory', () => {
test("a leftover ruled-out line is read as part of the quote, as before lines existed, so export and validate still redact the owner's ruling", () => {
const out = fs.mkdtempSync(path.join(os.tmpdir(), 'owner-ruling-'));
const ruling = 'leave my calendar alone, I mean it, no exceptions';
fs.writeFileSync(path.join(out, 'plan-source.md'), `# Plan\n\n## Implementation plan\n\n### Owner's words\n\n- The owner, 2026-11-12 09:00Z: "never touch my calendar or my reminders" → ruled out 2026-11-12: "${ruling}"\n\n## Review record\n`);
const owner = ownerWords({ out, phases: {}, gate: undefined, carry: undefined } as Parameters<typeof ownerWords>[0]);
const r = redactOwnerWords(`The reviewer repeats it: "${ruling}".`, owner);
expect(r.text).toContain(MARK);
expect(r.text).not.toContain('no exceptions');
expect(redactOwnerWords(`He said: "never touch my calendar or my reminders" → ruled out 2026-11-12: "${ruling}"`, owner).text).not.toContain('calendar');
fs.rmSync(out, { recursive: true, force: true });
});
});
describe('dropOwnerFields', () => {
test("drops owner_reply and a carry record's words, marks a human's deferral reason, keeps an agent's", () => {
const run = {
+126
View File
@@ -16,6 +16,7 @@ import { readState } from '../lib/autoplan-state';
import { recHash } from '../lib/gate-list';
import { ROOT, SMALL_PLAN, resultOf } from './helpers/autoplan-run-fixture';
import { capyRunner, phaseVia, readJsonl, readRunJson, writePlan } from './helpers/autoplan-capy';
import { parseOwnerWords, wordKey, type OwnerLine } from '../lib/autoplan-owner-text';
setDefaultTimeout(60_000);
const r = capyRunner();
@@ -332,3 +333,128 @@ describe("export --public drops the owner's own words (GST-1243)", () => {
expect(fs.readFileSync(path.join(pub, 'plan.md'))).toEqual(fs.readFileSync(path.join(out, 'plan.md')));
});
});
describe('a first-version export keeps no fragment of any owner quote (GST-3608)', () => {
const QUOTES = [
'blorptastic zanquiver mellowfrond grumbletide',
'zoëlqvist brûxelkorp façadrinth naïvequor',
'毎朝の予定をスヌーピー通知で教えてください',
'🚀 launchpadzz 🎉 fizzwickery 🌮 tacoloopz',
];
const plan = [
'# Morning helper (synthetic first version)', '', '## Implementation plan', '',
'Add a morning summary job in lib/morning.ts that reads the calendar and sends one notification.', '',
"### Owner's words", '',
`- The owner, 2026-11-20 08:00Z: "${QUOTES[0]}" → does it`,
`- The owner, 2026-11-20 08:01Z: "${QUOTES[1]}" → choice; size: one day`,
`- The owner, 2026-11-20 08:02Z: "${QUOTES[2]}" → choice; size: two days; leave out: needs a second permission`,
`- The owner, 2026-11-20 08:03Z: "${QUOTES[3]}" → ruled out 2026-11-20: "${QUOTES[3]} never"`, '',
'### Day one', '', '| action | frequency | source | feature | route | first build | check |', '|---|---|---|---|---|---|---|',
'| reads the morning summary | daily | owner words 1 | Summary | notification | build 1 | the summary lists today |', '',
"### What it won't do yet", '', '- No weekly digest', '', '## Review record', ''].join('\n');
const fragments = (q: string) => [...new Set([...q.split(/\s+/), ...wordKey(q).trim().split(' ')].filter(w => [...w].length >= 3))];
test('accented, CJK and emoji quotes leave no 3+ character fragment, raw or normalized, anywhere in the public bytes', () => {
const dir = path.join(r.host.base, `owner${++n}`);
const out = path.join(dir, 'run');
expect(r.ap(['next', '--out', out, '--plan', writePlan(dir, plan), '--no-ui', '--no-dx', '--first-version']).status).toBe(0);
const narrowing = [{ id: 'F1', severity: 'Medium', title: 'The summary does less than the owner asked', changes: 'scope', narrows_quote: 2 }];
phaseVia(r, out, 'ceo', { native: narrowing, outside: [] });
expect(phaseVia(r, out, 'eng', { native: [], outside: [] }).outside.stdout).toContain('status=gate_pending');
expect(gateOf(out).items.filter((i: { item_class?: string }) => i.item_class === 'owner_choice').length).toBeGreaterThan(0);
const pub = path.join(dir, 'public');
const e = r.ap(['export', '--out', out, '--public', pub]);
expect(e.status, e.stderr).toBe(0);
const bytes = allText(pub);
const leaks = QUOTES.flatMap(q => fragments(q).filter(w => bytes.includes(w)));
expect(leaks).toEqual([]);
});
});
describe('every attribution, line and quote shape reads as the merge base read it, and export keeps none of it (GST-3608)', () => {
/** The merge base's whole Owner's words rule (0d6cc1be): the first opening quote mark to the last closing one, who before it. */
const mergeBase = (bullet: string) => {
const m = /[“"](.+)[”"]/.exec(bullet);
return m && m[1]!.trim() ? { who: bullet.slice(0, m.index).replace(/[\s:,-]+$/, '').trim() || 'unattributed', text: m[1]!.trim() } : undefined;
};
const ATTRIBUTIONS: Array<[string, string]> = [
['plain', 'Garry, 2026-11-23 09:00Z'],
['an ascii arrow', 'Garry (Slack DM -> relayed), 2026-11-23'],
['an arrow', 'Garry (Slack DM → relayed), 2026-11-23'],
['a colon', 'Garry (re: importer), 2026-11-23'],
['straight quote marks', 'Garry ("G"), 2026-11-23'],
['curly quote marks', 'Garry (“G”), 2026-11-23'],
['an em dash', 'Garry — via Slack, 2026-11-23'],
['quote marks and an arrow', 'Garry ("G" -> relayed), 2026-11-23'],
];
const TEXTS: Array<[string, (u: string) => string]> = [
['plain', u => `blorptastic zanquiver ${u}`],
['nested straight quotes', u => `snarfle "grumbletide" vexwort ${u}`],
['nested curly quotes', u => `wibbleton “quorkle” ${u}`],
['an arrow between nested quotes', u => `frobnitz "plinky" -> "zorbly" ${u}`],
['an em dash', u => `drevnik—slorpine ${u}`],
['CJK', u => `毎朝の予定をスヌーピー通知で ${u}`],
['accented', u => `zoëlqvist brûxelkorp ${u}`],
['emoji', u => `🚀 launchpadzz 🎉 fizzwickery ${u}`],
];
const LINES: Array<[string, (u: string) => string, (u: string) => OwnerLine | undefined]> = [
['no line', () => '', () => undefined],
['does it', () => ' → does it', () => ({ kind: 'does' })],
['does it after an ascii arrow', () => ' -> does it', () => ({ kind: 'does' })],
['a choice with a size', () => ' -> choice; size: one day', () => ({ kind: 'choice', size: 'one day' })],
['a choice left out', () => ' → choice; size: two days; leave out: needs a second permission', () => ({ kind: 'choice', size: 'two days', leave_out: 'needs a second permission' })],
['a leftover ruled-out line', u => ` → ruled out 2026-11-20: "skrimblor dorvelin ${u}"`, () => undefined],
['a leftover ruled-out line with nested quotes and an arrow', u => ` → ruled out 2026-11-20: "grobble "nevermore" -> ${u}"`, () => undefined],
];
const tag = (prefix: string, i: number) => `${prefix}${String.fromCharCode(97 + Math.floor(i / 26))}${String.fromCharCode(97 + (i % 26))}vel`;
/** Every attribution with every text, each line shape rotating through both, so every pair of shapes meets. */
const ROWS = ATTRIBUTIONS.flatMap(([attrName, attr], a) => TEXTS.map(([textName, text], t) => {
const i = a * TEXTS.length + t;
const [lineName, line, parsed] = LINES[(a + t) % LINES.length]!;
const words = text(tag('qx', i)), ruling = tag('rz', i);
const bare = `- ${attr}: "${words}"`;
return { name: `${attrName} / ${textName} / ${lineName}`, bullet: bare + line(ruling), bare, words, line: parsed(ruling), ruling: line(ruling).includes('ruled out') ? line(ruling).replace(/^ → ruled out [\d-]+: "|"$/g, '') : undefined };
}));
const section = (bullets: string[]) => ["### Owner's words", '', ...bullets, '', '## Review record', ''].join('\n');
test.each(ROWS.map(r => [r.name, r] as const))('%s', (_, row) => {
const base = mergeBase((row.line ? row.bare : row.bullet).replace(/^- /, ''));
expect(base).toBeDefined();
const w = parseOwnerWords(section([row.bullet]));
expect(w.status, w.reason).toBe('ok');
expect(w.quotes).toEqual([{ n: 1, who: base!.who, text: base!.text, ...(row.line ? { line: row.line } : {}) }]);
});
test('an arrow in the attribution keeps the quote, and a line that is none of the three is still named after it', () => {
const slack = parseOwnerWords(section(['- Garry (Slack DM -> relayed), 2026-11-23: "ship the importer tonight"']));
expect(slack).toEqual({ status: 'ok', quotes: [{ n: 1, who: 'Garry (Slack DM -> relayed), 2026-11-23', text: 'ship the importer tonight' }] });
const bad = parseOwnerWords(section(['- Garry (Slack DM -> relayed), 2026-11-23: "ship the importer tonight" → maybe later']));
expect(bad.status).toBe('malformed');
expect(bad.reason).toBe('bullet 1 has a line that is not does it or choice');
expect(bad.quotes.map(q => q.text)).toEqual(['ship the importer tonight']);
});
test('a first-version export of every row leaves no 3+ character fragment of any quote or ruling in the public bytes', () => {
const plan = [
'# Morning helper (synthetic first version)', '', '## Implementation plan', '',
'Add a morning summary job in lib/morning.ts that reads the calendar and sends one notification.', '',
"### Owner's words", '', ...ROWS.map(r => r.bullet), '',
'### Day one', '', '| action | frequency | source | feature | route | first build | check |', '|---|---|---|---|---|---|---|',
'| reads the morning summary | daily | owner words 1 | Summary | notification | build 1 | the summary lists today |', '',
"### What it won't do yet", '', '- No weekly digest', '', '## Review record', ''].join('\n');
expect(parseOwnerWords(plan).quotes).toHaveLength(ROWS.length);
const dir = path.join(r.host.base, `owner${++n}`);
const out = path.join(dir, 'run');
expect(r.ap(['next', '--out', out, '--plan', writePlan(dir, plan), '--no-ui', '--no-dx', '--first-version']).status).toBe(0);
phaseVia(r, out, 'ceo', { native: [{ id: 'F1', severity: 'Medium', title: 'The summary does less than the owner asked', changes: 'scope', narrows_quote: 2 }], outside: [] });
expect(phaseVia(r, out, 'eng', { native: [], outside: [] }).outside.stdout).toContain('status=gate_pending');
const pub = path.join(dir, 'public');
const e = r.ap(['export', '--out', out, '--public', pub]);
expect(e.status, e.stderr).toBe(0);
const bytes = allText(pub);
const fragments = (q: string) => [...new Set([...q.split(/\s+/), ...wordKey(q).trim().split(' ')].filter(w => [...w].length >= 3))];
const leaks = ROWS.flatMap(row => [row.words, ...(row.ruling ? [row.ruling] : [])].flatMap(q => fragments(q).filter(w => bytes.includes(w)).map(w => `${row.name}: ${w}`)));
expect(leaks).toEqual([]);
});
});
+3 -1
View File
@@ -146,7 +146,9 @@ describe('/captain skill', () => {
expect(capySkill).toMatch(/## Session start[^#]*?read \[lane-card\.md\]\(lane-card\.md\), not the rest of this file/);
// 7,000 for the drive-write line (confirm a copy in the drive's version history before deleting its source), reached by two
// crews on their own (crew habit H5).
expect(Buffer.byteLength(card)).toBeLessThanOrEqual(7000);
// 7,300 for the first-version line (Garry's "do it" of 2026-11-23 on GST-3608: no crew ran gstack-first-use because nothing a
// lane reads pointed at it).
expect(Buffer.byteLength(card)).toBeLessThanOrEqual(7300);
const doc = read('crew/docs/captain.md').replace(/\s+/g, ' ');
for (const s of ['`duration_seconds: 240`', 'stops re-issuing the timer', 'The controller never warm-waits', '4k characters or less', 'twice the crew\'s median lane spend', '`handoffs/<code>/next.md`']) expect(doc, s).toContain(s);
expect(read('captain/templates/brief.md')).toMatch(/^Read: <[^>]+>$/m);
+3 -1
View File
@@ -698,7 +698,9 @@ describe('capy skill: factory.md, the auto-loaded "how we work" page', () => {
// that stops finished PRs piling up; the procedure is crew/docs/captain.md's Drain the queue).
// 5,550 for point 17's write-up before a shelve (Garry's "do it" of 2026-11-23: an attempt that fails or is shelved is
// documented first, as gstack's default; the template is docs/shelved-attempt.md).
expect(Buffer.byteLength(text)).toBeLessThanOrEqual(5550);
// 5,875 for point 18's first versions (Garry's "do it" of 2026-11-23 on GST-3608: a first version's plan quotes the owner's
// words with a line each, and gstack-first-use runs his exact try-it steps on the real target first; docs/first-use-check.md).
expect(Buffer.byteLength(text)).toBeLessThanOrEqual(5875);
expect(text).toMatch(/^# How we work/);
expect(citationProblems(text)).toEqual([]);
});
+238 -79
View File
@@ -2,9 +2,10 @@
* The first-use check (lib/first-use.ts, lib/first-use-message.ts, bin/gstack-first-use;
* docs/first-use-check.md). Every owner, app, plan and build here is made up. Pins the
* day-one table format both plan sources share (autoplan's ### Day one table and the
* one-page day-one list), so a change to lib/autoplan-owner-text.ts fails here rather
* than silently changing what the check freezes. Runs under a temporary HOME, drive and
* record root, serves its links from a local server, and proves the real drive is untouched.
* one-page day-one list), and the owner's quoted words each frozen row must cite, so a
* change to lib/autoplan-owner-text.ts fails here rather than silently changing what the
* check freezes. Runs under a temporary HOME, drive and record root, serves its links from
* a local server, and proves the real drive is untouched.
*/
import { afterAll, beforeAll, describe, expect, spyOn, test } from 'bun:test';
import { spawnSync } from 'node:child_process';
@@ -12,7 +13,7 @@ import * as fs from 'node:fs';
import * as os from 'node:os';
import * as path from 'node:path';
import { DAY_ONE_COLUMNS, DAY_ONE_TITLES } from '../lib/autoplan-owner-text';
import { buildFingerprint, checkLinks, decide, freezeActions, modelFamily, ownerScore, predict, readManifest, recordResult, recordRoot, startRun, type Fetcher } from '../lib/first-use';
import { buildFingerprint, checkLinks, decide, freezeActions, modelFamily, ownerScore, plainLine, predict, readManifest, recordResult, recordRoot, startRun, type Fetcher } from '../lib/first-use';
import { checkPlaySpec, PLAY_PARTS, renderBrief, renderPlayMessage } from '../lib/first-use-message';
const ROOT = path.resolve(import.meta.dir, '..');
@@ -25,53 +26,89 @@ const ONE_PAGE = fs.readFileSync(path.join(FIX, 'one-page-plan.md'), 'utf8');
const PLAY = JSON.parse(fs.readFileSync(path.join(FIX, 'play.json'), 'utf8'));
const COMMIT = 'c0ffee'.padEnd(40, '0');
const BUILD = { platform: 'ios' as const, commit: COMMIT, testflight: '17' };
const HOLDING = { build: 'TestFlight build 16', defects: 'the care card shows yesterday as the last watered date' };
const T0 = new Date('2026-11-18T10:00:00Z');
const ACTIONS = [
'adds her first three plants by photo', 'sees which plant needs water today', 'marks a plant as watered', 'gets a reminder at 8am', "opens a plant's care card",
];
const STEPS = 7;
const CHECKER = 'openai/gpt-6.2-sol';
const TARGET = PLAY.target.name;
let n = 0;
const fresh = (name: string) => { const d = path.join(TMP, `${name}-${++n}`); fs.mkdirSync(d, { recursive: true }); return d; };
const shot = (dir: string, name = 'shot.png', body = 'png bytes') => { const f = path.join(dir, name); fs.writeFileSync(f, body); return f; };
const playWith = (port: number) => ({ ...PLAY, links: PLAY.links.map((l: { url: string }) => ({ ...l, url: l.url.replace('PORT', String(port)) })) });
const playWith = (port: number, o: Record<string, unknown> = {}) => ({ ...PLAY, ...o, links: PLAY.links.map((l: { url: string }) => ({ ...l, url: l.url.replace('PORT', String(port)) })) });
const AS = { account: PLAY.account, device_class: 'ios' as const };
const okFetch: Fetcher = async url => ({ status: url.endsWith('/account') ? 401 : 200 });
/** A run on its own plan copy and record root, with every action passed, the links checked and a prediction. */
function passedRun(o: { plan?: string } = {}) {
const root = fresh('root'), work = fresh('work');
const start = (o: { plan?: string; play?: unknown; root?: string; checker?: string } = {}) => {
const root = o.root ?? fresh('root'), work = fresh('work');
const planPath = path.join(work, 'plan.md');
fs.writeFileSync(planPath, o.plan ?? AUTOPLAN);
const r = startRun({ root, app: 'plantpal', planPath, build: BUILD, play: playWith(1), builder: 'anthropic/claude-opus-5-5', checker: 'openai/gpt-6.2-sol', now: T0 });
const r = startRun({ root, app: 'plantpal', planPath, build: BUILD, play: o.play ?? playWith(1), holding: HOLDING, builder: 'anthropic/claude-opus-5-5', checker: o.checker ?? CHECKER, now: T0 });
if ('error' in r) throw new Error(r.error.detail);
for (let a = 1; a <= 5; a++) {
const rec = recordResult({ dir: r.dir, action: a, verdict: 'pass', evidence: shot(work, `a${a}.png`, `screen ${a}`), device: 'iPhone 17 Pro (cloud)', account: PLAY.account, by: 'openai/gpt-6.2-sol', now: T0 });
if ('error' in rec) throw new Error(rec.error.detail);
}
const p = predict({ dir: r.dir, score: '6', why: 'the reminder works but adding plants is slow', by: 'openai/gpt-6.2-sol', now: T0 });
if ('error' in p) throw new Error(p.error.detail);
return { ...r, planPath, work, root };
};
type Rec = { verdict?: string; line?: string; at?: Date; by?: string; account?: string; target?: string; evidence?: string; needsLookup?: string; notice?: string };
const rec = (r: { dir: string; work: string }, step: number, o: Rec = {}) => recordResult({ dir: r.dir, step, verdict: o.verdict ?? 'useful', line: o.line ?? `step ${step} does what she asked`,
evidence: o.evidence ?? shot(r.work, `s${step}-${o.verdict ?? 'useful'}-${++n}.png`, `screen ${step}-${n}`), device: 'iPhone 17 Pro (cloud)', account: o.account ?? PLAY.account, target: o.target ?? TARGET,
by: o.by ?? CHECKER, needsLookup: o.needsLookup, notice: o.notice, now: o.at ?? T0 });
/** A run on its own plan copy and record root, with every step useful and a prediction. */
function passedRun(o: { plan?: string } = {}) {
const r = start(o);
for (let s = 1; s <= STEPS; s++) { const x = rec(r, s); if ('error' in x) throw new Error(x.error.detail); }
const p = predict({ dir: r.dir, score: '6', why: 'the reminder works but adding plants is slow', by: CHECKER, now: T0 });
if ('error' in p) throw new Error(p.error.detail);
return r;
}
describe('the day-one table format (pinned)', () => {
describe('the day-one table and the owner quotes it cites (pinned)', () => {
test('the parser this check reads keeps its titles and columns', () => {
expect(DAY_ONE_TITLES).toEqual(['Day one', 'Day-one page', 'Day one page']);
expect([...DAY_ONE_COLUMNS]).toEqual(['action', 'frequency', 'source', 'feature', 'route', 'first build', 'check']);
});
test('an autoplan plan and a one-page day-one list freeze the same five actions', () => {
test('an autoplan plan and a one-page day-one list freeze the same five actions and quotes', () => {
const a = freezeActions(AUTOPLAN), b = freezeActions(ONE_PAGE);
if ('error' in a || 'error' in b) throw new Error('fixture did not freeze');
if ('error' in a) throw new Error(a.error.detail);
if ('error' in b) throw new Error(b.error.detail);
expect(a.actions.map(x => x.action)).toEqual(ACTIONS);
expect(b.actions).toEqual(a.actions);
expect(b.quotes).toEqual(a.quotes);
expect(b.rows_sha256).toBe(a.rows_sha256);
expect(a.actions[3]).toEqual({ n: 4, action: 'gets a reminder at 8am', frequency: 'daily', feature: 'Morning reminder', route: 'notification', first_build: 'build 1', check: 'a notification arrives at 8:00 on the device', source: 'calendar habit' });
expect(a.actions[3]).toEqual({ n: 4, action: 'gets a reminder at 8am', frequency: 'daily', feature: 'Morning reminder', route: 'notification', first_build: 'build 1', check: 'a notification arrives at 8:00 on the device', source: 'owner words 2', quote: 2 });
expect(a.quotes[1]).toEqual({ n: 2, who: 'Ada Example, day 0', when: 'day 0', text: 'remind me every morning before work', line: 'does it' });
});
test('a sixth row marked assumed is not frozen; an assumed row in the first five refuses', () => {
expect('error' in freezeActions(AUTOPLAN)).toBe(false);
const assumed = AUTOPLAN.replace('| gets a reminder at 8am | daily | calendar habit |', '| gets a reminder at 8am | daily | assumed |');
const r = freezeActions(assumed);
expect('error' in r && r.error).toEqual({ code: 'FIRST_USE_PLAN_UNREADY', detail: 'day-one row 4 is still marked assumed' });
const assumed = AUTOPLAN.replace('| gets a reminder at 8am | daily | owner words 2 |', '| gets a reminder at 8am | daily | assumed |');
expect(freezeActions(assumed)).toMatchObject({ error: { code: 'FIRST_USE_PLAN_UNREADY', detail: 'day-one row 4 is still marked assumed' } });
});
test('a row that cites no real quote refuses, so the five actions come from the owner\'s words', () => {
const habit = AUTOPLAN.replace('| owner words 2 |', '| calendar habit |');
expect(freezeActions(habit)).toMatchObject({ error: { code: 'FIRST_USE_PLAN_UNREADY', detail: expect.stringMatching(/^day-one row 4 cites none of the owner's quotes/) } });
const ghost = AUTOPLAN.replace('| owner words 2 |', '| owner words 9 |');
expect(freezeActions(ghost)).toMatchObject({ error: { detail: expect.stringMatching(/^day-one row 4 cites none/) } });
});
test('no Owner\'s words, a quote with no time or no line, or a bad line refuses', () => {
const none = AUTOPLAN.replace(/### Owner's words[\s\S]*?### Day one/, '### Day one');
expect(freezeActions(none)).toMatchObject({ error: { detail: expect.stringMatching(/^the plan has no ### Owner's words section/) } });
const noLine = AUTOPLAN.replace('before work" → does it', 'before work"');
expect(freezeActions(noLine)).toEqual({ error: { code: 'FIRST_USE_PLAN_UNREADY', detail: 'owner quote 2 needs a line (does it or choice)' } });
const noTime = AUTOPLAN.replace('- Ada Example, day 0: "remind', '- Ada Example: "remind');
expect(freezeActions(noTime)).toEqual({ error: { code: 'FIRST_USE_PLAN_UNREADY', detail: 'owner quote 2 needs when it was said' } });
const bad = AUTOPLAN.replace('before work" → does it', 'before work" → maybe later');
expect(freezeActions(bad)).toMatchObject({ error: { detail: expect.stringContaining('bullet 2 has a line that is not does it or choice') } });
});
test('editing or inserting a quote changes the frozen hash, even when the rows stay the same', () => {
const a = freezeActions(AUTOPLAN), edited = freezeActions(AUTOPLAN.replace('before work', 'after breakfast'));
const inserted = freezeActions(AUTOPLAN.replace('- Ada Example, day 0: "I keep', '- Ada Example, day 0: "I travel a lot" → does it\n- Ada Example, day 0: "I keep'));
if ('error' in a || 'error' in edited) throw new Error('fixture did not freeze');
expect(edited.rows_sha256).not.toBe(a.rows_sha256);
expect('error' in inserted || inserted.rows_sha256 !== a.rows_sha256).toBe(true);
});
test('fewer than five rows, or an empty cell in the first five, refuses', () => {
@@ -84,7 +121,7 @@ describe('the day-one table format (pinned)', () => {
test('no table, a missing column or an empty table refuses', () => {
expect(freezeActions('# A plan\n\nNo day one here.\n')).toEqual({ error: { code: 'FIRST_USE_PLAN_UNREADY', detail: 'the plan has no ### Day one table' } });
const noCheck = ONE_PAGE.replace('| Check |', '| Notes |');
expect('error' in freezeActions(noCheck) && freezeActions(noCheck)).toMatchObject({ error: { detail: 'the table has no check column' } });
expect(freezeActions(noCheck)).toMatchObject({ error: { detail: 'the table has no check column' } });
const empty = '## Day one\n\n| action | frequency | source | feature | route | first build | check |\n|---|---|---|---|---|---|---|\n';
expect(freezeActions(empty)).toMatchObject({ error: { code: 'FIRST_USE_PLAN_UNREADY' } });
});
@@ -107,15 +144,26 @@ describe('model families and build fingerprints', () => {
test('a same-family or unknown checker refuses at start', () => {
const work = fresh('fam'), planPath = path.join(work, 'plan.md');
fs.writeFileSync(planPath, AUTOPLAN);
const base = { root: fresh('root'), app: 'plantpal', planPath, build: BUILD, play: PLAY };
const base = { root: fresh('root'), app: 'plantpal', planPath, build: BUILD, play: PLAY, holding: HOLDING };
expect(startRun({ ...base, builder: 'anthropic/claude-opus-5-5', checker: 'claude-fable-5-2' })).toMatchObject({ error: { code: 'FIRST_USE_SAME_FAMILY', detail: 'builder and checker are both anthropic' } });
expect(startRun({ ...base, builder: 'anthropic/claude-opus-5-5', checker: 'mystery-model' })).toMatchObject({ error: { code: 'FIRST_USE_SAME_FAMILY' } });
});
test('a build needs a full commit and exactly one of TestFlight build or deploy version', () => {
test('the build the owner holds now is named at start: a label and its known defects, or none', () => {
const work = fresh('hold'), planPath = path.join(work, 'plan.md');
fs.writeFileSync(planPath, AUTOPLAN);
const base = { root: fresh('root'), app: 'plantpal', planPath, build: BUILD, play: PLAY, builder: 'anthropic/claude-opus-5-5', checker: CHECKER };
expect(startRun({ ...base, holding: { build: 'TestFlight build 16' } })).toMatchObject({ error: { code: 'FIRST_USE_RECORD_INVALID', detail: expect.stringContaining('--holding-defects') } });
expect('dir' in startRun({ ...base, holding: { build: 'none', defects: 'none' } })).toBe(true);
});
test('a build needs a full commit and exactly one of TestFlight build or deploy version; Mac and server builds count', () => {
expect(buildFingerprint({ ...BUILD, commit: 'abc123' })).toMatchObject({ error: { code: 'FIRST_USE_RECORD_INVALID' } });
expect(buildFingerprint({ ...BUILD, deploy: 'v1' })).toMatchObject({ error: { code: 'FIRST_USE_RECORD_INVALID' } });
expect(buildFingerprint({ platform: 'web', commit: COMMIT })).toMatchObject({ error: { code: 'FIRST_USE_RECORD_INVALID' } });
expect(buildFingerprint({ platform: 'watch' as any, commit: COMMIT, deploy: 'v1' })).toMatchObject({ error: { detail: '--platform must be ios, android, web, macos, server' } });
expect('fingerprint' in buildFingerprint({ platform: 'macos', commit: COMMIT, deploy: '0.3.1' })).toBe(true);
expect('fingerprint' in buildFingerprint({ platform: 'server', commit: COMMIT, deploy: 'gateway 2026.11.23' })).toBe(true);
const a = buildFingerprint(BUILD), b = buildFingerprint({ ...BUILD, testflight: '18' });
if ('error' in a || 'error' in b) throw new Error('valid builds refused');
expect(a.fingerprint).not.toBe(b.fingerprint);
@@ -123,9 +171,9 @@ describe('model families and build fingerprints', () => {
});
});
describe('the play spec carries the ten parts of every play ask', () => {
describe('the play spec carries the ten parts, the target and the numbered try-it steps', () => {
test('the fixture is complete and the parts are in order', () => {
expect('spec' in checkPlaySpec(PLAY)).toBe(true);
expect(checkPlaySpec(PLAY)).toMatchObject({ spec: { target: { kind: 'realistic-copy', name: TARGET }, steps: [{ writes: 'none' }, { writes: 'a Plantpal account' }] } });
expect(PLAY_PARTS.map(p => p.part)).toEqual([
'The links, each checked live minutes before sending', 'Device and setup', 'What it is, in a sentence', 'How to start', 'Controls',
'How long to play', 'What we want to learn', 'How to report back', 'Known quirks', 'Reply word',
@@ -137,6 +185,29 @@ describe('the play spec carries the ten parts of every play ask', () => {
const r = checkPlaySpec({ ...rest, links: [{ label: 'x', url: 'ftp://nope' }], minutes: 0 });
expect(r).toEqual({ error: { code: 'FIRST_USE_PLAY_SPEC_INCOMPLETE', detail: 'missing or invalid: The links, each checked live minutes before sending (links); Controls (controls); How long to play (minutes); Known quirks (quirks)' } });
expect(checkPlaySpec({ ...PLAY, reply_word: 'two words' })).toMatchObject({ error: { detail: 'missing or invalid: Reply word (reply_word)' } });
expect(checkPlaySpec({ ...PLAY, steps: [{ text: 'Open it' }] })).toMatchObject({ error: { detail: 'missing or invalid: How to start (steps)' } });
expect(checkPlaySpec({ ...PLAY, target: { name: 'a copy' } })).toMatchObject({ error: { detail: 'missing or invalid: Device and setup (target)' } });
});
test('a copy is the default target; a step that writes on the owner\'s real setup needs his approval named', () => {
const { target: _t, ...noTarget } = PLAY;
expect(checkPlaySpec({ ...noTarget, target: { name: 'a copy', data: 'sample rows' } })).toMatchObject({ spec: { target: { kind: 'realistic-copy' } } });
const reads = Array.from({ length: 5 }, () => ({ writes: 'none' }));
const real = { ...PLAY, target: { kind: 'real', name: "Ada's own phone" }, action_writes: reads };
expect(checkPlaySpec(real)).toEqual({ error: { code: 'FIRST_USE_PLAY_SPEC_INCOMPLETE', detail: "step 2 writes on the owner's real setup with no approved_write naming his lettered approval; run it on a realistic copy, or get his approval for that write first" } });
const approved = { ...real, steps: [PLAY.steps[0], { ...PLAY.steps[1], approved_write: 'Ada, 2026-11-18: "B1"' }] };
expect(checkPlaySpec(approved)).toMatchObject({ spec: { target: { kind: 'real' }, steps: [{}, { approved_write: 'Ada, 2026-11-18: "B1"' }], action_writes: reads } });
});
test('on the owner\'s real setup each day-one action says what it writes, and a write needs his approval', () => {
const steps = [PLAY.steps[0]];
const real = { ...PLAY, steps, target: { kind: 'real', name: "Ada's own phone" } };
expect(checkPlaySpec(real)).toMatchObject({ error: { detail: 'missing or invalid: Device and setup (action_writes)' } });
expect(checkPlaySpec({ ...real, action_writes: [{ writes: 'none' }] })).toMatchObject({ error: { detail: 'missing or invalid: Device and setup (action_writes)' } });
const acts = [{ writes: 'none' }, { writes: 'none' }, { writes: 'archives a plant' }, { writes: 'none' }, { writes: 'none' }];
expect(checkPlaySpec({ ...real, action_writes: acts })).toEqual({ error: { code: 'FIRST_USE_PLAY_SPEC_INCOMPLETE', detail: "day-one action 3 writes on the owner's real setup with no approved_write naming his lettered approval; run it on a realistic copy, or get his approval for that write first" } });
acts[2] = { writes: 'archives a plant', approved_write: 'Ada, 2026-11-18: "C1"' } as typeof acts[number];
expect(checkPlaySpec({ ...real, action_writes: acts })).toMatchObject({ spec: { action_writes: [{}, {}, { approved_write: 'Ada, 2026-11-18: "C1"' }, {}, {}] } });
});
});
@@ -167,26 +238,32 @@ describe('where records live', () => {
});
describe('the gate', () => {
test('five passes, live links and a prediction clear the exact build, and the message carries every part', async () => {
test('every step played, live links and a prediction clear the exact build; the message opens with her words and names the build she holds', async () => {
const r = passedRun();
expect(decide(r.dir, BUILD, T0).reasons).toEqual(['link_unchecked: http://127.0.0.1:1/testflight (as a fresh Apple ID with notifications allowed on ios)', 'link_unchecked: http://127.0.0.1:1/account (as a fresh Apple ID with notifications allowed on ios)']);
const links = await checkLinks(r.dir, AS, okFetch, () => T0);
expect('receipts' in links && links.receipts.map(x => x.verdict)).toEqual(['live', 'live']);
const d = decide(r.dir, BUILD, new Date(T0.getTime() + 5 * 60_000));
expect(d).toMatchObject({ ok: true, reasons: [], passed: 5 });
expect(d).toMatchObject({ ok: true, reasons: [], passed: STEPS });
const msg = renderPlayMessage(d, new Date(T0.getTime() + 5 * 60_000));
expect(msg.startsWith('**Try plantpal: c0ffee000000, TestFlight build 17**\n\n**What you asked for, and what this version does with it:**\n- Ada Example, day 0: “I keep forgetting which plant needs water” → does it\n')).toBe(true);
for (const [i, label] of ['Links', 'Device and setup', 'What it is', 'How to start', 'Controls', 'How long', 'What we want to learn', 'How to report back', 'Known quirks', 'Reply word'].entries()) {
expect(msg).toContain(`${i + 1}. **${label}`);
}
expect(msg).toContain('It runs on the Plantpal test account (a copy loaded with three sample plants with a watering history).');
expect(msg).toContain(' 1. Open the TestFlight invite and install Plantpal');
expect(msg).toContain(' 4. Try: sees which plant needs water today');
expect(msg).toContain('checked live at 10:00 UTC, 5 min before this message');
expect(msg).toContain('[TestFlight invite](http://127.0.0.1:1/testflight)');
expect(msg).toContain('(asks you to sign in)');
expect(msg).toContain('Try plantpal: c0ffee000000, TestFlight build 17');
for (const a of ACTIONS) expect(msg).toContain(`- ${a}`);
expect(msg).toContain("**What you'll notice:**\n- nothing beyond the known quirks above");
expect(msg).toContain('**The build on your device now:** TestFlight build 16. Known defects in it: the care card shows yesterday as the last watered date.');
expect(msg).toContain('- 7 (useful): step 7 does what she asked');
expect(msg).not.toContain('predict');
expect(msg.startsWith(d.manifest!.try_text)).toBe(true);
});
test('another build, a stale link, a changed day-one row and tampered evidence each refuse', async () => {
test('another build, a stale link, a changed day-one row or quote and tampered evidence each refuse', async () => {
const r = passedRun();
await checkLinks(r.dir, AS, okFetch, () => T0);
expect(decide(r.dir, { ...BUILD, testflight: '18' }, T0).reasons).toEqual(['build_mismatch: this run checked c0ffee000000, TestFlight build 17, not c0ffee000000, TestFlight build 18']);
@@ -194,36 +271,87 @@ describe('the gate', () => {
'link_stale: http://127.0.0.1:1/testflight was checked at 2026-11-18T10:00:00.000Z, over 15 minutes ago',
'link_stale: http://127.0.0.1:1/account was checked at 2026-11-18T10:00:00.000Z, over 15 minutes ago',
]);
const changed = "source_changed: the day-one rows or the owner's quotes changed since the check started; start a new run";
fs.writeFileSync(r.planPath, AUTOPLAN.replace('gets a reminder at 8am', 'gets a reminder at 9am'));
expect(decide(r.dir, BUILD, T0).reasons).toEqual(['source_changed: the day-one rows changed since the check started; start a new run']);
expect(decide(r.dir, BUILD, T0).reasons).toEqual([changed]);
fs.writeFileSync(r.planPath, AUTOPLAN.replace('before work', 'after breakfast'));
expect(decide(r.dir, BUILD, T0).reasons).toEqual([changed]);
fs.writeFileSync(r.planPath, AUTOPLAN + '\nAn edit outside the table does not count.\n');
expect(decide(r.dir, BUILD, T0).ok).toBe(true);
const ev = fs.readdirSync(path.join(r.dir, 'evidence')).find(f => f.startsWith('2-'))!;
fs.writeFileSync(path.join(r.dir, 'evidence', ev), 'edited');
expect(decide(r.dir, BUILD, T0).reasons).toEqual(['action_2_evidence_stale']);
expect(decide(r.dir, BUILD, T0).reasons).toEqual(['step_2_evidence_stale']);
});
test('a failed action, a down link and a missing prediction refuse; the newest result for an action counts', async () => {
const root = fresh('root'), work = fresh('work'), planPath = path.join(work, 'plan.md');
fs.writeFileSync(planPath, ONE_PAGE);
const r = startRun({ root, app: 'plantpal', planPath, build: BUILD, play: playWith(1), builder: 'anthropic/claude-opus-5-5', checker: 'gemini-4-carbon', now: T0 });
if ('error' in r) throw new Error(r.error.detail);
const rec = (a: number, verdict: string, at: Date, note?: string) => recordResult({ dir: r.dir, action: a, verdict, evidence: shot(work, `a${a}-${verdict}.mp4`, `${a}${verdict}`), device: 'iPhone 17 Pro (cloud)', account: PLAY.account, by: 'google/gemini-4-carbon', note, now: at });
for (let a = 1; a <= 4; a++) rec(a, 'pass', T0);
expect(rec(5, 'fail', T0)).toMatchObject({ error: { detail: 'a fail needs --note saying what happened' } });
rec(5, 'fail', T0, 'the care card is blank');
test('a stored result whose verdict is not useful or thin refuses, whatever it says (fail closed, as the merge base required pass)', async () => {
for (const verdict of ['pass', 'great', undefined]) {
const r = passedRun();
await checkLinks(r.dir, AS, okFetch, () => T0);
expect(decide(r.dir, BUILD, T0).ok).toBe(true);
const file = path.join(r.dir, 'results', fs.readdirSync(path.join(r.dir, 'results')).find(f => JSON.parse(fs.readFileSync(path.join(r.dir, 'results', f), 'utf8')).step === 3)!);
const row = JSON.parse(fs.readFileSync(file, 'utf8'));
fs.chmodSync(file, 0o600);
fs.writeFileSync(file, JSON.stringify({ ...row, verdict }));
expect(decide(r.dir, BUILD, T0).reasons).toEqual([`step_3_verdict_unknown: ${String(verdict)}`]);
}
});
test('a try-it text edited after the check refuses', async () => {
const r = passedRun();
await checkLinks(r.dir, AS, okFetch, () => T0);
const file = path.join(r.dir, 'manifest.json'), m = JSON.parse(fs.readFileSync(file, 'utf8'));
fs.chmodSync(file, 0o600);
fs.writeFileSync(file, JSON.stringify({ ...m, try_text: m.try_text + '\nOne more line.\n' }));
expect(decide(r.dir, BUILD, T0).reasons.some(x => x.startsWith('try_text_changed'))).toBe(true);
});
test('broken, wrong, a lookup the owner would be asked for and a thin day-one action refuse; the newest result counts', async () => {
const r = start({ checker: 'gemini-4-carbon' });
const by = 'google/gemini-4-carbon';
for (let s = 1; s <= STEPS; s++) rec(r, s, { by });
rec(r, 2, { by, verdict: 'useful', line: 'asks for her iCloud address', needsLookup: 'her iCloud address, which the Mac already knows', at: new Date(T0.getTime() + 1000) });
rec(r, 4, { by, verdict: 'thin', line: 'shows one plant, not which needs water', at: new Date(T0.getTime() + 1000) });
rec(r, 5, { by, verdict: 'broken', line: 'the Watered button does nothing', at: new Date(T0.getTime() + 1000) });
rec(r, 6, { by, verdict: 'wrong', line: 'the reminder arrives at 8pm', at: new Date(T0.getTime() + 1000) });
await checkLinks(r.dir, AS, async () => ({ status: 401 }), () => T0);
expect(decide(r.dir, BUILD, T0).reasons).toEqual([
'action_5_failed: the care card is blank', 'link_down: http://127.0.0.1:1/testflight (status 401)', 'no_predicted_score',
'step_2_needs_lookup: her iCloud address, which the Mac already knows (an agent looks it up or does it; the owner is never asked)',
"step_4_thin: shows one plant, not which needs water (a day-one action comes from the owner's own words)",
'step_5_broken: the Watered button does nothing', 'step_6_wrong: the reminder arrives at 8pm',
'link_down: http://127.0.0.1:1/testflight (status 401)', 'no_predicted_score',
]);
rec(5, 'pass', new Date(T0.getTime() + 60_000));
await checkLinks(r.dir, AS, okFetch, () => new Date(T0.getTime() + 60_000));
const later = new Date(T0.getTime() + 60_000);
for (const s of [2, 4, 5, 6]) rec(r, s, { by, at: later });
await checkLinks(r.dir, AS, okFetch, () => later);
expect(predict({ dir: r.dir, score: '7', why: 'clean', by: 'gemini-4-carbon' })).toMatchObject({ prediction: { score: 7 } });
expect(predict({ dir: r.dir, score: '8', why: 'again', by: 'gemini-4-carbon' })).toMatchObject({ error: { code: 'FIRST_USE_RECORD_INVALID' } });
expect(decide(r.dir, BUILD, T0)).toMatchObject({ ok: true, passed: 5 });
expect(decide(r.dir, BUILD, later)).toMatchObject({ ok: true, passed: STEPS });
});
test('link receipts and results bind the owner-equivalent account and device class', async () => {
test('a thin play step and a notice pass, and the message names both', async () => {
const r = passedRun();
const later = new Date(T0.getTime() + 1000);
rec(r, 2, { verdict: 'thin', line: 'sign-in works but asks for a password twice', notice: 'iOS asks to allow notifications', at: later });
await checkLinks(r.dir, AS, okFetch, () => later);
const d = decide(r.dir, BUILD, later);
expect(d).toMatchObject({ ok: true, passed: STEPS });
const msg = renderPlayMessage(d, later);
expect(msg).toContain("**What you'll notice:**\n- Step 2 is thin: sign-in works but asks for a password twice\n- At step 2 you'll see: iOS asks to allow notifications\n");
expect(msg).toContain('- 2 (thin): sign-in works but asks for a password twice');
});
test('a first build says so; checker text is one plain line', () => {
const r = start();
const read = readManifest(r.dir);
if ('error' in read) throw new Error(read.error.detail);
const first = { ...read.manifest, holding: { build: 'none', defects: 'none' } };
expect(renderPlayMessage({ ok: true, reasons: [], manifest: first, passed: 0, verdicts: [], links: [{ checked_at: T0.toISOString() } as any] }, T0)).toContain('**The build on your device now:** none yet: this is your first build of it.');
expect(plainLine('see [the docs](https://evil.example) <b>now</b>\nplease')).toBe('see the docs now please');
expect(plainLine('x'.repeat(500))).toHaveLength(240);
expect(rec(r, 1, { line: ' \n ' })).toMatchObject({ error: { detail: '--line needs one line on what the owner would see at this step' } });
});
test('link receipts and results bind the owner-equivalent account, device class and target', async () => {
const r = passedRun();
expect(await checkLinks(r.dir, { account: 'any session', device_class: 'ios' }, okFetch, () => T0)).toMatchObject({ error: { code: 'FIRST_USE_RECORD_INVALID' } });
expect(await checkLinks(r.dir, { account: PLAY.account, device_class: 'web' }, okFetch, () => T0)).toMatchObject({ error: { code: 'FIRST_USE_RECORD_INVALID' } });
@@ -232,17 +360,28 @@ describe('the gate', () => {
fs.mkdirSync(path.join(r.dir, 'links'));
fs.writeFileSync(path.join(r.dir, 'links', 'other.json'), JSON.stringify(other));
expect(decide(r.dir, BUILD, T0).reasons[0]).toBe('link_unchecked: http://127.0.0.1:1/testflight (as a fresh Apple ID with notifications allowed on ios)');
expect(recordResult({ dir: r.dir, action: 1, verdict: 'pass', evidence: shot(r.work, 'dev.png'), device: 'd', account: 'a developer account', by: 'openai/gpt-6.2-sol' })).toMatchObject({ error: { detail: 'play on the owner-equivalent account and pass it exactly: --account "a fresh Apple ID with notifications allowed"' } });
expect(rec(r, 1, { account: 'a developer account' })).toMatchObject({ error: { detail: 'play on the owner-equivalent account and pass it exactly: --account "a fresh Apple ID with notifications allowed"' } });
expect(rec(r, 1, { target: 'a scratch config' })).toMatchObject({ error: { detail: 'play on the play spec\'s target and pass it exactly: --target "the Plantpal test account"' } });
});
test('the builder cannot record a result or a prediction, and evidence must be a screenshot or video', () => {
test('the builder cannot record a result or a prediction, and evidence must be a screenshot, video or terminal capture', () => {
const r = passedRun();
expect(recordResult({ dir: r.dir, action: 1, verdict: 'pass', evidence: shot(r.work, 'self.png'), device: 'd', account: PLAY.account, by: 'anthropic/claude-opus-5-5' })).toMatchObject({ error: { code: 'FIRST_USE_SAME_FAMILY' } });
expect(recordResult({ dir: r.dir, action: 1, verdict: 'pass', evidence: shot(r.work, 'notes.txt'), device: 'd', account: PLAY.account, by: 'openai/gpt-6.2-sol' })).toMatchObject({ error: { code: 'FIRST_USE_RECORD_INVALID' } });
expect(recordResult({ dir: r.dir, action: 6, verdict: 'pass', evidence: shot(r.work, 'six.png'), device: 'd', account: PLAY.account, by: 'openai/gpt-6.2-sol' })).toMatchObject({ error: { detail: '--action must be 1 to 5' } });
expect(rec(r, 1, { by: 'anthropic/claude-opus-5-5' })).toMatchObject({ error: { code: 'FIRST_USE_SAME_FAMILY' } });
expect(rec(r, 1, { evidence: shot(r.work, 'notes.pdf') })).toMatchObject({ error: { code: 'FIRST_USE_RECORD_INVALID' } });
expect(rec(r, 1, { evidence: shot(r.work, 'terminal.log', 'gateway: ok') })).toMatchObject({ result: { evidence: { kind: 'text' } } });
expect(rec(r, 1, { verdict: 'pass' })).toMatchObject({ error: { detail: '--verdict must be useful, thin, wrong, broken' } });
expect(rec(r, 8)).toMatchObject({ error: { detail: '--step must be 1 to 7' } });
const link = path.join(r.work, 'link.png');
fs.symlinkSync(shot(r.work, 'real.png'), link);
expect(recordResult({ dir: r.dir, action: 1, verdict: 'pass', evidence: link, device: 'd', account: PLAY.account, by: 'openai/gpt-6.2-sol' })).toMatchObject({ error: { detail: 'the evidence must be a regular file, not a link or directory' } });
expect(rec(r, 1, { evidence: link })).toMatchObject({ error: { detail: 'the evidence must be a regular file, not a link or directory' } });
});
test('a schema-1 run from before this change refuses with a clear line', () => {
const r = passedRun();
const m = JSON.parse(fs.readFileSync(path.join(r.dir, 'manifest.json'), 'utf8'));
const old = fresh('old');
fs.writeFileSync(path.join(old, 'manifest.json'), JSON.stringify({ ...m, schema_version: 1 }));
expect(readManifest(old)).toMatchObject({ error: { detail: `${old} is a schema-1 run from before the try-it steps and the owner's quotes were checked; start a new run` } });
});
test('the owner score and words sit beside the prediction; the manifest is written once', () => {
@@ -254,7 +393,7 @@ describe('the gate', () => {
expect(d.prediction?.score).toBe(6);
expect(d.owner).toMatchObject({ score: 5, words: '5, better after the fix' });
expect(fs.readdirSync(path.join(r.dir, 'owner'))).toHaveLength(2);
const again = startRun({ root: r.root, app: 'plantpal', planPath: r.planPath, build: BUILD, play: PLAY, builder: 'anthropic/claude-opus-5-5', checker: 'openai/gpt-6.2-sol', now: T0 });
const again = startRun({ root: r.root, app: 'plantpal', planPath: r.planPath, build: BUILD, play: PLAY, holding: HOLDING, builder: 'anthropic/claude-opus-5-5', checker: CHECKER, now: T0 });
expect(again).toMatchObject({ error: { code: 'FIRST_USE_RECORD_INVALID' } });
});
@@ -264,29 +403,28 @@ describe('the gate', () => {
fs.rmSync(path.join(r.dir, d), { recursive: true, force: true });
fs.writeFileSync(path.join(r.dir, d), 'not a directory');
}
expect(recordResult({ dir: r.dir, action: 1, verdict: 'pass', evidence: shot(r.work, 'again.png', 'again'), device: 'd', account: PLAY.account, by: 'openai/gpt-6.2-sol' })).toMatchObject({ error: { code: 'FIRST_USE_RECORD_INVALID' } });
expect(rec(r, 1)).toMatchObject({ error: { code: 'FIRST_USE_RECORD_INVALID' } });
expect(await checkLinks(r.dir, AS, okFetch)).toMatchObject({ error: { code: 'FIRST_USE_RECORD_INVALID' } });
expect(ownerScore({ dir: r.dir, score: '4', words: '4, fine', by: 'GStack Minder' })).toMatchObject({ error: { code: 'FIRST_USE_RECORD_INVALID' } });
});
test('the brief shell-quotes every value it puts into the record and predict lines', () => {
const work = fresh('quote'), planPath = path.join(work, 'plan.md'), marker = path.join(work, 'ran');
fs.writeFileSync(planPath, AUTOPLAN);
const marker = path.join(fresh('quote'), 'ran');
const account = `Ada's "test" $HOME \`touch ${marker}\` $(touch ${marker}) account`;
const r = startRun({ root: path.join(fresh('root'), 'it\'s "$x"'), app: 'plantpal', planPath, build: BUILD, play: { ...PLAY, account }, builder: 'anthropic/claude-opus-5-5', checker: 'openai/gpt-6.2-sol', now: T0 });
if ('error' in r) throw new Error(r.error.detail);
const target = `it's $(touch ${marker}) copy`;
const r = start({ root: path.join(fresh('root'), 'it\'s "$x"'), play: { ...PLAY, account, target: { ...PLAY.target, name: target } } });
const lines = renderBrief(r.manifest, r.dir).split('\n').filter(l => l.startsWith('gstack-first-use '));
expect(lines).toHaveLength(3);
for (const line of lines) {
const argv = spawnSync('bash', ['-c', line.replace(/^gstack-first-use /, "printf '%s\\n' ")], { encoding: 'utf8', timeout: 10_000 }).stdout.split('\n');
expect(argv[argv.indexOf('--run') + 1]).toBe(r.dir);
expect(argv[argv.indexOf('--by') + 1]).toBe('openai/gpt-6.2-sol');
if (line.includes(' record ')) expect(argv[argv.indexOf('--account') + 1]).toBe(account);
expect(argv[argv.indexOf('--by') + 1]).toBe(CHECKER);
if (line.includes(' record ')) { expect(argv[argv.indexOf('--account') + 1]).toBe(account); expect(argv[argv.indexOf('--target') + 1]).toBe(target); }
}
expect(fs.existsSync(marker)).toBe(false);
});
test('the brief gives the checker only the play text and the frozen actions', () => {
test('the brief gives the checker the exact try-it message, the target and its rules, and nothing about the build', () => {
const r = passedRun();
const read = readManifest(r.dir);
if ('error' in read) throw new Error('no manifest');
@@ -294,10 +432,27 @@ describe('the gate', () => {
expect(brief).toContain('You run on openai/gpt-6.2-sol; the team that built it runs on anthropic models');
expect(brief).toContain('tools.capy.phone');
expect(brief).toContain('TestFlight build 17');
for (const a of ACTIONS) expect(brief).toContain(a);
expect(brief).toContain(`gstack-first-use record --run '${r.dir}' --action N --verdict pass --evidence FILE --device 'DEVICE YOU USED' --account 'a fresh Apple ID with notifications allowed' --by 'openai/gpt-6.2-sol'`);
expect(brief).not.toContain('Ada Example');
expect(brief).toContain(read.manifest.try_text.trimEnd());
expect(brief).toContain('Never send anything as the owner');
expect(brief).toContain('Run every step on the Plantpal test account (a copy loaded with three sample plants with a watering history)');
expect(brief).toContain('2. Sign in with the account above. Writes: a Plantpal account');
expect(brief).toContain("3. Day-one action, from the owner's words (quote 1): adds her first three plants by photo. It works when: three plants show on the home screen with names. Writes: unknown, so treat it as a write");
expect(brief).toContain(`gstack-first-use record --run '${r.dir}' --step N --verdict useful --line 'WHAT THE OWNER SEES' --evidence FILE --device 'DEVICE YOU USED' --account 'a fresh Apple ID with notifications allowed' --target 'the Plantpal test account' --by 'openai/gpt-6.2-sol'`);
expect(brief).not.toContain(r.planPath);
expect(brief).not.toContain('TestFlight build 16');
});
test('the brief drives a Mac through Aside and a server over its shell', () => {
const work = fresh('mac'), planPath = path.join(work, 'plan.md');
fs.writeFileSync(planPath, AUTOPLAN);
const base = { root: fresh('root'), app: 'helper', planPath, holding: HOLDING, builder: 'anthropic/claude-opus-5-5', checker: CHECKER, now: T0 };
const mac = startRun({ ...base, build: { platform: 'macos', commit: COMMIT, deploy: '0.3.1' }, play: { ...PLAY, target: { kind: 'real', name: "Ada's Mac" }, steps: [{ text: 'Run helper setup', writes: 'none' }], action_writes: Array.from({ length: 5 }, () => ({ writes: 'none' })) } });
if (!('error' in mac)) expect(mac.manifest.steps.filter(s => s.kind === 'action').map(s => s.writes)).toEqual(['none', 'none', 'none', 'none', 'none']);
if ('error' in mac) throw new Error(mac.error.detail);
expect(renderBrief(mac.manifest, mac.dir)).toContain('through the Aside CLI, preferably over Tailscale');
const srv = startRun({ ...base, root: fresh('root'), build: { platform: 'server', commit: COMMIT, deploy: 'gw-7' }, play: PLAY });
if ('error' in srv) throw new Error(srv.error.detail);
expect(renderBrief(srv.manifest, srv.dir)).toContain('over its shell or CLI');
});
});
@@ -328,42 +483,46 @@ describe('gstack-first-use (CLI, temporary HOME and drive)', () => {
fs.writeFileSync(plan, AUTOPLAN);
fs.writeFileSync(play, JSON.stringify(playWith(server.port!)));
const build = ['--platform', 'ios', '--commit', COMMIT, '--testflight', '17'];
const start = await cli('start', '--app', 'plantpal', '--plan', plan, '--play', play, ...build, '--builder', 'anthropic/claude-opus-5-5', '--checker', 'openai/gpt-6.2-sol');
expect(start.code).toBe(0);
const dir = /^FIRST_USE_RUN: (.+)$/m.exec(start.stdout)![1]!;
const holding = ['--holding', 'TestFlight build 16', '--holding-defects', 'none'];
expect((await cli('start', '--app', 'plantpal', '--plan', plan, '--play', play, ...build, '--builder', 'anthropic/claude-opus-5-5', '--checker', CHECKER)).stderr).toContain('--holding, --holding-defects');
const begun = await cli('start', '--app', 'plantpal', '--plan', plan, '--play', play, ...build, ...holding, '--builder', 'anthropic/claude-opus-5-5', '--checker', CHECKER);
expect(begun.code).toBe(0);
const dir = /^FIRST_USE_RUN: (.+)$/m.exec(begun.stdout)![1]!;
expect(dir.startsWith(path.join(home, '.capy', 'drive', 'user-ada-example', 'first-use', 'plantpal') + path.sep)).toBe(true);
expect(start.stdout).toContain('FIRST_USE_FROZEN: 5 actions');
expect(begun.stdout).toContain('FIRST_USE_FROZEN: 7 steps (5 day-one actions) quotes=2');
expect(begun.stdout).toContain(' 2. Sign in with the account above (writes: a Plantpal account)');
const early = await cli('message', '--run', dir, ...build);
expect(early.code).toBe(3);
expect(early.stdout).toBe('');
expect(early.stderr).toContain('(FIRST_USE_REFUSED)');
expect(early.stderr).toContain('action_1_not_played');
expect(early.stderr).toContain('step_1_not_played');
const brief = await cli('brief', '--run', dir);
expect(brief.stdout).toContain('# Cold first-use check: plantpal');
expect(brief.stderr).toContain('DISPATCH: give this brief');
for (let a = 1; a <= 5; a++) {
const rec = await cli('record', '--run', dir, '--action', String(a), '--verdict', 'pass', '--evidence', shot(work, `a${a}.png`, `s${a}`), '--device', 'iPhone 17 Pro (cloud)', '--account', PLAY.account, '--by', 'openai/gpt-6.2-sol');
expect(rec.code).toBe(0);
for (let s = 1; s <= STEPS; s++) {
const one = await cli('record', '--run', dir, '--step', String(s), '--verdict', 'useful', '--line', 'works', '--evidence', shot(work, `s${s}.png`, `s${s}`), '--device', 'iPhone 17 Pro (cloud)', '--account', PLAY.account, '--target', TARGET, '--by', CHECKER);
expect(one.code).toBe(0);
}
expect((await cli('predict', '--run', dir, '--score', '6', '--why', 'reminder works, adding is slow', '--by', 'openai/gpt-6.2-sol')).stdout).toContain('FIRST_USE_PREDICTED: 6');
expect((await cli('predict', '--run', dir, '--score', '6', '--why', 'reminder works, adding is slow', '--by', CHECKER)).stdout).toContain('FIRST_USE_PREDICTED: 6');
expect((await cli('links', '--run', dir)).code).toBe(1);
const links = await cli('links', '--run', dir, '--account', PLAY.account, '--device-class', 'ios');
expect(links.code).toBe(0);
expect(links.stdout).toContain('LINK: live status=403 as=ios');
const check = await cli('check', '--run', dir, ...build);
expect(check.stdout).toMatch(/^FIRST_USE: pass app=plantpal build=c0ffee000000, TestFlight build 17 actions=5\/5 links=2\/2 checker=openai\/gpt-6.2-sol predicted=6$/m);
expect(check.stdout).toMatch(/^FIRST_USE: pass app=plantpal build=c0ffee000000, TestFlight build 17 steps=7\/7 thin=0 notices=0 links=2\/2 checker=openai\/gpt-6.2-sol predicted=6$/m);
const msg = await cli('message', '--run', dir, ...build);
expect(msg.code).toBe(0);
expect(msg.stdout).toContain('10. **Reply word:** played');
expect(msg.stdout).toContain('**The build on your device now:** TestFlight build 16. Known defects in it: none.');
expect((await cli('check', '--run', dir, '--platform', 'ios', '--commit', COMMIT, '--testflight', '18')).code).toBe(3);
expect((await cli('score', '--run', dir, '--score', '4', '--words', '4, Talk is slow', '--by', 'Example Captain')).code).toBe(0);
const show = await cli('show', '--run', dir, '--json');
expect(JSON.parse(show.stdout)).toMatchObject({ passed: 5, predicted: 6, owner: { score: 4, words: '4, Talk is slow' }, gap: -2 });
expect(JSON.parse(show.stdout)).toMatchObject({ passed: 7, steps: 7, predicted: 6, owner: { score: 4, words: '4, Talk is slow' }, gap: -2 });
expect(realRecords()).toEqual(before);
});
+3 -2
View File
@@ -6,7 +6,8 @@ Made-up plan for test/first-use.test.ts. The owner, the app and every row are in
### Owner's words
- Ada Example, day 0: "I keep forgetting which plant needs water"
- Ada Example, day 0: "I keep forgetting which plant needs water" → does it
- Ada Example, day 0: "remind me every morning before work" → does it
### Day one
@@ -15,7 +16,7 @@ Made-up plan for test/first-use.test.ts. The owner, the app and every row are in
| adds her first three plants by photo | once | owner words 1 | Add plant | home screen, plus button | build 1 | three plants show on the home screen with names |
| sees which plant needs water today | daily | owner words 1 | Today list | root screen | build 1 | the plant due today is at the top, marked due |
| marks a plant as watered | daily | owner words 1 | Watered button | Today list, tap a plant | build 1 | the plant drops off today's list |
| gets a reminder at 8am | daily | calendar habit | Morning reminder | notification | build 1 | a notification arrives at 8:00 on the device |
| gets a reminder at 8am | daily | owner words 2 | Morning reminder | notification | build 1 | a notification arrives at 8:00 on the device |
| opens a plant's care card | weekly | owner words 1 | Care card | home screen, tap a plant | build 1 | the card shows light, water and the last watered date |
| shares a plant with her partner | assumed | assumed | Sharing | plant card, share | build 2 | the partner's phone shows the plant |
+6 -1
View File
@@ -2,6 +2,11 @@
The first five things the owner does on day one, each with a check that it works. Invented for tests.
## Owner's words
- Ada Example, day 0: "I keep forgetting which plant needs water" → does it
- Ada Example, day 0: "remind me every morning before work" → does it
## Day one
| Action | Feature | Route | First build | Check | Frequency | Source |
@@ -9,7 +14,7 @@ The first five things the owner does on day one, each with a check that it works
| adds her first three plants by photo | Add plant | home screen, plus button | build 1 | three plants show on the home screen with names | once | owner words 1 |
| sees which plant needs water today | Today list | root screen | build 1 | the plant due today is at the top, marked due | daily | owner words 1 |
| marks a plant as watered | Watered button | Today list, tap a plant | build 1 | the plant drops off today's list | daily | owner words 1 |
| gets a reminder at 8am | Morning reminder | notification | build 1 | a notification arrives at 8:00 on the device | daily | calendar habit |
| gets a reminder at 8am | Morning reminder | notification | build 1 | a notification arrives at 8:00 on the device | daily | owner words 2 |
| opens a plant's care card | Care card | home screen, tap a plant | build 1 | the card shows light, water and the last watered date | weekly | owner words 1 |
## Install
+15
View File
@@ -13,8 +13,23 @@
"device": "iPhone 17 Pro on iOS 26",
"setup": "Install TestFlight from the App Store first.",
"account": "a fresh Apple ID with notifications allowed",
"target": {
"kind": "realistic-copy",
"name": "the Plantpal test account",
"data": "three sample plants with a watering history"
},
"what": "Plantpal tells you which houseplant needs water today.",
"start": "Open the TestFlight invite, tap Install, then open Plantpal.",
"steps": [
{
"text": "Open the TestFlight invite and install Plantpal",
"writes": "none"
},
{
"text": "Sign in with the account above",
"writes": "a Plantpal account"
}
],
"controls": "Tap to open, swipe left on a plant to mark it watered.",
"minutes": 10,
"learn": "Whether the Today list is the first thing you want every morning.",
@@ -0,0 +1,4 @@
{
"bytes": 296,
"why": "apple-release: one paragraph sending a TestFlight build for an owner trying a first version through gstack-first-use (GST-3608, Garry do it 2026-11-23)"
}