Skip to content

feat: 载体启动装配(清单、配置器、原生句柄、组件阶段) - #36

Merged
residua1 merged 5 commits into
mainfrom
v2
Nov 17, 2026
Merged

residua1 merged 5 commits into
mainfrom
v2

Conversation

@residua1

Copy link
Copy Markdown
Contributor

ADR-0061 / 0064 / 0065 的核心半边。

  • CarrierStartup:读载体清单 → 并共享层 → 建容器 → 跑 carrier.bootstrap → 交 IServiceProvider。
  • NativeHostingEntry 宿主契约 2:Start/StartUnderParent 参数为 { const char* carrierDirectory; void* host; },nullptr 等价旧行为;启动链在装载插件之前 StartComponents,失败中止启动;StopCore 先 StopComponents。
  • 组件与配置器的错误走资源文案(中英)。
  • 宿主断言 A67/A68:清单+共享层+配置器+句柄贯通;无载体目录照常启动。管理器宿主 97 项断言本机全过。

合并顺序:契约 → 核心 → HostingShim → 文档。

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T09:58:37.353890Z 6e2af32 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 469c22c843

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/NativeHostingEntry.cs
return 0;
}

// 组件停止在分发停止之前(ADR-0061);超时只记账,不拖住退出。

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Restart carrier components when reusing the parent host

On the supported StopUnderParent → StartUnderParent reload path, this new call stops and clears all carrier components, but StartCore returns immediately whenever s_host already exists. Consequently, the next startup reports success without restarting any components; it also skips the configurator and retains services containing the previous native host handle. Reinitialize the carrier lifecycle and handle-dependent services on the reuse path before allowing the parent to deliver plugins.

Useful? React with 👍 / 👎.

Comment thread src/NativeHostingEntry.cs Outdated
Comment on lines +366 to +369
if (!s_host.StartComponents(carrierDirectory, startup.Components))
{
logger.LogError("{Message}", CoreText.Get("Native_ComponentsFailed", string.Join(" | ", startup.Components)));
return 1;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Clear the published host after component startup fails

If a declared component cannot load or throws during startup, this branch returns failure after s_host has already been assigned. StartComponents rolls back the components, but the static host remains published, so a subsequent startup returns success through the existing-host shortcut without retrying components or, in self-hosted mode, reaching LoadAll. Keep the host local until startup succeeds, or clear and clean it up on failure, so a retry cannot mistake an aborted startup for a running core.

Useful? React with 👍 / 👎.

@residua1

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: 54a87ff614

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@residua1

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 073da31c78

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/NativeHostingEntry.cs Outdated
Comment on lines +313 to +314
var restarted = CarrierStartup.Create(
args.CarrierDirectory, args.Host, s_loggerFactory!, out var restartError);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Catch startup exceptions on the reused-host path

During a parent reload, this branch executes outside the try/catch protecting initial startup. CarrierStartup.Create can still throw—for example, when a configurator registers an invalid open-generic service and BuildServiceProvider() rejects it after TryConfigure returns. Such a failure escapes StartUnderParent through its [UnmanagedCallersOnly] boundary instead of returning a startup error, potentially terminating the server. Put the reuse path under the same exception boundary as initial startup.

Useful? React with 👍 / 👎.

Comment thread src/NativeHostingEntry.cs Outdated
return 1;
}

reused.RepublishCarrierServices(restarted.Services);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Dispose the previous carrier container when replacing it

On each parent reload, a newly built service provider replaces the previous one, but neither StopCore nor RepublishCarrierServices disposes the old provider. If the configurator registers disposable singleton services that components or plugins resolve, their cleanup never runs; services owning timers or other persistent resources can consequently remain active across successive reloads. Track ownership of these internally created providers and dispose the previous generation after its consumers have stopped, before discarding it.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 073da31c78

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/NativeHostingEntry.cs Outdated
reused.RepublishCarrierServices(restarted.Services);
if (restarted.Directory is { Length: > 0 } reusedDirectory && restarted.Components.Count > 0)
{
if (!reused.StartComponents(reusedDirectory, restarted.Components))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Contain exceptions on the reused-host startup path

On a StopUnderParent → StartUnderParent reload, this branch executes outside the try/catch that protects initial startup. For example, if the carrier manifest contains "components": [null], CarrierStartup.Create succeeds, but StartComponents throws when accessing component.Assembly. That exception escapes the [UnmanagedCallersOnly] entry point and can terminate the server instead of returning a startup failure. Put the reuse initialization and component startup inside the same exception boundary as initial startup.

Useful? React with 👍 / 👎.

@residua1

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5fce11f2c3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/PluginManager.cs Outdated
Comment on lines +322 to +324
if (previous is IDisposable disposable && !ReferenceEquals(previous, services))
{
disposable.Dispose();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Support asynchronous disposal of carrier services

If a carrier configurator registers a singleton that implements only IAsyncDisposable and a component or plugin resolves it, the built-in DI provider's synchronous Dispose() throws rather than disposing that service. On the next parent reload, this exception propagates from RepublishCarrierServices into the startup error handler, so startup fails before restarting any components and the old service remains uncleaned. Dispose internally built providers through their asynchronous disposal path when supported, and await completion before continuing startup.

Useful? React with 👍 / 👎.

@residua1

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 6e2af3201b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@residua1
residua1 merged commit 89bbf02 into main Nov 17, 2026
5 checks passed
@residua1
residua1 deleted the v2 branch November 17, 2026 09:59
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.

2 participants