feat(ws5): memory/handbook injection seams (context-provider pattern) #43

Merged
amoussa1229 merged 3 commits from feat/ws5-memory-handbook-seams into main 2026-06-23 19:48:14 +00:00
amoussa1229 commented 2026-06-23 01:09:02 +00:00 (Migrated from github.com)

Summary

  • retriever.py: adds save_memory(name, content, *, memory_dir=None) -> Path that writes to a _box-drafts/ review-queue subdirectory (never visible to load_memories); adds memory_dir param to retrieve() for isolated routing in tests and production injection
  • agent_team/nodes/handbook.py (new): load_handbook_conventions(path=None) -> str reads *.md files from the Sea Haven engineering-handbook directory (env SEA_HAVEN_HANDBOOK_DIR or ~/.sea-haven/engineering-handbook); safe no-op contract — returns "" and never raises when dir absent, empty, or unreadable
  • clarifier_llm.py: adds context_provider: ContextProvider | None = None seam to ClaudeClarifier.__init__ and build_claude_clarifier_callables(); provider failure is silently swallowed
  • planner.py: adds context_provider seam to build_plan_prompt() and plan_node(); identical behavior when None
  • coordinator.py: threads context_provider through default_plan_node_factory(); kwarg is only forwarded when non-None to preserve monkeypatched stub signatures in existing tests
  • tests/test_ws5_memory_handbook.py (new): 19 tests covering all five seams

CI status

ruff check clean · pytest -q — 1063 passed

Security notes

  • save_memory rejects names containing /, \\, \x00, or .. (path-traversal guard)
  • load_handbook_conventions hard-caps file count (_MAX_FILES=20) and bytes per file (_MAX_FILE_BYTES=4096) to avoid prompt-stuffing from an oversized handbook dir
  • All provider callables are wrapped in bare except Exception — no untrusted content reaches the exception path

OUTSTANDING (attended — do NOT merge until done)

  • GPT-4.1 cross-family review — mandatory before merge; no Claude self-review counts
  • /sh-security-review — formal security sign-off on the new save_memory path-traversal guard and the handbook file-read caps
  • Live deploy steps (attended, on R720 box):
    • Rsync ~/.sea-haven/engineering-handbook/ from Mac to R720 box (or confirm handbook dir already present)
    • Restart orchestrator systemd unit to pick up new code
    • Smoke-test: confirm load_handbook_conventions() returns non-empty string on the box
    • Optional: seed one real memory file and confirm save_memory → _box-drafts/ round-trip works

Generated by Claude Code

## Summary - **`retriever.py`**: adds `save_memory(name, content, *, memory_dir=None) -> Path` that writes to a `_box-drafts/` review-queue subdirectory (never visible to `load_memories`); adds `memory_dir` param to `retrieve()` for isolated routing in tests and production injection - **`agent_team/nodes/handbook.py`** (new): `load_handbook_conventions(path=None) -> str` reads `*.md` files from the Sea Haven engineering-handbook directory (env `SEA_HAVEN_HANDBOOK_DIR` or `~/.sea-haven/engineering-handbook`); safe no-op contract — returns `""` and never raises when dir absent, empty, or unreadable - **`clarifier_llm.py`**: adds `context_provider: ContextProvider | None = None` seam to `ClaudeClarifier.__init__` and `build_claude_clarifier_callables()`; provider failure is silently swallowed - **`planner.py`**: adds `context_provider` seam to `build_plan_prompt()` and `plan_node()`; identical behavior when `None` - **`coordinator.py`**: threads `context_provider` through `default_plan_node_factory()`; kwarg is only forwarded when non-`None` to preserve monkeypatched stub signatures in existing tests - **`tests/test_ws5_memory_handbook.py`** (new): 19 tests covering all five seams ## CI status `ruff check` clean · `pytest -q` — **1063 passed** ## Security notes - `save_memory` rejects names containing `/`, `\\`, `\x00`, or `..` (path-traversal guard) - `load_handbook_conventions` hard-caps file count (`_MAX_FILES=20`) and bytes per file (`_MAX_FILE_BYTES=4096`) to avoid prompt-stuffing from an oversized handbook dir - All provider callables are wrapped in bare `except Exception` — no untrusted content reaches the exception path ## OUTSTANDING (attended — do NOT merge until done) - [x] **GPT-4.1 cross-family review** — mandatory before merge; no Claude self-review counts - [x] **`/sh-security-review`** — formal security sign-off on the new `save_memory` path-traversal guard and the handbook file-read caps - [x] **Live deploy steps (attended, on R720 box)**: - Rsync `~/.sea-haven/engineering-handbook/` from Mac to R720 box (or confirm handbook dir already present) - Restart `orchestrator` systemd unit to pick up new code - Smoke-test: confirm `load_handbook_conventions()` returns non-empty string on the box - Optional: seed one real memory file and confirm `save_memory` → `_box-drafts/` round-trip works --- _Generated by [Claude Code](https://claude.ai/code/session_01QYp761G9HojkmLqLZrASVi)_
This repo is archived. You cannot comment on pull requests.
No description provided.