altk-evolve icon indicating copy to clipboard operation
altk-evolve copied to clipboard

Redesign evolve-lite: no hooks, no custom modes — native memory + EVOLVE.md

Open illeatmyhat opened this issue 5 months ago • 3 comments

Redesign evolve-lite: no hooks, no custom modes — native memory + EVOLVE.md

This PR replaces evolve-lite's hook- and custom-mode-driven machinery with a self-directed, native-memory methodology. Recall and save are now the agent's own native behavior; evolve adds only the two things native memory lacks — sharing (mirror into a shared .evolve/ store) and provenance (measure whether recalled guidance actually influenced a session) — delivered as an always-on EVOLVE.md instruction plus a few explicit skills. No background hooks fire; nothing is a no-op.

Per platform:

  • Bob — full EVOLVE.md as a global rules file (~/.bob/rules/00-evolve-lite.md); custom-mode merge dropped. No native memory, so recall/save are self-directed straight into the shared .evolve/entities/ store.
  • Codex — single always-read pointer in ~/.codex/AGENTS.md → ~/.codex/evolve-lite/EVOLVE.md; UserPromptSubmit/SessionStart hooks dropped. Like Bob, self-directs recall/save into .evolve/entities/.
  • Claude — thin EVOLVE.md delivered via a single @.evolve/EVOLVE.md import line in the repo's CLAUDE.md; all auto-firing hooks removed. Native memory owns recall/save; evolve adds mirror-on-save (into the same .evolve/entities/ store) + audit-on-recall.

"Memory" and "entity" are the same thing: there is one store, .evolve/entities/<type>/<name>.md (typed dir + a trigger line), that recall, learn, provenance, sync, publish, and subscribe all speak. On Bob/Codex, recall is framed as an explicit first action ("before reading source or running anything, check .evolve/entities/") with the audit folded into it — passive phrasing is reliably skipped by some hosts.

It also closes the provenance loop deterministically (recall → entity → trajectory → recorded verdict) on all three platforms, with native-transcript awareness so it works in the hookless world. Each host's saved transcript is located by its own scheme: Claude ~/.claude/projects/<slug>/<sid>.jsonl, Codex ~/.codex/sessions/.../rollout-<ts>-<sid>.jsonl, and Bob ~/.bob/tmp/<sha256(projectpath)>/chats/session-<ts>-<sid8>.json. Bob exposes no session-id env var, so audit_recall.py recovers the real sessionId from that chat file (gated on BOBSHELL_CLI, inert elsewhere) and provenance matches the trajectory by it.


For human reviewers — get your agent to test this with you

This change is mostly agent-facing plumbing (install scripts, skills, an always-on instruction file, audit/provenance flow). The fastest way to review it is to hand this PR to your coding agent and have it drive the checks while you watch. Suggested prompt to your agent:

"We're reviewing this evolve-lite redesign PR. Check out the branch, then:

  1. Run the platform-integrations test suite and summarize pass/fail.
  2. Install evolve-lite for my platform into a throwaway temp project and show me what files it created/changed (especially the always-on instruction and any line injected into my agent config).
  3. Walk me through the provenance loop end-to-end on a fake .evolve/ so I can see a recall row turn into a recorded influence verdict.
  4. Confirm uninstall cleanly removes everything it added. Explain each step in plain language before you run it, and stop if anything touches a path outside the temp project or my real config."

What you (the human) should personally confirm:

  • Blast radius of install. The Claude installer injects one @.evolve/EVOLVE.md line into your repo's CLAUDE.md, and Bob/Codex write an always-on instruction to your global agent config (~/.bob/rules/, ~/.codex/AGENTS.md). Make sure you're comfortable with that before running a real (non-dry-run) install.
  • The one-time Claude import approval. On Claude, the @import needs a per-project "allow external imports" approval. If you (or a past session) decline it, the import silently disables and evolve becomes a no-op with no error. The new doctor skill detects exactly this — run it and confirm it reports OK after you approve.
  • Nothing fires on its own. There are no more recall/save/learn hooks. Recall and save are your agent's native judgment; the evolve steps are explicit. If you expected automatic background behavior, that's intentionally gone.

Quick manual smoke test (safe, no real config touched):

# Test suite (CI-equivalent filter)
uv run pytest tests/platform_integrations/ -q

# Dry-run an install so nothing is written
bash platform-integrations/install.sh install --platform claude --dir /tmp/evolve-demo --dry-run

Testing the live cascade with your agent

Objective: confirm evolve actually captures a memory in a real session and mirrors it into the shared .evolve/ store — then, on a second run, that the recall gets audited. The sandboxed plumbing is covered by the test suite; what you're checking here is the soft, live "loaded ≠ obeyed" layer.

Install for your platform into a throwaway repo, then give your agent a real task with a non-obvious gotcha — an empty repo teaches it nothing, so nothing is worth saving. A reliable shape: a uv-managed project whose tests fail for a non-obvious reason (e.g. a generated-but-uncommitted fixture). Ask it to get the tests passing and to note anything non-obvious for next time, then check that an entity appears under .evolve/entities/.

