chore: sync main hotfixes into develop before 3.6.0 - #2022
Merged
Conversation
Release v3.4.0 — promote develop to main
Release v3.4.1 — promote develop to main
Release v3.5.0 — promote develop to main
…ments (#1630) L1's generate() scored drawers by importance/emotional_weight/weight, and the docstring promised "prefer high importance, recent filing". But no ingest path (miner, convo_miner, diary, add_drawer) writes any of those fields, so the sort collapsed to insertion order (oldest first) and recency was never consulted. A scoped `wake-up --wing X` therefore surfaced the *oldest* moments: the opposite of useful. Add filed_at (present on every drawer, ISO-8601, lexically chronological) as the secondary sort key. Importance stays primary for the day a scoring pass populates it; filed_at is the effective signal today, making the "recent filing" half of the promise true with data already present. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Co-authored-by: Igor Lins e Silva <4753812+igorls@users.noreply.github.com>
On Windows, Path.read_text() and open(path, 'a') use locale encoding (GBK on Chinese-locale systems) before PEP 686 / Python 3.15. A valid UTF-8 .gitignore with non-ASCII comments crashes _ensure_mempalace_files_gitignored() with UnicodeDecodeError, which aborts 'mempalace init' on Windows for any user whose .gitignore contains non-ASCII text. Force encoding='utf-8' on both read and append, with errors='replace' on read as a defensive fallback for legacy mixed-encoding files. Co-authored-by: ALaDingAhmad <16530935@qq.com> Co-authored-by: Igor Lins e Silva <4753812+igorls@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Syncs two post-v3.5.0 hotfixes from main back into develop ahead of the 3.6.0 promotion, aligning runtime behavior and the 3.6.0 changelog with what’s already shipped on the release branch.
Changes:
- Force UTF-8 (with defensive decode) when reading/appending
.gitignoreduringmempalace init, avoiding Windows locale decode crashes. - Update Layer1 wake-up scoring to break importance ties by
filed_atrecency (newest-first). - Add both hotfixes to the 3.6.0 changelog.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| mempalace/cli.py | Pins .gitignore read/append encoding to UTF-8 to prevent Windows decode failures during init. |
| mempalace/layers.py | Adjusts Layer1 scoring sort to prefer newest filed_at when importance ties. |
| CHANGELOG.md | Documents the two hotfixes under the 3.6.0 notes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+159
to
+161
| # Sort by importance desc, then recency (filed_at) desc; take top N. | ||
| scored.sort(key=lambda x: (x[0], x[1]), reverse=True) | ||
| top = [(imp, meta, doc) for imp, _recency, meta, doc in scored[: self.MAX_DRAWERS]] |
Comment on lines
+262
to
272
| # Force UTF-8: Windows defaults to GBK and chokes on non-ASCII .gitignore | ||
| # comments, killing auto-init even though the file is valid UTF-8. | ||
| existing = gitignore.read_text(encoding="utf-8", errors="replace") if gitignore.exists() else "" | ||
| existing_lines = {line.strip() for line in existing.splitlines()} | ||
| missing = [p for p in _MEMPALACE_PROJECT_FILES if p not in existing_lines] | ||
| if not missing: | ||
| return False | ||
| prefix = "" if not existing or existing.endswith("\n") else "\n" | ||
| block = prefix + "\n# MemPalace per-project files (issue #185)\n" + "\n".join(missing) + "\n" | ||
| with open(gitignore, "a") as f: | ||
| with open(gitignore, "a", encoding="utf-8") as f: | ||
| f.write(block) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Sync
mainhotfixes back intodevelopThe 3.6.0 promotion PR #2020 is behind
mainbecause two post-v3.5.0 hotfixes landed directly on the release branch and were never merged back:fix(cli): force UTF-8 when reading/writing .gitignore in init(fix(cli): force UTF-8 when reading/writing .gitignore in init #1648)fix(layers): order L1 wake-up by recency so it surfaces the latest moments(fix(layers): order L1 wake-up by recency (filed_at) so it surfaces the latest moments #1630)This branch merges
mainintodevelopand adds both fixes to the 3.6.0 changelog. The effective production diff is limited tomempalace/cli.pyandmempalace/layers.py; focused regression tests cover both behaviors.Validation
uv run pytest tests/test_cli.py tests/test_layers.py tests/test_init_gitignore_protection.py tests/test_version_consistency.py tests/test_readme_claims.py -q— 178 passeduv run ruff check .— cleanuv run ruff format --check .— 189 files cleangit diff --check— cleanRelease flow
develop.develophead.main.v3.6.0, then approve the gated PyPI publish.