deepseek-harness/docs
Hypatia May d6da8ca29a fix(compact): decide step-alignment from surface tool-pairing, fire compaction pre-step (CBR-001)
Codex round 1 CBR-001: a head-anchored compaction checkpoint was
mis-classified by the log-position step-alignment scan, so a second
auto-compaction over a checkpoint-headed surface silently failed.

Root cause: `isStepAlignedStart/End` scanned the LOG by seq, but a
`replace` op lands a checkpoint at a high log seq whose SURFACE position
is the head — its log neighbours (the open step's assistant/message) are
not its surface neighbours, so the forward scan wrongly reported mid-step.

Fix, per the agreed direction:
- Replace the two log-position predicates with one surface-anchored
  helper `isToolPairingBalanced(nodes, events, beforeSeq)` in
  `dsh-session` (renamed step-boundary.ts → tool-pairing.ts). A cut is
  balanced when no unanswered tool-call precedes it on the surface; a
  region is collapsible iff both edges are balanced cuts. The open-tail
  and free-node cases fall out of the same counter. It also throws on a
  corrupt surface (a tool/result with no matching call).
- Move compaction off the in-step seam to a new "pre-step" seam fired
  after turn/start and before step/start, so a compaction's log-only
  compact/* records and its replacement node land cleanly OUTSIDE any
  step (the honest structure crash-safety relies on). Renamed the event
  agent/pre-request → agent/pre-step and switched its dispatch from
  parallel → serial (listeners mutate the surface as a side effect;
  serial isolates them so concurrent appends can't interleave). Extended
  the catalog generator to accept @mode serial.

Regression coverage: a real-loop test driving an auto-compaction asserts
the landed checkpoint is a balanced cut on both sides; unit tests pin the
checkpoint case, the mid-step injection case, multi-call steps, and the
corrupt-surface guard. Proven red on the old log-position logic.
2026-06-26 13:51:01 +08:00
..
cookbook docs: sync package cookbook with build config 2026-06-22 11:36:35 +08:00
cordis-catalog fix(compact): decide step-alignment from surface tool-pairing, fire compaction pre-step (CBR-001) 2026-06-26 13:51:01 +08:00
core-data-structures refactor(compact): turn-agnostic retention + dedicated agent/pre-request seam 2026-06-26 08:59:33 +08:00
postmortem Fix doc cross-links for the hierarchy; add package-path + shape gates 2026-06-20 23:12:14 +08:00
rfc refactor(compact): turn-agnostic retention + dedicated agent/pre-request seam 2026-06-26 08:59:33 +08:00
AGENTS.md docs(rfc): classify RFCs by kind via path-encoded subdirectories 2026-06-20 22:29:45 +08:00
architecture.md refactor(compact): turn-agnostic retention + dedicated agent/pre-request seam 2026-06-26 08:59:33 +08:00
development.md docs: sync development CI gate docs 2026-06-22 12:54:11 +08:00
module-graph.md feat(compact-basic): baseline compaction backend (squashed from compact-basic) 2026-06-25 17:30:42 +08:00