Skip to content

Track when experience records were added and used; forget unused ones - #318

Open
DavertMik wants to merge 2 commits into
mainfrom
experience-usage
Open

DavertMik wants to merge 2 commits into
mainfrom
experience-usage

Conversation

@DavertMik

Copy link
Copy Markdown
Contributor

Experience files only grow, and agents cannot tell a recipe that worked yesterday from one recorded months ago. Each record now stores when it was added and when it was last used. Agents see that age, and the compactor removes records nobody ever used.

Spec: docs/superpowers/specs/2026-11-22-experience-usage-tracking-design.md

Format

Every ## FLOW: / ## ACTION: record gets comments under its heading:

## ACTION: open the user menu

<!-- added: 2026-11-02T09:14:00.000Z -->

<!-- used: 2026-11-20T16:40:00.000Z -->
  • added is stamped by writeExperienceFile, the single write path, so new records, compactor rewrites and legacy files all get it.
  • used is set when learnExperience reads the record, or when the same code or flow is recorded again (that covers Navigator, which gets recipes inline). It is day-based: a second use on the same UTC day does not touch the file.
  • markUsed edits only the used comment of the raw file through mdq. Frontmatter and the rest of the file are untouched. A record found in a secondary experience directory is updated where it lives.

Agents see the age

A.1 ## ACTION: open the user menu (used 2 days ago)
A.3 ## ACTION: filter by role (never used, added 9 days ago)

The same appears in inline recipes (## HOW to … (single-step, used 2 days ago)) and in explorbot experience. The comments are stripped from every body sent to an agent, and maxReadLines counts lines without them.

Forgetting

ExperienceCompactor.forgetUnusedRecords() runs first in autocompact and compactAllExperiences. It is deterministic: it drops records whose added is older than experience.forgetUnusedAfterDays (default 15; 0/false keeps them) and that have no used. Records without added are stamped, not deleted. AI compaction keeps the newest used (restoreLastUsed), so a used record does not turn into an unused one.

Notes

  • No prompt wording changed. Agents get the age annotation only.
  • The first start stamps legacy files, which updates their mtime, so the next explorbot compact AI-reviews them once.
  • CLAUDE.md envelope table and docs/reference/configuration.md are updated.

Tests

  • New unit tests for stamping, day-based used, $ in recorded code, secondary directories, TOC ages, forgetting and the used date surviving AI compaction.
  • bun test tests/unit tests/integration: 1999 pass, 1 fail. The failure, ApibotConfigParser environment fallback > enables Langfuse from LANGFUSE_* env vars, fails the same way on main.
  • Touches src/ai/, so the regression gate will queue; it is left for a reviewer to approve.

🤖 Generated with Claude Code

DavertMik and others added 2 commits November 22, 2026 23:30
Each FLOW/ACTION record carries <!-- added --> and <!-- used --> comments
under its heading. A record is used when learnExperience reads it or when
the same recipe is recorded again; the used date updates once per day.
Agents see the age of each record in the experience TOC and inline recipes.
ExperienceCompactor drops records never used within
experience.forgetUnusedAfterDays (default 15) and keeps the last-used date
through AI compaction.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	CHANGELOG.md

This branch is waiting to be deployed

1 waiting deployment
regression — 2a15301a Waiting Nov 22, 2026 by DavertMik via regression #221
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