Skip to content

chore(runtime): split date.rs under the 2000-line CI cap#4925

Merged
proggeramlug merged 1 commit into
mainfrom
chore/split-date-rs
Jun 10, 2026
Merged

chore(runtime): split date.rs under the 2000-line CI cap#4925
proggeramlug merged 1 commit into
mainfrom
chore/split-date-rs

Conversation

@proggeramlug

Copy link
Copy Markdown
Contributor

What

Brings crates/perry-runtime/src/date.rs back under the 2000-line CI cap by extracting the date-string parsing code into a sibling submodule.

Why

date.rs had grown to 2008 lines (pushed over by the Temporal tail in #4923), tripping scripts/check_file_size.sh and failing the required lint gate on every open PR — the file-size check runs against each PR's merge with current main, so this blocks the whole queue, not just one PR.

How

Extracted the date-string parsing cluster — parse_date_string + its per-grammar helpers (parse_iso8601, parse_rfc_or_named, parse_tz_offset, normalize_millis, month_from_name, FULL_MONTHS) — into a new crates/perry-runtime/src/date/parse.rs. Rust 2018 keeps date.rs alongside date/parse.rs (no rename to mod.rs).

  • date.rs declares mod parse; and re-exports the single entry point with use parse::parse_date_string;.
  • The per-grammar helpers stay private to the submodule (nothing else in the crate calls them — verified crate-wide).
  • Shared time math (make_utc_ms, time_clip, timestamp_to_local_components) stays in the parent and is reached via super:: — a child module can see its ancestor's private items, so no visibility was widened beyond parse_date_string.

Pure code movement, no behavior change. date.rs 2008 → 1675 lines; date/parse.rs 347.

Testing

  • Builds clean; cargo fmt -p perry-runtime --check clean.
  • All date:: tests pass except test_full_year_setters_revive_invalid_date_only, which is pre-existing and timezone-dependent (it asserts local hours == 0 after a local setFullYear). It fails identically on clean main on a non-UTC host (verified locally on UTC+1); CI runs in UTC and passes it. Not introduced by this PR.

Note

Unblocks the lint gate for all open PRs (e.g. #4897). Tiny follow-up date/ split candidates remain (formatting helpers, the setter rebuild logic) if we want more headroom later.

date.rs grew to 2008 lines (pushed over by the Temporal tail in #4923), tripping
scripts/check_file_size.sh and failing the required lint gate on every open PR
(the check runs against each PR's merge with current main).

Extract the date-string parsing cluster - parse_date_string + its per-grammar
helpers (parse_iso8601, parse_rfc_or_named, parse_tz_offset, normalize_millis,
month_from_name, FULL_MONTHS) - into a new crates/perry-runtime/src/date/parse.rs
submodule (Rust 2018 keeps date.rs alongside date/parse.rs, no rename). date.rs
declares `mod parse;` and re-exports the single entry point via
`use parse::parse_date_string;`; the per-grammar helpers stay private to the
submodule. Shared time math (make_utc_ms, time_clip,
timestamp_to_local_components) stays in the parent and is reached via super::
(a child module can see its ancestor's private items, so no visibility was
widened beyond parse_date_string).

Pure code movement, no behavior change. date.rs 2008 -> 1675 lines,
date/parse.rs 347. fmt clean; all date tests pass except the pre-existing
test_full_year_setters_revive_invalid_date_only, which is timezone-dependent
(asserts local hours == 0 after a local setFullYear) and fails identically on
clean main on a non-UTC host - CI runs UTC and passes it.
@proggeramlug proggeramlug merged commit fceca46 into main Jun 10, 2026
12 of 13 checks passed
@proggeramlug proggeramlug deleted the chore/split-date-rs branch June 10, 2026 14:25
proggeramlug pushed a commit that referenced this pull request Jun 10, 2026
…ine CI cap

#4930 (regex d flag) pushed regex.rs to 2260 lines, tripping the lint
job's file-size gate on every PR merged after it. Extract the match-
result array decoration group (index/input/groups/indices builders for
both the regex-crate fast path and the fancy_regex fallback, plus the
char/byte index converters) into regex/exec_array.rs — same recipe as
the date.rs split (#4925). No behavior change; d-flag output verified
byte-identical with Node post-split.
proggeramlug added a commit that referenced this pull request Jun 10, 2026
…nstructable via new (#4904) (#4936)

* fix(http): make Agent/ClientRequest/IncomingMessage/ServerResponse constructable via new (#4904)

Node exposes http.Agent, http.ClientRequest, http.IncomingMessage, and
http.ServerResponse as constructable classes; under Perry, new-ing them
threw 'TypeError: <X> is not a constructor' through every value-aliasing
path (const { Agent } = require('http'), require('_http_agent').Agent,
const CR = http.ClientRequest, new http.IncomingMessage(), ...).

Mechanism (mirrors the existing OutgoingMessage route end-to-end):

- runtime/native_module: export the four classes (plus the previously
  missing http.get / http.request twins of the https entries) as bound
  callable values with Node .length arities.
- runtime/class_registry: extend the http construct arm so
  js_new_function_construct forwards (module, class, args) through
  JS_NATIVE_HTTP_DISPATCH; forward the real module name so https.Agent
  constructs with the https protocol default.
- stdlib/dispatch: constructor arms — Agent -> js_http_agent_new,
  ClientRequest -> new js_http_client_request_standalone_new,
  IncomingMessage/ServerResponse -> new standalone factories in
  perry-ext-http-server; plus get/request value-call arms.
- HIR: member-form new http.{ClientRequest,IncomingMessage,
  ServerResponse}() joins the OutgoingMessage NewDynamic route;
  bare-ident forms (destructured imports) added for all four classes;
  the three handle-backed classes are skip-listed from typed
  native-instance registration so instances dispatch dynamically.
- cjs_wrap: require('_http_agent') (and the other _http_* internal
  modules) binds its hoisted import to the public 'http' surface.

Instance surface (perry-ext-http-server):
- IncomingMessage: standalone constructor storing the socket argument;
  socket/connection get/set aliasing (Node's connection accessor writes
  this.socket); _addHeaderLine with Node's matchKnownFields semantics
  (first-wins singles, ', '/'; ' joins, set-cookie array).
- ServerResponse: standalone constructor (req.method captured; HEAD
  suppresses the body), assignSocket/detachSocket with
  ERR_HTTP_SOCKET_ASSIGNED on double assignment, write(chunk, cb)
  callback queueing, end() flushing head+body through the assigned
  socket's JS write method (one corked write + the zero-length finish
  chunk), write/end callbacks invoked in order.
- Agent: dynamic property reads (maxSockets, freeSockets, protocol, ...)
  and writes (tunables + createConnection/createSocket monkeypatching)
  through handle dispatch in both perry-stdlib and perry-ext-http.

Also fixes a latent SIGSEGV: json/stringify's is_closure_value probed
CLOSURE_MAGIC at offset 12 of POINTER_TAG payloads without the handle-
band guard (same #2154 bug class as the sibling probe in the file), so
JSON.stringify of { agent, lookup: () => {} } dereferenced unmapped low
memory. Route through addr_class::is_handle_band first.

Node corpus (test/parallel, pinned v22): 7 of the 13 tests in #4904 now
pass outright (client-defaults, agent-timeout-option,
client-timeout-option-with-agent, incoming-message-connection-setter,
incoming-message-destroy, outgoing-message-write-callback,
server-response-standalone); the other 6 construct and run to their
assertions, failing on deeper Agent pool emulation (sockets/freeSockets
per-key arrays, real createConnection sockets) and a pre-existing
deepStrictEqual divergence, tracked separately.

Closes #4904. Part of #2132.

* chore: cargo fmt — regex.rs long call from #4930 landed unformatted

* chore(runtime): split regex.rs exec-array decoration under the 2000-line CI cap

#4930 (regex d flag) pushed regex.rs to 2260 lines, tripping the lint
job's file-size gate on every PR merged after it. Extract the match-
result array decoration group (index/input/groups/indices builders for
both the regex-crate fast path and the fancy_regex fallback, plus the
char/byte index converters) into regex/exec_array.rs — same recipe as
the date.rs split (#4925). No behavior change; d-flag output verified
byte-identical with Node post-split.

---------

Co-authored-by: Ralph Küpper <ralph@skelpo.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant