Remove upsert_qa_from_call reducer and related references.

This commit is contained in:
Aadesh Kheria 2026-07-16 17:01:00 -07:00
parent e494e97224
commit ad06547679
7 changed files with 16 additions and 45 deletions

View File

@ -26,7 +26,6 @@ const ALL_MUTATING_REDUCERS: Array<{ name: string, args: unknown[] }> = [
args: ["corr", "chat", "sys", "q", "s", "model", false, opt(null), opt(null), "[]", "[]", "[]", "text", opt(null), opt(null), opt(null), opt(null), opt(null), opt(null), opt(null), 0, 0n, opt(null), opt(null)],
},
{ name: "update_ai_query_usage", args: ["corr", opt(null), opt(null), opt(null), opt(null), opt(null)] },
{ name: "upsert_qa_from_call", args: ["corr", "q", "a", false] },
{ name: "delete_mcp_call_log", args: ["corr"] },
{ name: "delete_ai_query_log", args: ["corr"] },
{ name: "clear_mcp_qa_review", args: ["corr"] },

View File

@ -28,7 +28,7 @@ const SIGNING_KEY_VAR = "HEXCLAVE_SPACETIMEDB_SIGNING_KEY_JWK";
async function ensureSigningKey() {
const existing = existsSync(ENV_LOCAL) ? readFileSync(ENV_LOCAL, "utf8") : "";
const line = existing.split(/\r?\n/).find((l) => l.startsWith(`${SIGNING_KEY_VAR}=`));
const line = existing.split(/\r?\n/).filter((l) => l.startsWith(`${SIGNING_KEY_VAR}=`)).at(-1);
const value = line ? line.slice(SIGNING_KEY_VAR.length + 1).trim() : "";
if (value !== "" && value !== "REPLACE_ME") return;

View File

@ -451,25 +451,6 @@ export const set_human_reviewed = spacetimedb.reducer(
}
);
export const upsert_qa_from_call = spacetimedb.reducer(
{
correlationId: t.string(),
question: t.string(),
answer: t.string(),
publish: t.bool(),
},
(ctx, args) => {
requireProjectMember(ctx.senderAuth);
upsertQaEntryFromCall(ctx, {
correlationId: args.correlationId,
question: args.question,
answer: args.answer,
publish: args.publish,
editedBy: actorName(ctx.senderAuth),
});
}
);
export const upsert_qa_from_call_and_mark_reviewed = spacetimedb.reducer(
{
correlationId: t.string(),

View File

@ -16,11 +16,16 @@ export async function getVerifiedQaContext(accessToken: string): Promise<string>
async function getVerifiedQaContextInner(accessToken: string): Promise<string> {
const rows = await callSql(
accessToken,
"SELECT question, answer FROM published_qa"
"SELECT id, question, answer FROM published_qa"
);
if (rows.length === 0) return "";
const sorted = [...rows].sort((a, b) => {
const aId = readId(a);
const bId = readId(b);
return aId < bId ? -1 : aId > bId ? 1 : 0;
});
const formatted = rows.map((row, i) =>
const formatted = sorted.map((row, i) =>
`${i + 1}. Q: ${readString(row, "question")}\n A: ${readString(row, "answer")}`
).join("\n\n");
@ -37,6 +42,14 @@ RULES:
${formatted}`;
}
function readId(row: Record<string, unknown>): bigint {
const value = row["id"];
if (typeof value === "number" && Number.isSafeInteger(value)) return BigInt(value);
if (typeof value === "string" && /^[0-9]+$/.test(value)) return BigInt(value);
throw new Error(`published_qa.id must be a u64 number or numeric string, got: ${typeof value}`);
}
function readString(row: Record<string, unknown>, key: string): string {
const value = row[key];
if (typeof value !== "string") {

View File

@ -46,7 +46,6 @@ import TouchSessionReducer from "./touch_session_reducer";
import UpdateAiQueryUsageReducer from "./update_ai_query_usage_reducer";
import UpdateMcpQaReviewReducer from "./update_mcp_qa_review_reducer";
import UpdateQaEntryWithPublishReducer from "./update_qa_entry_with_publish_reducer";
import UpsertQaFromCallReducer from "./upsert_qa_from_call_reducer";
import UpsertQaFromCallAndMarkReviewedReducer from "./upsert_qa_from_call_and_mark_reviewed_reducer";
// Import all procedure arg schemas
@ -105,7 +104,6 @@ const reducersSchema = __reducers(
__reducerSchema("update_ai_query_usage", UpdateAiQueryUsageReducer),
__reducerSchema("update_mcp_qa_review", UpdateMcpQaReviewReducer),
__reducerSchema("update_qa_entry_with_publish", UpdateQaEntryWithPublishReducer),
__reducerSchema("upsert_qa_from_call", UpsertQaFromCallReducer),
__reducerSchema("upsert_qa_from_call_and_mark_reviewed", UpsertQaFromCallAndMarkReviewedReducer),
);

View File

@ -18,7 +18,6 @@ import TouchSessionReducer from "../touch_session_reducer";
import UpdateAiQueryUsageReducer from "../update_ai_query_usage_reducer";
import UpdateMcpQaReviewReducer from "../update_mcp_qa_review_reducer";
import UpdateQaEntryWithPublishReducer from "../update_qa_entry_with_publish_reducer";
import UpsertQaFromCallReducer from "../upsert_qa_from_call_reducer";
import UpsertQaFromCallAndMarkReviewedReducer from "../upsert_qa_from_call_and_mark_reviewed_reducer";
export type AddManualQaParams = __Infer<typeof AddManualQaReducer>;
@ -33,6 +32,5 @@ export type TouchSessionParams = __Infer<typeof TouchSessionReducer>;
export type UpdateAiQueryUsageParams = __Infer<typeof UpdateAiQueryUsageReducer>;
export type UpdateMcpQaReviewParams = __Infer<typeof UpdateMcpQaReviewReducer>;
export type UpdateQaEntryWithPublishParams = __Infer<typeof UpdateQaEntryWithPublishReducer>;
export type UpsertQaFromCallParams = __Infer<typeof UpsertQaFromCallReducer>;
export type UpsertQaFromCallAndMarkReviewedParams = __Infer<typeof UpsertQaFromCallAndMarkReviewedReducer>;

View File

@ -1,18 +0,0 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
/* eslint-disable */
/* tslint:disable */
import {
TypeBuilder as __TypeBuilder,
t as __t,
type AlgebraicTypeType as __AlgebraicTypeType,
type Infer as __Infer,
} from "spacetimedb";
export default {
correlationId: __t.string(),
question: __t.string(),
answer: __t.string(),
publish: __t.bool(),
};