fix(memory-qmd): restore qmd compatibility defaults

This commit is contained in:
Vincent Koc
2026-04-06 01:31:19 +01:00
parent ca462fb928
commit 098f4eeebb
7 changed files with 51 additions and 10 deletions

View File

@@ -895,7 +895,7 @@ describe("QmdMemoryManager", () => {
);
});
it("prefers --mask for collection add and falls back to --glob when --mask is rejected", async () => {
it("prefers --glob for collection add and falls back to --mask when --glob is rejected", async () => {
cfg = {
...cfg,
memory: {
@@ -917,10 +917,10 @@ describe("QmdMemoryManager", () => {
}
if (args[0] === "collection" && args[1] === "add") {
const child = createMockChild({ autoClose: false });
const flag = args.includes("--mask") ? "--mask" : args.includes("--glob") ? "--glob" : "";
const flag = args.includes("--glob") ? "--glob" : args.includes("--mask") ? "--mask" : "";
addFlagCalls.push(flag);
if (flag === "--mask") {
emitAndClose(child, "stderr", "unknown flag: --mask", 1);
if (flag === "--glob") {
emitAndClose(child, "stderr", "unknown flag: --glob", 1);
return child;
}
queueMicrotask(() => child.closeWith(0));
@@ -932,7 +932,7 @@ describe("QmdMemoryManager", () => {
const { manager } = await createManager({ mode: "full" });
await manager.close();
expect(addFlagCalls).toEqual(["--mask", "--glob", "--glob", "--glob"]);
expect(addFlagCalls).toEqual(["--glob", "--mask", "--mask", "--mask"]);
expect(logWarnMock).toHaveBeenCalledWith(
expect.stringContaining("retrying with legacy compatibility flag"),
);

View File

@@ -274,7 +274,7 @@ export class QmdMemoryManager implements MemorySearchManager {
private attemptedNullByteCollectionRepair = false;
private attemptedDuplicateDocumentRepair = false;
private readonly sessionWarm = new Set<string>();
private collectionPatternFlag: QmdCollectionPatternFlag | null = "--mask";
private collectionPatternFlag: QmdCollectionPatternFlag | null = "--glob";
private constructor(params: {
cfg: OpenClawConfig;
@@ -653,7 +653,7 @@ export class QmdMemoryManager implements MemorySearchManager {
private async addCollection(pathArg: string, name: string, pattern: string): Promise<void> {
const candidateFlags: QmdCollectionPatternFlag[] =
this.collectionPatternFlag === "--mask" ? ["--mask", "--glob"] : ["--glob", "--mask"];
this.collectionPatternFlag === "--glob" ? ["--glob", "--mask"] : ["--mask", "--glob"];
let lastError: unknown;
for (const flag of candidateFlags) {
try {