feat: cross-mission memory store and pattern library#94
Merged
harrymunro merged 4 commits intomainfrom Apr 10, 2026
Merged
Conversation
Add persistent knowledge base that accumulates learnings across missions. Surfaces relevant patterns via intelligence brief before new missions. - Add .nelson/memory/ store with patterns.json and standing-order-stats.json - Add --adopt/--avoid args to stand-down for capturing reusable patterns - Add `brief` command for pre-mission intelligence briefs with context matching - Add `analytics` command with success-rate, standing-orders, efficiency metrics - Auto-extract patterns and violation stats at stand-down - Backfill memory store when running `index` - Fix duplicate code bug in cmd_index() (lines ran outside lock) - Add 21 new tests (87 total, all passing) - Update structured-data.md with new schemas and command docs
nelson-data.py (2557 lines) and test_nelson_data.py (1759 lines) exceeded the 800-line guideline. Split into 5 source modules and 3 test files while preserving backward compatibility: - nelson-data.py: thin CLI entry point (287 lines) - nelson_data_utils.py: shared I/O, validation, constants (261 lines) - nelson_data_memory.py: cross-mission memory store (491 lines) - nelson_data_lifecycle.py: mission lifecycle commands (825 lines) - nelson_data_fleet.py: fleet intelligence + analytics (806 lines) - conftest.py: shared test helpers (171 lines) - test_nelson_data.py: lifecycle tests (620 lines) - test_nelson_data_fleet.py: fleet/analytics/brief tests (719 lines) - test_nelson_data_memory.py: memory store + I/O tests (303 lines) CI updated to discover all test files via pytest directory discovery.
Replace bare open()+try/finally lock pattern with a _file_lock() context manager across all 6 lock sites. Fix mid-file import and replace time.sleep with deterministic mission IDs in tests.
Integrate six PRs merged to main since this branch diverged: - PR #89: formation consolidation (form, headless commands) - PR #90: path-scoped auto-discovery - PR #91: typed handoff packet - PR #92: hook enforcement layer - PR #93: deterministic phase engine - PR #96: task list visibility Port new commands (form, headless, handoff, recover) into the modular architecture. Add phase field support to lifecycle commands for compatibility with the phase engine. All 234 tests pass.
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 #83 — adds a persistent, structured knowledge base that accumulates learnings across Nelson missions.
.nelson/memory/):patterns.jsonaccumulates adopt/avoid patterns from every mission;standing-order-stats.jsontracks violation frequency and correlationsstand-downnow accepts--adoptand--avoidrepeatable flags and auto-updates the memory storenelson-data.py brief): Pre-mission command that surfaces relevant patterns, win rate, standing order hot spots, and context-matched precedents from past missionsnelson-data.py analytics --metric success-rate|standing-orders|efficiency|all): Focused metric queries with text and JSON outputcmd_index()that ran outside the file lockindexnow backfills the memory store for missions completed before the feature existedTest plan
TestStandDownPatterns—--adopt/--avoidargs and defaultsTestMemoryStore— patterns.json creation, accumulation, stats update, non-fatal failure on read-only dir, violation captureTestBrief— empty state, with missions, JSON output, context matchingTestAnalyticsCommand— each metric, all metrics, JSON output,--lastflag, missing index errorTestIndexMemorySync— backfill from index, incremental syncCloses #83