Skip to content

chore: sync main hotfixes into develop before 3.6.0 - #2022

Merged
igorls merged 8 commits into
developfrom
chore/sync-main-before-3.6.0
Jul 15, 2026
Merged

chore: sync main hotfixes into develop before 3.6.0#2022
igorls merged 8 commits into
developfrom
chore/sync-main-before-3.6.0

Conversation

@igorls

@igorls igorls commented Jul 15, 2026

Copy link
Copy Markdown
Member

Sync main hotfixes back into develop

The 3.6.0 promotion PR #2020 is behind main because two post-v3.5.0 hotfixes landed directly on the release branch and were never merged back:

This branch merges main into develop and adds both fixes to the 3.6.0 changelog. The effective production diff is limited to mempalace/cli.py and mempalace/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 -q178 passed
  • Full merged-branch suite before the focused test additions — 3299 passed, 31 skipped
  • New focused regression tests — 51 passed
  • uv run ruff check . — clean
  • uv run ruff format --check . — 189 files clean
  • git diff --check — clean

Release flow

  1. Merge this sync PR into develop.
  2. Let Release v3.6.0 — promote develop to main #2020 refresh and pass CI at the updated develop head.
  3. Merge Release v3.6.0 — promote develop to main #2020 into main.
  4. Create GitHub Release/tag v3.6.0, then approve the gated PyPI publish.

milla-jovovich and others added 7 commits June 6, 2026 01:43
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>
Copilot AI review requested due to automatic review settings July 15, 2026 00:33
@igorls
igorls requested a review from milla-jovovich as a code owner July 15, 2026 00:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 .gitignore during mempalace init, avoiding Windows locale decode crashes.
  • Update Layer1 wake-up scoring to break importance ties by filed_at recency (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 thread mempalace/layers.py
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 thread mempalace/cli.py
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)
@igorls
igorls merged commit ec8788c into develop Jul 15, 2026
8 checks passed
@igorls
igorls deleted the chore/sync-main-before-3.6.0 branch July 15, 2026 06:06
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.

5 participants