Commit 9235db9
authored
* feat(memory-core): archiveMemoriesByAgentIdentity tombstone + recall-exclusion (#13384)
The Memory-Core primitive the Fleet agent-removal reconciliation consumes via the
archiveMemoriesFn seam (split from #13190 per the 1-ticket-1-PR contract).
- archiveMemoriesByAgentIdentity({agentIdentity, reason, dryRun}): dual-store tombstone
(Chroma metadata + graph-node SQL + in-memory node-cache), idempotent, keyed on the
stamped @<github-username> write-identity.
- unarchiveMemoriesByAgentIdentity: reversible (Chroma empty-string + graph json_remove + cache).
- archivedAt-exclusion across recall paths: queryMemories + listMemories (Chroma),
queryRecentTurns (graph SQL), getContextFrontier frontier (GraphService).
- Leak-test: 5 cases (exclusion on both Chroma paths, dryRun, idempotency, identity-scoping,
fail-closed) + 59 existing memory-core specs green (no regression).
Refs #13190.
* fix(memory-core): durable tombstone marker survives graph-projection lag (#13384)
archiveMemoriesByAgentIdentity stamped archivedAt on the Chroma rows and on ALREADY-projected graph nodes, but a record embedded into Chroma while still graph-pending (graphProjectionVersion:1, no .graph.jsonl marker) had no node to stamp. The deferred drainPendingGraphProjections -> _projectMemoryToGraph later minted a fresh AGENT_MEMORY node from the pre-archive WAL snapshot, silently re-introducing the row un-tombstoned. Chroma embed and graph projection are independent derived states that catch up on different clocks.
Fix: a durable, globally-visible RLS-exempt ARCHIVED_AGENT_IDENTITY:<identity> marker (upsertGlobalNode), written by the archive op and removed by unarchive, plus _archivedIdentityState + _withArchiveState helpers. _projectMemoryToGraph now replays the tombstone onto the projected node when the identity is archived, so a lag-window archive survives projection (and a restart).
Test: a real (non-stubbed) projection-lag behavior test + durable-marker round-trip exercising the actual _projectMemoryToGraph path; 8/8 green. The existing recall-exclusion suite is unaffected (its db stub gains transaction/removeNode for the marker ops).
Remaining before re-request (NOT this commit): the other AGENT_MEMORY mint/overlay sites — the buildMiniSummary re-upsert, mergeMiniSummary, and the _readPendingWalRecencyRows recency overlay — get the same archive-awareness, then the leak test extends across all four sites.
* fix(memory-core): archive-aware projection across all four mint/overlay sites (#13384)
Extends the durable-marker core to the remaining three AGENT_MEMORY sites the projection-lag analysis mapped, so a tombstone set during projection lag survives every (re)mint and recall surface — not just the drain path:
- buildMiniSummary inline re-upsert: wrapped in _withArchiveState (archive-vs-summary race no longer drops archivedAt). - updateMemoryMiniSummary: the addNodes overwrite now replays the tombstone from the durable marker (merge-vs-archive race). - _readPendingWalRecencyRows: identity-level short-circuit excludes an archived identity's graph-PENDING rows from recency recall (the graph-SQL path already excluded archivedAt; this closes the WAL-pending overlay gap).
Test: the projection-lag suite extends with a recency-overlay short-circuit assertion (9/9 green). Full memory-core unit suite regression-free (13 failed = pre-existing local-LM-dependent specs on clean dev; 510 passed = clean + the 4 new tests).
* test(memory-core): public graph-recall leak coverage for archive — queryRecentTurns + getContextFrontier (#13384)
Addresses the cycle-2 CHANGES_REQUESTED: the prior tests proved the projection-lag mechanism via private helpers, but the source issue's ACs name queryRecentTurns + getContextFrontier (the public graph-backed recall surfaces), which now have direct coverage against the real in-memory SQLite graph (UNIT_TEST_MODE ':memory:', mirroring QueryRecentTurns.spec).
queryRecentTurns: full end-to-end — addMemory -> archiveMemoriesByAgentIdentity (real op: Chroma sweep + graph-SQL stamp + durable marker) -> the row is excluded from the public recency surface -> unarchive restores it.
getContextFrontier: its frontier is agent-identity RLS-scoped (isRlsVisible keys on the acting agentIdentityNodeId, never a tenant userId), so a tenant memory node is never one of its strategic neighbors. The test exercises the public surface's archivedAt exclusion directly with a globally-visible frontier neighbor carrying the same node-cache archivedAt state the archive op's coherence sweep stamps (the op's stamping itself is pinned in the sibling spec). 2/2 green; 22 passed alongside ArchiveByIdentity + QueryRecentTurns (no cross-spec interference).
* test(memory-core): point ArchiveByIdentity header at the public-recall spec — gpt cycle-2 RA3 (#13384)
The header claimed the graph-SQL (queryRecentTurns) + frontier (getContextFrontier) exclusion was 'covered by a separate integration assertion'. That assertion now exists — MemoryService.ArchiveByIdentity.PublicRecall.spec.mjs — so the comment points at it directly. Completes the third of gpt's cycle-2 Required Actions; RA1 (queryRecentTurns public test) + RA2 (getContextFrontier public test) landed in 51d4561.
1 parent 57c9c67 commit 9235db9
4 files changed
Lines changed: 762 additions & 5 deletions
File tree
- ai/services/memory-core
- test/playwright/unit/ai/services/memory-core
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
869 | 869 | | |
870 | 870 | | |
871 | 871 | | |
872 | | - | |
| 872 | + | |
873 | 873 | | |
874 | 874 | | |
875 | 875 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
527 | 527 | | |
528 | 528 | | |
529 | 529 | | |
530 | | - | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
531 | 533 | | |
532 | 534 | | |
533 | 535 | | |
| |||
621 | 623 | | |
622 | 624 | | |
623 | 625 | | |
624 | | - | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
625 | 630 | | |
626 | 631 | | |
627 | 632 | | |
| |||
806 | 811 | | |
807 | 812 | | |
808 | 813 | | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
809 | 822 | | |
810 | 823 | | |
811 | 824 | | |
| |||
913 | 926 | | |
914 | 927 | | |
915 | 928 | | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
916 | 932 | | |
917 | 933 | | |
918 | 934 | | |
| |||
927 | 943 | | |
928 | 944 | | |
929 | 945 | | |
930 | | - | |
| 946 | + | |
931 | 947 | | |
932 | 948 | | |
933 | 949 | | |
| |||
958 | 974 | | |
959 | 975 | | |
960 | 976 | | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
| 1148 | + | |
| 1149 | + | |
| 1150 | + | |
| 1151 | + | |
| 1152 | + | |
| 1153 | + | |
| 1154 | + | |
| 1155 | + | |
| 1156 | + | |
| 1157 | + | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
| 1165 | + | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
961 | 1186 | | |
962 | 1187 | | |
963 | 1188 | | |
| |||
1045 | 1270 | | |
1046 | 1271 | | |
1047 | 1272 | | |
| 1273 | + | |
1048 | 1274 | | |
1049 | 1275 | | |
1050 | 1276 | | |
| |||
1282 | 1508 | | |
1283 | 1509 | | |
1284 | 1510 | | |
1285 | | - | |
| 1511 | + | |
| 1512 | + | |
| 1513 | + | |
1286 | 1514 | | |
1287 | 1515 | | |
1288 | 1516 | | |
| |||
1502 | 1730 | | |
1503 | 1731 | | |
1504 | 1732 | | |
| 1733 | + | |
| 1734 | + | |
| 1735 | + | |
| 1736 | + | |
| 1737 | + | |
| 1738 | + | |
| 1739 | + | |
| 1740 | + | |
| 1741 | + | |
| 1742 | + | |
| 1743 | + | |
| 1744 | + | |
| 1745 | + | |
1505 | 1746 | | |
1506 | 1747 | | |
1507 | 1748 | | |
| |||
0 commit comments