Introducing a new way to review your PRs.

Read the announcement

getarcaneapp / arcane

Modern Docker Management, Designed for Everyone

View on GitHub

26 documents · Updated Oct 19, 2026

docs / domain-types-and-protocol-contracts

Domain types and protocol contracts

The shared domain types and tunnel protocol define the common language between Arcane services and clients. The type packages describe resource data and API payloads, while the tunnel contract describes how a manager and an edge agent exchange requests, events, streams, and control messages.

Shared domain type model

Resource type packages

The shared types use one Go package for each major product domain. These packages keep resource names, request shapes, response shapes, and allowed values consistent wherever the domain crosses an API boundary. The package set is published as the versioned github.com/getarcaneapp/arcane/types/v2 module, so clients share one domain contract across service boundaries.

Package groupContract role
baseCommon success, error, pagination, count, and multi-environment result wrappers.
Resource packages such as container, image, project, network, port, volume, and environmentResource data and actions for the main management features. The project package also joins Compose content, service state, tags, image update state, and project status.
imagepatch and vulnerabilityImage repair, scan, risk, finding, and remediation contracts.
template and metaTemplate content, registry data, template metadata, and related Compose environment values.
Cross-cutting packages such as activity, event, stream, auth, httpx, settings, system, and userData that joins several resource areas or supports a shared user flow. httpx carries shared outbound client timeout options.
Root types packageSmall values that must remain stable across the application, such as the local Docker environment ID.

The packages can refer to one another when a product view combines domains. For example, container summaries can carry image update and resource-sample data, image summaries can carry vulnerability scan data, and container actions can carry registry credentials. Project contracts similarly connect Compose service definitions with live container state and image update results. Environment tags and failed-environment entries let multi-environment views show where each row came from and which results are missing. This keeps related product state in one shared shape instead of forcing each client to rebuild it.

References: types/go.mod• L1-12 types/…/environment.go• L3-25 types/…/response.go• L14-53 types/…/container.go• L819-981 types/…/image.go• L16-29 types/…/project.go• L185-317 types/…/network.go• L11-63 types/…/port.go• L5-47 types/…/volume.go• L9-77 types/…/imagepatch.go• L27-84 types/…/client.go• L5-11

Template and registry packages

The template contracts describe reusable Compose content and the sources that provide it. A template can be custom or remote, can include optional environment content and metadata, and can be linked to a local registry; registry contracts describe availability, enablement, and the last fetch error.

Template content gives clients the Compose text, environment text, service names, and discovered environment variables needed to preview or use a template. Separate request and response shapes support template and registry changes without exposing one storage shape as every API contract.

References: types/…/template.go• L8-195 types/…/template.go• L197-324 types/…/template_meta.go• L3-44

Runtime feature and job metadata

Runtime feature definitions connect a stable feature ID to the setting that controls it and to its default state. This gives the manager and clients one shared way to describe optional product areas such as vulnerability management and Docker Swarm. Some features also have runtime rules beyond the stored toggle, such as remaining active when the environment already has an active Swarm cluster.

Job metadata gives scheduled work a shared product description. It connects a job to its category, schedule and enabled settings, manager scope, continuous or manual behavior, and any settings that must be active first. The settings contract carries these controls and other application values through stable JSON keys; optional update fields let a caller change only the values included in a request.

References: types/…/features.go• L4-46 types/…/features_test.go• L9-36 types/…/job_metadata.go• L9-20 types/…/job_metadata.go• L28-235 types/…/settings.go• L3-55 types/…/settings.go• L139-213

API and live-data shapes

The shared types serve two related contracts. Request and response types describe individual API actions, while stream event types describe updates that keep an already loaded view current.

Resource types use JSON field names as part of their public contract. Optional fields mark data that may be absent, and nested types express relationships such as an image's scan summary or a container's resource sample. The generic base wrappers give callers a common way to read success state, data, pagination, aggregate counts, and partial multi-environment results. Some resource responses add contract data that callers need for the same action, such as an image upload limit or an activity ID.

