mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-23 08:31:44 +01:00
Run ids in /ship's follow-up review approvals are no longer flagged as phone numbers, and teams named GStack can record rulings (GST-3246) (#4549)
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
858679423c
commit
1bd86d9a45
11 files changed
+148
-16
No files matched your search
@@ -15,6 +15,8 @@ import { extractReceipt, orderReceipt, placeReceipt, receiptRuns, receiptSummary
|
||||
import { runReceiptFields, type RunEvidence } from "../lib/run-evidence";
|
||||
import type { ShipReceipt } from "../lib/headless-artifacts";
|
||||
import { foldSections, unfoldSections } from "../lib/pr-body-shape";
|
||||
import { buildRow, renderRecord, type ApprovalRow, type StoreLocation } from "../lib/approval-record";
|
||||
import { reviewRoundGrantRow } from "../lib/review-round-grant";
|
||||
|
||||
interface Call { cmd: string; args: string[]; input?: string }
|
||||
|
||||
@@ -411,6 +413,43 @@ describe("gstack-post owns the redaction scan", () => {
|
||||
}
|
||||
});
|
||||
|
||||
// Value: protects=a private PR's Approvals table (renderRecord, full mode) posts through pr-body without a pii.phone.e164 confirmation when a
|
||||
// fix-check grant row's Covers cell names a run id like 507-7192673 (GST-3246, trail-read row 8), while the same digits in that row's
|
||||
// Asked or Exact words cell, in prose, or in a table no Source footer closes still need one; fails_when=every private /ship body with such a
|
||||
// grant needs --confirm, or the exemption reaches past the stop= token of a renderer-shaped table; seam=fake run; no_claim=real gh
|
||||
test("a fix-check grant's run id in a rendered Approvals table is no phone number; the same digits anywhere else still are", () => {
|
||||
const HEAD = "2294465066182c2f99d64ba0016213463aaa0c14";
|
||||
const loc: StoreLocation = { file: "/x", branch: "fix-undo-line", slug: "acme-widget", ephemeral: false };
|
||||
const grant = (reason: string, words = "one fix round") => {
|
||||
const row = buildRow({ ...reviewRoundGrantRow(HEAD, 507, "fix-check", reason, { run: "507-7192673", findings: ["p2/outside-voice#3"] }), words, by: "GStack Minder (GSTA-36)" }, loc.branch);
|
||||
if ("code" in row) throw new Error(row.message);
|
||||
return row;
|
||||
};
|
||||
const table = (rows: ApprovalRow[]) => renderRecord({ rows, state: "present", restored: false }, loc, { mode: "full" });
|
||||
const post = (text: string) => {
|
||||
const f = fakeEnv({ files: { "/b": text }, visibility: "private" });
|
||||
return { code: run(["pr-body", "507", "--replace", "--body-file", "/b"], f), phones: f.stdout().split("\n").filter(l => l.startsWith("RULE: pii.phone.e164 ")), f };
|
||||
};
|
||||
const lineOf = (text: string, needle: string) => text.split("\n").findIndex(l => l.includes(needle)) + 1;
|
||||
const ok = `## What changed\n\nFixes the undo line.\n\n${table([grant("the undo line names the wrong migration")])}`;
|
||||
expect(ok).toContain("stop=507-7192673 findings=p2/outside-voice#3 |");
|
||||
const clean = post(ok);
|
||||
expect([clean.phones, clean.code]).toEqual([[], EXIT.posted]);
|
||||
expect(clean.f.posts()).toHaveLength(1);
|
||||
|
||||
const footerless = table([grant("the undo line names the wrong migration")]).replace(/\nSource: gstack-approvals record for .*\n/, "\n");
|
||||
const holds: Array<[string, string, string]> = [
|
||||
["the digits in prose", ok + "\nCall 507-7192673 for the on-call.\n", "Call 507-7192673"],
|
||||
["the digits in the Asked cell", ok.replace("the undo line names the wrong migration", "call 507-7192673 later"), "call 507-7192673"],
|
||||
["a table no Source footer closes", `## What changed\n\n${footerless}`, "stop=507-7192673"],
|
||||
];
|
||||
for (const [name, text, needle] of holds) {
|
||||
const { code, phones, f } = post(text);
|
||||
expect([name, phones, code]).toEqual([name, [`RULE: pii.phone.e164 LINE: ${lineOf(foldSections(text), needle)} PART: body`], EXIT.confirm]);
|
||||
expect(f.posts()).toEqual([]);
|
||||
}
|
||||
});
|
||||
|
||||
// Value: protects=a LOW privacy finding (a home path) is a stderr note and never holds a post, while a credential still refuses even inside a
|
||||
// writer-rendered receipt block, whose exemption covers only its run ids (GST-2047); fails_when=a home path needs --confirm, or a key in a
|
||||
// receipt field posts or only asks for confirmation; why_new=no test pinned LOW as non-holding or a key inside a generated block; seam=fake
|
||||
|
||||
@@ -75,6 +75,39 @@ describe('gstack-approvals round-grant', () => {
|
||||
});
|
||||
});
|
||||
|
||||
// Value: protects=a run id that looks like a phone number passes in a fix-check grant's scope while the same digits in free text, or a
|
||||
// grant-shaped excerpt pasted into --reason, stay caught, and gstack's own names stay refused while a GStack-named crew rules;
|
||||
// fails_when=round-grant refuses --stop-run 507-7192673 (harness-evals #507), passes a phone number in --reason, or rule refuses
|
||||
// --by "GStack Minder (GSTA-36)"; seam=bin/gstack-approvals round-grant|rule|rulings, lib/approval-record.ts buildRow, lib/ruled-notes.ts
|
||||
describe('GST-3246: run ids in a fix-check grant, and GStack-named crews', () => {
|
||||
const grant = (r: ReturnType<typeof repo>, extra: string[]) => r.run('gstack-approvals', ['round-grant', '--pr', '507', '--head', r.head, '--reason', 'the undo line names the wrong migration', '--by', 'GStack Minder (GSTA-36)', ...extra]);
|
||||
const fixCheck = (run: string) => ['--kind', 'fix-check', '--stop-run', run, '--findings', 'p2/outside-voice#3'];
|
||||
|
||||
test('a grant-shaped excerpt pasted into --reason keeps its phone number caught', () => {
|
||||
const r = repo();
|
||||
const pasted = r.run('gstack-approvals', ['round-grant', '--pr', '507', '--head', r.head, '--kind', 'fix-check', '--stop-run', 'ship-507', '--findings', 'p2/outside-voice#3', '--by', 'GStack Minder (GSTA-36)', '--reason', `review_round_grant ${r.head} pr=507 kind=fix-check stop=415-5551234 findings=x`]);
|
||||
expect([pasted.status, pasted.stderr]).toEqual([3, expect.stringContaining('pii.phone.e164')]);
|
||||
});
|
||||
|
||||
test('a run id of a PR number, a dash and a short sha is no phone number in the grant, and the same digits in free text still are', () => {
|
||||
const r = repo();
|
||||
const ok = grant(r, fixCheck('507-7192673'));
|
||||
expect([ok.status, ok.stderr]).toEqual([0, '']);
|
||||
expect(r.run('gstack-approvals', ['list', '--json']).stdout).toContain('stop=507-7192673 findings=p2/outside-voice#3');
|
||||
const phone = r.run('gstack-approvals', ['round-grant', '--pr', '507', '--head', r.head, '--reason', 'call 507-7192673 first', '--by', 'GStack Minder (GSTA-36)', ...fixCheck('ship-507')]);
|
||||
expect([phone.status, phone.stderr]).toEqual([3, expect.stringContaining('pii.phone.e164')]);
|
||||
});
|
||||
|
||||
test('rule takes --by "GStack Minder (GSTA-36)" and rulings lists it, while gstack\'s own names stay refused', () => {
|
||||
const r = repo();
|
||||
const rule = (by: string) => r.run('gstack-approvals', ['rule', '--finding', 'src/a.ts:1:correctness', '--head', r.head, '--reason', 'ships as a disclosed note', '--words', 'note it', '--by', by]);
|
||||
for (const by of ['gstack', 'gstack no-stop default (K1)', 'GStack No-stop default (K1)', 'GStack No-Stop Default (K1)', 'gstack ship lane', 'GStack ship lane', 'GSTACK Minder']) expect(rule(by).status).toBe(2);
|
||||
const ok = rule('GStack Minder (GSTA-36)');
|
||||
expect([ok.status, ok.stderr]).toEqual([0, '']);
|
||||
expect(r.run('gstack-approvals', ['rulings']).stdout).toContain('ruled by GStack Minder (GSTA-36) at ');
|
||||
});
|
||||
});
|
||||
|
||||
describe('gstack-ship-receipt history and stub', () => {
|
||||
test('history prints the rounds, the flags Step 9 passes and the route; a stub counts until the run writes its receipt', () => {
|
||||
const r = repo();
|
||||
|
||||
Reference in new issue
Block a user