Skip to content

Draft: runtime-validated non-destructive reconstruction workflow for ChromaDB 1.x - #25

Draft
apajon wants to merge 30 commits into
mainfrom
split/reconstruction-experimental
Draft

Draft: runtime-validated non-destructive reconstruction workflow for ChromaDB 1.x#25
apajon wants to merge 30 commits into
mainfrom
split/reconstruction-experimental

Conversation

@apajon

@apajon apajon commented Apr 17, 2026

Copy link
Copy Markdown
Owner

Summary

This draft PR isolates the reconstruction workflow for rebuilding a ChromaDB 0.6.x palace into a separate ChromaDB 1.x target.

This is still not a claim of universal 1.x support.
This is not an in-place migration path.
This is a non-destructive, explicitly validated reconstruction path with bounded guarantees.

The key change from the earlier framing is this:

reconstructed 1.x targets are now validated not only structurally, but also at real MemPalace MCP runtime level within the tested scope.

In other words, this branch is no longer just an exploration lab.
It now demonstrates a controlled reconstruction workflow that can produce runtime-usable 1.x targets, while preserving the source palace and failing explicitly on invalid inputs.


Base / dependency

This branch is currently stacked on top of:

  • split/mcp-json-migration

That keeps the reconstruction work aligned with the current stable configuration baseline while remaining isolated from the conservative stable-path contract.


What’s included

  • palace format detection
  • stable-path palace safety gate
  • .mcp.json migration work
  • ChromaDB 1.x exploration findings
  • reconstruction prototype
  • neutral reconstruction bundle format
  • structural validation
  • retrieval / usage comparison tooling
  • runtime compatibility guardrails
  • real MCP runtime validation tooling
  • adversarial robustness harness
  • structured reconstruction diagnostics
  • experimental workflow docs

What this branch now demonstrates

1. Non-destructive reconstruction

  • source palace is preserved
  • reconstruction always targets a separate 1.x palace
  • no destructive in-place migration is introduced

2. Runtime-valid reconstructed targets within tested scope

Reconstructed 1.x palaces have been validated against native 1.x palaces at multiple levels:

  • structural parity
  • document / metadata parity
  • embedding parity
  • retrieval parity
  • MCP runtime parity

In the tested scope, reconstructed 1.x targets were indistinguishable from native 1.x targets at real MCP runtime level:

  • same tools exposed
  • same queries
  • same results
  • no semantic differences observed

3. Explicit runtime mismatch handling

This branch also formalizes a failure mode that previously produced misleading results:

  • 0.6.x and 1.x runtime stacks can be mixed accidentally
  • this can produce failures such as _type / masked “No palace found” behavior
  • the branch now detects and surfaces those mismatches explicitly

4. Safe failure model

Adversarial and invalid inputs were exercised to ensure the reconstruction path does not fail ambiguously:

  • no silent corruption observed
  • invalid inputs rejected explicitly
  • low-level SQLite failures wrapped into structured reconstruction errors

What this branch does not claim

This PR does not claim:

  • universal compatibility with all historical MemPalace palaces
  • support for all real-world datasets
  • automatic repair of corrupted sources
  • that all ChromaDB / MemPalace version combinations are supported
  • that the reconstruction path should replace the stable conservative 0.6.x path today

This remains a bounded reconstruction workflow, not a blanket 1.x support declaration.


Stable vs experimental contract

Stable path

The existing stable path remains conservative and 0.6.x-oriented.

Experimental / reconstruction path

This branch adds a separate reconstruction workflow for producing validated 1.x targets, with:

  • explicit runtime targeting
  • explicit diagnostics
  • validation-first workflow
  • no source mutation

This keeps the stable support contract narrow while allowing the reconstruction path to mature independently.


Validation performed

Test suite

  • pytest tests/

Reconstruction validation

Validated on controlled fixtures with:

  • structure checks
  • retrieval checks
  • usage comparison
  • runtime compatibility checks

MCP runtime validation

Validated through real MemPalace MCP server behavior:

  • server startup
  • tool exposure
  • tool calls
  • query execution
  • same observable behavior vs native 1.x palaces in the tested scope

