# Portability / Infrastructure / Deployment

> Every principle in this category is listed as a record.

Page: Ontology · Principles
Canonical: https://banes-lab.com/ontology#arch-category-portability-infrastructure-deployment

Every principle in this category is listed as a record. Each record carries its kind, its severity, the scopes it applies at and the layer it lives in, then the edge relations that join it to other records, the records that point back at it, the contracts that answer to it and the tensions it takes part in. The descriptors say how it is violated, detected, measured, repaired and enforced. Where the record carries one, an exemplar shows the shape before and after the principle is applied.

Relations diagram

The relations inside this category.

```mermaid
flowchart LR
n_portability["Portability"]
n_platform_independence["Platform Independence"]
n_environment_parity["Environment Parity"]
n_containerization["Containerization"]
n_infrastructure_as_code["Infrastructure as Code"]
n_standards_compliance["Standards Compliance"]
n_protocol_independence["Protocol Independence"]
n_configuration_externalization["Configuration Externalization"]
n_immutable_infrastructure["Immutable Infrastructure"]
n_platform_independence --> n_portability
n_environment_parity --> n_configuration_externalization
n_environment_parity --> n_infrastructure_as_code
n_containerization --> n_portability
n_containerization --> n_environment_parity
n_protocol_independence --> n_portability
n_configuration_externalization --> n_portability
n_configuration_externalization --> n_environment_parity
n_immutable_infrastructure --> n_infrastructure_as_code
n_immutable_infrastructure --> n_environment_parity
```

### Portability

