diff --git a/factlog/cli.py b/factlog/cli.py index b8653268..43d86dc7 100644 --- a/factlog/cli.py +++ b/factlog/cli.py @@ -960,8 +960,9 @@ def cmd_reject(args: argparse.Namespace) -> int: def cmd_amend(args: argparse.Namespace) -> int: """Correct a fact's subject / relation / object / note (durable). - The positional triple identifies the fact (exact NFC match, any status); the - --set-* flags give the new values (at least one required, or --accept). A + The positional triple identifies a live fact (exact NFC match); superseded + tombstones are never matched. The --set-* flags give the new values (at + least one required, or --accept). A fact's values live in runs/*.json (merge rebuilds candidates.csv from it), so amend updates BOTH the matching candidates.csv rows AND their backing runs/*.json rows — otherwise the edit would vanish on the next sync. diff --git a/tests/test_amend.sh b/tests/test_amend.sh index a4023eb1..7622a0b4 100644 --- a/tests/test_amend.sh +++ b/tests/test_amend.sh @@ -197,7 +197,12 @@ printf '[{"subject":"Lib","relation":"name","object":"Numpy","source":"sources/a > "$KB/runs/T1.json" "$PYTHON" "$MERGE" --wiki "$KB" >/dev/null 2>&1 "$PYTHON" -m factlog amend Lib name Numpy --set-object NumPy --accept --target "$KB" >/dev/null 2>&1 -"$PYTHON" -m factlog amend Lib name Numpy --set-object NumPy --accept --target "$KB" >/dev/null 2>&1 || true +set +e +out="$("$PYTHON" -m factlog amend Lib name Numpy --set-object NumPy --accept --target "$KB" 2>&1)"; rc=$? +set -e +[ "$rc" -eq 1 ] && printf '%s' "$out" | grep -qF "no fact matches" \ + && ok "#220 d2: superseded tombstone is not an amend target (rc 1)" \ + || bad "#220 d2: superseded tombstone amend contract wrong (rc=$rc, out=$out)" n_acc=$(grep -c "Lib,name,NumPy,sources/a.md,accepted," "$KB/facts/candidates.csv" || true) [ "$n_acc" -eq 1 ] && ok "#220 d2: repeated amend keeps exactly one accepted row (no duplicate)" || bad "#220 d2: duplicate accepted rows ($n_acc): $(grep name "$KB/facts/candidates.csv")" n_tomb=$(grep -c "Lib,name,Numpy,sources/a.md,superseded," "$KB/facts/candidates.csv" || true)