deepseek-harness/scripts
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
..
check-vendor-manifest.sh Add lefthook git hooks with a vendor-manifest guard 2026-06-11 15:07:55 +08:00
check-workspace-constraints.ts fix: make constraints, lint and md-links happy 2026-06-22 01:38:44 +08:00
doc-typecheck.ts Merge remote-tracking branch 'origin/master' into feat/adr0016-type-build-check 2026-06-22 00:35:51 +08:00
gen-cordis-catalog.ts fix(compact): decide step-alignment from surface tool-pairing, fire compaction pre-step (CBR-001) 2026-06-26 13:51:01 +08:00
gen-module-graph.ts Reorganize packages into a modular hierarchy 2026-06-20 22:55:20 +08:00
install-lefthook.mjs fix(dev): make hooks and bash seams safer 2026-06-17 21:26:44 +08:00
publint-all.ts Reorganize packages into a modular hierarchy 2026-06-20 22:55:20 +08:00
type-equiv.manifest.json Merge branch 'session-surface' into compact-interface 2026-06-25 09:10:50 +08:00
verify-doc-refs.ts docs(rfc): classify RFCs by kind via path-encoded subdirectories 2026-06-20 22:29:45 +08:00
verify-md-links.ts Reorganize packages into a modular hierarchy 2026-06-20 22:55:20 +08:00
verify-md-wrap.ts Reorganize packages into a modular hierarchy 2026-06-20 22:55:20 +08:00
verify-node-next-types.ts docs: update rewriteRelativeImportExtensions to current rfc 2026-06-22 09:03:28 +08:00
verify-package-paths.ts fix review findings: don't treat disabled entries as load failures; scope the verify-package-paths lib skip to a real package root 2026-06-21 19:47:22 +08:00
verify-rfc-classification.ts docs(rfc): classify RFCs by kind via path-encoded subdirectories 2026-06-20 22:29:45 +08:00
verify-type-equiv.ts Reorganize packages into a modular hierarchy 2026-06-20 22:55:20 +08:00