kunibert
All repositories: gitoria
6.5 KB
# K4 git cache and local diff — reportAll proofs ran against a LOCAL stand-in remote (`file://`, scratch only), with a fake codex. No real codex, no gitoria, no commits.## Files- NEW `lib/gitcache.hl`: ref names in ONE place (`prHeadRemote/prHeadLocal/baseRemote/baseLocal`: `refs/pull/<N>/head` -> `refs/kunibert/pr/<N>`, `refs/heads/<base>` -> `refs/kunibert/base/<base>`), `maxDiffBytes = 400000`, `repoKey` (encodeURIComponent, `%`->`_`, `.`->`_2e`), `authEnv(tokenFile)` (the only token code), `cacheRepo` (bare `<data>/git/<key>.git`, `git init --bare` on first use), `fetchRefs` (`fetch --quiet --no-tags --force <url> +pr:+base`, timeout 120), `addWorktree`/`removeWorktree`/`worktreePath` (`<data>/work/<key>/<N>`).- CHANGED `lib/runner.hl`: `review` (local) now only checks and calls the new shared `runReview(path, gitDir, work, baseSha, headSha, threads, forced, cache, checkoutSha)`; new `reviewPr`. merge-base, diff, delta (rename sides, rewritten) run in `gitDir` (the bare cache for PRs). Order in a PR run: fetch -> shas -> skip check -> diff + size cap -> delta -> worktree created only when a model run is certain -> `.kunibert/pr.diff`, `delta.diff` written in the worktree -> codex (cwd = worktree) -> `cleanup()` before result validation. Exported `cleanup()` removes a live worktree; the tool's global `on Error` calls it too (failure anywhere). A stale worktree at the same path is removed before a new one is made.- CHANGED `tools/runner.hl`: `review-pr <data> <remote-url> <pr> <base> [--token-file f] [--threads f] [--force]`; `review` and `reset` unchanged. Error JSON with `error` key -> exit 1.- Token: `GIT_CONFIG_COUNT=1`, `GIT_CONFIG_KEY_0=http.extraHeader`, `GIT_CONFIG_VALUE_0=Authorization: Bearer <token>` as `env` of the fetch child only; token read from file via `cat` (argv holds only the file path). PR state key = PR number (`<data>/<urlencoded url>/1.json`).## Commands- Proof: `cd /media/STORAGE/claude-scratch/kunibert/K4 && python3 proof.py` (output saved in `K4/proof-output.txt`; fake codex `K4/bin/codex` copies the worktree's `.kunibert/*` to `K4/calls/NN` and prints a valid saved-style output; `mode` file `fail` = exit 1).- Single run: `PATH=K4/bin:$PATH hybriel tools/runner.hl review-pr K4/data file:///media/STORAGE/claude-scratch/kunibert/K4/remote.git 1 main --token-file K4/tok`## Proof results (all "ALL OK")1. First run: bare cache created, `for-each-ref` shows exactly `refs/kunibert/base/main` and `refs/kunibert/pr/1`; codex cwd was `<data>/work/<key>/1`, that dir is gone afterwards (and `git worktree list` shows only the bare repo); `.kunibert/pr.diff` identical to `git diff $(merge-base main refs/pull/1/head) refs/pull/1/head` run in the remote; state file `<data>/<url>/1.json` stored.2. Commit pushed to PR ref: delta.diff contains only the new `+d` hunk of a.txt (new.txt not in it).3. Force push (history rewrite): bare ref equals remote ref afterwards (forced update picked up); prompt says "The branch history was rewritten…", delta.diff empty.4. Base moved (main touches other.txt), PR head merges main: prompt "New commits … touch none of this PR's files (e.g. a merge from the base branch)". Also a base-only move with `--force` -> "No new commits since your last review".5. Diff 486236 B > cap: `{"error":"diff too large","bytes":486236,"limit":400000}`, exit 1, no fake-codex call (calls dir count unchanged), no worktree left.6. Fake codex exit 1: error JSON `codex failed (1)`, exit 1, `data/work/*/*` empty, `git worktree list` clean.7. Token (`TESTTOKEN123` in a file): bare `config` (printed in output) has no token; not in FETCH_HEAD/HEAD; not in the codex argv; a git wrapper on PATH logged every git argv (printed, no token) and counted the token in each git child's env: 1 for the fetch, 0 for all others. Not tested: a real HTTPS server accepting the header (no network).8. Existing K3 proof: copied K3 `setup.py`/`proof-fake.py` to `K4/k3rerun` (paths rewritten) and re-ran against the new code: all steps skip/resolve/comments/comments-skip/force/merge/rewrite/missing/generation passed; the LAST assertion of that old script (`after-reset` expects the text "Earlier thread ledger") fails, because since K3's final changes a reset fresh review writes "Settled thread ledger (fresh review…)" (unchanged code path, I did not touch it) — stale assertion, not a regression. `reset` command ran inside that proof (mode `reset`) and worked.## DOCS / GAP- DOCS: expression-bodied lambdas (`f = (x) => x + 1`) are rejected: "body is a BLOCK — '=>' must be followed by '{'"; the error text is clear, HL-PRIMER does not say it in one line (found by trying).- DOCS: hl:fs `remove` only deletes a file or an EMPTY directory (documented in the source, not in a recursive form), so the worktree is removed with `git worktree remove --force` (plus `rm -rf` fallback via `run`).- GAP: none found. No try/finally in HL, so cleanup is "cleanup before validation + global `on Error` calls `cleanup()` + stale-removal before the next worktree". A hard kill (SIGKILL) leaves a worktree until the next run of the same PR removes it.## Open points- Ref names are assumed; the real gitoria names change only `lib/gitcache.hl`.- Fetch failures surface as `git failed (…): <stderr>`; stderr could echo the URL (no token is in it by construction) — fine for logs.- Size cap applies to `review` (local) too (same core); the "operator alert" is not built.- Concurrent runs of the same PR would share one worktree path and one cache; no locking yet (the caller must serialize per PR).- `repoKey` is long for file URLs (full encoded URL); fine for HTTPS URLs, could be hashed if path length matters.## Fix 1 (gitoria apps-api.md section 2: Basic auth)- `lib/gitcache.hl` `authEnv`: header is now `Authorization: Basic ` + `toBase64('app:' + token)`, `import { toBase64 } from 'hl:crypto'` (works as written). Token file is read with hl:fs `readFile` (first line, trimmed; empty -> error) instead of `cat`. No other file touched.- Re-run: `python3 K4/proof.py` -> ALL OK (output `K4/proof-output-fix1.txt`; first run, delta, rewrite, base-moved, cap, failure cleanup). Token test: neither `TESTTOKEN123` nor its base64 `YXBwOlRFU1RUT0tFTjEyMw==` appears in the proof output, the bare repo config (0 matches), git argv log or codex argv. An env-logging git wrapper showed the fetch child alone got `Authorization: Basic YXBwOlRFU1RUT0tFTjEyMw==` (= base64 of `app:TESTTOKEN123`); every other git child got an empty value.- The old env count (raw token string) is meaningless now since the value is base64; the header check above replaces it. No GAP.
Branches
Latest commits
- bd3591c7conductor: gates run on the live day44 binarymre
- 47f747a7records: jukebox #9 fix livemre
- 0a3169fdMerge branch 'vendored-size' into mainKunibert
- e447bb09Vendored size fix: keep renames with an app side whole; type the filter parameter (L10)mre
- 99ccc742Vendored size fix: no renames in the app diff, filter the resumed delta toomre
- 1a52e100|||PR Diff size limit counts only app files when vendored paths are setmre
- 50a1867estatus: jukebox #9mre
- c57484e6log: jukebox #9 diff sizemre
- 795a20carecords: guard fix live (PR 8)mre
- 6981d96fMerge branch 'fresh-on-nocmd' into mainKunibert
- 37c47840runner: one shared prompt for both fresh-session fallbacks (L16)mre
- f945d2e1|||PR runner: a resumed run with no command on a new head gets one fresh session instead of a tool errormre
- 10b2a49estatus: PR 314, guard fix proposedmre
- e73995a3log: hycon PR 314 approved after fresh reviewmre
- f60427falog: hycon PR 314 false tool errormre
- 481974f7log: Hermes accepts PR 259 findingmre
- bb0976acrecords: hycon PR 259 design findingmre
- 5c637c24records: hycon PR 259 false tool errormre
- a344c406log: routger 132 reviewedmre
- 56e70dcbrecords: review time limit 1800 s (routger 132)mre