people_find reads every interaction per matched Person and builds rows past the page #86
Labels
No labels
bug
enhancement
epic
needs-info
needs-triage
ready-for-agent
ready-for-human
svd:fire
svd:go
svd:hold
svd:respec
svd:skip
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
dev/people-mind-mcp#86
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What happens
people_findgets slower as the store collects interactions. On the #49 pair store (rc.9, 401 Persons) it took about 100 ms at 21,600 interactions. At 168,000 interactions it took 27–30 s, even for a query that matches nothing. The I01 run saw nine probe calls in a row exceed their 10 s client timeout, from 2026-11-04T14:04:27Z.Cause
Two defects in
src/people_mind_mcp/views.py, confirmed on a read-only copy of the pair store:interactionshas no index onperson_id. The only index isinteractions_once.LAST_INTERACTION(SELECT MAX(date) FROM interactions WHERE person_id = ?,views.py:29) andRECENT(views.py:48) read the whole table for each Person.find(views.py:133) callsdefault_rowfor every match before_pagedselects one page (views.py:183). In hybrid mode, the matches are every Person with a semantic score of 0.55 or more (config.py:110), so one call can build hundreds or thousands of rows to return 20.Measured on the store copy (native arm64; the pair container runs amd64 under emulation, which is about 10 times slower):
find, no rows builtLAST_INTERACTION, one Person, 168,000 interactionsdefault_rowfor all 401 PersonsLive store (rc.9, read-only, during the #338 rebuild): 3,939 Persons, 93,714 interactions,
LAST_INTERACTION8.3 ms per Person. If most Persons pass the semantic threshold, the worst case is about 33 s perpeople_findcall. A live call was not timed.What to change
CREATE INDEX interactions_person_date ON interactions(person_id, date). Follow the migration pattern insrc/people_mind_mcp/store.py(MIGRATIONS,SCHEMA_VERSION); the nextuser_versionis 10.find, page the ranked matches first, then builddefault_rowonly for the rows on the selected page. Keep the footer total: it is the count of all matches, not of the page.Acceptance
EXPLAIN QUERY PLANforLAST_INTERACTIONandRECENTnames the new index.findcallsdefault_rowat mostlimittimes per call.findoutput is unchanged for existing tests, including the footer total and the next cursor.user_version9 migrates to 10 in place, and the migration test covers it.people_findanswers in under 1 s.Out of scope
relatedbuilds no default rows, so it needs no change.Blocks
#10: the Grok re-run uses
people_find, and a call that takes about 30 s fails the client's timeout.Filed under: operator word "yes, file it that way" sha256:df2e44592f44
⏸ SVD architect gate: dev/people-mind-mcp#86 people-find-reads-every-interaction-per-matched-person-and-b
Status: CLEAN after 0 rework round(s) · 0 blocking defect(s) · 0 lens(es) INCONCLUSIVE (could not run) · 0 lens(es) DEGRADED (deterministic denial) · complexity
substrate· dispatch efforthighRun:
20261104T142905Z-db82f6efHeld because: CLEAN but 2 open risk(s) (2 verification) — HOLD-ALL parks everything. The risks, verbatim:
Open risks:
Change: Schema 10 goes in the post-v6 upgrade block of store.py open_writer (store.py:162-172), not in MIGRATIONS. MIGRATIONS covers only versions 1-6, so appending a seventh entry would apply it at the wrong version. Add a constant INDEXES = ("CREATE INDEX IF NOT EXISTS interactions_person_date ON interactions(person_id, date)",), mirroring the UPGRADES shape (store.py:19-24). Run it after the UPGRADES loop. Replace SCHEMA_9 with SCHEMA_10 = "PRAGMA user_version=10" and set SCHEMA_VERSION = 10. IF NOT EXISTS keeps the #69 concurrent-writer path and the version-marker heal paths idempotent. In views.find (views.py:182-183), page the (pid, reason) matches with rows.page first (rows.py:49-54), build default_row only for the selected page, then join row(...) with the footer. The total and next_cursor are unchanged because page counts len(matches). Keep _paged for related and recent. Raise every schema-9 literal (test_identity:528, test_mailpeer:607/628/663, test_embed:64, test_config_cli:119, test_deploy:295/328, README:177) and add a README:141 rollback sentence.
Files:
src/people_mind_mcp/store.py·src/people_mind_mcp/views.py·tests/test_identity.py·tests/test_embed.py·tests/test_mailpeer.py·tests/test_config_cli.py·tests/test_deploy.py·README.mdDecision: accept the 2 open risk(s) above and dispatch this spec (
svd:go), or park (svd:skip) / re-spec (svd:respec)?Your call (when this issue is held at the gate via
svd:hold):svd:go— approve; Half-B dispatch accepts exactly this spec (open risks accepted)svd:firebesidesvd:go— approve AND authorise the Half-B fire from the phone; never on its ownsvd:skip— park it; dispatch refuses it and the issue stays for a humansvd:respec— discard this spec; the next Half-A run re-produces it with this record as prior-attempt contextSpec:
/Users/piers/.local/state/exhaust/groupthink/specs/2026-11-04-people-find-reads-every-interaction-per-matched-person-and-b.md— next:codex-svd dispatch --args '<same-json>' --approved-spec-path /Users/piers/.local/state/exhaust/groupthink/specs/2026-11-04-people-find-reads-every-interaction-per-matched-person-and-b.mdspec-verify-dispatch Half B for dev/people-mind-mcp#86 people-find-reads-every-interaction-per-matched-person-and-b completed integration verify.
63d066cfe8codex-svd ship --run-id 20261104T201458Z-31b0c2dc --confirm-merge)Live check on 0.1.0-rc.10 (piers store, 2026-11-04)
rc.10 carries PR #88 (
61febb4). The pod rolled at 21:34:30Z (starbase/iac#340,sha256:caf5c3f3cd71…). All three containers are ready, with 0 restarts. The checks are read-only.peoplemind check:store=ok schema=10 persons=3939 organisations=1516 tombstones=0.PRAGMA user_version: 10. The indexinteractions_person_dateis present.EXPLAIN QUERY PLANforLAST_INTERACTION:SEARCH interactions USING COVERING INDEX interactions_person_date (person_id=?).views.findtimings, run in the api container against the live store. Each call is timed once after a warm-up call, withlimit20:Every call is under the 1 s target. Before the change, the estimate for this store was about 33 s in the worst case.
The Grok re-run on #10 used
people_findover MCP at 22:05Z to 22:07Z. All fourpeople_findcalls returnedcode=ok. The api log does not record call times.Open Risk 1: met on the live store at 93,705 interactions. It is not yet measured on the #49 pair store at 168,000 interactions; the next #49 run covers that.
Open Risk 2 (
make test-integrationfor the schema-10 literals intests/test_deploy.py): this check does not cover it.