Skip to content

feat(lake): per-environment retention policy settings#510

Merged
TerrifiedBug merged 1 commit into
mainfrom
feat/lake-retention-settings
Jun 16, 2026
Merged

feat(lake): per-environment retention policy settings#510
TerrifiedBug merged 1 commit into
mainfrom
feat/lake-retention-settings

Conversation

@TerrifiedBug

Copy link
Copy Markdown
Owner

Summary

Lake hot/cold retention windows were hardcoded defaults (7 hot / 90 cold days) with no way to change them short of a raw DB write. The LakeRetentionPolicy model and the daily retention sweep already supported per-dataset windows — this PR wires a settings surface to drive them, placed beside the existing cold-tier bucket config in Environment → Lake Storage.

What changed

  • lake-retention-policy.ts (new) — manages a dedicated per-environment policy (__env:<environmentId>) and keeps every dataset in the environment attached to it. Includes bounds (1–3650 days) + validation (coldDays >= hotDays).
  • environment routergetLakeRetention (VIEWER), setLakeRetention / clearLakeRetention (ADMIN, audited, demo-gated, system-env rejected).
  • upsertLakeDataset — a newly created dataset inherits its environment's policy, so the sweep enforces it without a manual re-save.
  • UI — "Lake retention" card in the Lake Storage tab with hot/cold inputs, Default/Custom badge, and reset-to-default.

Enforcement semantics (intentional asymmetry)

  • coldDays = hard delete horizon. Enforced per dataset by the daily sweepLakeRetention() DELETE — works at runtime with no DDL. Can shorten retention below the shared lake_events table default.
  • hotDays = hot→cold tier move. Governed by the shared table TTL (set at migration time, requires a cold tier). The per-env value is stored for effectiveRetention's clamp and surfaced in the UI; a per-dataset move is not issued here. The UI copy states this.

No schema change (the model already existed) → no migration.

Test plan

  • lake-retention-policy.test.ts — service unit tests (get/set/clear/resolve, validation, attach counts)
  • environment-lake-retention.test.ts — router gating (VIEWER/ADMIN), audit wiring, NOT_FOUND, system-env reject, BAD_REQUEST on inverted window
  • Existing lake-catalog suite updated for the new policy lookup on dataset create
  • Full lake + bucket suites green (153 tests); typecheck + lint clean on changed files

Lake hot/cold retention windows were hardcoded defaults (7/90) with no way
to change them short of a raw DB write. The LakeRetentionPolicy model and the
daily retention sweep already supported per-dataset windows — this wires a
settings surface to drive them.

- lake-retention-policy.ts: manage a dedicated per-env policy (named
  __env:<environmentId>), attaching every dataset in the environment. coldDays
  is the delete horizon enforced per dataset by the sweep; hotDays is the
  hot->cold move stored for the shared table TTL. Bounds + validation included.
- environment router: getLakeRetention (VIEWER) / setLakeRetention,
  clearLakeRetention (ADMIN, audited) env-scoped procedures.
- upsertLakeDataset: a new dataset inherits its environment's policy so the
  sweep enforces it without a manual re-save.
- UI: Lake retention card in the environment Lake Storage tab, beside the
  cold-tier bucket config.

Tests: service unit tests + router gating/audit/behaviour tests; existing
lake-catalog suite updated for the new policy lookup.
@TerrifiedBug TerrifiedBug merged commit 169d5bd into main Jun 16, 2026
17 checks passed
@TerrifiedBug TerrifiedBug deleted the feat/lake-retention-settings branch June 16, 2026 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant