Skip to content

feat(factorydroid): map hook failClosed to onFailure - #3913

Merged
dyoshikawa merged 3 commits into
mainfrom
resolve-issue-3414-factorydroid-hook-onfailure
Nov 20, 2026
Merged

dyoshikawa merged 3 commits into
mainfrom
resolve-issue-3414-factorydroid-hook-onfailure

Conversation

@dyoshikawa

Copy link
Copy Markdown
Owner

Summary

Factory Droid's hooks reference now documents a per-hook onFailure field: "continue" (the default) or "block". With "block", a hook that cannot start, times out, exits with a code other than 0 or 2, or prints JSON that cannot be applied blocks the event the way exit 2 would. This works on PreToolUse, PostToolUse, UserPromptSubmit and PreCompact. It has no effect on Stop, SubagentStop or the events that cannot block. Until now rulesync dropped the canonical failClosed for Droid without a warning.

Source: https://docs.factory.com/harness/hooks#block-when-a-hook-fails

Changes:

  • FACTORYDROID_CONVERTER_CONFIG gets a keywordPassthroughFields entry, using the same mechanism as the Claude Code, Goose and ZCode mappings:
    • failClosed: true is written as onFailure: "block" on preToolUse / postToolUse / beforeSubmitPrompt / preCompact.
    • false is omitted because it is the default.
    • On import, "block" reads back as true and "continue" as false.
    • A true on an event where Droid ignores the field is dropped with a warning, in both directions.
  • The failClosed paragraph in docs/reference/file-formats.md and the generated docs-content.ts are updated.

Remaining items in #3414

  • Emitting canonical bash allow / ask / deny as native permissionRules. This needs a maintainer design decision because the feature is org-gated and every rule needs tests. Authoring and importing permissionRules through the factorydroid override already landed in feat(factorydroid): round-trip native permissionRules through the override #3447.
  • Moving the remaining docs.factory.ai links to docs.factory.com. Page paths changed as well, so each link has to be mapped to its new page.
  • Optionally passing preserveRiskLevel through factorydroid.hooks.

Tests

  • New unit tests in src/features/hooks/factorydroid-hooks.test.ts cover:
    • generation on a blocking event and a non-blocking event, with the warning;
    • import of "block", "continue" and an invalid value.
  • pnpm cicheck passes.

Refs #3414

🤖 Generated with Claude Code

https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4

dyoshikawa and others added 3 commits November 20, 2026 11:25
Factory Droid's hooks reference documents a per-hook `onFailure` field
("continue" by default, or "block"), which makes a failing hook block the
event the way exit code 2 would on PreToolUse, PostToolUse,
UserPromptSubmit and PreCompact. rulesync dropped the canonical
`failClosed` for Droid without a warning.

Emit `failClosed: true` as `onFailure: "block"` on those events, omit
`false` as the default, and read `"block"` / `"continue"` back on import.
A `true` on an event where Droid ignores the field is dropped with a
warning.

Refs #3414

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4
Assert failClosed maps to onFailure: "block" on preToolUse, postToolUse,
beforeSubmitPrompt and preCompact, and revert unrelated command path
edits in the commandRegex tests.

Refs #3414

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4
…ctorydroid-hook-onfailure

# Conflicts:
#	src/generated/docs-content.ts
@dyoshikawa
dyoshikawa merged commit f1ee6ef into main Nov 20, 2026
10 checks passed
@dyoshikawa
dyoshikawa deleted the resolve-issue-3414-factorydroid-hook-onfailure branch November 20, 2026 02:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant