Repository navigation
Keep gateway lifecycle loaders stable across rebuilds - #73964
pashpashpash wants to merge 4 commits into
Conversation
Greptile SummaryThis PR bundles two distinct changes: it promotes a set of first-hop gateway lifecycle modules to explicit Both changes are well-tested. The Confidence Score: 4/5Safe to merge; no bugs found. The PR title describes only one of the two features introduced. No P0 or P1 issues found. The routing logic, owner-key matching, and sort comparator are all correct and backed by comprehensive tests. The score stops at 4 rather than 5 because the PR title only describes the tsdown change, while the majority of the diff implements a separate private-routing feature for sensitive commands. No files require special attention for correctness; src/auto-reply/reply/commands-private-route.ts is the most complex new code but is thoroughly exercised by the accompanying test file. Reviews (1): Last reviewed commit: "Stabilize gateway lifecycle lazy boundar..." | Re-trigger Greptile |
steipete
left a comment
There was a problem hiding this comment.
Thanks for jumping on this. I found two things I think should be fixed before merge.
- Slack cross-surface private routing will drop valid owners.
commands-private-route.ts builds candidate owner keys from the returned route target. Slack's native approver resolver maps an approver to to: "user:<id>", but the new key builder only adds user:<id>, user:user:<id>, and slack:user:<id>. That means an owner allow entry like slack:U123, which is the natural/documented Slack form, does not match and the route is filtered out.
Relevant paths:
src/auto-reply/reply/commands-private-route.ts:144extensions/slack/src/approval-native.ts:159
I think this needs normalization that understands kind:id targets before applying the channel prefix, or at least adds slack:<id> when channel === "slack" && to.startsWith("user:"). Please add a regression test for a Discord-origin private command routing to a Slack owner configured as slack:U....
- The lifecycle stable-entry list still misses
config/configon the restart path.
buildGatewayLifecycleLazyEntries() adds several first-hop lazy imports, but src/cli/gateway-cli/run-loop.ts still calls loadRuntimeConfigModule() during signal/restart handling to read gateway.reload.deferralTimeoutMs. That import is ../../config/config.js, and it is not in the new stable lifecycle entries. After a rebuild, a running gateway can still hit this lazy boundary while processing restart/shutdown and land back on a deleted hashed chunk.
Relevant paths:
tsdown.config.ts:204src/cli/gateway-cli/run-loop.ts:44src/cli/gateway-cli/run-loop.ts:280
Please either add config/config as a stable entry or preload/cache it before the long-lived boundary can be invalidated, and add it to the stability test so the exact restart-time import is covered.
One non-blocking note: this PR combines the private-command routing behavior and the gateway lifecycle bundling fix. Both are useful, but the title/description should call out both, or this should split so the release note and review surface are clearer.
|
Clownfish could not safely update this branch, so it opened a narrow replacement PR instead. Replacement PR: #74075 |
This fixes the rebuild failure mode where a running gateway keeps a lazy import boundary into a hashed dist chunk and then loses that chunk underneath itself during a rebuild.
We already had the right architectural idea in
tsdown.config.ts: long-lived runtime boundaries should resolve through stable filenames. The problem was that the restart, shutdown, and heartbeat paths were only partially enrolled in that rule. Some first-hop lifecycle imports still compiled to hashed chunk names, so a live gateway could strand its own control paths even though the high-level build policy was already correct.This change does not add runtime fallbacks, retries, or extra recovery branches. It makes the lifecycle modules themselves explicit tsdown entries so the existing lazy imports resolve to stable build paths. That keeps the fix in the build graph, where the problem actually lives.
I kept the scope to the first-hop modules that can fire after startup from an already-running gateway process: the run-loop restart and drain helpers, the shutdown prelude and close handler, and the heartbeat runtime loader. There is also a focused tsdown config test now, so we keep this contract visible instead of silently drifting back to hashed lifecycle chunks later.