Skip to content

[intern-31] Integration test: convert → chunk → query - #422

Open
Supermonters wants to merge 1 commit into
masterfrom
intern/31-integration-test-workflow
Open

[intern-31] Integration test: convert → chunk → query#422
Supermonters wants to merge 1 commit into
masterfrom
intern/31-integration-test-workflow

Conversation

@Supermonters

@Supermonters Supermonters commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

Closes #369

cc @anhnth24 — em xin gửi PR intern-31 để anh review ạ.

Summary

  • Thêm integration test happy path trong crates/core/tests/integration_convert_chunk.rs: file DOCX thật → Converter::convert_pathchunk_markdownsearch_corpus.
  • Fixture synthetic crates/core/tests/fixtures/heading-hierarchy.docx (Heading 1 Phần I + intro + 3× Heading 2 Mục 1/2/3, mã REF-M1/M2/M3). Không dùng tài liệu khách hàng.
  • Không mock converter, không path tuyệt đối (CARGO_MANIFEST_DIR + tests/fixtures/). Không đổi logic production.

Thay đổi file

crates/core/tests/fixtures/heading-hierarchy.docx

DOCX tự soạn, style Word Heading 1/2 (không chỉ Bold). Convert ra:

# Phần I

Giới thiệu phần I.

## Mục 1

Nội dung mục 1. Mã tham chiếu REF-M1.

## Mục 2

Nội dung mục 2. Mã tham chiếu REF-M2.

## Mục 3

Nội dung mục 3. Mã tham chiếu REF-M3.

Golden DOCX sẵn có (gold-006.docx, …) chỉ 1 H1 + 1 H2 → sau chunk thường 1 mảnh, không đủ AC “heading 1 → 2–3 heading 2”.

Tên file mô tả nội dung (heading-hierarchy), không gắn intern31. Trace issue để ở title PR / Closes #369.

crates/core/tests/integration_convert_chunk.rs

Một test: integration_convert_chunk_then_query_happy_path.

Luồng:

  1. Converter::new().convert_path — convert thật, format == Docx, markdown có # Phần I.
  2. chunk_markdown(md, 2000) — chia theo heading, giữ path "Phần I > Mục 2".
  3. build_corpus + search_corpus("REF-M2", 5) — keyword search có sẵn (không viết TF-IDF riêng).

Test nào pass? Assertion nào validate?

Loại (AC issue) Assert Ý nghĩa
Count chunks.len() == 4, corpus.len() khớp H1 intro + 3 H2
Title chunks[i].heading = Phần I, Phần I > Mục 1/2/3 hierarchy đúng
Order chunks[i].index == i Mục 1 → 2 → 3, không đảo
Retrieval search_corpus("REF-M2") không rỗng, hits[0] chứa Mục 2 query ra đúng chunk

Vì sao đây là integration test (không nhét vào chunk.rs)?

  • Unit test chunk.rs (intern-05) đã khóa heading path trên chuỗi Markdown hardcode.
  • intern-31 khóa cả pipeline: Word style Heading → converter DOCX → chunk → search. Mock convert_path sẽ không chứng minh file thật convert đúng.

Test plan

  • cargo test -p fileconv-core integration_convert_chunk -- --nocapture
  • cargo fmt --all -- --check
  • cargo metadata --locked --format-version 1 --no-deps
  • python3 scripts/check-dependency-policy.py

Cover intern-31 / #369 with a real DOCX fixture: convert_path, heading
chunks (count/title/order), then keyword search_corpus.

Co-authored-by: Cursor <cursoragent@cursor.com>
@Supermonters
Supermonters requested a review from anhnth24 as a code owner August 13, 2026 09:50
@Supermonters Supermonters changed the title test(intern-31): convert → chunk → query workflow (#369) [intern-31] Integration test: convert → chunk → query Aug 13, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Unmanaged test fixture
    • Added crates/core/tests/fixtures/manifest.json for heading-hierarchy.docx and wired that root into make check-fixtures so checksum, unmanaged-file, and secret-canary checks cover it.

Create PR

Or push these changes by commenting:

@cursor push fe6df63fc6
Preview (fe6df63fc6)
diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -49,6 +49,7 @@
 	python3 scripts/check-fixtures.py
 	python3 scripts/check-fixtures.py --root app/src-tauri/fixtures/knowledge/v1
 	python3 scripts/check-fixtures.py --root crates/knowledge/fixtures
+	python3 scripts/check-fixtures.py --root crates/core/tests/fixtures
 	python3 scripts/check-fixtures.py --self-test
 
 check-markhand-gates:

diff --git a/crates/core/tests/fixtures/manifest.json b/crates/core/tests/fixtures/manifest.json
new file mode 100644
--- /dev/null
+++ b/crates/core/tests/fixtures/manifest.json
@@ -1,0 +1,15 @@
+{
+  "version": 1,
+  "fixtures": [
+    {
+      "id": "core.docx.heading-hierarchy.v1",
+      "path": "heading-hierarchy.docx",
+      "sha256": "806a293e688a70880f3a62a727fc84085d76cf8862c861dcf259a1819c3aaf25",
+      "kind": "docx",
+      "owner": "markhand-core",
+      "source": "synthetic",
+      "license": "CC0-1.0",
+      "sensitive": false
+    }
+  ]
+}

You can send follow-ups to the cloud agent here.

Reviewed by Cursor Bugbot for commit f7771c1. Configure here.

path.is_file(),
"missing fixture at {} — add heading-hierarchy.docx under crates/core/tests/fixtures/",
path.display()
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unmanaged test fixture

Medium Severity

The new heading-hierarchy.docx under crates/core/tests/fixtures/ has no local manifest.json (id, sha256, license, sensitive: false) and is not wired into make check-fixtures. That skips the repo fixture contract and secret/canary checks used by other component fixture roots such as crates/knowledge/fixtures.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit f7771c1. Configure here.

@cursor
cursor Bot requested a review from CodingMinh August 13, 2026 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[intern-31] Integration test suite: convert-then-chunk-then-query workflow

1 participant