feat: brain-expand pipeline scripts + hardening (closes #18)#23
Merged
Conversation
adds the five scripts that brain-expand references but were previously stubs or missing entirely (issue #18): - run_session_sync.sh: extracts recent Claude/Codex session artifacts into the inbox as timestamped notes with frontmatter - detect_knowledge_gaps.py: scans the knowledge graph for orphan notes, broken wikilinks, and stale content; writes gaps.json - generate_review_queue.py: builds a prioritized review queue from unrouted inbox items older than 24 hours - route_inbox.py: sorts inbox notes into knowledge graph subdirectories based on frontmatter type and tags (supports --apply for dry run) - archive_inbox.py: moves notes older than 30 days to archive/inbox (supports --apply and --days flags) all scripts conform to the JSON stdout contract expected by lacp-brain-expand and pass the existing test suite.
Audit fixes for community PR #21: - run_session_sync.sh: add set -e, fix JSON stdout contract - Extract shared parse_frontmatter() to brain_utils.py (was duplicated 3x) - Replace deprecated datetime.utcnow() with timezone-aware alternative - Add path traversal guard (skip filenames containing ..) - Add scripts/ci/test-brain-automation-scripts.sh (20 tests, exercises all 5 scripts directly with real temp dirs)
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
Implements the 5 missing automation scripts that
brain-expandcalls, based on @w3t-wr3's community contribution in #21 with security hardening and test coverage.Scripts added
run_session_sync.sh— pulls recent Claude/Codex session artifacts into inboxdetect_knowledge_gaps.py— scans knowledge graph for orphans, broken links, stale notesgenerate_review_queue.py— builds prioritized review queue from unrouted inbox itemsroute_inbox.py— sorts inbox notes into knowledge graph subdirectoriesarchive_inbox.py— archives notes older than N daysHardening applied (audit of #21)
run_session_sync.shmissingset -e— errors now halt execution..are skipped beforeshutil.moveparse_frontmatter()to sharedscripts/brain_utils.pydatetime.utcnow()withdatetime.now(timezone.utc)Tests
scripts/ci/test-brain-automation-scripts.sh— 20 tests exercising all 5 scripts directly with real temp directories (session sync, gap detection, review queue, routing dry-run + apply, archiving dry-run + apply, path traversal guard)Closes #18. Based on #21 by @w3t-wr3 — thank you for the contribution.
Test plan
bash scripts/ci/test-brain-automation-scripts.sh— 20/20 passingbash -nsyntax check🤖 Generated with Claude Code