Skip to content

feat: native compaction, auto candidate generation, lesson auto-promotion + Hermes integration - #57

Merged
NovasPlace merged 13 commits into
masterfrom
feat/csm-native-claude
Jul 31, 2026
Merged

feat: native compaction, auto candidate generation, lesson auto-promotion + Hermes integration#57
NovasPlace merged 13 commits into
masterfrom
feat/csm-native-claude

Conversation

@NovasPlace

@NovasPlace NovasPlace commented Jul 23, 2026

Copy link
Copy Markdown
Owner

Summary

Four pipeline fixes that unblock the CSM compounding loop for all agents (Hermes, Codex, Claude Code).

1. Native Runtime Compaction

  • Extracted shared compaction pipeline into messages-transform-pipeline.ts
  • Added native-compaction.ts entry point (runtimeKind: native_hook)
  • Per-session tool-call buffering, flushed+compacted at Stop event

2. Auto-Scheduled Memory Candidate Generation

  • New MemoryMaintenanceConfig + 4th LifecycleOrchestrator job
  • Runs every 5 min (configurable via CSM_MEMORY_MAINTENANCE_* env vars)

3. Lesson Auto-Promotion (strict gates)

  • New lesson-auto-promotion.ts: promotes candidates into lesson memories
  • Gates: 10+ recalls, 2+ sessions, content quality filter, dedup
  • Noise filter rejects file-change/loop-detection/tool-usage patterns

4. Hermes Agent Host Integration

  • hermes-hook-mapping.ts, hermes-hook-client.ts, hermes-mcp-server.ts
  • HERMES_HOST_PROFILE added to the HostProfile seam

Also Fixed

  • Recall-quality SQL bug (0AND concatenation)
  • brace-expansion DoS vulnerability
  • Removed tracked .tmp/ artifacts, gitignored .hermes/

Verification

  • Typecheck: 0 errors | Lint: 7 warnings (baseline) | Build: clean
  • Tests: 55/55 relevant tests pass

NovasPlace and others added 8 commits July 22, 2026 20:34
Captures transport pipe name, hook wire-format mappings for all 10
lifecycle events, and the native tool catalog surface. This is the
behavioral invariant the HostProfile seam must preserve.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Introduce src/native-host-profile.ts and thread an optional HostProfile
(default CODEX_HOST_PROFILE) through the hook relay, native runtime, and
lifecycle hooks. All host-specific strings (pipe prefix, default session
id, agent/message ids, host label, restart message) now flow through the
profile with no `if (host)` branches in the internals.

Codex behavior is unchanged: the default profile carries the exact prior
strings; golden + parity suites stay green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Extract runNativeMcpServer(profile) and runNativeHookClient(profile) as
the single implementation of the stdio MCP server and lifecycle hook
client. Codex and Claude entrypoints are thin wrappers passing their
HostProfile. Add claude-hook-relay convenience wrappers.

Codex stdio behavior is byte-identical (stdio + golden suites green); the
Claude server boots with a distinct named pipe and Claude-labeled
initialize instructions.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
plugins/cross-session-memory/ ships the Claude-native runtime bundle:
.claude-plugin/plugin.json manifest, .mcp.json (full CSM tool surface via
launch-mcp -> claude-mcp-server), hooks.json wiring all 10 lifecycle
events to run-hook -> claude-hook-client, and dev/packaged resolution in
both launch scripts.

