ION DocsV3
  • Architecture
    • ION Architecture V2
      • ION V2 — Architecture Overview
      • V2 context
        • V2 capacity model
        • V2 constraints
        • V2 integration boundaries
        • V2 requirements
        • V2 solution strategy
      • V2 Structural Design
        • ION V2 Landscape
        • ION V2 Platform Views
          • ION V2 Delivery and Runway
          • ION V2 Incident-Processing Pipelines
          • ION V2 Platform Networking
          • ION V2 Platform Observability
          • ION V2 Platform Security
        • ION V2 System Context
        • ION V2 Systems
          • Alya System Topology
          • Cogs System Topology
          • Ion IQ System Topology
          • Kingsman System Topology
          • Pigeon System Topology
          • Veritas System Topology
          • Watchtower System Topology
      • V2 evolution and platform lineage
        • Tiberium Origins
          • Tiberium Architecture Overview
          • Tiberium Components Architecture Overview
        • Voyager and the V2 Merge
          • Voyager Architecture Overview
          • Voyager Identity Architecture Overview
          • Voyager Services Architecture Overview
      • V2 Platform Architecture
        • Alya Workbench
          • Mission Brief: Alya (Workbench for Cyber Defenders)
        • Asset Discovery
        • Automation
        • Customer Communications
          • Notification and Escalation Design
        • Reporting and Dashboards
        • Vulnerability Mitigations
      • V2 Well-Architected
        • V2 Reliability
          • Availability Architecture
        • V2 Security
          • API Management
            • API Management Architecture
            • API Management Guidelines
            • API Management Implementation
              • APIM Deployment and Debugging
              • APIM Global Policy Implementation
              • APIM Platform Provisioning
              • APIM Policy Authoring
              • APIM Service Onboarding
              • APIM Webhook Flow Implementation
            • API Management Policy Model
          • V2 Security Architecture
          • Teams Notification Security
          • Customer Data and PII
          • V2 Identity
            • Applications and Authorization
            • V2 Identity Architecture
            • Microsoft Entra ID
            • V2 Identity Standard
            • V2 Identity Implementation
              • Application Registration
              • Application Roles
              • Customer Identity Onboarding
              • Identity Lifecycle and Operations
              • Managed Identity
            • V2 Identity Workflows
              • Alya Workbench Identity Workflow
              • Customer Portal Identity Workflow
              • Microservices Identity Workflow
              • ServiceNow Inbound Identity Workflow
              • Microsoft Teams Identity Workflow
          • Customer Environment Access
            • Customer Environment Access Architecture
            • Customer Environment Access Guidelines
            • Customer Environment Access How-to
    • ION Architecture V3
      • ION V3 Architecture Overview
      • V3 context
        • V3 capacity model
        • V3 constraints
        • V3 integration boundaries
        • V3 requirements
        • V3 solution strategy
      • V3 Structural Design
        • Data and events
          • Archival and retention
          • Event model
          • Event sourcing
          • Event store
          • Micro-frontend interaction
          • Recovery and disaster recovery
          • Replay and reconstruction
          • Reporting and customer analytics
          • Event-sourcing requirements
          • Snapshots
          • UI interaction
        • ION v3 domains
          • Assets domain
            • Assets domain flows
            • Assets domain implementation
            • Assets domain model
          • Customer Collaboration domain
            • Customer Collaboration domain flows
            • Customer Collaboration domain implementation
            • Customer Collaboration domain model
          • Incident domain
            • Incident domain flows
            • Incident domain implementation
            • Incident domain model
          • Investigation domain
            • Investigation domain flows
            • Investigation domain implementation
            • Investigation domain model
          • Remediation domain
            • Remediation domain implementation
            • Remediation domain model
          • Ticket domain
            • Ticket domain flows
            • Ticket domain implementation
            • Ticket domain model
        • ION V3 Landscape
        • ION V3 Platform Views
          • Internal API
            • Internal API architecture
            • Internal API consumer guide
            • Internal API identity and access
            • Internal API implementation
          • Micro-Frontends
            • Micro-Frontends architecture
            • Micro-Frontends capability service (Signet)
            • Micro-Frontends composition
            • Micro-Frontends identity and access
            • Micro-Frontends implementation
            • Micro-Frontends real-time (SignalR)
            • Micro-Frontends routing and ingress
            • Shells and MFEs
          • SOAR Integration
            • SOAR Integration architecture
            • SOAR Integration customer onboarding
            • SOAR Integration Identity and Access Design
            • SOAR Integration implementation
            • SOAR Integration operations
        • ION V3 System Context
        • ION V3 systems
          • Alya
          • Cogs
          • ION IQ
          • Kingsman
          • Pigeon
          • Veritas
          • Watchtower
      • V2 to V3 evolution
        • V2 to V3 architecture delta
        • V2 to V3 decision changes
        • V2 to V3 migration guidance
        • V2 to V3 service impact
      • Well-Architected
        • Cost Optimization
          • Cost Governance
            • Cost Governance Architecture
            • Cost Governance Guidelines
            • Cost Governance Implementation
          • SKU Strategy
            • SKU Strategy Architecture
            • SKU Strategy Guidelines
            • SKU Strategy Implementation
        • Operational excellence
          • Audit Logs
            • Audit Logs Architecture
            • Audit Logs Guidelines
            • Audit Logs Implementation
          • CI/CD Runway
            • CI/CD Runway Architecture
            • CI/CD Runway Guidelines
            • CI/CD Runway Implementation
          • Feature Flags
            • Feature Flags Architecture
            • Feature Flags Guidelines
            • Feature Flags Implementation
          • Incident management
            • Incident management architecture
            • Incident management guidelines
            • Incident management implementation
          • Azure Landing Zone
            • Azure Landing Zone Architecture
            • Azure Landing Zone Guidelines
            • Azure Landing Zone Implementation
          • Notifications
            • Notifications Architecture
            • Notifications Guidelines
            • Notifications Implementation
          • Observability
            • Observability Architecture
            • Observability Guidelines
            • Observability Implementation
        • Performance efficiency
          • Capacity, sizing, and scaling
            • Capacity, sizing, and scaling architecture
            • Capacity, sizing, and scaling guidelines
            • Implement capacity, sizing, and scaling
          • UI responsiveness
            • UI responsiveness architecture
            • UI responsiveness guidelines
            • Implement UI responsiveness
        • V3 reliability
          • Application resilience patterns
          • Critical flows
          • Customer reliability assurance
            • ION Platform reliability and service continuity
            • Customer reliability slides
          • Disaster recovery
            • Disaster recovery architecture
            • Disaster recovery guidelines
            • Disaster recovery implementation
              • DR implementation: API Management
              • DR implementation: App Configuration
              • DR implementation: Application Gateway
              • DR implementation: Azure SQL Database
              • DR implementation: Container Apps
              • DR implementation: Container Registry
              • DR implementation: Cosmos DB
              • DR implementation: Event Hubs
              • DR implementation: Azure Front Door
              • DR implementation: Function Apps
              • DR implementation: Key Vault
              • DR implementation: Log Analytics and Application Insights
              • DR implementation: MySQL Flexible Server (Temporal)
              • DR implementation: PostgreSQL Flexible Server
              • DR implementation: Azure Managed Redis
              • DR implementation: Service Bus
              • DR implementation: SignalR
              • DR implementation: Storage accounts
            • Operational-data replication
            • Disaster recovery operations
          • Edge and routing
            • Azure Application Gateway
              • Azure Application Gateway architecture
              • Azure Application Gateway guidelines
              • Azure Application Gateway implementation
              • Azure Application Gateway resiliency
              • Azure Application Gateway security
            • Azure Front Door
              • Azure Front Door architecture
              • Azure Front Door guidelines
              • Azure Front Door implementation
              • Azure Front Door resiliency
              • Azure Front Door security
          • Event-store disaster recovery (moved)
          • Failure mode analysis
          • Graceful degradation
            • Graceful degradation architecture
            • Graceful degradation guidelines
            • Graceful degradation implementation
          • V3 reliability maturity model
            • V3 reliability maturity assessment
            • Maturity level 2: self-preservation
            • Maturity level 3: recovery readiness
            • Maturity level 4: maintain stability
            • Maturity level 5: stay resilient
          • Multi-region replication
            • Multi-region replication architecture
            • Multi-region replication guidelines
            • Multi-region replication implementation assessment
          • Reliability testing
          • Scaling and headroom
          • Targets and health model
          • Trade-offs and accepted risks
        • V3 Security
          • API Management
            • API Management Architecture
            • API Management Guidelines
            • API Management Implementation
              • API Contracts and Asynchronous Operations
              • APIM Deployment and Debugging
              • APIM Global Policy Implementation
              • APIM Platform Provisioning
              • APIM Policy Authoring
              • APIM Service Onboarding
              • APIM Webhook Flow Implementation
            • API Management Policy Model
          • V3 Security Architecture
          • Data protection
            • Data protection architecture
            • Data protection guidelines
            • Data protection implementation guidelines
              • API Management
              • Application Gateway
              • Azure SQL Database
              • Azure Container Apps
              • Azure Cosmos DB
              • Azure Front Door
              • Azure Function Apps
              • Azure Database for MySQL
              • Azure Database for PostgreSQL
              • Data protection procedures
          • V3 Security Guidelines
          • V3 Identity
            • Applications and Authorization in ION V3
            • V3 Identity Architecture
            • Capabilities
            • Microsoft Entra ID for ION V3
            • V3 Identity Standard
            • V3 Identity Implementation
              • App Service Authentication
              • Application Registration
              • Application Roles
              • Customer Azure RBAC
              • Customer Identity Onboarding
              • Identity Lifecycle and Operations
              • Mailbox-Scoped Access
              • Managed Identity
              • Workload Identity Federation
            • V3 Identity Workflows
              • Alya Workbench Identity Workflow
              • Customer Azure RBAC Identity Workflow
              • Customer Portal Identity Workflow
              • Mailbox Access Identity Workflow
              • Microservices Identity Workflow
              • ServiceNow Inbound Identity Workflow
              • Shell and MFE Identity Workflow
              • Microsoft Teams Identity Workflow
          • Customer Environment Access
            • Azure Lighthouse
              • Azure Lighthouse implementation
            • GDAP and Tenant Governance
              • Access Packages (legacy)
              • GDAP human access implementation
            • Customer environment access guidelines
            • Multi-tenant Entra apps
              • Multi-tenant Entra apps implementation
            • Teams B2B Direct Connect
              • Teams B2B Direct Connect implementation
          • Network Security
            • Network Security Architecture
            • Network Security Guidelines
            • Network Security Implementation
              • Egress and Static IPs
              • Resource Access Restrictions
          • V3 Security Patterns
    • ION Architecture V4
      • How V4 evolves from V3
  • Principles
  • Patterns
    • Application Permissions Only
    • Async REST
    • Audit Logs (Pattern)
    • Auth / AuthZ
    • Dead Letter Queue (DLQ)
    • Dual Writes (and how to avoid them)
    • ECST — Event-Carried State Transfer
    • Event Hubs Throttling
    • Feature Flags (Pattern)
    • Idempotent Write
    • MFE UI Interaction
    • Notifications (Pattern)
    • Private Data Store Access
    • Schema Evolution
    • Service Bus Topic Throttling
    • UI Interaction with an Event-Sourced Backend
  • Standards
    • API Standard
    • API Standards
    • Coding Standard
    • Coding Standards
    • Documentation Standard
    • Documentation Standards
    • Microservice Standard
    • Microservice Checklist
    • Operational Readiness Standard
    • ORR — Operational Readiness Review Checklist
  • Decisions
    • ADR-0001
    • ADR-0002
    • ADR-0003
    • ADR-0004
    • ADR-0005
    • ADR-0006
    • ADR-0007
    • ADR-0008
    • ADR-0009
    • ADR-0010
    • ADR-0011
    • ADR-0012
    • ADR-0013
    • ADR-0014
    • ADR-0015
    • ADR-0016
    • ADR-0017
    • ADR-0018
    • ADR-0019
    • ADR-0020
    • ADR-0021
    • ADR-0022
    • ADR-0023
    • ADR-0024
    • ADR-0025
    • ADR-0026
    • ADR-0027
    • ADR-0028
    • ADR-0029
    • ADR-0030
    • ADR-0031
    • ADR-0032
    • ADR-0033
    • ADR-0034
  • Services
  • Governance
    • Assumptions
    • Discrepancies
    • V3 reference coverage and conflict matrix
