Skip to content

refactor(daemon): keep the request router under the line cap - #5001

Merged
thymikee merged 1 commit into
0.22from
fix/0.22-request-router-line-cap
Nov 23, 2026
Merged

thymikee merged 1 commit into
0.22from
fix/0.22-request-router-line-cap

Conversation

@thymikee

@thymikee thymikee commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Summary

packages/daemon/src/server/request-router.ts sits at 998 lines against the 1000-line max-lines cap, so the next small PR to the router re-trips pnpm lint.

The router's error half — repairExpiredIfTombstoned, idleExpiredIfTombstoned, and the enrichDaemonError retriable graft — moves to request-finalization.ts, the module that already owns the reply a request leaves with (finalizeDaemonResponse). Same final-answer decisions, one owner. The move is verbatim: only those three functions gain export; no behavior, wire shape, or error text changes. packages/daemon-client/src/daemon-client-lifecycle.ts updates its cross-package pointer to the new home.

request-finalization.ts is already in the eager closure of both entries that reach the router (packages/daemon/src/index.ts, src/daemon.ts), so no new eager module is introduced — the ADR-0019 eager-closure gate is untouched, and no max-lines waiver is added.

Value

  • request-router.ts: 998 -> 889 lines (cap 1000; 111 lines of headroom)
  • request-finalization.ts: 216 -> 331 lines
  • Eager closure of the two reaching entries: 362 and 363 modules, 4962 and 4967 top-level statements — identical at base and head

Validation

Head de71c28bd9, base origin/0.22 (e02e1f7dc2). pnpm check:affected --run --base origin/0.22 --head HEAD: all selected runnable checks passed (format, lint, typecheck, layering, fallow, build, vitest-related, unit). The eager-closure budgets suite passes standalone (955 tests), as do the 1164 tests under packages/daemon/src/server. CI obligations: the 0.22 Lint and Typecheck lanes. No device-facing dispatch, capture, or lifecycle code changed, so no device run applies.

@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Size Report

Metric Base Current Diff
Installed (including dependencies) 5.02 MB 5.02 MB -928 B
Package (unpacked) 5.02 MB 5.02 MB -928 B
Package (download) 1.53 MB 1.53 MB -287 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 54.7 ms 66.4 ms +11.7 ms
CLI --help 73.4 ms 96.8 ms +23.4 ms

@apex-sentinel-staging

This comment has been minimized.

@thymikee

Copy link
Copy Markdown
Member Author

This PR is ready at cb138bc: the review found no problems in the code. CI shows only two cancelled Body rules jobs, which check the PR body and not code, and the diff does not overlap them, so please re-run them before merge. There are no conflicts. Not verified here: lint, typecheck and tests were not re-run locally; this relies on the reported check:affected run and the green CI lanes. Not blocking, take or leave: request-finalization.ts:252 builds the same commit-failure teardown message and replay guidance as surfaceUnrecoveredRepairCommitFailure in packages/daemon-client/src/daemon-client-lifecycle.ts, so the common message builder could move into packages/daemon-contracts/src/session-repair-tombstone.ts, with each caller keeping its own session label, evidence lookup and error metadata.

The router's error half — the repair and idle-expiry tombstone answers and the
typed-signal graft — now lives in `request-finalization.ts`, the module that
already owns the reply a request leaves with. The moved code is verbatim; only
the three router-facing helpers gained `export`.

`request-finalization.ts` is already in the eager closure of every entry that
reaches the router, so the split loads no new module anywhere, and the file's
top-level statement weight is unchanged.
@thymikee
thymikee force-pushed the fix/0.22-request-router-line-cap branch from cb138bc to de71c28 Compare November 23, 2026 10:42
@apex-sentinel-staging

Copy link
Copy Markdown

Apex Sentinel · ✅ Approve · review of de71c28

Since the review of cb138bc: 0 new · 0 still open · 0 no longer raised

No open findings.

Reviewed with this repository's own Sentinel configuration (65ba7bb4c228).

💬 Talking to Sentinel

In a finding's thread, reply with:

Command What it does
@apex-sentinel-staging note <context> Adds context; Sentinel re-checks the cited code
@apex-sentinel-staging pivot <why> Says the finding is wrong; Sentinel re-checks the cited code
@apex-sentinel-staging like Marks the finding as useful
@apex-sentinel-staging dislike <why> Marks it as not useful, so it is not raised again

On this conversation, comment @apex-sentinel-staging review to run a full review once again.

@thymikee

Copy link
Copy Markdown
Member Author

The change at de71c28 is clean. The request router now stays under the line cap, and the earlier review of cb138bc found no problems; nothing from that review remains open.

The Smoke Tests failure looks unrelated to this PR. The log excerpt shows it failing in the Install Linux desktop dependencies step (apt-get), before any repository code runs, and this diff only touches daemon request finalization and a comment. Body rules was cancelled and checks the PR body, not code. Not verified here: lint, typecheck and tests were not run locally, and the Smoke Tests attribution comes from that install-step excerpt alone. Re-run the cancelled Body rules and Smoke Tests jobs before merge.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 23, 2026
@thymikee

Copy link
Copy Markdown
Member Author

Merging with only Linux Smoke Tests failing, on apt-get update did not finish within 30s on 3 attempts. This runner outage has hit every branch since about 10:14 UTC. All other checks pass, and Sentinel approves.

@thymikee
thymikee merged commit abada92 into 0.22 Nov 23, 2026
16 of 18 checks passed
@thymikee
thymikee deleted the fix/0.22-request-router-line-cap branch November 23, 2026 11:19
hannojg pushed a commit to hannojg/agent-device that referenced this pull request Nov 23, 2026
…ck#5001)

The router's error half — the repair and idle-expiry tombstone answers and the
typed-signal graft — now lives in `request-finalization.ts`, the module that
already owns the reply a request leaves with. The moved code is verbatim; only
the three router-facing helpers gained `export`.

`request-finalization.ts` is already in the eager closure of every entry that
reaches the router, so the split loads no new module anywhere, and the file's
top-level statement weight is unchanged.
thymikee added a commit that referenced this pull request Nov 24, 2026
The router's error half — the repair and idle-expiry tombstone answers and the
typed-signal graft — now lives in `request-finalization.ts`, the module that
already owns the reply a request leaves with. The moved code is verbatim; only
the three router-facing helpers gained `export`.

`request-finalization.ts` is already in the eager closure of every entry that
reaches the router, so the split loads no new module anywhere, and the file's
top-level statement weight is unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant