Files
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 <[email protected]>

* 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 <[email protected]>

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

Co-authored-by: Qwen-Coder <[email protected]>

* 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 <[email protected]>

* 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 <[email protected]>

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

Co-authored-by: Qwen-Coder <[email protected]>

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

Co-authored-by: Qwen-Coder <[email protected]>

* 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 <[email protected]>

* 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 <[email protected]>

---------

Co-authored-by: Qwen-Coder <[email protected]>
Co-authored-by: Shaojin Wen <[email protected]>
2026-10-14 00:58:38 +00:00

30 lines
1.7 KiB
SQL

/* No default on role: an INSERT omitting it must fail loudly, matching the
booleans it replaces (an omission used to violate NOT NULL). The column
therefore arrives NULL, the backfill below supplies every existing row's
value explicitly, and only then is NOT NULL set. */
ALTER TABLE managed_workspace_access
ADD COLUMN role VARCHAR(16) NULL;
-- A row without can_read grants nothing today; keeping it would gain
-- READER (or OPERATOR, for a can_create row) through the backfill.
DELETE FROM managed_workspace_access WHERE can_read = FALSE;
UPDATE managed_workspace_access
SET role = CASE WHEN can_create THEN 'OPERATOR' ELSE 'READER' END;
ALTER TABLE managed_workspace_access
MODIFY COLUMN role VARCHAR(16) NOT NULL;
ALTER TABLE managed_workspace_access DROP COLUMN can_read;
ALTER TABLE managed_workspace_access DROP COLUMN can_create;
/* utf8mb4 comparisons ignore trailing spaces (PAD SPACE), so a plain IN
list would store 'READER ' — which the enum parser then rejects at
read time. Equality plus a length per name pins the stored values
byte-exact ('READER ' matches 'READER' under PAD SPACE but is 7
chars, not 6). The predicate carries no backslash, so neither H2 nor
MySQL's string-literal escaping can rewrite it on the way in. */
ALTER TABLE managed_workspace_access
ADD CONSTRAINT managed_workspace_access_role
CHECK ((role = 'READER' AND CHAR_LENGTH(role) = 6)
OR (role = 'OPERATOR' AND CHAR_LENGTH(role) = 8)
OR (role = 'OWNER' AND CHAR_LENGTH(role) = 5));
ALTER TABLE managed_agent_session
ADD COLUMN owner_actor_key VARBINARY(2048) NULL;
UPDATE managed_agent_session SET owner_actor_key = creator_actor_key;