3a72b84a03a77221634018881a2aa66d60328aa8 — Thomas Orgis 4 months ago 6e5f1e1
libdepengine: ignore pre_remove and post_remove failures for failure detection

The loop prevention hack guessed wrongly that a pre_remove failure is
serious and hence caused lots of spells being dropped once e.g.
grep was cast, which has a PRE_REMOVE that returns non-zero (something we could
investigate). Sorcery ignores that return value also for post_remove, but
the runtime mechanism still stores the failure reason.

Maybe we should ignore that failure reason log altogether. But I think I
had a reason including it.

We need to rewrite this all ...

This commit also makes the two messages different, adding 'subtly' for the
cases where the spell didn't outright fail but still has a reason (conflicts
is one remaining case which we might want to settle) and listing the
found reasons. This mainly should aid debugging once we get rid of these
cases. Either there is a failure or not, please.
1 files changed, 8 insertions(+), 5 deletions(-)

M var/lib/sorcery/modules/libdepengine
M var/lib/sorcery/modules/libdepengine => var/lib/sorcery/modules/libdepengine +8 -5
@@ 135,19 135,22 @@ depengine_cast_engine() {

  # pre_sub_depends failure is non-fatal, just means re-cast
  # Also, pre_remove and post_remove return values are ignored, anyway.
  local fail_reasons=$(grep -s "^$spell " "$CAST_BACKUPDIR/failure_reason_log" \
    | cut -f 2 -d ' ' \
    | grep -v -e '(pre_sub_depends)' -e '(pre_remove)' -e '(post_remove)')
  # Crude hacks to avoid casting spells whose dependencies failed.
  # Since sorcery does not properly keep track of spell state with
  # its multiple passes, some grepping in files that store failures
  # does the trick.
  if grep -qs "^$spell$" "$FAILED_LIST"; then
    message "${MESSAGE_COLOR}The spell ${SPELL_COLOR}$spell$MESSAGE_COLOR" \
            " failed to cast. Remembering that.$DEFAULT_COLOR"
            " failed to cast. Remembering that. ${fail_reasons}$DEFAULT_COLOR"
  # pre_sub_depends failure is non-fatal, just means re-cast
  elif grep -s "^$spell " "$CAST_BACKUPDIR/failure_reason_log" \
    | grep -q -v pre_sub_depends; then
  elif [[ -n $fail_reasons ]]; then
    message "${MESSAGE_COLOR}The spell ${SPELL_COLOR}$spell$MESSAGE_COLOR" \
            " failed before cast. Remembering that.$DEFAULT_COLOR"
            " subtly failed before cast. Remembering that. ${fail_reasons}$DEFAULT_COLOR"