The resource packages also carry product-specific state across these boundaries. Container types cover creation, editing, runtime state, networking, health, and resource sorting. Image types cover listing, inspection, pull options, build history, update state, attestations, and cleanup results. Network, port, and volume types describe both resource views and actions against the Docker environment. Project types cover creation, Compose and environment content, deployment options, runtime services, tags, archive state, and image update summaries. Vulnerability and image-patch types connect scan state, severity data, repair choices, and patch outcomes to image records.

References: types/…/response.go• L23-53 types/…/container.go• L438-469 types/…/container.go• L819-870 types/…/image.go• L16-29 types/…/image.go• L115-187 types/…/build_history.go• L9-55 types/…/network.go• L114-327 types/…/port.go• L5-47 types/…/project.go• L31-183 types/…/project.go• L455-633 types/…/vulnerability.go• L217-285 types/…/imagepatch.go• L27-84

Image patch and build history

Image patch contracts describe a repair run as a product workflow rather than as a low-level package update. They identify the source and patched image, the selected mode, the run status, package results, errors, and the follow-up scan that shows whether fixable findings remain. A local-only image is represented as unavailable for patching because it has no registry source.

Build history provides the matching record of image build work. It preserves the build inputs, result state, output or error, timing, environment identity, and whether output was truncated so clients can explain both completed and failed builds without reading build storage directly.

References: types/…/imagepatch.go• L10-84 types/…/build_history.go• L9-55

Diagnostics and user contracts

The system package defines operational data that helps clients inspect the manager and its live connections. A diagnostics snapshot combines runtime, memory, garbage collector, WebSocket, and actor-host health data. The same contract supports REST responses and live diagnostics messages, including on-demand leak reports, profiles, and command results.

The user package defines account data and personal display settings at the API boundary. Create and update shapes keep account changes separate from role assignment changes, while the user response joins permissions, role assignment summaries, access flags, and preferences. Optional preference values preserve the difference between an unset choice and an explicit user choice.

References: types/…/diagnostics.go• L5-29 types/…/diagnostics.go• L46-76 types/…/diagnostics.go• L112-195 types/…/user.go• L3-34 types/…/user.go• L36-57 types/…/user.go• L59-88

Project workflow contracts

The project package defines the shared language for Compose-based project work. Its workflow contracts connect project loading and deployment with image pull, image build, service update, progress, wait, and recovery behavior without making callers depend on one execution path.

The project model also distinguishes user-managed tags from Compose-managed tags, and it can report a file-system configuration problem that blocks project operations. Project references provide a small ID-and-name shape for callers that need to identify a project without loading its full details. These distinctions let clients show project state and available actions without treating all project problems as runtime failures.

References: types/…/project.go• L58-145 types/…/project.go• L412-439 types/…/project.go• L441-617 types/…/compose_operation.go• L13-77

Resource normalization

The type packages also provide the shared boundary between Docker or scanner data and the application-facing contract. Conversion functions turn source records into stable summaries and details, while preserving the product meaning of fields such as health, network state, image identity, scan status, and severity.

This boundary matters because source formats are not the same as API formats. For example, Docker health durations are represented differently for create and read views, scanner severity values are normalized into the shared severity set, and Docker prune results are reduced to the fields the API exposes. Callers should use the shared result rather than depend on source-specific records.

References: types/…/container.go• L1149-1206 types/…/container.go• L1264-1389 types/…/container.go• L1794-1928 types/…/image.go• L257-280 types/…/image.go• L467-538 types/…/volume.go• L146-175 types/…/vulnerability.go• L509-616

Tunnel protocol contract

Bidirectional tunnel session

The tunnel is a reverse connection from an edge agent to a manager. The agent opens one persistent bidirectional gRPC stream through TunnelService.Connect; the manager uses that session to reach services behind the agent, and the agent uses it to return results and publish events.

The session starts with registration. The agent presents its token, runtime identity, capabilities, and an optional session to resume. The manager answers with acceptance, environment identity, session data, security mode, and the capabilities that apply to the session.

This diagram shows the main session flow and the traffic that continues after registration.

sequenceDiagram
    participant A as Edge agent
    participant M as Manager
    A->>M: Connect bidirectional stream
    A->>M: RegisterRequest
    M-->>A: RegisterResponse
    loop Active session
        M->>A: HTTP, command, WebSocket, or stream request
        A-->>M: Response, output, chunks, or stream end
        A->>M: Heartbeat or event
        M-->>A: Heartbeat acknowledgement or control message
    end

References: backend/…/tunnel.proto• L7-11 backend/…/tunnel.proto• L56-72 backend/…/server.go• L43-61 backend/…/client.go• L108-130

Tunnel message families

The protocol groups messages by the work they carry. AgentMessage contains messages from the edge agent to the manager, and ManagerMessage contains messages in the other direction. Each envelope carries one payload so the peer can identify the message family without inspecting unrelated fields.

Message familyDirection and purpose
Registration and heartbeatThe agent registers the session. Both sides use heartbeat messages to keep the session live.
HTTP request and responseThe manager sends a request for a service behind the agent. The agent returns status, headers, and body data.
WebSocket start, data, and closeThe manager and agent carry a long-lived WebSocket exchange through the tunnel.
Stream open, data, end, and closeThe peers carry incremental output for long-running or streaming work.
Command request, acknowledgement, output, and completionThe manager asks the agent to run a named edge command and receives progress and the final result. The manager can also return byte credit for output flow control when the session supports it.
File chunksEither side transfers a large payload in ordered chunks with an end marker.
Events and cancellationThe agent forwards events to the manager, and a peer can cancel an in-flight command.

Correlation IDs tie responses, chunks, stream events, and command results to the request or stream that created them. Status, headers, bodies, sequence values, and error fields carry the result without coupling the protocol to one particular backend action.

References: backend/…/tunnel.proto• L13-55 backend/…/tunnel.proto• L76-210 backend/…/types.go• L301-343 backend/…/tunnel.pb.go• L302-578

Transport contract

The tunnel message model is shared by more than one transport. gRPC uses the typed protocol messages, while the WebSocket path carries the same logical message model as JSON. This lets the manager and agent keep request behavior stable when deployment needs a different network path.

The transport-neutral tunnel connection exposes send, receive, close, and transport identity behavior. The protocol adapter maps between that model and the generated gRPC messages. It also keeps the wire meaning of IDs, chunk sequence numbers, WebSocket message types, and event fields aligned in both directions.

References: backend/…/tunnel.go• L19-89 backend/…/tunnel.go• L91-181 backend/…/tunnel_proto_adapter.go• L18-24 backend/…/tunnel_proto_adapter.go• L372-489

Protocol generation and evolution

Protocol schema and generated bindings

The .proto file is the source contract for the backend gRPC tunnel. Buf treats backend/proto as a module, applies standard lint rules, and checks file-level breaking changes before generated bindings are refreshed.

Generation uses the Go Protocol Buffers and Go gRPC plugins. The output stays next to the source schema with source-relative paths, so the generated message and service bindings remain in the tunnel/v1 package used by the backend. The generated Go file mirrors the schema's directional envelopes and oneof payloads, including newer cancellation, stream, and command-credit messages.

References: backend/…/tunnel.proto• L1-10 backend/…/buf.yaml• L1-17 backend/…/buf.gen.yaml• L1-12 backend/…/tunnel.pb.go• L25-55 backend/…/tunnel.pb.go• L302-578 backend/…/tunnel_grpc.pb.go• L23-119

Compatibility boundaries

The protocol must allow a manager and an agent to run different releases during an upgrade. Protobuf unknown fields and unknown oneof payloads provide a safe boundary: a peer can ignore a message it does not yet understand instead of treating the whole session as invalid.

Some newer stream, cancellation, and command flow-control messages are capability-gated. The proto-parity-v1 capability tells the manager that the agent understands the native stream encodings. The command-credit-v1 capability tells the manager that the agent accepts output credit. Without the matching capability, the sender uses the older compatible representation where one exists; a message with no safe older form is not sent.

