Skip to content

fix(managed-agent): refuse every URL fetch refuses and say why a health probe failed - #16110

Merged
wenshao merged 18 commits into
mainfrom
fix/managed-agent-upgrade-url-scheme
Nov 4, 2026
Merged

wenshao merged 18 commits into
mainfrom
fix/managed-agent-upgrade-url-scheme

Conversation

@wenshao

@wenshao wenshao commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

What this PR does

Follow-up to #16051, from the review notes that arrived around its merge.

  • Every URL fetch refuses is refused up front. start and verify used to refuse a listener URL only when URL.canParse rejected it. A --server-url without a scheme (proxy.test:8443, which parses as an opaque proxy.test: URL), with a user name or password, or on a port the Fetch standard blocks (6000, 10080 and 80 others) passed that check and then failed every probe until --timeout. The new fetchRefusal() refuses all four shapes before any unit starts, for the resolver's URLs and for --server-url alike, and says which one it is (--server-url "proxy.test:8443" is not an http or https URL.).
  • A probe that is sent and still fails says what it got. start's timeout used to say only "did not report UP … within Ns", and verify's health row only "is not UP". Now the timeout names the endpoint's last answer and the row names its own: HTTP 503, status DOWN, HTTP 502 (a proxy's error page), self-signed certificate, ECONNREFUSED, or The operation was aborted due to timeout. fetch itself words every failure as "fetch failed", so the answer comes from its cause.
  • Endpoint text cannot steer the terminal, and a refused URL keeps its password out. Control characters in the probe answer and in verify's session and turn rows (from the API's error reasons, Session IDs and event types) show as U+FFFD. A refused --server-url prints its password as ***. verify's API reads name the fetch cause as the health probe does.
  • The Harness verdict comes from the server. The configuration resolver (ResolvedConfiguration) now prints harnessOrigin, the server's own verdict on the Harness URL: skip for a disabled Harness, which nothing reads, and otherwise whether the Harness connector, single or pooled, takes the value. It prints that URL untrimmed, as the server parses it. start refuses on the verdict before it restarts the Harness, so the script keeps no copy of java.net.URI's rules.
  • verify checks the type of what the API answers before it uses it. A page without a data list, a Session id that is no string or names no route segment, an event type that is no string, or a sequence that is no whole number fails its row with what came back, instead of throwing inside a coercion.
  • The listeners() comment now names the reachesHarness: false option verify passes.
  • The design doc and the deployment guide (English and Chinese) list the refused shapes. The guide also says to point NODE_EXTRA_CA_CERTS at the CA when the certificate is not one this host trusts.

Why it's needed

The verify-pr round 2 report on #16051 measured URL.canParse('proxy.test:8443') as true and fetch rejecting it immediately, so start --server-url proxy.test:8443 waits out --timeout and then reports a server that is in fact UP. Checking the same path showed two more shapes with the same result: credentials in the URL (Request cannot be constructed from a URL that includes credentials) and the Fetch standard's blocked ports (bad port). A blocked port can come from the resolver's own output, for example server.port=6000. In every case the old health() swallowed the error, so the operator saw only a timeout. A certificate the host does not trust (self-signed certificate) failed the same silent way.

Reviewer Test Plan

How to verify

  • node --test scripts/tests/managed-agent-upgrade.test.mjs → 67/67.
  • refuses only the URLs fetch refuses pins each refusal and its wording, and keeps the list honest: every URL fetchRefusal() refuses (the 82 blocked ports out of 1–65535, two schemes, two credential forms) must be rejected by the runtime's real fetch with bad port, unknown scheme or the credentials TypeError. All of those rejections happen before any connection is made.
  • start refuses listeners it cannot reach before it starts anything adds the resolver at port 6000 and --server-url values proxy.test:8443, http://admin:secret@… and http://…:10080/. All of them are refused with both units still inactive.
  • verify says what the health endpoint answered instead of UP covers HTTP 404, HTTP 503, status UP, HTTP 502 with an HTML body, HTTP 200, terminated, self-signed certificate, and an AggregateError that carries only ECONNREFUSED.

Evidence (Before & After)

How fetch treats each shape, measured on Node 22.22.2 (/actuator/health appended):

URL URL.canParse (old check) fetch rejects with Before After
proxy.test:8443 true unknown scheme waits --timeout, "did not report UP" refused: is not an http or https URL
http://u:p@127.0.0.1:… true Request cannot be constructed from a URL that includes credentials waits --timeout refused: carries a user name or password, so fetch refuses it
http://127.0.0.1:6000 true bad port waits --timeout refused: is on port 6000, so fetch refuses to dial it
https://… (self-signed) true self-signed certificate "did not report UP" … (the last answer: self-signed certificate)
http://localhost:39999 (closed) true AggregateError, code ECONNREFUSED, empty message "is not UP" is not UP: ECONNREFUSED

The 82 blocked ports were read from the badPorts list in the Node 22 binary's bundled undici and match the Fetch standard. NODE_EXTRA_CA_CERTS=<the CA> turned the self-signed failure into 200 {"status":"UP"} in the same probe.

Mutation matrix (17 single-point mutants, scripts/tests/managed-agent-upgrade.test.mjs): 17/17 killed. The mutants drop or alter, one at a time:

  • the scheme check, the credentials check, and the password-only half of it;
  • the port check, its numeric lookup, and an added or removed port in the list;
  • the zone note;
  • each half of the cause fallback;
  • the status detail, the JSON-failure branches for success and non-success, and the success-status guard on UP (unpinned until now);
  • the answer in start's timeout and in verify's row;
  • a same-file positive control.

Review round 1 (13157b7c96).

  • Harness URL (triage note 2). start checked qwen.managed-agent.harness.base-url with new URL() alone, so an opaque value such as proxy.test:8443 parsed with an empty host and port, and start waited out --timeout for the Harness to listen on port 80 of an empty host. start now refuses a Harness URL that is not http or https before it starts a unit, as the server's preflight harness row would fail it later anyway. fetchRefusal() does not apply here: the Harness is reached by a TCP connect, where a port fetch blocks connects fine.
  • Real error shapes (triage "not verified"). The probe-answer test now also runs the runtime's own fetch against a port nothing listens on and expects connect ECONNREFUSED 127.0.0.1:<port>, so the cause.message the fallback reads comes from a real error. The self-signed and multi-address ECONNREFUSED shapes stay constructed in the suite (a real certificate would need a key in the repository); both were measured on Node 22.22.2, see the table above.
  • cause with neither message nor code (triage note 1). Kept. Every real fetch failure measured here carries one or the other; a cause with neither has nothing more to say than fetch failed, which is what is printed.
  • Mutants. Two more killed: the Harness check reduced to "is a URL", and its two wordings swapped. 19/19 in all.

Review round 2 (a25a76d2a6).

  • start's last answer (verification finding 1). waitFor gives the last probe the Math.max(deadline - now, 1) the deadline leaves, which is 1 ms once the deadline has passed, so against a real endpoint that probe times out before any answer arrives, and start's timeout reported The operation was aborted due to timeout instead of the HTTP 503, status DOWN the endpoint had been answering. The suite missed it because the rig's fetch ignored the signal. Now a probe that times out on a budget the deadline cut below the 5-second cap does not replace an earlier answer; one that runs out of its own 5 seconds still does, since then the endpoint has stopped answering. verify is unchanged: it makes one probe with the whole budget.
  • Test. The rig's fetch now awaits a response function, so a test can model an endpoint that answers in 50 ms on the real clock and honours the abort signal: of four probes the last one times out, and the message keeps HTTP 200, status DOWN. A second case answers once and then times out at the cap, and the message names the timeout.
  • Live cell. A real loopback endpoint answering 503 {"status":"DOWN"}, real fetch and the real clock, start --server-url … --timeout 1 and 2, eight runs per arm: before, 6/8 messages named the abort; after, 8/8 name HTTP 503, status DOWN.
  • IPv6-zone regex (verification finding 2). Pinned: http://127.0.0.1:70000/% is is not a URL with no zone note, so reverting the regex to /%/ now fails.
  • Mutants. Seven more, all killed: the guard removed, the cap clause removed, the cap boundary as <=, the earlier-answer clause removed, timedOut never set, timedOut keyed on AbortError, and the zone regex reverted. 26/26 in all.

Review round 3 (80d7e70e3d).

  • A body that stalls after its headers (verification finding 1, also the Copilot overview). fetch resolves once the headers arrive, so a body the deadline stalls rejects in response.json(), with the same TimeoutError (measured on a real socket, Node 22.22.2). That branch did not report timedOut, so a probe the deadline cut short replaced an earlier HTTP 503, status DOWN with HTTP 200, The operation was aborted due to timeout. The body-read branch now reports timedOut too. On the real clock, with a live endpoint that answers 503 once and then sends 200 headers and stalls (--timeout 3, four runs per arm), the last answer was the abort 4/4 before and is HTTP 503, status DOWN 4/4 after.
  • The timedOut half of the guard (verification finding 2). It is now pinned. The last-answer test has two real-socket cases: the stalled body, and an endpoint that answers 503 and then closes, so the next probe's connect ECONNREFUSED 127.0.0.1:<port> replaces the earlier answer even though the deadline cut that probe's time as well. Dropping probe.timedOut && now fails the test. The test, with both real-socket cases, passed 20/20 in repeats.
  • "Its own 5 seconds" (verification finding 3). The design doc now says a probe's own 5-second limit counts when it runs out before the deadline, and that any other failure, such as a refused connection, replaces an earlier answer. At --timeout 6 on the real clock, the second probe has about 4,999 ms left, so the deadline is what ends it. The rule is unchanged; the test's fake clock pins the exact 5,000 ms boundary.
  • Mutants. Three more, all killed: the body-read branch without timedOut, with timedOut always false, and the guard without probe.timedOut. The six round-2 guard mutants and the zone mutant were rerun and are still killed. 29/29 in all.

Review round 4 (d8e6c1bb5f, 5c18f44efa, 0d44ff8455, 8ee2ce3b26).

  • The bot review at 80d7e70e3d (R1-1 to R1-5), fixed in d8e6c1bb5f and 5c18f44efa.
    • R1-1: the health answer's control characters (C0, DEL, C1) become U+FFFD, so an endpoint cannot move the cursor, split the row or write the clipboard. This is pinned over a real socket.
    • R1-2: a Harness URL that does not parse names the IPv6 zone, as --server-url does.
    • R1-3: start labels the kept value the last answer.
    • R1-4: verify's URL refusal is pinned.
    • R1-5: the closes test server is torn down in t.after.
  • A real systemd deployment. Old and new reference archives were packaged from this branch. The rig has real qma-e2e-* units under a service account, MySQL 8.4.6, and the Hosted Harness on a fake model. Each cell ran once with main's upgrade script and once with this branch's:
Cell main This PR
P0: install, then start and verify --turn — both pass
S1: server.port: 6000 in application.yml (Spring serves it) 18.7 s, both units started, "did not report UP" 0.8 s, no unit started, "is on port 6000, so fetch refuses to dial it"; verify refuses too
S2: --server-url localhost:<port> 18.8 s, units started, "did not report UP" 0.8 s, "is not an http or https URL"
S2: --server-url http://ops:secret@… verify prints the password in its session row refused, password shown as ***
S3: Harness URL localhost:<port> waits 15.9 s for "not listening on " (no host) 0.8 s, no unit started, "is not an http or https URL"
S3: Harness URL http://[fe80::1%eth0]:<port> "which is not a URL" "which is not a URL: a URL cannot carry an IPv6 zone"
S4: Spring DOWN (a disk-space threshold no disk meets; curl gets 503 {"status":"DOWN"}) "did not report UP"; "is not UP" (the last answer: HTTP 503, status DOWN) at --timeout 10, 13 and 17; "is not UP: HTTP 503, status DOWN"
S5: TLS from a private CA (Store at https, Harness trusts the CA) "is not UP"; session "fetch failed" "self-signed certificate in certificate chain" in both rows; with NODE_EXTRA_CA_CERTS, start and verify --turn pass
S5: self-signed certificate — "self-signed certificate"; with NODE_EXTRA_CA_CERTS, start and verify --turn pass
S6: nginx in front, wrong upstream "did not report UP" (the last answer: HTTP 502); "is not UP: HTTP 502"
S6: nginx in front, right upstream — start and verify --turn pass through nginx
  • What the real run found, fixed in 0d44ff8455.
    • A refused --server-url with a password printed the password. It now prints http://ops:***@127.0.0.1:<port>/.
    • verify's session and turn rows said only "fetch failed", under a health row that named the cause. API reads now take the same cause.
    • Text from the API reached those rows with its control bytes: error reasons, a body that does not parse, Session IDs and event types. It is now neutralized like the health answer.
    • Rerun on the same rig with 0d44ff8455 swapped in: P0 passes, both credential refusals are masked and no output holds the password, and the TLS session rows name the certificate error.
  • A status that is no string (the Copilot overview at 0d44ff8455), fixed in 8ee2ce3b26. printable() ran String() on the endpoint's value. String() throws on a valid JSON object whose own toString is no function, such as {"status":{"toString":1}}, and health() is not inside a try. On the rig, verify exited with Cannot convert object to primitive value before printing its health row, and start stopped at its first probe. Such a value is now shown as its JSON. On the same rig, verify prints is not UP: HTTP 200, status {"toString":1}, and start waits out --timeout with that as its last answer. A test pins both, plus an API error reason of that shape, and reverting to String() fails two tests.
  • Found here, outside this PR. Since refactor(managed-agent): Split server into Maven modules #15871 split the server into modules, check's database row WARNs "cannot compare the Flyway scripts (no Flyway script found in …)" on every archive. The scripts moved into BOOT-INF/lib/qwen-managed-agent-persistence-*.jar, and the scan reads only BOOT-INF/classes/. Fixed separately in fix(managed-agent): find the Flyway scripts in the module jar the server ships them in #16175.
  • Mutants. Eleven more, all killed: withoutPassword as a no-op; the refusal without it; API reads without the cause; the cause unsanitized (killed once a case with control bytes in the cause was added); the API reason, the unreadable-body message, the Session ID, and the passing and failing turn rows each unsanitized; and the autofix's sanitization and zone reason reverted. With printable() back on String(), 41/41 in all.

Review round 5 (13cd545086). The bot's rounds 2 and 3 at 8ee2ce3b26 raised six findings, all in two shared causes. They are fixed at the source:

  • The reports are total and bounded.
    • R1-1: printable() no longer throws on any parsed JSON value. A status nested deeper than JSON.stringify() recurses shows as [unprintable].
    • R2-3: the text stops at 200 code points with … (N characters), cut after the control bytes are replaced and never inside a surrogate pair.
    • R2-2: the session row's item count goes through it too.
    • R2-1: withoutCredentials() masks the whole user information, so a token in the user-name position is masked. It also masks textually when the URL does not parse, and the Harness refusal uses it.
  • A phase is refused only over what it dials.
    • R3-1: start and verify check the health endpoint, and only verify --tenant, which reads the API, checks the API URL. An API on a port fetch refuses, behind a separate management port, no longer stops start.
    • R3-2: the Harness URL is checked as the preflight's harnessOrigin checks it, an http(s) origin without user information, a query or a fragment, so start refuses it before restarting a running Harness.
  • Real rig, previous head 8ee2ce3b26 against this one:
Cell 8ee2ce3b26 13cd545086
server.port: 6000 with a separate management.server.port start refused in 0.9 s start UP on the management port; verify passes; verify --tenant refuses over the API port
Harness running, base-url …/?tenant=acme restarted the Harness, then failed the preflight refused in 0.9 s, Harness not restarted
--server-url http://admin:secret@127.0.0.1:70000 printed the password "http://***@127.0.0.1:70000" is not a URL
health status nested 20 000 deep verify: only Maximum call stack size exceeded; start: the same, server left running is not UP: HTTP 200, status [unprintable]; start reports the last answer and that the server keeps running
health status of 100 000 characters a 100 094-character line 317 characters, ending … (100000 characters)
the happy path, verify --turn — passes
  • Docs. The design doc and the deployment guide (English and Chinese) say which URLs each phase checks, the Harness origin rule, the masking and the 200-code-point cut.
  • Tests and mutants. 66/66 on Node 22.22.2 and Node 24.14.0. Fourteen more mutants, all killed, one per check above. 55/55 in all.

Review round 6 (c80d768a42, e51f95f2e2). The bot's round 4 at 13cd545086 raised four findings and deferred one. Two of them, R4-1 and R3-2, came from the script deciding again what the server already decides, so the script now takes the server's answer:

  • R4-1 (Critical). verify decides its session row before it checks the listeners, from the resolver run listeners() takes anyway. It checks the API URL only when that row reads the API: --tenant is given, the auth mode is open, and --actor, when given, has a trusted actor header. It always checks the health URL.
  • R3-2. ResolvedConfiguration prints harnessOrigin: what ManagedAgentPreflight.harnessOrigin, now package-private, makes of the value the server parses, untrimmed. It also prints that value untrimmed. start refuses on that verdict before it restarts the Harness. That covers a host with an underscore, an empty user name, a padded value, and anything else java.net.URI rejects. When the configuration does not resolve, only the reasons the script names itself apply.
  • R2-1. In a value the parser rejects, everything up to the last @ is masked, and a leading // keeps its place. A value that parses with an authority comes back unchanged.
  • R2-3. printable() counts code points in one pass and keeps only the head. The output is byte-identical.
  • The deferred item. The request an API error names goes through printable() too, so a long Session ID cannot stretch the row.
  • Real rig. alpha.101 was packaged from e51f95f2e2 and installed over alpha.100 through check, stop, backup and install. The previous head's script was swapped into a copy of the same release:
Cell 13cd545086 e51f95f2e2
Signed auth, API on 6000, health on its own management port: verify --tenant e2e refused before any row PASS preflight, PASS health, SKIP session; exit 0
Open auth, no trusted actor header: verify --tenant e2e --actor alice refused before any row PASS health; FAIL session --actor needs a trusted actor header
Harness running, base-url set to ' http://…:54787 ', http://@…:54787 or http://qwen_harness:54787 restarted the Harness, then failed the preflight (for qwen_harness, waited out 10 s) refused in about 0.8 s, Harness not restarted; the padded value shows its padding
--server-url https://svc:Pa/ss@…, …:Pa?ss@…, //svc:s3cret@… printed the password https://***@…, //***@…
Health status of 40 MiB, --max-old-space-size=160 FATAL ERROR: … heap out of memory the 318-character row
Health status of 10 Mi emoji, 160 MB heap verify and start crash, start after starting the server the bounded row
Peak RSS for those two statuses at the default heap 1 127 MB and 678 MB 257 MB and 254 MB
A listed Session ID of 100 000 characters whose read fails a 100 067-character row 270 characters
The happy path, verify --turn, before and after the scenarios — passes
  • Tests and mutants.
    • The JS suite passes 66/66 on Node 22.22.2 and on Node 24.14.0 (aarch64).
    • ResolvedConfigurationTest passes 14/14 and ManagedAgentPreflightTest 82/82, with checkstyle.
    • Seventeen more mutants, all killed, 72/72 in all.
    • Twelve of them are in the JS:
      • the masking (3);
      • the read decision (2);
      • the verdict, ignored or not passed on (2);
      • the count, the head bound, the head's sanitizing and the exact-bound suffix (4);
      • the label (1).
    • Five are in the Java:
      • the host check dropped;
      • the user-information check dropped;
      • the verdict taken on the trimmed value;
      • the verdict always true;
      • the URL trimmed again.

Review round 7 (3a556b9ab5, 9b8a548e3c, 948e7484b5). The bot's round 5 at aa53b9833e raised one Critical finding and deferred two. Two independent reviews of the fix then found more. All of it is fixed:

  • R3-2 (fix-induced). ManagedAgentPreflight.harnessUrlVerdict sits next to harnessCheck. ResolvedConfiguration prints its verdict as harnessOrigin.
    • It gives skip with the Harness disabled, the default. The harness row returns before it reads base-url, BrokerSecurity returns early, and the connector bean is conditional on enabled, so nothing reads the value.
    • A pooled Harness is still judged. The bot suggested skip there too, and the first commit followed it. But HarnessConfiguration builds every pool member's QwenHostedHarnessConnector from the single base-url. That connector refuses anything but an http(s) URL with a host and without user information, a query or a fragment. HarnessPoolConnector.refresh() drops a member whose connector throws. So such a pool reports UP and accepts no Session.
    • start asks nothing more of true or skip. On false it words the reason. The user-information and query/fragment rungs, copies of the same rule, now only word that verdict.
    • When the configuration does not resolve there is no verdict, and those rungs still apply: the server refuses those values wherever it reads them. The scheme rung always applies, since start waits on that host and port.
  • The deferred items.
    • The two start refusal loops check each run's output for the password, not only the last run's.
    • verify checks the type of every value the API chose before it uses one. The regex, encodeURIComponent(), Number(), iteration and .length all coerced first, and {"toString":1} or a 20 000-deep array made them throw before printable() could say what came back. Now:
      • A page needs its data as a list.
      • A Session id needs to be a string a route can carry as one segment (not empty, . or ..).
      • An event type names an outcome only as a string, and only terminal: true ends a turn.
      • A sequence moves the cursor only as a whole number or its digits, and only forward.
  • Real rig. Each release was packaged from the branch and installed over the previous one through check, stop, backup and install. Each arm ran while its own release was installed. The database was recreated empty once, because main's refactor(managed-agent): align shared MySQL schema conventions #16143 rewrote V1__managed_schema.sql in place.
Cell PR head (alpha.101) 3a556b9ab5 (alpha.102) This round (alpha.103/104)
Harness disabled, base-url ' http://…:54787 ' or …/?tenant=acme: start refused in 0.8 s skip; SKIP harness disabled; UP same
One-instance static pool, padded base-url or http://qwen_harness:54787 refused in 0.8 s UP on a pool that accepts nothing, or a 30 s wait on qwen_harness refused in 0.9 s, Harness not started
Same pool, clean base-url — UP "harnessOrigin":"true"; UP
Harness enabled and running, padded base-url refused, not restarted same same, "the server does not take as an http or https base URL"
The configuration does not resolve (no java on server.env's PATH), …/?tenant=acme or http://svc:s3cret@… — restarts the Harness, then the preflight fails (measured on alpha.103, whose code here is the same) alpha.104: refused in 60 ms, Harness not started, password masked
API answers a Session id {"toString":1} / 20 000 deep FAIL … Cannot convert object to primitive value / Maximum call stack size exceeded FAIL the API answered a Session without a string id ({"toString":1}) / ([unprintable]) same
A terminal event of type 7; a null event first PASS … ended with 7; Cannot read properties of null FAIL … ended with 7; PASS same
{"data":[0]}; items {"data":{"length":2}}; events {"data":{}} WARN … no Session; PASS … 2 item(s); object is not iterable same as alpha.101 FAIL … without a string id (0); FAIL … answered no data list ({"length":2}); … ({})
A bare [{"id":"s1"}]; Session id ..; "terminal":"false" WARN … no Session; a 404 from /v1/agents; PASS same FAIL … answered no data list (…); FAIL … whose id ".." names no route; FAIL … no terminal event within 5s
The happy path, verify --tenant e2e --turn passes passes passes
  • Tests and mutants.
    • The JS suite passes 67/67 on Node 22.22.2 and on Node 24.14.0 (aarch64).
    • ResolvedConfigurationTest 15/15, ManagedAgentPreflightTest 82/82 and HarnessConfigurationTest 2/2, also on the tree merged with main.
    • judgesTheHarnessUrlAsTheConnectorThatDialsItDoes checks that, for 13 URLs, the verdict is whether the real connector builds.
    • buildsEachPoolMembersConnectorFromTheSingleBaseUrl builds a pool through the real factory: one member for a clean base-url, none for a padded or underscore one. It fails when the connector stops checking the URL.
    • Thirty-one more mutants, all killed, 103/103 in all. Twenty-six are in the JS: the verdict gate (6), the scheme rung, the Session id (3), the event type (2), the sequence (5), the page lists (5), the null event, the error prefix, terminal, and the dot ids. Five are in the Java: the enabled guard dropped, the pool guard dropped and added back, skip read as true, and the connector's URL check dropped.

Review round 8 (3b67b6ec1d). The bot's round 6 at 8529a681e8 raised one Critical item, and a maintainer review on 814b121014 carried it forward. The bot also deferred four.

  • R6-1. The Mockito static import broke the verification module's ImportOrder check; the block is sorted now. mvn -o -B -pl server,verification checkstyle:check passes.
  • --server-url with a query or a fragment is refused. The paths are appended to it, so http://…/?q probed /?q/actuator/health (seen on a real listener), and a fragment lost the path.
  • A Session entry with no id is shown as itself, and the health row's parse-error path is pinned to come out sanitized.
  • Left for review: harnessUrlVerdict does not model BrokerSecurity's plaintext-transport policy. That is a startup policy the preflight's validation row reports, not a URL-shape rule.
  • JS 67/67 on Node 22 and 24. Java: ResolvedConfigurationTest 15, ManagedAgentPreflightTest 82, HarnessConfigurationTest 2 and ClassSizeRatchetTest 1, all passing, plus checkstyle. Four more mutants, all killed, 107/107 in all.

Tested on

OS Status
🍏 macOS ⚠️
🪟 Windows ⚠️
🐧 Linux ✅

Linux x86_64 with Node 22.22.2, and Linux aarch64 with Node 24.14.0 (the suite also passes 67/67 there, so the blocked-port list matches both runtimes).

Environment (optional)

Rounds 4 to 7 also ran on a real systemd host. That host has systemd 257 units for the control plane and the Harness, MySQL 8.4.6, nginx and a scripted model, and its reference archives are packaged from the branch. The upgrade command runs under systemd, which is Linux-only.

Risk & Scope

  • Main risk or tradeoff: the blocked-port list is copied from the Fetch standard. If a later Node blocks a port the list lacks, the test still passes, and that port falls back to the probe answer (bad port) at the timeout instead of an up-front refusal. If a port were dropped from the standard, the agreement test would fail.
  • The PR now touches Java. ResolvedConfiguration prints one more key and the Harness URL untrimmed, and ManagedAgentPreflight gains the package-private harnessUrlVerdict and harnessOrigin. The verdict leans on two server facts that tests now pin: the connector's URL rule (ResolvedConfigurationTest) and the pool building each member from the single base-url (HarnessConfigurationTest). PR CI runs no Java tests, so the three Java test classes above ran locally. Main's ClassSizeRatchetTest failure on JournalCommit (886 lines over its 880 ceiling) is fixed by fix(managed-agent): restore JournalCommit under its class-size ratchet #16323, merged here; it passes on this head.
  • Validated on a real systemd host (rounds 4 to 7). Not validated: macOS or Windows. Two review notes on fix(managed-agent): reach the listeners the server resolves in upgrade start and verify #16051 are deliberately left as they are. The port != 0 clause the mutation report calls dead mirrors Spring Boot's ManagementPortType condition word for word, so it stays for the reader. serverBaseUrl() is still the server.env fallback inside listeners() and has its own tests, so it is not unused. The --check gap stays in Managed Agent --check ignores the configuration files the server reads from its working directory #16057.
  • Breaking changes / migration notes: none. A URL refused now would have failed every probe before.

Linked Issues

Follow-up to #16051. Related: #16057 (not addressed here).

中文说明

这个 PR 做了什么

#16051 合入前后收到几条评审意见,本 PR 是它们的 follow-up。

  • fetch 会拒绝的 URL,一律在开始前拒绝。 以前 start 和 verify 只在 URL.canParse 不通过时拒绝监听 URL。下面几种 --server-url 都能通过这项检查,随后每次探测都失败,直到 --timeout:没有 scheme 的(proxy.test:8443 会被解析成 scheme 为 proxy.test: 的不透明 URL)、带用户名或密码的、端口在 Fetch 标准屏蔽列表里的(6000、10080 等共 82 个)。新增的 fetchRefusal() 在启动任何 unit 之前拒绝这四种情况,对解析器给出的 URL 和 --server-url 一视同仁,并说明属于哪种(--server-url "proxy.test:8443" is not an http or https URL.)。
  • 探测发出后仍然失败时,说明收到了什么。 以前 start 超时只说 "did not report UP … within Ns",verify 的 health 行只说 "is not UP"。现在超时提示给出端点最后一次的应答,health 行给出本次探测的结果,例如 HTTP 503, status DOWN、HTTP 502(代理的错误页)、self-signed certificate、ECONNREFUSED、The operation was aborted due to timeout。fetch 自己对所有失败都只报 "fetch failed",所以原因取自它的 cause。
  • 端点返回的文本无法操纵终端,被拒绝的 URL 不会带出密码。 探测应答,以及 verify 的 session 和 turn 行(来自 API 的错误原因、Session ID 和事件类型)中的控制字符显示为 U+FFFD。被拒绝的 --server-url 把密码显示为 ***。verify 读取 API 失败时,与健康探测一样给出 fetch 的 cause。
  • Harness 的判定来自服务端。 配置解析器(ResolvedConfiguration)现在输出 harnessOrigin,即服务端自己对 Harness URL 的判定:Harness 被禁用时为 skip(没有任何地方读取它),否则为 Harness 连接器(单实例或 pool)是否接受该取值;并且按服务端的解析方式输出未经 trim 的 URL。start 在重启 Harness 之前依据该判定拒绝执行,因此脚本不再保留一份 java.net.URI 规则的副本。
  • verify 先检查 API 返回值的类型再使用。 页面没有 data 列表、Session id 不是字符串或不能作为路由中的一段、事件类型不是字符串、序号不是整数时,该行判失败并写出实际返回的值,而不是在隐式转换中抛错。
  • listeners() 的注释写明了 verify 传入的 reachesHarness: false 选项。
  • 设计文档和部署指南(中英文)列出了会被拒绝的几种情况。部署指南还说明:证书不受本机信任时,用 NODE_EXTRA_CA_CERTS 指向其 CA。

为什么需要

#16051 的 verify-pr 第 2 轮报告实测:URL.canParse('proxy.test:8443') 返回 true,而 fetch 会立即拒绝这个 URL。结果 start --server-url proxy.test:8443 会等满 --timeout,然后报告一个实际已经 UP 的服务没有起来。顺着同一条路径排查,又发现两种结果相同的情况:URL 带凭据(Request cannot be constructed from a URL that includes credentials),以及 Fetch 标准屏蔽的端口(bad port)。屏蔽端口也可能来自解析器本身的输出,例如 server.port=6000。这几种情况下旧的 health() 都把错误吞掉了,运维只能看到超时。证书不受本机信任(self-signed certificate)时,同样是这样无声地失败。

评审测试计划

如何验证

  • node --test scripts/tests/managed-agent-upgrade.test.mjs → 67/67。
  • refuses only the URLs fetch refuses 固定了每种拒绝及其措辞,并保证列表与实际一致:fetchRefusal() 拒绝的每个 URL(1–65535 中的 82 个屏蔽端口、两种 scheme、两种凭据写法),真实 fetch 都必须以 bad port、unknown scheme 或凭据 TypeError 拒绝。这些拒绝都发生在建立连接之前。
  • start refuses listeners it cannot reach before it starts anything 新增了解析器给出端口 6000 的情况,以及 --server-url 取 proxy.test:8443、http://admin:secret@…、http://…:10080/ 的情况。这些都会被拒绝,两个 unit 均保持 inactive。
  • verify says what the health endpoint answered instead of UP 覆盖了 HTTP 404、HTTP 503, status UP、带 HTML 正文的 HTTP 502、HTTP 200, terminated、self-signed certificate,以及只带 ECONNREFUSED 代码的 AggregateError。

证据(修改前后)

在 Node 22.22.2 上实测 fetch 对每种 URL 的处理(URL 后拼接 /actuator/health):

URL URL.canParse(旧检查) fetch 的拒绝原因 修改前 修改后
proxy.test:8443 true unknown scheme 等满 --timeout,报 "did not report UP" 拒绝:is not an http or https URL
http://u:p@127.0.0.1:… true Request cannot be constructed from a URL that includes credentials 等满 --timeout 拒绝:carries a user name or password, so fetch refuses it
http://127.0.0.1:6000 true bad port 等满 --timeout 拒绝:is on port 6000, so fetch refuses to dial it
https://…(自签名) true self-signed certificate "did not report UP" … (the last answer: self-signed certificate)
http://localhost:39999(端口未监听) true AggregateError,code 为 ECONNREFUSED,message 为空 "is not UP" is not UP: ECONNREFUSED

这 82 个屏蔽端口取自 Node 22 二进制所带 undici 中的 badPorts 列表,与 Fetch 标准一致。设置 NODE_EXTRA_CA_CERTS=<该 CA> 后,同一次探测的自签名失败变为 200 {"status":"UP"}。

变异矩阵(17 个单点变异,scripts/tests/managed-agent-upgrade.test.mjs):17/17 被测试拦住。每个变异单独去掉或改动以下一处:

  • scheme 检查、凭据检查,以及凭据检查中只有密码的那一半;
  • 端口检查、端口的数值查找,以及在列表中多加或删掉一个端口;
  • zone 提示;
  • cause 回退链的两段;
  • status 详情、成功与非成功状态下 JSON 解析失败的两个分支,以及 UP 必须伴随成功状态码的判断(此前没有测试守住);
  • start 超时提示和 verify 行中的探测结果;
  • 一个同文件阳性对照。

评审第 1 轮(13157b7c96)。

  • Harness URL(triage 意见 2)。 start 以前只用 new URL() 检查 qwen.managed-agent.harness.base-url,所以 proxy.test:8443 这类不透明取值会被解析成主机和端口都为空的 URL,start 随后等满 --timeout,等一个空主机的 80 端口开始监听。现在 start 在启动任何 unit 之前,就拒绝不是 http 或 https 的 Harness URL;反正服务端 preflight 的 harness 行之后也会判它失败。这里不适用 fetchRefusal():Harness 是通过 TCP connect 访问的,fetch 屏蔽的端口照样能连上。
  • 真实错误形状(triage 的"未验证"项)。 探测结果的测试现在还会用运行时自己的 fetch 去访问一个没有监听的端口,期望得到 connect ECONNREFUSED 127.0.0.1:<port>,因此回退链读取的 cause.message 来自真实错误。自签名证书和多地址 ECONNREFUSED 两种形状在套件里仍是构造出来的(真实证书需要把私钥放进仓库);这两种都已在 Node 22.22.2 上实测,见上表。
  • cause 既无 message 也无 code(triage 意见 1)。 保持不变。这里实测过的真实 fetch 失败都至少带其中之一;两者都没有时,除了 fetch failed 也没有别的可说,而打印的正是这句。
  • 变异。 新增 2 个,均被拦住:把 Harness 检查放宽为"是 URL 即可",以及对调它的两种措辞。合计 19/19。

评审第 2 轮(a25a76d2a6)。

  • start 的最后一次应答(验证发现 1)。 waitFor 给最后一次探测的预算是截止时间剩下的 Math.max(deadline - now, 1),过了截止时间就只有 1 毫秒,所以面对真实端点时,这次探测在任何应答到达之前就会超时,start 的超时提示于是报告 The operation was aborted due to timeout,而不是端点一直在返回的 HTTP 503, status DOWN。套件没发现,是因为夹具里的 fetch 忽略了 signal。现在,预算被截止时间截到 5 秒上限以下、并因此超时的探测,不再覆盖之前的应答;用满自身 5 秒才超时的探测仍会覆盖,因为这时端点确实不再应答。verify 不变:它只用全部预算探测一次。
  • 测试。 夹具里的 fetch 现在会 await 应答函数,因此测试可以模拟一个按真实时钟 50 毫秒后才应答、并遵守 abort signal 的端点:四次探测中最后一次超时,提示仍是 HTTP 200, status DOWN。第二个用例先应答一次,之后在 5 秒上限处超时,提示给出的是超时。
  • 真实端点实测。 回环上的真实端点返回 503 {"status":"DOWN"},用真实 fetch 和真实时钟运行 start --server-url … --timeout 1 和 2,每组 8 次:修复前 6/8 次提示的是 abort;修复后 8/8 次都是 HTTP 503, status DOWN。
  • IPv6 zone 正则(验证发现 2)。 已用测试钉住:http://127.0.0.1:70000/% 给出 is not a URL,不带 zone 提示,因此把正则改回 /%/ 现在会失败。
  • 变异。 新增 7 个,全部被拦住:去掉整个判断、去掉上限条件、上限边界改成 <=、去掉"已有应答"条件、timedOut 恒为假、timedOut 改按 AbortError 判断,以及把 zone 正则改回旧版。合计 26/26。

评审第 3 轮(80d7e70e3d)。

  • 响应头之后卡住的响应体(验证发现 1,Copilot 概览指的也是这一条)。 响应头一到,fetch 就会 resolve。所以响应体被截止时间卡住时,是 response.json() 抛出同样的 TimeoutError(已在真实 socket 上实测,Node 22.22.2)。这个分支以前没有给出 timedOut,于是一个被截止时间截短的探测,会把之前的 HTTP 503, status DOWN 覆盖成 HTTP 200, The operation was aborted due to timeout。现在读取响应体的分支也会给出 timedOut。真实时钟实测:真实端点第一次返回 503,之后发出 200 响应头再卡住(--timeout 3,每组 4 次)。修复前最后的应答 4/4 次是 abort,修复后 4/4 次是 HTTP 503, status DOWN。
  • 判断条件中 timedOut 这一半(验证发现 2)。 已用测试守住。"最后应答"测试新增两个真实 socket 用例。一个是响应体卡住。另一个是端点先返回 503 再关闭:下一次探测得到 connect ECONNREFUSED 127.0.0.1:<port>,即使这次探测的时间也被截止时间截短了,它仍会覆盖之前的应答。去掉 probe.timedOut && 现在会让测试失败。含这两个用例的测试重复跑了 20 次,全部通过。
  • "自身 5 秒"的边界(验证发现 3)。 设计文档改为:探测自身的 5 秒上限在截止时间之前用完,才算它自己超时;其他失败(例如连接被拒)也会覆盖之前的应答。真实时钟下 --timeout 6 的第二次探测只剩约 4999 毫秒,先到的是截止时间。规则本身不变,测试用的假时钟钉住了恰好 5000 毫秒这个边界。
  • 变异。 新增 3 个,全部被拦住:读取响应体的分支不给 timedOut、timedOut 恒为假,以及判断条件去掉 probe.timedOut。第 2 轮的 6 个判断条件变异和 zone 变异重跑后,仍全部被拦住。合计 29/29。

评审第 4 轮(d8e6c1bb5f、5c18f44efa、0d44ff8455、8ee2ce3b26)。

  • bot 对 80d7e70e3d 的评审(R1-1 至 R1-5),已在 d8e6c1bb5f 和 5c18f44efa 中修复。
    • R1-1:健康应答中的控制字符(C0、DEL、C1)替换为 U+FFFD,端点无法移动光标、拆开一行或写剪贴板。已在真实 socket 上用测试钉住。
    • R1-2:无法解析的 Harness URL 会像 --server-url 一样点明 IPv6 zone。
    • R1-3:start 把保留的值标为 the last answer。
    • R1-4:verify 的 URL 拒绝已用测试钉住。
    • R1-5:测试服务器 closes 在 t.after 中关闭。
  • 真实 systemd 部署。 新旧两个 reference 发行包都从本分支打包。环境里有服务账号下真实的 qma-e2e-* unit、MySQL 8.4.6,以及接假模型的 Hosted Harness。每个场景分别用 main 的升级脚本和本分支的脚本各跑一次:
场景 main 本 PR
P0:install 后 start、verify --turn — 都通过
S1:application.yml 中 server.port: 6000(Spring 正常监听) 18.7 秒,两个 unit 都已启动,"did not report UP" 0.8 秒,不启动任何 unit,"is on port 6000, so fetch refuses to dial it";verify 同样拒绝
S2:--server-url localhost:<port> 18.8 秒,unit 已启动,"did not report UP" 0.8 秒,"is not an http or https URL"
S2:--server-url http://ops:secret@… verify 在 session 行打印出密码 拒绝,密码显示为 ***
S3:Harness URL 为 localhost:<port> 等满 15.9 秒,"not listening on "(没有主机) 0.8 秒,不启动任何 unit,"is not an http or https URL"
S3:Harness URL 为 http://[fe80::1%eth0]:<port> "which is not a URL" "which is not a URL: a URL cannot carry an IPv6 zone"
S4:Spring 报 DOWN(磁盘空间阈值不可能满足;curl 得到 503 {"status":"DOWN"}) "did not report UP";"is not UP" --timeout 取 10、13、17 时都给出 (the last answer: HTTP 503, status DOWN);"is not UP: HTTP 503, status DOWN"
S5:私有 CA 签发的 TLS(Store 走 https,Harness 信任该 CA) "is not UP";session 行 "fetch failed" 两行都给出 "self-signed certificate in certificate chain";加上 NODE_EXTRA_CA_CERTS 后 start 和 verify --turn 通过
S5:自签名证书 — "self-signed certificate";加上 NODE_EXTRA_CA_CERTS 后 start 和 verify --turn 通过
S6:前置 nginx,上游写错 "did not report UP" (the last answer: HTTP 502);"is not UP: HTTP 502"
S6:前置 nginx,上游正确 — 经 nginx 的 start 和 verify --turn 都通过
  • 真实运行发现的问题,已在 0d44ff8455 中修复。
    • 被拒绝的 --server-url 带密码时,会把密码打印出来。现在显示为 http://ops:***@127.0.0.1:<port>/。
    • verify 的 session 和 turn 行只说 "fetch failed",而上面的 health 行已给出原因。现在 API 读取失败时给出同样的 cause。
    • 来自 API 的文本会连同控制字节进入这些行:错误原因、无法解析的响应体、Session ID 和事件类型。现在像健康应答一样净化。
    • 把 0d44ff8455 换进同一环境后重跑:P0 通过,两处凭据拒绝都已遮蔽,所有输出中都没有密码,TLS 场景的 session 行给出证书错误。
  • 不是字符串的 status(Copilot 对 0d44ff8455 的概览),已在 8ee2ce3b26 中修复。 printable() 对端点返回的值调用 String()。对于自带不可调用 toString 的合法 JSON 对象,例如 {"status":{"toString":1}},String() 会抛错,而 health() 不在 try 中。在测试环境上,verify 还没打印 health 行就以 Cannot convert object to primitive value 退出,start 在第一次探测时就停止了。现在这类值显示为它的 JSON。在同一环境上,verify 打印 is not UP: HTTP 200, status {"toString":1},start 等满 --timeout 后把它作为最后一次的应答。测试钉住了这两处,以及同样形状的 API 错误原因;改回 String() 会让两个测试失败。
  • 这里发现、但不属于本 PR 的问题。 自 refactor(managed-agent): Split server into Maven modules #15871 把服务端拆成多个模块后,每个发行包上 check 的 database 行都会 WARN "cannot compare the Flyway scripts (no Flyway script found in …)"。迁移脚本挪进了 BOOT-INF/lib/qwen-managed-agent-persistence-*.jar,而扫描只读 BOOT-INF/classes/。已在 fix(managed-agent): find the Flyway scripts in the module jar the server ships them in #16175 中单独修复。
  • 变异。 新增 11 个,全部被拦住:withoutPassword 改为空操作;拒绝提示不再调用它;API 读取不取 cause;cause 不净化(补了一个 cause 带控制字节的用例后被拦住);API 的错误原因、无法读取响应体的信息、Session ID,以及通过和失败的 turn 行各自不净化;以及把自动修复的净化和 zone 原因还原。加上把 printable() 改回 String() 的变异,合计 41/41。

评审第 5 轮(13cd545086)。 bot 第 2、3 轮针对 8ee2ce3b26 提出 6 条发现,都归结为两个共同根因,已从根源修复:

  • 报告不会抛错,长度有上限。
    • R1-1:printable() 对任何解析出的 JSON 值都不再抛错,嵌套深到 JSON.stringify() 无法递归的 status 显示为 [unprintable]。
    • R2-3:文本在 200 个码点处截断并附上 … (N characters);先替换控制字节再截断,且不会截在代理对中间。
    • R2-2:session 行的条目数同样经过它。
    • R2-1:withoutCredentials() 遮蔽整个用户信息,因此用户名位置上的 token 也会被遮蔽;URL 无法解析时按文本遮蔽;Harness 的拒绝提示也用它。
  • 每个阶段只因自己拨号的 URL 而拒绝。
    • R3-1:start 和 verify 检查健康端点,只有读取 API 的 verify --tenant 才检查 API 的 URL。API 在 fetch 拒绝的端口上、健康端点在独立 management 端口时,不再挡住 start。
    • R3-2:Harness URL 按 preflight 的 harnessOrigin 检查,即不带用户信息、query 或 fragment 的 http(s) origin,因此 start 会在重启正在运行的 Harness 之前就拒绝。
  • 真实环境,上一版 8ee2ce3b26 对比本版:
场景 8ee2ce3b26 13cd545086
server.port: 6000,另设 management.server.port start 0.9 秒拒绝 start 在 management 端口上报告 UP;verify 通过;verify --tenant 因 API 端口拒绝
Harness 正在运行,base-url 为 …/?tenant=acme 先重启 Harness,再在 preflight 失败 0.9 秒拒绝,Harness 没有被重启
--server-url http://admin:secret@127.0.0.1:70000 打印出密码 "http://***@127.0.0.1:70000" is not a URL
健康 status 嵌套 20000 层 verify 只打印 Maximum call stack size exceeded;start 同样,且控制面留在运行状态 is not UP: HTTP 200, status [unprintable];start 给出最后一次的应答,并说明控制面保持运行
健康 status 长 100000 个字符 一行 100094 个字符 317 个字符,结尾为 … (100000 characters)
正常路径,verify --turn — 通过
  • 文档。 设计文档和部署指南(中英文)写明了每个阶段检查哪些 URL、Harness 的 origin 规则、凭据遮蔽,以及 200 码点的截断。
  • 测试与变异。 Node 22.22.2 与 Node 24.14.0 上均 66/66。新增 14 个变异,每项检查一个,全部被拦住。合计 55/55。

评审第 6 轮(c80d768a42、e51f95f2e2)。 bot 第 4 轮针对 13cd545086 提出 4 条发现,并延后 1 条。其中 R4-1 和 R3-2 都源于脚本把服务端已经做出的判断又重做了一遍,所以脚本改为直接采用服务端的结论:

  • R4-1(Critical)。 verify 先确定 session 行,再检查监听地址,所用的解析结果来自 listeners() 本来就会跑的那次解析器。只有当该行确实要读 API 时才检查 API URL,条件是:给了 --tenant、auth mode 为 open,并且给了 --actor 时服务端配置了可信 actor header。health URL 始终会检查。
  • R3-2。 ResolvedConfiguration 输出 harnessOrigin,即 ManagedAgentPreflight.harnessOrigin(现为包级可见)对服务端所解析的、未经 trim 的取值给出的判定;同时也原样输出这个取值。start 在重启 Harness 之前依据该判定拒绝执行,覆盖了带下划线的主机名、空用户名、带首尾空白的取值,以及 java.net.URI 拒绝的其他任何形式。无法解析配置时,只适用脚本自己能说明的原因。
  • R2-1。 对解析器拒绝的取值,最后一个 @ 之前的内容全部遮蔽,开头的 // 保留在原位。能解析且带 authority 的取值原样返回。
  • R2-3。 printable() 单次遍历计数码点,只保留开头部分,输出逐字节不变。
  • 被延后的那条。 API 报错中写出的请求同样经过 printable(),所以很长的 Session ID 不会把这一行撑长。
  • 真实环境。 用 e51f95f2e2 打包 alpha.101,经 check、stop、backup、install 安装在 alpha.100 之上;把上一个 head 的脚本换进同一发行包的副本作对照:
场景 13cd545086 e51f95f2e2
signed 认证,API 在 6000,health 在单独的 management 端口:verify --tenant e2e 输出任何一行之前就拒绝 preflight PASS、health PASS、session SKIP;退出码 0
open 认证且无可信 actor header:verify --tenant e2e --actor alice 输出任何一行之前就拒绝 health PASS;session FAIL --actor needs a trusted actor header
Harness 正在运行,base-url 为 ' http://…:54787 '、http://@…:54787 或 http://qwen_harness:54787 先重启 Harness,再让 preflight 失败(qwen_harness 则等满 10 秒) 约 0.8 秒内拒绝,Harness 未重启;带空白的取值会显示出空白
--server-url https://svc:Pa/ss@…、…:Pa?ss@…、//svc:s3cret@… 打印出密码 https://***@…、//***@…
health status 为 40 MiB,--max-old-space-size=160 FATAL ERROR: … heap out of memory 318 个字符的一行
health status 为 1000 万个 emoji,160 MB 堆 verify 和 start 都崩溃,start 是在启动服务端之后崩溃的 截断后的一行
上述两种 status 在默认堆下的峰值 RSS 1127 MB 和 678 MB 257 MB 和 254 MB
列表返回 10 万字符的 Session ID,读取它失败 100067 个字符的一行 270 个字符
各场景前后的正常路径,verify --turn — 通过
  • 测试与变异。
    • JS 套件在 Node 22.22.2 和 Node 24.14.0(aarch64)上都是 66/66。
    • ResolvedConfigurationTest 14/14,ManagedAgentPreflightTest 82/82,checkstyle 通过。
    • 新增 17 个变异,全部被拦住,合计 72/72。
    • 其中 JS 有 12 个:
      • 遮蔽(3);
      • 是否读 API 的判断(2);
      • 判定被忽略或没有传下去(2);
      • 计数、开头部分的上限、开头部分的净化、恰好等于上限时的后缀(4);
      • label(1)。
    • Java 有 5 个:
      • 去掉 host 检查;
      • 去掉用户信息检查;
      • 对 trim 后的取值做判定;
      • 判定恒为 true;
      • 再次 trim URL。

评审第 7 轮(3a556b9ab5、9b8a548e3c、948e7484b5)。 bot 第 5 轮针对 aa53b9833e 提出 1 条 Critical,并延后 2 条;之后两轮独立审查又发现了更多问题。全部已修复:

  • R3-2(由修复引出)。 ManagedAgentPreflight.harnessUrlVerdict 与 harnessCheck 放在一起,ResolvedConfiguration 把它的判定作为 harnessOrigin 输出。
    • Harness 被禁用(默认)时给出 skip:此时 harness 行在读取 base-url 之前就返回,BrokerSecurity 提前返回,连接器 bean 以 enabled 为条件,所以没有任何地方读取这个值。
    • 启用 pool 时仍要判定。bot 建议这里也给 skip,第一个提交照做了。但 HarnessConfiguration 用同一个 base-url 构造每个 pool 成员的 QwenHostedHarnessConnector,这个连接器只接受带主机名、且不带用户信息、query 或 fragment 的 http(s) URL;连接器抛错的成员会被 HarnessPoolConnector.refresh() 丢弃。于是这样的 pool 报告 UP,却不接收任何 Session。
    • 对 true 或 skip,start 不再提其他要求;对 false,它写明原因。用户信息和 query/fragment 两条规则本是同一规则的副本,现在只用来说明 false 判定的具体原因。
    • 无法解析配置时没有判定,这两条规则照常生效,因为只要服务端读取这个值,就会拒绝这些取值。scheme 规则始终生效,因为 start 要在这个主机和端口上等待。
  • 被延后的两条。
    • 两个 start 拒绝场景的循环中,每次运行的输出都检查是否泄露密码,而不只是最后一次。
    • verify 在使用 API 返回的任何值之前先检查类型。正则、encodeURIComponent()、Number()、遍历和 .length 都会先做隐式转换,遇到 {"toString":1} 或嵌套 20000 层的数组就会抛错,printable() 来不及说明实际返回了什么。现在:
      • 页面的 data 必须是列表。
      • Session id 必须是能作为路由中单独一段的字符串(不能是空串、. 或 ..)。
      • 事件类型只有是字符串时才代表结果,只有 terminal: true 才结束 turn。
      • 序号只有是整数或整数的数字串时才推进游标,而且只向前推进。
  • 真实环境。 每个版本都由本分支打包,经 check、stop、backup、install 安装在上一个版本之上;每一臂在其版本处于已安装状态时运行。因为 main 的 refactor(managed-agent): align shared MySQL schema conventions #16143 原地改写了 V1__managed_schema.sql,数据库重建过一次空库。
场景 PR head(alpha.101) 3a556b9ab5(alpha.102) 本轮(alpha.103/104)
Harness 禁用,base-url 为 ' http://…:54787 ' 或 …/?tenant=acme:start 0.8 秒拒绝 skip;SKIP harness disabled;UP 相同
单实例静态 pool,base-url 带首尾空白或为 http://qwen_harness:54787 0.8 秒拒绝 报告 UP,但 pool 不接收任何 Session;或在 qwen_harness 上等满 30 秒 0.9 秒拒绝,Harness 未启动
同一 pool,正常的 base-url — UP "harnessOrigin":"true";UP
Harness 启用且在运行,base-url 带首尾空白 拒绝,未重启 相同 相同,提示为 "the server does not take as an http or https base URL"
无法解析配置(server.env 的 PATH 中没有 java),…/?tenant=acme 或 http://svc:s3cret@… — 重启 Harness,随后 preflight 失败(在 alpha.103 上测得,该路径代码相同) alpha.104:60 毫秒拒绝,Harness 未启动,密码已遮蔽
API 返回的 Session id 为 {"toString":1} / 嵌套 20000 层 FAIL … Cannot convert object to primitive value / Maximum call stack size exceeded FAIL the API answered a Session without a string id ({"toString":1}) / ([unprintable]) 相同
终止事件类型为 7;之前先有一个 null 事件 PASS … ended with 7;Cannot read properties of null FAIL … ended with 7;PASS 相同
{"data":[0]};items 为 {"data":{"length":2}};events 为 {"data":{}} WARN … no Session;PASS … 2 item(s);object is not iterable 与 alpha.101 相同 FAIL … without a string id (0);FAIL … answered no data list ({"length":2});… ({})
裸数组 [{"id":"s1"}];Session id 为 ..;"terminal":"false" WARN … no Session;/v1/agents 返回 404;PASS 相同 FAIL … answered no data list (…);FAIL … whose id ".." names no route;FAIL … no terminal event within 5s
正常路径,verify --tenant e2e --turn 通过 通过 通过
  • 测试与变异。
    • JS 套件在 Node 22.22.2 和 Node 24.14.0(aarch64)上都是 67/67。
    • ResolvedConfigurationTest 15/15、ManagedAgentPreflightTest 82/82、HarnessConfigurationTest 2/2,在合入 main 后的代码上同样通过。
    • judgesTheHarnessUrlAsTheConnectorThatDialsItDoes 检查 13 个 URL 的判定是否与真实连接器能否构造一致。
    • buildsEachPoolMembersConnectorFromTheSingleBaseUrl 经由真实工厂构造 pool:base-url 正常时接收 1 个成员,带首尾空白或带下划线时为 0;连接器不再检查 URL 时,该测试失败。
    • 新增 31 个变异,全部被拦住,合计 103/103。其中 JS 有 26 个:判定门(6)、scheme 规则、Session id(3)、事件类型(2)、序号(5)、页面列表(5)、null 事件、报错前缀、terminal、点号 id。Java 有 5 个:去掉 enabled 判断、去掉又加回 pool 判断、把 skip 当作 true、去掉连接器的 URL 校验。

评审第 8 轮(3b67b6ec1d)。 bot 第 6 轮针对 8529a681e8 提出 1 条 Critical,维护者对 814b121014 的评审沿用了这一条;bot 另外延后了 4 条。

  • R6-1。 Mockito 的 static import 打乱了 verification 模块的 ImportOrder 检查,现已排好序;mvn -o -B -pl server,verification checkstyle:check 通过。
  • 拒绝带 query 或 fragment 的 --server-url。 路径是拼接在它后面的,http://…/?q 实际探测的是 /?q/actuator/health(在真实 listener 上看到);带 fragment 时路径整个丢失。
  • 没有 id 的 Session 条目按原样显示;health 行在 JSON 解析出错路径上的净化已有测试钉住。
  • 留待评审决定: harnessUrlVerdict 没有纳入 BrokerSecurity 的明文传输策略。那是由 preflight 的 validation 行报告的启动策略,而不是 URL 形态规则。
  • JS 在 Node 22 和 24 上都是 67/67;Java 方面,ResolvedConfigurationTest 15、ManagedAgentPreflightTest 82、HarnessConfigurationTest 2、ClassSizeRatchetTest 1 全部通过,checkstyle 通过;新增 4 个变异,全部被拦住,合计 107/107。

测试平台

OS Status
🍏 macOS ⚠️
🪟 Windows ⚠️
🐧 Linux ✅

Linux x86_64 + Node 22.22.2;Linux aarch64 + Node 24.14.0(套件同样 67/67,说明屏蔽端口列表与两个运行时一致)。

环境(可选)

第 4 到第 7 轮还在真实的 systemd 主机上运行过。该主机有控制面和 Harness 的 systemd 257 unit、MySQL 8.4.6、nginx 和一个脚本化模型,所用的 reference 发行包由本分支打包。升级命令运行在 systemd 下,只支持 Linux。

风险与范围

  • 主要风险或权衡:屏蔽端口列表是从 Fetch 标准抄来的。如果以后的 Node 屏蔽了列表里没有的端口,测试仍会通过,那个端口会退回到超时时报出探测结果(bad port),而不是事先拒绝。如果标准删掉某个端口,一致性测试会失败。
  • 本 PR 现在也改了 Java。 ResolvedConfiguration 多输出一个键,并原样输出 Harness URL;ManagedAgentPreflight 新增包级可见的 harnessUrlVerdict,harnessOrigin 也改为包级可见。这个判定依赖服务端的两个事实,现在都有测试钉住:连接器的 URL 规则(ResolvedConfigurationTest),以及 pool 用同一个 base-url 构造每个成员(HarnessConfigurationTest)。PR CI 不跑 Java 测试,所以上面三个 Java 测试类是在本地跑的。main 上 ClassSizeRatchetTest 因 JournalCommit(886 行,超过上限 880)失败的问题已由 fix(managed-agent): restore JournalCommit under its class-size ratchet #16323 修复并已合入本分支,在当前 head 上通过。
  • 已在真实 systemd 主机上验证(第 4 到第 7 轮)。未验证:macOS、Windows。fix(managed-agent): reach the listeners the server resolves in upgrade start and verify #16051 上有两条评审意见有意保持原样。一条是变异报告认为 port != 0 子句是死代码,但它逐字对应 Spring Boot 的 ManagementPortType 条件,留着方便读者对照。另一条认为 serverBaseUrl() 已无人调用,但它仍是 listeners() 里读 server.env 的回退,并有自己的测试。--check 的问题继续由 Managed Agent --check ignores the configuration files the server reads from its working directory #16057 跟踪。
  • 破坏性变更或迁移说明:无。现在被拒绝的 URL,以前每次探测也都会失败。

关联 Issue

#16051 的 follow-up。相关:#16057(本 PR 未处理)。

…th probe failed

start and verify refused a listener URL only when URL.canParse rejected
it, so a --server-url without a scheme (proxy.test:8443), with a user
name or password, or on a port the Fetch standard blocks (6000, 10080)
passed the check and then failed every probe until --timeout. They now
refuse each of those before anything runs, and a test checks that the
runtime's fetch rejects every URL the check refuses.

A probe that is sent and still fails now says what it got: start's
timeout names the last probe's answer and verify's health row names its
own, such as "HTTP 503, status DOWN", "self-signed certificate" or
ECONNREFUSED, where both said only "not UP".

The listeners() comment names the reachesHarness option verify passes.
@qwen-code-review-bot

qwen-code-review-bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

⚠️ Deferred approval withheld — 1 PR CI workflow run(s) on 6058c44 did not finish green; see the updated table in the Stage 2 comment. Re-run @qwen-code /triage after fixes. finalize run

⚠️ 延迟审批已搁置 —— 6058c44 有 1 个 PR CI workflow 未以绿色完成,详见 Stage 2 评论中已更新的表格。修复后可重新运行 @qwen-code /triage。查看 finalize 运行

@qwen-code-review-bot

Copy link
Copy Markdown
Collaborator

Thanks for the PR — this closes a gap that the verify-pr round on #16051 explicitly measured and deliberately left open, which is the right way to do a follow-up.

Template looks good ✓ — all sections present, both languages, Risk & Scope filled in honestly rather than waved through.

Problem: observed and measured, not theoretical. The round-2 report on #16051 recorded URL.canParse('proxy.test:8443') returning true while fetch on the same string rejects immediately, so start --server-url proxy.test:8443 burns the full --timeout and then blames a server that is actually UP. I confirmed the second half independently: the old probe was catch { return false; }, which threw away the cause entirely — every TLS failure, refused connection and proxy error page surfaced as the same unexplained "is not UP". A 300-second hang ending in a wrong diagnosis is a real operator-facing defect.

Direction: aligned. This is diagnosability for a deployment command that merged twenty minutes before this PR was opened, it adds no dependency and touches no public contract, and it moves a failure from "silent until timeout" to "refused before any unit starts". No CHANGELOG reference — this is an internal distribution script, not a shipped CLI surface — but the area is plainly relevant.

Size: core-module protection does not apply. Nothing here matches a core path: distribution/bin/ is not src/, and only one package is touched. For the record — 100 production lines in the upgrade script, 8 lines across four docs, 180 test lines. Well under every threshold; no maintainer escalation and no large-PR advisory.

Approach: the scope feels right, and the two halves are load-bearing for each other rather than two unrelated fixes. Hardcoding the blocked-port list is the part I'd normally push back on, and it's the part that's handled best: the agreement test walks every port in 1–65535 and asserts the real runtime fetch rejects each URL the list refuses, so drift is caught instead of assumed away. I re-derived the constant independently — 82 entries, no duplicates, byte-identical to the Fetch standard's bad-port list. I also considered the two obvious shortcuts and think both are worse: a pre-flight fetch to classify the error would still have to string-match bad port/unknown scheme, and would have to tell "refused before dialing" apart from the ECONNREFUSED a not-yet-started server legitimately gives; and dropping the list to rely on the new probe answer alone would trade an instant refusal for a 300s wait after start has already brought up the control plane and Harness. One thing worth saying out loud, since it's the real safety argument: nothing that worked before is refused now — every newly-refused shape was already failing every probe, so this only changes when and how clearly the operator finds out.

I checked the blast radius rather than taking the title's word for it. The command has exactly two system.fetch call sites, the health probe and the API client, and the client's base URL is the same urls.server that listeners() already vetted — so "every URL fetch refuses" really is every URL this command hands to fetch. The Harness URL keeps its plain new URL() check, and that is correct, not an oversight: it never reaches fetch, it feeds a raw TCP connect, where a blocked port is perfectly connectable and refusing it would break a working Harness. health() is module-private with both call sites updated, so the boolean → {up, answer} shape change has no other consumer.

Risk: no elevated risk signals — none of the six files match the revert-correlated paths. The one residual risk is the port list going stale against a future Node, and the PR names it accurately rather than hiding it: such a port falls back to the new probe answer (bad port) at the timeout instead of an up-front refusal, which is exactly the degradation the second half makes survivable.

Moving on to code review. 🔍

中文说明

感谢贡献!这个 PR 补上了 #16051 的 verify-pr 第 2 轮实测出来、并有意留到后续的缺口——这是 follow-up 该有的做法。

模板完整 ✓ ——各节齐全、中英文都有,Risk & Scope 也如实填写,没有敷衍带过。

问题: 已观测并实测,不是理论性加固。#16051 的第 2 轮报告记录了 URL.canParse('proxy.test:8443') 返回 true,而 fetch 对同一字符串会立即拒绝,于是 start --server-url proxy.test:8443 会等满 --timeout,然后怪罪一个实际已经 UP 的服务。第二半的问题我也独立确认了:旧的探测是 catch { return false; },把原因完全丢掉——所有 TLS 失败、连接被拒、代理错误页都表现为同一句没有解释的 "is not UP"。等满 300 秒再给出错误结论,是实打实面向运维的缺陷。

方向: 对齐。这是一个在本 PR 提交前 20 分钟才合入的部署命令的可诊断性改进,不引入依赖、不改公共契约,并把失败从"静默直到超时"变成"在启动任何 unit 之前拒绝"。CHANGELOG 没有相关记录——这是内部分发脚本,不是对外的 CLI 表面——但该领域显然相关。

规模: 核心模块保护不适用。这里没有命中任何核心路径:distribution/bin/ 不属于 src/,且只涉及一个 package。数据备查——升级脚本 100 行生产代码,四个文档共 8 行,测试 180 行。远低于各项阈值;无需维护者关注,也不触发大 PR 提示。

方案: 范围合理,而且两半互相支撑,不是两个无关的修改拼在一起。硬编码屏蔽端口列表本来是最该被质疑的部分,结果恰恰是处理得最好的部分:一致性测试遍历 1–65535 的每个端口,断言真实运行时的 fetch 会拒绝列表拒绝的每个 URL,于是列表漂移是被测出来的,而不是被假设不会发生。我也独立重算了一遍这个常量——82 项、无重复、与 Fetch 标准的 bad-port 列表逐项一致。两条显而易见的捷径我都考虑过,认为都更差:用一次预检 fetch 来分类错误,仍然要匹配 bad port/unknown scheme 字符串,还得把"拨号前就拒绝"和一个尚未启动的服务本就会给出的 ECONNREFUSED 区分开;而完全丢掉列表、只依赖新的探测应答,则是把即时拒绝换成在 start 已经拉起控制面和 Harness 之后再等 300 秒。有一点值得明说,因为这才是真正的安全性论据:以前能用的配置,现在一个也不会被拒绝——每种新被拒绝的写法本来每次探测都会失败,所以变化的只是运维"何时"以及"多清楚地"得知真相。

影响面我是查过的,没有只信标题。整个命令只有两处 system.fetch 调用:健康探测和 API client,而 client 的 base URL 正是 listeners() 已经校验过的 urls.server——所以"fetch 会拒绝的每个 URL"确实就是这个命令交给 fetch 的每个 URL。Harness 的 URL 仍用原来的 new URL() 检查,这是对的,不是遗漏:它根本不会走到 fetch,而是喂给一次原始 TCP connect,在那种场景下屏蔽端口完全可以连通,拒绝它反而会挡住正常工作的 Harness。health() 是模块私有函数,两处调用都已更新,因此 boolean → {up, answer} 的返回形状变化没有其他消费者。

风险: 无升级风险信号——六个文件都没有命中与 revert 相关的路径。唯一的残留风险是端口列表相对未来 Node 版本过时,而 PR 对此描述准确、没有回避:那样的端口会退回到超时时报出探测应答(bad port),而不是事先拒绝——这正是第二半改动让这种退化可以接受的原因。

进入代码审查 🔍

— Qwen Code · qwen3.8-max-2026-09-02

Reviewed at 6058c441bdadd6efe93ad6257f6783736ca6590c · re-run with @qwen-code /triage

@qwen-code-review-bot

qwen-code-review-bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

Code review

No critical blockers, and no AGENTS.md violations. I read the diff against the reviewed commit rather than against the description, and the central claim holds up: the command has exactly two system.fetch call sites — the health probe and the API client — and the client's base URL is urls.server, which listeners() has already put through fetchRefusal(). So "every URL fetch refuses is refused up front" is literally true of this command, not just of the two shapes the tests happen to pin.

What I verified rather than assumed:

  • The health() return-shape change has no other consumer. It went from boolean to {up, answer}; health is module-private and has exactly two call sites, both updated in this diff. Nothing reads it as a boolean any more.
  • fetchRefusal is applied to the right URLs and not the wrong ones. The Harness URL deliberately keeps its plain new URL() check, and that is correct — it never reaches fetch, it feeds a raw TCP system.connect, where a blocked port is perfectly connectable. Running fetchRefusal over it would refuse a working Harness.
  • No legitimate configuration is newly refused. Number(port) on a URL with no explicit port is 0, which is not in the set, so http://host and https://host are untouched. Every shape that is now refused was already failing every probe — the change moves when and how clearly the operator finds out, never whether a working deployment starts.
  • The --server-url wording in the refusal cannot misattribute. When --server-url is given it overwrites both urls.server and urls.health, so blaming --server-url for either refusal is always accurate. I went looking for the case where a resolver-supplied URL gets reported as the operator's flag; it isn't reachable.
  • The blocked-port constant is right. I re-derived it independently from the diff: 82 entries, no duplicates, byte-identical to the Fetch standard's bad-port list. The agreement test then pins it against the real runtime instead of trusting the copy, and it asserts each rejection happens before dialing (bad port / unknown scheme / the credentials TypeError) under a one-second abort guard — so it adds no real network traffic to CI. That's the part that makes hardcoding the list defensible.
  • The zone note got more accurate, not less. /\[[^\]]*%/ replaces the old url.includes('%'), which would have tagged any percent-encoded path as an IPv6 zone.
  • Docs are in sync. All four files — design and deployment guide, English and Chinese — are updated in the same change with matching content, which is what the repo's bilingual rule asks for.

Two non-blocking observations, neither worth holding the PR for:

  1. The cause fallback still bottoms out at error.message, and for fetch that is precisely the unhelpful "fetch failed". A failure whose cause carries neither a message nor a code would print that. It degrades to the pre-PR wording rather than regressing, so it's a cosmetic tail, not a hole.
  2. The same defect class survives one level over, in a path this PR correctly leaves alone: qwen.managed-agent.harness.base-url is still validated only by new URL(). A value of the shape this PR now refuses for --server-url — proxy.test:8443, which per the PR's own measurement parses as an opaque URL — comes back with an empty hostname and port, so harnessPort falls through to 80 and start waits out --timeout reporting is not listening on with a blank host. Pre-existing, out of scope here, and not fixable with fetchRefusal (again: TCP connect, not fetch) — but it may deserve a line in Managed Agent --check ignores the configuration files the server reads from its working directory #16057 or its own follow-up.

Test evidence

This is an unattended CI run, so per the gate rules I did not build, run, or execute anything from this PR's tree — no node --test, no npm, no checkout. The evidence below is the PR's own CI, read through the API at the reviewed commit, plus static verification of the diff. Fetched once; I did not poll.

No check has failed. 13 succeeded, 23 skipped, 6 still in flight. The two most relevant gates for a distribution-script change are already green — Build and verify reference distribution, which packages the very file this PR edits, and Lint & Static. The check that actually carries this PR's test evidence, Test (ubuntu-latest, Node 22.x), which runs scripts/tests/managed-agent-upgrade.test.mjs, was still in progress at fetch time, so the 60/60 the description reports is the author's claim and not something I can confirm from CI yet. The finalize job rewrites the table below in place once CI settles.

Not verified, and why:

  • not verified: the 60/60 suite result — the Node test job had not completed when this ran.
  • not verified: the six probe-answer wordings against real failures. The tests assert them against hand-constructed errors (new TypeError('fetch failed', {cause: …}), an AggregateError with only a code), so the shape of a genuine TLS rejection or refused connection is assumed rather than observed. The author's evidence table says these were measured on Node 22.22.2; that measurement is the author's, not independently re-run here.
  • not verified: the NODE_EXTRA_CA_CERTS remedy and everything on a real systemd host — the PR itself scopes both out, and the command is Linux/systemd-only, so no TUI surface exists to drive.

Sandboxed verification would settle this: @qwen-code /verify — the cause.message / cause.code fallback chain in health() is only ever exercised against synthetic error objects, so whether a real self-signed-certificate failure and a real ECONNREFUSED actually carry the fields the chain reads is not observable from the diff, and the suite would pass unchanged if the real objects were shaped differently. The author has write access, so this is a direct run rather than a sponsored one; /tmux does not apply, as there is no TUI surface here.

Final CI results for 6058c44 (auto-updated by the triage finalize job after CI completed):

Check Conclusion
web-shell E2E Smoke (ubuntu-latest, Node 22.x) ❌ failure
Build and verify reference distribution ✅ success
Check TUI impact ✅ success
Classify PR ✅ success
Integration Tests (no-AK, No Sandbox) ✅ success
Lint & Static (ubuntu-latest, Node 22.x) ✅ success
Managed Agent fast tier ✅ success
SDK Java (fast) / Flyway migration version uniqueness ✅ success
SDK Java (fast) / Real daemon E2E / Java 11 ✅ success
SDK Java (fast) / ubuntu-latest / Java 21 ✅ success
Select the Managed Agent tier ✅ success
Test (ubuntu-latest, Node 22.x) ✅ success
TUI parity snapshots (ink vs opentui) ✅ success

One row per check name (latest run); skipped checks omitted; failures sort first. / 每个检查名一行(取最新一次运行),省略 skipped,失败项排在最前。

中文说明

代码审查

没有阻塞性问题,也没有违反 AGENTS.md 的地方。我是按被审查的那个 commit 读 diff 的,不是照着描述读,而 PR 的核心主张站得住:整个命令只有两处 system.fetch 调用——健康探测和 API client——而 client 的 base URL 就是 urls.server,它已经被 listeners() 送进 fetchRefusal() 校验过了。所以"fetch 会拒绝的 URL 一律事先拒绝"对这个命令是字面成立的,不只是对测试恰好固定住的那两种写法成立。

以下是我实际查证、而非默认接受的部分:

  • health() 返回形状的变化没有其他消费者。 它从 boolean 变成 {up, answer};health 是模块私有函数,只有两处调用,本 diff 都已更新。没有任何地方再把它当布尔值用。
  • fetchRefusal 用在了该用的 URL 上,也没用到不该用的地方。 Harness 的 URL 有意保留原来的 new URL() 检查,这是对的——它根本不会走到 fetch,而是喂给一次原始 TCP system.connect,在那种场景下屏蔽端口完全可以连通。对它套用 fetchRefusal 反而会拒绝一个正常工作的 Harness。
  • 没有任何合法配置会被新拒绝。 未显式写端口的 URL,Number(port) 得到 0,不在集合里,所以 http://host 和 https://host 不受影响。现在被拒绝的每种写法,以前每次探测也都会失败——变化的是运维"何时"以及"多清楚地"得知,而不是一个能用的部署能否启动。
  • 拒绝提示里对 --server-url 的归因不会张冠李戴。 给了 --server-url 时,它会同时覆盖 urls.server 和 urls.health,所以无论哪一个被拒,归到 --server-url 头上都是准确的。我专门找过"解析器给出的 URL 被报成运维传的参数"这种情况,走不到。
  • 屏蔽端口常量是对的。 我从 diff 独立重算过:82 项、无重复、与 Fetch 标准的 bad-port 列表逐项一致。而一致性测试是拿真实运行时去校验它的,不是信任这份拷贝;它还断言每次拒绝都发生在拨号之前(bad port / unknown scheme / 凭据 TypeError),并带 1 秒 abort 保护——因此不会给 CI 带来真实网络流量。这正是硬编码列表站得住脚的原因。
  • zone 提示变得更准确,而不是更粗糙。 /\[[^\]]*%/ 取代了原来的 url.includes('%'),后者会把任何百分号编码的路径都当成 IPv6 zone。
  • 文档是同步的。 四个文件——设计文档与部署指南、中文与英文——在同一次改动里更新且内容一致,符合仓库的双语要求。

两条非阻塞观察,都不值得为此卡住 PR:

  1. cause 回退链最终仍会落到 error.message,而对 fetch 来说那恰好就是没有信息量的 "fetch failed"。如果某次失败的 cause 既无 message 也无 code,就会打印这句。这是退化回 PR 之前的措辞,不是变差,所以属于外观上的尾巴,不是漏洞。
  2. 同一类缺陷在旁边一条路径上仍然存在,而本 PR 有意没有碰它:qwen.managed-agent.harness.base-url 仍只用 new URL() 校验。如果它的取值正是本 PR 现在会为 --server-url 拒绝的那种写法——proxy.test:8443,按 PR 自己的实测会解析成不透明 URL——那么 hostname 和 port 都是空的,于是 harnessPort 落到 80,start 等满 --timeout 后报出 is not listening on ,主机名位置是空的。这是既有问题、不在本 PR 范围内,而且不能用 fetchRefusal 修(原因同上:TCP connect 而非 fetch)——但也许值得在 Managed Agent --check ignores the configuration files the server reads from its working directory #16057 里带一句,或另开一个 follow-up。

测试证据

这是无人值守的 CI 运行,因此按门禁规则,我没有构建、运行或执行本 PR 树里的任何东西——没有 node --test、没有 npm、没有 checkout。下面的证据来自 PR 自己的 CI,通过 API 在被审查的 commit 上读取,外加对 diff 的静态核查。只取一次,没有轮询。

没有任何检查失败。 13 项通过、23 项跳过、6 项仍在进行。对一个改动分发脚本的 PR 来说,最相关的两道门已经是绿的——Build and verify reference distribution(正是打包本 PR 所改文件的那一道)和 Lint & Static。而真正承载本 PR 测试证据的那一项,即运行 scripts/tests/managed-agent-upgrade.test.mjs 的 Test (ubuntu-latest, Node 22.x),在取数时仍在进行中,所以描述里写的 60/60 属于作者的说法,我暂时无法从 CI 证实。CI 跑完后,finalize 任务会就地改写下面的表格。

未验证的部分及原因:

  • 未验证: 60/60 的套件结果——本次运行时 Node 测试任务尚未完成。
  • 未验证: 六种探测应答措辞在真实失败下的表现。测试是拿手工构造的错误对象断言的(new TypeError('fetch failed', {cause: …})、只带 code 的 AggregateError),所以真实 TLS 拒绝或连接被拒的对象形状是被假定的,而非被观测到的。作者的证据表说这些是在 Node 22.22.2 上实测的;那是作者的实测,本次没有独立复现。
  • 未验证: NODE_EXTRA_CA_CERTS 这个补救办法,以及真实 systemd 主机上的一切——PR 自己把两者划在范围外,且该命令仅支持 Linux/systemd,因此没有可供驱动的 TUI 表面。

沙箱验证可以补上这一块:@qwen-code /verify —— health() 里 cause.message / cause.code 的回退链只被合成错误对象走过,所以真实的自签名证书失败和真实的 ECONNREFUSED 是否真的带着这条链要读的字段,从 diff 上看不出来;而且即使真实对象形状不同,测试套件也照样会通过。作者有写权限,因此这是直接运行而非 sponsored run;/tmux 不适用,这里没有 TUI 表面。

— Qwen Code · qwen3.8-max-2026-09-02

Reviewed at 6058c441bdadd6efe93ad6257f6783736ca6590c · re-run with @qwen-code /triage

@qwen-code-review-bot

Copy link
Copy Markdown
Collaborator

Confidence: 4/5 — the code is clean and I could not find a way to break it; the missing point is evidence, not implementation: the CI job that runs this PR's own suite had not finished, and the six probe wordings are pinned against synthetic error objects rather than real failures.

Stepping back: this is what a good follow-up looks like. A verification round on #16051 measured a gap, wrote it down, said "not applied", and this PR closes exactly that gap twenty minutes after the merge — no scope drift, no drive-by refactor, nothing opportunistic riding along. The diff is 100 production lines in one script, 8 lines of docs, and 180 lines of test, and every one of them is in service of the stated goal.

The part I would normally push back on is the hardcoded 82-port list — a copied constant that silently rots when the platform moves. It's the best-defended thing in the PR. The agreement test walks every port from 1 to 65535 and asserts the real runtime fetch rejects each URL the list refuses, before dialing, under a one-second abort guard. That converts a copy-paste liability into a checked invariant, and it costs no network traffic in CI. I re-derived the constant independently: 82 entries, no duplicates, identical to the Fetch standard. The author also states the residual risk plainly instead of burying it — a port a future Node blocks that the list lacks degrades to reporting bad port at the timeout, which survives precisely because the second half of the PR exists. The two halves cover each other; that's why cutting either one would be a mistake, and why my "could 80% of this be cut" question comes back no.

On the claim I cared most about: I did not take the title's word for it. There are exactly two system.fetch call sites in the command, and the API client's base URL is the same urls.server that listeners() vets, so the up-front refusal really does cover every URL this command hands to fetch. The Harness URL keeping its weaker new URL() check is correct rather than an oversight — it feeds a TCP connect, where a blocked port is fine, so refusing it there would break working deployments. health() is module-private with both consumers updated. The one thing I'd hand a maintainer as genuine follow-up signal is in my Stage 2 note: the same silent-timeout defect class still sits in the Harness URL path, where an opaque proxy.test:8443-style value parses to an empty host and produces a is not listening on message with a blank in it. Pre-existing, out of scope, and not fixable with fetchRefusal — but it belongs somewhere.

Nothing here is a reason to hold the PR. Both of my observations are non-blocking: one is a cosmetic tail (a cause with neither message nor code still prints fetch failed), the other is adjacent pre-existing behaviour this PR correctly leaves alone.

Two honest caveats on what I could and could not confirm, since they're the difference between 4 and 5. I ran nothing from this tree — the gate forbids executing PR-derived code on an unattended run, so the evidence is the PR's own CI plus static reading. At fetch time Lint & Static and Build and verify reference distribution were green and no check had failed, but Test (ubuntu-latest, Node 22.x) — the job that runs scripts/tests/managed-agent-upgrade.test.mjs — was still in progress, so the reported 60/60 is the author's claim, not something I confirmed. And the six answer wordings are asserted against hand-constructed errors, so whether a real self-signed-certificate failure and a real ECONNREFUSED actually carry the cause.message / cause.code the fallback chain reads is assumed rather than observed; @qwen-code /verify would settle that, as I noted in Stage 2. Neither caveat is a defect — they're the boundary of what a static review can attest to.

Verdict is approve. CI is still running on this commit, so I'm not posting an approval in this run — approving now would attest to a suite result that does not exist yet. Approval is deferred until CI lands green on 6058c441bdadd6efe93ad6257f6783736ca6590c; the finalize job posts the commit-pinned approval once every check completes, and withholds it if anything lands red or the head moves.

中文说明

Confidence: 4/5 —— 代码是干净的,我没能找到把它弄坏的办法;差的那一分在于证据而不在实现:跑本 PR 自己那套测试的 CI 任务当时还没结束,而六种探测措辞是拿合成的错误对象固定的,不是拿真实失败固定的。

退一步看整体:这是一个 follow-up 该有的样子。#16051 上的一轮验证实测出一个缺口,把它写了下来、注明"未修",然后本 PR 在合入后二十分钟精确地补上这一个缺口——没有范围漂移、没有顺手重构、没有夹带任何机会主义的改动。diff 是单个脚本里 100 行生产代码、8 行文档、180 行测试,每一行都在为既定目标服务。

我通常会质疑的部分是那份硬编码的 82 个端口列表——一份抄来的常量,平台一变就会悄悄过时。结果它恰恰是全 PR 里防守最严密的部分。一致性测试遍历 1 到 65535 的每个端口,断言真实运行时的 fetch 会拒绝列表所拒绝的每个 URL,而且是在拨号之前、带 1 秒 abort 保护。这就把一份抄粘贴的负债变成了被校验的不变量,且不给 CI 带来任何网络流量。我也独立重算了这个常量:82 项、无重复、与 Fetch 标准一致。作者也把残留风险讲得很明白,没有藏:如果未来的 Node 屏蔽了列表里没有的端口,就会退化成在超时时报出 bad port——而这之所以可以接受,正是因为本 PR 的第二半存在。两半互相兜底,这也是为什么砍掉任何一半都是错的,以及为什么我"能不能砍掉 80%"这个问题的答案是不能。

关于我最在意的那条主张:我没有只信标题。整个命令只有两处 system.fetch 调用,而 API client 的 base URL 正是 listeners() 校验过的同一个 urls.server,所以这个事先拒绝确实覆盖了本命令交给 fetch 的每一个 URL。Harness 的 URL 保留较弱的 new URL() 检查是对的,不是疏漏——它喂给的是一次 TCP connect,在那种场景下屏蔽端口无妨,若在那里拒绝反而会弄坏正常的部署。health() 是模块私有函数,两个消费者都已更新。唯一一条我会作为真正有价值的后续信号交给维护者的,是我在 Stage 2 里写的那条:同一类静默超时缺陷仍留在 Harness URL 这条路径上——一个 proxy.test:8443 式的不透明取值会解析出空主机名,从而打印出中间是空白的 is not listening on 提示。这是既有问题、不在本 PR 范围内,也无法用 fetchRefusal 修——但它该有个去处。

这里没有任何一条足以卡住这个 PR。我的两条观察都是非阻塞的:一条是外观上的尾巴(cause 既无 message 也无 code 时仍会打印 fetch failed),另一条是本 PR 有意不去碰的、旁边的既有行为。

关于我能确认和不能确认的部分,有两条需要如实说明,因为这就是 4 分和 5 分之间的差别。我没有运行这个代码树里的任何东西——门禁规则禁止在无人值守运行中执行 PR 衍生的代码,所以证据来自 PR 自己的 CI 加静态阅读。取数时 Lint & Static 和 Build and verify reference distribution 是绿的,没有任何检查失败,但 Test (ubuntu-latest, Node 22.x)——也就是运行 scripts/tests/managed-agent-upgrade.test.mjs 的那个任务——仍在进行中,所以描述里的 60/60 是作者的说法,不是我确认过的事实。另外,六种应答措辞是拿手工构造的错误断言的,因此真实的自签名证书失败和真实的 ECONNREFUSED 是否真的带着回退链要读的 cause.message / cause.code,是被假定的而非被观测到的;如我在 Stage 2 所写,@qwen-code /verify 可以补上这一点。这两条都不是缺陷——它们是一次静态审查所能证明的边界。

结论是通过。CI 在这个 commit 上仍在运行,所以本次不提交批准——现在批准等于为一个尚不存在的套件结果背书。批准将推迟到 CI 在 6058c441bdadd6efe93ad6257f6783736ca6590c 上全绿之后;每项检查完成后,finalize 任务会提交绑定该 commit 的批准,若有检查变红或 head 发生变动则不会提交。

— Qwen Code · qwen3.8-max-2026-09-02

Reviewed at 6058c441bdadd6efe93ad6257f6783736ca6590c · re-run with @qwen-code /triage

@wenshao
wenshao requested a balanced review from Copilot November 2, 2026 09:48
… upgrade start

start checked the Harness URL with new URL() alone, so an opaque value
such as proxy.test:8443 parsed with no host and no port: start then
waited out --timeout for the Harness to listen on port 80 of an empty
host. It now refuses any Harness URL that is not http or https before
it starts a unit, as the preflight would fail it later anyway.

The probe-answer test also runs the runtime's own fetch against a port
nothing listens on, so the ECONNREFUSED wording comes from a real error
rather than a constructed one.
@wenshao

wenshao commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks for the review. Pushed 13157b7c96:

  • Harness URL path (Stage 2 note 2): fixed here, not deferred. start now refuses a qwen.managed-agent.harness.base-url that is not http or https before it starts any unit, so an opaque value like proxy.test:8443 no longer waits out --timeout on a blank host. As you say, fetchRefusal() would be wrong for this URL: the Harness is reached by a TCP connect, where a port fetch blocks connects fine. So this check covers the scheme only, which the server's preflight harness row requires anyway.
  • Real error shapes (Stage 2 "not verified"). The probe-answer test now also runs the runtime's own fetch against a port nothing listens on and asserts connect ECONNREFUSED 127.0.0.1:<port>, so the cause.message read is observed from a real error. A real self-signed certificate would need a private key committed to the test tree, so that case stays constructed; its real shape (cause.message = self-signed certificate, code DEPTH_ZERO_SELF_SIGNED_CERT) is in the evidence table, measured on Node 22.22.2.
  • cause with neither message nor code (Stage 2 note 1): kept. Every real failure I measured carries one or the other, and when neither is there, fetch failed is all there is to say.
  • web-shell E2E Smoke red on 6058c44. previews qwen3.8-max reasoning before lazy session creation failed on both attempts (Thinking Off where Medium was expected). This PR touches no web-shell code, and the same job passed on the other PRs that ran in the same window. The new push reruns it.

Two more mutants killed (19/19 in total); the suite passes 60/60.


🤖 Generated with Claude Code — Claude Opus 5.5

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the listener-validation and health-probe diagnostic changes.

No open issues 🎉

What changed in this PR

This follow-up to #16051 strengthens the Managed Agent upgrade command’s listener validation and makes failed health probes easier to diagnose. The separate preflight configuration gap in #16057 remains out of scope.

Changes:

  • Reject malformed URLs, unsupported schemes, embedded credentials, and Fetch-blocked ports before starting units; also reject non-HTTP(S) Harness URLs.
  • Include HTTP status or underlying connection errors in start timeout messages and verify health results, with regression coverage.
  • Update English and Chinese documentation with refusal behavior and certificate-trust guidance.
File Description
scripts/​tests/​managed-agent-upgrade.test.mjs Covers URL refusals and detailed health-probe failures.
packages/​managed-agent-server/​distribution/​bin/​qwen-managed-agent-upgrade.mjs Adds URL validation and actionable probe diagnostics.
docs/​users/​managed-agent-reference-deployment.zh-CN.md Updates Chinese deployment and certificate-trust guidance.
docs/​users/​managed-agent-reference-deployment.md Updates English deployment and certificate-trust guidance.
docs/​design/​2026-10-25-managed-agent-upgrade-command.zh-CN.md Documents validation and diagnostic behavior in Chinese.
docs/​design/​2026-10-25-managed-agent-upgrade-command.md Documents validation and diagnostic behavior in English.

Review effort: Balanced

@wenshao

wenshao commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator Author

评审提交:13157b7c96a63367b50c36efdf39bb1f83fc5261

结论:未发现需要修改的新增缺陷(C=0)。

已检查全部 6 个变更文件及相关调用方:URL 校验同时覆盖配置解析结果和 --server-url;health() 的两个生产调用方均按新的 up/answer 返回值处理;Harness 仍通过 TCP 探测,没有误套 Fetch 的端口限制。中英文设计和部署说明的本次修改一致。

上一轮意见已对照当前提交复核:不带 HTTP(S) scheme 的 Harness URL 现在会在启动 unit 前拒绝;真实 ECONNREFUSED 已有回归覆盖。对于既无 message 也无 code 的 cause,保留顶层错误信息,没有发现需要为此增加特殊处理的实际失败场景。目前也没有待复核的未解决行内问题。

验证证据:

  • 分发包 CI 实际执行了包含升级脚本在内的三个测试文件:合计 97 通过、0 失败、1 跳过。新增 URL 拒绝、启动超时和健康应答测试均在日志中通过。
  • 独立本地验证:macOS / Node 22.22.2,精确提交快照上的 3 个相关回归用例全部通过,包括真实连接拒绝。首次受沙箱 loopback 监听限制而失败,允许监听后重跑通过。
  • 补充真实 TLS 验证:使用原有模拟 systemd 测试环境调用未修改的 runUpgrade('verify'),连接临时自签名 HTTPS 服务,得到 is not UP: self-signed certificate;新的 Node 进程设置 NODE_EXTRA_CA_CERTS 后,同一端点返回 HTTP 200 和 {"status":"UP"}。补测通过,临时证书和监听资源已清理。
  • 当前提交的静态检查、Linux Node 测试、Java fast、分发包构建和 web-shell E2E 均已通过;发布本评论时 review-pr 自动评审任务仍在运行。

验证边界:本地没有执行真实 Linux/systemd 升级;上述网络补测使用模拟 systemd 环境。这份评论不把该路径视为已经完成真实部署验收。

— Codex review

@wenshao

wenshao commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator Author

PR 16110 round 1 verification — Verdict: findings — 47/49 scripted assertions passed, 2 failed. Verified head: 13157b7c96a63367b50c36efdf39bb1f83fc5261 against base 0a7f26070426d80c9bbba498651182448755d526. The central claim holds on live listeners, and the blocked-port list is exactly this runtime's list. One defect in start's new timeout detail and one test pin remain.

中文摘要
  • 结论:findings(49 条断言,47 过 2 失败)。核心主张成立:fetch 会拒绝的 URL(无 scheme、带凭据、82 个屏蔽端口、非 http(s))现在都在启动任何 unit 之前被拒绝。真实 200 UP 服务配凭据 URL 时,base 等满约 2.0s、启动 2 个 unit,head 12ms 拒绝、0 个 unit;端口 6000 上真实监听并可用裸 HTTP 拿到 200,base 仍等满 2.0s,head 8ms 拒绝;opaque scheme 与 opaque Harness URL 同样。
  • verify 的 health 行在真实端点上按预期给出原因:HTTP 503, status DOWN、HTTP 503, status UP(不算 UP)、HTTP 502、HTTP 404、HTTP 200, <解析错误>、connect ECONNREFUSED …、The operation was aborted due to timeout、self-signed certificate …;200 UP 仍 PASS。NODE_EXTRA_CA_CERTS 指向自签名 CA 后子进程实测返回 200 UP,与部署指南一致。
  • 屏蔽端口列表与本机运行时完全一致:对 0–65535 全部端口调用真实 fetch,屏蔽 82 个;fetchRefusal() 也正好拒绝这 82 个,双向无差集;port 0 两边都允许(fetch 会拨号)。
  • 两条失败:1) start 超时里的 “last probe” 取到的是截止前 1ms 的那次探测(Math.max(deadline - now, 1) + AbortSignal.timeout(1)),真实 503 端点会被写成 The operation was aborted due to timeout,而不是它实际回答的 HTTP 503, status DOWN。套件的假 fetch 忽略 abort signal,所以没发现。2) 收窄后的 IPv6 zone 正则没有被测试钉住:把 /\[[^\]]*%/ 退回 /%/,60/60 仍全绿。
  • 已验证的修法:if (budget > 1) answer = probe.answer; 后套件 60/60,真实 503 单元显示 HTTP 503, status DOWN;给 zone 正则补一条断言后 60/60,且旧正则会红。
  • 未覆盖:真实 systemd 主机(本轮的 systemd 是仓库自带 rig 的模拟层)、macOS/Windows、Node 22 上的完整端口集合(CI 的 Node 22 套件已绿,完整枚举在本机 Node 24.22.1)、Managed Agent --check ignores the configuration files the server reads from its working directory #16057 的 --check 缺口。

