Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/lib/hook-audit/agentic-dependency-constraints.json
Original file line number Diff line number Diff line change
Expand Up @@ -1670,13 +1670,14 @@
"mapping": "mapped",
"kitImpact": { "refs": ["plan Branch 3 item 4: defend reporting tells a detection from the post-detection crash"], "files": ["src/lib/live-checks.mjs"] },
"adjustment": "verify reads `-o json`; text-mode crash is reported as a crash. Once a released Ruflo prints every detected threat and exits with its own verdict in text mode, nothing further is needed in ak.",
"status": "fixed-unreleased",
"status": "dispatched",
"constraintIds": [],
"history": [
{ "date": "2026-09-26", "event": "filed" },
{ "date": "2026-09-26", "event": "registered" },
{ "date": "2026-09-27", "event": "watching", "note": "re-checked: still reproduces on 3.46.1 (text mode: 2 threat(s) detected, then [ERROR] Cannot read properties of undefined (reading 'color'), exit 1); ak x verify security now reads the -o json verdict" },
{ "date": "2026-09-27", "event": "closed", "note": "completed by PR 3477; not in 3.47.1" }
{ "date": "2026-09-27", "event": "closed", "note": "completed by PR 3477; not in 3.47.1" },
{ "date": "2026-11-01", "event": "dispatched", "note": "released in Ruflo 3.48.0; opened a draft PR on upstream/ruvnet-ruflo-3473 that stops naming the closed issue in the live `-o json` crash message, since a crash seen on 3.48.0+ would be a different bug" }
]
},
{
Expand Down
12 changes: 8 additions & 4 deletions src/lib/live-checks.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,8 @@ export async function verifyMemory({
/**
* The verdict `ruflo security defend -o json` prints after its banner: the last
* complete top-level JSON object with a boolean `safe`, else null (no verdict,
* e.g. the text-mode crash after a detection, ruvnet/ruflo#3473).
* e.g. the text-mode crash after a detection seen through Ruflo 3.46.1, fixed
* upstream in 3.48.0 as ruvnet/ruflo#3473).
* @param {string} stdout
* @returns {{ safe: boolean, threats: number } | null}
*/
Expand Down Expand Up @@ -251,17 +252,20 @@ export async function verifySecurity({ runner = runCmd, cwd = process.cwd() } =
else if (rufloBuiltinDefence()) {
warn("aidefence missing: defend uses Ruflo's built-in engine; adaptive learning and the aidefence_* MCP tools are unavailable. Fix: ak sync");
} else { fail('aidefence missing — defend is silently non-functional (ruvnet/ruflo#2670). Fix: ak sync'); return false; }
// `-o json` because text-mode defend crashes after printing its detection
// count (ruvnet/ruflo#3473, still in 3.46.1); the JSON verdict does not.
// `-o json` regardless of host version: through 3.46.1, text-mode defend
// crashed after printing its detection count (ruvnet/ruflo#3473, fixed
// upstream in 3.48.0); the JSON verdict never did.
const defend = (input) => runner('ruflo', ['security', 'defend', '-i', input, '-o', 'json']);
const inj = await defend(DEFEND_INJECTION);
const cln = await defend(DEFEND_CLEAN);
const injVerdict = parseDefendVerdict(inj.stdout);
const clnVerdict = parseDefendVerdict(cln.stdout);
if (!injVerdict || !clnVerdict) {
const crashed = [inj, cln].some((r) => /\[ERROR\]/.test(`${r.stdout ?? ''}${r.stderr ?? ''}`));
// The historical fix is ruvnet/ruflo#3473 (closed, released in 3.48.0); a
// crash seen here on a current host is a different bug, so it is not named.
fail(crashed
? 'defend crashed before reporting a verdict (ruvnet/ruflo#3473)'
? 'defend crashed before reporting a verdict'
: `defend returned no verdict (injection exit=${inj.code}, clean exit=${cln.code})`);
good = false;
} else if (!injVerdict.safe && injVerdict.threats > 0 && clnVerdict.safe) {
Expand Down
16 changes: 10 additions & 6 deletions tests/kit/live-checks.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,12 @@ test('the security check calls out the aidefence gap by name and stops early', a
} finally { rmrf(secDir); }
});

// Ruflo 3.32.2+ ships a built-in defend engine (ruvnet/ruflo#2670), and in
// 3.46.1 text-mode defend still crashes after it detects a threat
// (ruvnet/ruflo#3473). The check reads the `-o json` verdict, so a detection is
// reported from the verdict and a crash as a crash, never a pass.
// Ruflo 3.32.2+ ships a built-in defend engine (ruvnet/ruflo#2670). Through
// 3.46.1, text-mode defend crashed after detecting a threat; fixed upstream
// in 3.48.0 (ruvnet/ruflo#3473). The check reads the `-o json` verdict
// regardless of host version, so a detection is reported from the verdict and
// a crash as a crash, never a pass; the runtime message no longer names the
// closed issue, since a future crash under `-o json` would be a different bug.
const DEFEND_FIXTURES = new URL('../fixtures/ruflo-defend/', import.meta.url);
const fixture = (name) => fs.readFileSync(new URL(name, DEFEND_FIXTURES), 'utf8');

Expand Down Expand Up @@ -346,7 +348,7 @@ test('verifySecurity reports a detection from the JSON verdict when only the bui
} finally { cleanup(); }
});

test('verifySecurity reports the post-detection crash (ruvnet/ruflo#3473) as a crash and fails', async () => {
test('verifySecurity reports a post-detection crash as a crash and fails, without naming the closed ruvnet/ruflo#3473', async () => {
seedHome();
const cleanup = securityTree({ aidefence: true, builtin: true });
try {
Expand All @@ -356,7 +358,9 @@ test('verifySecurity reports the post-detection crash (ruvnet/ruflo#3473) as a c
});
const { result, out } = await captureLog(() => live.verifySecurity({ runner }));
assert.equal(result, false);
assert.match(out, /defend crashed before reporting a verdict \(ruvnet\/ruflo#3473\)/);
assert.match(out, /defend crashed before reporting a verdict/);
assert.doesNotMatch(out, /ruvnet\/ruflo#3473/,
'the issue is fixed upstream (3.48.0); a future crash under -o json would be a different bug');
assert.doesNotMatch(out, /defend: flags injection/);
} finally { cleanup(); }
});
Expand Down
Loading