namespace ZB.MOM.WW.OtOpcUa.Core.Scripting.Protocol;
///
/// The environment variables the host sets on a ScriptWorker (design §6). The nonce travels in the environment,
/// never on the command line (mxaccessgw WorkerBootstrap.md): a command line is world-readable on most
/// systems.
///
public static class ScriptWorkerEnvironment
{
/// The pipe name the worker connects to.
public const string PipeName = "OTOPCUA_SCRIPTWORKER_PIPE";
/// The one-time launch nonce the worker must echo in Ready.
public const string Nonce = "OTOPCUA_SCRIPTWORKER_NONCE";
/// The host's process id; the worker exits when it disappears.
public const string ParentPid = "OTOPCUA_SCRIPTWORKER_PARENT_PID";
/// The worker's shard label, for its own diagnostics.
public const string Shard = "OTOPCUA_SCRIPTWORKER_SHARD";
///
/// Exit code of a worker whose pipe reached end of stream (the host went away). Distinct from a crash so the
/// host's exit reason metric can tell them apart.
///
public const int ExitPipeClosed = 3;
/// Exit code of a worker whose handshake or framing failed.
public const int ExitProtocolFault = 4;
/// Exit code of a worker whose parent process disappeared.
public const int ExitParentGone = 5;
/// Exit code of a worker that found a forbidden assembly loaded in itself.
public const int ExitForbiddenAssembly = 6;
///
/// Assembly-name prefixes that must never be loaded in a worker (design §6): the host's cluster, database,
/// OPC UA and secrets stacks. The worker checks itself against this list and exits if it finds one.
///
public static readonly IReadOnlyList ForbiddenAssemblyPrefixes =
[
"Akka",
"Microsoft.Data.SqlClient",
"System.Data.SqlClient",
"Microsoft.EntityFrameworkCore",
"Opc.Ua",
"ZB.MOM.WW.Secrets",
"ZB.MOM.WW.OtOpcUa.Runtime",
"ZB.MOM.WW.OtOpcUa.Host",
"ZB.MOM.WW.OtOpcUa.Driver.",
"Grpc.",
];
}