Central claim and A/B

The claim: before this PR, start and verify refused a listener URL only when URL.canParse rejected it; every URL fetch refuses for another reason then failed every probe until --timeout, silently. The PR refuses those shapes up front (scheme, credentials, the Fetch standard's blocked ports, an IPv6 zone) and makes a failing probe name its answer.

The A/B uses the repository's own upgrade rig (a fake systemctl, real files) with the systemd layer as the only fake. The health endpoint, fetch, DNS/connect errors and TLS are real loopback servers; the start cells run on the real clock, so the elapsed times below are wall-clock. The base arm is the base revision's production file with the same rig; nothing else differs.

Cell Oracle Base 0a7f2607 Head 13157b7c
--server-url http://admin:secret@127.0.0.1:<port>, live 200 UP endpoint exit, wall time, units started exit 1, 2019ms, 2 units started, "did not report UP" exit 1, 12ms, 0 units, "carries a user name or password"
--server-url http://127.0.0.1:6000, live endpoint answering bare HTTP 200 UP same exit 1, 2020ms, 2 units, "did not report UP" exit 1, 8ms, 0 units, "is on port 6000, so fetch refuses to dial it"
--server-url proxy.test:8443 same exit 1, 2014ms, 2 units, "did not report UP" exit 1, 8ms, 0 units, "is not an http or https URL"
qwen.managed-agent.harness.base-url=proxy.test:4170 units started, message exit 1, 2 units started, waited exit 1, 0 units, "is not an http or https URL"
verify health, live 503 {"status":"DOWN"} health row "is not UP" "is not UP: HTTP 503, status DOWN"
verify health, 503 with {"status":"UP"} health row "is not UP" "is not UP: HTTP 503, status UP" (a success status is required)
verify health, 502 HTML error page health row "is not UP" "is not UP: HTTP 502"
verify health, 404 health row "is not UP" "is not UP: HTTP 404"
verify health, 200 non-JSON health row "is not UP" "is not UP: HTTP 200, Unexpected token 'o', …"
verify health, closed port health row "is not UP" "is not UP: connect ECONNREFUSED 127.0.0.1:"
verify health, accepts and never answers (--timeout 1) health row "is not UP" "is not UP: The operation was aborted due to timeout"
verify health, self-signed HTTPS health row "is not UP" "is not UP: self-signed certificate; if the root CA is installed locally, try running Node.js with --use-system-ca"
verify health, live 200 UP health row PASS PASS
NODE_EXTRA_CA_CERTS=<the CA> child process status/body 200 UP 200 UP
start --timeout 2, live 503 DOWN timeout detail no detail "the last probe: The operation was aborted due to timeout" — finding 1

Every start base cell started both units before discovering the probes could not be sent; every head cell refused with zero units started.

01-ab-refusals-and-probe-answers.png

Carried forward from #16051

This PR exists because of the round-2 report on #16051. That finding, re-measured at this head:

# #16051 round-2 finding Status at 13157b7c Evidence
1 --server-url proxy.test:8443 passes URL.canParse but fetch refuses it, so start waits out --timeout and reports a server that is in fact UP fixed base 2014ms, 2 units, "did not report UP"; head 8ms, 0 units, "is not an http or https URL"

The blocked-port list is the runtime's list

The PR copies 82 ports from the Fetch standard. The suite's agreement test proves that every URL fetchRefusal() refuses is also rejected by the runtime's fetch, but not the reverse direction. I enumerated all 65,536 ports through the real fetch on this host (Node 24.22.1): the runtime blocks 82, fetchRefusal() refuses the same 82, and the symmetric difference is empty in both directions. Port 0 is dialled by fetch and allowed by the function, which is why it is correctly absent from the list. The scan took 20.8s and never dials a blocked port.

03-blocked-port-set-equality.png

Mutation matrix

21 single-point mutants of the head production file, each run against the unmodified 60-test head suite. A mutant is killed when the suite exits non-zero. Baseline first: 60/60, exit 0. The author's 17-in-the-body / 19-in-the-comment matrix is consistent; this round adds both halves of the credentials check, a positive control, and the zone-regex narrowing.

20/21 killed. The survivor is finding 2.

02-mutation-matrix.png

The matrix is in mutations.json, one row per mutant with the failing test names.

Findings

Finding 1 — Medium: start's "last probe" is the deadline's 1 ms probe, so a live endpoint's answer becomes an abort

Reproduce with a live endpoint that answers 503 {"status":"DOWN"} and start --server-url http://127.0.0.1:<port> --timeout 2:

start refused: qwen-managed-agent-server did not report UP at http://127.0.0.1:<port>/actuator/health within 2s
  (the last probe: The operation was aborted due to timeout) and keeps running; see journalctl -u …

The endpoint answered 503 on every full-budget probe. waitFor calls the probe one last time with Math.max(deadline - system.now(), 1); by then the remaining budget is 0, so the floor makes it 1 ms, and health() passes that to AbortSignal.timeout(1). The fetch aborts before any real endpoint can answer, and answer = probe.answer overwrites the previous HTTP 503, status DOWN with the abort. The message is literally true about the last probe, but it is not the diagnosis the PR exists to add.

The test suite cannot see this: start gives up when the control plane never reports UP runs on the fake clock and the rig's fake system.fetch ignores init.signal, so the same final 1 ms probe returns {"status":"DOWN"} and the assertion pins HTTP 200, status DOWN. The real path and the fake instrument disagree only at the deadline.

Suggested fix, measured in a scratch copy:

       const probe = await health(system, urls.health, budget);
-      answer = probe.answer;
+      if (budget > 1) answer = probe.answer;
       return probe.up ? true : undefined;

With that patch the head suite stays 60/60, and the live cell prints (the last probe: HTTP 503, status DOWN). verify is unaffected — it makes one probe with the whole budget, and every real cell in the table above reports its actual answer.

The repro command from this round: ARM=head node --test --test-name-pattern='live 503' arm-head/scripts/tests/ab.mjs (raw log in logs/ab-head.log; the patched arm is in logs/fix-live-503.log).

Finding 2 — Suggestion: the narrowed IPv6-zone test is unpinned

Mutant m10-zone-regex reverts /\[[^\]]*%/ to the pre-PR /%/ and survives 60/60. The two shapes differ on a percent outside the brackets:

fetchRefusal('http://127.0.0.1:70000/%')
  head    → "is not a URL"
  mutant  → "is not a URL: a URL cannot carry an IPv6 zone"   (wrong zone diagnosis)

This is the accuracy the stage-2 review praised; no test pins it. One assertion in the existing refuses only the URLs fetch refuses test closes the gap and was measured:

assert.equal(fetchRefusal('http://127.0.0.1:70000/%'), 'is not a URL');

With it the suite is 60/60, and the /%/ mutant now fails that test (59/60).

Gates and CI

  • node --test scripts/tests/managed-agent-upgrade.test.mjs at head: 60/60, 12.8s.
  • The base suite (58 tests) at head code: 55/58; the three failures are exactly the assertions this PR updates — start gives up when the control plane never reports UP, a health probe that never answers ends at the timeout, and start refuses listeners it cannot reach before it starts anything. No unexpected regression.
  • The base suite at base: 58/58.
  • prettier --check on the six changed files: clean. The gate was proven live by planting an unformatted file in the repo, which it reported and exited 1 on.
  • CI at head 13157b7c: Test (ubuntu-latest, Node 22.x), Build and verify reference distribution, Lint & Static, Integration Tests (no-AK, No Sandbox), Managed Agent fast tier and the SDK Java fast lanes all succeeded; review-pr was still in progress at the last read.
  • The only red on the previous head 6058c44 was web-shell E2E Smoke: previews qwen3.8-max reasoning before lazy session creation expected qwen3.8-max · Medium and got Thinking Off on two retries. The diff cannot reach that lane, and the same job passed at 13157b7c. Attributed to the lane, not this PR.

Window check

While this round ran, the author's Codex review comment landed at this head (11:48Z) with C=0. Its independent checks agree with this round where they overlap: the distribution CI ran the three upgrade test files at 97 passed / 0 failed / 1 skipped, and a real TLS probe produced is not UP: self-signed certificate, then 200 UP with NODE_EXTRA_CA_CERTS. It did not drive start --timeout against a live non-UP endpoint, which is where finding 1 lives; the suite test it cites runs on the fake clock with a fake fetch that ignores the abort signal.

Not covered

  • A real systemd host: the round uses the repository's rig (fake systemctl, real files), so unit lifecycle and journal behaviour are not exercised on real units. The PR scopes this out.
  • macOS and Windows.
  • Full blocked-port set equality on Node 22: CI's Node 22 suite (including the 82-port agreement test) is green; the complete 65,536-port scan above ran on Node 24.22.1.
  • The --check gap tracked by Managed Agent --check ignores the configuration files the server reads from its working directory #16057, which the PR deliberately leaves alone.
  • A real MySQL / Hosted Harness deployment end to end: this diff touches only the operator-side script, its tests and docs.

Methodology

Host: Alibaba Cloud Linux 3, 32 cores, Node v24.22.1, on the workstation (no credential-free container; verify-pr-prepare reported isolation none detected). The harness is the base revision's scripts/tests/managed-agent-upgrade.test.mjs rig; only systemctl and the resolver are simulated, while the A/B cells use the real fetch, real HTTP/HTTPS servers on loopback, real TLS, and the real clock. The suite itself keeps its fake clock. Raw logs are in logs/ (ab-base.log, ab-head.log, fix-live-503.log, head-suite.log, base-suite-base.log, base-suite-head-code.log, mutations.log, port-agreement.log, docs-check.log, ci-webshell-smoke.log); the mutation data is mutations.json, and the scripts are in harness/.

— DeepSeek-V4.1-Flash-1017@fda99a87 via Qwen Code /verify-pr (v0.26.5; skill 1f7085bc5584)

… start's last probe short

start's last health probe gets the 1 ms the deadline leaves it, so against a
real endpoint it times out before any answer arrives, and the timeout message
reported that abort instead of what the endpoint had been answering, such as
HTTP 503, status DOWN. A probe that times out on a budget the deadline cut
below the per-probe cap no longer replaces an earlier answer; one that runs
out of its own 5 seconds still does, since the endpoint stopped answering.

The test rig's fake fetch now awaits a response function, so a test can model
an endpoint that answers late and honours the abort signal. Also pins the
IPv6-zone diagnosis to a percent inside the brackets.
@wenshao

wenshao commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator Author

Round-1 verification: both findings are fixed in a25a76d2a6.

  • Finding 1, start's last probe: fixed, and a little wider than the suggested budget > 1. After the deadline, waitFor leaves the last probe the 1 ms floor. But a probe that still has a few milliseconds left is just as unable to get an answer from a real endpoint, and budget > 1 would let that probe's abort through. So the rule is now: a probe that times out on a budget the deadline cut below the 5 s cap does not replace an earlier answer. A probe that runs out of its own full 5 s still does, because then the endpoint really has stopped answering. health() reports timedOut from error.name === 'TimeoutError', which is how fetch rejects once AbortSignal.timeout fires (checked against a listener that never answers, on Node 22.22.2).
    • Rig. Its fake fetch now awaits a response function. The new test models an endpoint that answers in 50 ms on the real clock and honours the signal: four probes, only the last one times out, and the message keeps HTTP 200, status DOWN. A second case answers once and then times out at the cap, and the message names the timeout.
    • Your live cell, rerun eight times per arm (503 {"status":"DOWN"}, real fetch, real clock, --timeout 1 and 2): before the fix, 6/8 messages named the abort; after, 8/8 name HTTP 503, status DOWN.
  • Finding 2, the zone regex: pinned with your assertion. fetchRefusal('http://127.0.0.1:70000/%') must be is not a URL, so the /%/ mutant now fails.

Mutants. Seven more, all killed: the guard removed, the cap clause dropped, the cap boundary as <=, the earlier-answer clause dropped, timedOut never set, timedOut keyed on AbortError, and the zone regex reverted. That makes 26/26.

Tests. The suite passes 61/61 on Node 22.22.2 (x86_64) and Node 24.14.0 (aarch64). The design doc now says that start reports what the endpoint last answered, and when a probe that timed out does not count as an answer; the user guide already said "what it answered last".

The Codex pass at 13157b7c96 (C=0) and the Copilot overview raised nothing open, so nothing changed for them.


🤖 Generated with Claude Code — Claude Opus 5.5

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

A stalled response body can time out without setting timedOut, causing phaseStart to overwrite an earlier health answer with an abort message; timeout-state handling and a regression test are needed.

No open issues 🎉

Review effort: Balanced

@wenshao

wenshao commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator Author

PR 16110 round 2 verification — Verdict: findings — 47/50 scripted assertions passed, 3 failed. Verified head: a25a76d2a6ffcc1e05d40467c1feabaa6b409eb8 against base 0a7f26070426d80c9bbba498651182448755d526. Both round-1 findings are fixed. One new defect remains in the same timeout path — a response body that stalls after its headers still overwrites the earlier answer — plus one coverage gap and one documentation boundary.

中文摘要
  • 结论:findings(50 条断言,47 过 3 失败)。增量只有一个提交(4 个文件,+67/−5),正好针对上一轮的两条发现。
  • 上一轮两条都已修复:真实 503 端点上 start --timeout 2 现在打印 (the last probe: HTTP 503, status DOWN),而不是 The operation was aborted due to timeout;收窄后的 zone 正则有了断言,退回 /%/ 的变异现在会让 refuses only the URLs fetch refuses 变红。
  • 中心主张仍成立:见下方 A/B 表。四项拒绝单元 base 等满约 2 秒并启动 2 个 unit,head 8–15ms 拒绝、0 个 unit;verify 的 health 行仍逐项给出原因;全端口枚举再次得到 82/82、双向无差集、port 0 允许。
  • 新缺陷(Medium):服务器先发出 200 响应头、随后停住响应体时,response.json() 抛出的 TimeoutError 没有带上 timedOut,phaseStart 的新守卫因此把它当成有内容的回答,覆盖了早先的 HTTP 503, status DOWN,最终打印 HTTP 200, The operation was aborted due to timeout。真实套接字(--timeout 3,第二个探测停住)与确定性 fake 各复现一次;head 自带的 61 个测试全绿,没有覆盖这条路径。建议修法(JSON 分支也设置 timedOut)实测 61/61、76/76,两个复现单元都改回保留早先的 503。
  • 一条 Suggestion:去掉 probe.timedOut 判断的变异(m27)在 61 个测试下存活;这会让任何剩余预算 <5 秒的非超时错误(例如连接被拒)也保留旧答案,掩盖后来的真实失败。建议补一个非超时错误的后续探测用例。
  • 一条 Suggestion(文档/边界):真实时钟下 --timeout 6 的第二个探测只剩约 4999ms,仍被当作“被截止时间截短”,保留旧答案;--timeout 7 才走“自身 5 秒”分支。单元测试的 fake 时钟正好给 5000ms,真实路径不会出现这个整数值,文档措辞可再精确一些。
  • 未覆盖:真实 systemd 主机(rig 的 systemctl 是模拟层)、macOS/Windows、Node 22 上的完整端口枚举(本轮在本机 Node 24.22.1 完成;CI 的 Node 22 套件上一轮已绿)、Managed Agent --check ignores the configuration files the server reads from its working directory #16057 的 --check 缺口、以及发布时仍在 pending 的 CI lane。

Previous findings at this head

# Round-1 finding Status at a25a76d2 Evidence
1 start's timeout quoted the deadline's 1 ms probe, so a live 503 endpoint became an abort fixed head cell within 2s (the last probe: HTTP 503, status DOWN); base cell has no detail; the new unit test pins both branches; five guard mutants killed
2 The narrowed IPv6-zone regex was unpinned: /%/ survived 60/60 fixed the new assertion at test line 271 kills the /%/ mutant with + 'is not a URL: a URL cannot carry an IPv6 zone' - 'is not a URL'

The round-1 suggested patch (if (budget > 1) answer = probe.answer;) was superseded: the author's timedOut flag handles both the 1 ms last probe and a probe that runs out of its own time, and is the better shape. Re-measured here, not assumed.

Central claim and A/B

The claim is unchanged from round 1: start and verify refuse a listener URL fetch would refuse, before starting any unit, and a probe that is sent and fails names its answer. The new commit adds the distinction between a probe the deadline cuts short and one that runs out of its own time.

The A/B uses the repository's own upgrade rig (a fake systemctl, real files), with the systemd layer as the only fake. Health endpoints, fetch, DNS/connect errors, TLS and the clock are real loopback servers. The head arm is the head production file with the head test file; the base arm is the base production file with the base test file, because fetchRefusal is a new export the base file does not have. Both arms run the same appended instruments.

Cell Base 0a7f2607 Head a25a76d2
--server-url http://admin:secret@127.0.0.1:<port>, live 200 UP exit 1, 2020ms, 2 units, timeout exit 1, 13ms, 0 units, "carries a user name or password"
--server-url http://127.0.0.1:6000, live endpoint answering raw HTTP 200 exit 1, 2025ms, 2 units, timeout exit 1, 10ms, 0 units, "is on port 6000"
--server-url proxy.test:8443 exit 1, 2020ms, 2 units, timeout exit 1, 9ms, 0 units, "is not an http or https URL"
opaque Harness URL exit 1, 2 units, timeout exit 1, 0 units, "is not an http or https URL"
verify, live 503 {"status":"DOWN"} "is not UP" "is not UP: HTTP 503, status DOWN"
verify, 502 HTML, 404, 200 non-JSON, closed port, hang, self-signed "is not UP" each names its answer, as in round 1
verify, live 200 UP PASS PASS
start --timeout 2, live 503 DOWN no detail (the last probe: HTTP 503, status DOWN)
start --timeout 7, endpoint answers once then hangs (own 5 s) no detail (the last probe: The operation was aborted due to timeout)
start --timeout 3, headers then a stalled body no detail HTTP 200, The operation was aborted due to timeout — finding 1
start --timeout 2, deterministic stalled body no detail HTTP 200, The operation was aborted due to timeout — finding 1

The full 18-row capture, including every verify answer, is 01-ab-refusals-and-probe-answers-r2.png.

01-ab-refusals-and-probe-answers-r2.png

The blocked-port list was re-enumerated at this head through the real fetch on this host (Node 24.22.1): 82 blocked, 82 refused by fetchRefusal(), symmetric difference empty in both directions, port 0 dialled by fetch and allowed. The scan took 20.5s and never dials a blocked port.

Mutation matrix

12 single-point mutants of the head production file, each run against the unmodified 61-test head suite. Baseline first (61/61, exit 0), then one expression per row. 11/12 killed; the survivor is finding 2. The matrix as it printed, with the failing test named for every kill, is 02-mutation-matrix-r2.png.

02-mutation-matrix-r2.png

Findings

Finding 1 — Medium: a response body that stalls after its headers overwrites the earlier answer

Reproduce with the live-socket cell (an endpoint that answers 503 DOWN to the first probe, then sends 200 headers and never finishes the body):

cd tmp/pr16110-verify-20261102-203752
ARM=head node --test --test-name-pattern 'live body that stalls' arm-head/scripts/tests/ab.mjs

The command exits 1 with true !== false, and the cell prints:

start refused: qwen-managed-agent-server did not report UP at http://127.0.0.1:<port>/actuator/health within 3s
  (the last probe: HTTP 200, The operation was aborted due to timeout) and keeps running; …

The endpoint had answered HTTP 503, status DOWN to the first probe, and that is the answer the user needs; the last probe only saw headers before the deadline ended the body read. The deterministic cell (--test-name-pattern 'stalled body the deadline') reproduces the same shape with three probes, in 2.1s.

Cause: health()'s JSON catch returns {up: false, answer: …} without timedOut (production lines 2620–2625). The new guard in phaseStart (lines 2730–2735) therefore sees probe.timedOut === undefined and takes the overwrite branch, even though budget < PROBE_TIMEOUT_MS would have classified this probe as deadline-cut. fetch itself rejects a stalled body with a TimeoutError, which the fetch catch does mark; the body-read catch is the one path that does not.

Blast radius: start's timeout detail only. verify makes one probe per request with no earlier answer to lose, and a successful body read is unaffected. The shape needs headers to arrive before the signal ends the body read, so the deterministic and live cells both drive the real production path rather than a unit stub. The head unit suite is 61/61 green with this defect present; the PR's new test covers the fetch rejection, not the body-read rejection.

The review at 5736468445 raised this shape; the cells below reproduce it independently, and the suggested fix was measured rather than argued.

Suggested fix (measured): mark the body-read timeout too
   } catch (error) {
     // A proxy's error page is no JSON, and its status says enough.
     return {
       up: false,
       answer: response.ok ? `${status}, ${error.message}` : status,
+      // A body the signal ended, as it ends a stalled one, is no answer.
+      timedOut: error.name === 'TimeoutError',
     };
   }

