Skip to content

feat(runtime-host): page semantic transcript turns - #1

Draft
Sun-GLiang wants to merge 71 commits into
codex/4123-pr1-storage-position-indexfrom
codex/4123-pr2-host-semantic-pager
Draft

feat(runtime-host): page semantic transcript turns#1
Sun-GLiang wants to merge 71 commits into
codex/4123-pr1-storage-position-indexfrom
codex/4123-pr2-host-semantic-pager

Conversation

@Sun-GLiang

@Sun-GLiang Sun-GLiang commented Aug 31, 2026

Copy link
Copy Markdown
Owner

Summary

Adds the first production consumer of the semantic transcript position snapshots introduced by PR apache#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 apache#4123

Issue: apache#4123

Stacked on upstream Draft PR apache/maka#4258 in response to review 5060816416. This is a temporary fork-local stacked Draft PR because apache/maka does not contain the fork-only PR1 base ref. It must not be merged or marked ready; any later upstream delivery or retarget requires a new controller decision.

  • Plan packet: issue-4123-pr2-semantic-transcript-v1.4-controller-approved-2026-08-31
  • Exact stacked base: b00436209373c0d8453c51f1c0cbad9f53dfeb8d
  • Exact head: 6044ea430df4ef45045d1c8667519e12f6e5d830

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. Retargeting this PR to main is controller-owned after PR1 merges.

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.

Stacked Draft

This remains a temporary fork-local Draft stacked on upstream PR apache#4258 so PR1+PR2 can be reviewed cumulatively before PR1 is marked ready. The fork-local topology is necessary because apache/maka lacks the PR1 base ref. It must not merge before PR1 or be marked ready, and later upstream delivery or retargeting to main requires a new controller decision.

AI use

Select exactly one:

  • No generative tool made a substantive contribution
  • 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

  • Tests cover the change and fail without it
  • Lint, format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No

liuxiaocs7 and others added 30 commits August 30, 2026 16:46
Project the first optimistic message before activating its new Session and suppress empty-chat content whenever a transient row is visible.

Generated-by: Maka
Clear the Desktop queue projection as soon as the matching steering message is delivered, while preserving unrelated follow-ups and allowing later nack projections to restore the entry.

Generated-by: Maka
Exercise the production model picker across saving, empty, high-cardinality, long-label, and stale-model states so Storybook and accessibility checks cover the real UI boundaries.
Exercise the production ToastProvider across diagnostics failures, destructive confirmation, long content, and dense notification stacks while preserving Astryx overlay behavior.
…pache#3905)

Cache the loaded external-session catalog per source, archive filter, and search selection so revisits render immediately while Runtime Host remains the catalog authority and background refreshes stay generation-safe.
Remove x-preview-f-free consistently from derived defaults, persisted picker synthesis, and send authorization while preserving live alternatives until upstream metadata catches up.
Exercise the production Workbar change panel across empty, failure, source-truncated, file-truncated, and edge-diff states while keeping each truncation authority distinct.
Remove the unsupported known_hosts prerequisite and align Desktop Nightly publishing with the five rsync secrets Apache Infra provides. Keep historical cleanup project-owned and lock the transport contract with regression coverage.

Generated-by: Codex
Keep native Codex compaction preferred and use the existing text summarizer once when a non-retryable compaction rejection occurs.
…S Seatbelt (apache#4237)

Allow directory-only ancestor traversal under macOS Seatbelt so Bun can reach an explicitly readable workspace.
Use one shared source policy for Codex thread discovery and import across the core and SQLite-backed paths.
Centralize CLI/TUI user-facing copy and preserve stable localized message contracts across locales.
Tie Desktop-owned ephemeral Runtime Hosts to the launcher lifecycle so an orphaned Host cannot block relaunch.
Wait on the Runtime Host readiness authority before first-run pairing to avoid a transient host_not_ready failure.
…4116)

Discover symlinked Skills that remain inside the configured root while preserving discoveryRoot as the containment authority.
Remove the fabricated permission vocabulary and report the capability facts owned by Skills and scheduled tasks directly.
…e#4255)

Regenerate the committed renderer architecture ledger so it matches the current source and restores the required main CI check. Process follow-up remains tracked in apache#4257.
Reject image- and audio-only models through the shared chat-capability authority while preserving conservative handling for unknown output modalities.
…e#4187)

Bind companion capability providers to Host-authenticated Client identities while preserving a single access-authority association contract.
Declare a main-only, approval-free Nightly deployment environment through ASF's self-service repository configuration. Extend the repository control-plane contract so the environment cannot drift to another ref or approval model.

Generated-by: Codex
…a plane (apache#3857)

* feat(runtime-host): add Gitoxide successor authority

* feat(runtime-host): project accepted Gitoxide trees

* feat(runtime-host): read accepted Gitoxide tree files

* refactor(runtime-host): separate Gitoxide candidates from accepted state

* fix(runtime-host): bind Gitoxide candidate outcomes

* chore(test): refresh Windows skip inventory

* fix(runtime-host): require direct Gitoxide receipt refs

* fix(runtime-host): close Gitoxide operation evidence gaps

* test(gitoxide): corrupt loose object portably

* test(gitoxide): tamper retry blob portably

* fix(gitoxide): verify exact candidate retry tree
…e#3705)

Derive Auto-mode tool guidance from the Runtime Host permission snapshot and the final model-visible tool surface. Keep execution, sandbox, and approval authority unchanged, fail closed when no usable shell plan exists, and cover the eligibility and exclusion boundaries in composition tests.
Add focused contract coverage for the shared Unicode sanitization pipeline used by session and foreign-session text. Lock down normalization, unsafe-format handling, whitespace collapse, code-point capping, and empty-output behavior without changing production code.
… re-login (apache#3358)

* fix(desktop): show the Codex device sign-in code on connection-detail re-login

The connection detail sheet's re-login notice drives the same
browser-assisted OAuth flow as the provider catalog panel, but never
rendered the flow's stateHint. For Codex that hint is the 9-digit device
user code the authorization page requires — the verification URL does not
embed it — so a re-login started from the notice could never be completed.

- OAuthLoginService gains showsDeviceCode: true for Codex, false for xAI,
  whose page needs no manual code (mirrors the catalog panel's !isXai
  guard). The mapping stays in use-connection-detail so the legacy AppShell
  closure gains no file and no dependency.
- OAuthReloginNotice appends the sign-in code to the banner description
  while authorization is pending, reusing the catalog's deviceCode copy.

Fixes apache#3357

Generated-by: Claude Code (Fable 5)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* chore(deps): normalize locked npm registry sources (apache#3381)

Replace stale Microsoft 1ES proxy resolutions with the canonical npm registry tarballs while preserving the exact package versions. Refresh their integrity metadata to npm-published SHA-512 digests so clean installs no longer depend on an unrelated proxy.

Generated-by: Codex

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: Wang <m4n5terrr@gmail.com>
Add production-reachable Storybook coverage for empty activity, capped many-session summaries, long generated reports, and failed generation archives.\n\nRefs apache#3944 and apache#3893.
Seventh surface under apache#3944 (one surface per PR): the Agent Graph panel had no
Storybook story. Add its failure and edge states, mounted through a scoped
`window.maka.graphs` bridge inside the real composer host seam
(.maka-detail-with-artifacts → .mainColumn), each pinning one
AgentGraphClientSnapshot.

- EmptyGraph — graph mode enabled, no operators yet: the panel's empty state.
- FailedGraph — a failed operator beside completed/running ones.
- BlockedOnUpstream — a blocked operator with the amber "waiting for input" line.
- ManyOperators — a wide fan-out (28 operators) with no fabricated omitted count
  (the read-model only elides operators past 256) — review feedback.
- LoadError — the IPC snapshot read rejects: the panel's error Banner + Retry.

The panel renders operators as a flat list (no edges/hierarchy), so tree depth
and cycles have no distinct rendering and are left out. Plays assert
reachability of each state; exact row counts / omitted lines are read-model
contracts left to the read-model's own tests (review feedback).

Refs apache#3944, apache#3893

Generated-by: Claude Code
Sixth surface under apache#3944 (one surface per PR): extend the chat transcript
(ChatView → materializeTurns → TurnView, via Product/Shell Official AppShell)
with the failure and edge states that never show up in normal use. All feed a
real message ledger through ComposedShell, like InterruptedToolAfterTurnAbort.

- FailedTurnWithToolError — a tool call errors mid-turn and the turn settles
  `failed`: the errored tool row plus the failed Banner + erroredTool description.
- ProviderRateLimited — a settled `failed` turn with errorClass 'rate_limit'.
- ProviderRetrying — a live turn whose providerRetry swaps the working phrase
  for the ModelProviderRetryIndicator banner.
- SafeResumeAfterRestart — the last turn failed with errorClass 'app_restarted',
  offering the warning-severity Banner with the 继续这一轮 safe-resume button.
- ManyTurns — 120 turns, past the transcript virtualizer's window (review
  feedback: 20 did not guarantee the virtualization path).

Streaming, aborted/interrupted, empty, and long-message states were already
covered, so this adds only the genuinely missing ones. All are safe
presentational states driven by the message ledger and live overlay.

Refs apache#3944, apache#3893

Generated-by: Claude Code
* refactor(runtime): remove unvalidated Auto tool guidance

Remove the prompt fragment, composition wiring, export, and feature-specific tests added by apache#3705. Maka has no demonstrated retry-loop reproduction or A/B evidence for this guidance, and the implemented best-fit wording does not match the issue’s CLI-first premise.

Generated-by: OpenAI Codex

* test(core): remove speculative sanitizer coverage

Remove the direct sanitizer matrix added by apache#3692. It was not tied to a reported regression, planned behavior change, or failing contract, while existing session-name and foreign-session tests continue to cover the real trust-adjacent behavior.

Generated-by: OpenAI Codex
Canonicalize Seatbelt roots through the deepest existing ancestor so writable roots and explicit denies share one path namespace. Fail closed on permission errors, symlink loops, and other non-missing canonicalization failures.
amaldevcm and others added 13 commits August 31, 2026 09:47
…section (apache#4281)

* docs(eval): restructure README with navigation and a troubleshooting section

Adds a table of contents and section headers over the existing prose,
plus two new sections with no prior coverage: the ExperimentExecutor/
SubjectAdapter extension pattern for custom executors and subjects,
and a symptom-to-fix troubleshooting table sourced from the actual
preflight/egress error strings in the codebase. No existing technical
content was altered, only reorganized.

Fixes apache#3895

Generated-by: Claude

* docs(eval): clarify the relay frame's size bound

RESULT_PAYLOAD_LIMIT_BYTES caps only the JSON payload at 2 KiB before
base64url encoding; the complete emitted line (prefix, token, length,
64-char SHA-256 digest, base64url expansion) runs closer to 2.8 KiB.
Both figures stay below Linux PIPE_BUF, but "under 2 KB" was wrong for
the whole line. Say what's actually capped at 2 KiB and what's below
PIPE_BUF instead of conflating the two.

Addresses review comment on apache#4281.

Generated-by: Claude
* feat(storage): define quiescent session snapshot boundary

Generated-by: OpenAI Codex

* fix(storage): clarify snapshot trust boundaries

Generated-by: OpenAI Codex

* fix(storage): close snapshot policy review gaps

Generated-by: OpenAI Codex

* chore(test): refresh Windows skip inventory

Generated-by: OpenAI Codex

* feat(storage): require explicit snapshot path confirmation

* fix(storage): recover orphaned snapshot staging
* refactor(cli): share local target activation guard

* feat(cli): add exact source Host retirement helper

* feat(cli): reconcile external npm Host replacement

* fix(cli): adjudicate target settlement durably

* fix(runtime-host): gate candidate admission until commit

* fix(cli): bound durable target settlement

* fix(cli): bound target activator settlement
)

* feat(runtime-host): bind OAuth login to Connection entities

Make interactive OAuth enrollment create or reauthenticate one exact Connection, recover credential and catalog publication durably, and keep Desktop account actions entity-scoped.

Generated-by: Codex

* style(storage): format OAuth enrollment paths

* fix(desktop): preserve active OAuth presentation

* test(desktop): consolidate OAuth IPC fixtures
apache#4273)

* refactor(desktop): separate shared sessions from Runtime Host profiles

Generated-by: OpenAI Codex

* fix(desktop): preserve guest authority settlement

* fix(desktop): complete Runtime Host identity projection

Generated-by: OpenAI Codex

* fix(desktop): retire sessions by Host profile identity
…4274)

* refactor(runtime-host): reconcile Peer Mesh membership state

Generated-by: OpenAI Codex

* fix(runtime-host): preserve peer mesh join intent

* fix(runtime-host): reconcile interrupted mesh joins

* fix(runtime-host): reconcile Mesh intent through live Hosts

Generated-by: OpenAI Codex

* fix(runtime-host): preserve Mesh intent through lifecycle changes
* feat(desktop): make Peer Mesh operations responsive

Generated-by: OpenAI Codex

* fix(desktop): settle guest imports before shutdown

* fix(desktop): preserve peer mesh operation outcomes

* fix(desktop): close cancellable Mesh work immediately

Generated-by: OpenAI Codex

* fix(desktop): cancel only transient Mesh work
…nversation (apache#4289)

* fix(runtime-host): copy user-uploaded attachments when branching a conversation

Forking/branching a conversation (and the sibling revision / side-conversation
copies) that contained a user-uploaded attachment failed every time with
`persistence_failed: Conversation copy is missing Session file attachment-<id>`,
surfaced to the user as the generic "操作失败 / 任务操作失败,请稍后重试" toast.

User uploads are committed as artifact records whose `turnId` is the upload id
sentinel, not a conversation turn, so the turn-scoped artifact copy never
selected them and `rewriteStorageRef` could not resolve their `session_file`
refs — the copy threw and rolled back.

Collect the `session_file` attachment ids the copied slice actually references
(new `collectConversationCopySessionFileRefs`, walking the same ref sites as
`rewriteStorageRef`) and force-include them via a new same-Session
`includeArtifactIds` input to `copyConversationArtifacts`, alongside the
existing turn-scoped selection. Lenient: unknown ids are a no-op.

Fixes apache#4288

Generated-by: Claude Code

* test(runtime-host): harden conversation-copy attachment coverage

Address non-blocking review feedback on apache#4289:

- collectConversationCopySessionFileRefs: add an archivedResults image case
  (and a child-Session archived image that must be ignored), covering the
  previously-untested archived tool-result branch.
- two-client UDS branch E2E: read back the copied attachment bytes and assert
  the rewritten session_file ref for the branch, the admitted revision, and the
  active-source side conversation — proving all three copy kinds carry the
  user-uploaded attachment, not just branch.

Refs apache#4288

Generated-by: Claude Code
The renderer architecture ledger records zero `hookTransitions` entries, so
the one-time Hook replacement escape hatch has no remaining consumers. Remove
the config key, its schema validation, the transition accounting inside the
monotonic debt check, and the tests that covered only that path. Every live
debt ledger (legacy files, feature/platform imports, growth directories,
AppShell files and closure, root debt and closure) is untouched, and the
checker output is unchanged.

Generated-by: Claude Code
* feat(desktop): migrate Nightly to GitHub Releases

Generated-by: Codex

* refactor(desktop): remove Nightlies compatibility bridge

Generated-by: Codex

* fix(desktop): accept Nightly update metadata

Generated-by: Codex

* refactor(desktop): remove redundant Latest check

Generated-by: Codex

* test(desktop): make Nightly metadata checks portable

Generated-by: Codex
* feat(core): define durable tool result projections

Generated-by: Codex

* feat(runtime): add durable projection codec

Generated-by: Codex

* feat(runtime): commit projections atomically at T2

Generated-by: Codex

* refactor(runtime): replay effective tool result projections

Generated-by: Codex

* feat(runtime-host): persist projected artifacts and recoveries

Generated-by: Codex

* refactor(runtime): remove transient Tool Result authority

Generated-by: Codex

* fix(storage): reuse projected image artifacts

Generated-by: Codex

* fix(runtime): remap projected artifacts on copy

Generated-by: Codex

* refactor(runtime): remove synthetic projection return

Generated-by: Codex

* refactor(runtime): privatize synthetic result writer

Generated-by: Codex

* fix(runtime): validate projected images before persistence

Generated-by: Codex

* fix(runtime): reject unowned projection copies

Generated-by: Codex

* refactor(runtime): remove retired conversation copy owner

Generated-by: Codex

* test(runtime): verify durable projection owner boundaries

Generated-by: Codex

* refactor(runtime): keep projection helper types private

Generated-by: Codex

* test(runtime): target durable projection T2 rollback

Generated-by: Codex

* refactor(runtime): trim projection artifact input

Generated-by: Codex

* test(runtime): produce restart projection through T2

Generated-by: Codex

* style(runtime): format session manager tests

Generated-by: Codex

* fix(runtime): make projection admission side-effect free

Generated-by: Codex

* test(runtime): replay persisted image after restart

Generated-by: Codex

* test(runtime-host): cover projection artifact restart

Generated-by: Codex

* refactor(runtime): preserve projection content fidelity

Generated-by: Codex

* fix(storage): protect projection artifacts

Generated-by: Codex

* fix(runtime): admit tool calls before publication

Generated-by: Codex

* fix(runtime): bound projection copies before allocation

Generated-by: Codex

* test(runtime-host): consolidate projection lifecycle coverage

Generated-by: Codex

* test(runtime): lock T1 failure side effects

Generated-by: Codex

* refactor(core): unify artifact source policy

Generated-by: Codex

* fix(runtime): make tool result projectors total

Generated-by: Codex
@Sun-GLiang
Sun-GLiang force-pushed the codex/4123-pr2-host-semantic-pager branch from 6044ea4 to 1d166a2 Compare August 31, 2026 09:52
Keep the Host-produced SkillInvocationResult for every admitted message disposition, including steering, follow-up, queued, started, and blocked submissions.

Persist both the original submitted placement and the Skill outcome through admission, SQLite recovery, promotion, restart, and durable retry. This lets Desktop and CLI report partial Skill preparation failures without turning a promoted next-turn retry into an operation conflict.

Update the Runtime Host protocol epoch and session schema together, with production-owner recovery coverage and exact-head CI passing.

Fixes apache#4026

Generated-by: OpenAI Codex
@Sun-GLiang
Sun-GLiang force-pushed the codex/4123-pr2-host-semantic-pager branch from 1d166a2 to 7e1e96d Compare August 31, 2026 10:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.