@sealant/api-contracts-next 0.40.0-next.936 → 0.40.0-next.938

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,41 @@
1
+ /**
2
+ * An executor's control scope (workspace isolation architecture §6.1): the one subdirectory of
3
+ * the deployment's control root (Mend's `mend-control` volume, `WORKSPACE_CONTROL_SOCKET_HOST_DIR`)
4
+ * that the executor mounts at `/run/sealant`. sealantd binds `control.sock` there; the caller
5
+ * binds the executor's two channels to it there before the executor dials them:
6
+ *
7
+ * - `capture.sock`: captures and presigned object requests. On `host-vm`, sealantd always dials
8
+ * it (vsock 1025, relayed to the socket); on `docker`, when the spec asks for it
9
+ * (`runtime.executorSockets.capture`). A recovery boot dials only this one.
10
+ * - `session.sock`: the session channel. On `host-vm`, relayed from vsock 1027 on normal boots
11
+ * only; on `docker`, reachable by the workspace's non-root processes when the spec asks for it
12
+ * (`runtime.executorSockets.session`).
13
+ *
14
+ * A create may name the scope (`controlScope`); without one it is the executor's container name.
15
+ * Either way the executor reports it (`runtime.controlScope`).
16
+ *
17
+ * Deliberately dependency-free, like `network-policy.ts`: data plus pure functions, shared by the
18
+ * SDK (client-side refusal with the server's wording), the API and the runtimes.
19
+ */
20
+ /** One path segment: lowercase letters, digits, `_`, `.` and `-`, starting with a letter or digit. */
21
+ export declare const CONTROL_SCOPE_PATTERN: RegExp;
22
+ /**
23
+ * What no caller's scope may start with: every directory sealant makes in the control root (each
24
+ * executor's `sealant-<run>` or `sealant-vm-<run>`, each egress proxy's `<name>-proxy`, which holds
25
+ * its admin socket) starts with it. So a scope a caller names can never be another executor's or
26
+ * a proxy's directory.
27
+ */
28
+ export declare const RESERVED_CONTROL_SCOPE_PREFIX = "sealant";
29
+ /** Where an executor's control scope is mounted inside it. */
30
+ export declare const EXECUTOR_CONTROL_MOUNT = "/run/sealant";
31
+ /** The caller's capture relay in an executor's control scope. */
32
+ export declare const EXECUTOR_CAPTURE_SOCKET = "capture.sock";
33
+ /** The caller's session channel in an executor's control scope. */
34
+ export declare const EXECUTOR_SESSION_SOCKET = "session.sock";
35
+ /** Why a control scope is refused: constant words, never the value, so a refusal can repeat them. */
36
+ export declare const CONTROL_SCOPE_PROBLEMS: {
37
+ readonly shape: "must be one path segment of at most 128 lowercase letters, digits, '_', '.' or '-', starting with a letter or digit";
38
+ readonly reserved: "may not start with 'sealant': sealant's own directories in the control root do";
39
+ };
40
+ /** Why `scope` cannot be a control scope a create names, or undefined when it can. */
41
+ export declare const controlScopeProblem: (scope: string) => string | undefined;
@@ -0,0 +1,47 @@
1
+ /**
2
+ * An executor's control scope (workspace isolation architecture §6.1): the one subdirectory of
3
+ * the deployment's control root (Mend's `mend-control` volume, `WORKSPACE_CONTROL_SOCKET_HOST_DIR`)
4
+ * that the executor mounts at `/run/sealant`. sealantd binds `control.sock` there; the caller
5
+ * binds the executor's two channels to it there before the executor dials them:
6
+ *
7
+ * - `capture.sock`: captures and presigned object requests. On `host-vm`, sealantd always dials
8
+ * it (vsock 1025, relayed to the socket); on `docker`, when the spec asks for it
9
+ * (`runtime.executorSockets.capture`). A recovery boot dials only this one.
10
+ * - `session.sock`: the session channel. On `host-vm`, relayed from vsock 1027 on normal boots
11
+ * only; on `docker`, reachable by the workspace's non-root processes when the spec asks for it
12
+ * (`runtime.executorSockets.session`).
13
+ *
14
+ * A create may name the scope (`controlScope`); without one it is the executor's container name.
15
+ * Either way the executor reports it (`runtime.controlScope`).
16
+ *
17
+ * Deliberately dependency-free, like `network-policy.ts`: data plus pure functions, shared by the
18
+ * SDK (client-side refusal with the server's wording), the API and the runtimes.
19
+ */
20
+ /** One path segment: lowercase letters, digits, `_`, `.` and `-`, starting with a letter or digit. */
21
+ export const CONTROL_SCOPE_PATTERN = /^[a-z0-9][a-z0-9_.-]{0,127}$/;
22
+ /**
23
+ * What no caller's scope may start with: every directory sealant makes in the control root (each
24
+ * executor's `sealant-<run>` or `sealant-vm-<run>`, each egress proxy's `<name>-proxy`, which holds
25
+ * its admin socket) starts with it. So a scope a caller names can never be another executor's or
26
+ * a proxy's directory.
27
+ */
28
+ export const RESERVED_CONTROL_SCOPE_PREFIX = "sealant";
29
+ /** Where an executor's control scope is mounted inside it. */
30
+ export const EXECUTOR_CONTROL_MOUNT = "/run/sealant";
31
+ /** The caller's capture relay in an executor's control scope. */
32
+ export const EXECUTOR_CAPTURE_SOCKET = "capture.sock";
33
+ /** The caller's session channel in an executor's control scope. */
34
+ export const EXECUTOR_SESSION_SOCKET = "session.sock";
35
+ /** Why a control scope is refused: constant words, never the value, so a refusal can repeat them. */
36
+ export const CONTROL_SCOPE_PROBLEMS = {
37
+ shape: "must be one path segment of at most 128 lowercase letters, digits, '_', '.' or '-', starting with a letter or digit",
38
+ reserved: `may not start with '${RESERVED_CONTROL_SCOPE_PREFIX}': sealant's own directories in the control root do`,
39
+ };
40
+ /** Why `scope` cannot be a control scope a create names, or undefined when it can. */
41
+ export const controlScopeProblem = (scope) => {
42
+ if (!CONTROL_SCOPE_PATTERN.test(scope))
43
+ return CONTROL_SCOPE_PROBLEMS.shape;
44
+ if (scope.startsWith(RESERVED_CONTROL_SCOPE_PREFIX))
45
+ return CONTROL_SCOPE_PROBLEMS.reserved;
46
+ return undefined;
47
+ };