You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maka.apache.org by "chihumyum (via GitHub)" <gi...@apache.org> on 2026/10/06 16:46:11 UTC
[PR] fix(runtime-host): preserve Kernel ownership after startup failure [maka]
chihumyum opened a new pull request, #5972:
URL: https://github.com/apache/maka/pull/5972
## Summary
When Host recovery fails and shutdown reaches its deadline, Candidate's outer catch released the State Root owner even though the old composition had not stopped. A successor could then acquire the root before the required process termination.
Prepare the Kernel inputs within Candidate's cleanup scope, then transfer ownership by calling `Kernel.start` outside that scope. Preparation failures still release their resources; Kernel alone controls cleanup and ownership retention after transfer.
## Verification
- New behavior regressions: **before fix 2 passed / 1 failed** (`owner.closed` was `true`, expected `false`); **after fix 7 related cases passed**. Covers preparation failure, clean recovery failure and a ready successor, cleanup timeout, and late cleanup completion.
- Rebuilt from current source; full Runtime Host suite: **2,231 passed, 12 skipped, 0 failed**. Tests use temporary State Roots and controlled composition failures/timers. The suite also runs a public model-metadata refresh; no model-provider account was used.
- Passed: root build, lint, format check, typecheck; Knip for Desktop and UI; strict renderer architecture; Astryx inventory/tests/theme; Windows inventory; ASF headers; model metadata; protocol epoch check; `git diff --check`.
- This does not claim real user-data recovery, multi-process data corruption reproduction, or native UI acceptance. Skipped native/platform cases remain outside local acceptance.
## AI use
Select exactly one:
- [ ] No generative tool made a substantive contribution
- [x] Generative tooling made a substantive contribution
Tool(s) and scope: Codex / GPT-6 Astra contributed investigation, implementation, regression tests, validation and this PR description. The commit includes `Generated-by: Codex`. Final review and merge remain with human maintainers.
## Checklist
- [x] Tests cover the change and fail without it
- [x] Lint, format, typecheck and the affected suites pass locally
Does this PR entail a change in behavior?
- [x] Yes — described under Summary above
- [ ] No
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] fix(runtime-host): preserve Kernel ownership after startup failure [maka]
Posted by "chihumyum (via GitHub)" <gi...@apache.org>.
chihumyum commented on PR #5972:
URL: https://github.com/apache/maka/pull/5972#issuecomment-6049850769
Also fixed the review's P2 on the service path in 8a2cabef6. `startExecutionRuntimeHostService` now releases the State Root owner only when startup fails before `RuntimeHostKernel.start`. After that the Kernel owns the root, including keeping it past a shutdown-deadline overrun until the CLI's fatal path exits the process. The Candidate's clean-recovery and deadline-overrun tests now run against both startup paths, plus a service preparation-failure test. The service deadline case fails on the previous code: the owner was closed while the composition was still closing.
_🤖 Addressed by [Claude Code](https://claude.com/claude-code)_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] fix(runtime-host): preserve Kernel ownership after startup failure [maka]
Posted by "Astro-Han (via GitHub)" <gi...@apache.org>.
Astro-Han merged PR #5972:
URL: https://github.com/apache/maka/pull/5972
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] fix(runtime-host): preserve Kernel ownership after startup failure [maka]
Posted by "Astro-Han (via GitHub)" <gi...@apache.org>.
Astro-Han commented on code in PR #5972:
URL: https://github.com/apache/maka/pull/5972#discussion_r4198323332
##########
packages/runtime-host/src/server/candidate.ts:
##########
@@ -83,45 +84,54 @@ export async function startInteractiveRuntimeHostCandidate(
);
if (!ownership) return { kind: 'loser' };
const { owner, managedConfig } = ownership;
- try {
- const composition = await createComposition(managedConfig);
- const loadedKernel = await kernelModule;
- if (loadedKernel.kind === 'failed') throw loadedKernel.error;
- const { RuntimeHostKernel } = loadedKernel.module;
- const websocket = managedConfig?.listeners.websocket;
- const accessAuthority = websocket
- ? await import('./access-authority.js').then(({ openRuntimeHostAccessAuthority }) =>
- openRuntimeHostAccessAuthority(owner.controlDirectory),
- )
- : undefined;
- const host = await RuntimeHostKernel.start({
- owner,
- lifecycleMode: 'ephemeral',
- initialConnectionTimeoutMs: options.initialConnectionTimeoutMs,
- idleGraceMs: options.idleGraceMs,
- handshakeTimeoutMs: options.handshakeTimeoutMs,
- generation: options.generation,
- composition,
- ...(options.initialClientAdmission
- ? { initialClientAdmission: options.initialClientAdmission }
- : {}),
- ...(accessAuthority ? { accessAuthority } : {}),
- ...(websocket && accessAuthority
- ? {
- listenerSetFactory: async (input) => {
- const { startRuntimeHostAuthenticatedListenerSet } = await import(
- './listener-set.js'
- );
- return startRuntimeHostAuthenticatedListenerSet(input, {
- websocket: { ...websocket, accessAuthority },
- });
- },
- }
- : {}),
- });
- return { kind: 'winner', host };
- } catch (error) {
- if (!owner.closed) await owner.close();
- throw error;
- }
+ const prepared = await (async () => {
+ let preparedAccessAuthority: RuntimeHostAccessAuthority | undefined;
+ try {
+ const composition = await createComposition(managedConfig);
+ const loadedKernel = await kernelModule;
+ if (loadedKernel.kind === 'failed') throw loadedKernel.error;
+ const websocket = managedConfig?.listeners.websocket;
+ const accessAuthority = websocket
+ ? await import('./access-authority.js').then(({ openRuntimeHostAccessAuthority }) =>
+ openRuntimeHostAccessAuthority(owner.controlDirectory),
+ )
+ : undefined;
+ preparedAccessAuthority = accessAuthority;
+ const kernelOptions = {
+ owner,
+ lifecycleMode: 'ephemeral',
+ initialConnectionTimeoutMs: options.initialConnectionTimeoutMs,
+ idleGraceMs: options.idleGraceMs,
+ handshakeTimeoutMs: options.handshakeTimeoutMs,
+ generation: options.generation,
+ composition,
+ ...(options.initialClientAdmission
+ ? { initialClientAdmission: options.initialClientAdmission }
+ : {}),
+ ...(accessAuthority ? { accessAuthority } : {}),
+ ...(websocket && accessAuthority
+ ? {
+ listenerSetFactory: async (input) => {
+ const { startRuntimeHostAuthenticatedListenerSet } = await import(
+ './listener-set.js'
+ );
+ return startRuntimeHostAuthenticatedListenerSet(input, {
+ websocket: { ...websocket, accessAuthority },
+ });
+ },
+ }
+ : {}),
+ } satisfies RuntimeHostKernelOptions;
+ return { Kernel: loadedKernel.module.RuntimeHostKernel, options: kernelOptions };
+ } catch (error) {
+ await preparedAccessAuthority?.close().catch(() => undefined);
Review Comment:
P3: this close never runs for a real authority. `preparedAccessAuthority` is only set at line 99, and nothing after that inside the try can throw: the options object literal can't, and `satisfies` is compile-time only. When `openRuntimeHostAccessAuthority` itself rejects, the variable is still `undefined`. Either drop it, or move the authority open to the end and comment that it is the last fallible step, so a later edit that adds a fallible step after it gets the cleanup for free. That is harmless as written, but the comment would be clearer than code that suggests coverage the tests don't exercise (there is no websocket-config preparation-failure case).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] fix(runtime-host): preserve Kernel ownership after startup failure [maka]
Posted by "chihumyum (via GitHub)" <gi...@apache.org>.
chihumyum commented on code in PR #5972:
URL: https://github.com/apache/maka/pull/5972#discussion_r4213509782
##########
packages/runtime-host/src/server/candidate.ts:
##########
@@ -83,45 +84,54 @@ export async function startInteractiveRuntimeHostCandidate(
);
if (!ownership) return { kind: 'loser' };
const { owner, managedConfig } = ownership;
- try {
- const composition = await createComposition(managedConfig);
- const loadedKernel = await kernelModule;
- if (loadedKernel.kind === 'failed') throw loadedKernel.error;
- const { RuntimeHostKernel } = loadedKernel.module;
- const websocket = managedConfig?.listeners.websocket;
- const accessAuthority = websocket
- ? await import('./access-authority.js').then(({ openRuntimeHostAccessAuthority }) =>
- openRuntimeHostAccessAuthority(owner.controlDirectory),
- )
- : undefined;
- const host = await RuntimeHostKernel.start({
- owner,
- lifecycleMode: 'ephemeral',
- initialConnectionTimeoutMs: options.initialConnectionTimeoutMs,
- idleGraceMs: options.idleGraceMs,
- handshakeTimeoutMs: options.handshakeTimeoutMs,
- generation: options.generation,
- composition,
- ...(options.initialClientAdmission
- ? { initialClientAdmission: options.initialClientAdmission }
- : {}),
- ...(accessAuthority ? { accessAuthority } : {}),
- ...(websocket && accessAuthority
- ? {
- listenerSetFactory: async (input) => {
- const { startRuntimeHostAuthenticatedListenerSet } = await import(
- './listener-set.js'
- );
- return startRuntimeHostAuthenticatedListenerSet(input, {
- websocket: { ...websocket, accessAuthority },
- });
- },
- }
- : {}),
- });
- return { kind: 'winner', host };
- } catch (error) {
- if (!owner.closed) await owner.close();
- throw error;
- }
+ const prepared = await (async () => {
+ let preparedAccessAuthority: RuntimeHostAccessAuthority | undefined;
+ try {
+ const composition = await createComposition(managedConfig);
+ const loadedKernel = await kernelModule;
+ if (loadedKernel.kind === 'failed') throw loadedKernel.error;
+ const websocket = managedConfig?.listeners.websocket;
+ const accessAuthority = websocket
+ ? await import('./access-authority.js').then(({ openRuntimeHostAccessAuthority }) =>
+ openRuntimeHostAccessAuthority(owner.controlDirectory),
+ )
+ : undefined;
+ preparedAccessAuthority = accessAuthority;
+ const kernelOptions = {
+ owner,
+ lifecycleMode: 'ephemeral',
+ initialConnectionTimeoutMs: options.initialConnectionTimeoutMs,
+ idleGraceMs: options.idleGraceMs,
+ handshakeTimeoutMs: options.handshakeTimeoutMs,
+ generation: options.generation,
+ composition,
+ ...(options.initialClientAdmission
+ ? { initialClientAdmission: options.initialClientAdmission }
+ : {}),
+ ...(accessAuthority ? { accessAuthority } : {}),
+ ...(websocket && accessAuthority
+ ? {
+ listenerSetFactory: async (input) => {
+ const { startRuntimeHostAuthenticatedListenerSet } = await import(
+ './listener-set.js'
+ );
+ return startRuntimeHostAuthenticatedListenerSet(input, {
+ websocket: { ...websocket, accessAuthority },
+ });
+ },
+ }
+ : {}),
+ } satisfies RuntimeHostKernelOptions;
+ return { Kernel: loadedKernel.module.RuntimeHostKernel, options: kernelOptions };
+ } catch (error) {
+ await preparedAccessAuthority?.close().catch(() => undefined);
Review Comment:
Dropped the unreachable authority close in 0cbeeac0e. The authority open is the last fallible preparation step, and Kernel.start owns the authority after it; a comment at the open now says it must stay last.
_🤖 Addressed by [Claude Code](https://claude.com/claude-code)_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org