Skip to content

feat(commands): add @gittensory chat <question> — grounded LLM Q&A via local Ollama - #4985

Merged
JSONbored merged 1 commit into
mainfrom
feat/chat-qa-command-4595
Jul 11, 2026
Merged

feat(commands): add @gittensory chat <question> — grounded LLM Q&A via local Ollama#4985
JSONbored merged 1 commit into
mainfrom
feat/chat-qa-command-4595

Conversation

@JSONbored

@JSONbored JSONbored commented Jul 11, 2026

Copy link
Copy Markdown
Owner

Summary

Adds a new @gittensory chat <question> command that answers a contributor's real question in natural prose, sourced from the same cached decision-pack facts ask/preflight already read — but generated entirely by local Ollama (env.AI_ADVISORY), never the frontier chain.

  • New generation service (src/services/ai-chat-qa.ts): enable-flag → shared daily neuron-budget gate → provider call → output-safety check, mirroring ai-summaries.ts's shape. Redacts private decision-pack terms before they ever reach the prompt.
  • New chatQa capability flag on advisoryAiRouting (default false), threaded through the type, both normalizers (+ engine-package twin), the focus-manifest merge, OpenAPI schema, and both yml config examples. Unlike the 4 existing capabilities, this one never falls back to the frontier chain — it declines instead.
  • Registered in DEFAULT_COMMAND_AUTHORIZATION_POLICY as ["maintainer", "collaborator"] (narrower than ask's default — excludes confirmed_miner for v1), and in AI_COST_BEARING_COMMANDS for the tighter per-command rate limit.
  • New Q&A-catalog-only command, structurally isolated from the write-capable action catalog. A static import-isolation test asserts the generation module can never reach a write/action handler or an undeclared DB-mutation helper.
  • Fixed, non-LLM disclaimer footer on every answer card: read-only, cannot change review outcomes or gate state.
  • The model's own generated text is markdown-neutralized the same way ask's question text already is (neutralizePublicMarkdownText + sanitizePublicComment), since this is the first surface where model output — not just user input — is echoed into a trusted bot comment.

Closes #4595
Part of #4594

Test plan

  • Unit tests for every ChatQaResult status (disabled/unavailable/declined ×3/quota_exceeded/unsafe/ok/error) and the pure grounding-redaction helpers (test/unit/ai-chat-qa.test.ts)
  • Import-isolation architecture test (test/unit/ai-chat-qa-import-isolation.test.ts)
  • Parser, authorization default, rate-limit-set membership, and full answer-card rendering incl. the injection-neutralization regression (test/unit/github-commands.test.ts)
  • Full end-to-end webhook dispatch test proving processors.ts actually reaches generateChatQaAnswer for a real chat command (test/unit/queue-5.test.ts)
  • Capability-flag normalization + focus-manifest merge tests (both app and engine-package copies)
  • npm run typecheck, npm run test:coverage (unsharded), npm run test:ci, npm audit --audit-level=moderate all green
  • npm run ui:openapi and npm run command-reference regenerated and committed
  • npx tsx scripts/check-engine-parity.ts passes

@superagent-security

Copy link
Copy Markdown
Contributor

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

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 11, 2026

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 767f73c Commit Preview URL

Branch Preview URL
Jul 11 2026, 07:48 AM

@codecov

codecov Bot commented Jul 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.33%. Comparing base (f175e0c) to head (767f73c).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4985      +/-   ##
==========================================
+ Coverage   94.31%   94.33%   +0.01%     
==========================================
  Files         455      456       +1     
  Lines       39083    39185     +102     
  Branches    14256    14288      +32     
==========================================
+ Hits        36862    36965     +103     
  Misses       1572     1572              
+ Partials      649      648       -1     
Flag Coverage Δ
shard-1 46.82% <33.98%> (-0.04%) ⬇️
shard-2 33.41% <30.09%> (+0.05%) ⬆️
shard-3 31.50% <6.79%> (+0.37%) ⬆️
shard-4 32.72% <69.90%> (-0.28%) ⬇️
shard-5 33.56% <6.79%> (-0.07%) ⬇️
shard-6 45.16% <8.73%> (-0.10%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
packages/gittensory-engine/src/focus-manifest.ts 99.17% <100.00%> (+<0.01%) ⬆️
...ry-engine/src/review/advisory-ai-routing-config.ts 100.00% <ø> (ø)
...nsory-engine/src/settings/command-authorization.ts 100.00% <ø> (ø)
src/github/commands.ts 98.27% <100.00%> (+0.09%) ⬆️
src/openapi/schemas.ts 100.00% <ø> (ø)
src/queue/processors.ts 95.30% <100.00%> (+0.03%) ⬆️
src/review/advisory-ai-routing-config.ts 100.00% <ø> (ø)
src/services/ai-chat-qa.ts 100.00% <100.00%> (ø)
src/settings/command-authorization.ts 100.00% <ø> (ø)
src/signals/focus-manifest.ts 99.64% <100.00%> (+<0.01%) ⬆️
... and 1 more
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@loopover-orb loopover-orb Bot added the gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. label Jul 11, 2026
@loopover-orb

loopover-orb Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Warning

🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨

⏸️ Gittensory review result - manual review recommended

Review updated: 2026-07-11 07:51:06 UTC

27 files · 1 AI reviewer · no blockers · readiness 100/100 · CI green · clean

⏸️ Suggested Action - Manual Review

  • Touches a guarded path — held for manual review: This PR changes guardrail-protected path(s): src/queue/processors.ts (matched src/queue/**), src/services/ai-chat-qa.ts (matched src/services/**).

Review summary
Adds a self-contained `@​gittensory chat <question>` capability generated exclusively via local Ollama (env.AI_ADVISORY), with a hard decline-not-fallback design that is distinct from the four existing advisoryAiRouting capabilities, and threads the new `chatQa` flag through every required site (types, both normalizers/twins, focus-manifest merge, OpenAPI schema+doc, yml examples, command-authorization defaults, AI_COST_BEARING_COMMANDS). The generation module is import-isolated from the write/action path and DB-mutation helpers, verified by a dedicated static-analysis test, and both the contributor question and the model's own output are run through the same sanitizePublicComment/neutralizePublicMarkdownText pipeline `ask` already uses, plus a pre-prompt regex redaction and a post-generation forbidden-term check before anything model-authored reaches the public card. Tests cover every ChatQaResult status, the redaction/compaction helpers, focus-manifest override precedence, command authorization defaults, and an end-to-end queue dispatch for both the enabled and default-off paths — this is a well-scoped, issue-linked (#4595, part of #4594) change with no scope creep and no schema/migration gap since advisoryAiRouting is an existing schemaless JSON blob.

Nits — 7 non-blocking
  • The pre-prompt redaction in `redactGroundingText` (src/services/ai-chat-qa.ts) is an explicit regex allow-list of known blocker codes/boundary terms — a newly added private blocker code elsewhere in the codebase won't be redacted here until this file is updated in lockstep; worth a comment or a shared constant so the two don't drift.
  • Several new magic numbers (256/64/512 token clamps, 0.1 temperature, the 5/4/4/8 slice caps, the 4-chars-per-token and 0.035 neurons-per-token heuristics in src/services/ai-chat-qa.ts) would read clearer as named constants, especially since ai-summaries.ts is cited as the model this mirrors.
  • test/unit/queue-5.test.ts:1284 was flagged by secret scanning for `GITHUB_APP_PRIVATE_KEY: await generatePrivateKeyPem()` — please confirm this is a freshly generated ephemeral test key and not a checked-in fixture, since the helper name alone doesn't rule out a hardcoded PEM.
  • The OpenAPI description notes `commandRateLimitPolicy: hold` as a co-requisite for the tighter AI-cost rate limit to actually apply, but that's documentation-only — since the fleet default is `off`, an operator who enables `chatQa` without also flipping that policy gets an AI-cost-bearing command with no effective per-window ceiling; consider surfacing this more forcefully than a schema description (e.g., a warning in the normalizer) so it isn't missed.
  • Consider a shared constant/list for the private blocker codes so `PRIVATE_DECISION_BLOCKER_PATTERN` and any public-redaction helper elsewhere in the codebase can't silently diverge as new blocker codes are added.
  • PR author also opened the linked issue — Link an issue that was opened by a different contributor, or provide a rationale for why this self-authored issue represents genuine discovery work.
  • Touches a guarded path — held for manual review — A maintainer must review and merge this change.
Signal Result Evidence
Code review ✅ No blockers 1 reviewer
Linked issue ✅ Linked #4595
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (1 linked issue).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 48 registered-repo PR(s), 40 merged, 420 issue(s).
Contributor context ✅ Confirmed Gittensor contributor JSONbored; Gittensor profile; 48 PR(s), 420 issue(s).
Gate result ⚠️ Not blocking Advisory; not blocking this PR.
Improvement ✅ Minor risk: clean · value: minor — Code changes are accompanied by test evidence.
Review context
  • Author: JSONbored
  • Role context: owner (maintainer lane)
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: not available
  • Official Gittensor activity: 48 PR(s), 420 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Treat this as maintainer-lane context rather than normal contributor-lane activity.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
Visual preview
Route Viewport Before (production) After (this PR's preview) Diff
/ desktop before / after /
/ mobile before / (mobile) after / (mobile)

Click any thumbnail to open the full-size screenshot. Before = production · After = this PR's preview deploy.

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.

  • Re-run Gittensory review

@loopover-orb loopover-orb Bot added the manual-review Gittensor contributor context label Jul 11, 2026
…a local Ollama

Extends the existing advisoryAiRouting capability set with a 5th, Ollama-only
capability (chatQa) that never falls back to the frontier chain. The new
generation service rewrites the same cached decision-pack facts ask/preflight
already read into natural prose, structurally confined to the Q&A command
catalog so it can never reach a write/action path.

Closes #4595
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. manual-review Gittensor contributor context

Development

Successfully merging this pull request may close these issues.

feat(commands): add @gittensory chat <question> — grounded LLM Q&A via local Ollama

1 participant