Skip to content

#611: add context window to memory extractors + environment field + confidence honesty - #620

Open
NOVA-Openclaw wants to merge 8 commits into
mainfrom
issue-611-extraction-context-window
Open

#611: add context window to memory extractors + environment field + confidence honesty#620
NOVA-Openclaw wants to merge 8 commits into
mainfrom
issue-611-extraction-context-window

Conversation

@NOVA-Openclaw

Copy link
Copy Markdown
Owner

Closes #611.

Summary

Adds a ~10-message context window to both memory extractors (per-turn hook + daily/REM batch) with extract-current-only guardrails, environment field extraction, and confidence honesty. Fixes a pre-existing event-INSERT drop bug surfaced during QA.

Changes

  • feat(memory): context window, environment field, confidence honesty (57b33b2)
  • feat(memory-extract): per-turn context assembly in hook (d255ef8)
  • feat(memory-catchup,replay): batch/replay context assembly (1f2ee32)
  • test(docs): automated tests, fixtures, pipeline docs (e462810)
  • fix(memory): restore event_date COALESCE guard in events INSERT (88d76ed)
  • fix(memory-catchup): honor context_window_enabled gate (103e137)
  • test(memory): real-DB integration test for events INSERT (8edc8c5)
  • docs(memory): correct process-input.sh drift, document confidence honesty (f3c901a)

Test results

  • 27 unit + 2 real-DB integration tests PASS at 8edc8c5
  • TC-611-C4 (blockhenge acceptance) verified via LIVE OpenRouter replay — correct interpretation, environment=blockhenge-sarsen-2, zero context-echo
  • Staging (SE-nova-system-test): broader-repo health 125/125 green, P0 hook-load gate PASS, gateway healthy
  • All 3 acceptance criteria met (context window both paths, environment field end-to-end, confidence honesty)

Coverage honesty

Actual #611 coverage = 29 automated tests (27 unit + 2 integration) + manual LLM-behavioral replay. The 94 turn-context tests are a separate unrelated suite.

Follow-ups (non-blocking)

  • nova-mind#616 (bash jq // true cannot detect explicit false)
  • Coverage gaps G1-G3 (TS tests, automated batch/replay path, unused fixture)
  • TC-611-D5 confirmed N/A (no events_archive populator in codebase)

SE Run #718.

Coder and others added 8 commits August 17, 2026 23:31
- Add max_prior_messages (default 10) and context_window_enabled config keys
- Create shared context_window_helper for config, truncation, formatting
- extract_memories.py reads EXTRACTION_CONTEXT_JSON, builds prompt guardrail
- Add environment field to events schema and INSERT
- Add apply_confidence_honesty cap for short no-context messages
- Add events.environment and events_archive.environment columns to schema.sql
- Hot-reload max_prior_messages and context_window_enabled from config
- loadPriorContext fetches last N prior messages from same channel_session
- Pass EXTRACTION_CONTEXT_JSON to extract_memories.py
- Graceful degradation: context fetch failure logs warning and proceeds no-context
- extraction-replay.sh reconstructs same-session prior context from channel_transcripts
- memory-catchup.sh calls extract_memories.py directly with EXTRACTION_CONTEXT_JSON
- Both scripts read shared max_prior_messages / context_window_enabled config
- Add 25 pytest cases covering config, truncation, prompt, confidence, environment
- Add blockhenge-regression and cross-channel-privacy fixtures
- Add REPLAY-PROCEDURE.md for LLM-behavioral TCs
- Update memory-extraction-pipeline.md with context window docs
Keep event_date in vals_list unconditionally and use
COALESCE(%s::timestamptz, NOW()) so placeholders stay symmetric when
event_date is None and src_timestamp is empty. Adds mock-free placeholder
count regression guards.
Gates context assembly in add_to_cache_and_get_context() with
is_context_window_enabled(), matching extraction-replay.sh and handler.ts.
Cache/duplicate detection still runs; context fetch is skipped when disabled.
Uses a scratch-schema copy of public.events and a fresh subprocess to
exercise store_extracted with (a) date omitted + empty src_timestamp and
(b) same with environment populated. Skipped when nova_memory is unavailable.
…e honesty, fix replay log-string reference

- memory/docs/memory-extraction-pipeline.md: intro note, path diagram, §3
  Components, troubleshooting table, and Next Steps all still described
  memory-catchup.sh's pre-#611 broken process-input.sh call path as current
  behavior despite the doc's own opening note claiming it was fixed. Corrected
  all five locations to describe the AS-BUILT #611 behavior (memory-catchup.sh
  calls extract_memories.py directly, passing EXTRACTION_CONTEXT_JSON).
- Added a new "Confidence Honesty (#611)" subsection documenting both the
  prompt-level CONFIDENCE GUIDANCE change and the apply_confidence_honesty()
  post-hoc capping safety net (short-message + no-context gate, trust-level-based
  cap via get_initial_confidence(), owner-entity short-circuit) — previously
  undocumented despite being a #611 deliverable (C7/E1-E6).
- memory/ARCHITECTURE.md, memory/INSTALLATION.md, memory/README.md: same
  process-input.sh drift existed in three more places; corrected to match.
  memory/README.md's older 20-message rolling-context-window section (2026-02-07)
  also cross-referenced against the #611 config-driven window to clarify they
  are related-but-distinct mechanisms, and its stale extract-memories.sh/
  store-memories.sh script-update bullets were annotated as historical (both
  scripts were removed in #174 and do not exist).
- tests/issue-611/REPLAY-PROCEDURE.md: fixed the per-turn-hook verification
  step's log-string reference (handler.ts logs
  '[memory-extract] Loaded prior context messages' with a count field, not
  'Loaded N prior message(s) as context'); added an explicit coverage caveat
  cross-referencing step8-qa-validation.md so this manual procedure isn't
  mistaken for automated coverage.

Per Step 8 QA (Gem, PASS-WITH-NOTES): corrects doc-source drift found during
the #611 documentation pass. No test-coverage overclaims (e.g. '125/125')
existed in-repo docs at 8edc8c5; none required correction.
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.

feat(extraction): pass recent conversation context to extractor + extract environment field for events

1 participant