How long OpenGov keeps its two kinds of record
In five lines
OpenGov keeps two very different things, and conflating them is how retention policies go wrong. Operational logs are the diagnostic trace an engineer reads after an incident — short-lived, disposable, and free of personal data by design. The audit log is the record of official acts: who decided what, when, and whether anyone altered it afterwards. This file records what was decided for each, and the reasoning, so the next person does not re-derive it.
Nothing here asserts that any job, endpoint or script exists. Everything below is either a decision or a citation.
Decision 1 — Operational logs: 90 days
| Default | 90 days |
| Bounds | 7–400 days |
| Out of bounds | the service refuses to start — never clamps |
| Where the number lives | deployments/<code>/config.yaml, the committed per-country artifact |
| Residency | fixed in code: logs never leave the deployment |
| Content | fixed in code: no applicant identifiers, no document references, no free-text echo of user input, and no client IP addresses |
Why 90 rather than 30. Thirty days assumes incidents are reported quickly. A government registration platform is used intermittently — an applicant may raise a problem weeks after filing, and a complaint can travel through an agency before it reaches anyone technical. Ninety days survives that lag and still keeps the stream short enough that it is not, in practice, a personal-data store.
Why bounds and not a single number. No single figure survives contact with the first country whose law mandates a different one. The floor and the ceiling protect different people: the floor (7) protects operability — set 1 day, nothing visibly breaks, and the first real incident is unreconstructable. The ceiling (400) protects citizens — “no personal data by construction” is a design goal, not a proof, and short retention is the damage bound for the day the content rule fails.
Why refuse rather than clamp. Clamping is the silent version of the same failure: an operator sets 500 believing they satisfy a mandate, the system quietly runs at 400, and the gap surfaces when a regulator asks for year-old logs.
Why no client IP addresses. Under GDPR-family law an IP address is personal data, and the countries most likely to deploy have GDPR-modelled statutes. A stream without IPs sits largely outside data-protection scope, which is the entire point of “PII-free by construction”; a stream with them is a personal-data store needing its own regime. Diagnosis needs a request identifier, not an IP. Abuse investigation is a security function and belongs on the audit side.
What makes this real rather than decorative
This platform has already run the experiment of writing a retention number down and trusting follow-through; see “The precedent” below. So the decision includes its enforcement, and the two are not separable:
- The acceptance criterion is a running purge test — insert an over-age artifact, run the purge, assert it is gone — shipped in the same change as the logging itself. No stream merges without its deletion.
- A traceability claim gated by a passing marker. Never
loop2_red, never a test that asserts the shape of a document. - A declared
Settingsfield with read-back. An undeclaredOPENGOV_*variable set in the process environment is silently ignored, so the effective value must be readable back from the running deployment. - No deferral to “first production deployment.” That trigger is what parked the precedent for three months.
- Name the deletion mechanism explicitly.
docker-compose.ymlsets nologging:options today, so container stdout uses Docker’s default driver, unbounded, whose only rotation controls are size-based. “90 days” implemented as “10 files × 10 MB” is three days under load and three years when quiet.
The deletion mechanism, named (answers item 5)
Shipped 2026-08-12 — spec docs/specs/2026-08-12-logging-spine.md, claim 9.25.
The platform writes its own daily files to /var/log/opengov on a named volume,
and deletes them itself. Two things do the deleting, and both are needed:
- The daily rollover (
TimedRotatingFileHandler,backupCountset to the declared number of days) closes one file per day and drops the oldest. It prunes only the files it wrote, and only when the process writes a line. - A sweep (
purge_expiredinsrc/opengov/platform/logs/retention.py) walks the directory and deletes anything past the window regardless of which process wrote it or whether that process still exists. It runs when each process starts and once a day as a background task. A container that died last month leaves files that nothing else would remove.
The acceptance test plants a real over-age file and checks it is gone
(tests/platform/logs/test_retention_purge.py); a second test checks the sweep is
actually called; a third checks it is on the worker’s schedule and not merely
in its list of known jobs, which are two different registries — with only the
weaker check, removing the schedule left the test passing and the sweep never
running.
The file a stopped container leaves behind (fixed 2026-08-12). A file’s name carries the container’s own host name, and a container recreate gives a new one, so each redeploy leaves the previous container’s file behind. Nothing rotates it — no process holds it open — and it has no date in its name, which is what the sweep had been using to age a file. So it stayed for ever: one file of real log content past the declared window, per deploy, and the sandbox redeploys on every merge. An undated file of ours is now aged by its last-written time instead. The one file the running process is writing is named to the sweep explicitly and never deleted, because unlinking it would leave that process writing to a file nobody can open.
Separately, docker-compose.yml now caps each service’s container log by size.
That is a disk-safety bound and not this retention promise — stated in as
many words in the file itself, because the two are exactly what item 5 warns
against conflating.
What the number governs, and what it does not
The platform enforces the window on the copy it owns. A copy a country forwards to its own log collector is governed by that collector’s retention, not by this number.
Three copies exist and they are not the same promise:
| Copy | Bounded by |
|---|---|
| The platform’s own files, on the log volume | Time — the declared window, deleted by the platform |
| The container log the runtime keeps | Size — the caps in docker-compose.yml, never time |
| Anything a country forwards to its own collector | That collector’s configuration; the platform has no reach into it |
Opt-in forwarded collector copies — such as VictoriaLogs in the companion
UNCTAD-OpenGov/opengov-monitoring stack — sit under that third row. Operators
should set the collector’s retention at or below the country’s declared
operational_logs.retention_days window so forwarded logs do not outlive the
in-image copy.
Two limits, stated rather than glossed. The rollover only acts when a process writes a line, so a deployment that is idle and whose background worker is down holds files past the window until its next line. And under Docker Swarm a named volume belongs to the node, so a stack rename or a node move loses the history — the health of logging must never be inferred from files being present.
Item 3, answered differently than written — flagged for review
Item 3 asks for “a declared Settings field with read-back”. The window is
declared in the deployment artifact only, with no OPENGOV_LOG_RETENTION_DAYS
environment variable. The read-back, which is item 3’s purpose, is kept: both
processes write a startup line stating the window and where they are writing.
The reasoning is item 3’s own: an undeclared OPENGOV_* variable in the process
environment is silently ignored, so an environment override would be the least
trustworthy half of the pair, and two sources is how a knob stops controlling
anything. If the environment field is wanted anyway it must be one-way
(environment wins) and the read-back must name which source won.
A related hole was closed at the same time: the artifact model accepted unknown
keys, so operational_log: without the s would have been dropped in silence
and the window would have fallen back to the default — a knob attached to
nothing, in the file that is supposed to be the single source of truth. Unknown
keys now refuse the boot.
Decision 2 — The audit log: permanent, and no deletion knob until the design supports one
Recommendation: retain indefinitely. Not because deleting is hard, though it is, but because of what the record is.
What the record actually is
src/opengov/platform/audit.py records every state-changing operation: action,
entity_type, entity_id, actor_id, full before/after snapshots,
timestamp, and a prev_hash/entry_hash chain, append-only via a Postgres
trigger.
That is not a security log. It is the record of official administrative acts — who approved this registration, when, on what basis, and whether anyone altered it afterwards. The comparable class is a registry decision file, a licensing case file, a land-register entry. Those are governed by public-records and archives law, where permanent or multi-decade retention is ordinary, not by IT log standards. Applying CIS Control 8’s 90-day minimum here would be a category error: that figure is an intrusion-detection window, not a records schedule.
Two technical facts that decide the answer
It contains personal data. before and after are full JSON snapshots, so the
chain holds copies of whatever changed — including applicant data. This is not a
metadata-only log.
It is a hash chain, so deletion is architecturally hostile. Each entry hashes
its predecessor. Deleting row N invalidates verification for every row after it. A
retention policy implemented as DELETE FROM audit_log WHERE timestamp < … would
silently destroy the tamper-evidence guarantee that is the log’s entire value —
and the likely “fix” would be to re-chain, which means the log can now be rewritten
at will.
The only sound deletion primitive is prefix truncation: remove the oldest contiguous block and keep the last removed entry’s hash as a new genesis anchor, stored separately and ideally externally witnessed. Verifiability of the removed period is lost; the retained chain still verifies. That primitive does not exist today.
The options, scored
Criteria and weights: legal defensibility 30, evidentiary sufficiency 25, data-protection risk 20, architectural soundness 15, operational cost 10.
| Option | Legal | Evidence | DP risk | Arch | Cost | Total |
|---|---|---|---|---|---|---|
| A — Permanent | 3 | 5 | 2 | 5 | 3 | 360 |
| B — 10 years, then truncate | 4 | 3 | 4 | 2 | 3 | 335 |
| C — Permanent act, bounded personal detail | 5 | 5 | 5 | 4 | 2 | 455 |
| D — Match the operational stream (90 days) | 1 | 1 | 5 | 2 | 5 | 235 |
C is the right destination and A is the right decision today, because C is a design change and A is what C degrades to gracefully while that change is pending. B scores worst where it matters: it fails the year-twelve corruption case, and it requires building a capability to delete audit history — which is itself an insider risk on a tamper-evidence log.
The decision
- The audit log is retained permanently, as the record of official administrative acts of the registration authority.
- No per-country retention knob is added. Without the deletion primitive a knob would control nothing — precisely the failure this file’s precedent section describes. The knob arrives with the capability or not at all.
- Never a mid-chain delete. Written down here so that nobody later “implements
retention” with a
DELETE. If deletion is ever required, it is prefix truncation with a signed re-anchor, and the truncation is itself an audit event. - The floor, if a period is ever set, is 10 years. FATF Recommendation 11’s five-year record-keeping minimum, ordinary civil limitation periods, and the fact that fraud limitation commonly runs from discovery rather than from the act make anything shorter indefensible for a registration authority. (Recalled, not read — verify before citing in a country agreement.)
The design change that unlocks option C
Today the chain hashes the payload inline, which is why deleting content breaks verification. If the chain instead covers a commitment to the payload — a hash of it — with the payload in a separately-retained table, then the payload can be deleted on a schedule while the chain still verifies end to end. That is how certificate transparency and credential status lists reconcile the same two goals. It converts retention from “break the guarantee or keep everything” into an ordinary policy choice. Worth doing before the first country with a deletion mandate signs, not after.
Why permanent is defensible, stated for an auditor
The lawful basis is the performance of a task carried out in the public interest and in the exercise of official authority; the right to erasure does not apply to such processing, and storage limitation expressly permits longer retention for archiving purposes in the public interest, subject to safeguards. The safeguards here are access control and the append-only, tamper-evident structure itself. (GDPR Art. 5(1)(e), Art. 17(3)(b) — recalled from practice, not read; verify the text before this sentence appears in any country agreement.)
What makes this defensible is not the duration but that the purpose is stated. An indefinite store nobody decided on is a finding. An indefinite store held as a public record, with a written basis, is a records schedule.
The precedent this file exists because of
docs/compliance/notification-retention-policy.md was mandated as
“non-negotiable pre-merge” and promises three retention jobs, three per-country
override variables, an erasure endpoint and an ops script. Verified on 2026-08-11:
the named prune job has zero hits in src/; the deliveries redaction sweep and the
test-log delete were never built; and none of the three documented override
variables is a declared settings field, so an operator following the published
policy turns a knob attached to nothing. Its gate asserts that the document exists
and contains three literal strings — it pins the prose, not the deletion.
The gap was found by a discovery loop on 2026-07-23, pinned under a marker excluded
from every gating surface, and escalated, which is terminal. It was un-parked on
2026-08-11 as backlog item notification-retention-policy-unenforced.
That is why Decision 1 above is stated as an enforcement contract with a number in it, rather than as a number.
Standards consulted, and what each is worth here
| Standard | Weight for OpenGov |
|---|---|
| The deployment country’s own data-protection and archives law | Binding. The real reason retention is a per-country number. |
| UN Principles on Personal Data Protection and Privacy (2018) | Governs the default we ship. The UN is not subject to GDPR, but commits to purpose limitation and proportionate retention. |
| FATF Recommendations 11 and 24 | Binding on the country where company/beneficial-ownership registration is in scope; the source of the 10-year floor reasoning. |
| GDPR Art. 5(1)(e) storage limitation, Art. 17(3)(b), Art. 32 | Binding where a country’s statute mirrors it, which most likely deployments do. |
| NIST SP 800-92 | Its real instruction — decide retention before collecting — is the one being followed by this file existing. |
| NIST SP 800-53 AU-11 | Sets no number; says retain per your own policy. US federal scope. |
| ISO/IEC 27001:2022 A.8.15 / A.8.16 | Not binding unless a country certifies, but the checklist a national auditor most likely carries. Demands a policy, protection and review — not a number. |
| OMB M-21-31 | US federal only. Importing its 30 months here would be compliance by imitation. |
| CIS Controls v8, Control 8 | A detection window for security logs. A category error if applied to the audit log. |
Every clause and recommendation number above is recalled from practice, not read from the source text. Verify before any of it enters a spec, a country agreement, or a published privacy notice.