refactor(examples): replace sector-specific example material with generic, fictitious examples
The context sets, the packaged knowledge bases and the example bundles are replaced by one fictitious example set about IT operations in an invented organisation: three context sets (serverrom-2027, driftsavtale-2027 and the two-base drift-og-avtale-2027), two synthetic knowledge bases under src/portfolio_optimiser/data/kunnskapsbaser and two example bundles under src/portfolio_optimiser/data/bundles. Numbers, codes and structural values in tests and fixtures are kept; names, ids and wording change. Dated measurement documents that only recorded runs on the replaced material are deleted. Gate figures measured on the new set are not comparable with earlier ones. The exclusion gate from the previous commit is green: 0 tracked files hit outside the shared/ subtree. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
058dd25570
commit
37547fe292
1147 changed files with 24138 additions and 9503 deletions
|
|
@ -22,19 +22,19 @@ from portfolio_optimiser.retrieval import (
|
|||
def docs(tmp_path):
|
||||
d = tmp_path / "docs"
|
||||
d.mkdir()
|
||||
(d / "asphalt.txt").write_text(
|
||||
"Asphalt Ab11 unit rate renegotiation reduced the paving cost on the school stretch.",
|
||||
(d / "licence.txt").write_text(
|
||||
"Licence unit price renegotiation reduced the office-suite cost for the head office.",
|
||||
encoding="utf-8",
|
||||
)
|
||||
(d / "drainage.txt").write_text(
|
||||
"Drainage length was reduced after a survey on the low-traffic section.",
|
||||
(d / "cabling.txt").write_text(
|
||||
"Cabling length was reduced after a survey on the low-use floor.",
|
||||
encoding="utf-8",
|
||||
)
|
||||
return d
|
||||
|
||||
|
||||
def test_locator_exactly_slices_snippet(docs) -> None:
|
||||
hits = retrieve("asphalt paving cost", str(docs), top_k=5)
|
||||
hits = retrieve("licence office-suite cost", str(docs), top_k=5)
|
||||
assert hits
|
||||
for h in hits:
|
||||
text = (docs / h.file).read_text(encoding="utf-8")
|
||||
|
|
@ -42,8 +42,8 @@ def test_locator_exactly_slices_snippet(docs) -> None:
|
|||
|
||||
|
||||
def test_retrieve_is_deterministic(docs) -> None:
|
||||
a = retrieve("drainage survey", str(docs), top_k=3)
|
||||
b = retrieve("drainage survey", str(docs), top_k=3)
|
||||
a = retrieve("cabling survey", str(docs), top_k=3)
|
||||
b = retrieve("cabling survey", str(docs), top_k=3)
|
||||
assert [(h.file, h.locator) for h in a] == [(h.file, h.locator) for h in b]
|
||||
|
||||
|
||||
|
|
@ -65,13 +65,13 @@ def test_parent_traversal_rejected(docs) -> None:
|
|||
def test_symlink_escape_is_not_read(tmp_path, docs) -> None:
|
||||
# A symlink INSIDE docs_dir pointing OUTSIDE must never be read (fail-closed).
|
||||
secret = tmp_path / "secret.txt"
|
||||
secret.write_text("TOPSECRET asphalt asphalt asphalt exfiltrated", encoding="utf-8")
|
||||
secret.write_text("TOPSECRET licence licence licence exfiltrated", encoding="utf-8")
|
||||
os.symlink(str(secret), str(docs / "link.txt"))
|
||||
# safe_resolve refuses the escaping symlink...
|
||||
with pytest.raises(PathSecurityError):
|
||||
safe_resolve(str(docs), "link.txt")
|
||||
# ...and retrieve never surfaces the outside content even on a matching query.
|
||||
hits = retrieve("asphalt", str(docs), top_k=10)
|
||||
hits = retrieve("licence", str(docs), top_k=10)
|
||||
assert all("TOPSECRET" not in h.snippet for h in hits)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue