fix: only fire after_compaction hook on successful compaction

Match legacy path semantics: compactEmbeddedPiSessionDirect only reaches
the after_compaction hook after session.compact() succeeds. Gate the
engine-owned path on result.ok && result.compacted so subscribers don't
receive after_compaction for failed compactions.
This commit is contained in:
David Rudduck
2026-03-10 02:42:36 +10:00
committed by Josh Lehman
parent 054ded7b02
commit c0e451e418

View File

@@ -981,7 +981,7 @@ export async function compactEmbeddedPiSession(
force: params.trigger === "manual",
runtimeContext: params as Record<string, unknown>,
});
if (hookRunner?.hasHooks("after_compaction")) {
if (result.ok && result.compacted && hookRunner?.hasHooks("after_compaction")) {
try {
await hookRunner.runAfterCompaction(
{