mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-11 00:27:01 +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
83 lines
2.8 KiB
Python
83 lines
2.8 KiB
Python
"""Edge cases of the note join that the rule tests do not reach."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
from python_pkg.token_audit import (
|
|
notes,
|
|
notes_backlog,
|
|
notes_collect,
|
|
notes_link,
|
|
notes_scan,
|
|
pricing,
|
|
)
|
|
from python_pkg.token_audit.model import Session
|
|
from python_pkg.token_audit.tests import test_notes_fixtures as fx
|
|
|
|
HANDOFF = "/home/kuhy/.claude/handoff/e.md"
|
|
|
|
|
|
def test_prompt_text_rejects_tool_results_and_non_text() -> None:
|
|
result = fx.tool_result("x")
|
|
assert notes_scan.prompt_text(result) is None
|
|
empty = fx.prompt("x")
|
|
empty["message"]["content"] = None
|
|
assert notes_scan.prompt_text(empty) is None
|
|
|
|
|
|
def test_bad_backlog_stamp_and_malformed_status_field() -> None:
|
|
text = '<!-- @note id="x" updated="garbage" -->\nbody'
|
|
assert notes_backlog.parse_backlog(text)[0].updated is None
|
|
odd = '{"n": {"fields": {"status": [2]}}}'
|
|
assert notes_backlog.merge_devices({"d": odd}) == {}
|
|
|
|
|
|
def test_non_handoff_writes_and_repeat_writes_are_ignored(tmp_path: Path) -> None:
|
|
root = tmp_path / "projects"
|
|
fx.transcript(
|
|
root,
|
|
"w1",
|
|
[
|
|
fx.tool_use("Write", {"file_path": "/home/kuhy/notes/x.md"}, msg="m1"),
|
|
fx.tool_use("Write", {"file_path": HANDOFF}, "2026-10-20T09:00:00Z", "m2"),
|
|
fx.tool_use("Write", {"file_path": HANDOFF}, "2026-10-20T10:00:00Z", "m3"),
|
|
],
|
|
)
|
|
fx.subagent(root, "orphan", "z", [fx.tool_use("Write", {"file_path": HANDOFF})])
|
|
facts = notes_scan.scan_root(root)
|
|
assert set(facts) == {"w1"}
|
|
assert list(facts["w1"].creates) == ["e.md"]
|
|
|
|
|
|
def test_unlinked_writer_passes_nothing_on(tmp_path: Path) -> None:
|
|
root = tmp_path / "projects"
|
|
fx.transcript(
|
|
root,
|
|
"w1",
|
|
[
|
|
fx.prompt("nothing matching at all here", "2026-10-20T08:00:00Z"),
|
|
fx.tool_use("Write", {"file_path": HANDOFF}, "2026-10-20T08:10:00Z"),
|
|
],
|
|
)
|
|
fx.transcript(
|
|
root, "r1", [fx.prompt(f"Implement {HANDOFF}", "2026-10-20T09:00:00Z")]
|
|
)
|
|
notes_list = notes_backlog.parse_backlog(fx.backlog(tmp_path / "B.md").read_text())
|
|
assert notes_link.link_all(notes_scan.scan_root(root), notes_list) == {}
|
|
|
|
|
|
def test_sessions_started_before_window_are_not_reused(tmp_path: Path) -> None:
|
|
root = tmp_path / "projects"
|
|
path = fx.transcript(root, "s1", [fx.prompt("x", "2026-10-01T00:00:00Z")])
|
|
facts = notes_scan.scan_root(root)
|
|
sessions = [Session("s1", str(path)), Session("ghost", "/nowhere")]
|
|
reuse = notes_collect._reusable(sessions, facts, 2e9, pricing.load())
|
|
assert reuse == {}
|
|
|
|
|
|
def test_standalone_entry_without_backlog_writes_nothing(tmp_path: Path) -> None:
|
|
out = tmp_path / "out"
|
|
assert notes.main(["--root", str(tmp_path), "--out", str(out)]) == 0
|
|
assert not out.exists()
|