zeroclaw/src
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
..
agent fix(channels): ensure newline between narration and draft status lines (#4394) 2026-03-23 15:30:15 -04:00
approval fix(approval): merge default auto_approve entries with user config (#4262) 2026-03-22 14:28:09 -04:00
auth feat(auth): add import functionality for existing OpenAI Codex auth p… (#3762) 2026-03-21 06:49:44 -04:00
channels fix(sop): fix state file leak and add deterministic execution tests (#4404) 2026-03-23 16:40:26 -04:00
commands fix(update): diagnose arch mismatch in validate_binary before execution (#4379) 2026-03-23 13:36:44 -04:00
config fix(sop): fix state file leak and add deterministic execution tests (#4404) 2026-03-23 16:40:26 -04:00
cost fix(channels): add cost tracking and enforcement to all channels (#4143) 2026-03-21 07:37:15 -04:00
cron feat: declarative cron job configuration (#4045) 2026-03-22 19:03:00 -04:00
daemon fix(heartbeat): prevent UTF-8 panic, add memory bounds and path validation in session context 2026-03-22 00:01:44 -04:00
doctor feat(tool): enrich delegate sub-agent system prompt and add skills_directory config key (#3344) 2026-03-21 07:53:02 -04:00
gateway fix(gateway): improve WebSocket chat error handling and diagnostics (#4407) 2026-03-23 15:30:18 -04:00
hands feat(hands): add autonomous knowledge-accumulating agent packages (#3603) 2026-03-15 16:06:14 -04:00
hardware fix(hardware): drain stdin in subprocess test to prevent broken pipe flake (#4161) 2026-03-21 12:19:53 -04:00
health refactor(sync): migrate remaining std mutex usage to parking_lot 2026-02-18 00:45:26 +08:00
heartbeat feat(heartbeat): add health metrics, adaptive intervals, and task history 2026-03-16 12:08:32 -04:00
hooks feat(hooks): add webhook-audit builtin hook (#3212) 2026-03-11 23:34:17 -04:00
integrations feat(matrix): add allowed_rooms config for room-level gating (#4230) (#4260) 2026-03-22 14:41:43 -04:00
memory feat(memory): restore time-decay scoring lost in main→master migration (#4274) 2026-03-22 19:01:40 -04:00
nodes feat(nodes): add secure HMAC-SHA256 node transport layer (#3654) 2026-03-16 01:53:47 -04:00
observability fix(observability): handle missing OtelObserver match arms and add all-features CI check (#3981) 2026-03-19 17:48:35 -04:00
onboard fix(sop): fix state file leak and add deterministic execution tests (#4404) 2026-03-23 16:40:26 -04:00
peripherals feat(hardware): add RPi GPIO, Aardvark I2C/SPI/GPIO, and hardware plugin system (#4125) 2026-03-21 04:17:01 -04:00
plugins fix(plugins): integrate WASM tools into registry, add gateway routes and tests 2026-03-17 18:10:24 -04:00
providers fix(gateway): improve WebSocket chat error handling and diagnostics (#4407) 2026-03-23 15:30:18 -04:00
rag chore(lint): extend low-risk clippy cleanup batch 2026-02-17 16:40:58 +08:00
runtime feat(tools): add Windows support for shell tool_call execution (#3442) 2026-03-13 17:12:16 -04:00
security fix(security): update blocked_commands_basic test after #4338 (#4399) 2026-03-23 14:16:42 -04:00
service fix: use POSIX-compatible sh -c instead of dash-specific -lc (#4209) (#4217) 2026-03-22 00:07:37 -04:00
skillforge chore: Remove blocking read strings 2026-02-19 14:52:29 +08:00
skills fix(skills): surface actionable warning when skills are skipped due to script policy (#4383) 2026-03-23 12:47:32 -04:00
sop fix(sop): fix state file leak and add deterministic execution tests (#4404) 2026-03-23 16:40:26 -04:00
tools fix(sop): fix state file leak and add deterministic execution tests (#4404) 2026-03-23 16:40:26 -04:00
tunnel Feat/add pinggy tunnel (#4060) 2026-03-20 15:11:50 -04:00
verifiable_intent feat(verifiable_intent): add native verifiable intent lifecycle module (#2938) 2026-03-20 17:52:55 -04:00
cli_input.rs fix(onboard): make tmux paste safe for text prompts (#4106) 2026-03-21 05:14:37 -04:00
i18n.rs feat(i18n): externalize tool descriptions for translation (#3912) 2026-03-18 17:01:39 -04:00
identity.rs test: cover deterministic HashMap ordering paths 2026-02-18 21:55:40 +08:00
lib.rs fix(sop): fix state file leak and add deterministic execution tests (#4404) 2026-03-23 16:40:26 -04:00
main.rs fix(sop): fix state file leak and add deterministic execution tests (#4404) 2026-03-23 16:40:26 -04:00
migration.rs readd tests, remove markdown files 2026-02-18 14:42:39 +08:00
multimodal.rs feat(multimodal): route image messages to dedicated vision provider (#4264) 2026-03-22 14:36:29 -04:00
util.rs feat(hardware): add RPi GPIO, Aardvark I2C/SPI/GPIO, and hardware plugin system (#4125) 2026-03-21 04:17:01 -04:00