gitoria

kunibert

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit070e01a4070e01a4Records: parkmre070e01a4/lib/gitoria-events.hl

3.8 KB

  1. $mode = 'static'
  2. \\ THE ONE FILE that knows gitoria's event names and field paths (apps-api.md v0, section 4).
  3. \\ When the contract changes (the [OPEN] marks), only this file changes.
  4. headerEvent = 'x-push-event'
  5. headerDelivery = 'x-push-delivery'
  6. headerSignature = 'x-push-signature-256'
  7. signaturePrefix = 'sha256='
  8. eventNames = ['ping', 'pull_request', 'review_requested', 'review_comment', 'pull_comment', 'review_thread']
  9. botMention = '@kunibert'
  10. isKnown = (name) => {
  11. return name != null && eventNames.includes(name)
  12. }
  13. \\ the repo id the secret is keyed by; null when the body has none
  14. repoId = (body) => {
  15. if (body.repo == null || body.repo.id == null) { return null }
  16. return '' + body.repo.id
  17. }
  18. \\ `@kunibert reset` / `@kunibert <text>` at the start of a comment: { reset } or { note } or null
  19. mention = (text) => {
  20. if (hlTypeName(text) != 'String') { return null }
  21. t = text.trim()
  22. if (!t.toLowerCase().startsWith(botMention)) { return null }
  23. rest = t.slice(botMention.length).trim()
  24. if (rest == '') { return null }
  25. if (rest.toLowerCase() == 'reset') { return { reset = true } }
  26. return { note = rest }
  27. }
  28. \\ A change a job can use, from one parsed event. Answer: { kind, reason, ... }
  29. \\ kind: 'ignore' | 'ping' | 'review' | 'thread-state' | 'close'
  30. \\ A review/thread-state change carries: repo, number, head, time, pull, force, reset, threads, notes, replyCandidate.
  31. \\ review: starts or updates a review job. thread-state: only records a resolved/settled flip (no review).
  32. \\ replyCandidate: a review_comment; the queue makes it threadReplyOnly when it brings no new head.
  33. classify = (String name, Hybrid body) => {
  34. action = body.action
  35. pull = body.pull
  36. if (name == 'ping') { return { kind = 'ping' } }
  37. if (pull == null || pull.number == null || repoId(body) == null) { return { kind = 'ignore', reason = 'no repo.id or pull.number' } }
  38. change = {
  39. kind = 'review'
  40. repoId = repoId(body)
  41. repo = body.repo
  42. number = pull.number
  43. head = pull.head
  44. time = body.time
  45. pull = pull
  46. force = false
  47. reset = false
  48. threads = []
  49. notes = []
  50. delivery = body.delivery
  51. event = name + '.' + action
  52. replyCandidate = false
  53. }
  54. if (name == 'pull_request') {
  55. if (action == 'closed' || action == 'merged') { change.kind = 'close'
  56. return change }
  57. if (pull.draft == true) { return { kind = 'ignore', reason = 'draft pull request' } }
  58. if (action == 'opened' || action == 'reopened' || action == 'synchronize' || action == 'ready') { return change }
  59. return { kind = 'ignore', reason = 'pull_request.' + action + ' not handled' }
  60. }
  61. if (pull.draft == true) { return { kind = 'ignore', reason = 'draft pull request' } }
  62. if (name == 'review_requested') {
  63. change.force = true
  64. return change
  65. }
  66. if (name == 'review_comment' && action == 'created') {
  67. change.threads.push({ event = 'review_comment.created', thread = body.thread, comment = body.comment })
  68. change.replyCandidate = true
  69. return change
  70. }
  71. if (name == 'review_thread' && (action == 'resolved' || action == 'unresolved')) {
  72. change.threads.push({ event = 'review_thread.' + action, thread = body.thread })
  73. change.kind = 'thread-state'
  74. return change
  75. }
  76. if (name == 'pull_comment' && action == 'created') {
  77. let m = null
  78. if (body.comment != null) { m = mention(body.comment.body) }
  79. if (m == null) { return { kind = 'ignore', reason = 'comment without @kunibert' } }
  80. if (m.reset) { change.reset = true change.force = true }
  81. if (m.note != null) { change.force = true change.notes.push({ text = m.note, by = body.comment.author }) }
  82. return change
  83. }
  84. return { kind = 'ignore', reason = name + '.' + action + ' not handled' }
  85. }

Branches

Latest commits

  • 070e01a4Records: parkmre
  • bf8af0dcRecords: v1.4 checkedmre
  • 44af321bRecords: contract v1.4mre
  • 310f3fd0Records: outdated semanticsmre
  • 268ebfe6Records: #11 proven live and closedmre
  • 88e8aad3Records: K11 verified and deployedmre
  • cd4cb09cNo review and status error when the model's tools did not run (kunibert#11)Kunibert
  • a6b54efaStatus updatemre
  • 5a72268eRecords: #4-#10 done, #11 started, review package on #1mre
  • 194c7da6Records: real proof greenmre
  • cdfa94a9Records: AppArmor profile for the review sandboxmre
  • c1bf02d8Status: sandbox blockermre
  • 88aaacc5Records: real proof part 2 (posting works, sandbox blocked by AppArmor userns)mre
  • 401df4e8Records: review user logged inmre
  • 6ca681b3Records: login command, status cleanupmre
  • 6b8d763cRecords: review user, device login startedKunibert
  • 07025b99Open the job worktree read-only for the review user before each model runKunibert
  • 2a44bd54Runner CLI: --review-user/--codex-bin/--work-dir work in every modeKunibert
  • 2177f66fReview model runs as its own unix user (reviewUser, codexBin, workDir)Kunibert
  • 35df8306Records: live service on byrodin, real proof part 1Kunibert