-
Notifications
You must be signed in to change notification settings - Fork 413
docs: improve Claw Compactor integration + security notes #80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
aeromomo
wants to merge
1
commit into
BlockRunAI:main
Choose a base branch
from
aeromomo:docs/compactor-integration-and-security-notes
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| # ClawRouter × Claw Compactor Integration Guide | ||
|
|
||
| This guide explains how to combine: | ||
|
|
||
| - **ClawRouter** (model routing + payment) | ||
| - **Claw Compactor** (context compression) | ||
|
|
||
| Together, they reduce cost from two directions: | ||
|
|
||
| 1. **Fewer tokens sent** (Compactor) | ||
| 2. **Lower $/token paid** (Router) | ||
|
|
||
| --- | ||
|
|
||
| ## Why combine them? | ||
|
|
||
| ClawRouter alone optimizes model choice. | ||
| Claw Compactor alone optimizes context size. | ||
|
|
||
| Using both usually gives better savings than either one alone. | ||
|
|
||
| --- | ||
|
|
||
| ## Recommended order in request pipeline | ||
|
|
||
| ```text | ||
| OpenClaw request | ||
| -> Claw Compactor (compress context) | ||
| -> ClawRouter (route to lowest-cost capable model) | ||
| -> Provider | ||
| ``` | ||
|
|
||
| Compaction should happen **before routing**, so router sees the real token footprint. | ||
|
|
||
| --- | ||
|
|
||
| ## Practical setup | ||
|
|
||
| 1. Install and enable ClawRouter plugin | ||
| 2. Install Claw Compactor in your workspace | ||
| 3. Enable Compactor auto mode (or hook mode) | ||
| 4. Keep ClawRouter on `auto` profile | ||
|
|
||
| --- | ||
|
|
||
| ## Validation checklist | ||
|
|
||
| Use the same workload and compare: | ||
|
|
||
| - Baseline: no compaction + fixed expensive model | ||
| - Router only | ||
| - Compactor only | ||
| - Router + Compactor | ||
|
|
||
| Track: | ||
|
|
||
| - input/output tokens | ||
| - effective $/request | ||
| - p95 latency | ||
| - task quality / regression rate | ||
|
|
||
| --- | ||
|
|
||
| ## Safety notes | ||
|
|
||
| - Keep compression deterministic and reversible where possible | ||
| - Do not compress secrets into logs or headers | ||
| - Audit tool-output compression for semantic loss before production rollout | ||
|
|
||
| --- | ||
|
|
||
| ## What ClawRouter already includes | ||
|
|
||
| ClawRouter contains built-in context compression layers inspired by Claw Compactor (dictionary, observation compression, dynamic codebook). | ||
|
|
||
| Use external Claw Compactor when you need: | ||
|
|
||
| - workspace-level file compression workflows | ||
| - custom memory/markdown compression policies | ||
| - explicit per-run savings reporting in chat | ||
|
|
||
| --- | ||
|
|
||
| ## Attribution | ||
|
|
||
| Parts of ClawRouter compression architecture are inspired by Claw Compactor design patterns. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| # Security: Secrets, Wallet Material, and Local State | ||
|
|
||
| This document defines secure defaults for ClawRouter operators and contributors. | ||
|
|
||
| ## 1) Never persist seed material in plaintext | ||
|
|
||
| High-risk secrets must not be written to disk unencrypted: | ||
|
|
||
| - wallet mnemonic / seed phrase | ||
| - private keys | ||
| - exported wallet seeds | ||
| - long-lived API tokens | ||
|
|
||
| If persistence is required, use OS-backed secure storage (Keychain / Secret Service / KMS). | ||
|
|
||
| --- | ||
|
|
||
| ## 2) Token handling | ||
|
|
||
| - Read tokens from env at runtime | ||
| - Avoid printing tokens in logs | ||
| - Redact sensitive values in diagnostics and errors | ||
| - Prefer short-lived credentials when possible | ||
|
|
||
| --- | ||
|
|
||
| ## 3) File permissions are defense-in-depth, not primary protection | ||
|
|
||
| `chmod 600` is useful but **not sufficient** for critical key material. | ||
|
|
||
| Treat local files as potentially recoverable through: | ||
|
|
||
| - backups | ||
| - endpoint compromise | ||
| - misconfigured sync | ||
|
|
||
| --- | ||
|
|
||
| ## 4) Contributor checklist for security-sensitive PRs | ||
|
|
||
| Before merge: | ||
|
|
||
| - [ ] Secret-bearing files are avoided or encrypted | ||
| - [ ] Logs do not leak secrets | ||
| - [ ] New env vars are documented with risk level | ||
| - [ ] Fallback paths do not silently downgrade security | ||
| - [ ] Migration/cleanup steps exist for legacy insecure state | ||
|
|
||
| --- | ||
|
|
||
| ## 5) Incident response | ||
|
|
||
| If potential secret leakage is discovered: | ||
|
|
||
| 1. Rotate impacted credentials immediately | ||
| 2. Revoke/replace wallet material if applicable | ||
| 3. Add temporary guardrails to block re-introduction | ||
| 4. Publish a patch + security note | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: BlockRunAI/ClawRouter
Length of output: 50378
🏁 Script executed:
Repository: BlockRunAI/ClawRouter
Length of output: 1162
🏁 Script executed:
Repository: BlockRunAI/ClawRouter
Length of output: 389
Policy contradicts actual wallet storage — plaintext files violate stated security requirement.
Lines 5-15 require high-risk secrets "must not be written to disk unencrypted" and recommend OS-backed secure storage (Keychain / Secret Service / KMS). However, README line 190 documents that wallet material is saved plaintext to
~/.openclaw/blockrun/wallet.key, and README line 211 advertises/wallet exportto retrieve it. The implementation insrc/auth.tsconfirms this:writeFile(WALLET_FILE, derived.evmPrivateKey, { mode: 0o600 })writes the EVM private key unencrypted, as does the mnemonic file—relying only on Unix file permissions (0o600), not encryption.Either update the policy to document that plaintext storage with file-level permissions is an accepted exception, or implement actual encryption (Keychain on macOS, Secret Service on Linux, DPAPI on Windows) before this document is published.
🤖 Prompt for AI Agents