OntinueION Docs
  1. Standards
  2. Coding Standard
  3. Editions
  4. Coding Standards

Coding Standards

from references
standardsv2v3v4from-references

Coding Standards

Source references: Architecture- Logging and Metrics Guidelines.md; Architecture- Logging Guidelines.md; Architecture- Security Architecture.md; principles in ../principles/README.md.


Scope

Baseline expectations for all code shipped in ION — application code, infrastructure code, tests, and tooling. Language-specific style guides live in each service repo; this document defines the platform-wide rules that every language guide must inherit.

Legend: MUST, SHOULD, MUST NOT.


1. Repository & code hygiene

  • MUST every service lives in its own GitHub repo, registered in Anvil/service-map.json (ADR-0024).
  • MUST trunk-based development on main; changes via short-lived PR branches; PR-validation workflow blocks merge.
  • MUST conventional-commits + semantic-versioning for published artefacts.
  • MUST NOT commit secrets, tokens, connection strings, private keys, tenant IDs, or personal identifiers. Verified by pre-commit + secret scan in CI.
  • MUST every merge is signed / verified per repo policy.
  • SHOULD every PR ≤ 500 lines of net change; larger changes split or explicitly justified.

2. Language, frameworks & dependencies

  • MUST use platform-sanctioned languages: TypeScript / Node (services, MFEs, BFFs), C#/.NET (Azure Functions where preferred), Go / Java / TS / .NET (Temporal workflows). New languages require an ADR.
  • MUST pin dependency versions in a lockfile checked into the repo.
  • MUST dependency scan (SCA) in CI blocks build on High/Critical CVEs unless waived with expiry.
  • MUST NOT vendor libraries that duplicate an Azure-native capability without an ADR exception (§21). Current exception list: Temporal.
  • SHOULD prefer standard libraries and platform-standard packages (logging, config, HTTP client) — do not re-invent per service.

3. Code style

  • MUST enforce style via linter + formatter in pre-commit + CI (ESLint + Prettier / dotnet-format / golangci-lint / etc.).
  • MUST language-specific style guide in the service repo cites this document as its baseline.
  • MUST every public function / method has a doc comment describing purpose + non-obvious constraints.
  • MUST NOT add comments that restate the code. Comments describe why, not what.
  • SHOULD prefer explicitness over cleverness.

4. Domain modelling

  • MUST modelling follows DDD (§3): bounded contexts, aggregates, invariants defined in design/domains/.
  • MUST ubiquitous-language terms used unchanged in code (Incident, Ticket, Investigation, Customer) — no abbreviations, no synonyms.
  • MUST aggregates enforce their own invariants; no cross-aggregate transactions.
  • MUST NOT leak infrastructure types (Cosmos response, SB ServiceBusMessage) into the domain layer.

5. Events, commands, and idempotency

  • MUST every event conforms to the platform API Standards §2.
  • MUST every command handler is idempotent by key.
  • MUST every subscription handler tolerates duplicate + out-of-order delivery.
  • MUST publish domain events through the platform event helper (do not hand-craft CloudEvents envelopes per service).

6. Configuration

  • MUST all configuration sourced from Azure App Configuration + Key Vault references. No environment-specific config baked into images.
  • MUST every runtime toggle wired through Feature Flags.
  • MUST NOT call process.env / Environment.GetEnvironmentVariable directly from business logic — go through a config abstraction.
  • MUST limits, quotas, retry counts, timeouts all be configurable at runtime.

