Skip to content

feat(platform): bound how long automation versions are kept - #4843

Merged
yannickmonney merged 1 commit into
mainfrom
feat/automation-version-retention
Oct 12, 2026
Merged

yannickmonney merged 1 commit into
mainfrom
feat/automation-version-retention

Conversation

@yannickmonney

Copy link
Copy Markdown
Contributor

What

Governance can bound how long saved automation versions are kept (P5 S13). Builds on #4789 (protectedVersions) and #4823.

  • A new retention category, automationVersions. Off by default. The bundled bounds allow 90 to 3650 days (default 3650); the policy value is chosen in Settings > Governance > Policies & Limits > Retention policy like every other category (EN/DE/FR strings, env TALE_RETENTION_VERSIONS_{MIN,MAX,DEFAULT}).
  • The daily sweep removes versions older than the period, except the ones the product still reads (pruneVersions, on protectedVersions from feat(platform): record who changed an automation and when it went live #4789): the live version, the versions of the last ten deployments, every version a run used, the newest twenty, what those were restored from or based on, and versions saved by a custodian under a legal hold (an API key's included). An organization under hold is not swept. Version numbers are never reused (the newest twenty stay, so max(version) never drops).
    • Per automation: its name lock first, as every writer takes it, then one transaction and one audit row (automation_version.retention_deleted, naming the versions, first 200), and a definition hint so open builders refresh their version lists.
    • The run-start race is closed. A run starting on a version and the sweep reaching it at once agree in either order: beginRunInTx now reads its version row FOR KEY SHARE, and the sweep locks its candidates FOR UPDATE and reads the kept set again, so it either waits for the run and keeps the version, or removes it first and the run finds nothing and starts nothing. Proven on real Postgres both ways.
  • An organization created before the category existed keeps a working editor. An org's retention.json is written once at creation and the scaffolder never tops it up, while applyEnvTightening throws for a category the file lacks — so a plain new category would have left every existing org's retention editor without bounds after the upgrade. loadOrgRetentionConfig now takes a missing category's bounds (and its env bindings, when both files share the envPrefix) from the bundled catalog; the org's own file always wins. As for any bounds change, the org's admin sees the operator proposal and applies it before the sweep enforces the category.
  • A removed version says it was removed. A link to a version below the latest that is gone (numbers are never reused, so it can only have been removed) opens Version N was removed in the editor and vN was removed by the retention policy. on the compare page, instead of "doesn't exist … mistyped". The compare page's default "compare with" is the nearest older version that is left when the one just before was removed.
  • Spec: AUTO-R51, and AUTO-R47's "versions are kept until the automation is deleted" now points to it.

Docs, screenshot and manual

  • EN/DE/FR: the self-hosted retention page (the category, its env names, the top-up, what is always kept, the audit event), the admin Policies & Limits page, and the editor page's Versions intro.
  • The governance-policies-limits screenshot is retaken: its Retention policy summary gains the Automation versions row, and its fold now lands in the gap under the retention card (it used to cut through the deletion timeline). The demo seed gains ensureRetentionBounds, which applies the operator bounds the way a first policy save does — without it a freshly seeded demo org shows an "initial approval" banner in that section, which the shipped image does not.
  • Manual: GOV-F67 and a reference row for the automated coverage.

Verification (local)

  • The whole local gate on the tree rebased onto acd5dbd107: platform tsc, oxlint, the server and PII projects (87,780 tests), the UI suite (7,631), the automations browser tests (95), packages/shared (935), services/docs (710), lint:links, lint:manual, knip, the format check.

    • One real red, found by the gate and fixed: the de-CH coverage test caught a ß in my German category description ("außer"); reworded ("ausgenommen") so de-CH needs no override.
    • Six UI tests timed out in that run (a document import, a contact dialog, two task tests, connector settings, and the editor's save test) with the machine's load average above 100; the six files pass together alone (259 of 259). The editor save test, which takes 3.5–5.1 s at that load, gets an explicit 20 s budget, and the compare page's wait for its double-draw to settle 10 s.
    • Two server tests that are timing bounds (corpus.test.ts, travels.test.ts) failed under the same load in an earlier run and pass alone.
  • After the last rebase onto 6bf33cedd4 (feat(platform): chat makes files and uses skills, sandbox only as needed #4817 landed on the same page, docs and manual suite): a manual box ID collision fixed (mine is GOV-F67; GOV-F65 and GOV-F66 are feat(platform): chat makes files and uses skills, sandbox only as needed #4817's), then tsc, the governance / retention / automations / i18n / guard / docs-screenshot server tests (213 files, 3,488 tests), the governance, versions and editor UI tests, packages/shared (939), services/docs (713), the format check, lint:links, lint:manual, knip and the integration lanes below (110 of 110) again.

  • Real Postgres (ITEST_LANES, throwaway databases, fresh MinIO): the new checkVersionRetention lane (what goes and what stays with a live version, two deployments, a run, lineage, a held custodian's two versions; the audit row and hint; a second sweep removes nothing and the next version number is 33; category off / org under hold do nothing; both orderings of the run-start race), plus checkVersionHistory, checkLegalHolds, checkRetention, checkRetentionAuditTrail, checkChatFilterEventRetention and checkRetentionHeldRowsProgress, whose fixtures list every category by hand and now carry the new one.

  • Unit tests: the sweep (lock → kept set → locked candidates → kept set again → delete → hint in one transaction; a run seen at the second read; held authors; no row when nothing goes; one transaction and row per automation; off / no window; the window and grace); withCatalogCategories (an old org's file gains the category and its env bindings; the org's own file and other prefixes win; no catalog adds nothing); the loader on real files (catalog filled in, no catalog, an unreadable catalog logged); the removed-version wording in the editor and on the compare page; versionBefore.

  • The spec guard (domain-specs.guard.test.ts) holds AUTO-R51 to a running test that names it.

  • Live in Chromium on a local stack (the demo org, whose own bounds file and applied snapshot predate the category), 1440 and 390 px:

    • The upgraded organization: its Retention policy shows Operator has proposed retention bound changes. listing automationVersions min and max; Apply takes the category into its snapshot; the editor drawer lists Automation versions with its range (Allowed: 90–3650 days.); enabling it at 365 days shows "disabled → enabled" and "— → 365 days" in the confirmation, and the save lands in the policy file.
    • The server holds the new category to its bounds: a policy with 30 days is refused 400 RETENTION_BELOW_FLOOR (category: automationVersions, bound 90).
    • A removed version: ?version=1 of a 3-version automation whose v1 was removed reads Version 1 was removed with Open latest; the compare page for v2 says v1 was removed by the retention policy. and v3 compares with v2.
    • The seed step's own call (POST /retention/bounds/apply) answers 200 twice.
  • The live check found a gap in its own test data, not in the product: a policy saved through the editor is written as retention-policy.yml and the old .json is removed — a restore that puts the .json back leaves both, and the .yml wins.

Governance gets a retention category for saved automation versions, off
by default (90 to 3650 days). The daily sweep removes versions older than
the period except the ones the product still reads: the live one, the
last ten deployments' versions, every version a run used, the newest
twenty, what those were restored from or based on, and a held custodian's.
Each automation that loses versions gets one audit row naming them, and
version numbers are never reused.

A run starting on a version and the sweep reaching it at once agree in
either order: starting a run reads its version row FOR KEY SHARE, and the
sweep locks its candidates FOR UPDATE and reads the kept set again.

An organization created before the category existed keeps a working
retention editor: the bounds loader takes a missing category's bounds
and env bindings from the bundled catalog, the organization's own file
winning. A removed version reads as removed in the editor and on the
compare page, which opens against the nearest older version left.

Docs (EN/DE/FR), the spec card AUTO-R51 and the manual box GOV-F65
follow.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant