Skip to content

docs(llm): record P0.2 event-sourcing audit — net-new infra, explicit defer - #143

Merged
dahai80 merged 1 commit into
mainfrom
doc/defer-item7-p02-event-sourcing
Aug 26, 2026
Merged

dahai80 merged 1 commit into
mainfrom
doc/defer-item7-p02-event-sourcing

Conversation

@dahai80

@dahai80 dahai80 commented Aug 26, 2026

Copy link
Copy Markdown
Owner

What

Record audit + explicit deferral decision for P0.2 (enhance-0819.md:472 — 事件溯源会话日志 + surfaceOp).

Audit findings

P0.2 is net-new infrastructure: zero matches for SessionEvent/surfaceOp/deriveMessages/SessionEventMap/sourceEventSeqs/SESSION_FORMAT_VERSION in src/.

Existing informal event log (disk side)

mutableMessages mutation surface (spec's "大改")

Decision

The in-memory typed layer replacing mutableMessages = spec's own flagged "大改消息管理" large refactor. Spec's step ordering (先写事件旁路 → deriveMessages 替换 → 压缩迁移) confirms step 1 produces a foundation with no consumer; deriveMessages must exactly mirror 16 distinct site behaviors to pass the invariant = re-implementing message management = the refactor itself.

The 3 spec motivations are partially served by the existing disk log:

  1. audit full model-visible event stream → disk JSONL captures full stream
  2. compaction loses provenance → PR feat(item6): transcript 磁盘裁剪 79x + 崩溃安全 checkpoint (CC 2.1.208) #114 retains pre-compact segments on disk
  3. trajectory flywheel 临时重构 → collector reads JSONL ad-hoc but works (D1 verified)

No concrete failure driving. Explicit defer decision + gap map + spec's incremental path, not backlog. Mirrors the resolution pattern of Items 5 (PR #141) and 6 (PR #142).

Verification

  • Doc-only, 0 code change
  • Clean tree off main 47a1e25

Co-Authored-By: Claude Fable 5 [email protected]

… defer

P0.2 (SessionEvent/surfaceOp/deriveMessages/SessionEventMap/SESSION_FORMAT_VERSION)
is net-new: zero matches in src/. The 3 spec motivations are partially served
by the existing append-only JSONL transcript (recordTranscript → insertMessageChain
→ enqueueWrite with parentUuid chaining + compact_boundary markers, PR #114
pre-compact segments retained on disk) that the trajectory collector already
reads ad-hoc (RawEvent {type, message, cwd}, D1 flywheel verified).

The in-memory typed layer replacing mutableMessages is spec's own flagged
'大改消息管理' large refactor: 16 direct mutation sites (12 QueryEngine, 2
queryHelpers, 2 print.ts) + 3 assignments. Spec's step ordering (先写事件旁路
→ deriveMessages 替换 → 压缩迁移) confirms step 1 produces a foundation with no
consumer; deriveMessages must exactly mirror 16 distinct site behaviors to pass
the invariant = re-implementing message management = the refactor itself.

No concrete failure driving; mirrors Items 5/6 resolution pattern.
Recorded as explicit defer decision + gap map + spec's incremental path,
not backlog.

Co-Authored-By: Claude Fable 5 <[email protected]>
@dahai80
dahai80 merged commit bfae466 into main Aug 26, 2026
1 check passed
@dahai80
dahai80 deleted the doc/defer-item7-p02-event-sourcing branch August 26, 2026 07:15
dahai80 added a commit that referenced this pull request Aug 26, 2026
…#144)

Audit P1.2 (enhance-0819.md:528) across 3 steps, defer as explicit decision:

Step 3 (KV-cache prefix boundary negotiation): fusion-mlx /v1/messages
ALREADY honors cache_control (anthropic_routes.py:198
_extract_prefix_cache_boundary; issues #196/#241/#289/#386 all CLOSED).
memory_cache.py:721 = auto prefix match (exact+prefix+supersequence+LCP)
-> KV reuse happens without explicit breakpoint. fusion-code MLX path
createFusionMlxFetch translates /v1/messages -> /v1/chat/completions,
dropping cache_control. Fixing = route MLX direct to /v1/messages =
large adapter refactor (1500+ lines, deliberately OpenAI-compatible),
no concrete failure (auto-match covers). Defer.

Step 1+2 (shadow-price pruning): net-new (shadowPrice/tool-result-pruner
0 matches). hardCompact.ts:42 truncateString = fixed head/tail, not
cost-model. Reference-frequency signal partially exists but binary not
frequency: sessionMemoryCompact.ts:153 getToolResultIds/
adjustIndexToPreserveAPIInvariants = orphan correctness guard, not
count. New cost model + live compaction path change, no failure driving.
Defer.

Step 4 (surfaceOp:replace): blocked by P0.2 defer (PR #143).

Cross-repo boundary: fusion-mlx KV API fully delivered, no upstream
issue needed.

Co-authored-by: Claude Fable 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant