Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG/v3.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- **Stop-hook cadence policy — P1 every-K-turns checkpoint** ([#749](https://github.com/robotrocketscience/aelfrice/issues/749)). The Stop hook now supports a periodic-checkpoint cadence that fires the rebuilder pass every K turn boundaries, independent of when the host harness chooses to PreCompact. Originating concern: post-[#746](https://github.com/robotrocketscience/aelfrice/issues/746) PreCompact-fire-rate data showed 6 fires across 2 sessions over 6 days at `trigger_mode='threshold'` — the maintainer's typical workload `/clear`s faster than the harness compacts, so the P0 PreCompact-only policy misses most state-recovery opportunities. The [#749](https://github.com/robotrocketscience/aelfrice/issues/749) body OR-clause was tripped by maintainer self-report and this PR ships the smallest of the body's pre-registered policies. New `src/aelfrice/cadence.py` module: `CadenceConfig` dataclass, `[cadence]` TOML section (`enabled` / `policy` / `k`), env > kwarg > TOML > default resolvers, and the pure `should_fire(fire_idx, config)` predicate (`fire_idx > 0 AND fire_idx % k == 0`, gated on `enabled AND policy == "p1_every_k_turns"`). The resolver shape leaves a slot between env and kwarg for a future [#480](https://github.com/robotrocketscience/aelfrice/issues/480) `meta:hook.cadence_k` meta-belief read without changing call sites. Stop-hook wiring: a new `_maybe_fire_cadence_checkpoint(payload, session_id, serr)` helper reads the current session's `next_fire_idx` from `session_ring.read_ring_state` (same monotonic counter UPS already maintains), checks `should_fire`, and on True calls `_rebuild_and_format` with `rebuild_log_enabled=True` — discarding the returned body since Stop has no `additionalContext` channel. The rebuild_log entry and touch-state refresh are the side effects that carry value. Stderr observability line: `aelfrice: cadence checkpoint fired @ fire_idx=N (policy=p1_every_k_turns, k=15)`. Restructured `stop()` so a session with zero lock-prompt candidates no longer early-returns before cadence gets a chance to run; the lock-prompt behaviour itself is unchanged (41 existing `test_hook_stop_lock_prompt` + `test_setup_stop_hook` tests pass). Default-OFF (`enabled = false` is the default; an unset `[cadence]` section is byte-identical to a pre-#749 Stop hook). K defaults to 15 per the [#749](https://github.com/robotrocketscience/aelfrice/issues/749) body's literature-typical starting point. Determinism contract ([#605](https://github.com/robotrocketscience/aelfrice/issues/605)): the firing predicate is a pure function of `(fire_idx, k)` — no wall-clock, no random sampling. A replay with the same UPS sequence and same config produces the same fire decisions. 30 unit tests in `tests/test_cadence.py` cover the predicate cross-product (enabled / policy / k including k=0 / k=1 / negative-k / fire_idx=0 cold-start guard / negative fire_idx), TOML parser fail-soft on missing-file / missing-section / malformed-TOML / wrong-typed-enabled / unknown-policy / non-positive-k / bool-as-k / parent-dir walk, and the env > kwarg > TOML > default resolver precedence including env-unparseable falls-through. 11 integration tests in `tests/test_hook_stop_cadence.py` against the actual `hook.stop()` entry point cover default-OFF, policy-off-with-enabled-true, the multiples-of-K firing pattern (15/30/45 fire; 1/14/16/29 skip), cold-start fire_idx=0 suppression, missing/session-mismatched ring sentinel, empty recent-turns slice, env-override beats TOML, the stderr observability line carries policy/k/fire_idx, the regression that zero-lock-candidate sessions still fire cadence, and the lock-prompt + cadence coexistence path. P2 (token-budget watermark) and P3 (turn-density-aware) per the [#749](https://github.com/robotrocketscience/aelfrice/issues/749) body remain unimplemented; the policy enum is forward-compatible so those land as new values without rewriting the resolver or predicate.
Comment thread
robotrocketscience marked this conversation as resolved.
Resolved
Comment thread
robotrocketscience marked this conversation as resolved.
Resolved

- **Session-scoped retrieval exclusion — `aelf scope-out` / `/aelf:scope-out`** ([#856](https://github.com/robotrocketscience/aelfrice/issues/856), defect 1 of [#855](https://github.com/robotrocketscience/aelfrice/issues/855)). The UserPromptSubmit memory hook now honors a per-session exclusion list, addressing the failure mode where an agent appears unable to follow direct instructions because the hook keeps re-injecting beliefs about a topic the user has explicitly asked it to drop. `aelf scope-out <pattern>` (slash form `/aelf:scope-out <pattern>`) writes a case-insensitive literal substring to `<git-common-dir>/aelfrice/session_exclusions.json`, keyed by the active `session_id` read from the sibling `session_first_prompt.json`. The hook reads the list inside `_filter_session_exclusions(hits, session_id)` immediately after `_retrieve()` and drops every belief whose content contains a listed pattern, before telemetry / dedup / format run so downstream counts reflect what was actually injected. L0 (locked) beliefs surfaced by the per-turn retrieval are filtered too — when the user explicitly says "stop bringing this up," that overrides ground-truth re-injection for the rest of the session; the lock stays in the DB and the one-shot SessionStart sub-block (which dumps L0 on the very first prompt of a session) runs before the user can have typed scope-out, so it remains unfiltered by design. Auto-clear on new session: a mismatch between the stored and current `session_id` returns an empty pattern list, so a fresh session starts with no carried-over exclusions. Sibling CLI flags: `aelf scope-out --list` prints active patterns, `aelf scope-out --clear` empties the list (preserving session_id). Regex deliberately not supported — substring keeps the surface deterministic per the v3.0 PHILOSOPHY ratification ([#605](https://github.com/robotrocketscience/aelfrice/issues/605)). 31 unit tests in `tests/test_session_exclusions.py` cover the module API (load / save / add / clear / `is_excluded` / `read_current_session_id`) including auto-clear on session_id mismatch, dedup-with-order-preservation on save, malformed-JSON tolerance, and empty-pattern guards. Six new hook-integration tests in `tests/test_hook_user_prompt_submit.py` cover the per-turn filter for L0 + L1 beliefs, case-insensitivity, multi-pattern composition, the no-file no-op, and the session-id-mismatch no-op. New module `src/aelfrice/session_exclusions.py`, slash file `src/aelfrice/slash_commands/scope-out.md`, CLI subparser in `src/aelfrice/cli.py`, hook filter in `src/aelfrice/hook.py`.

- **Project-context retrieval filter — within-repo scope tag** ([#858](https://github.com/robotrocketscience/aelfrice/issues/858), defect 3 of [#855](https://github.com/robotrocketscience/aelfrice/issues/855)). The UserPromptSubmit hook now drops retrieved beliefs whose stored `project_context` disagrees with the active in-process context resolved by `db_paths.active_project_context()`. Cross-repo isolation already exists via `db_path()`'s `--git-common-dir` routing (two repos → two DBs → no contamination); `project_context` catches the within-repo re-scope case (same DB, same repo, but the project's conceptual identity has shifted and old-scope beliefs should no longer surface). Schema: `beliefs.project_context TEXT NOT NULL DEFAULT ''` plus `idx_beliefs_project_context`. The empty-string default preserves pre-#858 semantics — legacy rows always pass the filter. Active context is read once per UserPromptSubmit from `$AELFRICE_PROJECT_CONTEXT`; unset or whitespace-only means "no filter" (full backward compat). Filter rule: empty active → no-op; `scope != 'project'` (federation `global` / `shared:*` or user-promoted `user`) bypasses; project-scope rows kept iff `project_context == '' OR project_context == active`. Distinct from `scope` ([#688](https://github.com/robotrocketscience/aelfrice/issues/688) federation visibility) — the two columns answer orthogonal questions and the read-only federation overlay ([#661](https://github.com/robotrocketscience/aelfrice/issues/661)) does not interact with `project_context`. Implemented as a post-`_retrieve()` filter in `hook.py` rather than a SQL WHERE clause pushed into `MemoryStore.search_beliefs`, keeping the L0/L2.5/L1/L3 retrieval-tier matrix trivial and including federation peer hits (`search_peer_beliefs`) under the same scope check. 25 new tests across `tests/test_project_context_field.py` (schema migration on fresh + legacy DB, column default `''`, insert/update round-trip, search round-trip), `tests/test_active_project_context.py` (env-var resolver, whitespace strip, public constant name), and `tests/test_hook_project_context_filter.py` (full filter matrix: legacy cross-context, matching/mismatching active context, user / global / `shared:*` bypass, whitespace-active no-op, order preservation, empty-input fast path). State-file fallback (`.aelfrice/context` at git-common-dir set by an `aelf context set <name>` CLI subcommand) deferred to a follow-up issue; env var alone is sufficient for interactive agent sessions and CI pipelines that set context at startup. Write-side stamping ships in the same PR but is opt-in: callers that want a belief tagged set `b.project_context` before `insert_belief` / `update_belief`; legacy writers fall through to the `''` default unchanged.
Expand Down
Loading
Loading