fix(kb): two comments claimed things the code does not do (improvise-9d5k)
kb-test case 10 said it was where same_key is discriminated. Reverting same_key to unification leaves case 10 PASSING and fails the wildcard rm and case 17 instead -- a rule keys on its whole clause, so the `:-` term cannot unify with probe_fact(a) and conflicts never fires there. Re-demonstrated by injection before rewriting the comment. The site is guarded; the explanation was wrong. replace's refusal said it would add the rules "beside the ones already there", which is false when the predicate has none. The behaviour was always right and fail-safe; only that clause of the sentence was wrong. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FC2jVn8Au7E9JPkw6bwXXH
This commit is contained in:
+1
-1
@@ -212,7 +212,7 @@ check_rule_replace(Funcs, replace, Old, New) :-
|
||||
Fresh),
|
||||
( Fresh == []
|
||||
-> true
|
||||
; format("kb-merge: REFUSED -- replace cannot find these rules, so it would ADD them beside the ones already there:~n", []),
|
||||
; format("kb-merge: REFUSED -- replace cannot find these rules, so it would ADD them rather than replace anything:~n", []),
|
||||
forall(member(T, Fresh), format(" ~q~n", [T])),
|
||||
die('a rule is keyed on its whole clause, so an edited body is a NEW clause: kb rm the old one, then kb add')
|
||||
).
|
||||
|
||||
+5
-3
@@ -319,9 +319,11 @@ printf 'probe_fact(a).\nprobe_fact(b).\n' > "$work/facts.pl"
|
||||
kb add "$work/facts.pl" >/dev/null 2>&1
|
||||
printf 'probe_fact(X) :- doctrine(X,_).\n' > "$work/rule.pl"
|
||||
# `add`, not `replace`: the rule is new, and a rule that is not already there
|
||||
# is what case 15 makes replace refuse. This is also the discriminating door --
|
||||
# under unification `conflicts` sees the non-ground key match both facts and
|
||||
# refuses the add outright, so the reverted fix fails HERE.
|
||||
# is what case 15 makes replace refuse. This case is NOT where same_key is
|
||||
# discriminated -- a rule keys on its whole clause, so the `:-` term cannot
|
||||
# unify with probe_fact(a) and `conflicts` never fires here. Reverting same_key
|
||||
# to unification leaves this case passing and fails the wildcard rm and case 17
|
||||
# instead; the site is guarded, by those (improvise-9d5k).
|
||||
if kb add "$work/rule.pl" >/dev/null 2>&1; then
|
||||
kept=0
|
||||
grep -q '^probe_fact(a)\.$' "$work/kb.pl" && grep -q '^probe_fact(b)\.$' "$work/kb.pl" && kept=1
|
||||
|
||||
Reference in New Issue
Block a user