Skip to content

Commit 8121209

Browse files
author
SqlRush
committed
Accept sidechain description field aliases
1 parent 2399baa commit 8121209

5 files changed

Lines changed: 22 additions & 8 deletions

File tree

docs/claude-code-go-rewrite-plan.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ test/parity/ # golden tests against TS/official behavior
182182
当前进度:
183183

184184
- 已落地 JSONL/session 基础、resume/search/title 支撑、prompt history lock/buffered flush/field aliases、official subagent transcript layout、agent metadata sidecar/field aliases、sidechain runtime start/append/finish/cancel/fail 和 parent-chain append/finish 初版、sidechain manager orchestration 初版、sidechain manifest 聚合、sidechain state/list/resume/content-field aliases 初版、sidechain resume context builder、sidechain conversation/content-replacement reconstruction、transcript tail/window/metadata/index loaders、byte-budget transcript tail loader、agent-scoped content replacement metadata/record field-alias loading、session-scoped metadata reappend including AI-title/last-prompt/task-summary、transcript line offset index/window/byte-budget-window/parent-chain/resume/tail/byte-budget-tail loaders、extended transcript metadata entries/type/field aliases、transcript message/session UUID field aliases including top-level `messageUuid`/`messageId`/`id` record IDs and `role`/`entry_type`/`messageType`/`createdAt` timestamp aliases、transcript tombstone metadata delete/relink、transcript resume conversation builder、index 文本预览和 AI-title/last-prompt/task metadata 字段、流式 transcript 搜索、session list pagination、remote history token refresh、remote history 全量分页抓取/page-field/event-list/records/entries/eventList/sessionEvents/last-id/cursor/event-id/has-next alias/wrapped-data/links/paging/bare-array/connection/eventConnection/sessionEventsConnection wrapper response/edge-cursor fallback/max-pages 截断状态/before_id 续抓、remote event transcript materialization/fallback field fill/去重追加/duplicate parent guard、remote history 一步 sync 到 transcript、CLAUDE.md/memdir 扫描、team-memory secret guard、compact runner/boundary plan、conversation auto-compact、失败熔断、microcompact/cache 初版、persistent cached microcompact 初版、cache digest structural/rich-content metadata 覆盖、cache version/TTL/prune、in-memory micro cache prune、memory-cache write-through 到磁盘、atomic cache write、坏缓存默认 fail-open、session memory summary/frontmatter aliases/recall 初版、model-ranked recall session-id selection 和 invalid-selection fallback 初版、recall agent alternate/camel response keys/fenced-prose JSON extraction/scalar id parsing/nested/wrapped/collection-alias selection parsing、resume context model-assisted recall 接入、session memory rollup/prune compaction、rollup archive exclusion/merge、rune-safe rollup truncation、resume context + session memory recall、conversation recall 注入、deterministic/model-backed memory extraction 初版、extraction agent fenced-prose JSON/wrapped facts/provider-style response wrapper/alternate/structured field/nested source object/nested response/fact kind alias parsing 和 turn-end memory extraction 落盘。
185-
- 本轮补充:sidechain agent metadata sidecar 读取接受 `type`/`subagentType`/`agentName`/`name``workspacePath`/`workspace`/`path`/`directory``taskDescription`/`prompt`/`input`/`command`/`title` 等字段别名,避免历史或第三方 subagent sidecar 在 resume/list 时丢失 agent 类型、worktree 路径或任务描述。
185+
- 本轮补充:sidechain agent metadata sidecar 读取接受 `type`/`subagentType`/`agentName`/`name``workspaceRoot`/`workspacePath`/`workspace`/`path`/`directory``taskDescription`/`operationName`/`commandName`/`displayTitle`/`prompt`/`input`/`command`/`title` 等字段别名,避免历史或第三方 subagent sidecar 在 resume/list 时丢失 agent 类型、worktree 路径或任务描述。
186186
- 本轮补充:sidechain/subagent lifecycle content 读取会递归解包 `payload`/`data`/`body`/`result`/`response`/`metadata` 等 wrapper,嵌套的 subagent ID、status/outcome、summary、agent type、workspace path 和 task description 都可参与 state/list/resume 恢复。
187187
- 本轮补充:sidechain/subagent lifecycle content 读取现在也接受 JSON:API/resource-style 的 `resource`/`attributes`/`properties` wrapper;外层 resource `id` 可作为 sidechain ID fallback,内层 metadata、status/outcome 和 summary 仍会参与 state/list/resume 恢复。
188188
- 本轮补充:sidechain/subagent lifecycle content 读取现在也递归解包 GraphQL/JSON:API 风格的 `edge`/`node`/`attrs` wrapper,wrapped start/summary event 可继续恢复 ID、status、summary 和 agent metadata。
@@ -219,7 +219,7 @@ test/parity/ # golden tests against TS/official behavior
219219
- 本轮补充:remote history response parser 现在也接受 provider-style `choices`/`outputs`/`candidates`/`generations` wrapper 以及顶层 `message`/`content`/`text` envelope,可从 `message.content`、content-block array 和 `content.parts[].text` 中恢复 event page JSON(包括 fenced `json` code block),并保留 pagination 继续驱动 `before_id` 续抓。
220220
- 本轮补充:remote history pagination 现在接受 `starting_after`/`startingAfter`/`after*` cursor aliases,page 字段和 link URL query 都可驱动下一页 `before_id` 续抓。
221221
- 本轮补充:remote history `SDKEvent` 本体接受 `eventType`/`event_type`/`role` 类型别名、`createdAt`/`created_at` 时间戳别名,以及 `payload`/`data`/`body`/`metadata`/`meta`/`attributes`/`properties`/`serializedMessage` message payload 别名;payload 只有 `role`/`content` 时也能 materialize 成 transcript message。
222-
- 本轮补充:sidechain lifecycle 读取现在接受运行时相邻字段别名,包括 `jobId`/`threadId`/`workflowId`/`operationId`/`requestId``workerType`/`taskType``workspaceRoot`/`projectPath``instructions``jobStatus``resultState``outputText` 和毫秒级 start/end time 字段,并会递归解包 `runtime`/`context`/`state` 容器。
222+
- 本轮补充:sidechain lifecycle 读取现在接受运行时相邻字段别名,包括 `jobId`/`threadId`/`workflowId`/`operationId`/`requestId``workerType`/`taskType``workspaceRoot`/`projectPath``instructions`/`operationName`/`commandName`/`displayTitle``jobStatus``resultState``outputText` 和毫秒级 start/end time 字段,并会递归解包 `runtime`/`context`/`state` 容器。
223223
- 本轮补充:transcript resume 的嵌套 content block 接受 `toolUseId`/`toolUseID``isError``cacheControl``cacheReference` 字段别名,并保留 cache edit 的 `cacheReference`
224224
- 本轮补充:transcript resume 的 nested content block `id`/`tool_use_id`/`toolUseId` 现在接受 JSON number,并保留为字符串 tool-use ID。
225225
- 本轮补充:嵌套 contract message 的 `content` 接受字符串、单个 content-block 对象,以及混合字符串/content-block 数组;字符串会归一为 text block,并接受 `text`/`body`/`message`/`value`/`output` 正文字段和 `role`/`messageType` 类型别名,提升 transcript/remote history payload 恢复率。

