Repository navigation
Description
Ready: implementation plan (refined 2026-10-17 at 3dd7fa6)
The plan is in this comment, because the body has no room for it. It supersedes any text below that conflicts with it.
Problem
Lines cited at dcafadf.
At 132ecc5, ai/mcp/server.py:2050 is :2073, and in config/constants.py :2296-2299 is :2297-2300, :2505 is :2539, :2512-2518 is :2546-2552 and :3003 is :3037; every other cited line is unchanged.
- Nothing enforces the library rule, and three AGENTS.md lines point the other way. AGENTS.md asks for the standard library and official parsers (:20, :25, :383-386), but no gate checks it, and:
- :22 allows string or regex matching over "closed, exhaustive domains defined by official RFCs", so
startswith("169.254.")reads as compliant; - :24 makes "declare it in
config/constants.py" the compliance step, so cleanups such as feat(k8s): support fqdn addressing, template rendering, and cloudflare management #653, feat(devcontainer): configure extensions, integrate structural invariants, and migrate profiles to daemonsets (#722) #723 and fix(security): unify cloud metadata predicate and harden path validation (#701) #760 moved lists instead of deleting them; - :380 lists "protocol regexes" among the constants.
- :22 allows string or regex matching over "closed, exhaustive domains defined by official RFCs", so
- Scale. The 12 ast-grep rules below, run over
srcat dcafadf, report 114 rule hits on 103 lines in 46 files, with 3 false positives. The rules as written in this issue were re-run offline and reproduce exactly those counts. The hits include defects nobody had filed, for exampleurlparse(url).netloc.split(":")[0]returning[for an IPv6 host (ai/harness/agents.py:392), protocol detection by":4317" in self.endpoint(telemetry/tracer.py:709), and the same443 if … else 80default-port table five times (ai/benchmark/runner.py:60, commands/k8s/networking.py:223, core/validation.py:250, sandbox/probe.py:490, telemetry/waterfall.py:139). - Fixes keep adding them. Of the 134 fix PRs merged into release/v0.2.22 to v0.2.25 (2026-09-19 to 2026-10-03), at least 10 added one; the count is a lower bound, because lists read through constants are missed. Examples:
- fix(security): unify cloud metadata predicate and harden path validation (#701) #760 ("unify cloud metadata predicate") added four
startswith("169.254.")branches (core/validation.py:80, :86, :93, :103) and moved the literals to config/constants.py:2296-2299. On Python 3.14,ip_address("::ffff:169.254.169.254").is_link_localis already True, and, run offline at dcafadf,validate_url(u, allow_private=True)still letshttp://2852039166/andhttp://0xa9fea9fe/(both 169.254.169.254) through. - fix(ai): client timeouts take effect, replies are read under the size limit, and remote models go where their settings say (#960) #1077 added
_is_loopback_hostwith one more hand-written host canonicaliser,.strip().lower().strip("[]").rstrip(".")(core/validation.py:330). The same bracket, dot and case steps already stood at core/validation.py:83 and :154, sandbox/probe.py:57 and telemetry/waterfall.py:130. - fix(ai): the embedding benchmark takes no endpoint from an MCP client and counts failed embeddings as failures (#954) #1072 built the AI-key trust boundary on a default-port table (
_url_origin, ai/benchmark/runner.py:56-63) and a substring guard that refuses an MCP model string naming any endpoint (ai/mcp/server.py:2050 overCONST_MODEL_ENDPOINT_MARKERS, config/constants.py:269).httpx2.URL(u).originreplaces the port table; the substring guard goes once one parser readsmodel@endpoint(fix(security): URL and host:port reads use the sending client's parser, so key trust, crawls, probes and settings act on the host actually dialled #1112). - Issue bodies prescribed the same pattern until rewritten: fix(security): egress guards refuse cloud metadata in every numeric, NAT64 and provider form, classified by ipaddress and one maintained library #897 proposed a hand-written embedded-IPv4 helper and cited AGENTS.md:21-24 as permission, and fix(security): local names come from the public suffix list, and domains match on DNS labels, not string suffixes #887 a literal list of special-use names.
- fix(security): unify cloud metadata predicate and harden path validation (#701) #760 ("unify cloud metadata predicate") added four
- The replacement libraries were already locked, and nothing asks a builder to look. httpx2 2.13.0 is a direct dependency (
URL.originis public since 2.11.0); pydantic-ai 2.35.0 is direct and ships a cloud-metadata and NAT64 classifier; docker 7.2.0 is direct and shipsdocker.utils.parse_host. - The review throws out exactly these findings. Two deterministic checks mark a finding INVALIDATED by matching substrings of its title and description, and run in
early_checks(src/devops_cli/ai/review/verification.py:1543-1544). Neither reads the cited code, so each dismisses any finding worded this way, whatever the code holds:_check_localhost_default_url_hallucination(:1116-1132) fires when the text holds "localhost" or "127.0.0.1", plus "default" or "config", plus "ssrf", "insecure default" or "arbitrary internal"._check_posix_signal_zero_liveness_hallucination(:1135-1150) fires when the text holds "os.kill", "signal 0" or "process signal" plus "race condition", "pid", "reuse" or "liveness", so it dismisses findings shaped like fix(cli): argo ignores the namespace, and workspace, devcontainer, port-forward, tls, drift-report and label state handling #961.- An offline run at dcafadf marked both synthetic fixtures under "Review" below INVALIDATED, by
deterministic:localhost_default_configanddeterministic:posix_signal_zero_liveness. - tests/test_common_hallucinations_hardening.py:272-317 pins both. Their catalogue twins, HALLUCINATION-LOCALHOST-DEFAULT-CONFIG and HALLUCINATION-POSIX-SIGNAL-ZERO-LIVENESS (ai/review/common_hallucinations.json:755 and :778), state the same stances, and the verification prompt repeats the second (ai/tasks/verify_finding_system.md:33).
- The generated copies carry the old rule. The AGENTS.md template in src/devops_cli/ai/instruction_generator.py (:264-266 "Avoid custom workarounds", :301-308), which
devops ai agents --templateand devcontainer scaffolding use (commands/devcontainer.py:180, :887, :1133); the LLM path's Step 3 (src/devops_cli/ai/tasks/generate_agents.md:10-14), which has no library rule; and the knowledge-base tenet it reads (src/devops_cli/ai/knowledge_base/devops_cli/architecture.md:29).
Acceptance criteria
Rules
.ast-grep/rules/holds exactly these 12 rules, one file each, withlanguage: python,severity: errorand a message that names the library. Hits are distinct rule-and-line pairs at dcafadf; ast-grep itself prints 124 matches, because chained calls such as.replace(...).replace(...)match more than once on one line.
| Rule | Matches | Hits | Message names |
|---|---|---|---|
net-scheme-in |
"…://…" in x or not in x |
14 | urllib.parse.urlsplit(value).scheme |
net-scheme-affix |
startswith, endswith, removeprefix, removesuffix or replace with an argument holding ://, starting unix:, or an IPv4 prefix such as "169.254." |
27 (debatable: ai/agents/media.py:184 and security/vault_broker.py:53, the project's own schemes) | urlsplit, docker.utils.parse_host, jeepney, ipaddress |
net-bracket-affix |
startswith("[") / endswith("[") inside a boolean expression that also holds a : string |
3 | urlsplit(value).hostname, httpx2.URL(value).host, ipaddress |
net-domain-suffix |
endswith / removesuffix on a value named like host, domain, netloc, server, endpoint, url, addr or fqdn, with a .-leading argument (".x", f".{d}", "." + d) |
10 | dns.name is_subdomain, tldextract |
net-ip-literal |
a comparison involving an IPv4 or IPv6 literal or CIDR | 5 (false positive: ai/review/defects.py:693; debatable: security/tflint.py:63) | ipaddress.ip_address properties, ip_network membership |
net-address-list |
a set, tuple or list holding an IPv4 literal with an IPv6 literal or "localhost", an IPv6 literal with "localhost", a bare scheme ("http://") or "://" |
23 (false positives: models/tls.py:51, config/defaults.py:189) | ipaddress, urlsplit; provider data as ipaddress constants with source cited |
net-domain-list |
an assignment to a domain- or tld-named target whose value holds a .-leading string |
1 | tldextract, dns.name |
net-normalise |
strip/lstrip/rstrip with "[]", or with "." in a chain that contains .lower() |
9 | httpx2.URL(value).host, urlsplit(value).hostname, ipaddress, dns.name.from_text |
net-hostport |
split/rsplit/partition/rpartition on ":" or "@" of a value named like host, netloc, addr, endpoint, server or authority |
3 | urlsplit (.hostname, .port, .username), urlsplit("//" + authority), httpx2.URL |
net-port-table |
443 if … else 80, 80 if … else 443 |
5 | httpx2.URL(value).origin |
net-cidr-build |
an f-string ending }/32 or }/128 |
1 | ipaddress.ip_network(value, strict=False).with_prefixlen |
net-url-build |
an f-string scheme://{…} whose first field names a host, addr, address, ip, netloc, url, target or endpoint |
13 | httpx2.URL(scheme=..., host=..., port=...), copy_with, join |
- Each rule has at least one valid and one invalid case in
.ast-grep/rule-tests/<rule-id>-test.yml, anduv run ast-grep test --skip-snapshot-testspasses (measured: 12 passed in about 26 ms). - The root
sgconfig.ymlholds onlyruleDirs: [.ast-grep/rules]andtestConfigs: [{testDir: .ast-grep/rule-tests}].
Rule files (verified with ast-grep 0.45.3 against src at dcafadf: 114 rule hits, 103 lines, 46 files)
# .ast-grep/rules/net-scheme-in.yml
id: net-scheme-in
language: python
severity: error
message: Scheme detected by substring. Read it with urllib.parse.urlsplit(value).scheme.
rule:
any:
- pattern: $S in $X
- pattern: $S not in $X
constraints:
S:
kind: string
regex: "://"
# .ast-grep/rules/net-scheme-affix.yml
id: net-scheme-affix
language: python
severity: error
message: Prefix or suffix test on a scheme or an address. Read the scheme with urllib.parse.urlsplit(value).scheme, container-engine endpoints (Podman or Docker) with docker.utils.parse_host and D-Bus addresses with jeepney; classify addresses with ipaddress (is_link_local, is_loopback, is_private).
rule:
kind: call
all:
- has:
field: function
kind: attribute
has:
field: attribute
regex: ^(startswith|endswith|removeprefix|removesuffix|replace)$
- has:
field: arguments
has:
stopBy: end
kind: string
regex: '://|^["'']unix:|^["'']\d{1,3}\.(\d{1,3}\.){0,2}["'']$'
# .ast-grep/rules/net-bracket-affix.yml
id: net-bracket-affix
language: python
severity: error
message: IPv6 brackets handled by hand. urllib.parse.urlsplit(value).hostname or httpx2.URL(value).host returns the bare host; parse it with ipaddress.ip_address.
rule:
kind: call
all:
- has:
field: function
kind: attribute
has:
field: attribute
regex: ^(startswith|endswith)$
- has:
field: arguments
has:
kind: string
regex: '^["'']\[["'']$'
- inside:
kind: boolean_operator
stopBy: end
has:
stopBy: end
kind: string
regex: ':'
# .ast-grep/rules/net-domain-suffix.yml
id: net-domain-suffix
language: python
severity: error
message: Domain matched by string suffix. Use dns.name.from_text(host).is_subdomain(dns.name.from_text(domain)); public-suffix questions go to tldextract.
rule:
kind: call
all:
- has:
field: function
kind: attribute
all:
- has:
field: attribute
regex: ^(endswith|removesuffix)$
- has:
field: object
regex: (?i)(host|domain|netloc|server|endpoint|url|addr|fqdn)
- has:
field: arguments
has:
stopBy: end
kind: string
regex: '^f?["'']\.'
# .ast-grep/rules/net-ip-literal.yml
id: net-ip-literal
language: python
severity: error
message: Comparison with an IP address literal. Parse with ipaddress.ip_address(host) and test is_loopback, is_link_local, is_private, or membership in an ipaddress.ip_network.
rule:
kind: comparison_operator
has:
stopBy: end
kind: string
regex: '^["''](\d{1,3}(\.\d{1,3}){3}(/\d+)?|[0-9a-fA-F]*:[0-9a-fA-F:]*:[0-9a-fA-F]+(/\d+)?)["'']$'
# .ast-grep/rules/net-address-list.yml
id: net-address-list
language: python
severity: error
message: Literal list of addresses, loopback names or schemes. Classify with ipaddress (is_loopback, is_link_local, is_private, is_global) and read schemes with urllib.parse.urlsplit; data no library knows is a constant of ipaddress objects with its source cited.
utils:
ipv4:
kind: string
regex: '^["'']\d{1,3}(\.\d{1,3}){3}(/\d+)?["'']$'
ipv6:
kind: string
regex: '^["''][0-9a-fA-F]*:[0-9a-fA-F:]*:[0-9a-fA-F]*(/\d+)?["'']$'
localhost:
kind: string
regex: '^["'']localhost["'']$'
scheme:
kind: string
regex: '^["''][a-z][a-z0-9+.-]*://["'']$|^["'']://["'']$'
rule:
all:
- any:
- kind: set
- kind: tuple
- kind: list
- any:
- all:
- has: {matches: ipv4}
- any:
- has: {matches: ipv6}
- has: {matches: localhost}
- all:
- has: {matches: ipv6}
- has: {matches: localhost}
- has: {matches: scheme}
# .ast-grep/rules/net-domain-list.yml
id: net-domain-list
language: python
severity: error
message: Literal list of domain suffixes. Use tldextract (Public Suffix List) or dns.name is_subdomain.
rule:
kind: assignment
all:
- has:
field: left
regex: (?i)(domain|tld)
- has:
field: right
has:
stopBy: end
kind: string
regex: '^["'']\.[a-z]'
# .ast-grep/rules/net-normalise.yml
id: net-normalise
language: python
severity: error
message: Host canonicalised by hand. httpx2.URL(value).host or urllib.parse.urlsplit(value).hostname drops brackets and lower-cases; ipaddress.ip_address and dns.name.from_text give the canonical form.
rule:
kind: call
all:
- has:
field: function
kind: attribute
has:
field: attribute
regex: ^(strip|rstrip|lstrip)$
- any:
- has:
field: arguments
has:
kind: string
regex: '^["'']\[\]["'']$'
- all:
- has:
field: arguments
has:
kind: string
regex: '^["'']\.["'']$'
- regex: '\.lower\(\)'
# .ast-grep/rules/net-hostport.yml
id: net-hostport
language: python
severity: error
message: Host, port or userinfo split by hand. Use urllib.parse.urlsplit(value) (.hostname, .port, .username), urlsplit("//" + authority) for a bare authority, or httpx2.URL(value).
rule:
any:
- pattern: $R.$M($SEP)
- pattern: $R.$M($SEP, $$$REST)
constraints:
M:
regex: ^(split|rsplit|partition|rpartition)$
SEP:
kind: string
regex: '^["''][:@]["'']$'
R:
regex: (?i)(host|netloc|addr|endpoint|server|authority)
# .ast-grep/rules/net-port-table.yml
id: net-port-table
language: python
severity: error
message: Default-port table. httpx2.URL(value).origin fills in the scheme's default port.
rule:
any:
- pattern: 443 if $C else 80
- pattern: 80 if $C else 443
# .ast-grep/rules/net-cidr-build.yml
id: net-cidr-build
language: python
severity: error
message: CIDR built as text. Use ipaddress.ip_network(value, strict=False).with_prefixlen.
rule:
kind: string
regex: '^f["''].*\}/(32|128)["'']$'
# .ast-grep/rules/net-url-build.yml
id: net-url-build
language: python
severity: error
message: URL authority built with an f-string. Build it with httpx2.URL(scheme=..., host=..., port=...), which brackets IPv6 hosts, or httpx2.URL.copy_with / join.
rule:
kind: string
regex: '(?i)^f["''][a-z][a-z0-9+.-]*://\{[a-z_.]*(host|addr|address|ip|netloc|url|target|endpoint)'Rule test files (all 12 pass)
# .ast-grep/rule-tests/net-address-list-test.yml
id: net-address-list
valid:
- 'METADATA = frozenset({ipaddress.ip_address("169.254.169.254")})'
- 'EXTENSIONS = (".yaml", ".yml")'
invalid:
- 'LOOPBACK = {"localhost", "127.0.0.1", "::1"}'
- 'MARKERS = ("@", "://")'
- 'SCHEMES = ("http://", "https://")'
# .ast-grep/rule-tests/net-bracket-affix-test.yml
id: net-bracket-affix
valid:
- 'host = urlsplit(url).hostname'
invalid:
- 'is_v6 = host.startswith("[") and ":" in host'
# .ast-grep/rule-tests/net-cidr-build-test.yml
id: net-cidr-build
valid:
- 'cidr = ipaddress.ip_network(value, strict=False).with_prefixlen'
invalid:
- 'cidr = f"{clean}/32"'
- 'cidr = f"{clean}/128"'
# .ast-grep/rule-tests/net-domain-list-test.yml
id: net-domain-list
valid:
- 'LOCAL_DOMAIN = "example.com"'
invalid:
- 'LOCAL_DOMAIN_SUFFIXES = (".internal", ".home.arpa")'
# .ast-grep/rule-tests/net-domain-suffix-test.yml
id: net-domain-suffix
valid:
- 'inside = dns.name.from_text(host).is_subdomain(dns.name.from_text("example.com"))'
- 'is_yaml = filename.endswith(".yaml")'
invalid:
- 'inside = host.endswith(".example.com")'
- 'inside = hostname.endswith(f".{domain}")'
- 'inside = netloc.endswith("." + domain)'
# .ast-grep/rule-tests/net-hostport-test.yml
id: net-hostport
valid:
- 'host = urlsplit(url).hostname'
- 'key, value = line.split(":", 1)'
invalid:
- 'host = urlparse(url).netloc.split(":")[0]'
- 'host, _, port = endpoint.rpartition(":")'
# .ast-grep/rule-tests/net-ip-literal-test.yml
id: net-ip-literal
valid:
- 'local = ipaddress.ip_address(host).is_loopback'
invalid:
- 'local = host == "127.0.0.1"'
- 'local = host in ("::1",)'
# .ast-grep/rule-tests/net-normalise-test.yml
id: net-normalise
valid:
- 'host = httpx2.URL(url).host'
- 'name = value.strip().lower()'
invalid:
- 'host = value.strip("[]")'
- 'host = value.lower().rstrip(".")'
# .ast-grep/rule-tests/net-port-table-test.yml
id: net-port-table
valid:
- 'origin = httpx2.URL(url).origin'
invalid:
- 'port = 443 if scheme == "https" else 80'
- 'port = 80 if plain else 443'
# .ast-grep/rule-tests/net-scheme-affix-test.yml
id: net-scheme-affix
valid:
- 'secure = urlsplit(url).scheme == "https"'
- 'is_meta = ipaddress.ip_address(host).is_link_local'
invalid:
- 'secure = url.startswith("https://")'
- 'is_meta = host.startswith("169.254.")'
- 'path = address.removeprefix("unix:path=")'
# .ast-grep/rule-tests/net-scheme-in-test.yml
id: net-scheme-in
valid:
- 'has_scheme = urlsplit(url).scheme in ("http", "https")'
invalid:
- 'has_scheme = "://" in url'
- 'bare = "://" not in url'
# .ast-grep/rule-tests/net-url-build-test.yml
id: net-url-build
valid:
- 'url = str(httpx2.URL(scheme="http", host=host, port=port))'
- 'message = f"see {host} for details"'
invalid:
- 'url = f"http://{host}:{port}"'
- 'url = f"http://{node_ip}:{node_port}"'Gate
ast-grep-cli==0.45.3is in thedevdependency group (pyproject.toml:64-77), installed the wayactionlint-pyis. Commands call the binaryast-grep, neversg, which on Linux is the shadow-utils group command.- Three new constants in src/devops_cli/config/constants.py back the gate and its meta-test:
CONST_NET_CONSTRUCT_RULES: the 12 rule ids above;CONST_AST_GREP_SCAN_ARGS:("scan", "--error=unused-suppression", "--error=no-suppress-all", "src");CONST_BANNED_HAND_ROLLED_APIS: the foursocketfunctions banned under TID251 below.
- The two commands below land as one
constructsrow of refactor(ci): github ci runs the gate throughdevops cifrom one check table #843's check table, whichdevops ciand GitHub CI both run (refactor(ci): github ci runs the gate throughdevops cifrom one check table #843 makes the static job run the gate throughdevops ci, with a parity test over the table). If this item lands before refactor(ci): github ci runs the gate throughdevops cifrom one check table #843, refactor(ci): github ci runs the gate throughdevops cifrom one check table #843 carries the row. There is no separate task entry incommands/ci.pyand no separate step in.github/workflows/ci.yml. The row builds the scan command as["uv", "run", "ast-grep", *CONST_AST_GREP_SCAN_ARGS].uv run ast-grep scan --error=unused-suppression --error=no-suppress-all srcuv run ast-grep test --skip-snapshot-tests
- The same two commands run as hooks in the
repo: localblock of .pre-commit-config.yaml (:45) withlanguage: systemandpass_filenames: false. The hooks calluv run ast-grepdirectly, notdevops ci, because importing devops_cli costs about five seconds (the comment at .pre-commit-config.yaml:47-51). - The step takes 1 s of wall time or less (measured 0.25-0.27 s on an idle host and 0.43-0.50 s at load average 20), and passes under
unshare -rn, with no network. ast-grep sends no telemetry. - The generated CLI docs reflect the new row (
uv run devops docs checkpasses), and the gate lists at AGENTS.md:60 and docs/SELF_IMPROVEMENT.md:332 nameconstructs. docs(agents): instruction surfaces state only what is true, anddevops ai agentsnever overwrites AGENTS.md #840 replaces gate counts with "every checkdevops ciruns"; whichever lands second rebases.
Baseline
- Every hit left after this item's own deletions carries
# ast-grep-ignore: <rule-id>[, <rule-id>…]on its own line directly above the hit, at the hit's indentation, listing every rule that hits that line.- The markers are generated by a one-off script from
uv run ast-grep scan --json=stream srcon the PR's tree, grouping rule ids by start line; ast-grep has no--add-noqa. - At dcafadf this is 110 rule ids on 99 lines in 42 files: the 114 / 103 / 46 above, less the four hits this item deletes (ai/review/verification.py:1118, ai/review/common_hallucinations.py:732, models/tls.py:51, config/defaults.py:189). Recount at the merge base, which holds feat(cli): extend the ruff rule set to the correctness families #420 (see TID251 below) and any burn-down item that landed first.
- The markers are generated by a one-off script from
- Same-line markers are not used. On a copy of the tree they left 5 hits unsuppressed on continuation lines inside parenthesised expressions (core/validation.py:80 and :93, security/reference_extractor.py:739 and :747, core/paths.py:190), raised 5
unused-suppressionerrors there, and maderuff formatrewrite 29 files. - Measured on a copy with line-above markers: the scan exits 0 with both
--errorflags,ruff checkpasses, andruff formatre-wraps one generator expression (security/reference_extractor.py near :973). The scan still passes after that re-wrap. In the PR,ruff checkandruff format --checkpass. - The only permanent marker is ai/review/defects.py:693, where HCL mutation seeding tests a line for an existing
"0.0.0.0/0". The debatable hits (security/tflint.py:63, ai/agents/media.py:184, security/vault_broker.py:53) keep baseline markers until the burn-down item for their file decides them.
Ceiling
DEFAULT_NET_CONSTRUCT_SUPPRESSION_CEILINGsits in src/devops_cli/config/defaults.py next toDEFAULT_C901_SUPPRESSION_CEILING(:694), with a comment saying it only goes down, and equals the number ofnet-rule ids in markers at merge. A marker that lists two ids counts two.- A test in tests/test_architectural_invariants.py, modelled on
_c901_suppressions(:717) andtest_c901_suppressions_stay_under_the_ceiling(:1088), countsnet-ids inast-grep-ignore:comments undersrcwith a regex (about 0.02 s; notokenize). It fails when the count exceeds the ceiling, and names the files that carry markers. - Each later item that removes markers lowers the ceiling in the same PR. The check is count ≤ ceiling, so independent PRs merge cleanly.
- This is the only ceiling for these markers. When test(cli): suppression comments may not grow unnoticed #849 lands, its
tokenizepass countsnet-rule ids inast-grep-ignoremarkers as one more suppression kind against this same constant, and replaces this item's regex count, so one count backs the ceiling. No second ceiling is declared for the same markers.
Behaviour (each shown in the PR with the command and its output; all three measured with ast-grep 0.45.3)
- Adding
if "://" in url:to a module undersrcfails the step witherror[net-scheme-in]and a message namingurllib.parse.urlsplit. - A marker above a line with no hit fails (
error[unused-suppression]). - A bare
# ast-grep-ignore, on a line or at the top of a file, fails (error[no-suppress-all]).
Meta-test
- A test in tests/test_architectural_invariants.py beside
_complexity_cap_escapes(:697) reads files only (it does not run the binary) and reports each of:sgconfig.ymlkeys other thanruleDirsandtestConfigs, orruleDirsother than[.ast-grep/rules]; this also banslanguageGlobs, which could map.pyfiles to another language;- a second
sgconfig.ymlanywhere in the checkout outside the excludedrepos/; - a rule-id set that differs from
CONST_NET_CONSTRUCT_RULES; - a rule whose
severityis noterror, or that setsfilesorignores; - a rule with no valid or no invalid test case;
- a scan command in the
constructsrow of refactor(ci): github ci runs the gate throughdevops cifrom one check table #843's check table or in .pre-commit-config.yaml that differs fromCONST_AST_GREP_SCAN_ARGS, so--off,--filter,--min-severity,--globs,--no-ignore,--rule,--inline-rules,--configand the--warning/--info/--hintoverrides cannot be added; - an ignore file that hides a source: ast-grep honours
.gitignoreand.ignore, so reuse_ignore_file_escapes(:645); - TID251 not enforced (use
_ruff_enforces, :480), a banned-api entry missing fromCONST_BANNED_HAND_ROLLED_APIS, or a per-file ignore that waives TID251.
- Each escape has a case that shows it is reported, as
test_every_complexity_cap_escape_is_reported(:1053) does for C901.
TID251
[tool.ruff.lint] select(pyproject.toml:99-101) namesTID251by its own code, and[tool.ruff.lint.flake8-tidy-imports.banned-api]banssocket.inet_aton,socket.inet_ntoa,socket.inet_ptonandsocket.inet_ntop, each with the message "Parse and format addresses with ipaddress.ip_address." There are 0 uses at dcafadf; the ban stops manual octet arithmetic from arriving. Measured with ruff 0.16.8: bothsocket.inet_aton(...)andfrom socket import inet_ptonare reported.flake8-tidy-importsis added toCONST_RUFF_LINT_KEYS(config/constants.py:3003); otherwise the existing ruff key allowlist rejects the new table.- feat(cli): extend the ruff rule set to the correctness families #420 (v0.2.26) also edits
[tool.ruff.lint] selectandCONST_RUFF_LINT_KEYS(it addsallowed-confusables); TID251 is out of its scope. This item lands after feat(cli): extend the ruff rule set to the correctness families #420, regenerates its markers on a merge base that holds feat(cli): extend the ruff rule set to the correctness families #420, and keeps feat(cli): extend the ruff rule set to the correctness families #420's key and select entries beside its own.
AGENTS.md
- AGENTS.md is edited by hand, as feat(cli): enforce the complexity cap with ruff C901 and an inline baseline that only shrinks #586 did. It is not regenerated, because
devops ai agentsrewrites the whole file (docs(agents): instruction surfaces state only what is true, anddevops ai agentsnever overwrites AGENTS.md #840 fixes that).git diff AGENTS.mdshows only the changes this item lists. - Lines :21-23 (the "Strict Prohibition of Brittle Pattern Subsets" heading and its two sub-bullets) become this bullet:
- **Parse With the Library; Hand-Rolled Parsing Is a Defect**:
- Parse and classify every structured value with the standard library or a maintained package, in this order: the standard library, a package already in `uv.lock` (declared in `pyproject.toml` when first imported), a new reputable, actively maintained package. URL parts and schemes: `urllib.parse.urlsplit`. Building URLs, origins and default ports: `httpx2.URL` and `httpx2.URL(...).origin`. Addresses and networks: `ipaddress` (`is_loopback`, `is_link_local`, `is_private`, `ipv4_mapped`, `ip_network(...).with_prefixlen`). Domain names: `dns.name` (`is_subdomain`, canonical form); public-suffix questions: `tldextract`. Container-engine endpoints, Podman's or Docker's: `docker.utils.parse_host`. D-Bus addresses: `jeepney`. File locks: `filelock`. Version specifiers: `packaging`. Trace context: the OpenTelemetry propagator. SSH host keys: OpenSSH, through `~/.ssh/known_hosts`.
- A **hand-rolled** construct re-implements one of these with strings: an affix or substring test on a scheme, host, IP prefix or domain suffix; a literal list of addresses, loopback names, schemes or domain suffixes; a split on `:`, `@` or `/` of a host or URL; `strip("[]")` or `lower().rstrip(".")` canonicalisation; an f-string URL authority or CIDR; a default-port table; a regex over one of these formats.
- Whenever a task, issue, review finding or fix touches a hand-rolled construct, the change deletes it and calls the library at that site, even when the issue's acceptance criteria or proposed answer spell out the hand-rolled form (say so in the PR). One more edge case handled inside it (a prefix, an `rstrip`, a regex branch), or a move into `config/constants.py`, keeps the defect.
- Literal matching stays right for closed sets this project defines itself (its command names, enum values, config keys); where such a table lives is set by the Matching Table Placement bullet, not by this one.
- Data a library cannot know is a constant with its source cited: a cloud's published metadata addresses as `ipaddress` objects; a vendor's published SSH host keys as its published known_hosts lines, written to `~/.ssh/known_hosts` for OpenSSH to check.
- Enforced by the `net-*` ast-grep rules (`.ast-grep/rules/`) and ruff `TID251` in `uv run devops ci`, GitHub CI and pre-commit. Sites older than the rules carry `# ast-grep-ignore: <rule-id>` on the line above; a test caps their number, and `unused-suppression` flags a marker once its site is fixed. New code carries no marker; a false positive becomes a rule test case and a rule fix.
- Review: a new hand-rolled construct is a major finding: HIGH where it decides egress, SSRF, a credential's destination, authentication or host trust; MEDIUM elsewhere.- Line :24's placement sentence keeps its wording and becomes a bullet of its own, headed "Matching Table Placement", for docs(agents): a matching table lives beside its one owner, and moves to config/ only when a second package imports it #1016 to rewrite (see the docs(agents): a matching table lives beside its one owner, and moves to config/ only when a second package imports it #1016 key question).
- Delete :383-385 (the "Standard Parsers Over Brittle Literal Collections" heading and its first two sub-bullets). Keep :386's target-agnostic sentence as a bullet of its own, because it is not about parsing. Delete the "Avoid custom workarounds…" sentence at :25. Drop
ipaddressandurllib.parsefrom :20. Line :380 reads "(system paths, project-defined identifiers)".
Template and LLM path
- The template (src/devops_cli/ai/instruction_generator.py) replaces :301-303 with the new bullet, turns :304's sentence, wording kept, into its own bullet headed "Matching Table Placement" (as in AGENTS.md), deletes :305-308, and drops the "Avoid custom workarounds" sentence at :266.
- The template serves any repository (
devops ai agents --templateand devcontainer scaffolding), so the bullet's repository-specific parts sit behindmeta.is_devops_cli, asalpha_lifecycle_block(:195-203) does. Those parts are: the library list beyondurllib.parseandipaddress, theuv.lockandpyproject.tomlwording, the nameconfig/constants.py, and the enforcement sub-bullet. Withmeta.is_devops_clithe template yields the AGENTS.md bullet exactly; for any other repository it yields:
- **Parse With the Library; Hand-Rolled Parsing Is a Defect**:
- Parse and classify every structured value with the standard library or a maintained package, in this order: the standard library, a package the project already depends on, a new reputable, actively maintained package. For example, URL parts and schemes: `urllib.parse.urlsplit`; addresses and networks: `ipaddress`.
- A **hand-rolled** construct re-implements one of these with strings: an affix or substring test on a scheme, host, IP prefix or domain suffix; a literal list of addresses, loopback names, schemes or domain suffixes; a split on `:`, `@` or `/` of a host or URL; `strip("[]")` or `lower().rstrip(".")` canonicalisation; an f-string URL authority or CIDR; a default-port table; a regex over one of these formats.
- Whenever a task, issue, review finding or fix touches a hand-rolled construct, the change deletes it and calls the library at that site, even when the issue's acceptance criteria or proposed answer spell out the hand-rolled form (say so in the PR). One more edge case handled inside it (a prefix, an `rstrip`, a regex branch), or a move into a constants module, keeps the defect.
- Literal matching stays right for closed sets the project defines itself (its command names, enum values, config keys); where such a table lives is set by the Matching Table Placement bullet, not by this one.
- Data a library cannot know is a constant with its source cited: a cloud's published metadata addresses as parsed address objects; a vendor's published SSH host keys as its published known_hosts lines, written to `~/.ssh/known_hosts` for OpenSSH to check.
- Review: a new hand-rolled construct is a major finding: HIGH where it decides egress, SSRF, a credential's destination, authentication or host trust; MEDIUM elsewhere.- A test renders the template with
meta.is_devops_clifalse and checks that this bullet names none ofconfig/constants.py,uv.lock,httpx2,docker.utils,jeepneyorast-grep. - src/devops_cli/ai/tasks/generate_agents.md Step 3 (:10-14) gains: "Define library-first parsing: URLs, hosts, IP addresses, domains, versions and paths are parsed by the standard library or a maintained dependency; a hand-rolled string or regex parser is a defect, and its fix deletes it."
- src/devops_cli/ai/knowledge_base/devops_cli/architecture.md:29 drops
ipaddressandurllib.parsefrom "Maximize standard library leverage" and adds: "Structured values (URLs, hosts, IP addresses, domains, versions) are parsed by the standard library or a maintained dependency; hand-rolled string or regex parsing is a defect."
Review (the review's deterministic layer only; see the key question on the prompt freeze)
_check_localhost_default_url_hallucinationand_check_posix_signal_zero_liveness_hallucinationare removed fromearly_checks(verification.py:1543-1544) and deleted. TheLOCALHOST/LOOPBACKbranch of_verify_general_ground_truth(ai/review/common_hallucinations.py:731-732) goes with them, because it is another substring test on the finding's prose. tests/test_common_hallucinations_hardening.py:272-317 keeps its pre-1.0 and compliment cases and drops the other two, with their imports (:18-19).- The catalogue entries HALLUCINATION-LOCALHOST-DEFAULT-CONFIG (ai/review/common_hallucinations.json:755) and HALLUCINATION-POSIX-SIGNAL-ZERO-LIVENESS (:778), which record the stances of the two deleted checks, are deleted. Neither dismisses the fixtures below through
_check_catalog_hallucination(verification.py:1490) today: the first one's category check confirms only resource-exhaustion claims, and the second one's wants syntax words. Left in place, each would be an orphan that still states its stance. - Two regression tests build synthetic findings. The deleted checks read only a finding's title and description, so a fixture need not describe a defect at its cited line:
- HIGH at
src/devops_cli/config/settings.py:10, the location the existing test uses, title "Loopback guard compares host strings and misses 127.0.0.2", description "The SSRF egress check for a configured URL compares the host with the strings localhost and 127.0.0.1, so http://127.0.0.2/ and LOCALHOST. are not treated as loopback." The wording is the point: the real loopback check,_is_loopback_host(core/validation.py:328-336), already parses the host withipaddressand treats both spellings as loopback. - MEDIUM at
src/devops_cli/k8s/port_forward_daemon.py:67-68, theos.kill(pid, 0)fallback thatis_alive(:55-71) uses where /proc cannot be read (elsewhere it compares the recorded /proc start time), title "A reused pid is signalled as a live port-forward", description "Where /proc cannot be read, the liveness test falls back to os.kill(pid, 0) on a pid read from a state file; after the forward exits the pid can be reused, so another process is reported as the live port-forward." - For each fixture, the test asserts that
_check_early_hallucinations(finding, ())returns None and that_deterministic_pre_verification(finding, repo_root=tmp_path, dependencies=(), consult_judged=False)(verification.py:1641) leaves its status UNVERIFIED. That function runs only the deterministic checks, with no model call and no network; the tests do not go through the model-backed verification path. - Measured offline at dcafadf: both fixtures come back INVALIDATED today (
deterministic:localhost_default_configanddeterministic:posix_signal_zero_liveness); with the two checks stubbed out, both stay UNVERIFIED.
- HIGH at
- A third test sends both fixtures through
_check_catalog_hallucination, the loopback one located underconfig/,ai/andcore/in turn, and asserts that none comes back INVALIDATED. Run offline at dcafadf, none does, so this test holds the line rather than fixing a failure. - verify_finding_system.md:33 keeps "
os.kill(pid, 0)tests that a process exists without signalling it" and drops "it is not a race or a security flaw" (see the key question). The("os.kill(pid, 0)", _VERIFIER)entry of_NON_DEFECTS(tests/test_review_prompt_consistency.py:100) goes with it, because the verification prompt no longer callsos.kill(pid, 0)a non-defect; the rest of that file stays green. - .devops/review.md "House rules" (:51-71) gains: "Hand-rolled network parsing: a changed line that hits a
net-*ast-grep rule or a TID251 banned API, or adds anast-grep-ignore/noqa: TID251marker, is a finding: HIGH on an egress, SSRF, credential-destination, authentication or host-trust path, MEDIUM elsewhere. Its fix deletes the construct and calls the library AGENTS.md names." - No persona, review-task or verification prompt gains a sentence.
TLS defaults
DEFAULT_HOMELAB_IPS(config/defaults.py:189) and thesansdefault ofCertGenerationRequest(models/tls.py:51) holdipaddressobjects for their addresses. Their consumers (crypto/tls_certificates.py:62-77 and :326, commands/tls.py:286) take the objects, and JSON output stays strings. This removes the 2 false positives without markers.
Release
uv run devops cipasses, and a changelog.d fragment records the new gate; CHANGELOG.md is not edited.- Pending a person: rerun the fix(review): the devsecops persona reports misconfiguration and error-handling defects again, scored against a fixed recall set #1015 recall set after the review changes, and record recall next to the previous run.
Key questions
- Is a new dev dependency acceptable? (owner decision) Proposed: yes,
ast-grep-cli==0.45.3.- It is MIT-licensed, has about 16.1k GitHub stars, and ships wheels for Linux, macOS and Windows. It had six releases from 0.44.0 (2026-06-22) to 0.45.3 (2026-08-31) and none since; its main branch had commits as late as 2026-10-03.
- It is a reputable, maintained tool, which is what the owner's 2026-10-03 rule asks fixes to use in place of hand-rolled parsers; it is still a new dependency in every CI run, so the owner confirms it.
- Its tree-sitter parser handles the 86 files that use PEP 758
except A, B:. - Its built-in
unused-suppressionandno-suppress-allchecks fill the roles RUF100 and PGH004 fill for ruff, andast-grep testgives each rule unit tests. - Rejected: a stdlib
asttest, at 2.2-2.4 s per run plus about 250 lines of home-grown detector, suppression syntax and stale-marker logic, which is the maintenance this policy removes. Also rejected: Semgrep 1.178, at 14-16 s per run, which failed to parse 30 files (PEP 758except A, B:and PEP 696 type-parameter defaults).
- Enforce first, or after the cleanup? Proposed: first, as feat(cli): enforce the complexity cap with ruff C901 and an inline baseline that only shrinks #586 did.
- Ten fix PRs added constructs in two weeks, and every burn-down item is itself a fix PR at the same risk.
- Markers give each burn-down item a checkable finish line: its markers are gone, the ceiling is lowered, and
unused-suppressioncatches a fix that leaves a stale marker. - The review has to stop dismissing these findings before it reviews the burn-down PRs.
- Cost: the PR touches the 46 files the rules hit (markers in 42 of them) and conflicts with open PRs, so it lands right after a release starts, as that release's first item PR, after feat(cli): extend the ruff rule set to the correctness families #420 and before fix(security): egress guards refuse cloud metadata in every numeric, NAT64 and provider form, classified by ipaddress and one maintained library #897. Markers are regenerated by the script on rebase.
- A burn-down item that lands before this one deletes its constructs, and the recount leaves no marker for them; one that lands after removes its markers and lowers the ceiling.
- What about the 10 use sites the rules cannot see? Proposed: accept the gap; add no
net-legacy-listrule.- ast-grep cannot follow names imported from config/constants.py, so these sites are invisible: ai/spend/pricing.py:91 and :93; commands/k8s/networking.py:267, :268, :296, :440 and :441; core/validation.py:79 and :92; docker/engine.py:234. The declarations themselves are flagged and marked.
- The burn-down items delete the six lists: config/constants.py:269 (fix(security): URL and host:port reads use the sending client's parser, so key trust, crawls, probes and settings act on the host actually dialled #1112), :2011-2018 (fix(docker): the Docker endpoint check covers the endpoint the SDK dials, including contexts and the TUI, and pushes accept registry ports #1108), :2296-2299 and :2505 (fix(security): egress guards refuse cloud metadata in every numeric, NAT64 and provider form, classified by ipaddress and one maintained library #897), and :2512-2518 (fix(security): local names come from the public suffix list, and domains match on DNS labels, not string suffixes #887).
- An interim identifier rule over those names would add 35 hits.
- Ban
fcntl.flockandfcntl.lockftoo? Proposed: not here. The 7 uses in 5 modules are not networking, and they go with the deferred filelock item (filelock 3.32.6 is already locked). So this item needs nonoqa: TID251baseline or ceiling. - Should the rules also run on repositories the review tool reviews? Proposed: not in this item. The evidence-first review can later run the same pack over a reviewed commit's changed files, offline, in about 0.25 s per 500 files. Hits on changed lines would become findings banded by the house rule, and hits on unchanged lines context for the personas.
- How does this coexist with docs(agents): a matching table lives beside its one owner, and moves to config/ only when a second package imports it #1016, which rewrites the heading and placement sentence at AGENTS.md:21-24 and template :301-304? Proposed: this item replaces :21-23 and template :301-303, and leaves the placement sentence (:24, template :304) as its own bullet. docs(agents): a matching table lives beside its one owner, and moves to config/ only when a second package imports it #1016 then rewrites only that bullet, and whichever lands second rebases. The new bullet defers placement to that bullet, and says a move into
config/constants.pydoes not fix a hand-rolled construct. - Does the "POSIX signal 0" line at verify_finding_system.md:33, which tells the verification model that
os.kill(pid, 0)"is not a race", stay as written? Proposed: no. Left as is, it still refutes a fix(cli): argo ignores the namespace, and workspace, devcontainer, port-forward, tls, drift-report and label state handling #961-shaped finding after the deterministic check is gone. Keep the true half ("tests that a process exists without signalling it") and drop "it is not a race or a security flaw", so a finding that the pid may name another process is judged on where the pid comes from. - Do review prompt additions fall under the persona and verification-prompt freeze? Decided (owner, 2026-10-03): yes. Deterministic tools originate findings and the language model correlates and plans; persona and verification-prompt additions are frozen after the v0.2.25 cut and wait for the evidence-first redesign. This item lands after that cut and adds none.
- Here the
net-*rules and TID251 originate the findings, the house rule bands them, and the deletions above stop the review from discarding them. None of that needs a model to look for hand-rolled parsing. - Left to the evidence-first redesign as input: prompt lines that would tell the personas or the verification model to flag hand-rolled parsing themselves, and the Fix field. ai/tasks/review.md:42 defines a fix as "replacement code for the cited lines", so when the cited line is the construct, the fix adds one more case to it. A fix that deletes the construct and calls the library belongs in the redesign's planning step.
- Proposed: the verify_finding_system.md:33 edit stays in this item, because it only deletes a refutation, the prompt form of the deleted check, and adds no instruction.
- Here the
Strategic alignment
- Priority P1. This is the root-cause fix the owner asked for: hand-rolled networking constructs are removed and replaced by reputable libraries, and none can come back. Burn-down items that land after it work off its baseline; without it, the next fix adds the next copy (10 in two weeks).
- Milestone: none; the roadmap tooling places it. Ordering constraint for that placement: it lands after feat(cli): extend the ruff rule set to the correctness families #420 (v0.2.26) and before fix(security): egress guards refuse cloud metadata in every numeric, NAT64 and provider form, classified by ipaddress and one maintained library #897 (v0.2.27), as the first item PR of its release, because it touches the 46 files the rules hit and conflicts with open PRs. If it is not placed ahead of fix(security): egress guards refuse cloud metadata in every numeric, NAT64 and provider form, classified by ipaddress and one maintained library #897, fix(security): egress guards refuse cloud metadata in every numeric, NAT64 and provider form, classified by ipaddress and one maintained library #897 lands without the gate and adds its own markers later.
- Evidence-first review: the
net-*rules and TID251 originate these findings, and the language model correlates and plans the fix. The review changes here stay in the deterministic layer: they delete prose-matching dismissals and add no prompt rule. - Depends on: lands after feat(cli): extend the ruff rule set to the correctness families #420. It lands before fix(security): egress guards refuse cloud metadata in every numeric, NAT64 and provider form, classified by ipaddress and one maintained library #897 (v0.2.27) and fix(security): every HTTP client dials only addresses its egress level allows, checked at the connect and on every redirect #898 (v0.2.29), which order this item first.
- Children (this item is the parent of the library-first URL, address and host parsing group; tracking only, with no blocked-by links from this item to its children, because a burn-down item that lands first simply leaves no marker):
- fix(security): egress guards refuse cloud metadata in every numeric, NAT64 and provider form, classified by ipaddress and one maintained library #897: cloud metadata and embedded IPv4 classification (absorbs fix(security): ssrf guards admit azure's wireserver metadata address 168.63.129.16 #989);
- fix(security): every HTTP client dials only addresses its egress level allows, checked at the connect and on every redirect #898: every HTTP client dials only addresses its egress level allows;
- fix(security): local names come from the public suffix list, and domains match on DNS labels, not string suffixes #887: local names from the public suffix list;
- fix(docker): the Docker endpoint check covers the endpoint the SDK dials, including contexts and the TUI, and pushes accept registry ports #1108: the Docker endpoint check;
- fix(security): URL credential masking uses urllib and httpx2, so passwords containing '@' and non-http schemes are masked and IPv6 hosts stay intact #1109: URL credential masking;
- fix(ai): replies carry their server as an httpx2 origin, so a password in an AI URL stays out of output, the spend ledger, metrics, spans and cache #1110: reply origins as httpx2 origins;
- fix(k8s): service URLs bracket IPv6 hosts, k8s:// addresses reach only their Service, and https probe targets are probed over https #1111: service URLs and probe targets;
- fix(security): URL and host:port reads use the sending client's parser, so key trust, crawls, probes and settings act on the host actually dialled #1112: URL and host:port reads use the sending client's parser;
- fix(valkey): one validated URL names every Valkey endpoint, valkey-py dials an address that one check vetted, and the unused cache layer goes #1113: Valkey endpoints through GLIDE;
- fix(git): GitHub clones trust GitHub's published host keys through OpenSSH, so junk known_hosts lines and a failed key scan no longer skip pinning #1114: GitHub host keys through OpenSSH.
- Burn-down items that delete constructs these rules flag: fix(security): egress guards refuse cloud metadata in every numeric, NAT64 and provider form, classified by ipaddress and one maintained library #897, fix(security): every HTTP client dials only addresses its egress level allows, checked at the connect and on every redirect #898, fix(security): local names come from the public suffix list, and domains match on DNS labels, not string suffixes #887, fix(docker): the Docker endpoint check covers the endpoint the SDK dials, including contexts and the TUI, and pushes accept registry ports #1108, fix(security): URL credential masking uses urllib and httpx2, so passwords containing '@' and non-http schemes are masked and IPv6 hosts stay intact #1109, fix(k8s): service URLs bracket IPv6 hosts, k8s:// addresses reach only their Service, and https probe targets are probed over https #1111, fix(security): URL and host:port reads use the sending client's parser, so key trust, crawls, probes and settings act on the host actually dialled #1112, fix(valkey): one validated URL names every Valkey endpoint, valkey-py dials an address that one check vetted, and the unused cache layer goes #1113. Each one that lands after this item removes its markers and lowers the ceiling in the same PR. fix(ai): replies carry their server as an httpx2 origin, so a password in an AI URL stays out of output, the spend ledger, metrics, spans and cache #1110 and fix(git): GitHub clones trust GitHub's published host keys through OpenSSH, so junk known_hosts lines and a failed key scan no longer skip pinning #1114 remove constructs these rules do not detect.
- Related:
- feat(cli): enforce the complexity cap with ruff C901 and an inline baseline that only shrinks #586 (closed): the pattern of an inline baseline, a ceiling that only shrinks, and a meta-test against escapes;
- feat(cli): extend the ruff rule set to the correctness families #420: shares the ruff select list and the lint-key allowlist;
- test(cli): suppression comments may not grow unnoticed #849: counts
ast-grep-ignoreas one more suppression kind against this item's ceiling (see "Ceiling"); - refactor(ci): github ci runs the gate through
devops cifrom one check table #843: carries this item'sconstructsrow; - docs(agents): a matching table lives beside its one owner, and moves to config/ only when a second package imports it #1016: table placement wording;
- docs(agents): instruction surfaces state only what is true, and
devops ai agentsnever overwrites AGENTS.md #840: gate counts anddevops ai agentsoverwriting AGENTS.md; - fix(review): the devsecops persona reports misconfiguration and error-handling defects again, scored against a fixed recall set #1015: recall set;
- fix(cli): argo ignores the namespace, and workspace, devcontainer, port-forward, tls, drift-report and label state handling #961: the shape of the second dismissed finding.
Update 2026-10-08: refinement
#420, #843, #840, #897 and #898 landed, so drop 'after #420 and before #897'; this lands first in its release and adds the constructs row itself. Recount the 114/103/46 counts. AGENTS.md lines are now :19-24 and :432-438. If #1150 lands first, the Review section keeps only the .devops/review.md house rule.
Proposed design
Problem statement
The codebase contains 114 hand-rolled URL, address, and host-parsing constructs across 46 files that should use standard-library or locked-dependency parsers. AGENTS.md both mandates and contradicts the library rule, no gate enforces it, fix PRs keep adding new copies (10 in two weeks), and the review system's deterministic checks dismiss exactly the findings that would flag these constructs.
Acceptance criteria
- Criterion 1: Twelve ast-grep rules exist in .ast-grep/rules/ with language: python, severity: error, and a message naming the replacement library; the 12 rule ids match CONST_NET_CONSTRUCT_RULES.
Verification: ls .ast-grep/rules/ shows exactly 12 .yml files; grep -l 'severity: error' .ast-grep/rules/*.yml lists all 12; each message field names at least one of urlsplit, ipaddress, httpx2.URL, docker.utils.parse_host, jeepney, dns.name, tldextract. - Criterion 2: Each rule has at least one valid and one invalid case in .ast-grep/rule-tests/-test.yml, and ast-grep test passes.
Verification: uv run ast-grep test --skip-snapshot-tests exits 0 with 12 passed. - Criterion 3: The root sgconfig.yml holds only ruleDirs: [.ast-grep/rules] and testConfigs: [{testDir: .ast-grep/rule-tests}].
Verification: cat sgconfig.yml shows exactly those two keys and no others; no second sgconfig.yml exists outside repos/. - Criterion 4: ast-grep-cli==0.45.3 is in the dev dependency group of pyproject.toml.
Verification: grep 'ast-grep-cli' pyproject.toml shows the pinned version in the dev group; uv sync installs it. - Criterion 5: Three new constants (CONST_NET_CONSTRUCT_RULES, CONST_AST_GREP_SCAN_ARGS, CONST_BANNED_HAND_ROLLED_APIS) exist in src/devops_cli/config/constants.py.
Verification: grep -n 'CONST_NET_CONSTRUCT_RULES|CONST_AST_GREP_SCAN_ARGS|CONST_BANNED_HAND_ROLLED_APIS' src/devops_cli/config/constants.py shows all three. - Criterion 6: The constructs row in the CI check table runs uv run ast-grep scan --error=unused-suppression --error=no-suppress-all src and uv run ast-grep test --skip-snapshot-tests; the same two commands run as pre-commit hooks with language: system and pass_filenames: false.
Verification: grep -A5 'constructs' in the CI check table shows both commands; grep -A5 'ast-grep' .pre-commit-config.yaml shows both hooks with the required settings. - Criterion 7: Every remaining hit after this item's own deletions carries # ast-grep-ignore: on the line directly above, at the hit's indentation; the scan exits 0 with both --error flags.
Verification: uv run ast-grep scan --error=unused-suppression --error=no-suppress-all src exits 0; grep -r 'ast-grep-ignore' src/ shows markers only on lines above hits. - Criterion 8: DEFAULT_NET_CONSTRUCT_SUPPRESSION_CEILING in config/defaults.py equals the count of net- rule ids in markers at merge, and a test in tests/test_architectural_invariants.py fails when the count exceeds it.
Verification: grep 'DEFAULT_NET_CONSTRUCT_SUPPRESSION_CEILING' src/devops_cli/config/defaults.py shows the value; uv run pytest tests/test_architectural_invariants.py -k 'net_construct' passes. - Criterion 9: A meta-test in tests/test_architectural_invariants.py reports each escape: sgconfig keys, second sgconfig, rule-id mismatch, non-error severity, missing test cases, scan-command drift, ignore-file escapes, and TID251 not enforced.
Verification: uv run pytest tests/test_architectural_invariants.py -k 'net_construct_escape' passes; each escape case has a test that shows it is reported. - Criterion 10: TID251 is in [tool.ruff.lint] select and [tool.ruff.lint.flake8-tidy-imports.banned-api] bans socket.inet_aton, inet_ntoa, inet_pton, inet_ntop; flake8-tidy-imports is in CONST_RUFF_LINT_KEYS.
Verification: grep 'TID251' pyproject.toml shows the select entry; grep 'inet_aton|inet_ntoa|inet_pton|inet_ntop' pyproject.toml shows the banned-api entries; grep 'flake8-tidy-imports' src/devops_cli/config/constants.py shows it in the allowlist; uv run ruff check --select TID251 src/ reports 0 violations. - Criterion 11: AGENTS.md lines :19-24 are replaced with the new 'Parse With the Library' bullet and the 'Matching Table Placement' bullet; :432-438 (Standard Parsers heading) is deleted; the 'Avoid custom workarounds' sentence is removed; ipaddress and urllib.parse are dropped from the standard-library-leverage line.
Verification: git diff AGENTS.md shows only the listed changes; grep 'Parse With the Library' AGENTS.md finds the new bullet; grep 'Avoid custom workarounds' AGENTS.md returns nothing. - Criterion 12: The template in instruction_generator.py replaces the brittle-pattern block with the new bullet behind meta.is_devops_cli; a test renders with is_devops_cli false and asserts no repository-specific names appear.
Verification: uv run pytest tests/ -k 'template_non_devops_cli' passes; the rendered output names none of config/constants.py, uv.lock, httpx2, docker.utils, jeepney, or ast-grep. - Criterion 13: generate_agents.md Step 3 gains the library-first parsing sentence; architecture.md:29 drops ipaddress/urllib.parse and adds the hand-rolled-is-a-defect sentence.
Verification: grep 'hand-rolled' src/devops_cli/ai/tasks/generate_agents.md finds the new sentence; grep 'hand-rolled' src/devops_cli/ai/knowledge_base/devops_cli/architecture.md finds the new sentence. - Criterion 14: _check_localhost_default_url_hallucination and _check_posix_signal_zero_liveness_hallucination are removed from early_checks and deleted; the LOCALHOST/LOOPBACK branch in common_hallucinations.py is removed; the two catalogue entries are deleted; regression tests confirm both synthetic fixtures stay UNVERIFIED.
Verification: grep -n 'localhost_default_url_hallucination|posix_signal_zero_liveness' src/devops_cli/ai/review/verification.py returns nothing; uv run pytest tests/test_common_hallucinations_hardening.py -k 'loopback_guard|reused_pid' passes with both fixtures UNVERIFIED. - Criterion 15: .devops/review.md gains the hand-rolled network parsing house rule; verify_finding_system.md:33 keeps the true half and drops 'it is not a race or a security flaw'; the _NON_DEFECTS entry for os.kill(pid, 0) is removed.
Verification: grep 'Hand-rolled network parsing' .devops/review.md finds the house rule; grep 'not a race' src/devops_cli/ai/tasks/verify_finding_system.md returns nothing; grep 'os.kill' tests/test_review_prompt_consistency.py returns nothing. - Criterion 16: DEFAULT_HOMELAB_IPS and the sans default of CertGenerationRequest hold ipaddress objects; their consumers accept the objects and JSON output stays strings.
Verification: grep 'ipaddress' src/devops_cli/config/defaults.py shows ipaddress objects in DEFAULT_HOMELAB_IPS; uv run pytest tests/ -k 'tls_cert' passes. - Criterion 17: A changelog.d fragment records the new gate; uv run devops ci passes.
Verification: ls changelog.d/ shows the fragment for this issue; uv run devops ci exits 0.
Key questions
- Is a new dev dependency acceptable?: Yes. ast-grep-cli==0.45.3 is MIT-licensed, has about 16.1k GitHub stars, ships wheels for Linux/macOS/Windows, had six releases from 0.44.0 to 0.45.3 with main-branch commits as late as 2026-10-03, handles PEP 758 except syntax, and its built-in unused-suppression and no-suppress-all checks fill the roles RUF100 and PGH004 fill for ruff. [sources: pyproject.toml:64-77]
- Enforce first, or after the cleanup?: Enforce first, as feat(cli): enforce the complexity cap with ruff C901 and an inline baseline that only shrinks #586 did. Ten fix PRs added constructs in two weeks, and every burn-down item is itself a fix PR at the same risk. Markers give each burn-down item a checkable finish line. The review must stop dismissing these findings before it reviews the burn-down PRs. The PR lands right after a release starts, as that release's first item PR. (proposed) [sources: AGENTS.md:19-24]
- What about the 10 use sites the rules cannot see (imported from config/constants.py)?: Accept the gap; add no net-legacy-list rule. ast-grep cannot follow names imported from config/constants.py. The burn-down items delete the six lists. An interim identifier rule over those names would add 35 hits. (proposed) [sources: src/devops_cli/config/constants.py:2296-2299, src/devops_cli/config/constants.py:2505]
- Ban fcntl.flock and fcntl.lockf too?: Not here. The 7 uses in 5 modules are not networking, and they go with the deferred filelock item (filelock 3.32.6 is already locked). This item needs no noqa: TID251 baseline or ceiling for them. (proposed) [sources: pyproject.toml]
- Should the rules also run on repositories the review tool reviews?: Not in this item. The evidence-first review can later run the same pack over a reviewed commit's changed files, offline, in about 0.25 s per 500 files. Hits on changed lines would become findings banded by the house rule. (proposed) [sources: docs/adr/0005-review-findings-come-from-tools-not-models.md]
- How does this coexist with docs(agents): a matching table lives beside its one owner, and moves to config/ only when a second package imports it #1016, which rewrites the heading and placement sentence at AGENTS.md:21-24 and template :301-304?: This item replaces :21-23 (now :19-21) and template :301-303, and leaves the placement sentence (:24, template :304) as its own bullet headed 'Matching Table Placement'. docs(agents): a matching table lives beside its one owner, and moves to config/ only when a second package imports it #1016 then rewrites only that bullet, and whichever lands second rebases. The new bullet defers placement to that bullet and says a move into config/constants.py does not fix a hand-rolled construct. (proposed) [sources: AGENTS.md:19-24, src/devops_cli/ai/instruction_generator.py:264-266]
- Does the 'POSIX signal 0' line at verify_finding_system.md:33 stay as written?: No. Keep the true half ('tests that a process exists without signalling it') and drop 'it is not a race or a security flaw', so a finding that the pid may name another process is judged on where the pid comes from. The edit stays in this item because it only deletes a refutation, the prompt form of the deleted check, and adds no instruction. (proposed) [sources: docs/adr/0005-review-findings-come-from-tools-not-models.md]
- Do review prompt additions fall under the persona and verification-prompt freeze?: Yes. Decided by the owner on 2026-10-03: persona and verification-prompt additions are frozen after the v0.2.25 cut and wait for the evidence-first redesign. This item lands after that cut and adds no prompt rule. The net-* rules and TID251 originate the findings, the house rule bands them, and the deletions stop the review from discarding them. None of that needs a model to look for hand-rolled parsing. (proposed) [sources: docs/adr/0005-review-findings-come-from-tools-not-models.md]
Open questions
- It is MIT-licensed, has about 16.1k GitHub stars, and ships wheels for Linux, macOS and Windows. It had six releases from 0.44.0 (2026-06-22) to 0.45.3 (2026-08-31) and none since; its main branch had commits as late as 2026-10-03.
- It is a reputable, maintained tool, which is what the owner's 2026-10-03 rule asks fixes to use in place of hand-rolled parsers; it is still a new dependency in every CI run, so the owner confirms it.
- Its tree-sitter parser handles the 86 files that use PEP 758
except A, B:. - Its built-in
unused-suppressionandno-suppress-allchecks fill the roles RUF100 and PGH004 fill for ruff, andast-grep testgives each rule unit tests. - Rejected: a stdlib
asttest, at 2.2-2.4 s per run plus about 250 lines of home-grown detector, suppression syntax and stale-marker logic, which is the maintenance this policy removes. Also rejected: Semgrep 1.178, at 14-16 s per run, which failed to parse 30 files (PEP 758except A, B:and PEP 696 type-parameter defaults). - Ten fix PRs added constructs in two weeks, and every burn-down item is itself a fix PR at the same risk.
- Markers give each burn-down item a checkable finish line: its markers are gone, the ceiling is lowered, and
unused-suppressioncatches a fix that leaves a stale marker. - The review has to stop dismissing these findings before it reviews the burn-down PRs.
- Cost: the PR touches the 46 files the rules hit (markers in 42 of them) and conflicts with open PRs, so it lands right after a release starts, as that release's first item PR, after feat(cli): extend the ruff rule set to the correctness families #420 and before fix(security): egress guards refuse cloud metadata in every numeric, NAT64 and provider form, classified by ipaddress and one maintained library #897. Markers are regenerated by the script on rebase.
- A burn-down item that lands before this one deletes its constructs, and the recount leaves no marker for them; one that lands after removes its markers and lowers the ceiling.
- What about the 10 use sites the rules cannot see? Proposed: accept the gap; add no
net-legacy-listrule. - ast-grep cannot follow names imported from config/constants.py, so these sites are invisible: ai/spend/pricing.py:91 and :93; commands/k8s/networking.py:267, :268, :296, :440 and :441; core/validation.py:79 and :92; docker/engine.py:234. The declarations themselves are flagged and marked.
- The burn-down items delete the six lists: config/constants.py:269 (fix(security): URL and host:port reads use the sending client's parser, so key trust, crawls, probes and settings act on the host actually dialled #1112), :2011-2018 (fix(docker): the Docker endpoint check covers the endpoint the SDK dials, including contexts and the TUI, and pushes accept registry ports #1108), :2296-2299 and :2505 (fix(security): egress guards refuse cloud metadata in every numeric, NAT64 and provider form, classified by ipaddress and one maintained library #897), and :2512-2518 (fix(security): local names come from the public suffix list, and domains match on DNS labels, not string suffixes #887).
- An interim identifier rule over those names would add 35 hits.
- Does the "POSIX signal 0" line at verify_finding_system.md:33, which tells the verification model that
os.kill(pid, 0)"is not a race", stay as written? Proposed: no. Left as is, it still refutes a fix(cli): argo ignores the namespace, and workspace, devcontainer, port-forward, tls, drift-report and label state handling #961-shaped finding after the deterministic check is gone. Keep the true half ("tests that a process exists without signalling it") and drop "it is not a race or a security flaw", so a finding that the pid may name another process is judged on where the pid comes from. - Here the
net-*rules and TID251 originate the findings, the house rule bands them, and the deletions above stop the review from discarding them. None of that needs a model to look for hand-rolled parsing. - Left to the evidence-first redesign as input: prompt lines that would tell the personas or the verification model to flag hand-rolled parsing themselves, and the Fix field. ai/tasks/review.md:42 defines a fix as "replacement code for the cited lines", so when the cited line is the construct, the fix adds one more case to it. A fix that deletes the construct and calls the library belongs in the redesign's planning step.
- Proposed: the verify_finding_system.md:33 edit stays in this item, because it only deletes a refutation, the prompt form of the deleted check, and adds no instruction.
Fit
Needs splitting into 5 items:
- Core gate: 12 ast-grep rules, 12 test files, sgconfig.yml, ast-grep-cli dependency, CI constructs row, pre-commit hooks, baseline markers in 42+ files, ceiling constant and test, meta-test
- TID251: ruff select and banned-api config for socket.inet_*, CONST_RUFF_LINT_KEYS update
- Documentation: AGENTS.md edits, instruction_generator.py template edits, generate_agents.md Step 3, architecture.md edit, non-devops-cli template test
- Review changes: remove 2 deterministic checks, delete 2 catalogue entries, regression tests, .devops/review.md house rule, verify_finding_system.md edit, test_review_prompt_consistency.py and test_common_hallucinations_hardening.py edits
- TLS defaults: ipaddress objects in config/defaults.py and models/tls.py, consumer updates
Suspected block
None.
Dependencies
None.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
dan-petty-bot commentedon Oct 10, 2026
Proposal needs splitting into 5 items at 69c99cf (see proposed design in issue body).
dan-petty commentedon Oct 14, 2026
Moved to the backlog: it was New, not Ready, when v0.2.36 started. (devops roadmap reprioritize)
dan-petty commentedon Oct 17, 2026
Readiness check for v0.2.37, against
release/v0.2.36at 22d8748. Line numbers are at that commit.Status: partly done. Split into three.
Not built: the gate. None of these exist:
.ast-grep/andsgconfig.yml;pyproject.toml:78-97);TID251in Ruff's select (:113-116);devops ci(src/devops_cli/commands/ci.py:435-548).The only check is
tests/test_url_credential_masking.py:391, a grep over two files.Fewer constructs remain than the body counts:
src/devops_cli/core/validation.py:439), down from 5;strip("[]")calls;The body's counts of 114, 103 and 46 need a recount.
Done by #1150:
verification.py,common_hallucinations.{py,json},verify_finding_system.md, the hardening test and theos.kill_NON_DEFECTSentry are deleted. The Review section therefore shrinks to the.devops/review.mdhouse rule (:57-78).Done by #849:
DEFAULT_NET_CONSTRUCT_SUPPRESSION_CEILING = 0(src/devops_cli/config/defaults.py:703,:718), counted by tokenize (tests/test_architectural_invariants.py:1547-1590).References that moved
:17-20;:21;:16;:185. The ":380 protocol regexes" line is gone.src/devops_cli/ai/instruction_generator.py)::277and:312-319.CONST_RUFF_LINT_KEYS:constants.py:3235.tests/test_architectural_invariants.pyhelpers:_ruff_enforces:731,_ignore_file_escapes:917,_complexity_cap_escapes:969,_c901_suppressions:989. The escape test is at:1325and the ceiling test at:1360.DEFAULT_HOMELAB_IPS:defaults.py:181.CONST_MODEL_ENDPOINT_MARKERSand_url_origin.Dependencies: closed: #420, #843, #840, #897, #898, #1150 and #849. Open: #1016, which edits the same bullet (AGENTS.md
:20, template:315), and the children #887, #1110 and #1113, which don't block this issue.Questions for the owner
Proposed split
ipaddressobjects.dan-petty commentedon Oct 17, 2026
Moved to the backlog: it was New, not Ready, when v0.2.37 started. (devops roadmap reprioritize)
dan-petty commentedon Oct 17, 2026
Ready: implementation plan (refined 2026-10-17 at 3dd7fa6)
This section supersedes any text below that conflicts with it.
Decisions
Does the gate need ast-grep, or do Ruff TID251 and Semgrep cover it? It needs ast-grep.
ast-grep-cli==0.51.0(MIT; 0.50.0 shipped 2026-10-09 and 0.51.0 on 2026-10-15) goes in thedevdependency group, asactionlint-pyandzizmorare. TID251 is added as well, for the bannedsocket.inet_*APIs. Measured at 3dd7fa6:"://" in urlorstartswith("169.254.").src/devops_cli/tools_lock/tools.lock:381) took 14.3-15.6 s to run one rule oversrc. It skippedsrc/devops_cli/ai/review_schema.pyentirely, at the PEP 695 bound on:286, and parsed three files only partly:ai/agents/agent.py:177,ai/analyze/scanner.py:377(a three-name PEP 758except) andai/response_repair.py:523.devops install-tools, and feat(review): devops-cli's rule pack turns the recall set's network-exposure entries into tested Semgrep rules, and CI runs the pack's tests when a rule changes #1145 deliberately kept it out of the local gate (.github/workflows/ci.yml:371-372).src/devops_cli/review/rules_pack.py) is for reviewed repositories, and its validator requires MIT and CWE metadata on every rule (:80-92). Project lint rules do not belong there.srcin 0.32-0.41 s, includinguvxstart-up, and all 12 rule tests passed. Its only parse errors are the two PEP 696 type-parameter defaults (ai/response_repair.py:523,ai/agents/agent.py:177), and they cover justT =and= Any. It skips no file.The suppression ceiling:
DEFAULT_NET_CONSTRUCT_SUPPRESSION_CEILINGstays at 0 (src/devops_cli/config/defaults.py:703), andnoqa: TID251keeps the 0 every unlisted noqa code has (:704-706). There is no baseline of markers. A rule ships only in the PR that leavessrcwith no hit for it. The body's "markers above every hit, ceiling equal to their count, lowered by each burn-down" plan is dropped. Raising the ceiling would be a relaxation.Enforce first, or clean up first? Clean up first, one rule group at a time. Each rule enters
.ast-grep/rules/andCONST_NET_CONSTRUCT_RULESin the PR that deletes its last hit, so the gate never carries a marker and never has a known hole for a shipped rule. This follows from the ceiling of 0.Counts: the body's 114, 103 and 46 are replaced. At 3dd7fa6 the 12 rules report 52 rule hits on 46 lines in 31 files (55 raw matches). Each PR records the count at its own merge base in its PR body, and no doc or test hard-codes a count. Many constructs were deleted by the children that have landed.
A false positive in
net-ip-literal:"0.0.0.0/0" in lineatsecurity/tflint.py:63, and the same shape atai/review/defects.py:693, search HCL text for a literal and do not classify a host. The rule is refined so that a membership test with the literal on the left counts only when the right-hand name looks like a host or URL."127.0.0.1" in urlis still caught. Checked with 0.51.0: the refined rule passes its tests and leaves onlysecurity/sanitizer.py:393insrc. Thenotclause added to the body's rule is:Its tests add
matches = "0.0.0.0/0" in lineandif not match or "0.0.0.0/0" in match.group(3): passas valid, andlocal = "127.0.0.1" in urlandlocal = "::1" not in parsed.netlocas invalid. The body's rule says "a false positive becomes a rule test case and a rule fix". The HCL brace-counting intflint.pyis a different hand-rolled parser and is not this rule's business.The other 11 rules: kept exactly as written in the body. Each passes
ast-grep testwith 0.51.0.The
constructsrow: oneCheckSpecinget_check_specs()(src/devops_cli/commands/ci.py:435-547) running["uv", "run", "ast-grep", *CONST_AST_GREP_SCAN_ARGS], whereCONST_AST_GREP_SCAN_ARGSis("scan", "--error=unused-suppression", "--error=no-suppress-all", "src"). GitHub CI already runs the table throughdevops ci(refactor(ci): github ci runs the gate throughdevops cifrom one check table #843). The rule unit tests run in pytest, through a test that callsast-grep test --skip-snapshot-tests(about 30 ms, offline), and as a pre-commit hook.CheckSpecholds one command (:146-156). With no marker allowed, the two--errorflags back up test(cli): suppression comments may not grow unnoticed #849's count: a stray marker fails the scan too.Pre-commit: two
language: system,pass_filenames: falsehooks in therepo: localblock (.pre-commit-config.yaml:45) calluv run ast-grep scan ...anduv run ast-grep test --skip-snapshot-testsdirectly, because importing devops_cli costs seconds (the block's comment,:47-53).TID251:
select(pyproject.toml:113-116) namesTID251, and[tool.ruff.lint.flake8-tidy-imports.banned-api]banssocket.inet_aton,socket.inet_ntoa,socket.inet_ptonandsocket.inet_ntop, each with "Parse and format addresses with ipaddress.ip_address."flake8-tidy-importsjoinsCONST_RUFF_LINT_KEYS(src/devops_cli/config/constants.py:3235-3245). There are 0 uses at 3dd7fa6.The meta-test, beside
_complexity_cap_escapes(tests/test_architectural_invariants.py:969), reads files only and reports each of the following, with one case per escape, astest_every_complexity_cap_escape_is_reported(:1325) does:sgconfig.ymlkeys other thanruleDirsandtestConfigs, orruleDirsother than[.ast-grep/rules];sgconfig.ymloutsiderepos/;CONST_NET_CONSTRUCT_RULES;severity: error, or that setsfilesorignores;constructsrow or in pre-commit that differs fromCONST_AST_GREP_SCAN_ARGS;_ignore_file_escapes,:917);_ruff_enforces,:731), a banned API missing fromCONST_BANNED_HAND_ROLLED_APIS, or a per-file ignore that waives TID251.Use sites the rules cannot see (names imported from
config/constants.py): accept the gap and add nonet-legacy-listrule. Most of those lists are gone, and fix(security): local names come from the public suffix list, and domains match on DNS labels, not string suffixes #887 deletesCONST_LOCAL_DOMAIN_SUFFIXES.fcntl.flock/lockf: not banned here. Locking is not network parsing.Running the rules on repositories the review tool reviews: not in this item. That is the Semgrep rule pack's job, if it is ever wanted.
D-Bus addresses (
commands/devcontainer.py:1286-1288): read withjeepney.bus.get_connectable_addresses. jeepney 0.9.0 is already inuv.lock(:1526), installed on Linux through keyring, and is declared inpyproject.tomlwith thesys_platform == 'linux'marker when first imported, so deptry stays green. The body names jeepney, and its parser handles escapes and multiple addresses, which the hand-rolledremoveprefixdoes not.Valkey endpoint parsing (
valkey/client.py:46-61,config/settings.py:213-250,commands/ai_runs.py:159): rewritten here withurllib.parse.urlsplitandhttpx2.URL. fix(valkey): one validated URL names every Valkey endpoint, valkey-py dials an address that one check vetted, and the unused cache layer goes #1113 keeps its own scope, the GLIDE client swap and deleting the RESP stack, and starts from library-parsed endpoints. fix(valkey): one validated URL names every Valkey endpoint, valkey-py dials an address that one check vetted, and the unused cache layer goes #1113 is in the backlog, and waiting for it would hold four rules off indefinitely.TLS defaults:
DEFAULT_HOMELAB_IPS(src/devops_cli/config/defaults.py:181) and thesansdefault ofCertGenerationRequest(src/devops_cli/models/tls.py:51) holdipaddressobjects for their addresses. Their consumers (src/devops_cli/crypto/tls_certificates.py:62-77,:325-326,src/devops_cli/commands/tls.py:298) take the objects, and JSON output stays strings. This lands withnet-address-list, which cannot ship otherwise.Instruction surfaces: the body's AGENTS.md and template bullets are kept, with one change. The enforcement sub-bullet now reads: "Enforced by the
net-*ast-grep rules (.ast-grep/rules/) and RuffTID251inuv run devops ciand pre-commit. No site may carry anast-grep-ignoreornoqa: TID251marker, because their suppression ceiling is 0. A rule ships only oncesrchas no hit for it, and a false positive becomes a rule test case and a rule fix." The Review section shrinks to the.devops/review.mdhouse rule, because refactor(review): the model verifier, the hallucination catalog and the model-claim guards are deleted, and person-recorded verdicts become suppressions #1150 deletedverification.py, the hallucination catalogue,verify_finding_system.mdand their tests. The body's verification-prompt and hallucination-check items are therefore void.docs(agents): a matching table lives beside its one owner, and moves to config/ only when a second package imports it #1016 coexistence: PR 2 replaces AGENTS.md:17-19 and template
:312-314. It leaves the placement sentence (AGENTS.md:20, template:315) as its own bullet, headed "Matching Table Placement", for docs(agents): a matching table lives beside its one owner, and moves to config/ only when a second package imports it #1016 to rewrite. Whichever lands second rebases.Children: feat(ci): hand-rolled URL and address parsing fails
devops ci, AGENTS.md makes the library the rule, and reviews stop discarding the findings #1107 is not a pure tracking parent, because it has its own gate. It closes with its last PR. fix(ai): replies carry their server as an httpx2 origin, so a password in an AI URL stays out of output, the spend ledger, metrics, spans and cache #1110 and fix(valkey): one validated URL names every Valkey endpoint, valkey-py dials an address that one check vetted, and the unused cache layer goes #1113 stay open as independent items, and no rule waits on them.Delivery
PR 1 (M): the gate, with TID251, the meta-test and the first three rules:
net-cidr-build(no hit),net-port-table(core/validation.py:439becomeshttpx2.URL(url).origin.port) and the refinednet-ip-literal(security/sanitizer.py:393becomesis_loopback_host). It also createsdocs/agent/tasks/task-1107-hand-rolled-network-parsing-gate.mdandchangelog.d/1107.md, and later PRs extend both. Refs feat(ci): hand-rolled URL and address parsing failsdevops ci, AGENTS.md makes the library the rule, and reviews stop discarding the findings #1107. Tests first:ast-grep test --skip-snapshot-tests;_enforce_non_private_ssrf(core/validation.py:414) resolving with port 443 forhttps://example.comand 80 forhttp://example.com(_resolve_host_ipspatched);sanitize_telemetry_endpoint(security/sanitizer.py:383) keeping the hostslocalhost,127.0.0.2and[::1], as it does today;constructsrow's command;tmp_path,port = 443 if tls else 80failing the scan witherror[net-port-table].Files:
pyproject.toml,uv.lock,sgconfig.yml,.ast-grep/rules/*.yml,.ast-grep/rule-tests/*-test.yml,.pre-commit-config.yaml,src/devops_cli/config/constants.py,src/devops_cli/commands/ci.py,src/devops_cli/lang/en/messages.py,src/devops_cli/core/validation.py,src/devops_cli/security/sanitizer.py, generated CLI docs,tests/test_architectural_invariants.py,tests/test_net_construct_rules.py(new),tests/test_validation.py,tests/test_consolidation_security_sanitizer.py,docs/agent/tasks/task-1107-hand-rolled-network-parsing-gate.md,changelog.d/1107.md.PR 2 (S): the instruction surfaces, as the body specifies them with the enforcement sub-bullet above. They are AGENTS.md (
:16,:17-20,:21,:185); the template insrc/devops_cli/ai/instruction_generator.py(:277,:312-319, behindmeta.is_devops_cli);src/devops_cli/ai/tasks/generate_agents.mdStep 3 (:11-15);src/devops_cli/ai/knowledge_base/devops_cli/architecture.md:29; and the.devops/review.mdhouse rule (after:77). AGENTS.md is edited by hand. Refs feat(ci): hand-rolled URL and address parsing failsdevops ci, AGENTS.md makes the library the rule, and reviews stop discarding the findings #1107. Tests first: render the template withis_devops_cli=Falseand assert that the bullet names none ofconfig/constants.py,uv.lock,httpx2,docker.utils,jeepneyorast-grep; render it withis_devops_cli=Trueand assert that it equals the AGENTS.md bullet. Files:AGENTS.md,src/devops_cli/ai/instruction_generator.py,src/devops_cli/ai/tasks/generate_agents.md,src/devops_cli/ai/knowledge_base/devops_cli/architecture.md,.devops/review.md,tests/test_instruction_generator.py, the task file,changelog.d/1107.md.PR 3 (M):
net-address-list. Scheme tuples becomeurlsplit(value).schememembership atai/agents/tools.py:156,ai/research/edges.py:173,ai/review/samples.py:67,commands/ai_ingest.py:91andcommands/k8s/networking.py:85, and the TLS defaults holdipaddressobjects. Refs feat(ci): hand-rolled URL and address parsing failsdevops ci, AGENTS.md makes the library the rule, and reviews stop discarding the findings #1107. Tests first:HTTPS://example.com, whichurlsplitlowercases and today'sstartswithmisses), and with a non-URL;x509.IPAddressfor each default address;devops tlsJSON output still being strings.Files: those five modules,
src/devops_cli/config/defaults.py,src/devops_cli/models/tls.py,src/devops_cli/crypto/tls_certificates.py,src/devops_cli/commands/tls.py, their tests,.ast-grep/,src/devops_cli/config/constants.py, the task file,changelog.d/1107.md.PR 4 (M):
net-scheme-in,net-scheme-affix,net-url-buildandnet-bracket-affix. Refs feat(ci): hand-rolled URL and address parsing failsdevops ci, AGENTS.md makes the library the rule, and reviews stop discarding the findings #1107. The sites:"://" intests becomeurlsplit(...).schemeatcommands/k8s/cluster_context.py:195,commands/repos.py:208and:211,commands/sandbox.py:456and:678,config/settings.py:218,core/paths.py:190andsecurity/reference_extractor.py:178and:455;ai/agents/media.py:184androadmap/refine.py:458become scheme comparisons;commands/devcontainer.py:1286-1288);httpx2.URL(scheme=..., host=..., port=...)atcommands/ai_gateway.py:206,commands/ai_runs.py:159andconfig/settings.py:219;urlsplit(valkey/client.py:46-61,config/settings.py:213-250).Tests first:
[2001:db8::1]:6379,valkey://[2001:db8::1]) and upper-case schemes at each parser;DBUS_SESSION_BUS_ADDRESSwith an escaped path and with two addresses;if "://" in url:failing the scan witherror[net-scheme-in].Files: the modules above, their tests,
pyproject.toml(jeepney),uv.lock,.ast-grep/,src/devops_cli/config/constants.py, the task file,changelog.d/1107.md.PR 5 (S):
net-domain-suffix,net-domain-list,net-normaliseandnet-hostport, after fix(security): local names come from the public suffix list, and domains match on DNS labels, not string suffixes #887 has merged and deleted its own sites. Closes feat(ci): hand-rolled URL and address parsing failsdevops ci, AGENTS.md makes the library the rule, and reviews stop discarding the findings #1107. The sites left outside fix(security): local names come from the public suffix list, and domains match on DNS labels, not string suffixes #887's scope at 3dd7fa6:ai/models/ollama.py:102andcommands/review.py:1368usedns.nameis_subdomain;k8s/template.py:26usesdns.name.from_text;commands/k8s/networking.py:493andhttp/urls.py:37useurlsplit("//" + authority)or the parsed URL's own fields;core/validation.py:72and:257, unless fix(security): local names come from the public suffix list, and domains match on DNS labels, not string suffixes #887 rewrote them, useurlsplit("//" + host).hostnamewithdns.namefor the trailing dot.The PR re-runs all 12 rules at its merge base and fixes whatever is left. Tests first: each site with mixed-case, trailing-dot and bracketed-IPv6 input, and a look-alike (
evilollama.com) staying outside. Files: those modules, their tests,.ast-grep/,src/devops_cli/config/constants.py, the task file (**Status**: Done),changelog.d/1107.md.Acceptance criteria
ast-grep-cli==0.51.0is in thedevgroup.uv run devops cihas aconstructsrow that runsast-grep scan --error=unused-suppression --error=no-suppress-all src, and pre-commit runs the scan andast-grep test --skip-snapshot-tests..ast-grep/rules/holds exactly the 12net-*rules, withnet-ip-literalrefined as above. Each has at least one valid and one invalid case, andCONST_NET_CONSTRUCT_RULESlists them.uv run ast-grep scan ... srcexits 0 with no hit at every PR's merge. Noast-grep-ignoreornoqa: TID251marker exists insrc.DEFAULT_NET_CONSTRUCT_SUPPRESSION_CEILINGis still 0.socket.inet_*APIs are banned with theipaddressmessage. Bothsocket.inet_aton(...)andfrom socket import inet_ptonare reported in a scratch module.unshare -rn), and ast-grep sends no telemetry.is_devops_cli),generate_agents.md,architecture.md:29and.devops/review.mdcarry the library-first rule as decided above.git diff AGENTS.mdshows only those lines.DEFAULT_HOMELAB_IPSand thesansdefault holdipaddressobjects. Certificates and JSON output are unchanged in content.uv run devops cianduv run devops docs checkpass.changelog.d/1107.mdrecords the gate; CHANGELOG.md and docs/ROADMAP.md are not edited.Current references
Ceiling:
DEFAULT_NET_CONSTRUCT_SUPPRESSION_CEILINGsrc/devops_cli/config/defaults.py:702-703, inDEFAULT_SUPPRESSION_CEILINGS:718; marker countingtests/test_architectural_invariants.py:1547-1555, ceiling test:1673; marker kind and regexessrc/devops_cli/config/constants.py:3285,:3338-3344Meta-test helpers:
_ruff_enforcestests/test_architectural_invariants.py:731,_ignore_file_escapes:917,_complexity_cap_escapes:969,test_every_complexity_cap_escape_is_reported:1325,test_the_complexity_cap_has_no_escape:1348Dev group:
pyproject.toml:78-98; Ruffselect::113-116;CONST_RUFF_LINT_KEYS:src/devops_cli/config/constants.py:3235-3245Check table:
CheckSpecsrc/devops_cli/commands/ci.py:146-156;get_check_specs():435-547Pre-commit
repo: local:.pre-commit-config.yaml:45Semgrep pin:
src/devops_cli/tools_lock/tools.lock:381; rule pack metadata check:src/devops_cli/review/rules_pack.py:80-92; rule-pack CI job:.github/workflows/ci.yml:371-417AGENTS.md: standard-library list
:16; brittle-pattern block:17-20(placement:20); "Avoid custom workarounds":21; Standard Parsers:185Template: "Avoid custom workarounds"
src/devops_cli/ai/instruction_generator.py:277; brittle block:312-315; Standard Parsers:316-319;is_devops_cli:48,:116src/devops_cli/ai/tasks/generate_agents.md:11-15;src/devops_cli/ai/knowledge_base/devops_cli/architecture.md:29;.devops/review.mdhouse rules:57-77TLS:
src/devops_cli/config/defaults.py:181-185;src/devops_cli/models/tls.py:51;src/devops_cli/crypto/tls_certificates.py:62-77,:325-326;src/devops_cli/commands/tls.py:298Hits per rule at 3dd7fa6:
net-scheme-in9;net-scheme-affix10;net-address-list8;net-domain-suffix6;net-normalise5;net-bracket-affix3;net-hostport3;net-ip-literal3 (1 after the refinement);net-url-build3;net-domain-list1;net-port-table1;net-cidr-build0.The sites are listed in the Delivery steps. fix(security): local names come from the public suffix list, and domains match on DNS labels, not string suffixes #887 owns
ai/common_tools.py:481and:486,ai/harness/agents.py:392and:394,ai/spend/pricing.py:159,commands/k8s/networking.py:710,core/validation.py:358andconfig/constants.py:2545.Dependencies and order
devops cifrom one check table #843, docs(agents): instruction surfaces state only what is true, anddevops ai agentsnever overwrites AGENTS.md #840, test(cli): suppression comments may not grow unnoticed #849, refactor(review): the model verifier, the hallucination catalog and the model-claim guards are deleted, and person-recorded verdicts become suppressions #1150, fix(security): egress guards refuse cloud metadata in every numeric, NAT64 and provider form, classified by ipaddress and one maintained library #897, fix(security): every HTTP client dials only addresses its egress level allows, checked at the connect and on every redirect #898, fix(docker): the Docker endpoint check covers the endpoint the SDK dials, including contexts and the TUI, and pushes accept registry ports #1108, fix(security): URL credential masking uses urllib and httpx2, so passwords containing '@' and non-http schemes are masked and IPv6 hosts stay intact #1109, fix(k8s): service URLs bracket IPv6 hosts, k8s:// addresses reach only their Service, and https probe targets are probed over https #1111, fix(security): URL and host:port reads use the sending client's parser, so key trust, crawls, probes and settings act on the host actually dialled #1112, fix(git): GitHub clones trust GitHub's published host keys through OpenSSH, so junk known_hosts lines and a failed key scan no longer skip pinning #1114 and feat(review): devops-cli's rule pack turns the recall set's network-exposure entries into tested Semgrep rules, and CI runs the pack's tests when a rule changes #1145.CONST_LOCAL_DOMAIN_SUFFIXESamong them. PR 5 waits for it. fix(security): local names come from the public suffix list, and domains match on DNS labels, not string suffixes #887 needs no marker: the rules its sites trip ship only in PR 5, and any code it adds must pass the rules shipped by then.is_example_or_invalid_network_targetinsrc/devops_cli/security/reference_extractor.py:168-195, which holds thenet-scheme-inhit at:178. Land fix(security): reference_extractor classifies addresses with ipaddress, and the sandbox local whitelist stops mapping host.docker.internal to pod loopback #1174 first; PR 4 rebases.urlsplit. Its GLIDE swap is unaffected, and its refinement should start from those parsers.1 remaining item
feat(ci): hand-rolled network parsing gate and first rules (Part of #…
dan-petty commentedon Oct 21, 2026
Feasibility check: PR 2 cannot be built as specified (AGENTS.md character budget breach)
During the pre-coding feasibility check for PR 2 of #1107:
Specified Requirements:
AGENTS.mdwhile droppingipaddress/urllib.parsefrom line 15,Avoid custom workarounds...from line 20, and line 186 ("Standard Parsers Over Brittle Literals").Verification: git diff AGENTS.md shows only the listed changes; grep 'Parse With the Library' AGENTS.md finds the new bullet; grep 'Avoid custom workarounds' AGENTS.md returns nothing.tests/test_agents_md_claims.py::test_agents_md_stays_within_character_budgetassertsCONST_AGENTS_MD_MAX_CHARS <= 40_000andlen(AGENTS.md) <= CONST_AGENTS_MD_MAX_CHARS.Evidence of Unworkable Premise:
devops ci, AGENTS.md makes the library the rule, and reviews stop discarding the findings #1107 was planned and refined at commit3dd7fa6(2026-10-17),AGENTS.mdwas 38,656 characters. Applying the net +1,119 characters resulted in 39,775 characters, which satisfied the<= 40,000character budget.v0.2.37, intervening PRs (docs(agents): the full gate runs once per push, after the last rebase or amend, so the pre-push hook reuses its verdict #1663, fix(github): a pull request that delivers part of an item says Part of #N and passes readiness #1620, docs(cli): docs/TESTING.md holds the test conventions, ADR 0005 records that tests double only process edges, and AGENTS.md and the contributor docs point to them #1308) expandedAGENTS.mdto 39,866 characters, leaving only 134 characters of headroom.release/v0.2.38(HEAD), applying the specified changes (added: 2,984 chars; removed: 1,295 chars; net: +1,689 chars) bringsAGENTS.mdto 41,555 characters (1,555 characters over the 40,000-character ceiling).test_agents_md_stays_within_character_budgetduringuv run devops ci.Why Compensating Code Cannot Be Added:
CONST_AGENTS_MD_MAX_CHARScannot be increased becausetest_agents_md_stays_within_character_budgetexplicitly assertsCONST_AGENTS_MD_MAX_CHARS <= 40_000and modifying this invariant violates the rule "Never Lower Security Standards or Quality Thresholds".AGENTS.mdviolates Criterion 11 (git diff AGENTS.md shows only the listed changes) and requires refactoring beyond the scope of PR 2 (which was planned as a separate future deliverable in docs(agents): AGENTS.md fits a context budget and Claude Code loads it #841's Step 2 to lowerAGENTS.mdto 20,000 characters).Current Status of feat(ci): hand-rolled URL and address parsing fails
devops ci, AGENTS.md makes the library the rule, and reviews stop discarding the findings #1107:release/v0.2.38(core gate,ast-grep-cli,sgconfig.yml, TID251,constructscheck row, and the first 3 rules).AGENTS.mdcharacter budgeting is refined or refactored.Per AGENTS.md ("Stop Rather Than Add Compensating Code" / #1348), returning #1107 to New for refinement on
AGENTS.mdcharacter budgeting.dan-petty commentedon Oct 21, 2026
Proposal needs splitting into 5 items at be39289 (see proposed design in issue body).
feat(ci): net-address-list ast-grep rule and ipaddress TLS defaults (…
feat(ci): scheme, URL authority, and IPv6 bracket ast-grep rules (Par…
feat(ci): domain suffix, domain list, normalization, and hostport ast…
dan-petty commentedon Oct 21, 2026
What changed
#1784, merged into
release/v0.2.38as df141a3.23 file(s) changed.
How it was verified
Check runs at 4ab26c9:
Acceptance Criteria of
docs/agent/tasks/task-1107-hand-rolled-network-parsing-gate.md:No Acceptance Criteria section.
feat(release): v0.2.38 (#1799)
feat(release): v0.2.38 (#1798)