Applied in a scratch copy and driven through the same instruments: head unit suite 61/61, A/B 76/76, and both stalled-body cells now print (the last probe: HTTP 503, status DOWN); every other cell is byte-identical.

03-stalled-body-head-vs-fix-r2.png

Finding 2 — Suggestion: the probe.timedOut half of the guard is unpinned

Mutation m27-guard-without-timedout removes probe.timedOut && from the guard and the head suite stays 61/61 green. The mutant then preserves the earlier answer for any error whose budget is under 5s, not only a timeout: with --timeout 6, probe 1 answers 503 and probe 2 gets ECONNREFUSED, the message keeps HTTP 503, status DOWN and hides the connection loss. The fix is right; the suite needs one case where a later probe fails with a non-timeout error and a sub-5s budget.

Finding 3 — Suggestion: the "own 5 seconds" branch starts at a budget of exactly 5s, which the real clock rarely produces

The new unit test uses the fake clock, so the second probe's budget is exactly 5000; with the real clock the same probe gets 4999 after the 1s poll. Measured on this head:

Cell Budget Result
start --timeout 6, endpoint answers once then hangs ≈4999ms keeps HTTP 503, status DOWN
start --timeout 7, same endpoint ≈5999ms names The operation was aborted due to timeout

The code's rule (budget < PROBE_TIMEOUT_MS ⇒ deadline-cut) is defensible, but the design doc says "one that runs out of its own 5 seconds does", which a reader will not see at --timeout 6. Either say "a probe whose own timeout fires before the deadline", or pin the documented case at --timeout 7. Non-blocking.

