Skip to content

Commit bb558ad

Browse files
committed
테스트: 구독 세션과 의미 검색의 공개 계약 검증 보강
읽기 도구 노출, 제한된 진단 출력, 재무·공시 열 선택과 원문 출처 보존을 직접 검증한다. 모델 준비의 고정 revision과 다운로드 범위, 인덱스 상태와 반복 검색 계약도 확인한다. 관련 100개 테스트 통과. 변경 소스 25개 파일의 공개 함수 138개에서 테스트 참조 누락 0건. 전체 preflight의 메모리 종료와 기존 출력 snapshot 한계는 실사용 보고서에 유지한다. Cinch-Understanding: 459d3a0dcfd416bb7ab72923abe0c50b307e932e8489239fe71fb78d320655a0 Cinch-Understanding: d1c2e8561b941bbc31adfcc8dc90a430f787621cde4e9cfe83956776dba36057 Cinch-Work: 06e8e69a-cdf3-400e-bb36-2444f6b2b7b5 Cinch-Assignment: 54871ec2-81c3-4079-ab4e-fe633a6fee99 Cinch-Run: d860276d-7b3c-475d-91e0-2d96f18ecb29
1 parent c78eab3 commit bb558ad

6 files changed

Lines changed: 80 additions & 1 deletion

File tree

‎mainPlan/dartlab-universe/10-conversationalQueryResearch.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ dartlab.search.indexInfo()["semantic"]
280280
회귀 테스트는 native 세션 재개·도구 권한·host receipt, 인자 계약, finance 직접 조회, 보고 기간·공시 링크, 증분 재사용·삭제·실패 보존·읽기 중 publication, 원문 뒤쪽 문단, 기간·출처·회사 제외, 외부 본문 표시와 근거 재시작 복구를 다룬다.
281281

282282
- 변경 관련 묶음 234 passed, 1 skipped. 외부 본문 경계 보강 뒤 관련 52 passed, 검색·공개 문서 계약 보강 뒤 54 passed, 1 skipped. 검색 함수 정리 뒤 최종 19 passed. 각 묶음은 중복 테스트를 포함하므로 합산하지 않는다.
283+
- 커밋 후 공개 함수 참조 검사에서 누락된 직접 계약을 보강했다. 해당 묶음 100 passed, 변경된 소스 25개 파일의 공개 함수 138개에서 테스트 참조 누락 0건이다. 이는 실행 경로의 전체 coverage 비율을 뜻하지 않는다.
283284
- L0/L1.5 strict guard, lint, 포맷, 복잡도·죽은 코드, source/wheel smoke, 노트북 공개 계약, schema drift, eval, mutation smoke, DART panel 검사를 통과했다. 선택 인덱스가 없는 상태는 available=False로 명시하고 실제 검색은 준비 오류를 내므로 optional loader로 감사 목록에 등록했다.
284285
- UI 타입 검사 오류 0건, 기존 경고 48건. 변경 adapter 테스트 4 passed. 로컬 UI·landing 빌드와 데스크톱·모바일 화면 검수를 통과했다.
285286
- 전체 preflight의 test-fast는 6,492 passed, 17 skipped, 1 xfailed 뒤 79%에서 worker 종료로 중단됐다. 같은 감사 테스트를 별도 재현하면 약 3,116 MB에서 기존 메모리 보호가 종료한다. 한도를 올려 통과시키지 않았다. 실행 도중 발견된 CLI 인자·topK mock·문서 호출 계약 실패 3건은 수정 후 관련 묶음에서 재검증했다. 미실행된 나머지 전체 테스트까지 통과했다고 주장하지 않는다.

‎tests/ai/runtime/test_runtimeCore.py‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,18 @@ def testProcessSupervisorUsesNdjsonWithoutShell(tmp_path):
554554
supervisor.stop()
555555

556556

557+
def testProcessSupervisorRetainsBoundedDiagnosticText(tmp_path):
558+
from io import BytesIO
559+
from types import SimpleNamespace
560+
561+
supervisor = ProcessSupervisor(ProcessSpec((sys.executable,), tmp_path, outputLimitBytes=4096))
562+
tail = "인증 세션이 종료됨".encode("utf-8") + b"\xff"
563+
supervisor.process = SimpleNamespace(stderr=BytesIO(b"x" * 4096 + tail))
564+
supervisor._readStderr()
565+
assert supervisor.stderrText() == "인증 세션이 종료됨\ufffd"
566+
assert supervisor._stderrBytes <= supervisor.spec.outputLimitBytes
567+
568+
557569
def testJsonRpcStartRequestUsesAnIdWithoutWaiting(tmp_path):
558570
from dartlab.ai.runtime.processSupervisor import JsonRpcChannel
559571

