mirror of
https://github.com/garrytan/gstack.git
synced 2026-12-02 04:43:59 +01:00
/autoplan stops asking the owner again for changes his "do it" already approved (GST-3753) (#4809)
When the review rounds run out and every decision in the last revision is a recommendation the owner already took in his own words, /autoplan now finishes instead of raising another approval gate, and leaves one note saying no reviewer read that last revision. Why: a run answered "do it" twice still got a third gate of 63 items, three of them "accept the unreviewed changes" once per review phase, which only the owner could answer. Nothing to do: `gstack-autoplan status` shows the note as open until `gstack-autoplan rule` closes it. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> Review-Finding: p1/outside-voice#2 reader=outside-voice Review-Finding: p1/adversarial-native#4 reader=adversarial
This commit is contained in:
1 parent
f2ca920bc4
commit
2679c6f7ad
16 files changed
+422
-46
No files matched your search
@@ -147,7 +147,7 @@ describe('the round cap', () => {
|
||||
expect(run.status).toBe('gate_pending');
|
||||
expect(run.capped_deltas.map((d: any) => [d.phase, d.status])).toEqual([['ceo', 'pending'], ['eng', 'pending']]);
|
||||
const deltas = gate(s.out).items.filter((i: any) => i.cap?.kind === 'delta');
|
||||
expect(deltas.map((i: any) => i.title.replace(/\(.*/, '').trim())).toEqual(['plan changed after ceo cap: unreviewed delta', 'plan changed after eng cap: unreviewed delta']);
|
||||
expect(deltas.map((i: any) => i.title.replace(/\(.*/, '').trim())).toEqual(['plan changed after the ceo and eng cap: unreviewed delta']);
|
||||
expect(deltas.every((i: any) => i.kind === 'approval')).toBe(true);
|
||||
const partial = answer(s.out, 2, 'p1a');
|
||||
expect(partial.stdout).toMatch(/^GATE_PENDING: /m);
|
||||
@@ -205,9 +205,8 @@ describe('deferred close keeps earlier open findings; a reopened phase reruns En
|
||||
phaseVia(r, s.out, 'eng', NONE);
|
||||
expect(r.ap(['revise', '--out', s.out, '--plan', v2File(s.dir)]).status).toBe(0);
|
||||
const items = gate(s.out).items;
|
||||
const ceo = items.find((i: any) => i.cap?.kind === 'delta' && i.phase === 'ceo');
|
||||
const eng = items.find((i: any) => i.cap?.kind === 'delta' && i.phase === 'eng');
|
||||
const replied = answer(s.out, readRunJson(s.out).gate_rev, `${ceo.id}b ${eng.id}a p1a`);
|
||||
const delta = items.find((i: any) => i.cap?.kind === 'delta' && i.phase === 'ceo');
|
||||
const replied = answer(s.out, readRunJson(s.out).gate_rev, `${delta.id}b p1a`);
|
||||
expect(replied.status, replied.stderr).toBe(0);
|
||||
expect(replied.stdout).toMatch(/^ROUND_GRANTED: eng cap=2 \(reruns after ceo; /m);
|
||||
phaseVia(r, s.out, 'ceo', NONE);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* Carry-forward (GSTA-155, lib/autoplan-carry.ts): a later gate revision that asks nothing new is answered with the
|
||||
* owner's recorded words from the revision before it, and recorded as a carry; every other case prints why not and
|
||||
* stays at the gate. A "do it" also covers new auto items that change no scope, cost or direction. A capped,
|
||||
* unreviewed delta gets one reviewer on the delta first (CARRY_CHECK, gstack-autoplan check): High or above means no
|
||||
* unreviewed delta the owner did not take as a recommendation gets one reviewer on the delta first (CARRY_CHECK, gstack-autoplan check): High or above means no
|
||||
* carry. Runs on the simulated Capy host.
|
||||
*/
|
||||
import { afterAll, describe, expect, setDefaultTimeout, test } from 'bun:test';
|
||||
@@ -51,6 +51,27 @@ function answeredAndRevised(args: string[] = [], words = 'Garry: Do it', ceo: {
|
||||
}
|
||||
const recHashOf = (out: string) => recHash(gateOf(out));
|
||||
|
||||
/**
|
||||
* Gate 1 answered item by item in the owner's words, taking a change the gate did not recommend (d1b), then revised to take
|
||||
* it. At the round cap that is an unreviewed change the owner did not take as a recommendation, so it keeps its gate item
|
||||
* and the delta check (a revise that only takes recommendations he approved needs neither, GST-3753).
|
||||
*/
|
||||
function overriddenAndRevised(args: string[] = []) {
|
||||
const dir = path.join(r.host.base, `carry${++n}`);
|
||||
const out = path.join(dir, 'run');
|
||||
expect(r.ap(['next', '--out', out, '--plan', writePlan(dir), '--no-ui', ...args]).status).toBe(0);
|
||||
phaseVia(r, out, 'ceo', ONE_VOICE);
|
||||
expect(phaseVia(r, out, 'eng', NONE).outside.stdout).toContain('status=gate_pending');
|
||||
const ans = r.ap(['answer', '--out', out, '--gate-rev', '1', '--reply', 'd1b p1b', '--by', 'agent:gstack-minder', '--owner-reply', 'd1b p1b']);
|
||||
expect(ans.status, ans.stderr).toBe(0);
|
||||
expect(ans.stdout).toMatch(/^APPLY: /m);
|
||||
const v2 = path.join(dir, 'plan-v2.md');
|
||||
fs.writeFileSync(v2, V2);
|
||||
const rev = r.ap(['revise', '--out', out, '--plan', v2, '--incorporates', 'd1']);
|
||||
expect(rev.status, rev.stderr).toBe(0);
|
||||
return { dir, out, v2, rev };
|
||||
}
|
||||
|
||||
describe('whose words answered the gate (GEVA-2, P7)', () => {
|
||||
test("an agent's own words are recorded as its own, never as the owner's, never carried, and imported under the agent", () => {
|
||||
const dir = path.join(r.host.base, `carry${++n}`);
|
||||
@@ -312,9 +333,9 @@ describe('carry-forward', () => {
|
||||
|
||||
describe('the delta check before a carry', () => {
|
||||
function capped() {
|
||||
const s = answeredAndRevised(['--max-rounds', '1']);
|
||||
const s = overriddenAndRevised(['--max-rounds', '1']);
|
||||
expect(s.rev.stdout).toMatch(/^CAPPED: ceo used round 1 of 1/m);
|
||||
expect(s.rev.stdout).toMatch(/^CARRY_CHECK: attempt=\S+-c2 items=uc\d+,uc\d+ prompt=\S+ result=\S+ model_family=not anthropic estimate=5\.00 cap=5\.00$/m);
|
||||
expect(s.rev.stdout).toMatch(/^CARRY_CHECK: attempt=\S+-c2 items=uc\d+ prompt=\S+ result=\S+ model_family=not anthropic estimate=5\.00 cap=5\.00$/m);
|
||||
expect(s.rev.stdout).toMatch(/^GATE: gate_rev=2 /m);
|
||||
const run = readRunJson(s.out);
|
||||
expect(run.status).toBe('gate_pending');
|
||||
@@ -335,10 +356,10 @@ describe('the delta check before a carry', () => {
|
||||
const ok = r.ap(['check', '--out', s.out, '--attempt', s.check.attempt, '--result', s.check.result, '--model', 'openai/gpt-6.1-sol']);
|
||||
expect(ok.status, ok.stderr).toBe(0);
|
||||
expect(ok.stdout).toMatch(/^CARRY_CHECK: passed attempt=\S+ model=openai\/gpt-6\.1-sol findings=1 highest=Low$/m);
|
||||
expect(ok.stdout).toMatch(/^CARRIED: gate_rev=2 <- gate_rev=1 .*reason=delta check passed on uc\d+,uc\d+; plan unchanged/m);
|
||||
expect(ok.stdout).toMatch(/^CARRIED: gate_rev=2 <- gate_rev=1 .*reason=delta check passed on uc\d+; plan unchanged/m);
|
||||
expect(ok.stdout).toContain('status=complete');
|
||||
expect(gateOf(s.out).carry_check).toMatchObject({ verdict: 'passed', model: 'openai/gpt-6.1-sol', max_severity: 'Low', findings: 1 });
|
||||
expect(decisions(s.out).filter(x => x.gate_rev === 2 && x.carry_check).length).toBe(2);
|
||||
expect(decisions(s.out).filter(x => x.gate_rev === 2 && x.carry_check).length).toBe(1);
|
||||
expect(fs.readFileSync(path.join(s.out, 'decisions.tsv'), 'utf8')).toContain('delta check before carrying gate_rev 2');
|
||||
expect(r.ap(['export', '--out', s.out]).status).toBe(0);
|
||||
expect(r.validate(s.out).status).toBe(0);
|
||||
@@ -367,7 +388,7 @@ describe('the delta check before a carry', () => {
|
||||
// fails_when=the cap comparison or the attempt guard is dropped or inverted; why_new=tests above run at the default cap
|
||||
// with the right attempt only; seam=none; no_claim=real reviewer dispatch (simulated Capy host)
|
||||
test('a check over --carry-check-cap refuses the carry; a wrong --attempt is refused', () => {
|
||||
const over = answeredAndRevised(['--max-rounds', '1', '--carry-check-cap', '1']);
|
||||
const over = overriddenAndRevised(['--max-rounds', '1', '--carry-check-cap', '1']);
|
||||
expect(over.rev.stdout).toMatch(/^CARRY: no \(delta check estimate 5\.00 is over the per-gate cap 1\.00 \(--carry-check-cap\)\)$/m);
|
||||
expect(over.rev.stdout).not.toMatch(/^CARRY_CHECK:/m);
|
||||
expect(readRunJson(over.out).status).toBe('gate_pending');
|
||||
|
||||
@@ -0,0 +1,233 @@
|
||||
/**
|
||||
* GST-3753: the owner's "do it" is carried through the round cap. Replays the shape of run autoplan-embftp-20261124162738
|
||||
* (gstack v1.103.1.0) on the simulated Capy host: gate 1 answered "do it", a revise and re-review, gate 2 answered "do it",
|
||||
* then a revise at the round cap that only takes those recommendations. Before the fix that revise raised gate 3 with one
|
||||
* "accept the unreviewed delta" approval per capped phase, which a relaying agent could not settle (OWNER_REPLY_REQUIRED),
|
||||
* and a cut whose command was renamed counted as a new item. Now the run finishes with an UNREVIEWED note a ruling closes;
|
||||
* a change the owner did not approve still raises one item for all capped phases; a phase that does review the revision
|
||||
* still raises its finding; and a cut carries its answer only while its words are unchanged.
|
||||
*/
|
||||
import { afterAll, describe, expect, setDefaultTimeout, test } from 'bun:test';
|
||||
import * as fs from 'node:fs';
|
||||
import * as path from 'node:path';
|
||||
import { OWNER_RECS_AT_CAP, ownerTookRecs } from '../lib/autoplan-budget';
|
||||
import type { RunState } from '../lib/autoplan-state';
|
||||
import { recReopens } from '../lib/autoplan-gate-cost';
|
||||
import { recHash } from '../lib/gate-list';
|
||||
import { SMALL_PLAN } from './helpers/autoplan-run-fixture';
|
||||
import { capyRunner, phaseVia, readJsonl, readRunJson, writePlan } from './helpers/autoplan-capy';
|
||||
|
||||
setDefaultTimeout(60_000);
|
||||
const r = capyRunner();
|
||||
afterAll(() => r.cleanup());
|
||||
let n = 0;
|
||||
const NONE = { native: [], outside: [] };
|
||||
const DO_IT = 'Garry: Do it';
|
||||
const both = (id: string, title: string, fix: string) => ({
|
||||
native: [{ id: `N${id}`, severity: 'High', title, user_challenge: true, changes: 'scope', fix }],
|
||||
outside: [{ id: `O${id}`, severity: 'High', title, user_challenge: true, changes: 'scope', fix }],
|
||||
});
|
||||
const FLAG = both('1', 'Ship the backoff behind a flag first', 'gate the change behind RETRY_BACKOFF=1');
|
||||
const DEAD = both('2', 'Dead-letter jobs after the last retry', 'move a job to the dead-letter table after 8 attempts');
|
||||
const V2 = SMALL_PLAN.replace('cap 30 s', 'cap 30 s, behind RETRY_BACKOFF=1');
|
||||
const V3 = V2.replace('jitter 10%.', 'jitter 10%; a job moves to the dead-letter table after 8 attempts.');
|
||||
const gateOf = (out: string) => JSON.parse(fs.readFileSync(path.join(out, 'gate.json'), 'utf8'));
|
||||
const pending = (out: string) => readRunJson(out).amendments.filter((a: any) => a.status === 'pending').map((a: any) => a.decision).join(',');
|
||||
const file = (dir: string, text: string) => { const f = path.join(dir, `plan-${++n}.md`); fs.writeFileSync(f, text); return f; };
|
||||
|
||||
function answer(out: string, rev: number, reply: string, words: string, extra: string[] = []) {
|
||||
return r.ap(['answer', '--out', out, '--gate-rev', String(rev), '--reply', reply, '--rec-hash', recHash(gateOf(out)), '--by', 'agent:gstack-minder', '--owner-reply', words, ...extra]);
|
||||
}
|
||||
|
||||
/** Gate 1 "do it", revise, round 2 with a new challenge, gate 2 answered with `gate2` in the owner's words: the revise at the cap comes next. */
|
||||
function toTheCap(o: { first?: string[]; round2?: { native?: unknown[]; outside?: unknown[] }; gate2?: string; words2?: string } = {}) {
|
||||
const dir = path.join(r.host.base, `cap${++n}`);
|
||||
const out = path.join(dir, 'run');
|
||||
expect(r.ap(['next', '--out', out, '--plan', writePlan(dir), ...(o.first ?? ['--no-ui'])]).status).toBe(0);
|
||||
phaseVia(r, out, 'ceo', FLAG);
|
||||
expect(phaseVia(r, out, 'eng', NONE).outside.stdout).toMatch(/^GATE: gate_rev=1 /m);
|
||||
const a1 = answer(out, 1, 'rec', DO_IT);
|
||||
expect(a1.status, a1.stderr).toBe(0);
|
||||
const v2 = r.ap(['revise', '--out', out, '--plan', file(dir, V2), '--incorporates', pending(out)]);
|
||||
expect(v2.stdout).toMatch(/^REVISED: plan=\S+ reopened=ceo,eng$/m);
|
||||
phaseVia(r, out, 'ceo', o.round2 ?? DEAD);
|
||||
expect(phaseVia(r, out, 'eng', NONE).outside.stdout).toMatch(/^GATE: gate_rev=2 /m);
|
||||
const a2 = answer(out, 2, o.gate2 ?? 'rec', o.words2 ?? DO_IT);
|
||||
expect(a2.status, a2.stderr).toBe(0);
|
||||
expect(a2.stdout).toMatch(/^APPLY: /m);
|
||||
return { dir, out };
|
||||
}
|
||||
|
||||
describe('two "do it" answers, then the round cap', () => {
|
||||
test("ownerTookRecs counts only recommendations the owner answered in his own words, not ones taken under \"do it\" unseen", () => {
|
||||
const out = path.join(r.host.base, `took${++n}`);
|
||||
fs.mkdirSync(out, { recursive: true });
|
||||
const row = (id: string, extra: Record<string, unknown>) => JSON.stringify({ id, status: 'approved', chosen: 'a', recommended: 'a', owner_reply: DO_IT, ...extra });
|
||||
fs.writeFileSync(path.join(out, 'decisions.jsonl'), [row('seen', {}), row('unseen', { carried_under: 'do it' }), row('own', { owner_reply: undefined, answer_words: 'ok', words_by: 'agent:x' }), row('over', { chosen: 'b', status: 'overridden' })].join('\n') + '\n');
|
||||
const state = { out } as RunState;
|
||||
expect(ownerTookRecs(state, ['seen'])).toBe(DO_IT);
|
||||
for (const id of ['unseen', 'own', 'over']) expect(ownerTookRecs(state, ['seen', id])).toBeUndefined();
|
||||
});
|
||||
|
||||
test('the revise that only takes the approved recommendations finishes the run: no third gate, one UNREVIEWED note', () => {
|
||||
const s = toTheCap();
|
||||
const rev = r.ap(['revise', '--out', s.out, '--plan', file(s.dir, V3), '--incorporates', pending(s.out)]);
|
||||
expect(rev.status, rev.stderr).toBe(0);
|
||||
expect(rev.stdout).toMatch(/^REVISED: plan=\S+ reopened=none capped=ceo,eng$/m);
|
||||
expect(rev.stdout).not.toMatch(/^GATE: gate_rev=3/m);
|
||||
expect(rev.stdout).toMatch(/^APPROVED: gate_rev=2 /m);
|
||||
const note = rev.stdout.split('\n').filter(l => l.startsWith('UNREVIEWED:'));
|
||||
expect(note).toHaveLength(1);
|
||||
expect(note[0]).toContain(`changed the plan after ceo,eng used their last round, so no reviewer read it; accepted without a gate: ${OWNER_RECS_AT_CAP}`);
|
||||
expect(note[0]).toContain(`answered in the owner's words ${JSON.stringify(DO_IT)}`);
|
||||
expect(note[0]).toMatch(/open note: gstack-autoplan rule --out \S+ --revision 2 /);
|
||||
const run = readRunJson(s.out);
|
||||
expect(run.status).toBe('complete');
|
||||
expect(run.gate_rev).toBe(2);
|
||||
expect(run.capped_deltas.map((d: any) => [d.phase, d.status, d.basis])).toEqual([['ceo', 'accepted', OWNER_RECS_AT_CAP], ['eng', 'accepted', OWNER_RECS_AT_CAP]]);
|
||||
expect(readJsonl(path.join(s.out, 'attempts.jsonl')).filter((j: any) => j.event === 'unreviewed_at_cap')).toMatchObject([{ k: 2, phases: ['ceo', 'eng'], reason: OWNER_RECS_AT_CAP }]);
|
||||
expect(r.validate(s.out).status).toBe(0);
|
||||
expect(fs.readFileSync(path.join(s.out, 'review-record.md'), 'utf8')).toContain(`accepted without a gate (${OWNER_RECS_AT_CAP}`);
|
||||
});
|
||||
|
||||
test("a ruling closes the note, as a ruled note closes a /ship finding after round two; gstack can't rule on its own", () => {
|
||||
const s = toTheCap();
|
||||
expect(r.ap(['revise', '--out', s.out, '--plan', file(s.dir, V3), '--incorporates', pending(s.out)]).status).toBe(0);
|
||||
for (const bad of [['--revision', '1', '--by', 'GStack Minder (GSTA-36)', '--reason', 'x'], ['--revision', '2', '--by', 'gstack', '--reason', 'x'], ['--revision', '2', '--by', 'agent:lane', '--reason', 'x'], ['--revision', '2', '--by', '--reason', 'x'], ['--revision', '2', '--by', 'GStack Minder (GSTA-36)'],
|
||||
['--revision', '2', '--by', 'GStack Minder (GSTA-36)', '--reason', 'x', '--owner-ref', 'not a ref']]) {
|
||||
const res = r.ap(['rule', '--out', s.out, ...bad]);
|
||||
expect(res.status, res.stdout).toBe(3);
|
||||
}
|
||||
expect(r.ap(['status', '--out', s.out]).stdout).toMatch(/^CAPPED_DELTA: v2 \S+ .* accepted unreviewed open: needs gstack-autoplan rule$/m);
|
||||
const ok = r.ap(['rule', '--out', s.out, '--revision', '2', '--by', 'GStack Minder (GSTA-36)', '--owner-ref', 'GSTA-36:2026-11-24T16:00:00Z', '--reason', "the owner's standing do it covers the applied changes"]);
|
||||
expect(ok.status, ok.stderr).toBe(0);
|
||||
expect(ok.stdout).toMatch(/^UNREVIEWED: revise v2 .*; closed by GStack Minder \(GSTA-36\) \(relayed from GSTA-36:2026-11-24T16:00:00Z\): the owner's standing do it covers the applied changes$/m);
|
||||
expect(readRunJson(s.out).capped_deltas.every((d: any) => d.ruling?.by === 'GStack Minder (GSTA-36)')).toBe(true);
|
||||
expect(fs.readFileSync(path.join(s.out, 'review-record.md'), 'utf8')).toContain('closed by GStack Minder (GSTA-36)');
|
||||
expect(r.ap(['status', '--out', s.out]).stdout).toMatch(/^CAPPED_DELTA: v2 \S+ .* accepted unreviewed ruled by GStack Minder \(GSTA-36\)$/m);
|
||||
const reason = "the owner's standing do it covers the applied changes";
|
||||
expect(fs.readFileSync(path.join(s.out, 'review-record.md'), 'utf8')).not.toContain(reason);
|
||||
const pub = path.join(s.dir, 'public');
|
||||
expect(r.ap(['export', '--out', s.out, '--public', pub]).status).toBe(0);
|
||||
expect(fs.readFileSync(path.join(pub, 'run.json'), 'utf8')).not.toContain(reason);
|
||||
expect(readRunJson(pub).capped_deltas[0].ruling).toMatchObject({ by: 'GStack Minder (GSTA-36)', owner_ref: 'GSTA-36:2026-11-24T16:00:00Z' });
|
||||
const again = r.ap(['rule', '--out', s.out, '--revision', '2', '--by', 'Garry', '--reason', 'second thoughts']);
|
||||
expect(again.status).toBe(3);
|
||||
expect(again.stderr).toContain('already ruled by GStack Minder (GSTA-36)');
|
||||
expect(r.validate(s.out).status).toBe(0);
|
||||
});
|
||||
|
||||
test('a settled change the owner did not take in his own words keeps the cap item, even beside an approved one', () => {
|
||||
const PACK = { native: [...DEAD.native, { id: 'N5', severity: 'Medium', title: 'Split the backoff into its own PR', user_challenge: true, changes: 'packaging', fix: 'land the schedule change as its own PR' }], outside: [...DEAD.outside, { id: 'O5', severity: 'Medium', title: 'Split the backoff into its own PR', user_challenge: true, changes: 'packaging', fix: 'Land the schedule change as its own PR.' }] };
|
||||
const s = toTheCap({ round2: PACK });
|
||||
const open = readRunJson(s.out).amendments.filter((a: any) => a.status === 'pending');
|
||||
const settle = open.find((a: any) => a.changes === 'packaging').decision, inc = open.find((a: any) => a.changes === 'scope').decision;
|
||||
const rows = readJsonl(path.join(s.out, 'decisions.jsonl'));
|
||||
fs.writeFileSync(path.join(s.out, 'decisions.jsonl'), rows.map((d: any) => JSON.stringify(d.id === settle ? { ...d, carried_under: 'do it' } : d)).join('\n') + '\n');
|
||||
const rev = r.ap(['revise', '--out', s.out, '--plan', file(s.dir, V3), '--incorporates', inc, '--settle', settle]);
|
||||
expect(rev.status, rev.stderr).toBe(0);
|
||||
expect(rev.stdout).toMatch(/^GATE: gate_rev=3 /m);
|
||||
expect(rev.stdout).not.toMatch(/^(APPROVED|UNREVIEWED):/m);
|
||||
expect(readRunJson(s.out).capped_deltas.every((d: any) => d.status === 'pending' && !d.basis)).toBe(true);
|
||||
});
|
||||
|
||||
test('a rule interrupted after its journal row is retried to the same ruling, never a second one', () => {
|
||||
const s = toTheCap();
|
||||
expect(r.ap(['revise', '--out', s.out, '--plan', file(s.dir, V3), '--incorporates', pending(s.out)]).status).toBe(0);
|
||||
const args = ['rule', '--out', s.out, '--revision', '2', '--by', 'GStack Minder (GSTA-36)', '--reason', 'covered by do it'];
|
||||
expect(r.ap(args).status).toBe(0);
|
||||
const run = readRunJson(s.out);
|
||||
for (const d of run.capped_deltas) delete d.ruling;
|
||||
fs.writeFileSync(path.join(s.out, 'run.json'), JSON.stringify(run, null, 2));
|
||||
const other = r.ap(['rule', '--out', s.out, '--revision', '2', '--by', 'Garry', '--reason', 'something else']);
|
||||
expect(other.status).toBe(3);
|
||||
expect(other.stderr).toContain('already ruled by GStack Minder (GSTA-36)');
|
||||
const retry = r.ap(args);
|
||||
expect(retry.status, retry.stderr).toBe(0);
|
||||
expect(readRunJson(s.out).capped_deltas.every((d: any) => d.ruling?.reason === 'covered by do it')).toBe(true);
|
||||
expect(readJsonl(path.join(s.out, 'attempts.jsonl')).filter((j: any) => j.event === 'unreviewed_ruled')).toHaveLength(1);
|
||||
});
|
||||
|
||||
test('a change the owner did not approve still raises a gate, with one item for every capped phase', () => {
|
||||
const s = toTheCap({ round2: { native: [{ id: 'N2', severity: 'High', title: 'Dead-letter jobs after the last retry', user_challenge: true, changes: 'scope', fix: 'dead-letter after 8 attempts' }], outside: [] }, gate2: 'd1b p1b', words2: 'd1b p1b' });
|
||||
const rev = r.ap(['revise', '--out', s.out, '--plan', file(s.dir, V3), '--incorporates', pending(s.out)]);
|
||||
expect(rev.status, rev.stderr).toBe(0);
|
||||
expect(rev.stdout).not.toMatch(/^UNREVIEWED:/m);
|
||||
expect(rev.stdout).toMatch(/^GATE: gate_rev=3 /m);
|
||||
const deltas = gateOf(s.out).items.filter((i: any) => i.cap?.kind === 'delta');
|
||||
expect(deltas).toHaveLength(1);
|
||||
expect(deltas[0].title).toStartWith('plan changed after the ceo and eng cap: unreviewed delta');
|
||||
const own = answer(s.out, 3, 'rec', 'Accepted on the standing approval', ['--words-by', 'agent:gstack-minder']);
|
||||
expect(own.status).toBe(3);
|
||||
expect(own.stderr).toContain(`(${deltas[0].id} is a round-cap approval only the owner can settle, and this reply`);
|
||||
expect(own.stderr).toContain('(OWNER_REPLY_REQUIRED)');
|
||||
const reopen = r.ap(['answer', '--out', s.out, '--gate-rev', '3', '--reply', `${deltas[0].id}b p1a`, '--by', 'human']);
|
||||
expect(reopen.status, reopen.stderr).toBe(0);
|
||||
expect(reopen.stdout).toMatch(/^ROUND_GRANTED: ceo cap=3 /m);
|
||||
expect(reopen.stdout).toMatch(/^ROUND_GRANTED: eng cap=3 \(reruns after ceo; /m);
|
||||
expect(readRunJson(s.out).capped_deltas.filter((d: any) => d.k === 2).map((d: any) => d.status)).toEqual(['reopened', 'reopened']);
|
||||
});
|
||||
|
||||
test('a gate written before this change, with one delta item per phase, still settles each phase on its own', () => {
|
||||
const s = toTheCap({ round2: { native: [{ id: 'N2', severity: 'High', title: 'Dead-letter jobs after the last retry', user_challenge: true, changes: 'scope', fix: 'dead-letter after 8 attempts' }], outside: [] }, gate2: 'd1b p1b', words2: 'd1b p1b' });
|
||||
expect(r.ap(['revise', '--out', s.out, '--plan', file(s.dir, V3), '--incorporates', pending(s.out)]).stdout).toMatch(/^GATE: gate_rev=3 /m);
|
||||
const g = gateOf(s.out);
|
||||
const one = g.items.find((i: any) => i.cap?.kind === 'delta');
|
||||
const { phases: _phases, ...cap } = one.cap;
|
||||
const id2 = `uc${g.items.filter((i: any) => i.id.startsWith('uc')).length + 1}`;
|
||||
g.items.splice(g.items.indexOf(one), 1, { ...one, cap: { ...cap, phase: 'ceo' } }, { ...one, id: id2, origin: `${one.origin}|eng`, cap: { ...cap, phase: 'eng' } });
|
||||
fs.writeFileSync(path.join(s.out, 'gate.json'), JSON.stringify(g, null, 2));
|
||||
const res = r.ap(['answer', '--out', s.out, '--gate-rev', '3', '--reply', `${one.id}b ${id2}a p1a`, '--by', 'human']);
|
||||
expect(res.status, res.stderr).toBe(0);
|
||||
expect(res.stdout).toMatch(/^ROUND_GRANTED: ceo cap=3 /m);
|
||||
expect(readRunJson(s.out).capped_deltas.filter((d: any) => d.k === 2).map((d: any) => [d.phase, d.status])).toEqual([['ceo', 'reopened'], ['eng', 'accepted']]);
|
||||
});
|
||||
|
||||
test('a phase that does review the revision still raises its new finding at a gate', () => {
|
||||
const s = toTheCap({ first: [] });
|
||||
const rev = r.ap(['revise', '--out', s.out, '--plan', file(s.dir, `<!-- gstack-autoplan-scope: --ui -->\n${V3}`), '--incorporates', pending(s.out)]);
|
||||
expect(rev.status, rev.stderr).toBe(0);
|
||||
expect(rev.stdout).toMatch(/^REVISED: plan=\S+ reopened=none added=design capped=ceo,eng$/m);
|
||||
const design = phaseVia(r, s.out, 'design', { native: [{ id: 'D1', severity: 'High', title: 'The retry status has no screen' }], outside: [] });
|
||||
expect(design.outside.stdout).toMatch(/^GATE: gate_rev=3 /m);
|
||||
const items = gateOf(s.out).items;
|
||||
expect(items.filter((i: any) => i.item_class === 'finding').map((i: any) => i.title)).toEqual([expect.stringContaining('The retry status has no screen')]);
|
||||
expect(items.some((i: any) => i.cap?.kind === 'delta')).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('the grant cost line, and cuts that carry only on unchanged words', () => {
|
||||
const plan = (button: string, extra = '') => [`# Plantpal watering coach (synthetic)`, '', '## Implementation plan', '', "### Owner's words", '',
|
||||
'- Ada Example, day 0: "I keep forgetting which plant needs water" → does it', '', '### Day one', '',
|
||||
'| action | frequency | source | feature | route | first build | check |', '|---|---|---|---|---|---|---|',
|
||||
'| sees which plant needs water today | daily | owner words 1 | Today list | root screen | build 1 | the plant due today is at the top |', '',
|
||||
"### What it won't do yet", '', `- No \`${button}\` command for shared households`, '- No Android build', '',
|
||||
`### Units`, '', `U1 the Today list${extra}. U2 the watering reminder.`, '', '## Review record', ''].join('\n');
|
||||
|
||||
test('the cost line for granting rounds counts every phase the one cap item reopens', () => {
|
||||
const opt = (key: string) => ({ key, text: key, changes_plan: key === 'b' });
|
||||
const list = { schema_version: 1, run: 'r', gate_rev: 3, items: [{ id: 'uc1', title: 'cap', options: [opt('a'), opt('b')], recommended: 'b', kind: 'approval', cap: { phase: 'ceo', kind: 'delta', ref: '2', phases: ['ceo', 'design'] } }] } as any;
|
||||
expect(recReopens(list, { phase_order: ['ceo', 'design', 'eng'] })).toEqual(['ceo', 'design', 'eng']);
|
||||
});
|
||||
|
||||
test('a cut whose words changed, a renamed command included, is asked again; an unchanged cut carries its answer', () => {
|
||||
const dir = path.join(r.host.base, `cuts${++n}`);
|
||||
const out = path.join(dir, 'run');
|
||||
expect(r.ap(['next', '--out', out, '--plan', writePlan(dir, plan('share')), '--no-ui', '--no-dx']).status).toBe(0);
|
||||
phaseVia(r, out, 'ceo', FLAG);
|
||||
expect(phaseVia(r, out, 'eng', NONE).outside.stdout).toMatch(/^GATE: gate_rev=1 /m);
|
||||
const cut1 = gateOf(out).items.find((i: any) => i.item_class === 'cut' && i.title.includes('share'));
|
||||
expect(cut1).toBeDefined();
|
||||
expect(answer(out, 1, 'rec', DO_IT).status).toBe(0);
|
||||
const rev = r.ap(['revise', '--out', out, '--plan', file(dir, plan('invite', ', behind RETRY_BACKOFF=1')), '--incorporates', pending(out)]);
|
||||
expect(rev.stdout).toMatch(/^REVISED: plan=\S+ reopened=ceo,eng$/m);
|
||||
phaseVia(r, out, 'ceo', NONE);
|
||||
const eng = phaseVia(r, out, 'eng', NONE).outside;
|
||||
const gate = gateOf(out);
|
||||
const cut2 = gate.items.find((i: any) => i.item_class === 'cut' && i.title.includes('invite'));
|
||||
expect(cut2.origin).not.toBe(cut1.origin);
|
||||
expect(cut2.carried).toBeUndefined();
|
||||
expect(gate.items.find((i: any) => i.item_class === 'cut' && i.title.includes('Android')).carried).toMatchObject({ chosen: 'a', gate_rev: 1 });
|
||||
expect(eng.stdout).toMatch(new RegExp(`^CARRY: no \\(new item ${cut2.id}: Cut: No \`invite\` command`, 'm'));
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user