Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 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
c8d336f
fix(server): tighten memory standing-check safeguards
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
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
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ it.effect("takes a hub's reset for an unreset usage_limit, then refreshes the sn
generateReviewGuide: () => Effect.die("unused"),
generateKnowledgeCandidates: () => Effect.die("unused"),
generateConversationSummary: () => Effect.die("unused"),
checkFactStanding: () => Effect.die("unused"),
generateTranscriptionPostProcessing: () => Effect.die("unused"),
},
snapshot: {
Expand Down
33 changes: 33 additions & 0 deletions apps/server/src/persistence/Migrations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ import * as Exit from "effect/Exit";
import * as FileSystem from "effect/FileSystem";
import * as Path from "effect/Path";
import * as SqlClient from "effect/sql/SqlClient";
import { ProjectId } from "@t3tools/contracts";

import { createMessageSearchTriggers } from "../orchestration-v2/messageSearchIndex.ts";
import { makeStore } from "../project/knowledge/persistence.ts";
import { migrationManifest, runMigrations } from "./Migrations.ts";
import ProjectLoomTimeIndexes from "./Migrations/075_ProjectLoomTimeIndexes.ts";
import ProjectLoomBoundedReads from "./Migrations/077_ProjectLoomBoundedReads.ts";
Expand Down Expand Up @@ -1406,6 +1408,37 @@ it.effect(
{ term: "lantern", doc: 1 },
{ term: "πύλη", doc: 1 },
]);
// Set-aside facts are never recall candidates, so they never weigh recall's terms.
const store = yield* makeStore;
const recallStats = store
.termStats(["cobalt", "harrier", "kestrel", "lantern", "πύλη"], ProjectId.make("project"))
.pipe(Effect.map((stats) => [stats.corpusSize, Object.fromEntries(stats.docs)]));
yield* sql`
INSERT INTO project_knowledge_facts
(id, project_id, status, revision, content, entities_json, tags_json, kind, trust,
retrieval_count, created_at, updated_at, forgotten_at, sources_json, origin_json, verdict)
VALUES ('third', 'project', 'saved', 1, 'harrier cobalt', '[]', '[]',
'note', 0.6, 0, '2026-11-16', '2026-11-16', NULL, '[]', '{"kind":"assisted"}', 'task')`;
assert.deepEqual(yield* recallStats, [1, { cobalt: 1, lantern: 1, πύλη: 1 }]);
yield* sql`UPDATE project_knowledge_facts SET verdict='code' WHERE id='second'`;
assert.deepEqual(yield* recallStats, [0, {}]);
yield* sql`UPDATE project_knowledge_facts SET content='cobalt kestrel' WHERE id='second'`;
assert.deepEqual(yield* recallStats, [0, {}]);
yield* sql`UPDATE project_knowledge_facts SET verdict='standing' WHERE id='second'`;
const standingOnly = [1, { cobalt: 1, kestrel: 1, lantern: 1 }];
assert.deepEqual(yield* recallStats, standingOnly);
yield* sql`UPDATE project_knowledge_facts SET verdict=NULL WHERE id='third'`;
assert.deepEqual(yield* recallStats, [2, { cobalt: 2, harrier: 1, kestrel: 1, lantern: 1 }]);
yield* sql`UPDATE project_knowledge_facts SET verdict='task' WHERE id='third'`;
assert.deepEqual(yield* recallStats, standingOnly);
yield* sql`UPDATE project_knowledge_facts SET superseded_by_id='second' WHERE id='third'`;
yield* sql`UPDATE project_knowledge_facts SET verdict=NULL WHERE id='third'`;
assert.deepEqual(yield* recallStats, standingOnly);
yield* sql`UPDATE project_knowledge_facts SET verdict='task', superseded_by_id=NULL WHERE id='third'`;
yield* sql`UPDATE project_knowledge_facts SET status='forgotten',content=NULL WHERE id='third'`;
assert.deepEqual(yield* recallStats, standingOnly);
yield* sql`DELETE FROM project_knowledge_facts WHERE id='third'`;
assert.deepEqual(yield* recallStats, standingOnly);
yield* sql`UPDATE project_knowledge_facts SET project_id='other' WHERE id='second'`;
assert.deepEqual(yield* counts, []);
yield* sql`DELETE FROM project_knowledge_facts WHERE id='second'`;
Expand Down
2 changes: 2 additions & 0 deletions apps/server/src/persistence/Migrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ import Migration0111 from "./Migrations/111_TurnItemMessageOrdinalIndex.ts";
import Migration0112 from "./Migrations/112_TurnItemInlineWorkOutput.ts";
import Migration0113 from "./Migrations/113_RepairSubagentGroups.ts";
import Migration0114 from "./Migrations/114_ProjectKnowledgeRecallIndex.ts";
import Migration0115 from "./Migrations/115_ProjectKnowledgeFactVerdict.ts";

