qwen-code/docs/archive/managed-agent-schema/sql/V2__managed_agent_projection.sql
jinye 1f39a80bf0
feat(managed-agent): consolidate persistence into a 32-table baseline (#14069)
* feat(managed-agent): consolidate persistence into a 32-table baseline

Preserve journal, idempotency, runtime, physical storage and recovery boundaries in a shared fresh-database schema. Add fixed snapshots, typed operations, scoped resource collection and atomic automation projections with MySQL fault and load coverage.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* fix(managed-agent): restore schema CI and channel claim fencing

Avoid nested snapshot connection borrowing while preserving committed read-lease expiry and retirement checks. Carry reserved channel reconciliation identities into private journal commands and retain UNKNOWN no-resend behavior.

Update canonical-schema fixtures, migration discovery and application packaging. Preserve the 32-table fresh-database boundary and record local versus pending CI acceptance in both languages.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* fix(managed-agent): refuse system catalogs before schema initialization

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* fix(managed-agent): restore fresh-schema E2E and MariaDB validation

Port the real-stack runner and its audits to canonical tables, retain stream and approval scopes, and register fresh Linux storage before Harness admission.

Validate MariaDB CHECK enforcement and InnoDB without relying on MySQL-only metadata or negative-test syntax. Add regression coverage and document current platform and acceptance boundaries.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* fix(managed-agent): normalize boolean CASE catalog literals

Accept MariaDB's numeric representation of bare SQL boolean literals while retaining structural CHECK validation, quoted values and enforcement guards.

Add alias and tamper regression coverage and synchronize the bilingual verification evidence.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* fix(ci): raise managed schema MariaDB packet budget

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* fix(managed-agent): support MariaDB load-test query plans

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* fix(managed-agent): Restore native storage fixtures and const read witnesses

Preserve measured row counts while bounding MariaDB optimization-stage page reads, and register Linux Hosted test storage through the production guard before tool admission. Keep recovery registration across restarts and resolve physical owners through aliases.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* test(managed-agent): Await snapshot publication in retraction checks

Keep the strict terminal snapshot watermark assertion while allowing after-commit publication to finish under the concurrent materializer.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

---------

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
Co-authored-by: Shaojin Wen <shaojin.wensj@alibaba-inc.com>
2026-10-14 00:58:38 +00:00

68 lines
2.6 KiB
SQL

CREATE TABLE managed_agent_item (
tenant_id VARCHAR(128) NOT NULL,
session_id VARCHAR(64) NOT NULL,
item_id VARCHAR(128) NOT NULL,
turn_id VARCHAR(64) NOT NULL,
item_type VARCHAR(32) NOT NULL,
item_role VARCHAR(32),
item_status VARCHAR(32) NOT NULL,
attributes_json LONGTEXT NOT NULL,
first_sequence BIGINT NOT NULL,
last_sequence BIGINT NOT NULL,
created_at BIGINT NOT NULL,
updated_at BIGINT NOT NULL,
revision BIGINT NOT NULL DEFAULT 1,
PRIMARY KEY (tenant_id, session_id, item_id),
FOREIGN KEY (tenant_id, session_id)
REFERENCES managed_agent_session (tenant_id, session_id)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
CREATE INDEX managed_agent_item_history_idx
ON managed_agent_item (tenant_id, session_id, first_sequence);
CREATE TABLE managed_agent_item_part (
tenant_id VARCHAR(128) NOT NULL,
session_id VARCHAR(64) NOT NULL,
item_id VARCHAR(128) NOT NULL,
part_id VARCHAR(128) NOT NULL,
part_type VARCHAR(32) NOT NULL,
part_text LONGTEXT NOT NULL,
first_sequence BIGINT NOT NULL,
last_sequence BIGINT NOT NULL,
created_at BIGINT NOT NULL,
updated_at BIGINT NOT NULL,
revision BIGINT NOT NULL DEFAULT 1,
PRIMARY KEY (tenant_id, session_id, item_id, part_id),
FOREIGN KEY (tenant_id, session_id, item_id)
REFERENCES managed_agent_item (tenant_id, session_id, item_id)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
CREATE TABLE managed_agent_snapshot (
tenant_id VARCHAR(128) NOT NULL,
session_id VARCHAR(64) NOT NULL,
snapshot_version BIGINT NOT NULL,
covered_sequence BIGINT NOT NULL,
items_json LONGTEXT NOT NULL,
created_at BIGINT NOT NULL,
updated_at BIGINT NOT NULL,
PRIMARY KEY (tenant_id, session_id),
FOREIGN KEY (tenant_id, session_id)
REFERENCES managed_agent_session (tenant_id, session_id)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
CREATE TABLE managed_agent_consumer_progress (
tenant_id VARCHAR(128) NOT NULL,
session_id VARCHAR(64) NOT NULL,
consumer_name VARCHAR(64) NOT NULL,
covered_sequence BIGINT NOT NULL DEFAULT 0,
updated_at BIGINT NOT NULL,
PRIMARY KEY (tenant_id, session_id, consumer_name),
FOREIGN KEY (tenant_id, session_id)
REFERENCES managed_agent_session (tenant_id, session_id)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
INSERT INTO managed_agent_consumer_progress (
tenant_id, session_id, consumer_name, covered_sequence, updated_at
)
SELECT tenant_id, session_id, 'message_projection', 0, updated_at
FROM managed_agent_session;