Skip to content

feat(core,tools): goal lifecycle and TACO output compression#3591

Merged
bug-ops merged 1 commit intomainfrom
3567-goal-lifecycle
May 4, 2026
Merged

feat(core,tools): goal lifecycle and TACO output compression#3591
bug-ops merged 1 commit intomainfrom
3567-goal-lifecycle

Conversation

@bug-ops
Copy link
Copy Markdown
Owner

@bug-ops bug-ops commented May 4, 2026

Summary

Key invariants enforced

  • G1: at-most-one-active-goal via partial unique index + transactional create()
  • G3: <active_goal> injected after <!-- cache:volatile --> (snapshot-tested)
  • T4: audit log records raw output, LLM context receives compressed
  • H1: goal text XML-escaped; </active_goal> literal rejected at store level
  • H2: max 4 concurrent regex compile tasks via AtomicUsize

Test plan

  • cargo nextest run --workspace --lib --bins — 8785 passed, 21 skipped
  • cargo +nightly fmt --check — clean
  • cargo clippy --workspace -- -D warnings — clean
  • New tests: GoalStatus FSM (5), GoalStore transitions (4), GoalAccounting (6), CompressedExecutor (3), RuleBasedCompressor (3), safe_compile (2), G3 snapshot test, T4 audit invariant, H1 injection guard
  • Live testing playbook: .local/testing/playbooks/goal-taco.md
  • Coverage status: .local/testing/coverage-status.md (both features marked Untested)

Migrations

  • SQLite: 081_goal_lifecycle.sql, 082_compression_rules.sql
  • Postgres: 076_goal_lifecycle.sql, 077_compression_rules.sql
  • Config: steps 41 (migrate_goals_config) + 42 (migrate_tools_compression_config)

@github-actions github-actions Bot added enhancement New feature or request documentation Improvements or additions to documentation rust Rust code changes core zeph-core crate dependencies Dependency updates size/XL Extra large PR (500+ lines) and removed enhancement New feature or request labels May 4, 2026
@bug-ops bug-ops force-pushed the 3567-goal-lifecycle branch from 6882164 to bf83705 Compare May 4, 2026 19:17
@github-actions github-actions Bot added the enhancement New feature or request label May 4, 2026
@bug-ops bug-ops enabled auto-merge (squash) May 4, 2026 19:25
@bug-ops bug-ops force-pushed the 3567-goal-lifecycle branch 3 times, most recently from 015b761 to 5fa297b Compare May 4, 2026 19:56
…3306)

Adds two long-horizon agent features:

**Goal lifecycle** (`/goal` command):
- `GoalStore` (SQLite + Postgres) with transactional `create()` that atomically
  pauses any active goal; partial unique index enforces at-most-one-active invariant
- `GoalStatus` FSM: active → paused/completed/cleared, paused → active/cleared
- `GoalAccounting` caches active goal in-memory; dispatches `record_turn` as a
  fire-and-forget background task tracked in the supervisor JoinSet
- Active goal text injected into system prompt after `<!-- cache:volatile -->` (G3)
  with XML escaping and `</active_goal>` injection guard (H1)
- `/goal create|pause|resume|complete|clear|status|list` registered in all channels
- TUI status badge (▶/⏸/✓/✗) in status panel
- Config section `[goals]` with `enabled`, `max_text_chars`, `default_token_budget`
- SQLite migration `081_goal_lifecycle.sql`, Postgres `076_goal_lifecycle.sql`
- Config migrations `migrate_goals_config` (step 41)

**TACO output compression** (`OutputCompressor` + `CompressedExecutor`):
- `OutputCompressor` async trait with `IdentityCompressor` (zero-cost no-op)
- `RuleBasedCompressor`: regex rules from `compression_rules` table, hit counts
  in `DashMap<String, AtomicU64>`, rules in `parking_lot::RwLock<Vec<CompiledRule>>`
- `safe_compile`: `spawn_blocking` + `tokio::time::timeout` + `RegexBuilder` size
  limits + `AtomicUsize` concurrency cap (max 4 concurrent compiles, H2)
- `CompressedExecutor<E>` decorator: audit log sees raw output, LLM gets compressed
- Self-evolution hook in `maybe_autodream` generates candidate rules via LLM
- Config section `[tools.compression]` with `enabled`, `min_lines_to_compress`,
  `evolution_provider`, `regex_compile_timeout_ms`
- SQLite migration `082_compression_rules.sql`, Postgres `077_compression_rules.sql`
- Config migrations `migrate_tools_compression_config` (step 42)

Closes #3567, #3306
@bug-ops bug-ops force-pushed the 3567-goal-lifecycle branch from 5fa297b to 8c6cc2c Compare May 4, 2026 20:05
@bug-ops bug-ops merged commit 4e77b4f into main May 4, 2026
32 checks passed
@bug-ops bug-ops deleted the 3567-goal-lifecycle branch May 4, 2026 20:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core zeph-core crate dependencies Dependency updates documentation Improvements or additions to documentation enhancement New feature or request rust Rust code changes size/XL Extra large PR (500+ lines)

Projects

None yet

1 participant