Skip to content

feat(config): make store_document_text overridable per bank - #2940

Merged
nicoloboschi merged 7 commits into
mainfrom
feat/store-document-text-per-bank
Jul 24, 2026
Merged

feat(config): make store_document_text overridable per bank#2940
nicoloboschi merged 7 commits into
mainfrom
feat/store-document-text-per-bank

Conversation

@nicoloboschi

Copy link
Copy Markdown
Collaborator

Summary

Makes HINDSIGHT_API_STORE_DOCUMENT_TEXT overridable per bank. It was a
static, server-level flag; now a data-minimizing bank (e.g. a GDPR-sensitive
one) can keep only derived facts — documents.original_text NULL,
chunks.chunk_text empty — while other banks on the same deployment retain the
raw source for expansion / re-extraction.

What changed

  • Hierarchical config: store_document_text added to _CONFIGURABLE_FIELDS,
    so it's settable per bank through the config API's generic updates dict
    (same mechanism as audit_log_enabled — no typed-model change needed).
  • Storage path: the per-bank resolved value is threaded from the retain
    orchestrator's resolved config into chunk_storage.store_chunks_batch and
    fact_storage.{upsert_document_metadata, handle_document_tracking, _upsert_document_row}. The new param falls back to the server-level config
    when unset, so non-retain callers (e.g. import) are unchanged.
  • Consistency guards made per-bank so a store-off bank behaves coherently
    (previously these read the global flag):
    • append-mode rejection (retain_batch_async) — resolves per bank only when
      an append is actually requested;
    • recall include_chunks force-off (no raw chunk text to attach);
    • reflect expand tool exclusion (it only reads back raw source text).
  • Docs: the flag is marked hierarchical in configuration.md.

Notes for review

  • The server-defaults response (/config-style) intentionally still reports the
    global default — the per-bank value lives on the bank config.
  • The existing global-flag tests now also set the ConfigResolver global
    snapshot: the resolver snapshots the global layer at construction, so flipping
    the env var alone is not enough for a hierarchical field (mirrors the existing
    enable_audit_default helper).

Test plan

  • test_store_document_text.py::test_store_document_text_per_bank_override
    one bank set store_document_text=false, one left default: the first drops
    raw doc/chunk text (facts still stored), the second keeps it. Real Postgres.
  • test_store_document_text_is_bank_configurable — the field is in the
    configurable set.
  • Existing global on/off, append-rejection, HTTP-null-text, and reflect
    expand-tool tests still pass (fixture updated for the hierarchical layer).
  • test_retain.py mock-LLM suite green (orchestrator threading unaffected);
    ruff + ty clean.

HINDSIGHT_API_STORE_DOCUMENT_TEXT was static/server-level. Make it hierarchical
so a data-minimizing bank (e.g. GDPR-sensitive) can keep only derived facts
while other banks on the same deployment retain the raw source.

- Add store_document_text to _CONFIGURABLE_FIELDS (settable per bank via the
  config API's generic updates dict, like audit_log_enabled).
- Thread the per-bank resolved value into the retain storage path
  (chunk_storage.store_chunks_batch + fact_storage.upsert_document_metadata /
  handle_document_tracking / _upsert_document_row) from the orchestrator's
  resolved config; falls back to the server-level config when unset so
  non-retain callers (import) are unchanged.
- Make the three consistency guards per-bank too so a store-off bank behaves
  coherently: append-mode rejection, recall include_chunks force-off, and the
  reflect 'expand' tool exclusion.
- Docs: mark the flag hierarchical.

Covered by a per-bank override test (one bank off, one default-on) + a
configurable-fields guard; existing global-flag tests set the ConfigResolver
global snapshot (env alone no longer suffices for a hierarchical field,
mirroring enable_audit_default).
…tes & UI

- BankTemplateConfig gains store_document_text and audit_log_enabled so bank
  templates can preset them; regenerated bank-template-schema.json.
- Control-plane bank config: new 'Document Storage' tri-state section
  (Inherit / On / Off), mirroring the audit toggle; translations added across
  all 10 locales (non-en use English placeholders pending translation).

Backend template round-trip + messages parity/used-keys + tsc all green.
…ivacy' section

Combine the separate Audit Logging and Privacy config sections into a single
Security & Privacy section with both tri-state toggles and one save (writes
audit_log_enabled + store_document_text together). Drop the now-unused
section-level message keys across all locales; add securityPrivacy* keys.
store_document_text became bank-configurable, so get_config().store_document_text
now raises ConfigFieldAccessError (the guard forcing per-bank resolution). The
storage functions' None-fallback hit that guard, breaking every direct/delta
caller that didn't pass the value (test_chunk_storage_upsert, test_delta_retain).

Fall back to _get_raw_config() instead — the unguarded global layer the
ConfigResolver and the /config defaults response already use. The retain path
still passes the per-bank resolved value; only non-retain callers hit the
fallback.
…ig fields

Adding store_document_text/audit_log_enabled to BankTemplateConfig changed the
OpenAPI schema; regenerate the spec, Go/Python/TS client models, and docs-skill
copies, and apply lint formatting (verify-generated-files).
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