Skip to content

feat: cap-aware auto-consolidation + docs sweep (B4 step 2) - #245

Merged
jkyberneees merged 3 commits into
mainfrom
feat/auto-consolidation
Sep 16, 2026
Merged

jkyberneees merged 3 commits into
mainfrom
feat/auto-consolidation

Conversation

@jkyberneees

Copy link
Copy Markdown
Contributor

Summary

  • Cap-triggered consolidation: crossing consolidate_at_cap_pct (*int, default 80, explicit 0 disables) of a fact file's cap fires ONE background LLM consolidation per crossing — long-lived serve/REPL sessions never hit the session-end trigger, so facts otherwise fossilize near the cap for the process lifetime.
  • Lock discipline: the LLM call never runs under the facts flock — snapshot flock-free, merge in a temp clone (PreviewConsolidation), ApplyConsolidation takes the flock only for the verified snapshot swap (conflicts, never overwrites concurrent writes).
  • Churn guard: per-manager in-flight flag + 10-minute cooldown, so threshold-hovering adds cannot churn LLM calls.
  • Docs sweep: SUBAGENTS (tail-keep headlines), PLANNING (stall escalation, bounded polling, side-call titles), MEMORY (pending-expiry knob, consolidation pass), CONFIG (both new knobs), SECURITY (test-binary fail-closed).

Review-found fixes (3-judge panel)

  • HIGH: consolidate_at_cap_pct was not wired through the config loader (JSON key silently ignored) — wired + introspect listing added
  • MAJOR: 10-min cooldown added (threshold-hovering LLM churn)
  • MEMORY.md contradictions with the feature removed
  • Security cleared: applied entries re-scanned; untrusted content cannot enter facts via this path; knob is operator-config-only

Test plan

  • RED-first: internal/memory/cap_consolidation_test.go (fires/disabled/in-flight/best-effort)
  • internal/memory + extended + config green under -race; full cmd/odek green under -race (×2)
  • 3 adversarial judges; all findings fixed or documented

Long-lived serve/REPL sessions never hit the session-end consolidation
trigger, so facts fossilize near the cap for the life of the process.
Crossing consolidate_at_cap_pct (*int, default 80, explicit 0 disables)
of a fact file's cap now fires ONE background consolidation per crossing
(per-target in-flight guard).

Lock discipline: the LLM call never runs under the facts flock — the
pass snapshots entries flock-free, merges in a temp clone
(PreviewConsolidation), and ApplyConsolidation takes the flock only for
the verified snapshot swap, conflicting instead of overwriting
concurrent writes. Best-effort: errors logged, never surfaced to
AddFact callers.

Pinned RED-first in internal/memory/cap_consolidation_test.go (fires on
crossing, disabled at 0, in-flight guard, best-effort). internal/memory
+ internal/memory/extended + full cmd/odek green under -race.
- consolidate_at_cap_pct wired through internal/config loader (the JSON
  key was silently ignored — HIGH, all judges) and added to introspect
- 10-minute cooldown between cap-triggered passes: adds hovering at the
  threshold can no longer churn LLM consolidation calls (cost-attack
  surface contained)
- guard scope corrected: one pass per manager, both targets share it
- size calculation reuses facts.sizeOf
- MEMORY.md contradictions with the feature removed; cap-triggered
  pass documented with its safety properties (re-scan, verified
  snapshot swap, no silent deletes)

internal/memory, internal/config, full cmd/odek green under -race.
@jkyberneees
jkyberneees merged commit 6886798 into main Sep 16, 2026
10 checks passed
@jkyberneees
jkyberneees deleted the feat/auto-consolidation branch September 16, 2026 19:56
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