Skip to content

fix(evolve): harden indexer edge cases - #681

Merged
baleen37 merged 1 commit into
mainfrom
crisp-panda-sagan
Jun 2, 2026
Merged

fix(evolve): harden indexer edge cases#681
baleen37 merged 1 commit into
mainfrom
crisp-panda-sagan

Conversation

@baleen37

@baleen37 baleen37 commented Jun 2, 2026

Copy link
Copy Markdown
Owner

Summary

  • Harden evolve build-index argument validation for confusing edge inputs
  • Normalize skill body line endings and improve skill/session matching behavior
  • Filter additional harness context markers from user improvement signals

Changes

  • Reject duplicate singleton flags and path-like --session/--skill values with clear errors
  • Return friendly errors for missing or directory positional transcript paths
  • Support user-facing namespaced --skill values while preserving exact colon skill names
  • Treat CRLF/CR/LF skill bodies equivalently for stale detection
  • Add regression coverage for edge cases found by direct indexer calls

Tests

  • bats tests/me/evolve-build-index.bats (54/54 pass)

Summary by CodeRabbit

  • Bug Fixes

    • Improved skill detection accuracy and event attribution
    • Fixed transcript processing to exclude system context markers
    • Enhanced stale detection for transcripts with different line-ending formats
  • Refactor

    • Strengthened command-line argument validation with clearer error messages

@baleen37
baleen37 enabled auto-merge (squash) June 2, 2026 05:11
@coderabbitai

coderabbitai Bot commented Jun 2, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8587f39d-44f9-4f97-b57a-6b8d15f11750

📥 Commits

Reviewing files that changed from the base of the PR and between 09b6abd and 96e9bd6.

📒 Files selected for processing (2)
  • plugins/me/skills/evolve/scripts/build-index.ts
  • tests/me/evolve-build-index.bats

📝 Walkthrough

Walkthrough

This PR strengthens the skill-indexing pipeline with cross-platform transcript normalization, refactors skill-session discovery to support candidate-based matching, and enforces stricter CLI argument validation. Changes improve stale detection, event attribution, pseudo-user filtering, and input error reporting.

Changes

Skill Indexing Robustness and Argument Validation

Layer / File(s) Summary
Cross-platform newline normalization and base-dir extraction
plugins/me/skills/evolve/scripts/build-index.ts, tests/me/evolve-build-index.bats
Introduces LINE_BREAK constant and updates base-dir extraction and bodyHash to normalize \r\n and \r to \n before hashing. Adds regression tests verifying CRLF and CR-only injected bodies match LF disk bodies (stale == false).
Pseudo-user marker filtering
plugins/me/skills/evolve/scripts/build-index.ts, tests/me/evolve-build-index.bats
Adds <system-reminder> and <ide-context> to pseudo-user prefixes so harness-injected context markers are excluded from user event emission. Test validates only real user messages appear in user events.
Skill event attribution with fallback matching
plugins/me/skills/evolve/scripts/build-index.ts
Skill events now prefer direct ev.name matches against invoked skill hashes, but fall back to colon-suffix-derived names when direct matches fail, changing acc.*.eventsByHash population for skills.
Skill session discovery refactor with multi-candidate support
plugins/me/skills/evolve/scripts/build-index.ts, tests/me/evolve-build-index.bats
Introduces skillNameCandidates() and findSkillSessionPaths(names, n) to filter recent sessions by transcript content match using stricter boundary regex. Tests verify prefixed skill names (e.g., me:evolveevolve) and exact colon names (e.g., foo:bar does not match bar).
Strict CLI argument parsing and validation
plugins/me/skills/evolve/scripts/build-index.ts, tests/me/evolve-build-index.bats
Rewrites parseArgs to enforce single-use of flags, reject path separators and .jsonl in --session/--skill, validate --recent as positive integer, and prevent --session combined with transcript path. Adds comprehensive validation tests for all error cases with specific exit codes and error substrings.
--skill execution flow with candidate-based filtering
plugins/me/skills/evolve/scripts/build-index.ts
Updates --skill path to attempt exact matching first, fall back to candidate names, and filter output index.skills and headline counts to resolved candidates, with --recent 2 tests enforcing exact session aggregation.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • baleen37/bstack#675: Both PRs modify skill invocation hashing, normalization, and stale/currentness body-hash logic.
  • baleen37/bstack#672: Both PRs update transcript-tail stripping and base-directory matching for cross-project skill discovery.
  • baleen37/bstack#664: Both PRs touch the same /me:evolve indexing pipeline and build-index scripts, with this PR providing incremental enhancements.

Poem

🐰 The base directories now align,
Cross-platform newlines finally shine,
Pseudo-users fade from view,
Candidates bloom—both old and new,
CLI gates stand strict and true,
Indexing flows clean through and through! 🌳

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch crisp-panda-sagan

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@baleen37
baleen37 merged commit 3d54f3b into main Jun 2, 2026
4 of 5 checks passed
@baleen37
baleen37 deleted the crisp-panda-sagan branch June 2, 2026 05:11
baleen-release-app Bot pushed a commit that referenced this pull request Jun 2, 2026
## [17.21.1](v17.21.0...v17.21.1) (2026-06-02)

### Bug Fixes

* **evolve:** harden indexer edge cases ([#681](#681)) ([3d54f3b](3d54f3b))
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.

1 participant