Skip to content

feat!: v2 管理器与打包器(元数据换代、Reload、载体组件、三段超时) - #35

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

residua1 merged 18 commits into
mainfrom
v2

Conversation

@residua1

Copy link
Copy Markdown
Contributor

实现 ADR-0058–0063 的运行时面(spec:HosihikariFramework/Design#2)。依赖契约仓 #20。

内容

  • 清单读取改 hosihikari.json,旧包拒载并提示 hosihikari-pack migrate;打包器生成 LeviLamina 信封。
  • 打包器 --carrier 并入载体声明的共享层;kind: carrier 校验组件程序集与类型。
  • 钩子投专用线程(避开同步上下文死锁)、三段独立超时、UnloadResult 区分结局。
  • Reload 仅在管理器拥有插件集时提供;父级态返回 NotSupported。
  • 事件优先级六档;状态迁移事件;ILoaderContext 按 kind 分流。
  • 载体组件阶段:清单声明、分发开启前启动、停止前倒序停止。

验证

五仓构建 0 错误;宿主 94 条、Testing 18 条全过;打包冒烟通过。

合并顺序:等 #20 合入后本 PR(ADR-0059)。

最小编译修复,不做语言层适配(ADR-0059)。

- 四处钩子调用改 GetAwaiter().GetResult() 等待 ValueTask:装载、启用/停用、
  卸载与回滚清理
- Validate 收 PluginDiagnostic 并取其 Message 进装载报告;ReportFault 同形状
- PluginContext 与 TestPluginContext 改实现 ILoaderContext,普通上下文没有
  RegisterLoader 时调用方按接口取
- BaseSharedAssemblyFileNames 跟着契约的基地清单改名,DechareShared 不再追加静态清单
- PluginState 移入契约,删掉本仓那份;EventBus 按六档桶分发,Subscribe 带优先级
- csproj 的契约与模型引用改 3.0.0,夹具清单 api_version 抬到 3
ManifestReader 只认 hosihikari.json:缺文件时若同目录有旧信封就报
「旧包,跑 hosihikari-pack migrate」,扫描时按信封 type 判断是不是我们
的路由对象,父级自己的 mod 不吭声。apiVersion 与 schemaVersion 走新
字段,kind 取顶层。

打包器把作者清单原样进包,另外按清单生成最小信封 manifest.json
(name/type/entry/version/hosihikari 依赖,有则带展示字段)。新增
migrate 子命令:读 manifest.json、写 hosihikari.json、删旧文件、列出
要人工补的 pack 与 carrier 字段。kind 为 carrier 时校验组件程序集与
类型存在且实现 ICarrierComponent。

Build 包的缺省 apiVersion 抬到 3,生成清单改新格式,包版本 1.2.0;
smoke 的示例插件改新钩子签名与新清单,并断言 dist 清单的 apiVersion
是 3。夹具与宿主断言、Testing 的包辅助、三个回归用例一并换新格式,
新增旧包拒载、carrier 组校验与 migrate 三条断言。

普通包不再拿到 ILoaderContext(上下文按 kind 分型):加载失败时绕过
了钩子线程等待,OnLoad 超时被误记成 30 秒的问题随之消失。

Refs #17 #29 #28
信封里的 description 与 author 是从清单单向派生的展示副本:有则写、
无则省,作者不为它再手写一份(ADR-0058)。补一条断言把两个方向都
钉住。

verify.yml 的 ref 注释按 ADR-0059 写明合并顺序(契约 → 核心 → 加载器)
与钉同名分支的来历;DotNetCorePlugins 是外部 fork,不重复注释。

Refs #17
载体组件按清单声明在事件分发开启前启动、停止前倒序停止,受独立的
组件停止超时约束;组件实现类拆到独立文件。ReportFault 全链携带
PluginDiagnostic,Manager_Fault 带错误码,Validate 结果按严重级别呈现。

RPC 回归里 A10 的偶发由钩子投线程引入,宿主断言改为轮询等待。
--carrier 指向已安装的载体包,读它的 carrier.sharedAssemblies 与基地
清单合并后再剔除副本;运行期同一份判定(ADR-0061)。宿主补 A63 钉住
合并与缺失目录的回落。
ADR-0062 已定稿但方法一直没落地。新增 ReloadResult 与 OwnsPluginSet
选项:自持态依次 Disable→Unload→Load→Enable 并逐步回报,父级态返回
不支持并说明所有权在父级。宿主补 A64/A65。
Copilot AI balanced review requested due to automatic review settings November 17, 2026 02:24
@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-17T08:15:20.900564Z a68ad4b 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: 22a4046552

ℹ️ 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
/// 每一步失败就停在那一步并如实回报,不做假成功。
/// </summary>
/// <param name="name">插件名,等于包目录名。</param>
public ReloadResult Reload(string name)

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 Resolve the repository's Reload prohibition before exposing this API

The root AGENTS.md explicitly says “do not add a Reload verb,” but this change adds a public Reload method while the manager package remains version 1.3.0. Although the commit describes a v2 transition, the applicable repository invariant has not been changed. Resolve that policy/version transition with the maintainers before exposing this API in the current release line.

AGENTS.md reference: AGENTS.md:L31-L32

Useful? React with 👍 / 👎.

Comment thread src/PluginManager.cs Outdated
if (!TryInvokeHook(
manifest.Name,
"OnLoad",
token => plugin.OnLoad(context, token),

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 Pass the restricted context to the plugin's OnLoad hook

For an ordinary kind: "plugin" package, only loader.Load receives context.ForPlugin(); the actual plugin's OnLoad receives the original PluginContext, which implements ILoaderContext. Consequently, any ordinary plugin can cast its hook context to ILoaderContext and register loaders, bypassing the new package-kind separation. Pass the restricted view to both consumers. The A56 assertion currently misses this because HookPluginLoader records the context received by Load, not by the plugin hook.

Useful? React with 👍 / 👎.

Comment thread src/PluginManager.cs
Comment on lines +1092 to +1096
if (_loading.TryGetValue(instanceId, out var loadingName) && loadingName == name)
{
// 装载钩子还没跑完,实例尚未交给表。记下来,让 LoadOne 在回滚时一并报。
_pendingFaults[instanceId] = diagnostic;
return;

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 Queue fault reports from all active lifecycle hooks

If a previously loaded plugin calls context.ReportFault(...) synchronously from OnEnable, OnDisable, or OnUnload, its instance is no longer in _loading, so this fast path falls through to lock (_gate). Those hooks now execute on a separate thread while Enable, Disable, or UnloadCore holds _gate waiting for the hook, creating a lock cycle. With the default settings this stalls until the hook timeout; with HookTimeout = Timeout.InfiniteTimeSpan it hangs permanently. Defer fault processing for every active hook, rather than only the initial load.

Useful? React with 👍 / 👎.

Comment thread tools/Pack/Packager.cs Outdated
Comment on lines +216 to +218
var manifestName = Path.GetFileName(manifestPath);
File.Copy(manifestPath, Path.Combine(staging, manifestName), overwrite: true);
File.WriteAllText(Path.Combine(staging, LegacyEnvelopeFileName), BuildEnvelope(manifest));

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 Always write the author manifest under its canonical filename

When the supplied manifest path has a basename other than hosihikari.json, packing now succeeds but preserves that alternate name in the package. ManifestReader.Read only reads hosihikari.json, so the resulting package cannot load; if the supplied basename is manifest.json, the next statement also overwrites the copied author metadata with the routing envelope. This affects the public Pack API and custom HosihikariPluginManifest paths. Copy the author metadata to ManifestFileName regardless of its source filename.

Useful? React with 👍 / 👎.

Copilot AI 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.

🟡 Changes recommended

Unresolved critical defects allow loader-permission bypasses and lifecycle deadlocks, violate component threading requirements, and can produce unusable packages or discard migration settings.

24 open issues

And 4 more that still need to be addressed.

What changed in this PR

This PR moves the plugin manager and packaging tools to the v2 runtime model, with new metadata, asynchronous lifecycle hooks, carrier components, and topology-aware reload support.

Changes:

  • Adopt hosihikari.json, generate LeviLamina envelopes, and add migration and carrier-aware packaging.
  • Add lifecycle timeouts, reload results, state notifications, and six event-priority levels.
  • Update build integration, testing utilities, fixtures, and localized diagnostics for the new contract.
File Description
tools/​Pack/​Resources/​PackStrings.zh.resx Update Chinese packaging diagnostics.
tools/​Pack/​Resources/​PackStrings.ru.resx Update Russian packaging diagnostics.
tools/​Pack/​Resources/​PackStrings.resx Add neutral migration and carrier messages.
tools/​Pack/​Resources/​PackStrings.fr.resx Update French packaging diagnostics.
tools/​Pack/​Resources/​PackStrings.es.resx Update Spanish packaging diagnostics.
tools/​Pack/​Resources/​PackStrings.ar.resx Update Arabic packaging diagnostics.
tools/​Pack/​README.md Document new manifests and migration.
tools/​Pack/​Program.cs Add migration and carrier CLI options.
tools/​Pack/​Packager.cs Generate envelopes, migrate metadata, and validate components.
tools/​Build/​smoke.sh Update packaging smoke checks.
tools/​Build/​Hosihikari.Plugin.Build.csproj Bump the build package version.
tools/​Build/​build/​Hosihikari.Plugin.Build.targets Generate new-format author manifests.
testing/​Hosihikari.Testing/​TestPluginScope.cs Forward event priorities.
testing/​Hosihikari.Testing/​TestPluginContext.cs Adopt loader context and structured diagnostics.
testing/​Hosihikari.Testing/​TestEventBus.cs Implement priority-ordered event delivery.
testing/​Hosihikari.Testing/​README.md Update the harness example terminology.
testing/​Hosihikari.Testing/​PluginTestHost.cs Drive asynchronous lifecycle hooks.
testing/​Hosihikari.Testing/​PluginManagerHarness.cs Write hosihikari.json packages.
testing/​Hosihikari.Testing.Smoke/​Program.cs Update contract checks and test event priorities.
test/​Retained/​RetainedPlugin.cs Adopt asynchronous hooks.
test/​Retained/​Retained.csproj Update contract and model references.
test/​Retained/​manifest.json Remove the legacy manifest.
test/​Retained/​hosihikari.json Add the new-format manifest.
test/​NativeProbe/​NativeProbePlugin.cs Adopt asynchronous hooks.
test/​NativeProbe/​NativeProbe.csproj Update contract and model references.
test/​NativeProbe/​manifest.json Remove the legacy manifest.
test/​NativeProbe/​hosihikari.json Add the new-format manifest.
test/​Foo/​manifest.json Remove the legacy manifest.
test/​Foo/​hosihikari.json Add the new-format manifest.
test/​Foo/​FooPlugin.cs Adopt asynchronous hooks.
test/​Foo/​Foo.csproj Update contract and model references.
test/​Bindings.Stub/​StubCarrier.cs Add carrier-component fixtures.
test/​Bindings.Stub/​Bindings.Stub.csproj Reference the component contract.
test/​Bar/​manifest.json Remove the legacy manifest.
test/​Bar/​hosihikari.json Add the new-format dependency manifest.
test/​Bar/​BarPlugin.cs Adopt asynchronous hooks.
test/​Bar/​Bar.csproj Update contract and model references.
src/​Resources/​CoreStrings.zh.resx Update Chinese runtime diagnostics.
src/​Resources/​CoreStrings.ru.resx Add Russian timeout and component messages.
src/​Resources/​CoreStrings.resx Add runtime, migration, and reload messages.
src/​Resources/​CoreStrings.fr.resx Add French timeout and component messages.
src/​Resources/​CoreStrings.es.resx Add Spanish timeout and component messages.
src/​Resources/​CoreStrings.ar.resx Add Arabic timeout and component messages.
src/​ReloadResult.cs Introduce structured reload outcomes.
src/​PluginState.cs Remove the manager-local state enum.
src/​PluginScope.cs Forward event priorities through scoped subscriptions.
src/​PluginManagerOptions.cs Add hook/component budgets and ownership settings.
src/​PluginManager.cs Implement asynchronous lifecycle driving, components, reload, and state events.
src/​PluginContext.cs Introduce kind-based context views.
src/​NativeHostingEntry.cs Set plugin ownership from hosting topology.
src/​ManifestReader.cs Read new metadata and reject legacy packages.
src/​Hosihikari.PluginManager.csproj Reference the v3 contract and model.
src/​EventBus.cs Dispatch events across six priority levels.
src/​CarrierComponentContext.cs Provide component logging and event access.
src/​AssemblyPluginLoader.cs Read carrier-declared shared assemblies.
host/​ScriptPluginLoader.cs Adopt asynchronous fixture hooks.
host/​RegressionChecks.cs Update metadata and migration regression checks.
host/​Program.cs Add lifecycle, carrier, envelope, and reload assertions.
host/​PinnedPluginLoader.cs Adopt asynchronous fixture hooks.
host/​HookPluginLoader.cs Add asynchronous and timeout hook fixtures.
host/​GuardedPluginLoader.cs Update hooks and fault reporting.
host/​DiagnosticsPluginLoader.cs Return structured validation diagnostics.
.github/​workflows/​verify.yml Select matching branches for sibling repositories.

Review effort: Balanced

Comment thread src/PluginManager.cs Outdated
budget.CancelAfter(_componentStopTimeout);
}

var task = RunOffPool(() => call(budget.Token));
Comment thread src/PluginManager.cs Outdated
// 预算用 CTS 的 CancelAfter 而不是 WaitAsync(TimeSpan):后者的定时器要等 Task 完成才摘掉,
// 会把钩子闭包(进而把插件的 ALC)钉住一整个超时时长(ADR-0023)。
using var budget = CreateHookBudget();
var task = RunOffPool(() => call(budget.Token));
Comment thread src/PluginManager.cs Outdated
{
var result = plugin.OnDisable();
if (!result.Allowed)
if (!TryInvokeHook(name, "OnDisable", plugin.OnDisable, reportList, out var disableResult))
Comment thread src/PluginManager.cs Outdated
private void PublishState(string name, PluginState previous, PluginState current)
{
var notification = new PluginStateChanged(name, previous, current);
_ = Task.Run(() => _events.Publish(notification));
Comment thread src/PluginManager.cs Outdated
if (!TryInvokeHook(
manifest.Name,
"OnLoad",
token => plugin.OnLoad(context, token),
Comment thread src/Resources/CoreStrings.resx Outdated
<value>{0}: legacy package (manifest.json only, api_version 2 or older) - run 'hosihikari-pack migrate {0}' and pack again</value>
</data>
<data name="Manager_ReloadParented" xml:space="preserve">
<value>{0}: 父级在场时不提供重载;插件的启停由父级驱动(ADR-0003)</value>
Comment thread tools/Pack/Packager.cs Outdated

foreach (var assembly in carrier.SharedAssemblies)
{
if (!string.IsNullOrWhiteSpace(assembly) && !File.Exists(Path.Combine(sourceDirectory, assembly)))
Comment thread tools/Pack/Packager.cs
Comment on lines +845 to +846
var assemblyPath = Path.Combine(sourceDirectory, component.Assembly);
if (!File.Exists(assemblyPath))
Comment thread tools/Pack/Packager.cs

// 在只读元数据里契约是另一套类型对象,按名字认(与 IsEntryPoint 同理)。
// 抽象类装配不了;静态类也是 IsAbstract,一并拦掉。
if (!type.IsClass || type.IsAbstract || !ImplementsCarrierComponent(type))
Comment thread tools/Pack/Packager.cs
File.ReadAllText(legacyPath),
new JsonSerializerOptions { PropertyNameCaseInsensitive = true });
}
catch (JsonException ex)
重载验收需要一个没有依赖者的包;A39 原先卸载 Bar,而 Lua 依赖它,
CI 上按依赖图拒绝卸载。两处都改成指向自己的目标。

@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: 72ccc6c9fe

ℹ️ 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 +325 to +326
if (assembly.GetType(component.Type, throwOnError: false) is not { } type
|| Activator.CreateInstance(type) is not ICarrierComponent instance)

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 Catch component construction failures during startup

If a declared component lacks a public parameterless constructor or its constructor throws, Activator.CreateInstance throws outside either startup exception handler. ValidateCarrier currently accepts such types, so a successfully packed carrier can trigger this path. Instead of returning false and reporting the failed component as documented, StartComponents exits with an exception, skips subsequent components, and never reports the accumulated diagnostics. Catch construction failures and route them through the existing component-failure reporting path.

Useful? React with 👍 / 👎.

Comment thread src/PluginManager.cs Outdated
private void PublishState(string name, PluginState previous, PluginState current)
{
var notification = new PluginStateChanged(name, previous, current);
_ = Task.Run(() => _events.Publish(notification));

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 Serialize state-change notification delivery

When a plugin is loaded and then immediately unloaded or reloaded, each transition is dispatched through an independent Task.Run. These tasks can publish concurrently or in reverse order, contrary to the ordering promised above this method. A subscriber can therefore receive Loaded→Detached before Detached→Loaded and finish with an incorrect view of the plugin's state. Use an ordered notification queue or another serialized dispatcher while retaining delivery outside _gate; the A59 check currently verifies only that both events exist, not their order.

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: be464050c5

ℹ️ 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
return ReloadResult.Failed(CoreText.Get("Manager_ReloadDisableFailed", name));
}

var unloaded = Unload(name);

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 Avoid invoking OnDisable twice during Reload

For an enabled plugin, Disable(name) already invokes OnDisable and sets slot.Stopped, but the subsequent Unload(name) enters Detach, which invokes OnDisable unconditionally without checking that flag. The new Reload operation therefore calls the stop hook twice in one lifecycle cycle. A plugin that releases resources on the first call can throw or refuse the second call, preventing an otherwise valid reload. Have the unload path honor slot.Stopped so Reload performs a single disable before unloading.

Useful? React with 👍 / 👎.

Comment thread src/PluginManager.cs Outdated
Comment on lines 1380 to 1385
_loading.Remove(slot.Id);
_pendingFaults.Remove(slot.Id);
}
if (!loaded)
{
RemoveLoaders(slot.Id);

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 Reject loader registrations from timed-out load instances

If a loader package's OnLoad ignores cancellation and registers its loader after the hook timeout, rollback can finish before that registration occurs. RemoveLoaders only removes registrations already present, while the retained context's RegisterLoader still calls TryAddLoader and MarkLoader without checking whether its instance remains valid. This leaves a failed, unregistered package's loader permanently routing future loads and can cause duplicate-ID failures when the package is retried. Invalidate registration capability atomically with rollback and reject registrations from the abandoned instance.

Useful? React with 👍 / 👎.

Comment thread src/PluginManager.cs Outdated
Comment on lines +350 to +355
lock (_gate)
{
_componentsStarted = true;
}

return reports.Count == 0;

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 Preserve component startup failure on subsequent calls

When a component assembly fails to load or StartAsync throws or times out, this method returns false but still sets _componentsStarted to true. A subsequent StartComponents call then immediately returns true without attempting the failed components, even if no component ever started. This lets a startup retry report success with required components absent. Track successful completion separately from partial startup, preserving the failure result or retrying only the components that did not start.

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: 550e6acda3

ℹ️ 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

try
{
call(budget.Token).AsTask().WaitAsync(budget.Token).GetAwaiter().GetResult();

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 Enforce the component stop budget during synchronous execution

If a component's StopAsync blocks before returning its ValueTask (for example, while waiting synchronously for native listeners to drain), call(budget.Token) blocks the shutdown thread before WaitAsync is reached. Cancelling the token cannot interrupt that call, so even a finite ComponentStopTimeout permits shutdown to hang indefinitely and prevents subsequent components from stopping. Ensure the stop deadline also covers the synchronous portion of component execution, rather than only awaiting the returned task.

Useful? React with 👍 / 👎.

Comment thread src/PluginManager.cs
Comment on lines +380 to +383
if (!TryInvokeComponent(component.Type, token => instance.StartAsync(context, token), reports))
{
ok = false;
break;

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 Include the failing component in startup cleanup

If StartAsync subscribes to context.Events or acquires native resources and then throws or is cancelled, this branch discards the instance before adding it to started. The rollback loop therefore stops only earlier components, and a later StopComponents cannot clean up the failing instance either. Because CarrierComponentContext exposes the raw event bus without scoped cleanup, its subscriptions can remain active, and retrying startup can install duplicate handlers or listeners. Retain the attempted instance for cleanup and invoke its stop path when startup fails.

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: ab9af9d501

ℹ️ 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
{
try
{
TryInvokeHook(slot, hook, cleanup, reports);

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 Drain fault reports queued by rollback hooks

When a failed load's cleanup OnDisable or OnUnload calls context.ReportFault, TryInvokeHook marks the instance in _hooking, so ReportFault queues the diagnostic in _pendingFaults. However, the load's final removal from that dictionary has already happened before these cleanup hooks run, and CleanupHook never drains it afterward. The cleanup fault is therefore never reported and its diagnostic remains retained for the lifetime of the manager; repeated failed loads accumulate these entries. Drain and report pending faults after rollback hooks, including when a hook throws.

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: 8f85c5b5fc

ℹ️ 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 tools/Pack/Packager.cs Outdated
Comment on lines +901 to +904
if (item.GetString() is { Length: > 0 } text)
{
packages.Add(text);
return;

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 Split legacy package lists when migrating manifests

When a 1.x manifest declares multiple dependencies in extraInfo.packages, such as "A/1.0.0,B/2.0.0", migration copies the entire string into one pack.packages entry. The previous ReadPackages implementation explicitly split this field on commas, whereas the new implementation treats each array entry as one package reference. Consequently, migration reports success and deletes the old manifest, but subsequent packing passes 1.0.0,B/2.0.0 as A's version to RestorePackages and fails. Split legacy strings with the previous trimming and empty-entry handling before writing the new array.

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: df580e412c

ℹ️ 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 +1578 to +1580
try
{
ReportFault(manifest.Name, slot.Id, late);

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 Process late load faults after releasing the manager lock

If a background fault arrives between the final pending-fault check and removal from _loading, this branch calls ReportFault while Load or LoadAll still holds _gate around LoadOne. Although ReportFault exits its own lock blocks before invoking ReportAll and _onRemoved, the outer lock remains held. A parent callback that waits for another thread accessing the manager can therefore deadlock—the same callback-lock ordering exercised by A43 in host/Program.cs. Defer processing this fault until the outer load operation has released _gate.

Useful? React with 👍 / 👎.

Comment thread src/PluginManager.cs
}

return result.Reason ?? CoreText.Get("Common_NoReason");
return disableResult.Reason ?? CoreText.Get("Common_NoReason");

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 Drain queued faults before returning a disable refusal

When OnDisable calls context.ReportFault(...) and then returns a refusal during Unload, the diagnostic is queued because the instance is in _hooking, but this return bypasses TakePendingFault below. The unload reports only the refusal, leaving the fault unreported in _pendingFaults while the plugin remains active; without another lifecycle operation, nothing consumes it. Drain and report the queued diagnostic on the refusal path as well.

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. Hooray!

Reviewed commit: c675acc946

ℹ️ 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: 862f15971a

ℹ️ 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 tools/Pack/Program.cs Outdated
Comment on lines +168 to +170
if (Path.GetFullPath(file).StartsWith(skipRoot, comparison))
{
continue;

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 Preserve source files when the output root is an ancestor

When outputRoot contains sourceDirectory, the new filter skips every source file rather than just previously generated packages. For example, packing from /project/bin/Release/net10.0 into /project now produces an empty staging directory and fails the assembly-entry check, even though the resulting /project/Foo package would not overlap the build output. Apply this exclusion only when the output directory is nested within the source directory, or exclude the actual generated package directory instead.

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: a68ad4b37b

ℹ️ 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 12f4389 into main Nov 17, 2026
5 checks passed
@residua1
residua1 deleted the v2 branch November 17, 2026 08:18
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.

3 participants