130 lines
2.9 KiB
Bash
130 lines
2.9 KiB
Bash
#!/usr/bin/env bash
|
|
# diagnose-run-ingest.sh
|
|
# Run from the repo root: bash diagnose-run-ingest.sh
|
|
# Builds the same fixture the bats test uses and runs run-ingest under `bash -x`
|
|
# so we can see exactly which command makes it exit non-zero.
|
|
|
|
set -uo pipefail
|
|
|
|
REPO="$(pwd)"
|
|
RI="${REPO}/skills/ingest/scripts/run-ingest.sh"
|
|
|
|
echo "==================== ENV ===================="
|
|
echo "bash: $(bash --version | head -1)"
|
|
echo "git : $(git --version)"
|
|
echo "jq : $(jq --version 2>/dev/null || echo MISSING)"
|
|
echo "py : $(python3 --version 2>/dev/null || echo MISSING)"
|
|
echo
|
|
|
|
echo "============ run-ingest.sh on disk ============"
|
|
if [[ ! -f "$RI" ]]; then echo "NOT FOUND: $RI (run me from the repo root)"; exit 1; fi
|
|
echo "-- helper invocations (want 'bash ...'): --"
|
|
grep -nE 'log-append\.sh|scoped-lint\.sh|open-pr\.sh' "$RI"
|
|
echo "-- result emitter (want 'jq -nc'): --"
|
|
grep -nE 'jq -nc?|jq -n ' "$RI"
|
|
echo
|
|
|
|
echo "============ build hermetic fixture ============"
|
|
T="$(mktemp -d)"
|
|
mkdir -p "$T/nohooks"
|
|
git init --bare -q "$T/origin.git"
|
|
g="$T/g"
|
|
mkdir -p "$g"/{raw/articles,wiki/sources,wiki/entities,wiki/concepts,wiki/queries,wiki/private}
|
|
|
|
cat > "$g/wiki/index.md" <<'EOF'
|
|
---
|
|
title: "Index"
|
|
type: index
|
|
domain: genome-test
|
|
maturity: stable
|
|
last_updated: 2026-01-01
|
|
private: false
|
|
---
|
|
|
|
# Index
|
|
|
|
---
|
|
|
|
## Sources (`wiki/sources/`)
|
|
*x*
|
|
|
|
|
|
## Entities (`wiki/entities/`)
|
|
*x*
|
|
|
|
|
|
## Concepts (`wiki/concepts/`)
|
|
*x*
|
|
|
|
|
|
## Queries (`wiki/queries/`)
|
|
*x*
|
|
|
|
|
|
## Conflicts Pending Review (`wiki/queries/conflict-*.md`)
|
|
*x*
|
|
EOF
|
|
|
|
cat > "$g/wiki/log.md" <<'EOF'
|
|
---
|
|
title: "Log"
|
|
type: log
|
|
domain: genome-test
|
|
maturity: stable
|
|
last_updated: 2026-01-01
|
|
private: false
|
|
---
|
|
|
|
# Log
|
|
|
|
---
|
|
|
|
## [2026-01-01] CONFIG | init
|
|
- run_id: `init`
|
|
EOF
|
|
|
|
echo raw > "$g/raw/articles/test.md"
|
|
|
|
(
|
|
cd "$g"
|
|
git init -q
|
|
git config commit.gpgsign false
|
|
git config core.hooksPath "$T/nohooks"
|
|
git config user.email t@t
|
|
git config user.name t
|
|
git add .
|
|
git commit -qm init
|
|
git branch -M main
|
|
git remote add origin "$T/origin.git"
|
|
git push -q -u origin main
|
|
) && echo "fixture commit+push OK" || echo "FIXTURE SETUP FAILED (look above)"
|
|
|
|
cat > "$g/wiki/sources/test-source.md" <<'EOF'
|
|
---
|
|
title: "Test Source"
|
|
type: source
|
|
domain: genome-test
|
|
tags: [t]
|
|
maturity: draft
|
|
last_updated: 2026-06-04
|
|
private: false
|
|
---
|
|
body
|
|
EOF
|
|
|
|
cat > "$g/.ingest-manifest.json" <<'EOF'
|
|
{ "raw_source":"raw/articles/test.md","model":"m","reasoning":"r","pr_summary":"s","contradictions":"None",
|
|
"pages":[{"path":"wiki/sources/test-source.md","summary":"a source","maturity":"draft","status":"created"}] }
|
|
EOF
|
|
|
|
echo
|
|
echo "============ run-ingest (bash -x) ============"
|
|
cd "$g"
|
|
export KG_LIB_DIR="${REPO}/lib" FORGEJO_URL=http://x FORGEJO_USER=u FORGEJO_TOKEN=t DRY_RUN=1
|
|
bash -x "$RI" genome-test >"$T/out.txt" 2>"$T/trace.txt"
|
|
rc=$?
|
|
echo "EXIT=$rc"
|
|
echo "-- run-ingest stdout (final JSON should be here): --"
|
|
cat "$T/out.txt"
|
|
echo "-- last 25 lines of the trace (the failing command is near the end): --"
|
|
tail -n 25 "$T/trace.txt"
|