task_update stored any string as a task's status, so an agent writing
"complete" left a finished task every reader misread: the ruflo-console
Automation kanban listed it under PENDING (offering assign/cancel), and
Mission Control derived it as ready, so nextTask() would hand finished work
to Claude again as a new billed turn.
CLI (mcp-tools/task-tools.ts)
- statusOf(): trimmed, case-insensitive, aliases complete/done/canceled/
running/in-progress; anything else (incl. "" and prototype keys) is
refused with the allowed list and the task is left unchanged.
- No schema enum on purpose: the HTTP/WebSocket registry validates enums
before the handler, which would refuse aliases there but not over stdio.
- Completing through task_update now finishes the task as task_complete
does (progress 100, completedAt, worker idle and counted once per
hand-out); cancelling frees workers as failing already did. Worker
effects run after the task store is saved.
Console
- taskStatusOf() reads the spellings older CLIs already stored; used by the
kanban lanes and verbs, Mission Control derive (no re-dispatch), mission
cancel, workflow links and the workflow guide.
Co-Authored-By: Ruflo & AQE
Claude-Session: https://claude.ai/code/session_01CGoza3gyxBjpaiMPhGHcHs
The status backfill set modified=true even when the UPDATE touched 0 rows, so
every open of an up-to-date store re-exported and rewrote the whole image; with
encryption at rest each write uses a fresh nonce, so read-only commands such as
'memory stats' changed the RFE1 bytes every call. Gate on getRowsModified().
Co-Authored-By: RuFlo <ruv@ruv.net>
The anchor mirror and trust key were resolved with userInfo().homedir, which
ignores a throwaway HOME, so tests wrote into the developer's real
~/.config/ruflo/policy-trust and later failed closed on a reused path.
Resolve from the environment at call time (XDG_CONFIG_HOME when absolute,
else os.homedir()/.config; legacy location kept for XDG users who already
have trust state there). mcp-client-guardrail.test.ts now uses a scratch
cwd and HOME.
Co-Authored-By: RuFlo <ruv@ruv.net>
Found by running the 3.54.1 CLI with missing and bad arguments:
1. `agent status <unknown>` and `task status <unknown>`: the MCP tool answers
{ status: 'not_found' } and the command rendered it as a record,
"Agent: undefined", "Created: Invalid Date", "Progress: undefined%",
and exited 0, so scripts and agents read it as success. Both now print
"<Agent|Task> not found: <id>" (or the raw JSON under --format json) and
exit 1.
2. A string/number option given with no value (`hooks route --task`,
`memory retrieve --key`, or followed by another flag) was parsed as
boolean `true`, and commands used it as the value: `hooks route --task`
failed with "task.trim is not a function", `memory retrieve --key` looked
up the key "true". validateFlags now reports "Option --<name> needs a
value" for every declared string/number option, so all commands get it.
Co-Authored-By: Ruflo & AQE
Claude-Session: https://claude.ai/code/session_01RMjr52YGVk9fkqtNvb5jg2
The once-per-process warning added in the prior commit was keyed by a
single global boolean, so a process touching more than one RFE1-encrypted
dbPath (a custom dbPath passed to insertGraphEdge/queryEdgesBySource/
countGraphEdges, or any multi-store scenario) only ever warned for the
first path it happened to see — the second silently returned null with
zero diagnostic signal, reproducing the original bug's exact symptom for
that second store.
_warnedRfe1Encrypted: boolean -> _warnedRfe1EncryptedPaths: Set<string>,
keyed by path.resolve(dbPath), matching this module's existing per-path
convention (_dbPath). _resetRfe1WarningFlag() now clears the set.
Added a regression test: two distinct encrypted paths in one module
instance each get exactly one warning, and a repeat call on the first
path doesn't double-warn.
Co-Authored-By: RuFlo <ruv@ruv.net>
graph-edge-writer.ts's getBridgeDb() opened dbPath via `new BetterSqlite3(dbPath)`
with no RFE1 encryption-at-rest sniff. When CLAUDE_FLOW_ENCRYPT_AT_REST=1,
memory.db is an opaque encrypted blob; the native open throws SQLITE_NOTADB,
caught by a generic catch that returns null with zero diagnostic signal —
indistinguishable from a missing native module, a permissions failure, or
genuine corruption. Nothing stopped a caller from concluding the store was
broken and running the destructive `memory init`, which creates a fresh
EMPTY store instead of using the existing encrypted data. The underlying
corpus was never damaged, but nothing said so.
This implements only the narrow, safe guard (Option C) a prior automated
triage pass on this issue recommended as the scoped starting point. The two
bigger options are deliberately out of scope: teaching the external
@claude-flow/memory package to decrypt RFE1 natively is a different
package entirely, and an automatic decrypt-and-migrate has real
data-safety stakes that call for human judgment, not a guess.
getBridgeDb() now sniffs the file's header bytes (never buffering the
whole file — memory.db can be multi-GB) before attempting the native open,
using the existing isEncryptedBlob() primitive (encryption/vault.ts) the
same way commands/doctor.ts already does, reimplemented locally since a
memory-layer module must not depend on the command layer. If the file is
RFE1-encrypted, the native open is skipped entirely (it would only throw)
and a clear, once-per-process warning fires: the store is encrypted, this
is a known limitation not corruption, the data is NOT lost, and do NOT run
`memory init`. Every other failure mode is byte-for-byte unchanged.
Also fixed the three reachable call sites in agentdb-tools.ts
(graph-pathfinder's semantic, pagerank, and algorithm-dispatch branches)
that turned a null db handle into a hardcoded "try `memory init`" hint —
now they call the new isBridgeDbEncryptedAtRest() predicate first and
pick the correct hint. Checked hooks-tools.ts's own memory-init hint too;
it's in a vector-search fallback that never touches getBridgeDb/
insertGraphEdge, so it's unreachable from this path and was left alone.
Added graph-edge-writer-rfe1-guard-2889.test.ts (4 tests): a genuinely
RFE1-encrypted file (real encryptBuffer/getKey, not a hand-faked prefix)
never reaches the native open and warns exactly once across repeated
calls; a genuinely corrupted non-encrypted file still reaches the native
open and does NOT produce the encrypted-store warning, proving the two
failure modes are actually distinguished; a normal plaintext memory.db is
unaffected. Spot-verified the core guard test is a real regression guard
by reverting it locally and confirming the test fails, then restoring it.
Existing graph-writer-shared-sqlite-3693.test.ts passes unmodified.
Co-Authored-By: RuFlo <ruv@ruv.net>