ctfy.sdk.resources.competitions

client.competitions — discover competitions (list / get).

Acting within a competition — register, your team, invites, challenges, instances, submissions, standings — lives on the scoped handle client.competition(id) (ctfy.sdk.competition.Competition).

  1"""``client.competitions`` — discover competitions (list / get).
  2
  3Acting *within* a competition — register, your team, invites, challenges,
  4instances, submissions, standings — lives on the scoped handle
  5``client.competition(id)`` (:class:`ctfy.sdk.competition.Competition`).
  6"""
  7
  8from __future__ import annotations
  9
 10import builtins
 11from typing import Any
 12
 13from ctfy.sdk._helpers import PagedList, _extract_items, _raise_for_status
 14from ctfy.sdk.base import BaseHttpClient
 15from ctfy.server.models import (
 16    AgentActionsPage,
 17    AgentPulsePage,
 18    CapacityWatchResult,
 19    CompetitionAttachmentsResponse,
 20    CompetitionDetail,
 21    CompetitionEligibility,
 22    CompetitionExclusion,
 23    CompetitionInfo,
 24    CompetitionTopicInfo,
 25    CompetitionTopicsResponse,
 26    PublicRecap,
 27    ScoringChangeInfo,
 28    ScoringChangesResponse,
 29    VirtualGhostBoard,
 30)
 31
 32
 33class CompetitionsResource:
 34    """Browse competitions. To act within one, use ``client.competition(id)``."""
 35
 36    def __init__(self, http: BaseHttpClient) -> None:
 37        self._http = http
 38
 39    def list(
 40        self, phase: str = "", offset: int = 0, limit: int = 50, kind: str = ""
 41    ) -> PagedList[CompetitionInfo]:
 42        """Public competition list. ``phase`` ∈ ``"" | "upcoming" |
 43        "running" | "past"`` ("" = all). ``kind`` ∈ ``"" | "event" | "suite"``
 44        ("" = both): an *event* is a hosted contest with a window and
 45        registration, a *suite* a public benchmark set open at any time --
 46        to evaluate an agent, ask for ``kind="suite"`` (or
 47        ``client.suites.list()``). Start here, then scope into one with
 48        ``client.competition(comp.id)``."""
 49        params: dict[str, Any] = {"offset": offset, "limit": limit}
 50        if phase:
 51            params["phase"] = phase
 52        if kind:
 53            params["kind"] = kind
 54        resp = self._http.request("GET", "/competitions", params=params)
 55        _raise_for_status(resp)
 56        return _extract_items(resp.json(), CompetitionInfo)
 57
 58    def get(self, competition_id: str) -> CompetitionDetail:
 59        """Full competition detail including resolved challenge summaries
 60        (``.challenges``). Same as ``client.competition(id).detail()``."""
 61        resp = self._http.request("GET", f"/competitions/{competition_id}")
 62        _raise_for_status(resp)
 63        return CompetitionDetail.model_validate(resp.json())
 64
 65    def attachments(self, competition_id: str) -> CompetitionAttachmentsResponse:
 66        """The competition's rules / handbook / notice files, in display
 67        order and every language's (``locale`` ``""`` is for everyone).
 68        Read these before playing — they are the rules as the organiser
 69        published them. Fetch one with :meth:`download_attachment`."""
 70        resp = self._http.request("GET", f"/competitions/{competition_id}/attachments")
 71        _raise_for_status(resp)
 72        return CompetitionAttachmentsResponse.model_validate(resp.json())
 73
 74    def download_attachment(self, competition_id: str, attachment_id: str) -> bytes:
 75        """One competition file's raw bytes (id from :meth:`attachments`)."""
 76        # The platform may answer 302 to the file's CDN or presigned
 77        # object-store URL (#4201, as #3939); httpx drops the bearer on
 78        # the new origin.
 79        resp = self._http.request(
 80            "GET",
 81            f"/competitions/{competition_id}/attachments/{attachment_id}",
 82            follow_redirects=True,
 83        )
 84        _raise_for_status(resp)
 85        return resp.content
 86
 87    def topics(self, competition_id: str) -> CompetitionTopicsResponse:
 88        """The competition's released topics, in release order (#1965).
 89
 90        An organiser schedules each with a ``release_at`` and the clock
 91        releases it — nothing is pushed, so **poll this** (around the
 92        start of each authoring window) to learn the day's topic. For
 93        registered entrants: anybody else is ``403 not_registered``, and
 94        a competition you cannot see is ``404``."""
 95        resp = self._http.request("GET", f"/competitions/{competition_id}/topics")
 96        _raise_for_status(resp)
 97        return CompetitionTopicsResponse.model_validate(resp.json())
 98
 99    def topic(self, competition_id: str, topic_id: str) -> CompetitionTopicInfo:
