feat(schema): add signals and signal sources tables

This commit is contained in:
-Puter
2026-07-23 17:08:41 +05:30
parent 5b0bf35175
commit 6d86c8e538
3 changed files with 957 additions and 0 deletions

View File

@@ -199,6 +199,52 @@ export default defineSchema({
"clientRequestId",
]),
// -----------------------------------------------------------------
// Product Signals. A Signal is the agent-produced interpretation of one
// or more exact user messages into a structured problem statement. It is
// organization-scoped, optionally project-scoped, and idempotent by
// organization + ordered source-message selection (`sourceKey`). Raw text
// is never accepted from the agent: it is copied server-side from the
// normalized conversation messages into immutable source snapshots.
// -----------------------------------------------------------------
signals: defineTable({
organizationId: v.id("organizations"),
projectId: v.optional(v.id("projects")),
conversationId: v.string(),
sourceKey: v.string(),
problemStatement: v.object({
title: v.string(),
summary: v.string(),
desiredOutcome: v.string(),
constraints: v.array(v.string()),
}),
processedByAgentName: v.string(),
processedByAgentInstanceId: v.string(),
createdAt: v.number(),
})
.index("by_organization_and_createdAt", ["organizationId", "createdAt"])
.index("by_organization_and_sourceKey", ["organizationId", "sourceKey"])
.index("by_project_and_createdAt", ["projectId", "createdAt"]),
// Immutable ordered source snapshots copied from `conversationMessages`.
// `ordinal` is the zero-based position in the agent's ordered selection.
signalSources: defineTable({
signalId: v.id("signals"),
organizationId: v.id("organizations"),
conversationId: v.string(),
messageId: v.string(),
ordinal: v.number(),
rawTextSnapshot: v.string(),
sourceCreatedAt: v.number(),
submissionId: v.optional(v.string()),
})
.index("by_signal_and_ordinal", ["signalId", "ordinal"])
.index("by_organization_and_message", [
"organizationId",
"conversationId",
"messageId",
]),
// -----------------------------------------------------------------
// Flue persistence stores (schema/format version 4).
// -----------------------------------------------------------------