paperclip-github-plugin 0.17.6 → 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 +3 -2
- package/dist/manifest.js +1 -1
- package/dist/worker.js +94 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -85,7 +85,7 @@ A pull-request link may include `followThroughAssigneeAgentId`, an optional Pape
|
|
|
85
85
|
|
|
86
86
|
The worker validates an explicit owner against the authoritative Paperclip agent service before writing the link. The agent must exist and belong to the authenticated company; missing and cross-company ids fail closed. Successful owner changes carry `followThroughAssigneeUpdatedAt` in the durable link and agent-tool changes remain visible in the existing issue interaction ledger.
|
|
87
87
|
|
|
88
|
-
The owner is stored on the PR-link entity, so unrelated title/state refreshes, process restarts, and execution-state cleanup do not remove it. Old link records without the property remain valid and use the previous fallback behavior. For actionable direct-PR work, assignment precedence is: an active execution-state `returnAssignee`, the PR's durable follow-through owner, the configured company executor, then the configured default assignee. Red CI, unresolved review threads, trusted follow-up, and merge-conflict/action-required states assign and wake the selected owner. A healthy external-maintainer wait remains `in_review`
|
|
88
|
+
The owner is stored on the PR-link entity, so unrelated title/state refreshes, process restarts, and execution-state cleanup do not remove it. Old link records without the property remain valid and use the previous fallback behavior. For actionable direct-PR work, assignment precedence is: an active execution-state `returnAssignee`, the PR's durable follow-through owner, the configured company executor, then the configured default assignee. Red CI, unresolved review threads, trusted follow-up, and merge-conflict/action-required states assign and wake the selected owner. A healthy external-maintainer wait remains `in_review` with no agent assignee; a human assignee is left in place, because a person parked on such an issue is the reviewer the work is waiting on. Effective-state fingerprints include durable routing so unchanged polls neither repeat the mutation nor enqueue another wake.
|
|
89
89
|
|
|
90
90
|
### Project pull request command center
|
|
91
91
|
|
|
@@ -201,9 +201,10 @@ 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
|
-
- 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 assignee atomically when restoring `done` to `in_review`, and
|
|
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.
|
|
207
208
|
- When sync moves work back into active execution, GitHub Sync first follows the Paperclip issue execution policy `returnAssignee` when it is available. Otherwise it uses the durable pull-request follow-through owner, then falls back to the configured executor handoff assignee and finally to the default imported assignee.
|
|
208
209
|
- Sync-driven handoffs to agent assignees best-effort enqueue an explicit wakeup so the next reviewer, approver, or executor can pick the issue up even when their agent is not running heartbeats.
|
|
209
210
|
- After applying a GitHub-derived state, GitHub Sync immediately stores a bounded fingerprint of the effective issue/PR condition (including head SHA, closure outcome, and the highest-priority actionable check/review/merge condition). While local Paperclip status, assignment, and execution metadata still match the desired state, the same fingerprint remains quiescent: sync does not repeat the transition, comment, or wake, including for `done`/`cancelled` closure outcomes and directly PR-linked issues. If local state later drifts under unchanged remote evidence, sync reconciles it through a drift-specific journal attempt and issues one required wake when the corrected state is actionable and agent-owned. Raw `UNKNOWN`/aggregate jitter that does not change the effective action cannot re-arm the transition. A changed effective fingerprint or a trusted new issue/PR/review comment bypasses suppression; untrusted comment-count changes do not. Status/comment watermarks advance only after their action succeeds. When a required assignee wake fails, the successful mutation and a bounded pending-wake record are already durable, so the next sync retries only the wake without repeating the status change or comment.
|
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.
|
|
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
|
@@ -6430,6 +6430,10 @@ function normalizePaperclipIssueExecutionState(value) {
|
|
|
6430
6430
|
...lastDecisionOutcome !== null ? { lastDecisionOutcome } : {}
|
|
6431
6431
|
};
|
|
6432
6432
|
}
|
|
6433
|
+
function readPaperclipIssueAssigneeUserId(issue) {
|
|
6434
|
+
if (!issue) return null;
|
|
6435
|
+
return normalizeOptionalString2(issue.assigneeUserId) ?? null;
|
|
6436
|
+
}
|
|
6433
6437
|
function getPaperclipIssueAssigneePrincipal(issue) {
|
|
6434
6438
|
const record = issue;
|
|
6435
6439
|
const assigneeAgentId = normalizeOptionalString2(record.assigneeAgentId);
|
|
@@ -7120,6 +7124,31 @@ function isGitHubPullRequestPendingExternalWaitForSync(pullRequest) {
|
|
|
7120
7124
|
function isGitHubPullRequestBlockedMaintainerApprovalWaitForSync(pullRequest) {
|
|
7121
7125
|
return pullRequest.ciState === "green" && !pullRequest.hasUnresolvedReviewThreads && pullRequest.mergeability !== "conflicting" && pullRequest.mergeStateStatus === "blocked" && (pullRequest.reviewDecision === "unknown" || pullRequest.reviewDecision === "review_required");
|
|
7122
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
|
+
}
|
|
7123
7152
|
function shouldPreserveBlockedExternalPullRequestWait(params) {
|
|
7124
7153
|
return params.currentStatus === "blocked" && params.linkedPullRequests.length > 0 && params.linkedPullRequests.every(
|
|
7125
7154
|
(pullRequest) => isGitHubPullRequestPendingExternalWaitForSync(pullRequest) || isGitHubPullRequestBlockedMaintainerApprovalWaitForSync(pullRequest)
|
|
@@ -7955,6 +7984,9 @@ function compareImportedPaperclipIssueCreatedAt(left, right) {
|
|
|
7955
7984
|
}
|
|
7956
7985
|
return leftTime - rightTime;
|
|
7957
7986
|
}
|
|
7987
|
+
function isLiveGitHubIssueLinkRecord(record) {
|
|
7988
|
+
return record.status !== "unlinked";
|
|
7989
|
+
}
|
|
7958
7990
|
async function listImportedPaperclipIssuesForMapping(ctx, mapping) {
|
|
7959
7991
|
if (!mapping.companyId || !mapping.paperclipProjectId || !ctx.issues || typeof ctx.issues.list !== "function") {
|
|
7960
7992
|
return /* @__PURE__ */ new Map();
|
|
@@ -7963,6 +7995,9 @@ async function listImportedPaperclipIssuesForMapping(ctx, mapping) {
|
|
|
7963
7995
|
const normalizedRepositoryUrl = getNormalizedMappingRepositoryUrl(mapping);
|
|
7964
7996
|
const linkedIssueRecords = await listGitHubIssueLinkRecords(ctx);
|
|
7965
7997
|
for (const record of linkedIssueRecords) {
|
|
7998
|
+
if (!isLiveGitHubIssueLinkRecord(record)) {
|
|
7999
|
+
continue;
|
|
8000
|
+
}
|
|
7966
8001
|
if (record.data.repositoryUrl !== normalizedRepositoryUrl) {
|
|
7967
8002
|
continue;
|
|
7968
8003
|
}
|
|
@@ -10190,6 +10225,9 @@ async function updatePaperclipIssueState(ctx, params) {
|
|
|
10190
10225
|
syncContext,
|
|
10191
10226
|
nextAssignee
|
|
10192
10227
|
});
|
|
10228
|
+
const liveIssue = await ctx.issues.get(issueId, companyId);
|
|
10229
|
+
const liveCurrentStatus = liveIssue?.status ?? currentStatus;
|
|
10230
|
+
const liveSyncContext = liveIssue ? getPaperclipIssueSyncContext(liveIssue) : syncContext;
|
|
10193
10231
|
const issuePatch = {
|
|
10194
10232
|
status: nextStatus,
|
|
10195
10233
|
...syncExecutionStatePatch !== void 0 ? { executionState: syncExecutionStatePatch } : {},
|
|
@@ -10205,7 +10243,7 @@ async function updatePaperclipIssueState(ctx, params) {
|
|
|
10205
10243
|
}
|
|
10206
10244
|
} else if (clearAssignee) {
|
|
10207
10245
|
issuePatch.assigneeAgentId = null;
|
|
10208
|
-
issuePatch.assigneeUserId = null;
|
|
10246
|
+
issuePatch.assigneeUserId = readPaperclipIssueAssigneeUserId(liveIssue) ?? (syncContext.assignee?.kind === "user" ? syncContext.assignee.id : null);
|
|
10209
10247
|
}
|
|
10210
10248
|
if (statusWillChange && !trimmedTransitionComment) {
|
|
10211
10249
|
throw new Error("GitHub Sync refused to update a Paperclip issue status without an explanatory transition comment.");
|
|
@@ -10213,9 +10251,6 @@ async function updatePaperclipIssueState(ctx, params) {
|
|
|
10213
10251
|
if (statusWillChange && typeof ctx.issues.createComment !== "function") {
|
|
10214
10252
|
throw new Error("This Paperclip runtime does not expose issue comment creation, so GitHub Sync refused to update a Paperclip issue status without an explanatory comment.");
|
|
10215
10253
|
}
|
|
10216
|
-
const liveIssue = await ctx.issues.get(issueId, companyId);
|
|
10217
|
-
const liveCurrentStatus = liveIssue?.status ?? currentStatus;
|
|
10218
|
-
const liveSyncContext = liveIssue ? getPaperclipIssueSyncContext(liveIssue) : syncContext;
|
|
10219
10254
|
const issuePatchAlreadyApplied = isPaperclipIssuePatchApplied({
|
|
10220
10255
|
currentStatus: liveCurrentStatus,
|
|
10221
10256
|
syncContext: liveSyncContext,
|
|
@@ -11300,6 +11335,30 @@ async function synchronizePaperclipIssueStatuses(ctx, octokit, repository, mappi
|
|
|
11300
11335
|
if (paperclipIssue.status === "blocked" && nextStatus !== "blocked" && await hasUnresolvedPaperclipIssueBlocker(ctx, paperclipIssue, mapping.companyId)) {
|
|
11301
11336
|
nextStatus = "blocked";
|
|
11302
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
|
+
}
|
|
11303
11362
|
const shouldPreserveMaintainerWaitRouting = isHealthyMaintainerWaitTransition({
|
|
11304
11363
|
currentStatus: paperclipIssue.status,
|
|
11305
11364
|
nextStatus,
|
|
@@ -11703,6 +11762,33 @@ async function synchronizePaperclipPullRequestIssueStatuses(ctx, octokit, mappin
|
|
|
11703
11762
|
if (paperclipIssue.status === "blocked" && nextStatus !== "blocked" && pullRequestSnapshots.some((entry) => entry.lifecycleState === "open") && await hasUnresolvedPaperclipIssueBlocker(ctx, paperclipIssue, mapping.companyId)) {
|
|
11704
11763
|
nextStatus = "blocked";
|
|
11705
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
|
+
}
|
|
11706
11792
|
const shouldPreserveMaintainerWaitRouting = isHealthyMaintainerWaitTransition({
|
|
11707
11793
|
currentStatus: paperclipIssue.status,
|
|
11708
11794
|
nextStatus,
|
|
@@ -18289,6 +18375,10 @@ function shouldStartWorkerHost(moduleUrl, entry = process.argv[1]) {
|
|
|
18289
18375
|
}
|
|
18290
18376
|
var __testing = {
|
|
18291
18377
|
listIssueInteractionEvents,
|
|
18378
|
+
isLiveGitHubIssueLinkRecord,
|
|
18379
|
+
buildExternalPullRequestStateHash,
|
|
18380
|
+
resolveUnblockedExternalStateHash,
|
|
18381
|
+
shouldPreserveDeliberateBlockedWait,
|
|
18292
18382
|
buildDirectPullRequestActionFingerprint,
|
|
18293
18383
|
buildRemoteActionFingerprint,
|
|
18294
18384
|
canReservePendingWake,
|