@@ -42,7 +42,13 @@ const withFakeSystemd = <A, E>(
4242 readonly calls : ReadonlyArray < ReadonlyArray < string > > ;
4343 readonly stateDir : string ;
4444 } ) => Effect . Effect < A , E > ,
45- { oomPolicy = true } : { readonly oomPolicy ?: boolean } = { } ,
45+ {
46+ oomPolicy = true ,
47+ delegate = true ,
48+ } : {
49+ readonly oomPolicy ?: boolean ;
50+ readonly delegate ?: boolean ;
51+ } = { } ,
4652) =>
4753 Effect . gen ( function * ( ) {
4854 const bin = NodeFS . mkdtempSync ( NodePath . join ( NodeOS . tmpdir ( ) , "t3-agent-scope-" ) ) ;
@@ -68,6 +74,9 @@ const withFakeSystemd = <A, E>(
6874 if ( ! oomPolicy && args . some ( ( arg ) => arg . startsWith ( "--property=OOMPolicy=" ) ) ) {
6975 return output ( "" , 1 ) ;
7076 }
77+ if ( ! delegate && args . some ( ( arg ) => arg . startsWith ( "--property=Delegate=" ) ) ) {
78+ return output ( "" , 1 ) ;
79+ }
7180 const [ , verb , unit = "" ] = args ;
7281 if ( verb === "reset-failed" ) units . delete ( unit ) ;
7382 if ( verb !== "show" ) return output ( "" ) ;
@@ -208,4 +217,17 @@ describe("AgentScope service", () => {
208217 } ) ,
209218 ) ,
210219 ) ;
220+
221+ it . effect ( "falls back when systemd rejects delegation" , ( ) =>
222+ withFakeSystemd (
223+ ( { scope } ) =>
224+ Effect . gen ( function * ( ) {
225+ const agent = yield * scope . wrap ( { command : "agent" , args : [ ] , name : "t" , threadId : "a" } ) ;
226+ expect ( agent . args ) . not . toContain ( "--property=Delegate=cpu cpuset io memory pids" ) ;
227+ expect ( agent . args ) . toContain ( "--property=OOMPolicy=stop" ) ;
228+ expect ( agent . args ) . toContain ( "--property=TimeoutStopSec=10s" ) ;
229+ } ) ,
230+ { delegate : false } ,
231+ ) ,
232+ ) ;
211233} ) ;
0 commit comments