feat(ai-provider,core): implement CodeGenerationProvider seam (G5 Phase 1)#494
Conversation
…se 1)
core declared a `CodeGenerationProvider` interface ("implemented by
cap-ai-provider") but no implementation existed and the type was on no public
barrel. This is G5 Phase 1 — the foundation for AI code generation of the
irreducibly-code parts of a proposal (action / event-handler / flow logic bodies
a declarative ChangeDefinition cannot express).
- @linchkit/core/server now exports CodeGenerationProvider / CodeGenerationResult
/ ProjectContext / QualityGateRunner (type-only) so a capability can implement
the seam.
- @linchkit/cap-ai-provider adds createCodeGenerationProvider(ai, options): a
thin adapter over the configured AIService (GLM per linchkit.config, never
hardcoded). generateCode(prompt, context?) shapes context→system + prompt→user,
defaults temperature 0 + taskType "code", forwards model/maxTokens/tenantId,
and throws when the AIService is unconfigured.
SAFETY: adds only the generator — NOT wired into any live path. It only produces
candidate source as a string; never writes files, runs code, or touches the
approval/graduation pipeline. Generated source still flows through validation +
double human review (draft + graduation PR). "AI never modifies production
directly."
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Warning Review limit reached
More reviews will be available in 10 minutes and 59 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request implements the CodeGenerationProvider seam for G5 Phase 1, exporting core types from @linchkit/core/server and introducing a thin adapter implementation over AIService in @linchkit/cap-ai-provider along with corresponding unit tests. Review feedback recommends adding defensive checks to validate that the ai service is defined and that the prompt is a non-empty string, handling potential null or undefined completion results, and adding unit tests to verify these validation behaviors.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Address gemini-code-assist review on #494: - generateCode throws on an empty / whitespace-only prompt (before any model call) — robust input validation, avoids a wasted generation. - Guard a completion with no string `content`: throw instead of returning a non-string, so the Promise<string> contract holds and the caller's retry / quality gate surfaces the failure. - Tests for both new failure paths (empty prompt, whitespace prompt, no content). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
What
G5 Phase 1 — implement the
CodeGenerationProviderseam: the foundation forAI code generation of the irreducibly-code parts of a proposal (action /
event-handler / flow logic bodies that a declarative
ChangeDefinitioncannotexpress).
@linchkit/coredeclared aCodeGenerationProviderinterface ("implemented bycap-ai-provider") but no implementation existed and the type was on no public
barrel.
@linchkit/core/servernow exportsCodeGenerationProvider,CodeGenerationResult,ProjectContext,QualityGateRunner(type-only) so acapability can implement the seam.
@linchkit/cap-ai-provideraddscreateCodeGenerationProvider(ai, options)— a thin adapter over the configured
AIService(GLM/zhipu perlinchkit.config; never hardcoded).generateCode(prompt, context?)shapescontext→system +prompt→user, defaults temperature 0 and taskType"code",forwards model/maxTokens/tenantId, and throws when the AIService is
unconfigured (so the caller's retry/quality-gate surfaces a clear failure).
Safety boundary
This implements the design the user approved: narrow scope + free-form TS,
gated by build + double human review. This PR adds only the generator — it is
NOT wired into any live path. It only PRODUCES candidate source as a string; it
never writes files, runs code, or touches the approval / graduation pipeline.
("AI never modifies production directly.")
G5 plan context
proposal changes (draft-only).
Verification
bun run check/bun run typecheck— cleanbun run test— PASS (6 new unit tests, fakeAIServiceinjected; no realmodel is called)
🤖 Generated with Claude Code