docs/first-second-parity-audit.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ M6 progress now includes:
205205
- `internal/session`: sidechain lifecycle content loading now also recurses through GraphQL/JSON:API `edge`/`node`/`attrs` wrappers, preserving wrapped start and summary event fields during state/list/resume recovery.
206206
- `internal/session`: sidechain lifecycle field extraction now also traverses collection wrappers such as `edges`, `nodes`, and `included`, plus array elements, so GraphQL connection or JSON:API included start/summary payloads can still recover state/list/resume fields.
207207
- `internal/session`: sidechain lifecycle scalar fields now accept JSON number values for IDs and other string-like fields, preserving numeric subagent IDs as strings across state/list/resume recovery.
208-
- `internal/session`: sidechain lifecycle loading now accepts adjacent runtime aliases such as `jobId`, `threadId`, `workflowId`, `operationId`, `requestId`, `workerType`, `taskType`, `workspaceRoot`, `projectPath`, `instructions`, `jobStatus`, `resultState`, `outputText`, and millisecond start/end time fields under `runtime`/`context`/`state` wrappers.
208+
- `internal/session`: sidechain lifecycle and metadata sidecar loading now accept adjacent runtime aliases such as `jobId`, `threadId`, `workflowId`, `operationId`, `requestId`, `workerType`, `taskType`, `workspaceRoot`, `projectPath`, `instructions`, `operationName`, `commandName`, `displayTitle`, `jobStatus`, `resultState`, `outputText`, and millisecond start/end time fields under `runtime`/`context`/`state` wrappers.
209209
- `internal/session`: sidechain runtime finish now canonicalizes status aliases such as `success`, `error`, and `canceled` before writing summary records, keeping sidechain and main transcript lifecycle output stable.
210210
- `internal/session`: sidechain runtime now rejects duplicate starts while the same sidechain ID is running, and state loading treats a later start as a fresh lifecycle by clearing stale summary/end metadata.
211211
- `internal/session`: sidechain lifecycle state loading now accepts adjacent subtype aliases such as `subagent_started`, `agentStarted`, `task_failed`, and `sidechainCompleted`, with broader task/worker/run ID fields plus `resultText`/`finalMessage` summaries and subtype-derived failed/cancelled defaults.

