You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maka.apache.org by "chihumyum (via GitHub)" <gi...@apache.org> on 2026/10/06 16:51:54 UTC

[PR] fix(storage): reallocate local sequences when importing sessions [maka]

chihumyum opened a new pull request, #5973:
URL: https://github.com/apache/maka/pull/5973

   ## Summary
   
   Importing a Session bundle into a populated workspace can fail with a UNIQUE constraint error even when the Sessions are unrelated: the importer copies database-local `tool_journal_events.journal_seq` and `message_admissions.sequence` values from the source database.
   
   Let SQLite allocate those two keys in the target, inserting in source sequence order. Preserve stable identities, payloads, queue order, and all other sequence columns within the existing operational write transaction. No schema migration or public API change is needed.
   
   ## Verification
   
   - RED on unchanged production code: populated tool-history and admission imports fail on `tool_journal_events.journal_seq` and `message_admissions.sequence`. Both fresh-target cases pass; the late-conflict regression fails early on the admission sequence collision.
   - GREEN: all 32 Session import tests pass, including the five new cases. They cover fresh/populated targets, complete tool history and journal order, reordered queues and cancellation identity after reopen, unchanged existing Sessions, duplicate import rejection, and complete operational rollback plus retry after a later usage identity collision.
   - Storage suite: 1,554 tests, 1,546 passed, 8 platform/backend skips, no failures. Runtime/runtime-host affected export/import/copy/recovery/checkpoint/transcript suites: 159 passed. Tests ran from freshly built source with `NODE_NO_WARNINGS=1`.
   - Passed: `npm run lint`, `npm run format:check`, `npm run build`, `npm run typecheck`, `npx knip --workspace apps/desktop`, and `npx knip --workspace packages/ui`.
   - Passed renderer architecture check against `3597abe84356409ccc9fb649c761c1649abe941d`, Astryx surface inventory and its tests, theme artifact check, Windows skip inventory, model metadata check, and ASF header check.
   - Validation used temporary roots and synthetic data. No live account or desktop UI acceptance was performed; operational rollback coverage does not claim cross-store crash atomicity.
   
   ## AI use
   
   - [ ] No generative tool made a substantive contribution
   - [x] Generative tooling made a substantive contribution
   
   Tool(s) and scope: Codex / GPT-6 Astra contributed investigation, design comparison, implementation, regression tests, validation, and independent agent review. Agent review does not substitute for the required human committer review.
   
   ## Checklist
   
   - [x] Tests cover the change and fail without it
   - [x] Lint, format, typecheck and the affected suites pass locally
   
   Does this PR entail a change in behavior?
   
   - [x] Yes — described under Summary above
   - [ ] No
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [PR] fix(storage): reallocate local sequences when importing sessions [maka]

Posted by "chihumyum (via GitHub)" <gi...@apache.org>.
chihumyum commented on PR #5973:
URL: https://github.com/apache/maka/pull/5973#issuecomment-6050145546

   Added 34c6b2cb2 for the import-side `ORDER BY` gap. Reordering the bundle rows can't show it, because both keys are the rowid, so a plain read always returns sequence order. The test instead turns on `PRAGMA reverse_unordered_selects` on the import's own connection and imports into a populated workspace. It fails for `tool_journal_events` and for `message_admissions` independently when the import-side `ORDER BY` is removed, and checks `data_version` so it cannot pass by importing through a different connection.
   
   _🤖 Addressed by [Claude Code](https://claude.com/claude-code)_


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [PR] fix(storage): reallocate local sequences when importing sessions [maka]

Posted by "Astro-Han (via GitHub)" <gi...@apache.org>.
Astro-Han merged PR #5973:
URL: https://github.com/apache/maka/pull/5973


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [PR] fix(storage): reallocate local sequences when importing sessions [maka]

Posted by "chihumyum (via GitHub)" <gi...@apache.org>.
chihumyum commented on code in PR #5973:
URL: https://github.com/apache/maka/pull/5973#discussion_r4213481748


##########
packages/storage/src/session-bundle-policy.ts:
##########
@@ -680,6 +680,14 @@ const SESSION_LINK_COLUMNS = [
  */
 const TRIGGER_MAINTAINED_TABLES = new Set(['session_catalog_projection']);
 
+// These are database-local ordering keys, not portable identities or references.
+// Keep this semantic policy explicit: other sequence columns belong to Sessions,
+// invocations or streams and must retain their values.
+const LOCAL_SEQUENCE_COLUMNS = new Map([

Review Comment:
   Added a schema-derived guard in fe9fd2c39: it exports a real bundle, migrates a target, and fails if any table the merge copies has a single INTEGER key not in LOCAL_SEQUENCE_COLUMNS or a reasoned test allow-list (empty today). Checked that it fails when an entry is removed or a new AUTOINCREMENT session table is added.
   
   _🤖 Addressed by [Claude Code](https://claude.com/claude-code)_



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [PR] fix(storage): reallocate local sequences when importing sessions [maka]

Posted by "Astro-Han (via GitHub)" <gi...@apache.org>.
Astro-Han commented on code in PR #5973:
URL: https://github.com/apache/maka/pull/5973#discussion_r4198323661


##########
packages/storage/src/session-bundle-policy.ts:
##########
@@ -680,6 +680,14 @@ const SESSION_LINK_COLUMNS = [
  */
 const TRIGGER_MAINTAINED_TABLES = new Set(['session_catalog_projection']);
 
+// These are database-local ordering keys, not portable identities or references.
+// Keep this semantic policy explicit: other sequence columns belong to Sessions,
+// invocations or streams and must retain their values.
+const LOCAL_SEQUENCE_COLUMNS = new Map([

Review Comment:
   P3: this map is correct today. I checked every `INTEGER PRIMARY KEY` in storage, and these are the only database-global rowid keys in session-describing tables. But it is hand-maintained, so a future session table with an `AUTOINCREMENT` key would bring this collision back with no warning, and only for users importing into a populated workspace. A small schema-derived guard test would catch that. It would open a migrated database, find each table `describesASession` accepts whose PK is a single `INTEGER` column (`pk = 1` in `table_info`, with no other pk columns), and assert that each one is either in `LOCAL_SEQUENCE_COLUMNS` or deliberately allow-listed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org