mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-12 21:53:00 -06:00
refactor(state): retire tenant-free agent lease schema (#121943)
* refactor(state): retire agent lease schema * chore(plugin-sdk): refresh schema version closure * test(state): preserve v17 migration fixtures * docs(state): align lease schema inventory
This commit is contained in:
committed by
GitHub
parent
30530ae2a3
commit
38fabc4e03
@@ -55,17 +55,23 @@ Use a SQLite online backup or another WAL-aware snapshot produced while the sour
|
||||
|
||||
## Agent schema history
|
||||
|
||||
| Version | Change | First release |
|
||||
| ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------- |
|
||||
| 1 | Initial per-agent store ([#88349](https://github.com/openclaw/openclaw/pull/88349)) | `v2026.5.30-beta.1`, stable through `v2026.7.1` |
|
||||
| 2 | Memory index identity ([#104449](https://github.com/openclaw/openclaw/pull/104449)) | `v2026.7.2-beta.1` |
|
||||
| 4 | Sessions and transcripts moved into SQLite ([#98236](https://github.com/openclaw/openclaw/pull/98236)) | `v2026.7.2-beta.1` |
|
||||
| 5-6 | Terminal freshness and state lifecycle ([#104859](https://github.com/openclaw/openclaw/pull/104859)) | `v2026.7.2-beta.1` |
|
||||
| 7 | Per-entry lifecycle status projection ([#106151](https://github.com/openclaw/openclaw/pull/106151)) | `v2026.7.2-beta.1` |
|
||||
| 8 | Per-transcript session provenance ([#106766](https://github.com/openclaw/openclaw/pull/106766)) | `v2026.7.2-beta.2` |
|
||||
| 9 | `STRICT` tables ([#108663](https://github.com/openclaw/openclaw/pull/108663)) | `v2026.7.2-beta.2` |
|
||||
| 10 | Materialized active transcript paths ([#108851](https://github.com/openclaw/openclaw/pull/108851)) | Unreleased |
|
||||
| 11 | Leases, durable delivery, conversation addresses, and heartbeat outcomes ([#109636](https://github.com/openclaw/openclaw/pull/109636), [#95838](https://github.com/openclaw/openclaw/pull/95838), [#109999](https://github.com/openclaw/openclaw/pull/109999)) | Unreleased |
|
||||
| Version | Change | First release |
|
||||
| ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------- |
|
||||
| 1 | Initial per-agent store ([#88349](https://github.com/openclaw/openclaw/pull/88349)) | `v2026.5.30-beta.1`, stable through `v2026.7.1` |
|
||||
| 2 | Memory index identity ([#104449](https://github.com/openclaw/openclaw/pull/104449)) | `v2026.7.2-beta.1` |
|
||||
| 4 | Sessions and transcripts moved into SQLite ([#98236](https://github.com/openclaw/openclaw/pull/98236)) | `v2026.7.2-beta.1` |
|
||||
| 5-6 | Terminal freshness and state lifecycle ([#104859](https://github.com/openclaw/openclaw/pull/104859)) | `v2026.7.2-beta.1` |
|
||||
| 7 | Per-entry lifecycle status projection ([#106151](https://github.com/openclaw/openclaw/pull/106151)) | `v2026.7.2-beta.1` |
|
||||
| 8 | Per-transcript session provenance ([#106766](https://github.com/openclaw/openclaw/pull/106766)) | `v2026.7.2-beta.2` |
|
||||
| 9 | `STRICT` tables ([#108663](https://github.com/openclaw/openclaw/pull/108663)) | `v2026.7.2-beta.2` |
|
||||
| 10 | Materialized active transcript paths ([#108851](https://github.com/openclaw/openclaw/pull/108851)) | Unreleased |
|
||||
| 11 | Durable delivery, conversation addresses, and heartbeat outcomes ([#109636](https://github.com/openclaw/openclaw/pull/109636), [#95838](https://github.com/openclaw/openclaw/pull/95838), [#109999](https://github.com/openclaw/openclaw/pull/109999)) | Unreleased |
|
||||
| 12 | Session-owned ACP parent-stream events | Unreleased |
|
||||
| 13 | Durable transcript rewrite watermarks | Unreleased |
|
||||
| 14 | Logical session nodes, generation windows, and node-owned artifact foreign keys | Unreleased |
|
||||
| 15 | Board and session-sharing tables | Unreleased |
|
||||
| 16 | Legacy top-level transcript media fields retired | Unreleased |
|
||||
| 17 | Tenant-free per-agent lease table retired after the last writer and routing arm were removed ([#121113](https://github.com/openclaw/openclaw/pull/121113), [#121615](https://github.com/openclaw/openclaw/pull/121615)) | Unreleased |
|
||||
|
||||
Version 3 was an unshipped development step folded into version 4.
|
||||
|
||||
@@ -129,31 +135,41 @@ The general procedure is:
|
||||
3. Set `PRAGMA user_version` and `schema_meta.schema_version` to the target version.
|
||||
4. Run the target release's full database verification before starting the Gateway.
|
||||
|
||||
### Example: agent schema 11 to 9
|
||||
### Example: agent schema 17 to 16
|
||||
|
||||
Schema 10 added the active transcript projection. Schema 11 added leases, durable delivery, conversation-address state, and heartbeat outcomes.
|
||||
Schema 17 removed the tenant-free per-agent lease table. A schema 16 build still requires that canonical table, so a manual downgrade must recreate its exact schema before lowering the version.
|
||||
|
||||
Run equivalent SQL against each affected per-agent database after inspecting the exact schema that wrote it:
|
||||
|
||||
```sql
|
||||
BEGIN IMMEDIATE;
|
||||
|
||||
DROP TABLE IF EXISTS heartbeat_outcomes;
|
||||
DROP TABLE IF EXISTS conversation_deliveries;
|
||||
DROP TABLE IF EXISTS state_leases;
|
||||
DROP TABLE IF EXISTS session_transcript_active_events;
|
||||
CREATE TABLE state_leases (
|
||||
scope TEXT NOT NULL,
|
||||
lease_key TEXT NOT NULL,
|
||||
owner TEXT NOT NULL,
|
||||
expires_at INTEGER,
|
||||
heartbeat_at INTEGER,
|
||||
payload_json TEXT,
|
||||
created_at INTEGER NOT NULL,
|
||||
updated_at INTEGER NOT NULL,
|
||||
PRIMARY KEY (scope, lease_key)
|
||||
) STRICT;
|
||||
|
||||
ALTER TABLE session_transcript_index_state DROP COLUMN active_event_count;
|
||||
ALTER TABLE session_transcript_index_state DROP COLUMN active_message_count;
|
||||
ALTER TABLE conversations DROP COLUMN delivery_target;
|
||||
CREATE INDEX idx_agent_state_leases_expiry
|
||||
ON state_leases(expires_at, scope, lease_key)
|
||||
WHERE expires_at IS NOT NULL;
|
||||
|
||||
PRAGMA user_version = 9;
|
||||
CREATE INDEX idx_agent_state_leases_owner
|
||||
ON state_leases(owner, updated_at DESC);
|
||||
|
||||
PRAGMA user_version = 16;
|
||||
UPDATE schema_meta
|
||||
SET schema_version = 9,
|
||||
SET schema_version = 16,
|
||||
updated_at = unixepoch('now') * 1000
|
||||
WHERE meta_key = 'primary';
|
||||
|
||||
COMMIT;
|
||||
```
|
||||
|
||||
This discards version 10-11 state, including in-flight delivery operations, leases, heartbeat outcomes, and the derived active transcript projection. A botched downgrade means restore from the verified backup.
|
||||
The recreated table starts empty because schema 17 has no agent-DB lease tenants to preserve. A botched downgrade means restore from the verified backup.
|
||||
|
||||
Reference in New Issue
Block a user