Code Farm: per-plot auto-replant pause and crop-lock check; community sync and node work

Continuous Delivery could never be turned off once a crop was planted. Add a
one-shot per-plot "stop after harvest" flag (POST /game/plot/stop, Devii tool
game_plot_stop, game_plots.stop_after_harvest), cleared by the next plant,
autoreplant claim or Refactor. Autoreplant now also respects crop locks through
the shared _crop_lock predicate. Plan and measurements in happyplanting.md.

Also includes the pending community sync, node network and related work in the
tree; the full suite passed (4999) with all of it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-17 02:23:43 +02:00
co-authored by Claude Sonnet 5.5
parent ce899fc5e1
commit 02ab747cd0
203 changed files with 11624 additions and 301 deletions
@@ -135,3 +135,89 @@ def test_crawl_degrades_to_httpx_when_the_playwright_driver_cannot_start(monkeyp
)
assert len(outcome.pages) == 1
assert outcome.pages[0].source == "httpx"
REDDIT_URL = "https://www.reddit.com/r/python/comments/abc/post/"
REDDIT_HTML = "<html><head><title>A thread</title></head><body><p>" + "Real thread text from a donor. " * 30 + "</p></body></html>"
REDDIT_CANDIDATE = {"url": REDDIT_URL, "title": "t", "description": "", "content": "snippet " * 30}
def _patch_node_client(monkeypatch, handler):
import httpx
real = crawl_module.stealth.stealth_async_client
def factory(**kwargs):
kwargs.pop("transport", None)
return real(transport=httpx.MockTransport(handler), **kwargs)
monkeypatch.setattr(crawl_module.stealth, "stealth_async_client", factory)
def test_node_servable_is_exactly_the_node_allowlist():
assert crawl_module.node_servable(REDDIT_URL)
assert crawl_module.node_servable("https://redd.it/abc")
assert not crawl_module.node_servable("https://x.com/a/status/1")
assert not crawl_module.node_servable("https://evilreddit.com/")
assert not crawl_module.node_servable("https://reddit.com:22/")
def test_a_hostile_reddit_page_is_fetched_through_the_nodes_when_a_key_is_present(monkeypatch):
seen = []
def handler(request):
import httpx
seen.append((request.url.path, request.headers.get("authorization"), request.content.decode()))
return httpx.Response(200, json={"url": REDDIT_URL, "status": 200, "via": "tunnel", "text": REDDIT_HTML})
_patch_node_client(monkeypatch, handler)
page = run_async(crawl_module._resolve_candidate(REDDIT_CANDIDATE, 1, None, "key123"))
assert page.source == "node-tunnel" and page.title == "A thread" and "Real thread text" in page.text
assert seen[0][0] == "/nodes/internal/fetch" and seen[0][1] == "Bearer key123" and "reddit.com" in seen[0][2]
def test_without_a_key_or_when_the_nodes_refuse_the_snippet_is_used(monkeypatch):
def handler(request):
import httpx
return httpx.Response(503, json={"error": {"reason": "no_nodes"}})
_patch_node_client(monkeypatch, handler)
assert run_async(crawl_module._resolve_candidate(REDDIT_CANDIDATE, 1, None, "")).source == "search"
assert run_async(crawl_module._resolve_candidate(REDDIT_CANDIDATE, 1, None, "key")).source == "search"
def test_a_blocked_donor_answer_falls_back_to_the_snippet(monkeypatch):
def handler(request):
import httpx
return httpx.Response(200, json={"url": REDDIT_URL, "status": 403, "via": "fetch", "text": "blocked " * 100})
_patch_node_client(monkeypatch, handler)
assert run_async(crawl_module._resolve_candidate(REDDIT_CANDIDATE, 1, None, "key")).source == "search"
def test_other_hostile_hosts_never_reach_the_nodes(monkeypatch):
calls = []
def handler(request):
import httpx
calls.append(request.url)
return httpx.Response(200, json={})
_patch_node_client(monkeypatch, handler)
candidate = {"url": "https://x.com/a/status/1", "title": "t", "description": "", "content": "snippet " * 30}
assert run_async(crawl_module._resolve_candidate(candidate, 1, None, "key")).source == "search"
assert calls == []
def test_a_thin_node_page_is_rejected(monkeypatch):
def handler(request):
import httpx
return httpx.Response(200, json={"url": REDDIT_URL, "status": 200, "via": "fetch", "text": "<html><body>tiny</body></html>"})
_patch_node_client(monkeypatch, handler)
assert run_async(crawl_module.node_page(REDDIT_URL, 1, "key")) is None
@@ -21,7 +21,7 @@ def _patch_pipeline(monkeypatch, pages):
return [{"url": page.url, "title": page.title, "description": ""} for page in pages]
async def fake_crawl(
candidates, max_pages, emit, is_cached, should_stop, query="", depth=1, seen_hashes=None
candidates, max_pages, emit, is_cached, should_stop, query="", depth=1, seen_hashes=None, api_key=""
):
outcome = CrawlOutcome(seen_hashes=seen_hashes if seen_hashes is not None else set())
for page in pages[:max_pages]:
@@ -176,7 +176,7 @@ def test_worker_run_performs_refinement_round_when_budget_remains(monkeypatch):
return [{"url": refined_page.url, "title": refined_page.title, "description": ""}]
async def fake_crawl_refinement(
candidates, max_pages, emit, is_cached, should_stop, query="", depth=1, seen_hashes=None
candidates, max_pages, emit, is_cached, should_stop, query="", depth=1, seen_hashes=None, api_key=""
):
outcome = CrawlOutcome(seen_hashes=seen_hashes if seen_hashes is not None else set())
outcome.pages.append(refined_page)