feat: add CTF swarm foundation - #1
Open
ryu7eroo wants to merge 64 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Introduces the initial “CTF Swarm” foundation package, including the core async scheduler orchestration, shared data models, and a basic verification boundary, along with a smoke test and updated project metadata/docs.
Changes:
- Added core orchestration (
Scheduler) with round progression, candidate verification, and global cancellation events. - Added foundational domain models (
Challenge,Evidence,Candidate,TaskState) plusAgentprotocol/context andBlackboard. - Added packaging/test scaffolding (
pyproject.toml,tests/test_scheduler.py) and replaced the README with CTF Swarm documentation.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
ctf_swarm/agent.py |
Defines agent protocol and the context passed into solver workers. |
ctf_swarm/blackboard.py |
Stores/merges evidence and derives “dead ends” across rounds. |
ctf_swarm/models.py |
Adds core data structures and enums for rounds/events/state. |
ctf_swarm/scheduler.py |
Implements async scheduling, verification, and global cancellation event emission. |
ctf_swarm/verifier.py |
Adds a minimal verification policy boundary for candidates. |
ctf_swarm/__init__.py |
Exposes the package’s main public symbols. |
tests/test_scheduler.py |
Adds a basic test for “first verified candidate wins + cancellation.” |
pyproject.toml |
Adds minimal project metadata and pytest config. |
README.md |
Documents the CTF Swarm architecture and dev workflow. |
Suppressed comments (3)
ctf_swarm/scheduler.py:38
- run_one is annotated as returning
Candidate | object | None, butAgent.solveis specified to returnCandidate | Evidence | None. Usingobjecthere defeats type checking and makes it easier for non-Evidence values to slip into Blackboard handling.
async def run_one(agent: Agent) -> Candidate | object | None:
ctf_swarm/scheduler.py:61
- Non-candidate results are passed directly to Blackboard.add_evidence, but Blackboard expects an Evidence instance. If an agent accidentally returns an unsupported non-None value, this will raise at runtime. Guard this with an Evidence type check (and optionally record a REJECTED event for unexpected return types).
elif result is not None:
board.add_evidence(result)
tests/test_scheduler.py:38
- Compare EventTypes directly rather than comparing
.valuestrings; this keeps the test resilient to enum value changes and makes failures clearer.
assert any(e.type.value == "global_cancel" for e in scheduler.events)
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
|
||
| from .agent import Agent, AgentContext | ||
| from .blackboard import Blackboard | ||
| from .models import Candidate, Challenge, EventType, Round, TaskState |
Comment on lines
+49
to
+51
| for task in asyncio.as_completed(tasks): | ||
| result = await task | ||
| if isinstance(result, Candidate): |
| from __future__ import annotations | ||
|
|
||
| from dataclasses import dataclass | ||
| from typing import Callable |
| @@ -0,0 +1,14 @@ | |||
| from __future__ import annotations | |||
|
|
|||
| from dataclasses import dataclass | |||
Comment on lines
+11
to
+13
| async def solve(self, context: AgentContext): | ||
| await asyncio.sleep(0.05) | ||
| return Evidence(self.id, context.challenge.id, "wrong path", failed_paths=("sql-union",)) |
| import asyncio | ||
|
|
||
| from ctf_swarm.agent import AgentContext | ||
| from ctf_swarm.models import Candidate, Challenge, Evidence |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.