From bb59565cd5536548a5e1e58317a964f1349f1347 Mon Sep 17 00:00:00 2001 From: Justin Kim Date: Sun, 26 Jul 2026 20:20:21 +0900 Subject: [PATCH] =?UTF-8?q?docs:=20amend=20tombstone=20=EB=8C=80=EC=83=81?= =?UTF-8?q?=20=EA=B3=84=EC=95=BD=EC=9D=84=20=EB=AA=85=ED=99=95=ED=9E=88=20?= =?UTF-8?q?=ED=95=9C=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- factlog/cli.py | 5 +++-- tests/test_amend.sh | 7 ++++++- 2 files changed, 9 insertions(+), 3 deletions(-) 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)