paperclip-github-plugin 0.17.7 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -201,6 +201,7 @@ Additional behavior:
201
201
  - If the Paperclip host initially creates that imported maintainer issue in `backlog`, GitHub Sync promotes it to `todo` without replacing the configured default assignee with the executor handoff assignee, so triage ownership stays intact.
202
202
  - When Paperclip board access is connected for a company, the advanced assignee dropdowns list both company agents and `Me` for the connected board user.
203
203
  - Newly imported issues that finish sync in `todo` and are assigned to an agent enqueue an assignee wakeup so the agent can pick them up promptly.
204
+ - GitHub Sync will not repeatedly re-open a deliberately blocked issue. When it moves an issue out of `blocked` it records a hash of the linked pull requests' externally observable state (head SHA, CI state, mergeability, merge state status, review decision, unresolved review threads); while that state is unchanged, a later pass leaves `blocked` alone. This matters when a required check is red for something nobody in the company can clear — the contributor CLA gate is the common case, an upstream baseline failure or an unreleased dependency behave the same. Previously each sync pass moved the issue back to active work, the assignee woke, re-established that it was still externally blocked, and the loop repeated on the next pass. Any real change — a push, a CI result, a review, a resolved conflict — changes the hash and normal routing resumes immediately.
204
205
  - For linked pull requests, GitHub Sync treats merge-conflict, behind-branch, blocked, draft, unstable merge states, and unresolved review threads as executor work, while merge-ready states such as `CLEAN` and `HAS_HOOKS` can move work into `in_review` when CI is green and review threads are resolved. If an issue is already `blocked` and GitHub reports only pending external merge requirements while CI is unfinished, sync preserves the external wait instead of waking an executor. A stale aggregate `CHANGES_REQUESTED` review decision alone does not move that maintainer wait back to active execution. Transient `UNKNOWN` mergeability also does not move an already `in_review` maintainer wait back to active execution when CI is green and review threads are resolved.
205
206
  - Imported issues that are already `blocked` stay `blocked` while any first-class `blockedBy` issue is still non-terminal, even if the linked GitHub pull request is otherwise green and review-ready.
206
207
  - When sync moves work into `in_review`, GitHub Sync first follows the Paperclip issue execution policy's current reviewer or approver when that stage is visible on the issue. If Paperclip exposes an internal review or approval stage but not yet the participant, the plugin falls back to the configured reviewer or approver handoff assignee. If the transition is only a healthy linked-PR wait with no visible internal review or approval stage, GitHub Sync leaves the issue unassigned so it can wait on normal maintainer review without waking an internal owner. An execution state explicitly marked `completed` contains historical stage and decision fields, not active routing: GitHub Sync clears that completed policy/state and the stale internal agent assignee atomically when restoring `done` to `in_review`, keeps any human assignee, and emits no assignment wakeup.