const migrationEntries = [
[1, "OrchestrationEvents", Migration0001],
Expand Down Expand Up @@ -242,6 +243,7 @@ const migrationEntries = [
[112, "TurnItemInlineWorkOutput", Migration0112],
[113, "RepairSubagentGroups", Migration0113],
[114, "ProjectKnowledgeRecallIndex", Migration0114],
[115, "ProjectKnowledgeFactVerdict", Migration0115],
] as const;

export const migrationManifest = migrationEntries.map(([id, name]) => [id, name] as const);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import * as Effect from "effect/Effect";
import * as SqlClient from "effect/sql/SqlClient";

// Existing facts keep a NULL verdict: unchecked, and recallable exactly as before, so the recall
// term counts from migration 114 stay correct without a rebuild.
export default Effect.gen(function* () {
const sql = yield* SqlClient.SqlClient;
yield* sql`ALTER TABLE project_knowledge_facts ADD COLUMN verdict TEXT
CHECK (verdict IN ('standing', 'task', 'code'))`;
yield* sql`ALTER TABLE project_knowledge_facts ADD COLUMN verdict_by TEXT
CHECK (verdict_by IN ('check', 'person', 'agent'))`;
yield* sql`ALTER TABLE project_knowledge_facts ADD COLUMN verdict_at TEXT`;
yield* sql`ALTER TABLE project_knowledge_learning_queue ADD COLUMN check_attempts INTEGER NOT NULL DEFAULT 0`;
yield* sql`ALTER TABLE project_knowledge_learning_queue ADD COLUMN retry_at INTEGER`;

// Recall's term statistics count exactly the facts recall may offer (`recallable` in
// project/knowledge/persistence.ts), so set-aside facts never change term weights.
for (const name of [
"project_knowledge_recall_insert",
"project_knowledge_recall_delete",
"project_knowledge_recall_update_old",
"project_knowledge_recall_update_new",
])
yield* sql`DROP TRIGGER ${sql(name)}`;
yield* sql`DROP INDEX project_knowledge_recall_current`;
yield* sql`CREATE INDEX project_knowledge_recall_current ON project_knowledge_facts(project_id)
WHERE status = 'saved' AND superseded_by_id IS NULL AND (verdict IS NULL OR verdict = 'standing')`;
yield* sql`
CREATE TRIGGER project_knowledge_recall_insert AFTER INSERT ON project_knowledge_facts
WHEN new.status = 'saved' AND new.superseded_by_id IS NULL
AND (new.verdict IS NULL OR new.verdict = 'standing')
BEGIN
INSERT INTO project_knowledge_recall_terms (project_id, term, doc)
SELECT new.project_id, token, 1 FROM project_knowledge_tokenizer
WHERE input = new.content || ' ' || new.entities_json || ' ' || new.tags_json
GROUP BY token
ON CONFLICT (project_id, term) DO UPDATE SET doc = doc + 1;
END
`;
yield* sql`
CREATE TRIGGER project_knowledge_recall_delete AFTER DELETE ON project_knowledge_facts
WHEN old.status = 'saved' AND old.superseded_by_id IS NULL
AND (old.verdict IS NULL OR old.verdict = 'standing')
BEGIN
UPDATE project_knowledge_recall_terms SET doc = doc - 1
WHERE project_id = old.project_id AND term IN (
SELECT token FROM project_knowledge_tokenizer
WHERE input = old.content || ' ' || old.entities_json || ' ' || old.tags_json
);
DELETE FROM project_knowledge_recall_terms WHERE project_id = old.project_id AND doc = 0;
END
`;
yield* sql`
CREATE TRIGGER project_knowledge_recall_update_old BEFORE UPDATE OF content, entities_json, tags_json, project_id, status, superseded_by_id, verdict ON project_knowledge_facts
WHEN old.status = 'saved' AND old.superseded_by_id IS NULL
AND (old.verdict IS NULL OR old.verdict = 'standing')
BEGIN
UPDATE project_knowledge_recall_terms SET doc = doc - 1
WHERE project_id = old.project_id AND term IN (
SELECT token FROM project_knowledge_tokenizer
WHERE input = old.content || ' ' || old.entities_json || ' ' || old.tags_json
);
DELETE FROM project_knowledge_recall_terms WHERE project_id = old.project_id AND doc = 0;
END
`;
yield* sql`
CREATE TRIGGER project_knowledge_recall_update_new AFTER UPDATE OF content, entities_json, tags_json, project_id, status, superseded_by_id, verdict ON project_knowledge_facts
WHEN new.status = 'saved' AND new.superseded_by_id IS NULL
AND (new.verdict IS NULL OR new.verdict = 'standing')
BEGIN
INSERT INTO project_knowledge_recall_terms (project_id, term, doc)
SELECT new.project_id, token, 1 FROM project_knowledge_tokenizer
WHERE input = new.content || ' ' || new.entities_json || ' ' || new.tags_json
GROUP BY token
ON CONFLICT (project_id, term) DO UPDATE SET doc = doc + 1;
END
`;
});
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ describe("V2 preview upgrade", () => {
[112, "TurnItemInlineWorkOutput"],
[113, "RepairSubagentGroups"],
[114, "ProjectKnowledgeRecallIndex"],
[115, "ProjectKnowledgeFactVerdict"],
]);
assert.deepStrictEqual(yield* runMigrations(), []);
assert.deepStrictEqual(yield* sql`SELECT * FROM orchestration_v2_legacy_imports`, imports);
Expand Down Expand Up @@ -231,6 +232,7 @@ describe("V2 preview upgrade", () => {
[112, "TurnItemInlineWorkOutput"],
[113, "RepairSubagentGroups"],
[114, "ProjectKnowledgeRecallIndex"],
[115, "ProjectKnowledgeFactVerdict"],
]);
}).pipe(Effect.provide(NodeSqliteClient.layer({ filename: ":memory:" }))),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ const makeFixture = Effect.fn("ExternalHistory.test.fixture")(function* () {
generateTranscriptionPostProcessing: unused,
generateKnowledgeCandidates: unused,
generateConversationSummary: unused,
checkFactStanding: unused,
generateModelEvaluation: unused,
},
};
Expand Down
Loading
Loading