Pitfalls worth avoiding — otherwise trust the agent:

  • Don't name evolve's skills or scripts in your prompt. The always-on EVOLVE.md is meant to drive the mirror on its own; naming it invalidates the test.
  • Nudge the save. Memory saves on the agent's own judgment — a plain "remember this for next time" reliably triggers it; a bare task usually won't.
  • On Claude, recall and save are native and evolve only adds mirror + audit + provenance — there's no recall step to look for. On Codex/Bob (no native memory) the always-on EVOLVE.md self-directs recall/save straight into .evolve/entities/ — the agent checks the store as a first action and writes a typed entity, rather than you invoking a skill.

For the recall half, run a second session in the same repo that hits the same wall — it should consult the saved entity and log a recall row, which provenance then closes (entity and trajectory resolve on all three platforms). Finish by confirming uninstall reverses everything (it also sweeps legacy pre-redesign installs). The installer auto-allowlists evolve's own scripts, so a real install shouldn't prompt on the mirror/audit steps.


For agents working on this PR

Read this section before editing anything.

Source of truth: edit plugin-source/, never the rendered tree

platform-integrations/{claude,claw-code,codex,bob}/... is generated output. Do not hand-edit it — your change will be overwritten and the drift gate will fail. Edit the templates/scripts under plugin-source/, then regenerate:

uv run python plugin-source/build_plugins.py render   # rewrite platform-integrations/
uv run python plugin-source/build_plugins.py check    # MUST exit 0 (no drift)
  • *.j2 files render through Jinja2 per platform ({{ platform }} + macros in plugin-source/_macros.j2).
  • Non-.j2 scripts (e.g. provenance.py, log_influence.py, adapt_memory.py, doctor.py) are copied verbatim to all four platforms, so one edit fans out to all of them.
  • The shared lib lives at plugin-source/lib/ and renders into lib/evolve-lite/ on every host. Scripts resolve it by walking up to lib/evolve-lite/entity_io.py; that resolution only works in the rendered tree, so integration tests run the rendered Claude copy.
  • Three EVOLVE.md variants exist (Claude is thin/native; Bob+Codex are the full self-directed methodology). When touching skill scripts, remember the bob path is structurally different (.bob/skills/evolve-lite-<name>/, colon-free on disk).

Required gate before any commit

The pre-commit gate runs more than pytest. All of these must pass:

uv run ruff check .
uv run ruff format --check .
uv run mypy .
uv run python plugin-source/build_plugins.py check   # render drift
uv run pytest tests/platform_integrations/ -q        # default CI filter

Notes:

  • mypy excludes plugin-source/ and platform-integrations/, but not tests/ — typed test code is checked.
  • Any module-level import after a sys.path.insert needs # noqa: E402.
  • After a sys.path shim, scripts import the shared lib (entity_io, audit) by bare name; keep that pattern.

Test layout

  • Tests live in tests/platform_integrations/ and are marked platform_integrations (+ sometimes e2e/llm).
  • CI runs the default filter -m 'not llm and not e2e' (~270 of ~430 collected). Sandboxed, fast tests (doctor, provenance, the end-to-end chain, the per-platform trajectory locators) deliberately ship without the e2e marker so they run as guards in the default suite. Don't re-add e2e to a fast sandboxed test.
  • conftest.py sandboxes HOME for every test (so installs never touch real ~/.bob, ~/.codex, ~/.claude). Reuse temp_project_dir, sandbox_home, and the *_audit_script / *_evolve_md fixtures rather than building paths by hand.
  • The native-transcript locator builds ~/.claude/projects/<slug>/<sid>.jsonl where <slug> slugifies the resolved project root (every non-alphanumeric → -). The same slug logic lives in doctor.py; keep the two in sync.

Provenance: keep the verdict agent-driven

provenance.py does only deterministic work — read recall rows, skip already-influenced pairs, resolve <type>/<name> entity files, locate the trajectory, emit JSONL candidates (gaps surfaced via a missing:[...] field, never dropped), and persist a verdict via the existing log_influence writer. The semantic verdict (followed/contradicted/not_applicable) is an LLM judgment and must stay agent-driven. Do not invent a heuristic verdict. If you can't separate the judgment from the plumbing, stop and flag it rather than faking it.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Mirror native memories into a shared, auditable evolve store (idempotent, deterministic writes)
    • Record which memories were consulted via a recall-audit CLI (prints session token when minted)
    • Generate provenance candidates and record single-verdict provenance entries
    • Add a diagnostic "doctor" command to verify evolve import delivery
  • Documentation

    • New/rewritten guides for adapt-memory, provenance, and doctor workflows
  • Chores

    • Installer now deploys per-platform evolve files, managed pointer lines, and global audit scripts

illeatmyhat avatar Jun 09 '26 11:06 illeatmyhat

Review Change Stack

