@@ -70,7 +70,13 @@ const withFakeSystemd = <A, E>(
7070 readonly calls : ReadonlyArray < ReadonlyArray < string > > ;
7171 readonly stateDir : string ;
7272 } ) => Effect . Effect < A , E > ,
73- { oomPolicy = true } : { readonly oomPolicy ?: boolean } = { } ,
73+ {
74+ oomPolicy = true ,
75+ delegate = true ,
76+ } : {
77+ readonly oomPolicy ?: boolean ;
78+ readonly delegate ?: boolean ;
79+ } = { } ,
7480) =>
7581 Effect . gen ( function * ( ) {
7682 const bin = NodeFS . mkdtempSync ( NodePath . join ( NodeOS . tmpdir ( ) , "t3-agent-scope-" ) ) ;
@@ -96,6 +102,9 @@ const withFakeSystemd = <A, E>(
96102 if ( ! oomPolicy && args . some ( ( arg ) => arg . startsWith ( "--property=OOMPolicy=" ) ) ) {
97103 return output ( "" , 1 ) ;
98104 }
105+ if ( ! delegate && args . some ( ( arg ) => arg . startsWith ( "--property=Delegate=" ) ) ) {
106+ return output ( "" , 1 ) ;
107+ }
99108 const [ , verb , unit = "" ] = args ;
100109 if ( verb === "reset-failed" ) units . delete ( unit ) ;
101110 if ( verb !== "show" ) return output ( "" ) ;
@@ -275,4 +284,17 @@ describe("AgentScope service", () => {
275284 } ) ,
276285 ) ,
277286 ) ;
287+
288+ it . effect ( "falls back when systemd rejects delegation" , ( ) =>
289+ withFakeSystemd (
290+ ( { scope } ) =>
291+ Effect . gen ( function * ( ) {
292+ const agent = yield * scope . wrap ( { command : "agent" , args : [ ] , name : "t" , threadId : "a" } ) ;
293+ expect ( agent . args ) . not . toContain ( "--property=Delegate=cpu cpuset io memory pids" ) ;
294+ expect ( agent . args ) . toContain ( "--property=OOMPolicy=stop" ) ;
295+ expect ( agent . args ) . toContain ( "--property=TimeoutStopSec=10s" ) ;
296+ } ) ,
297+ { delegate : false } ,
298+ ) ,
299+ ) ;
278300} ) ;
0 commit comments