Skip to content

fix(post): stop flagging ship run ids in history blocks as phone numbers (#4725) - #4729

Closed
thomsjack wants to merge 1 commit into
garrytan:mainfrom
thomsjack:fix/4725-exempt-receipt-runs-session-id
Closed

thomsjack wants to merge 1 commit into
garrytan:mainfrom
thomsjack:fix/4725-exempt-receipt-runs-session-id

Conversation

@thomsjack

Copy link
Copy Markdown
Contributor

Why (in your own words)

When /ship updates a PR body that carries prior run history, gstack-post exempts the <pid>-<10-digit-epoch>-<hex> session id inside the closed gstack-ship-receipt block from pii.phone.e164, but receiptIdSpans() in lib/gstack-post.ts did not inspect the adjacent gstack-receipt-runs block. As a result, gstack-post falsely held the post with exit 2 (RULE: pii.phone.e164) on the tool-written "run" value in gstack-receipt-runs.

This change extends receiptIdSpans() to exempt only the exact column span of the top-level "run" value when it matches SESSION_ID inside a closed gstack-receipt-runs block whose line is canonical single-line JSON (JSON.stringify(entry) === raw) with a non-empty string head. Real phone numbers in any other field on the same line, a phone or truncated id in "run", non-canonical JSON, lines missing head, and unclosed blocks still trigger pii.phone.e164.

Live evidence

Before fix (from test/gstack-post.test.ts reproducing #4725):

RULE: pii.phone.e164 LINE: 4 PART: body
EXIT=2

After fix (running bin/gstack-post pr-comment 1 --repo-visibility private --body-file body.md in a scratch repo with an unreachable GitHub origin):

REPO_VISIBILITY: private
gstack-post: gh failed (exit 1); nothing more was sent.
GraphQL: Could not resolve to a Repository with the name 'example/unreachable-repo'. (repository)
EXIT=3

Typecheck and unit tests:

$ bun run typecheck
$ tsc -p tsconfig.json
$ bun run typecheck:test
test typecheck ratchet: 812 known diagnostics, none new.
$ bun test test/gstack-post.test.ts test/ship-receipt-runs.test.ts test/pr-review-history.test.ts
 85 pass
 0 fail
 637 expect() calls

Scope

  • Changed: lib/gstack-post.ts (handle closed gstack-receipt-runs blocks in receiptIdSpans), test/gstack-post.test.ts (positive and negative regression tests for gstack-receipt-runs session ids).
  • Verified live by: Reproducing the exact gstack-post holds the PR body on the receipt's own run id in the gstack-receipt-runs fence (pii.phone.e164) #4725 gstack-post pr-comment CLI scenario in a scratch git repo and running bun run typecheck, bun run typecheck:test, and 85 tests across test/gstack-post.test.ts, test/ship-receipt-runs.test.ts, and test/pr-review-history.test.ts.
  • Did NOT test: Live gh write against a real GitHub PR (verified up to the gh invocation boundary).

Checklist

@trunk-io

trunk-io Bot commented Nov 23, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@capy-ai

capy-ai Bot commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Thank you, and for the negative cases in the test (a phone number in another field, a truncated id, non-canonical JSON, an unclosed block). I reproduced #4725 on current main (c4cfe6d): gstack-post holds the post on pii.phone.e164 at the run value inside gstack-receipt-runs.

We're taking the fix. Because it adds an exemption to the privacy scanner, we'll rebuild it on current main with a security read instead of taking the branch directly, keeping your approach and crediting you as co-author (tracking thread GSTA-36). We'll link the change here and close this PR when it lands.

@capy-ai capy-ai Bot added the S3 Severity 3: everything else label Nov 23, 2026
@capy-ai

capy-ai Bot commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Thanks, @thomsjack. I'm taking ownership: I'll rebuild this on current main with you credited as co-author, bundled with #4402's run-id change, and I'll comment here when it lands.

@capy-ai

capy-ai Bot commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Thanks, @thomsjack. Your idea (skip /ship's run ids in the earlier-runs block for the phone check) was rebuilt on current main in #4747 (0d6cc1b) with you credited as co-author, plus negative controls so real phone numbers in that block are still caught. Closing this one in favor of #4747.

@capy-ai capy-ai Bot closed this Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S3 Severity 3: everything else

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gstack-post holds the PR body on the receipt's own run id in the gstack-receipt-runs fence (pii.phone.e164)

1 participant