cortex-vec 0.10.0__tar.gz → 0.11.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {cortex_vec-0.10.0/src/cortex_vec.egg-info → cortex_vec-0.11.0}/PKG-INFO +1 -1
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/pyproject.toml +1 -1
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/src/cortex_vec/cli.py +6 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/src/cortex_vec/raw_map.py +18 -7
- {cortex_vec-0.10.0 → cortex_vec-0.11.0/src/cortex_vec.egg-info}/PKG-INFO +1 -1
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/tests/test_raw_map.py +44 -2
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/LICENSE +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/NOTICE +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/README.md +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/setup.cfg +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/src/cortex_vec/__init__.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/src/cortex_vec/bm25.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/src/cortex_vec/config.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/src/cortex_vec/distill_plan.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/src/cortex_vec/distill_queue.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/src/cortex_vec/errors.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/src/cortex_vec/eval/__init__.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/src/cortex_vec/eval/adapters.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/src/cortex_vec/eval/corpus.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/src/cortex_vec/eval/report.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/src/cortex_vec/eval/run.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/src/cortex_vec/eval/score.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/src/cortex_vec/fusion.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/src/cortex_vec/graph.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/src/cortex_vec/parser.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/src/cortex_vec/raw_page.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/src/cortex_vec/raw_source.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/src/cortex_vec/raw_span.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/src/cortex_vec/raw_view.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/src/cortex_vec/reclaim.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/src/cortex_vec/rerank.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/src/cortex_vec/store.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/src/cortex_vec/synonyms.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/src/cortex_vec/tokenize.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/src/cortex_vec.egg-info/SOURCES.txt +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/src/cortex_vec.egg-info/dependency_links.txt +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/src/cortex_vec.egg-info/entry_points.txt +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/src/cortex_vec.egg-info/requires.txt +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/src/cortex_vec.egg-info/top_level.txt +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/tests/test_adapters.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/tests/test_bm25.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/tests/test_bm25_synonym.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/tests/test_cli_errors.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/tests/test_cli_json.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/tests/test_cmd_search.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/tests/test_cmd_search_flags.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/tests/test_config.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/tests/test_config_plan2.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/tests/test_corpus.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/tests/test_cosine_backfill.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/tests/test_distill_plan.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/tests/test_distill_queue.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/tests/test_fusion_diversify.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/tests/test_fusion_graph.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/tests/test_fusion_graph_filter.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/tests/test_fusion_rerank.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/tests/test_fusion_rrf.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/tests/test_fusion_search.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/tests/test_fusion_synonym.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/tests/test_graph_build.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/tests/test_graph_stream.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/tests/test_lockstep.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/tests/test_no_weekly_type.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/tests/test_raw_page.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/tests/test_raw_source.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/tests/test_raw_span.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/tests/test_raw_view.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/tests/test_rebuild_bm25_only.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/tests/test_reclaim.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/tests/test_report.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/tests/test_rerank.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/tests/test_run.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/tests/test_score.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/tests/test_smoke.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/tests/test_synonyms.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/tests/test_tokenize.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/tests/test_vector_stream.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/tests/test_where_shape_lockstep.py +0 -0
- {cortex_vec-0.10.0 → cortex_vec-0.11.0}/tests/test_wikilinks.py +0 -0
|
@@ -109,6 +109,12 @@ def _main():
|
|
|
109
109
|
p_rm.add_argument("--find-only", action="store_true", dest="find_only",
|
|
110
110
|
help="With --find: emit only `find_matches` (no cards, "
|
|
111
111
|
"no map progress); costs one envelope, not a page")
|
|
112
|
+
p_rm.add_argument("--find-after", type=int, dest="find_after",
|
|
113
|
+
metavar="SPAN_ID",
|
|
114
|
+
help="With --find: report only hits in spans after this "
|
|
115
|
+
"id. `find_matches` holds at most 50 ids; when "
|
|
116
|
+
"`find_truncated` is true, pass the last id here "
|
|
117
|
+
"for the next 50 (`find_total` counts all hits)")
|
|
112
118
|
|
|
113
119
|
p_rsp = sub.add_parser(
|
|
114
120
|
"raw-span", help="Bounded original-source page of one span"
|
|
@@ -7,6 +7,7 @@ is complete); prose/output_body/ambiguous/opaque always need raw-span.
|
|
|
7
7
|
"""
|
|
8
8
|
from __future__ import annotations
|
|
9
9
|
|
|
10
|
+
import bisect
|
|
10
11
|
import re
|
|
11
12
|
|
|
12
13
|
from . import distill_plan as dp
|
|
@@ -16,6 +17,8 @@ from .raw_page import (PAGE_BUDGET_DEFAULT, PageError, decode_cursor,
|
|
|
16
17
|
render_page)
|
|
17
18
|
|
|
18
19
|
PREVIEW_CHARS = 160
|
|
20
|
+
# span ids per find envelope; keeps a find-only reply inside its page budget
|
|
21
|
+
FIND_LIMIT = 50
|
|
19
22
|
_ISSUE_RE = re.compile(r"\b[A-Z][A-Z0-9]{1,9}-\d{3,7}\b")
|
|
20
23
|
_URL_RE = re.compile(r"https?://\S+")
|
|
21
24
|
|
|
@@ -95,15 +98,21 @@ def _dispatch(args) -> None:
|
|
|
95
98
|
reason="--find-only needs --find <literal>")
|
|
96
99
|
find_matches = None
|
|
97
100
|
if find:
|
|
98
|
-
|
|
101
|
+
# Spans partition the text contiguously, so a bisect on char_start
|
|
102
|
+
# maps each occurrence to its span without scanning every span.
|
|
103
|
+
starts = [s.char_start for s in spans]
|
|
104
|
+
after = getattr(args, "find_after", None)
|
|
105
|
+
hits = []
|
|
99
106
|
pos = text.find(find)
|
|
100
|
-
while pos != -1
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
find_matches.append(s.id)
|
|
105
|
-
break
|
|
107
|
+
while pos != -1:
|
|
108
|
+
sid = spans[bisect.bisect_right(starts, pos) - 1].id
|
|
109
|
+
if not hits or hits[-1] != sid:
|
|
110
|
+
hits.append(sid)
|
|
106
111
|
pos = text.find(find, pos + 1)
|
|
112
|
+
later = [h for h in hits if after is None or h > after]
|
|
113
|
+
find_matches = later[:FIND_LIMIT]
|
|
114
|
+
find_total = len(hits)
|
|
115
|
+
find_truncated = len(later) > FIND_LIMIT
|
|
107
116
|
|
|
108
117
|
used_before = state["session_used_chars"]
|
|
109
118
|
budget = state["session_budget"] - dp.CONTROL_RESERVE
|
|
@@ -126,6 +135,8 @@ def _dispatch(args) -> None:
|
|
|
126
135
|
}
|
|
127
136
|
if find_matches is not None:
|
|
128
137
|
obj["find_matches"] = find_matches
|
|
138
|
+
obj["find_total"] = find_total
|
|
139
|
+
obj["find_truncated"] = find_truncated
|
|
129
140
|
if find_only:
|
|
130
141
|
# Locate only: no cards, no map progress, no continuation.
|
|
131
142
|
obj["find_only"] = True
|
|
@@ -31,9 +31,10 @@ def env(tmp_path, monkeypatch):
|
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
def _page(capsys, raw, st, cursor=None, max_chars=12000, find=None,
|
|
34
|
-
find_only=False):
|
|
34
|
+
find_only=False, find_after=None):
|
|
35
35
|
rm.dispatch(Args(path=str(raw), plan_id=st["plan_id"], cursor=cursor,
|
|
36
|
-
max_chars=max_chars, find=find, find_only=find_only
|
|
36
|
+
max_chars=max_chars, find=find, find_only=find_only,
|
|
37
|
+
find_after=find_after))
|
|
37
38
|
out = capsys.readouterr().out
|
|
38
39
|
assert out.endswith("\n")
|
|
39
40
|
assert len(out) <= max_chars
|
|
@@ -153,3 +154,44 @@ def test_find_only_without_find_errors(env, capsys):
|
|
|
153
154
|
max_chars=12000, find=None, find_only=True))
|
|
154
155
|
out = capsys.readouterr().out
|
|
155
156
|
assert json.loads(out)["error"] == "FIND_ONLY_REQUIRES_FIND"
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
# 60 user turns, each with its own "needle" prose span: more hits than the
|
|
160
|
+
# 50 ids one find envelope reports.
|
|
161
|
+
MANY = ("---\nrepo: cortex\n---\n"
|
|
162
|
+
+ "### User\n\nneedle here\n\n### Claude\n\nok\n\n" * 60)
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
@pytest.fixture
|
|
166
|
+
def many(tmp_path, monkeypatch):
|
|
167
|
+
monkeypatch.setenv("XDG_CACHE_HOME", str(tmp_path / "cache"))
|
|
168
|
+
raw = tmp_path / "many.md"
|
|
169
|
+
raw.write_text(MANY, encoding="utf-8")
|
|
170
|
+
st = dp.start_plan(str(raw), 12000, 100000)
|
|
171
|
+
return raw, st
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
def test_find_reports_total_and_truncation_past_the_cap(many, capsys):
|
|
175
|
+
raw, st = many
|
|
176
|
+
page = _page(capsys, raw, st, find="needle", find_only=True)
|
|
177
|
+
assert len(page["find_matches"]) == 50
|
|
178
|
+
assert page["find_total"] == 60
|
|
179
|
+
assert page["find_truncated"] is True
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
def test_find_under_the_cap_is_not_truncated(env, capsys):
|
|
183
|
+
raw, st = env
|
|
184
|
+
page = _page(capsys, raw, st, find="PROJ-4521", find_only=True)
|
|
185
|
+
assert page["find_total"] == len(page["find_matches"]) == 1
|
|
186
|
+
assert page["find_truncated"] is False
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
def test_find_after_pages_to_the_hits_past_the_cap(many, capsys):
|
|
190
|
+
raw, st = many
|
|
191
|
+
first = _page(capsys, raw, st, find="needle", find_only=True)
|
|
192
|
+
rest = _page(capsys, raw, st, find="needle", find_only=True,
|
|
193
|
+
find_after=first["find_matches"][-1])
|
|
194
|
+
assert len(rest["find_matches"]) == 10
|
|
195
|
+
assert min(rest["find_matches"]) > max(first["find_matches"])
|
|
196
|
+
assert rest["find_total"] == 60
|
|
197
|
+
assert rest["find_truncated"] is False
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|