diff --git a/autoplan/DRIVER.md b/autoplan/DRIVER.md index ca47a067e..88c9ec105 100644 --- a/autoplan/DRIVER.md +++ b/autoplan/DRIVER.md @@ -20,7 +20,7 @@ The first `next` prints `SCOPE: ui=… (terms; visual; files) dx=… (detected) TODOS*, docs/** but not docs/*-policy.md, or other markdown outside a skill dir) runs CEO on the native voice only, then Eng. UI needs a rendered file path (including a named non-test `.ts`/`.js` file that holds a tagged `html`, `css` or `svg` template, such as Lit or htm) or a UI term next to a visual noun in the Implementation plan. To keep flags for later runs on the same plan, add the `SCOPE_PIN:` marker it prints (``) as the plan's first -line yourself; gstack never writes the plan. **First versions** (a `### Day one` section or `--first-version`): the plan quotes the owner under `### Owner's words`, one bullet each, `- , : "" → does it | choice[; size: ][; leave out: ]`; the gate letters each quote this version doesn't fully do and every cut, the five day-one rows cite `owner words `, and the build clears `gstack-first-use` before the owner is asked to try it ([docs/first-use-check.md](../docs/first-use-check.md)). **Kinds (R65), first `next` only.** `--kind fix` reviews nothing: it prints `AUTOPLAN: not needed (bug fix; R65)`, a `PROOF:` line and `GSTACK_RESULT: skill=autoplan status=skipped run=-`, writes nothing and needs no `--out` or `--plan`; the PR still carries the bug's proof, a repro on current main or a failing test written first. `--kind feature`, the default for an unattended run on Capy (`GSTACK_CAPY=1`) that names no kind, is the lean run. Its `phase_order` is `eng` alone with one native reviewer, whose prompt merges the CEO and Eng lenses (Design or DX only when scope detects them), each a short role or brief plus that review skill's checklist, never the skill's own method, always asks "Any outside terms, licences or rights involved?" and shows the draft code. The draft is `git diff` from the merge base with `--base ` (default: `gstack-diff-scope`'s base, never an `origin/HEAD` naming the checked-out branch), untracked files included and the run directory left out, written to the snapshot as `draft.diff` and hashed; with no code yet it says `DRAFT: none ()`. The first `next` prints `LEAN:` and each opened phase `DRAFT:`; the reviewer's line after INPUT must be `DRAFT: ` or `DRAFT: none`, or submit refuses it (`RESULT_RECEIPT_MISSING`). No outside voice, `--max-rounds 1`, no carry check and one gate revision: `revise --incorporates` applies the accepted changes without re-review and approves. `--full` brings back every phase and both voices: each native reviewer gets a five-question brief and its phase's checklist, each outside reviewer a one-paragraph role, and neither the skill's own method. Off Capy, and in an interactive session, the default stays full. +line yourself; gstack never writes the plan. **First versions** (a `### Day one` section or `--first-version`): the plan quotes the owner under `### Owner's words`, one bullet each, `- , : "" → does it | choice[; size: ][; leave out: ] | ruled out : ""` (a ruling stands against a reviewer only when a recorded owner reply holds it; otherwise the gate asks him, recommending it); the gate letters each quote this version doesn't fully do and every cut, the five day-one rows cite `owner words `, and the build clears `gstack-first-use` before the owner is asked to try it ([docs/first-use-check.md](../docs/first-use-check.md)). **Kinds (R65), first `next` only.** `--kind fix` reviews nothing: it prints `AUTOPLAN: not needed (bug fix; R65)`, a `PROOF:` line and `GSTACK_RESULT: skill=autoplan status=skipped run=-`, writes nothing and needs no `--out` or `--plan`; the PR still carries the bug's proof, a repro on current main or a failing test written first. `--kind feature`, the default for an unattended run on Capy (`GSTACK_CAPY=1`) that names no kind, is the lean run. Its `phase_order` is `eng` alone with one native reviewer, whose prompt merges the CEO and Eng lenses (Design or DX only when scope detects them), each a short role or brief plus that review skill's checklist, never the skill's own method, always asks "Any outside terms, licences or rights involved?" and shows the draft code. The draft is `git diff` from the merge base with `--base ` (default: `gstack-diff-scope`'s base, never an `origin/HEAD` naming the checked-out branch), untracked files included and the run directory left out, written to the snapshot as `draft.diff` and hashed; with no code yet it says `DRAFT: none ()`. The first `next` prints `LEAN:` and each opened phase `DRAFT:`; the reviewer's line after INPUT must be `DRAFT: ` or `DRAFT: none`, or submit refuses it (`RESULT_RECEIPT_MISSING`). No outside voice, `--max-rounds 1`, no carry check and one gate revision: `revise --incorporates` applies the accepted changes without re-review and approves. `--full` brings back every phase and both voices: each native reviewer gets a five-question brief and its phase's checklist, each outside reviewer a one-paragraph role, and neither the skill's own method. Off Capy, and in an interactive session, the default stays full. ## The loop diff --git a/autoplan/DRIVER.md.tmpl b/autoplan/DRIVER.md.tmpl index 220a1a9d5..c12338f44 100644 --- a/autoplan/DRIVER.md.tmpl +++ b/autoplan/DRIVER.md.tmpl @@ -17,7 +17,7 @@ The first `next` prints `SCOPE: ui=… (terms; visual; files) dx=… (detected) TODOS*, docs/** but not docs/*-policy.md, or other markdown outside a skill dir) runs CEO on the native voice only, then Eng. UI needs a rendered file path (including a named non-test `.ts`/`.js` file that holds a tagged `html`, `css` or `svg` template, such as Lit or htm) or a UI term next to a visual noun in the Implementation plan. To keep flags for later runs on the same plan, add the `SCOPE_PIN:` marker it prints (``) as the plan's first -line yourself; gstack never writes the plan. **First versions** (a `### Day one` section or `--first-version`): the plan quotes the owner under `### Owner's words`, one bullet each, `- , : "" → does it | choice[; size: ][; leave out: ]`; the gate letters each quote this version doesn't fully do and every cut, the five day-one rows cite `owner words `, and the build clears `gstack-first-use` before the owner is asked to try it ([docs/first-use-check.md](../docs/first-use-check.md)). **Kinds (R65), first `next` only.** `--kind fix` reviews nothing: it prints `AUTOPLAN: not needed (bug fix; R65)`, a `PROOF:` line and `GSTACK_RESULT: skill=autoplan status=skipped run=-`, writes nothing and needs no `--out` or `--plan`; the PR still carries the bug's proof, a repro on current main or a failing test written first. `--kind feature`, the default for an unattended run on Capy (`GSTACK_CAPY=1`) that names no kind, is the lean run. Its `phase_order` is `eng` alone with one native reviewer, whose prompt merges the CEO and Eng lenses (Design or DX only when scope detects them), each a short role or brief plus that review skill's checklist, never the skill's own method, always asks "Any outside terms, licences or rights involved?" and shows the draft code. The draft is `git diff` from the merge base with `--base ` (default: `gstack-diff-scope`'s base, never an `origin/HEAD` naming the checked-out branch), untracked files included and the run directory left out, written to the snapshot as `draft.diff` and hashed; with no code yet it says `DRAFT: none ()`. The first `next` prints `LEAN:` and each opened phase `DRAFT:`; the reviewer's line after INPUT must be `DRAFT: ` or `DRAFT: none`, or submit refuses it (`RESULT_RECEIPT_MISSING`). No outside voice, `--max-rounds 1`, no carry check and one gate revision: `revise --incorporates` applies the accepted changes without re-review and approves. `--full` brings back every phase and both voices: each native reviewer gets a five-question brief and its phase's checklist, each outside reviewer a one-paragraph role, and neither the skill's own method. Off Capy, and in an interactive session, the default stays full. +line yourself; gstack never writes the plan. **First versions** (a `### Day one` section or `--first-version`): the plan quotes the owner under `### Owner's words`, one bullet each, `- , : "" → does it | choice[; size: ][; leave out: ] | ruled out : ""` (a ruling stands against a reviewer only when a recorded owner reply holds it; otherwise the gate asks him, recommending it); the gate letters each quote this version doesn't fully do and every cut, the five day-one rows cite `owner words `, and the build clears `gstack-first-use` before the owner is asked to try it ([docs/first-use-check.md](../docs/first-use-check.md)). **Kinds (R65), first `next` only.** `--kind fix` reviews nothing: it prints `AUTOPLAN: not needed (bug fix; R65)`, a `PROOF:` line and `GSTACK_RESULT: skill=autoplan status=skipped run=-`, writes nothing and needs no `--out` or `--plan`; the PR still carries the bug's proof, a repro on current main or a failing test written first. `--kind feature`, the default for an unattended run on Capy (`GSTACK_CAPY=1`) that names no kind, is the lean run. Its `phase_order` is `eng` alone with one native reviewer, whose prompt merges the CEO and Eng lenses (Design or DX only when scope detects them), each a short role or brief plus that review skill's checklist, never the skill's own method, always asks "Any outside terms, licences or rights involved?" and shows the draft code. The draft is `git diff` from the merge base with `--base ` (default: `gstack-diff-scope`'s base, never an `origin/HEAD` naming the checked-out branch), untracked files included and the run directory left out, written to the snapshot as `draft.diff` and hashed; with no code yet it says `DRAFT: none ()`. The first `next` prints `LEAN:` and each opened phase `DRAFT:`; the reviewer's line after INPUT must be `DRAFT: ` or `DRAFT: none`, or submit refuses it (`RESULT_RECEIPT_MISSING`). No outside voice, `--max-rounds 1`, no carry check and one gate revision: `revise --incorporates` applies the accepted changes without re-review and approves. `--full` brings back every phase and both voices: each native reviewer gets a five-question brief and its phase's checklist, each outside reviewer a one-paragraph role, and neither the skill's own method. Off Capy, and in an interactive session, the default stays full. ## The loop diff --git a/capy/skill/gstack/factory.md b/capy/skill/gstack/factory.md index e19e5d985..6c344028f 100644 --- a/capy/skill/gstack/factory.md +++ b/capy/skill/gstack/factory.md @@ -19,4 +19,4 @@ Your crew's CREW.md and recorded approvals decide who may merge, update a base, 15. **Subagents earn their context.** Start one only for parallel work you can throw away, a fresh-eyes review or another model family, never for a step of your own procedure; name the compact result it returns. [crew/docs/captain.md: Lane context] 16. **Drain the queue.** Captains run `gstack-ship-queue count` every sweep and standing wake; a `DRAIN:` line means drain that turn: low-risk PRs land alone, risky ones in bundles of 3 to 6, idle owners get their next step. [crew/docs/captain.md: Drain the queue] 17. **Write it up before you shelve it.** Before an attempt closes as failed, shelved, cut, null or not now, a short write-up of what worked, what didn't and what would reopen it exists, and the close links it. [docs/shelved-attempt.md] -18. **First versions start from the owner's words.** The plan quotes his messages that state the job, each with a line (does it, or a lettered choice), and before he is asked to try it an agent from another model family runs the exact try-it steps on his real setup [docs/first-use-check.md]. +18. **First versions start from the owner's words.** The plan quotes his messages that state the job, each with a line (does it, a lettered choice, or his recorded ruling against it), and before he is asked to try it an agent from another model family runs the exact try-it steps on his real setup [docs/first-use-check.md]. diff --git a/changelog.d/first-versions-check-ruled-out-line-against-owner-replies.md b/changelog.d/first-versions-check-ruled-out-line-against-owner-replies.md new file mode 100644 index 000000000..b75f77c67 --- /dev/null +++ b/changelog.d/first-versions-check-ruled-out-line-against-owner-replies.md @@ -0,0 +1 @@ +**A first version's plan can say the owner ruled something out, and that line now counts only when he actually said it.** Under `### Owner's words`, a quote's line can be `ruled out : ""`. When one of the owner's recorded replies holds the ruling (three or more words, not just the quote repeated), the ruling beats a reviewer. A finding that says the plan does less than his words becomes one item recommending his ruling, and a cut of those words stays a cut. When no recorded reply holds it, the approval gate asks him once, showing the ruling and any finding side by side and recommending the ruling. A finding's twin from the other reviewer that doesn't name the quote now joins the same item instead of becoming a separate take-the-change proposal, and public exports redact the ruling like the quote. (GST-3646) diff --git a/docs/first-use-check.md b/docs/first-use-check.md index f21a60f7a..ac1b40cbb 100644 --- a/docs/first-use-check.md +++ b/docs/first-use-check.md @@ -2,7 +2,7 @@ When an agent builds the first version of something for a person, every review can pass and the first thing the owner tries can still be broken, or do less than he asked. Six first versions in November 2026 all drew a complaint first: in at least four the gap was written down before he touched it, and in none did anyone run the exact steps we then asked him to do on his real setup. Two things close that gap. -1. **The plan and the try-it message start from the owner's own words.** A first version's plan quotes each message of the owner's that states the job, with its time, and gives each one a line: it does it, or it leaves it as a lettered choice. Nothing his words asked for sits under "What it won't do yet". The five things he'll do on day one cite those quotes. +1. **The plan and the try-it message start from the owner's own words.** A first version's plan quotes each message of the owner's that states the job, with its time, and gives each one a line: it does it, it leaves it as a lettered choice, or it follows his own ruling against it. Nothing his words asked for sits under "What it won't do yet". The five things he'll do on day one cite those quotes. 2. **An agent runs his exact try-it steps on the real target first.** Before a build reaches its owner as "ready to try", a fresh agent from a **different model family** than the one that built it follows the exact message we're about to send, step by step, on the real target, and records a verdict and one line per step. Only when nothing is broken, wrong or asks him for something an agent could look up does `gstack-first-use` print the message. It gates two things: the message that asks the owner to try a build, and any "v1 is ready" report. It does not gate `/ship`: code review and the first-use check answer different questions. Any report of a passing test on a build the owner doesn't hold yet also names the build he does hold and its known defects. @@ -16,6 +16,7 @@ A plan is a first version when it has a `Day one` section or the run passes `--f - Ada Example, 2026-11-18 09:12Z: "I keep forgetting which plant needs water" → does it - Ada Example, 2026-11-18 09:14Z: "and tell my partner when I'm away" → choice; size: two days; leave out: needs a second account +- Ada Example, 2026-11-18 09:20Z: "and maybe post my streak" → ruled out 2026-11-18: "no posting anywhere, ever" ``` Each bullet is who, when, the words in quotes, then an arrow (`→` or `->`) and the line: @@ -24,8 +25,9 @@ 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: `, shown on the choice. `size: ` is shown as the cost | +| `ruled out : ""` | the owner ruled it out himself | when one of his recorded replies holds the ruling, it beats a reviewer: a finding that says the plan falls short of these words becomes one item recommending his ruling, and a cut of them stays a cut. When no recorded reply holds it, the gate asks him once, with the ruling and any finding side by side and the ruling recommended | -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 public export (`gstack-autoplan export --public`) drops the owner's words: every quote and every ruling, 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. diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index 48f340155..42bcdc890 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -2500,7 +2500,7 @@ whose Plan line differs from the PR body's current line. ### `gstack-first-use start: ... (FIRST_USE_PLAN_UNREADY)` -**Meaning.** `start` could not freeze the steps: the plan has no `### Day one` table, the table is missing a column or has fewer than five rows, one of its first five rows has an empty cell, is still marked `assumed` or cites none of the owner's quotes (`owner words `), or the plan has no `### Owner's words` section, or a quote there has no time or no line (`does it` or `choice`). Exit 3; nothing is written. **Fix.** Quote the owner's messages that state the job and cite them from the table ([first-use-check.md](first-use-check.md#the-owners-words-and-the-day-one-table)); a row the owner confirmed at the gate cites his answer, added to Owner's words. Then rerun `start`. +**Meaning.** `start` could not freeze the steps: the plan has no `### Day one` table, the table is missing a column or has fewer than five rows, one of its first five rows has an empty cell, is still marked `assumed` or cites none of the owner's quotes (`owner words `), or the plan has no `### Owner's words` section, or a quote there has no time or no line (`does it`, `choice` or `ruled out : ""`). Exit 3; nothing is written. **Fix.** Quote the owner's messages that state the job and cite them from the table ([first-use-check.md](first-use-check.md#the-owners-words-and-the-day-one-table)); a row the owner confirmed at the gate cites his answer, added to Owner's words. Then rerun `start`. ### `gstack-first-use start: ... (FIRST_USE_PLAY_SPEC_INCOMPLETE)` diff --git a/lib/autoplan-gate-items.ts b/lib/autoplan-gate-items.ts index b6c6d502e..718098304 100644 --- a/lib/autoplan-gate-items.ts +++ b/lib/autoplan-gate-items.ts @@ -20,7 +20,7 @@ import * as path from 'node:path'; import { spawnSync } from 'node:child_process'; import { branchKey, captainApprovalsDir } from './approval-record'; import { readVersionedSlugCache, sanitizeSlug } from './bin-context'; -import { cutDrops, cutQuote, isFirstVersion, parseCuts, parseDayOne, parseOwnerWords, quoteGaps, quoteWhen, wordKey, type DayOneTable, type OwnerQuote, type OwnerWordsSection } from './autoplan-owner-text'; +import { cutDrops, cutQuote, isFirstVersion, parseCuts, parseDayOne, parseOwnerWords, quoteGaps, quoteWhen, wordKey, type CheckedQuote, type DayOneTable, type OwnerQuote, type OwnerWordsSection } from './autoplan-owner-text'; import { SETTLEABLE_CHANGES } from './autoplan-reconcile'; import { readDecisions, readJournal, type RunState } from './autoplan-state'; import { resolveStateRoot } from './state-root'; @@ -29,8 +29,9 @@ import type { FindingRow } from './headless-artifacts'; export type ChallengeRow = FindingRow & { user_challenge?: boolean; changes?: string; settled_by?: string; owner_quote?: number; narrows_quote?: number; resolves?: string }; export type NewItem = Omit & { idKind: 'd' | 'uc'; key: string }; -export interface GateOwnerWords { status: OwnerWordsSection['status']; quotes: Array; reason?: string; fix?: string } -export interface OwnerContext { words: OwnerWordsSection; verified: Set; dayOne: DayOneTable; cuts: string[]; app: boolean; lean: boolean; firstVersion: boolean } +export interface GateOwnerWords { status: OwnerWordsSection['status']; quotes: Array; reason?: string; fix?: string } +/** `verified`: quotes whose words are in a recorded owner reply; `ruled`: ruled-out lines whose ruling is (GST-3646). */ +export interface OwnerContext { words: OwnerWordsSection; verified: Set; ruled: Set; dayOne: DayOneTable; cuts: string[]; app: boolean; lean: boolean; firstVersion: boolean } /** * The owner's words in this repository's approvals record for the branch checked out at `cwd` (lib/approval-record.ts @@ -75,13 +76,20 @@ export function ownerContext(state: RunState, recorded: string[] = recordedOwner try { text = fs.readFileSync(state.active_plan, 'utf8'); } catch { /* no plan text: nothing is quoted */ } const words = parseOwnerWords(text); const keys = recorded.map(wordKey); - const verified = new Set(words.quotes.filter(q => keys.some(k => k.includes(wordKey(q.text)))).map(q => q.n)); - return { words, verified, dayOne: parseDayOne(text), cuts: parseCuts(text), app: !!state.scope?.ui, lean: !!state.lean, + const said = (text: string) => keys.some(k => k.includes(wordKey(text))); + const verified = new Set(words.quotes.filter(q => said(q.text)).map(q => q.n)); + const ruledBy = (q: OwnerQuote) => { + if (q.line?.kind !== 'ruled_out') return false; + const key = wordKey(q.line.ruling); + return key.trim().split(/\s+/).length >= 3 && !wordKey(q.text).includes(key) && said(q.line.ruling); + }; + const ruled = new Set(words.quotes.filter(ruledBy).map(q => q.n)); + return { words, verified, ruled, dayOne: parseDayOne(text), cuts: parseCuts(text), app: !!state.scope?.ui, lean: !!state.lean, firstVersion: isFirstVersion(text, !!state.scope?.first_version) }; } export function gateOwnerWords(ctx: OwnerContext): GateOwnerWords { - return { status: ctx.words.status, quotes: ctx.words.quotes.map(q => ({ ...q, verified: ctx.verified.has(q.n) })), + return { status: ctx.words.status, quotes: ctx.words.quotes.map(q => ({ ...q, verified: ctx.verified.has(q.n), ...(q.line?.kind === 'ruled_out' ? { ruling_verified: ctx.ruled.has(q.n) } : {}) })), ...(ctx.words.reason ? { reason: ctx.words.reason, fix: ctx.words.fix } : {}) }; } @@ -156,14 +164,14 @@ export function dayOneItems(ctx: OwnerContext, narrowed: ChallengeRow[] = []): N items.push({ idKind: 'uc', key: 'owner-words', kind: 'approval', recommended: 'a', item_class: 'owner_words', changes: 'scope', cost: `a ${reopen}`, title: 'This is a first version, but the plan quotes none of your messages that ask for it', why: 'a first version is checked against your own words for the job, not against the plan: each quoted message, with its time, gets a line saying what this version does with it', - options: [{ key: 'a', text: "add it: an ### Owner's words section quoting each message that states the job, with its time and a line each (does it or choice), then revise", changes_plan: true }, + options: [{ key: 'a', text: "add it: an ### Owner's words section quoting each message that states the job, with its time and a line each (does it, choice or ruled out), then revise", changes_plan: true }, { key: 'b', text: 'approve without it', changes_plan: false }] }); } const gaps = ctx.firstVersion ? ctx.words.quotes.filter(q => quoteGaps(q).length) : []; if (gaps.length) { items.push({ idKind: 'uc', key: `owner-lines:${gaps.map(q => q.n).join(',')}`, kind: 'approval', recommended: 'a', item_class: 'owner_words', changes: 'scope', cost: `a ${reopen}`, title: `${gaps.length} of your quoted messages ${gaps.length === 1 ? 'has' : 'have'} no time or no line saying what this version does with ${gaps.length === 1 ? 'it' : 'them'}: ${gaps.map(q => `“${q.text}” (missing ${quoteGaps(q).join(' and ')})`).join('; ')}`, - why: 'on a first version every quote says when it was said and whether this version does it or leaves it as a lettered choice', + why: 'on a first version every quote says when it was said and whether this version does it, leaves it as a lettered choice, or follows your own ruling against it', options: [{ key: 'a', text: 'add the time and the line to each, then revise', changes_plan: true }, { key: 'b', text: 'approve without them', changes_plan: false }] }); } if (ctx.app && ctx.dayOne.status !== 'ok') { @@ -181,20 +189,23 @@ export function dayOneItems(ctx: OwnerContext, narrowed: ChallengeRow[] = []): N const left = new Map(); const note = (q: OwnerQuote, why: string) => left.set(q.n, [...(left.get(q.n) ?? []), why]); for (const q of ctx.words.quotes) if (q.line?.kind === 'choice') note(q, "the plan's line for it says this version doesn't do it yet"); - const quoteCuts = ctx.cuts.filter(c => cutQuote(c, ctx.words.quotes)); - for (const cut of quoteCuts) note(cutQuote(cut, ctx.words.quotes)!, `the plan cuts it: "${cut}"`); - for (const f of narrowed) { const q = ctx.words.quotes.find(x => x.n === f.narrows_quote); if (q) note(q, `a reviewer (${f.voice}) says the plan narrows it: ${f.title}`); } + for (const q of ctx.words.quotes) if (q.line?.kind === 'ruled_out' && !ctx.ruled.has(q.n)) note(q, `the plan says you ruled it out on ${q.line.date}: “${q.line.ruling}”, but no recorded reply of yours says that`); + const open = ctx.words.quotes.filter(q => !(q.line?.kind === 'ruled_out' && ctx.ruled.has(q.n))); + const quoteCuts = ctx.cuts.filter(c => cutQuote(c, open)); + for (const cut of quoteCuts) note(cutQuote(cut, open)!, `the plan cuts it: "${cut}"`); + for (const f of narrowed) { const q = open.find(x => x.n === f.narrows_quote); if (q) note(q, `a reviewer (${f.voice}) says the plan narrows it: ${f.title}`); } for (const q of ctx.words.quotes.filter(x => left.has(x.n))) { const choice = q.line?.kind === 'choice' ? q.line : undefined; + const ruling = q.line?.kind === 'ruled_out' ? q.line : undefined; const blocking = narrowed.find(f => f.narrows_quote === q.n && (f.severity === 'Critical' || f.severity === 'High')); const leave = blocking ? undefined : choice?.leave_out; const size = choice?.size ? `about ${choice.size}` : 'size not stated'; - items.push({ idKind: 'uc', key: `quote:${q.n}`, kind: 'approval', recommended: leave ? 'b' : 'a', item_class: 'owner_choice', changes: 'scope', - recommended_basis: blocking ? `your own words asked for it, and a ${blocking.severity} finding says the plan falls short of them` : leave ? `the plan's reason to leave it out: ${leave}` : 'your own words asked for it, and only your words are direction', + items.push({ idKind: 'uc', key: `quote:${q.n}`, kind: 'approval', recommended: leave || ruling ? 'b' : 'a', item_class: 'owner_choice', changes: 'scope', + recommended_basis: ruling ? `your ruling as the plan quotes it; it isn't in your recorded replies, so this asks you${blocking ? ` beside the ${blocking.severity} finding` : ''}` : blocking ? `your own words asked for it, and a ${blocking.severity} finding says the plan falls short of them` : leave ? `the plan's reason to leave it out: ${leave}` : 'your own words asked for it, and only your words are direction', cost: `a adds ${size} to this version and ${reopen}`, title: `Your words${quoteWhen(q) ? ` (${quoteWhen(q)})` : ''}: “${q.text}”, which this version doesn't fully do`, why: left.get(q.n)!.join('; '), - options: [{ key: 'a', text: `build it in this version (${size})`, changes_plan: true }, { key: 'b', text: `leave it out for now${leave ? `: ${leave}` : ''}`, changes_plan: false }] }); + options: [{ key: 'a', text: `build it in this version (${size})`, changes_plan: true }, { key: 'b', text: ruling ? `leave it out, as your ruling says: “${ruling.ruling}”` : `leave it out for now${leave ? `: ${leave}` : ''}`, changes_plan: false }] }); } const rest = ctx.cuts.filter(c => !quoteCuts.includes(c)); const rowTargets = ctx.dayOne.rows.flatMap(r => [r.action, r.feature]).filter(Boolean); diff --git a/lib/autoplan-gate.ts b/lib/autoplan-gate.ts index 5104f238a..664b54f7a 100644 --- a/lib/autoplan-gate.ts +++ b/lib/autoplan-gate.ts @@ -27,6 +27,7 @@ import { applyCapChoices, pendingDeltas, releaseUndispatched, roundCap, roundOf import { evaluateCarry, gateEvidence, voidPendingCheck } from './autoplan-carry'; import { buildEli5, capyRelayLine } from './captain-brief'; import { FINDING_ORIGIN, openEarlier, previousReview, reviewRows, settledIds } from './autoplan-confirm'; +import { lineText } from './autoplan-owner-text'; import { blockingProposal, confirmDirectionItem, dayOneItems, directionIsOwners, gateOwnerWords, heaviestChanges, narrowedQuoteOf, ownerContext, ownerQuoteOf, proposalItem, type ChallengeRow, type NewItem } from './autoplan-gate-items'; import { phaseClose } from './autoplan-timing'; import { agentWords, ANSWERED_BY_RE, applyReply, autoDefault, decisionId, decisionRows, keepDirection, legacyRecHash, parseReply, pendingHint, recHash, replyShape, validateGateList, type GateChoice, type GateItem, type GateList, type GateOption, type ParsedReply } from './gate-list'; @@ -252,9 +253,19 @@ export function buildGate(state: RunState, gateRev: number): GateList { const twinOf = (id: string) => twins.get(id) ?? [...twins].find(([, out]) => out === id)?.[0]; for (const f of [...native, ...outside, ...carried] as ChallengeRow[]) { if (challenged.has(f.id) || f.settled_by) continue; - if (narrowedQuoteOf(owner, f)) { challenged.add(f.id); narrowed.push(f); continue; } + const twin = twinOf(f.id) ? byId.get(twinOf(f.id)!) as ChallengeRow | undefined : undefined; + const narrows = narrowedQuoteOf(owner, f) ?? narrowedQuoteOf(owner, twin); + if (narrows) { + const rows = [f, ...(twin && !twin.settled_by && !challenged.has(twin.id) ? [twin] : [])]; + rows.forEach(r => challenged.add(r.id)); + if (!(narrows.line?.kind === 'ruled_out' && owner.ruled.has(narrows.n))) { narrowed.push(...rows.map(r => ({ ...r, narrows_quote: narrows.n }))); continue; } + const ids = rows.map(r => r.id); + push({ id: `d${++d}`, title: `${f.title} [${ids.join(' + ')}]`, kind: 'auto', recommended: 'a', phase, item_class: 'challenge1', ...(heaviestChanges(rows) ? { changes: heaviestChanges(rows) } : {}), + why: `${rows.map(r => r.voice).join(' + ')} say${rows.length > 1 ? '' : 's'} the plan does less than your words “${narrows.text}”, but ${lineText({ ...narrows, ruling_verified: true })}`, + cost: `b reopens ${phase}${phase === 'eng' ? '' : ' and eng'}`, options: [KEEP('keep your ruling'), { key: 'b', text: 'accept the change', changes_plan: true }] }, ids.join('+')); + continue; + } if (quoted && (f.changes || f.user_challenge) && !ownerQuoteOf(owner, f)) { - const twin = twinOf(f.id) ? byId.get(twinOf(f.id)!) as ChallengeRow | undefined : undefined; propose(twin && !twin.settled_by && !ownerQuoteOf(owner, twin) && !narrowedQuoteOf(owner, twin) ? [f, twin] : [f], carried.includes(f)); continue; } diff --git a/lib/autoplan-owner-text.ts b/lib/autoplan-owner-text.ts index 4d5375ad6..f5e5f7a3c 100644 --- a/lib/autoplan-owner-text.ts +++ b/lib/autoplan-owner-text.ts @@ -10,7 +10,9 @@ * cuts. Read by the gate builder and the owner and captain briefs. On a first * version each Owner's words bullet also carries a line after an arrow saying * what this version does with those words: `does it`, `choice` (a lettered - * gate choice, optionally `; size: …` and `; leave out: `) (GST-3608). + * gate choice, optionally `; size: …` and `; leave out: `) or + * `ruled out : ""`, which the gate checks against the owner's + * recorded replies (GST-3608, GST-3646). */ import { findSection } from './markdown-sections'; @@ -19,7 +21,7 @@ export const DAY_ONE_TITLES = ['Day one', 'Day-one page', 'Day one page']; export const CUTS_TITLES = ["What it won't do yet", 'What it will not do yet', "Won't do yet"]; export const DAY_ONE_COLUMNS = ['action', 'frequency', 'source', 'feature', 'route', 'first build', 'check'] as const; -export type OwnerLine = { kind: 'does' } | { kind: 'choice'; size?: string; leave_out?: string }; +export type OwnerLine = { kind: 'does' } | { kind: 'choice'; size?: string; leave_out?: string } | { kind: 'ruled_out'; date: string; ruling: string }; export interface OwnerQuote { n: number; who: string; text: string; line?: OwnerLine } export interface OwnerWordsSection { status: 'none' | 'ok' | 'malformed'; quotes: OwnerQuote[]; reason?: string; fix?: string } export interface DayOneRow { action: string; frequency: string; source: string; feature: string; route: string; first_build: string; check: string; assumed: boolean } @@ -27,6 +29,7 @@ export interface DayOneTable { status: 'none' | 'ok' | 'malformed'; rows: DayOne const BULLET = /^\s*[-*+]\s+(.*)$/; const QUOTED = /[“"](.+)[”"]/; +const RULED = /^ruled out\s+([^“"]+?)\s*:\s*[“"](.+)[”"]\s*$/i; const count = (s: string, c: string) => s.split(c).length - 1; const paired = (s: string) => count(s, '"') % 2 === 0 && count(s, '“') === count(s, '”'); @@ -48,9 +51,11 @@ export function splitLine(bullet: string): { left: string; line?: string } { return arrow ? { left: bullet.slice(0, close + arrow.index).trimEnd(), line: bullet.slice(close + arrow.index + arrow[0].length).trim() } : { left: bullet }; } -/** A bullet's line: `does it` or `choice[; size: …][; leave out: …]`; undefined when it reads as neither. */ +/** A bullet's line: `does it`, `choice[; size: …][; leave out: …]` or `ruled out : ""`; undefined when it reads as none of them. */ export function parseLine(line: string): OwnerLine | undefined { if (/^does it\W*$/i.test(line)) return { kind: 'does' }; + const ruled = RULED.exec(line); + if (ruled) return { kind: 'ruled_out', date: ruled[1]!.trim(), ruling: ruled[2]!.trim() }; if (!/^choice\b/i.test(line)) return undefined; const out: { kind: 'choice'; size?: string; leave_out?: string } = { kind: 'choice' }; for (const part of line.replace(/^choice\b[^;]*/i, '').split(';').map(p => p.trim()).filter(Boolean)) { @@ -86,20 +91,27 @@ export function parseOwnerWords(planText: string): OwnerWordsSection { quotes.push({ n: i + 1, who: left.slice(0, m.index).replace(/[\s:,-]+$/, '').trim() || 'unattributed', text: m[1]!.trim(), ...(parsed ? { line: parsed } : {}) }); }); const reasons = [...(bad.length ? [`bullet ${bad.join(', ')} quotes no words`] : []), - ...(badLine.length ? [`bullet ${badLine.join(', ')} has a line that is not does it or choice`] : [])]; - return reasons.length ? { status: 'malformed', quotes, reason: reasons.join('; '), fix: badLine.length ? fix + ' → does it | choice' : fix } : { status: 'ok', quotes }; + ...(badLine.length ? [`bullet ${badLine.join(', ')} has a line that is not does it, choice or ruled out : ""`] : [])]; + return reasons.length ? { status: 'malformed', quotes, reason: reasons.join('; '), fix: badLine.length ? fix + ' → does it | choice | ruled out : ""' : fix } : { status: 'ok', quotes }; } /** What a first version still owes on a quote: when it was said, and a line. Empty when both are there. */ -export const quoteGaps = (q: OwnerQuote): string[] => [...(quoteWhen(q) ? [] : ['when it was said']), ...(q.line ? [] : ['a line (does it or choice)'])]; +export const quoteGaps = (q: OwnerQuote): string[] => [...(quoteWhen(q) ? [] : ['when it was said']), ...(q.line ? [] : ['a line (does it, choice or ruled out)'])]; /** The quote a cut drops, by its words (cutDrops), or undefined. */ export const cutQuote = (cut: string, quotes: OwnerQuote[]): OwnerQuote | undefined => quotes.find(q => cutDrops(cut, q.text)); +/** A quote as the gate shows it: whether its words, and a ruled-out line's ruling, were found in the owner's recorded replies. */ +export type CheckedQuote = OwnerQuote & { verified?: boolean; ruling_verified?: boolean }; + +/** A ruled-out line whose ruling was found in the owner's recorded replies: it stands without asking him again. */ +export const ruledByOwner = (q: CheckedQuote): boolean => q.line?.kind === 'ruled_out' && q.ruling_verified === true; + /** A quote's line in the owner's words. */ -export function lineText(q: OwnerQuote): string { +export function lineText(q: CheckedQuote): string { if (!q.line) return 'no line yet: asked below'; if (q.line.kind === 'does') return 'does it'; + if (q.line.kind === 'ruled_out') return `you ruled it out on ${q.line.date}: “${q.line.ruling}”${q.ruling_verified === false ? ' (not found in your recorded replies: asked below)' : ''}`; return 'not in this version yet: a lettered choice below'; } @@ -145,9 +157,9 @@ export const FIRST_USE_LINE = "Before you're asked to try it, an agent from anot * this version does with them, then the day-one table, then what it won't do yet. A cut that drops a quoted line is asked * beside that quote as a lettered choice, never listed under "What it won't do yet". Empty when the plan has none of them. */ -export function renderOwnerPage(planText: string, quotes: Array = [], o: { firstVersion?: boolean } = {}): string[] { +export function renderOwnerPage(planText: string, quotes: CheckedQuote[] = [], o: { firstVersion?: boolean } = {}): string[] { const day = parseDayOne(planText); - const cuts = parseCuts(planText).filter(c => !cutQuote(c, quotes)); + const cuts = parseCuts(planText).filter(c => !cutQuote(c, quotes.filter(q => !ruledByOwner(q)))); const out: string[] = []; if (quotes.length) out.push('### Your words this plan follows', '', ...quotes.map(q => `- ${q.who}: “${q.text}”${q.verified === false ? ' (not found in your recorded replies)' : ''} → ${lineText(q)}`), '', 'A reviewer who wants to change one of these needs your answer. Anything else in the plan was written by the planning agent, so a reviewer\'s change to it is recommended below.', ''); diff --git a/lib/autoplan-owner-words.ts b/lib/autoplan-owner-words.ts index eaf22a889..d80dd3f85 100644 --- a/lib/autoplan-owner-words.ts +++ b/lib/autoplan-owner-words.ts @@ -293,7 +293,8 @@ export function ownerWords(state: Pick 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 */ } 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 planWords = [...new Set(planQuotes.flatMap(q => [q.text, ...(q.line?.kind === 'ruled_out' ? [q.line.ruling] : [])]))]; + for (const text of planWords) note(text, undefined, false); const deferred = new Map(); 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)); @@ -302,7 +303,7 @@ export function ownerWords(state: Pick ({ 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))], + quoted: planWords, reasons: [...new Set(planQuotes.flatMap(q => (q.line?.kind === 'choice' && q.line.leave_out ? [q.line.leave_out] : [])))], }); } diff --git a/lib/gate-list.ts b/lib/gate-list.ts index a871643e8..56e93409c 100644 --- a/lib/gate-list.ts +++ b/lib/gate-list.ts @@ -58,7 +58,7 @@ export interface GateList { schema_version: 1; run: string; gate_rev: number; it /** The plan's plain-language ask, read from the reviewed plan (lib/captain-brief.ts `buildEli5`); printed first. */ eli5?: GateEli5; /** The plan's `### Owner's words` (lib/autoplan-owner-text.ts): the quotes a challenge must name to keep the plan's direction; `verified` when a recorded owner reply holds it. */ - owner_words?: { status: 'ok' | 'malformed' | 'none'; quotes: Array<{ n: number; who: string; text: string; verified: boolean; line?: OwnerLine }>; reason?: string; fix?: string }; + owner_words?: { status: 'ok' | 'malformed' | 'none'; quotes: Array<{ n: number; who: string; text: string; verified: boolean; ruling_verified?: boolean; line?: OwnerLine }>; reason?: string; fix?: string }; /** A first version (a Day one section or `--first-version`): the owner brief adds the gstack-first-use line. */ first_version?: boolean; /** The one-reviewer check of an unreviewed post-cap delta before a carry (lib/autoplan-carry.ts). */ diff --git a/lib/result-codes-capy.ts b/lib/result-codes-capy.ts index 3a414ca01..4625452c1 100644 --- a/lib/result-codes-capy.ts +++ b/lib/result-codes-capy.ts @@ -208,7 +208,7 @@ export const CAPY_RESULT_CODES = { FIRST_USE_PLAN_UNREADY: { anchor: 'first-use-plan-unready', summary: 'the plan has no usable ### Day one table or ### Owner\'s words to freeze (missing, malformed, fewer than five complete rows, a row still marked assumed or citing no quote, or a quote with no time or line)', - fix: 'quote the owner\'s messages that state the job under ### Owner\'s words (who, when, "words" → does it | choice), cite them from the five ### Day one rows as owner words , then run start again', + fix: 'quote the owner\'s messages that state the job under ### Owner\'s words (who, when, "words" → does it | choice | ruled out : ""), cite them from the five ### Day one rows as owner words , then run start again', }, FIRST_USE_PLAY_SPEC_INCOMPLETE: { anchor: 'first-use-play-spec-incomplete', diff --git a/test/autoplan-day-one-gate.test.ts b/test/autoplan-day-one-gate.test.ts index 9f9227a7e..c08032eef 100644 --- a/test/autoplan-day-one-gate.test.ts +++ b/test/autoplan-day-one-gate.test.ts @@ -145,7 +145,7 @@ describe('replay: a reviewed app plan whose product challenges were hidden', () ['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(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, choice or ruled out))', 'a']]); expect(list.first_version).toBe(true); expect(list.owner_words).toMatchObject({ status: 'ok', quotes: [{ n: 1, verified: false }] }); }); @@ -517,6 +517,87 @@ describe('first versions: the owner page quotes the owner and letters what it le expect(notes.origin!.endsWith('|finding')).toBe(true); }); + describe("a ruled-out line beats a reviewer only when the owner's recorded replies hold his ruling (GST-3646)", () => { + const RULING = 'never touch my calendar, I mean it'; + const CASE5 = CASE4 + `\n- The owner, 2026-11-12 09:00Z: "never touch my calendar" → ruled out 2026-11-12: "${RULING}"`; + const calendar = (voice: 'native' | 'outside', tagged = true) => row('ceo', voice, { id: `${RUN}-ceo-r2-${voice}-1`, severity: 'High', title: 'Leaving the calendar out does less than the owner asked for', changes: 'scope', resolution: 'add calendar reads', ...(tagged ? { narrows_quote: 3 } : {}) } as Row); + const run = (name: string, o: { said?: boolean; native?: FindingRow[]; outside?: FindingRow[]; cuts?: string }) => { + const state = makeRun(name, { plan: plan(CASE5, o.cuts), round2: { native: o.native ?? [], outside: o.outside ?? [] }, round1: false, ui: false }); + if (o.said) fs.writeFileSync(path.join(state.out, 'attempts.jsonl'), JSON.stringify({ owner_reply: `c3: no. ${RULING}` }) + '\n'); + return state; + }; + const calendarItems = (list: GateList) => list.items.filter(i => i.title.includes('calendar')); + + test('the parser reads the ruled-out line, and only a recorded reply verifies the ruling', () => { + expect(parseOwnerWords(CASE5).quotes[2]!.line).toEqual({ kind: 'ruled_out', date: '2026-11-12', ruling: RULING }); + expect(ownerContext(run('ruled-ctx', {}), []).ruled).toEqual(new Set()); + expect(ownerContext(run('ruled-ctx-said', { said: true })).ruled).toEqual(new Set([3])); + expect(ownerContext(run('ruled-ctx-other', {}), ['never touch my calendar']).ruled).toEqual(new Set()); + }); + + test('a ruling dated with a time parses; a short ruling, or one that only repeats the quote, never counts as recorded', () => { + expect(parseOwnerWords("### Owner's words\n\n- The owner, 2026-11-23 10:04Z: \"add dark mode\" → ruled out 2026-11-24 09:12Z: \"not in the first version\"").quotes[0]).toMatchObject({ text: 'add dark mode', line: { kind: 'ruled_out', date: '2026-11-24 09:12Z', ruling: 'not in the first version' } }); + const ruledWith = (ruling: string, replies: string[]) => { + const state = makeRun(`ruled-floor-${ruling.replace(/\W+/g, '-')}`, { plan: plan(CASE4 + `\n- The owner, 2026-11-12 09:00Z: "never touch my calendar or my reminders" → ruled out 2026-11-12: "${ruling}"`), round2: { native: [], outside: [] }, round1: false, ui: false }); + return ownerContext(state, replies).ruled; + }; + expect(ruledWith('no', ['c1: no, keep the dark mode'])).toEqual(new Set()); + expect(ruledWith('never touch my calendar', ['never touch my calendar or my reminders'])).toEqual(new Set()); + expect(ruledWith('leave my calendar alone', ['never touch my calendar or my reminders. actually leave my calendar alone'])).toEqual(new Set([3])); + }); + + test('a recorded ruling beats a High finding: one item recommending the ruling, never a build-it choice or a proposal', () => { + const list = buildGate(run('ruled-said', { said: true, native: [calendar('native')] }), 1); + const items = calendarItems(list); + expect(items.map(i => [i.item_class, i.kind, i.recommended, i.options[0]!.text, i.options[0]!.changes_plan])).toEqual([['challenge1', 'auto', 'a', 'keep your ruling', false]]); + expect(items[0]!.why).toBe(`native says the plan does less than your words “never touch my calendar”, but you ruled it out on 2026-11-12: “${RULING}”`); + expect(rec(list)[items[0]!.id]).toBe('a'); + }); + + test('an unrecorded ruling and the High finding are one question, side by side, recommending the ruling', () => { + const list = buildGate(run('ruled-unsaid', { native: [calendar('native')] }), 1); + const items = calendarItems(list); + expect(items.map(i => [i.item_class, i.kind, i.recommended])).toEqual([['owner_choice', 'approval', 'b']]); + const item = items[0]!; + expect(item.why).toBe(`the plan says you ruled it out on 2026-11-12: “${RULING}”, but no recorded reply of yours says that; a reviewer (native) says the plan narrows it: Leaving the calendar out does less than the owner asked for`); + expect(item.options.map(o => [o.text, o.changes_plan])).toEqual([['build it in this version (size not stated)', true], [`leave it out, as your ruling says: “${RULING}”`, false]]); + expect(item.recommended_basis).toBe("your ruling as the plan quotes it; it isn't in your recorded replies, so this asks you beside the High finding"); + expect(item.origin!.split('|')[1]!.split('+')).toEqual(['quote:3', `${RUN}-ceo-r2-native-1`]); + expect(item.origin!.endsWith('|finding')).toBe(true); + expect(rec(list)[item.id]).toBe('b'); + const page = renderOwnerPage(fs.readFileSync(path.join(TMP, 'ruled-unsaid', 'plan-active.md'), 'utf8'), list.owner_words?.quotes).join('\n'); + expect(page).toContain(`→ you ruled it out on 2026-11-12: “${RULING}” (not found in your recorded replies: asked below)`); + }); + + test('an unrecorded ruling with no finding and no cut still costs one question; a recorded one costs none', () => { + expect(calendarItems(buildGate(run('ruled-quiet', {}), 1)).map(i => [i.item_class, i.recommended])).toEqual([['owner_choice', 'b']]); + const said = buildGate(run('ruled-quiet-said', { said: true }), 1); + expect(calendarItems(said)).toEqual([]); + expect(renderOwnerPage(fs.readFileSync(path.join(TMP, 'ruled-quiet-said', 'plan-active.md'), 'utf8'), said.owner_words?.quotes).join('\n')).toContain(`→ you ruled it out on 2026-11-12: “${RULING}”\n`); + }); + + test('a cut that follows a recorded ruling stays a cut recommending keep; an unrecorded one is asked beside the quote', () => { + const cuts = '- It never touches your calendar: never touch my calendar\n- No Android build\n'; + const said = buildGate(run('ruled-cut-said', { said: true, cuts }), 1); + expect(calendarItems(said).map(i => [i.title, i.recommended])).toEqual([['Cut: It never touches your calendar: never touch my calendar', 'a']]); + const unsaid = buildGate(run('ruled-cut-unsaid', { cuts }), 1); + expect(calendarItems(unsaid).map(i => [i.item_class, i.recommended])).toEqual([['owner_choice', 'b']]); + expect(calendarItems(unsaid)[0]!.why).toContain('the plan cuts it: "It never touches your calendar: never touch my calendar"'); + }); + + test.each([['recorded', true], ['unrecorded', false]] as const)('an untagged twin of a finding on a %s ruling joins its item and never becomes a take-the-change proposal', (_, said) => { + for (const [tagged, untagged] of [['native', 'outside'], ['outside', 'native']] as const) { + const rows = { [tagged]: [calendar(tagged)], [untagged]: [calendar(untagged, false)] } as { native: FindingRow[]; outside: FindingRow[] }; + const list = buildGate(run(`ruled-twin-${said}-${tagged}`, { said, ...rows }), 1); + expect(byClass(list, 'proposal'), `${tagged} tagged`).toEqual([]); + const items = calendarItems(list); + expect(items.length, `${tagged} tagged`).toBe(1); + expect(items[0]!.origin!.split('|')[1]!.split('+').sort(), `${tagged} tagged`).toEqual(said ? [`${RUN}-ceo-r2-native-1`, `${RUN}-ceo-r2-outside-1`] : ['quote:3', `${RUN}-ceo-r2-native-1`, `${RUN}-ceo-r2-outside-1`]); + expect(items[0]!.options.find(o => o.key === rec(list)[items[0]!.id])!.changes_plan, `${tagged} tagged`).toBe(false); + } + }); + }); + 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') => @@ -526,6 +607,7 @@ describe('first versions: the owner page quotes the owner and letters what it le { 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)] }, + { name: 'a paired finding: only the native names the does-it quote', native: [finding('native', 1)], outside: [{ ...finding('outside', 1), narrows_quote: undefined }] }, ]; 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 }); @@ -533,7 +615,7 @@ describe('first versions: the owner page quotes the owner and letters what it le 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 q = quotes.find(x => x.n === (r.narrows_quote ?? kind.native[0]!.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) { diff --git a/test/autoplan-owner-words.test.ts b/test/autoplan-owner-words.test.ts index 5a47d6dd3..3e959b542 100644 --- a/test/autoplan-owner-words.test.ts +++ b/test/autoplan-owner-words.test.ts @@ -182,7 +182,7 @@ 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", () => { + test("a plan's ruled-out line indexes the owner's ruling as well as the quote, so export and validate both redact it", () => { 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`); @@ -190,7 +190,7 @@ describe('ownerWords over a run directory', () => { 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'); + expect(redactOwnerWords('He said never touch my calendar or my reminders today.', owner).text).toContain(MARK); fs.rmSync(out, { recursive: true, force: true }); }); }); diff --git a/test/autoplan-public-owner-words.test.ts b/test/autoplan-public-owner-words.test.ts index 29f1ed1e2..bfcd5bc5c 100644 --- a/test/autoplan-public-owner-words.test.ts +++ b/test/autoplan-public-owner-words.test.ts @@ -403,8 +403,8 @@ describe('every attribution, line and quote shape reads as the merge base read i ['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], + ['a ruling', u => ` → ruled out 2026-11-20: "skrimblor dorvelin ${u}"`, u => ({ kind: 'ruled_out', date: '2026-11-20', ruling: `skrimblor dorvelin ${u}` })], + ['a ruling with nested quotes and an arrow', u => ` → ruled out 2026-11-20: "grobble "nevermore" -> ${u}"`, u => ({ kind: 'ruled_out', date: '2026-11-20', ruling: `grobble "nevermore" -> ${u}` })], ]; 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. */ @@ -413,12 +413,12 @@ describe('every attribution, line and quote shape reads as the merge base read i 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 }; + return { name: `${attrName} / ${textName} / ${lineName}`, bullet: bare + line(ruling), bare, words, line: parsed(ruling), ruling: parsed(ruling)?.kind === 'ruled_out' ? ruling : 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(/^- /, '')); + const base = mergeBase(row.bare.replace(/^- /, '')); expect(base).toBeDefined(); const w = parseOwnerWords(section([row.bullet])); expect(w.status, w.reason).toBe('ok'); @@ -430,7 +430,7 @@ describe('every attribution, line and quote shape reads as the merge base read i 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.reason).toBe('bullet 1 has a line that is not does it, choice or ruled out : ""'); expect(bad.quotes.map(q => q.text)).toEqual(['ship the importer tonight']); }); diff --git a/test/first-use.test.ts b/test/first-use.test.ts index 73455cddb..0e3f00272 100644 --- a/test/first-use.test.ts +++ b/test/first-use.test.ts @@ -97,11 +97,11 @@ describe('the day-one table and the owner quotes it cites (pinned)', () => { 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)' } }); + expect(freezeActions(noLine)).toEqual({ error: { code: 'FIRST_USE_PLAN_UNREADY', detail: 'owner quote 2 needs a line (does it, choice or ruled out)' } }); 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') } }); + expect(freezeActions(bad)).toMatchObject({ error: { detail: expect.stringContaining('bullet 2 has a line that is not does it, choice or ruled out') } }); }); test('editing or inserting a quote changes the frozen hash, even when the rows stay the same', () => {