7. Secrets & credentials

  • MUST every secret retrieved via Managed Identity → Key Vault at runtime (ADR-0013).
  • MUST NOT log secrets, tokens, or Auth headers. Redaction middleware mandatory.
  • MUST NOT store credentials in code, config files, container images, CI variables, or repo files.

8. Logging (structured)

  • MUST structured JSON logs (one event per line).
  • MUST every log entry includes: timestamp, level, service, env, correlationId, traceId, spanId, customerShort / tenantId / workspaceId (where in scope), entityId (incidentId / ticketId where applicable).
  • MUST log level configurable at runtime; default WARN.
  • MUST NOT log PII, secrets, tokens, request bodies containing sensitive fields, or full stack traces to public sinks.
  • MUST use levels correctly: - ERROR — unrecoverable failure requiring investigation - WARN — recoverable or degraded condition - INFO — significant lifecycle events - DEBUG — developer diagnostics, off in prod by default

9. Metrics

  • MUST publish the 4 golden signals — Latency, Traffic, Errors, Saturation — per endpoint + per consumer (Observability).
  • MUST business KPIs published as custom metrics (e.g. incidents_processed_total, dashboard_freshness_seconds).
  • MUST metric names snake_case; dimensions bounded (never unbounded cardinality — no per-user, no per-incident-ID dimensions).

