Skip to content

Commit 9a08f9c

Browse files
jmbish04claude
andcommitted
fix: resolve merge conflicts with main — align schemas with PR #452
- Merge origin/main (PR #452's Sentinel infra) into claude/sentinel-engine - Remove duplicate kebab-case schema files (ai-insights.ts, ai-pr-reflections.ts, etc.) in favor of main's camelCase versions (aiInsights.ts, aiPrReflections.ts) - Update all imports to use main's schema exports (learningAiInsights, etc.) - Merge LearningAgent: keep main's pattern detection + contemplation gate, add Sentinel pipeline routes (/ingest, /enrich, /schedule/run, /ingest-pr) - Remove duplicate v7 migration (LearningAgent already in v1_sentinel) - Restore Sentinel frontend routes in App.tsx Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent d05eb9c commit 9a08f9c

14 files changed

Lines changed: 344 additions & 372 deletions

File tree

src/backend/src/ai/agents/LearningAgent.ts

Lines changed: 292 additions & 81 deletions
Large diffs are not rendered by default.

src/backend/src/automations/pr/SentinelInterceptor.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ import {
1616
type AutomationMetadata,
1717
} from "@/core/BaseAutomation";
1818
import { getDb } from "@db";
19-
import { aiInsights } from "@/db/schemas/github/learning/ai-insights";
20-
import { aiPrReflections } from "@/db/schemas/github/learning/ai-pr-reflections";
19+
import { learningAiInsights } from "@db/schemas/github/learning";
2120
import { eq, and } from "drizzle-orm";
2221

2322
const PullRequestPayloadSchema = z.object({
@@ -91,11 +90,11 @@ export class SentinelInterceptor extends BaseAutomation<SentinelPayload> {
9190
const db = getDb(this.env.DB);
9291
const repoInsights = await db
9392
.select()
94-
.from(aiInsights)
93+
.from(learningAiInsights)
9594
.where(
9695
and(
97-
eq(aiInsights.githubRepo, repoFullName),
98-
eq(aiInsights.status, "IMMUNIZED")
96+
eq(learningAiInsights.repo, repoFullName),
97+
eq(learningAiInsights.status, "proposed")
9998
)
10099
)
101100
.limit(10);
@@ -128,7 +127,7 @@ export class SentinelInterceptor extends BaseAutomation<SentinelPayload> {
128127
const analysisPrompt = `Analyze this PR diff for architectural anti-patterns, style drift, or improvements based on these known patterns:
129128
130129
**Known Immunized Insights for ${repoFullName}:**
131-
${repoInsights.map((i) => `- [${i.category}/${i.severity}] ${i.insightAnalysis?.substring(0, 200)}`).join("\n") || "None yet."}
130+
${repoInsights.map((i) => `- [${i.patternType}/${i.severity}] ${i.description?.substring(0, 200)}`).join("\n") || "None yet."}
132131
133132
**Vector Similarity Matches:**
134133
${vectorMatches.join("\n") || "No similar prior patterns found."}

src/backend/src/automations/pr/SentinelPostMerge.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
type AutomationMetadata,
1515
} from "@/core/BaseAutomation";
1616
import { getDb } from "@db";
17-
import { aiInsightPrs } from "@/db/schemas/github/learning/ai-insight-prs";
17+
import { learningAiInsightPrs } from "@db/schemas/github/learning";
1818

1919
const PullRequestClosedPayloadSchema = z.object({
2020
action: z.literal("closed"),
@@ -60,14 +60,14 @@ export class SentinelPostMerge extends BaseAutomation<PostMergePayload> {
6060
const db = getDb(this.env.DB);
6161

6262
// Record the merged PR in the learning database
63-
await db.insert(aiInsightPrs).values({
63+
await db.insert(learningAiInsightPrs).values({
6464
id: crypto.randomUUID(),
65-
repoOwner: repository.owner.login,
66-
repoName: repository.name,
65+
insightId: "", // Linked during analysis
6766
prNumber: pr.number,
68-
prUrl: pr.html_url,
69-
prDescription: pr.body?.substring(0, 2000),
70-
outcome: "MERGED",
67+
repo: `${repository.owner.login}/${repository.name}`,
68+
status: "merged",
69+
outcome: "merged",
70+
createdAt: new Date(),
7171
});
7272

7373
// Signal the LearningAgent to ingest this PR

src/backend/src/db/schemas/github/learning/ai-insight-messages.ts

Lines changed: 0 additions & 29 deletions
This file was deleted.

src/backend/src/db/schemas/github/learning/ai-insight-pr-mapping.ts

Lines changed: 0 additions & 30 deletions
This file was deleted.

src/backend/src/db/schemas/github/learning/ai-insight-prs.ts

Lines changed: 0 additions & 43 deletions
This file was deleted.

src/backend/src/db/schemas/github/learning/ai-insights.ts

Lines changed: 0 additions & 41 deletions
This file was deleted.

src/backend/src/db/schemas/github/learning/ai-pr-reflections.ts

Lines changed: 0 additions & 44 deletions
This file was deleted.

src/backend/src/db/schemas/github/learning/tag-mapping.ts

Lines changed: 0 additions & 26 deletions
This file was deleted.

src/backend/src/db/schemas/github/learning/tags.ts

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)