mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-11-24 14:16:34 +09:00
fix(memory): ADR-125 CLI-flag precedence over RUFLO_MEMORY_SCAN_ON_WRITE (#2794)
Verification agent (12-hour cadence, #2794) caught v3.32.17's #2752 MemPoison env var without the ADR-125 §"CLI flag wins" / ADR-130 §env-var-config-precedence pattern. CI on main red since 03:04 UTC. Fix (Option A per the report): restructure the read so the CLI flag takes precedence via nullish coalescing, with the exact ADR-125 comment the audit script scans for: // CLI flag ctx.flags.scanContent takes precedence over // RUFLO_MEMORY_SCAN_ON_WRITE env var (ADR-125 / ADR-130 — #2794). const scanContent = (ctx.flags.scanContent as boolean | undefined) ?? /^(1|true|yes|on)$/i.test(String(process.env.RUFLO_MEMORY_SCAN_ON_WRITE ?? '')); Removed `default: false` from the option definition so the parser leaves the flag `undefined` when the user doesn't pass it — required for `?? env` to see the env value. Explicit `--no-scan-content` still sets false and correctly wins over any env value. Audit script confirms: "ok: all CLAUDE_FLOW_* / RUFLO_* env var reads have documented CLI-flag precedence". Regression tests still pass: planflip-mempoison-2752 (6/6) + memory-search-2790 (4/4) — 10/10 total for the affected paths. Closes: #2794. Co-Authored-By: RuFlo <ruv@ruv.net>
This commit is contained in:
1 parent
fa6f9429f9
commit
4467aeebba
1 file changed
+9
-4
@@ -83,10 +83,13 @@ const storeCommand: Command = {
|
||||
// on the value BEFORE persistence and refuse the write if a
|
||||
// finding is present. Opt-in per-call; RUFLO_MEMORY_SCAN_ON_WRITE=1
|
||||
// enables it globally.
|
||||
// NOTE: no `default:` here — needed so the ADR-125 CLI-flag-wins
|
||||
// precedence (`ctx.flags.scanContent ?? envVar`) can distinguish
|
||||
// "user didn't pass the flag" (undefined) from "user explicitly
|
||||
// said --no-scan-content" (false). Fixes #2794.
|
||||
name: 'scan-content',
|
||||
description: 'Scan the value for injection payloads before persisting (dream-cycle #2752 MemPoison gate)',
|
||||
type: 'boolean',
|
||||
default: false
|
||||
},
|
||||
DB_PATH_OPTION
|
||||
],
|
||||
@@ -135,9 +138,11 @@ const storeCommand: Command = {
|
||||
}
|
||||
|
||||
// #2752 MemPoison gate — scan before persist when opted in.
|
||||
const scanContentFlag = ctx.flags.scanContent as boolean | undefined;
|
||||
const scanContentEnv = /^(1|true|yes|on)$/i.test(String(process.env.RUFLO_MEMORY_SCAN_ON_WRITE ?? ''));
|
||||
if (scanContentFlag || scanContentEnv) {
|
||||
// CLI flag ctx.flags.scanContent takes precedence over RUFLO_MEMORY_SCAN_ON_WRITE env var
|
||||
// (ADR-125 §"CLI flag wins" / ADR-130 §env-var-config-precedence — fix for #2794).
|
||||
const scanContent = (ctx.flags.scanContent as boolean | undefined)
|
||||
?? /^(1|true|yes|on)$/i.test(String(process.env.RUFLO_MEMORY_SCAN_ON_WRITE ?? ''));
|
||||
if (scanContent) {
|
||||
try {
|
||||
const { scanChannelMessage } = await import('../security/channel-guard.js');
|
||||
const scan = scanChannelMessage(value);
|
||||
|
||||
Reference in new issue
Block a user