Repository navigation
feat(github): the github session reads rest listings page by page, following rel=next and failing closed on a page that is no list - #1662
Merged
Conversation
…llowing rel=next and failing closed on a page that is no list GitHubSession.paginate(path, *, iterable_key=None) is a lazy, synchronous iterator over a REST listing's items. Each page is one call through the session's portal, made only when the consumer has read the items before it, so a consumer that stops early sends no further request. Pages follow the rel="next" URL gidgethub reads from each answer's Link header, by page number or by cursor, and pass through the same pacing, ledger, retries, origin hook and error classes as rest(), so a Link to another origin is refused before it is sent. A page must be a JSON array, or an object holding one under iterable_key (check_runs, workflow_runs, items). Anything else, such as an HTML page, an error object or a missing body, raises GitHubUnreadError naming the endpoint, the page and the type that came back, and a truncated page raises the classifier's GitHubUnreadError, which now names the page of a listing. An empty array or a page without a next link ends the listing. gidgethub's getiter is not used, since it would read a string's characters or an object's keys as items (#1034's rule). _fetch_issues_rest and _resolve_milestone_number read through paginate() instead of gh api --paginate, with their queries built by urlencode, stop reading at the limit or the matching title, and fail closed; _parse_milestones_response is gone. Their tests run over the github_api fake. ADR 0006 and the #983 task file describe the pagination. Part of #983
…nated reader keeps GitHubSession.paginate() followed rel="next" without a bound, so a chain of next links that never ends, from a GitHub fault, a cursor loop or a hostile answer, was read forever; the issue and milestone reads lost the cap gh api --paginate gave them. paginate() now stops at DEFAULT_GH_MAX_PAGINATED_PAGES, read when the listing runs rather than bound at definition, and a listing still linking a next page past it raises GitHubUnreadError naming the endpoint and the cap. A listing whose last page falls on the cap is read whole. ADR 0006 and the #983 task file say so. Part of #983
Closed
24 tasks
dan-petty
added a commit
that referenced
this pull request
Oct 20, 2026
* fix(security): local names come from the public suffix list, and domains match on DNS labels (#887) (#1618)
* refactor(mcp): generate FastMCP tool bridge from Typer app (#997) (#1619)
* refactor(mcp): generate FastMCP tool bridge from Typer app (#997)
* fix(mcp): normalize absolute path defaults to empty string in generator (#997)
* fix(github): a pull request that delivers part of an item says Part of #N and passes readiness (#1620)
Readiness let a pull request into a release branch through only if its body closed exactly one issue, so an item planned as several pull requests could deliver only its last one: every earlier pull request closed no issue and `devops pr check-readiness` blocked it. Refinement on 2026-10-17 planned nine items that way, and the owner chose a `Part of #N` line over a child issue per pull request.
`extract_part_references` in `github/issue_closure.py` reads the issues a body delivers part of with the same rules as closing keywords: one scan, shared with `extract_linked_issues`, skips what is not prose and a reference to another repository, and the phrase lives in `CONST_ISSUE_PART_PHRASE`, matched case-insensitively. `Part 1 of #N` is not the phrase. `strip_non_prose` now reads the body with markdown-it-py's CommonMark parser and keeps only the text of paragraphs, headings and list items outside block quotes, so a tilde or unclosed fence, indented code and an HTML comment no longer close an issue through `devops roadmap close` or name a part.
Readiness grounds a pull request on the one issue it closes or, closing none, the one it delivers part of. A body that names both, two part references, several closed issues or none is one blocker that says which. The task-file, release-file and release checks judge that issue, and a part reference to an issue that is not open is refused, since the pull request that closes the item is its last. A part pull request's task file may read In Progress, and it adds no changelog fragment: the pull request that closes the item adds it, and the release-file blocker for a part says so. An unread issue is its own check, and the release blocker says "closes" or "delivers part of".
`devops roadmap close` is unchanged: it reads only closing keywords, so the item stays open until its last pull request closes it, which a new test pins. `devops roadmap reprioritize` links an item to its part pull requests too, so their updates count as its activity for the stall window and a part keeps the item from a trim; a multi-PR item busy with its parts was otherwise readied and moved on part-way through.
AGENTS.md, docs/ROUTINE_TASKS.md, the task-file README, changelog.d/README.md, the pull request template and the check-readiness docstring with its generated docs describe the multi-PR delivery and its one fragment, and task-740 and task-1294 name the renamed release check.
Fixes #1617
* fix(github): pr readiness exempts a release-process pull request only by the files it changes (#1621)
* fix(github): pr readiness exempts a release-process pull request only by the files it changes
`devops pr check-readiness` exempted any `chore/open-vX.Y.Z[-slug]` pull request into `release/vX.Y.Z` from grounding whatever it changed, so code fixes reached `release/v0.2.28` with no issue, task file or changelog fragment, while it held the cut pull request (`chore/cut-vX.Y.Z` into `release/vX.Y.Z`, as #1614 cut v0.2.36) to grounding, so the cut failed with "closes no issue".
The exemption now depends on the files the pull request changes. A cut is exempt when every path is one of the cut's files with status `modified` or a `changelog.d/<n>.md` with status `removed`, exactly what `cut_release` writes, judged from the file list readiness already reads. A merge of `main` (`chore/open-vX.Y.Z[-slug]`) is exempt when every path is a cut file or a file `main` changed since its merge base with the release branch, read with one compare request, and only when a path is not a cut file. Both paths of a rename must be allowed. Otherwise grounding applies, led by one bounded blocker naming the other files. An unread file list holds the pull request, as does a compare that fails, returns no file list or lists GitHub's limit of 300 files, with a blocker naming the failure. A fork, another version, a slug before the version, a non-chore head or a head into the default branch is held as before.
The cut's file list moves from `roadmap/close.py` (`CUT_FILES`) to `CONST_RELEASE_CUT_FILES` in `config/constants.py`, read by `devops roadmap close` and readiness alike. The release-process branch pattern gains a `kind` group. The `check-readiness` help, its generated docs, RELEASE_CYCLE.md, `docs/agent/tasks/README.md` and the pull request template name the release pull request, the cut pull request and the merge of `main`, each with its file rule.
Fixes #1344
* test(server): await the startup tick's job instead of a fixed pause
test_polling_tick_advances_with_injected_fixtures gave the lane's worker thread a fixed 0.1 s to run the startup poll before asserting, so on a loaded machine it failed with an empty batch list that held the batch by the time pytest printed it. It now waits, bounded, for the job to run and for the loop to sleep its interval, as the other service tests wait on their events.
* fix(github): a merge of main whose payload names no default branch is held without a compare request
When the pull request payload carries no `base.repo.default_branch`, `_read_default_branch_changes` sends no `compare/<sha>...` request, which could not succeed, and the merge of `main` is held with a blocker that says the pull request names no default branch for the repository instead of leaving the branch's name blank. `test_a_merge_of_main_whose_default_branch_is_unnamed_is_held_without_a_compare` pins the blocker and that no compare is read.
`docs/agent/tasks/README.md` rule 5 names the release pull request and two release-process pull requests, as the pull request template and `_release_process_kind` do, and the `_grounding_scope` docstring says a merge of the default branch may read one compare request before it is exempt. The task file records the `test_polling_tick_advances_with_injected_fixtures` fix this branch carries, which `devops ci` needed on a loaded machine.
Fixes #1344
* fix(security): addresses are classified with ipaddress, and the sandbox local whitelist refuses host.docker.internal and never emits an empty egress rule (#1622)
The reference extractor's hand-kept RFC 6890 tables are gone. Every specified address is now in exactly one class: a documented example when it lies in CONST_DOCUMENTATION_IP_NETWORKS (RFC 5737, RFC 3849, RFC 9637, RFC 2544, RFC 5180); public when ipaddress reads it as global, not reserved and not multicast, outside CONST_NON_GLOBAL_NETWORKS_STDLIB_READS_GLOBAL (192.88.99.0/24 and the deprecated site-local fec0::/10, which Python still reads as global although IANA does not); and local otherwise. An IPv4-mapped IPv6 address is classed as the IPv4 address it carries, so ::ffff:192.88.99.2 is local and ::ffff:192.0.2.1 a documented example. With the tables, multicast was in no class, so check_threat_intel and CloudflareRadarClient.check_domain sent 224.0.0.1 and ff02::1 to Radar's domain lookup; they are now local and no request leaves. is_example_or_reserved_ip is removed and its callers use is_example_ip. A test pins that 192.88.99.2 and fec0::1 are still global to Python, so each network leaves the second constant when CPython follows IANA.
Every class reads the address a target names, network_target_address: without the punctuation prose leaves after it (CONST_PROSE_TRAILING_PUNCTUATION), as the host of a URL or host:port without its trailing dot, and in the legacy numeric spellings inet_aton reads, through core.validation.parse_numeric_ip, now public, with no lookup. A target holding whitespace names no address, since glibc's inet_aton reads 1 555 0100 as 0.0.0.1. classify_network_target puts a target in one NetworkTargetClass, and is_example_or_invalid_network_target, the three address predicates, Shodan InternetDB, Cloudflare Radar and check_threat_intel all read it. 100.64.0.1., 224.0.0.1,, 10.0.0.1., 2130706433 and http://100.64.0.1./v1 used to reach Radar's domain lookup from check_threat_intel, check_domain and its batch path; no request is made for them now, and a public address with a trailing mark goes to Shodan as the bare address. Shodan is asked about a public address in its canonical spelling, and Radar about a public address or a domain that is neither an example nor local. Both answer every other class from one table whose summary names what the target is: a documentation or benchmarking address, an unspecified address, local network space, a fictional phone number, an example domain or a local domain.
check_threat_intel names everything is_example_or_invalid_network_target excludes: example domains (RFC 2606, 6761), documentation (RFC 5737, 3849, 9637) and benchmarking (RFC 2544, 5180) addresses, fictional phone numbers (ATIS-0300115, Ofcom) and the unspecified addresses (RFC 1122, 4291), and no longer RFC 6890. It answers a local address itself, saying the target is a local address and no threat intelligence service was asked, instead of presenting Radar's static record as Radar intelligence for a domain.
In the sandbox local whitelist, host.docker.internal is refused at SandboxNetworkConfig validation with a SandboxValidationError, compared with dns.name so case and a trailing dot do not matter, before the private-host check and before any lookup, with a message asking for the IP address or CIDR the cluster reaches the host on. #887's private-host check admits the name, since internal is not on the Public Suffix List, so the refusal is what keeps it out. It used to become a 127.0.0.1/32 ipBlock, the pod's own loopback. A loopback entry (localhost, a loopback address or a loopback network) now resolves to no address, since NetworkPolicy never polices a pod's loopback, and _build_whitelist_egress adds no rule for an entry that resolves to none, so no generated rule has an empty to, which would allow every destination on its port. No DNS lookup was added to the policy builder.
The two RFC 1918 local whitelist fixture addresses in tests/test_sandbox_networking.py are RFC 5737 addresses now, the sandbox property test expects no address for a loopback host, and task-207 and task-702 describe the local whitelist as it now behaves. changelog.d/1174.md lists every report-class shift.
Fixes #1174
* fix(k8s): tempo runs under the otel namespace's restricted pod security, so traces reach their volume (#1633)
* fix(k8s): tempo runs under the otel namespace's restricted pod security, so traces reach their volume
Tempo trace storage, shipped in v0.2.35 by #1135, never ran. The otel namespace enforces PodSecurity restricted, and the tempo chart values set no seccomp profile on the pod and no container security context, so admission refused every pod the StatefulSet created: 343 FailedCreate events over 3 days 17 hours, with the volume claim left Pending.
The values now set what restricted requires. The pod runs as the chart's non-root user with the RuntimeDefault seccomp profile, and the tempo container cannot escalate privileges, drops every capability and keeps a read-only root filesystem, since tempo writes only under its /var/tempo volume. A server-side dry run of the pod the chart renders from these values is admitted into otel; the same dry run of the previous values is refused with the same violation. A test pins every restricted control against the namespace's enforce label.
Fixes #1627
* docs: regenerate MCP_TOOLS.md for the pr check-readiness description release/v0.2.37 carries
#1619 builds each tool's description from its Typer command, and #1620 and #1621 changed the check-readiness docstring; each passed its docs check on its own base, so the merged branch carried a stale MCP_TOOLS.md and devops docs check failed on every branch cut from it.
Part of #1627
* fix(ai): reasoning request parameters follow declared capability (#888) (#1636)
* fix(ai): gateway requests stay within the backend slot count in every command (#1639)
In gateway mode a review sized its persona-stage file pool by ai.ollama_urls times ai.ollama_max_parallel, although gateway traffic goes only to gateway_url, and each file runs its personas in parallel. With three URLs the stage reviewed six files at once and kept more requests in flight than the gateway's 3 backend slots, which rebuilds the backend queue #1069 meant to prevent.
One limiter per process now covers every chat request LLMClient sends to the gateway. network.py holds a BoundedSemaphore at DEFAULT_GATEWAY_REVIEW_CONCURRENCY and acquire_gateway_slot(), whose wait is bounded by the new DEFAULT_GATEWAY_SLOT_TIMEOUT_SECONDS (900 s) and fails with an AIClientError naming the slot count. uses_gateway_slots(config), true for the gateway provider only, is the one test the client and the review sizing both use: ai.gateway_enabled with another provider sends no chat call to the gateway, so it takes no slot and keeps its node sizing and an explicit --concurrency. _openai_compat_messages and _openai_compat_stream take a slot for the gateway provider, so persona calls, group analysis, roadmap intake and the devops ai chat commands are all covered; a stream holds its slot until the generator closes, and a call holds one slot across the transport's own retries. Model listing, gateway probes, embeddings and other providers take no slot.
The wait is an ai.llm.gateway_slot span under the call's span and an observation of the new devops_cli_ai_gateway_slot_wait_seconds histogram, by outcome. A plain call is timed from when it holds its slot, and a stream now is too: the stream passes its wait back through a ContextVar, and its time to first chunk, llm.wall_seconds and spend duration leave it out, so a review waiting for slots does not look like slow inference. docs/TELEMETRY.md describes both.
The review's worker sizing moves into helpers. Through the gateway the file pool is min(total_files, slot sum) whatever ai.ollama_urls holds, and effective_review_concurrency lowers an explicit --concurrency above the slot sum to it, with one warning that names both numbers. devops review benchmark records that concurrency in its run setup, so a gateway benchmark asked for 8 records the 3 it ran at. The --concurrency help says it is capped at the gateway's backend slots, and the CLI reference and docs/MCP_TOOLS.md are regenerated. The release branch's docs/MCP_TOOLS.md had not been regenerated for the pr_check_readiness description, so it now carries that too.
fix_llm_response returns a plain FormattedLLMResponse. FormattedLLMResponse[T] made pydantic build a parametrized class that its generic cache holds only weakly, so after any garbage collection the next reply rebuilt its schema, about 30 ms of CPU per reply.
The review-level test's fake gateway holds each request until more than the slot sum are in flight, or until 0.25 s after the first request, so the base and a review without the limiter reach 4 in flight on every run, and the change never passes 3. It runs six files of two personas, 12 calls, with a call phase under 1 s.
Fixes #1354
* docs(agents): task files carry no status, milestone or priority (#879) (#1660)
Task files historically carried Status, Milestone, and Priority lines,
leading to drift between files and GitHub Projects v2, and creating
unnecessary administrative commits. Under ADR 0001, GitHub is the single
source of truth for task status, release milestones, and priority.
- Removed Status, Milestone, and Priority lines from all 504 existing task files.
- Deleted 36 non-Done task files whose work has not been implemented.
- Updated tests/test_agent_task_files.py to enforce that task files link their issue, have no PR field, and carry no Status, Milestone, or Priority lines.
- Updated docs/agent/tasks/README.md to remove metadata fields from the template and document that status, release milestone, and priority live on GitHub.
- Updated AGENTS.md and github_project_management.md so no instruction asks for a task file before implementation or for a status in it; task files are authored only by delivering pull requests.
- Added deliverable task file and changelog fragment changelog.d/879.md.
Fixes #879
* feat(github): the github session sends rest requests through gidgethub, paced, charged and classified by status and headers (#1661)
* feat(github): the github session sends rest requests through gidgethub, paced, charged and classified by status and headers
GitHubSession.rest(method, path, *, accept=None, body=None) sends a REST request as the session's identity through a subclass of gidgethub 6.0.0's httpx2 adapter, over one httpx2.AsyncClient from the egress-checked factory running in an anyio blocking portal the session owns; reset_github_session() closes both. The client follows redirects under one request hook that compares request.url.origin with the API origin and refuses any other origin before the request is sent, so the token never reaches another host. Each attempt waits its turn on GitHubRateLimiter in a worker thread, a write as a write, and each answer's x-ratelimit headers update the quota of the resource GitHub names. gidgethub's handle_rate_limit_error hook retries a rate limit, and a read's 5xx, up to DEFAULT_GH_MAX_RETRIES times with the waits run_gh uses, now shared through GitHubRateLimiter.retry_delay.
The new github/error_classifier.py maps gidgethub's exceptions by type, status and headers, never by message text, onto GitHubUnauthenticatedError, GitHubRateLimitError and the new GitHubScopeError, GitHubNotFoundError and GitHubUnreadError, each carrying the status and the bounded request path; GitHubFileNotFoundError becomes a GitHubNotFoundError. GitHubClient.get_pr_diff and SSH signing-key registration become session requests, which removes their own httpx2 clients and the hand-written redirect code that copied the token onto a github.com hop. The User-Agent, API version, diff media type and header names are constants.
ADR 0006 records the choice of gidgethub. tests/github_session_fakes.py is a fake GitHub API on httpx2.MockTransport, and the github_api fixture puts the process's session over it, with the redirect table, the retry and pacing cases and the error table run through the real client and hook.
Part of #983
* fix(github): the session's transport closes at exit, fails only with typed errors and charges its own identity's ledger
A process that sent a request through the GitHub session and never closed it hung at interpreter exit: the portal context's own exit called into a portal thread that no longer ran. Each RestTransport now registers weakref.finalize over its resources, so it is closed by close(), when garbage-collected, or at exit while the daemon thread still runs, and closing stops the portal with cancel_remaining=True so a request waiting out a retry or a pacing pause is cancelled. get_github_session() closes a session a token change replaces, and a request a close stops raises GitHubUnreadError. A child-interpreter test sends requests and exits within its bound.
No other exception leaves rest(): a DevOpsCLIError passes through, and a ValueError or LookupError from an answer that cannot be read (an unknown charset, a status outside http.HTTPStatus, quota headers that are not numbers) is GitHubUnreadError. A retry wait past max_rate_limit_wait names the request's path and status, and GitHubRateLimitError keeps numeric details as numbers, so status is an int on every class. The retry wait and its throttle record run in a worker thread like pacing and charging, and each session paces and charges the ledger of its own token through identity_rate_limiter. A path's template braces are percent-encoded before gidgethub expands it, get_pr_diff raises GitHubUnreadError for an answer that is not text, and GitHubClient's unused token attribute is gone. The session's mock transport now goes through new_async_http_client(mock_transport=...), so tests and production share one constructor and its timeouts. The redirect table's look-alike host gives way to another port on the API host, and the github_api fixture replaces only the rate limiter's clock. ADR 0006 records the lifecycle rule.
Part of #983
* refactor(github): tests fake the github session through the httpx2 client seam, and the egress factory keeps no way around vetting
new_async_http_client loses the mock_transport parameter the previous commit added, so the egress factory is again identical to the release branch's, and GitHubSession, RestTransport and session_client lose their transport argument: the session's client comes only from the factory at EgressLevel.PUBLIC. A parameter that let a client skip egress vetting existed in product code only for tests.
Tests fake the session the way stub_web fakes web pages. The github_api fixture installs GitHubApiFake.client_class(), an httpx2.AsyncClient that keeps everything the factory passes except the transport, which becomes a MockTransport over the fake behind vetted_handler, now shared with StubWeb, at the level egress_level_of reads from the factory's transport. The factory's timeouts, the redirect handling and the origin hook stay real, and every request is still vetted, resolving through public_dns. install_async_client_fake raises when a test asks for both github_api and stub_web, so neither fake silently wins. A new test shows the session's client is built at the public level and that a request whose host comes to resolve to loopback raises SSRFBlockedError before it reaches the fake; the subprocess exit test's child fakes GitHub through the same seam and resolves the API host with the web fakes' resolver. ADR 0006 and the task file record the seam as a deviation from the plan's transport= argument.
Part of #983
* feat(github): the github session reads rest listings page by page, following rel=next and failing closed on a page that is no list (#1662)
* docs(github): the #983 task file follows #879's format, with no status, milestone or priority
The #983 task file was written before #879 merged, so it still carried the Status, Milestone and Priority lines that tests/test_agent_task_files.py now rejects. They are removed; the file keeps its issue, scope and feasibility lines.
Part of #983
* feat(github): the github session reads rest listings page by page, following rel=next and failing closed on a page that is no list
GitHubSession.paginate(path, *, iterable_key=None) is a lazy, synchronous iterator over a REST listing's items. Each page is one call through the session's portal, made only when the consumer has read the items before it, so a consumer that stops early sends no further request. Pages follow the rel="next" URL gidgethub reads from each answer's Link header, by page number or by cursor, and pass through the same pacing, ledger, retries, origin hook and error classes as rest(), so a Link to another origin is refused before it is sent.
A page must be a JSON array, or an object holding one under iterable_key (check_runs, workflow_runs, items). Anything else, such as an HTML page, an error object or a missing body, raises GitHubUnreadError naming the endpoint, the page and the type that came back, and a truncated page raises the classifier's GitHubUnreadError, which now names the page of a listing. An empty array or a page without a next link ends the listing. gidgethub's getiter is not used, since it would read a string's characters or an object's keys as items (#1034's rule).
_fetch_issues_rest and _resolve_milestone_number read through paginate() instead of gh api --paginate, with their queries built by urlencode, stop reading at the limit or the matching title, and fail closed; _parse_milestones_response is gone. Their tests run over the github_api fake. ADR 0006 and the #983 task file describe the pagination.
Part of #983
* fix(github): a session listing stops at the page cap every other paginated reader keeps
GitHubSession.paginate() followed rel="next" without a bound, so a chain of next links that never ends, from a GitHub fault, a cursor loop or a hostile answer, was read forever; the issue and milestone reads lost the cap gh api --paginate gave them. paginate() now stops at DEFAULT_GH_MAX_PAGINATED_PAGES, read when the listing runs rather than bound at definition, and a listing still linking a next page past it raises GitHubUnreadError naming the endpoint and the cap. A listing whose last page falls on the cap is read whole. ADR 0006 and the #983 task file say so.
Part of #983
* fix(review): a group-analysis reply cut at its token cap is rejected, not shown (#876) (#1665)
When an LLM response is truncated at its token ceiling (finish_reason == CONST_FINISH_REASON_LENGTH),
json-repair fallback previously could parse the partial response into an incomplete
GroupAnalysisOutput, passing G10 checks and surfacing a truncated explanation in review reports.
Group analysis explanation is all-or-nothing and should not be retried with the same prompt.
- Checked finish_reason on the returned LLMResponse prior to parsing in _execute_single_group_job.
- A cut reply (finish_reason="length") is rejected immediately with reason reply-truncated and output None.
- Rejection is recorded in AnalysisReport.rejections without retry.
- Rendered markdown displays the group rejection notice and none of the cut text.
- Added CONST_ANALYSIS_REJECTION_REPLY_TRUNCATED, CONST_ANALYSIS_REJECTION_SCHEMA_VALIDATION_FAILED, and CONST_ANALYSIS_REJECTION_MODEL_CALL_ERROR in src/devops_cli/config/constants.py.
- Decomposed rejected record creation into _rejected_group_record helper keeping cyclomatic complexity M <= 4.
- Added comprehensive offline unit tests with fake client returning LLMResponse in tests/test_review_group_analysis.py.
- Stripped stale metadata lines from task-983 to satisfy tests/test_agent_task_files.py.
- Added changelog fragment changelog.d/876.md and task file docs/agent/tasks/task-876-group-analysis-cut-reply-rejected.md.
Fixes #876
* refactor(ai): delete the pass-through package facades and the two stagepipeline protocols (Part of #1002) (#1676)
* refactor(github): the internal paginated reads go through the session, and run_gh hands --paginate to gh unchanged (#1678)
* refactor(github): the internal paginated reads go through the session, and run_gh hands --paginate to gh unchanged
The pull request timeline and reviews (pr_monitor), the check-runs listing (check_verdict, iterable_key check_runs), a pull request's changed files (commands/pr) and reconcile's issue and pull request listings (projects) now read through session.paginate(), so each follows GitHub's rel="next" links and fails closed: a page that can't be read or holds no list is a read failure, never a shorter list. Each keeps its callers' contract, and the timeline takes its events from the listing instead of parsing gh's output. Reconcile's dry run lists those listings as the session's GETs.
run_gh stops paging. devops gh api is the only caller left with --paginate, and run_gh hands gh that flag with --slurp, --jq and --template as given, since gh follows Link itself. The page loop and its flag refusals are deleted, with incompatible_gh_api_paginate_flag, parse_paginated_json, GhCliClient.api's unused paginate argument, run_gh_async, get_async_limiter and aiolimiter, and the tests that only exercised them, the one that spun through 100 pages among them.
Tests answer the moved reads through the github_api fake, or, where a gh stub already answers a test's reads, from the same routes: test_pr_cmd's _RoutedSession and the reconcile fake's paginate. ADR 0006 records the consequence, and the #983 task file ticks PR 4.
Part of #983
* fix(github): an unreadable paginated graphql call is paced as a write, a paginated api walk gets the listing timeout, and a listing entry that is no object fails the read
The request classifier loses the --paginate read path it kept for the deleted page-by-page path, so a gh api graphql --paginate call whose document can't be read counts as a write, as #1125's rule says of anything the classifier can't read. devops gh api --paginate runs under DEFAULT_GH_API_PAGINATE_TIMEOUT_SECONDS, since gh walks every Link page in one process. A repository listing entry that is not an object raises GitHubUnreadError naming its type, never its text, instead of a TypeError or AttributeError in reconcile.
The test_pr_cmd routed session records each session read, asks the run_gh stub with a session argv and refuses to run with run_gh unstubbed, and the reconcile fake answers no gh listing, so a reader regressed to one gh page fails offline. The task files and ADR 0006 record the lost on-disk listing cache, the paginate walk's timeout and retry, and the gh and GitHub schema sources PR 4 was checked against.
Part of #983
* refactor(ai): lazy pydantic_ai imports on command and help dispatch paths (Part of #1002) (#1679)
Ensure that running commands, root --help, --version, and command group --help invocations do not eagerly import heavy packages. Decoupled pydantic_ai exception classes into exceptions/ai_pydantic with lazy loading in exceptions/ai, lazified SSRF checks in core/validation and http/egress, converted ai/rag, ai/review, and ai/benchmark facades to lazy __getattr__ dispatchers, and added comprehensive isolation tests in tests/test_cli_startup_imports.py.
* refactor(ai): startup import budget invariants and dry-run isolation tests (#1002) (#1680)
Adds named startup import budget constants and enforcement tests ensuring `devops --help` and `devops --version` finish importing within 0.5 s (-X importtime cumulative for devops_cli.main) and any `<command> --help` within 1.0 s, reporting the slowest imports on budget breach. Adds dry-run isolation tests verifying that `ai benchmark`, `k8s deploy-stack`, and `review path` import only what their plan requires.
Fixes #1002
* feat(agent): gateway URL variable, grant-aware 401 hint, and Claude Code deny rules (Part of #1154) (#1681)
Introduces agent session prerequisites:
- Adds AI_GATEWAY_URL and DEVOPS_CLI_AI_GATEWAY_URL configuration options with EnvVarSpec metadata and documentation.
- Declares ENV_AGENT_GRANT constant and updates credentials_error to provide a grant-aware 401 error message naming the grant ID (capped at 256 chars) and omitting the generic API key hint when DEVOPS_CLI_AGENT_GRANT is set.
- Adds Claude Code deny rules in .claude/settings.json for settings.local.json, settings.json, and ~/.kube/**.
- Adds comprehensive regression tests in tests/test_claude_code_settings.py, tests/test_config_env_overrides.py, and tests/test_ai_gateway.py.
Part of #1154
* refactor(github): gh failures are classified once, from gh's exit status and stderr through one table (#1682)
* refactor(github): gh failures are classified once, by gh's exit status and the gh-output table
error_classifier.py gains classify_gh_failure. It reads gh's exit status, where 4 means the command requires authentication, and the gh-output table in config/constants.py, the one place gh's text is matched. That table holds the rate-limit rows, the board lookup's and scope check's phrases, the login phrases, HTTP 401 and Bad credentials. Each classified error carries gh's exit status and the HTTP status gh names as ints, with gh's output bounded on one line.
run_gh's rate-limit check, the project scope check, the board lookup and reads, the roadmap store's _failure, devops pr ready and _gh_add_key now read gh's failures through the classifier, and check_github_rate_limit_error and the unused is_secondary_rate_limit are gone. A quota refresh GitHub refuses gh's token for raises GitHubUnauthenticatedError, and any other failed refresh raises GitHubUnreadError. parse_retry_after moves into the classifier module, which rate_limiter now imports.
Part of #983
* fix(github): gh failures are classified from gh's stderr, and an owner lookup, a refused token and a timed-out refresh are handled as their causes
The gh classifier, run_gh's retry decision, the board reads, the roadmap store's _failure and _gh_add_key read gh's stderr only. gh writes every failure there, while its stdout holds GitHub's answer, whose partial GraphQL data can carry item titles. The table loses the rows gh never writes for a failure: graphql_rate_limit, insufficient_scopes, abuse-rate-limit, retry-after and retry after. It is the one place gh's failures are classified by gh's text; four other modules still match gh's text of their own and are named for a follow-up. CONST_GH_HTTP_STATUS_RE is now the only status regex, and the store's and devops pr's 404 reads use gh_http_status.
"unknown owner type" is no rate-limit row, so run_gh no longer backs off on it before the @me fallback; where no fallback recovers it, the classifier still calls it a rate limit. A failed quota refresh raises the class the classifier names and is unread otherwise. A refresh that times out is GitHubUnreadError instead of a raw TimeoutExpired, and intake stops a round on a refused token as on a rate limit. _gh_add_key confirms a 422 by listing the keys, so an invalid key is not reported as registered. The project scope check asks for the project scope board sync needs, devops gh views sync prints gh's [read:project] as written, and devops pr ready no longer doubles gh's closing period.
Part of #983
* feat(github): a release pull request gets a set number of copilot passes (#1683)
* feat(github): a release pull request gets a set number of copilot passes
`.github/roadmap.toml` sets `release_copilot_passes` (default 2, at least 1), and `devops pr copilot-pass [<number>] [--repo] [--dry-run]` requests a Copilot pass on the release pull request only while its passes are below it. A pass is every Copilot review submitted on the pull request, whoever asked for it, and one still running; nothing is stored, so each release pull request starts with the whole budget. Once the passes are spent the command requests nothing, prints "Copilot budget spent: N of N passes" and exits 1, and it refuses any pull request but the release pull request. The request is gh's documented `gh pr edit <n> --add-reviewer @copilot`, made only from `src/devops_cli/github/copilot_budget.py`, and `--dry-run` makes no request and lists the reads and the request a real run would make.
A review is Copilot's only when its author's login is exactly `copilot-pull-request-reviewer[bot]` (REST) or `copilot-pull-request-reviewer` (GraphQL). The monitor matched "copilot" anywhere in a login, so a person named copilot-fan set Copilot's state, ended a running pass and had their approval ignored; the monitor and the budget now share the exact check. The release pull request predicate moves from the pr command to `github/pr_branches.py`, so the budget refuses exactly what grounding exempts.
`RELEASE_CYCLE.md` Step 3 states the budget and the stop rule: once it is spent, a remaining Copilot comment blocks the release only if it is a regression the release introduces, and every other one becomes a follow-up issue. ADR 0004 and `docs/SDLC.md` say re-reviews go through `devops pr copilot-pass`. The monitor's gate is unchanged: it already stops holding on Copilot's changes-recommended state once no thread is unresolved (#216).
Part of #1345
* fix(github): copilot's timeline review ends its pass, and a pending request counts
GitHub names Copilot's code review account differently in two payloads: the reviews endpoint calls it `copilot-pull-request-reviewer[bot]`, and the issue timeline calls the same account `Copilot` (type Bot), a login the Copilot coding agent shares. The exact-login check therefore never recognised Copilot's own `reviewed` event, so after its first `copilot_work_started` a pull request read as having a pass running for good: `devops pr copilot-pass` refused pass 2 of 2, and `devops pr monitor` timed out on every pull request Copilot had reviewed. A timeline `reviewed` event now ends the pass when its id is the id of one of Copilot's reviews; logins stay exact for review records only, and the timeline fixtures are rewritten in the shape #1283 recorded.
A review requested of Copilot that it has not started now counts as one pass in the budget, since Copilot starts up to a minute later and a second request in that time would spend a pass the budget does not have. The request is recognised by the requested reviewer's type and its app's page, `/apps/copilot-pull-request-reviewer`. The monitor never waits on it, since Copilot may never take a request up.
`devops pr copilot-pass` also refuses a release pull request that is merged or closed, its dry run lists the gh commands a real run sends from the same argv builders, a request gh refuses without saying why is named by its exit code from the lang catalogue, and a test pins the command to the budget `.github/roadmap.toml` sets.
Part of #1345
* feat(agent): read-only agent identity under GitOps (Closes #1154) (#1684)
- Add namespace agents with restricted Pod Security Standards in k8s/namespaces.yaml
- Add ServiceAccount devops-agent with automountServiceAccountToken: false in k8s/agents/serviceaccount.yaml
- Add ClusterRoleBinding devops-agent-view binding devops-agent to built-in view ClusterRole in k8s/agents/clusterrolebinding.yaml
- Add Argo CD Application agents in k8s/argocd/apps/agents.yaml under homelab project
- Add agents destination and agent-grant-* orphan ignore in k8s/argocd/apps/projects.yaml
- Integrate agents manifests into devops stack in stack_lifecycle.py
- Update leaf application counts (22 -> 23) and add Agent sessions documentation in k8s/README.md
- Add comprehensive unit tests in tests/test_k8s_agents_manifests.py and update argocd / stack tests
- Add changelog fragment changelog.d/1154.md and update task documentation
* test(cli): test modules read the repository root and their test data from tests.support.paths (#1685)
`tests/support/paths.py` names the repository root, the test root and the `fixtures` and `golden` directories, found from the `tests` package rather than by counting a module's parents, so a test module reads the same paths at any depth. `tests/support/` and `tests/support/fakes/` are new packages for what test modules share and for the fakes of external edges.
The 91 `Path(__file__)` sites in 63 test modules now import the shared paths, each module dropping its own root constant, and the four root-relative and two working-directory reads of test data read `FIXTURES`. The swallowed-failures ratchet runs as a module, `uv run python -m tests.test_swallowed_failures_ratchet --lower`, and builds that command from its own dotted name. The root conftest and the modules other pull requests are changing keep their 10 sites until the item's last pull request; the task file names them.
Collection is the base's 10703 tests plus the new paths test, and the full run keeps the base's pass, skip and xfail counts.
Part of #1312
* feat(release): every Argo CD application builds at the release head (Part of #1343) (#1688)
* feat(release): live Argo CD diff and override report at release cut (Closes #1343) (#1689)
* refactor(roadmap): the roadmap store reads its REST listings through the GitHub session (#1690)
* refactor(roadmap): the roadmap store reads its REST listings through the GitHub session
GitHubRoadmapStore takes the session beside its runner and reads its ten REST listings with session.paginate(), which follows GitHub's next links, raises on a failed page, a page that is no list and a listing past the page cap, and requests a page only when the store reads into it. _read_listing, listing_page_args and the store's own page cap are gone. A listing read newest first, as changes_since reads the events, pull requests and GitHub Releases, stops at its first entry older than the cutoff and asks for no later page. The request plan lists each listing as the session's GET and URL, and the store's gh commands keep the runner.
When gh project drops why it could not look up the board's owner, the store reads GraphQL's quota from gh api rate_limit, which spends none, so a failure with points left is no longer reported as a rate limit. The session's signing-key upload confirms a 422 against its signing-key listing, as the gh path does, so an invalid key is not taken as registered. The session's client connects within a 10 s public-internet timeout instead of the factory's 1 s, which failed live reads of api.github.com on a lost SYN.
Part of #983
* fix(roadmap): the store's owner lookups ask GraphQL's own budget, Release ships are judged a whole page, and intake's spend counts the session's requests
An owner lookup gh project drops the cause of is now decided by GraphQL's own budget, the source the project trusts since #1125, in one helper the roadmap store and the board reads in github/projects.py share. A budget above the floor makes a plain failure that still allows a secondary limit; a spent, refused or unread budget keeps the rate limit, so an intake round stops, and a refused token is the unauthenticated error naming the command. run_gh no longer parses a failed gh api rate_limit answer's error body.
The GitHub Releases listing reads on to the end of the page it stops in, which GitHub has already sent, so a Release for an older tag published after the cutoff is a ship again. intake --plan counts the requests the identity's ledger paces, gh commands and session requests alike, so its spend line includes the listings again. A refused key on the session path of devops ssh is a registration error, so rotate removes the key it generated. The store's default session path, the milestones failed read and the records are pinned and brought up to date.
Part of #983
* fix(ci): the startup import budget counts what a command imports, not wall-clock seconds (Closes #1687) (#1691)
* feat(github): the GitHub session sends a repeated GET conditional on the ETag it kept (#1692)
* feat(github): the GitHub session sends a repeated GET conditional on the ETag it kept
Each session's transport hands gidgethub a bounded cachetools LRUCache, in memory, so the next GET of a URL carries If-None-Match and a 304 gives back the stored answer. Every attempt, a 304 too, is still paced and charged on the identity's ledger, retried by the same hook and vetted by the origin hook, and a stored page still fails closed in listed_items. One identity's ETags are never sent as another's, a write's answer is never stored, and every GET's answer is a copy, so no caller changes what a later 304 returns.
GitHub's ETag covers a page's body only and its 304 carries no Link header, so a full last page that gains a next page keeps its ETag; a page whose stored answer linked no next page is read in full. cachetools is declared, its size is DEFAULT_GH_SESSION_ETAG_CACHE_SIZE, and the GitHub API fake answers a matching If-None-Match with a 304.
Part of #983
* fix(github): a last page holds no slot in the GitHub session's ETag store
A page that links no next page is dropped from the store after it is read as well as before, so one-page listings and the last page of every listing no longer evict the pages that can answer 304. A test pins that help for the session's commands leaves cachetools unloaded, the size comment and risk note count rest() answers such as a diff, and the red record cites the merged release commit.
Part of #983
* feat(test): devops test and devops ci test choose tests through one selector, and a change that reaches every test runs the suite (#1693)
* feat(test): devops test maps a change through the shared selector, and a tests/support change forces a full devops ci run
`devops test run --changed` keeps its listing of the branch's changes and the working tree's, and hands those paths to the selector `devops ci test` uses instead of its own flat name table. It runs the targets that exist, so a deleted test module is never passed to pytest, runs the whole suite when nothing changed or nothing maps, and names each changed source no test module covers.
The shared selector gains three rules. A module in a subpackage of devops_cli also selects the test modules directly in the directory under tests/ that mirrors its package, and a package's `__init__.py` its own directory, while a module directly in devops_cli gets none. A changed conftest selects its directory, and a changed file under tests/support/ selects the whole suite.
`devops ci` treats tests/support/ like a conftest, because a support module may register a fixture that reaches tests that never import it: the full-run triggers move to `CONST_FULL_RUN_TRIGGER_NAMES` beside the new `CONST_TEST_SUPPORT_DIR`, and a public `forces_full_run` serves both the trigger check and the coverage index. The two `noqa: C901` markers in the test command are gone, and the C901 suppression ceiling falls from 49 to 47.
Part of #1312
* fix(test): a change that reaches every test selects the suite before any test module is read
`select_tests_for_sources` now returns `tests` as soon as a changed path forces a full `devops ci test` run, a file under `tests/support/`, a conftest in the repository root or directly in `tests/`, `pyproject.toml`, `uv.lock` or `.python-version`, before it lists or reads a test module. On a topic branch `devops test run --changed` lists against `main`, which takes in the whole release and its `tests/conftest.py` changes, so the 877 paths this branch lists selected the full suite only after a selection pass of 26 to 73 s; it now takes 0.003 s. A conftest below `tests/` still selects its own directory.
`devops test run --changed` reads `git status --porcelain --untracked-files=all`, so a new test package not yet added is listed file by file: its test modules run, and its `__init__.py` selects its own directory, as a conftest does, instead of being named as a source no test covers. `_changed_paths` diffs against `CONST_GIT_MAIN_BRANCH`, without the `base_ref` parameter no caller passed and its ref pattern.
`devops ci test` drops only a leading `./` from a relative path. `.lstrip("./")` also dropped the dot of `.python-version` and the `../` of a parent path, so `devops ci test .python-version --no-fallback` passed with nothing run; it now refuses like the other trigger names.
The task file records the recheck at the real base, 0ae4ea4, and that a `--base` option for `--changed` is #1667's. The #852 and #406 task files name the `tests/support/` trigger.
Part of #1312
* fix(test): selection drops the mirror-directory rule, sends a hook conftest to the whole suite, and a stale index to the text selector
The selector no longer adds the test modules beside a changed module's own, in the directory under `tests/` that mirrors its package. Replayed over the last 40 commits, in all 15 where that rule added test modules none of them ran the changed module, and once #1313 moves the tests it would add up to 36 unrelated modules a commit; naming at any depth already finds a module's own test there. A package's `__init__.py` selects the tests named for it or importing it, like any module, and the unmapped-source warning no longer names the rule.
A conftest below `tests/` that binds a `pytest_*` hook, defined or imported, as `ast` reads it, now selects the whole suite, since pytest calls such a hook for every test: a `pytest_collection_modifyitems` in `tests/a/conftest.py` changes the outcome of a test in `tests/b`. One that cannot be read, or star-imports, does too; one of fixtures only still selects its own directory.
`devops ci test` counts a full-run trigger only among the files it is given. One that changed only since the coverage index was built leaves the index stale, and the given files are selected by name and import, with a warning naming the file; before, every later hook run after a committed `tests/support/` or `pyproject.toml` change ran the whole suite, or refused under `--no-fallback`, until the index was rebuilt. A `tests/support/` change itself still selects the whole suite.
Run as a script, which has no `__spec__` and cannot import `tests`, the swallowed-failures ratchet prints the `-m` command that runs it and exits 1 instead of failing with a traceback.
The task file records the measurement as the reason PR 2 departs from the plan's mirror rule, the recheck at 0510f6e, and the `ast` classification of `tests/support/` as a follow-up on #1312; the #852 and #406 task files say a drifted trigger now leaves the index stale.
Part of #1312
* docs(cli): docs/TESTING.md holds the test conventions, ADR 0007 records that tests double only process edges, and AGENTS.md and the contributor docs point to them (#1694)
`docs/TESTING.md` holds the testing vocabulary and the conventions the owner settled on 2026-10-07: tests double only process edges, each through one seam and one shared fake with a contract suite, the clock's seam being the sleep and clock parameters the libraries take, and no test starts a real gh; tests find the repository root and their test data through `tests.support.paths`; `tests/` is to mirror `src/devops_cli`; a test is named after its behaviour in glossary terms and compares whole values; and no test asserts on elapsed wall-clock time, so the startup budget counts imported modules and fails on heavy ones, never on seconds. What later items deliver is marked as a target, and the file says what exists today and what a new test does meanwhile: most test files still sit flat, and a new test joins the file that already tests its behaviour, flat or in its mirror directory. ADR 0007 records why tests double only process edges, and that ratelimit, which takes only a clock, has its sleep patched at the stdlib; 0005 and 0006 were taken after the draft of 2026-10-07, which this brings onto today's tree.
TESTING.md states, with no target mark, how a narrowed run selects tests as #1312's selection change (#1693) built it: a test module is reached by name at any depth and by import; with a fresh coverage index, `devops ci test` selects the tests that executed each module the index holds in place of name-and-import matching; `conftest.py`, `pyproject.toml`, `uv.lock`, `.python-version` and any file under `tests/support/` run the whole suite; `devops ci test`, and so the commit hook, runs the whole suite for any `conftest.py`, while `devops test run --changed` narrows a nested conftest that only defines fixtures to its own directory; and the commit hook passes only staged Python files, so the dependency and interpreter files reach the whole suite through `devops ci test`, `devops test run --changed` or the pre-push `uv run devops ci`.
AGENTS.md, `CONTRIBUTING.md`, `RELEASE_CYCLE.md`, `docs/SDLC.md`, `docs/ROUTINE_TASKS.md`, `docs/SELF_IMPROVEMENT.md`, `.devops/review.md` and three knowledge base articles link `docs/TESTING.md` instead of stating test rules of their own, and the targeted test commands in `docs/ROUTINE_TASKS.md` and `docs/SELF_IMPROVEMENT.md` read `uv run pytest <test-file>`. AGENTS.md no longer requires linear asserts to be merged into tuple comparisons, which rested on Ruff's C901 counting asserts, nor one test file per submodule, nor mock isolation and `__test__ = False` in product code; its link to `docs/TESTING.md`, which named a missing file, now resolves, and it no longer names `docs/SDLC.md` Phase 2 as a second source. `.devops/review.md` keeps the settled claim that a tuple equality assert compares every element and is not an assertion bug, since review personas read its text and follow no link. The rule-mapping table in #841's task file no longer says AGENTS.md keeps the test rules this drops.
`tests/test_agents_md_claims.py` checks that each of those documents links `docs/TESTING.md`, and that every relative link in TESTING.md, the ADR and those documents resolves, its percent-decoded fragment included, with a negative control that also passes a link to a heading with letters outside ASCII; on the base it fails on AGENTS.md's link to the missing file.
Closes #1308
* feat(github): the release pull request's remaining review threads become follow-up issues (#1695)
* feat(github): the release pull request's remaining review threads become follow-up issues
`devops pr threads file-issues <pr>` is the step of the stop rule that files what remains once the release pull request's Copilot passes are spent. With `--confirm` it files each unresolved thread not named by `--keep` as one issue through the roadmap store, labelled source/agent with no milestone, then replies in the thread naming the issue and resolves it, one thread after another. Without `--confirm` it reads the threads and writes nothing, and `--dry-run` makes no request and lists the requests a real run makes, built by the same argument builders. Any pull request but the release pull request is refused before its threads are read.
The issue quotes the thread's comments inside a backtick fence longer than any in them, so a mention neither notifies nor an issue reference links, cut at 4000 characters, then names the thread's file and line and links its first comment through the comment's GraphQL url, which the thread queries now select. The reply carries a marker, so a rerun resolves a thread an earlier run filed and files it no second time, and a failed write stops the run before that thread's reply.
`RELEASE_CYCLE.md` Step 3 names the command in the stop rule, and `changelog.d/1345.md` records both pull requests of the item.
Closes #1345
* fix(github): filing review threads opens no second issue, refuses an unknown --keep, and trusts only its own replies
A `--keep` id that names no unresolved thread now stops `devops pr threads file-issues` before any write, with or without `--confirm`; a mistyped id used to leave the regression thread to be filed and resolved, so the release pull request showed no unresolved thread. The preview keeps a kept thread, and the stop rule in `RELEASE_CYCLE.md` and the task file preview with the same `--keep` flags before confirming.
The filed marker is now a whole line giving the issue's number, `<!-- devops-cli: filed as #N -->`, and counts only in a reply written by the account running the command, read once through GraphQL's `viewer`. A Copilot suggestion quoting the marker, or another person's reply holding it, no longer resolves a thread with no issue. A thread's comments past its first 50 are read by cursor, so a marker reply on a later page is found.
A rerun after a reply that failed once its issue was open opens no second issue: the thread is matched to the open issue whose body ends a line with the link to its first comment, read once through the store, and gets the reply and the resolve. A failed reply or resolve names the thread and the issue already opened, and each thread is printed as it is done, so a run that fails part-way has named what it filed.
A merged or closed release pull request is refused before its threads are read, through one `require_open_release_pr` in `pr_branches.py` that `devops pr copilot-pass` now shares, both reading the pull request through `pr_monitor.fetch_pr_details`, no longer private. `source/agent` goes only on a thread Copilot started, and the help and the stop rule say a person runs the command. A deleted author is `ghost`, a thread a push moved off the diff is placed by its `originalLine`, a thread on a whole file is told apart by its first comment's id, and an outdated thread is marked in what the command prints.
The tests' GraphQL stand-in answers each query with only the fields it selects, read with graphql-core's parser, so a query that stopped selecting `url` now fails the link and rerun tests.
Closes #1345
* fix(github): filing review threads plans its issue listing as the GitHub session reads it
Since #1690 the roadmap store reads its REST listings through the GitHub session, and the gh page helper `devops pr threads file-issues` built its dry-run entry from is gone. The plan now takes that entry from the store's own plan of its issue listing, `StoreRequests.issues`, so it shows the session's `GET` of the listing, read per page while GitHub links a next one, under the same condition as before, and still comes from the builders the real run uses.
The tests open the GitHub roadmap store as the command does: its gh commands go to the scripted stand-in, which answers the issue it opens in the shape GitHub's REST API returns from a recorded one, and its issue listing goes through the GitHub session, `RunnerSession` asking the stand-in. Over the real session and the `github_api` fake, a run lists the issues once and names the open issue that ends a line with the thread's link, not one whose link only begins with it nor a closed one; a page that holds no list stops the run before any write; and `--dry-run` makes no request through gh or the session.
Closes #1345
* fix(test): isolate review stall cache state and report dispatch exception types (Closes #1609) (#1696)
* fix(deps): aiohttp 3.14.5 clears three advisories that failed every devops ci audit, and the maintain test runs no real uv audit (#1698)
aiohttp moves from 3.14.3 to 3.14.5, which carries the fixes for GHSA-494j-54xm-rwp3, GHSA-5wr8-gcqf-gqf3 and GHSA-2g87-pp6c-29x5, and yarl from 1.24.5 to 1.25.1, which aiohttp 3.14.5 requires; no other package moves. `uv audit`, and with it the audit check of `devops ci`, the pre-push gate and every pull request's CI, passes again.
`test_ci_maintain_live` patched `_run` but not `_returncode`, through which `devops ci maintain` runs the audit check's command, so the test ran a real `uv audit` against the live advisory database and failed as soon as the advisories were published. It now patches `_returncode` and asserts that maintain ran exactly the audit check's command; what the audit's exit codes mean stays covered offline by `test_maintain_audits_with_uv_audit_and_says_whether_the_audit_ran`.
Closes #1697
* fix(roadmap): the job clone and change filter fail closed when the session login lookup fails (Closes #1409) (#1699)
* refactor(test): in-memory model fake and contract suite (Part of #1001) (#1700)
* test(cli): tests wait for a background thread with one generous bound, not a 1-second deadline (#1701)
A test that waited for another thread gave it 1 or 2 seconds, and under load a ready thread can wait longer than that for a CPU. tests/support/waits.py now holds THREAD_HANDOFF_BOUND_SECONDS (30 s) and wait_until, which checks its deadline after each sleep and before the next read. Every wait that expects its event in the touched files uses the bound: the 32 of the issue grep's 38 matches that are such waits, the 1 s and 2 s polls in test_ai_request_priority.py and test_harness.py, the 0.1 s sleep before test_prometheus_metrics_export reads /metrics, a 5 s drain timeout, the harness's 20 s poll, and the files' other 3-10 s waits. A wait returns when its event fires, so a passing test is no slower.
A hold a test relies on outlives every wait that observes it, or records that the test released it: the #958 group members sleep ten times the bound, and the held Service rounds, slot holders, searches, replies and the quiet log read record their release and assert it. With a hold on its observer's bound, a mutant of the code each test guards passed.
Three of the failures had other causes. The tracer's exporter threads posted trace exports through the patched httpx2.Client.post and took a worker's place at the barrier in test_once_the_model_answers_lookups_stop_taking_turns, so only embedding requests meet there now. In test_every_worker_refused_for_one_reset_logs_one_wait_line and test_a_budget_refusal_in_the_model_lane_holds_the_release_lane_too a refusal could come before the other worker took its batch and hold it; the refusals now wait until the rounds the tests need have started.
docs/TESTING.md gains the rules for waiting on another thread and lists waits.py among what exists today. The four short windows that check nothing happens stay, each opened after an asserted, bounded wait for the competing thread and each with a comment. Two grep matches were no waits: limiter.acquire(1.0) now names tokens=, and github.comments.get(1) reads get(1, []).
The amendment folded into the issue: tests/conftest.py sets OPENBLAS_NUM_THREADS=1 before its own imports, and test_ci_repeat.py imports numpy.random in the fixture that uses it, so a 16-worker run holds 2 threads per worker at collection (briefly 3 while OpenTelemetry's resource detection runs) instead of 17. devops ci test --repeat loads pytest-randomly, which imports numpy before the conftest runs, so that one process keeps OpenBLAS's per-CPU threads. The embeddings tests' fixture now answers Qdrant's collection check, which looked up the Qdrant host (refused by the suite's guard) and slept through about 3 s of retries.
tests/test_server_service.py and tests/test_review_embeddings_unserved.py passed 17 of 20 runs before and 20 of 20 after with -n logical on a shared host.
Closes #1664
* refactor(ai): provider adapters over pydantic-ai models with egress factory (Part of #1001) (#1702)
* feat(test): every tests/support module registers as a plugin, and a change to one selects the tests it reaches (#1703)
The root conftest's one pytest_plugins entry names tests.support.bootstrap, whose trylast pytest_configure isolates HOME and then registers every submodule and subpackage of tests.support as a plugin, so a fixture defined there reaches every test and a support module that imports devops-cli binds its paths under the isolated HOME. The registration fails the run, naming the module and the attribute, when pytest finds a fixture or hook in a module whose source the test selector cannot see one in, as for a fixture made by a decorator factory or through getattr, or imported under a new name. The conftest marks tests.support for assertion rewriting before its entry, and filterwarnings turns PytestAssertRewriteWarning into an error. The workspace tripwire moves to tests/support/workspace_tripwire.py with public helper names and reads pytest's rootpath, the GitHub identity moves to tests/support/github_identity.py, and verify_test_paths_isolated, its helper, its test and CONST_ISOLATED_TEST_ENV_KEYS are deleted, since the check read only paths the suite's own fixtures set.
A change under tests/support/ no longer runs the whole suite by its path alone. SuiteImports reads the test tree with ast once, following imports inside functions and the packages each module runs first: a helper module that defines a fixture or binds a pytest_* name, that a conftest or such a helper imports, or that cannot be read, reaches every test, and any other selects the test modules that import it, directly or through other modules. A package directory that holds no test module is never handed to pytest. Two invariants keep the rule's premises: a helper module under tests/ does nothing on import but bind names, and no module but bootstrap holds the tests.support package itself. A tests/support/paths.py change now runs 67 test modules and 2767 test IDs instead of all 483 modules. docs/TESTING.md states the rule and drops the target mark on the registration. devops ci test and the coverage index share forces_full_run, and devops test shares SuiteImports. devops test run --changed lists renames with --no-renames, so a helper renamed away reaches every test through its old path, and devops ci test forces a full run when a helper module the coverage index knew is gone.
Part of #1312
* refactor(ai): consolidate LLM client construction into client factory (Part of #1001) (#1704)
Consolidate LLMClient instantiation into get_llm_client in src/devops_cli/ai/client/factory.py, building clients per task with active settings, task-specific configurations, API keys, and model overrides.
Delete get_llm_client from src/devops_cli/config/settings.py to eliminate coupling from config into ai/client, and route all inline LLMClient constructions across src/devops_cli to get_llm_client. Add comprehensive factory test suite in tests/test_ai_client_factory.py.
Part of #1001
* refactor(ai): model_fake fixture and factory seam registration (Part of #1001) (#1705)
Register the model_fake fixture in tests/conftest.py and integrate it with the client factory seam (_client_override in src/devops_cli/ai/client/factory.py).
Add preload_models, chat_structured, and chat_messages_stream ducking to ModelFake, add comprehensive fixture test suite in tests/test_model_fixture.py, and migrate existing tests in test_instruction_generator.py and test_roadmap_refine.py away from internal LLMClient patches.
Part of #1001
* test(cli): shared builders, example modules and borrowed test data live under tests/support (#1706)
tests/support/builders.py builds the objects tests make most often (a review finding or saved finding, a verdict, a board item, a Release, a candidate and a changelog fragment), each through its type's own constructor or parser, so an override the type refuses raises the type's own error, and a key that is no field of a model raises TypeError naming it. The changelog reader's checks become the public parse_changelog_fragment, which the reader and the fragment builder share, so …
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.
The second of #983's seven pull requests: the GitHub session reads REST listings page by page. It also returns the release branch to green.
The release tip. #1660 (#879) dropped the
**Status**,**Milestone**and**Priority**lines from every task file, andtests/test_agent_task_files.pynow rejects them. #1661 was branched before #1660 and merged after it, so it leftdocs/agent/tasks/task-983-github-session-transport.mdin the old format, and the test fails at 2c6be2e. The first commit removes those three lines.GitHubSession.paginate(path, *, iterable_key=None). A lazy, synchronous iterator over every item of a listing.rest(): every page goes through the same pacing, ledger charge, retries, origin hook and error classes.Link: rel="next", whether by page number or by cursor. A link to another origin is refused before anything is sent.run_gh's loop,github/projects.py, the roadmap store's listings), a listing stops atDEFAULT_GH_MAX_PAGINATED_PAGES. A listing still linking a next page past the cap raisesGitHubUnreadErrornaming the endpoint and the cap, so arel="next"chain that never ends cannot loop forever. The cap is read when the listing starts, not bound as a default argument, so a test that patches it takes effect.iterable_key(check_runs,workflow_runs,items), and the items come out as one flat sequence. An empty page or one without a next link ends the listing.GitHubUnreadErrornaming the endpoint, the page number and the type GitHub returned. That covers an HTML page, an error object, a missing body, a wrapped page without its key and a truncated body. gidgethub's owngetiteris not used, because in 6.0.0 it iterates a string's characters or a dict's keys and defaultsiterable_keytoitems.First callers. In
src/devops_cli/github/issues.py:_fetch_issues_restbuilds its query withurlencode, so labels are encoded, and stops paging oncelimitissues are kept._resolve_milestone_numberstops at the matching title._parse_milestones_responseis deleted.GitHubOperationErrorsubclasses), where before a body that was not JSON read as no issues or as an unknown milestone.ADR 0006 gains a pagination bullet, and the task file ticks PR 2's criteria. As a Part of pull request it adds no changelog fragment.
Verification
paginate, the readers still usedgh api --paginate, and the fallback test ran out of scripted gh answers.github_apifake intests/test_github_session.py,tests/test_github_issues.pyandtests/test_gh_issues_milestones.pycover:Linkwith no request sent;tests/test_agent_task_files.pypasses again.git diff origin/release/v0.2.37 -- src/devops_cli/http/is empty.uv run devops cipassed (pre-push hook). The fail-to-pass check run on this pull request reports the tests that fail on the base.Part of #983