Adversarial robustness

Tested against invalid / hostile cases such as:

  • corrupted SQLite files
  • wrong schema inputs
  • duplicated identifiers
  • inconsistent metadata
  • malformed / rejected inputs

Observed result:

  • no silent corruption
  • explicit structured failures
  • no uncontrolled hard failures in the tested adversarial matrix

Reviewer focus

Please review:

  1. whether the reconstruction workflow is correctly isolated from the stable path
  2. whether the current guarantees are stated precisely enough
  3. whether the runtime-validation claims are appropriately bounded
  4. whether the safety / failure model is clear enough for future users
  5. whether this should remain a long-lived draft branch or be split further before merge

Why this is still a draft

This branch proves much more than the original exploration framing, but it is still draft because the support boundary must remain explicit.

What is proven:

  • safe non-destructive reconstruction
  • runtime-usable reconstructed 1.x targets in tested scope
  • explicit runtime mismatch detection
  • no silent corruption in tested adversarial cases

What is not yet claimed:

  • universal migration support
  • broad real-world compatibility across all legacy palaces
  • replacement of the conservative stable path

Expected outcome

This branch should be treated as:

  • a serious reconstruction path with real validation
  • a bounded migration workflow
  • a safer foundation for future 1.x support work

It should not be read as:

  • “everything about ChromaDB 1.x is now solved”
  • “stable support contract has been widened”
  • “all MemPalace data can now be migrated automatically”

apajon and others added 17 commits April 17, 2026 11:57
Add a conservative palace detector that classifies a palace as chroma_0_6, chroma_1_x, or unknown using manifest-first evidence and a narrow structural fallback, with unit tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Document the detector decision rules, ambiguity handling, and example outputs, and link the new documentation from the README.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add a stable-path palace safety gate that blocks unsafe read, write, create, and repair flows unless the detected palace format is chroma_0_6. Wire it into init, mine, health checks, MCP startup, and verify, with unit coverage.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Document the stable safety gate policy, guarded flows, and blocked-versus-allowed behavior, and surface the feature in the README.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Move the generated Copilot MCP config to .mcp.json, switch validation to the mcpServers schema, and add legacy .vscode/mcp.json migration handling in update.sh.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Update the README, MCP docs, troubleshooting notes, update workflow guide, and example config to reflect Copilot CLI's .mcp.json format and the jq-based migration path.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Document the ChromaDB 1.x compatibility exploration and add an exploration-only MCP launcher that bypasses the stable branch guardrails for isolated testing.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Document the feasibility, risks, required building blocks, validation checklist, and recommendation for a source-preserving ChromaDB reconstruction migration flow.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Explicitly set README to the final reviewed state from the experimental
branch. The README was surgically excluded from all mixed commits during
the split; this commit applies the intended final state.

Includes all stable content (format detection, safety gate, .mcp.json
references) plus the experimental reconstruction section, clearly
labeled as not part of the supported bridge path.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@apajon apajon mentioned this pull request Apr 17, 2026
apajon added 9 commits April 17, 2026 14:41
Centralized palace/runtime version detection and compatibility check.
- classify_chromadb_version() detects 0.6.x vs 1.x runtime
- probe_palace_format() inspects palace SQLite config_json_str
- diagnose() returns structured CompatDiagnostic with actionable message
- 19 unit tests covering all version combinations
run_mcp_server.py: replace ad-hoc _check_config_type() with
runtime_compat.diagnose() — blocks on mismatch with actionable error.

run_mcp_server_exploration.py: add diagnose() call that warns on
mismatch but does not block (exploration mode).
- create_rich_palace.py: 45-drawer fixture (5 wings, 16 rooms, Unicode,
  emoji, near-dupes, varied metadata, long content)
- compare_palaces.py: 6-tier migration-grade comparison
- mcp_runtime_test.py: MCP stdio JSON-RPC test harness (15 phases)
- compare_mcp_results.py: structured comparison of MCP test outputs
- create_native_palace.py, runtime_load_test.py: earlier investigation tools
Reports:
- runtime_compatibility_matrix.md: 6-case version mismatch study
- runtime_targeting_hardening.md: launcher audit and safeguards
- migration_grade_validation_plan.md: 10-tier validation plan with
  honest status classification
