Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).

## [Unreleased]

## [1.25.0] - 2026-06-24

### Added

- **Opt-in redaction-at-capture — `KIT_MEMORY_REDACT=1` (#91).** The memory store is raw by default (a key in any transcript is persisted to `memory.db` in cleartext — a stolen-laptop / backup-spillage risk). With `KIT_MEMORY_REDACT=1`, secret-shaped substrings in a message's `content` and a tool's `tool_input` are masked (via the same `redactSecrets` patterns) **before** they are written, so the secret never lands in the DB. Off by default → no behavior change; FTS still works over the redacted text for non-secret terms.

### Removed

- **Dead `Redacted<T>` wrapper (#92).** The `src/utils/redacted.ts` wrapper (added in 1.15.0) had no importers; removed it and its test. (Secret masking is done by `redactSecrets`, which stays.)

## [1.24.0] - 2026-06-24

Consolidated security-hardening batch (merged PRs #70–#94) + two recovered features.
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sandstream-kit",
"version": "1.24.0",
"version": "1.25.0",
"description": "developer kit. zero LLM, local-first, multi-vault. one command from git clone to working dev environment.",
"license": "MIT",
"funding": "https://buymeacoffee.com/sandstream",
Expand Down
32 changes: 32 additions & 0 deletions src/memory/db.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,3 +246,35 @@ describe("memory db", () => {
db.close();
});
});

describe("redaction-at-capture (KIT_MEMORY_REDACT)", () => {
const SECRET = ["sk", "live", "Z".repeat(40)].join("_");
function insertAndRead(redact: boolean): string {
const prev = process.env.KIT_MEMORY_REDACT;
if (redact) process.env.KIT_MEMORY_REDACT = "1";
else delete process.env.KIT_MEMORY_REDACT;
try {
const db = openMemoryDb(":memory:");
upsertSession(db, { sessionId: "s", harness: "claude-code" });
insertMessage(db, { uuid: "u", sessionId: "s", type: "user", content: `key ${SECRET}` });
const row = db.prepare("SELECT content FROM messages WHERE uuid = ?").get("u") as {
content: string;
};
db.close();
return row.content;
} finally {
if (prev === undefined) delete process.env.KIT_MEMORY_REDACT;
else process.env.KIT_MEMORY_REDACT = prev;
}
}

it("stores raw content by default (opt-in off)", () => {
assert.ok(insertAndRead(false).includes(SECRET));
});

it("masks secrets at capture when KIT_MEMORY_REDACT=1", () => {
const c = insertAndRead(true);
assert.ok(!c.includes(SECRET), "secret must not be persisted");
assert.match(c, /\[REDACTED\]/);
});
});
21 changes: 19 additions & 2 deletions src/memory/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,26 @@ import { join } from "node:path";
import { existsSync, mkdirSync, chmodSync, statSync } from "node:fs";
import type { MemoryStats, MessageInput, SearchHit, SessionInput, ToolUseInput } from "./types.js";
import { summarizeTokens } from "./stats.js";
import { redactSecrets } from "../utils/redactSecrets.js";

export const SCHEMA_VERSION = 4;

/**
* Opt-in redaction-at-capture (KIT_MEMORY_REDACT=1). The memory store is raw by
* default; a regulated/air-gapped deployment can have secret-shaped substrings
* masked BEFORE they ever land in memory.db, so a leaked key in a transcript is
* never persisted (spillage prevention). Off by default — no behavior change.
*/
function captureRedactEnabled(): boolean {
return ["1", "true", "yes"].includes((process.env.KIT_MEMORY_REDACT ?? "").trim().toLowerCase());
}

/** Apply capture-time redaction to a stored text field when enabled. */
function captureText(text: string | null | undefined): string | null {
if (text == null) return null;
return captureRedactEnabled() ? redactSecrets(text) : text;
}

export function getMemoryDir(): string {
return process.env.KIT_MEMORY_DIR ?? join(homedir(), ".kit");
}
Expand Down Expand Up @@ -253,7 +270,7 @@ export function insertMessage(db: DatabaseSync, m: MessageInput): boolean {
m.parentUuid ?? null,
m.type,
m.role ?? null,
m.content ?? null,
captureText(m.content),
m.model ?? null,
m.inputTokens ?? null,
m.outputTokens ?? null,
Expand Down Expand Up @@ -281,7 +298,7 @@ export function insertToolUse(db: DatabaseSync, t: ToolUseInput): void {
t.messageUuid ?? null,
t.sessionId ?? null,
t.toolName,
t.toolInput ?? null,
captureText(t.toolInput),
t.timestamp ?? null,
);
}
Expand Down
44 changes: 0 additions & 44 deletions src/utils/redacted.test.ts

This file was deleted.

45 changes: 0 additions & 45 deletions src/utils/redacted.ts

This file was deleted.

Loading