@1aboveio/skills 1.0.29 → 1.0.31

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.
Files changed (74) hide show
  1. package/.codex-plugin/plugin.json +1 -1
  2. package/.codex-plugin/resources.json +136 -134
  3. package/package.json +4 -4
  4. package/skills/app-dev/airflow/SKILL.md +1 -1
  5. package/skills/app-dev/android-development/SKILL.md +1 -1
  6. package/skills/app-dev/app-debug/SKILL.md +1 -1
  7. package/skills/app-dev/better-auth/SKILL.md +1 -1
  8. package/skills/app-dev/data-catalog/SKILL.md +1 -1
  9. package/skills/app-dev/data-quality/SKILL.md +1 -1
  10. package/skills/app-dev/ios-foundation/SKILL.md +1 -1
  11. package/skills/app-dev/maestro/SKILL.md +1 -1
  12. package/skills/app-dev/monorepo/SKILL.md +1 -1
  13. package/skills/app-dev/nextjs-fullstack/SKILL.md +1 -1
  14. package/skills/app-dev/prisma-setup/SKILL.md +1 -1
  15. package/skills/app-dev/pyspark/SKILL.md +1 -1
  16. package/skills/app-dev/python-backend/SKILL.md +2 -2
  17. package/skills/app-dev/shadcn/SKILL.md +1 -1
  18. package/skills/app-dev/zod-v4/SKILL.md +1 -1
  19. package/skills/cicd/cloud-build/SKILL.md +1 -1
  20. package/skills/cicd/cloud-debug/SKILL.md +2 -2
  21. package/skills/cicd/cloud-deploy/SKILL.md +1 -1
  22. package/skills/cicd/docker/SKILL.md +1 -1
  23. package/skills/cicd/github-actions/SKILL.md +1 -1
  24. package/skills/cicd/github-flow/SKILL.md +1 -1
  25. package/skills/cicd/google-cloud/SKILL.md +1 -1
  26. package/skills/cicd/mergify/SKILL.md +4 -1
  27. package/skills/cicd/mergify/references/watch-contract.md +73 -16
  28. package/skills/cicd/mergify/scripts/batch-health.mjs +98 -0
  29. package/skills/cicd/mergify/scripts/read-delivery-attention.mjs +17 -0
  30. package/skills/cicd/mergify/scripts/watch-pr-delivery-core.mjs +149 -31
  31. package/skills/cicd/podman/SKILL.md +1 -1
  32. package/skills/content/article-review/SKILL.md +1 -1
  33. package/skills/content/article-to-image/SKILL.md +1 -1
  34. package/skills/content/flowchart-svg/SKILL.md +1 -1
  35. package/skills/content/image-gen/SKILL.md +1 -1
  36. package/skills/content/mermaid/SKILL.md +1 -1
  37. package/skills/content/wechat-article-writer/SKILL.md +1 -1
  38. package/skills/content/wechat-publisher/SKILL.md +1 -1
  39. package/skills/content/wechat-search/SKILL.md +1 -1
  40. package/skills/content/xai-search/SKILL.md +1 -1
  41. package/skills/core/distill-writing/SKILL.md +1 -1
  42. package/skills/core/doc-to-md/SKILL.md +1 -1
  43. package/skills/core/editorial-review/SKILL.md +1 -1
  44. package/skills/core/house-style/SKILL.md +1 -1
  45. package/skills/core/plain-language/SKILL.md +1 -1
  46. package/skills/core/polish-cn/SKILL.md +1 -1
  47. package/skills/core/reg-parser/SKILL.md +1 -1
  48. package/skills/core/terminology/SKILL.md +1 -1
  49. package/skills/core/write-doc/SKILL.md +1 -1
  50. package/skills/core/write-report/SKILL.md +1 -1
  51. package/skills/engineering/better-review/SKILL.md +1 -1
  52. package/skills/engineering/e2e-test/SKILL.md +1 -1
  53. package/skills/engineering/engineering/SKILL.md +1 -1
  54. package/skills/engineering/engineering-runtime/SKILL.md +1 -1
  55. package/skills/engineering/engineering-runtime/coherence/workflow.json +13 -13
  56. package/skills/engineering/ensure-coverage/SKILL.md +1 -1
  57. package/skills/engineering/golden-path/SKILL.md +1 -1
  58. package/skills/engineering/harness-runtime/SKILL.md +1 -1
  59. package/skills/engineering/resolve-issues/SKILL.md +1 -1
  60. package/skills/engineering/resolve-release/SKILL.md +1 -1
  61. package/skills/engineering/resolve-release/references/prepared-metadata.md +16 -2
  62. package/skills/engineering/resolve-release/scripts/plan.mjs +92 -3
  63. package/skills/engineering/rush-issues/SKILL.md +1 -1
  64. package/skills/engineering/rush-release/SKILL.md +1 -1
  65. package/skills/engineering/test-quality/SKILL.md +1 -1
  66. package/skills/risk-compliance/compliance-audit/SKILL.md +2 -2
  67. package/skills/risk-compliance/contract-compare/SKILL.md +1 -1
  68. package/skills/risk-compliance/contract-review/SKILL.md +1 -1
  69. package/skills/risk-compliance/doc-authenticity/SKILL.md +1 -1
  70. package/skills/risk-compliance/fraud-detection/SKILL.md +1 -1
  71. package/skills/risk-compliance/payment-analysis/SKILL.md +1 -1
  72. package/skills/risk-compliance/portfolio-payment-analysis/SKILL.md +1 -1
  73. package/skills/risk-compliance/similar-domain/SKILL.md +1 -1
  74. package/skills/risk-compliance/tld-detection/SKILL.md +1 -1
@@ -1,4 +1,55 @@
1
1
  import { execFileSync } from 'node:child_process'
