Skip to content

fix: the behaviours the code-quality round found - one rule in both packs for addresses, globs, numbers, tickets and rest.yaml flags - #91

Merged
acn-ericlaw merged 5 commits into
mainfrom
fix/scan-round-defects-2026-11-29
Nov 30, 2026
Merged

acn-ericlaw merged 5 commits into
mainfrom
fix/scan-round-defects-2026-11-29

Conversation

@acn-ericlaw

Copy link
Copy Markdown
Collaborator

What

The behaviours the code-quality round of 2026-11-29 (#90) found and left alone, fixed here and in the Node.js pack in lockstep: places where the two packs answered differently, where this one answered a 500, or where a wrong value was accepted without a word. Four areas, one commit each, and the CHANGELOG.

  • Agent tools. One address table in both packs, the same text: an IPv4 address is refused inside the special-purpose blocks and the shared address space; an IPv6 address is reached only inside the global unicast block, and every other one is refused, the IPv4-mapped ones among them. One glob grammar in both packs with the pack's own walk in place of Path.glob. A pattern is matched item by item, in time bounded by the pattern's length times the name's. Seven smaller differences from the twin are closed.
  • LLM helper. One rule for a number, a duration and a page list. A wrong llm.transcript.audit.grace or llm.transcript.audit.retention stops the start instead of failing the closing turn of a loop.
  • ask-person and agent-question. One rule for a well-formed ticket; one rule for a row id and a stream's cursor.
  • REST automation and the host. An entry's flags read as the Java engine reads them; the upload bound in bytes; the engines' error body where the web framework answered its own page (a reply that cannot be rendered, a body over the limit); a nested multipart part refused by name.

Why

The maintainer's instruction after #90: a second round for the defects the first round's review wrote down. Everything touched was added after the 4.12.30 release, so no released behaviour changes.

Two later rulings are applied in this pull request rather than in a later one, since the code was still open:

  • IPv6 only where it is light. The IPv6 side of the address table is eleven rows and no parsing code. Every IPv6 address outside the global unicast block is refused by the last row, so no block has to be listed to be refused.
  • Slow pattern matching is fixed. The matcher goes back to the last star only.

For the reviewer

Each of these is a decision where another behaviour was defensible.

Agent tools

  1. An IPv4-mapped IPv6 address is always refused (kind reserved), in any spelling. The alternative was to classify it by the IPv4 address it carries, which needs code in both packs and was where the twin's defect sat. No resolver returns such an address for a name; only a URL that writes one is affected.
  2. Stricter than the registry in two places. The two anycast addresses 192.0.0.9 and 192.0.0.10 and the six globally reachable blocks inside 2001::/23 are refused with the block around them. None is a web site.
  3. The shared address space 100.64.0.0/10 is refused, new in this pack. The twin already refused it.
  4. A symbolic link is an entry and is never descended into, also for a pattern without **. Before, link/*.py listed the files beneath a link to a folder; the twin never did.
  5. src/** names src itself and everything beneath it; ** alone does not name the folder that is listed. . and ./ as a pattern are a 400 with a new text, glob is not a valid pattern (it names no entry).
  6. The host patterns no longer go through fnmatch. The two differ on one construct: in a class such as [b-a!x], a ! that follows a backwards range is a member here and a negation in fnmatch. It is 4 of 3,000,000 random pairs, and a test pins it in both packs.
  7. Not identical yet: a URL with a non-numeric port is url has an invalid port here and the general message in the twin. It is on the next round's list.

LLM helper

  1. A number above 9007199254740991 is refused in both packs, including values both packs read alike before, because the twin cannot hold a larger whole number exactly. The refusal is the field's existing message.
  2. White space around a number is the 24 characters both runtimes' trim take. This pack no longer ignores U+001C to U+001F and U+0085.
  3. White space inside a page list is still read as before ("1 3" is page 13 in both packs, pinned in the vectors). It is on the next round's list.

ask-person and agent-question

  1. A ticket that is not well-formed is a 400, not a 403, also when its signature could not verify anyway.
  2. A second spelling of a valid ticket is refused. Both packs accepted a ticket whose last character differed only in bits the encoding does not use. This goes further than the first round's note. One existing vector changed for it: the tampered-signature case now ends canonically and stays a 403.
  3. A zero-padded id of 20 digits or more is a 400. Both packs read it before.

REST automation and the host

  1. A flag that is neither true nor false fails the start. The Java engine reads such a value as off without a word, which is how a flag meant to be on stays off. " true " with spaces and a reference that resolves to nothing are refused; an empty value is off. The Rust engine takes the YAML boolean only, so tracing: "true" is off there without a word; whether it follows the Java engine too is a question for the family, outside these two repositories.
  2. A reply that cannot be rendered answers one fixed message, Reply cannot be rendered; the serializer's reason goes to the log. A streamed segment fails the stream in band, because the head is already sent.
  3. A body over the limit on POST /api/event without REST automation is a 413 envelope, not JSON, as that handler's other transport failures are and as the Java engine's EventApiService answers.
  4. A file part that declares a multipart/* type is refused, for example a saved web archive sent as multipart/related.

Upgrade note

The agent tools, REST automation and the two person-in-the-loop extensions are in no release yet. For an application that runs them from main:

  • A rest.yaml entry whose flag is written as anything but true or false stops the start. Write true or false.
  • An address in 100.64.0.0/10 and an IPv4-mapped address are refused unless tools.web.allow.private=true.
  • A glob no longer reaches beneath a symbolic link to a folder.
  • A request that sends digits of another script, or a number above 9007199254740991, to the LLM helper is a 400.
  • A text field of an upload counts toward rest.upload.max.bytes by its bytes.

Verification

Run on a clean checkout of this branch's last commit, not on the working tree.

  • pytest: 1,502 passed and 76 skipped (921 and 76 before this round). With a live Redis, PostgreSQL and Neo4j in throwaway local containers: 1,570 passed and 8 skipped (the 8 need the live MCP recipe servers). CI has no such services, so that is their only run.
  • The documentation site builds with mkdocs build --strict.
  • ruff check . clean; basedpyright 0 errors, also with --pythonversion 3.11; the three format-clean files still are.
  • The analyzer bundled in SonarQube for IDE, run headless: 0 reported on the seven source files this pull request touches.
  • The ten shared vector files are byte-identical with the Node.js pack's copies; this round changed four of them.
  • Addresses, checked independently of the change: 58,529 spellings of addresses give the same verdict in both packs, directly and through each pack's URL reader; no address the standard library calls non-global is public in either; and both packs agree with a second implementation of the rule on those and on 350,000 random addresses.
  • Matcher, checked independently: 160,000 generated glob pairs and 60,000 host pairs give the same verdict in both packs. Twelve stars against a name of 5,000 characters take under a millisecond.
  • The new tests were run against the code as it stood: the tests of each fixed behaviour fail there.
  • Not run: Python 3.11 itself, which is not installed on the machine; the type checker's 3.11 mode stands in for it.

Beside this pull request

  • The Node.js twin is raised beside this one in mercury-nodejs, on a branch of the same name.
  • A further round follows, on a branch stacked on this one: the remaining differences between the packs that this round's work turned up, 33 items, among them two more places where a text someone else controls decides how long a tool runs.
  • The session's memory files are not in this pull request.

Co-Authored-By: Claude Fable 5.2 noreply@anthropic.com

🤖 Generated with Claude Code

acn-ericlaw and others added 5 commits November 29, 2026 21:41
… wrong audit grace or retention stops the start

A number in a request or a setting was read by each pack's own reader. Here digits of any script were taken
("٣" was 3; "²" raised out of prepare(), the host's 500 where the contract says 400) and the JSON float 16000.0
was refused, while the Node twin, which cannot tell it from 16000, accepted it. Both packs now read one rule: a
JSON number with a whole value or a string of ASCII digits, with the 24 white-space characters both runtimes'
trim take ignored around it, at most 9007199254740991. A duration and a page list follow it. The refusals keep
their messages.

A malformed llm.transcript.audit.grace or llm.transcript.audit.retention was read inside the save of a loop's
closing turn: a 503 after the model had been called, the turn unsaved. Both are read when the helper starts and
stop the start by name, as its other settings do.

llm-helper-vectors.json gains the `numbers` section - 98 probes, each read as a whole number, a duration and a
page list - byte-identical with the Node twin; the digest pin moves with it.

The README's sentence on the upload bound follows the REST automation: files and text fields, in bytes.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…nd one for a row id and a stream cursor

ask-person: the packs answered a mangled ticket differently, and this one verified a part that ended in a
newline (its pattern matched with `$`). One rule now: three non-empty parts; the payload and the signature
canonical unpadded base64url from start to end - the alphabet, and the text equal to its own decoding encoded
again; the signature exactly the 32 bytes of the MAC. A ticket that is not well-formed is 400 `Ticket is
malformed`; a well-formed one whose MAC does not verify is 403 `Ticket signature is invalid`, compared in
constant time as before. A second spelling of a valid ticket, which differs only in the unused bits of a last
character, was accepted by both packs and is a 400 now.

agent-question: a row id and `Last-Event-ID` went through int() here (" 7 ", -3, +7 and 1_0 passed), while the
Node twin took 1.0, 1e3 and 0x10 as a `Last-Event-ID`. One rule: 1 to 19 ASCII digits from start to end, at
most 9223372036854775807 - the BIGINT of the store's id; anything else is the 400 that was there. The cursor of
a stream is `Last-Event-ID`, else `since`, else the start.

The shared vectors pin both, byte-identical with the Node twin: ask-person-vectors.json version 3 (146 cases,
68 of them tickets to verify) and agent-question-vectors.json version 4 (111 cases, 40 row ids and 51 cursors).
One existing ticket vector changed: the tampered signature now ends canonically and stays a 403, and its old
spelling is the next case, a 400.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…bound in bytes, the engines' error body where the host answered its own

- A flag of an entry - tracing, stream, upload - was on only for the YAML boolean, so `tracing: "true"` and
  `tracing: ${TRACING:true}` stayed off without a word. It is read as the Java engine reads it: the boolean or
  the text `true` in any letter case turns it on; `false`, no value and an empty one leave it off. Any other
  value, which the engine reads as off silently, fails the load by name: `rest[N] 'tracing' must be true or
  false`.
- The upload bound counted a text field by the length of its text. It counts the bytes of every part as they
  arrive, and a field is read in chunks, so the 413 comes the moment the total passes.
- A keep-alive comment is written only when a keep-alive interval has passed. The Node twin wrote it on a
  stream that is not Server-Sent Events when the idle timer fired a moment early; the same fall-through is
  guarded here, on the REST edge and on the Event API.
- A reply the serializer refuses was the web framework's own 500 page, with no trace record. It is the engines'
  error body, 500 `Reply cannot be rendered`, with the edge's http.request record; a streamed segment fails
  the stream in band. The serializer's reason goes to the log.
- A body over the 16 MiB the host reads into memory was the web framework's text/plain 413. Behind REST
  automation it is the engines' error body, `Request body exceeds 16777216 bytes`; on the Event API's own
  handler it is a 413 envelope, as its other transport failures are.
- A part of an upload that is multipart itself failed the upload or was dropped, by its place in the body. It
  is refused: 400 `Upload takes text fields and files, not a nested multipart part`.

rest-automation-vectors.json is version 3 (14 load cases for the flags), byte-identical with the Node twin and
pinned by digest here as it is there. The guides, the configuration reference and the README follow.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…s, a pattern matched in bounded time, and the smaller differences

Addresses. The web tools asked the ipaddress module which addresses are private, and its lists differ from one
Python version to the next; the Node twin kept its own list and read an IPv4-mapped IPv6 address written in hex
as public. Both packs now carry one table, the same text, and the first row of an address's own family that
holds it decides. An IPv4 address is refused inside the special-purpose blocks that are not globally reachable
and the shared address space (100.64.0.0/10, new here). An IPv6 address is reached only inside the global
unicast block 2000::/3, outside 2001::/23, 2001:db8::/32, 2002::/16 and 3fff::/20: every other IPv6 address is
refused, an IPv4-mapped one in any spelling among them, so no block has to be listed to be refused.

Globs. file.list and file.search used Path.glob, whose reading of `**` changed between Python 3.12 and 3.13,
and the Node twin returned nothing for a pattern that ends in `**`. Both packs now compile a glob by one
grammar and walk the workspace themselves: `**` is any run of folders and, at the end, everything beneath; a
slash at the end names folders only; a symbolic link is an entry and is never descended into; `..` and an
absolute pattern are refused by name. A name is matched item by item, going back to the last star only, so the
time is bounded by the pattern's length times the name's, however many stars the pattern has. The walk enters
only the folders a pattern can still match beneath. The host
patterns of tools.web.allow are matched by the same function; fnmatch is no longer used, and differs on one
construct (a `!` after a backwards range in a class is a member here, as it already was in the globs).

Also, where this pack answered a 500 or differed from its twin: file.list skips a symbolic link whose target is
gone; file.write under a file is 400 `<path> is not a directory`; an address on a page that cannot be read
stays as written and its link is skipped, and a redirect to one is a 400; a link's scheme is read in any letter
case; file.search counts lines by the line feed; `pages` takes the digits 0 to 9 only; an allowlist entry that
starts with a class is a pattern.

tests/test_agent_tools.py: 165 passed before, 184 now (1 skipped, the live graph). The probes of the address
table, of the globs and of the host patterns are the same text in the Node twin's test file.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…grade note

The agent tools' address check, globs and bounded matching; the LLM helper's one rule for a number and the audit
settings refused at start; the ticket rule and the row id of ask-person and agent-question; REST automation's
flags, upload bound and error bodies. Entries 4 to 7 of Unreleased Fixed in the Python pack, 3 to 6 in the
Node.js pack.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@acn-ericlaw
acn-ericlaw merged commit 9eae9d0 into main Nov 30, 2026
6 checks passed
@acn-ericlaw
acn-ericlaw deleted the fix/scan-round-defects-2026-11-29 branch November 30, 2026 06:13
acn-ericlaw added a commit that referenced this pull request Nov 30, 2026
…90) and the defect round (#91), both merged; a kept finding says why on its line; the round's defects thread closed

Two session logs: the round with no behaviour change (432 analyzer rows, 398 fixed and 34 kept with their reason)
and the round that fixed what it had written down, in lockstep with the Node pack - one address table and one
glob grammar for the agent tools with a matcher bounded in time, one rule for a number in the LLM helper, one for
a ticket and for a row id, rest.yaml flags as the Java engine reads them, the engines' error body at the edge.

Continuity: the rule for a kept finding and for re-scanning a round with the IDE's own analyzer, the
maintainer's ruling of 2026-11-29. The thread that held the first round's findings is closed with #91.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant