mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-29 19:34:29 +01:00
A first version's public copy keeps out the owner's short quotes, and phone first-use checks install a build the phone can run (GST-3646) (#4772)
A first version's public export now keeps out the owner's short quotes and his reasons to leave something out, and a phone first-use check installs a build the cloud phone can actually run. Why: a one- or two-word quote or a leave-out reason could reach the public copy through the gate's choice titles, and the phone check named a TestFlight build the cloud phone can't install. Phone checks now need `--phone-build ` on `gstack-first-use start`; phone runs started before this change must be started again. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> Review-Finding: p1/specialist-batched#1 reader=testing Review-Finding: p2/specialist-batched#1 reader=security
This commit is contained in:
1 parent
7c321fff5d
commit
84b4eab0a9
10 files changed
+139
-22
No files matched your search
@@ -3,7 +3,7 @@
|
||||
* gstack-first-use — the cold first-use check for a first version or app build (docs/first-use-check.md).
|
||||
*
|
||||
* gstack-first-use start --app <slug> --plan <plan.md> --play <play.json> --platform ios|android|web|macos|server --commit <sha>
|
||||
* (--testflight <build> | --deploy <version>) --holding <build label|none> --holding-defects <list|none>
|
||||
* (--testflight <build> | --deploy <version>) [--phone-build <id>] --holding <build label|none> --holding-defects <list|none>
|
||||
* --builder <model> --checker <model> [--json]
|
||||
* gstack-first-use brief --run <dir>
|
||||
* gstack-first-use record --run <dir> --step <n> --verdict useful|thin|wrong|broken --line <text> --evidence <file> --device <text>
|
||||
@@ -35,8 +35,9 @@ import { resultLine } from '../lib/result-codes';
|
||||
const HELP = `gstack-first-use — a cold first-use check: the owner's exact try-it steps, run on the real target before the owner is asked (docs/first-use-check.md)
|
||||
|
||||
start --app <slug> --plan <plan.md> --play <play.json> --platform ios|android|web|macos|server --commit <sha>
|
||||
(--testflight <build> | --deploy <version>) --holding <build label|none> --holding-defects <list|none>
|
||||
(--testflight <build> | --deploy <version>) [--phone-build <id>] --holding <build label|none> --holding-defects <list|none>
|
||||
--builder <model> --checker <model> [--json]
|
||||
--phone-build: ios and android only, the 26-character id of Capy's mobile build of --commit that the cloud phone installs
|
||||
brief --run <dir> what the checker from the other model family is given
|
||||
record --run <dir> --step <n> --verdict useful|thin|wrong|broken --line <text> --evidence <file> --device <text> --account <text>
|
||||
--target <text> --by <model> [--needs-lookup <text>] [--notice <text>]
|
||||
@@ -74,7 +75,7 @@ function cmdStart(a: string[], json: boolean): number {
|
||||
if ('error' in root) return refuse('start', root.error);
|
||||
let play: unknown;
|
||||
try { play = JSON.parse(fs.readFileSync(flag(a, '--play')!, 'utf8')); } catch { return refuse('start', { code: 'FIRST_USE_PLAY_SPEC_INCOMPLETE', detail: `${flag(a, '--play')} is not a readable JSON play spec` }); }
|
||||
const r = startRun({ root: root.root, app: flag(a, '--app')!, planPath: flag(a, '--plan')!, build: buildArgs(a), play, holding: { build: flag(a, '--holding'), defects: flag(a, '--holding-defects') }, builder: flag(a, '--builder')!, checker: flag(a, '--checker')! });
|
||||
const r = startRun({ root: root.root, app: flag(a, '--app')!, planPath: flag(a, '--plan')!, build: buildArgs(a), phoneBuild: flag(a, '--phone-build'), play, holding: { build: flag(a, '--holding'), defects: flag(a, '--holding-defects') }, builder: flag(a, '--builder')!, checker: flag(a, '--checker')! });
|
||||
if ('error' in r) return refuse('start', r.error);
|
||||
const m = r.manifest;
|
||||
if (json) { say(JSON.stringify({ run: r.dir, steps: m.steps.length, actions: m.actions.length, quotes: m.quotes.length, rows_sha256: m.source.rows_sha256, try_sha256: m.try_sha256, target: m.play.target, build: m.build })); return EXIT.ok; }
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
**A first version's public export now keeps out the owner's short quotes and his reasons to leave something out, and a phone first-use check installs a build the cloud phone can actually run.** `gstack-autoplan export --public` used to redact only owner quotes of three or more words, so a one- or two-word quote, or a `leave out:` reason, could reach the public copy through the gate's choice titles. Now every plan quote is redacted wherever it appears directly inside quote marks, and every `leave out:` reason wherever the gate shows it, whatever case the key is typed in; `validate --public` catches either one written back. `gstack-first-use start` for an iOS or Android build now takes `--phone-build <id>`, the Capy mobile build of the same commit, because the cloud phone installs only that kind of build and a TestFlight number left the checker unable to install anything. An iOS or Android run started before this change is refused with a note to start a new one (docs/first-use-check.md).
|
||||
@@ -25,6 +25,8 @@ Each bullet is who, when, the words in quotes, then an arrow (`→` or `->`) and
|
||||
| `does it` | this version does what the words ask | a reviewer who finds it does less files a `narrows_quote` finding, and the gate asks |
|
||||
| `choice` | this version doesn't fully do it yet | one lettered choice quoting the words: a) build it in this version, b) leave it out. It recommends a, unless the line says `leave out: <reason>`, shown on the choice. `size: <n>` is shown as the cost |
|
||||
|
||||
A public export (`gstack-autoplan export --public`) drops the owner's words: every quote, however short, wherever it appears in quote marks, and every `leave out:` reason, wherever the gate shows it. A quote of three or more words is also caught where it is repeated without quote marks.
|
||||
|
||||
A cut under `### What it won't do yet` that drops a quoted line becomes that quote's choice and leaves the list. On a first version every other cut gets its own letter. The owner brief shows the quotes and their lines first, then the day-one table, then the remaining cuts.
|
||||
|
||||
The day-one table needs a heading named `Day one` (any level; `Day-one page` also works) followed by a table with these seven columns, in any order:
|
||||
@@ -43,14 +45,14 @@ Run these from the thread that owns the build (on Capy, a Captain or the agent b
|
||||
|
||||
```bash
|
||||
gstack-first-use start --app plantpal --plan plan.md --play play.json \
|
||||
--platform ios --commit <full commit sha> --testflight 17 \
|
||||
--platform ios --commit <full commit sha> --testflight 17 --phone-build <mobile build id> \
|
||||
--holding "TestFlight build 16" --holding-defects "the care card shows yesterday's date" \
|
||||
--builder anthropic/claude-opus-5-5 --checker openai/gpt-6.2-sol
|
||||
```
|
||||
|
||||
Platforms are `ios`, `android`, `web`, `macos` (a Mac app or helper) and `server` (software on the owner's box); give `--deploy <version>` for anything not on TestFlight. `--holding none --holding-defects none` marks a first build. `start` freezes the owner's quotes, the play spec's numbered steps followed by the five day-one actions, and the try-it text into a write-once `manifest.json`, with a hash over the rows and the text of every quote, and prints `FIRST_USE_RUN: <dir>`. It refuses a plan whose table or quotes are missing or malformed, a play spec that misses a part, and a checker from the builder's model family.
|
||||
Platforms are `ios`, `android`, `web`, `macos` (a Mac app or helper) and `server` (software on the owner's box); give `--deploy <version>` for anything not on TestFlight. An ios or android check also needs `--phone-build <id>`: the 26-character id of Capy's mobile build (`tools.mobile.build`) of the same commit. The cloud phone installs only that kind of build, never a TestFlight or store number, so `start` refuses a phone build without it. gstack can't check that this build is the same code TestFlight ships. The builder names it, and the brief records which one the checker installed. `--holding none --holding-defects none` marks a first build. `start` freezes the owner's quotes, the play spec's numbered steps followed by the five day-one actions, and the try-it text into a write-once `manifest.json`, with a hash over the rows and the text of every quote, and prints `FIRST_USE_RUN: <dir>`. It refuses a plan whose table or quotes are missing or malformed, a play spec that misses a part, and a checker from the builder's model family.
|
||||
|
||||
2. **Hand the checker its brief.** `gstack-first-use brief --run <dir>` prints everything the checker gets: the target and its rules, the exact try-it message, and each step with what it writes and the commands to record it. Give it to one fresh agent on the `--checker` model and nothing else about the build: no plan, no code, no notes. On Capy, start a subagent with that model on `machine: "fresh"`. For a phone build it attaches a cloud phone (`tools.capy.phone`) pointed at the target; for a Mac build on the owner's own Mac it drives Aside over Tailscale; for a server build it works over the box's shell. It runs its own gstack install check first.
|
||||
2. **Hand the checker its brief.** `gstack-first-use brief --run <dir>` prints everything the checker gets: the target and its rules, the exact try-it message, and each step with what it writes and the commands to record it. Give it to one fresh agent on the `--checker` model and nothing else about the build: no plan, no code, no notes. On Capy, start a subagent with that model on `machine: "fresh"`. For a phone build it attaches a cloud phone (`tools.capy.phone`), installs the `--phone-build` build on it and points it at the target; for a Mac build on the owner's own Mac it drives Aside over Tailscale; for a server build it works over the box's shell. It runs its own gstack install check first.
|
||||
|
||||
3. **The checker records each step and predicts the score.**
|
||||
|
||||
@@ -107,7 +109,7 @@ On the owner's real setup the checker only reads: the brief forbids sending anyt
|
||||
|
||||
The record holds the owner's own scores and words, so it stays private. On Capy it lives in the owner's user-level Capy Drive folder (`~/.capy/drive/user-*/first-use/<app>/<run>/`), which every thread the owner has opened can read and nobody else's can. If none or several such folders are mounted, the tool refuses rather than fall back to the machine's throwaway folder. Off Capy it lives under the gstack state root (`first-use/`). `GSTACK_FIRST_USE_DIR` overrides both. Nothing from a run belongs in a public repository or a PR body.
|
||||
|
||||
A run directory holds `manifest.json`, `results/`, `evidence/`, `links/`, `prediction.json` and `owner/`. Every file is written once; to check again (a new build, changed day-one rows or quotes, a new prediction), start a new run. Runs started before the try-it steps were checked (schema 1) refuse with a line saying to start a new one.
|
||||
A run directory holds `manifest.json`, `results/`, `evidence/`, `links/`, `prediction.json` and `owner/`. Every file is written once; to check again (a new build, changed day-one rows or quotes, a new prediction), start a new run. Runs started before the try-it steps were checked (schema 1), and ios or android runs started without `--phone-build`, refuse with a line saying to start a new one.
|
||||
|
||||
## How we'll know it helps
|
||||
|
||||
|
||||
@@ -2520,7 +2520,7 @@ whose Plan line differs from the PR body's current line.
|
||||
<a id="first-use-record-invalid"></a>
|
||||
### `gstack-first-use: ... (FIRST_USE_RECORD_INVALID)`
|
||||
|
||||
**Meaning.** A value or file is invalid: a bad `--commit`, `--platform`, `--step`, `--verdict`, `--line` or score, missing `--holding` or `--holding-defects`, an `--account`, `--target` or `--device-class` that isn't the run's owner-equivalent audience and target, a run directory outside the record root, evidence that is not a screenshot, short video or terminal capture (or is empty, a link, or over 100 MB), an unreadable manifest or a schema-1 run from before the try-it steps were checked, or a second prediction on a run. Exit 1. **Fix.** Correct the value. Run files are written once; to redo a check, or to continue from a schema-1 run, start a new run.
|
||||
**Meaning.** A value or file is invalid: a bad `--commit`, `--platform`, `--step`, `--verdict`, `--line` or score, missing `--holding` or `--holding-defects`, an ios or android `start` without `--phone-build <id>` (the 26-character id of Capy's mobile build of `--commit`, which is what the cloud phone installs; a TestFlight or store number can't be installed there), an `--account`, `--target` or `--device-class` that isn't the run's owner-equivalent audience and target, a run directory outside the record root, evidence that is not a screenshot, short video or terminal capture (or is empty, a link, or over 100 MB), an unreadable manifest, a schema-1 run from before the try-it steps were checked, an ios or android run started before `--phone-build` existed, or a second prediction on a run. Exit 1. **Fix.** Correct the value. Run files are written once; to redo a check, or to continue from a schema-1 run or an older phone run, start a new run (with `--phone-build` for a phone).
|
||||
|
||||
<a id="first-use-refused"></a>
|
||||
### `gstack-first-use check|message: ... (FIRST_USE_REFUSED)`
|
||||
@@ -6028,7 +6028,10 @@ is a quote wherever it appears whole, and from 8 words any 8 consecutive words
|
||||
are one, compared across punctuation, line breaks, JSON escapes, entities, HTML and
|
||||
Markdown markup, invisible format characters, contractions and case; replies
|
||||
of 1 or 2 words are not scanned for, and words the owner echoed from earlier
|
||||
text he didn't write are not his (the words a reply adds to an echo still are). See
|
||||
text he didn't write are not his (the words a reply adds to an echo still are).
|
||||
A plan quote of any length is also one wherever it appears directly inside quote
|
||||
marks, and so is its `leave out:` reason after `leave out:`, `leave it out for
|
||||
now:` or `reason to leave it out:`, in any case. See
|
||||
[the public copy](unattended.md#the-public-copy). `gstack-artifact validate --public <dir> --private
|
||||
<run>/run.json` reports each quote with file:line, and `gstack-autoplan export
|
||||
--public` runs that check on a staging copy and writes nothing when it fails.
|
||||
|
||||
@@ -386,6 +386,11 @@ owner's own words: nothing a person wrote leaves without their click (GST-1243).
|
||||
wherever it appears whole; from 8 words, any 8 consecutive words of it are a
|
||||
quote too. Replies of 1 or 2 words ("yes", "do it") are not scanned for:
|
||||
they are codes or grammar, and the field itself is already dropped. A quote
|
||||
under the plan's `### Owner's words` heading is redacted at any length
|
||||
wherever it appears directly inside quote marks, and the reason on its
|
||||
`leave out:` line wherever it follows `leave out:`, `leave it out for now:`
|
||||
or `reason to leave it out:`, in any case; a bare mention of a short quote's
|
||||
words outside quote marks stays. A quote
|
||||
extends over the neighboring words that also belong to that reply, and the
|
||||
marker replaces the original characters from its first word to its last.
|
||||
- **Echoes stay.** Words the owner repeated from text recorded before the reply,
|
||||
|
||||
@@ -9,7 +9,9 @@
|
||||
* answer at the same gate replaced), the words a carried gate reused, each
|
||||
* quote in a `### Owner's words` section of any plan text the run kept (plan-active.md, plan-source*.md,
|
||||
* plan-at-gate.r*.md, plan-file.*.md; lib/autoplan-owner-text.ts), so a quote a revision removed stays redacted,
|
||||
* and a reason a human gave for `close --deferred <reason> --by human`. A reply that
|
||||
* and a reason a human gave for `close --deferred <reason> --by human`. A plan quote of any length, and a
|
||||
* quote's `leave out: <reason>`, are also redacted wherever gstack renders them: the quote between quote marks,
|
||||
* the reason after `leave out:`, `leave it out for now:` or `reason to leave it out:` in any case (GST-3646). A reply that
|
||||
* parsed as gate grammar (`owner_reply_parsed`) is the decision code and is
|
||||
* not scanned for; `reply` and the agent's own `answer_words` stay.
|
||||
*
|
||||
@@ -159,7 +161,7 @@ const DEFERRAL_RENDERINGS = (r: string) => [`^deferred: (${r})$`, `\\((${r}); by
|
||||
* The scan index: each owner reply and deferral reason of MIN_TOKENS+ words (grammar skipped), each run of MIN_TOKENS+
|
||||
* of its words between echoed windows, and the placements of deferral reasons and carried words.
|
||||
*/
|
||||
export function ownerIndex(replies: OwnerSource[], o: { deferred?: OwnerSource[]; carried?: string[] } = {}): OwnerWords {
|
||||
export function ownerIndex(replies: OwnerSource[], o: { deferred?: OwnerSource[]; carried?: string[]; quoted?: string[]; reasons?: string[] } = {}): OwnerWords {
|
||||
const keysOf = (texts: string[]) => ` ${texts.flatMap(t => [tokens(t, false), tokens(t)].map(ts => ts.map(k => k.key).join(' '))).join(' \u0001 ')} `;
|
||||
const seen = new Set<string>();
|
||||
const indexed: Indexed[] = [];
|
||||
@@ -188,7 +190,8 @@ export function ownerIndex(replies: OwnerSource[], o: { deferred?: OwnerSource[]
|
||||
const placements = [
|
||||
...(o.deferred ?? []).flatMap(d => DEFERRAL_RENDERINGS(escape(d.text))),
|
||||
...(o.carried ?? []).map(w => `words=(${escape(JSON.stringify(w))})(?= by=|$)`),
|
||||
].map(p => new RegExp(p, 'gd'));
|
||||
...(o.quoted ?? []).map(q => `["“](${escape(q)})["”]`),
|
||||
].map(p => new RegExp(p, 'gd')).concat((o.reasons ?? []).map(r => new RegExp(`(?:leave out|leave it out for now|reason to leave it out)\\s*:\\s*(${escape(r)})`, 'gdi')));
|
||||
return { replies: indexed, placements };
|
||||
}
|
||||
|
||||
@@ -279,7 +282,8 @@ export function ownerWords(state: Pick<RunState, 'out' | 'phases' | 'gate' | 'ca
|
||||
note(state.carry?.words, undefined, false);
|
||||
let names: string[] = [];
|
||||
try { names = fs.readdirSync(out).filter(f => f === FILES.active || /^plan-source.*\.md$/.test(f) || /^plan-at-gate\.r\d+\.md$/.test(f) || /^plan-file\..+\.md$/.test(f)).sort(); } catch { /* no run directory */ }
|
||||
for (const text of new Set(names.flatMap(f => parseOwnerWords(read(f) ?? '').quotes.map(q => q.text)))) note(text, undefined, false);
|
||||
const planQuotes = names.flatMap(f => parseOwnerWords(read(f) ?? '').quotes);
|
||||
for (const text of new Set(planQuotes.map(q => q.text))) note(text, undefined, false);
|
||||
|
||||
const deferred = new Map<string, string | undefined>();
|
||||
for (const r of journal) if (r.event === 'phase_deferred' && r.by === 'human' && typeof r.reason === 'string') deferred.set(r.reason, deferred.get(r.reason) ?? String(r.ts));
|
||||
@@ -288,5 +292,7 @@ export function ownerWords(state: Pick<RunState, 'out' | 'phases' | 'gate' | 'ca
|
||||
return ownerIndex([...byText].map(([text, r]) => ({ text, parsed: r.parsed, prior: prior(r.at) })), {
|
||||
deferred: [...deferred].map(([text, at]) => ({ text, prior: prior(at) })),
|
||||
carried: state.carry?.words ? [state.carry.words] : [],
|
||||
quoted: [...new Set(planQuotes.map(q => q.text))],
|
||||
reasons: [...new Set(planQuotes.flatMap(q => (q.line?.kind === 'choice' && q.line.leave_out ? [q.line.leave_out] : [])))],
|
||||
});
|
||||
}
|
||||
@@ -138,7 +138,7 @@ const DRIVE: Record<Manifest['build']['platform'], (m: Manifest) => string> = {
|
||||
};
|
||||
function phone(m: Manifest): string {
|
||||
const b = m.build;
|
||||
return `attach a ${platformName[b.platform]} phone (\`tools.capy.phone\` with action "attach", platform "${b.platform}" and the model closest to the device above), install this exact build on it (action "install"; ${b.testflight ? `TestFlight build ${b.testflight}` : `version ${b.deploy}`}), point it at ${m.play.target.name}, and drive its screen with \`tools.capy.computer.on({ machine_id })\``;
|
||||
return `attach a ${platformName[b.platform]} phone (\`tools.capy.phone\` with action "attach", platform "${b.platform}" and the model closest to the device above), install this exact build on it (action "install" with build_id "${m.phone_build}", the mobile build service's build of commit ${b.commit.slice(0, 12)}, which ${b.testflight ? `TestFlight build ${b.testflight}` : `version ${b.deploy}`} ships; if it won't install, record step 1 broken), point it at ${m.play.target.name}, and drive its screen with \`tools.capy.computer.on({ machine_id })\``;
|
||||
}
|
||||
|
||||
/** What the cold checker is given: the exact try-it text, the target and its rules, and the commands that record each step. */
|
||||
|
||||
+6
-3
@@ -49,7 +49,7 @@ export interface Holding { build: string; defects: string }
|
||||
export interface Manifest {
|
||||
schema_version: 2; kind: 'first-use-manifest'; app: string; created_at: string;
|
||||
source: { path: string; rows_sha256: string }; quotes: FrozenQuote[]; actions: FrozenAction[]; steps: FrozenStep[];
|
||||
try_text: string; try_sha256: string; build: BuildId & { fingerprint: string }; play: PlaySpec; holding: Holding;
|
||||
try_text: string; try_sha256: string; build: BuildId & { fingerprint: string }; phone_build?: string; play: PlaySpec; holding: Holding;
|
||||
builder: { model: string; family: string }; checker: { model: string; family: string };
|
||||
}
|
||||
export interface StepResult {
|
||||
@@ -162,7 +162,7 @@ function checkHolding(h: Partial<Holding> | undefined): Result<{ holding: Holdin
|
||||
return { holding: { build, defects } };
|
||||
}
|
||||
|
||||
export interface StartInput { root: string; app: string; planPath: string; build: Partial<BuildId>; play: unknown; holding: Partial<Holding>; builder: string; checker: string; now?: Date }
|
||||
export interface StartInput { root: string; app: string; planPath: string; build: Partial<BuildId>; phoneBuild?: string; play: unknown; holding: Partial<Holding>; builder: string; checker: string; now?: Date }
|
||||
/** Freezes the owner's quotes, the steps and the try-it text, and writes the run's manifest once; returns the run directory. */
|
||||
export function startRun(o: StartInput): Result<{ dir: string; manifest: Manifest }> {
|
||||
if (!/^[a-z0-9][a-z0-9-]{0,63}$/.test(o.app)) return fail('FIRST_USE_RECORD_INVALID', '--app must be a lowercase slug like ghome');
|
||||
@@ -174,6 +174,8 @@ export function startRun(o: StartInput): Result<{ dir: string; manifest: Manifes
|
||||
if ('error' in play) return play;
|
||||
const build = buildFingerprint(o.build);
|
||||
if ('error' in build) return build;
|
||||
const phone = build.platform === 'ios' || build.platform === 'android';
|
||||
if (phone && !/^[0-9A-Za-z]{26}$/.test(o.phoneBuild ?? '')) return fail('FIRST_USE_RECORD_INVALID', `a ${build.platform} check installs on a cloud phone, which takes only a build from Capy's mobile build service: give --phone-build <its 26-character build id> for commit ${build.commit.slice(0, 12)}, not a TestFlight or store number`);
|
||||
const holding = checkHolding(o.holding);
|
||||
if ('error' in holding) return holding;
|
||||
const builder = modelFamily(o.builder), checker = modelFamily(o.checker);
|
||||
@@ -186,7 +188,7 @@ export function startRun(o: StartInput): Result<{ dir: string; manifest: Manifes
|
||||
];
|
||||
const base = { schema_version: 2 as const, kind: 'first-use-manifest' as const, app: o.app, created_at: now.toISOString(),
|
||||
source: { path: path.resolve(o.planPath), rows_sha256: frozen.rows_sha256 }, quotes: frozen.quotes, actions: frozen.actions, steps,
|
||||
build, play: play.spec, holding: holding.holding, builder: { model: o.builder, family: builder }, checker: { model: o.checker, family: checker } };
|
||||
build, ...(phone ? { phone_build: o.phoneBuild } : {}), play: play.spec, holding: holding.holding, builder: { model: o.builder, family: builder }, checker: { model: o.checker, family: checker } };
|
||||
const try_text = renderTryText(base);
|
||||
const manifest: Manifest = { ...base, try_text, try_sha256: sha256(try_text) };
|
||||
const dir = path.join(o.root, o.app, `${stamp(now)}-${build.fingerprint.slice(0, 8)}`);
|
||||
@@ -198,6 +200,7 @@ export function readManifest(dir: string): Result<{ manifest: Manifest }> {
|
||||
const m = readJson<Omit<Manifest, 'schema_version'> & { schema_version: number }>(path.join(dir, 'manifest.json'));
|
||||
if (m?.kind === 'first-use-manifest' && m.schema_version === 1) return fail('FIRST_USE_RECORD_INVALID', `${dir} is a schema-1 run from before the try-it steps and the owner's quotes were checked; start a new run`);
|
||||
if (!m || m.schema_version !== 2 || m.kind !== 'first-use-manifest' || !Array.isArray(m.steps) || !m.build?.fingerprint) return fail('FIRST_USE_RECORD_INVALID', `no readable manifest.json in ${dir}`);
|
||||
if ((m.build.platform === 'ios' || m.build.platform === 'android') && !/^[0-9A-Za-z]{26}$/.test(m.phone_build ?? '')) return fail('FIRST_USE_RECORD_INVALID', `${dir} is a ${m.build.platform} run with no --phone-build, so its checker can't install the build on a cloud phone; start a new run with --phone-build`);
|
||||
return { manifest: m as Manifest };
|
||||
}
|
||||
|
||||
|
||||
@@ -458,3 +458,73 @@ describe('every attribution, line and quote shape reads as the merge base read i
|
||||
});
|
||||
});
|
||||
|
||||
describe("short owner quotes and leave-out reasons stay out of a first-version export (GST-3646)", () => {
|
||||
const tag = (prefix: string, i: number) => `${prefix}${String.fromCharCode(97 + Math.floor(i / 26))}${String.fromCharCode(97 + (i % 26))}vel`;
|
||||
const QUOTES: Array<[string, (u: string) => string]> = [
|
||||
['one word', u => u],
|
||||
['two words', u => `quimbly ${u}`],
|
||||
['an emoji and a word', u => `🚀 ${u}`],
|
||||
['CJK', u => `毎朝ベル${u}`],
|
||||
];
|
||||
const LINES: Array<[string, (r: string) => string, boolean]> = [
|
||||
['does it', () => ' → does it', false],
|
||||
['a choice with a size', () => ' → choice; size: one day', false],
|
||||
['a one-word reason to leave it out', r => ` → choice; size: two days; leave out: ${r}`, true],
|
||||
['a two-word reason to leave it out', r => ` → choice; leave out: blint ${r}`, true],
|
||||
['a longer reason to leave it out', r => ` -> choice; size: one day; leave out: ${r} plinkwort drazzle fippery`, true],
|
||||
['a reason after extra spaces', r => ` → choice; leave out : ${r}`, true],
|
||||
['a reason after a capitalized key', r => ` → choice; Leave Out: ${r}`, true],
|
||||
['does it in mixed case', () => ' → Does It', false],
|
||||
['a choice and size in mixed case', () => ' → Choice; Size: one day', false],
|
||||
['a recommended reason in mixed case', r => ` → CHOICE; size: two days; Recommend Leave Out: ${r}`, true],
|
||||
];
|
||||
const ROWS = QUOTES.flatMap(([qName, quote], a) => LINES.map(([lName, line, hasReason], b) => {
|
||||
const i = a * LINES.length + b, reason = tag('rz', i);
|
||||
const words = quote(tag('qx', i));
|
||||
return { name: `${qName} / ${lName}`, bullet: `- The owner, 2026-11-20 08:${String(i).padStart(2, '0')}Z: "${words}"${line(reason)}`, words, reason: hasReason ? line(reason).replace(/^.*leave out\s*:\s*/i, '') : undefined };
|
||||
}));
|
||||
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(row => row.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');
|
||||
const fragments = (q: string) => [...new Set([...q.split(/\s+/), ...wordKey(q).trim().split(' ')].filter(w => [...w].length >= 3))];
|
||||
const exported = () => {
|
||||
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: 1 }], 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);
|
||||
return { out, pub };
|
||||
};
|
||||
|
||||
test('every short quote and every reason to leave one out reaches the gate, and none leaves a 3+ character fragment in the public bytes', () => {
|
||||
expect(parseOwnerWords(plan).quotes).toHaveLength(ROWS.length);
|
||||
const { out, pub } = exported();
|
||||
const gate = JSON.stringify(gateOf(out).items);
|
||||
expect(ROWS.filter(row => !gate.includes(row.words) && !/does it/i.test(row.bullet)).map(row => row.name)).toEqual([]);
|
||||
expect(ROWS.filter(row => row.reason && !gate.includes(row.reason)).map(row => row.name)).toEqual([]);
|
||||
const bytes = allText(pub);
|
||||
const leaks = ROWS.flatMap(row => [row.words, ...(row.reason ? [row.reason] : [])].flatMap(q => fragments(q).filter(w => bytes.includes(w)).map(w => `${row.name}: ${w}`)));
|
||||
expect(leaks).toEqual([]);
|
||||
});
|
||||
|
||||
test('validate --public --private catches a short quote or a leave-out reason written back in quote marks, and passes the plain words', () => {
|
||||
const { out, pub } = exported();
|
||||
const record = path.join(pub, 'review-record.md');
|
||||
const before = fs.readFileSync(record, 'utf8');
|
||||
const validate = () => artifact(['validate', '--public', pub, '--private', path.join(out, 'run.json')]);
|
||||
expect(validate().status).toBe(0);
|
||||
const ownerWordsAt = (added: string) => { fs.writeFileSync(record, before + added); return validate().stderr.includes('ARTIFACT_OWNER_WORDS'); };
|
||||
expect(ownerWordsAt(`The owner said “${ROWS[0]!.words}”.\n`)).toBe(true);
|
||||
expect(ownerWordsAt(`The plan's reason: leave out: ${ROWS[2]!.reason}\n`)).toBe(true);
|
||||
expect(ownerWordsAt(`A plain mention of ${ROWS[0]!.words} and ${ROWS[2]!.reason}.\n`)).toBe(false);
|
||||
fs.writeFileSync(record, before);
|
||||
expect(validate().status).toBe(0);
|
||||
});
|
||||
});
|
||||
+31
-5
@@ -26,6 +26,7 @@ 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 PHONE_BUILD = '01KPHQ7Z3M8V2X5C9B4N6R1T0W';
|
||||
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 = [
|
||||
@@ -44,7 +45,7 @@ const start = (o: { plan?: string; play?: unknown; root?: string; checker?: stri
|
||||
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: o.play ?? playWith(1), holding: HOLDING, builder: 'anthropic/claude-opus-5-5', checker: o.checker ?? CHECKER, now: T0 });
|
||||
const r = startRun({ root, app: 'plantpal', planPath, build: BUILD, phoneBuild: PHONE_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);
|
||||
return { ...r, planPath, work, root };
|
||||
};
|
||||
@@ -144,7 +145,7 @@ 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, holding: HOLDING };
|
||||
const base = { root: fresh('root'), app: 'plantpal', planPath, build: BUILD, phoneBuild: PHONE_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' } });
|
||||
});
|
||||
@@ -152,7 +153,7 @@ describe('model families and build fingerprints', () => {
|
||||
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 };
|
||||
const base = { root: fresh('root'), app: 'plantpal', planPath, build: BUILD, phoneBuild: PHONE_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);
|
||||
});
|
||||
@@ -393,7 +394,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, holding: HOLDING, builder: 'anthropic/claude-opus-5-5', checker: CHECKER, now: T0 });
|
||||
const again = startRun({ root: r.root, app: 'plantpal', planPath: r.planPath, build: BUILD, phoneBuild: PHONE_BUILD, play: PLAY, holding: HOLDING, builder: 'anthropic/claude-opus-5-5', checker: CHECKER, now: T0 });
|
||||
expect(again).toMatchObject({ error: { code: 'FIRST_USE_RECORD_INVALID' } });
|
||||
});
|
||||
|
||||
@@ -442,6 +443,31 @@ describe('the gate', () => {
|
||||
expect(brief).not.toContain('TestFlight build 16');
|
||||
});
|
||||
|
||||
test('a phone build installs the build-service build start names, and start refuses a phone build without one (GST-3646)', () => {
|
||||
const work = fresh('phone'), planPath = path.join(work, 'plan.md');
|
||||
fs.writeFileSync(planPath, AUTOPLAN);
|
||||
const base = { app: 'plantpal', planPath, play: playWith(1), holding: HOLDING, builder: 'anthropic/claude-opus-5-5', checker: CHECKER, now: T0 };
|
||||
for (const build of [BUILD, { platform: 'android' as const, commit: COMMIT, deploy: '1.0.3' }]) {
|
||||
expect(startRun({ ...base, root: fresh('root'), build })).toMatchObject({ error: { code: 'FIRST_USE_RECORD_INVALID', detail: expect.stringContaining('--phone-build') } });
|
||||
expect(startRun({ ...base, root: fresh('root'), build, phoneBuild: '17' })).toMatchObject({ error: { code: 'FIRST_USE_RECORD_INVALID', detail: expect.stringContaining('--phone-build') } });
|
||||
}
|
||||
const r = startRun({ ...base, root: fresh('root'), build: BUILD, phoneBuild: PHONE_BUILD });
|
||||
if ('error' in r) throw new Error(r.error.detail);
|
||||
expect(r.manifest.phone_build).toBe(PHONE_BUILD);
|
||||
const brief = renderBrief(r.manifest, r.dir);
|
||||
expect(brief).toContain(`(action "install" with build_id "${PHONE_BUILD}"`);
|
||||
expect(brief).not.toContain('action "install"; TestFlight build');
|
||||
const old = { ...r.manifest } as Partial<typeof r.manifest>;
|
||||
delete old.phone_build;
|
||||
fs.writeFileSync(path.join(r.dir, 'manifest.json'), JSON.stringify(old));
|
||||
expect(readManifest(r.dir)).toMatchObject({ error: { code: 'FIRST_USE_RECORD_INVALID', detail: expect.stringContaining('start a new run with --phone-build') } });
|
||||
const android = startRun({ ...base, root: fresh('root'), build: { platform: 'android', commit: COMMIT, deploy: '1.0.3' }, phoneBuild: PHONE_BUILD });
|
||||
if ('error' in android) throw new Error(android.error.detail);
|
||||
expect(renderBrief(android.manifest, android.dir)).toContain(`build_id "${PHONE_BUILD}", the mobile build service's build of commit ${COMMIT.slice(0, 12)}, which version 1.0.3 ships`);
|
||||
const web = startRun({ ...base, root: fresh('root'), build: { platform: 'web', commit: COMMIT, deploy: 'web-12' } });
|
||||
expect('error' in web ? web.error.detail : web.manifest.phone_build).toBeUndefined();
|
||||
});
|
||||
|
||||
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);
|
||||
@@ -485,7 +511,7 @@ describe('gstack-first-use (CLI, temporary HOME and drive)', () => {
|
||||
const build = ['--platform', 'ios', '--commit', COMMIT, '--testflight', '17'];
|
||||
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);
|
||||
const begun = await cli('start', '--app', 'plantpal', '--plan', plan, '--play', play, ...build, '--phone-build', PHONE_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);
|
||||
|
||||
Reference in new issue
Block a user