100        """One released topic (id from :meth:`topics`); an unreleased one
101        is ``404 competition_topic_not_found``, like an unknown id."""
102        resp = self._http.request("GET", f"/competitions/{competition_id}/topics/{topic_id}")
103        _raise_for_status(resp)
104        return CompetitionTopicInfo.model_validate(resp.json())
105
106    def scoring_changes(self, competition_id: str) -> builtins.list[ScoringChangeInfo]:
107        """Every change to the competition's scoring rule made while it was
108        live, oldest first (#1965 H) — when, why, and the rule and params
109        before and after. The board is recomputed under the new rule as a
110        whole, so **poll this** beside the scoreboard: standings that moved
111        with no new solve moved because the rule did. Empty for an event
112        whose scoring never changed while live."""
113        resp = self._http.request("GET", f"/competitions/{competition_id}/scoring-changes")
114        _raise_for_status(resp)
115        return ScoringChangesResponse.model_validate(resp.json()).changes
116
117    def recap(self, competition_id: str) -> PublicRecap:
118        """The competition's published recap (#3023): reach and the contest,
119        as the public board shows them (frozen, anonymised). 404
120        ``recap_not_published`` until an organiser publishes it."""
121        resp = self._http.request("GET", f"/competitions/{competition_id}/recap")
122        _raise_for_status(resp)
123        return PublicRecap.model_validate(resp.json())
124
125    def eligibility(self, competition_id: str) -> CompetitionEligibility:
126        """Whether you may register, and what to do if not (#2184).
127
128        ``restricted`` is false for an ordinary competition. For one limited to
129        certain institutions, ``state`` is ``eligible`` (you hold a proved
130        address at an accepted domain), ``needs_verification`` (you hold one
131        but never proved it: ``pending_email``) or ``needs_email`` (you hold
132        none). ``exempt`` is an organiser's invitation. Gate on ``may_register``.
133        """
134        resp = self._http.request("GET", f"/competitions/{competition_id}/eligibility")
135        _raise_for_status(resp)
136        return CompetitionEligibility.model_validate(resp.json())
137
138    def watch_capacity(self, competition_id: str, *, on: bool = True) -> CapacityWatchResult:
139        """Ask to be told, once, when a place frees in a full competition (#2767).
140
141        ``on=False`` withdraws the request. Refused with ``409
142        registration_not_full`` when the competition has no cap or a free
143        place: register instead. The request is consumed when it is reported,
144        so asking again after a notice is a new request.
145        """
146        if on:
147            resp = self._http.request(
148                "PUT", f"/competitions/{competition_id}/registration-capacity/watch"
149            )
150        else:
151            resp = self._http.request(
152                "DELETE", f"/competitions/{competition_id}/registration-capacity/watch"
153            )
154        _raise_for_status(resp)
155        return CapacityWatchResult.model_validate(resp.json())
156
157    def exclusion(self, competition_id: str) -> CompetitionExclusion:
158        """Which other competitions this one is mutually exclusive with (#2301).
159
160        When ``exclusive`` is true, a person may hold a team in only one
161        competition of the group. ``peers`` are the ones you may open; the
162        rest are counted in ``hidden`` and never named. ``blocked`` is
163        ``holding`` (you already hold a team in ``blocked_by``) or
164        ``switch_closed`` (you left one after the group started) when
165        registering here would be refused right now, else ``None``.
166        """
167        resp = self._http.request("GET", f"/competitions/{competition_id}/exclusion")
168        _raise_for_status(resp)
169        return CompetitionExclusion.model_validate(resp.json())
170
171    def start_virtual(self, competition_id: str) -> CompetitionInfo:
172        """Replay a finished contest on your own clock.
173
174        Returns the *replay*, which is an ordinary competition you are
175        already registered in — so every other call takes its
176        ``.id`` unchanged: launch instances, submit answers, submit
177        patches, read its board.
178
179        **Idempotent.** Asking twice returns the replay you already
180        started rather than minting a second sitting, so a retry cannot
181        split one attempt across two competitions.
182
183        Refused (400) when a replay is not defined: the source has not
184        finished, has no window, is multi-session, never ran, or is
185        itself a replay. The error code says which.
186        """
187        resp = self._http.request("POST", f"/competitions/{competition_id}/virtual")
188        _raise_for_status(resp)
189        return CompetitionInfo.model_validate(resp.json())
190
191    def ghosts(self, competition_id: str) -> VirtualGhostBoard:
192        """The source contest's standings at the instant this replay has
193        reached, with you merged in and ranked among them.
194
195        Takes the **replay's** id, not the source's. At T+40 minutes
196        into your run you see the contest as it stood at T+40 minutes on
197        the day — which is what makes a replay a race rather than an
198        exercise, since a board holding only your own solves answers
199        nothing.
200
201        Refused (400 ``not_a_virtual_sitting``) on an ordinary
202        competition. A source that has since been deleted costs the
203        ghosts and nothing else: the reply comes back with no items and
204        the run itself keeps working.
205        """
206        resp = self._http.request("GET", f"/competitions/{competition_id}/ghosts")
207        _raise_for_status(resp)
208        return VirtualGhostBoard.model_validate(resp.json())
209
210    def agent_actions(self, competition_id: str) -> AgentActionsPage:
211        """One scrubbed line per agent saying what it is doing now.
212
213        :meth:`agent_pulse`'s sibling, and the whole difference is that
214        this one carries content. What makes that publishable is two
215        gates, neither of which stands in for the other:
216
217        * the line is a single tool call picked out of the newest
218          finished conversation, run through the platform's secret-shape
219          table and cut — so the round's minted flag and the untrusted
220          markup do not travel;
221        * a row exists only for an entrant whose **author** opted in
222          (``POST /eval/runs/{run_id}/wall``), which is the answer to
223          the one rule no scrubbing dissolves: the conversation belongs
224          to the person who ran it.
225
226        ⚠️ **An empty ``rows`` is four different things and the three
227        numbers beside it say which**: ``indexing: false`` is a
228        deployment with no transcript index, ``entrants: 0`` is nobody
229        having entered an agent, ``published: 0`` is nobody's author
230        having agreed, and all three set with no rows is everybody
231        having agreed and no call having finished yet.
232
233        ⚠️ **At most ``max_rows`` entrants are read**, because each one
234        costs an archived-transcript read; the reply publishes that
235        ceiling beside ``published`` so a truncated answer cannot read
236        as a complete one.
237
238        Refused (403 ``silent_standings``) on a silent competition, for
239        :meth:`agent_pulse`'s reason.
240
241        Wraps ``GET /competitions/{competition_id}/agent-actions``."""
242        resp = self._http.request("GET", f"/competitions/{competition_id}/agent-actions")
243        _raise_for_status(resp)
244        return AgentActionsPage.model_validate(resp.json())
245
246    def agent_pulse(self, competition_id: str, *, limit: int = 200) -> AgentPulsePage:
247        """What this event's agents have been asking a model, without it.
248
249        One lane per entrant, one beat per **finished** model call. The
250        gateway composes a record once, at completion — streamed
251        completions included — so no caller of this can see a
252        conversation in flight, whatever cadence they poll at.
253
254        ⚠️ **Carries no prompt and no completion, and cannot be made
255        to.** A relayed conversation holds the challenge's own minted
256        answer, which on an AWD gamebox is the round's flag, and its
257        prompt half is written by whoever is attacking the challenge —
258        so what travels is the shape of the traffic: how much each call
259        wrote, how long it took, and what went wrong. The bodies live
260        behind ``/admin/llm-calls/{id}`` and the run's own author-scoped
261        route, both of which rule on who may read them.
262
263        Empty means one of two opposite things and the reply says
264        which: ``indexing: false`` is a deployment that keeps no
265        transcript index at all.
266
267        Refused (403 ``silent_standings``) on a silent competition, like
268        the board — a lane per entrant saying who is still working is
269        the field's progress.
270        """
271        resp = self._http.request(
272            "GET",
273            f"/competitions/{competition_id}/agent-pulse",
274            params={"limit": limit},
275        )
276        _raise_for_status(resp)
277        return AgentPulsePage.model_validate(resp.json())
class CompetitionsResource:
 34class CompetitionsResource:
 35    """Browse competitions. To act within one, use ``client.competition(id)``."""
 36
 37    def __init__(self, http: BaseHttpClient) -> None:
 38        self._http = http
 39
 40    def list(
 41        self, phase: str = "", offset: int = 0, limit: int = 50, kind: str = ""
 42    ) -> PagedList[CompetitionInfo]:
 43        """Public competition list. ``phase`` ∈ ``"" | "upcoming" |
 44        "running" | "past"`` ("" = all). ``kind`` ∈ ``"" | "event" | "suite"``
 45        ("" = both): an *event* is a hosted contest with a window and
 46        registration, a *suite* a public benchmark set open at any time --
 47        to evaluate an agent, ask for ``kind="suite"`` (or
 48        ``client.suites.list()``). Start here, then scope into one with
 49        ``client.competition(comp.id)``."""
 50        params: dict[str, Any] = {"offset": offset, "limit": limit}
 51        if phase:
 52            params["phase"] = phase
 53        if kind:
 54            params["kind"] = kind
 55        resp = self._http.request("GET", "/competitions", params=params)
 56        _raise_for_status(resp)
 57        return _extract_items(resp.json(), CompetitionInfo)
 58
 59    def get(self, competition_id: str) -> CompetitionDetail:
 60        """Full competition detail including resolved challenge summaries
 61        (``.challenges``). Same as ``client.competition(id).detail()``."""
 62        resp = self._http.request("GET", f"/competitions/{competition_id}")
 63        _raise_for_status(resp)
 64        return CompetitionDetail.model_validate(resp.json())
 65
 66    def attachments(self, competition_id: str) -> CompetitionAttachmentsResponse:
 67        """The competition's rules / handbook / notice files, in display
 68        order and every language's (``locale`` ``""`` is for everyone).
 69        Read these before playing — they are the rules as the organiser
 70        published them. Fetch one with :meth:`download_attachment`."""
 71        resp = self._http.request("GET", f"/competitions/{competition_id}/attachments")
 72        _raise_for_status(resp)
 73        return CompetitionAttachmentsResponse.model_validate(resp.json())
 74
 75    def download_attachment(self, competition_id: str, attachment_id: str) -> bytes:
 76        """One competition file's raw bytes (id from :meth:`attachments`)."""
 77        # The platform may answer 302 to the file's CDN or presigned
 78        # object-store URL (#4201, as #3939); httpx drops the bearer on
 79        # the new origin.
 80        resp = self._http.request(
 81            "GET",
 82            f"/competitions/{competition_id}/attachments/{attachment_id}",
 83            follow_redirects=True,
 84        )
 85        _raise_for_status(resp)
 86        return resp.content
 87
 88    def topics(self, competition_id: str) -> CompetitionTopicsResponse:
 89        """The competition's released topics, in release order (#1965).
 90
 91        An organiser schedules each with a ``release_at`` and the clock
 92        releases it — nothing is pushed, so **poll this** (around the
 93        start of each authoring window) to learn the day's topic. For
 94        registered entrants: anybody else is ``403 not_registered``, and
 95        a competition you cannot see is ``404``."""
 96        resp = self._http.request("GET", f"/competitions/{competition_id}/topics")
 97        _raise_for_status(resp)
 98        return CompetitionTopicsResponse.model_validate(resp.json())
 99