package/dist/manifest.js CHANGED
@@ -719,7 +719,7 @@ var COMPANY_METRIC_API_ROUTE_URL_PATH = `/api/plugins/${GITHUB_SYNC_PLUGIN_ID}/a
719
719
  var require2 = createRequire(import.meta.url);
720
720
  var packageJson = require2("../package.json");
721
721
  var SCHEDULE_TICK_CRON = "* * * * *";
722
- var MANIFEST_VERSION = "0.17.7"?.trim() || typeof packageJson.version === "string" && packageJson.version.trim() || process.env.npm_package_version?.trim() || "0.0.0-dev";
722
+ var MANIFEST_VERSION = "0.18.0"?.trim() || typeof packageJson.version === "string" && packageJson.version.trim() || process.env.npm_package_version?.trim() || "0.0.0-dev";
723
723
  var COMPANY_SECRET_REF_VALUE_SCHEMA = {
724
724
  anyOf: [
725
725
  { type: "string" },
package/dist/worker.js CHANGED
@@ -7124,6 +7124,31 @@ function isGitHubPullRequestPendingExternalWaitForSync(pullRequest) {
7124
7124
  function isGitHubPullRequestBlockedMaintainerApprovalWaitForSync(pullRequest) {
7125
7125
  return pullRequest.ciState === "green" && !pullRequest.hasUnresolvedReviewThreads && pullRequest.mergeability !== "conflicting" && pullRequest.mergeStateStatus === "blocked" && (pullRequest.reviewDecision === "unknown" || pullRequest.reviewDecision === "review_required");
7126
7126
  }
7127
+ function buildExternalPullRequestStateHash(pullRequests) {
7128
+ if (pullRequests.length === 0) return void 0;
7129
+ const normalized = pullRequests.map((pullRequest) => ({
7130
+ repositoryUrl: pullRequest.repositoryUrl,
7131
+ number: pullRequest.number,
7132
+ headSha: pullRequest.headSha ?? null,
7133
+ ciState: pullRequest.ciState,
7134
+ mergeability: pullRequest.mergeability,
7135
+ mergeStateStatus: pullRequest.mergeStateStatus,
7136
+ reviewDecision: pullRequest.reviewDecision,
7137
+ hasUnresolvedReviewThreads: pullRequest.hasUnresolvedReviewThreads
7138
+ })).sort(
7139
+ (left, right) => left.repositoryUrl.localeCompare(right.repositoryUrl) || left.number - right.number
7140
+ );
7141
+ return createHash("sha256").update(JSON.stringify(normalized)).digest("hex");
7142
+ }
7143
+ function resolveUnblockedExternalStateHash(params) {
7144
+ const { currentStatus, nextStatus, currentExternalStateHash, previousHash } = params;
7145
+ if (currentStatus === "blocked" && nextStatus !== "blocked") return currentExternalStateHash;
7146
+ if (currentStatus !== "blocked" && nextStatus === "blocked") return void 0;
7147
+ return previousHash;
7148
+ }
7149
+ function shouldPreserveDeliberateBlockedWait(params) {
7150
+ return params.currentStatus === "blocked" && params.nextStatus !== "blocked" && params.currentExternalStateHash !== void 0 && params.unblockedExternalStateHash === params.currentExternalStateHash;
7151
+ }
7127
7152
  function shouldPreserveBlockedExternalPullRequestWait(params) {
7128
7153
  return params.currentStatus === "blocked" && params.linkedPullRequests.length > 0 && params.linkedPullRequests.every(
7129
7154
  (pullRequest) => isGitHubPullRequestPendingExternalWaitForSync(pullRequest) || isGitHubPullRequestBlockedMaintainerApprovalWaitForSync(pullRequest)
@@ -7959,6 +7984,9 @@ function compareImportedPaperclipIssueCreatedAt(left, right) {
7959
7984
  }
7960
7985
  return leftTime - rightTime;
7961
7986
  }
7987
+ function isLiveGitHubIssueLinkRecord(record) {
7988
+ return record.status !== "unlinked";
7989
+ }
7962
7990
  async function listImportedPaperclipIssuesForMapping(ctx, mapping) {
7963
7991
  if (!mapping.companyId || !mapping.paperclipProjectId || !ctx.issues || typeof ctx.issues.list !== "function") {
7964
7992
  return /* @__PURE__ */ new Map();
@@ -7967,6 +7995,9 @@ async function listImportedPaperclipIssuesForMapping(ctx, mapping) {
7967
7995
  const normalizedRepositoryUrl = getNormalizedMappingRepositoryUrl(mapping);
7968
7996
  const linkedIssueRecords = await listGitHubIssueLinkRecords(ctx);
7969
7997
  for (const record of linkedIssueRecords) {
7998
+ if (!isLiveGitHubIssueLinkRecord(record)) {
7999
+ continue;
8000
+ }
7970
8001
  if (record.data.repositoryUrl !== normalizedRepositoryUrl) {
7971
8002
  continue;
7972
8003
  }
@@ -11304,6 +11335,30 @@ async function synchronizePaperclipIssueStatuses(ctx, octokit, repository, mappi
11304
11335
  if (paperclipIssue.status === "blocked" && nextStatus !== "blocked" && await hasUnresolvedPaperclipIssueBlocker(ctx, paperclipIssue, mapping.companyId)) {
11305
11336
  nextStatus = "blocked";
11306
11337
  }
11338
+ const currentExternalStateHash = buildExternalPullRequestStateHash(snapshot.linkedPullRequests);
11339
+ const previousUnblockedExternalStateHash = importedIssue.unblockedExternalStateHash;
11340
+ if (shouldPreserveDeliberateBlockedWait({
11341
+ currentStatus: paperclipIssue.status,
11342
+ nextStatus,
11343
+ currentExternalStateHash,
11344
+ unblockedExternalStateHash: previousUnblockedExternalStateHash
11345
+ })) {
11346
+ nextStatus = "blocked";
11347
+ }
11348
+ const nextUnblockedExternalStateHash = resolveUnblockedExternalStateHash({
11349
+ currentStatus: paperclipIssue.status,
11350
+ nextStatus,
11351
+ currentExternalStateHash,
11352
+ previousHash: previousUnblockedExternalStateHash
11353
+ });
11354
+ if (nextUnblockedExternalStateHash === void 0) {
11355
+ delete importedIssue.unblockedExternalStateHash;
11356
+ } else {
11357
+ importedIssue.unblockedExternalStateHash = nextUnblockedExternalStateHash;
11358
+ }
11359
+ if (nextUnblockedExternalStateHash !== previousUnblockedExternalStateHash) {
11360
+ await persistImportRegistry();
11361
+ }
11307
11362
  const shouldPreserveMaintainerWaitRouting = isHealthyMaintainerWaitTransition({
11308
11363
  currentStatus: paperclipIssue.status,
11309
11364
  nextStatus,
@@ -11707,6 +11762,33 @@ async function synchronizePaperclipPullRequestIssueStatuses(ctx, octokit, mappin
11707
11762
  if (paperclipIssue.status === "blocked" && nextStatus !== "blocked" && pullRequestSnapshots.some((entry) => entry.lifecycleState === "open") && await hasUnresolvedPaperclipIssueBlocker(ctx, paperclipIssue, mapping.companyId)) {
11708
11763
  nextStatus = "blocked";
11709
11764
  }
11765
+ const currentExternalStateHash = buildExternalPullRequestStateHash(
11766
+ pullRequestSnapshots.map((entry) => entry.pullRequest).filter((pullRequest) => Boolean(pullRequest))
11767
+ );
11768
+ const previousUnblockedExternalStateHash = remoteAction.unblockedExternalStateHash;
11769
+ if (shouldPreserveDeliberateBlockedWait({
11770
+ currentStatus: paperclipIssue.status,
11771
+ nextStatus,
11772
+ currentExternalStateHash,
11773
+ unblockedExternalStateHash: previousUnblockedExternalStateHash
11774
+ })) {
11775
+ nextStatus = "blocked";
11776
+ }
11777
+ const nextUnblockedExternalStateHash = resolveUnblockedExternalStateHash({
11778
+ currentStatus: paperclipIssue.status,
11779
+ nextStatus,
11780
+ currentExternalStateHash,
11781
+ previousHash: previousUnblockedExternalStateHash
11782
+ });
11783
+ if (nextUnblockedExternalStateHash === void 0) {
11784
+ delete remoteAction.unblockedExternalStateHash;
11785
+ } else {
11786
+ remoteAction.unblockedExternalStateHash = nextUnblockedExternalStateHash;
11787
+ }
11788
+ if (nextUnblockedExternalStateHash !== previousUnblockedExternalStateHash) {
11789
+ await persistRemoteActionRegistry();
11790
+ remoteAction = remoteActionRegistry.find((record) => record.key === remoteActionKey) ?? remoteAction;
11791
+ }
11710
11792
  const shouldPreserveMaintainerWaitRouting = isHealthyMaintainerWaitTransition({
11711
11793
  currentStatus: paperclipIssue.status,
11712
11794
  nextStatus,
@@ -18293,6 +18375,10 @@ function shouldStartWorkerHost(moduleUrl, entry = process.argv[1]) {
18293
18375
  }
18294
18376
  var __testing = {
18295
18377
  listIssueInteractionEvents,
18378
+ isLiveGitHubIssueLinkRecord,
18379
+ buildExternalPullRequestStateHash,
18380
+ resolveUnblockedExternalStateHash,
18381
+ shouldPreserveDeliberateBlockedWait,
18296
18382
  buildDirectPullRequestActionFingerprint,
18297
18383
  buildRemoteActionFingerprint,
18298
18384
  canReservePendingWake,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "paperclip-github-plugin",
3
- "version": "0.17.7",
3
+ "version": "0.18.0",
4
4
  "description": "Paperclip plugin for synchronizing GitHub issues into Paperclip projects.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",