Summary
memory save silently accepts unknown flags (e.g. --kind, --body) and misroutes their values into positional arguments, causing data corruption in the database.
Reproduction
memory save --project muzzle --kind learning --topic "My Topic" --body "actual content"
Expected: error like unknown flag: --kind
Actual: silently saves with title=muzzle, content=learning (garbage)
Root cause
find_positional() in memory/src/main.rs:305 only recognizes flags in VALUE_FLAGS (-p, --type, --topic, --source). Unknown --flags are treated as boolean flags — skipped themselves but their following value becomes a positional arg.
if arg.starts_with('-') {
if VALUE_FLAGS.contains(&arg.as_str()) {
skip_next = true; // skip this flag's value
}
continue; // ← unknown flags silently skipped, value becomes positional
}
Proposed fix
Reject unknown flags early in cmd_save (and other subcommands):
for arg in args {
if arg.starts_with('-') && !VALUE_FLAGS.contains(&arg.as_str()) {
return Err(format!("unknown flag: {arg}"));
}
}
Alternatively, validate at the find_positional level so all subcommands benefit.
Impact
Observed in production: observation #161 was saved with title=muzzle, content=learning instead of the intended 40-line H-4 origin story. Had to manually delete and re-save.
Summary
memory savesilently accepts unknown flags (e.g.--kind,--body) and misroutes their values into positional arguments, causing data corruption in the database.Reproduction
Expected: error like
unknown flag: --kindActual: silently saves with
title=muzzle,content=learning(garbage)Root cause
find_positional()inmemory/src/main.rs:305only recognizes flags inVALUE_FLAGS(-p,--type,--topic,--source). Unknown--flagsare treated as boolean flags — skipped themselves but their following value becomes a positional arg.Proposed fix
Reject unknown flags early in
cmd_save(and other subcommands):Alternatively, validate at the
find_positionallevel so all subcommands benefit.Impact
Observed in production: observation #161 was saved with
title=muzzle,content=learninginstead of the intended 40-line H-4 origin story. Had to manually delete and re-save.