Adds `Coder.AbbreviationFirstUse`, a Vale rule that requires each abbreviation to be expanded on its first use on a page, in the form "Expanded Form (ABBR)". It supports [WCAG 2.2 Level AAA Success Criterion 3.1.4 (Abbreviations)](https://www.w3.org/TR/WCAG22/#abbreviations). Following the "Adding a Vale rule" pattern in `docs/.style/README.md`, the PR has two commits: the cleanup first, then the enable. ## Cleanup commit 431 first uses expanded across 167 pages, so the rule ships with zero findings across `docs/`, excluding `docs/.style/style-guide/`. The branch was rebuilt on current `main`, so pages added or moved since the first draft are covered. - Where the first use is a bold UI label (**CA Path**, **Add redirect URI**, **Redirect URI**), the label stays as the UI shows it and the expansion goes elsewhere in the same paragraph or list item. - Reversed forms such as "PKCE (Proof Key for Code Exchange)" are flipped to the expanded-first form. - A few sentences took a small rewording to fit the expansion: list steps that would pass the 20-word limit (`Coder.StepLength`), and spots where the expansion would nest parentheses. - MITM is expanded as "machine-in-the-middle" rather than "man-in-the-middle". Every use describes the AI Gateway Proxy intercepting traffic on purpose, so "on-path attacker" doesn't fit. The inclusive-language table on `accessibility-and-inclusion.md` gains the substitution: "on-path attacker" for the attack, "machine-in-the-middle" for the feature. - Unrelated fixes on lines already being edited: `DERP MAP` → `DERP map`, and `ENV` → "environment variable" in `faqs.md`. ## Enable commit **Rule design.** The rule is a `conditional`. `first` matches 2 to 6 capitals, each optionally followed by digits (`EC2`, `P2P`), and a lookahead lets a plural `s` count as a use of the singular. `second` captures the abbreviation in `word (ABBR)`, including `(CI/CD)` and `(PCI DSS)` pairs. Vale collects the captures across the page's blocks in document order, so a later expansion doesn't cover an earlier use. Within a single paragraph, list item, or table cell, an expansion anywhere in the block counts. **Scope.** `scope: ~heading` skips headings, because a page title often names an abbreviation that the first paragraph then expands. Vale already skips front matter, code blocks, inline code, and link URLs. `.vale.ini` turns the rule off for the pages generated from Go source that `Coder.UnitSpacing` already skips: `docs/reference/{api,cli}/*.md`, `configuration-reference.md`, and `prometheus.md`. **Severity: `warning`.** Whether an abbreviation is familiar enough to skip is a judgment call, so this is guidance with legitimate exceptions, not hard policy. **Exceptions**, each group commented in the rule file: | Group | Entries | Reason | | --- | --- | --- | | Known to every reader | AI, API, AWS, CLI, CPU, DNS, GCP, HTTP(S), ID, IDE, IP, JSON, OS, PR, RAM, SDK, SQL, SSH, TLS, UI, URL, VM, YAML | Abbreviations every reader of the docs knows. Plurals such as VMs and SDKs pass too | | Units, clock times, file and package formats | GB, KB, MB, AM, PM, CSV, GIF, JPEG, PDF, PNG, RPM, SVG, VSIX, ZIP | Readers know these by the abbreviation, not the expansion | | Not abbreviations | NOTE, TIP, OK, README, SKILL, ALL, AND, ANY, ERROR, MUST, NOT, ON, OR, DELETE, GET, POST, PUT, ILIKE, VACUUM, LOGIN, PLAIN, NUL, CRON, TERM, DOCS, `DOC\d+`, `RFC\d+`, TL, DR | Alert labels, file names, emphasis in capitals, HTTP methods, SQL keywords, SMTP auth mechanisms, rule labels in `docs/AGENTS.md`, RFC numbers, TL;DR | | Names written in capitals | VS, IDEA, IU, NGINX, SUSE, GNU, XFCE, DX, IBM, DCV, TRAMP, MSYS2, NET, VSX, ARM, AMD, GPT, AES, GCM, HMAC, HS256, RSA, SHA, SHA256 | The capitals are the product, company, or algorithm name (VS Code, IntelliJ IDEA, .NET, Open VSX, Amazon DCV, AMD) | The "known to every reader" group is the list that needs judgment, and it's the one to push back on. The other groups only stop the regex from treating words and names as abbreviations. **Documentation.** A new "Expand abbreviations on first use" section on `accessibility-and-inclusion.md`, and the style guide README's checks table, coverage table, and rule counts (90 → 91 rules, 22 → 23 tool-checked). ## Known limits - The rule checks that an expansion exists, not that it's correct: any word followed by `(ABBR)` satisfies it. - An abbreviation in an image's alt text is checked before the paragraph around it, so one alt text (`aws-marketplace.md`) carries its own expansion. - Some expansions read heavily in dense table cells and inline lists, for example the four Kubernetes services in `docker-in-workspaces.md`. They're correct, but a reviewer may prefer adding a specific abbreviation to the exceptions instead. ## Testing - `vale docs/` (Vale 3.7.1 through mise): zero `Coder.AbbreviationFirstUse` findings. Findings from every other rule match `main` file for file. - `pnpm run format-docs`, `pnpm run lint-docs`, `scripts/check_emdash.sh`, and `make lint/prose` run clean, and the repository pre-commit hooks (including `lint/style-claims`) pass on both commits. Linear: DOCS-1311 Generated by Coder Agents on behalf of @nickvigilante.
8.2 KiB
title
| title |
|---|
| Data retention |
Coder supports configurable retention policies that automatically purge old Audit Logs, Connection Logs, Workspace Agent Logs, API keys, and AI Gateway records. These policies help manage database growth by removing records older than a specified duration.
Overview
Large deployments can accumulate significant amounts of data over time. Retention policies help you:
- Reduce database size: Automatically remove old records to free disk space.
- Improve performance: Smaller tables mean faster queries and backups.
- Meet compliance requirements: Configure retention periods that align with your organization's data retention policies.
Note
Retention policies are disabled by default (set to
0) to preserve existing behavior. The exceptions are API keys and workspace agent logs, which default to 7 days.
Configuration
You can configure retention policies using CLI flags, environment variables, or a YAML configuration file.
Settings
| Setting | CLI Flag | Environment Variable | Default | Description |
|---|---|---|---|---|
| Audit Logs | --audit-logs-retention |
CODER_AUDIT_LOGS_RETENTION |
0 (disabled) |
How long to retain Audit Log entries |
| Connection Logs | --connection-logs-retention |
CODER_CONNECTION_LOGS_RETENTION |
0 (disabled) |
How long to retain Connection Logs |
| API Keys | --api-keys-retention |
CODER_API_KEYS_RETENTION |
7d |
How long to retain expired API keys |
| Workspace Agent Logs | --workspace-agent-logs-retention |
CODER_WORKSPACE_AGENT_LOGS_RETENTION |
7d |
How long to retain workspace agent logs |
| AI Gateway | --ai-gateway-retention |
CODER_AI_GATEWAY_RETENTION |
60d |
How long to retain AI Gateway records |
Note
AI Gateway retention is configured separately from other retention settings. See AI Gateway Setup for detailed configuration options.
Duration Format
Retention durations support days (d) and weeks (w) in addition to standard Go duration units (h, m, s):
7d- 7 days2w- 2 weeks30d- 30 days90d- 90 days365d- 1 year
CLI Example
coder server \
--audit-logs-retention=365d \
--connection-logs-retention=90d \
--api-keys-retention=7d \
--workspace-agent-logs-retention=7d \
--ai-gateway-retention=60d
Environment Variables Example
export CODER_AUDIT_LOGS_RETENTION=365d
export CODER_CONNECTION_LOGS_RETENTION=90d
export CODER_API_KEYS_RETENTION=7d
export CODER_WORKSPACE_AGENT_LOGS_RETENTION=7d
export CODER_AI_GATEWAY_RETENTION=60d
YAML Configuration Example
retention:
audit_logs: 365d
connection_logs: 90d
api_keys: 7d
workspace_agent_logs: 7d
ai_gateway:
retention: 60d
How Retention Works
Background Purge Process
Coder runs a background process that periodically deletes old records. The purge process:
- Runs approximately every 10 minutes.
- Processes records in batches to avoid database lock contention.
- Deletes records older than the configured retention period.
- Logs the number of deleted records for monitoring.
Effective Retention
Each retention setting controls its data type independently:
- When set to a non-zero duration, records older than that duration are deleted.
- When set to
0, retention is disabled and data is kept indefinitely.
API Keys Special Behavior
API key retention only affects expired keys. A key is deleted only when:
- The key has expired (past its
expires_attimestamp). - The key has been expired for longer than the retention period.
Setting --api-keys-retention=7d deletes keys that expired more than 7 days ago.
Active keys are never deleted by the retention policy.
Keeping expired keys for a short period allows Coder to return a more helpful error message when users attempt to use an expired key.
Workspace Agent Logs Behavior
Workspace agent logs are deleted based on when the agent last connected, not the age of the logs themselves. Logs from the latest build of each workspace are always retained regardless of when the agent last connected. This ensures you can always debug issues with active workspaces.
For non-latest builds, logs are deleted if the agent hasn't connected within the retention period.
Setting --workspace-agent-logs-retention=7d deletes logs for agents that haven't connected in 7 days (excluding those from the latest build).
AI Gateway Data Behavior
AI Gateway retention applies to interception records and all related data, including token usage, prompts, and tool invocations. The default of 60 days provides a reasonable balance between storage costs and the ability to analyze usage patterns.
For details on what data is retained, see the AI Gateway Data Retention documentation.
Best Practices
Recommended Starting Configuration
For most deployments, we recommend:
retention:
audit_logs: 365d
connection_logs: 90d
api_keys: 7d
workspace_agent_logs: 7d
ai_gateway:
retention: 60d
Compliance Considerations
Warning
Audit Logs provide critical security and compliance information. Purging Audit Logs may impact your organization's ability to investigate security incidents or meet compliance requirements. Consult your security and compliance teams before configuring Audit Log retention.
Common compliance frameworks have varying retention requirements:
- System and Organization Controls (SOC) 2: Typically requires 1 year of audit logs.
- Health Insurance Portability and Accountability Act (HIPAA): Requires 6 years for certain records.
- Payment Card Industry Data Security Standard (PCI DSS): Requires 1 year of audit logs, with 3 months immediately available.
- General Data Protection Regulation (GDPR): Requires data minimization but does not specify maximum retention.
External Log Aggregation
If you use an external log aggregation system (Splunk, Datadog, and so on), you can configure shorter retention periods in Coder since logs are preserved externally. See Capture and export audit logs for details on exporting logs.
Database Maintenance
After enabling retention policies, you may want to run a VACUUM operation on your PostgreSQL database to reclaim disk space.
See Maintenance Procedures for guidance.
Keep data indefinitely
To keep data indefinitely for any data type, set its retention value to 0:
retention:
audit_logs: 0s # Keep audit logs forever
connection_logs: 0s # Keep connection logs forever
api_keys: 0s # Keep expired API keys forever
workspace_agent_logs: 0s # Keep workspace agent logs forever
ai_gateway:
retention: 0s # Keep AI Gateway records forever
Monitoring
The purge process logs deletion counts at the DEBUG level.
To monitor retention activity, enable debug logging or search your logs for entries containing the table name (for example, audit_logs, connection_logs, api_keys).
Related Documentation
- Audit Logs: Learn about Audit Logs and manual purge procedures.
- Connection Logs: Learn about Connection Logs and monitoring.
- AI Gateway: Learn about AI Gateway for centralized large language model (LLM) and Model Context Protocol (MCP) proxy management.
- AI Gateway Setup: Configure AI Gateway data retention.
- AI Gateway Monitoring: Monitor AI Gateway usage and metrics.