Sidecar
sidecar
¶
Per-container supervisor sidecar JSON writer.
The terok-sandbox OCI hook (installed by terok-sandbox setup)
spawns one supervisor process per container at start. The hook is
triggered by — and reads from — the terok.sandbox.sidecar OCI
annotation; the annotation's value is the absolute path to the JSON
written here.
Schema mirrors the sandbox writer (terok_sandbox.launch._write_sidecar):
keys container_name, ipc_mode ("socket" or "tcp"),
db_path, scope_id, project_id, task_id, runtime_dir,
plus tcp_port / ssh_signer_port in TCP mode and an optional
dossier_path. When the git gate is wired the payload also carries
gate_base_path / gate_token (and gate_port in TCP mode) so
the per-container supervisor can serve the gate in-process. Socket
paths are deliberately absent — in socket mode the supervisor derives
them from the container name and runtime dir, so only the
freshly-allocated TCP ports need carrying.
The caller (AgentRunner.launch_prepared) emits the returned
path as the OCI annotation so the hook can find this file.
Path: <cfg.state_dir>/sidecar/<container-name>.json. The
single sidecar/ segment is the canonical location — no XDG
guessing, no nested terok/ infix — and matches what the
terok-sandbox writer also emits.
write_supervisor_sidecar(container_name, *, cfg, per_container, scope_id='', project_id='', task_id='', dossier_path=None, gate_base_path=None, gate_token=None, gate_port=None)
¶
Persist the per-container supervisor sidecar JSON.
Best-effort: a write failure is logged to stderr and returns
None — the supervisor will refuse to spawn (no sidecar = no
terok-managed container) but the launch itself isn't blocked.
Mirrors the soft-fail policy of
terok_sandbox.launch._write_sidecar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
container_name
|
str
|
The |
required |
cfg
|
SandboxConfig
|
Sandbox config — sources |
required |
scope_id
|
str
|
Credential scope; empty for non-scoped runs. |
''
|
project_id
|
str
|
Terok project ID; empty when not under a project. |
''
|
task_id
|
str
|
Terok task ID; empty for standalone executor runs. |
''
|
dossier_path
|
Path | str | None
|
Optional path to the per-task dossier file the
shield reads; |
None
|
gate_base_path
|
str | None
|
Absolute path to the dir holding the per-project
bare mirrors the supervisor's gate serves; |
None
|
gate_token
|
str | None
|
Per-container gate access token the supervisor
validates in-process; |
None
|
gate_port
|
int | None
|
TCP port the gate listens on (TCP mode only);
|
None
|
Returns:
| Type | Description |
|---|---|
Path | None
|
The written sidecar path, or |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/terok_executor/container/sidecar.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | |