Skip to content

fix(CF-5, CF-8, CF-10, CF-15): GM-assistant follow-up — knowledge corrections, phase-4 panels, story attribution - #154

Merged
spuentesp merged 9 commits into
masterfrom
gap/wave1-integration
Nov 13, 2026
Merged

spuentesp merged 9 commits into
masterfrom
gap/wave1-integration

Conversation

@spuentesp

@spuentesp spuentesp commented Nov 13, 2026 •

Copy link
Copy Markdown
Owner

What

Post-#147 follow-up for the GM-assistant wave (7 commits on gap/wave1-integration):

  • Knowledge corrections, end to end (CF-5/CF-8/CF-15): the inspector's Challenge flow can retract an attribution or correct a statement; accepting runs it through CanonKeeper across MongoDB + Qdrant + fact properties with a checkpointed, retryable multi-store write (prepare_knowledge_memory_change / apply_knowledge_correction). Staged challenges detect stale attributions and refuse to apply over changed text; knowledge_excluded is honored by fact_visible_to, the audit, and the pending-proposal queue.
  • Auto-reconciler for interrupted corrections (CF-8/CF-15): the multi-store write is not one transaction, but a periodic sweep (monitor_ui/correction_reconcile.py, MONITOR_CORRECTION_RECONCILER_INTERVAL — 60 s default, 0 disables) now completes accepts whose writes were cut off, with no manual retry. A correction whose target moved under it is marked knowledge_reconciliation_error for a human instead of looping; a reconciled contradiction override still lands its G08 audit row.
  • G02 phase 4 (CF-10): segment review UI in the recorder (play a segment, edit text, map speaker, queue as entry); collision-proof upload keys; failed transcriptions clean up their stored recording.
  • G09 phase 4 (CF-15): paginated knowledge inspector (offset/next_offset through tool → agent → route → UI) with retract/correct challenge dialogs.
  • Review-panel fixes (CF-5/CF-8): batch verdicts (by ids and by filter) route through accept_proposal so a batch accept cannot sidestep the G08 override requirement; the by-filter path owner-checks each match; _resolve_review_flags merges flags instead of dropping them.
  • P3.2(b) — story attribution from scratchpad ingest (CF-8/CF-15): notes ingested during a recorded session stamp the recording's story_id onto the ingestion job and every proposal the pack materializes (explicit on apply, inherited from the job otherwise), so story-scoped review sees them alongside the ingest listing.
  • Docs/close-out (DOC-1): handoff + status refresh, P3.2(b) closed in the plan trackers, MONITOR_PROVIDER_KEY_ENCRYPTION_KEY documented in env.example.

Verified

  • Full backend: uv run pytest packages tests -q -n auto — 10,416 passed, 236 skipped (includes the P3.2(b) tests, the reconciler tests, and the general knowledge-correction lifecycle behaviour test: staging → retract/correct across memory/fact/proposal → interruption → auto-reconcile → stale-attribution refusal).
  • Full frontend: npx vitest run — 581 passed (88 files; includes the story-reporting test).
  • ruff check, mypy (486 source files), tsc --noEmit, check_layer_dependencies.py — all clean.
  • Live knowledge-correction pass lives in tests/contracts/test_knowledge_correction_live.py (RUN_INTEGRATION=1; passed earlier against Neo4j/Mongo/Qdrant + the embedding service).

Sebastian added 9 commits November 12, 2026 00:39
…GM panel follow-ups

Review fixes and phase-4 work on top of PR #147:

- Knowledge corrections: retract or correct a character's attribution
  through CanonKeeper across MongoDB + Qdrant + fact properties, with a
  retryable checkpoint (prepare_knowledge_memory_change /
  apply_knowledge_correction); stale staged challenges are detected instead
  of applied over changed text, and knowledge_excluded is honored by
  fact_visible_to, the audit, and the proposal queue.
- G02 phase 4: segment review UI in SessionRecorder (play, edit text, map
  speaker, queue as entry), collision-proof upload keys, cleanup on failed
  transcription.
- G09 phase 4: paginated knowledge inspector (offset/next_offset through
  tool, agent, route, UI) with retract/correct challenge dialogs.
- Review panel: batch verdicts (by ids and by filter) route through
  accept_proposal so a batch accept cannot sidestep the G08 override; the
  by-filter path owner-checks each match; _resolve_review_flags merges
  flags instead of dropping them.
Scratchpad notes ingested during a recorded session now attribute their
proposals to the recording's story — dual attribution (recording story +
ingest job) so the story-level review lane sees them:

- SessionRecorder reports the active recording's story to the GM page;
  the scratchpad's Ingest button sends it as story_id on the upload.
- The upload route validates and ownership-checks story_id and threads it
  through _run_ingest_in_thread -> IngestionPipeline.ingest_file.
- ingest_file stamps story_id on the ingestion job (both create paths).
- mongodb_apply_knowledge_pack stamps story_id on every proposal it
  materialises, from the request or inherited from the job via the pack —
  covering both the analyzer auto-apply and the delayed manual apply.
- bulk_enqueue_proposals carries the same stamp on the retag path.
- GM_ASSISTANT_MODE_PLAN / FORGE_EXPANSION §17: P3.2(b) marked done.
- STATUS.md / HANDOFF.md: record the story-attribution follow-up and the
  enabled provider-key encryption (key generated into .env; re-save keys
  with the stack up to encrypt pre-existing rows).
- env.example: document MONITOR_PROVIDER_KEY_ENCRYPTION_KEY.
Accepting a correction writes MongoDB + Qdrant + fact properties and then
the verdict; a crash in between used to require a manual accept-retry.
A periodic sweep (monitor_ui/correction_reconcile.py, every
MONITOR_CORRECTION_RECONCILER_INTERVAL seconds — 60 by default, 0
disables) now completes those accepts on its own:

- mongodb_find_interrupted_corrections / mongodb_mark_correction_stalled
  scan for checkpointed accepts without an applied verdict.
- The checkpoint proves review gating already passed, so reconciliation
  finishes the write + verdict like the original accept — including the
  G08 override audit row when a contradiction was overridden.
- A correction whose target moved under it is marked
  knowledge_reconciliation_error for a human instead of looping.

Tests: hermetic reconciler finish/idempotence/stall cases plus mongomock
unit tests for the scan tools. Full suite 10,409 passed, 236 skipped.
…iour test

One end-to-end rule on the hermetic stack: a challenged attribution is
retracted or corrected and lands in every store the character's knowledge
is read from (MongoDB, Qdrant, fact visibility, the pending-proposal
queue) — completely, never half. Covers staging via KnowledgeAuditAgent
(challenge records the original statement), memory retract/correct, fact
retract, proposal retract, an accept cut off mid-write finished by the
auto-reconciler (idempotent), and a stale attribution refused rather than
applied over.
@spuentesp
spuentesp merged commit b80ed01 into master Nov 13, 2026
5 checks passed
@spuentesp
spuentesp deleted the gap/wave1-integration branch November 13, 2026 05:56
spuentesp added a commit that referenced this pull request Nov 13, 2026
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