ReMe/tests/integration/_provenance.py
jinliyl 54fa3381d7
Some checks failed
CI and Release / Docker / Build and test / amd64 (push) Has been cancelled
CI and Release / Docker / Build and test / arm64 (push) Has been cancelled
Security / CodeQL / Analyze python (push) Has been cancelled
CI / Python quality / Pre-commit (push) Has been cancelled
CI / Python tests / Unit Tests - py3.12 (push) Has been cancelled
CI / Python tests / Unit Tests - py3.13 (push) Has been cancelled
CI / Python tests / Unit Tests - py3.14 (push) Has been cancelled
CI / Python packages / Build and verify distributions (push) Has been cancelled
CI / Python quality / GitHub Actions (push) Has been cancelled
CI / Python tests / Hermes embedded - ubuntu-latest (push) Has been cancelled
CI / Python tests / Hermes embedded - windows-latest (push) Has been cancelled
CI / Python tests / Unit Tests - py3.11 (push) Has been cancelled
CI / ReMe Studio / Studio checks (push) Has been cancelled
Deploy / Documentation / Build documentation (push) Has been cancelled
CI / Windows / CLI smoke - py3.11 (push) Has been cancelled
Security / CodeQL / Analyze javascript-typescript (push) Has been cancelled
CI and Release / Docker / Publish multi-platform tags (push) Has been cancelled
Deploy / Documentation / deploy (push) Has been cancelled
refactor(core): reorganize the ReMe runtime and shared helpers (#769)
* refactor(core): reorganize the ReMe runtime and shared helpers

* test(status): import the base component from its canonical module

* test: remove redundant unit checks

* refactor(core): use canonical runtime imports and shared CLI discovery

Restore evolve behavior to the base branch and update its imports. Use Application as the runtime entry point and encode SSE in the HTTP service.

* fix(cli): honor caller config when service replay is incomplete

Use partial startup overrides for port probes and resolve named configs before requesting the service process working directory.
2026-11-20 22:06:46 +08:00

24 lines
1.1 KiB
Python

"""Provenance-link predicate shared by the auto_dream integration assertion and its CI unit coverage.
Kept dependency-light (stdlib + ``WikilinkHandler`` only) so ``tests/unit``
can import it without LLM credentials or the integration workspace fixture.
"""
from reme.utils.documents.wikilink_handler import WikilinkHandler
def targets_with_provenance(target_texts: dict[str, str], source_path: str) -> list[str]:
"""Return the targets whose text links to ``source_path`` at least once.
Uses the shared wikilink grammar (``WikilinkHandler.iter_matches``) rather
than substring matching, so every form the integrate prompt permits counts:
bare links, contextual sentences, aliases, embeds, and anchored links (the
anchor lives in its own regex group, so the target still compares equal).
Unterminated ``[[...`` spans the parser rejects do not count, and links to
any other target do not either.
"""
return [
rel
for rel, text in target_texts.items()
if any(match.target == source_path for match in WikilinkHandler.iter_matches(text))
]