c8746b1ca1
Seven cases wrote straight into the shared table and told their rows apart by a call_id prefix. Reading was never the problem; the prefix did that correctly, and it was built for concurrent runs. What it could not do was stop those writes and deletes from moving a row count that another test was watching, which is how issue #18 turned red. They now write into sandbox schemas, which also ends the orphan rows a killed run used to leave in there. Six fixtures collapse into factory calls; what they yield is unchanged, so the cases that consume them did not have to be touched, which is what makes them worth anything as a check on the move. Two of the seven kept something. The pool footprint case needs a unique application_name, since connections are an instance-wide resource that schema isolation does not reach, so it generates its own uuid instead of borrowing the run prefix. And the frozen-columns case was querying information_schema without a schema filter, so any leftover table of the same name anywhere in the database could fail it: the file already knew this, in a comment explaining why another fixture cleans up so carefully. It now filters, and gets checked against a leftover table planted on purpose. The gate that keeps the literal out of tests/ is a smoke alarm, not proof. Concatenation and parameterised queries walk straight past it. The isolation is the factory withholding the admin connection and the script running as a role with no grant.
47 lines
1.9 KiB
Makefile
47 lines
1.9 KiB
Makefile
.PHONY: install test lint format check ci wiki wiki-check shared-table-gate
|
|
|
|
ENV := PolyGateway
|
|
|
|
# 集成测试触碰共享表 llm_calls 的字面量门(issue #18)。
|
|
# 这道门是**烟雾报警器,不是隔离证明**: 它拦不住 f"{schema}.{table}" 拼接、
|
|
# 参数化查询,或不带限定名的 DELETE 配上 admin 的默认 search_path。真正的隔离
|
|
# 来自两处——沙箱工厂不把管理连接交给用例,以及清理脚本以无权角色运行。
|
|
# 留着它是因为字面量回归最常见、也最便宜拦。
|
|
shared-table-gate:
|
|
@if grep -rn --include='*.py' 'public\.llm_calls' tests/; then \
|
|
echo ""; \
|
|
echo "错误: 集成测试不得触碰共享表(见上面的命中行)。"; \
|
|
echo "改用 tests/integration/conftest.py 的 pg_sandbox 工厂;注释里提到它请写「共享表 llm_calls」。"; \
|
|
exit 1; \
|
|
fi
|
|
|
|
install:
|
|
conda run -n $(ENV) pip install -e ".[redis,postgres,structured,dev]"
|
|
|
|
test:
|
|
conda run -n $(ENV) pytest tests/ --cov=src/polygateway --cov-report=term-missing
|
|
|
|
lint: shared-table-gate
|
|
conda run -n $(ENV) ruff check src/ tests/ --fix
|
|
conda run -n $(ENV) lint-imports
|
|
|
|
format:
|
|
conda run -n $(ENV) ruff format src/ tests/
|
|
|
|
check: shared-table-gate
|
|
conda run -n $(ENV) ruff format --check src/ tests/
|
|
conda run -n $(ENV) ruff check src/ tests/
|
|
conda run -n $(ENV) lint-imports
|
|
|
|
ci: check test
|
|
|
|
wiki:
|
|
conda run -n $(ENV) python3 .claude/tools/research_wiki.py rebuild_index research-wiki/
|
|
|
|
# 用户文档站(Gitea Wiki)与源码的机械对齐校验。wiki 是独立仓库,须显式给路径:
|
|
# make wiki-check WIKI=~/PolyGateway.wiki
|
|
# 不并入 ci: 仓库里没有 wiki,自动跳过等于静默降级(违 P5),宁可让人显式跑。
|
|
wiki-check:
|
|
@test -n "$(WIKI)" || (echo "用法: make wiki-check WIKI=<PolyGateway.wiki 克隆路径>" && exit 1)
|
|
conda run -n $(ENV) python3 tools/check_wiki_alignment.py --wiki $(WIKI)
|