‎tests/ai/runtime/test_sessionTools.py‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,21 @@
1212
from dartlab.ai.runtime.readiness import _runtimeStatusEntry, probeToolConnection
1313
from dartlab.ai.runtime.registry import loadRuntimeRegistry
1414
from dartlab.ai.runtime.sessionTools import callSessionTool, sessionToolSpecs
15-
from dartlab.ai.tools.registry import executeAgentTool
15+
from dartlab.ai.tools.registry import agentToolSpecs, executeAgentTool, isToolReadOnly
1616

1717
pytestmark = pytest.mark.unit
1818

1919

20+
def testSessionAdvertisesCanonicalReadOnlySchemas():
21+
specs = agentToolSpecs()
22+
names = [spec["name"] for spec in specs]
23+
assert {"ReadSkill", "EngineCall", "PeerCompareN"}.issubset(names)
24+
assert len(names) == len(set(names))
25+
assert not {"RunPython", "SaveArtifact"}.intersection(names)
26+
assert all(isToolReadOnly(name) for name in names)
27+
assert sessionToolSpecs() == [{key: spec[key] for key in ("name", "description", "inputSchema")} for spec in specs]
28+
29+
2030
def testSessionOnlyExecutesAdvertisedReadOnlyTools(monkeypatch):
2131
calls = []
2232
monkeypatch.setattr("dartlab.ai.tools.registry.executeTool", lambda *args: calls.append(args) or {"ok": True})

‎tests/ai/test_peer_compare_n.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,10 @@ def testPeerFactsSkipWideBoardAndUnrequestedContext(monkeypatch):
173173

174174
import polars as pl
175175

176+
from dartlab.ai.tools.companyMetrics import statementTable
177+
178+
selected = []
179+
176180
class Company:
177181
corpName = "기업"
178182

@@ -181,8 +185,12 @@ def panel(self):
181185
raise AssertionError("전체 원문 보드는 필요하지 않다")
182186

183187
def select(self, topic, **kwargs):
188+
selected.append((topic, kwargs))
184189
return SimpleNamespace(df=pl.DataFrame({"snakeId": ["sales", "total_assets"], "2025Q4": [100.0, 300.0]}))
185190

191+
statement = statementTable(Company(), "IS", scope="separate")
192+
assert statement["2025Q4"].to_list() == [100.0, 300.0]
193+
assert selected == [("IS", {"scope": "separate", "strict": False})]
186194
monkeypatch.setattr("dartlab.ai.tools.peerCompareN.resolveCompanyOrNone", lambda code: Company())
187195

188196
def forbidden(*args):

‎tests/providers/dart/builder/test_filingsCatalog.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ def projected(paths, *, columns):
4545
return original(paths, columns=columns)
4646

4747
monkeypatch.setattr(dataLoader, "readParquetSafe", projected)
48+
metadata = read.readFilingMetadata("005930")
49+
assert metadata.to_dicts() == [{"period": "2025Q4", "rceptNo": "20260310002820"}]
4850
result = buildFilings(SimpleNamespace(_hasPanel=True, stockCode="005930"))
4951
assert result["period"].to_list() == ["2025Q4"]
5052
assert result["reportType"].to_list() == ["사업보고서"]

‎tests/providers/dart/search/test_semanticIndex.py‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,43 @@ def catalog(path, rows):
3131
normalizeCatalogRows(rows).write_parquet(path)
3232

3333

