Repository navigation
Commit 3c329ff
authored
feat(storage-lifecycle): one retention contract for audio buckets; lifecycle gate reads it (#24349)
## Summary
This PR adds one retention contract for the audio buckets, and the
lifecycle release prerequisite now reads it.
Before this PR, two checks judged bucket lifecycles by different rules:
- `backend/scripts/check_sync_staging_lifecycle.py` failed on any
lifecycle Delete.
- The workspace drift and retention tools allowed a Delete if it was at
least as old as the longest hold.
Neither covered the derived, syncing-local, canonical-audio or
speech-profile buckets, and neither checked a ceiling. This follows the
workspace daily review SP-1102-01 and lead ruling 19540a.
**Why it matters:** on 11-01, a whole-bucket 7-day Delete on the batch
staging bucket removed 161 `failed_held` sync uploads that had been held
8+ days. They were the only server copy.
## Changes
### `backend/deploy/storage-lifecycle/retention_contract.json`: the
single threshold source
Each bucket lists its protected prefixes, its holds and a ceiling. The
workspace tools read this file through `git show origin/main:`.
**Floor:**
- Code windows are cited by file and regex. A test fails if a cited
constant changes.
- These holds are unbounded, so no age Delete may reach them:
- accepted sync staging until custody (`staging_custody`);
- capture audio of record (`source_audio`; David 10-15, FORWARD.md);
- speech profiles.
- `batch_finalization_alarm` encodes David's 06:09Z ruling (bus 6be2e1),
with `decided_by: David`: no 21-day deadline; most audio within 30 min
of finalization (`finalization_target_seconds: 1800`); alarm at 2 h
(`finalization_alarm_seconds: 7200`, owned by lane alarm2h); `deadline:
null`. **`control_verified: false`:** `failed_held` units never finalize
and have no TTL in code, so the hold stays unbounded until an alarm by
age since enqueue that covers them is installed and verified (asked
alarm2h). Once it is, the floor is 2 h + `margin_days` (7), i.e. 8 d
with the 1-day code windows, and the 30-day staging Delete passes.
Raising `margin_days` is the knob if more response time is wanted.
**Ceiling:** soft delete, versioning, noncurrent cleanup, and cache max
ages (`merged/` 3 d, `playback/` 30 d, batch staging 30 d). Each ceiling
is cited to the runbook, `artifacts.py verify_voice_retention`,
FORWARD.md or prod.json. Ceilings that differ from live today carry
`ruling: pending`.
**Buckets covered:**
- syncing-local
- omi-audio-derived-uc1
- based-hardware-batch-pipeline-staging (prod and dev)
- omi-private-cloud-sync
- speech-profiles
- `BUCKET_CANONICAL_AUDIO` (not provisioned)
### `backend/scripts/retention_contract.py`
Pure `floor_violations` and `ceiling_findings`.
### `check_sync_staging_lifecycle.py`
- A contract bucket is judged by its floor. Noncurrent-only deletes keep
the live object, so they are allowed.
- Any other bucket keeps the strict rule: any Delete fails.
- The gate now also reads `softDeletePolicy` and `versioning`.
- The receipt adds `contract` and `ceilings` (reason codes only, never
names or prefixes). **Ceilings never change PASS/FAIL.** Promoting a
ceiling to enforcing is a separate decision.
### Runbook
The `audio-cleanup-custody.md` paragraph is updated to match.
## Verification
- `backend/test.sh` with `BACKEND_UNIT_TEST_FILE_LIST` =
`tests/unit/test_retention_contract.py` and
`tests/unit/test_sync_staging_lifecycle_guard.py`: 13 + 27 passed, run
through `bin/omi-heavy` with no ambient GCP credentials.
- Live, read-only (ro-prod, metadata only, 11-02), `--bucket
syncing-local --bucket omi-private-cloud-sync`: **PASS**.
- syncing-local ceilings: `ceiling_soft_delete:pending` (7-day soft
delete) and `ceiling_noncurrent_unbounded:pending`.
- omi-private-cloud-sync ceilings:
`ceiling_noncurrent_unbounded:pending` (14.75 TB of noncurrent
generations; the lifecycle is frozen) and `ceiling_max_age:pending` (no
`merged/` rule live).
- The batch staging, derived and speech-profile buckets are unreadable
to ro-prod (no `storage.buckets.get`). The read-only grant is an access
change for David.
## Product invariants affected
none
## Risk / rollout
No deploy, flag, IAM or data change. The gate is run by an operator
before promotion.
The only behaviour change: a contract bucket with a Delete beyond its
floor now passes. Today that is `omi-private-cloud-sync` with
`playback/` 30 d, which used to fail as `lifecycle_delete`. The batch
staging 30-day rule still fails until the stuck-unit alarm is verified
(`control_verified`), as it does today. Unlisted buckets are unchanged.
Rollback: revert the PR.
🤖 Generated with [Claude Code](https://claude.com/claude-code)6 files changed
Lines changed: 520 additions & 12 deletions
File tree
- backend
- deploy/storage-lifecycle
- docs/runbooks
- scripts
- tests/unit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
116 | 123 | | |
117 | 124 | | |
118 | 125 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
5 | 11 | | |
6 | 12 | | |
7 | 13 | | |
| |||
10 | 16 | | |
11 | 17 | | |
12 | 18 | | |
| 19 | + | |
13 | 20 | | |
| 21 | + | |
14 | 22 | | |
15 | 23 | | |
16 | 24 | | |
17 | 25 | | |
18 | 26 | | |
19 | 27 | | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
20 | 31 | | |
21 | 32 | | |
22 | 33 | | |
| |||
27 | 38 | | |
28 | 39 | | |
29 | 40 | | |
30 | | - | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
31 | 44 | | |
32 | 45 | | |
33 | 46 | | |
| |||
42 | 55 | | |
43 | 56 | | |
44 | 57 | | |
| 58 | + | |
| 59 | + | |
45 | 60 | | |
46 | 61 | | |
47 | 62 | | |
48 | 63 | | |
49 | 64 | | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
50 | 68 | | |
51 | 69 | | |
52 | 70 | | |
| |||
58 | 76 | | |
59 | 77 | | |
60 | 78 | | |
61 | | - | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
62 | 82 | | |
63 | 83 | | |
64 | 84 | | |
| |||
68 | 88 | | |
69 | 89 | | |
70 | 90 | | |
| 91 | + | |
71 | 92 | | |
72 | 93 | | |
73 | 94 | | |
74 | 95 | | |
75 | | - | |
| 96 | + | |
76 | 97 | | |
77 | | - | |
| 98 | + | |
78 | 99 | | |
| 100 | + | |
| 101 | + | |
79 | 102 | | |
80 | 103 | | |
81 | 104 | | |
82 | | - | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
83 | 117 | | |
84 | 118 | | |
85 | 119 | | |
86 | 120 | | |
87 | | - | |
| 121 | + | |
| 122 | + | |
88 | 123 | | |
89 | 124 | | |
90 | 125 | | |
91 | 126 | | |
92 | 127 | | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
93 | 131 | | |
94 | 132 | | |
95 | 133 | | |
| |||
121 | 159 | | |
122 | 160 | | |
123 | 161 | | |
124 | | - | |
| 162 | + | |
125 | 163 | | |
126 | 164 | | |
127 | 165 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
0 commit comments