fix(framework): pr-review.sh -r/--repo + -H/--host overrides + UA + repo preflight (Patches 5/5c) #896
Reference in New Issue
Block a user
Delete Branch "feat/pr-review-5-family"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Upstreams the
pr-review.shpatch family 5 + 5b + 5c + 5d from the host-localtooling-patches kit into the framework, against a fresh clone of origin/main
(not the stale
/src/mosaic-stackcheckout).Per the reproduce-first-or-halt discipline: two of the four named sub-changes
(5b, 5d) did not reproduce against baseline — the current framework
pr-review.shalready implements a more robust fix for each, landedindependently of the host-local kit. Those two are HALTed (not ported) to
avoid regressing already-shipped hardening. Only 5 and 5c genuinely
reproduced and are included.
Patch 5 —
-r/--repooverride +User-Agent: mosaic-pr-reviewheaderReproduced against baseline: neither flag existed —
./pr-review.sh -n 1 -a comment -c x -r foo/barfailed withUnknown option: -r;grep -c User-Agent pr-review.shwas0.Change:
-r/--repo <owner/repo>— explicit slug override, skipping git-remote sluginference. Mirrors the already-established
-rconvention of the siblingwrappers (
pr-view.sh,pr-diff.sh,pr-ci-wait.sh; #867), rather thanreinventing a parallel scheme.
detect_platformis now tolerant of amissing/foreign git origin when
-ris given (assumes gitea), matching thesame sibling-wrapper convention — otherwise
-rcouldn't achieve its statedpurpose (reviewer worktrees with a nonstandard/missing origin).
User-Agent: mosaic-pr-reviewadded to every Gitea curl call in the file(comment write, comment read-back,
/useridentity read, PR-head read,review submit, review read-back, and the new preflight) — some
Cloudflare-fronted Gitea hosts intermittently reject curl's default UA.
Patch 5c —
-H/--hostoverride + repo-exists preflightReproduced against baseline:
./pr-review.sh -n 1 -a comment -c x -H example.testfailed with
Unknown option: -H.Change:
-H/--host <host>— explicit Gitea host override, skipping remote-hostinference, so ambient CWD/remote state can't cross-wire a review to the
wrong instance.
-ris used,GET .../repos/<slug>runsbefore any write. A wrong-host cross-wire now surfaces as a clear
preflight error instead of an opaque write-404 with no residue.
Patch 5b — HALTED (does not reproduce; already superseded)
Named bug: readback verification asserts on
issue_urland fails when Giteareturns it empty on PR comments.
This does not reproduce against baseline. The current
gitea_create_comment_verified()doesn't assert onissue_urlat all — itkeys off
pull_request_urlwith full origin + path pinning (scheme, host,port, and the entire path, not a bare
endswithsuffix check), explicitlyrejecting a bare
issue_urlfor a claimed PR comment (see the inlinerationale and
test-pr-review-gitea-comment.shcase 17,comment-plain-issue), and already case-folds a mixed-case repo slug in thatsame comparison (case 15b,
comment-mixed-case-slug,#875). This is astrictly stronger fix than the "fall back to
html_url" patch described in thesource kit — porting the kit's simpler fallback verbatim would have weakened
an already-hardened, already-tested verification path. Not ported.
Patch 5d — HALTED (does not reproduce; already superseded)
Named bug:
tea approve/rejectpath used instead of REST-native/pulls/{n}/reviews.This does not reproduce against baseline.
grep -c 'tea pr' pr-review.shis
0— there is notea approve/tea rejectcall anywhere in the file.gitea_submit_review_verified()already POSTs to/pulls/{n}/reviewsandverifies the created review by its exact provider-returned id, with additional
hardening not present in the source kit's description: identity-bound
verification (author == acting identity), PR-head
commit_idpinning, exactsubmitted-body verification (catching Gitea's pending-review reuse/lost-body
edge cases), and a current-head TOCTOU close-out (re-reads the PR head after
verification and fails closed if it advanced). Already covered by 18 cases in
test-pr-review-gitea-comment.sh. Not ported.Verification
test-pr-review-gitea-comment.sh: passes, unchanged.test-pr-review-repo-host-override.sh(wired intopackages/mosaic'stest:framework-shell): covers flag parsing, help text,detect_platformtolerance with no git origin, override winning over awrong git-remote, the repo-exists preflight (pass + fail), and that every
curl call in a full run carries the
User-Agent: mosaic-pr-reviewheader.Red-first confirmed: fails against the pre-patch baseline file
(
Unknown option: -r), passes against the patched file.pnpm run test:framework-shellchain: all green (both pr-reviewtests + the rest of the wired suite).
shellcheckon both changed.shfiles: zero new findings (the solepre-existing SC1091 info-level note on the
sourceline is unchangedbesides its line number shifting).
grep -niE 'jason|woltje|jarvis'on changed files: 0 hits.packages/mosaic/framework/tools/quality/scripts/verify-sanitized.sh:passes (sanitization gate).
Discipline notes
origin/main(mosaicstack/stack), authoredas
mosaic-coder <coder@fleet.mosaicstack.dev>— not the stale/src/mosaic-stackcheckout.Part of #891
fix(framework): pr-review.sh repo/host overrides + UA + html_url readback fallback + REST-native reviews (Patches 5/5b/5c/5d)to fix(framework): pr-review.sh -r/--repo + -H/--host overrides + UA + repo preflight (Patches 5/5c)Record of Review — PR #896 (pr-review.sh Patches 5+5c; Part of #891) — POST-FIX, VERDICT APPROVE
VERDICT: APPROVE at CI-green head. Independent re-review after a REQUEST-CHANGES fix cycle.
Reviewer: independent subagent
a81636717(ms-lead-reviewer), fresh clone, reproduced from first principles — ≠ builder (a3c08f74, commit-authormosaic-coder).REVIEWED-HEAD:
dac9838b26e35c196c6442ffe90fd2d7157f4bd1(unmoved).The 3 REQUEST-CHANGES items — ALL FIXED + independently verified
host="${HOST_OVERRIDE:-$(get_remote_host 2>/dev/null || true)}". Reproduced from first principles with stub env in a TRUE no-origin dir: pre-fix (03e1cdb) all 3 actions died silent (exit1, zero output); post-fix all 3 emit a clear diagnostic (proceed to token lookup). Proved-H/HOST_OVERRIDE genuinely honored (trap-git stub: get_remote_host never called with -r+-H). Audited a 4th call site (line 298) — safe (set -e suspended in conditional function call). No remaining unguarded sites.mktemp -dunder /tmp + GIT_CEILING_DIRECTORIES + self-check; coverage extended to approve/request-changes with assert_not_silently_dead. Genuine RED-FIRST: old pr-review.sh + new test = FAIL (silent-death caught); fixed = PASS.Unchanged-good confirmed
tea pr=0; pull_request_url pinning present/unchanged. No regression to 5/5c.Gates + CI
test:framework-shellfull 19-step chain green; shellcheck 0 new; firewalljason|woltje|jarvis=0; verify-sanitized passed.dac9838b, ALL 8 steps success incltest(the #897-flaky recovery_b1 did NOT flake this run — clean unambiguous pass, not flake-masked).Part of #891(maps to (b)), commit-author mosaic-coder ≠ reviewer.GO for id-11 stamp + merge at FULL-40 head
dac9838b26e35c196c6442ffe90fd2d7157f4bd1. I relay; Mos stamps id-11 + merges. Non-executor.GO — Gate-16 id-11 stamp, pinned to exact FULL head
dac9838b26.Basis: verbatim RoR (comment 18796) — independent re-review APPROVE after a full REQUEST-CHANGES cycle in which the reviewer reproduced both the original silent-fail (pre-fix silent death in a true no-origin dir) and its cure (clear diagnostic; -H/HOST_OVERRIDE honored, no unguarded get_remote_host sites), verified the genuinely-isolated fixture with red-first, and confirmed the 5b/5d halt decisions remain intact (baseline REST-native path untouched, zero tea invocations). CI terminal-green (pipeline 2016, all 8 steps, clean test pass). Patches 5+5c upstream; 5b/5d closed OBE — the baseline exceeded the kit. Part of #891. Named executor: Mos (id-11), squash pinned.