@@ -172,6 +172,7 @@ const mocks = vi.hoisted(() => ({
172172 requirement : hit . reason ,
173173 } ) ,
174174 ) ,
175+ collectBundledChannelPackageStateLoadFailures : vi . fn ( ( ) => [ ] as unknown [ ] ) ,
175176 collectStalePluginRuntimeSymlinkHealthFindings : vi . fn ( async ( ) => [ ] as unknown [ ] ) ,
176177 collectChannelPreviewWarningHealthFindings : vi . fn (
177178 async ( ) : Promise < readonly HealthFinding [ ] > => [ ] ,
@@ -514,6 +515,12 @@ vi.mock("../commands/doctor/shared/channel-plugin-blockers.js", () => ({
514515 channelPluginBlockerHitToHealthFinding : mocks . channelPluginBlockerHitToHealthFinding ,
515516} ) ) ;
516517
518+ vi . mock ( "../channels/plugins/package-state-probes.js" , async ( importOriginal ) => ( {
519+ ...( await importOriginal < typeof import ( "../channels/plugins/package-state-probes.js" ) > ( ) ) ,
520+ collectBundledChannelPackageStateLoadFailures :
521+ mocks . collectBundledChannelPackageStateLoadFailures ,
522+ } ) ) ;
523+
517524vi . mock ( "./doctor-startup-channel-maintenance.js" , async ( importOriginal ) => {
518525 const actual = await importOriginal < typeof import ( "./doctor-startup-channel-maintenance.js" ) > ( ) ;
519526 return {
@@ -805,6 +812,8 @@ describe("doctor health contributions", () => {
805812 mocks . scanConfiguredChannelPluginBlockers . mockReset ( ) ;
806813 mocks . scanConfiguredChannelPluginBlockers . mockReturnValue ( [ ] ) ;
807814 mocks . channelPluginBlockerHitToHealthFinding . mockClear ( ) ;
815+ mocks . collectBundledChannelPackageStateLoadFailures . mockReset ( ) ;
816+ mocks . collectBundledChannelPackageStateLoadFailures . mockReturnValue ( [ ] ) ;
808817 mocks . collectStalePluginRuntimeSymlinkHealthFindings . mockReset ( ) ;
809818 mocks . collectStalePluginRuntimeSymlinkHealthFindings . mockResolvedValue ( [ ] ) ;
810819 mocks . collectChannelPreviewWarningHealthFindings . mockReset ( ) ;
@@ -2341,6 +2350,7 @@ describe("doctor health contributions", () => {
23412350 expect ( contributionIds ) . toContain ( "core/doctor/whatsapp-responsiveness" ) ;
23422351 expect ( contributionIds ) . toContain ( "core/doctor/device-pairing" ) ;
23432352 expect ( contributionIds ) . toContain ( "core/doctor/channel-plugin-blockers" ) ;
2353+ expect ( contributionIds ) . toContain ( "core/doctor/channel-package-state-capabilities" ) ;
23442354 expect ( contributionIds ) . toContain ( "core/doctor/channel-preview-warnings" ) ;
23452355 expect ( contributionIds ) . toContain ( "core/doctor/systemd-linger" ) ;
23462356 expect ( contributionChecks . map ( ( check ) => check . id ) ) . toEqual ( contributionIds ) ;
@@ -3058,6 +3068,41 @@ describe("doctor health contributions", () => {
30583068 expect ( mocks . scanConfiguredChannelPluginBlockers ) . toHaveBeenCalledWith ( ctx . cfg , process . env ) ;
30593069 } ) ;
30603070
3071+ it ( "reports channel package-state capability load failures by default" , async ( ) => {
3072+ const contributionChecks = await resolveDoctorContributionHealthChecks ( ) ;
3073+ const capabilityCheck = contributionChecks . find (
3074+ ( check ) => check . id === "core/doctor/channel-package-state-capabilities" ,
3075+ ) ;
3076+ expect ( capabilityCheck ) . toMatchObject ( { defaultEnabled : true } ) ;
3077+ expect ( capabilityCheck ) . toBeDefined ( ) ;
3078+ mocks . collectBundledChannelPackageStateLoadFailures . mockReturnValue ( [
3079+ {
3080+ detail : "plugin module path not found: /plugins/example-chat/auth-presence" ,
3081+ metadataKey : "persistedAuthState" ,
3082+ pluginId : "example-chat" ,
3083+ } ,
3084+ ] ) ;
3085+
3086+ const ctx = {
3087+ cfg : { } ,
3088+ mode : "lint" ,
3089+ runtime : { log : vi . fn ( ) , error : vi . fn ( ) , exit : vi . fn ( ) } ,
3090+ } as const ;
3091+
3092+ await expect ( runDoctorLintChecks ( ctx , { checks : [ capabilityCheck ! ] } ) ) . resolves . toMatchObject ( {
3093+ checksRun : 1 ,
3094+ checksSkipped : 0 ,
3095+ findings : [
3096+ expect . objectContaining ( {
3097+ checkId : "core/doctor/channel-package-state-capabilities" ,
3098+ severity : "warning" ,
3099+ target : "example-chat" ,
3100+ requirement : "declared-channel-package-state-capability-loadable" ,
3101+ } ) ,
3102+ ] ,
3103+ } ) ;
3104+ } ) ;
3105+
30613106 it ( "keeps channel preview warnings opt-in for default lint selection" , async ( ) => {
30623107 const contribution = requireDoctorContribution ( "doctor:startup-channel-maintenance" ) ;
30633108 expect ( contribution . healthCheckIds ) . toEqual ( [
0 commit comments