You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maka.apache.org by "Sun-GLiang (via GitHub)" <gi...@apache.org> on 2026/08/31 00:38:11 UTC

[PR] feat(runtime-host): page semantic transcript turns [maka]

Sun-GLiang opened a new pull request, #4295:
URL: https://github.com/apache/maka/pull/4295

   ## Summary
   
   Adds the first production consumer of the semantic transcript position snapshots introduced by PR #4258. Runtime Host now exposes subscription-scoped semantic position paging and complete semantic Turn windows through strict, additive protocol operations, while keeping exact Storage identities, leases, watermarks, and shared-only data private to the Host.
   
   Refs #4123
   
   Issue: https://github.com/apache/maka/issues/4123
   
   **Depends on [apache/maka#4258](https://github.com/apache/maka/pull/4258). Do not merge or mark this PR Ready before PR1.** This is an upstream cumulative Draft targeting `main` because `apache/maka` does not contain the fork-only PR1 base ref. It temporarily exposes the cumulative PR1 + PR2 diff. After PR1 merges, the controller must revalidate the exact resulting history and, if the project merge method requires it, explicitly authorize the rebase/update that narrows this PR to PR2-only. This delivery follows [review 5060816416](https://github.com/apache/maka/pull/4258#pullrequestreview-5060816416).
   
   - Plan packet: `issue-4123-pr2-semantic-transcript-v1.4-controller-approved-2026-08-31`
   - Exact embedded PR1 predecessor: `1c79bad38d12cffabfd329be8bfd83baf8728561`
   - Exact head: `9d9c67d73313000869a452180654eb27169f3c35`
   - `apache/maka` main ref observed immediately before creation: `ac59b47b72cdfd63b737dac6946715789ce277c5`
   
   ### Protocol and client surface
   
   - `session.transcript.positions.query` accepts the strict `acquire | page | continue | replace | release` union and returns `page | building | capacity | snapshot_stale | anchor_not_found | released`.
   - `session.transcript.turn_window.page` accepts `open | continue` and returns `page | building | capacity | snapshot_stale | anchor_not_found | position_too_large`.
   - Wire positions expose only dense `{ ordinal, key }` values, where the key is `turn | note | empty`. Storage snapshot triples, leases, projection, sequences, recovery progress, raw counts, and retained generations remain Host-private.
   - Snapshot tokens, position cursors, and window cursors are opaque, subscription-bound, incarnation-bound, domain-separated HMAC-SHA256 values. Snapshot handles map to the exact Storage triple and lease in Host state; cursors bind the snapshot-token digest and their ordinal/window continuation state.
   - `ClientSessionSubscription` now provides `queryTranscriptPositions(...)`, `loadTranscriptTurnWindow(...)`, and `decodeTranscriptTurnWindowPage(...)`. The existing fragment assembler was extracted and reused; callers receive only a complete digest- and decode-validated logical window.
   
   Retryable `building` and `capacity` results carry only a fixed retry hint. A valid opaque handle whose internal exact snapshot is gone returns `snapshot_stale`; invisible/missing anchors return `anchor_not_found`; an individually oversized position returns `position_too_large` with no fragments. Tampered/replayed inputs map to `invalid_request`, access failures to non-disclosing `not_found`, recovery corruption to `persistence_failed`, and failed replacement CAS to `operation_conflict`.
   
   ### Lifecycle, privacy, and bounds
   
   - Semantic acquisition uses a separately delivered `semanticEligibleThroughSequence`; v34 subscription open performs no semantic Storage work.
   - One Host-owned opaque lease is tied to each active semantic snapshot. Acquire is idempotent, replace prepares before CAS, release is idempotent, and subscription/connection/access/Host shutdown paths await cleanup.
   - Shared subscriptions use `projectSharedSessionTranscriptMessage` as the only sanitizer. Dense shared positions reveal neither hidden identities nor hidden counts; hidden records still count against Storage body limits.
   - A logical window contains at most 10 complete positions, 256 records, and 16 MiB raw/encoded data. Each retained immutable window is encoded and hashed once, fragments are at most 512 KiB, and continuation performs slicing only.
   - Existing and semantic transcript users share the 64 MiB retained ledger, 48 MiB preparation reservation, 64-waiter cap, one active semantic window per subscription, 64-window maximum, and 5-minute idle TTL.
   
   ### PR1 consumer-invariant mapping
   
   | PR1 mechanism | Production PR2 invariant |
   | --- | --- |
   | normalized membership/order metadata | dense position pages and exact per-key body probes |
   | bounded legacy/imported/chunked recovery | one bounded Storage step per Host request; v34 chunk recovery resumes after Host reopen |
   | persisted SHA/scanner state | >4 MiB recovery continuation survives owner replacement without retaining bodies |
   | exact snapshot triple and immutable Ready rows | private handle state and signed continuation stability |
   | two retained generations | replacement can be prepared while the current snapshot remains usable |
   | opaque leases/refcounts | subscription lifecycle, shared-generation ownership, and awaited release |
   | capacity/backpressure | privacy-neutral typed Host result, without eviction/fallback |
   | monotonic generation | stale-handle/cursor ABA rejection after release, reopen, and reallocation |
   
   ### Out of scope
   
   No Desktop/Preload/Renderer production activation, continuous layout, navigation, export, compatibility-epoch switch, legacy-path removal, Storage schema redesign, or PR3/PR4 behavior is included. The two Desktop/CLI changes are test-fixture compile stubs only. Current Desktop does not call either operation. Any post-PR1-merge history update or narrowing remains controller-owned.
   
   ## Verification
   
   - `npm --workspace @maka/storage test` — 1072 total, 1065 passed, 7 skipped, 0 failed.
   - `npm --workspace @maka/runtime-host test` — 1449 total, 1440 passed, 9 skipped, 0 failed.
   - Focused Storage semantic index tests — 55/55 passed.
   - Focused compiled Runtime Host semantic/protocol/reader/client/coordinator/connection/composition tests — 184/184 passed.
   - `npm test` — all workspace tests passed on the final exact-command rerun.
   - `npm run build`, `npm run format:check`, `npm run lint`, `npm run typecheck` — passed.
   - `npx knip --workspace apps/desktop` and `npx knip --workspace packages/ui` — passed.
   - ASF headers, repository notices, and CLI notices checks — passed.
   - Epoch guard against exact stacked base — declared compatible extension at epoch 73; guard tests 12/12 and semantic protocol codec tests 6/6 passed.
   - Both exact-base and cumulative `git diff --check` — passed.
   
   Benchmark evidence (`npm --workspace @maka/runtime-host run benchmark:transcript`, plus `MAKA_TRANSCRIPT_BENCHMARK_FULL_SEMANTIC=1`):
   
   - 10,000 alternating-visibility positions: owner 10,000 / shared 5,000; two generations contain 20,000 position rows; 100 warm exact tail/ordinal/Turn-anchor reads kept the exact key stable with WAL delta 0 and data-version delta 0.
   - 15 MiB single position: one body read/project/encode, 31 fragments, wire amplification 1.335, no oversized result.
   - 17 MiB single position: `position_too_large`, zero fragments.
   - 17 MiB / 64 MiB multi-position fixtures: 428 / 1609 logical windows, wire amplification 1.383, peak retained accounting about 0.04 MiB, and cleanup returned retained accounting to zero.
   - Production integration covers real SQLite -> Runtime Host -> production client, shared privacy, bodyless admissions, visible/hidden notes, two-slot capacity, lease refcount, monotonic ABA, and persisted v34 >4 MiB chunk recovery across Host reopen.
   
   Independent Standards and Spec/Composition reviews both passed the final head with no blocking or high-severity findings.
   
   ### Cumulative Draft
   
   This upstream Draft targets `main` only because `apache/maka` lacks the fork-only PR1 base ref. Its current review surface is intentionally cumulative PR1 + PR2 and depends on upstream PR #4258. It must not merge or be marked Ready before PR1. After PR1 merges, the controller must revalidate the resulting history and explicitly authorize any rebase/update required to narrow the diff to PR2-only.
   
   ## AI use
   
   Select exactly one:
   
   - [ ] No generative tool made a substantive contribution
   - [x] Generative tooling made a substantive contribution
   
   Tool(s) and scope: OpenAI Codex implemented the Runtime Host protocol/client/server changes, tests, benchmark coverage, and review fixes. The commit includes the required `Generated-by: OpenAI Codex` trailer.
   
   ## 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] feat(transcript): add semantic position snapshots and Runtime Host paging [maka]

Posted by "Sun-GLiang (via GitHub)" <gi...@apache.org>.
Sun-GLiang closed pull request #4295: feat(transcript): add semantic position snapshots and Runtime Host paging
URL: https://github.com/apache/maka/pull/4295


-- 
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] feat(transcript): add semantic position snapshots and Runtime Host paging [maka]

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

   Thanks for putting so much work into this. Please pause here before spending more time on PR3 or PR4. I need to correct the direction first.
   
   #4123 describes a real problem: the durable transcript is complete, but Desktop only exposes the current resident range to the Renderer. When the user jumps from the live tail to an old Turn, the range is replaced and the intermediate Turns lose their logical positions. They are still in Storage, but the conversation can look discontinuous.
   
   I wrote #4123 before #4206 landed. At that time, the Renderer had its own Turn virtualizer, height index, spacers, scroll compensation, and observers. #4206 later removed those mechanisms because they created a second layout and scroll state machine. It moved the active transcript bound into Runtime Host, kept the Renderer projection small and stable, and left the existing chat scroll logic as the single scroll authority.
   
   I should have updated #4123 after that change, but I didn’t. The issue still described the old virtualizer architecture, so it encouraged you to build the backend for a design that no longer exists on `main`. That is my mistake, not yours.
   
   The current PR builds a much stronger system than the remaining product problem requires. It adds materialized position snapshots, two retained generations, durable leases, resumable legacy scanning, a second body paging protocol, and several new recovery and cursor state machines. Those pieces are carefully implemented, but there is still no Desktop consumer in this PR, so the user-visible problem remains unchanged.
   
   Some of these guarantees also work against the performance goal. A new transcript watermark can require rebuilding the complete position snapshot, and every normal transcript append now synchronously maintains the new semantic index even though Desktop does not consume it yet. I don’t think it is responsible to ask you to keep polishing this design before the real Desktop composition proves that these mechanisms are necessary.
   
   I’m going to revise #4123 around the architecture that exists after #4206. The smaller direction I want to validate is:
   
   - Keep Runtime Host’s existing bounded transcript range and the current single scroll authority.
   - Add one lightweight, incrementally maintained logical position index containing only the identity and ordering needed for layout and navigation.
   - Page that index with a watermark or revision and a simple keyset cursor. A stale index can be re-anchored instead of retaining old materialized generations.
   - Continue using the existing `session.transcript.page` path for message bodies rather than introducing another body window, fragment, cache, and cursor protocol.
   - Start with one real Desktop owner path and an end-to-end regression covering old, intermediate, and live-tail navigation. That consumer should determine which backend guarantees are actually needed.
   - Defer shared guest virtualization, bodyless durable positions, exact old-snapshot survival, and byte-level resumable scanning until a concrete product path requires them.
   
   Please keep this PR as Draft for now. I don’t want you to throw away the branch yet because the tests and implementation are useful evidence, and parts of the normalized position index may still carry over. I first need to rewrite the issue and narrow the contract against current `main`.
   
   If I have missed a constraint that makes this smaller design unworkable, please push back. You have spent more time inside these failure and recovery paths than I have, and I want that context before deciding what can be removed.
   
   I used Codex to compare this PR with current `main`, #4123, and #4206, and independently checked the architecture and production paths discussed here.
   


-- 
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