- Kind: [quality-attribute](https://banes-lab.com/records/kind/quality-attribute.md)
- Severity: contextual
- Scope: application, infrastructure, runtime
- Layer: [Resource Core](https://banes-lab.com/records/layer/resource-core.md)

Details

Requires
[Abstraction](https://banes-lab.com/records/arch/abstraction.md), [Standards](https://banes-lab.com/records/lex/standards.md)

Reinforces
[Replaceability](https://banes-lab.com/records/arch/replaceability.md)

Enables
[Platform Migration](https://banes-lab.com/records/lex/platform-migration.md)

In tension with
[Platform Optimization](https://banes-lab.com/records/lex/platform-optimization.md)

Conflicts with
[Platform-Specific Coupling](https://banes-lab.com/records/lex/platform-specific-coupling.md)

Referenced by
[Interoperability](https://banes-lab.com/records/arch/interoperability.md), [Low Coupling](https://banes-lab.com/records/arch/low-coupling.md), [Abstraction](https://banes-lab.com/records/arch/abstraction.md), [Independence](https://banes-lab.com/records/arch/independence.md), [Platform Independence](https://banes-lab.com/records/arch/platform-independence.md), [Containerization](https://banes-lab.com/records/arch/containerization.md), [Protocol Independence](https://banes-lab.com/records/arch/protocol-independence.md), [Configuration Externalization](https://banes-lab.com/records/arch/configuration-externalization.md)

Tensions
[Portability Platform Optimization](https://banes-lab.com/records/tension/platform-optimization-portability.md)

Violated by
direct dependency on non-abstracted platform APIs

Detected by
platform-specific imports in core

Measured by
portability violation count

Refactored by
Add Adapter, Externalize Platform Dependency

Enforced by
dependency rules

Before

```typescript
const path = "C:\\foo\\data\\foos.json";
const processId = windowsApi.currentProcessId();
```

After

```typescript
const path = join(config.dataDirectory, "foos.json");
const processId = runtime.processId();
```

### Platform Independence

- Kind: [principle](https://banes-lab.com/records/kind/principle.md)
- Severity: contextual
- Scope: application, runtime
- Layer: [Resource Core](https://banes-lab.com/records/layer/resource-core.md)

Details

Requires
[Platform Abstraction](https://banes-lab.com/records/lex/platform-abstraction.md)

Reinforces
[Portability](https://banes-lab.com/records/arch/portability.md)

Enables
[Cross-Platform Deployment](https://banes-lab.com/records/lex/cross-platform-deployment.md)

In tension with
[Native Optimization](https://banes-lab.com/records/lex/native-optimization.md)

Conflicts with
[OS/Vendor Lock-In](https://banes-lab.com/records/lex/os-vendor-lock-in.md)

Tensions
[Platform Independence Native Optimization](https://banes-lab.com/records/tension/native-optimization-platform-independence.md)

Violated by
hardcoded platform assumptions

Detected by
OS-specific paths/APIs in portable layers

Measured by
cross-platform test pass rate

Refactored by
Abstract Platform API, Normalize Paths

Enforced by
cross-platform CI

Before

```typescript
function saveFoo(foo: Foo) { return winRegistry.write("Foo", foo); }
```

After

```typescript
interface FooPersistence { save(foo: Foo): Promise<void>; }
function saveFoo(foo: Foo, persistence: FooPersistence) { return persistence.save(foo); }
```

### Environment Parity

- Kind: [principle](https://banes-lab.com/records/kind/principle.md)
- Severity: recommended
- Scope: dev, test, staging, production
- Layer: [Resource Core](https://banes-lab.com/records/layer/resource-core.md)

Details

Requires
[Configuration Externalization](https://banes-lab.com/records/arch/configuration-externalization.md), [Infrastructure as Code](https://banes-lab.com/records/arch/infrastructure-as-code.md)

Reinforces
[Reproducibility](https://banes-lab.com/records/arch/reproducibility.md)

Enables
[Reliable Deployment](https://banes-lab.com/records/lex/reliable-deployment.md)

In tension with
[Cost](https://banes-lab.com/records/lex/cost.md)

Conflicts with
[Snowflake Environments](https://banes-lab.com/records/lex/snowflake-environments.md)

Referenced by
[Containerization](https://banes-lab.com/records/arch/containerization.md), [Configuration Externalization](https://banes-lab.com/records/arch/configuration-externalization.md), [Immutable Infrastructure](https://banes-lab.com/records/arch/immutable-infrastructure.md)

Tensions
[Environment Parity Cost](https://banes-lab.com/records/tension/cost-environment-parity.md)

Violated by
environment-specific behavior not config-driven

Detected by
works-in-dev-only defects

Measured by
[environment drift](https://banes-lab.com/records/lex/environment-drift.md)

Refactored by
Containerize, Externalize Config, Use IaC

Enforced by
environment drift checks

Before

```typescript
if (env === "dev") useMemoryFooStore();
if (env === "prod") useSqlFooStore();
```

After

```typescript
const container = buildFooImage("foo-app:1.0.0");
runEnvironment("dev", container, devConfig);
runEnvironment("prod", container, prodConfig);
```

### Containerization

- Kind: [mechanism](https://banes-lab.com/records/kind/mechanism.md)
- Severity: contextual
- Scope: application, runtime, deployment
- Layer: [Resource Core](https://banes-lab.com/records/layer/resource-core.md)

Details

Requires
[Image Definition](https://banes-lab.com/records/lex/image-definition.md), [Externalized Config](https://banes-lab.com/records/lex/externalized-config.md)

Reinforces
[Portability](https://banes-lab.com/records/arch/portability.md), [Environment Parity](https://banes-lab.com/records/arch/environment-parity.md)

Enables
[Repeatable Runtime Packaging](https://banes-lab.com/records/lex/repeatable-runtime-packaging.md)

In tension with
[Image Complexity](https://banes-lab.com/records/lex/image-complexity.md)

Conflicts with
[Host-Coupled Deployment](https://banes-lab.com/records/lex/host-coupled-deployment.md)

Tensions
[Containerization Image Complexity](https://banes-lab.com/records/tension/containerization-image-complexity.md)

Violated by
undeclared host dependency

Detected by
manual host setup requirements

Measured by
image reproducibility

Refactored by
Add Containerfile, Externalize Runtime Dependencies

Enforced by
image scans, build pipeline

Before

```typescript
installFooDependenciesOnHost();
startFooWithHostRuntime();
```

After

```typescript
const image = containerImage({
base: "node:22-alpine",
copy: ["dist", "package.json"],
command: ["node", "dist/main.js"],
});
```

### Infrastructure as Code

- Kind: [activity](https://banes-lab.com/records/kind/activity.md)
- Severity: mandatory for managed infrastructure
- Scope: infrastructure, deployment
- Aliases: IaC
- Layer: [Resource Core](https://banes-lab.com/records/layer/resource-core.md)

Details

Requires
[Declarative Configuration](https://banes-lab.com/records/arch/declarative-configuration.md), [Version Control](https://banes-lab.com/records/lex/version-control.md)

Reinforces
[Reproducibility](https://banes-lab.com/records/arch/reproducibility.md), [Governance](https://banes-lab.com/records/arch/governance.md)

Enables
[Automated Provisioning](https://banes-lab.com/records/lex/automated-provisioning.md)

In tension with
[Tooling Complexity](https://banes-lab.com/records/lex/tooling-complexity.md)

Conflicts with
[Manual Infrastructure Changes](https://banes-lab.com/records/lex/manual-infrastructure-changes.md)

Referenced by
[Declarative Configuration](https://banes-lab.com/records/arch/declarative-configuration.md), [Environment Parity](https://banes-lab.com/records/arch/environment-parity.md), [Immutable Infrastructure](https://banes-lab.com/records/arch/immutable-infrastructure.md)

Tensions
[Infrastructure as Code Tooling Complexity](https://banes-lab.com/records/tension/infrastructure-as-code-tooling-complexity.md)

Violated by
untracked manual infra mutation

Detected by
drift between code and live infra

Measured by
drift count, IaC coverage

Refactored by
Codify Resource, Import State

Enforced by
[policy-as-code](https://banes-lab.com/records/arch/policy-as-code.md), drift detection

Before

```typescript
cloudConsole.createDatabase("foo-prod");
cloudConsole.openPort(5432);
```

After

```typescript
const fooDatabase = databaseResource({
name: "foo-prod",
engine: "postgres",
encrypted: true,
networkPolicy: "foo-only",
});
```

### Standards Compliance

- Kind: [constraint](https://banes-lab.com/records/kind/constraint.md)
- Severity: contextual
- Scope: protocol, security, data, infrastructure
- Layer: [Resource Core](https://banes-lab.com/records/layer/resource-core.md)

Details

Requires
[Applicable Standard](https://banes-lab.com/records/lex/applicable-standard.md)

Reinforces
[Interoperability](https://banes-lab.com/records/arch/interoperability.md), [Compliance](https://banes-lab.com/records/arch/compliance.md)

Enables
[Certification/Compatibility](https://banes-lab.com/records/lex/certification-compatibility.md)

In tension with
[Innovation/Flexibility](https://banes-lab.com/records/lex/innovation-flexibility.md)

Conflicts with
[Proprietary Deviation](https://banes-lab.com/records/lex/proprietary-deviation.md)

Tensions
[Standards Compliance Innovation/Flexibility](https://banes-lab.com/records/tension/innovation-flexibility-standards-compliance.md)

Violated by
nonconforming implementation

Detected by
conformance test failure

Measured by
standard compliance score

Refactored by
Align Implementation, Add Conformance Tests

Enforced by
standards checks

Before

```typescript
const payload = encodePrivateFooBinary(foo);
```

After

```typescript
const payload: JsonFooV1 = toJsonFoo(foo);
http.send(JSON.stringify(payload), { contentType: "application/json; charset=utf-8" });
```

### Protocol Independence

- Kind: [principle](https://banes-lab.com/records/kind/principle.md)
- Severity: recommended
- Scope: integration, service boundary
- Layer: [Resource Core](https://banes-lab.com/records/layer/resource-core.md)

Details

Requires
[Adapter/Port Abstraction](https://banes-lab.com/records/lex/adapter-port-abstraction.md)

Reinforces
[Portability](https://banes-lab.com/records/arch/portability.md), [Replaceability](https://banes-lab.com/records/arch/replaceability.md)

Enables
[Protocol Swap](https://banes-lab.com/records/lex/protocol-swap.md)

In tension with
[Protocol-Specific Features](https://banes-lab.com/records/lex/protocol-specific-features.md)

Conflicts with
[Protocol-Coupled Domain Logic](https://banes-lab.com/records/lex/protocol-coupled-domain-logic.md)

Tensions
[Protocol Independence Protocol-Specific Features](https://banes-lab.com/records/tension/protocol-independence-protocol-specific-features.md)

Violated by
HTTP/gRPC/etc. types in domain core

Detected by
protocol imports in core layer

Measured by
protocol leakage count

Refactored by
Add Port, Add Protocol Adapter

Enforced by
import rules

Before

```typescript
class FooService {
handleHttp(request: HttpRequest) { return fooStore.save(request.body); }
}
```

After

```typescript
class CreateFoo {
constructor(private readonly store: FooStore) {}
execute(input: CreateFooInput) { return this.store.save(Foo.create(input)); }
}
httpAdapter.bind(createFoo);
grpcAdapter.bind(createFoo);
```

### Configuration Externalization

- Kind: [principle](https://banes-lab.com/records/kind/principle.md)
- Severity: mandatory
- Scope: application, deployment, runtime
- Layer: [Resource Core](https://banes-lab.com/records/layer/resource-core.md)

Details

Requires
[Config Schema](https://banes-lab.com/records/lex/config-schema.md), [Secure Config Handling](https://banes-lab.com/records/lex/secure-config-handling.md)

Reinforces
[Portability](https://banes-lab.com/records/arch/portability.md), [Environment Parity](https://banes-lab.com/records/arch/environment-parity.md)

Enables
[Environment-Specific Deployment](https://banes-lab.com/records/lex/environment-specific-deployment.md)

In tension with
[Config Sprawl](https://banes-lab.com/records/lex/config-sprawl.md)

Conflicts with
[Hardcoded Configuration](https://banes-lab.com/records/arch/hardcoded-configuration.md)

Referenced by
[Environment Parity](https://banes-lab.com/records/arch/environment-parity.md)

Tensions
[Configuration Externalization Config Sprawl](https://banes-lab.com/records/tension/config-sprawl-configuration-externalization.md)

Violated by
environment values hardcoded in code

Detected by
hardcoded URLs/secrets/paths

Measured by
externalized config coverage

Refactored by
Move to Config, Add Validation

Enforced by
secret/config scans

Before

```typescript
const config = {
fooUrl: "https://foo.prod.example",
retries: 3,
};
```

After

```typescript
type FooConfig = Readonly<{ fooUrl: URL; retries: number }>;
const config = FooConfigSchema.parse({
fooUrl: process.env.FOO_URL,
retries: process.env.FOO_RETRIES,
});
```

### Immutable Infrastructure

- Kind: [approach](https://banes-lab.com/records/kind/approach.md)
- Severity: mandatory for managed infrastructure
- Scope: infrastructure, deployment, reproducibility
- Layer: [Resource Core](https://banes-lab.com/records/layer/resource-core.md)

Details

Requires
[Infrastructure as Code](https://banes-lab.com/records/arch/infrastructure-as-code.md)

Reinforces
[Environment Parity](https://banes-lab.com/records/arch/environment-parity.md), [Reproducibility](https://banes-lab.com/records/arch/reproducibility.md)

Enables
[Deterministic Redeploys](https://banes-lab.com/records/lex/deterministic-redeploys.md), [Instance Replacement over Mutation](https://banes-lab.com/records/lex/instance-replacement-over-mutation.md)

In tension with
[Deploy Time](https://banes-lab.com/records/lex/deploy-time.md)

Conflicts with
[In-Place Server Mutation](https://banes-lab.com/records/lex/in-place-server-mutation.md)

Tensions
[Immutable Infrastructure Deploy Time](https://banes-lab.com/records/tension/deploy-time-immutable-infrastructure.md)

Violated by
patching running servers in place

Detected by
SSH mutation of live instances

Measured by
config drift across instances

Refactored by
Replace Instances from Immutable Images

Enforced by
deployment review

Before

```typescript
ssh(server, "apt-get update && systemctl restart foo");
```

After

```typescript
const image = buildFooImage("foo:1.4.0");
replaceInstances("foo", image);
```

## Links to

- [quality-attribute](https://banes-lab.com/records/kind/quality-attribute.md)
- [Resource Core](https://banes-lab.com/records/layer/resource-core.md)
- [Abstraction](https://banes-lab.com/records/arch/abstraction.md)
- [Standards](https://banes-lab.com/records/lex/standards.md)
- [Replaceability](https://banes-lab.com/records/arch/replaceability.md)
- [Platform Migration](https://banes-lab.com/records/lex/platform-migration.md)
- [Platform Optimization](https://banes-lab.com/records/lex/platform-optimization.md)
- [Platform-Specific Coupling](https://banes-lab.com/records/lex/platform-specific-coupling.md)
- [Interoperability](https://banes-lab.com/records/arch/interoperability.md)
- [Low Coupling](https://banes-lab.com/records/arch/low-coupling.md)
- [Independence](https://banes-lab.com/records/arch/independence.md)
- [Platform Independence](https://banes-lab.com/records/arch/platform-independence.md)
- [Containerization](https://banes-lab.com/records/arch/containerization.md)
- [Protocol Independence](https://banes-lab.com/records/arch/protocol-independence.md)
- [Configuration Externalization](https://banes-lab.com/records/arch/configuration-externalization.md)
- [Portability / Platform Optimization](https://banes-lab.com/records/tension/platform-optimization-portability.md)
- [principle](https://banes-lab.com/records/kind/principle.md)
- [Platform Abstraction](https://banes-lab.com/records/lex/platform-abstraction.md)
- [Portability](https://banes-lab.com/records/arch/portability.md)
- [Cross-Platform Deployment](https://banes-lab.com/records/lex/cross-platform-deployment.md)
- [Native Optimization](https://banes-lab.com/records/lex/native-optimization.md)
- [OS/Vendor Lock-In](https://banes-lab.com/records/lex/os-vendor-lock-in.md)
- [Platform Independence / Native Optimization](https://banes-lab.com/records/tension/native-optimization-platform-independence.md)
- [Infrastructure as Code](https://banes-lab.com/records/arch/infrastructure-as-code.md)
- [Reproducibility](https://banes-lab.com/records/arch/reproducibility.md)
- [Reliable Deployment](https://banes-lab.com/records/lex/reliable-deployment.md)
- [Cost](https://banes-lab.com/records/lex/cost.md)
- [Snowflake Environments](https://banes-lab.com/records/lex/snowflake-environments.md)
- [Immutable Infrastructure](https://banes-lab.com/records/arch/immutable-infrastructure.md)
- [Environment Parity / Cost](https://banes-lab.com/records/tension/cost-environment-parity.md)
- [Environment Drift](https://banes-lab.com/records/lex/environment-drift.md)
- [mechanism](https://banes-lab.com/records/kind/mechanism.md)
- [Image Definition](https://banes-lab.com/records/lex/image-definition.md)
- [Externalized Config](https://banes-lab.com/records/lex/externalized-config.md)
- [Environment Parity](https://banes-lab.com/records/arch/environment-parity.md)
- [Repeatable Runtime Packaging](https://banes-lab.com/records/lex/repeatable-runtime-packaging.md)
- [Image Complexity](https://banes-lab.com/records/lex/image-complexity.md)
- [Host-Coupled Deployment](https://banes-lab.com/records/lex/host-coupled-deployment.md)
- [Containerization / Image Complexity](https://banes-lab.com/records/tension/containerization-image-complexity.md)
- [activity](https://banes-lab.com/records/kind/activity.md)
- [Declarative Configuration](https://banes-lab.com/records/arch/declarative-configuration.md)
- [Version Control](https://banes-lab.com/records/lex/version-control.md)
- [Governance](https://banes-lab.com/records/arch/governance.md)
- [Automated Provisioning](https://banes-lab.com/records/lex/automated-provisioning.md)
- [Tooling Complexity](https://banes-lab.com/records/lex/tooling-complexity.md)
- [Manual Infrastructure Changes](https://banes-lab.com/records/lex/manual-infrastructure-changes.md)
- [Infrastructure as Code / Tooling Complexity](https://banes-lab.com/records/tension/infrastructure-as-code-tooling-complexity.md)
- [Policy as Code](https://banes-lab.com/records/arch/policy-as-code.md)
- [constraint](https://banes-lab.com/records/kind/constraint.md)
- [Applicable Standard](https://banes-lab.com/records/lex/applicable-standard.md)
- [Compliance](https://banes-lab.com/records/arch/compliance.md)
- [Certification/Compatibility](https://banes-lab.com/records/lex/certification-compatibility.md)
- [Innovation/Flexibility](https://banes-lab.com/records/lex/innovation-flexibility.md)
- [Proprietary Deviation](https://banes-lab.com/records/lex/proprietary-deviation.md)
- [Standards Compliance / Innovation/Flexibility](https://banes-lab.com/records/tension/innovation-flexibility-standards-compliance.md)
- [Adapter/Port Abstraction](https://banes-lab.com/records/lex/adapter-port-abstraction.md)
- [Protocol Swap](https://banes-lab.com/records/lex/protocol-swap.md)
- [Protocol-Specific Features](https://banes-lab.com/records/lex/protocol-specific-features.md)
- [Protocol-Coupled Domain Logic](https://banes-lab.com/records/lex/protocol-coupled-domain-logic.md)
- [Protocol Independence / Protocol-Specific Features](https://banes-lab.com/records/tension/protocol-independence-protocol-specific-features.md)
- [Config Schema](https://banes-lab.com/records/lex/config-schema.md)
- [Secure Config Handling](https://banes-lab.com/records/lex/secure-config-handling.md)
- [Environment-Specific Deployment](https://banes-lab.com/records/lex/environment-specific-deployment.md)
- [Config Sprawl](https://banes-lab.com/records/lex/config-sprawl.md)
- [Hardcoded Configuration](https://banes-lab.com/records/arch/hardcoded-configuration.md)
- [Configuration Externalization / Config Sprawl](https://banes-lab.com/records/tension/config-sprawl-configuration-externalization.md)
- [approach](https://banes-lab.com/records/kind/approach.md)
- [Deterministic Redeploys](https://banes-lab.com/records/lex/deterministic-redeploys.md)
- [Instance Replacement over Mutation](https://banes-lab.com/records/lex/instance-replacement-over-mutation.md)
- [Deploy Time](https://banes-lab.com/records/lex/deploy-time.md)
- [In-Place Server Mutation](https://banes-lab.com/records/lex/in-place-server-mutation.md)
- [Immutable Infrastructure / Deploy Time](https://banes-lab.com/records/tension/deploy-time-immutable-infrastructure.md)

## Linked from

- [The layer topology](https://banes-lab.com/ontology/schema/the-layer-topology.md)
- [The membership](https://banes-lab.com/ontology/schema/the-membership.md)
