Some checks failed
lakehouse/auditor 16 blocking issues: cloud: claim not backed — "Verified end-to-end:"
Migrates the four TypeScript /generate callers to the gateway's
/v1/chat surface so every LLM call lands on /v1/usage and Langfuse:
tests/multi-agent/agent.ts::generate() provider="ollama"
tests/agent_test/agent_harness.ts::callAgent provider="ollama"
bot/propose.ts::generateProposal provider="ollama_cloud"
mcp-server/observer.ts (error analysis) provider="ollama"
Each migration follows the same pattern as the prior generateCloud()
migration (already on /v1/chat from 2026-04-24): replace
`fetch(SIDECAR/generate)` with `fetch(GATEWAY/v1/chat)`, swap the
prompt-style body for OpenAI-compat messages array, extract
content from `choices[0].message.content` instead of `text`.
Same upstream models in every case — gateway is the new home for
the call, transport otherwise unchanged.
Adds scripts/check_phase44_callers.sh — fail-loud regression guard
that exits non-zero if any non-adapter file fetches /generate or
api/generate. Adapter files (crates/gateway, crates/aibridge,
sidecar/) are exempt. Pre-tightening regex flagged prose mentions
in comments; the shipped regex requires `fetch(...)` or
`client.post(...)` shape so comments don't trip it.
Verification:
bun build mcp-server/observer.ts compiles
bun build tests/multi-agent/agent.ts compiles
bun build tests/agent_test/agent_harness.ts compiles
bun build bot/propose.ts compiles
./scripts/check_phase44_callers.sh ✅ clean
systemctl restart lakehouse-observer active
Phase 44 part 2 (deferred):
- crates/aibridge/src/client.rs:118 still posts to sidecar /generate
directly. AiClient is the foundational Rust LLM caller used by
8+ vectord modules; migrating it is a workspace-wide refactor
that needs its own commit. Plan: keep AiClient as the local-
transport layer for the gateway's `provider=ollama` arm, but
introduce a thin `/v1/chat` wrapper for external callers (vectord
autotune, agent, rag, refresh, supervisor, playbook_memory).
- tests/real-world/hard_task_escalation.ts: comment mentions
/api/generate but doesn't actually call it. Comment is left
intentionally as historical context; regex no longer flags it.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
59 lines
2.0 KiB
Bash
Executable File
59 lines
2.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Phase 44 caller-migration guard. Fails if any non-adapter file
|
|
# fetches the sidecar's /generate endpoint or hits Ollama Cloud's
|
|
# /api/generate directly. Adapter files (gateway provider crate +
|
|
# the sidecar's own Python implementation) are exempt.
|
|
#
|
|
# Run: ./scripts/check_phase44_callers.sh
|
|
# CI: fail-loud (exits non-zero on regression)
|
|
# Watch: pre-commit hook — invoke from .git/hooks/pre-commit
|
|
|
|
set -e
|
|
cd "$(dirname "$0")/.."
|
|
|
|
FORBIDDEN_TS=$(grep -rEln "fetch\([^)]*[/\$]generate" \
|
|
--include="*.ts" \
|
|
--exclude-dir=node_modules \
|
|
--exclude-dir=target \
|
|
--exclude-dir=.git \
|
|
. 2>/dev/null | grep -v "^\./sidecar/" || true)
|
|
|
|
FORBIDDEN_RS=$(grep -rEln "post\([^)]*\"\.?/generate\"" \
|
|
--include="*.rs" \
|
|
--exclude-dir=target \
|
|
. 2>/dev/null | \
|
|
grep -vE "^\./crates/(gateway|aibridge)/" || true)
|
|
|
|
# Ollama Cloud /api/generate outside the gateway adapter. Match only
|
|
# when the URL appears in an actual fetch/post call (not in a comment).
|
|
# Tightened 2026-04-27 — pre-tightening regex flagged prose mentions.
|
|
FORBIDDEN_CLOUD=$(grep -rEln "(fetch|client\.post)\([^)]*api/generate" \
|
|
--include="*.ts" --include="*.rs" \
|
|
--exclude-dir=node_modules \
|
|
--exclude-dir=target \
|
|
--exclude-dir=.git \
|
|
. 2>/dev/null | \
|
|
grep -vE "^\./(crates/gateway|sidecar)" || true)
|
|
|
|
ANY_FAIL=0
|
|
if [ -n "$FORBIDDEN_TS" ]; then
|
|
echo "❌ Direct sidecar /generate calls (migrate to /v1/chat):"
|
|
echo "$FORBIDDEN_TS" | sed 's/^/ /'
|
|
ANY_FAIL=1
|
|
fi
|
|
if [ -n "$FORBIDDEN_RS" ]; then
|
|
echo "❌ Direct Rust /generate post() calls (migrate via gateway adapter):"
|
|
echo "$FORBIDDEN_RS" | sed 's/^/ /'
|
|
ANY_FAIL=1
|
|
fi
|
|
if [ -n "$FORBIDDEN_CLOUD" ]; then
|
|
echo "❌ Direct Ollama Cloud /api/generate (migrate to gateway provider=ollama_cloud):"
|
|
echo "$FORBIDDEN_CLOUD" | sed 's/^/ /'
|
|
ANY_FAIL=1
|
|
fi
|
|
|
|
if [ $ANY_FAIL -eq 0 ]; then
|
|
echo "✅ Phase 44 caller-migration: clean (no direct /generate outside adapters)"
|
|
fi
|
|
exit $ANY_FAIL
|