/ship's state-machine check accepts the header lines its reader is told to write (GST-3115) (#4504)

The state-machine check in /ship no longer stops a review because its
reader opened the reply with the `REVIEWED_TREE` and `REVIEW_VERDICT`
lines its instructions require.

Why: on yc-software/qm#3728 the check reported those two lines as gaps,
so /ship stopped before its adversarial review step.

Nothing to do after merge.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
Garry Tanandcapy-ai[bot] authored and GitHub committed 2026-11-18 22:33:08 +00:00
1 parent 2f57b07495
commit 43026970b7
3 files changed
+42 -2

No files matched your search

@@ -0,0 +1,4 @@
---
important: blocker
---
- **/ship no longer stops a review because the state-machine reader started its reply the way its instructions say.** Every /ship reader is told to open its reply with a `REVIEWED_TREE: <tree> <path>` line and, for readers that can block, a `REVIEW_VERDICT: blocking=<n>` line under it. The state-machine check read those two lines as unexplained text and reported the review as incomplete (`STATE_MATRIX_CHECK: incomplete gaps=2`), which stopped /ship before the adversarial review step on any change that touches a proposal, hold or approval flow. The check now skips exactly those two lines at the top of the reply, using the same parsers /ship's collector uses, so the two can't drift apart. Any other line that isn't a matrix record or a finding, including a misplaced or malformed header line, is still reported as a gap.
+9 -2
View File
@@ -20,6 +20,8 @@
*/
import * as fs from 'node:fs';
import * as path from 'node:path';
import { isReviewedTreeLine } from './review-brief';
import { parseVerdict } from './review-verdict';
const SUBJECT = new Set(['proposal', 'proposals', 'propose', 'proposed', 'hold', 'holds', 'held', 'approval', 'approvals', 'pending']);
const ACTION = new Set(['accept', 'accepted', 'accepts', 'approve', 'approved', 'approves', 'drop', 'dropped', 'drops', 'reject', 'rejected', 'rejects', 'deny', 'denied', 'dismiss', 'dismissed', 'withdraw', 'withdrawn', 'release', 'released']);
@@ -55,12 +57,17 @@ export interface Expectation { kinds: string[]; actions: string[]; untested: Arr
export interface Gap { code: string; cell?: string; detail: string }
export interface MatrixCheck { machines: Array<{ machine: string; kinds: number; actions: number; cells: number; tested: number; untested: number; reported: number }>; gaps: Gap[]; findings: number; noFindings: boolean }
/** Matrix records, findings and whether the output is the literal `NO FINDINGS`; unparseable lines are gaps. */
/**
* Matrix records, findings and whether the output is the literal `NO FINDINGS`; unparseable lines are gaps. The header a
* dispatched reader's brief requires (lib/review-brief.ts workspaceStep: a `REVIEWED_TREE` first line, then a well-formed
* `REVIEW_VERDICT` line) is read by the same parsers collect uses and skipped; anywhere else such a line is a gap.
*/
export function parseSpecialistOutput(text: string): { matrices: Matrix[]; findings: MatrixFinding[]; noFindings: boolean; gaps: Gap[] } {
const matrices: Matrix[] = [];
const findings: MatrixFinding[] = [];
const gaps: Gap[] = [];
const lines = text.split('\n').map(l => l.trim()).filter(Boolean);
let lines = text.split('\n').map(l => l.trim()).filter(Boolean);
if (lines[0] !== undefined && isReviewedTreeLine(lines[0])) lines = lines.slice(lines[1] !== undefined && parseVerdict(lines[1]).state === 'valid' ? 2 : 1);
const noFindings = lines.length === 1 && lines[0] === 'NO FINDINGS';
if (noFindings) return { matrices, findings, noFindings, gaps };
for (const line of lines) {
+29
View File
@@ -17,6 +17,7 @@ import * as fs from 'node:fs';
import * as os from 'node:os';
import * as path from 'node:path';
import { EXIT } from '../lib/headless-artifacts';
import { VERDICT_ASK, workspaceStep } from '../lib/review-brief';
import { checkStateMatrix, detectStateMachine, words } from '../lib/state-matrix';
import { makeStateMatrixRepo, STATE_MATRIX_FIXTURE, type StateMatrixRepo } from './helpers/state-matrix-fixture';
@@ -143,6 +144,34 @@ describe('gstack-state-matrix check on the captured #6792 review', () => {
expect(checkStateMatrix('NO FINDINGS\n', r.work, EXPECT).gaps.map(g => g.code)).toEqual(['no-matrix']);
expect(checkStateMatrix('Here is my review:\n' + CAPTURED, r.work, EXPECT).gaps.map(g => g.code)).toEqual(['unparsed-line']);
});
/** The two header lines a /ship reader's brief asks for, made the way the brief says: its fingerprint command run in the checkout, then its verdict line with n=0. */
function briefHeader(dir: string): string {
const command = /run `([^`]+)`/.exec(workspaceStep(dir, true))![1]!;
const tree = spawnSync('bash', ['-c', command], { encoding: 'utf8', timeout: 30_000 });
expect(tree.status, tree.stderr).toBe(0);
const verdict = /`(REVIEW_VERDICT: blocking=)<n>`/.exec(VERDICT_ASK)![1]! + '0';
return `${tree.stdout.trim()}\n${verdict}\n`;
}
// Value: protects=a /ship state-machines reader that follows its brief is checked on its matrix, not stopped as incomplete; fails_when=the REVIEWED_TREE or REVIEW_VERDICT header the brief requires is read as an unparsed-line gap (CAPY-1 on yc-software/qm#3728), or any other prose line stops being one.
test('a reply that opens with the REVIEWED_TREE and REVIEW_VERDICT lines its brief requires is complete; other prose is still a gap', () => {
const r = repos[0] ?? repo();
const header = briefHeader(r.work);
const c = run(r.work, ['check', '-', '--expect', path.join(STATE_MATRIX_FIXTURE, 'expect.json')], header + CAPTURED);
expect(c.status, c.out + c.err).toBe(EXIT.ok);
expect(c.out).toMatch(/^STATE_MATRIX_CHECK: ok machines=1$/m);
expect(c.out).not.toContain('STATE_MATRIX_GAP');
expect(run(r.work, ['check', '-'], header + 'NO FINDINGS\n').out).toBe('STATE_MATRIX_CHECK: ok machines=0\n');
expect(checkStateMatrix(header.split('\n')[0] + '\n' + CAPTURED, r.work, EXPECT).gaps).toEqual([]);
const gaps = (text: string) => checkStateMatrix(text, r.work, EXPECT).gaps.map(g => `${g.code}: ${g.detail}`);
expect(gaps(header + 'Here is my review:\n' + CAPTURED)).toEqual(['unparsed-line: Here is my review:']);
expect(gaps(header + CAPTURED + header)).toEqual(header.trim().split('\n').map(l => `unparsed-line: ${l}`));
expect(gaps(header.replace('blocking=0', 'blocking=none') + CAPTURED)).toEqual(['unparsed-line: REVIEW_VERDICT: blocking=none']);
const [tree, verdict] = header.trim().split('\n');
expect(gaps(`${verdict}\n${tree}\n` + CAPTURED)).toEqual([verdict, tree].map(l => `unparsed-line: ${l}`));
});
});
describe('gstack-specialist-stats', () => {