100    def topic(self, competition_id: str, topic_id: str) -> CompetitionTopicInfo:
101        """One released topic (id from :meth:`topics`); an unreleased one
102        is ``404 competition_topic_not_found``, like an unknown id."""
103        resp = self._http.request("GET", f"/competitions/{competition_id}/topics/{topic_id}")
104        _raise_for_status(resp)
105        return CompetitionTopicInfo.model_validate(resp.json())
106
107    def scoring_changes(self, competition_id: str) -> builtins.list[ScoringChangeInfo]:
108        """Every change to the competition's scoring rule made while it was
109        live, oldest first (#1965 H) — when, why, and the rule and params
110        before and after. The board is recomputed under the new rule as a
111        whole, so **poll this** beside the scoreboard: standings that moved
112        with no new solve moved because the rule did. Empty for an event
113        whose scoring never changed while live."""
114        resp = self._http.request("GET", f"/competitions/{competition_id}/scoring-changes")
115        _raise_for_status(resp)
116        return ScoringChangesResponse.model_validate(resp.json()).changes
117
118    def recap(self, competition_id: str) -> PublicRecap:
119        """The competition's published recap (#3023): reach and the contest,
120        as the public board shows them (frozen, anonymised). 404
121        ``recap_not_published`` until an organiser publishes it."""
122        resp = self._http.request("GET", f"/competitions/{competition_id}/recap")
123        _raise_for_status(resp)
124        return PublicRecap.model_validate(resp.json())
125
126    def eligibility(self, competition_id: str) -> CompetitionEligibility:
127        """Whether you may register, and what to do if not (#2184).
128
129        ``restricted`` is false for an ordinary competition. For one limited to
130        certain institutions, ``state`` is ``eligible`` (you hold a proved
131        address at an accepted domain), ``needs_verification`` (you hold one
132        but never proved it: ``pending_email``) or ``needs_email`` (you hold
133        none). ``exempt`` is an organiser's invitation. Gate on ``may_register``.
134        """
135        resp = self._http.request("GET", f"/competitions/{competition_id}/eligibility")
136        _raise_for_status(resp)
137        return CompetitionEligibility.model_validate(resp.json())
138
139    def watch_capacity(self, competition_id: str, *, on: bool = True) -> CapacityWatchResult:
140        """Ask to be told, once, when a place frees in a full competition (#2767).
141
142        ``on=False`` withdraws the request. Refused with ``409
143        registration_not_full`` when the competition has no cap or a free
144        place: register instead. The request is consumed when it is reported,
145        so asking again after a notice is a new request.
146        """
147        if on:
148            resp = self._http.request(
149                "PUT", f"/competitions/{competition_id}/registration-capacity/watch"
150            )
151        else:
152            resp = self._http.request(
153                "DELETE", f"/competitions/{competition_id}/registration-capacity/watch"
154            )
155        _raise_for_status(resp)
156        return CapacityWatchResult.model_validate(resp.json())
157
158    def exclusion(self, competition_id: str) -> CompetitionExclusion:
159        """Which other competitions this one is mutually exclusive with (#2301).
160
161        When ``exclusive`` is true, a person may hold a team in only one
162        competition of the group. ``peers`` are the ones you may open; the
163        rest are counted in ``hidden`` and never named. ``blocked`` is
164        ``holding`` (you already hold a team in ``blocked_by``) or
165        ``switch_closed`` (you left one after the group started) when
166        registering here would be refused right now, else ``None``.
167        """
168        resp = self._http.request("GET", f"/competitions/{competition_id}/exclusion")
169        _raise_for_status(resp)
170        return CompetitionExclusion.model_validate(resp.json())
171
172    def start_virtual(self, competition_id: str) -> CompetitionInfo:
173        """Replay a finished contest on your own clock.
174
175        Returns the *replay*, which is an ordinary competition you are
176        already registered in — so every other call takes its
177        ``.id`` unchanged: launch instances, submit answers, submit
178        patches, read its board.
179
180        **Idempotent.** Asking twice returns the replay you already
181        started rather than minting a second sitting, so a retry cannot
182        split one attempt across two competitions.
183
184        Refused (400) when a replay is not defined: the source has not
185        finished, has no window, is multi-session, never ran, or is
186        itself a replay. The error code says which.
187        """
188        resp = self._http.request("POST", f"/competitions/{competition_id}/virtual")
189        _raise_for_status(resp)
190        return CompetitionInfo.model_validate(resp.json())
191
192    def ghosts(self, competition_id: str) -> VirtualGhostBoard:
193        """The source contest's standings at the instant this replay has
194        reached, with you merged in and ranked among them.
195
196        Takes the **replay's** id, not the source's. At T+40 minutes
197        into your run you see the contest as it stood at T+40 minutes on
198        the day — which is what makes a replay a race rather than an
199        exercise, since a board holding only your own solves answers
200        nothing.
201
202        Refused (400 ``not_a_virtual_sitting``) on an ordinary
203        competition. A source that has since been deleted costs the
204        ghosts and nothing else: the reply comes back with no items and
205        the run itself keeps working.
206        """
207        resp = self._http.request("GET", f"/competitions/{competition_id}/ghosts")
208        _raise_for_status(resp)
209        return VirtualGhostBoard.model_validate(resp.json())
210
211    def agent_actions(self, competition_id: str) -> AgentActionsPage:
212        """One scrubbed line per agent saying what it is doing now.
213
214        :meth:`agent_pulse`'s sibling, and the whole difference is that
215        this one carries content. What makes that publishable is two
216        gates, neither of which stands in for the other:
217
218        * the line is a single tool call picked out of the newest
219          finished conversation, run through the platform's secret-shape
220          table and cut — so the round's minted flag and the untrusted
221          markup do not travel;
222        * a row exists only for an entrant whose **author** opted in
223          (``POST /eval/runs/{run_id}/wall``), which is the answer to
224          the one rule no scrubbing dissolves: the conversation belongs
225          to the person who ran it.
226
227        ⚠️ **An empty ``rows`` is four different things and the three
228        numbers beside it say which**: ``indexing: false`` is a
229        deployment with no transcript index, ``entrants: 0`` is nobody
230        having entered an agent, ``published: 0`` is nobody's author
231        having agreed, and all three set with no rows is everybody
232        having agreed and no call having finished yet.
233
234        ⚠️ **At most ``max_rows`` entrants are read**, because each one
235        costs an archived-transcript read; the reply publishes that
236        ceiling beside ``published`` so a truncated answer cannot read
237        as a complete one.
238
239        Refused (403 ``silent_standings``) on a silent competition, for
240        :meth:`agent_pulse`'s reason.
241
242        Wraps ``GET /competitions/{competition_id}/agent-actions``."""
243        resp = self._http.request("GET", f"/competitions/{competition_id}/agent-actions")
244        _raise_for_status(resp)
245        return AgentActionsPage.model_validate(resp.json())
246
247    def agent_pulse(self, competition_id: str, *, limit: int = 200) -> AgentPulsePage:
248        """What this event's agents have been asking a model, without it.
249
250        One lane per entrant, one beat per **finished** model call. The
251        gateway composes a record once, at completion — streamed
252        completions included — so no caller of this can see a
253        conversation in flight, whatever cadence they poll at.
254
255        ⚠️ **Carries no prompt and no completion, and cannot be made
256        to.** A relayed conversation holds the challenge's own minted
257        answer, which on an AWD gamebox is the round's flag, and its
258        prompt half is written by whoever is attacking the challenge —
259        so what travels is the shape of the traffic: how much each call
260        wrote, how long it took, and what went wrong. The bodies live
261        behind ``/admin/llm-calls/{id}`` and the run's own author-scoped
262        route, both of which rule on who may read them.
263
264        Empty means one of two opposite things and the reply says
265        which: ``indexing: false`` is a deployment that keeps no
266        transcript index at all.
267
268        Refused (403 ``silent_standings``) on a silent competition, like
269        the board — a lane per entrant saying who is still working is
270        the field's progress.
271        """
272        resp = self._http.request(
273            "GET",
274            f"/competitions/{competition_id}/agent-pulse",
275            params={"limit": limit},
276        )
277        _raise_for_status(resp)
278        return AgentPulsePage.model_validate(resp.json())

