Code Farm: per-plot auto-replant pause and crop-lock check; community sync and node work
DevPlace CI / test (push) Failing after 44m45s

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
+62
View File
@@ -392,3 +392,65 @@ def test_recent_devices_is_capped_and_excludes_deleted(local_db):
assert len(store.recent_devices(10_000)) <= store.ADMIN_LIST_LIMIT
store.revoke_device(row["uid"], owner)
assert row["uid"] not in {item["uid"] for item in store.recent_devices(store.ADMIN_LIST_LIMIT)}
def test_touch_devices_updates_only_the_given_devices_in_one_statement(owner):
first, _ = store.create_device(owner, "a", "native")
second, _ = store.create_device(owner, "b", "native")
assert store.touch_devices([first["uid"]]) == 1
assert store.get_device(first["uid"])["last_seen_at"]
assert not store.get_device(second["uid"]).get("last_seen_at")
assert store.touch_devices([]) == 0
many = [generate_uid() for _ in range(store.BATCH_SIZE + 5)]
assert store.touch_devices(many) == 0
def test_class_override_round_trip(owner):
device, _ = store.create_device(owner, "a", "native")
assert store.set_class_override(device["uid"], "allow")
assert store.get_device(device["uid"])["class_override"] == "allow"
assert store.set_class_override(device["uid"], "")
assert not store.get_device(device["uid"])["class_override"]
assert not store.set_class_override(generate_uid(), "allow")
def test_connection_records_country_asn_and_class(owner):
device, _ = store.create_device(owner, "a", "native")
store.record_device_connection(device["uid"], platform="linux/amd64", country="nl", asn="3320", asn_class="residential")
row = store.get_device(device["uid"])
assert (row["country"], row["asn"], row["asn_class"]) == ("NL", "3320", "residential")
def test_counters_accumulate_and_ignore_empty_or_non_positive(local_db):
name = f"test_counter_{generate_uid()[:8]}"
assert store.flush_counters({}) == 0
assert store.flush_counters({name: 0}) == 0
assert store.flush_counters({name: 3}) == 1
assert store.flush_counters({name: 4}) == 1
assert store.lifetime_counters(name)[name] == 7
def test_lifetime_prefix_is_a_literal_prefix(local_db):
store.flush_counters({"outcome:reddit:residential:ok": 1, "outcomeXreddit:residential:ok": 1})
found = store.lifetime_counters("outcome:")
assert "outcome:reddit:residential:ok" in found and "outcomeXreddit:residential:ok" not in found
assert store.lifetime_counters("100%") == {}
def test_circuit_snapshots_replace_each_other_and_are_capped(local_db):
rows = [{"key": f"destination:d{index}", "failures": 5, "state": "open", "opened_at": 1.5} for index in range(LIMITS.circuit_snapshot_max + 20)]
assert store.save_circuits(rows) == LIMITS.circuit_snapshot_max
assert len(store.load_circuits()) == LIMITS.circuit_snapshot_max
assert store.save_circuits([]) == 0
assert store.load_circuits() == []
def test_the_request_queue_cap_counts_shadows_too(local_db):
get_table("node_requests").delete()
try:
for index in range(LIMITS.max_queue_depth):
store.enqueue_request("user", "c", f"https://reddit.com/{index}", "GET", "reddit", "any")
with pytest.raises(store.QueueFull):
store.enqueue_request("shadow", "x", "https://reddit.com/z", "GET", "reddit", "fetch", shadow_of="u")
finally:
get_table("node_requests").delete()