Skip to content

refactor(pr-unblock): dedupe repeated logic in gate-source, limit-stop and publish-feedback - #14283

Merged
melodic-automation-lanes[bot] merged 1 commit into
mainfrom
work-resolve-issue/issue-14136-42535204287-1
Nov 9, 2026
Merged

melodic-automation-lanes[bot] merged 1 commit into
mainfrom
work-resolve-issue/issue-14136-42535204287-1

Conversation

@melodic-automation-lanes

@melodic-automation-lanes melodic-automation-lanes Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Closes #14136

Summary

Opened by the work-resolve-issue lane. The run's own summary:

Replaced code repeated within each pr-unblock script with one named helper per pattern. Every output, exit code, written file, printed message, export and flag stays the same. gate-source.mjs: gateSource and sharedCopyGate now share their opening (label history, open hold, last-adder check) through one labelGate helper. Hand-inlined timestamp checks now call writtenSince/writtenAt/lastWrite, and the escalation-comment test and lanes-App comment filter are each written once. limit-stop.mjs: the three completed-neutral-titled run checks share one predicate. publish-feedback.mjs: one helper splits evidence path:line entries and one checks recorded SHA-256 values, and redundant assignments made just before a return are gone. Choice: install-script-pin.mjs, lane-hold.mjs and read-pr-head.bash are left unchanged. A review of each through the four /simplify checks found no repetition or simplification worth the diff. Removing the bare block that wraps postReplies' body would re-indent about 170 lines for no behavior gain, so it was not done. Net line counts rose slightly (+20 over three files) because each new helper carries its own definition and comment. The repeated expressions are gone.

Not verified

  • node test suites (gate-source.test.mjs, limit-stop.test.mjs, publish-feedback.test.mjs and their callers' tests) were not executed: this lane runs no interpreter. Left to the PR's CI.
  • ci-status green on the PR: a PR CI check, left to the PR's CI
  • tidy skipped: the change sits under .github/, a listed shared path for the tidy cutoffs
  • lint/build of the touched .mjs files beyond check-affected: no JS linter runs in this lane; left to the PR's CI

Fix

  • .github/scripts/pr-unblock/gate-source.mjs: moved writtenAt up and rewrote writtenSince on top of it. Added module-level result, isEscalation and lanesAppComments helpers plus a labelGate helper shared by gateSource and sharedCopyGate. Replaced the inline !(writtenAt(x) < lifted)/Math.max…
  • .github/scripts/pr-unblock/limit-stop.mjs: added a neutralTitled predicate used by heldSkip, headLagStop and killSwitchStop.
  • .github/scripts/pr-unblock/publish-feedback.mjs: added citation (path:line split) and matchesSha256 helpers used for evidence parsing and the run/replies/adjudication hash checks. Returned the escalation reason directly in three early returns.

Verification

The runner ran each check from the base copy against 9b58323:

  • scripts/check-changelog-fragments.sh --check: passed
  • scripts/check-changed-skills.sh --merge-base: passed

The run reports:

  • check-changelog-fragments: all 10 fragments valid; .github scripts belong to no plugin, so no fragment is owed
  • check-changed-skills: no changed skills, nothing to gate
  • check-affected: 8 passed, 8 skipped over 3 changed files
  • fresh-context review subagent (read-only) compared every hunk for behavior equivalence (NaN in Date.parse/Math.max, null inputs, the one added optional chain in heldSkip, destructuring moved into labelGate, TDZ, shadowing) and found no behavior differences. It also confirmed that the source-text…
  • diff size: 3 files, 115 changed lines (63 added, 52 removed), within the issue's 400-line / 15-file cap
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/42535204287

Left out: the items under Not verified.

Related

#14136

Merge-Risk: max=HIGH demote=true head=9b5832325f4ec2d0865cd6eae9fc66bff1f60ec4 rubric=8.1.2 rater=claude-opus-5-5 checker=claude-opus-5-5

Lane-Activity: work-resolve-issue/resolve-issue
@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 9b5832325f4ec2d0865cd6eae9fc66bff1f60ec4: read 3 of 3 changed file(s); 0 finding(s), 0 as inline comments.

Security review: PR #14283 (refactor of pr-unblock gate-source, limit-stop and publish-feedback)

No security issues found.

All three changed files are trusted paths. gate-source.mjs decides which source a human-gated label came from (review-lane hold, signed-commits hold, credential hold, lane escalation, shared-copy refusal), and pr-merge's hold modules import it. I read every hunk and compared each refactor to the base code to check whether any hold or gate got weaker.

gate-source.mjs

  • writtenSince is now !(writtenAt(item) < since). The old form was !(c < since) || !(u < since). Both are true when either time is NaN, and both equal max(c,u) >= since when the times parse. The updated_at ?? created_at fallback is unchanged, and unparsable times still count as since, so it still fails closed.
  • openReviewHold, openActionsHold and openHold's unparsable check now call writtenSince. Each new call does the same test as the inline expression it replaces.
  • labelGate reproduces the shared opening of gateSource and sharedCopyGate: labelHistory with the caller's trusted, then openHold, then the last-adder / NaN-since check. since is only returned on the path where it is a non-NaN number. After the gate, gateSource no longer uses head or trusted, and sharedCopyGate still destructures head for its at head match (
    const { timeline, label, head, isLanesApp } = args;
    ).
  • isEscalation, lanesAppComments and the module-level result are exact copies of the inline code they replace. ESCALATION and RESUME_KEY are read only when the function is called, so moving them earlier in the module causes no load-order error.
  • reviewEntries now uses lastWrite, which computes the same Math.max(Date.parse(created_at), Date.parse(updated_at)) (
    const lastWrite = (item) => Math.max(Date.parse(item.created_at), Date.parse(item.updated_at));
    ). A person's comment or review since the label went on still blocks laneEscalationAllows.