[!NOTE]

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • [ ] ▶️ Resume reviews
  • [ ] 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds per-platform EVOLVE docs and audit scripts, deterministic entity IO and adapt/doctor/provenance CLIs, installer managed-pointer/global-script delivery, and wide test updates including end-to-end provenance validation.

Changes

Evolve-lite memory, audit, and provenance workflow

Layer / File(s) Summary
Rendered EVOLVE docs and audit CLIs
platform-integrations/*/EVOLVE.md, plugin-source/EVOLVE.md.j2, platform-integrations/*/lib/evolve-lite/audit_recall.py, plugin-source/lib/audit_recall.py
Adds per-platform EVOLVE docs and a portable audit_recall.py CLI to record recall events into .evolve/audit.log; build context exposes audit_script to templates.
Entity IO and adapt-memory/doctor
platform-integrations/*/lib/evolve-lite/entity_io.py, platform-integrations/*/skills/evolve-lite/adapt-memory/..., platform-integrations/*/skills/evolve-lite/doctor/..., plugin-source/lib/entity_io.py
Introduces sanitize_type, preserves native_path in frontmatter, and extends write_entity_file(directory, entity, filename=None, overwrite=False) with deterministic overwrite=True behavior; adds adapt_memory.py to mirror native memories and doctor.py to validate Claude import delivery.
Provenance candidate and record flow
platform-integrations/*/skills/evolve-lite/provenance/*, plugin-source/skills/evolve-lite/provenance/*
Adds provenance.py with candidates (emit JSONL candidates per unresolved (session,entity)) and record (validate and append deduplicated influence rows); trajectory resolution checks .evolve/trajectories/ then native Claude transcripts.
Installer and managed-pointer delivery
platform-integrations/install.sh, plugin-source/build_plugins.py
Installer gains marker/sentinel helpers and shifts Bob/Claude/Codex to managed-pointer delivery: writes per-platform EVOLVE copies or global EVOLVE files, injects/removes managed pointer lines, installs global audit-recall scripts, and removes old Codex hook-group wiring.
Tests: fixtures, integration, and e2e
tests/platform_integrations/*
Adds sandboxed HOME fixture, unit tests for marker-line ops, audit_recall tests, entity_io/adapt e2e tests, provenance candidates/record integration tests, and updates installer/idempotency/preservation tests to the new managed-delivery contract.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant AdaptScript
  participant EntityStore
  participant AuditScript
  participant Provenance
  participant TranscriptStore
  User->>AdaptScript: mirror native memory (file path, --type, --trigger)
  AdaptScript->>EntityStore: write entity (type/slug + native_path)
  User->>AuditScript: record consulted entity ids
  Provenance->>AuditScript: read recall events
  Provenance->>TranscriptStore: locate transcript for session_id
  Provenance->>EntityStore: read entity excerpt

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related issues

  • AgentToolkit/altk-evolve#219: The PR implements the unified plugin-source + build pipeline and cross-platform render changes referenced by this issue.

Possibly related PRs

Suggested reviewers

  • visahak
  • vinodmut

Poem

"I’m a rabbit with a tiny pad,
I hop through memories, not so bad. 🐇
I stamp a log and mirror a thought,
Then provenance finds what time has taught.
Hooray for audits neatly had!"

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • [ ] Create PR with unit tests
  • [ ] Commit unit tests in branch redesign/evolve-lite-no-hooks-modes

coderabbitai[bot] avatar Jun 09 '26 11:06 coderabbitai[bot]

No vulnerabilities found.

agent-toolkit-owl avatar Jun 09 '26 12:06 agent-toolkit-owl

Re: CodeRabbit's Critical — Claude-only doctor skill copied into the Codex (and Bob) plugins (commit 5196fff)

Agreed the diagnostic is Claude-specific: it greps ~/.claude/projects/<slug>/*.jsonl transcripts for the @import canary and checks .claude/CLAUDE.md paths — none of which exist where there's no @import (Codex uses an ~/.codex/AGENTS.md pointer instead). Rather than ship a stub Codex health check with no real signal, we exclude doctor from the codex and bob plugins at build time:

  • Added target_excludes = [r"^skills/evolve-lite/doctor/"] to the codex and bob entries in plugin-source/build_plugins.py PLATFORMS (matched against the source-side path, pre-rewrite, so it also covers bob's flattened skills/evolve-lite-doctor/).
  • Fixed _bob_command_targets() to honor target_excludes — it previously walked _discover_skills() unconditionally and would still emit commands/evolve-lite-doctor.md for bob (drift).
  • Updated test_build_pipeline.py::TestBobCommandGeneration to derive the expected command set from _bob_command_targets() and assert doctor is excluded.

doctor is kept for claude and claw-code (claw-code is a claude-code fork reusing the same @import/.claude-plugin mechanics). Full gate green (ruff/format/mypy/drift-check + 252 tests).

illeatmyhat avatar Jun 09 '26 16:06 illeatmyhat