Files
settled-reach/tooling/check-decision-ids
T
jpmschweitzerandClaude Opus 4.6 0cf4dcc3f9 feat(db): decision ID claim system — prevent cross-worktree collisions
- `db/connectors/decision next [D|Q|R]` — show next available ID
- `db/connectors/decision claim <prefix> <domain> [title]` — reserve ID in DB
- `db/connectors/decision check-dupes` — detect duplicate IDs in markdown
- `tooling/check-decision-ids` — pre-commit hook for dupe detection
- D-035 added as known exception (139 files, too embedded to renumber)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-25 10:51:46 +01:00

29 lines
1.0 KiB
Bash
Executable File

#!/usr/bin/env bash
# Pre-commit check: detect duplicate decision IDs across decisions/*.md files.
# Fails if the same D-NNN, Q-NNN, or R-NNN appears in more than one file.
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
REPO_ROOT="$(dirname "$SCRIPT_DIR")"
# Use the decisions_sync.py check-dupes command
RESULT=$(python3 "$REPO_ROOT/db/connectors/decisions_sync.py" check-dupes 2>&1)
# Parse the JSON result
DUPES=$(echo "$RESULT" | python3 -c "import sys,json; d=json.load(sys.stdin); print(d.get('duplicates',0))" 2>/dev/null || echo "0")
TOTAL=$(echo "$RESULT" | python3 -c "import sys,json; d=json.load(sys.stdin); print(d.get('total_ids',0))" 2>/dev/null || echo "0")
if [ "$DUPES" -gt 0 ]; then
echo "check-decision-ids: FAILED — $DUPES duplicate ID(s) found"
echo "$RESULT" | python3 -c "
import sys, json
d = json.load(sys.stdin)
for detail in d.get('details', []):
print(f' {detail}')
" 2>/dev/null
exit 1
fi
echo "check-decision-ids: OK — $TOTAL unique IDs, no duplicates"
exit 0