Repository navigation
send_message tool, ~14 more condenser families, promptware defense, task-aware orient - #230
Conversation
…sk-aware orient Four features, one per gap called out against hermes / rtk / atlas: 1. send_message model tool (PasClaw.Tools.SendMessage). pasclaw post was CLI-only; the model can now push to channels mid-task. The model addresses channels strictly BY NAME -- the name->kind/target mapping lives in config.json's new "channels" array under operator control, so a prompt-injected model can't exfiltrate to an arbitrary webhook URL. Registers only when channels are configured (zero context cost otherwise). Same senders as pasclaw post: discord/slack/teams/webhook/line/whatsapp. tcMutating. 2. Shell-filter expansion (rtk had ~40 command families; we had ~6). New: docker ps/images (tabular), docker build (classic+BuildKit), docker/kubectl logs + describe (head/tail), kubectl get, gh pr/run/issue/release (tabular), cargo build/check/clippy (clippy warnings exit 0 -- kept verbatim while Checking-spam collapses), go test, eslint (stylish reporter aggregation), npm install/ci, pip install, mvn ([INFO] wall), gradle/gradlew, terraform plan/apply, aws (JSON output routes through PasClaw.Condense.JSON). Canonicalizer learns sudo/npx peeling, pip3->pip, npm i->install, gradlew->gradle; an option token in subcommand position degrades to the unmatched one-word key (pass-through beats mis-dispatch). Tee-on-failure + unknown-pass-through contracts unchanged. 3. Promptware defense (PasClaw.Promptware) -- injection-pattern scan at the three indirect-input chokepoints: tool output (ToolLoop, post-condense pre-cap), recalled memory (memory_search), stored skills (descriptions advertised in the system prompt). Annotate- don't-block: hits get a [promptware-warning] banner naming rule + source; flagged skill DESCRIPTIONS are suppressed outright since they'd speak with system authority. 18 substring rules in 5 families; two-substring rules for curl|sh droppers. On by default (linear scan over in-memory bytes), promptware_enabled: false opts out, propagated through LoadConfig so every entry point honours it. Counters surface in the TUI /stats overlay. 4. Task-aware orientation (PasClaw.Agent.Orient, atlas orient). Opt-in via orient_task_aware: when on AND the call site passes a task hint (one-shot -m, each interactive turn, each goal turn), BuildMemorySection slices MEMORY.md + daily notes into markdown- heading sections (paragraph fallback), scores them against the hint by stopword-stripped token overlap, and injects only matching sections -- document order preserved, 4KB/file budget, "(N sections elided -- memory_search reaches them)" note. No hint or flag off = whole-file injection, byte-identical to before. Lexical on purpose: runs synchronously in prompt assembly, no dependency on provisioned vector weights. New tests: promptware_tests (9 cases), orient_tests (7), 11 new shell-filter cases. Full make test green; new units registered in PasClaw.dproj. https://claude.ai/code/session_01TBcLtmpj7dqA5tyFbGnQon
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7007642e20
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| declares named channels ("channels": [{name,kind,target}]), so | ||
| there's no flag to thread through here. The model can only post | ||
| to operator-declared targets -- see PasClaw.Tools.SendMessage. } | ||
| RegisterSendMessageTool(Result); |
There was a problem hiding this comment.
Register send_message in every tool registry
Adding send_message only in the CLI agent's registry builder leaves the other chat surfaces without the new tool even when config.json declares channels. I checked the sibling registry builders in src/cmd/PasClaw.Cmd.TUI.pas (lines 103-123), src/cmd/PasClaw.Cmd.Serve.pas (lines 160-180), src/cmd/PasClaw.Cmd.Gateway.pas (lines 194-214), and TPasClawServer.Start in src/pkg/agent/PasClaw.Agent.pas (lines 889-906); they still build the built-ins/skills list but never call RegisterSendMessageTool, so users of pasclaw tui, pasclaw serve, pasclaw gateway, or the embedded server won't see the documented channel-notification tool.
Useful? React with 👍 / 👎.
| if (Pos('warning', T) = 1) or (Pos('error', T) = 1) then | ||
| begin | ||
| InWarn := WarnBlocks < MAX_WARN_BLOCKS; | ||
| if InWarn then | ||
| begin | ||
| Inc(WarnBlocks); | ||
| Out_.Add(L); |
There was a problem hiding this comment.
Report cargo diagnostics elided after the cap
When cargo clippy/cargo build exits 0 with more than 10 warning blocks, this branch stops adding diagnostics after MAX_WARN_BLOCKS but also stops counting them, so the returned filtered output gives no indication that additional warnings were omitted. Because clippy warnings commonly exit successfully and bypass tee-on-failure, the model/user can see only the first 10 warnings and mistakenly believe the remaining diagnostics do not exist.
Useful? React with 👍 / 👎.
…p cargo diagnostics Two P2s from Codex on PR #230, both legit: 1. NewBuiltinRegistry was the only registry builder calling RegisterSendMessageTool; pasclaw tui / serve / gateway and TPasClawServer.Start each build their own registry independently and weren't getting the tool even when config.json declared channels. Added the call to all four sibling builders (PasClaw.Cmd.TUI.pas, PasClaw.Cmd.Serve.pas, PasClaw.Cmd.Gateway.pas, PasClaw.Agent.pas's TPasClawServer.Start), each with the same self-gating contract -- no channels configured = no tool. 2. FilterCargoCompile capped warning bodies at MAX_WARN_BLOCKS but also stopped COUNTING after the cap, so warnings 11+ disappeared silently. Worse than verbose noise: clippy exits 0 with warnings, so they bypass tee-on-failure -- the model would see ten and believe there were no others. Fixed by counting every warning/ error header and emitting "(+ N more warning/error block(s) elided ...)" when WarnBlocks > cap. Regression test TestCargoOverCapReportsElidedCount pins it: 15 warnings -> "5 more ... elided" surfaces while the first 10 bodies stay verbatim. Full make test green; the new shell-filter case is added to the test program's run list. https://claude.ai/code/session_01TBcLtmpj7dqA5tyFbGnQon
Both changelog files were stuck at the 2026-06-10 TUI / background- subagent / session_search / tool-RPC entries. ~7 weeks of merged PRs (#214 through #244) had landed without a corresponding entry in either file -- the git log was the only record of features like the knowledgebase, inbound MCP server mode, checkpoints + /undo, heartbeat daemon, shell backends (local | docker), send_message, promptware defense, Windows shell-output encoding fixes, fs_grep ripgrep optimisations, OpenTelemetry traces, and `pasclaw agent --quiet`. Added (newest first): 2026-06-13 #244 agent --quiet log-level clamp 2026-06-12 #243 dcc64 search path + agent --quiet / -q #242 OpenTelemetry traces (OTLP/HTTP+JSON) #241 fs_grep tier 5+6 (byte walker + Boyer-Moore-Horspool) #240 fs_grep tier 1-4 (deferred hash + skip-dirs + binary sniff + size cap) 2026-06-11 #239 Windows shell output: auto-detect UTF-8 vs OEM #238 Hashline fs_read header mojibake fix (¶ vs ¶) #237 Windows shell output: OEM codepage decode 2026-06-10 #233 Shell backends (local | docker via IShellBackend) #232 Heartbeat daemon + reversible condensation (CCR) #230 send_message tool + condenser families + promptware defense + task-aware MEMORY.md slicing 2026-06-09 #223 /goal Ralph loop + judge model + JSON-aware condenser #222 /undo wired into agent + sample dprojs #221 Checkpoints (auto-snapshot + TUI /undo) #220 mcp catalog: lenient hub projector #219 mcp: SSE / Streamable HTTP / stdio hub transports #218 Inbound MCP server mode #217 onboard: offer to index docs into the knowledgebase #214 Knowledgebase (RAG over operator-curated docs) Skipped from this changelog (build-system / Delphi-fix / FPC-fix PRs visible in the git log but not user-facing features): #215, #216, #224, #225, #226, #227, #228, #229, #231, #234, #236. Both files (README.md and docs/changelog.md) updated with the same entries -- intentional mirror so a reader on either surface sees the same history. Same prose in both; same footnote refs at the bottom. Validated: every [#N] reference in both files has a matching [#N]: URL footnote (no broken links).
…sation (CCR)
Two features from the recent gap analysis against picoclaw / openclaw
and chopratejas/headroom respectively.
1. Heartbeat -- proactive periodic wake-up. The picoclaw/openclaw
"agent that comes to you" pattern: read workspace/heartbeat.md
every N minutes, run the agent on its body, optionally post the
result to a named channel.
- PasClaw.Heartbeat: standalone THeartbeat class + thread; reads
content file fresh on every tick (operator edits land without
restart), skips empty/missing files cleanly, tight 4-iter loop
to keep ticks bounded.
- pasclaw heartbeat command: foreground daemon mode (blocks until
Ctrl-C) + --once for testing + --interval / --content overrides
+ --force to override the config gate.
- Off by default in TConfig.Heartbeat. Onboarding adds a
PromptHeartbeat step after PromptCheckpoints: explicit y/N with
interval and channel-name follow-ups. Refuses to run without
the flag (or --force) so an operator who skipped onboarding
doesn't end up with unsolicited model spend.
- Channel post reuses Cfg.Channels (the same name->kind/target
mapping send_message uses): operator pre-declares targets, model
can't exfiltrate to an arbitrary URL.
- heartbeat_tests pins: missing/empty/non-empty content paths,
default-path fallback, no double-call when no body. Scripted
fake ILLMProvider keeps the suite model-free.
2. Reversible condensation (CCR). PR FMXExpress#230 added the JSON condenser
and 20-ish shell-filter families -- all DESTRUCTIVE: a 200 KB
tool result that collapses to a 4 KB structural summary loses
the original bytes. headroom's CCR layer keeps both: condense
for the model's default view, stash the original under a handle
for retrieval when the shape isn't enough.
- PasClaw.Tools.OutputCache gets AttachReversibleStashFooter:
when (Original - Condensed) >= MinSavingsBytes, stash the
ORIGINAL under a fresh handle and append a one-line footer
naming it. No-op below the floor, no-op when
SetCondenseReversible(False).
- Wired at the two condensation points:
* RunToolLoop after MaybeCondenseJSON (every tool result)
* Tool_Shell after ApplyShellFilter (shell_exec only)
Both pass (RawBody, FilteredBody) -- tee-on-failure already
means the bytes are byte-identical on failure and no stash
attaches.
- tool_output_get registration generalised: it now registers
when Cfg.ToolOutputCap > 0 OR Cfg.CondenseReversible (default
True). All five registry builders (CLI agent, TUI, Serve,
Gateway, embedder x2) updated.
- LoadConfig propagates SetCondenseReversible() symmetrically
with the existing SetPromptwareEnabled() pattern.
- condense_reversible_tests pins: no-op same-size, sub-floor
skip, real saving stash + dereferenceable handle, disable
switch, counter accumulation, MinSavingsBytes override.
- TUI /stats overlay grows a "ccr N stash(es), M bytes preserved"
row alongside the existing promptware/shell-filter rows; box
height bumped from 11 to 12.
FPC make smoke + full make test (33 targets, +2 new) green. New
units registered in PasClaw.dproj. README updated.
https://claude.ai/code/session_01TBcLtmpj7dqA5tyFbGnQon
Four features in one pass, each closing a gap against hermes / rtk / atlas:
1.
send_messagemodel toolpasclaw postwas CLI-only — the model couldn't push to channels mid-task. NewPasClaw.Tools.SendMessageregisters asend_messagetool using the same channel senders (Discord / Slack / Teams / generic webhook / LINE / WhatsApp).Security shape: the model addresses channels strictly by name; the name→(kind, target) mapping lives in
config.json's new"channels": [{"name","kind","target"}]array under operator control, so a prompt-injected model can't exfiltrate to a webhook URL it invented. The tool self-gates — no channels configured means it isn't registered at all (zero context-token cost). Wired into bothNewBuiltinRegistry(CLI) andTPasClawAgent.EnsureRegistry(embedders/gateway).tcMutating.2. Condenser expansion: ~6 → ~20 command families
New filters in
PasClaw.Tools.Shell.Filters: tabular CLIs (docker ps/images,kubectl get,gh pr/run/issue/release),docker build(classic + BuildKit), head/tail log shapes (docker logs,kubectl logs/describe,tsc), compile walls (cargo build/check/clippy— clippy warnings exit 0, so warnings stay verbatim while theCheckingspam collapses to a count),go test,eslint(stylish-reporter per-file aggregation),npm install/ci,pip install,mvn([INFO]wall),gradle/gradlew,terraform plan/apply(resource headers +Plan:summary survive; attribute diffs collapse), andaws(JSON output routes through the sharedPasClaw.Condense.JSONengine).Canonicalizer learns:
sudo/npxpeeling,pip3→pip,npm i→npm install,./gradlew→gradle. An option token in subcommand position (docker --context prod ps) degrades to the unmatched one-word key — pass-through beats mis-dispatch. Tee-on-failure and unknown-command pass-through contracts unchanged.3. Promptware defense (hermes)
New leaf unit
PasClaw.Promptwarescans for injection patterns at the three indirect-input chokepoints:RunToolLoop, after JSON condensation, before the byte-cap (so the banner survives truncation's head slice)memory_searchresults, labelled explicitly so the model knows which trust boundary the content crossed (banner-mark idempotence prevents double-wrap when the result re-traverses the loop scan)fs_readwhere chokepoint 1 annotates themAnnotate-don't-block: 18 lowercase-substring rules in 5 families (instruction override, fake system prompt, concealment, prompt exfil, curl-pipe-to-shell with two-substring co-occurrence). On by default (linear scan over in-memory bytes);
"promptware_enabled": falseopts out, propagated viaLoadConfigso every entry point honours it. Scan/hit counters surface in the TUI/statsoverlay.4. Task-aware orientation (atlas
orient)Opt-in
"orient_task_aware": true: when on and the call site passes a task hint (one-shot-m, each interactive turn, each/goalturn),BuildMemorySectionslices MEMORY.md + daily notes via newPasClaw.Agent.Orient— markdown-heading sections (paragraph fallback for headingless prose), scored by stopword-stripped token overlap with the task, only matching sections injected. Document order preserved, 4 KB/file budget,(N sections elided — memory_search reaches them)note. No hint or flag off = whole-file injection, byte-identical to today. Deliberately lexical (no embeddings): runs synchronously in prompt assembly and can't depend on provisioned vector weights.Test plan
make testfully green (31 targets)test-promptware(9 cases: every rule family, two-substring co-occurrence, idempotence, disable switch, counters),test-orient(7 cases: relevance, order preservation, paragraph fallback, budget, degenerate hints, case-insensitivity)PasClaw.dprojfor the Delphi buildchannelsentry, ask the agent to post a progress update; fliporient_task_awarewith a multi-section MEMORY.md and verify slicinghttps://claude.ai/code/session_01TBcLtmpj7dqA5tyFbGnQon
Generated by Claude Code