Principle:24kchengYe MemoMind Patch Based Customization
| Knowledge Sources | |
|---|---|
| Domains | Software_Engineering, Deployment |
| Last Updated | 2026-10-28 00:00 GMT |
Overview
Technique that customizes a pip-installed package by overwriting specific files in the installed site-packages directory with patched versions, enabling behavior modification without forking or maintaining a separate package.
Description
When a system depends on a pip package (hindsight-api) but needs behavior changes that aren't available as configuration, the options are: fork the package, submit upstream PRs (slow), or patch specific files post-install.
MemoMind uses the patch approach: a `patches/` directory contains modified versions of key files. An `install.sh` script runs `patch_hindsight.py`, which copies each patched file over the installed package, backing up the original as `.orig`.
The patches address MemoMind-specific needs:
- fact_extraction.py: occurred_start fallback logic
- fact_storage.py: Windows strftime fix
- orchestrator.py: original_document_id tracking
- link_expansion_retrieval.py: super-entity filtering
- consolidation_prompts.py: language preservation rule
- consolidator.py: skip trivial observations, lower similarity threshold
- hindsight/server.py: 600s startup timeout for CUDA model loading
Usage
Use this principle when you need to modify a third-party package's behavior but cannot fork it or wait for upstream changes. It is a pragmatic approach for rapid iteration, at the cost of fragility (patches may break on package updates).
Theoretical Basis
# Abstract patch application (not real implementation)
for patch_file in patches:
src = os.path.join("patches/", patch_file)
dst = os.path.join(site_packages, "hindsight_api/", patch_file)
shutil.copy2(dst, dst + ".orig") # Backup original
shutil.copy2(src, dst) # Apply patch
The Docker build bakes patches into the image, ensuring consistency between deployments. The `PATCHES.md` file documents each patch and its rationale.