Skip to content

Local-first 🧠 memory for Hermes Agent that lives in your Obsidian vault and remembers project context. Nightly 😴 dream passes turn repeat corrections into confirmed preferences with measurable confidence. Adapters ship for Claude Code, Codex, and OpenClaw, with an MCP server for anything else.

TypeScript

v0.10.9: address CodeRabbit review

Sol Aitkenfc220d78b453
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d8750891..b3e7746c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2075,6 +2075,7 @@ Hermes / Claude Code / Codex / OpenClaw configurations do not change.
- Sandbox vault and plugin manifest fixtures for tests.
- GitHub release workflow for tag-based and manually dispatched releases.
+[0.10.9]: https://github.com/itechmeat/open-second-brain/compare/v0.10.8...v0.10.9
[0.10.8]: https://github.com/itechmeat/open-second-brain/compare/v0.10.7...v0.10.8
[0.10.7]: https://github.com/itechmeat/open-second-brain/compare/v0.10.6...v0.10.7
[0.10.6]: https://github.com/itechmeat/open-second-brain/compare/v0.10.5...v0.10.6
diff --git a/docs/plans/2026-05-19-vault-scope-design.md b/docs/plans/2026-05-19-vault-scope-design.md
index 163c66d3..1ae12a96 100644
--- a/docs/plans/2026-05-19-vault-scope-design.md
+++ b/docs/plans/2026-05-19-vault-scope-design.md
@@ -343,8 +343,11 @@ Failure modes:
- Vault path missing: exit 1, single-line stderr error
(matches existing `o2b brain doctor` convention).
-- `_brain.yaml` unreadable: status falls back to defaults but
- prints a `warning:` line on stderr.
+- `_brain.yaml` unreadable / malformed: status fails closed
+ (§5) — single-line stderr error from the propagated
+ `BrainConfigError` and exit 1. Walkers cannot silently drop
+ the operator's policy, so the CLI surface refuses to render
+ partial counts.
### 7.2 `o2b vault inspect <relpath>`
diff --git a/docs/plans/2026-05-19-vault-scope-impl.md b/docs/plans/2026-05-19-vault-scope-impl.md
index 8a124af5..e6452dff 100644
--- a/docs/plans/2026-05-19-vault-scope-impl.md
+++ b/docs/plans/2026-05-19-vault-scope-impl.md
@@ -642,12 +642,13 @@ function buildScope(
const DEFAULT_SCOPE = buildScope(DEFAULT_VAULT_IGNORE_PATHS, "defaults");
export function resolveVaultScope(vault: string): VaultScope {
- let cfg;
- try {
- cfg = loadBrainConfig(vault);
- } catch {
- return DEFAULT_SCOPE;
- }
+ // Missing `_brain.yaml` is the only "silent" case — pre-v0.10.9
+ // vaults stay working under built-in defaults. Anything else
+ // (malformed YAML, schema mismatch, unreadable file) fails closed
+ // by propagating the `BrainConfigError` to the caller; walkers
+ // refuse to ingest paths the operator meant to hide.
+ if (!existsSync(brainConfigPath(vault))) return DEFAULT_SCOPE;
+ const cfg = loadBrainConfig(vault);
const declared = cfg.vault?.ignore_paths;
if (declared === undefined) return DEFAULT_SCOPE;
return buildScope(declared, "_brain.yaml");
diff --git a/src/cli/main.ts b/src/cli/main.ts
index 12408a26..c03baef6 100644
--- a/src/cli/main.ts
+++ b/src/cli/main.ts
@@ -507,7 +507,12 @@ export async function main(argv: ReadonlyArray<string>): Promise<number> {
// Per-command --help support: print the dedicated help line plus generic.
// The `brain` subcommand has its own dispatcher with per-verb help, so we
// skip the generic shortcut and hand control over directly.
- if (rest.length === 1 && (rest[0] === "-h" || rest[0] === "--help") && command !== "brain") {
+ if (
+ rest.length === 1 &&
+ (rest[0] === "-h" || rest[0] === "--help") &&
+ command !== "brain" &&
+ command !== "vault"
+ ) {
process.stdout.write(`${command}: see https://github.com/itechmeat/open-second-brain\n`);
if (command === "uninstall") {
process.stdout.write(
diff --git a/src/cli/vault.ts b/src/cli/vault.ts
index b3fc2144..ecee227c 100644
--- a/src/cli/vault.ts
+++ b/src/cli/vault.ts
@@ -44,7 +44,10 @@ export async function handleVaultSubcommand(
} catch (exc) {
if (exc instanceof CliError) {
process.stderr.write(`error: ${exc.message}\n`);
- return 1;
+ // Argument / usage errors use exit 2 to stay consistent with the
+ // rest of the CLI; runtime failures inside a verb still bubble up
+ // through `fail()` (exit 1).
+ return 2;
}
throw exc;
}
diff --git a/src/core/brain/inline-scan.ts b/src/core/brain/inline-scan.ts
index 701ba63f..2e17cc8d 100644
--- a/src/core/brain/inline-scan.ts
+++ b/src/core/brain/inline-scan.ts
@@ -115,7 +115,10 @@ export async function scanInline(
const scope = resolveVaultScope(vault);
const rules: VaultIgnoreRule[] = [
...scope.rules,
- { raw: "Brain", kind: "name" },
+ // `path` (not `name`) so the hard-skip targets only the top-level
+ // `<vault>/Brain/` directory; a project file like
+ // `projects/Brain/notes.md` keeps being scanned.
+ { raw: "Brain", kind: "path" },
...(opts.exclude ?? []).map(
(raw): VaultIgnoreRule => ({ raw: normalisePrefix(raw), kind: "path" }),
),
@@ -227,9 +230,11 @@ export async function scanInline(
// ----- Walker ---------------------------------------------------------------
function normalisePrefix(rel: string): string {
- // POSIX-normalise: strip leading/trailing slashes, replace OS-native
- // separator with `/`. `matchIgnore` expects POSIX rel-paths.
- return rel.replace(/^\/+|\/+$/g, "").split(sep).join("/");
+ // POSIX-normalise: replace OS-native separator with `/` FIRST, then
+ // strip leading/trailing slashes. On Windows `notes\\` must become
+ // `notes` (not `notes/`), so the separator conversion has to happen
+ // before the slash trim. `matchIgnore` expects POSIX rel-paths.
+ return rel.split(sep).join("/").replace(/^\/+|\/+$/g, "");
}
function* walkVault(
diff --git a/src/core/brain/policy.ts b/src/core/brain/policy.ts
index 39f77516..0e87b5af 100644
--- a/src/core/brain/policy.ts
+++ b/src/core/brain/policy.ts
@@ -482,6 +482,17 @@ export function validateBrainConfigDetailed(
source,
);
}
+ // Reject leading-slash entries explicitly. `matchIgnore` only
+ // compares vault-relative POSIX prefixes (no leading `/`), so
+ // `/Brain/.snapshots` would silently never match — exactly the
+ // fail-closed contract violation the v0.10.9 policy forbids.
+ if (normalised.startsWith("/")) {
+ throw new BrainConfigError(
+ "must be a bare name or vault-relative POSIX path without a leading '/'",
+ `vault.ignore_paths[${i}]`,
+ source,
+ );
+ }
validated.push(normalised);
});
vault = { ignore_paths: Object.freeze(validated) };
diff --git a/tests/cli/vault.test.ts b/tests/cli/vault.test.ts
index 98c282af..0705836b 100644
--- a/tests/cli/vault.test.ts
+++ b/tests/cli/vault.test.ts
@@ -161,6 +161,7 @@ describe("o2b vault inspect", () => {
["vault", "inspect", "idea.md", "--vault", vault, "--json"],
{ env: { OPEN_SECOND_BRAIN_CONFIG: config } },
);
+ expect(r.returncode).toBe(0);
const payload = JSON.parse(r.stdout);
expect(payload.status).toBe("included");
expect(payload.exists_on_disk).toBe(true);
diff --git a/tests/core/brain.inline-scan.test.ts b/tests/core/brain.inline-scan.test.ts
index 14233f3e..9d2fb1e3 100644
--- a/tests/core/brain.inline-scan.test.ts
+++ b/tests/core/brain.inline-scan.test.ts
@@ -261,6 +261,22 @@ describe("scanInline", () => {
expect(result.found).toBe(0);
});
+ test("v0.10.9: hardcoded Brain rule is path-scoped — nested 'Brain' dirs keep being scanned", async () => {
+ // The hard-skip targets `<vault>/Brain` specifically. A project
+ // directory like `projects/Brain/notes.md` is unrelated to the
+ // derived layer and must still be discoverable by scan-inline.
+ writeMd(
+ "projects/Brain/notes.md",
+ `@osb feedback negative topic=nested-brain-keep principle=p\n`,
+ );
+ const result = await scanInline(tmp, { agent: "test" });
+ expect(result.created).toBe(1);
+ const inbox = readdirSync(brainDirs(tmp).inbox);
+ expect(
+ inbox.some((f) => f.includes("nested-brain-keep")),
+ ).toBe(true);
+ });
+
test("v0.10.9: vault.ignore_paths additions are respected", async () => {
atomicWriteFileSync(
join(brainDirs(tmp).brain, "_brain.yaml"),
diff --git a/tests/core/brain.policy.test.ts b/tests/core/brain.policy.test.ts
index 5e656995..625a11b2 100644
--- a/tests/core/brain.policy.test.ts
+++ b/tests/core/brain.policy.test.ts
@@ -473,6 +473,15 @@ describe("validateBrainConfig — vault block (v0.10.9)", () => {
),
).toThrow(/vault\.ignore_paths\[0\].*empty/);
});
+
+ test("leading-slash entry is rejected (matchIgnore cannot match it)", () => {
+ expect(() =>
+ validateBrainConfig(
+ { schema_version: 1, vault: { ignore_paths: ["/Brain/.snapshots"] } },
+ "<test>",
+ ),
+ ).toThrow(/vault\.ignore_paths\[0\].*leading '\/'/);
+ });
});
describe("loadBrainConfig — filesystem integration", () => {