2
+ import { mkdtempSync } from 'node:fs'
3
+ import { tmpdir } from 'node:os'
4
+ import { join } from 'node:path'
5
+ import { appendHealthEvents, healthSummary, observeBatchHealth } from './batch-health.mjs'
6
+
7
+ // The last active read separates unchanged-head queue attempts even without IDs.
8
+ export function nextQueueAttempt({ previous = null, pr = {}, queue = {}, nowMs }) {
9
+ if (pr.readable === false) return previous
10
+ const head = pr.headRefOid || null
11
+ const prior = previous?.head === head ? previous : null
12
+ if (queue.readable === false || queue.queued !== true) return prior
13
+ const raw = queue.raw || {}
14
+ const entry = raw.queue_enter || {}
15
+ const metadata = entry.metadata || {}
16
+ const session = raw.session_id || metadata.session_id || null
17
+ const enteredMs = Date.parse(raw.queued_at || metadata.queued_at || '')
18
+ return { head, session, enteredMs, lastActiveMs: nowMs }
19
+ }
20
+
21
+ export function currentDequeue({ pr = {}, queue = {}, attempt = null } = {}) {
22
+ if (pr.readable === false || queue.readable === false || queue.queued === true) return null
23
+ const raw = queue.raw || {}
24
+ const leave = raw.queue_leave
25
+ const meta = leave?.metadata || {}
26
+ const head = meta.pull_request_head_sha || raw.queue_leave_head_sha
27
+ if (raw.dequeued !== true || raw.queued !== false || !attempt || !head || head !== pr.headRefOid || head !== attempt.head) return null
28
+ if (raw.queue_leave_head_sha && raw.queue_leave_head_sha !== head) return null
29
+ const enteredMs = Date.parse(meta.queued_at || '')
30
+ const leftMs = Date.parse(leave?.received_at || '')
31
+ if (!Number.isFinite(leftMs)) return null
32
+ if (attempt.session && meta.session_id && attempt.session !== meta.session_id) return null
33
+ if (Number.isFinite(attempt.enteredMs) && Number.isFinite(enteredMs) && enteredMs !== attempt.enteredMs) return null
34
+ if (Number.isFinite(enteredMs) && leftMs < enteredMs) return null
35
+ const identityMatches = (attempt.session && attempt.session === meta.session_id)
36
+ || (Number.isFinite(attempt.enteredMs) && attempt.enteredMs === enteredMs)
37
+ if (!identityMatches && leftMs <= attempt.lastActiveMs) return null
38
+ return { rawReason: meta.reason || meta.dequeue_code || null, code: meta.dequeue_code || null,
39
+ session: meta.session_id || null, enteredMs }
40
+ }
41
+
42
+ export function dequeueEvidence(providerExit, commentInfo = {}) {
43
+ if (!providerExit) return commentInfo
44
+ const sameSession = providerExit.session && providerExit.session === commentInfo.session
45
+ const sameEntry = Number.isFinite(providerExit.enteredMs) && providerExit.enteredMs === commentInfo.enteredMs
46
+ const conflicts = (providerExit.session && commentInfo.session && !sameSession)
47
+ || (Number.isFinite(providerExit.enteredMs) && Number.isFinite(commentInfo.enteredMs) && !sameEntry)
48
+ const matched = !conflicts && (sameSession || sameEntry)
49
+ return { rawReason: providerExit.rawReason || (matched ? commentInfo.rawReason : null),
50
+ batchPrNumber: matched ? commentInfo.batchPrNumber : null,
51
+ providerFailedChecks: matched ? (commentInfo.providerFailedChecks || []) : [] }
52
+ }
2
53
 