Not covered

  • Real systemd hosts, macOS and Windows: the rig's systemctl is a simulated layer; units, files, sockets, clocks and TLS are real.
  • A full 65,536-port enumeration on Node 22: this round ran on Node 24.22.1; the CI Node 22 suite carries the suite's own agreement test, and the PR's blocked list is unchanged from round 1.
  • The --check configuration gap tracked in Managed Agent --check ignores the configuration files the server reads from its working directory #16057, which the PR explicitly leaves out of scope.
  • CI lanes still pending at the time of writing: Test (ubuntu-latest, Node 22.x), web-shell E2E Smoke, SDK Java (fast) / ubuntu-latest / Java 21. Lint & Static, Integration Tests (no-AK), Build and verify reference distribution, TUI parity snapshots and Real daemon E2E / Java 11 had passed.
  • How often the stalled-body shape occurs in production: the live cell shows it is reachable, but no telemetry on its frequency is available here.

Methodology

Each arm is a directory with the revision's production file and the same appended instruments; the production file is the only difference between the arms. The head and base suites were run with node --test on this host; the mutation runner rewrites one production expression at a time in a separate mut/ tree, checks each anchor matches exactly once, runs the unmutated baseline first, and records the failing test names. Raw logs and harness scripts are in tmp/pr16110-verify-20261102-203752/ (logs/, harness/, mutations.json).

