root 19a65b87e3
Some checks failed
lakehouse/auditor 14 blocking issues: cloud: claim not backed — "Verified end-to-end:"
auditor: 3 fixes from Opus self-audit on 454da15 + tree-split deletion
The post-fix audit on commit 454da15 produced a fresh BLOCK and
re-flagged the dead tree-split as still dead. This commit lands the
BLOCK fix and the deletion.

LANDED:

1. kimi_architect.ts:113 BLOCK — MAX_TOKENS=128_000 exceeds Anthropic
   Opus 4.x's 32K output cap. Worked silently (Anthropic clamps
   server-side) but was technically invalid. Replaced single-default
   with `maxTokensFor(model)` returning per-model caps:
     claude-opus-*    -> 32_000  (Opus extended-output)
     claude-haiku-*   -> 8_192   (Haiku/Sonnet default)
     claude-sonnet-*  -> 8_192
     kimi-*           -> 128_000 (reasoning_content needs headroom)
     gpt-5*/o-series  -> 32_000
     default          -> 16_000  (conservative)
   LH_AUDITOR_KIMI_MAX_TOKENS env override still works (forces value
   regardless of model).

2. inference.ts dead-code removal — Opus flagged tree-split as still
   dead post-2026-04-27 mode-runner rebuild. Removed 156 lines:
     runCloudInference   (lines 464-503)  legacy /v1/chat caller
     treeSplitDiff       (lines 547-619)  shard-and-summarize fn
     callCloud           (lines 621-651)  helper for treeSplitDiff
     SHARD_MODEL         const            qwen3-coder:480b
     SHARD_CONCURRENCY   const            6
     DIFF_SHARD_SIZE     const            4500
     CURATION_THRESHOLD  const            30000
   No live callers — verified by grep before deletion. The mode
   runner's matrix retrieval against lakehouse_answers_v1 supplies
   the cross-PR context that tree-split was synthesizing from scratch.

3. inference.ts:38-49 stale comment about "curate via tree-split"
   replaced with current "matrix retrieval supplies cross-PR context"
   semantics. Block was already physically gone but the comment
   describing it remained, contradicting the actual code path.

SKIPPED (defensible / minor):

- WARN: outage sentinel TTL refresh on continued failure — intentional
  (refresh keeps cache valid while upstream is still down)
- WARN: enrichment counts use Math.max — defensible (consensus
  enrichment IS the max of the three runs)
- WARN: parseFindings regex eats severity into rationale on multi-
  paragraph inputs — minor, hasn't affected grounding rate
- WARN: selectModel uses pre-truncation diff.length — defensible
  (promotion is "is this audit worth Opus", not "what does the model
  see")
- INFO×3: static.ts state reset, parentStruct walk bound,
  appendMetrics 0-finding rows — all defensible per current intent

Verification:
  bun build auditor/checks/{inference,kimi_architect}.ts   compiles
  systemctl restart lakehouse-auditor.service              active

Net: -184 lines, +29 lines (155 net deletion).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-27 07:20:03 -05:00
..

Lakehouse Claim Auditor

A Bun sub-agent that watches open PRs on Gitea, reads the ship-claims in commit messages and PR bodies, and hard-blocks merges when the code doesn't back the claim.

Rationale: when "compiles + one curl works" gets called "phase shipped," placeholder code accumulates. This auditor runs every 90s, fetches each open PR, and subjects it to four checks:

  1. Static diff — grep/parse looking for placeholder patterns
  2. Dynamic — runs the never-before-executed hybrid test fixture
  3. Cloud inference — asks gpt-oss:120b via /v1/chat to identify gaps in the diff
  4. KB query — looks up data/_kb/ + observer for prior failure patterns on similar claims

Verdict is assembled, posted to Gitea as:

  • A failing commit status (hard block — branch protection prevents merge)
  • A review comment explaining every finding

Run manually

cd /home/profit/lakehouse
bun run auditor/index.ts

Defaults: polls every 90s, stops on auditor.paused file present.

State

  • data/_auditor/state.json — last-audited head SHA per PR
  • data/_auditor/verdicts/{pr}-{sha}.json — per-run verdict record
  • data/_kb/audit_lessons.jsonl — one row per block/warn finding, path-agnostic signature for dedup. Tailed by kb_query on each audit to surface recurring patterns (2+ distinct PRs with same signature → info, 3-4 → warn, 5+ → block). This is how the auditor learns.
  • data/_kb/scrum_reviews.jsonl — scrum-master per-file reviews. If a file in the current PR has been scrum-reviewed, kb_query surfaces the review as a finding with the accepted model and attempt count.

Where YOU edit

auditor/policy.ts — the verdict assembler. Controls which findings block vs warn vs inform. All other code is mechanical: fetching, running checks, posting to Gitea.

Hard-block mechanism

  1. Commit status is posted as failure with context lakehouse/auditor
  2. If main branch protection requires lakehouse/auditor status to pass, Gitea prevents merge
  3. When code is fixed and re-audit passes, status flips to success, merge unblocks

Enable branch protection (one-time, via Gitea UI or API):

  • POST /repos/profit/lakehouse/branch_protections
  • {"branch_name": "main", "required_status_checks": {"contexts": ["lakehouse/auditor"]}}