- mcp_runtime_comparison.md: MCP runtime comparison (verdict: IDENTICAL)
- type_failure_trace.md, type_usages_inventory.md: _type root cause

Logs:
- mcp_test_native_1x.json, mcp_test_reconstructed_1x.json: raw MCP test
- mcp_comparison_report.json: structured diff
- runtime_case_logs/: 6-case compatibility matrix logs
Add entries for:
- .vscode/c_cpp_properties.json (machine-specific C++ config)
- entities.json, mempalace.yaml (MemPalace local runtime)
- .venv-*/ (extra investigation virtualenvs)
19 adversarial palace generators (adversarial_palaces.py):
- Data integrity: duplicate IDs, blank IDs, missing/duplicate documents,
  duplicate metadata keys, empty metadata
- Encoding: emoji, CJK, RTL, zero-width, null bytes, astral plane, 100K chars
- Scale: 1MB, 10MB, 10K-line documents
- Structural: empty palace, missing/corrupted SQLite, wrong schema
- Format: mixed signals, missing/conflicting manifest
- Edge: single drawer, metadata type extremes (int 2^62, inf, bool)

Robustness harness (robustness_harness.py):
- 5-stage pipeline: extract → export → import → validate → integrity crosscheck
- Outcome classification: full_success, degraded, partial_failure, hard_failure
- Root cause tagging: expected_limitation, fixable_bug, upstream_constraint
- Silent corruption detection via source/target document comparison
- JSON + markdown report generation
Results from running 19 adversarial palaces through the full pipeline:
- 7 full success (unicode, large content, metadata edge types, etc.)
- 10 explicit rejections (correct pipeline behavior)
- 2 hard failures (fixable: unhandled sqlite3 exceptions)
- 0 silent corruption

Robustness matrix details boundaries, root causes, and recommendations.
All raw sqlite3.Error exceptions in extract_drawers_from_sqlite() and
_source_sqlite_integrity() are now caught and converted to structured
ReconstructionCliError with stage, category, file path, and actionable hint.

- Corrupted SQLite files → 'source palace database is unreadable'
- Wrong schema → 'source palace database query failed'
- Both caught at connect and query level

Robustness harness updated to classify ReconstructionCliError at extract
stage as partial_failure (structured rejection) instead of hard_failure.

Result: 19 adversarial cases → 7 success, 12 structured rejections,
0 hard failures, 0 silent corruption.

Tests: 4 new tests for corrupted/wrong-schema SQLite, 24/24 passing.
@apajon apajon changed the title Draft: experimental reconstruction workflow for ChromaDB 1.x Draft: runtime-validated non-destructive reconstruction workflow for ChromaDB 1.x Apr 17, 2026
apajon added 2 commits April 17, 2026 16:46
- Add global --debug flag to argparse parser
- 3-tier exception handler in main(): ReconstructionCliError (structured),
  RuntimeError (concise + --debug hint), Exception (catch-all + hint)
- Debug mode prints full tracebacks; normal mode prints actionable messages
- Propagate --debug through reconstruct.sh via run_step()
- Add 3 CLI error UX tests: no-traceback, debug-traceback, runtime-error-hint
- Document error model in docs/error_model.md
- docs/support_matrix.md: tested environments, validated input classes,
  adversarial results (7 success, 12 rejections, 0 corruption)
- docs/limitations.md: explicit scope, version, data, and operational
  constraints with honest 'not tested' section
apajon added 2 commits April 17, 2026 16:46
- docs/cli_usage.md: all subcommands, flags, examples, output modes
- README.md: upgrade reconstruction from 'experimental' to 'proven with
  explicit boundaries'; add evidence section, quick usage, guarantees;
  link new documentation; preserve honest framing of constraints
56/56 tests pass, 19 adversarial cases (0 silent corruption),
structured error UX verified, all documentation delivered.

Classification: non-destructive, runtime-valid, explicitly bounded
migration path with structured failure modes for the tested scope.
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