Skip to content

Harden compaction: durable anchor, atomic commit, continuation ledger - #1

Merged
russellhaering merged 2 commits into
mainfrom
russell_h/compaction-anchor-hardening
Aug 18, 2026
Merged

Harden compaction: durable anchor, atomic commit, continuation ledger#1
russellhaering merged 2 commits into
mainfrom
russell_h/compaction-anchor-hardening

Conversation

@russellhaering

@russellhaering russellhaering commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Hardens Orrery's context compaction so the active objective and report obligation stay concrete, durable, and verifiable after compaction, and makes the module build with the local toolchain.

Changes

Anchor hardening (internal/core/compaction.go)

  • selectDurableAnchor is the single source of truth for the active objective/report, shared by the semantic-summary prompt and the deterministic continuation anchor. All-complete wrap-up names the last completed todo.
  • validateCompactionAnchor fails compaction before any destructive write if the objective/report is empty, the selected todo is lost, or a resolved request is reopened as active work.
  • context.compacted carries non-sensitive anchor provenance (anchor_source, anchor_todo_*, anchor_hash, resolved-request source counts).

Atomic commit (internal/store/store.go)

  • ApplyCompaction commits the durable summary, message trim, and cache invalidation in one transaction — compaction can never leave a half-compacted state.

Checkpoint semantics

  • Checkpoints now snapshot and restore pending_inputs and the continuation ledger (work_items + continuation), so restore reproduces retained completed work and completion chronology.

Continuation ledger

  • New work_items + continuation tables populated by SetTodos (typed, plan-aware reconciliation: idempotent resubmission, phase-aware matching, retained completed rows, live-duplicate promotion). The compaction anchor derives from the ledger.
  • Engine.finish calls AcknowledgeReport on a passing final response, clearing the report obligation so a follow-up turn does not re-assert already-reported work (completed history retained).

Build

  • go.mod lowered to go 1.26.5 so the module builds with the local toolchain (no dependency requires 1.26.6).

Verification

  • go test ./... passes (all packages), go vet clean, gofmt clean.
  • CI green.
  • Reviewer (read-only, gpt-5.6-sol) approved after multiple rounds; all findings fixed with regression tests covering: active-todo selection, all-complete named wrap-up, fallback anchoring, compacted-event metadata, atomic compaction, checkpoint pending-input + ledger restore, duplicate-objective reconciliation (idempotency, phase, order-independence, live promotion), and report-acknowledgement clearing.

Name the last completed todo in the all-complete wrap-up anchor so the
report obligation stays concrete instead of a generic wrap-up, and add
a post-anchor invariant plus non-sensitive anchor provenance to the
compacted event.

- selectDurableAnchor is the single source of truth for the active
  objective/report, shared by the semantic prompt anchor and the
  deterministic continuation anchor.
- validateCompactionAnchor fails compaction (before any destructive
  write) if the current objective or pending report is empty, the
  selected todo is lost, or a resolved request is reopened.
- context.compacted now carries anchor_source, anchor_todo_*,
  anchor_hash, and resolved-request source counts.

Co-authored-by: c1-squire-dev[bot] <c1-squire-dev[bot]@users.noreply.github.com>
@russellhaering
russellhaering force-pushed the russell_h/compaction-anchor-hardening branch 12 times, most recently from 4464a8f to 1b37459 Compare August 18, 2026 18:18
- go.mod: lower to go 1.26.5 so the module builds with the local toolchain
  (no dependency requires 1.26.6).
- ApplyCompaction: commit durable summary, message trim, and cache
  invalidation in one transaction so compaction can never leave a
  half-compacted state.
- Checkpoints now snapshot and restore pending_inputs, so restoring a
  checkpoint no longer silently drops an unanswered user ask.
- Continuation ledger: work_items + continuation tables populated by
  SetTodos, with the compaction anchor derived from the ledger (active
  work item, report obligation) instead of todo prose. Completed work
  items are retained so the report obligation survives a cleared plan.
  Forks copy the ledger.

Co-authored-by: c1-squire-dev[bot] <c1-squire-dev[bot]@users.noreply.github.com>
@russellhaering
russellhaering force-pushed the russell_h/compaction-anchor-hardening branch from 1b37459 to bdf0b7a Compare August 18, 2026 18:25
@russellhaering russellhaering changed the title Harden compaction continuation anchor Harden compaction: durable anchor, atomic commit, continuation ledger Aug 18, 2026
@russellhaering
russellhaering merged commit 9f2a000 into main Aug 18, 2026
2 checks passed
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