Shared domain contracts
The shared domain contracts module is the common Go vocabulary for Arcane resources and API exchanges. It lets the backend describe domain state once and lets the CLI and integrations use the same request, response, JSON, and live-event shapes instead of creating separate copies.
Module boundary
Shared module role
The module is published as github.com/getarcaneapp/arcane/types/v2. Its packages define data contracts for resources such as containers, images, projects, environments, networks, volumes, vulnerabilities, users, API keys, and system operations. It also holds common API response wrappers, environment identity values, and shared HTTP client options that cross service and client boundaries. The contracts describe what a request or response means. They do not own the work that creates a container, checks an image, or authenticates a user.
References: types/go.mod• L1-12 types/go.sum• L5-49 types/…/response.go• L3-53 types/…/environment.go• L3-25 types/…/client.go• L5-11
Consumer alignment
The backend and CLI import the module through the same types/v2 path. This gives both consumers one contract for domain data while backend services keep ownership of the rules that act on that data. External integrations can use the same JSON contracts without depending on backend service internals.
References: backend/go.mod• L5-8 backend/go.mod• L31-33 cli/go.mod• L1-16 cli/…/client.go• L39-45
Contract layers
Domain resource models
Each domain package groups the shapes needed to describe one product area. A package can contain create and update requests, response models, summaries, status values, and related nested data. Containers, environments, projects, images, networks, volumes, ports, registries, templates, vulnerability records, and image patch runs use this pattern so each consumer sees the same product concepts.
References: types/…/environment.go• L5-82 types/…/environment.go• L112-268 types/…/container.go• L209-370 types/…/network.go• L11-63 types/…/volume.go• L9-76 types/…/port.go• L5-47 types/…/vulnerability.go• L54-141 types/…/imagepatch.go• L27-84
Container contracts connect Docker runtime state with product views. They cover creation, inspection, actions, health, networking, mounts, Compose context, resource samples, and edit-ready configuration. They also define the difference between an omitted edit field and a field that must be cleared or replaced. Resource sort keys, samples, and batched sample subscriptions stay together so a sorted list or live view can show the values that produced its order.
References: types/…/container.go• L805-870 types/…/container.go• L872-982 types/…/container.go• L1149-1233 types/…/container.go• L1465-1792
Project configuration caching
Project contracts include a cache boundary for loaded Compose configuration. The cache key ties a project to a fingerprint of its inputs, while the stored dependency data keeps environment files visible even after the executable project model no longer carries them.
References: types/…/compose_cache.go• L5-16
Image and patch models
Image contracts cover image inventory, update information, registry actions, build history, attestations, and links to vulnerability summaries. Image patch contracts extend that view with the selected patch mode, target image, patch status, and the scan result used to verify remediation.
References: types/…/image.go• L16-29 types/…/image.go• L31-96 types/…/image.go• L115-186 types/…/build_history.go• L9-55 types/…/imagepatch.go• L10-84
Infrastructure resource models
Network, volume, and port contracts describe infrastructure resources in a form that supports both single-environment views and multi-environment lists. Their summaries carry environment identity, while their request and result shapes cover creation, attachment, pruning, usage, and published-port state.
References: types/…/network.go• L11-63 types/…/network.go• L114-214 types/…/volume.go• L9-76 types/…/volume.go• L79-136 types/…/port.go• L5-47
Environment models
Environment contracts describe both saved configuration and live edge state. They carry connection settings, enablement, pairing, tunnel transport, security mode, capabilities, heartbeat data, and certificate status. Environment stream snapshots use replacement semantics, so a client replaces its visible list instead of inferring changes field by field.
References: types/…/environment.go• L38-110 types/…/environment.go• L112-230 types/…/environment.go• L232-268
Template models
Template contracts represent Compose content as a product resource that can come from local editing or a remote registry. They keep template metadata, Compose and environment content, service and variable views, registry state, and default Compose or Swarm content aligned across template management flows.
References: types/…/template.go• L8-24 types/…/template.go• L26-64 types/…/template.go• L84-160 types/…/template.go• L163-200 types/…/template.go• L250-330
Cross-environment identity
Cross-environment contracts use a small shared identity model so a result can say where a row came from or why one environment has no result. Resource rows carry an environment tag, while response wrappers carry an explicit failure entry when a multi-environment request is only partly complete.
References: types/…/environment.go• L3-25 types/…/response.go• L23-53 types/…/container.go• L872-878 types/…/image.go• L115-121
User contracts carry account identity, access summaries, display preferences, and the request shapes for account changes. Preferences use optional values so an unset choice can fall back to the product default, while user updates can change selected account fields without replacing the full user record.
References: types/…/user.go• L12-34 types/…/user.go• L36-57 types/…/user.go• L59-88
API key contracts distinguish keys with their own scoped grants from personal keys that inherit the owner's role permissions. Creation returns the full secret only in the creation result. Later views expose identification and grant data without repeating that secret, while updates preserve omitted fields as unchanged.
References: types/…/apikey.go• L5-28 types/…/apikey.go• L30-60
Capability and storage contracts
The shared module also defines contracts for cross-cutting capabilities and data protection. These types give runtime feature switches, scheduled work, notifications, uploads, volume backups, system backups, and workspace changes stable names, states, and request shapes across the backend and clients.
| Contract | Product meaning |
|---|---|
| Runtime features | A supported feature linked to its persisted setting and default state |
| GitOps synchronization | Repository-backed deployment or backup with lifecycle state and history |
| Volume and system backups | Backup targets, policies, discovery, recovery, and restore results |
| Scheduled work | Job identity, run state, attempts, and prerequisites |
| Notifications | Provider settings and event-specific payloads |
| Upload sessions | Resumable chunk receipt and domain ownership |
| Workspaces | File views and guarded changes for project and GitOps content |
References: types/…/features.go• L1-47 types/…/gitops.go• L5-37 types/…/backup.go• L9-109 types/…/system_backup.go• L5-115 types/…/requester.go• L3-9 types/…/upload.go• L23-47 types/…/workspace.go• L20-66
Application settings updates
Application settings contracts provide one partial-update surface for product paths, feature switches, service limits, authentication options, scan policy, build behavior, and timeouts. Each submitted setting is a value to change; an omitted setting remains under its current server value.
References: types/…/settings.go• L3-30 types/…/settings.go• L32-65 types/…/settings.go• L199-248 types/…/settings.go• L472-586
Runtime feature registry
The runtime feature registry gives each supported capability a stable ID, a persisted setting key, and a default state. It currently covers vulnerability management and Docker Swarm. Swarm remains active when a cluster is active even if its saved toggle is off.
References: types/…/features.go• L4-47 types/…/features_test.go• L9-41
Scheduled work metadata
Scheduled work uses shared metadata to connect a job ID with its name, purpose, category, settings, manual-run support, continuous behavior, manager scope, and prerequisites. The scheduler can turn this metadata into status that clients can use for controls and settings links.
References: types/…/job_metadata.go• L9-20 types/…/job_metadata.go• L28-47 types/…/job_metadata.go• L237-260
Durable operation state
Durable operation contracts define the state that asynchronous work must keep across a process or host restart. Scheduler runs retain attempts, target outcomes, remote delivery state, and reconciliation evidence. Updater targets also freeze the selected container, its baseline runtime state, and the intended image so a delayed update can act on the request that was approved rather than on a changed target.
References: types/…/run.go• L9-31 types/…/run.go• L33-61 types/…/run.go• L75-118 types/…/durable.go• L5-64 types/…/durable.go• L3-16
Fleet update contracts
Fleet update contracts describe a manager-wide update as a persisted job with one result per environment. They let clients distinguish whether an update can start from how each environment progressed from its source version and digest to its target.
References: types/…/upgrade.go• L5-39
System diagnostics contracts
System diagnostics contracts give operators a point-in-time view of runtime health and live connection state. They also carry actor-host status and commands for refreshes, leak scans, text dumps, and profiles through the diagnostics stream, so the REST endpoint and live view use one shape for operational data.
References: types/…/diagnostics.go• L5-29 types/…/diagnostics.go• L46-76 types/…/diagnostics.go• L112-129 types/…/diagnostics.go• L176-195
Service health contracts
Service health contracts separate a simple API health result from readiness checks. Readiness reports whether the service can accept work and preserves the state of each dependency so an operator or platform can see why it is not ready.
References: types/…/health.go• L3-20
API envelopes
The base package supplies the common outer shape of API results. A normal result carries a success flag and one data value. List results add pagination, and some list results add aggregate counts, warnings, or domain limits. Multi-environment results can also name failed environments, while message results can carry an activity ID that links an accepted background action to later progress.
References: types/…/response.go• L3-53 types/…/image.go• L16-29 types/…/dashboard.go• L68-95 types/…/activity.go• L50-92
Field errors
Field errors keep an input field tied to its validation failure while preserving the underlying error for normal error handling. Backend validation and shared callers can therefore show the problem at the right field and still classify the original cause.
References: types/…/errors.go• L3-11
Optional state
Request contracts use pointers when the difference between “not supplied” and an explicit zero value matters. An update can then change only the fields the caller sends. The same rule applies to environment, container, project, settings, API key, user, and role updates. Response contracts use optional fields when a value may not exist, such as edge connection details, a new API key, a resource sample, or a vulnerability summary.
References: types/…/environment.go• L38-63 types/…/container.go• L1465-1610 types/…/project.go• L121-146 types/…/settings.go• L32-65 types/…/apikey.go• L47-60 types/…/user.go• L12-16 types/…/user.go• L48-57 types/…/dashboard.go• L108-133
Client and integration flows
API exchange
The shared models sit between an API operation and its JSON representation. The backend accepts a domain request or returns a domain result. The CLI and integrations send and decode those same JSON fields through their clients.
This diagram shows the contract's place in a normal request path.
flowchart LR
Command[CLI command or integration] --> Client[API client]
Client -->|JSON request| Backend[Backend API]
Backend --> Domain[Domain service]
Domain --> Backend
Backend -->|JSON response| Client
Client --> Result[Shared domain result]
JSON tags on the shared structs define the wire names. The API wrappers give each consumer the same success, data, error, and list metadata meaning.
References: types/…/response.go• L3-53 types/…/browse.go• L5-85 types/…/upload.go• L23-47 types/…/vulnerability.go• L217-285 cli/…/client.go• L61-76
Live event exchange
Some contracts describe data that changes after the initial request. The stream package defines one event envelope, and its payloads point to domain-specific dashboard, activity, environment, event-log, or version events. A client can keep one live connection while handling each feed by its domain type.
References: types/…/stream.go• L1-8 types/…/stream.go• L20-74 types/…/activity.go• L50-110 types/…/environment.go• L232-252
Edge tunnel exchange
The edge tunnel is a separate binary protocol boundary for communication between an edge agent and a manager. Generated protocol messages carry remote work, while shared domain packages describe the meaning of requests and results at the API edge. The tunnel therefore complements the JSON contracts instead of replacing them.
This diagram shows how the protocol carries remote work while domain contracts describe the result.
sequenceDiagram
participant A as Edge agent
participant M as Manager
participant S as Domain service
A->>M: Register and open tunnel
M->>A: Typed command or HTTP request
A->>M: Ack, output, stream data, or result
M->>S: Apply result to manager-side operation
The tunnel uses typed messages and capability-aware behavior for mixed-version peers. For the full package map and protocol path, continue to Domain types and protocol contracts.
References: backend/…/tunnel.proto• L1-53 backend/…/tunnel_proto_adapter.go• L12-21
Contract navigation
Domain package map
Read the shared module from the domain package that owns the resource or operation. Start with base for common API envelopes and environment identity, then follow imports into related packages when a model nests another domain value. This shows which concepts travel together without requiring a reader to scan the whole module.
References: types/…/dashboard.go• L3-15 types/…/container.go• L3-14 types/…/image.go• L9-14 types/…/network.go• L3-9 types/…/stream.go• L10-18
For the package-level map and protocol-specific contracts, continue to Domain types and protocol contracts.
References: types/go.mod• L1-3 backend/…/tunnel.proto• L1-11
Change checklist
When these files or sections are changed, remember to consider these:
- A request or response field change must preserve its JSON name and its omitted-versus-empty meaning for backend handlers, CLI commands, and integrations.
- A multi-environment result change must keep environment tags on rows and failed-environment entries aligned so clients do not mistake partial data for a complete result.
- A shared package change must be checked against both module consumers. The backend and CLI use the same import path but can declare different released type versions.
- An API key change must keep scoped grants separate from personal role inheritance. Keep the full secret limited to the creation result.
- A manual backup request change must preserve the user, API key, environment, and permission used for delayed authorization checks.
- A scheduler run change must preserve status, attempt outcomes, target evidence, remote delivery state, and reconciliation meaning.
- A fleet update change must preserve manager start state, target version, and each environment's stage and outcome.
- A feature definition change must keep its ID, persisted setting key, and default state aligned with the runtime setting.
- A container create, inspect, edit, or resource-sort change must preserve runtime units, field aliases, and nil-versus-empty replacement semantics.
- A Compose cache change must keep its fingerprint tied to project identity, paths, Compose files, and environment-file inputs.
- A stream payload or channel change must preserve the channel name and the rule for replacing or updating client state.
- A tunnel message change must update the .proto source, generated Go contracts, and adapter behavior for older peers.
- A paginated or counted result must keep
data, pagination, and count meanings aligned across list consumers. - A vulnerability insight or patch change must keep scan identity, fixable counts, risk meaning, and patch outcome aligned.
- An image, image-build, network, volume, or port contract change must preserve the resource identity and the summary fields used by list and detail views.
- A project or settings update change must preserve the distinction between an omitted value and an explicit empty or false value.
- A shared HTTP client option change must preserve the meaning of zero timeout values for callers that rely on no request timeout.
- A diagnostics snapshot or command change must keep REST responses, live stream messages, and operational views aligned on snapshot and result meanings.
- A health or readiness change must preserve the difference between service health and dependency checks.
- A template change must keep local and remote origin, registry identity, Compose content, and environment content consistent.
- An updater target change must preserve the selected container identity, baseline runtime state, desired image reference, and desired digest.
- A user preference or update field change must preserve unset values as distinct from explicit defaults, especially when the frontend applies its own fallback.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| JSON tag or field meaning changes in a shared model | The CLI or an integration sends data that the backend does not read, or decodes a result incorrectly | Treat JSON names and optionality as wire contracts and review all consumers |
| A multi-environment response omits its failed-environment context | A client presents partial data as a complete result or cannot explain the missing rows | Preserve row environment tags and explicit failure entries together |
| A partial update loses pointer-based absence | An unset field can be cleared instead of left unchanged | Keep “not supplied” distinct from explicit false, empty, or zero values |
| A scoped or personal API key is represented as the wrong kind | Authentication can grant too much access or fail to apply the owner's role | Keep key kind, grants, scope, and one-time secret exposure distinct |
| A manual backup request loses requester permission context | Delayed delivery can run without re-checking the authority that started it | Keep user, API key, environment, and permission identity with the request |
| A durable scheduler run loses attempt or remote delivery evidence | A restart can repeat work or leave clients unable to explain a remote run | Keep run status, attempts, target outcomes, and reconciliation data together |
| A frozen updater target loses its baseline or desired digest | A delayed update can act on a different container state or image than the approved request | Preserve target identity, baseline runtime values, and immutable image intent |
| A container resource sort key changes without its sample | A list can sort by a value that it does not return | Treat sort keys and resource samples as one contract |
| An environment snapshot is merged as field updates | Renames or enable changes can leave stale client state | Replace the visible environment list for snapshot events |
| A stream payload or channel changes without its consumer rule | Live client state becomes stale or updates from the wrong feed | Preserve channel names, payload ownership, and replacement semantics |
| A tunnel message is added without matching generated code or adapter support | An agent or manager cannot complete the remote operation | Change the proto source, regenerate contracts, and preserve mixed-version behavior |
| A fleet update result loses environment or stage identity | A job can appear complete while hiding which environment failed | Keep each result linked to source, target, stage, and error data |
| A vulnerability scan, severity, or image identity changes alone | Security views can show stale or misattributed data | Keep scan results, summaries, image links, and severity values aligned |
| A diagnostics command or field changes without both REST and stream consumers | Operators can receive an empty, stale, or misread health view | Preserve command types, result fields, and snapshot timestamps across both paths |
| A readiness result loses a dependency check | Orchestration can send work to a service that is not ready or hide the cause of failure | Keep the overall readiness state and per-dependency checks together |
| A Compose cache fingerprint ignores an input file | A project can use stale Compose or environment values after its source changes | Include all project and environment-file inputs in cache identity |
| A template origin or content field is mapped to the wrong source | A user can edit a remote template as local content or deploy incomplete environment data | Keep origin, registry, Compose content, and environment content distinct |
| A user preference treats an omitted value as an explicit choice | The UI can override its intended default or reset a setting unexpectedly | Preserve optional preference values and their fallback meaning |
| A zero HTTP timeout is changed to a default timeout | Long-running integrations can fail even though they requested no request timeout | Preserve the documented zero-value behavior of shared client options |
Key files
| File | Why to read it |
|---|---|
types/go.mod | Defines the shared module identity and dependency boundary |
types/go.sum | Records the pinned versions of the external model and client libraries used by the module |
| types/…/response.go | Shows common success, error, message, pagination, warning, and partial-result shapes |
| types/…/environment.go | Defines shared environment identity, row tags, and partial-result failures |
| types/…/errors.go | Shows how validation errors retain field context and the underlying cause |
| types/…/container.go | Shows workload input, runtime state, edit semantics, resource sorting, and Docker mapping |
| types/…/environment.go | Demonstrates saved environment data, edge state, pairing, and live snapshots |
| types/…/project.go | Defines Compose project requests, runtime service views, tags, and update status |
| types/…/compose_cache.go | Defines the cache contract and the input dependencies that control project reuse |
| types/…/image.go | Defines image lists, update state, registry actions, and image detail views |
| types/…/build_history.go | Defines the shared history view for image build records |
| types/…/imagepatch.go | Defines image patch options, targets, scan checks, and patch lifecycle state |
| types/…/network.go | Defines network summaries, inspection data, connection requests, and prune results |
| types/…/volume.go | Defines volume views, usage, create and rename requests, and prune results |
| types/…/port.go | Defines environment-aware published-port rows |
| types/…/settings.go | Defines public settings and partial application-setting updates |
| types/…/template.go | Defines local and remote template content, registries, and template requests |
| types/…/health.go | Defines API health and dependency readiness results |
| types/…/client.go | Defines shared outbound HTTP timeout options |
| types/…/user.go | Defines user account fields, access summaries, display preferences, and account update requests |
| types/…/apikey.go | Defines scoped and personal API key creation, grants, updates, and one-time secret results |
| types/…/vulnerability.go | Shows scan state, findings, severity, risk, threat data, and ignore actions |
| types/…/requester.go | Defines the authorization context retained for manual backup delivery |
| types/…/run.go | Defines scheduler run status, attempts, outcomes, remote delivery, and reconciliation contracts |
| types/…/durable.go | Defines durable scheduler state and execution claims |
| types/…/durable.go | Defines the frozen target used to keep delayed image updates tied to their approved intent |
| types/…/upgrade.go | Defines fleet update checks and per-environment update results |
| types/…/diagnostics.go | Defines runtime, memory, garbage collection, WebSocket, actor, and diagnostics stream contracts |
| types/…/features.go | Defines runtime feature availability and persisted settings |
| types/…/job_metadata.go | Defines scheduled-job identity, settings links, prerequisites, scope, and client-facing metadata |
| types/…/stream.go | Defines the shared envelope for live domain feeds |
| backend/…/tunnel.proto | Defines the manager-agent protocol for remote operations |
| backend/…/tunnel_proto_adapter.go | Shows the boundary between generated tunnel messages and edge operations |
backend/go.mod | Shows backend consumption of the shared types module |
cli/go.mod | Shows CLI consumption of the shared types module |