Skip to content

feat: add conversation materialization - #1

Open
Amidwestnoob wants to merge 1 commit into
feat/temporal-claims-upstreamfrom
feat/conversation-materialization
Open

feat: add conversation materialization#1
Amidwestnoob wants to merge 1 commit into
feat/temporal-claims-upstreamfrom
feat/conversation-materialization

Conversation

@Amidwestnoob

@Amidwestnoob Amidwestnoob commented Aug 19, 2026

Copy link
Copy Markdown
Owner

PR draft 2: conversation materialization

Tracks VectifyAI#224

Status

This change is stacked on VectifyAI#223. It is independent of VectifyAI#179.

Summary

Add a small transport-neutral conversation package.

The package converts caller-supplied closed conversation windows into immutable source documents. It keeps source, speaker, authority, time, and evidence identifiers. It writes content hashes, closed-window fingerprints, and a replay-safe manifest.

The caller remains the source of truth. The wiki remains a read-only projection.

Changes

  • Add typed conversation turn and window records.
  • Validate ISO timestamps with UTC offsets.
  • Sort turn and compile times by normalized UTC values.
  • Preserve caller order when normalized turn times are equal.
  • Normalize text with caller-supplied pure hooks.
  • Fail closed for oversize turns.
  • Apply the document limit to final rendered characters.
  • Provide explicit middle truncation with a digest.
  • Deduplicate by (conversation_id, turn_id).
  • Reject conflicting duplicate identities.
  • Split only at turn boundaries.
  • Verify exact ordered turn coverage after every split.
  • Stop before mutation when one pending recovery turn cannot fit.
  • Render deterministic source-document bytes.
  • Store a canonical fingerprint for every closed window, including an empty window.
  • Store a fingerprint for each active document set.
  • Reject a changed normal replay before it writes a new path.
  • Use collision-resistant path tokens.
  • Validate manifest paths, UTF-8 text, timestamps, hashes, windows, and completed hashes.
  • Verify manifest file hashes.
  • Select oldest pending compile inputs without starting compilation.
  • Support custom manifest names during compile selection.
  • Store optional compile receipts by content hash.
  • Validate bounded compile budgets.
  • Re-split only uncompiled documents with a smaller recovery limit.
  • Match recovery turns with the full stable identity.
  • Remove replaced uncompiled files only after the new files and manifest are durable.
  • Use the shared mutation lock for manifest updates and verified claim updates.
  • Apply caller-verified claims through the feat: add temporal claims to wiki pages VectifyAI/OpenKB#223 claims API.

Scope boundaries

This change does not depend on VectifyAI#179. It does not copy the ingest-bundle pipeline.

This change does not add source-specific rules, live input, source data, scheduler wiring, or model calls.

A future VectifyAI#179 adapter can call this materializer.

Tests

The synthetic tests cover cleaning, hook order, explicit truncation, rendered limits, first-turn fit failure, exact split coverage, duplicate handling, UTC ordering, equal-time caller order, empty-window identity, changed segment sets, collision-resistant paths, manifest validation, corrupt UTF-8 text, custom manifest selection, compile receipts, concurrent manifest updates, concurrent claim updates, recovery identity, recovery no-mutation failure, stale-file removal, budget checks, verified authority, and claim idempotence.

Verification receipt

  • Earlier blocking review reproduction: PASS (7 grouped checks reproduced 7 failures)
  • Final review reproduction: PASS (5 checks reproduced 5 failures)
  • Targeted regression tests: PASS (34 passed)
  • Full python -m pytest: PASS (1,320 passed; 2 warnings in existing removal tests)
  • python -m ruff check .: PASS
  • python -m ruff format --check .: PASS (130 files already formatted)
  • python -m mypy on all new modules: PASS
  • git diff --check: PASS
  • tests/test_file_size.py: PASS (5 passed)
  • Untracked-file diff check: PASS
  • Forbidden-string scan: PASS
  • feat: add temporal claims to wiki pages VectifyAI/OpenKB#223 file scope scan: PASS
  • uv build: PASS (source archive and wheel)

Review notes

The package uses shared OpenKB lock, atomic write, frontmatter, and claims helpers. It does not modify openkb/claims.py or openkb/agent/compiler.py from VectifyAI#223.

The deployment values in the public document are examples. They are not code defaults.

Residual risk: A process stop after a recovery file write and before the manifest write can leave an untracked recovery file. It is not selectable. Automatic cleanup is outside this change.

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