internal/session/sidechain_metadata.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,25 @@ func (m *SidechainMetadata) UnmarshalJSON(data []byte) error {
2424
}
2525
metadata := SidechainMetadata(canonical)
2626
if metadata.AgentType == "" {
27-
metadata.AgentType = firstStringField(fields, "agent_type", "agentKind", "agent_kind", "agent", "type", "subagentType", "subagent_type", "agentName", "agent_name", "name")
27+
metadata.AgentType = firstStringField(fields, appendSidechainMetadataFallbackFields(sidechainLifecycleAgentTypeFields, "type")...)
2828
}
2929
if metadata.WorktreePath == "" {
30-
metadata.WorktreePath = firstStringField(fields, "worktree_path", "worktree", "worktreeDir", "worktree_dir", "workingDirectory", "working_directory", "cwd", "workspacePath", "workspace_path", "workspace", "path", "directory")
30+
metadata.WorktreePath = firstStringField(fields, sidechainLifecycleWorktreeFields...)
3131
}
3232
if metadata.Description == "" {
33-
metadata.Description = firstStringField(fields, "description_text", "descriptionText", "desc", "summary", "task", "taskDescription", "task_description", "prompt", "input", "command", "title")
33+
metadata.Description = firstStringField(fields, sidechainLifecycleDescriptionFields...)
3434
}
3535
*m = metadata
3636
return nil
3737
}
3838

39+
func appendSidechainMetadataFallbackFields(fields []string, fallback ...string) []string {
40+
out := make([]string, 0, len(fields)+len(fallback))
41+
out = append(out, fields...)
42+
out = append(out, fallback...)
43+
return out
44+
}
45+
3946
func (m SidechainMetadata) Empty() bool {
4047
return m.AgentType == "" && m.WorktreePath == "" && m.Description == ""
4148
}

internal/session/sidechain_status.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,13 @@ var sidechainLifecycleDescriptionFields = []string{
7676
"taskPrompt", "task_prompt",
7777
"instructions", "instruction",
7878
"objective", "goal", "request",
79+
"operationName", "operation_name",
80+
"commandName", "command_name",
81+
"displayName", "display_name",
82+
"displayTitle", "display_title",
83+
"jobName", "job_name",
84+
"runName", "run_name",
85+
"workflowName", "workflow_name",
7986
"prompt", "input", "command", "title",
8087
}
8188

internal/session/sidechain_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,7 @@ func TestLoadSidechainStateAcceptsRuntimeLifecycleFieldAliases(t *testing.T) {
721721
"jobID": "job_77",
722722
"workerType": "investigator",
723723
"workspaceRoot": "/tmp/runtime-worktree",
724-
"instructions": "inspect runtime aliases",
724+
"operationName": "inspect runtime aliases",
725725
"startedAtMs": 1700000000000,
726726
"jobStatus": "queued",
727727
},
@@ -797,7 +797,7 @@ func TestLoadSidechainStateAcceptsExtendedMetadataAliases(t *testing.T) {
797797
t.Fatal(err)
798798
}
799799
metadataPath := SidechainMetadataPath(sessionPath, sessionID, "subagent_7")
800-
if err := os.WriteFile(metadataPath, []byte(`{"subagentType":"planner","workspacePath":"/tmp/planner-worktree","taskDescription":"plan the migration"}`), 0o644); err != nil {
800+
if err := os.WriteFile(metadataPath, []byte(`{"agentName":"planner","workspaceRoot":"/tmp/planner-worktree","commandName":"plan the migration"}`), 0o644); err != nil {
801801
t.Fatal(err)
802802
}
803803

0 commit comments

Comments
 (0)