211 lines
6.1 KiB
Bash
211 lines
6.1 KiB
Bash
#!/usr/bin/env bats
|
|
# tests/run-ingest.bats — end-to-end orchestrator test (no LLM, no network).
|
|
# Simulates pi's output (a source page + manifest) and runs the mechanical pass.
|
|
load helpers
|
|
|
|
@test "run-ingest: DRY_RUN end-to-end updates index + log and opens a dry PR" {
|
|
command -v jq >/dev/null 2>&1 || skip "jq not installed"
|
|
|
|
G="$(make_fixture_genome)"; cd "$G"
|
|
|
|
# --- simulate the semantic pass that pi would have done ---
|
|
cat > wiki/sources/test-source.md <<'EOF'
|
|
---
|
|
title: "Test Source"
|
|
type: source
|
|
domain: genome-test
|
|
tags: [t]
|
|
maturity: draft
|
|
last_updated: 2026-06-03
|
|
private: false
|
|
---
|
|
body
|
|
EOF
|
|
|
|
cat > .ingest-manifest.json <<'EOF'
|
|
{
|
|
"raw_source": "raw/articles/test.md",
|
|
"model": "qwen3.5-9b",
|
|
"reasoning": "Ingested the test source.",
|
|
"pr_summary": "Ingest of test: 1 source page.",
|
|
"contradictions": "None",
|
|
"pages": [
|
|
{"path": "wiki/sources/test-source.md", "summary": "A smoke-test source.", "maturity": "draft", "status": "created"}
|
|
]
|
|
}
|
|
EOF
|
|
|
|
export KG_LIB_DIR="$LIB_DIR"
|
|
export FORGEJO_URL="http://forgejo.local" FORGEJO_USER="u" FORGEJO_TOKEN="t"
|
|
export DRY_RUN=1
|
|
|
|
run bash "$SKILL_SCRIPTS/run-ingest.sh" genome-test
|
|
[ "$status" -eq 0 ]
|
|
[[ "$output" == *'"status":"ok"'* ]]
|
|
[[ "$output" == *'"lint_clean":true'* ]]
|
|
[[ "$output" == *'"conflict":false'* ]]
|
|
|
|
# side effects on the working tree
|
|
grep -q 'sources/test-source' wiki/index.md
|
|
grep -q 'INGEST | test' wiki/log.md
|
|
git rev-parse --verify feat/ai-ingest-test
|
|
}
|
|
|
|
@test "run-ingest: a conflict page is labelled and lands in the Conflicts section" {
|
|
command -v jq >/dev/null 2>&1 || skip "jq not installed"
|
|
|
|
G="$(make_fixture_genome)"; cd "$G"
|
|
|
|
cat > wiki/queries/conflict-pricing-2026-06-03.md <<'EOF'
|
|
---
|
|
title: "Conflict: pricing"
|
|
type: conflict
|
|
domain: genome-test
|
|
maturity: draft
|
|
last_updated: 2026-06-03
|
|
private: false
|
|
---
|
|
conflict body
|
|
EOF
|
|
|
|
cat > .ingest-manifest.json <<'EOF'
|
|
{
|
|
"raw_source": "raw/articles/test.md",
|
|
"model": "m",
|
|
"reasoning": "Flagged a contradiction.",
|
|
"pr_summary": "Conflict on pricing.",
|
|
"contradictions": "1 conflict file created — pricing",
|
|
"pages": [
|
|
{"path": "wiki/queries/conflict-pricing-2026-06-03.md", "summary": "ignored", "maturity": "draft", "status": "created"}
|
|
]
|
|
}
|
|
EOF
|
|
|
|
export KG_LIB_DIR="$LIB_DIR"
|
|
export FORGEJO_URL="http://forgejo.local" FORGEJO_USER="u" FORGEJO_TOKEN="t"
|
|
export DRY_RUN=1
|
|
|
|
run bash "$SKILL_SCRIPTS/run-ingest.sh" genome-test
|
|
[ "$status" -eq 0 ]
|
|
[[ "$output" == *'"conflict":true'* ]]
|
|
# listed by slug under the Conflicts section
|
|
grep -q 'queries/conflict-pricing-2026-06-03' wiki/index.md
|
|
}
|
|
|
|
@test "run-ingest: records INGEST_MODEL in the log (manifest carries no model field)" {
|
|
command -v jq >/dev/null 2>&1 || skip "jq not installed"
|
|
|
|
G="$(make_fixture_genome)"; cd "$G"
|
|
|
|
cat > 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
|
|
|
|
# New contract: NO "model" field — the orchestrator supplies it via INGEST_MODEL.
|
|
cat > .ingest-manifest.json <<'EOF'
|
|
{
|
|
"raw_source": "raw/articles/test.md",
|
|
"reasoning": "Ingested the test source.",
|
|
"pr_summary": "Ingest of test: 1 source page.",
|
|
"contradictions": "None",
|
|
"pages": [
|
|
{"path": "wiki/sources/test-source.md", "summary": "A smoke-test source.", "maturity": "draft", "status": "created"}
|
|
]
|
|
}
|
|
EOF
|
|
|
|
export KG_LIB_DIR="$LIB_DIR"
|
|
export FORGEJO_URL="http://forgejo.local" FORGEJO_USER="u" FORGEJO_TOKEN="t" DRY_RUN=1
|
|
export INGEST_MODEL="qwen-test-tag"
|
|
|
|
run bash "$SKILL_SCRIPTS/run-ingest.sh" genome-test
|
|
[ "$status" -eq 0 ]
|
|
[[ "$output" == *'"status":"ok"'* ]]
|
|
grep -q 'qwen-test-tag' wiki/log.md
|
|
}
|
|
|
|
@test "run-ingest: rejects a manifest path that escapes wiki/ (traversal)" {
|
|
command -v jq >/dev/null 2>&1 || skip "jq not installed"
|
|
G="$(make_fixture_genome)"; cd "$G"
|
|
cat > .ingest-manifest.json <<'EOF'
|
|
{ "raw_source":"raw/articles/test.md","reasoning":"r","pr_summary":"s","contradictions":"None",
|
|
"pages":[{"path":"wiki/../etc/passwd","summary":"x","maturity":"draft","status":"created"}] }
|
|
EOF
|
|
export KG_LIB_DIR="$LIB_DIR" FORGEJO_URL=http://x FORGEJO_USER=u FORGEJO_TOKEN=t DRY_RUN=1
|
|
run bash "$SKILL_SCRIPTS/run-ingest.sh" genome-test
|
|
[ "$status" -ne 0 ]
|
|
[[ "$output" == *'"status":"error"'* ]]
|
|
}
|
|
|
|
@test "run-ingest: honours INGEST_BASE for the PR base" {
|
|
command -v jq >/dev/null 2>&1 || skip "jq not installed"
|
|
G="$(make_fixture_genome)"; cd "$G"
|
|
cat > 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 > .ingest-manifest.json <<'EOF'
|
|
{ "raw_source":"raw/articles/test.md","reasoning":"r","pr_summary":"s","contradictions":"None",
|
|
"pages":[{"path":"wiki/sources/test-source.md","summary":"s","maturity":"draft","status":"created"}] }
|
|
EOF
|
|
export KG_LIB_DIR="$LIB_DIR" FORGEJO_URL=http://x FORGEJO_USER=u FORGEJO_TOKEN=t DRY_RUN=1
|
|
export INGEST_BASE="develop"
|
|
run bash "$SKILL_SCRIPTS/run-ingest.sh" genome-test
|
|
[ "$status" -eq 0 ]
|
|
[[ "$output" == *"develop"* ]]
|
|
}
|
|
|
|
@test "run-ingest: branch name matches slug.sh --raw for nested raw paths" {
|
|
command -v jq >/dev/null 2>&1 || skip "jq not installed"
|
|
G="$(make_fixture_genome)"; cd "$G"
|
|
mkdir -p wiki/sources
|
|
cat > wiki/sources/cibo-il-pane.md <<'EOFMD'
|
|
---
|
|
title: "Il Pane"
|
|
type: source
|
|
domain: genome-test
|
|
tags: [cibo]
|
|
maturity: draft
|
|
last_updated: 2026-06-25
|
|
private: false
|
|
source_path: raw/articles/cibo/il-pane.md
|
|
source_sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
|
|
---
|
|
# Il Pane
|
|
body
|
|
EOFMD
|
|
cat > .ingest-manifest.json <<'EOFJSON'
|
|
{
|
|
"raw_source": "raw/articles/cibo/il-pane.md",
|
|
"model": "qwen3.5-9b",
|
|
"reasoning": "Ingest.",
|
|
"pr_summary": "Ingest summary.",
|
|
"contradictions": "None",
|
|
"pages": [
|
|
{"path": "wiki/sources/cibo-il-pane.md", "summary": "Summary.", "maturity": "draft", "status": "created"}
|
|
]
|
|
}
|
|
EOFJSON
|
|
export KG_LIB_DIR="$LIB_DIR"
|
|
export FORGEJO_URL="http://forgejo.local" FORGEJO_USER="u" FORGEJO_TOKEN="t" DRY_RUN=1
|
|
run bash "$SKILL_SCRIPTS/run-ingest.sh" genome-test
|
|
[ "$status" -eq 0 ]
|
|
[[ "$output" == *"cibo-il-pane"* ]]
|
|
}
|