Add thread notifications, SEO topic pages, and fix quiz auto-advance
Notifications: a new "thread" type notifies every other commenter on a
post whenever anyone comments on it, disregarding reply hierarchy -
excluding the actor and whoever already got a comment/reply
notification for that same event, so no one is double-notified.
Implemented via a background-deferred fan-out mirroring the existing
mention-notification pattern.
SEO: discussion_forum_posting() now embeds up to 20 of a post's
comments as nested schema.org Comment entities (not just an aggregate
count), and a new /topics hub plus /topics/{topic} pages give the
feed's topic filter real, independently crawlable/indexable URLs -
/feed?topic=X was never indexable since its canonical strips the
query string back to bare /feed. Both are wired end to end (schemas,
Devii actions, docs API, sitemap, locustfile load-test coverage).
Quiz player: the auto-advance to the next question used to hide the
just-answered slide in the same tick as rendering the grade, so on
any multi-question quiz the Correct/Not correct feedback was never
actually visible before the view moved on. Delayed via setTimeout,
with the pending timer cleared on manual navigation and on
disconnect so it can't race or fire on a removed component.
Also includes other local changes already in progress in this
working tree before this session (messaging, push delivery,
deepsearch jobs, game economy, quiz builder) - verified by the full
suite passing (3467 tests) but not authored or individually reviewed
in this session.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VL9Xn57W5UR3HZbbuuzxdK
This commit is contained in:
@@ -4,9 +4,16 @@ import json
|
||||
|
||||
from tests.conftest import run_async
|
||||
|
||||
from devplacepy.services.deepsearch.store import Chunk
|
||||
from devplacepy.services.jobs.deepsearch import orchestrate as orchestrate_module
|
||||
from devplacepy.services.jobs.deepsearch.crawl import CrawledPage
|
||||
from devplacepy.services.jobs.deepsearch.orchestrate import Orchestration, orchestrate, source_diversity
|
||||
from devplacepy.services.jobs.deepsearch.orchestrate import (
|
||||
Orchestration,
|
||||
_cosine,
|
||||
_mmr_select,
|
||||
orchestrate,
|
||||
source_diversity,
|
||||
)
|
||||
|
||||
|
||||
def _page(url, text="content " * 30):
|
||||
@@ -149,6 +156,67 @@ def test_linker_receives_full_source_list(monkeypatch):
|
||||
assert f"[{n}]" in seen["linker"]
|
||||
|
||||
|
||||
def test_cosine_identical_vectors_is_one():
|
||||
assert round(_cosine([1.0, 0.0], [1.0, 0.0]), 6) == 1.0
|
||||
|
||||
|
||||
def test_cosine_orthogonal_vectors_is_zero():
|
||||
assert _cosine([1.0, 0.0], [0.0, 1.0]) == 0.0
|
||||
|
||||
|
||||
def test_cosine_mismatched_or_empty_is_zero():
|
||||
assert _cosine([], [1.0]) == 0.0
|
||||
assert _cosine([1.0], [1.0, 0.0]) == 0.0
|
||||
|
||||
|
||||
def test_mmr_select_prefers_diverse_over_redundant():
|
||||
query_vector = [1.0, 0.0, 0.0]
|
||||
most_relevant = Chunk(uid="a", text="a", url="https://a", title="A", embedding=[0.9, 0.436, 0.0])
|
||||
near_duplicate = Chunk(uid="b", text="b", url="https://a2", title="B", embedding=[0.85, 0.527, 0.0])
|
||||
diverse = Chunk(uid="c", text="c", url="https://c", title="C", embedding=[0.85, 0.0, 0.527])
|
||||
selected = _mmr_select([most_relevant, near_duplicate, diverse], query_vector, limit=2)
|
||||
assert {chunk.uid for chunk in selected} == {"a", "c"}
|
||||
|
||||
|
||||
def test_mmr_select_falls_back_when_embeddings_missing():
|
||||
chunks = [Chunk(uid="a", text="a", url="https://a", title="A")]
|
||||
assert _mmr_select(chunks, [1.0, 0.0], limit=1) == chunks
|
||||
|
||||
|
||||
def test_mmr_select_empty_input():
|
||||
assert _mmr_select([], [1.0, 0.0], limit=3) == []
|
||||
|
||||
|
||||
def test_orchestrate_grounded_run_includes_follow_up_questions(monkeypatch):
|
||||
replies = iter(
|
||||
[
|
||||
"## Answer\nA grounded answer [1].",
|
||||
json.dumps(
|
||||
{
|
||||
"findings": [
|
||||
{"title": "Finding", "detail": "Detail", "confidence": 0.7, "citations": [1]}
|
||||
]
|
||||
}
|
||||
),
|
||||
json.dumps({"confidence": 0.8}),
|
||||
json.dumps({"questions": ["What about X?", "How does Y compare?"]}),
|
||||
]
|
||||
)
|
||||
|
||||
async def fake_request_completion(messages, api_key, **kwargs):
|
||||
return ({"choices": [{"message": {"content": next(replies)}}]}, {}, 5)
|
||||
|
||||
monkeypatch.setattr(orchestrate_module, "request_completion", fake_request_completion)
|
||||
pages = [_page("https://a.example"), _page("https://b.example")]
|
||||
result = run_async(orchestrate("question", pages, "k", lambda frame: None))
|
||||
assert result.follow_up_questions == ["What about X?", "How does Y compare?"]
|
||||
|
||||
|
||||
def test_orchestrate_heuristic_path_has_no_follow_up_questions():
|
||||
result = run_async(orchestrate("q", [], "k", lambda frame: None))
|
||||
assert result.follow_up_questions == []
|
||||
|
||||
|
||||
def test_parse_json_tolerates_fences_and_trailing_garbage():
|
||||
from devplacepy.services.jobs.deepsearch.orchestrate import _parse_json
|
||||
|
||||
|
||||
Reference in New Issue
Block a user