mirror of
https://github.com/garrytan/gstack.git
synced 2026-12-02 04:43:59 +01:00
Stop false phone-number holds on /ship run ids and name interactive /autoplan runs (#4747)
Posting a PR body that lists earlier /ship runs no longer stops for a "phone number" that is really a run id, and an interactive /autoplan approval is imported under its own run id instead of `autoplan`. Every /ship that rewrote a body holding earlier runs waited for a confirmation (#4725; about 1 in 10 run ids also reads as a card number and still asks, fixed in a follow-up), and interactive /autoplan runs could not be cited by run id (#4402). Nothing to do after merge. Co-authored-by: thomsjack <325974127+thomsjack@users.noreply.github.com> Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> Review-Finding: p1/outside-voice#1 reader=outside-voice Review-Finding: p1/outside-voice#2 reader=outside-voice Review-Finding: p1/outside-voice#3 reader=outside-voice Review-Finding: p1/outside-voice#4 reader=outside-voice Review-Finding: p2/red-team#1 reader=red-team Review-Finding: p2/outside-voice#1 reader=outside-voice Review-Finding: p2/outside-voice#2 reader=outside-voice
This commit is contained in:
10 files changed
+254
-18
No files matched your search
+17
-3
@@ -577,7 +577,9 @@ const lineIdSpans = (text: string, line: number): Span[] => RECEIPT_LINE_IDS.fla
|
||||
* span of each value below. In every closed ```gstack-ship-receipt``` block whose JSON passes the receipt schema and is byte-identical to
|
||||
* renderReceiptBlock's rendering of it: each ci_carried[].run, flaky_exception[].runs[] and issues.flakes[].run value that is a run id (11 to 20
|
||||
* digits, with an optional /attempt), the run value when it is a gstack-skill-start session id, and the RECEIPT_LINE_IDS values inside the
|
||||
* pregate and requires_remote[] values. On every line outside a fenced code block that opens with a receipt-line prefix (RECEIPT_LINE), its RECEIPT_LINE_IDS values. Only
|
||||
* pregate and requires_remote[] values. In every closed ```gstack-receipt-runs``` block that opens outside any other fence (gstack#4725), the top-level run value of each line that is a
|
||||
* JSON object byte-identical to its JSON.stringify rendering, with a 40-hex head and a run that is a gstack-skill-start session id. On every line
|
||||
* outside a fenced code block that opens with a receipt-line prefix (RECEIPT_LINE), its RECEIPT_LINE_IDS values. Only
|
||||
* those writers' own output qualifies, so a hand-written, schema-invalid, malformed or unclosed block exempts nothing, and the same number in
|
||||
* prose, in any other code block (a receipt-prefixed line inside one included), on a line without a receipt prefix or under any other key still reports.
|
||||
*/
|
||||
@@ -585,10 +587,11 @@ function receiptIdSpans(text: string): Span[] {
|
||||
const lines = text.split("\n");
|
||||
const rows = (v: unknown): number => v !== null && typeof v === "object" && Object.keys(v).length ? 2 + Object.values(v).reduce((n: number, c) => n + rows(c), 0) : 1;
|
||||
let fence = "";
|
||||
const blocks: Array<{ open: number; close: number }> = [];
|
||||
const spans: Span[] = lines.flatMap((l, i) => {
|
||||
const f = /^ {0,3}(`{3,}|~{3,})(.*)$/.exec(l);
|
||||
if (f && !fence) { fence = f[1]!; return []; }
|
||||
if (f && f[1]![0] === fence[0] && f[1]!.length >= fence.length && !f[2]!.trim()) { fence = ""; return []; }
|
||||
if (f && !fence) { fence = f[1]!; blocks.push({ open: i, close: -1 }); return []; }
|
||||
if (f && f[1]![0] === fence[0] && f[1]!.length >= fence.length && !f[2]!.trim()) { fence = ""; blocks.at(-1)!.close = i; return []; }
|
||||
return !fence && RECEIPT_LINE.test(l) ? lineIdSpans(l, i + 1) : [];
|
||||
});
|
||||
for (let open = 0; open < lines.length; open++) {
|
||||
@@ -626,6 +629,17 @@ function receiptIdSpans(text: string): Span[] {
|
||||
receipt.issues?.flakes?.forEach((_, i) => span(["issues", "flakes", i, "run"]));
|
||||
open = close;
|
||||
}
|
||||
for (const { open, close } of blocks) {
|
||||
if (close < 0 || lines[open] !== "```" + RUNS_FENCE) continue;
|
||||
for (let i = open + 1; i < close; i++) {
|
||||
let entry: Record<string, unknown>;
|
||||
try { entry = JSON.parse(lines[i]!); if (entry === null || typeof entry !== "object" || Array.isArray(entry) || JSON.stringify(entry) !== lines[i]) continue; } catch { continue; }
|
||||
if (typeof entry.head !== "string" || !/^[0-9a-f]{40}$/.test(entry.head) || typeof entry.run !== "string" || !SESSION_ID.test(entry.run)) continue;
|
||||
const before = Object.keys(entry).slice(0, Object.keys(entry).indexOf("run"));
|
||||
const from = JSON.stringify(Object.fromEntries(before.map(k => [k, entry[k]]))).length + (before.length ? 1 : 0) + '"run":'.length;
|
||||
spans.push({ line: i + 1, from, to: from + JSON.stringify(entry.run).length - 1 });
|
||||
}
|
||||
}
|
||||
return spans;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user