@@ -58,7 +58,20 @@ const MOCK_REGISTRY_BLOCKS: Record<string, unknown> = {
5858 mothership : {
5959 type : 'mothership' ,
6060 name : 'Sim Chat' ,
61- subBlocks : [ { id : 'tools' , type : 'tool-input' } ] ,
61+ subBlocks : [
62+ { id : 'prompt' , type : 'long-input' } ,
63+ { id : 'tools' , type : 'tool-input' } ,
64+ { id : 'secretScope' , type : 'dropdown' , hideFromCopilot : true } ,
65+ { id : 'mountedSecrets' , type : 'dropdown' , hideFromCopilot : true } ,
66+ ] ,
67+ } ,
68+ mothership_next : {
69+ type : 'mothership_next' ,
70+ name : 'Sim Chat Next' ,
71+ subBlocks : [
72+ { id : 'prompt' , type : 'long-input' } ,
73+ { id : 'secretScope' , type : 'dropdown' , hideFromCopilot : true } ,
74+ ] ,
6275 } ,
6376 function : {
6477 type : 'function' ,
@@ -233,9 +246,16 @@ function isCredentialField(blockType: string, field: string): boolean {
233246 return config ?. subBlocks . some ( ( sb ) => sb . id === field && sb . type === 'oauth-input' ) ?? false
234247}
235248
236- function toolInputField ( blockType : string , field : string ) : boolean {
237- const config = MOCK_REGISTRY_BLOCKS [ blockType ] as { subBlocks : { id : string ; type : string } [ ] }
238- return config ?. subBlocks . some ( ( sb ) => sb . id === field && sb . type === 'tool-input' ) ?? false
249+ /** An engine validation error source apply raises only for Copilot: a tool binding or hidden field. */
250+ function copilotGatedField ( blockType : string , field : string ) : boolean {
251+ const config = MOCK_REGISTRY_BLOCKS [ blockType ] as {
252+ subBlocks : { id : string ; type : string ; hideFromCopilot ?: boolean } [ ]
253+ }
254+ return (
255+ config ?. subBlocks . some (
256+ ( sb ) => sb . id === field && ( sb . type === 'tool-input' || sb . hideFromCopilot === true )
257+ ) ?? false
258+ )
239259}
240260
241261async function engineRefusals ( testCase : ParityCase ) : Promise < string [ ] > {
@@ -269,7 +289,7 @@ async function engineRefusals(testCase: ParityCase): Promise<string[]> {
269289 if ( ! isDeferredSkippedItem ( item ) ) refusals . add ( `${ item . type } :${ item . blockId } ` )
270290 }
271291 for ( const error of result . validationErrors ) {
272- if ( testCase . isCopilot && toolInputField ( error . blockType , error . field ) ) {
292+ if ( testCase . isCopilot && copilotGatedField ( error . blockType , error . field ) ) {
273293 refusals . add ( `invalid_subblock_field:${ error . blockId } ` )
274294 }
275295 }
@@ -323,6 +343,23 @@ const lockedLoopBase = graph(
323343 block ( ID . b , 'agent' , 'Outside' , { sub : { systemPrompt : 'old' } } )
324344)
325345
346+ /** Sets a stored Sim Chat block's server-managed fields; Copilot is refused, a user is not. */
347+ const setServerManagedFields = {
348+ base : graph ( block ( ID . a , 'mothership' , 'Sim Chat' , { sub : { prompt : 'hi' } } ) ) ,
349+ operations : [
350+ {
351+ operation_type : 'edit' ,
352+ block_id : ID . a ,
353+ params : { inputs : { secretScope : 'selected' , mountedSecrets : [ 'FOO' ] } } ,
354+ } ,
355+ ] ,
356+ target : graph (
357+ block ( ID . a , 'mothership' , 'Sim Chat' , {
358+ sub : { prompt : 'hi' , secretScope : 'selected' , mountedSecrets : [ 'FOO' ] } ,
359+ } )
360+ ) ,
361+ } satisfies Pick < ParityCase , 'base' | 'operations' | 'target' >
362+
326363const CASES : ParityCase [ ] = [
327364 // editing/operations.test.ts › sunset block types
328365 {
@@ -735,6 +772,56 @@ const CASES: ParityCase[] = [
735772 isCopilot : true ,
736773 expected : [ `invalid_subblock_field:${ ID . a } ` ] ,
737774 } ,
775+ // editing/validation.test.ts › hideFromCopilot fields (server-managed)
776+ {
777+ name : 'copilot: refuses setting a server-managed field on a stored block' ,
778+ ...setServerManagedFields ,
779+ isCopilot : true ,
780+ expected : [ `invalid_subblock_field:${ ID . a } ` ] ,
781+ } ,
782+ {
783+ name : 'copilot: refuses a new block that sets a server-managed field' ,
784+ base : graph ( ) ,
785+ operations : [
786+ {
787+ operation_type : 'add' ,
788+ block_id : ID . a ,
789+ params : { type : 'mothership' , name : 'Sim Chat' , inputs : { secretScope : 'all' } } ,
790+ } ,
791+ ] ,
792+ target : graph ( block ( ID . a , 'mothership' , 'Sim Chat' , { sub : { secretScope : 'all' } } ) ) ,
793+ isCopilot : true ,
794+ expected : [ `invalid_subblock_field:${ ID . a } ` ] ,
795+ } ,
796+ {
797+ name : 'copilot: a stored server-managed value the edit leaves alone is not refused' ,
798+ base : graph (
799+ block ( ID . a , 'mothership' , 'Sim Chat' , {
800+ sub : { prompt : 'hi' , secretScope : 'selected' , mountedSecrets : [ 'FOO' ] } ,
801+ } )
802+ ) ,
803+ operations : [ { operation_type : 'edit' , block_id : ID . a , params : { inputs : { prompt : 'bye' } } } ] ,
804+ target : graph (
805+ block ( ID . a , 'mothership' , 'Sim Chat' , {
806+ sub : { prompt : 'bye' , secretScope : 'selected' , mountedSecrets : [ 'FOO' ] } ,
807+ } )
808+ ) ,
809+ isCopilot : true ,
810+ expected : [ ] ,
811+ } ,
812+ {
813+ name : 'copilot: a retype keeping a stored server-managed value is not refused' ,
814+ base : graph ( block ( ID . a , 'mothership' , 'Sim Chat' , { sub : { secretScope : 'selected' } } ) ) ,
815+ operations : [ { operation_type : 'edit' , block_id : ID . a , params : { type : 'mothership_next' } } ] ,
816+ target : graph ( block ( ID . a , 'mothership_next' , 'Sim Chat' , { sub : { secretScope : 'selected' } } ) ) ,
817+ isCopilot : true ,
818+ expected : [ ] ,
819+ } ,
820+ {
821+ name : 'user: accepts setting a server-managed field' ,
822+ ...setServerManagedFields ,
823+ expected : [ ] ,
824+ } ,
738825 // credentials (editing/validation.ts preValidateCredentialInputs)
739826 {
740827 name : 'credentials: refuses a credential the user cannot reach, on add and on edit' ,
0 commit comments