gitoria

kunibert

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit44af321b44af321bRecords: contract v1.4mre44af321b/missions/K3-memory.md

5.0 KB

  1. # Mission K3: memory per PR / session resume (kunibert#3)
  2. Task (his words, kunibert#1): "basically we want vinzenz now to build a similar tool with gitoria and hybriel."
  3. This step only: Kunibert keeps one model session per PR and, on a wake-up, resumes it with only the delta (Konrad's memory rules). Local only: no gitoria, no posting, no tickets.
  4. ## Read first
  5. - /media/STORAGE/projects/kunibert/docs/DESIGN.md (sections 3, 7) and reports/K2-runner.md (what exists).
  6. - /media/STORAGE/projects/kunibert/docs/konrad-handover/1-design-and-lessons.md ("Memory") and 2-prompts-and-memory.md (RULES and wakePrompt, verbatim).
  7. - The existing code: schema.json, tools/runner.hl, lib/runner.hl, lib/review-output.hl, lib/review-prompt.hl. Extend it; keep what works.
  8. - /media/STORAGE/projects/hybriel/docs/HL-PRIMER.md, docs/CODE-ORDER.md; plugins/proc/server.hl, plugins/fs as needed.
  9. Copy working shapes from the docs. Not covered → DOCS line in the report; a framework gap → GAP line with a minimal repro, no workaround. Hybriel .hl only, no JavaScript/TypeScript.
  10. ## Hard rule (from Apollo): code never leaves the sandbox
  11. Every codex call, including `codex exec resume`, must carry the `offline` flags in lib/runner.hl (`--ignore-user-config`, web_search disabled, apps/plugins/browser features off, `mcp_servers={}`) and run read-only with stdin /dev/null. Check that resume accepts them; if one is refused, report it and stop, do not drop it.
  12. ## Build
  13. 1. **State per PR**: one JSON file per PR under a data dir (e.g. `<data>/<repo-key>/<pr>.json`, written with hl:fs; data dir given as an argument; tests use /media/STORAGE/claude-scratch/kunibert/K3/data). Fields: session id, last reviewed head sha, generation counter, threads (key T<n>, path, line, axis, title, resolved, settled, seen watermark = highest comment id), settled keys, pending notes. Keep it simple; a database comes later.
  14. 2. **First review**: as today, plus store the session, head, and the findings as threads T1..Tn.
  15. 3. **Wake-up**: resume the stored session (`codex exec resume --json -c sandbox_mode="read-only" <offline flags> --output-schema <schema> <session> <prompt>`, run in the repo dir, prompt to a file when >16 KB). Prompt = Konrad's wakePrompt and RULES ported (Konrad→Kunibert, .konrad→.kunibert):
  16. - delta diff last..head limited to the PR's files (`git diff --name-status -z` merge-base..head, both rename sides) into `.kunibert/delta.diff`; full PR diff stays in `.kunibert/pr.diff`;
  17. - "rewritten" when the last head is not an ancestor of the new head;
  18. - "no new commits" / "new commits touch none of the PR's files" cases;
  19. - thread updates from a local input file (JSON: per thread new comments with id/author/body and resolved flips) standing in for gitoria; only comments above the watermark count;
  20. - open thread keys listed; skip the run entirely when nothing is new (same head, no new replies, not forced).
  21. Apply replies: resolve:true → thread resolved and settled. New findings → new threads.
  22. 4. **Generation guard**: a run reads the generation at start; if it changed before the write (reset meanwhile), its writes are dropped.
  23. 5. **Reset**: `@kunibert reset` = a fresh, unbiased session (as in Konrad): drop the session id and pending notes, keep the settled keys (they must survive), bump the generation.
  24. 6. **Lost session** (resume fails because the session is gone): fall back to a fresh session with a one-line ledger of earlier threads.
  25. 7. CLI: `tools/runner.hl review <data> <repo> <base> <head> [--threads <file>] [--force]` and `tools/runner.hl reset <data> <repo> <pr>`; one JSON line out as before. PR key may simply be the head branch name for now (gitoria will give a number).
  26. 8. Log `usage` per run in the state file (append), so cost per PR is known.
  27. ## Proof (real codex runs: at most 3 in total, each costs Sol quota; develop against saved outputs and a fake codex on PATH first, like K2 did)
  28. Test repo under /media/STORAGE/claude-scratch/kunibert/K3/ (never a real repo): main; branch `feature` with a planted bug (commit 1).
  29. - Run A (real): first review → finding stored as T1.
  30. - Commit 2 on `feature` fixes the bug; Run B (real): resume → the reply resolves T1 (resolve:true), no new finding repeating it, verdict approve or comment. Show the prompt that was sent (the delta only).
  31. - Without real runs (fake codex or no-op): same head and no new replies → skipped; a merge from main into feature → "touch none of the PR's files"; a force-push rewrite → "rewritten"; a reset during a run → its writes dropped; a missing session → fallback with ledger.
  32. - Show that every codex argv (first and resume) contains the offline flags.
  33. ## Limits
  34. - At most 3 real codex runs. About 60 tool calls. No sudo, no new users, no ~/.codex changes, no commits in the kunibert repo, no pushes, no tickets, no messages to others. Scratch only under /media/STORAGE/claude-scratch/kunibert/K3/.
  35. - Stop when done or blocked.
  36. ## Report
  37. /media/STORAGE/projects/kunibert/reports/K3-memory.md: files changed, the proof (exact commands, outputs, the wake prompt of run B), DOCS/GAP lines, usage of every real run, open points. Then stop.

Branches

Latest commits

  • 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
  • 3a8d93f9gitoria client: parse only JSON answers, accept a plain-text errorKunibert