Verified end-to-end: SessionStart through the bundle reaches the live
Claude-profile relay and injects real CSM continuity as Claude-format
additionalContext, on a pipe distinct from the Codex bundle.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
surface-catalog.json is the single source of truth for the Claude plugin
surface; every command/agent/skill orchestrates the authoritative MCP
catalog (MCP stays the sole tool authority). scripts/validate-claude-surface.mjs
enforces agreement between the catalog, on-disk bundle files, and the live
MCP tool set (missing/undocumented/duplicate/tool-drift/unavailable-tool/
missing-bundle-file detection).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add staging build (build-claude-plugin.mjs), Windows release builder, and
a clean-room verifier that extracts the ZIP and boots ONLY the packaged
bundle — no repo sources, no host binary — asserting 82 served tools, a
live SQLite connection, and a native write/read round-trip. Register the
cross-session-memory plugin in the local marketplace and add plugin:*:claude
npm scripts. Claude Code installs natively via /plugin, so no install.ps1
is shipped.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add plugin parity, transport isolation, surface-catalog (positive +
negative drift detection via --plugin-root), and hook-client safety
(malformed/empty/oversized input, relay unreachable) suites. All green;
Codex parity suites unaffected.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add CLAUDE_INSTALLATION.md and CLAUDE_PLUGIN_PORTABLE_RELEASE.md; link
them from the README nav and quick-start, update the host row, and record
the milestone in AGENTS.md.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@NovasPlace NovasPlace changed the title Feat/csm native claude feat: make CSM a native Claude Code feature — full subsystem surface Jul 23, 2026
NovasPlace and others added 5 commits July 22, 2026 22:30
codex-hook-output.ts, codex-native-tool-catalog.ts, and
codex-transcript-client.ts were untracked; config.ts was modified but
unstaged. All four are imported by the committed native-mcp-server.ts,
codex-native-runtime.ts, and native-hook-client.ts — their absence
broke typecheck in CI.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… from branch

The branch's committed code (native-mcp-server, codex-native-runtime,
package.json files array, release-boundary test) references source modules,
skills, hooks, scripts, docs, and test updates from the Codex native plugin
and Phase 9C compaction work that existed locally but were never staged.

Adds: skills/, hooks/, scripts/run-hook.mjs, build/release/verify scripts,
release-assets/, Codex bridge plugin wiring, compaction attribution migration,
and all modified source/test/doc files that CI depends on.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
README.md links to docs/CLAUDE_INSTALLATION.md and
docs/CLAUDE_PLUGIN_PORTABLE_RELEASE.md but they were missing
from the package files list, failing the release-boundary test.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…on, and Hermes host integration

Four pipeline fixes that unblock the CSM compounding loop:

1. Native runtime compaction (Claude/Codex/Hermes):
   - Extract shared compaction pipeline into messages-transform-pipeline.ts
   - Add native-compaction.ts entry point (runtimeKind: 'native_hook')
   - Buffer tool calls per-session in CodexNativeRuntime, flush+compact at Stop
   - Wire postTool→buffer, Stop→drain+runNativeCompaction in codex-native-hooks

2. Auto-scheduled memory candidate generation:
   - Add MemoryMaintenanceConfig + 4th LifecycleOrchestrator job
   - CandidateGenerator.generate() now runs every 5 min (configurable via env)

3. Lesson auto-promotion with strict gates:
   - New lesson-auto-promotion.ts: promote_to_lesson candidates with
     ≥10 recalls + ≥2 sessions + content quality + dedup → lesson memories
   - Wired into memory-maintenance lifecycle job
   - Noise filter rejects file-change, loop-detection, and tool-usage patterns

4. Hermes Agent host integration:
   - hermes-hook-mapping.ts: event mapping, payload translation, response shaping
   - hermes-hook-client.ts: stdin/stdout I/O shell for Hermes shell hooks
   - hermes-mcp-server.ts: MCP server entry point for Hermes profile
   - HostProfile seam: HERMES_HOST_PROFILE for shared relay/runtime

Also fixes: recall-quality SQL bug (0AND concatenation), exports
CompactableMessage from context-compactor.ts for pipeline reuse.

Verification: typecheck 0 errors, lint 7 warnings (baseline), 55/55
relevant tests pass (1 pre-existing failure in compaction-safety unchanged).
…xpansion vuln

- Remove 6 stale .tmp/ report files accidentally committed
- Add .hermes/ to .gitignore (Hermes session artifacts)
- npm audit fix: brace-expansion DoS (high → 0 vulnerabilities)
- Delete 5 stale local branches (backups, snapshots, merged work)
@NovasPlace NovasPlace changed the title feat: make CSM a native Claude Code feature — full subsystem surface feat: native compaction, auto candidate generation, lesson auto-promotion + Hermes integration Jul 31, 2026
@NovasPlace
NovasPlace merged commit f9d0e16 into master Jul 31, 2026
8 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