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 - #152

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
Contributor

What

The behaviours the code-quality round of 2026-11-29 (#151) found and left alone, fixed here and in the Python 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. The web tools' address check read an IPv4-mapped IPv6 address written in hex as public; now an IPv6 address is reached only inside the global unicast block, and every other one is refused, the IPv4-mapped ones among them. A glob that ends in ** returned nothing; both packs now compile a glob by one grammar. A pattern is matched item by item, in time bounded by the pattern's length times the name's. Six 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; a 16 MiB limit on a request body, which had none; no keep-alive comment in a stream that is not Server-Sent Events; the engines' error body for a reply that cannot be rendered; a nested multipart part refused by name.

Why

The maintainer's instruction after #151: 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 the runtime's own subnet list (net.BlockList) reads the addresses, so the module parses none. 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. As a regular expression, three stars against a name of 1,500 characters did not finish in two minutes, with the event loop blocked. 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 parsing code in this pack and is where the 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. New refusals in this pack, which the twin already made: the documentation blocks, the benchmarking block and the protocol-assignment block of IPv4, and in IPv6 2001::/23, 2002::/16, 3fff::/20 and everything outside 2000::/3. That last one includes 64:ff9b::/96: on a network that reaches IPv4 sites through it, web.fetch refuses those sites unless tools.web.allow.private=true.
  4. A row holds only addresses of its own family. Without that, the subnet list would let an IPv4 row hold a mapped address and the last IPv6 row hold every IPv4 address.
  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. Not identical yet: a URL with a non-numeric port is the general message here and url has an invalid port 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 a larger whole number cannot be held exactly here. 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+FEFF.
  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. This pack answered 403 for a part that is too short.
  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. An id above 2^53-1 is carried as a BigInt, into the reader's lookup, comparisons and text only. The alternative was to stop at 2^53-1 in both packs, below what the store's id column holds.
  4. 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. rest.yaml is read with the boolean words of the Python pack's reader and the engine's. The single letters y and n were booleans here and are text now, as they are there. Only rest.yaml goes through this reader.
  3. A reply that cannot be rendered answers one fixed message, Reply cannot be rendered; the serializer's reason, which this pack sent before, goes to the log. A streamed segment fails the stream in band, because the head is already sent.
  4. 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.
  5. A file part that declares a multipart/* type is refused, for example a saved web archive sent as multipart/related. This pack delivered it before; the twin could not.
  6. The upload reader counts a text field by the size of its part in the body, found by the same delimiter scan the runtime's own parser makes; the two were compared on 6,000 generated bodies without a mismatch. If the two ever count different parts, the upload is a 400 by name.
  7. A body past its bound is let go by unread instead of the request being destroyed, so the client takes the 413. The server's own request timeout still ends a body that never ends.
  8. Three NOSONAR reasons in src/server.ts, on sequential awaits of the start and the stop that the first round had left reported.

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.
  • A request body over 16 MiB is refused with a 413. An upload keeps its own bound, rest.upload.max.bytes.
  • An IPv4-mapped address, the documentation and benchmarking blocks, and every IPv6 address outside the global unicast block are refused unless tools.web.allow.private=true.
  • A number above 9007199254740991 sent to the LLM helper is a 400.

Verification

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

  • npm test: 1,466 tests, 1,390 passed, 76 skipped, none failed (812 passed before this round). With a live Redis, PostgreSQL and Neo4j in throwaway local containers: 1,458 passed and 8 skipped, none failed (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.
  • The analyzer bundled in SonarQube for IDE, run headless: 0 reported on the eight source files this pull request touches.
  • The ten shared vector files are byte-identical with the Python 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 Python's 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: Node 22, the package's floor. It is not installed on the machine and CI runs Node 26 as well; a text scan of the changes found no runtime API newer than Node 22.

Beside 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: the Python twin took digits of any
script and refused the JSON float 16000.0, which this pack cannot tell from 16000 and accepted. 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 (U+FEFF is no longer one of them here), 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 Python 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. This one accepted a stray character after a
payload and answered 403 where the Python twin answered 400 for a part that is too short; the twin verified a
part that ended in a newline. 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: `Last-Event-ID` went through Number() here (1.0, 1e3 and 0x10 passed), while the Python twin
read a row id and the header with int() (" 7 ", -3, +7 and 1_0 passed). 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. Above 2^53-1 the id is carried as a BigInt, into the reader's lookup only. The cursor of a stream is
`Last-Event-ID`, else `since`, else the start.

The shared vectors pin both, byte-identical with the Python 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`. rest.yaml is read with the boolean words of the Python pack's reader and the engine's, so the single
  letters y and n are text here as they are there.
- The upload bound counted a text field by the length of its text. Each field counts as the bytes of its part
  in the body. The body is read within the bound and 1 MiB; past that the rest is let go by unread, so the
  client takes the 413 instead of a broken connection.
- nextSegment wrote the keep-alive comment on a stream that is not Server-Sent Events when the idle timer fired
  a moment before the clock reached the deadline: `: ping` in the body of a text/plain stream. A keep-alive is
  written only when a keep-alive interval has passed.
- A reply the serializer refuses was the host's catch-all 500 with no trace record, and a stream was destroyed.
  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 request body had no limit: 40 MiB was read into memory and delivered. The host takes the Python pack's
  16 MiB. Behind REST automation a body over it is the engines' error body, 413 `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 was delivered as a text field, or as a file of that type. It is
  refused: 400 `Upload takes text fields and files, not a nested multipart part`. An upload whose parts do not
  follow the boundary its content type declares is a 400 as well, as it is in the Python pack.

rest-automation-vectors.json is version 3 (14 load cases for the flags), byte-identical with the Python twin.
The three sequential awaits of the host's start and stop carry their reason on the line. 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' address check read an IPv4-mapped IPv6 address written in hex (`::ffff:7f00:1`) as
public, where the dotted spelling of the same address was loopback and the Python twin refused both; and its
list of blocks was shorter than the twin's. 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 (the documentation, benchmarking and protocol-assignment blocks are new here)
and the shared address space. 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. The table is read by the runtime's
own subnet list (net.BlockList): the module parses no address itself.

Globs. A pattern that ends in `**` returned nothing from file.list and file.search, and the Python twin's
Path.glob read `**` differently from one Python version to the next. Both packs now compile a glob by one
grammar: `**` 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 - as an expression, three stars against a name of 1,500 characters did not finish in two
minutes, with the event loop blocked. 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.

Also: the HTML reader looks a name from a page up in the tables' own keys only (`&constructor;` gave the text of
a function, a `<constructor>` element was a heading); a crawl that starts on an address literal or on a host
written with a dot at its end follows its links; an allowlist entry that starts with a class is a pattern
(`[ab].example.com` was read as the address `ab`), and one with a bracket that never closes is the pattern it
spells, where it was a 500 at the first request; file.write under a file is 400 `<path> is not a directory`; a
redirect to an address that cannot be read is a 400.

test/agent-tools.test.mjs: 59 pass before, 78 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 Python 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 c7ded7a into main Nov 30, 2026
5 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
…151) and the defect round (#152), 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 (127 analyzer rows, 107 fixed and 20 kept with their reason)
and the round that fixed what it had written down, in lockstep with the Python 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, a limit on a request body and 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 #152.

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