Skip to content

feat: community governance layer — task state, undo, policy, audit, health, isolation - #518

Draft
isair wants to merge 7 commits into
developfrom
feat/task-state-undo
Draft

feat: community governance layer — task state, undo, policy, audit, health, isolation#518
isair wants to merge 7 commits into
developfrom
feat/task-state-undo

Conversation

@isair

@isair isair commented Jul 19, 2026

Copy link
Copy Markdown
Owner

Summary

Brings sjackson0109's community governance work (the develop-community branch) into develop, rebased onto the current head with original authorship preserved. The five feature commits are cherry-picked verbatim under Simon Jackson's authorship; only conflict resolution and a small test-adaptation commit were added on top.

Integration notes

  • Rebased across 93 commits of drift: merged with the planner-era reply/engine.py (task steps, undo registration, and audit recording now coexist with the pre-flight planner, toolSearchTool allow-list widening, and tool-result digest), the llm/ package refactor, and the removal of recallConversation (fix(reply): small-model robustness — weather location, JSON leak scrub, router follow-ups, remove broken recallConversation #255).
  • undo registered alongside toolSearchTool in the builtin registry.
  • Spec files for all five areas are included and registered in the CLAUDE.md spec table; reply.spec.md merged to describe classification, approval checking, and task-state transitions alongside the current TTS/planner flow.
  • No new LLM contexts: all five features are deterministic, so docs/llm_contexts.md is unchanged.
  • Test adaptations: removed recallConversation references; path-guard tests now use a home-directory path so home_only assertions hold on every platform.

Tests

  • All new suites pass: 131 tests across task state, approval, undo registry/tool, classification, audit, runner, and orchestration.
  • Full suite vs develop baseline: zero regressions (the 68 pre-existing local Qt failures are identical on origin/develop).

Closes #130
Closes #131
Closes #132
Closes #133
Closes #134

🤖 Generated with Claude Code

@isair

isair commented Jul 19, 2026

Copy link
Copy Markdown
Owner Author

Multi-agent adversarial review completed (five specialists + verifier). All must-fix findings have been addressed in 2da83bd:

Fixed

  • Undo snapshot corruption: snapshots were captured via the localFiles read operation, whose 10k-char display truncation meant undoing a write on any larger file would have restored truncated content. Snapshots now use a direct bounded read (1 MB cap); oversized files get no undo entry rather than a corrupting one.
  • Planner direct-exec bypass: the fast path executed plan steps with no policy check, undo, or audit. It now runs only SAFE-risk, policy-allowed steps and defers anything else to the governed loop, failing closed.
  • Success gating: step completion and undo registration were keyed on reply_text presence, so failed or denied actions were marked complete and offered undo. Now gated on result.success, with the audit record using the same predicate.
  • Default path guard now blocks home credential stores (.ssh, .aws, .gnupg, .kube, .docker, .netrc, .npmrc, .pypirc, .git-credentials), and containment checks use device+inode identity so case tricks cannot evade blocked roots on macOS or Windows (verified against a live bypass reproduction).
  • Hardcoded English spoken warnings replaced with model-directed instructions on the tool-result message, so the reply LLM phrases irreversibility warnings and undo notes in the user's language.
  • Audit TaskRecord now finalised on the stop path.
  • Spec honesty: reply.spec.md rewritten to the act-then-undo model actually implemented; execution.spec.md and runtime.spec.md now state that ToolRunner and ShutdownManager are not yet integrated (with wiring preconditions); policy_mode docstring corrected to active | deny.

Follow-ups to file as issues (not blockers)

  • Wire ToolRunner (with policy fallback, scrubbed env, framed worker protocol) and ShutdownManager, then activate the two inert config keys.
  • Engine-level integration tests for the policy-deny / undo / audit interleaving, and an undo-routing eval.
  • Settings window metadata for the new policy keys; README section for undo and workspace confinement.
  • TaskState per-turn isolation (currently a module singleton, safe today with the single voice call site).
  • Async audit writes; remove the unused ApprovalStore grants machinery.

Test status: all 183 governance tests pass; full suite shows zero regressions against the develop baseline.

sjackson0109 and others added 7 commits July 21, 2026 02:10
Add session-scoped task state machine for tracking execution progress,
risk-based approval with voice-first undo model (act-then-undo instead
of blocking gates), and a language-agnostic UndoTool that replaces
English-only regex detection. Includes tool base class extensions for
classify() and assess_risk(), reply engine integration with policy
evaluation and audit recording, and comprehensive test coverage.

Co-Authored-By: Baris Sencan <[email protected]>
Add a centralised policy engine that evaluates every tool call through
classify → assess risk → path guard → MCP check → approval pipeline.
Includes workspace confinement via configurable roots and blocked paths,
tool classification delegated to each tool's classify() method, and
formal error types for the agent loop.

Co-Authored-By: Baris Sencan <[email protected]>
Add opt-in audit system (configured via audit_db_path) that records task
lifecycle, policy decisions, and tool execution steps. Includes redaction
of sensitive data before storage, parameterised status updates to avoid
hardcoded values, and comprehensive test coverage for the recorder.

Co-Authored-By: Baris Sencan <[email protected]>
Add health registry for tracking service status (ready/degraded/
unavailable), graceful shutdown manager with configurable diary timeout
(default 5s), and remove dead bootstrap/service_container code. Includes
critical failure detection and service-level health summaries.

Co-Authored-By: Baris Sencan <[email protected]>
Add subprocess-based tool execution for write operations with retry logic
that distinguishes transient errors (TimeoutExpired, ConnectionError,
OSError) from permanent failures. Includes zombie process prevention via
proc.wait(timeout=5) after kill, and configurable subprocess mode via
use_subprocess_for_writes config option.

Co-Authored-By: Baris Sencan <[email protected]>
- Drop references to the removed recallConversation tool (deleted on
  develop in #255) from approval, classification, and risk tests.
- Use a home-directory path in policy path-guard tests so the
  home_only mode assertion holds on every platform (/tmp is outside
  the user home and is correctly denied).

Co-Authored-By: Claude Fable 5 <[email protected]>
…ayer

Correctness:
- Gate step completion and undo registration on result.success, not on
  the presence of reply_text; failed or policy-denied actions no longer
  register undo entries or claim reversibility. Audit uses the same
  predicate.
- Capture undo snapshots via a direct bounded file read instead of the
  localFiles read operation, whose 10k-char display truncation would
  have made undo restore corrupted content; files over the cap get no
  undo entry rather than a lying one.
- The planner direct-exec fast path now runs only SAFE-risk,
  policy-allowed steps; write/destructive plan steps defer to the
  governed loop (policy -> snapshot -> undo -> audit). Fail-closed.
- Finalise the audit TaskRecord on the stop-tool path.

Security/privacy:
- Default blocked roots now cover home credential stores (~/.ssh,
  ~/.aws, ~/.gnupg, ~/.kube, ~/.docker, ~/.netrc, ~/.npmrc, ~/.pypirc,
  ~/.git-credentials); blocked roots are expanduser-ed.
- Path containment falls back to device+inode identity so
  differently-cased paths cannot evade blocked/read-only roots on
  case-insensitive filesystems.

Language-agnostic UX:
- Irreversibility warnings and undo notes are no longer hardcoded
  English spliced into the spoken reply; they ride the tool-result
  message as model instructions so the reply LLM phrases them in the
  user's language.

Docs/specs:
- reply.spec.md governance section rewritten to match the act-then-undo
  implementation (the approval-gate halt flow never existed in code).
- execution.spec.md and runtime.spec.md now state plainly that
  ToolRunner and ShutdownManager are not yet integrated, with the
  preconditions for wiring them in; the inert config keys say so.
- policy_mode docstring corrected to the real enum (active | deny).
- policy.spec.md documents the new blocked defaults and case handling.

Co-Authored-By: Claude Fable 5 <[email protected]>
@isair
isair force-pushed the feat/task-state-undo branch from dd765af to ed24796 Compare July 21, 2026 01:10
@isair
isair marked this pull request as draft August 4, 2026 14:09
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.

2 participants