Skip to content

feat(selfhost): local-inference binding for advisory-tier AI capabilities (AI_ADVISORY) - #4388

Merged
JSONbored merged 1 commit into
mainfrom
claude/ai-advisory-binding
Jul 9, 2026
Merged

feat(selfhost): local-inference binding for advisory-tier AI capabilities (AI_ADVISORY)#4388
JSONbored merged 1 commit into
mainfrom
claude/ai-advisory-binding

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Summary

  • Closes feat(selfhost): local-inference binding for advisory-tier AI capabilities (AI_ADVISORY) #4364. Only the core PR review needs frontier-model accuracy — it drives real gate blockers. Slop advisory, e2e test-gen, the issue planner, and AI summaries/rewrite are all advisory-only and were sharing the same frontier claude-code/codex chain purely because no cheaper alternative existed, spending real subscription tokens on every PR.
  • Adds env.AI_ADVISORY, wired in src/server.ts mirroring AI_EMBED/AI_VISION's exact pattern (AI_ADVISORY_BASE_URL/_MODEL/_API_KEY, absent-binding fallback to env.AI).
  • Routing is config-driven per capability via .gittensory.yml settings.advisoryAiRouting (global default + per-repo override, config-as-code only — no DB column, mirrors unlinkedIssueGuardrail's shape). Never hardcoded which capability uses it.
  • Wired at all four real call sites via a shared withAdvisoryAiEnv helper (src/selfhost/ai.ts): runAiSlopForAdvisory, the e2e-test-gen delivery path, the issue-planner command handler, and the agent-run AI summary attachment.
  • Fail-safe identical to AI_VISION/AI_EMBED: absent binding ⇒ every capability falls back to the existing shared env.AI chain, byte-identical to today.

Scope

  • env.AI_ADVISORY binding + .env.example documentation
  • AdvisoryAiRoutingConfig type + normalizer (both src/ and packages/gittensory-engine/src/ mirrors)
  • Engine package yml parser + resolveEffectiveSettings overlay
  • .gittensory.yml.example + config/examples/gittensory.full.yml documentation (byte-synced)
  • npm run selfhost:env-reference regenerated
  • OpenAPI regenerated (RepositorySettingsSchema read-only field, matches check-openapi-settings-parity)

Validation

  • npx tsc --noEmit -p . — clean
  • npm run ui:openapi:settings-parity — 101 fields, matches
  • npm run manifest:drift-check / npm run db:migrations:check / npm run db:schema-drift:check — clean
  • Dedicated tests: withAdvisoryAiEnv (3 branch cases), the yml normalizer (both mirrors, malformed/valid/omitted cases), the resolveEffectiveSettings sparse-overlay (parse + merge + malformed-field-drop), and an end-to-end call-site regression test on runAiSlopForAdvisory proving the actual provider swap (routes to AI_ADVISORY when opted in + configured, falls back to env.AI otherwise, including when the binding itself is absent)
  • Full suite run clean on this branch: test/unit/queue.test.ts (752 tests), agent-orchestrator.test.ts, ai-summaries.test.ts, selfhost-ai.test.ts, focus-manifest.test.ts, config-templates.test.ts — all passing

Safety

  • No secrets/wallets/hotkeys/trust-scores/reward values touched
  • Zero risk to the core review's model/accuracy — that call path is untouched
  • Fail-safe fallback to env.AI verified for both "capability opted out" and "binding unconfigured" cases

…ties (AI_ADVISORY)

Only the core PR review needs frontier-model accuracy -- it drives real
gate blockers. Slop advisory, e2e test-gen, the issue planner, and AI
summaries/rewrite are all advisory-only (never gate-blocking) and were
sharing the same frontier claude-code/codex chain purely because no
cheaper alternative existed, silently spending real subscription tokens
on every PR regardless of the repo's review-effort setting (which only
ever threaded through the core review path).

Adds env.AI_ADVISORY, wired in src/server.ts mirroring AI_EMBED/AI_VISION's
exact pattern (AI_ADVISORY_BASE_URL/_MODEL/_API_KEY, createOpenAiCompatibleAi,
absent-binding fallback to env.AI). Routing is config-driven per capability
via .gittensory.yml settings.advisoryAiRouting (global default + per-repo
override, config-as-code only, mirrors unlinkedIssueGuardrail's shape) --
never hardcoded, and a capability only actually routes through the local
binding when both the yml opt-in AND the binding itself are configured.

Wired at all four real call sites via a shared withAdvisoryAiEnv helper
(src/selfhost/ai.ts): runAiSlopForAdvisory, the e2e-test-gen delivery
path, the issue-planner command handler, and the agent-run AI summary
attachment. Zero risk to the core review's accuracy since that path is
untouched.
@JSONbored JSONbored self-assigned this Jul 9, 2026
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@JSONbored JSONbored added the gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. label Jul 9, 2026
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
gittensory-ui a246484 Commit Preview URL

Branch Preview URL
Jul 09 2026, 06:43 AM

@JSONbored
JSONbored merged commit dc37aea into main Jul 9, 2026
10 checks passed
@JSONbored
JSONbored deleted the claude/ai-advisory-binding branch July 9, 2026 06:44
@codecov

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.82609% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 93.96%. Comparing base (084cb38) to head (a246484).
⚠️ Report is 5 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
packages/gittensory-engine/src/focus-manifest.ts 90.90% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4388   +/-   ##
=======================================
  Coverage   93.95%   93.96%           
=======================================
  Files         400      402    +2     
  Lines       36820    36863   +43     
  Branches    13452    13475   +23     
=======================================
+ Hits        34595    34638   +43     
  Misses       1569     1569           
  Partials      656      656           
Files with missing lines Coverage Δ
...ry-engine/src/review/advisory-ai-routing-config.ts 100.00% <100.00%> (ø)
src/openapi/schemas.ts 100.00% <ø> (ø)
src/queue/processors.ts 95.39% <100.00%> (ø)
src/review/advisory-ai-routing-config.ts 100.00% <100.00%> (ø)
src/selfhost/ai.ts 98.65% <100.00%> (+<0.01%) ⬆️
src/services/agent-orchestrator.ts 95.80% <100.00%> (+0.02%) ⬆️
src/signals/focus-manifest.ts 99.63% <100.00%> (+<0.01%) ⬆️
src/types.ts 100.00% <ø> (ø)
packages/gittensory-engine/src/focus-manifest.ts 99.08% <90.90%> (-0.09%) ⬇️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier.

Development

Successfully merging this pull request may close these issues.

feat(selfhost): local-inference binding for advisory-tier AI capabilities (AI_ADVISORY)

1 participant