File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -50,8 +50,11 @@ export declare const MIN_CONTENT_LENGTH: number
5050 */
5151export declare const REQUIRED_KEYWORDS : readonly [ "agent" , "task" ]
5252
53- /** Required fields in YAML frontmatter */
54- export declare const REQUIRED_FRONTMATTER_FIELDS : string [ ]
53+ /**
54+ * Required fields in YAML frontmatter.
55+ * Frozen to prevent accidental mutation.
56+ */
57+ export declare const REQUIRED_FRONTMATTER_FIELDS : readonly [ "version" , "requires" ]
5558
5659/**
5760 * Get the package root directory from a module's import.meta.url
Original file line number Diff line number Diff line change @@ -56,8 +56,11 @@ export const MIN_CONTENT_LENGTH = 100
5656 */
5757export const REQUIRED_KEYWORDS = [ "agent" , "task" ]
5858
59- /** Required fields in YAML frontmatter */
60- export const REQUIRED_FRONTMATTER_FIELDS = [ "version" , "requires" ]
59+ /**
60+ * Required fields in YAML frontmatter.
61+ * Frozen to prevent accidental mutation.
62+ */
63+ export const REQUIRED_FRONTMATTER_FIELDS = Object . freeze ( [ "version" , "requires" ] )
6164
6265/**
6366 * Get the package root directory from a module's import.meta.url
Original file line number Diff line number Diff line change @@ -571,6 +571,34 @@ This is a test agent that handles various tasks for you.
571571 expect ( result . error ) . toContain ( "version" )
572572 expect ( result . error ) . toContain ( "requires" )
573573 } )
574+
575+ it ( "should be frozen (immutable)" , ( ) => {
576+ expect ( Object . isFrozen ( REQUIRED_FRONTMATTER_FIELDS ) ) . toBe ( true )
577+ } )
578+
579+ it ( "should prevent push to REQUIRED_FRONTMATTER_FIELDS" , ( ) => {
580+ const originalLength = REQUIRED_FRONTMATTER_FIELDS . length
581+ expect ( ( ) => {
582+ ; ( REQUIRED_FRONTMATTER_FIELDS as unknown as string [ ] ) . push ( "new-field" )
583+ } ) . toThrow ( )
584+ expect ( REQUIRED_FRONTMATTER_FIELDS . length ) . toBe ( originalLength )
585+ } )
586+
587+ it ( "should prevent modification of REQUIRED_FRONTMATTER_FIELDS elements" , ( ) => {
588+ const originalFirst = REQUIRED_FRONTMATTER_FIELDS [ 0 ]
589+ expect ( ( ) => {
590+ ; ( REQUIRED_FRONTMATTER_FIELDS as unknown as string [ ] ) [ 0 ] = "modified"
591+ } ) . toThrow ( )
592+ expect ( REQUIRED_FRONTMATTER_FIELDS [ 0 ] ) . toBe ( originalFirst )
593+ } )
594+
595+ it ( "should prevent pop from REQUIRED_FRONTMATTER_FIELDS" , ( ) => {
596+ const originalLength = REQUIRED_FRONTMATTER_FIELDS . length
597+ expect ( ( ) => {
598+ ; ( REQUIRED_FRONTMATTER_FIELDS as unknown as string [ ] ) . pop ( )
599+ } ) . toThrow ( )
600+ expect ( REQUIRED_FRONTMATTER_FIELDS . length ) . toBe ( originalLength )
601+ } )
574602 } )
575603
576604 it ( "should export TRANSIENT_ERROR_CODES as an array" , ( ) => {
You can’t perform that action at this time.
0 commit comments