docs: the convos miner does check mtime — finish a correction that stopped half-way

ARCHITECTURE.md and README.md still carried the claim from 954c3f2 (initial
commit) that the convos miner "keys on source_file path alone (convos miner
doesn't check mtime)", and told the operator to delete the staging dir to force a
re-mine. 29e660e corrected exactly that claim in AGENTS.md and SKILL.md — and
missed these two files, so the repo has been documenting both behaviours at once
ever since. Two files said mtime is checked, two said it is not.

Ground truth, read off the deployed mempalace 3.7.1 rather than inferred:
convo_miner.py:657 calls file_already_mined(..., check_mtime=True) inside
mine_lock(source_file), and palace.py:1430 re-mines when no drawers exist for the
source_file, when the stored normalize_version predates the current schema, or
when the mtime differs. On a mismatch the file's existing drawers are purged
(_source_file_delete_ids -> collection.delete) before refiling, so a changed
transcript is replaced rather than doubled. The docstring names the case outright:
transcripts are not assumed immutable, since a session keeps appending to its own
file while active and /compact or /clear can rewrite one in place.

The stale advice was not merely out of date, it was expensive. "Delete the staging
dir to force a re-mine" is the one gesture that re-keys dedup: the staged path IS
the key, so a stage that is wiped or recreated elsewhere makes the palace refile a
whole wing as duplicates instead of replacing it. The docs now say so, name `touch`
as the non-destructive way to force a single session, and record why staged copies
must carry the source's mtime — with the corollary that an old mtime in a stage or
a remote inbox says nothing about when the file was shipped, so a ship is judged by
the feeder's log instead.

Sample output blocks quoting "(dedup by source_file)" are deliberately left
verbatim: that is what bin/mempalace-session:426 and bin/mempalace-pi-session:857
actually print. Tightening the wrappers' own wording is a separate change, because
the samples have to move with it.
This commit is contained in:
2026-08-18 09:42:40 +02:00
parent 947604b25d
commit fd8b15f570
4 changed files with 25 additions and 5 deletions
+17 -1
View File
@@ -129,6 +129,18 @@ mempalace-session --session ses_abc123 # one specific session
### Force re-mine
You almost never need this. The convos miner keys on `source_file` + `mtime`, so a
session that grew or was rewritten in place re-mines by itself on the next run, and a
normalizer-schema bump re-mines what it affects. The non-destructive force for a single
session is to change its staged mtime:
```bash
touch <palace-root>/opencode-stage/<wing>/<slug>_<id>.jsonl
mempalace-session # purges that session's drawers, refiles
```
Nuking the stage is a last resort, not the normal route:
```bash
rm -rf <palace-root>/opencode-stage/<wing>/ # nukes staging dir
mempalace-session # stages + mines fresh
@@ -136,6 +148,10 @@ mempalace-session # stages + mines fresh
# a scoped sync prunes the drawers mined from it instead of refiling them.
```
The staged path *is* the dedup key, so this is a destructive way to get a refile: if the
stage comes back at a different path, the palace cannot match the new sources to the old
drawers and the whole wing lands a second time instead of being replaced.
Staging is ephemeral by design; the palace is the source of truth.
## Operational Routine (when to invoke)
@@ -245,7 +261,7 @@ Budget **~20 minutes per 60-session batch**. Scales roughly linearly with messag
- **Don't run `mempalace mine` directly on a project.** Use `mempalace-docs` — otherwise source code floods the palace.
- **Don't try to point `mempalace mine --mode convos` at `opencode.db` directly.** The convos miner reads files (txt/md/json/jsonl) only — no SQLite support. Use `mempalace-session` to export first.
- **Don't delete staging dirs unnecessarily.** They're dedup anchors; deleting means a forced re-mine of everything in that wing.
- **Don't delete staging dirs unnecessarily.** They're dedup anchors, not caches: deleting forces a re-mine of everything in that wing, and if the dir returns at a different path the old drawers are duplicated rather than replaced. To refile one session, `touch` its staged JSONL instead.
- **Don't forget `mempalace_reconnect`** after a mine from inside a live MCP session — otherwise search hits the stale index.
- **Don't mine with `--min-messages 0` or `1`** — 78 out of 140 sessions in reference corpus were throwaway `/exit`'d sessions that would flood the palace with noise. Default 3 is sensible.