Repository navigation
feat(ace): ACE Playbook Hooks — Curator Pattern (Spec 18) - #17
Merged
Merged
Conversation
ASPIR plan for Spec 18 (ACE Curator Pattern). Consulted with GPT 5.3 Codex (8/10) and Gemini 3.1 Pro (9/10). Key change from spec: added after_propose hook for cache invalidation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Phase 1+2: rules.py with PlaybookRule dataclass (matches/evaluate with Laplace smoothing + [0.5,2.0] clamping, age_lt_days support) and _parse_rules with graceful skip. __init__.py with on_startup, on_recall, before_save, after_save, after_propose, after_supersede hooks following SECOM patterns. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Phase 3: 64 tests covering TestConfigure, TestPlaybookRule (matches/evaluate with clamping/Laplace), TestParseRules (malformed skip), TestOnStartup, TestOnRecall (lazy-load/TTL/rerank/concurrent), TestBeforeSave (anti-pattern Warn + brevity Advise), TestAfterSave/Propose/Supersede (cache invalidation + telemetry), TestPipelineIntegration (end-to-end + concurrent cold cache). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
README covers quick start (module ref + local copy), config contract, all 6 hook lifecycle points, rule authoring guide with match criteria table and scoring formula, MCP create-and-promote workflow, ACE vs flat storage comparison, and literature references. 4 example rules: boost-recent-decisions, deprioritize-low-confidence, anti-pattern-no-terse-decisions, boost-tagged-important (with feedback counters demonstrating Laplace growth). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
…ence 0.0 Three bugs identified during codereview: - _parse_rules() now validates match/action are dicts before creating PlaybookRule - evaluate() normalizes helpful/harmful counters to non-negative before ratio computation - on_recall uses explicit None check for confidence instead of falsy `or 0.5` Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…eview) - matches() confidence_lt: use explicit None check instead of falsy `or 0.0` (confidence=0.0 was correctly handled by accident, but None was silently treated as 0.0 — now explicit) - _SAVE_TELEMETRY and _SUPERSEDE_STATS: FIFO eviction at configurable cap (default 10,000 per scope, ~3MB/scope). Configurable via telemetry_max_per_scope in hook config. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
0.0 is not guaranteed to be older than TTL_SECONDS on systems with uptime < 5 minutes (e.g. fresh CI containers). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
src/fava_trails/protocols/ace/)protocols/secomstructureon_startup,on_recall,before_save,after_save,after_propose,after_supersedeChanges
Phase 1 —
rules.py:PlaybookRuledataclass withmatches()(AND logic: source_type, confidence_lt, tags_include, tags_exclude, age_lt_days) andevaluate()(Laplace-smoothed ratio, clamped to [0.5, 2.0])._parse_rules()with graceful malformed-entry skip.Phase 2 —
__init__.py: All 6 hooks following SECOM patterns. 5-minute TTL cache per scope. Cache invalidated immediately onafter_save/after_propose/after_supersedeforace-playbooktagged thoughts. Telemetry accumulators (_SAVE_TELEMETRY,_SUPERSEDE_STATS) for external Reflector.Phase 3 —
tests/test_ace.py: 64 tests across TestConfigure, TestPlaybookRule, TestParseRules, TestOnStartup, TestOnRecall, TestBeforeSave, TestAfterSave, TestAfterPropose, TestAfterSupersede, TestPipelineIntegration. Includes concurrent cold-cache load test and TTL-expiry reload test.Phase 4 —
README.md+example_rules/: Quick start (module ref + local copy), config contract, all 6 hook lifecycle points, rule authoring guide with scoring formula, 4 example rules demonstrating retrieval_priority, confidence_floor, staleness, and anti_pattern rule types.Test plan
uv run pytest -v— all 446 tests pass (including 64 new ACE tests)uv run ruff check src/— no linting errorssrc/fava_trails/protocols/ace/example_rules/🤖 Generated with Claude Code