limit-stop.mjs

  • neutralTitled gives the same test for all three predicates. The only difference is that heldSkip now uses optional chaining (run?.status), so a null run returns false instead of throwing. A null entry is not a real check run, so this widens nothing.

publish-feedback.mjs

  • matchesSha256 keeps the 64-hex format check and the digest comparison for run.json, replies.jsonl and the adjudication file. A missing or malformed recorded hash still fails.
  • citation splits on the last : exactly as before.
  • In postReplies, the removed escalationReason = … assignments came just before returns that now return the same value directly. Nothing reads the local after those returns (no finally, and only the later loop and settleDisputes use it), so the reported escalation reasons are unchanged.

No trust control is widened. No hold is weakened, and the review-lane, signed-commits and credential holds and the lane-escalation checks all behave as before. No token, secret or untrusted-text path changes.

Not done: no tests were run, since this lane has no interpreter. The PR context file contains no embedded instructions aimed at this lane.

critical-findings: 0

@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

claude-review reviewed 9b5832325f4ec2d0865cd6eae9fc66bff1f60ec4: read 3 of 3 changed file(s); 0 finding(s), 0 as inline comments.

Code review: no findings

I read every hunk of all 3 changed files and checked each one against the code it replaces. Every rewrite behaves the same as before, including when a timestamp doesn't parse or a value is missing.

gate-source.mjs

  • The new writtenSince returns !(max(c,u) < since) where the old one returned !(c<since) || !(u<since). They agree when both times parse. They also agree when either time doesn't parse: Math.max then gives NaN and !(NaN < x) is true, which is what the old || gave. So openReviewHold, openActionsHold and the unparsable check in openHold behave as they did.
  • reviewEntries now calls lastWrite. At gate-source.mjs#L332, lastWrite uses Date.parse(item.updated_at) with no ?? created_at fallback, the same as the old inline expression. A missing updated_at still gives NaN, which personSince counts as since.
  • labelGate keeps the order gateSource and sharedCopyGate had: open hold first, then the last-adder check, then since. The default for trusted still applies when it is undefined. gateSource no longer uses head after the shared step, and sharedCopyGate still destructures head for its own checks. Moving result to module level shadows no other name.
  • isEscalation and lanesAppComments are exact copies of the expressions they replace.

limit-stop.mjs

  • neutralTitled adds one optional chain (run?.status) to heldSkip. Its only caller, released, also passes the same run to killSwitchStop, which already used run?., so no reachable input changes what it returns.

publish-feedback.mjs

  • citation and matchesSha256 are the same expressions as before. matchesSha256 treats an invalid recorded value the same way the three inline checks did.
  • The three early returns now return the reason directly instead of assigning it to escalationReason first. postReplies has no finally block that reads the local variable, so these returns behave the same.
  • The source-text test at publish-feedback.test.mjs:1921 reads "feedback-*" string literals. All of them are still in the file.

Closing issue #14136, acceptance criteria

  • Behavior is unchanged, and names, flags and exports are kept: met, by the line-by-line comparison above. The existing gate-source, limit-stop and publish-feedback test suites would fail if it broke. I did not run them, because this lane has no interpreter.
  • The diff edits only the listed files: met. It touches 3 of the 6 listed files and nothing else.
  • Size cap: met. The diff is 3 files with 63 lines added and 52 removed, well under 400 lines and 15 files.
  • ci-status is green: not judged here. It is left to the PR's CI.

The test runs and the fresh-context equivalence review described in the PR body are the author's claims; I have not verified them. There are no prior findings and no settled threads, and this is the lane's first review of this PR.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Unattended merge: native auto-merge leaves this pull request unarmed at head 9b5832325f4ec2d0865cd6eae9fc66bff1f60ec4. The lanes clear this reason on their own; the next scheduled run judges it again.

pr-merge's gate refuses its verifier verdict (verify:missing)

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The unattended merge path armed native auto-merge at head 9b5832325f4ec2d0865cd6eae9fc66bff1f60ec4, the head its arming checks judged.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Verification evidence for 9b58323

The verifier passed this head. The capture artifact holds the capture summary, which says whether the capture ran, and any screenshot or video that passed the mask check; this comment uploads no file.

Capture artifact: pr-capture-14283-9b5832325f4ec2d0865cd6eae9fc66bff1f60ec4, expires on 2026-12-08.

One comment per pull request, updated in place for each new head.

@melodic-automation-lanes
melodic-automation-lanes Bot added this pull request to the merge queue Nov 9, 2026
Merged via the queue into main with commit afb1eea Nov 9, 2026
66 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14136-42535204287-1 branch November 9, 2026 00:56
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The post-merge check verified merge commit afb1eeab309f553a15351fbde2d818e9fb6b5501; later checks count it verified from this comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Simplify the pr-unblock .github script (5 of 6)

0 participants