Protocol changes therefore have two contracts to preserve:

  • The numbered protobuf fields and oneof cases must remain readable by existing generated peers.
  • Capability negotiation must describe when a new behavior is safe to use.

References: backend/…/tunnel.proto• L13-55 backend/…/tunnel.proto• L135-143 backend/…/tunnel_proto_adapter.go• L18-21 backend/…/tunnel_proto_adapter.go• L55-77 backend/…/tunnel.go• L243-268

The shared domain contracts page gives the wider map of shared contracts. Use this page when the question concerns the organization of domain types or the manager-to-agent tunnel wire contract.

Change checklist

When these files or sections are changed, remember to consider these:

  • A new or renamed shared field can affect JSON clients, nested resource views, and live stream payloads at the same time.
  • Changes to container, image, project, vulnerability, image-patch, or template types must preserve the links between summaries and their nested update, scan, patch, resource, service, tag, registry, content, and action data.
  • A change to environment tags or failed-environment fields must preserve source identity and partial-result reporting in multi-environment responses.
  • A change to project tag sources or project content fields must preserve the difference between user-managed metadata, Compose metadata, and file content that controls deployment.
  • A change to project references must preserve the ID and name pairing expected by callers that select or resolve projects remotely.
  • A change to a source-to-domain conversion must preserve units and status values across create, read, and list views.
  • A tunnel message change must update both directional envelopes and the transport-neutral adapter so gRPC and WebSocket carry the same meaning.
  • A new protobuf payload needs a compatibility plan for peers that decode an older oneof set, including any capability gate.
  • A protobuf field or service change must keep Buf's breaking-change rules and the generated Go bindings in sync with the schema.
  • Changes to registration fields can alter session identity, environment resolution, or the capability set used later in the tunnel.
  • Changes to project workflow contracts must preserve the handoff between image resolution, Compose service actions, progress reporting, wait limits, and recovery.
  • A new runtime feature must keep its stable ID, persisted setting key, default state, and any environment-specific activation rule aligned.
  • A job metadata change must preserve the link between its schedule or enabled setting, prerequisite settings, execution scope, and the status shown to clients.
  • A settings update change must preserve JSON keys, optional-update meaning, and validation values shared with feature and job controls.
  • A diagnostics field change must preserve the meaning shared by REST snapshots, live diagnostics messages, and on-demand command results.
  • A user preference change must preserve omission semantics and the matching account, response, and persistence contracts.

Important failure modes

TriggerConsequenceGuard
A shared JSON field changes name, type, or unit without updating all viewsClients display missing or misleading resource, health, image, project, scan, or template dataTreat JSON names, optionality, and units as cross-service contracts.
A project update treats an omitted field and an empty field as the same valueAn existing Compose override, environment value, or tag association can be kept or removed by mistakePreserve the explicit nil-versus-empty meaning of project update and tag contracts.
A source record is mapped with the wrong status, severity, or time unitThe API reports a state that does not match the Docker or scanner resultKeep the conversion boundary as the single place that normalizes source values.
A project operation ignores a reported configuration error that blocks operationsA deploy or edit action fails later with less useful contextSurface the configuration error and its operation-blocking state before starting the workflow.
A project reference loses its ID or nameA remote selector cannot resolve or display the intended projectKeep both identity fields present and mapped to the same project.
A template loses its source, content, or environment distinctionA client cannot tell whether content is custom or remote, or cannot prepare the Compose inputPreserve template source flags, registry linkage, Compose content, and optional environment content as separate contract fields.
A patch run loses its source image, mode, status, or follow-up scan stateA client cannot tell which image was repaired or whether the repair reduced findingsKeep patch identity, lifecycle state, and scan outcome linked.
A manager sends a native parity-only message before the agent advertises supportAn older agent cannot process the stream or cancellation behavior correctlyGate the new encoding on the negotiated capability and keep the legacy form where one exists.
A manager sends command credit to an agent without flow-control supportThe agent cannot apply the output limit and may mishandle command outputSend CommandCredit only after command-credit-v1 negotiation.
A protobuf field number or oneof case changes incompatiblyA mixed-version agent and manager can decode the wrong value or lose a messageUse Buf file breaking checks and treat field numbers as stable wire identifiers.
A response or chunk uses a different correlation ID from its requestThe receiver cannot attach the result to the waiting operationPreserve the request, stream, command, or transfer ID across every mapping.
Registration is rejected or never completedThe agent has no usable manager session and cannot serve tunnel workValidate registration before marking the environment connected and apply the registration timeout.
An unknown tunnel payload is treated as a fatal stream errorA newer peer can disconnect an older peer merely by sending a new optional messageIgnore unknown payload kinds at the compatibility boundary and continue the session.
A feature ID, setting key, or default changes in only one part of the feature contractA feature can appear enabled or disabled under the wrong persisted settingKeep the feature registry, setting names, and environment activation rules aligned.
Job metadata points to a missing or unrelated schedule, enabled setting, or prerequisiteA job can show the wrong state or run when its required control is offTreat metadata links as one contract from job status to settings and prerequisites.
An optional settings update treats an omitted value as an empty valueA caller can clear a setting when it intended to leave it unchangedPreserve the distinction between an absent update field and an explicit value.
A diagnostics field changes without updating its REST or live-stream consumersOperational views show stale, incomplete, or misleading runtime and connection stateTreat snapshot, command, and result JSON fields as one diagnostics contract.
A user preference update converts an unset pointer to a concrete default too earlyA user choice can overwrite the frontend default or clear behavior unintentionallyPreserve unset-versus-explicit values through the user API and stored preferences.