Browse competitions. To act within one, use client.competition(id).

CompetitionsResource(http: ctfy.sdk.base.BaseHttpClient)
37    def __init__(self, http: BaseHttpClient) -> None:
38        self._http = http
def list( self, phase: str = '', offset: int = 0, limit: int = 50, kind: str = '') -> ctfy.sdk._helpers.PagedList[ctfy.server.models.CompetitionInfo]:
40    def list(
41        self, phase: str = "", offset: int = 0, limit: int = 50, kind: str = ""
42    ) -> PagedList[CompetitionInfo]:
43        """Public competition list. ``phase`` ∈ ``"" | "upcoming" |
44        "running" | "past"`` ("" = all). ``kind`` ∈ ``"" | "event" | "suite"``
45        ("" = both): an *event* is a hosted contest with a window and
46        registration, a *suite* a public benchmark set open at any time --
47        to evaluate an agent, ask for ``kind="suite"`` (or
48        ``client.suites.list()``). Start here, then scope into one with
49        ``client.competition(comp.id)``."""
50        params: dict[str, Any] = {"offset": offset, "limit": limit}
51        if phase:
52            params["phase"] = phase
53        if kind:
54            params["kind"] = kind
55        resp = self._http.request("GET", "/competitions", params=params)
56        _raise_for_status(resp)
57        return _extract_items(resp.json(), CompetitionInfo)