3
54
  export function classifyObservation({
4
55
  pr = {},
@@ -17,6 +68,8 @@ export function classifyObservation({
17
68
  missingActiveReads = 0,
18
69
  startedMs = null,
19
70
  dequeuedAtMs = null,
71
+ attempt = null,
72
+ labelDequeueAllowed = true,
20
73
  } = {}) {
21
74
  const labels = Array.isArray(pr.labels) ? pr.labels : []
22
75
  const hasQueuedLabel = labels.includes('queued')
@@ -39,6 +92,10 @@ export function classifyObservation({
39
92
  if (pr.state === 'CLOSED') {
40
93
  return { terminal: true, outcome: 'CLOSED_UNMERGED', reason: 'closed-unmerged', active, seenQueued: seenQueued || active, everActive: ever }
41
94
  }
95
+ const providerExit = currentDequeue({ pr, queue, attempt })
96
+ if (providerExit) {
97
+ return { terminal: true, outcome: 'DEQUEUED', reason: classifyDequeue({ rawReason: providerExit.code || providerExit.rawReason }), rawReason: providerExit.rawReason, active: false, seenQueued: true, everActive: true }
98
+ }
42
99
  // Issue #629: a `dequeued` label is a lifecycle MIRROR of Mergify's queue, never removed on
43
100
  // re-enqueue — so a PR dequeued once, fixed, and re-enqueued still carries the label from
44
101
  // the first attempt into a watch launched for the second one. Two guards, both from the
@@ -66,7 +123,9 @@ export function classifyObservation({
66
123
  // #629's actual failure mode is stale labels persisting across minutes-to-hours-old
67
124
  // attempts, not a coincidence this narrow.
68
125
  const DEQUEUE_TIMESTAMP_GRACE_MS = 60_000
69
- if (hasDequeuedLabel && !active) {
126
+ // Once an attempt is observed, minute-precision comment times cannot prove
127
+ // identity. Rejected structured exits must not become terminal via labels.
128
+ if (labelDequeueAllowed && !attempt && !queue.raw?.queue_leave && hasDequeuedLabel && !active && pr.readable !== false && queue.readable !== false) {
70
129
  const isThisWatchsDequeue = Number.isFinite(startedMs) && Number.isFinite(dequeuedAtMs) && dequeuedAtMs >= startedMs - DEQUEUE_TIMESTAMP_GRACE_MS
71
130
  if (isThisWatchsDequeue) {
72
131
  return { terminal: true, outcome: 'DEQUEUED', reason: 'dequeued-label', active, seenQueued: true, everActive: ever }
@@ -86,7 +145,7 @@ export function classifyObservation({
86
145
  // Lost-membership needs mayCountLoss (everActive observed, or legacy seenQueued-only
87
146
  // callers). Explicit everActive=false with seeded seenQueued is pre-admission resume:
88
147
  // do not count absences or fire DEQUEUED (epic-824 #859 first watch).
89
- if (mayCountLoss && missingActiveReads >= 2) {
148
+ if (mayCountLoss && missingActiveReads >= 2 && pr.readable !== false && queue.readable !== false) {
90
149
  return {
91
150
  terminal: true,
92
151
  outcome: 'DEQUEUED',
@@ -281,12 +340,12 @@ export function effectiveStallMinutes({
281
340
  // inside of. Pre-admission uses the shorter admission bound; post-entry uses the full stall.
282
341
  //
283
342
  // Issue #615 item 1 (round-2 NOTE-2 on #612): clamping to the *whole* bound is only correct
284
- // for a watcher that makes ONE read per poll. This watcher makes TWO (`gh pr view` +
285
- // `mergify queue show`), and the stall/ceiling bounds are evaluated only after both reads in
343
+ // for a watcher that makes ONE read per poll. This watcher makes up to THREE (original PR,
344
+ // `mergify queue show`, current batch), and bounds are evaluated only after those reads in
286
345
  // a poll return — so clamping each read to the full bound let a single poll take up to
287
346
  // `2 x min(effectiveStall, max)` before the loop ever checked it, a 2x overrun the reviewer
288
347
  // measured live as 58s against a 12s stall bound. Dividing the clamp by `readsPerPoll` keeps
289
- // the *sum* of a poll's reads inside the bound: this watcher passes 2 (`READS_PER_POLL`
348
+ // the *sum* of a poll's reads inside the bound: this watcher passes 3 (`READS_PER_POLL`
290
349
  // below), the sibling (`watch-delivery.mjs`, one read per poll) passes 1 and is unaffected
291
350
  // (dividing by 1 is a no-op) — matching `references/watch-contract.md`'s claim, made true
292
351
  // rather than aspirational.
@@ -332,9 +391,8 @@ export function readTimeoutMs(intervalSeconds, boundMinutes, readsPerPoll = 1) {
332
391
  return Number.isFinite(bound) && bound > 0 ? Math.min(computed, (bound * 60_000) / reads) : computed
333
392
  }
334
393
 
335
- // Both subprocess reads this watcher makes per poll — `gh pr view` in `prObservation`,
336
- // `mergify queue show` in `queueObservation`. See `readTimeoutMs` above.
337
- const READS_PER_POLL = 2
394
+ // Maximum regular reads: original PR, queue relationship, current batch.
395
+ const READS_PER_POLL = 3
338
396
 
339
397
  export function run(cmd, args, options = {}) {
340
398
  try {
@@ -425,7 +483,7 @@ export function checkTimings(rollup, { source = 'pr', nowMs = Date.now() } = {})
425
483
  // entry and the latest poll's reading of a running job replaces its earlier one.
426
484
  export function mergeCiJobs(previous = {}, jobs = []) {
427
485
  const next = { ...(previous && typeof previous === 'object' ? previous : {}) }
428
- for (const job of Array.isArray(jobs) ? jobs : []) next[`${job.source}|${job.name}|${job.startedAt}`] = job
486
+ for (const job of Array.isArray(jobs) ? jobs : []) next[`${job.source}${job.batchIdentity ? `:${job.batchIdentity}` : ''}|${job.name}|${job.startedAt}`] = job
429
487
  return next
430
488
  }
431
489
 
@@ -572,13 +630,17 @@ export function dequeueInfoFromComments(comments) {
572
630
  const list = Array.isArray(comments) ? comments : []
573
631
  const mergifyComments = list.filter((c) => c && c.author && c.author.login === 'mergify')
574
632
  let target = null
633
+ let targetPayload = null
575
634
  for (const comment of mergifyComments) {
576
635
  const body = typeof comment.body === 'string' ? comment.body : ''
577
636
  const payloadMatch = MERGIFY_PAYLOAD_RE.exec(body)
578
637
  if (!payloadMatch) continue
579
638
  let payload
580
639
  try { payload = JSON.parse(payloadMatch[1]) } catch { continue }
581
- if (payload && payload.state === 'dequeued') target = comment // last match wins — comments are chronological
640
+ if (payload && payload.state === 'dequeued') {
641
+ target = comment // last match wins — comments are chronological
642
+ targetPayload = payload
643
+ }
582
644
  }
583
645
  if (!target) return { dequeuedAtMs: null, rawReason: null, batchPrNumber: null, providerFailedChecks: [] }
584
646
  const body = typeof target.body === 'string' ? target.body : ''
@@ -602,6 +664,8 @@ export function dequeueInfoFromComments(comments) {
602
664
  }
603
665
  return {
604
666
  dequeuedAtMs,
667
+ session: targetPayload.session_id || null,
668
+ enteredMs: Date.parse(targetPayload.queued_at || ''),
605
669
  rawReason: reasonMatch?.[1]?.trim() || null,
606
670
  batchPrNumber: batchMatch ? Number(batchMatch[1]) : null,
607
671
  providerFailedChecks,
@@ -684,7 +748,7 @@ export function queueObservation({ pr, repo, intervalSeconds, stallMinutes, admi
684
748
  if (parsed) {
685
749
  return {
686
750
  readable: true,
687
- queued: parsed.queued === true || Boolean(parsed.queue_rule_name || parsed.queue_rule),
751
+ queued: parsed.queued === true || (parsed.queued !== false && Boolean(parsed.queue_rule_name || parsed.queue_rule)),
688
752
  queueState: parsed.status || parsed.state || parsed.mergeability_check?.state || null,
689
753
  position: typeof parsed.position === 'number' ? parsed.position : null,
690
754
  batchPrNumber: positivePrNumber(
@@ -705,14 +769,15 @@ function positivePrNumber(value) {
705
769
  return Number.isInteger(number) && number > 0 ? number : null
706
770
  }
707
771
 
708
- // The batch relationship is only queried after a terminal dequeue verdict, so normal polls
709
- // remain the documented two reads. This one-shot enrichment cannot influence lifecycle state.
772
+ // Read current-batch health while queued and enrich dequeue without influencing lifecycle.
710
773
  function batchPrObservation({ repo, batchPrNumber, intervalSeconds, stallMinutes, admissionStallMinutes, maxMinutes, everActive }) {
711
- const result = run('gh', ['pr', 'view', String(batchPrNumber), '--repo', repo, '--json', 'state,url,statusCheckRollup'], { timeout: readTimeoutForArgs({ intervalSeconds, stallMinutes, admissionStallMinutes, maxMinutes, everActive }) })
774
+ const result = run('gh', ['pr', 'view', String(batchPrNumber), '--repo', repo, '--json', 'state,url,headRefOid,statusCheckRollup'], { timeout: readTimeoutForArgs({ intervalSeconds, stallMinutes, admissionStallMinutes, maxMinutes, everActive }) })
712
775
  if (!result.ok) return { readable: false, failedChecks: [], error: result.stderr || result.stdout }
713
776
  const data = parseJson(result.stdout)
714
777
  if (!data) return { readable: false, failedChecks: [], error: 'gh pr view returned invalid JSON for synthetic batch PR' }
715
- return { readable: true, state: data.state || null, url: data.url || null, ciJobs: checkTimings(data.statusCheckRollup, { source: 'queue-batch' }), ...summarizeStatusChecks(data.statusCheckRollup) }
778
+ return { readable: true, headRefOid: data.headRefOid || null, checks: data.statusCheckRollup, state: data.state || null, url: data.url || null,
779
+ ciJobs: checkTimings(data.statusCheckRollup, { source: 'queue-batch' }).map((job) => ({ ...job, batchIdentity: `${batchPrNumber}:${data.headRefOid || 'unknown'}` })),
780
+ ...summarizeStatusChecks(data.statusCheckRollup) }
716
781
  }
717
782
 
718
783
  export function classifyDequeue({ rawReason = null, failedChecks = [] } = {}) {
@@ -720,7 +785,7 @@ export function classifyDequeue({ rawReason = null, failedChecks = [] } = {}) {
720
785
  if (['FAILURE', 'ERROR', 'TIMED_OUT', 'ACTION_REQUIRED', 'STARTUP_FAILURE'].some((status) => statuses.has(status))) return 'checks-failed'
721
786
  if (statuses.has('CANCELLED')) return 'checks-cancelled'
722
787
  const raw = String(rawReason || '').trim().toLowerCase()
723
- if (/failing checks|checks failed/.test(raw)) return 'checks-failed'
788
+ if (/failing checks|checks[ _-]failed/.test(raw)) return 'checks-failed'
724
789
  if (/pull[- ]request.*updated|draft[- ]pull[- ]request.*changed/.test(raw)) return 'pull-request-updated'
725
790
  if (/conflict/.test(raw)) return 'conflict'
726
791
  if (/conditions[- ]unmet/.test(raw)) return 'conditions-unmet'
@@ -743,7 +808,7 @@ export function progressRecord({ payload, changed, sinceChangeMs, nowIso }) {
743
808
  // 15) multiplied every dead watch's cost for no added signal. At a 90s poll, 10 minutes is
744
809
  // still ~6 consecutive identical observations before the watch calls it — comfortably more
745
810
  // than a transient blip. `intervalSeconds` at 90 also cuts the
746
- // API budget: two reads per poll is 80/hour per watched PR, against 240/hour at the old 30s,
811
+ // API budget: at most three reads per poll is 120/hour per watched PR,
747
812
  // which is what makes an epic-sized fan-out of concurrent watchers fit inside an authenticated
748
813
  // token's 5,000/hour limit. The cost is at most 90s of extra merge-detection latency on a
749
814
  // queue that takes minutes per batch.
@@ -754,6 +819,7 @@ export function parseArgs(argv) {
754
819
  admissionStallMinutes: DEFAULT_ADMISSION_STALL_MINUTES,
755
820
  maxMinutes: DEFAULT_MAX_MINUTES,
756
821
  slowJobMinutes: DEFAULT_SLOW_JOB_MINUTES,
822
+ requiredChecks: [],
757
823
  }
758
824
  for (let i = 0; i < argv.length; i += 1) {
759
825
  const arg = argv[i]
@@ -764,6 +830,8 @@ export function parseArgs(argv) {
764
830
  else if (arg === '--admission-stall-minutes') args.admissionStallMinutes = Number(argv[++i])
765
831
  else if (arg === '--max-minutes') args.maxMinutes = Number(argv[++i])
766
832
  else if (arg === '--slow-job-minutes') args.slowJobMinutes = Number(argv[++i])
833
+ else if (arg === '--attention-file') args.attentionFile = argv[++i]
834
+ else if (arg === '--required-check') args.requiredChecks.push(argv[++i])
767
835
  else if (arg === '--seen-queued') args.seenQueued = true
768
836
  else if (arg === '--quiet') args.quiet = true
769
837
  else if (arg === '--help' || arg === '-h') args.help = true
@@ -778,7 +846,7 @@ function help() {
778
846
  return `watch-pr-delivery --repo <owner/name> --pr <number> [options]
779
847
 
780
848
  Observe a Mergify-queued PR until MERGED, DEQUEUED, CLOSED_UNMERGED, or STALLED.
781
- The script observes only; it never queues, dequeues, merges, or records state.
849
+ The script never queues, dequeues or merges. It records local delivery-health evidence.
782
850
 
783
851
  Enqueue first. On a repo with manual delivery (no auto_merge_conditions, autoqueue: false)
784
852
  an unqueued PR never enters the queue on its own, so this watch can only ever end STALLED.
@@ -793,6 +861,8 @@ Options:
793
861
  post-entry bound applies.
794
862
  --max-minutes <n> Absolute safety ceiling, default 60, hard maximum 60
795
863
  --slow-job-minutes <n> Warn when one CI job runs longer than this, default 5
864
+ --attention-file <path> Durable queued-health event journal for supervisor subscription
865
+ --required-check <name> Exact required gate name, repeatable
796
866
  --seen-queued Resume hint only: keep phases/callers aware the PR was queued.
797
867
  Does NOT seed lost-membership counting — membership must be
798
868
  observed in this process (everActive) before DEQUEUED can fire.
@@ -807,8 +877,10 @@ Output:
807
877
  {"ciProfileSummary":true} line (outcome, profile verdict, slow jobs) so a
808
878
  short log tail shows the profile (emitted even with --quiet)
809
879
 
810
- The terminal verdict carries "ciProfile": every non-Mergify CI job's duration (PR checks
811
- from each poll, plus the queue batch PR's checks read once at the end), the slow ones,
880
+ The terminal verdict carries "deliveryHealth" and "attentionFile". Subscribe to the journal
881
+ with read-delivery-attention.mjs for live attention; terminal callbacks alone are insufficient.
882
+ It also carries "ciProfile": every observed non-Mergify CI job's duration (PR and current
883
+ batch checks from each poll), the slow ones,
812
884
  and how long each lifecycle phase lasted. Profiling never changes the verdict or exit code.
813
885
 
814
886
  Both carry "phases": the lifecycle progression observed so far, in order — e.g.
@@ -859,6 +931,13 @@ export async function runCli(argv) {
859
931
  }
860
932
 
861
933
  const startedMs = Date.now()
934
+ const attentionFile = args.attentionFile || join(mkdtempSync(join(tmpdir(), 'mergify-health-')), 'events.ndjson')
935
+ try { appendHealthEvents(attentionFile, []) } catch (error) {
936
+ console.error(`Cannot initialize attention journal ${attentionFile}: ${error.message}`)
937
+ return 2
938
+ }
939
+ let health = { state: 'unavailable', available: false, incidents: [], events: [] }
940
+ let liveBatch = null
862
941
  // `--seen-queued` seeds resume intent only. everActive flips only after THIS process
863
942
  // observes membership — required before lost-queue-membership can fire.
864
943
  let seenQueued = args.seenQueued === true
@@ -870,6 +949,9 @@ export async function runCli(argv) {
870
949
  let observations = 0
871
950
  let phases = []
872
951
  let lastBatchPrNumber = null
952
+ let attempt = null
953
+ let lastHead = null
954
+ let labelDequeueAllowed = true
873
955
  let phaseTimings = []
874
956
  let ciJobs = {}
875
957
  const warnedSlowJobs = new Set()
@@ -882,18 +964,17 @@ export async function runCli(argv) {
882
964
  console.error(slowJobWarning(job, { thresholdMs: slowThresholdMs, nowIso: new Date().toISOString() }))
883
965
  }
884
966
  }
885
- // Every terminal path goes through here, so the profile is on every verdict. The queue
886
- // batch PR (where the merge-queue CI actually runs) is read once, at the end, only if the
887
- // dequeue path has not already read it — normal polls stay at two reads.
967
+ // Every terminal path retains health history and profiling. Reuse the live batch
968
+ // observation unless dequeue has supplied fresh evidence.
888
969
  const finish = (result, { batchRead = null } = {}) => {
889
970
  const endMs = Date.now()
890
971
  let batch = batchRead
891
- if (!batch && lastBatchPrNumber) batch = batchPrObservation({ ...args, everActive, batchPrNumber: lastBatchPrNumber })
972
+ if (!batch && lastBatchPrNumber) batch = liveBatch || batchPrObservation({ ...args, everActive, batchPrNumber: lastBatchPrNumber })
892
973
  if (batch?.readable && Array.isArray(batch.ciJobs)) ciJobs = mergeCiJobs(ciJobs, batch.ciJobs)
893
974
  warnSlowJobs()
894
975
  const timings = nextPhaseTimings(phaseTimings, result.phases || phases, endMs)
895
976
  const profile = ciProfile(ciJobs, { thresholdMs: slowThresholdMs, phaseTimings: timings, startedMs, endMs })
896
- console.log(JSON.stringify({ ...result, ciProfile: profile }, null, 2))
977
+ console.log(JSON.stringify({ ...result, deliveryHealth: healthSummary(health, endMs), attentionFile, ciProfile: profile }, null, 2))
897
978
  console.error(ciProfileSummary(result, profile))
898
979
  }
899
980
 
@@ -904,6 +985,10 @@ export async function runCli(argv) {
904
985
  // admission clock while still being clamped only to the 10m post-entry bound.
905
986
  const pr = prObservation({ ...args, everActive })
906
987
  const queue = queueObservation({ ...args, everActive })
988
+ if (pr.readable !== false && pr.headRefOid) {
989
+ if (lastHead && lastHead !== pr.headRefOid) labelDequeueAllowed = false
990
+ lastHead = pr.headRefOid
991
+ }
907
992
  observations += 1
908
993
  if (pr.readable !== false && Array.isArray(pr.ciJobs)) {
909
994
  ciJobs = mergeCiJobs(ciJobs, pr.ciJobs)
@@ -912,10 +997,22 @@ export async function runCli(argv) {
912
997
  if (queue.readable !== false && queue.queued === true && queue.batchPrNumber) {
913
998
  lastBatchPrNumber = queue.batchPrNumber
914
999
  }
915
- const active = (Array.isArray(pr.labels) && pr.labels.includes('queued')) || queue.queued === true
1000
+ const previousAttempt = attempt
1001
+ attempt = nextQueueAttempt({ previous: attempt, pr, queue, nowMs: Date.now() })
1002
+ const newAttempt = previousAttempt && attempt && (
1003
+ (previousAttempt.session && attempt.session && previousAttempt.session !== attempt.session)
1004
+ || (Number.isFinite(previousAttempt.enteredMs) && Number.isFinite(attempt.enteredMs) && previousAttempt.enteredMs !== attempt.enteredMs)
1005
+ )
1006
+ if (previousAttempt && pr.readable !== false && (previousAttempt.head !== pr.headRefOid || newAttempt)) {
1007
+ everActive = false
1008
+ missingActiveReads = 0
1009
+ lastBatchPrNumber = queue.queued === true ? queue.batchPrNumber : null
1010
+ }
1011
+ const providerExit = currentDequeue({ pr, queue, attempt })
1012
+ const active = !providerExit && ((Array.isArray(pr.labels) && pr.labels.includes('queued')) || queue.queued === true)
916
1013
  // Only the PR read can show a merge, so an absence counts only when it succeeded: Mergify
917
1014
  // also reads "not in the merge queue" for a PR that just merged (ai #1762).
918
- const readable = pr.readable !== false
1015
+ const readable = pr.readable !== false && queue.readable !== false
919
1016
  if (active) {
920
1017
  seenQueued = true
921
1018
  everActive = true
@@ -930,21 +1027,39 @@ export async function runCli(argv) {
930
1027
  missingActiveReads,
931
1028
  startedMs,
932
1029
  dequeuedAtMs: pr.dequeuedAtMs ?? null,
1030
+ attempt,
1031
+ labelDequeueAllowed,
933
1032
  })
934
1033
  if (verdict.everActive === true) everActive = true
935
1034
  if (verdict.seenQueued === true) seenQueued = true
1035
+ // An unreadable relationship invalidates health even when no queued label
1036
+ // remains and lifecycle classification is WAITING rather than QUEUED.
1037
+ if (verdict.outcome === 'QUEUED' || queue.readable === false) {
1038
+ // Trust only this readable active queue relationship, never a retained old batch.
1039
+ const number = queue.readable !== false && queue.queued === true ? queue.batchPrNumber : null
1040
+ liveBatch = number ? batchPrObservation({ ...args, everActive, batchPrNumber: number }) : null
1041
+ const binding = { repo: args.repo, pr: Number(args.pr), prHead: pr.headRefOid || null,
1042
+ session: attempt?.session || null, enteredMs: Number.isFinite(attempt?.enteredMs) ? attempt.enteredMs : null,
1043
+ batchPrNumber: number, head: liveBatch?.headRefOid || null,
1044
+ batchUrl: liveBatch?.url || (number ? `https://github.com/${args.repo}/pull/${number}` : null) }
1045
+ const conditions = queue.raw?.queue_rule?.config?.merge_conditions || []
1046
+ const requiredChecks = [...new Set([...args.requiredChecks, ...conditions.filter((c) => typeof c === 'string' && c.startsWith('check-success=')).map((c) => c.slice('check-success='.length))])]
1047
+ health = observeBatchHealth({ previous: health, binding, batch: pr.readable === false ? { readable: false, error: pr.error } : liveBatch || { readable: false }, requiredChecks, nowMs: Date.now() })
1048
+ appendHealthEvents(attentionFile, health.events.map((event) => ({ ...event, lifecycle: verdict.outcome, repo: args.repo, pr: Number(args.pr) })))
1049
+ if (liveBatch?.readable) ciJobs = mergeCiJobs(ciJobs, liveBatch.ciJobs)
1050
+ }
936
1051
  if (verdict.preAdmission === true) phases = nextPhases(phases, 'NOT_YET_QUEUED')
937
1052
  phases = nextPhases(phases, verdict.outcome)
938
1053
  phaseTimings = nextPhaseTimings(phaseTimings, phases)
939
1054
  let dequeue = null
940
1055
  if (verdict.outcome === 'DEQUEUED') {
941
- const info = pr.dequeueInfo || { rawReason: null, batchPrNumber: null, providerFailedChecks: [] }
1056
+ const info = dequeueEvidence(providerExit, pr.dequeueInfo || { rawReason: null, batchPrNumber: null, providerFailedChecks: [] })
942
1057
  const batchPrNumber = lastBatchPrNumber ?? info.batchPrNumber ?? null
943
1058
  const batch = batchPrNumber ? batchPrObservation({ ...args, everActive, batchPrNumber }) : null
944
1059
  const failedChecks = batch?.readable && batch.failedChecks.length > 0
945
1060
  ? batch.failedChecks
946
1061
  : (info.providerFailedChecks || [])
947
- const classifiedReason = classifyDequeue({ rawReason: info.rawReason, failedChecks })
1062
+ const classifiedReason = classifyDequeue({ rawReason: providerExit?.code || info.rawReason, failedChecks })
948
1063
  dequeue = {
949
1064
  reason: classifiedReason === 'unknown' && !info.rawReason && failedChecks.length === 0
950
1065
  ? verdict.reason
@@ -963,6 +1078,8 @@ export async function runCli(argv) {
963
1078
  detail: verdict.detail || null,
964
1079
  mergedSha: verdict.mergedSha || null,
965
1080
  batchPrNumber: dequeue?.batchPrNumber || lastBatchPrNumber,
1081
+ deliveryHealth: healthSummary(health, Date.now()),
1082
+ attentionFile,
966
1083
  seenQueued,
967
1084
  everActive,
968
1085
  phases,
@@ -1005,12 +1122,13 @@ export async function runCli(argv) {
1005
1122
 
1006
1123
  const stallObservation = nextStallObservation({ cache: stallObservationCache, pr, queue })
1007
1124
  stallObservationCache = stallObservation.cache
1008
- const changed = stallObservation.changed
1125
+ const changed = stallObservation.changed || health.changed
1126
+ health.changed = false
1009
1127
  if (changed) {
1010
1128
  lastChangeMs = Date.now()
1011
1129
  }
1012
1130
 
1013
- const readability = JSON.stringify([pr.readable !== false, queue.readable !== false])
1131
+ const readability = JSON.stringify([pr.readable !== false, queue.readable !== false, health.available])
1014
1132
  if (!args.quiet && (changed || readability !== lastReadability)) {
1015
1133
  const now = Date.now()
1016
1134
  console.error(progressRecord({ payload, changed, sinceChangeMs: now - lastChangeMs, nowIso: new Date(now).toISOString() }))
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: podman
3
3
  description: "Debug, design, or fix Podman: rootless/rootful containers, pods, podman-compose, the socket and systemd services, Docker-compatible API (DOCKER_HOST/CONTAINER_HOST), networking, volumes, SELinux labels, Docker migration, and CI/SSH provisioning of rootless sockets (user lingering, XDG_RUNTIME_DIR). Covers FailedToOpenSocket and systemctl --user DBUS/XDG errors."
4
- release-version: 0.50.9
4
+ release-version: 0.50.11
5
5
  ---
6
6
  **Updates:** Once/session run `node <skill-base-dir>/release-check.mjs`.
7
7
  # Podman Operations
@@ -6,7 +6,7 @@ description: >
6
6
  Use when a user shares an article, pastes article text, sends a URL, or asks to
7
7
  review, rate, critique, evaluate, 评价, 点评, 分析, or 看看 any article, post, or 文章.
8
8
  Default template is 公众号-支付行业.
9
- release-version: 0.50.9
9
+ release-version: 0.50.11
10
10
  ---
11
11
  **Updates:** Once/session run `node <skill-base-dir>/release-check.mjs`.
12
12
  # 文章评审引擎
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: article-to-image
3
3
  description: "Generate article cover images: WeChat banner/square (公众号封面), Xiaohongshu (小红书封面), LinkedIn banner, general wide. Brainstorms 4 visual directions from the article, then renders each format with correct aspect ratios and title-safe zones. Use when given an article and asked for covers, banners, or 出图."
4
- release-version: 0.50.9
4
+ release-version: 0.50.11
5
5
  ---
6
6
  **Updates:** Once/session run `node <skill-base-dir>/release-check.mjs`.
7
7
  # Article-to-Image
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: flowchart-svg
3
3
  description: Create polished flowcharts directly as SVG and export PNG copies. Use when asked to draw, design, render, or deliver process diagrams, architecture diagrams, consulting workflows, decision flows, swimlanes, or other flowcharts as image files, especially when final outputs must include .svg and .png versions.
4
- release-version: 0.50.9
4
+ release-version: 0.50.11
5
5
  ---
6
6
  **Updates:** Once/session run `node <skill-base-dir>/release-check.mjs`.
7
7
  # Flowchart SVG
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: image-gen
3
3
  description: Generate an image from a text prompt with OpenAI gpt-image-2 or Google Nano Banana (Gemini), saved to an image file. Use whenever the user asks to generate, create, make, draw, paint, render, or design an image, picture, illustration, photo, artwork, logo, icon, avatar, banner, hero image, thumbnail, poster, wallpaper, sticker, or concept art — including phrasings like "an image of X", "a picture of X", "show me what X would look like", or a request for a visual for a slide, blog post, README, or social post. Also triggers on Chinese phrasings such as 生成图片, 画一张图, 做一张海报, 设计一个 logo. NOT for charts or data visualizations (dataviz), flowcharts or architecture diagrams (flowchart-svg), or editing an existing image file.
4
- release-version: 0.50.9
4
+ release-version: 0.50.11
5
5
  ---
6
6
  **Updates:** Once/session run `node <skill-base-dir>/release-check.mjs`.
7
7
  # Image Generation
@@ -2,7 +2,7 @@
2
2
  name: mermaid
3
3
  description: Create and edit Mermaid diagrams for architecture, API flows, database schemas, workflows, and data models.
4
4
  user-invocable: true
5
- release-version: 0.50.9
5
+ release-version: 0.50.11
6
6
  ---
7
7
  **Updates:** Once/session run `node <skill-base-dir>/release-check.mjs`.
8
8
  # Mermaid Diagram Creation
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: wechat-article-writer
3
3
  description: "Write WeChat 公众号 articles in Chinese content styles — 踩坑型 (pitfall-story), 实操型 (how-to), 对比型 (comparison), 观察型 (industry insight) — in the account's house style from the nearest WRITING.md. Use for drafting from scratch, rewriting a draft, adapting source material into a publishable article, or picking the right style. NOT for business or technical documents (write-doc)."
4
- release-version: 0.50.9
4
+ release-version: 0.50.11
5
5
  ---
6
6
  **Updates:** Once/session run `node <skill-base-dir>/release-check.mjs`.
7
7
  # WeChat Article Writer (公众号写作)
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: wechat-publisher
3
3
  description: "Publish articles to a WeChat Official Account (公众号) via API: push Markdown to the draft box (or auto-publish with --publish), convert Markdown to WeChat HTML, upload images to the media library. Requires AppID + AppSecret + whitelisted server IP on a 认证订阅号/服务号. Consumes wechat-article-writer's Markdown."
4
- release-version: 0.50.9
4
+ release-version: 0.50.11
5
5
  ---
6
6
  **Updates:** Once/session run `node <skill-base-dir>/release-check.mjs`.
7
7
  # WeChat Publisher (公众号发布)
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: wechat-search
3
3
  description: "Search WeChat 公众号 articles via Sogou Weixin, or read/summarize an article from a mp.weixin.qq.com URL (读/分析/总结) — suggest proactively when such a URL appears. Use for Chinese WeChat content, industry reports, competitor or trending topics. Requires Chrome Browser Relay. NOT general web search (web_search)."
4
- release-version: 0.50.9
4
+ release-version: 0.50.11
5
5
  ---
6
6
  **Updates:** Once/session run `node <skill-base-dir>/release-check.mjs`.
7
7
  # WeChat Article Search & Reader (搜狗微信搜索)
@@ -9,7 +9,7 @@ metadata:
9
9
  type: secret
10
10
  required: true
11
11
  description: API key for direct xAI or the explicitly configured Responses gateway
12
- release-version: 0.50.9
12
+ release-version: 0.50.11
13
13
  ---
14
14
  **Updates:** Once/session run `node <skill-base-dir>/release-check.mjs`.
15
15
  # xAI Search (X/Twitter + Web)
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: distill-writing
3
3
  description: "Learn a house writing style from approved sample documents, or save an explicitly stated project document preference, into WRITING.md and writing/templates/. Use for sample-based style learning, house-style setup or refresh, and requests such as 'remember this for future PRDs' or 'make this our report default', including handoffs from write-doc, write-report or plain-language. Preserve manual edits and separate document types. NOT for drafting a document (write-doc) or analytical report (write-report) or saving chat-only preferences (plain-language)."
4
- release-version: 0.50.9
4
+ release-version: 0.50.11
5
5
  ---
6
6
  **Updates:** Once/session run `node <skill-base-dir>/release-check.mjs`.
7
7
  # Distill a writing style
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: doc-to-md
3
3
  description: "Convert documents (PDF, DOCX, PPTX, XLSX, images) to Markdown so agents can read them. Use as the preprocessing step whenever binary files need to enter agent context — contract review, compliance audit, document analysis, evidence review."
4
- release-version: 0.50.9
4
+ release-version: 0.50.11
5
5
  ---
6
6
  **Updates:** Once/session run `node <skill-base-dir>/release-check.mjs`.
7
7
  # doc-to-md
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: editorial-review
3
3
  description: "Review a document or generated report for what it says (does the reader get the answer, is the argument sound, is anything unsupported, obvious or repeated), then fix the content. Use to review, tighten or clarify a doc or report, and as the review step of write-doc, write-report and domain report skills. NOT for Chinese wording (polish-cn) or code review (better-review)."
4
- release-version: 0.50.9
4
+ release-version: 0.50.11
5
5
  ---
6
6
  **Updates:** Once/session run `node <skill-base-dir>/release-check.mjs`.
7
7
  # Editorial review
@@ -3,7 +3,7 @@ name: house-style
3
3
  description: "Shared reference the writing skills read by path: WRITING.md lookup and precedence, template choice, gap markers, template shape, the bundled templates, and the default English and Chinese style guides. Never select or invoke it as a task."
4
4
  disable-model-invocation: true
5
5
  user-invocable: false
6
- release-version: 0.50.9
6
+ release-version: 0.50.11
7
7
  ---
8
8
  **Updates:** Once/session run `node <skill-base-dir>/release-check.mjs`.
9
9
  # House style
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: plain-language
3
3
  description: "Session mode: every reply and status line in plain language — lead with the point, everyday words, full sentences, no filler — in English or Chinese, until turned off. Enable by default when the project has an applicable WRITING.md, even without a slash command. Use for /plain-language, 'talk plainly', '说人话', and explicit requests to remember project reply preferences; an actual /plain-language invocation automatically configures the current directory's WRITING.md and loading pointers; init remains an alias. Save reply rules only under Agent replies; route document preferences to distill-writing. Natural-language toggles and off remain session-only. Turn off with '/plain-language off' or 'normal mode'. NOT for writing a document (write-doc) or analytical report (write-report) or reviewing one (editorial-review)."
4
- release-version: 0.50.9
4
+ release-version: 0.50.11
5
5
  ---
6
6
  **Updates:** Once/session run `node <skill-base-dir>/release-check.mjs`.
7
7
  # Plain language
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: polish-cn
3
3
  description: "Polish the Chinese wording of a finished document or report, with a script proving every number, date, identifier, link and protected term is unchanged; prefers a Chinese model and records which ran. Use for '中文润色' or as a report skill's last step. NOT for cutting or restructuring content (editorial-review) or translating (write-doc or write-report)."
4
- release-version: 0.50.9
4
+ release-version: 0.50.11
5
5
  ---
6
6
  **Updates:** Once/session run `node <skill-base-dir>/release-check.mjs`.
7
7
  # Polish Chinese
@@ -2,7 +2,7 @@
2
2
  name: reg-parser
3
3
  version: 1.1.0
4
4
  description: "Parse regulatory/scheme documents into structured outputs: convert a regulation (AML, VARS, PCI-DSS, KYC, GDPR) into an audit-ready compliance checklist, or trace contract clauses to a mandate source. Suggest proactively when a regulation PDF accompanies a contract review or compliance task. NOT general summarization (doc-to-md), writing a gap-analysis report (write-report), or writing a policy from the checklist (write-doc)."
5
- release-version: 0.50.9
5
+ release-version: 0.50.11
6
6
  ---
7
7
  **Updates:** Once/session run `node <skill-base-dir>/release-check.mjs`.
8
8
  # reg-parser
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: terminology
3
3
  description: "Build and keep a project's TERMINOLOGY.md: the preferred term per concept in English, 简体 and 繁體, and the terms to avoid. Use to set it up from the project's documents, when the user settles or corrects a term, or when another writing skill needs the format. NOT for writing documents (write-doc) or analytical reports (write-report) or the code domain model (domain-modeling)."
4
- release-version: 0.50.9
4
+ release-version: 0.50.11
5
5
  ---
6
6
  **Updates:** Once/session run `node <skill-base-dir>/release-check.mjs`.
7
7
  # Terminology
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: write-doc
3
3
  description: "Write or edit documents that define or propose something: BRD, PRD, technical spec, integration guide, proposal, policy or risk procedure; English, Chinese or bilingual. Use automatically for drafting or revising these documents. Markdown by default; export when requested. NOT for analytical reports or writing up findings (write-report), ordinary chat replies (plain-language), learning style or saving preferences alone (distill-writing), performing an audit (compliance-audit), or WeChat articles (wechat-article-writer)."
4
- release-version: 0.50.9
4
+ release-version: 0.50.11
5
5
  ---
6
6
  **Updates:** Once/session run `node <skill-base-dir>/release-check.mjs`.
7
7
  # Write a document
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: write-report
3
3
  description: "Write or edit analytical reports from data, research, analysis or findings: payment, fraud, operational, performance, research, gap-analysis, audit, external assessment, management and Visa VARS reports. Use whenever asked to report results, write up findings, or turn analysis into a report, even without naming this skill. English, Chinese or bilingual; Markdown by default, export when requested. NOT for defining requirements, policies or proposals (write-doc), performing the underlying domain analysis or audit, chat-only answers (plain-language), or learning house style (distill-writing)."
4
- release-version: 0.50.9
4
+ release-version: 0.50.11
5
5
  ---
6
6
  **Updates:** Once/session run `node <skill-base-dir>/release-check.mjs`.
7
7
  # Write an analytical report
@@ -4,7 +4,7 @@ description: "Slash/explicit-only (/better-review). Single-agent adversarial rev
4
4
  disable-model-invocation: true
5
5
  dependencies:
6
6
  - engineering-runtime
7
- release-version: 0.50.9
7
+ release-version: 0.50.11
8
8
  ---
9
9
  **Updates:** Once/session run `node <skill-base-dir>/release-check.mjs`.
10
10
  # Better Review
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: e2e-test
3
3
  description: "Playwright end-to-end guidance for affected browser journeys, render health and presentation checks, with route manifests and sweeps for broader audits. Use when browser routes or user flows ship or change, or a Playwright test flakes. NOT for non-browser tests, defining what to test (ensure-coverage), the curated ALIVE/DEAD golden-path gate (golden-path), or CI workflow YAML (github-actions)."
4
- release-version: 0.50.9
4
+ release-version: 0.50.11
5
5
  ---
6
6
  **Updates:** Once/session run `node <skill-base-dir>/release-check.mjs`.
7
7
  # E2E Testing Standard