Repository navigation
Conversation
…n search path (Refs #995) Adds ~/.config/brainlayer/lexical_defense.local.json (override: BRAINLAYER_LEXICAL_DEFENSE_LOCAL) merged at runtime on top of the packaged dictionary. Missing file -> packaged dictionary unchanged. Strict bounded schema; any violation rejects the whole file with one warning. User entries never claim a packaged surface or an earlier user entry's surface. The file is stat()ed per call and re-read only when (path, mtime_ns, size) changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L3NoZGEuwfULsRM3NY1aJh
…earch fallback (Refs #995) The hybrid helper (Python) and BrainBar's native fallback now expand the same optional ~/.config/brainlayer/lexical_defense.local.json, with identical bounds, whole-file rejection, conflict/cycle policy and stat-keyed freshness. The packaged lexicalDefenseReplacements table stays the empty literal. Documents the config contract and tightens the oversized fixture so only the byte bound can reject it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L3NoZGEuwfULsRM3NY1aJh
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
|
|
Overall Grade |
Security Reliability Complexity Hygiene |
Code Review Summary
| Analyzer | Status | Updated (UTC) | Details |
|---|---|---|---|
| Python | Nov 5, 2026 5:24a.m. | Review ↗ | |
| Swift | Nov 5, 2026 5:24a.m. | Review ↗ | |
| JavaScript | Nov 5, 2026 5:24a.m. | Review ↗ | |
| Shell | Nov 5, 2026 5:24a.m. | Review ↗ | |
| Secrets | Nov 5, 2026 5:24a.m. | Review ↗ |
Important
AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.
…er alias source (Refs #995) Swift: bind the canonical value instead of force-unwrapping it; the XCTest case drops implicitly unwrapped properties and owns its one database locally. Python: split per-entry validation out of parse_user_alias_entries and hold the effective-dictionary cache in a lock-guarded list instead of a global. No behavior change; 7/7 mutants still killed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L3NoZGEuwfULsRM3NY1aJh
BrainLayer ratchetEvery Value below was measured by this run. A row this machine cannot measure says Hosted success gives no verdict on mapped bytes, search p50/p95, idle CPU, hotlane backlog CPU, or fallback replay debt.
🟢 GREEN measured, within budget · 🔴 RED measured, out of budget — a finding to clear before merge · ⚪ n/a not measurable on this machine, never guessed. No RED rows. Measured on Linux/x86_64 · measured |
|
Why I think it isn't this PR's:
I tried a single re-run of the failed jobs and got Generated by Claude Code |
|
The 5 new Generated by Claude Code |
Change and evidence
Task marker:
cloud-credit-20261105-brainlayer-hammer-aliases995· Draft only, for the owning lead (routed toorc) to review. Not for merge as-is.main@d6b82f04f6baa00081c9dc38afca2ada9d114c78. Actual base: the same SHA, fetched inside the cloud container before any edit.claude/draft-pr-review-r6d95d. Head:395bbd8(3 commits).What #995 asked, and the path that is actually live
#994/#997 emptied the shipped alias data. #995's main item, the runtime user-config source, was never built. Tracing today's
brain_search:MCPRouter→ hybrid helper subprocess (brainbar_hybrid_helper.py) → Python_brain_search→_expanded_fts_query→_lexical_defense_variants→ packaged JSON.BrainDatabase.expandedSearchQueries→lexicalDefenseReplacements, which is the empty literal[:].Both paths now read one optional file with one contract. Fixing only path 1 would leave the fallback quietly without user aliases.
Config contract (also in
docs/configuration.md→ "Personal lexical aliases")~/.config/brainlayer/lexical_defense.local.json, or an absolute path inBRAINLAYER_LEXICAL_DEFENSE_LOCAL. Nothing creates or writes it.{"version": 1, "entries": [{"canonical": str, "aliases"?: [str], "split_forms"?: [str]}]}version; unknown keys; more than 256 entries; more than 16 surfaces per entry; a surface that is empty, longer than 64 characters, or punctuation-only.A→BplusB→Acollide under the conflict rule, so the later entry is skipped. Expansion is one hop, never transitive.stat()ed on every search and re-read only when(path, mtime, size)changes. Edits apply on the next search, with no restart of BrainBar or the helper.protect_from_split=Falsewith sourceuser_config. The VoiceLayer/GBNF/JSON export script still reads only the packaged dictionary, so user terms never reach exported artifacts.lexical_defense_dictionary.jsonis byte-for-byte unchanged (a sha256 check is in the test).private static let lexicalDefenseReplacements: [String: [String]] = [:]is unchanged, so the existing pin intest_brainbar_bundle_has_no_personal_lexical_defaultsstill holds.tests/conftest.py: onedelenvso an operator-exported override can't walk past the per-test HOME remap.Proof (synthetic fixtures only:
Zorbleth,qwvx,Plimsar, …)pytest tests/test_lexical_defense_user_aliases.py tests/test_lexical_defense.py tests/test_search_alias_expansion.py tests/test_search_handler.py tests/test_brainbar_hybrid_helper.py_brain_search("qwvx")test and the one-hop cycle test, run against main'ssrc/(stashed)[] == ['chunk-zorbleth'],['Zorbleth'] == ['Zorbleth', 'qwvx']). NEW: 2 passed395bbd8refactor. The byte-bound mutant first survived; the fixture was fixed to schema-valid JSON plus whitespace padding, so only the byte bound can reject itbrain-bar/Sources(12 files), plustest_ci_swift_gate.pyandtest_brainbar_update_script.pyruff check/ruff format --checkon changed Pythonglobal model retirement (installed + native)onmacos-15, Xcode 26.3, at395bbd838c74runsswift build --build-testsonbrain-barunconditionally (scripts/retirement_native.py)LexicalDefenseUserAliases.swift, the Daemon symlink and the new XCTest file. OnlyRetirementRatchetTestswere executed thereUNRUN / limitations
LexicalDefenseUserAliases.swift, the 3-lineBrainDatabasewiring, the Daemon symlink andLexicalDefenseUserAliasesTests.swift(5 XCTests: absent→unchanged native search then a hit, edit/delete freshness, 13 malformed cases + non-UTF-8, conflict/cycle/one-hop) were not compiled or run by me. Hosted macOS CI compiled them at395bbd8(row above). Running the 5 new XCTests is still UNRUN.swift (macos-15)started at 06:25Z and the process died at 06:30Z: a SIGSEGV in pre-existingEntityCache.startRefreshTimer→tableColumns(use-after-close of a rawsqlite3*) duringBrainBarMaintenanceRetryTests. That happened before the alphabetical suite order reachedLexicalDefenseUserAliasesTests. Analysis is in the PR comment; the job is green on main. Nothing here claims installed or live behavior.395bbd8(final read 06:35Z): green: lint, CodeQL (incl. Swift), crash sweeps,test (3.12), installed-wheel imports, ratchet table (no RED rows), BrainBar no-enrichment render, and nativeswift build --build-tests. Red, judged not this PR's (one PR comment each):test (3.11), where ci-unit hit its 1800s budget at 98% on an untouched WAL test (main ran 28 min, here 37 min); andswift (macos-15), theEntityCachecrash above.test (3.13)was cancelled by fail-fast. My re-run attempt returned 403, so the lead needs to re-run the failed jobs on run 41973840809.395bbd8(Swift force-unwrap and implicitly unwrapped optionals; Python complexity andglobal), and their threads are resolved. DeepSource: Python is also red on maind6b82f0. DeepSource: Swift is green on main but still red at395bbd8, and it posted no new inline findings. Whatever it flags is only on the DeepSource dashboard, which I couldn't read, so the lead needs to look there.scripts/run_tests.sh, or the repo pre-push hook (core.hooksPathisn't set in this clone; nothing was bypassed). Theconftest.pytouch will trigger the automatic crash sweep in CI.casefold+isalnum; Swift uses NFKC+lowercased+CharacterSet.alphanumerics. They are identical for ASCII and can differ on exotic scripts/marks. Documented, not unified.BrainDatabaseread the real$HOMEdefault path, because there is no HOME isolation on the Swift side. On a developer Mac that has a personal alias file, an existing search test could in theory see an extra expansion. The new tests inject their own path.Size: over the 400-line budget, reported rather than hidden
+645/−3total at395bbd8. Commit 1c11f9a2(Python path + conftest + tests) ≈ 333 lines, and the docs add 26. Commit 2d4670a8(Swift fallback + XCTests + docs) ≈ 318 lines. The two commits separate cleanly. If the lead wants it split, cherry-pickd4670a8onto its own PR.395bbd8only addresses static-analysis findings across both halves, with no behavior change. This dispatch allowed one branch only, so I didn't push a second one.Risks
stat()once per search on each path: negligible next to FTS.Handoff — addressed to
orc(dispatcher: copy intoorchestrator/docs.local/plans/2026-11-04-claude-cloud-batch/collab.md; that file was not mounted here)Loop-record: implementer=Claude Code cloud (Anthropic)/effort high; reviewer=none; rounds=0; defects=0
Generated by Claude Code
Note
Add optional user-config lexical alias source to both brain_search paths
BRAINLAYER_LEXICAL_DEFENSE_LOCALenvironment override.Macroscope summarized d4670a8. (Automatic summaries will resume when PR exits draft mode or review begins).