Skip to content

Quality round: 12 Sonar rules, EventEmitter rationale, and engine-parity host polish - #88

Merged
acn-ericlaw merged 15 commits into
mainfrom
chore/quality-polish
Aug 24, 2026
Merged

acn-ericlaw merged 15 commits into
mainfrom
chore/quality-polish

Conversation

@acn-ericlaw

Copy link
Copy Markdown
Contributor

What

The screenshot-driven code-quality round (the node twin of mercury-python PR #16),
plus the engine-parity loose ends, in 17 commits — suite green after every one:

Quality (12 SonarQube rules, each swept repo-wide, not just the flagged line):

  • S2933 readonly on construction-only fields (Mailbox, EventBus, registry, config)
  • S7773 Number.parseInt over the global (cli, server)
  • S6606 ??=, S6582 optional chain, S6594 RegExp.exec (config + log twin)
  • S6551 no default Object stringification — one shared asText exported from the
    codec module (primitives via String with positive typeof narrowing — negating
    typeof on unknown widens to {} and re-admits objects; structures via JSON);
    demo now validates text as a string (non-string → teaching 400)
  • S3776 cognitive complexity: fromMap 23 and checkServices 20 → helper extraction
  • S7722 the call-site stack probe's Error carries a message
  • S8786 the call-site regex was polynomial even after de-ambiguation — replaced with a
    right-to-left lastIndexOf parse, strictly linear
  • S6571 Handler returns honest unknown (the union was absorbed by it)
  • S7785 cli.ts uses top-level await; error exits re-verified as 1
  • S9073 composite test assertions split so failures name their condition
  • tsconfig pins "types": ["node"] for deterministic editor resolution

Design record: bus.ts's header now explains why the Mailbox is hand-built rather
than EventEmitter (anycast work queue vs broadcast notifier; the handle-free lifecycle
argument) — the maintainer-review rationale, pinned where the next reader will ask.

Engine-parity host polish (signatures extracted from the Java engine):
GET / serves the engines' minimal index page (embedded, no static file service);
actuator JSON is pretty-printed (SimpleMapper's default presentation); unknown paths
and non-GET methods answer {"status": 404, "message": "Resource not found", "type": "error"} (SimpleHttpUtility signature); all json/text/html responses carry
; charset=utf-8, matching the python twin. LICENSE copyright years refreshed.

Why

The wrapper should read like textbook TypeScript before publication, and operations
teams should not be able to tell a Node.js function host from an engine by its HTTP
presentation — page, rendering, and error signature included.

Verification

51/51 (tsc + node --test) after every commit, including new pins for the index
page, error shape (GET-unknown and POST-on-known), pretty rendering, and content
types. Live demo drives for everything the compiled suite cannot see: CLI top-level
await boot, error exit codes, demo string validation, and the full content-type map —
byte-symmetric with the python twin.

Co-Authored-By: Claude Code noreply@anthropic.com

🤖 Generated with Claude Code

acn-ericlaw and others added 15 commits August 23, 2026 19:48
Co-Authored-By: Claude Code <noreply@anthropic.com>
…tion

Co-Authored-By: Claude Code <noreply@anthropic.com>
Mailbox.items/waiters, EventBus.mailboxes, FunctionRegistry.services -
all mutated in place, never reassigned.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
…o default Object stringification

S2933 (overrides readonly), S6582 (!key?.trim()), S6606 (instance ??=),
S6594 (hoisted WHOLE_REF.exec; same-rule twin fixed in log.ts callSite),
S6551 x2 (asText helper: primitives via String, structures via JSON -
aligns with the python twin's str() rendering better than
'[object Object]').

Co-Authored-By: Claude Code <noreply@anthropic.com>
…est wire-text rendering (S6551)

copyStringFields/copyNumericFields extraction takes fromMap from 23 to
well under 15; asText (primitives via String, structures via JSON)
replaces default Object stringification for the wire id and string-map
values - golden vectors green.

Co-Authored-By: Claude Code <noreply@anthropic.com>
…ime CALL_SITE regex (S8786)

Excluding ':' from the name class removes the ambiguity that let the
lazy quantifier backtrack super-linearly.

Co-Authored-By: Claude Code <noreply@anthropic.com>
… absorbed by it

The teaching (body | EventEnvelope | promise of either) moves to the
type's doc comment; the bus awaits and instanceof-discriminates anyway.

Co-Authored-By: Claude Code <noreply@anthropic.com>
…their condition

Co-Authored-By: Claude Code <noreply@anthropic.com>
…Object stringification

Co-Authored-By: Claude Code <noreply@anthropic.com>
…near call-site parse

- actuator S3776: checkServices 20 -> per-route checkService extraction
- actuator/config/envelope S6551: one hardened asText (object -> JSON,
  function -> toString, primitives -> String), exported from the codec
  module; config's local copy removed
- cli S7785: top-level await replaces the then/catch chain (ESM, node>=20)
- log S8786 (round 2): the scanning regex was still polynomial on
  non-matching input; callSite now parses right-to-left with lastIndexOf -
  strictly linear

Co-Authored-By: Claude Code <noreply@anthropic.com>
…on on unknown widens to {}

Behavior identical for every input class (string/number/bigint/boolean/
symbol via String, function via toString, object/null via JSON,
undefined literal).

Co-Authored-By: Claude Code <noreply@anthropic.com>
…mitter

Anycast work queue vs broadcast notifier - the design rationale from the
maintainer review, pinned where the next reader will ask.

Co-Authored-By: Claude Code <noreply@anthropic.com>
…or shape

GET / serves the engines' minimal index page (embedded, no static file
service by design); actuator JSON responses are pretty-printed (the
engines' default SimpleMapper presentation); unknown paths and non-GET
methods answer the engines' SimpleHttpUtility error shape
{status, message, type: 'error'} with 'Resource not found'.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Eric's ruling: explicit charset on json/text/html actuator responses;
octet-stream (envelope wire) unchanged.

Co-Authored-By: Claude Code <noreply@anthropic.com>
@acn-ericlaw
acn-ericlaw merged commit 2a0d8f8 into main Aug 24, 2026
2 checks passed
@acn-ericlaw
acn-ericlaw deleted the chore/quality-polish branch August 24, 2026 02:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant