Repository navigation
feat(platform): bound how long automation versions are kept - #4843
Merged
Merged
Conversation
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.
This was referenced Oct 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Governance can bound how long saved automation versions are kept (P5 S13). Builds on #4789 (
protectedVersions) and #4823.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, envTALE_RETENTION_VERSIONS_{MIN,MAX,DEFAULT}).pruneVersions, onprotectedVersionsfrom 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, somax(version)never drops).automation_version.retention_deleted, naming the versions, first 200), and a definition hint so open builders refresh their version lists.beginRunInTxnow reads its version rowFOR KEY SHARE, and the sweep locks its candidatesFOR UPDATEand 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.retention.jsonis written once at creation and the scaffolder never tops it up, whileapplyEnvTighteningthrows 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.loadOrgRetentionConfignow takes a missing category's bounds (and its env bindings, when both files share theenvPrefix) 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.Docs, screenshot and manual
governance-policies-limitsscreenshot 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 gainsensureRetentionBounds, 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.GOV-F67and a reference row for the automated coverage.Verification (local)
The whole local gate on the tree rebased onto
acd5dbd107: platformtsc, 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.ßin my German category description ("außer"); reworded ("ausgenommen") so de-CH needs no override.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 isGOV-F67;GOV-F65andGOV-F66are feat(platform): chat makes files and uses skills, sandbox only as needed #4817's), thentsc, 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,knipand the integration lanes below (110 of 110) again.Real Postgres (
ITEST_LANES, throwaway databases, fresh MinIO): the newcheckVersionRetentionlane (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), pluscheckVersionHistory,checkLegalHolds,checkRetention,checkRetentionAuditTrail,checkChatFilterEventRetentionandcheckRetentionHeldRowsProgress, 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:
automationVersionsmin 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.400 RETENTION_BELOW_FLOOR(category: automationVersions, bound 90).?version=1of 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.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.ymland the old.jsonis removed — a restore that puts the.jsonback leaves both, and the.ymlwins.