Public competition list. phase ∈ "" | "upcoming" | "running" | "past" ("" = all). kind ∈ "" | "event" | "suite" ("" = both): an event is a hosted contest with a window and registration, a suite a public benchmark set open at any time -- to evaluate an agent, ask for kind="suite" (or client.suites.list()). Start here, then scope into one with client.competition(comp.id).

def get( self, competition_id: str) -> ctfy.server.models.CompetitionDetail:
59    def get(self, competition_id: str) -> CompetitionDetail:
60        """Full competition detail including resolved challenge summaries
61        (``.challenges``). Same as ``client.competition(id).detail()``."""
62        resp = self._http.request("GET", f"/competitions/{competition_id}")
63        _raise_for_status(resp)
64        return CompetitionDetail.model_validate(resp.json())

Full competition detail including resolved challenge summaries (ctfy.sdk.resources.challenges). Same as client.competition(id).detail().

def attachments( self, competition_id: str) -> ctfy.server.models.CompetitionAttachmentsResponse:
66    def attachments(self, competition_id: str) -> CompetitionAttachmentsResponse:
67        """The competition's rules / handbook / notice files, in display
68        order and every language's (``locale`` ``""`` is for everyone).
69        Read these before playing — they are the rules as the organiser
70        published them. Fetch one with :meth:`download_attachment`."""
71        resp = self._http.request("GET", f"/competitions/{competition_id}/attachments")
72        _raise_for_status(resp)
73        return CompetitionAttachmentsResponse.model_validate(resp.json())

The competition's rules / handbook / notice files, in display order and every language's (locale "" is for everyone). Read these before playing — they are the rules as the organiser published them. Fetch one with download_attachment().

def download_attachment(self, competition_id: str, attachment_id: str) -> bytes:
75    def download_attachment(self, competition_id: str, attachment_id: str) -> bytes:
76        """One competition file's raw bytes (id from :meth:`attachments`)."""
77        # The platform may answer 302 to the file's CDN or presigned
78        # object-store URL (#4201, as #3939); httpx drops the bearer on
79        # the new origin.
80        resp = self._http.request(
81            "GET",
82            f"/competitions/{competition_id}/attachments/{attachment_id}",
83            follow_redirects=True,
84        )
85        _raise_for_status(resp)
86        return resp.content

One competition file's raw bytes (id from attachments()).

def topics( self, competition_id: str) -> ctfy.server.models.CompetitionTopicsResponse:
88    def topics(self, competition_id: str) -> CompetitionTopicsResponse:
89        """The competition's released topics, in release order (#1965).
90
91        An organiser schedules each with a ``release_at`` and the clock
92        releases it — nothing is pushed, so **poll this** (around the
93        start of each authoring window) to learn the day's topic. For
94        registered entrants: anybody else is ``403 not_registered``, and
95        a competition you cannot see is ``404``."""
96        resp = self._http.request("GET", f"/competitions/{competition_id}/topics")
97        _raise_for_status(resp)
98        return CompetitionTopicsResponse.model_validate(resp.json())

The competition's released topics, in release order (#1965).

An organiser schedules each with a release_at and the clock releases it — nothing is pushed, so poll this (around the start of each authoring window) to learn the day's topic. For registered entrants: anybody else is 403 not_registered, and a competition you cannot see is 404.

def topic( self, competition_id: str, topic_id: str) -> ctfy.server.models.CompetitionTopicInfo:
100    def topic(self, competition_id: str, topic_id: str) -> CompetitionTopicInfo:
101        """One released topic (id from :meth:`topics`); an unreleased one
102        is ``404 competition_topic_not_found``, like an unknown id."""
103        resp = self._http.request("GET", f"/competitions/{competition_id}/topics/{topic_id}")
104        _raise_for_status(resp)
105        return CompetitionTopicInfo.model_validate(resp.json())

One released topic (id from topics()); an unreleased one is 404 competition_topic_not_found, like an unknown id.

def scoring_changes( self, competition_id: str) -> list[ctfy.server.models.ScoringChangeInfo]:
107    def scoring_changes(self, competition_id: str) -> builtins.list[ScoringChangeInfo]:
108        """Every change to the competition's scoring rule made while it was
109        live, oldest first (#1965 H) — when, why, and the rule and params
110        before and after. The board is recomputed under the new rule as a
111        whole, so **poll this** beside the scoreboard: standings that moved
112        with no new solve moved because the rule did. Empty for an event
113        whose scoring never changed while live."""
114        resp = self._http.request("GET", f"/competitions/{competition_id}/scoring-changes")
115        _raise_for_status(resp)
116        return ScoringChangesResponse.model_validate(resp.json()).changes

Every change to the competition's scoring rule made while it was live, oldest first (#1965 H) — when, why, and the rule and params before and after. The board is recomputed under the new rule as a whole, so poll this beside the scoreboard: standings that moved with no new solve moved because the rule did. Empty for an event whose scoring never changed while live.

def recap(self, competition_id: str) -> ctfy.core.recap.PublicRecap:
118    def recap(self, competition_id: str) -> PublicRecap:
119        """The competition's published recap (#3023): reach and the contest,
120        as the public board shows them (frozen, anonymised). 404
121        ``recap_not_published`` until an organiser publishes it."""
122        resp = self._http.request("GET", f"/competitions/{competition_id}/recap")
123        _raise_for_status(resp)
124        return PublicRecap.model_validate(resp.json())

The competition's published recap (#3023): reach and the contest, as the public board shows them (frozen, anonymised). 404 recap_not_published until an organiser publishes it.

def eligibility( self, competition_id: str) -> ctfy.server.models.CompetitionEligibility:
126    def eligibility(self, competition_id: str) -> CompetitionEligibility:
127        """Whether you may register, and what to do if not (#2184).
128
129        ``restricted`` is false for an ordinary competition. For one limited to
130        certain institutions, ``state`` is ``eligible`` (you hold a proved
131        address at an accepted domain), ``needs_verification`` (you hold one
132        but never proved it: ``pending_email``) or ``needs_email`` (you hold
133        none). ``exempt`` is an organiser's invitation. Gate on ``may_register``.
134        """
135        resp = self._http.request("GET", f"/competitions/{competition_id}/eligibility")
136        _raise_for_status(resp)
137        return CompetitionEligibility.model_validate(resp.json())