34+
def testExplicitModelPreparationPinsRevisionsAndDownloadFiles(monkeypatch, tmp_path):
35+
calls = []
36+
monkeypatch.setattr(semantic, "_requireModels", lambda: None)
37+
monkeypatch.setattr(semantic, "_modelDir", lambda name: tmp_path / name.rsplit("/", 1)[-1])
38+
monkeypatch.setattr("huggingface_hub.snapshot_download", lambda name, **kwargs: calls.append((name, kwargs)))
39+
semantic.prepareSemanticModels()
40+
assert [name for name, args in calls] == [semantic._MODEL, semantic._RERANK_MODEL]
41+
assert [args["revision"] for name, args in calls] == [semantic._REVISION, semantic._RERANK_REVISION]
42+
for name, args in calls:
43+
assert len(args["revision"]) == 40
44+
assert args["local_dir"] == str(tmp_path / name.rsplit("/", 1)[-1])
45+
assert "tokenizer.json" in args["allow_patterns"]
46+
assert all("*" not in pattern for pattern in args["allow_patterns"])
47+
assert "model.safetensors" in calls[0][1]["allow_patterns"]
48+
assert "onnx/model_qint8_avx512_vnni.onnx" in calls[1][1]["allow_patterns"]
49+
50+
51+
def testCatalogSourceLineageSurvivesSemanticProjection(tmp_path, encoder):
52+
from dartlab.providers.dart.search.sourceCatalog import buildCatalogSnapshot, buildSourceManifest
53+
54+
raw, snapshot, index = tmp_path / "raw.parquet", tmp_path / "catalog.parquet", tmp_path / "index"
55+
pl.DataFrame([{"rceptNo": "20250101000001", "date": "20250101", "searchText": "전력 공급 계획"}]).write_parquet(raw)
56+
manifest = buildSourceManifest("allFilings", [raw], producerRun={"id": "run-1"})
57+
assert manifest["totalRows"] == manifest["changedRows"] == 1
58+
assert manifest["producerRun"] == {"id": "run-1"}
59+
assert manifest["files"][0]["sizeBytes"] == raw.stat().st_size
60+
assert manifest["files"][0]["hash"]
61+
frame = buildCatalogSnapshot("allFilings", [raw], sourceDataAsOf="20250102", sourceAdapterVersion="trial-v2")
62+
assert frame["sourceAdapterVersion"].to_list() == ["trial-v2"]
63+
frame.write_parquet(snapshot)
64+
semantic.buildSemanticIndex(indexDir=index, sources=[(snapshot, "catalog")])
65+
hit = semantic.searchSemantic("전력", indexDir=index).row(0, named=True)
66+
assert hit["sourceRef"] == frame["sourceRef"][0]
67+
assert hit["sourceDataAsOf"] == "20250102"
68+
assert hit["coverage"] == "catalogExcerpt"
69+
70+
3471
def testIncrementalReusesTextAndRemovesDeletedDocuments(tmp_path, encoder):
3572
source, index = tmp_path / "source.parquet", tmp_path / "index"
3673
rows = [
@@ -40,6 +77,9 @@ def testIncrementalReusesTextAndRemovesDeletedDocuments(tmp_path, encoder):
4077
catalog(source, rows)
4178
first = semantic.buildSemanticIndex(indexDir=index, sources=[(source, "catalog")])
4279
assert first["encoded"] == 2
80+
info = semantic.semanticIndexInfo(indexDir=index)
81+
assert info["available"] and info["passages"] == 2
82+
assert "shards" not in info
4383
assert semantic.buildSemanticIndex(indexDir=index, sources=[(source, "catalog")])["encoded"] == 0
4484
rows[0]["companyName"] = "변경된 이름"
4585
rows[1]["deleted"] = True
@@ -51,6 +91,7 @@ def testIncrementalReusesTextAndRemovesDeletedDocuments(tmp_path, encoder):
5191
assert result.height == 2
5292
assert "20250102000001" not in result["rcept_no"]
5393
assert "변경된 이름" in result["corp_name"]
94+
assert semantic.semanticIndexInfo(indexDir=index)["passages"] == 2
5495

5596

5697
def testFailedRebuildKeepsLastReadableSnapshot(tmp_path, encoder, monkeypatch):
@@ -139,11 +180,16 @@ def testFiltersApplyBeforeRankingAndRelatedSearchExcludesSeed(tmp_path, encoder)
139180
otherCompanies = semantic.searchSemantic("", relatedTo=seed, excludeStockCode="005930", indexDir=index)
140181
assert set(otherCompanies["stock_code"]) == {"000660"}
141182
assert "news" not in otherCompanies["source"]
183+
assert list(semantic.iterSemantic("", relatedTo=seed, excludeStockCode="005930", indexDir=index)) == (
184+
otherCompanies.to_dicts()
185+
)
142186
with pytest.raises(ValueError, match="passageId"):
143187
semantic.searchSemantic("", relatedTo="missing", indexDir=index)
144188

145189

146190
def testMissingSemanticIndexExplainsPreparation(tmp_path, encoder):
191+
assert semantic.semanticIndexInfo(indexDir=tmp_path) == {"available": False}
192+
assert encoder == []
147193
with pytest.raises(RuntimeError, match="--build-semantic"):
148194
semantic.searchSemantic("설비", indexDir=tmp_path)
149195

0 commit comments

Comments
 (0)