Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
9781f80
Merge remote-tracking branch 'origin/t3/project-memory-relevance' int…
ScriptedAlchemy Nov 17, 2026
952fa31
Merge remote-tracking branch 'origin/fix/memory-capture-quality' into…
ScriptedAlchemy Nov 17, 2026
a9a7e16
test: automatic memory recalls only facts a blind check calls standing
ScriptedAlchemy Nov 17, 2026
e240c68
feat(server): automatic memory recalls only facts a blind check calls…
ScriptedAlchemy Nov 17, 2026
1c12d00
Merge remote-tracking branch 'origin/main' into t3/project-memory-cap…
ScriptedAlchemy Nov 17, 2026
f41653a
test(server): fakes and the set-aside recall test typecheck
ScriptedAlchemy Nov 17, 2026
e10e1b9
Merge remote-tracking branch 'origin/main' into t3/project-memory-cap…
ScriptedAlchemy Nov 17, 2026
c093feb
test(server): the set-aside recall test asks about the fact without r…
ScriptedAlchemy Nov 17, 2026
443ce84
Merge remote-tracking branch 'origin/main' into t3/memory-capture-rev…
ScriptedAlchemy Nov 17, 2026
9cd19cd
fix(server): one malformed standing-check answer sets aside only its …
ScriptedAlchemy Nov 17, 2026
307de9f
fix(server): set-aside facts stay out of recall and its term statistics
ScriptedAlchemy Nov 17, 2026
a8f0983
fix(server): the Codex standing check runs with the evaluator's isola…
ScriptedAlchemy Nov 17, 2026
b08079c
fix(opencode): the standing check runs on an isolated server, like bl…
ScriptedAlchemy Nov 17, 2026
389b3f6
fix(pi,cursor): the standing check gets each provider's blind-evaluat…
ScriptedAlchemy Nov 17, 2026
4bd6b0c
fix(server): the standing check's per-entry decoding typechecks
ScriptedAlchemy Nov 17, 2026
c510a0b
fix(server): automatic memory skips batches its provider cannot check
ScriptedAlchemy Nov 17, 2026
f8c9685
fix(server): group members build on the lead's answer instead of raci…
ScriptedAlchemy Nov 17, 2026
9501b78
fix(server): let group members answer when the lead cannot
ScriptedAlchemy Nov 17, 2026
1feb6ef
fix(lcm): recover searchable history with source-grounded summaries
ScriptedAlchemy Nov 17, 2026
1237645
fix(server): preserve group attachments and bounded context
ScriptedAlchemy Nov 17, 2026
c8d336f
fix(server): tighten memory standing-check safeguards
ScriptedAlchemy Nov 17, 2026
c6c6f66
fix(server): preserve memory recall for questions and constraints
ScriptedAlchemy Nov 17, 2026
612d4a9
fix(lcm): handle large payloads and FTS writes without overflow
ScriptedAlchemy Nov 17, 2026
f31387e
fix(lcm): preserve summary intent and integrate memory migrations
ScriptedAlchemy Nov 17, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions apps/mobile/src/components/ProjectKnowledgeEntry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ export function ProjectKnowledgeEntry(props: Scope) {
// Older servers lack readFact, status and supersede.
history={config.environment.capabilities.projectKnowledgeHistory === true}
assisted={config.environment.capabilities.projectKnowledgeAssistedLearning === true}
standingCheck={config.environment.capabilities.projectKnowledgeStandingCheck === true}
seedMessage={open.seed}
onClose={() => setOpen(null)}
/>
Expand All @@ -144,6 +145,7 @@ function ProjectKnowledgeSheet(
props: Scope & {
readonly history: boolean;
readonly assisted: boolean;
readonly standingCheck: boolean;
readonly seedMessage: MessageCitation | null;
readonly onClose: () => void;
},
Expand Down Expand Up @@ -460,6 +462,7 @@ function ProjectKnowledgeSheet(
projectId={props.projectId}
browse={browse}
assisted={props.assisted}
standingCheck={props.standingCheck}
canMutate={canMutate}
busy={busy}
selectionState={selectionState}
Expand Down
7 changes: 7 additions & 0 deletions apps/mobile/src/components/ProjectKnowledgeFactDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
isSupersededFact,
knowledgeConflictHintLabel,
knowledgeOriginLabel,
projectFactVerdictLabel,
projectFactHistoryLabel,
} from "@t3tools/client-runtime/projectKnowledge";

Expand Down Expand Up @@ -160,6 +161,12 @@ export function ProjectFactInspector(props: {
<AppText className="text-xs text-foreground-muted">
{fact.kind} · {fact.status} · {knowledgeOriginLabel(fact.origin)}
</AppText>
{fact.verdict ? (
<AppText className="text-xs text-foreground-muted">
{projectFactVerdictLabel(fact.verdict)}{" "}
{historyTimeFormatter.format(new Date(fact.verdict.at))}
</AppText>
) : null}
<AppText className="text-xs text-foreground-muted">
Trust signal {fact.trust.toFixed(2)} · revision {fact.revision}
</AppText>
Expand Down
19 changes: 13 additions & 6 deletions apps/mobile/src/components/ProjectKnowledgeFactList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import { KnowledgeHealthRow } from "./ProjectKnowledgeFactDetail";
import { AppText, AppTextInput } from "./ui/AppText";
import { Button } from "./ui/Button";

type StatusFilter = "saved" | "automatic" | "forgotten";
type StatusFilter = "saved" | "automatic" | "set_aside" | "forgotten";

/** Filters, search and paging for the fact list. The sheet reads its results for draft labels. */
export function useProjectKnowledgeBrowse(props: {
Expand All @@ -60,7 +60,9 @@ export function useProjectKnowledgeBrowse(props: {
? { sourceState: "unavailable" as const }
: status === "automatic"
? { status: "saved" as const, origin: "assisted" as const }
: { status }),
: status === "set_aside"
? { status: "saved" as const, verdict: "set_aside" as const }
: { status }),
...(afterId ? { afterId } : {}),
...(props.history && showSuperseded ? { includeSuperseded: true } : {}),
},
Expand Down Expand Up @@ -202,6 +204,7 @@ export function ProjectKnowledgeFactList(props: {
readonly projectId: ProjectId;
readonly browse: ProjectKnowledgeBrowse;
readonly assisted: boolean;
readonly standingCheck: boolean;
readonly canMutate: boolean;
readonly busy: boolean;
readonly selectionState: (current: KnowledgeSelection) => SelectionState;
Expand Down Expand Up @@ -240,13 +243,17 @@ export function ProjectKnowledgeFactList(props: {
</View>

<View className="flex-row flex-wrap gap-2">
{(props.assisted
? (["saved", "automatic", "forgotten"] as const)
: (["saved", "forgotten"] as const)
{(
[
"saved",
...(props.assisted ? (["automatic"] as const) : []),
...(props.standingCheck ? (["set_aside"] as const) : []),
"forgotten",
] as const
).map((value) => (
<Button
key={value}
label={value}
label={value === "set_aside" ? "set aside" : value}
tone={
browse.status === value && !searchInput && !browse.lostSourcesOnly
? "primary"
Expand Down
45 changes: 45 additions & 0 deletions apps/server/scripts/migrate-dev-db.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as FileSystem from "effect/FileSystem";
import * as Path from "effect/Path";
import * as SqlClient from "effect/sql/SqlClient";

import { backfillToolSearchBatch } from "../src/orchestration-v2/toolSearchIndex.ts";
import { runMigrations } from "../src/persistence/Migrations.ts";
import * as NodeSqliteClient from "@t3tools/shared/nodeSqliteClient";
import { runMigrateDevDb } from "./migrate-dev-db.ts";
Expand Down Expand Up @@ -177,6 +178,41 @@ it.layer(NodeServices.layer)("migrate-dev-db", (it) => {
const sourceDir = yield* fs.makeTempDirectoryScoped({ prefix: "migrate-dev-db-src-" });
const destDir = yield* fs.makeTempDirectoryScoped({ prefix: "migrate-dev-db-dest-" });
const source = yield* createFixtureSource(sourceDir);
yield* withDatabase(
source,
Effect.gen(function* () {
const sql = yield* SqlClient.SqlClient;
const item = {
id: "tool-copy",
threadId: "stopped-thread",
runId: null,
nodeId: null,
providerThreadId: null,
providerTurnId: null,
nativeItemRef: null,
parentItemId: null,
ordinal: 1,
status: "completed",
title: null,
startedAt: "2026-08-01T00:00:00.000Z",
completedAt: "2026-08-01T00:00:00.000Z",
updatedAt: "2026-08-01T00:00:00.000Z",
type: "command_execution",
input: "test",
output: "copiedtoolterm",
exitCode: 0,
};
yield* sql`INSERT INTO orchestration_v2_projection_turn_items
(turn_item_id, thread_id, ordinal, type, status, updated_at, payload_json, inline_work_output)
VALUES ('tool-copy', 'stopped-thread', 1, 'command_execution', 'completed',
${item.updatedAt}, ${JSON.stringify(item)}, 0)`;
yield* sql`INSERT INTO orchestration_v2_tool_search(rowid, text)
SELECT rowid, 'copiedtoolterm' FROM orchestration_v2_projection_turn_items WHERE turn_item_id = 'tool-copy'`;
yield* sql`UPDATE orchestration_v2_tool_search_state
SET cursor = (SELECT max(rowid) FROM orchestration_v2_projection_turn_items),
backfill_end = (SELECT max(rowid) FROM orchestration_v2_projection_turn_items) WHERE id = 1`;
}),
);

const result = yield* runMigrateDevDb(
{ baseDir: destDir, source, projects: 5, threadsPerProject: 2 },
Expand All @@ -188,6 +224,15 @@ it.layer(NodeServices.layer)("migrate-dev-db", (it) => {
result.databasePath,
Effect.gen(function* () {
const sql = yield* SqlClient.SqlClient;
while (!(yield* backfillToolSearchBatch(sql))) {}
const toolHits = yield* sql<{ id: string }>`SELECT items.turn_item_id AS id
FROM orchestration_v2_tool_search AS search
JOIN orchestration_v2_projection_turn_items AS items ON items.rowid = search.rowid
WHERE orchestration_v2_tool_search MATCH 'copiedtoolterm'`;
assert.deepEqual(
toolHits.map((hit) => hit.id),
["tool-copy"],
);
const threads = yield* sql<{ thread_id: string }>`
SELECT thread_id FROM orchestration_v2_projection_threads ORDER BY thread_id`;
const events = yield* sql<{ stream_id: string }>`
Expand Down
2 changes: 2 additions & 0 deletions apps/server/scripts/migrate-dev-db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import * as SqlClient from "effect/sql/SqlClient";
import { Command, Flag } from "effect/cli";

import * as ProjectionStore from "../src/orchestration-v2/ProjectionStore.ts";
import { resetToolSearch } from "../src/orchestration-v2/toolSearchIndex.ts";
import { rebuildMessageSearch } from "../src/orchestration-v2/messageSearchIndex.ts";
import { runMigrations } from "../src/persistence/Migrations.ts";
import * as NodeSqliteClient from "@t3tools/shared/nodeSqliteClient";
Expand Down Expand Up @@ -317,6 +318,7 @@ const copySourceSlice = Effect.fn("copyDevDbSourceSlice")(function* (sourcePath:
if (entry.type !== "table") yield* sql.unsafe(entry.sql).unprepared;
}
yield* rebuildMessageSearch(sql);
yield* resetToolSearch(sql);
if (virtualTables.includes("project_knowledge_fts")) {
yield* sql`INSERT INTO project_knowledge_fts(project_knowledge_fts) VALUES ('rebuild')`;
}
Expand Down
1 change: 1 addition & 0 deletions apps/server/src/environment/ServerEnvironment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ export const make = Effect.gen(function* () {
projectKnowledgeHistory: true,
projectKnowledgeDeliveries: true,
projectKnowledgeAssistedLearning: true,
projectKnowledgeStandingCheck: true,
conversationSummaries: true,
conversationSummarySourceFormat: 2,
externalHistory: 1,
Expand Down
5 changes: 5 additions & 0 deletions apps/server/src/git/GitManager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,8 @@ function createTextGeneration(
}),
generateKnowledgeCandidates: () => Effect.succeed({ candidates: [] }),
generateConversationSummary: () => Effect.succeed({ statements: [] }),
checkFactStanding: () => Effect.succeed({ verdicts: [] }),
supportsOperation: () => Effect.succeed(true),
generateModelEvaluation: () => Effect.die("Unused evaluation fixture"),
generateThreadTitle: () =>
Effect.succeed({
Expand Down Expand Up @@ -374,6 +376,9 @@ function createTextGeneration(
generateKnowledgeCandidates: (input) => implementation.generateKnowledgeCandidates(input),
generateConversationSummary: (input) => implementation.generateConversationSummary(input),
generateModelEvaluation: (input) => implementation.generateModelEvaluation(input),
checkFactStanding: (input) => implementation.checkFactStanding(input),
supportsOperation: (operation, instanceId) =>
implementation.supportsOperation(operation, instanceId),
generateTranscriptionPostProcessing: (input) =>
implementation.generateTranscriptionPostProcessing(input),
};
Expand Down
38 changes: 38 additions & 0 deletions apps/server/src/mcp/OrchestratorMcpService.activity.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,23 @@ it("readThread pages cut-off text without splitting an emoji across pages", asyn
sourceItemId: TurnItemId.make(`turn-item-mcp-${index}`),
item: { ...row.item, text: "x".repeat(600) },
})),
...["dynamic_tool", "command_execution"].map((type, index) => ({
...row,
position: 12 + index,
sourceItemId: TurnItemId.make(`turn-item-binary-${type}`),
item: {
...row.item,
type,
toolName: "Read",
input: "screenshot.png",
output: JSON.stringify({
content: [
{ type: "image", source: { type: "base64", data: "AAECAw==" } },
{ type: "text", text: "Screenshot captured; layout not verified." },
],
}),
},
})),
];

const layer = layerOrchestratorService.pipe(
Expand Down Expand Up @@ -421,6 +438,27 @@ it("readThread pages cut-off text without splitting an emoji across pages", asyn
});
expect(first.items).toHaveLength(10);
expect(first).toMatchObject({ nextPosition: 9, hasMore: true });
for (const source of rows.slice(-2)) {
const pieces: Array<string> = [];
let textOffset: number | null = 0;
while (textOffset !== null) {
const result: OrchestratorMcpThreadReadResult = yield* service.readThread(makeScope(), {
threadId: parentThreadId,
view: "activity",
itemId: source.sourceItemId,
textOffset,
maxCharsPerItem: 64,
});
const page = result.items[0]!;
expect(page.itemId).toBe(source.sourceItemId);
pieces.push(page.text!);
textOffset = page.nextTextOffset ?? null;
}
const recovered = pieces.join("");
expect(recovered).not.toContain("AAECAw==");
expect(recovered).toContain("Screenshot captured; layout not verified.");
expect("output" in source.item ? source.item.output : "").toContain("AAECAw==");
}
}).pipe(Effect.provide(layer), Effect.runPromise);
});

Expand Down
11 changes: 8 additions & 3 deletions apps/server/src/mcp/OrchestratorMcpService.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { conversationEvidenceText } from "@t3tools/provider-core/server/conversationEvidence";
import {
providerConstraints,
delegationProviderConstraints,
Expand Down Expand Up @@ -1019,7 +1020,7 @@ function threadRun(

function jsonText(value: unknown): string {
try {
return JSON.stringify(value, null, 2);
return conversationEvidenceText(JSON.stringify(value, null, 2));
} catch {
return String(value);
}
Expand Down Expand Up @@ -1052,7 +1053,10 @@ function turnItemText(item: OrchestrationV2TurnItem): string | null {
.filter((line): line is string => line !== undefined)
.join("\n");
case "command_execution":
return [`$ ${item.input}`, item.output]
return [
`$ ${conversationEvidenceText(item.input)}`,
item.output === undefined ? undefined : conversationEvidenceText(item.output),
]
.filter((line): line is string => line !== undefined)
.join("\n");
case "file_search":
Expand Down Expand Up @@ -1107,7 +1111,8 @@ function timelineItem(input: {
readonly textOffset?: number;
readonly messagesByThreadId: ReadonlyMap<ThreadId, OrchestrationV2ThreadProjection["messages"]>;
}): OrchestratorMcpThreadTimelineItem {
const text = turnItemText(input.row.item);
const rawText = turnItemText(input.row.item);
const text = rawText === null ? null : conversationEvidenceText(rawText);
const offset = input.textOffset ?? 0;
const end = textPageEnd(text, offset, input.maxChars);
const textTruncated = text !== null && text.length > end;
Expand Down
4 changes: 3 additions & 1 deletion apps/server/src/mcp/linkOrigin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import * as McpInvocationContext from "./McpInvocationContext.ts";
import * as PeerForwarding from "../peer/PeerForwarding.ts";
import * as ThreadGroupService from "../orchestration-v2/ThreadGroupService.ts";
import * as ThreadSearch from "../orchestration-v2/ThreadSearch.ts";
import * as ToolSearch from "../orchestration-v2/ToolSearch.ts";
import * as PeerLinkRequests from "../peer/PeerLinkRequests.ts";
import * as PeerLinks from "../peer/PeerLinks.ts";

Expand Down Expand Up @@ -186,8 +187,9 @@ const layerTools = Layer.mergeAll(
Layer.provide(Layer.mock(PeerLinkRequests.PeerLinkRequests)({})),
Layer.provide(Layer.mock(PeerLinks.PeerLinks)({})),
Layer.provide(
Layer.merge(
Layer.mergeAll(
Layer.mock(ThreadSearch.ThreadSearch)({}),
Layer.mock(ToolSearch.ToolSearch)({}),
Layer.mock(ThreadGroupService.ThreadGroupService)({}),
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ const failure = (error: ConversationSummaryError | OrchestratorMcpFailure) =>
const access = readCaller().pipe(Effect.andThen(ConversationSummaries.ConversationSummaries));

export const layer = McpToolAccess.toLayer(ConversationSummariesToolkit, {
t3_conversation_summary_search: McpToolAccess.reads((input) =>
Effect.flatMap(access, (service) => service.search(input)).pipe(Effect.mapError(failure)),
),
t3_conversation_summary_list: McpToolAccess.reads((input) =>
Effect.flatMap(access, (service) => service.list(input)).pipe(Effect.mapError(failure)),
),
Expand Down
16 changes: 15 additions & 1 deletion apps/server/src/mcp/toolkits/conversationSummaries/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {
ConversationSummaryList,
ConversationSummaryListInput,
ConversationSummaryRead,
ConversationSummarySearch,
ConversationSummarySearchInput,
OrchestratorMcpEnvironmentTarget,
OrchestratorMcpFailure,
} from "@t3tools/contracts";
Expand All @@ -25,6 +27,18 @@ const shared = {
};

export const ConversationSummariesToolkit = Toolkit.make(
Tool.make("t3_conversation_summary_search", {
...shared,
description:
"Search stored summaries across a project, optionally one thread, most relevant first. Use 1-3 distinctive terms: every query word must match (Unicode full-text terms, not substring or FTS syntax), so when nothing matches, rephrase with fewer or different terms in another call. Returns verified previews up to 1000 UTF-16 units each; limit defaults to 10, maximum 20. Read full statements with t3_conversation_summary_describe. Expand a hit with t3_conversation_summary_expand using its projectId, threadId and id as summaryId; recurse through child summaries for original evidence. Follow nextCursor with the same query and scope, even after an empty page. Never generates summaries.",
parameters: Schema.Struct({
...ConversationSummarySearchInput.fields,
environmentId: OrchestratorMcpEnvironmentTarget,
}),
success: ConversationSummarySearch,
})
.annotate(Tool.Readonly, true)
.annotate(Tool.Destructive, false),
Tool.make("t3_conversation_summary_list", {
...shared,
description:
Expand Down Expand Up @@ -52,7 +66,7 @@ export const ConversationSummariesToolkit = Toolkit.make(
Tool.make("t3_conversation_summary_expand", {
...shared,
description:
"Read source ranges, or a roll-up's child summaries; expand a cited child for the original text. Changed, removed, archived or unfinished sources are unavailable. maxChars (default 12000, max 48000 UTF-16 units) bounds page text; limit bounds sources. Continue with offset=nextOffset AND textOffset=nextTextOffset even when offset repeats. null nextOffset ends paging.",
"Read original messages/tool output, or a roll-up's child summaries; expand a cited child for original evidence. Once that evidence answers the question, no further thread read is needed. Changed, removed, archived or unfinished sources are unavailable. maxChars (default 12000, max 48000 UTF-16 units) bounds page text; limit bounds sources. Continue with offset=nextOffset AND textOffset=nextTextOffset even when offset repeats. null nextOffset ends paging.",
parameters: Schema.Struct({
...ConversationSummaryExpandInput.fields,
environmentId: OrchestratorMcpEnvironmentTarget,
Expand Down
Loading
Loading