Whether you may register, and what to do if not (#2184).

restricted is false for an ordinary competition. For one limited to certain institutions, state is eligible (you hold a proved address at an accepted domain), needs_verification (you hold one but never proved it: pending_email) or needs_email (you hold none). exempt is an organiser's invitation. Gate on may_register.

def watch_capacity( self, competition_id: str, *, on: bool = True) -> ctfy.server.models.CapacityWatchResult:
139    def watch_capacity(self, competition_id: str, *, on: bool = True) -> CapacityWatchResult:
140        """Ask to be told, once, when a place frees in a full competition (#2767).
141
142        ``on=False`` withdraws the request. Refused with ``409
143        registration_not_full`` when the competition has no cap or a free
144        place: register instead. The request is consumed when it is reported,
145        so asking again after a notice is a new request.
146        """
147        if on:
148            resp = self._http.request(
149                "PUT", f"/competitions/{competition_id}/registration-capacity/watch"
150            )
151        else:
152            resp = self._http.request(
153                "DELETE", f"/competitions/{competition_id}/registration-capacity/watch"
154            )
155        _raise_for_status(resp)
156        return CapacityWatchResult.model_validate(resp.json())

Ask to be told, once, when a place frees in a full competition (#2767).

on=False withdraws the request. Refused with 409 registration_not_full when the competition has no cap or a free place: register instead. The request is consumed when it is reported, so asking again after a notice is a new request.

def exclusion( self, competition_id: str) -> ctfy.server.models.CompetitionExclusion:
158    def exclusion(self, competition_id: str) -> CompetitionExclusion:
159        """Which other competitions this one is mutually exclusive with (#2301).
160
161        When ``exclusive`` is true, a person may hold a team in only one
162        competition of the group. ``peers`` are the ones you may open; the
163        rest are counted in ``hidden`` and never named. ``blocked`` is
164        ``holding`` (you already hold a team in ``blocked_by``) or
165        ``switch_closed`` (you left one after the group started) when
166        registering here would be refused right now, else ``None``.
167        """
168        resp = self._http.request("GET", f"/competitions/{competition_id}/exclusion")
169        _raise_for_status(resp)
170        return CompetitionExclusion.model_validate(resp.json())

Which other competitions this one is mutually exclusive with (#2301).

When exclusive is true, a person may hold a team in only one competition of the group. peers are the ones you may open; the rest are counted in hidden and never named. blocked is holding (you already hold a team in blocked_by) or switch_closed (you left one after the group started) when registering here would be refused right now, else None.

def start_virtual( self, competition_id: str) -> ctfy.server.models.CompetitionInfo:
172    def start_virtual(self, competition_id: str) -> CompetitionInfo:
173        """Replay a finished contest on your own clock.
174
175        Returns the *replay*, which is an ordinary competition you are
176        already registered in — so every other call takes its
177        ``.id`` unchanged: launch instances, submit answers, submit
178        patches, read its board.
179
180        **Idempotent.** Asking twice returns the replay you already
181        started rather than minting a second sitting, so a retry cannot
182        split one attempt across two competitions.
183
184        Refused (400) when a replay is not defined: the source has not
185        finished, has no window, is multi-session, never ran, or is
186        itself a replay. The error code says which.
187        """
188        resp = self._http.request("POST", f"/competitions/{competition_id}/virtual")
189        _raise_for_status(resp)
190        return CompetitionInfo.model_validate(resp.json())

Replay a finished contest on your own clock.

Returns the replay, which is an ordinary competition you are already registered in — so every other call takes its .id unchanged: launch instances, submit answers, submit patches, read its board.

Idempotent. Asking twice returns the replay you already started rather than minting a second sitting, so a retry cannot split one attempt across two competitions.

Refused (400) when a replay is not defined: the source has not finished, has no window, is multi-session, never ran, or is itself a replay. The error code says which.

def ghosts( self, competition_id: str) -> ctfy.server.models.VirtualGhostBoard:
192    def ghosts(self, competition_id: str) -> VirtualGhostBoard:
193        """The source contest's standings at the instant this replay has
194        reached, with you merged in and ranked among them.
195
196        Takes the **replay's** id, not the source's. At T+40 minutes
197        into your run you see the contest as it stood at T+40 minutes on
198        the day — which is what makes a replay a race rather than an
199        exercise, since a board holding only your own solves answers
200        nothing.
201
202        Refused (400 ``not_a_virtual_sitting``) on an ordinary
203        competition. A source that has since been deleted costs the
204        ghosts and nothing else: the reply comes back with no items and
205        the run itself keeps working.
206        """
207        resp = self._http.request("GET", f"/competitions/{competition_id}/ghosts")
208        _raise_for_status(resp)
209        return VirtualGhostBoard.model_validate(resp.json())

The source contest's standings at the instant this replay has reached, with you merged in and ranked among them.

Takes the replay's id, not the source's. At T+40 minutes into your run you see the contest as it stood at T+40 minutes on the day — which is what makes a replay a race rather than an exercise, since a board holding only your own solves answers nothing.

Refused (400 not_a_virtual_sitting) on an ordinary competition. A source that has since been deleted costs the ghosts and nothing else: the reply comes back with no items and the run itself keeps working.

def agent_actions(self, competition_id: str) -> ctfy.server.models.AgentActionsPage:
211    def agent_actions(self, competition_id: str) -> AgentActionsPage:
212        """One scrubbed line per agent saying what it is doing now.
213
214        :meth:`agent_pulse`'s sibling, and the whole difference is that
215        this one carries content. What makes that publishable is two
216        gates, neither of which stands in for the other:
217
218        * the line is a single tool call picked out of the newest
219          finished conversation, run through the platform's secret-shape
220          table and cut — so the round's minted flag and the untrusted
221          markup do not travel;
222        * a row exists only for an entrant whose **author** opted in
223          (``POST /eval/runs/{run_id}/wall``), which is the answer to
224          the one rule no scrubbing dissolves: the conversation belongs
225          to the person who ran it.
226
227        ⚠️ **An empty ``rows`` is four different things and the three
228        numbers beside it say which**: ``indexing: false`` is a
229        deployment with no transcript index, ``entrants: 0`` is nobody
230        having entered an agent, ``published: 0`` is nobody's author
231        having agreed, and all three set with no rows is everybody
232        having agreed and no call having finished yet.
233
234        ⚠️ **At most ``max_rows`` entrants are read**, because each one
235        costs an archived-transcript read; the reply publishes that
236        ceiling beside ``published`` so a truncated answer cannot read
237        as a complete one.
238
239        Refused (403 ``silent_standings``) on a silent competition, for
240        :meth:`agent_pulse`'s reason.
241
242        Wraps ``GET /competitions/{competition_id}/agent-actions``."""
243        resp = self._http.request("GET", f"/competitions/{competition_id}/agent-actions")
244        _raise_for_status(resp)
245        return AgentActionsPage.model_validate(resp.json())

One scrubbed line per agent saying what it is doing now.

agent_pulse()'s sibling, and the whole difference is that this one carries content. What makes that publishable is two gates, neither of which stands in for the other:

  • the line is a single tool call picked out of the newest finished conversation, run through the platform's secret-shape table and cut — so the round's minted flag and the untrusted markup do not travel;
  • a row exists only for an entrant whose author opted in (POST /eval/runs/{run_id}/wall), which is the answer to the one rule no scrubbing dissolves: the conversation belongs to the person who ran it.

⚠️ An empty rows is four different things and the three numbers beside it say which: indexing: false is a deployment with no transcript index, entrants: 0 is nobody having entered an agent, published: 0 is nobody's author having agreed, and all three set with no rows is everybody having agreed and no call having finished yet.

⚠️ At most max_rows entrants are read, because each one costs an archived-transcript read; the reply publishes that ceiling beside published so a truncated answer cannot read as a complete one.

Refused (403 silent_standings) on a silent competition, for agent_pulse()'s reason.

Wraps GET /competitions/{competition_id}/agent-actions.

def agent_pulse( self, competition_id: str, *, limit: int = 200) -> ctfy.server.models.AgentPulsePage:
247    def agent_pulse(self, competition_id: str, *, limit: int = 200) -> AgentPulsePage:
248        """What this event's agents have been asking a model, without it.
249
250        One lane per entrant, one beat per **finished** model call. The
251        gateway composes a record once, at completion — streamed
252        completions included — so no caller of this can see a
253        conversation in flight, whatever cadence they poll at.
254
255        ⚠️ **Carries no prompt and no completion, and cannot be made
256        to.** A relayed conversation holds the challenge's own minted
257        answer, which on an AWD gamebox is the round's flag, and its
258        prompt half is written by whoever is attacking the challenge —
259        so what travels is the shape of the traffic: how much each call
260        wrote, how long it took, and what went wrong. The bodies live
261        behind ``/admin/llm-calls/{id}`` and the run's own author-scoped
262        route, both of which rule on who may read them.
263
264        Empty means one of two opposite things and the reply says
265        which: ``indexing: false`` is a deployment that keeps no
266        transcript index at all.
267
268        Refused (403 ``silent_standings``) on a silent competition, like
269        the board — a lane per entrant saying who is still working is
270        the field's progress.
271        """
272        resp = self._http.request(
273            "GET",
274            f"/competitions/{competition_id}/agent-pulse",
275            params={"limit": limit},
276        )
277        _raise_for_status(resp)
278        return AgentPulsePage.model_validate(resp.json())

What this event's agents have been asking a model, without it.

One lane per entrant, one beat per finished model call. The gateway composes a record once, at completion — streamed completions included — so no caller of this can see a conversation in flight, whatever cadence they poll at.

⚠️ Carries no prompt and no completion, and cannot be made to. A relayed conversation holds the challenge's own minted answer, which on an AWD gamebox is the round's flag, and its prompt half is written by whoever is attacking the challenge — so what travels is the shape of the traffic: how much each call wrote, how long it took, and what went wrong. The bodies live behind /admin/llm-calls/{id} and the run's own author-scoped route, both of which rule on who may read them.

Empty means one of two opposite things and the reply says which: indexing: false is a deployment that keeps no transcript index at all.

Refused (403 silent_standings) on a silent competition, like the board — a lane per entrant saying who is still working is the field's progress.