fix(agent): unify atomic hydration and material progress - #2779
Conversation
…aterial-progress-current-main
…aterial-progress-current-main
…ydration-atomic-current-main
…aterial-progress-current-main
…ydration-atomic-current-main
…ic-hydration-material-progress
|
Exact-head independent rereview: READY. Accepted commit: The full base-to-head conflict audit retained both original invariant sets from #2763 and #2765: atomic hydration and durable tail replacement, reserved-occurrence matching, admission-terminal child retention including timestamp-less stale history, provider-neutral material-progress persistence/projection/rewind, explicit refresh ordering, and exactly-once terminal carry-forward. Independent gates: overlap suite 209/209, protocol/CLI/E2E 5/5, server typecheck, zero-finding lint, format, and diff check. Worktree remained clean; no live mutation. |
|
| Filename | Overview |
|---|---|
| packages/server/src/server/agent/agent-manager.ts | Integrates atomic hydration, event admission, epoch-bound checkpoints, and asynchronous persistence; closure can outpace the final durable append. |
| packages/server/src/server/agent/file-agent-timeline-store.ts | Adds atomic per-agent timeline persistence with serialized mutations and durable epochs. |
| packages/server/src/server/agent/material-progress.ts | Implements incremental classification, deduplication, compaction counting, continuation settlement, and payload projection. |
| packages/protocol/src/messages.ts | Adds an optional, validated material-progress snapshot and server feature advertisement. |
| packages/server/src/server/agent/agent-projections.ts | Projects the manager's checkpoint into agent snapshot payloads. |
| packages/server/src/server/agent/agent-storage.ts | Persists the optional material-progress checkpoint with existing agent records. |
Sequence Diagram
sequenceDiagram
participant Provider
participant Manager as AgentManager
participant Memory as In-memory timeline
participant Disk as File timeline store
participant Progress as Material progress
Provider->>Manager: Timeline event
Manager->>Memory: Append canonical row
Manager->>Progress: Advance checkpoint
Manager-->>Disk: Queue durable append
Note over Manager,Disk: Close currently does not await this write
Manager->>Manager: Close agent
Manager-->>Provider: Closure complete
Reviews (1): Last reviewed commit: "fix(agent): unify atomic hydration and m..." | Re-trigger Greptile
| this.timelineStore.getEpoch(agentId), | ||
| ); | ||
| } | ||
| this.enqueueDurableTimelineAppend(agentId, row); |
There was a problem hiding this comment.
Closure leaves timeline writes pending
When a timeline row is recorded immediately before agent closure and the daemon exits, recordTimeline queues the durable append without awaiting it while closeAgentRuntime returns without draining that task, causing the next startup to restore an incomplete timeline and material-progress checkpoint.
Summary
mainThis draft is intended to supersede #2763 and #2765 only after independent acceptance of this replacement. The original PRs remain open.
Verification
npm run build:protocolnpm run build:servernpm run typechecknpm run lintnpm run formatandnpm run format:checkgit diff --check 048b82f2a7b3ecc9b62bc5b817729f4ca2741863..HEAD