Key files

FileWhy to read it
types/go.modDefines the versioned shared type module boundary and its domain-model dependencies.
types/…/environment.goShows how multi-environment rows and failed results retain environment identity.
types/…/response.goShows the common API response, pagination, counts, and partial-result vocabulary.
types/…/container.goShows how container actions, runtime state, resource data, Docker records, and edit contracts share one API model.
types/…/image.goShows image list, update, inspection, pull, and cleanup shapes.
types/…/build_history.goShows the shared record for image build history and outcomes.
types/…/imagepatch.goShows the image repair workflow and its scan-linked results.
types/…/network.goShows network inspection, creation, attachment, and prune contracts.
types/…/port.goShows the normalized port mapping used across environments.
types/…/project.goShows project identity references, content, deployment state, runtime services, tags, update summaries, and configuration errors.
types/…/compose_operation.goShows the shared boundaries for Compose deployment, service updates, image work, and build work.
types/…/template.goShows template content, local and remote sources, registry links, and template management requests.
types/…/template_meta.goShows optional metadata shared by template records.
types/…/vulnerability.goShows scan state, severity summaries, findings, risk, and ignore actions linked to images.
types/…/volume.goShows volume views, usage state, creation, rename, and prune results.
types/…/environment.goShows how environment identity and live edge status are exposed to clients.
types/…/client.goShows the shared outbound HTTP timeout contract.
types/…/stream.goShows the shared envelope for multiplexed live updates.
types/…/dashboard.goShows how several resource packages combine into one product view.
types/…/features.goShows how runtime features map stable IDs to persisted settings and defaults.
types/…/job_metadata.goShows how scheduled work exposes settings, scope, run behavior, and prerequisites.
types/…/settings.goShows the public setting shape and the optional application settings update contract.
types/…/diagnostics.goShows the operational snapshot and live diagnostics message shapes.
types/…/user.goShows account requests, user responses, permissions, roles, and display preferences.
backend/…/tunnel.protoDefines the manager-agent service and all tunnel message families.
backend/…/tunnel.pb.goShows the generated Go representation of the tunnel envelopes and payload cases.
backend/…/buf.yamlDefines schema lint and breaking-change policy.
backend/…/buf.gen.yamlDefines how Go and gRPC bindings are generated.
backend/…/tunnel.goDefines the transport-neutral tunnel message and connection contracts.
backend/…/tunnel_proto_adapter.goShows the boundary between logical tunnel messages and protobuf messages.
backend/…/client.goShows the agent session lifecycle at a high level.
backend/…/server.goShows the manager-side connection and registration responsibilities.