zeroclaw/src/channels
Argenis b98971c635
fix(sop): fix state file leak and add deterministic execution tests (#4404)
* feat(sop): add deterministic execution mode with typed steps and approval checkpoints

Add opt-in deterministic execution to the SOP workflow engine, inspired
by OpenClaw's Lobster engine. Deterministic mode bypasses LLM round-trips
for step transitions, executing steps sequentially with piped outputs.

Key additions:
- SopExecutionMode::Deterministic variant and `deterministic: true` SOP.toml flag
- SopStepKind enum (Execute/Checkpoint) for marking approval pause points
- StepSchema for typed input/output validation (JSON Schema fragments)
- DeterministicRunState for persisting/resuming interrupted workflows
- DeterministicSavings for tracking LLM calls saved
- SopRunAction::DeterministicStep and CheckpointWait action variants
- SopRunStatus::PausedCheckpoint status
- Engine methods: start_deterministic_run, advance_deterministic_step,
  resume_deterministic_run, persist/load_deterministic_state
- SopConfig in config/schema.rs with sops_dir, default_execution_mode,
  max_concurrent_total, approval_timeout_secs, max_finished_runs
- Wire `pub mod sop` in lib.rs (previously dead/uncompiled module)
- Fix pre-existing test issues: TempDir import, async test annotations

All 86 SOP core tests pass (engine: 42, mod: 17, dispatch: 13, types: 14).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix(sop): resolve clippy warnings and fix metrics test failures

- Add `ampersona-gates = []` feature declaration to Cargo.toml to fix
  clippy `unexpected cfg condition value` errors in sop/mod.rs,
  sop/audit.rs, and sop/metrics.rs.
- Use dynamic Utc::now() timestamps in metrics test helper `make_run()`
  instead of hardcoded 2026-02-19 dates, which had drifted outside the
  7-day/30-day windowed metric windows causing 7 test failures.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix(sop): remove non-functional ampersona-gates feature flag

The ampersona-gates feature flag referenced ampersona_core and
ampersona_engine crates that do not exist, causing cargo check
--all-features to fail. Remove the feature flag and all gated code:

- Remove ampersona-gates from Cargo.toml [features]
- Delete src/sop/gates.rs (entire module behind cfg gate)
- Remove gated methods from audit.rs (log_gate_decision, log_phase_state)
- Remove gated MetricsProvider impl and tests from metrics.rs
- Simplify sop_status.rs gate_eval field and append_gate_status
- Update observability docs (EN + zh-CN)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* style(sop): fix formatting in metrics.rs

* fix(sop): wire SOP tools into tool registry

The five SOP tools (sop_list, sop_advance, sop_execute, sop_approve,
sop_status) existed as source files but were never registered in
all_tools_with_runtime. They are now conditionally registered when
sop.sops_dir is configured.

Also fixes:
- Add mod sop + SopCommands re-export to main.rs (binary crate)
- Handle new DeterministicStep/CheckpointWait variants in match arms
- Add missing struct fields (deterministic, kind, schema, llm_calls_saved)
  to test constructors

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix(sop): fix state file leak and add deterministic execution tests

- Fix persist_deterministic_state fallback: use system temp dir instead
  of current working directory when SOP location is unset, preventing
  state files from polluting the working directory.
- Add comprehensive test coverage for deterministic execution path:
  start, advance, checkpoint pause, completion with savings tracking,
  and rejection of non-deterministic SOPs.
- Add tests for deterministic flag in TOML manifest loading and
  checkpoint kind parsing from SOP.md.
- Add serde roundtrip tests for DeterministicRunState, SopStepKind,
  SopExecutionMode::Deterministic, and SopRunStatus::PausedCheckpoint.

* ci: retrigger CI

* fix: add missing attachments field to wati ChannelMessage after media pipeline merge

* fix(channels): add missing attachments field to voice_wake and lark

---------

Co-authored-by: Giulio V <vannini.gv@gmail.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: rareba <rareba@users.noreply.github.com>
2026-03-23 16:40:26 -04:00
..
bluesky.rs feat(channels): add automatic media understanding pipeline (#4402) 2026-03-23 15:14:11 -04:00
clawdtalk.rs Implement ChannelConfig for ClawdTalk 2026-02-21 19:38:19 +08:00
cli.rs feat(channels): add automatic media understanding pipeline (#4402) 2026-03-23 15:14:11 -04:00
dingtalk.rs feat(channels): add automatic media understanding pipeline (#4402) 2026-03-23 15:14:11 -04:00
discord_history.rs feat(channels): add automatic media understanding pipeline (#4402) 2026-03-23 15:14:11 -04:00
discord.rs feat(channels): add automatic media understanding pipeline (#4402) 2026-03-23 15:14:11 -04:00
email_channel.rs feat(channels): add automatic media understanding pipeline (#4402) 2026-03-23 15:14:11 -04:00
gmail_push.rs feat(channels): add automatic media understanding pipeline (#4402) 2026-03-23 15:14:11 -04:00
imessage.rs feat(channels): add automatic media understanding pipeline (#4402) 2026-03-23 15:14:11 -04:00
irc.rs feat(channels): add automatic media understanding pipeline (#4402) 2026-03-23 15:14:11 -04:00
lark.rs fix(sop): fix state file leak and add deterministic execution tests (#4404) 2026-03-23 16:40:26 -04:00
link_enricher.rs fix(channels): link enricher title extraction byte offset bug (#4271) 2026-03-22 19:09:09 -04:00
linq.rs feat(channels): add automatic media understanding pipeline (#4402) 2026-03-23 15:14:11 -04:00
matrix.rs feat(channels): add automatic media understanding pipeline (#4402) 2026-03-23 15:14:11 -04:00
mattermost.rs feat(channels): add automatic media understanding pipeline (#4402) 2026-03-23 15:14:11 -04:00
media_pipeline.rs feat(channels): add automatic media understanding pipeline (#4402) 2026-03-23 15:14:11 -04:00
mochat.rs feat(channels): add automatic media understanding pipeline (#4402) 2026-03-23 15:14:11 -04:00
mod.rs fix(channels): prevent draft streaming hang after tool loop completion (#4393) 2026-03-23 15:30:12 -04:00
mqtt.rs fix(web): call doctor endpoint with authenticated POST 2026-02-24 16:02:59 +08:00
nextcloud_talk.rs feat(channels): add automatic media understanding pipeline (#4402) 2026-03-23 15:14:11 -04:00
nostr.rs feat(channels): add automatic media understanding pipeline (#4402) 2026-03-23 15:14:11 -04:00
notion.rs feat(channels): add automatic media understanding pipeline (#4402) 2026-03-23 15:14:11 -04:00
qq.rs feat(channels): add automatic media understanding pipeline (#4402) 2026-03-23 15:14:11 -04:00
reddit.rs feat(channels): add automatic media understanding pipeline (#4402) 2026-03-23 15:14:11 -04:00
session_backend.rs feat(gateway): add named sessions with reconnect and validation fixes (#4275) 2026-03-22 18:58:15 -04:00
session_sqlite.rs feat(gateway): add named sessions with reconnect and validation fixes (#4275) 2026-03-22 18:58:15 -04:00
session_store.rs fix(channel): clear persisted JSONL session on /new command (#4014) 2026-03-19 21:48:33 -04:00
signal.rs feat(channels): add automatic media understanding pipeline (#4402) 2026-03-23 15:14:11 -04:00
slack.rs feat(channels): add automatic media understanding pipeline (#4402) 2026-03-23 15:14:11 -04:00
telegram.rs feat(channels): add automatic media understanding pipeline (#4402) 2026-03-23 15:14:11 -04:00
traits.rs feat(channels): add automatic media understanding pipeline (#4402) 2026-03-23 15:14:11 -04:00
transcription.rs feat(lark): add audio message transcription (#4388) 2026-03-23 14:58:11 -04:00
tts.rs feat(tts): add local Piper TTS provider (#4263) 2026-03-22 14:36:26 -04:00
twitter.rs feat(channels): add automatic media understanding pipeline (#4402) 2026-03-23 15:14:11 -04:00
voice_wake.rs fix(sop): fix state file leak and add deterministic execution tests (#4404) 2026-03-23 16:40:26 -04:00
wati.rs fix(sop): fix state file leak and add deterministic execution tests (#4404) 2026-03-23 16:40:26 -04:00
webhook.rs feat(channels): add automatic media understanding pipeline (#4402) 2026-03-23 15:14:11 -04:00
wecom.rs feat(channel): add WeCom (WeChat Enterprise) Bot Webhook channel (#3439) 2026-03-13 16:44:34 -04:00
whatsapp_storage.rs fix(security): remove sensitive fields from Debug impls 2026-02-20 22:06:21 -08:00
whatsapp_web.rs feat(channels): add automatic media understanding pipeline (#4402) 2026-03-23 15:14:11 -04:00
whatsapp.rs feat(channels): add automatic media understanding pipeline (#4402) 2026-03-23 15:14:11 -04:00