CI & Build / Python lint (push) Successful in 5s
CI & Build / Plugin hooks (push) Successful in 17s
CI & Build / TypeScript typecheck (push) Successful in 57s
CI & Build / integration (push) Successful in 1m19s
CI & Build / Python tests (push) Successful in 2m2s
CI & Build / Build & push image (push) Successful in 15s
Docstrings, section headers and assertion messages drop the record number, milestone or step that introduced the behaviour, and incident accounts are restated as the present-tense failure shape. A dead pointer to a design doc that is not in the repo is removed. Renamed to the property they check: test_the_old_shape_would_be_caught -> test_a_rank_then_scope_query_is_caught test_a_ledger_repeat_no_longer_produces_that_case_at_all -> test_a_ledger_repeat_is_counted_not_withheld test_the_header_no_longer_promises_once_per_session -> test_the_header_explains_the_seen_marker test_the_portal_case_no_longer_stamps_one_canon_onto_a_whole_file -> test_one_canon_is_not_stamped_onto_a_whole_file test_the_repos_own_prose_no_longer_defines_with -> test_the_repos_own_prose_does_not_define_with test_the_original_regression_create_note_with_content -> test_the_real_server_refuses_content_on_create_note Fixture and example ids stay: "note 5" in a supersession chain, "rule 156" in an illustrative question, `#2275` as the hex-versus-citation case, `#3244` as the example of a bare number, fixed dates in date-filter tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
55 lines
2.1 KiB
Python
55 lines
2.1 KiB
Python
"""A SessionStart that loads no project says why, and names the first move.
|
|
|
|
A fetch written as `curl -f … || body=""` collapses a timeout, an HTTP error
|
|
and a refused key into one sentence, and a fallback that suggests
|
|
`enter_project()` "as needed" reads as optional. A session that skips it starts
|
|
with no recent milestones or open tasks, and so has no way to know which prior
|
|
work exists to look for. These pin both halves on the path that needs no
|
|
server: the cause is named, and the fallback is a concrete first step.
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
import os
|
|
import subprocess
|
|
from pathlib import Path
|
|
|
|
from tests.helpers import need_tools
|
|
|
|
HOOK = Path(__file__).resolve().parents[1] / "plugin" / "hooks" / "scribe_session_context.sh"
|
|
|
|
|
|
def run_hook(tmp_path: Path, url: str, marker_project: int | None = None) -> str:
|
|
need_tools("bash", "curl", "awk")
|
|
if marker_project is not None:
|
|
(tmp_path / ".scribe").write_text(json.dumps({
|
|
"instance": url, "project_id": marker_project, "project": "P",
|
|
}))
|
|
env = {**os.environ, "SCRIBE_URL": url, "SCRIBE_TOKEN": "t",
|
|
"CLAUDE_PROJECT_DIR": str(tmp_path)}
|
|
r = subprocess.run(["bash", str(HOOK)], input=b'{"source":"startup"}',
|
|
capture_output=True, env=env, timeout=60)
|
|
assert r.returncode == 0, r.stderr.decode()
|
|
return json.loads(r.stdout)["hookSpecificOutput"]["additionalContext"]
|
|
|
|
|
|
# Port 9 (discard) on loopback: refused at once, so both tries fail fast.
|
|
DEAD = "http://127.0.0.1:9"
|
|
|
|
|
|
def test_an_unreachable_instance_is_named_as_one(tmp_path):
|
|
out = run_hook(tmp_path, DEAD)
|
|
assert "could not be reached (curl exit 7, after a retry)" in out
|
|
|
|
|
|
def test_the_fallback_is_a_first_step_not_an_option(tmp_path):
|
|
out = run_hook(tmp_path, DEAD)
|
|
assert "as needed" not in out
|
|
assert "Start by finding this repo's project" in out
|
|
assert "before any other work" in out
|
|
|
|
|
|
def test_a_marker_names_the_exact_call(tmp_path):
|
|
out = run_hook(tmp_path, DEAD, marker_project=31)
|
|
assert "Start by calling `enter_project(31)`" in out
|