gitoria

kunibert

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitcd4cb09ccd4cb09cNo review and status error when the model's tools did not run (kunibert#11)Kunibertcd4cb09c/lib/review-output.hl

4.3 KB

  1. $mode = 'static'
  2. isList = (value) => {
  3. return hlTypeName(value) == 'Hybrid' && JSON.stringify(value).startsWith('[')
  4. }
  5. require = (Boolean ok, String message) => {
  6. if (!ok) { hlError(message) }
  7. }
  8. parseResult = (String text) => {
  9. r = JSON.parse(text.trim())
  10. require(hlTypeName(r.summary) == 'String', 'result.summary must be a string')
  11. require(isList(r.findings), 'result.findings must be an array')
  12. require(isList(r.replies), 'result.replies must be an array')
  13. require(hlTypeName(r.axes.correctness) == 'String' && hlTypeName(r.axes.spec) == 'String' && hlTypeName(r.axes.standards) == 'String', 'result.axes must have three string axes')
  14. require(['approve', 'comment', 'request_changes'].includes(r.verdict), 'invalid verdict')
  15. require(hlTypeName(r.gates) == 'String', 'result.gates must be a string')
  16. for (let i = 0; i < r.findings.length; i = i + 1) {
  17. let f = r.findings[i]
  18. if (!['correctness', 'spec', 'standards'].includes(f.axis)) { f.axis = 'correctness' }
  19. require(hlTypeName(f.path) == 'String' && hlTypeName(f.title) == 'String' && hlTypeName(f.body) == 'String', 'invalid finding text')
  20. require(hlTypeName(f.line) == 'Number' && f.line >= 1 && f.line % 1 == 0, 'invalid finding line')
  21. require(['blocker', 'major', 'minor', 'nit'].includes(f.severity), 'invalid finding severity')
  22. r.findings[i] = f
  23. }
  24. for (reply of r.replies) {
  25. require(hlTypeName(reply.thread) == 'String' && hlTypeName(reply.body) == 'String' && hlTypeName(reply.resolve) == 'Boolean', 'invalid reply')
  26. }
  27. return r
  28. }
  29. parseEvents = (Hybrid lines) => {
  30. let session = null
  31. let message = ''
  32. let error = null
  33. let usage = { input_tokens = 0, cached_input_tokens = 0, output_tokens = 0 }
  34. // Tool executions the model made (kunibert#11): a command_execution item that completed is a success, any other end (failed/declined) a failure.
  35. // A tool call that could not even start (missing helper, broken sandbox) makes no item at all, so "no successful command" is the signal.
  36. let commandsOk = 0
  37. let commandsFailed = 0
  38. let spawnFailures = 0
  39. for (line of lines) {
  40. if (!line.startsWith('{')) { continue }
  41. e = JSON.parse(line)
  42. if (e.type == 'thread.started' && e.thread_id) { session = e.thread_id }
  43. if (e.type == 'item.completed' && e.item.type == 'agent_message' && hlTypeName(e.item.text) == 'String') { message = e.item.text }
  44. if (e.type == 'item.completed' && e.item.type == 'command_execution') {
  45. if (e.item.status == 'completed') { commandsOk = commandsOk + 1 }
  46. else {
  47. commandsFailed = commandsFailed + 1
  48. out = hlTypeName(e.item.aggregated_output) == 'String' ? e.item.aggregated_output : ''
  49. if (out.includes('failed to spawn') || out.includes('bwrap:') || out.includes('Operation not permitted')) { spawnFailures = spawnFailures + 1 }
  50. }
  51. }
  52. if (e.type == 'error' || e.type == 'turn.failed') {
  53. error = e.message
  54. if (error == null) { error = e.error.message }
  55. if (error == null) { error = JSON.stringify(e) }
  56. }
  57. if (e.usage != null) {
  58. for (key in e.usage) {
  59. require(hlTypeName(e.usage[key]) == 'Number', 'invalid usage counter')
  60. if (usage[key] == null) { usage[key] = 0 }
  61. usage[key] = usage[key] + e.usage[key]
  62. }
  63. }
  64. }
  65. return { =session, =message, =error, =usage, =commandsOk, =commandsFailed, =spawnFailures }
  66. }
  67. // needsCode: the run must have read the code (first review, new head, forced); a wake on an unchanged head may answer from memory.
  68. // No result without evidence that the tools worked: no successful command while the code had to be read, or only failed commands that
  69. // show a spawn/sandbox failure, is an error, whatever "review" the model wrote (kunibert#11). One failed command among successes is normal.
  70. checked = (Hybrid events, Number code, Boolean needsCode = true) => {
  71. require(code == 0 && events.error == null, 'codex failed (' + code + '): ' + events.error)
  72. require(events.commandsOk > 0 || (!needsCode && events.spawnFailures == 0), 'the model\'s tools failed')
  73. require(events.message != '', 'codex produced no final message')
  74. return { session = events.session, usage = events.usage, result = parseResult(events.message) }
  75. }

Branches

Latest commits

  • 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
  • 7480a98dkunibert.service: SIGTERM stop is a clean exitKunibert
  • 3a8d93f9gitoria client: parse only JSON answers, accept a plain-text errorKunibert
  • c9b48bfeVendor Hybriel plugins; deploy ships bin/ from zig-outKunibert
  • a41ba15fKunibert: event intake, git cache, review runner, posting, linked tickets, deploy filesKunibert