@@ -426,17 +426,24 @@ actor AgentTaskMetadataStore: AgentTaskPersisting {
426426 private static let directoryName = " .pine-agent-tasks-private "
427427
428428 private let storageRoot : URL ?
429+ /// Injectable so tests can exercise the production Application Support
430+ /// layout without touching the developer's real home directory. macOS may
431+ /// attach its own ACL to this trusted anchor; only Pine's child directory
432+ /// is required to be ACL-free and mode 0700.
433+ private let applicationSupportDirectory : URL ?
429434 private let limits : AgentTaskPersistenceLimits
430435 private let configuration : AgentTaskStoreConfiguration
431436 private let fileManager = FileManager ( )
432437 private var cleanupCursorByDirectory : [ AgentTaskCleanupDirectory : Int ] = [ : ]
433438
434439 init (
435440 storageRoot: URL ? = nil ,
441+ applicationSupportDirectory: URL ? = nil ,
436442 limits: AgentTaskPersistenceLimits = AgentTaskPersistenceLimits ( ) ,
437443 configuration: AgentTaskStoreConfiguration = AgentTaskStoreConfiguration ( )
438444 ) {
439445 self . storageRoot = storageRoot
446+ self . applicationSupportDirectory = applicationSupportDirectory
440447 self . limits = limits
441448 self . configuration = configuration
442449 }
@@ -740,10 +747,11 @@ actor AgentTaskMetadataStore: AgentTaskPersisting {
740747 if let storageRoot {
741748 return storageRoot. standardizedFileURL
742749 }
743- guard let base = fileManager. urls (
750+ let base = applicationSupportDirectory ?? fileManager. urls (
744751 for: . applicationSupportDirectory,
745752 in: . userDomainMask
746- ) . first else {
753+ ) . first
754+ guard let base else {
747755 return URL ( fileURLWithPath: " /dev/null/pine-agent-tasks " )
748756 }
749757 return base. resolvingSymlinksInPath ( )
@@ -757,7 +765,7 @@ actor AgentTaskMetadataStore: AgentTaskPersisting {
757765 let components = url. standardizedFileURL. pathComponents. dropFirst ( )
758766 let names = Array ( components)
759767 let privateCount = configuration. privateComponentCount
760- ?? ( storageRoot == nil ? 2 : 1 )
768+ ?? 1
761769 guard !names. isEmpty, ( 1 ... names. count) . contains ( privateCount) else {
762770 throw AgentTaskDirectoryError . unsafe
763771 }
0 commit comments