kunibert
All repositories: gitoria
5.1 KB
$mode = 'static'import { mkDir, tryReadFile, writeFile, exists, remove } from 'hl:fs'import { require, isList } from './review-output.hl'import { RULES_VERSION } from './review-prompt.hl'statePath = (String data, String repo, String pr) => {folder = data + '/' + encodeURIComponent(repo)mkDir(folder)return folder + '/' + encodeURIComponent(pr) + '.json'}loadState = (String path) => {text = tryReadFile(path)if (text != null) { return JSON.parse(text) }return { rules = RULES_VERSION, session = null, head = null, verdict = null, generation = 0, threads = [], settled = [], pending = [], usage = [] }}reset = (String data, String repo, String pr) => {path = statePath(data, repo, pr)let state = loadState(path)state.session = nullstate.pending = []state.generation = state.generation + 1writeFile(path, JSON.stringify(state))return { reset = true, generation = state.generation }}// The PR's session is removed (closed/merged PR): the state file goes. Answers whether there was one.drop = (String data, String repo, String pr) => {path = statePath(data, repo, pr)if (!exists(path)) { return { dropped = false } }remove(path)return { dropped = true }}// Author notes (`@kunibert <text>`) go to the state's pending list; the next prompt carries them and a finished run clears them.// A retry of the same job does not add them twice.addNotes = (String data, String repo, String pr, Hybrid notes) => {path = statePath(data, repo, pr)let state = loadState(path)for (n of notes) {let by = 'the author'if (n.by != null && hlTypeName(n.by) == 'Hybrid' && n.by.name != null) { by = '' + n.by.name }line = 'Note from ' + by + ' (@kunibert): ' + n.textif (!state.pending.includes(line)) { state.pending.push(line) }}writeFile(path, JSON.stringify(state))return state.pending.length}threadUpdates = (Hybrid state, String file) => {if (file == null) { return { =state, updates = [] } }return threadUpdatesFrom(state, JSON.parse(tryReadFile(file)))}// The same from an already parsed array. Comment ids are watermarks: in the local mode the file's own ids, with gitoria `comment.seq`.threadUpdatesFrom = (Hybrid state, Hybrid input) => {let updates = []require(isList(input), 'thread input must be an array')for (u of input) {let found = falsefor (let i = 0; i < state.threads.length; i = i + 1) {let t = state.threads[i]if (t.key != u.key) { continue }found = truelet bits = [t.key + ' ' + t.path + ':' + t.line + ' "' + t.title + '"']let changed = falseif (u.resolved != null) {require(hlTypeName(u.resolved) == 'Boolean', 'resolved must be boolean')if (u.resolved != t.resolved) {changed = trueif (u.resolved) { bits.push('was RESOLVED') } else { bits.push('was REOPENED') }t.resolved = u.resolvedif (u.resolved) { t.settled = true }}}if (u.comments != null) {require(isList(u.comments), 'comments must be an array')watermark = t.seenfor (c of u.comments) {require(hlTypeName(c.id) == 'Number' && c.id >= 0 && c.id % 1 == 0 && hlTypeName(c.author) == 'String' && hlTypeName(c.body) == 'String', 'invalid comment')if (c.id <= watermark) { continue }changed = truebits.push(c.author + ' replied: ' + JSON.stringify(c.body))if (c.id > t.seen) { t.seen = c.id }}}if (t.settled && !state.settled.includes(t.key)) { state.settled.push(t.key) }state.threads[i] = tif (changed) { updates.push('- ' + bits.join('; ')) }}require(found, 'unknown thread key: ' + u.key)}return { =state, =updates }}ledger = (Hybrid state, Boolean settledOnly = false) => {let lines = []for (t of state.threads) {if (settledOnly && !t.settled) { continue }lines.push(t.key + ' ' + t.path + ':' + t.line + ' [' + t.axis + '] ' + t.title + '; resolved=' + t.resolved + '; settled=' + t.settled)}return lines.join('')}applyResult = (Hybrid state, Hybrid result) => {for (reply of result.replies) {let found = falsefor (let i = 0; i < state.threads.length; i = i + 1) {let t = state.threads[i]if (t.key != reply.thread) { continue }found = trueif (reply.resolve) {t.resolved = truet.settled = trueif (!state.settled.includes(t.key)) { state.settled.push(t.key) }}state.threads[i] = t}require(found, 'reply references unknown thread: ' + reply.thread)}for (f of result.findings) {key = 'T' + (state.threads.length + 1)state.threads.push({ =key, path = f.path, line = f.line, axis = f.axis, title = f.title, resolved = false, settled = false, seen = 0, gid = null })}return state}
Branches
Latest commits
- 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
- 7480a98dkunibert.service: SIGTERM stop is a clean exitKunibert