Repository navigation
fix(lifecycle): establish process-global shutdown authority - #123
Merged
Merged
Conversation
|
✅ OpenCodeReview: Review complete: 0 finding(s) across 2 selected item(s). Reviewed |
CI Coverage Report
Coverage artifact was not available for this run. |
khanhkit
force-pushed
the
kit/KitDev2/session-1
branch
from
October 11, 2026 11:26
b91b680 to
dd4909b
Compare
khanhkit
force-pushed
the
kit/KitDev2/session-1
branch
from
October 11, 2026 14:43
692dc95 to
8b0fb71
Compare
khanhkit
force-pushed
the
kit/KitDev2/session-1
branch
5 times, most recently
from
October 12, 2026 01:54
9f6a0f5 to
68b8ffd
Compare
khanhkit
force-pushed
the
kit/KitDev2/session-1
branch
from
October 12, 2026 05:37
d26b80e to
fbb5f74
Compare
khanhkit
force-pushed
the
kit/KitDev2/session-1
branch
2 times, most recently
from
October 12, 2026 15:29
e9e8bdd to
5a2dbe5
Compare
added 16 commits
October 14, 2026 08:22
Port the already-proven AP-ISS-0136 root cleanup onto the current main-derived tree to unblock AP-ISS-0149 exact-head CI. This is test-only and does not change product behavior.
khanhkit
force-pushed
the
kit/KitDev2/session-1
branch
from
October 14, 2026 01:24
4ffba64 to
703685a
Compare
commented
Oct 20, 2026
Owner
Author
|
AP-ISS-0149 terminal lifecycle evidence (2026-10-20 ICT; KitDev2 Gen106, same durable task run
Status: PRODUCT MERGED / KITCONTROL TASK DONE / LEGACY PARK PENDING GUARDS. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AP-ISS-0149 — one process-global lifecycle and hook authority
Consolidate main-server shutdown ownership into one bounded lifecycle coordinator while keeping true standalone MCP/CLI/server processes independently owned.
Current exact source head:
96db0e0691e4611f50e789be8b851d32dca61275Current exact source tree:
c2e87c29181872103e1c8d12d883c073080c318aCurrent hosted base / merge-base:
2b9fafdea56bcb558bc3b72f0bdf113f04d2c58668b8ffde…and every earlier published head are superseded and MUST NOT be used as final merge evidence.Lifecycle contract
Main runtime tears down under one absolute deadline in this ordered composition:
STOP_ADMISSION → STOP_SCHEDULERS → DRAIN_ACTIVE → DRAIN_BACKGROUND → FLUSH_DURABLE → CLOSE_RESOURCES → STOP_CHILDREN → EXITDRAIN_BACKGROUNDis an internal refinement of the approved drain layer: request/job/service producers finish inDRAIN_ACTIVE, then process-owned durable background tasks drain before flush. It does not introduce a second deadline or weaken fail-closed timeout behavior.scripts/dev/run-next.mjsowns main custom-server SIGINT/SIGTERM/SIGHUP and final exit.src/lib/gracefulShutdown.tsis fallback signal/final-exit owner only when a custom owner is absent.STOP_SCHEDULERS; limiter persistence/teardown occurs after active producers quiesce.process.emit.Review findings dispositioned
Real OCR findings were reproduced RED→GREEN before publication, including routing OTLP unregister, strict shutdown-timeout normalization, supervisor stop-failure propagation, rate-limit phase separation, producer-before-background drain ordering, JobRegistry cron stop fencing, API Bridge stop/drain serialization, provider-limit stale-setup fencing, webhook lifecycle reset safety, custom-runner HTTP close error handling, pre-listen signal handling, and direct packaged-standalone timeout bounding.
Findings whose premise conflicts with current runtime semantics were dispositioned with source/executable evidence instead of redundant machinery: JavaScript run-to-completion closes alleged same-stack registration/listen interleavings, and the coordinator skips all later phases after a timed-out hook. A second local drain budget would violate the approved single-deadline contract.
Latest lifecycle OCR remediation on
e91bce7f…:run-next.mjsattaches a rejection handler toserverClosePromiseimmediately after creation so a close callback failure cannot surface as an unhandled rejection while lifecycle drain is awaited; the original promise remains rejected and the later await still marks shutdown non-clean.run-next.mjschecksserver.listeningbeforeserver.close(), so a signal received after handler registration but before bind is a clean admission-close no-op instead ofERR_SERVER_NOT_RUNNING.standalone-server-ws.mjsresolvesSHUTDOWN_TIMEOUT_MS, arms an unref'd hard force-exit timer, and clears it only after terminal cleanup. Duplicate SIGTERM remains idempotent because normalagentproxy serveprocess-group + parent forwarding can legitimately deliver the same signal twice; the hard timer supplies the bound without cutting durable flush mid-flight.All current inline review threads are resolved on the current source line.
Exact-head CI blocker follow-up on
777b3e0970: hosted CI run38197848596showed all 2785 UI tests passing but failed after suite teardown with the known baselineCursorAgentNudge.test.tsxjsdom race (ReferenceError: window is not defined). The file was unchanged fromorigin/main; the already-proven AP-ISS-0136 root-unmount cleanup was ported to the current tree as test-only code. Fresh local exact UI command: 415/415 files, 2785/2785 tests PASS, with no unhandled teardown error; focused file 8/8 PASS.No heap limit, assertion, package check, lifecycle gate, docs gate, or CI guard was weakened to manufacture green.
Exact-head local verification
Current branch is 29 ahead / 0 behind the exact merge-base above. Provenance audit is 29/29 author=KitDev2 and committer=KitDev2. Worktree is clean and local/remote branch SHA exactly match
96db0e0691….Fresh verification after the latest OCR remediation:
npm run typecheck:core: PASS, RC=0.npm run check:open-sse-typecheck: PASS, RC=0,openSseTypecheckErrors=0.npm run check:build-scope: PASS,9731 < 12000.npm run check:tracked-artifacts: PASS.git diff --check: PASS.Earlier current-line verification that remains applicable includes repo-native AP-ISS-0149 lifecycle/ownership regressions, standalone ownership checks, package closure checks, full hosted Build/Vitest/unit/integration/coverage/package/E2E success on the immediately preceding rebased head, and clean CodeQL/semgrep/DAST/API typecheck results.
File-size ratchet follow-up on
777b3e0970: exact-heada460750705exposed onlyopen-sse/services/rateLimitManager.tsat 1206/1200 lines. The shutdown cleanup block was simplified without behavior change; local exact ratchet is now 1199/1200 PASS, focused lifecycle wiring 13/13 PASS, and diff-check clean.Second exact-head OCR remediation on
777b3e0970: fixed rate-limit shutdown idempotence, routing observability re-init, parent signal-delivery escalation margin, strict Windows timeout parsing, LiveWS bind-failure ownership cleanup, and awaitable LiveWS listener drain. Review-only findings for pre-existing scheduler overlap, intentional backgroundunref, JavaScript run-to-completion, and already-handled promises were dispositioned with source evidence. Focused RED→GREEN 35/35 PASS; LiveWS EADDRINUSE 1/1 PASS; core/Open-SSE typechecks PASS; targeted ESLint PASS; file-size 1196/1200 PASS; all PR review threads resolved.Third exact-head OCR remediation on
de8339fff450a285be11a47e781f3b97798c3c9c: rate-limit shutdown single-flight state now clears after settlement so later lifecycle/retry calls get a fresh shutdown operation, and test reset awaits any in-flight shutdown before touching shared limiter state. Two additional OCR premises were closed with executable evidence: routing sink re-registration is Set-idempotent for stable memory/quality sink objects, and strict Windows timeout parsing still maps malformed30000junkto the documented 31s fallback while preserving1e3as 2s including escalation margin. Rebased onto latestorigin/maindefda037e7; focused exact-head lifecycle/routing/windows bundle 32/32 PASS, file-size ratchet PASS, core/Open-SSE typechecks PASS, targeted ESLint PASS, diff-check clean.Fourth exact-head OCR remediation on
de8339fff450a285be11a47e781f3b97798c3c9c: final learned-rate-limit persistence now propagates DB/write failure into the lifecycle report while debounced background persistence remains best-effort/logged; packaged standalone now refuses creation of new HTTP servers once shutdown begins, freezing listener admission across the pre-drain snapshot. RED→GREEN focused remediation gate 10/10 PASS;rateLimitManager.ts1197/1200; core/Open-SSE typechecks, file-size ratchet, ESLint and diff-check PASS. Eleven final OCR threads were dispositioned/resolved with exact-head evidence.Fifth exact-head base-drift reconciliation on
cb94c927f0f203ef61b9d01b21c848cd04be821c:mainadvanced by PR #112 toc0c91edd8b2b49cfbb5653451ab06bc0b0313d49after the prior exact-head oracle completed. The intervening main commit touches only parked-replay SSE code/tests. A pre-rebasemerge-treewas conflict-free; the 27 AP-ISS-0149 commits rebased cleanly, retained 27/27 KitDev2 author+committer provenance, and the rebased treecbf9ae2f57df4f3d41e1bbf5372297d08bc8b953exactly equals the precomputed merge-tree. The branch is 27 ahead / 0 behind,git diff --checkpasses, and the force-push used an exact lease pinned to superseded headde8339fff450a285be11a47e781f3b97798c3c9c. Fresh hosted gates on this rebased exact head supersede all prior hosted merge evidence.Sixth exact-head review/base reconciliation on
4ffba64f942ab92b2964aaab64a974dc4d15e813: prior exact-head hosted gates completed successfully but OpenCodeReview #195 emitted six new threads. Three findings were reproduced RED→GREEN: API Bridge now owns/destroys upgraded relay sockets during stop, direct API drain idempotently initiates stop, and webhook drain closes notification admission before reporting empty. Three review premises were dispositioned with source/executable evidence: free-proxy cycle failures are already absorbed/logged byrunCycle(), a timed-out lifecycle hook skips every later phase rather than closing resources beneath it, and provider-limit startup timers are synchronously cancelled in STOP_SCHEDULERS before DRAIN_ACTIVE. Focused lifecycle bundle 39/39 PASS; core/Open-SSE typechecks andgit diff --checkPASS.mainthen advanced to08bbb79b5dcbf3823e8826220c771cd7856ae054. The drift had zero changed-file overlap with AP-ISS-0149 and pre-rebasemerge-treewas conflict-free at treeb2fa269052e9056fe7d77dc87b0f06f1fc33f4ae. The 28-commit branch rebased cleanly; exact head4ffba64f942ab92b2964aaab64a974dc4d15e813has the same tree byte-for-byte and retains 28/28 KitDev2 author+committer provenance. The force-push used an exact lease pinned to superseded remote headcb94c927f0f203ef61b9d01b21c848cd04be821c.Final review/base reconciliation:
mainadvanced to2b9fafdea56bcb558bc3b72f0bdf113f04d2c586; the branch rebased cleanly and retained KitDev2 provenance. OpenCodeReview #247 emitted 12 findings. Eleven were stale/duplicate/contract/maintainability dispositions; one real shutdown race was reproduced deterministically and fixed: runtime config hot reload now closes admission before stop/drain can complete. Exact head96db0e0691e4611f50e789be8b851d32dca61275has focused lifecycle/config verification 45/45 PASS, core typecheck PASS, Open-SSE typecheck PASS (openSseTypecheckErrors=0), andgit diff --checkPASS. All review threads were replied to, resolved, and read back resolved before the final hosted oracle.Acceptance oracle
Protected hosted CI and OpenCodeReview on exact head
96db0e0691e4611f50e789be8b851d32dca61275are authoritative for final merge. Required Build, Package Boot Smoke, package/E2E/security/quality/docs gates, CodeQL, semgrep, DAST, API typecheck, and OpenCodeReview must be terminal-successful on this exact SHA; all review threads must remain resolved.Do not delete the source branch until exact-head hosted CI is terminal, source-head → accepted-main provenance is durable, and AP-ISS-0149 KitControl closure evidence is recorded.