Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions factlog/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 6 additions & 1 deletion tests/test_amend.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down