$ show Martian-Engineering/lossless-claw
Lossless Claw is a production-grade OpenClaw plugin for lossless context management in LLM conversations. It persists every message in SQLite, compresses older context into a DAG of hierarchical summaries (leaf and condensed), and assembles the active prompt by combining recent messages with summaries. The system provides recall tools (grep, describe, expand) for agents to retrieve details from compacted history, a doctor tool for repairing summary quality, a CLI for diagnostics, and a Go-based TUI for interactive inspection and maintenance. It integrates deeply with OpenClaw's plugin API, using the host's LLM dispatch for summarization and supporting multi-provider fallback, OAuth, and retry chains. The architecture is event-driven with deferred compaction, pending summary pipelines, and atomic publication. While the core is TypeScript, the TUI is written in Go, creating a bimodal maintenance burden. The codebase demonstrates strong engineering practices with extensive test coverage, but its tight coupling to OpenClaw's evolving API and large configuration surface introduce moderate technical drift risk.
The LLM identified 5 files worth highlighting for reuse:
Provides `withDatabaseTransaction` and `withExclusiveDatabaseLock` helpers for serializing concurrent SQLite operations. This pattern prevents nested transaction errors and is reusable in any SQLite-backed application requiring safe async access.
A token estimation utility with CJK-aware Unicode weighting, binary payload detection (substituted with fixed cost), and serialized message counting. It handles base64 substitution and circular references. Reusable in any LLM application needing budget-aware context assembly.
Implements replay detection and deduplication for incoming messages by matching content hashes, externalized references, host redaction, and structured parts identity. Reusable in any system requiring idempotent ingestion of LLM conversation messages.
Manages grant-based authorization for delegated summary expansion, with token budget tracking, grant lifecycle (create, validate, revoke, cleanup), and recursion guards. Reusable pattern for sub-agent delegation in multi-turn LLM systems.
A depth-aware summarization prompt template for leaf summaries, with explicit instructions to preserve decisions, drop operational detail, and target token lengths. Part of a set of four templates (leaf, condensed-d1 through d3) that define the hierarchical condensation strategy. Reusable for any hierarchical summarization system.