mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-10 22:07:03 +01:00
Some checks are pending
dependency freshness / dependencies on newest stable (push) Waiting to run
md-naming / markdown naming convention (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (mypy, mypy) (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (pylint, pylint) (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (rest, ) (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (shellcheck, shellcheck) (push) Waiting to run
Python tests / test (push) Waiting to run
repo-contract / repo contract (push) Waiting to run
Shell tests / shell-tests (push) Waiting to run
Shell tests / lib-tests (push) Waiting to run
Shell tests / arch-tests (push) Waiting to run
Links sessions to todo notes (note_claim.sh, todo-images prompts, fuzzy first prompt >= 0.5, handoff chains), dates completions from the status HLC in the first Firebase dump, and adds usd_per_note, note_linked_usd_share, notes_done(_linked) to the snapshot, a WEEKLY section and notes.json. token_dashboard stores the build-class A/B (agent-ab-build.jsonl) as meta ab_build. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WzxdWWMeapxnDcgk7HSw67
69 lines
2.5 KiB
Python
69 lines
2.5 KiB
Python
"""Rule (c): the first real prompt fuzzy-matched to one note's text."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import TYPE_CHECKING
|
|
|
|
from python_pkg.token_audit import notes_backlog, notes_link, notes_scan
|
|
from python_pkg.token_audit.tests import test_notes_fixtures as fx
|
|
|
|
if TYPE_CHECKING:
|
|
from pathlib import Path
|
|
|
|
|
|
def _notes(tmp_path: Path) -> list[notes_backlog.Note]:
|
|
return notes_backlog.parse_backlog(fx.backlog(tmp_path / "B.md").read_text())
|
|
|
|
|
|
def _link(tmp_path: Path, *texts: str) -> notes_link.Link | None:
|
|
root = tmp_path / "projects"
|
|
fx.transcript(root, "s1", [fx.prompt(t) for t in texts])
|
|
return notes_link.link_all(notes_scan.scan_root(root), _notes(tmp_path)).get("s1")
|
|
|
|
|
|
def test_pasted_note_body_links(tmp_path: Path) -> None:
|
|
pasted = f'<pasted_content id="ab12">\n{fx.BODY_B}\n</pasted_content>\nplease'
|
|
assert _link(tmp_path, pasted) == notes_link.Link((fx.NOTE_B,), "c")
|
|
|
|
|
|
def test_title_only_prompt_links_by_first_line(tmp_path: Path) -> None:
|
|
link = _link(tmp_path, "diet guard meal times picker")
|
|
assert link == notes_link.Link((fx.NOTE_A,), "c")
|
|
|
|
|
|
def test_unrelated_prompt_does_not_link(tmp_path: Path) -> None:
|
|
assert _link(tmp_path, "restart the steam backlog enforcer while game runs") is None
|
|
|
|
|
|
def test_only_first_prompt_is_matched(tmp_path: Path) -> None:
|
|
assert _link(tmp_path, "unrelated opening words here now", fx.BODY_A) is None
|
|
|
|
|
|
def test_short_prompt_is_never_matched(tmp_path: Path) -> None:
|
|
assert _link(tmp_path, "horror game") is None
|
|
|
|
|
|
def test_wrappers_and_caveats_are_skipped(tmp_path: Path) -> None:
|
|
link = _link(
|
|
tmp_path,
|
|
"<command-name>/clear</command-name>",
|
|
"Caveat: the messages below were generated by the user",
|
|
f"<system-reminder>noise</system-reminder>{fx.BODY_A}",
|
|
)
|
|
assert link == notes_link.Link((fx.NOTE_A,), "c")
|
|
|
|
|
|
def test_list_content_prompt_is_read(tmp_path: Path) -> None:
|
|
root = tmp_path / "projects"
|
|
record = fx.prompt("")
|
|
record["message"]["content"] = [{"type": "text", "text": fx.BODY_B}]
|
|
fx.transcript(root, "s1", [record])
|
|
links = notes_link.link_all(notes_scan.scan_root(root), _notes(tmp_path))
|
|
assert links["s1"].notes == (fx.NOTE_B,)
|
|
|
|
|
|
def test_score_is_symmetric_dice_or_title() -> None:
|
|
note = notes_backlog.Note("n", "alpha beta gamma delta", "x", "low", "todo", None)
|
|
assert notes_link.score("alpha beta gamma delta", note) == 1.0
|
|
assert notes_link.score("zeta eta theta iota", note) == 0.0
|