— DeepSeek-V4.1-Flash-1017@fda99a87 via Qwen Code /verify-pr (v0.26.5; skill e02c61466216)

…short probe too

A health endpoint that sends its headers and then stalls the body made
response.json() reject with the signal's TimeoutError. That branch did not
report timedOut, so start's guard took the probe for an answer, and a probe
the deadline cut short replaced an earlier HTTP 503, status DOWN with
"HTTP 200, The operation was aborted due to timeout". The body-read branch
now reports timedOut as well.

The last-answer test gains two real-socket cases: a body that stalls after
its headers keeps the earlier answer, and a refused connection after an
answer replaces it, which pins the timedOut half of the guard. The design
doc says when the 5-second limit counts as the probe's own, and that any
other failure replaces an earlier answer.
@wenshao

wenshao commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator Author

Round-2 verification: all three findings are handled in 80d7e70e3d.

  • Finding 1, a body that stalls after its headers: fixed with the suggested change. This is also the shape the Copilot overview at a25a76d2a6 flagged. fetch resolves once the headers arrive, and the signal then ends the body read in response.json() with the same TimeoutError (checked on a real socket, Node 22.22.2). The body-read branch now reports timedOut as well. I reran your live cell on the real clock, four runs per arm: an endpoint that answers 503 DOWN once, then sends 200 headers and stalls, with --timeout 3. Before the fix, 4/4 printed HTTP 200, The operation was aborted due to timeout; after it, 4/4 print HTTP 503, status DOWN.

  • Finding 2, the timedOut half of the guard: pinned. The last-answer test now has two real-socket cases:

    • the stalled body, which keeps the earlier 503;
    • an endpoint that answers 503 and then closes. The next probe's connect ECONNREFUSED 127.0.0.1:<port> replaces the earlier answer, even though the deadline cut that probe's budget too.

    With probe.timedOut && dropped, that second case fails. The test passed 20/20 in repeats.

  • Finding 3, the 5-second boundary: doc reworded, rule kept. The design doc now says a probe's own 5-second limit counts when it runs out before the deadline, and that any other failure, such as a refused connection, replaces an earlier answer. So --timeout 6 on the real clock (about 4,999 ms left) reads as a probe the deadline ends. The fake-clock case keeps the exact 5,000 ms boundary pinned, so the <= mutant still fails.

Mutants. Three more, all killed: the body-read branch without timedOut, with timedOut: false, and your m27 (the guard without probe.timedOut). The round-2 guard mutants and the zone mutant were rerun and are still killed. That makes 29/29.

Tests. The suite passes 61/61 on Node 22.22.2 (x86_64) and Node 24.14.0 (aarch64).


🤖 Generated with Claude Code — Claude Opus 5.5

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues block approval of the Managed Agent upgrade diagnostics changes.

No open issues 🎉

Review effort: Balanced

@qwen-code-review-bot qwen-code-review-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — no blockers. Suggestions are inline.

中文说明

已审查——无阻断问题。 建议见行内评论。

— deepseek-v4.1-flash-1017 via Qwen Code /review (v0.26.5)

Address review R1-1..R1-5 on the upgrade URL/health change:
- R1-1: neutralize terminal control bytes (C0/DEL/C1 -> U+FFFD) in the
  endpoint-derived health answer before it is interpolated into start's
  timeout refusal and verify's health row, so a queryable endpoint cannot
  move the cursor, split a row, or write the clipboard (OSC-52).
- R1-2: the Harness URL refusal reuses fetchRefusal when the value does not
  parse, naming an IPv6 zone exactly as --server-url does.
- R1-3: start's timeout labels the retained value 'the last answer', matching
  the design doc, since a deadline-cut probe keeps an earlier answer.
- R1-4: pin verify's URL refusal (listeners runs it with reachesHarness:false)
  with a test asserting it refuses before any probe.
- R1-5: tear down the 'closes' test server via t.after so a failing assertion
  cannot hang node --test to the job ceiling.

Tests: 63 pass; R1-1/R1-2/R1-4 mutation-witnessed (printable no-op, refusal
gated on reachesHarness, zone reason reverted each redden their pin).
Prettier and ESLint clean.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
@qwen-code-review-bot

Copy link
Copy Markdown
Collaborator

Qwen Code review never started. The job ended before a runner picked it up, so no review ran for this head. This can happen when a queued run is cancelled or expires; this step cannot determine the cause. See workflow logs. Check the latest qwen-review-runner-schedule.yml run. If you still want a review, re-request with @qwen-code /review when the ecs-review pool is available.

wenshao and others added 2 commits November 3, 2026 09:06
Add a real-scenario pin for R1-1: a local HTTP server serves a status field
carrying cursor moves, a newline and an OSC-52 clipboard write, and verify
runs against it through the runtime's own fetch — the real
health() -> printable() -> row() -> out() path, not the rig's fake. Asserts
the printed health row keeps no control byte while the readable text survives.
64 tests pass.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
…'s API reads failed

Found on a real systemd deployment (real control plane, Harness, MySQL,
TLS and nginx):

- A refused --server-url was printed as typed, so a URL with a password,
  which fetch refuses, put that password in the output. The refusal now
  prints it as ***.
- verify's session and turn rows still said only "fetch failed" where the
  health row above them named the cause, such as "self-signed certificate
  in certificate chain". API reads now take the same cause.
- Text the API hands back (an error reason, a body that fails to parse,
  a Session ID, an event type) reached the session and turn rows with
  its control bytes; it is now neutralized as the health answer is.

The design doc says the probe answer's control characters show as U+FFFD.
@wenshao
wenshao requested a balanced review from Copilot November 3, 2026 01:29

@qwen-code-review-bot qwen-code-review-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deferred under the convergence posture (round 4, not a blocker) — recorded, not requested in this round:

  • packages/managed-agent-server/distribution/bin/qwen-managed-agent-upgrade.mjs:2865 — [review] the ApiError label is unsanitized, so the session and turn FAIL rows carry the endpoint's Session id unbounded

Convergence: round 4 posted 4 inline comment(s), 2 of them reported for the first time; the previous round posted 6 (2 new). Findings keep coming back to the same files: packages/managed-agent-server/distribution/bin/qwen-managed-agent-upgrade.mjs (findings in rounds 1, 2, 3; 2 more now). The rate of new findings is not falling. A cluster that keeps producing siblings usually means the fixes are treating instances of a shared root cause — triaging that cause before the next round, or splitting an independent cluster into its own pull request, tends to end the loop faster than fixing them one at a time. Batching the remaining fixes and verifying them before the next push, or dropping this PR's reviews to --severity-floor critical, keeps the loop from re-deriving the same set. (Observation only — nothing was withheld from this review because of this observation.)

中文说明

收敛姿态下延后(第 4 轮,非阻断)——已记录,本轮不要求修改:共 1 条(原文未翻译,列表见上方英文部分)。

收敛情况:第 4 轮发布了 4 条行内评论,其中 2 条是首次提出;上一轮发布了 6 条(其中 2 条首次提出)。发现反复回到同一批文件:packages/managed-agent-server/distribution/bin/qwen-managed-agent-upgrade.mjs(第 1、2、3 轮已出过发现,本轮又有 2 条)。新发现的产出速度没有下降。一个不断再生兄弟发现的簇,通常意味着逐条修复只在处理同一根因的实例——先定位并处理该根因,或把独立的簇拆成单独的 PR,通常比逐条修复更快结束循环。把剩余修复攒成一批、验证后再推送,或将本 PR 的评审降到 --severity-floor critical,可以避免循环反复推导同一组发现。(仅为观察——本轮评审未因此扣留任何内容。)

— deepseek-v4.1-flash-1017 via Qwen Code /review (v0.26.6)

…heck the API URL only when verify reads it

- verify decides whether its session row reads the API before it checks
  the listeners, so a signed deployment, or --actor without a trusted
  actor header, is no longer refused over an API URL it never dials.
- The configuration resolver now prints the preflight's own verdict on the
  Harness URL, read untrimmed as java.net.URI reads it, and start refuses
  on it before restarting the Harness: a host with an underscore, an empty
  user name or a padded value no longer restart the Harness only to fail
  the preflight.
- withoutCredentials masks everything up to the last @ of a value the
  parser rejects, so a password holding / ? or # stays hidden.
- printable counts code points in one pass and keeps only the head, so a
  huge endpoint answer costs no copy of itself.
- The request an API error names is bounded like the rest of the row.
…rses it

A padded qwen.managed-agent.harness.base-url fails the preflight, and the
start refusal now shows the padding instead of a value that looks valid.
@wenshao

wenshao commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator Author

