Skip to content

akiiwa-games/AgentCompass / skills/dot-subagent

dot-subagent

Verified

Leaf-only runner for the local OpenAI Dot through dot2api. Use only after agent-compass has chosen Dot. Covers the runner, packets, code written and run on Dot's own computer, and how data reaches it (public re-fetch, text packets, the private GitHub repository) and how results come back. No routing and no spawning children.

scripts/test_parallel_fetch.py

View on GitHub
import http.server
import threading
import time
import types
import unittest
import urllib.error
from unittest import mock

import parallel_fetch


class Handler(http.server.BaseHTTPRequestHandler):
    flaky = {}
    active = peak = 0
    lock = threading.Lock()

    def log_message(self, *args):
        pass

    def do_GET(self):
        with Handler.lock:
            Handler.active += 1
            Handler.peak = max(Handler.peak, Handler.active)
        time.sleep(0.05)
        with Handler.lock:
            Handler.active -= 1
        if self.path == "/missing":
            self.send_error(404)
            return
        if self.path.startswith("/flaky"):
            seen = Handler.flaky.get(self.path, 0)
            Handler.flaky[self.path] = seen + 1
            if seen < 2:
                self.send_error(503)
                return
        body = self.path.encode()
        self.send_response(200)
        self.send_header("Content-Length", str(len(body)))
        self.end_headers()
        self.wfile.write(body)


class Server(http.server.ThreadingHTTPServer):
    # The default backlog of 5 is what a burst of back-to-back connections overflows on Windows, which answers with a refusal.
    request_queue_size = 128


class ParallelFetchTests(unittest.TestCase):
    def setUp(self):
        # Own server and counters per test: no test depends on a class-level server surviving the scheduler's ordering
        # (pytest-xdist may run the tests of one class on different workers, interleaved with other classes).
        # Binding and listening finish inside the constructor, so the port accepts connections before the first request.
        Handler.flaky = {}
        Handler.active = Handler.peak = 0
        self.server = Server(("127.0.0.1", 0), Handler)
        self.addCleanup(self.server.server_close)
        thread = threading.Thread(target=self.server.serve_forever, kwargs={"poll_interval": 0.01}, daemon=True)
        thread.start()
        self.addCleanup(thread.join)
        self.addCleanup(self.server.shutdown)
        self.base = f"http://127.0.0.1:{self.server.server_address[1]}"

    def no_pause_between_retries(self):
        # Only this module's retry pause is removed; time.sleep stays real for the server's handler threads.
        stub = types.SimpleNamespace(sleep=lambda seconds: None)
        patcher = mock.patch.object(parallel_fetch, "time", stub)
        patcher.start()
        self.addCleanup(patcher.stop)

    def test_downloads_overlap_and_each_url_keeps_its_own_bytes(self):
        urls = [f"{self.base}/f{i}" for i in range(16)]
        Handler.peak = 0
        many = parallel_fetch.fetch_all(urls, threads=8)
        self.assertEqual(many, {url: f'/f{i}'.encode() for i, url in enumerate(urls)})
        self.assertGreater(Handler.peak, 1)

    def test_a_404_is_none_and_a_flaky_server_is_retried(self):
        self.no_pause_between_retries()
        got = parallel_fetch.fetch_all([f"{self.base}/missing", f"{self.base}/flaky1"], threads=2)
        self.assertIsNone(got[f"{self.base}/missing"])
        self.assertEqual(got[f"{self.base}/flaky1"], b"/flaky1")
        self.assertEqual(Handler.flaky["/flaky1"], 3)

    def test_a_url_that_keeps_failing_raises_after_the_tries(self):
        self.no_pause_between_retries()
        Handler.flaky["/flaky9"] = -100
        with self.assertRaises(urllib.error.HTTPError):
            parallel_fetch.fetch_all([f"{self.base}/flaky9"], threads=1, tries=3)

    def test_duplicate_urls_are_fetched_once(self):
        url = f"{self.base}/dup"
        self.assertEqual(parallel_fetch.fetch_all([url, url, url], threads=4), {url: b"/dup"})


if __name__ == "__main__":
    unittest.main()
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall