Lines 444-484typescript
445 // Successful calls are keyed on their exact signature (not the coarse program name), so distinct
446 // successes are each kept rather than collapsed — the fact tag therefore embeds the full command.
447 const echoOk = mems.filter((m: any) => /bash_terminal `echo vibelm-ok` → ok/.test(m.content));
448 assert.equal(echoOk.length, 1, "a successful command records its own outcome fact");
449 assert.ok((echoOk[0].tags || []).some((t: string) => t.startsWith("fact:bash_terminal:") && t.endsWith(":ok")), "success fact is tagged with an ok-outcome key");
452 it("keeps distinct successful commands as separate facts but never leaks secret args into the fact key", async () => {
453 const { distillToolFact } = await import("../src/toolsProvider");
455 // Distinct successful commands must not collapse (regression caught in live testing).
456 const a = distillToolFact("bash_terminal", { command: "cat a.txt" }, { ok: true, data: { exitCode: 0, stdout: "ALPHA", stderr: "" } });
457 const b = distillToolFact("bash_terminal", { command: "cat b.txt" }, { ok: true, data: { exitCode: 0, stdout: "BRAVO", stderr: "" } });
458 assert.notEqual(a.key, b.key, "distinct successful commands must get distinct dedupe keys");
460 // A secret arg (ssh_exec password) must never appear in the key — the key is persisted as a
461 // memory tag, so the success key is a hash of the signature, not the raw args.
462 const s = distillToolFact(
464 { host: "h", user: "u", password: "SUPERSECRET123", command: "whoami" },
465 { ok: true, data: { exitCode: 0, stdout: "root", stderr: "" } },
467 assert.ok(!s.key.includes("SUPERSECRET123"), "the fact key must not embed the password");
468 assert.ok(!s.fact.includes("SUPERSECRET123"), "the fact text must not embed the password");
471 it("buildContextSpine pins goal + plan + facts as the head (cut-the-middle retention)", async () => {
472 const { buildContextSpine } = await import("../src/toolsProvider");
473 const { SessionLog } = await import("../src/sessionLog");
474 const logPath = resolve(CONFIG_DIR, `spine-${Date.now()}.jsonl`);
475 const log = new SessionLog(logPath);
476 const sid = "spine-sess";
477 log.saveMemory(["fact:bash_terminal:ls:fail", `session:${sid}`], "bash_terminal `ls /x` → failed: not found", 1, sid, "/ws", "workspace");
478 log.saveMemory(["fact:bash_terminal:#abc:ok", `session:${sid}`], "bash_terminal `cat a.txt` → ok: ALPHA-DATA", 2, sid, "/ws", "workspace");
483 goal: "Build the widget",