Skip to content

Commit 5d2530b

Browse files
tae2089claude
andcommitted
test: verify cross-namespace refs in Postgres integration suite
Add Phase 13: push a ccg:// annotation from sample-go targeting sample-calc through the real Gitea webhook pipeline, then assert list_cross_refs (outbound resolved + inbound), cross-namespace impact radius with namespace labels, default namespace-scoped impact, and federated search labeling — all against PostgreSQL. The phase polls list_cross_refs directly because wait_for_webhook_sync returns as soon as a namespace has any nodes, which is immediate on a re-push. Banner updated to 16/18 verified tools. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 5d7b9d0 commit 5d2530b

1 file changed

Lines changed: 69 additions & 3 deletions

File tree

scripts/integration-test.sh

Lines changed: 69 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,72 @@ else
680680
warn "MCP session unavailable under local debug override — skipping Phase 12"
681681
fi
682682

683+
# ── Phase 13: Cross-namespace refs (ccg:// annotations) ──
684+
if [ -n "$MCP_SESSION" ]; then
685+
info "Phase 13: Testing cross-namespace refs..."
686+
687+
# Declare a cross-namespace dependency from sample-go to sample-calc via a ccg:// annotation.
688+
cat > "${TMPDIR_CLONE}/repo/main.go" <<'GOEOF'
689+
package main
690+
691+
import "fmt"
692+
693+
// @intent greet a user by name
694+
// @see ccg://sample-calc/math.go#subtract
695+
func greet(name string) string {
696+
return fmt.Sprintf("Hello, %s!", name)
697+
}
698+
699+
func main() {
700+
fmt.Println(greet("world"))
701+
}
702+
GOEOF
703+
pushd "${TMPDIR_CLONE}/repo" >/dev/null
704+
git add -A
705+
git commit -q -m "docs: declare cross-namespace ref to sample-calc"
706+
info "Pushing cross-ref annotation to Gitea (triggers webhook)..."
707+
git push -q origin main
708+
popd >/dev/null
709+
710+
# The namespace already has nodes, so wait_for_webhook_sync would return
711+
# immediately; poll until the materialized ref itself becomes visible.
712+
info "Waiting for cross-ref materialization (max ${WEBHOOK_WAIT_SECONDS}s)..."
713+
CROSSREF_DEADLINE=$((SECONDS + WEBHOOK_WAIT_SECONDS))
714+
CROSSREF_RESP=""
715+
while [ $SECONDS -lt $CROSSREF_DEADLINE ]; do
716+
CROSSREF_RESP=$(mcp_call "list_cross_refs" "{\"namespace\":\"${REPO_NAME}\",\"direction\":\"outbound\"}")
717+
CROSSREF_TEXT=""
718+
[ -n "$CROSSREF_RESP" ] && CROSSREF_TEXT=$(mcp_text "$CROSSREF_RESP") || CROSSREF_TEXT=""
719+
if [[ "$CROSSREF_TEXT" == *'"status":"resolved"'* ]]; then
720+
break
721+
fi
722+
sleep 2
723+
done
724+
assert_mcp_ok "list_cross_refs(outbound)" "$CROSSREF_RESP"
725+
assert_mcp_contains "list_cross_refs(outbound)" "$CROSSREF_RESP" "\"to_namespace\":\"${REPO2_NAME}\""
726+
assert_mcp_contains "list_cross_refs(outbound)" "$CROSSREF_RESP" '"status":"resolved"'
727+
728+
RESP=$(mcp_call "list_cross_refs" "{\"namespace\":\"${REPO2_NAME}\",\"direction\":\"inbound\"}")
729+
assert_mcp_contains "list_cross_refs(inbound)" "$RESP" "\"from_namespace\":\"${REPO_NAME}\""
730+
731+
# Cross-namespace impact: greet -> (ccg ref) -> subtract in sample-calc.
732+
RESP=$(mcp_call "get_impact_radius" "{\"qualified_name\":\"main.greet\",\"depth\":1,\"namespace\":\"${REPO_NAME}\",\"cross_namespace\":true}")
733+
assert_mcp_contains "get_impact_radius(cross_namespace)" "$RESP" "main.subtract"
734+
assert_mcp_contains "get_impact_radius(cross_namespace)" "$RESP" "\"namespace\":\"${REPO2_NAME}\""
735+
736+
# Default impact stays namespace-scoped.
737+
RESP=$(mcp_call "get_impact_radius" "{\"qualified_name\":\"main.greet\",\"depth\":1,\"namespace\":\"${REPO_NAME}\"}")
738+
assert_mcp_not_contains "get_impact_radius(default)" "$RESP" "main.subtract"
739+
740+
# Federated search across both namespaces labels each hit.
741+
RESP=$(mcp_call "search" "{\"query\":\"subtract\",\"limit\":5,\"namespaces\":[\"${REPO_NAME}\",\"${REPO2_NAME}\"]}")
742+
assert_mcp_contains "search(namespaces)" "$RESP" "\"namespace\":\"${REPO2_NAME}\""
743+
744+
info "Phase 13 complete ✅"
745+
else
746+
warn "MCP session unavailable under local debug override — skipping Phase 13"
747+
fi
748+
683749
# ── Phase 14: Documentation discovery tools ──
684750
if [ -n "$MCP_SESSION" ]; then
685751
info "Phase 14: Testing documentation discovery tools..."
@@ -703,9 +769,9 @@ fi
703769

704770
# ── Summary ──
705771
TOOLS_TESTED=0
706-
TOTAL_MCP_TOOLS=17
772+
TOTAL_MCP_TOOLS=18
707773
if [ -n "$MCP_SESSION" ]; then
708-
TOOLS_TESTED=15
774+
TOOLS_TESTED=16
709775
fi
710776

711777
echo ""
@@ -718,7 +784,7 @@ fi
718784
echo -e "${GREEN}════════════════════════════════════════════════════════${NC}"
719785
echo ""
720786
info "Pipeline: Gitea push → webhook → ccg clone → build → DB ✅"
721-
info "MCP tools: graph query, analysis, namespace, documentation discovery, postprocess ✅"
787+
info "MCP tools: graph query, analysis, namespace, cross-namespace refs, documentation discovery, postprocess ✅"
722788
}
723789

724790
if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then

0 commit comments

Comments
 (0)