Skip to content

Commit dd34966

Browse files
author
SqlRush
committed
Accept resource microcompact cache payloads
1 parent 493bfd6 commit dd34966

5 files changed

Lines changed: 26 additions & 3 deletions

File tree

docs/cc-100-roadmap.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ M6 补充:microcompact disk cache loader 和 prune 现在接受 digest 缺失
4040

4141
M6 补充:microcompact disk cache loader 的 `cached`/`fromCache`/`cacheHit`/`isCached` 布尔字段现在接受 JSON bool、`true`/`false``yes`/`no``on`/`off``1`/`0` 数字/字符串形态。
4242

43+
M6 补充:microcompact disk cache loader 现在接受 JSON:API/resource-style `resource`/`attributes`/`properties` wrapper,summary payload 可放在 attributes/properties 内,外层 resource `id` 可作为 digest fallback。
44+
4345
M6 补充:sidechain/subagent lifecycle state loader 现在接受 `subagent_started``agentStarted``task_failed``sidechainCompleted` 等相邻 subtype aliases,支持 `taskID`/`workerId`/`runId``agentName`/`kind``resultText`/`finalMessage` 等字段,并在 failed/cancelled subtype 没有显式 status 时自动归一状态。
4446

4547
M6 补充:sidechain/subagent lifecycle content 读取现在接受 JSON:API/resource-style `resource`/`attributes`/`properties` wrapper,外层 resource `id` 可作为 sidechain ID fallback,内层 agent metadata、status/outcome 和 summary 字段仍能恢复到 state/list/resume。

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ test/parity/ # golden tests against TS/official behavior
251251
- 本轮补充:microcompact disk cache loader 和 prune 现在接受 digest 缺失但文件名已 keyed 的 cache entry,会用 `<digest>.json` 文件名作为 digest fallback,同时仍保留显式 digest mismatch 的 invalid-cache guard。
252252
- 本轮补充:microcompact disk cache loader 的 `cached`/`fromCache`/`cacheHit`/`isCached` 布尔字段现在接受 JSON bool、`true`/`false``yes`/`no``on`/`off``1`/`0` 数字/字符串形态。
253253
- 本轮补充:microcompact disk cache loader 现在会从 `metadata`/`meta`/`cacheInfo`/`cacheDetails`/`cacheEntry`/`entry`/`record`/`cache` 等 sidecar object 中补缺失的 digest、version、cache-hit、timestamp、TTL 和 count aliases;主 summary payload 字段仍保持优先。
254+
- 本轮补充:microcompact disk cache loader 现在也接受 JSON:API/resource-style `resource`/`attributes`/`properties` wrapper,summary payload 可放在 attributes/properties 内,外层 resource `id` 可作为 digest fallback。
254255

255256
### M7: TUI renderer 和交互体验
256257

docs/first-second-parity-audit.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ M6 progress now includes:
129129
- `internal/compact`: microcompact disk cache loading now fills missing cache metadata from sidecar objects such as `metadata`, `meta`, `cacheInfo`, `cacheDetails`, `cacheEntry`, `entry`, `record`, and `cache`, preserving primary result fields while recovering digest/version/cache-hit/timestamp/TTL/count aliases stored outside the summary payload.
130130
- `internal/compact`: microcompact disk cache loading and pruning now use the `<digest>.json` filename as a digest fallback when a cache entry omits an internal digest, while preserving explicit digest mismatch pruning/errors.
131131
- `internal/compact`: microcompact disk cache loading now accepts non-strict cache-hit booleans for `cached`/`fromCache`/`cacheHit`/`isCached`, including `yes`/`no`, `on`/`off`, and `1`/`0` JSON number or string values.
132+
- `internal/compact`: microcompact disk cache loading now accepts JSON:API/resource-style `resource`/`attributes`/`properties` wrappers, with summary payloads inside attributes/properties and outer resource IDs used as digest fallback when needed.
132133
- `internal/conversation`: optional auto-compact can now run before the main request, fail open with a consecutive-failure circuit breaker, emit runtime `token_warning` events from compact warning state, persist compact boundary metadata to transcript, write a session-memory summary, inject recalled session-memory snippets into API request context when enabled, and optionally extract turn-end memory facts into session memory.
133134
- `internal/memory`: session-memory summaries can now be loaded with frontmatter field aliases, rolled up/pruned into an archive summary with prior rollup archives excluded from candidate compaction and merged across archive IDs, rune-safe rollup truncation, recalled by query with deterministic scoring and recency ordering, ranked through a model-assisted candidate/session-id selection path with fallback when selected IDs are invalid or excluded, alternate/camel response-key parsing, fenced/prose JSON extraction, scalar session-id parsing, nested/wrapped/collection-alias selection parsing, and nested selected-memory item parsing, and injected into resume context through the same optional recall agent path; deterministic and model-backed memory fact extraction can summarize user preferences, requests, decisions, and tool-use facts, including fenced/prose JSON, wrapped facts responses, alternate and structured fact field names, nested source objects, nested fact response shapes, and fact kind aliases.
134135
- `internal/session`: project session listing and pagination, prompt-history lock/buffered flush/field aliases, lightweight transcript index/title/text-preview inference, line-offset transcript indexing/window/byte-budget-window/parent-chain/resume/tail/byte-budget-tail loading, AI-title/last-prompt/task/agent/PR/worktree transcript metadata loading and type/field aliases, transcript message/session UUID field aliases, tombstone metadata loading with target/session/reason aliases and delete/relink replay, agent-scoped content replacement metadata/record field-alias loading, session-scoped metadata reappend including AI-title/last-prompt/task-summary, streaming transcript search snippets for resume/search UI, official `subagents/agent-*.jsonl` transcript layout with legacy sidechain listing, agent metadata sidecar read/write/field aliases, sidechain runtime start/append/finish/cancel/fail summary bridging plus parent-chain append/finish, sidechain manager orchestration for spawn/append/finish/cancel/fail/list/resume, sidechain state/list/resume support with content-field aliases, sidechain resume context construction, sidechain conversation and agent-scoped content-replacement reconstruction, transcript tail/window loading and byte-budget tail loading for bounded-memory resume/UI paths, lightweight transcript metadata loading, remote-history token refresh retry, page-field/event-list/records/entries/last-id/cursor/event-id/has-next aliases plus wrapped-data/links/paging/bare-array/keyed-event-map responses, before_id resume, fallback field fill, and duplicate-aware parent linking during transcript materialization.

internal/compact/compact_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,18 @@ func TestLoadMicroResultAcceptsWrappedCacheObjects(t *testing.T) {
412412
body: `"value":{"text":"value summary","key":"wrapped-value","schemaVersion":"microcompact.v1","createdAt":100}`,
413413
want: "value summary",
414414
},
415+
{
416+
digest: "resource-attributes",
417+
body: `"id":"resource-attributes","type":"microcompact-cache","attributes":{"summaryMarkdown":"attributes summary","version":"microcompact.v1","createdAt":100,"ttlSeconds":3600}`,
418+
want: "attributes summary",
419+
wantExpires: true,
420+
},
421+
{
422+
digest: "resource-properties",
423+
body: `"resource":{"id":"resource-properties","type":"microcompact-cache","properties":{"compressedText":"properties summary","cacheVersion":"microcompact.v1","cachedAt":100,"ttlMs":"3600000"}}`,
424+
want: "properties summary",
425+
wantExpires: true,
426+
},
415427
{
416428
digest: "wrapped-envelope",
417429
body: `"data":{"summary":"envelope summary"},"digest":"wrapped-envelope","version":"microcompact.v1","createdAt":100,"ttlSeconds":3600`,

internal/compact/micro.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ func (r *MicroResult) UnmarshalJSON(data []byte) error {
5555
if err := microResultApplyFieldAliases(&result, fields, false, false); err != nil {
5656
return err
5757
}
58+
if result.Digest == "" {
59+
if value, ok, err := microStringJSONField(fields, "id", "cacheId", "cacheID", "cache_id", "resourceId", "resourceID", "resource_id"); err != nil {
60+
return err
61+
} else if ok {
62+
result.Digest = value
63+
}
64+
}
5865
if err := microResultApplyNestedFieldAliases(&result, fields); err != nil {
5966
return err
6067
}
@@ -153,7 +160,7 @@ func microResultApplyNestedFieldAliases(result *MicroResult, fields map[string]j
153160
"cacheMetadata", "cache_metadata", "cacheMeta", "cache_meta",
154161
"microMetadata", "micro_metadata", "microcompactMetadata", "microCompactMetadata", "microcompact_metadata",
155162
"microResultMetadata", "micro_result_metadata",
156-
"attributes", "attrs", "info",
163+
"attributes", "properties", "attrs", "info",
157164
"cacheInfo", "cache_info", "cacheDetails", "cache_details",
158165
"cacheEntry", "cache_entry", "entry", "record", "cache",
159166
} {
@@ -181,9 +188,9 @@ func microResultWrappedJSON(fields map[string]json.RawMessage) (json.RawMessage,
181188
return nil, false
182189
}
183190
for _, name := range []string{
184-
"result", "data", "cache", "cacheEntry", "cache_entry", "entry", "record", "item", "payload", "response", "body",
191+
"result", "data", "cache", "cacheEntry", "cache_entry", "entry", "record", "item", "resource", "payload", "response", "body",
185192
"microcompact", "microCompact", "micro_compact", "micro_result", "microResult", "microcompactResult", "microCompactResult", "micro_compact_result",
186-
"value",
193+
"attributes", "properties", "value",
187194
} {
188195
raw, ok := fields[name]
189196
if !ok {

0 commit comments

Comments
 (0)