10. Tracing

  • MUST OpenTelemetry SDK; propagate W3C traceparent through HTTP, Service Bus, SignalR.
  • MUST every outbound dependency call is a span with standard attributes.

11. Error handling

  • MUST typed / structured errors at module boundaries; no bare throw "string" / panic("...").
  • MUST every outbound call has: timeout, retries with exponential back-off + jitter, circuit breaker where dependency health matters.
  • MUST NOT swallow errors silently. Every catch has a log or a compensation.
  • MUST validate + sanitize every external input (API bodies, event payloads, config values).

12. Concurrency, state & memory

  • MUST service is stateless at the compute layer; session state in Redis or the client.
  • MUST graceful shutdown handler drains in-flight work on SIGTERM.
  • MUST cancellation tokens / AbortController propagated through every async call.
  • MUST NOT hold long-lived static caches without eviction policy.

13. Testing

  • MUST unit tests for domain + command handlers; aim ≥ 80 % coverage on business modules.
  • MUST integration tests for every REST endpoint + every event subscription.
  • MUST contract tests for every produced + consumed event (schema conformance).
  • MUST deterministic tests — no reliance on wall clock, network, or ordering.
  • SHOULD property-based / fuzz tests on parsing and validation surfaces.

14. Containers

  • MUST one process per container; handle PID 1 / signal forwarding correctly.
  • MUST run as non-root user with read-only root filesystem where possible.
  • MUST minimal base image (distroless / chiseled / alpine as per stack); remove build tooling from runtime layer.
  • MUST image tagged with immutable digest for deploy; latest never deployed.
  • MUST vulnerability scan in CI blocks build on High/Critical CVEs.

15. Infrastructure code

  • MUST Terraform via shared Anvil/tf-modules/ (ADR-0024, §25).
  • MUST state backend + locking configured per environment; no local state.
  • MUST terraform fmt, terraform validate, tflint, tfsec / checkov in CI.
  • MUST NOT manual portal changes above Alpha — reconciled or rolled back within one sprint.

16. CI/CD

  • MUST platform-standard push-to-main + PR-validation GitHub Actions workflows (ADR-0024).
  • MUST runners in the ION VNet with NIC-in-VNet for private deploy targets.
  • MUST Automation Account custom protection rules for prod promotion.
  • MUST end-to-end traceability: PR → commit → build → artefact → deploy → env.
  • SHOULD artefacts signed + provenance attested.

17. Documentation-in-code

  • MUST README in every repo covers: purpose, run/test locally, dependency map, links to service page in design/systems/.
  • MUST every architecture-affecting change ships with a doc update in ion-v3-arch/ in the same PR.
  • SHOULD ADRs authored in service repo when the decision is service-local; promoted to platform if it affects other services.

Related

  • Microservice Checklist — design/build gate
  • ORR Checklist — go-live gate
  • API Standards
  • Documentation Standards
  • Principles · Patterns · WA capabilities

On this page

  • Scope
  • 1. Repository & code hygiene
  • 2. Language, frameworks & dependencies
  • 3. Code style
  • 4. Domain modelling
  • 5. Events, commands, and idempotency
  • 6. Configuration
  • 7. Secrets & credentials
  • 8. Logging (structured)
  • 9. Metrics
  • 10. Tracing
  • 11. Error handling
  • 12. Concurrency, state & memory
  • 13. Testing
  • 14. Containers
  • 15. Infrastructure code
  • 16. CI/CD
  • 17. Documentation-in-code
  • Related
PreviousCoding Standard
NextDocumentation Standard
Edit on GitHubSecurity