Enum Class ScriptFailurePolicy

java.lang.Object
java.lang.Enum<ScriptFailurePolicy>
com.tnsai.hooks.external.ScriptFailurePolicy
All Implemented Interfaces:
Serializable, Comparable<ScriptFailurePolicy>, Constable

public enum ScriptFailurePolicy extends Enum<ScriptFailurePolicy>
What an ExternalScriptHook does when the subprocess fails (timeout, non-zero exit, unparseable response) (issue #64).

Distinct from HookFailurePolicy which is the HookDispatcher-wide policy covering in-process exceptions from Java hooks. ScriptFailurePolicy is per external-hook and targets the subprocess-specific failure surface: non-zero exit, missing stdout, timeout, malformed JSON.

Since:
0.5.0 (issue #64)
  • Enum Constant Details

    • FAIL_OPEN

      public static final ScriptFailurePolicy FAIL_OPEN
      On failure, behave as Allow — chain continues. Use for advisory hooks where availability matters more than every rule firing.

      Today: the implementation logs every failure at WARN regardless of policy; FAIL_OPEN's intent is "future-proofing for log-volume tuning where flaky scripts should not spam the log". Functionally identical to LOG_AND_ALLOW in this release; the distinction is preserved as a label so consumers signal intent at config time.

    • FAIL_CLOSED

      public static final ScriptFailurePolicy FAIL_CLOSED
      On failure, behave as Block — chain stops. Use for safety-critical hooks where a broken script must not let an operation through.
    • LOG_AND_ALLOW

      public static final ScriptFailurePolicy LOG_AND_ALLOW
      Default: on failure, log a structured warning event and allow the chain to continue. The safest production default — a flaky script doesn't take the system down, but operators still see the failure in logs / alerts.
  • Method Details

    • values

      public static ScriptFailurePolicy[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static ScriptFailurePolicy valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null