qwen-code/docs/archive/managed-agent-schema/sql/V45__managed_session_task_journal.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

49 lines
2.3 KiB
SQL

-- The bounded per-task event journal of a Managed Session's tasks (H3 of
-- #12827): one row per committed task event, written in the transaction that
-- commits the revision or durable output that produces it, so the task
-- events routes read a committed prefix and never an event ahead of its
-- commit. One logical cursor position per event; the sequence is assigned
-- under the Session's journal head lock, in commit order.
-- Named a journal, not qwen_managed_session_task_event, because the H0c
-- follow-up fixes in flight reserve that name for the task-view outbox the
-- event feed would drain from.
CREATE TABLE qwen_managed_session_task_journal (
session_scope_key CHAR(64) NOT NULL,
tenant_id VARCHAR(128) NOT NULL,
session_id VARCHAR(512) NOT NULL,
task_id VARCHAR(128) NOT NULL,
event_sequence BIGINT NOT NULL,
event_type VARCHAR(32) NOT NULL,
occurred_at BIGINT NOT NULL,
schema_version INT NOT NULL,
projection_version INT NOT NULL,
state VARCHAR(32),
runtime_state VARCHAR(32),
text MEDIUMTEXT,
truncated TINYINT(1),
artifact_id VARCHAR(512),
capture_id VARCHAR(128),
stream_id VARCHAR(128),
first_ordinal BIGINT,
end_ordinal BIGINT,
archived TINYINT(1) NOT NULL DEFAULT 0,
PRIMARY KEY (session_scope_key, task_id, event_sequence)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
-- The durable per-task positions the journal serves from: the last assigned
-- sequence (the committed tail the task view's output cursor points past),
-- the retention floor (the position after the newest expired event), and the
-- task's newest unique artifact references. The floor lives here and not in
-- the event rows, so it survives an empty retained set, restarts and
-- projection rebuilds; only an oldest prefix may expire, and never past an
-- output event whose full text is not yet durably archived.
CREATE TABLE qwen_managed_session_task_journal_cursor (
session_scope_key CHAR(64) NOT NULL,
tenant_id VARCHAR(128) NOT NULL,
session_id VARCHAR(512) NOT NULL,
task_id VARCHAR(128) NOT NULL,
last_sequence BIGINT NOT NULL DEFAULT 0,
expired_through BIGINT NOT NULL DEFAULT 0,
artifact_refs MEDIUMTEXT NOT NULL,
PRIMARY KEY (session_scope_key, task_id)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;