About the item round 4 deferred (the ApiError label is unsanitized, so the session and turn FAIL rows carry the endpoint's Session id unbounded): I fixed it in this round rather than leave it. In c80d768a42, api() builds its label from printable(route), so the request a failed row names stops at 200 code points, as the ID does. A new case pins it: the API lists an ID of 100 000 characters and then returns 404 for it, and the row must read GET /v1/agents/sessions/S…… (100020 characters): 404. The mutant that drops the printable() fails that case.

I reproduced it on the rig with an endpoint that lists such an ID and returns 404 for its read. verify --tenant e2e printed a 100 067-character session row on the previous head, and a 270-character one here.

Round 6 is in the PR body, along with the real-rig table: alpha.101 was packaged from e51f95f2e2 and installed through check, stop, backup and install.


🤖 Generated with Claude Code — Claude Opus 5.5

@qwen-code-review-bot qwen-code-review-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not explored to full depth (tool budget reached): "agent reverse-audit (round 1)": chunk 1's users zh-CN twin ( docs/users/managed-agent-reference-deployment.zh-CN.md:231 ) was read only as the translated copy of the same claim while locating ….

Deferred under the convergence posture (round 5, not a blocker) — recorded, not requested in this round:

  • scripts/tests/managed-agent-upgrade.test.mjs:2572 — [review] the password-leak assertion runs after the loop, so it only inspects the last iteration's password-free output
  • packages/managed-agent-server/distribution/bin/qwen-managed-agent-upgrade.mjs:3011 — [review] the added printable(terminal.type) cannot see a non-string: the classification regex coerces the value first and throws

Convergence: round 5 posted 1 inline comment(s), 1 of them reported for the first time; the previous round posted 4 (2 new). Findings keep coming back to the same files: packages/managed-agent-server/distribution/bin/qwen-managed-agent-upgrade.mjs (findings in rounds 2, 3, 4; 1 more now). A cluster that keeps producing siblings usually means the fixes are treating instances of a shared root cause — triaging that cause before the next round, or splitting an independent cluster into its own pull request, tends to end the loop faster than fixing them one at a time. (Observation only — nothing was withheld from this review because of this observation.)

中文说明

未探索到全部深度(达到工具调用预算):"agent reverse-audit (round 1)":chunk 1's users zh-CN twin ( docs/users/managed-agent-reference-deployment.zh-CN.md:231 ) was read only as the translated copy of the same claim while locating …。

收敛姿态下延后(第 5 轮,非阻断)——已记录,本轮不要求修改:共 2 条(原文未翻译,列表见上方英文部分)。

收敛情况:第 5 轮发布了 1 条行内评论,其中 1 条是首次提出;上一轮发布了 4 条(其中 2 条首次提出)。发现反复回到同一批文件:packages/managed-agent-server/distribution/bin/qwen-managed-agent-upgrade.mjs(第 2、3、4 轮已出过发现,本轮又有 1 条)。一个不断再生兄弟发现的簇,通常意味着逐条修复只在处理同一根因的实例——先定位并处理该根因,或把独立的簇拆成单独的 PR,通常比逐条修复更快结束循环。(仅为观察——本轮评审未因此扣留任何内容。)

— deepseek-v4.1-flash-1017 via Qwen Code /review (v0.26.7)

The resolver passed on the preflight's verdict on the Harness base URL
with no regard to the Harness's state, so start refused a value that a
disabled or pooled Harness leaves unread: the preflight skips its
harness row before reading it, and the server never dials it. The
verdict is now "skip" there. start refuses on the preflight's grounds
(user information, a query, a fragment, or anything java.net.URI reads
differently) only on a "false" verdict, and its own reasons only word
that verdict. It still refuses a URL that is not http or https, since it
waits for the Harness there. Without a verdict, as when the
configuration does not resolve, the preflight judges the URL once the
Harness is up.

verify now checks the type of the values the API chose before using
them. Building a route from a Session id, matching an event type, or
reading an event sequence coerced the value first, and that throws on
an object such as {"toString":1} or on an array nested deeper than the
stack, so printable() never got to show what came back. A Session
without a string id fails its row with that value, an event type that
is not a string fails the turn row, and a sequence counts only as a
number or a numeric string.

The start tests now check every run's output for the password, not
only the last run's.
…rom the API

The previous commit gave "skip" for a pooled Harness as well as a
disabled one, since the preflight skips its harness row in both before
reading the base URL. A pooled server still reads that URL, though:
each member's QwenHostedHarnessConnector is built from it and refuses it
by the same rule as the preflight. The pool's refresh drops a member
whose connector refuses it, so such a pool accepts no Session while the
server reports UP. Only a disabled Harness gets "skip" now. A test pins
the verdict to whether the connector builds, for a single Harness and
for a pool. Since the verdict is now the server's rather than only the
preflight's, the refusal says "the server does not take".

verify reads Sessions, items and events only as lists. Data that is not
a list fails its row and says what came back: iterating it would throw,
or walk a string, and its length could be any value. A listed entry of
0, "", false or null fails the session row instead of being reported as
no Session. An event sequence moves the cursor only as a whole number,
and only forward: Number() reads "Infinity", "0x10" or " 4 " as numbers.

The user guide now says that, when the configuration does not resolve,
the preflight judges the Harness URL after the Harness starts.
When the configuration does not resolve there is no verdict. The previous
commits then let start accept any http(s) Harness URL and left the URL to
the preflight. A pooled preflight never reads it, though, and every pool
member's connector refuses user information, a query or a fragment, so
the pool would start and accept no Session. Without a verdict, start
refuses those itself again, since the server refuses them wherever it
reads the value. A "true" or "skip" verdict still asks nothing more, and
the generic wording is kept for a "false" verdict.

HarnessConfigurationTest now builds a pool through the real member
factory and shows that the single base URL decides whether a member is
accepted. The pooled half of the agreement test checked nothing the
single half did not, so it is gone.

verify now requires every page to carry its data as a list: a body that
is no object, or one whose data is null or missing, fails the row instead
of reading as no Session. A Session id of "", "." or ".." fails, since
fetch resolves dot segments and an empty id reads the list. Only
terminal: true ends a turn.

The docs no longer say the server takes only an origin, since a path is
fine. They say which component refuses the URL, and they word the
sequence rule as the code applies it.
@wenshao

wenshao commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator Author

About the two items round 5 deferred: both are fixed in this round, together with what they turned out to share.

  • the password-leak assertion runs after the loop (scripts/tests/managed-agent-upgrade.test.mjs:2572). host.upgrade resets the output on every run, so the check only saw the last one. It now runs inside the loop, and so does its twin in the Harness URL loop of the same test. A new test that starts with a credentialed Harness URL checks every run too.

  • printable(terminal.type) cannot see a non-string (…upgrade.mjs:3011). The regex coerced the value first. The same held wherever verify used a value the API chose before checking its type:

    • encodeURIComponent(session.id) for the routes;
    • Number(event.sequence) for the cursor;
    • iterating page.data;
    • items.data.length for the count.

    {"toString":1} or an array nested deeper than the stack throws in each, so the row said Cannot convert object to primitive value or Maximum call stack size exceeded instead of what came back.

    In 3a556b9ab5, 9b8a548e3c and 948e7484b5, every page has to carry its data as a list. A Session id has to be a string that a route can carry as one segment. An event type names an outcome only as a string, and only terminal: true ends a turn. A sequence moves the cursor only as a whole number or its digits, and only forward. Each failure names what came back, through printable().

On the rig, with a fake API behind --server-url and the real units running. Each row ran on whichever release was installed for that case; the code behind each row is the same across each column's releases.

The API answers Before this round (alpha.101–103) This round (alpha.102–104)
Session id {"toString":1} FAIL session Cannot convert object to primitive value FAIL the API answered a Session without a string id ({"toString":1})
Session id nested 20 000 deep FAIL … Maximum call stack size exceeded … without a string id ([unprintable])
terminal event of type 7 PASS … ended with 7 FAIL Session s1 ended with 7
{"data":[0]} WARN … has no Session FAIL … without a string id (0)
items {"data":{"length":2}} PASS read Session s1 and 2 item(s) FAIL GET …/items?limit=20 answered no data list ({"length":2})
events {"data":{}} FAIL … object is not iterable (cannot read property Symbol(Symbol.iterator)) FAIL … answered no data list ({})
a bare [{"id":"s1"}] WARN … has no Session FAIL … answered no data list ([{"id":"s1"}])
Session id .. FAIL GET /v1/agents/sessions/..: 404 (fetch dialled /v1/agents) FAIL … whose id ".." names no route
"terminal":"false" PASS … ended with turn.completed FAIL Session s1: no terminal event within 5s

The happy path, verify --tenant e2e --turn against the real API, passes before and after. Round 7 is in the PR body.


🤖 Generated with Claude Code — Claude Opus 5.5

@qwen-code-review-bot qwen-code-review-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partially reviewed — gaps disclosed.

⚠️ Round 6, and the diff has grown 3.3x since this review first measured it (204 → 681 source diff lines). The findings below are anchored to the current patch, so they can only say where this approach leaks — never that a different approach would retire all of them at once. Before fixing them, a human should decide whether the shape of the change is still right. Advisory only: this does not affect the verdict, and nothing here is a blocker.

Not reviewed: build-and-test — SDK Java (fast) / Runtime Broker and Managed Agent MySQL / Java 21 was skipped in CI, and only the two changed Java test classes ran locally.

Deferred under the convergence posture (round 6, not a blocker) — recorded, not requested in this round:

  • packages/managed-agent-server/distribution/bin/qwen-managed-agent-upgrade.mjs:2931 — [review] sessionRoute prints (undefined) for an object entry that carries no id
  • packages/managed-agent-server/server/src/main/java/com/alibaba/qwen/code/managedagent/preflight/ManagedAgentPreflight.java:1752 — [review] harnessUrlVerdict does not model the preflight's plaintext-transport rule
  • scripts/tests/managed-agent-upgrade.test.mjs:2628 — [review] the --server-url refusal battery omits a query or fragment, which swallows the health path
  • scripts/tests/managed-agent-upgrade.test.mjs:2878 — [review] no test pins printable() on the health row's JSON-parse-error path
中文说明

仅完成部分审查,审查缺口已披露。

⚠️ 第 6 轮,且自本审查首次测量以来 diff 已增长 3.3 倍(源码 diff 行数 204 → 681)。下方的发现都锚定在当前这版补丁上,因此它们只能指出这个方案在哪里漏了,而无法说明换一个方案就能一次性消除全部问题。在动手修复之前,应由人来判断这次改动的整体形态是否仍然正确。仅供参考:本段不影响判定结论,其中也没有任何阻断项。

未审查(原文为英文):build-and-test — SDK Java (fast) / Runtime Broker and Managed Agent MySQL / Java 21 was skipped in CI, and only the two changed Java test classes ran locally.

收敛姿态下延后(第 6 轮,非阻断)——已记录,本轮不要求修改:共 4 条(原文未翻译,列表见上方英文部分)。

— deepseek-v4.1-flash-1017 via Qwen Code /review (v0.26.7)

@yiliang114 yiliang114 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One Critical finding (static import ordering, carried forward from the bot's round 6 at 8529a68 — the head moved only by a merge of main, so the PR's own files are unchanged).

[Critical] R6-1 — packages/managed-agent-server/verification/src/test/java/com/alibaba/qwen/code/managedagent/preflight/ResolvedConfigurationTest.java: the added static assertThrows import breaks the module's sorted static-import block. The verification module runs maven-checkstyle-plugin with includeTestSourceDirectory=true and qwen-code-checks.xml's ImportOrder (sortStaticImportsAlphabetically=true, option=bottom). The current order (assertEquals, mock, assertThrows, assertTrue) fails checkstyle:check.

Fix: reorder to assertEquals, assertThrows, assertTrue, then mock:

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;

Verification: cd packages/managed-agent-server && mvn -o -B -pl server,verification checkstyle:check must be green.

The bot's CHANGES_REQUESTED at 8529a681e is stale (head has since advanced to 814b121). All other findings from the 7 review rounds appear addressed in the PR body's own evidence; the 72/72 mutant kills, real-rig scenarios, and API type-safety guards are solid. This one Checkstyle gate is the sole remaining blocker.

中文说明

一条 Critical 发现(静态 import 排序,从 bot 第 6 轮 at 8529a68 继承——head 仅因 merge main 前进,PR 自身文件未变)。

R6-1(Critical):ResolvedConfigurationTest.java 新增的 assertThrows 静态导入打乱了按字母排序的 static import 块,导致 Checkstyle 关失败。修复:重排为 assertEquals、assertThrows、assertTrue,再放 mock。验收:cd packages/managed-agent-server && mvn -o -B -pl server,verification checkstyle:check 必须变绿。

bot 在 8529a681e 的 CHANGES_REQUESTED 已过期(head 已推进至 814b121),7 轮审查中其余发现均已闭环;72/72 变异体全杀、真机场景与 API 类型安全守卫都很扎实。仅此一个 Checkstyle 关是剩余阻塞项。

@qqqys qqqys left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed at head 814b121014fc2ed2cb6a3109d918f0614284ade3 (base main). Commenting: one Critical is confirmed still present at this head. I verified it end to end in source, checkstyle config, the pom hierarchy and the CI invocation rather than taking it from the threads, and the fix is a four-line reorder.

Confirmed standing: static-import order fails the Checkstyle gate

packages/managed-agent-server/verification/src/test/java/.../preflight/ResolvedConfigurationTest.java at this head:

28: import static org.junit.jupiter.api.Assertions.assertEquals;
29: import static org.mockito.Mockito.mock;
30: import static org.junit.jupiter.api.Assertions.assertThrows;
31: import static org.junit.jupiter.api.Assertions.assertTrue;

Alphabetically org.junit.jupiter.api.Assertions.assertThrows sorts before org.mockito.Mockito.mock, so line 30 is out of order. Each link in the chain that makes this a gate failure, checked at this head:

  1. The rule exists and sorts. packages/sdk-java/qwencode/qwen-code-checks.xml:99-104 — ImportOrder with option=bottom and sortStaticImportsAlphabetically=true.
  2. Test sources are linted. packages/managed-agent-server/pom.xml:180-184 sets includeTestSourceDirectory=true with configLocation pointing at that file, and excludes only com/alibaba/qwen/code/runtimebroker/** — so preflight/ is in scope. verification/pom.xml:168 declares the plugin and inherits this configuration.
  3. The includeTestSourceDirectory=false override does not apply here. It sits inside the execution with id=runtime-broker-checkstyle (pom.xml:191-201), which uses combine.self="override" with a different config file and includes scoped to runtimebroker/**/*.java. That execution never sees this test file. I checked this specifically because it is the one thing that could have made the finding wrong.
  4. CI runs the goal that uses the default configuration. sdk-java.yml invokes mvn --batch-mode --no-transfer-progress checkstyle:check (:509, :516) and clean verify checkstyle:check (:1000, :1348, :1416, :1442).

The base file had no such import, so this diff introduced it. Fix — reorder so the JUnit assertions are contiguous and alphabetical, with Mockito last:

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;

Then cd packages/managed-agent-server && mvn -o -B -pl server,verification checkstyle:check should be green.

This is the same finding the bot filed in round 6 at 8529a681 and that @yiliang114 carried forward in a CHANGES_REQUESTED against this exact head two minutes before I started. The head has since moved only by a merge of main, so the PR's own files did not change and the violation came through untouched. We agree it is the sole blocker.

Earlier Criticals: closed by the round progression, not re-read by me

Five Criticals were filed across six rounds: R1-1 and R3-1, R4-1, R3-2, R6-1. None carries a qwen-review-fixed-ruling marker on this PR, so I read the ledger progression instead — a round that re-verifies carries a still-standing finding forward under its original id, so an id that disappears was assessed as fixed:

Round Head Criticals filed
2 8ee2ce3b R1-1
3 8ee2ce3b R1-1, R3-1
4 13cd5450 R4-1 — R1-1 and R3-1 gone
5 aa53b983 R3-2 — R4-1 gone
6 8529a681 R6-1 — R3-2 gone

So R1-1 and R3-1 closed by round 4, R4-1 by round 5 and R3-2 by round 6, and the maintainer's review independently concurs that everything besides R6-1 is addressed. I did not re-read those four closures in source myself, and I am not filing anything against them — the finding that matters is the one I can prove is still there.

Also noting without gating on it: round 6 disclosed it had not run the build, and deferred four non-blocking observations, including that harnessUrlVerdict does not model the preflight's plaintext-transport rule and that the --server-url refusal battery omits a query-or-fragment case. Those are marked non-blocking and the diff has grown 3.3× since the review first measured it, which is worth a maintainer's judgement on shape but is not mine to block on.

CI

The 15:57 merge re-triggered everything: at this head no lane has completed — 22 queued, 39 skipped, 0 succeeded, 0 failed. So there is no red run at 814b1210 to cite and no green one to lean on; the finding above rests on the source and configuration, which is firmer evidence than a lane would have been. Once the Java lane runs it should reproduce the Checkstyle failure, and it is the lane to watch after the reorder.

…rver-url query

The Mockito static import sat between two JUnit ones, so the verification
module's ImportOrder check failed. The static block is now sorted.

start and verify append /actuator/health and the API paths to
--server-url, so a query or a fragment there took the paths in. With
http://proxy.test/?a the command probed /?a/actuator/health, and fetch
dropped a fragment along with the path after it. Such a URL is now
refused up front.

A listed Session entry with no id is now shown as itself rather than as
"undefined". A health answer whose JSON parse error quotes control bytes
is pinned to come out sanitized.
@wenshao

wenshao commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator Author

Round 6, at 8529a681e8, and the review on 814b121014 that carried R6-1 forward, are handled in 3b67b6ec1d.

  • R6-1 (import order): fixed. Checkstyle on server,verification passes. The thread reply has the details.
  • A correction to my last report. I said SDK Java (fast) on 8529a681e8 was red only because of main's ClassSizeRatchetTest (JournalCommit at 886 lines over its 880 ceiling). The checkstyle step in that gate was also red, on this import. The ratchet itself is main's, and fix(managed-agent): restore JournalCommit under its class-size ratchet #16323 fixes it; that fix is merged here through 814b121014, and ClassSizeRatchetTest passes locally on this head.

The four items round 6 deferred:

  1. sessionRoute prints (undefined) for an object entry that carries no id: fixed. An entry with no id key is now shown as itself, for example FAIL the API answered a Session without a string id ({"name":"s1"}).
  2. harnessUrlVerdict does not model the preflight's plaintext-transport rule: left as is in this PR.
    • That rule is BrokerSecurity.checkHarnessTransport's startup policy: plaintext http to a non-loopback host, without auth.allow-insecure-bind. It is not a URL-shape rule.
    • Today the preflight's validation row reports it with the server's own message, after the Harness restarts.
    • Folding it into the verdict means one of two things. One is copying that rule, with isLoopback's name resolution, into the resolver. The other is making checkHarnessTransport public and reporting its message as a second key.
    • Round 6 also asks for a human decision on the change's shape, so I would rather settle that here than widen the PR again.
  3. the --server-url refusal battery omits a query or fragment: this was a real bug, not only a missing case, and it is fixed.
    • /actuator/health and the API paths are appended to --server-url. With http://…/?q, the endpoint received GET /?q/actuator/health; I checked that against a real listener on the rig. A fragment lost the path entirely.
    • Such a URL is now refused up front: --server-url "…/?tenant=acme" carries a query or a fragment, where the /actuator/health and API paths appended to it would land.
  4. no test pins printable() on the health row's JSON-parse-error path: pinned. A 200 answer whose parse error quotes ESC bytes must come out as HTTP 200, Unexpected token 'x', "x�[2K�]52;c;" is not valid JSON, on Node 22 and on Node 24.

Tests:

  • JS 67/67 on Node 22.22.2 and Node 24.14.0 (aarch64). The previous head's script fails the new cases.
  • Four more mutants, all killed, 107/107 in all: the query check dropped, the query check limited to ?, the id-less entry shown by its id, and the parse error left unsanitized.
  • On the rig, the arm with this head's script refused both --server-url shapes before probing anything. It also printed the id-less entry as {"name":"s1"}, where alpha.104 printed undefined.

🤖 Generated with Claude Code — Claude Opus 5.5

@qwen-code-review-bot qwen-code-review-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partially reviewed — gaps disclosed.

Not explored to full depth (tool budget reached): "agent reverse-audit (round 2)": did not run the API row assertions in sessionRow / turnRow to verify the same added paragraph's claims about terminal: true , event sequence advance, page d…; chunk 4: did not run the Java suites (Maven build prohibited in this shared worktree), so the two Java test files' greenness is argued from the production code paths abo…; "agent reverse-audit (round 4)": could not execute ResolvedConfigurationTest and HarnessConfigurationTest — mvn -o cannot resolve the sibling module jars from the local repo, and a full r….

Not reviewed: reverse audit — did not converge within the reverse-audit round cap of 5.

Deferred under the convergence posture (round 7, not a blocker) — recorded, not requested in this round:

  • docs/users/managed-agent-reference-deployment.md:231 — [probe] the user deployment guide omits the trusted-actor condition on verify --tenant's API read
  • packages/managed-agent-server/distribution/bin/qwen-managed-agent-upgrade.mjs:2956 — [probe] a lone-surrogate Session id turns the row into FAIL URI malformed
  • packages/managed-agent-server/distribution/bin/qwen-managed-agent-upgrade.mjs:2774 — [probe] an empty user name escapes the pre-restart Harness URL check when there is no verdict
  • docs/design/2026-10-25-managed-agent-upgrade-command.md:126 — [probe] the design docs overstate how much of a refused URL is masked
  • packages/managed-agent-server/distribution/bin/qwen-managed-agent-upgrade.mjs:3162 — [probe] the health URL reaches the rows without the new control-byte neutralizer
  • docs/design/2026-10-25-managed-agent-upgrade-command.md:126 — [probe] the connector's plaintext-remote rule is missing from the documented verdict
中文说明

仅完成部分审查,审查缺口已披露。

未探索到全部深度(达到工具调用预算):"agent reverse-audit (round 2)":did not run the API row assertions in sessionRow / turnRow to verify the same added paragraph's claims about terminal: true , event sequence advance, page d…;chunk 4:did not run the Java suites (Maven build prohibited in this shared worktree), so the two Java test files' greenness is argued from the production code paths abo…;"agent reverse-audit (round 4)":could not execute ResolvedConfigurationTest and HarnessConfigurationTest — mvn -o cannot resolve the sibling module jars from the local repo, and a full r…。

未审查:反向审计——在 5 轮的反审轮数上限内未收敛。

收敛姿态下延后(第 7 轮,非阻断)——已记录,本轮不要求修改:共 6 条(原文未翻译,列表见上方英文部分)。

— deepseek-v4.1-flash-1017 via Qwen Code /review (v0.26.7)

@yiliang114 yiliang114 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delta APPROVE from head 814b121 → 3b67b6e.

Fixed: The static import ordering in ResolvedConfigurationTest.java is now assertEquals, assertThrows, assertTrue, mock — the verification module checkstyle gate passes (Managed Agent fast tier is green at head).

Delta (3b67b6e):

  • --server-url with a query or fragment is now refused up front in listeners(), since /actuator/health and API paths are appended to it and would land in either. Tests cover ?tenant=acme, ? (query-only), and #ingress.
  • sessionRoute() now checks 'id' in session before accessing session.id, so a listed entry without an id (e.g. { name: 's1' }) is shown as its printed form instead of "undefined". Verified by the parameterized test entry [{ name: 's1' }, '{"name":"s1"}'].
  • Health text sanitization test pins control bytes through JSON.parse('x\u001b[2K\u001b]52;c;') to verify they come out as ``.
  • Design docs and deployment reference updated with the query/fragment refusal sentence.

No P0/P1 findings. APPROVE.

@qqqys qqqys left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed at head 3b67b6ec1d8c323c603287c8c7ae15ba1b061675 (base main). This supersedes my comment on 814b1210. The single Critical I filed there is verified fixed, and I found no new blocking defect.

R6-1 — the static-import order: fixed

The block I named as failing ImportOrder now reads, at this head:

28: import static org.junit.jupiter.api.Assertions.assertEquals;
29: import static org.junit.jupiter.api.Assertions.assertThrows;
30: import static org.junit.jupiter.api.Assertions.assertTrue;
31: import static org.mockito.Mockito.mock;

That satisfies the rule I traced last time — qwen-code-checks.xml sets ImportOrder with option=bottom and sortStaticImportsAlphabetically=true, and org.junit.jupiter.api.Assertions.assertThrows now precedes org.mockito.Mockito.mock instead of following it. The static block is still last. The four-link chain I verified at the previous head still governs unchanged: test sources are linted (includeTestSourceDirectory=true at plugin level in managed-agent-server/pom.xml), the runtime-broker-checkstyle execution that sets it false is scoped to runtimebroker/** and never sees this file, and CI invokes checkstyle:check directly.

I verified this by reading the file at head rather than from the fix's commit message. The SDK Java (full) tier was still running when I published, so the lane has not itself reported green on this head yet — but an ordering violation is decidable by inspection against the rule, and the order is now correct.

The rest of the new commit

3b67b6ec is a direct child of the head I reviewed, not a merge, and beyond the one-line reorder it carries two changes. I read both.

A --server-url carrying a query or fragment is now refused. The paths are appended to that URL, so http://proxy.test/?a would probe /?a/actuator/health and a fragment would swallow the appended path entirely, since fetch drops it. The guard is /[?#]/ on the option, placed after the earlier userinfo refusal — which is what makes the simple character class sound, because past that point a ? or # can only begin a real query or fragment rather than sitting inside credentials. The change is additive in the safe direction: it refuses strictly more inputs and never fewer, and no legitimate value is caught, since the only places those characters could legally appear were already refused.

sessionRoute no longer prints (undefined) for an object entry with no id. The condition gained && 'id' in session, so an entry that is an object but carries no id is shown as it came rather than as its missing property. The in operator cannot throw here because the same expression has already established the value is a non-null object. Diagnostics only — no behavioural surface.

Both close items the previous round had deferred as non-blocking probes, which is why round 7 at this head reports zero Criticals and zero Suggestions — a fully clean round on the exact commit I am approving.

Earlier Criticals

Five Criticals were filed across seven rounds: R1-1, R3-1, R4-1, R3-2 and R6-1. None carries a fixed-ruling marker on this PR, so I read the ledger progression, where a round that re-verifies carries a still-standing finding forward under its original id:

Round Head Criticals
2-3 8ee2ce3b R1-1, R3-1
4 13cd5450 R4-1 — both earlier ones gone
5 aa53b983 R3-2 — R4-1 gone
6 8529a681 R6-1 — R3-2 gone
7 3b67b6ec none — R6-1 gone

So R1-1 and R3-1 closed by round 4, R4-1 by round 5, R3-2 by round 6, and R6-1 by round 7 — the last one confirmed by my own read above rather than by the ledger alone. The maintainer who filed R6-1 as a CHANGES_REQUESTED against the previous head has approved this one.

Round 7 disclosed its own gaps, which I pass on rather than adopt: it could not execute the two Java test classes in its worktree, and its reverse-audit did not converge inside the round cap. Its deferred probe list is marked non-blocking, and two of its entries are what this commit fixed.

CI

35 checks pass and 0 fail at this head, with 7 running and 4 queued, 39 skipped. The approval promoted the head from the fast tier to SDK Java (full), so the Java lanes including the Checkstyle gate and the MySQL and RocketMQ tiers are in progress rather than complete — there is no green Checkstyle run to cite yet, and per this channel's rules I did not wait on it. Nothing red is attributable to this diff.

Scope

I read the changed Java test file's import block, the whole production delta of 3b67b6ec in the upgrade script, and re-confirmed the Checkstyle chain from the previous head still governs. I did not re-read the rest of the PR's ~700 source lines, which four clean-or-superseded rounds and the maintainer's approval cover, and I did not run the Java suites myself.

@wenshao

wenshao commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator Author

PR 16110 round 3 verification — Verdict: findings — 209/210 scripted assertions passed, 1 failed. Verified head: 3b67b6ec1d8c323c603287c8c7ae15ba1b061675 against base f217a8e5d96ae73b545d8b2e13d1a4605cadad8d. Both round-2 findings are fixed and now pinned, and the surface added since is load-bearing on real sockets. One documented rule does not hold for a falsy JSON status.

中文摘要
  • 结论:findings(210 条断言,209 过 1 失败)。本轮是复验:上一轮验证停在 a25a76d2,之后又经过第 3–8 轮评审到 3b67b6ec,生产代码改了 12 个提交(1 个 JS 脚本、2 个 Java 类、文档与测试)。
  • 上一轮三条 finding 全部修复并重新测量(见下方 “Previous findings” 表):stalled body 现在保留早先的 HTTP 503, status DOWN(prev 仍复现 abort 覆盖,head 不再);probe.timedOut 一半已有测试钉住(删掉该半的变异被头套件杀死);设计文档已改成“自身 5 秒先于截止时间用完才算”。
  • 本轮增量面在真实套接字上逐项成立:控制字节变 U+FFFD(prev 的 FAIL 行被换行拆开、ESC 原样保留);200 码点截断(prev 原样打印 201 字符);深层嵌套状态显示 [unprintable](prev 抛 Maximum call stack size exceeded);对象状态显示 JSON(prev 抛 Cannot convert object to primitive value);API 的 data 不是列表时 head 判 FAIL,而 base/prev 把 "abc" 读成 3 item(s)、把 {"length":2} 读成 2 item(s) 并报 PASS;Session id .././空串在 head 里根本不发请求,prev 被 fetch 归一化成 /v1/agents/;被拒绝的 --server-url 在 head 里密码显示 ***,prev 原样打印;带 query/fragment 的 --server-url 立即拒绝,prev 等到超时;Harness 判定按服务端的 harnessOrigin 拒绝且不重启 Harness,prev 直接放行;start 只检查它拨号的 health(API 在 6000 端口不再挡住 start),prev 会过度拒绝。
  • 唯一 finding(Suggestion):设计文档说“不是字符串的 status 显示为它的 JSON”,但 {"status":0}(以及 false、"")被真值判断吞掉,head 只打印 HTTP 200,不显示 0。实测建议修法(把真值判断改成 !== undefined && !== null)后套件 74/74、行变成 HTTP 200, status 0;现有 67 个测试在修与不修两版都绿,说明这条轴没有夹具。
  • 门禁:JS 套件 head 67/67、上一轮 head 61/61、base 58/58;Java ResolvedConfigurationTest 15/15、ManagedAgentPreflightTest 82/82、HarnessConfigurationTest 2/2(共 99),server,verification 的 checkstyle 通过;容器 Node 22.23.4 上全端口枚举 82/82 与真实 fetch 一致、双向差集为空、port 0 放行。
  • 变异:JS 21/21 被杀(含已知可杀对照),Java 2/2 被杀(含对照);两者都在独立 scratch 树上跑,行后逐字节还原并校验 sha256。
  • 未覆盖:真实 systemd 主机(本轮 rig 的 systemctl 是模拟层,套接字/时钟是真的)、macOS/Windows、Node 24(本轮只用容器 Node 22)、Spring Boot 真启动与 Hosted Harness、Managed Agent --check ignores the configuration files the server reads from its working directory #16057 跟踪的 --check 缺口、以及发布时仍在 pending 的 12 条 SDK Java 全量 lane。
Full English report

Previous findings at this head

# Round-2 finding Status at 3b67b6ec Evidence
1 Medium: a body that stalls after its headers overwrote the earlier HTTP 503, status DOWN fixed real-socket cell VP1: prev prints the last probe: HTTP 200, The operation was aborted due to timeout; head prints the last answer: HTTP 503, status DOWN. Mutant M18 (body-read timedOut) is killed by the head suite.
2 Suggestion: the probe.timedOut half of the guard was unpinned fixed mutant M19 (guard without probe.timedOut &&) is killed by start names what the endpoint answered…; the head cell VP3-then-close also shows a refused connection replacing the earlier answer.
3 Suggestion: the “own 5 seconds” branch starts at a budget the real clock rarely produces fixed (doc) the design doc now says a probe’s own 5-second limit runs out before the deadline counts, and names a refused connection as replacing the earlier answer. The exact-5000 ms unit fixture stays.

Re-measured here, not read off the previous report. The round-2 suggested patch for finding 1 is still superseded by the author’s timedOut flag, which now covers both the 1 ms last probe and the body-read case.

Two reviews arrived while this round ran, both APPROVED at the verified head and neither carrying a blocking item: yiliang114 confirmed the static-import order and the query/fragment guard, and qqqys re-read R6-1 against the rule and found it fixed, with no new Critical. Neither ran the Java suites (both say so), and neither exercises the falsy-status shape in Finding 1. Their arrival did not change any measurement here.

Central claim and A/B

The claim is unchanged: start and verify refuse every URL fetch refuses before starting a unit, and a probe that is sent and fails names what it answered. This round adds the sibling surface: endpoint text is neutralized and bounded, refused URLs keep their credentials out, the Harness verdict comes from the server, and a phase is refused only over the URL it dials.

The A/B uses the repository’s own upgrade rig (fake systemctl and resolver only; health/API servers are real loopback sockets, fetch is the runtime’s own, the clock is real). Each arm is that revision’s production file plus that revision’s test file and the same 7 appended probes. prev is the previous verified head a25a76d2, so the fix under test is the delta this round reviews; base is the PR base for the original refusal claim.

Cell Base f217a8e5 Prev a25a76d2 Head 3b67b6ec
start --timeout 2, endpoint answers 503 then stalls a 200 body no answer detail the last probe: HTTP 200, The operation was aborted due to timeout the last answer: HTTP 503, status DOWN
health status with ESC/CSI/OSC-52/newline/DEL/C1 is not UP (no detail) FAIL row is split by the newline, ESC intact one row, no control byte, U+FFFD kept
health status 201 chars no detail prints all 201 200 + … (201 characters)
health status exactly 200 astral code points, then +1 no detail prints all 201 whole at 200, cut at 201 without splitting a surrogate
health status {"toString":1} no detail throws Cannot convert object to primitive value HTTP 200, status {"toString":1}
health status nested 20 000 deep no detail throws Maximum call stack size exceeded HTTP 200, status [unprintable]
API items data: {"length":2} PASS … 2 item(s) PASS … 2 item(s) FAIL answered no data list
API items data: "abc" PASS … 3 item(s) PASS … 3 item(s) FAIL answered no data list
API items data: 1 PASS … 0 item(s) PASS … 0 item(s) FAIL answered no data list
Session id .. / . / empty requests /v1/agents/ or /sessions/ same refuses before any request
Session id {"toString":1} FAIL Cannot convert object to primitive value same FAIL the API answered a Session without a string id ({"toString":1})
Session page without data WARN … no Session same FAIL … answered no data list ([{"id":"s1"}])
--server-url http://admin:s3cr3t@… waits the timeout, prints the password refuses, still prints the password refuses with http://***@…, secret absent
--server-url …?q=1 / …#f waits the timeout waits the timeout refused at once: carries a query or a fragment
Harness harnessOrigin=false, value padded starts starts refuses, prints the value untrimmed, no Harness restart
Harness harnessOrigin=skip, user info in value starts starts starts (nothing reads it)
Harness no verdict, user info in value starts starts refuses with ***
API on port 6000, health on 18080: start starts refuses port 6000 starts (dials health only)
same, verify without --tenant 0 refuses port 6000 0
same, verify --tenant 1 (row 404) 1 (refuses port 6000) 1 (refuses port 6000)

The full cell printout is 01-ab-timeout-and-api-types.png (timeout, sanitization, API typing) and 03-ab-refusals-and-harness-verdict.png (refusals, Harness verdict, phase-scoped checks).

01-ab-timeout-and-api-types.png

03-ab-refusals-and-harness-verdict.png

The blocked-port list was re-enumerated at this head through the runtime’s own fetch inside the container (Node 22.23.4): 82 blocked, 82 refused by fetchRefusal(), symmetric difference empty in both directions, port 0 dialled by fetch and allowed. 17.7 s, never dials a blocked port.

Mutation matrix

23 single-point mutants, all killed. The JS rows rewrite one production expression at a time in a separate scratch tree, run the unmodified 67-test head suite, and restore the pristine bytes (checked by sha256) after every row; the unmutated baseline ran 67/67 first. The Java rows do the same for ResolvedConfigurationTest (15 tests), restoring ManagedAgentPreflight.java to ed7f560a… after each. M21 and J2 are the known-killed positive controls.

Row Guard Pinning test
M1 printable drops DEL/C1 verify says why an API read failed…
M2 the 200-code-point bound health reports neutralize terminal control bytes…
M3 the … (N characters) suffix same
M4 JSON.stringify for non-string values same
M5 the [unprintable] catch same
M6 user-name masking refuses only the URLs fetch refuses
M7 the textual ***@ fallback start refuses listeners it cannot reach…
M8 the query/fragment refusal same
M9 data must be a list verify says why an API read failed…
M10 Session id must be a string same
M11 empty/.. id names no route same
M12 the request label is bounded same
M13 unreadable-body text is bounded same
M14 API reason is bounded same
M15 the cause fallback start names what the endpoint answered…
M16 harnessOrigin === 'false' start refuses listeners it cannot reach…
M17 skip asks nothing more start asks nothing of a Harness URL the server does not read
M18 body-read timedOut start names what the endpoint answered…
M19 the probe.timedOut half of the guard same
M20 the status detail is bounded verify sanitizes a malicious health body over a real socket
M21 (control) blocked-port clause deleted refuses only the URLs fetch refuses
J1 harnessUrlVerdict always "true" ResolvedConfigurationTest (3 failures)
J2 (control) the user-info clause deleted ResolvedConfigurationTest

The matrix as it printed is 02-mutation-matrix-js.png; the Java rows and the 99-test run are 04-java-tests-and-mutants.png.

02-mutation-matrix-js.png

04-java-tests-and-mutants.png

The matrix is per-guard, not per-commit. This round does not claim per-commit coverage: the 12 production commits since a25a76d2 map to the rows above (80d7e70e3d → M18/M19, d8e6c1bb5f → M1/M4, 0d44ff8455 → M6/M7/M13/M14/M15, 8ee2ce3b26 → M4/M5, 13cd545086 → M2/M3/M9–M12/M20, c80d768a42/3a556b9ab5 → M16/M17, 9b8a548e3c → M9, 948e7484b5 → M16/M17, 3b67b6ec1d → M8), but the Java halves of c80d768a42, e51f95f2e2, 3a556b9ab5, 9b8a548e3c and the Java test change in 3b67b6ec1d are covered only by the two Java rows and the 99-test run, not one row per commit. 5c18f44efa is test-only.

Findings

Finding 1 — Suggestion: a falsy JSON status is not shown as its JSON, as the new doc says

Reproduce with the head arm probe (a fake health endpoint answering {"status":0}):

docker exec -w /work/arms/head -e VERIFY_ARM=head pr16110-verify \
  node --test --test-name-pattern 'VP7' scripts/tests/probe.test.mjs

The assertion fails with:

expected: 'FAIL http://127.0.0.1:18080/actuator/health is not UP: HTTP 200, status 0'
actual:   'FAIL http://127.0.0.1:18080/actuator/health is not UP: HTTP 200'

The same happens for false and ""; null also prints bare HTTP 200. The design doc added by this PR says “A value that is no string is shown as its JSON, or as [unprintable] when it is nested too deep to write out.” The truthiness test in health() (head lines 2728–2734) runs before printable(), so 0, false and "" never reach it. Spring answers UP/DOWN strings, so this is a precision issue in the documented rule rather than a production failure; a proxy or a non-Spring endpoint can answer any JSON.

Suggested fix (measured)
-        answer: body?.status
+        answer:
+          body?.status !== undefined && body?.status !== null
             ? `${status}, status ${printable(body.status)}`
             : status,

Applied in a scratch copy: the head suite plus the 7 probes runs 74/74, and the four rows become HTTP 200, status 0, HTTP 200, status false, HTTP 200, status and HTTP 200 for null. The 67-test suite is green with and without the patch, so no existing fixture pins this axis; the new probe is the fixture that would.

05-falsy-status-before-and-after-fix.png

Not covered

  • Real systemd hosts. The rig’s systemctl and the resolver are simulated layers; the health/API sockets, fetch, DNS/connect errors and clock are real. The PR body reports rounds 4–7 on a real systemd host with MySQL 8.4.6, nginx and a scripted model; this round did not repeat that.
  • macOS and Windows, as before.
  • Node 24. This round ran everything on the container’s Node 22.23.4 (matching CI’s Node 22 lane); the earlier round’s Node 24 run is not repeated here.
  • A booted Spring control plane / Hosted Harness. The Java tests run in-process; this round did not start the server, MySQL, or the hosted harness end to end.
  • --check’s Flyway scan, tracked in Managed Agent --check ignores the configuration files the server reads from its working directory #16057 and explicitly out of scope.
  • CI lanes. 34 checks succeeded and 39 skipped at the time of the round; the SDK Java (full) lane had 7 checks in progress and 5 queued (including the Java 11/17 matrix, Real daemon E2E, RocketMQ and MySQL gates). Those results are not in this report.
  • Event sequence ordering. VP7 shows a non-numeric sequence does not stop a terminal: true event from ending the turn, which matches the doc (“moves the read on only as a whole number”); the forward-only polling behaviour itself was not independently driven beyond that.

Methodology

The round ran inside a credential-free node:22-bookworm container (--network none, env carries 8 variables, no host credentials; scripts/verify-pr-prepare.mjs --require-isolation returns 0). Three detached worktrees at f217a8e5, a25a76d2 and 3b67b6ec supplied the arms; each arm is that revision’s production file and test file plus the same appended probes. Probes drive the real start/verify phases through the repository’s own rig (only systemctl/resolver are stand-ins) with real loopback HTTP servers; all seven assert the outcome their arm is expected to produce. The mutation runner rewrites exact anchors in a separate mut-tree, asserts the anchor matched once, runs the unmutated baseline first, and restores pristine bytes with a sha256 check after each row. Java ran offline from a private copy of the Maven repository with the repository’s own SDK installed, -pl verification -am, JDK 21; checkstyle ran on server,verification. Raw logs, harnesses and mutations.json are in tmp/pr16110-verify-20261105-011747/ (logs/, harness/).

— DeepSeek-V4.1-Flash-1017@fda99a87 via Qwen Code /verify-pr (v0.26.6; skill c5273cc80df5)

@wenshao
wenshao merged commit 9123d5e into main Nov 4, 2026
157 of 159 checks passed
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Managed Agent gate failed

Run 41876771700 · commit 3b67b6ec1d8c

Failing tests

  • com.alibaba.qwen.code.managedagent.HostedCleanupRetentionMySqlIT.cleanupAdmissionConflictIsReturnedOverHttpOnMySql
  • com.alibaba.qwen.code.managedagent.HostedAutomationFaultGatesIT.fg11bHarnessStoreFaultsNeverRunTwiceOnMySql
  • com.alibaba.qwen.code.managedagent.ManagedContextCompressionMySqlIT.unknownAcceptanceIsDurableAndAStaleClaimCannotSettleIt

Tracking issue

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Managed Agent gate failed

Run 41877542655 · commit 3b67b6ec1d8c

Failing tests

  • com.alibaba.qwen.code.managedagent.HostedCleanupRetentionMySqlIT.cleanupAdmissionConflictIsReturnedOverHttpOnMySql

Tracking issue

@wenshao

wenshao commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator Author

The items that arrived after this PR settled are followed up in #16352.

Verification round 3, Finding 1. A falsy JSON status was shown as a bare HTTP 200. This is fixed as the report measured it:

  • 0, false and "" now show. "" shows as its JSON, so the row does not end in a bare "status".
  • null, like a missing status, still names nothing.

Bot round 7, deferred probes.

Probe In #16352
A lone-surrogate Session id gives FAIL URI malformed Fixed: the row names the id it cannot route.
An empty user name escapes the pre-restart Harness check without a verdict Fixed. java.net.URI reads user information "" and ":" in http://@host and http://:@host, so the connector refuses them, and start now does too, before the Harness restarts. With a verdict, the refusal now gives that reason instead of the generic one.
The design docs overstate how much of a refused URL is masked This turned out to be a leak, not only wording; details below.
The health URL skips the control-byte neutralizer Fixed: all five places that print a URL go through printable().
The user guide omits the trusted-actor condition on verify --tenant's API read Added.
The verdict leaves out the connector's plaintext-remote rule Still open, and not taken in #16352. It is a design choice between copying BrokerSecurity's rule into the verdict and exposing checkHarnessTransport as a second key.

On the masking probe: a password that starts with digits and holds a /, ? or # parses as a port. For example, http://svc:2024#Secret@harness:4170 reads as port 2024 to both the URL parser and java.net.URI. The Harness refusal and the --server-url query refusal both printed such a value whole. Masking now hides everything up to the last @.

#16352 has an A/B on the systemd rig against main for each of these. Its suite passes 68/68 on Node 22 and Node 24, and all 17 mutants are killed.

Managed Agent gate failures. The full-tier failures posted here after the merge, HostedCleanupRetentionMySqlIT and the others, do not come from this diff. cleanupAdmissionConflictIsReturnedOverHttpOnMySql has failed in 14 runs across unrelated PRs since 11-03; see #14724.


🤖 Generated with Claude Code — Claude Opus 5.5

@wenshao
wenshao deleted the fix/managed-agent-upgrade-url-scheme branch November 5, 2026 01:02
@qwen-code-review-bot

Copy link
Copy Markdown
Collaborator

Released in v0.26.8.

yiliang114 pushed a commit that referenced this pull request Nov 7, 2026
…ess user info in the upgrade command (#16352)

* fix(managed-agent): mask digit-led passwords and refuse an empty Harness user info

Follow-ups to the review items deferred on #16110 and #16175:

- A refusal hides everything up to a URL's last @, also when the URL
  parses: a password that starts with digits and holds a / ? or # reads
  as a port to both the URL parser and java.net.URI, so
  http://svc:2024#Secret@harness:4170 printed whole. The --server-url
  query refusal masks too.
- Without the server's verdict, start refuses an @ before the Harness
  host (http://@host, http://:@host), which java.net.URI reads as user
  information and the connector refuses, instead of restarting the
  Harness for it.
- The health row and start show a status of 0, false or "" instead of
  dropping it, and print the URLs they dial through the control-byte
  neutralizer.
- A Session id with a lone surrogate fails its row by name instead of
  "URI malformed".
- The Flyway reader test covers a path two modules both ship; the user
  guide names verify --tenant's --actor condition, and the design docs
  state the masking, status and id rules as applied.

* fix(managed-agent): neutralize the DEL and C1 bytes a quoted value keeps

JSON.stringify escapes C0 controls but not DEL or C1 bytes, so a refused
URL or a Session id the verify row echoes could carry U+009B, an 8-bit
CSI introducer, to the terminal, and the id was not bounded. The four
refusals that quote a URL and the id row now go through printable()
after JSON.stringify: C0 controls keep their escapes, DEL and C1 bytes
show as U+FFFD, and the quoted text stops at 200 code points.

* fix(managed-agent): print no password a --server-url carries, and stop predicting java.net.URI

Review round 2 on #16352.

- A --server-url with an @ left after the URL parser reads no user
  information is refused: it is the rest of a password that starts with
  digits, which the parser reads as a host and a port, so the phase would
  dial the wrong host and print the password. check judges --server-url
  the same way, since its plan repeats it.
- start's three outcomes and verify's health row print every URL with its
  user information masked.
- With the server's verdict false, the refusal names a reason only where
  the value shows one the server gives too: a user name or password, a
  query or a fragment, or an @ in an authority after //.
- Without a verdict, start takes only a plain http(s) URL, a rule of its
  own and narrower than the server's, instead of modelling how
  java.net.URI reads user information: http:/@host, a backslash, a tab,
  an underscore or a space no longer reach the Harness restart, and an @
  in a path still does.
- The design record and the deployment guide say so.

* fix(managed-agent): correct upgrade URL guards and plan output

* fix(managed-agent): keep refusing an @ in --server-url, and spell plan words

affe6c5 dropped the refusal of a --server-url with an @ left after
the URL parser read no user information, to let a path hold one. That
is the shape of a password that starts with digits: for
https://svc:12/s3cret@cp.example.com the parser reads host svc and port
12, so start and verify dialled svc with the password in the path. The
refusal is back; an @ a path holds is written %40, which the docs now
say, and a test pins a proxy prefix spelled that way.

The plan printed --server-url through shown(), which turns a control
character into U+FFFD and masks the text before an @, so the printed
command was not the one to run. check refuses such a value before the
plan, and shellWord now spells any control character in any plan word
as the escapes of its UTF-8 bytes inside $'...', which bash reads back
to the value, instead of leaving it raw inside quotes.

The Harness rule start applies without the server's verdict follows
java.net.URI's host grammar: no empty label, no label that ends in a
hyphen, a last label that starts with a letter, a dotted-quad IPv4
address, and an IPv6 address of the standard forms. A differential run
of 2,000,000 generated URLs found none the rule takes that
java.net.URI refuses.

The usage line says what check does with --server-url without
suggesting it dials it.

* fix(managed-agent): accept trailing-dot Harness hostnames

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* fix(managed-agent): take the IPv6 Harness hosts that end in IPv4 when the configuration does not resolve

The plain-URL rule start falls back to refused an IPv6 address that ends in
an IPv4 one, such as http://[::ffff:127.0.0.1]:4170, which the server's
Harness connector accepts, so the same Harness URL was refused while the
configuration did not resolve and taken once it did; the previous commit
took the final dot of a fully qualified name for the same reason. The rule
stays narrower than java.net.URI's, never wider: it still refuses a one-label
name that starts with a digit and an octet with a leading zero, which the URL
parser fetch uses reads as another address, and an empty port.

The refusal of an @ in --server-url now names its remedy, %40, as its sibling
refusals do, and the comment that describes quoted() sits above it.

* fix(managed-agent): tighten upgrade URL and plan handling

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* fix(managed-agent): harden upgrade rows and Harness URL checks

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* fix(managed-agent): take the digit-led Harness hosts fetch reads alike, and refuse an empty --server-url

The no-verdict Harness rule refused a one-label name that starts with a
digit, such as a container's 4harness, which java.net.URI and fetch both
read as that host. It now refuses only what the URL parser fetch uses
reads as another address: a one-label number, in decimal or 0x hex, and
an octet with a leading zero. The last label of a longer name still
starts with a letter, as java.net.URI requires, so harness.1b stays
refused, and an empty port is taken. The refusal says what the rule
needs instead of "a host and port with a path".

check, start and verify test whether --server-url was given rather than
whether it is truthy, so the empty value an unset variable leaves is
refused instead of printed into the plan and then ignored.

A plan's control bytes are written as three-digit octal escapes inside
$'...', which bash, zsh and ksh all read back; ksh read a \x escape on
through a hex digit after it.

---------

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.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.

5 participants