qwen-code/docs/developers/daemon
jinye dd82ba404e
feat(serve): Add live-state session activity watermark (#9396)
* docs(serve): Design live-state session activity timestamps

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* docs(serve): Clarify live-state timestamp semantics

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* feat(serve): Add live-state session activity watermark

Advance a bridge-local per-session activity watermark once when a prompt
that reached the running state publishes its formal terminal, project it
as the existing optional BridgeSessionSummary.updatedAt, and expose it on
the workspace live-state route. The advance is written before the
terminal is published so a client that observes the terminal cannot read
a stale value, and the extra millisecond keeps the watermark strictly
increasing when several terminals share a wall-clock millisecond or the
clock moves backward. A queued-only terminal, heartbeat, attach/detach,
or streamed update never advances it, and turn activity does not change
the session catalog version.

Populating the already-typed summary field lets full workspace session
lists merge live and persisted timestamps. Because the mtime and the
running-turn watermark are different authorities and the recorder writes
asynchronously, the merge picks the later valid timestamp instead of
blindly preferring the live value, so a row cannot move backward when an
async transcript write lands after the terminal.

Extend the response schema documentation for the live-state route and
GET /session/:id/status, and add the optional field on the TypeScript
SDK DaemonSessionLiveState type so consumers can pre-flight the tag once
and read the recency directly.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* fix(serve): Apply the later-valid activity rule on Live Task read paths

read_thread and wait_threads read the bridge summary directly, so once the
summary began carrying the running-turn watermark their fallbacks stopped
consulting the persisted transcript timestamp. Because the recorder writes
asynchronously, one task could report a later recency from the thread list than
from a thread read, and a wait cursor keyed on the live value alone stopped
changing when only the transcript advanced, so a consumer waiting for that
flush saw an unchanged cursor and exited early. Move the merge rule into a
shared helper and apply it at all three read points, including the revision
fallback used for a session with no attached client.

Add the watermark cases the design doc enumerates but the previous commit did
not ship: the deadline path publishes its terminal twice and must still advance
exactly once, a corrected forward clock jump must never decrease the value, and
a clock that advances between terminals must be reported instead of the logical
tie-breaker. Cover the single-session status route's verbatim pass-through of
the field, and cover the helper's both-invalid tail directly because no route
can supply two invalid candidates.

Correct two design-doc test-plan claims that did not match the code: the
teardown paths advance a watermark no consumer can read, because the entry
leaves live state in the same operation, and the duplicate deadline terminal
comes from the raced rejection reaching the settle handler rather than from a
late agent result.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* fix(serve): Merge live state on every organized session page

The organized view applied the live merge only on the first page, so page 1
sorted rows and encoded its cursor from merged activity keys while later pages
keyed the same rows by persisted mtime alone. That was harmless while bridge
summaries never carried an activity timestamp, because both keys were the mtime.
Now that a settled turn advances a watermark that leads storage until the
recorder flushes, a live row ordered onto page 1 by its watermark falls behind
the page-1 cursor boundary on page 2 and is returned a second time, displacing a
genuinely new row. Merge live state on every page so both pages key rows the
same way; a live-only row still has no persisted key to page by and stays a
first-page insertion.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* docs(serve): Document activity-cursor duplication on live retirement

The activity key merges the live watermark, which is in-memory only, so a
session whose live entry retires mid-pagination falls back to its transcript
mtime and can be admitted again by a cursor encoded from the higher watermark.
Pre-change keys came from mtime alone and only advanced, so pages could skip a
row but never repeat one. Name that mode in the design doc and warn SDK
consumers of the activity-ordered cursors to key accumulated pages by
sessionId.

* fix(serve): Exclude emitted identities from activity-cursor re-admission

An activity key merges the bridge's in-memory watermark, so it is not a
stable property of a row: when a live entry retires mid-pagination the key
regresses to the transcript mtime, and a live-only row that persists mid-pass
re-enters the scan keyed by its first flush. Either way a row already emitted
on an earlier page could pass the strictly-older cursor filter again and
displace a genuinely new row, which was structurally impossible while activity
keys came from mtime alone.

The organized and metadata activity cursors now carry the identities already
emitted at a live-derived key, and the after-cursor filter excludes them, so
one pass returns a session at most once. The list prunes itself: an identity
is dropped once its persisted floor alone can no longer pass the key filter or
once the row leaves the filtered collection while not live. Past a 64-identity
cap the highest floors are dropped first, degrading to the previous at-most-
once duplicate instead of failing the pass. Cursors minted before the field
existed stay valid, and the field is omitted when empty.

* fix(serve): Close carried-identity drop paths in activity-cursor pagination

The emitted-identity carry could still drop a carried session mid-pass and
re-admit it later: an identity absent from a page's collection was discarded
even though absence can be transient (pre-flush TTL cache, mid-pass group
movement), organized re-entry was evaluated under the row's current pin state
only, and the live-only cursor key could move backward when a wall-clock
rollback landed the first watermark behind createdAt.

Retain absent carried identities at a negative-infinity floor, test organized
re-entry under both pin states, and floor the first watermark advance at the
entry's createdAt. Extend the retire test to a three-page pass so carried-set
propagation through an intermediate cursor is pinned, probe scan visibility in
the mid-pass-flush tests, and cover the live-list-failure and unpin paths.
Scope the at-most-once pagination wording in the design and protocol docs to
what the carry actually guarantees.

* docs(design): floor the first watermark advance at createdAt in the normative formula

---------

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
2026-08-19 03:31:44 +00:00
..
00-index.md chore(serve): remove the /demo debug page (#8805) 2026-08-10 13:31:15 +00:00
01-architecture.md feat: consolidate Local Control into one daemon-owned implementation (#9106) 2026-08-17 16:44:48 +00:00
02-serve-runtime.md feat(serve): add pollable daemon turn status (#9080) 2026-08-18 06:35:17 +00:00
03-acp-bridge.md fix(acp-bridge): bound live journal replay chunks (#8801) 2026-08-10 09:52:17 +00:00
04-permission-mediation.md docs(daemon): refresh daemon docs for recent PRs (wave 2) (#5954) 2026-06-28 08:36:30 +00:00
05-mcp-transport-pool.md docs(serve): Close multi-workspace hardening gaps (#7019) 2026-07-16 17:33:53 +00:00
06-mcp-budget-guardrails.md docs(serve): Close multi-workspace hardening gaps (#7019) 2026-07-16 17:33:53 +00:00
07-workspace-filesystem.md feat(daemon): make serve new-file mode configurable (QWEN_SERVE_NEW_FILE_MODE) (#9364) 2026-08-18 03:42:35 +00:00
08-session-lifecycle.md chore(serve): Log session continuation admissions (#8932) 2026-08-11 14:34:08 +00:00
09-event-schema.md feat(daemon): attach skill-toggle mutation metadata to settings_changed (#9051) 2026-08-17 05:01:41 +00:00
10-event-bus.md fix: Make chat recording failures durable and visible (#6743) 2026-07-12 10:52:26 +00:00
11-capabilities-versioning.md feat(serve): Add workspace session live-state endpoint and catalog version (#9261) 2026-08-17 15:01:50 +00:00
12-auth-security.md feat(serve): add pollable daemon turn status (#9080) 2026-08-18 06:35:17 +00:00
13-sdk-daemon-client.md feat(serve): Add live-state session activity watermark (#9396) 2026-08-19 03:31:44 +00:00
14-cli-tui-adapter.md fix: Make chat recording failures durable and visible (#6743) 2026-07-12 10:52:26 +00:00
15-channel-adapters.md feat(web-shell): redesign Channel policy and workspace management (#8848) 2026-08-14 07:41:44 +00:00
16-vscode-ide-adapter.md feat(cli): Enable multi-workspace session routing (#6511) 2026-07-08 10:06:31 +00:00
17-configuration.md feat(review): Aone Code read path (second review-platform provider) (#9226) 2026-08-18 09:19:52 +00:00
18-error-taxonomy.md feat(serve): add pollable daemon turn status (#9080) 2026-08-18 06:35:17 +00:00
19-observability.md feat(cli): correlate daemon logs with OpenTelemetry spans (#9084) 2026-08-13 16:33:12 +00:00
20-quickstart-operations.md feat(daemon): Isolate the Conversations runtime boundary (#9181) 2026-08-16 17:32:45 +00:00
_meta.ts docs(daemon): Refresh daemon docs in English (#5144) 2026-06-15 22:38:01 +08:00