people_related links every blank-organisation Person as a colleague #64

Closed
opened 2026-11-04 03:15:23 +00:00 by svc-agent-writer · 3 comments

Symptom

people_related on a Person whose asserted organisation is blank returns every other Person with a blank organisation as a colleague. Each row has an empty label and via org: with nothing after it.

Seen on peoplemind-piers, 0.1.0-rc.7, 2026-11-04: people_related for one Person returned 137 such rows.

Cause

src/people_mind_mcp/views.py at v0.1.0-rc.7:

  • MEMBERSHIPS (line 39) selects every asserted organisation field, including an empty or whitespace-only value, with a NULL org id.
  • related (line 195) compares a membership pair as org_id == own_id if org_id and own_id else name == own_name. When both org ids are NULL and both names are "", "" == "" is true, so every blank-organisation Person matches.

Data on piers

Read-only query:

  • 1,053 asserted organisation fields, of which 140 are blank, on 138 Persons.
  • The CardDAV import stores an empty vCard ORG as a blank asserted field. Those Persons link to Sources fastmail (140), icloud (40) and mail (23).

Expected

A blank organisation is not a shared organisation and creates no colleague relation.

Possible fixes, for triage:

  1. In related, skip a membership whose name is empty after trimming and whose org id is NULL, on both sides of the comparison.
  2. Do not store an empty ORG as an asserted organisation field at import; existing blank rows would also need cleaning.

Option 1 alone fixes the read. Option 2 also stops the blank value from feeding other views and organisation derivation.

Test

Two Persons with ORG: empty and one with ORG:Acme: people_related on either blank Person returns no colleague rows.

Second symptom (triage, 2026-11-04)

A blank asserted organisation also shadows a derived Organisation on the default row. _field (src/people_mind_mcp/views.py:66-69 at b698c2e) returns the first asserted value through ASSERTED_FIELD (views.py:15), which has no blank filter. So a Person with an empty vCard ORG and a work-domain email shows an empty organisation instead of the derived one.

Decision

Fix both reads and the import (operator, triage 2026-11-04). No schema migration.

  1. Treat an asserted value that is empty after trimming as absent in MEMBERSHIPS (views.py:39) and in ASSERTED_FIELD (views.py:15), for example with AND trim(value) != ''. Keep the derived branches unchanged. ASSERTED_FIELD also serves the optional fields (views.py:98), so a blank title or note is skipped as well, which is intended.
  2. In sources/vcard.py:98-101, do not append an organisation field whose value is empty after trimming.
  3. Existing blank rows stay in the store. They are inert after step 1, and DELETE_RECORD_FIELDS (graph.py:98) removes them when each record is next re-ingested.

Acceptance criteria

  • Two Persons with an empty ORG and one with ORG:Acme: people_related on either blank Person returns no colleague rows.
  • A Person with an empty ORG and an email on a non-public domain shows the derived Organisation on the default row.
  • A vCard with an empty ORG yields no organisation field at import.
  • make check passes.
## Symptom `people_related` on a Person whose asserted organisation is blank returns every other Person with a blank organisation as a `colleague`. Each row has an empty label and `via` `org:` with nothing after it. Seen on peoplemind-piers, 0.1.0-rc.7, 2026-11-04: `people_related` for one Person returned 137 such rows. ## Cause `src/people_mind_mcp/views.py` at `v0.1.0-rc.7`: - `MEMBERSHIPS` (line 39) selects every asserted `organisation` field, including an empty or whitespace-only `value`, with a NULL org id. - `related` (line 195) compares a membership pair as `org_id == own_id if org_id and own_id else name == own_name`. When both org ids are NULL and both names are `""`, `"" == ""` is true, so every blank-organisation Person matches. ## Data on piers Read-only query: - 1,053 asserted `organisation` fields, of which 140 are blank, on 138 Persons. - The CardDAV import stores an empty vCard `ORG` as a blank asserted field. Those Persons link to Sources fastmail (140), icloud (40) and mail (23). ## Expected A blank organisation is not a shared organisation and creates no `colleague` relation. Possible fixes, for triage: 1. In `related`, skip a membership whose name is empty after trimming and whose org id is NULL, on both sides of the comparison. 2. Do not store an empty `ORG` as an asserted `organisation` field at import; existing blank rows would also need cleaning. Option 1 alone fixes the read. Option 2 also stops the blank value from feeding other views and organisation derivation. ## Test Two Persons with `ORG:` empty and one with `ORG:Acme`: `people_related` on either blank Person returns no `colleague` rows. ## Second symptom (triage, 2026-11-04) A blank asserted `organisation` also shadows a derived Organisation on the default row. `_field` (`src/people_mind_mcp/views.py:66-69` at `b698c2e`) returns the first asserted value through `ASSERTED_FIELD` (`views.py:15`), which has no blank filter. So a Person with an empty vCard `ORG` and a work-domain email shows an empty organisation instead of the derived one. ## Decision Fix both reads and the import (operator, triage 2026-11-04). No schema migration. 1. Treat an asserted value that is empty after trimming as absent in `MEMBERSHIPS` (`views.py:39`) and in `ASSERTED_FIELD` (`views.py:15`), for example with `AND trim(value) != ''`. Keep the derived branches unchanged. `ASSERTED_FIELD` also serves the optional fields (`views.py:98`), so a blank `title` or `note` is skipped as well, which is intended. 2. In `sources/vcard.py:98-101`, do not append an `organisation` field whose value is empty after trimming. 3. Existing blank rows stay in the store. They are inert after step 1, and `DELETE_RECORD_FIELDS` (`graph.py:98`) removes them when each record is next re-ingested. ## Acceptance criteria - [ ] Two Persons with an empty `ORG` and one with `ORG:Acme`: `people_related` on either blank Person returns no `colleague` rows. - [ ] A Person with an empty `ORG` and an email on a non-public domain shows the derived Organisation on the default row. - [ ] A vCard with an empty `ORG` yields no `organisation` field at import. - [ ] `make check` passes.
Collaborator

This was generated by AI during triage.

Agent brief

Category: bug. State: ready-for-agent (CONV-40 rule 2: three bounded files plus tests).

Verified at b698c2e:

  • sources/vcard.py:98-101 appends an organisation field with no blank guard.
  • views.py:39 (MEMBERSHIPS) selects that blank value with a NULL org id, and views.py:195 matches "" == "".
  • A second symptom: ASSERTED_FIELD (views.py:15) has no blank filter, so a blank asserted organisation shadows a derived Organisation on the default row (views.py:66-69).

Decision (operator): filter blanks in both reads and skip blank ORG at import, with no schema migration. Existing blank rows stay inert and go when each record is next re-ingested (graph.py:340). The body's ## Decision and ## Acceptance criteria sections are the contract.

Out of scope: a cleanup migration; case or whitespace normalisation of non-blank organisation names.

> *This was generated by AI during triage.* ## Agent brief **Category:** bug. **State:** ready-for-agent (CONV-40 rule 2: three bounded files plus tests). **Verified at `b698c2e`:** - `sources/vcard.py:98-101` appends an `organisation` field with no blank guard. - `views.py:39` (`MEMBERSHIPS`) selects that blank value with a NULL org id, and `views.py:195` matches `"" == ""`. - A second symptom: `ASSERTED_FIELD` (`views.py:15`) has no blank filter, so a blank asserted `organisation` shadows a derived Organisation on the default row (`views.py:66-69`). **Decision (operator):** filter blanks in both reads and skip blank `ORG` at import, with no schema migration. Existing blank rows stay inert and go when each record is next re-ingested (`graph.py:340`). The body's `## Decision` and `## Acceptance criteria` sections are the contract. **Out of scope:** a cleanup migration; case or whitespace normalisation of non-blank organisation names.
Collaborator

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 standard · dispatch effort medium

Run: 20261104T035302Z-a0e63f4c

Held because: CLEAN but 1 open risk(s) (1 verification) — HOLD-ALL parks everything. The risks, verbatim:

Open risks:

  1. Legacy blank-row cleanup is not proven in the store. After deploy, on peoplemind-piers, run SELECT COUNT(*) FROM fields WHERE name='organisation' AND kind='asserted' AND trim(value)='' (140 on 2026-11-04 per the issue). After the first full fastmail/icloud/mail sync it should fall toward 0. people_related on the Person from the issue report should return 0 rows whose via is 'org:'. Rows from a source that does not re-yield unchanged records stay until that record changes, but they are inert under the read fix. [verification]

Change: views.py:15 ASSERTED_FIELD: add AND trim(value) != '' before ORDER BY id LIMIT 1. _field (views.py:66-75) then falls through to DERIVED_FIELD unchanged, and the optional-field branch (views.py:97-99) inherits the filter. views.py:39-43 MEMBERSHIPS: add AND trim(value) != '' to the first (asserted) SELECT only. The derived UNION branch is unchanged, the parameter count stays 1, and related() (views.py:181-212) needs no edit. vcard.py:98-101 _record: keep the existing ORG loop and guard the append with if org.strip():. CardDAV reuses _record (carddav.py:17,236,291), so one guard covers both. No graph.py/store.py edit and no migration: legacy blank rows are inert after the read filter and are removed by DELETE_RECORD_FIELDS (graph.py:98/340) when rec_hash (graph.py:269-277) changes on next re-ingest. Tests mirror test_server.py:186-215 (direct INSERT INTO fields plus views.default_row) and test_vcard_sync.py:71-84 / 313-336 (make_cards().replace plus extra_public plus sync; VCardSource.records()).

Files: src/people_mind_mcp/views.py · src/people_mind_mcp/sources/vcard.py · tests/test_server.py · tests/test_vcard_sync.py

Decision: accept the 1 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):

  • add label svd:go — approve; Half-B dispatch accepts exactly this spec (open risks accepted)
  • add label svd:fire beside svd:go — approve AND authorise the Half-B fire from the phone; never on its own
  • add label svd:skip — park it; dispatch refuses it and the issue stays for a human
  • add label svd:respec — discard this spec; the next Half-A run re-produces it with this record as prior-attempt context

Spec: /Users/piers/.local/state/exhaust/groupthink/specs/2026-11-04-people-related-links-every-blank-organisation-person-as-a-co.md — next: codex-svd dispatch --args '<same-json>' --approved-spec-path /Users/piers/.local/state/exhaust/groupthink/specs/2026-11-04-people-related-links-every-blank-organisation-person-as-a-co.md

### ⏸ SVD architect gate: dev/people-mind-mcp#64 people-related-links-every-blank-organisation-person-as-a-co **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 `standard` · dispatch effort `medium` **Run:** `20261104T035302Z-a0e63f4c` **Held because:** CLEAN but 1 open risk(s) (1 verification) — HOLD-ALL parks everything. The risks, verbatim: **Open risks:** 1. Legacy blank-row cleanup is not proven in the store. After deploy, on peoplemind-piers, run `SELECT COUNT(*) FROM fields WHERE name='organisation' AND kind='asserted' AND trim(value)=''` (140 on 2026-11-04 per the issue). After the first full fastmail/icloud/mail sync it should fall toward 0. people_related on the Person from the issue report should return 0 rows whose via is 'org:'. Rows from a source that does not re-yield unchanged records stay until that record changes, but they are inert under the read fix. [verification] **Change:** views.py:15 ASSERTED_FIELD: add `AND trim(value) != ''` before `ORDER BY id LIMIT 1`. _field (views.py:66-75) then falls through to DERIVED_FIELD unchanged, and the optional-field branch (views.py:97-99) inherits the filter. views.py:39-43 MEMBERSHIPS: add `AND trim(value) != ''` to the first (asserted) SELECT only. The derived UNION branch is unchanged, the parameter count stays 1, and related() (views.py:181-212) needs no edit. vcard.py:98-101 _record: keep the existing ORG loop and guard the append with `if org.strip():`. CardDAV reuses _record (carddav.py:17,236,291), so one guard covers both. No graph.py/store.py edit and no migration: legacy blank rows are inert after the read filter and are removed by DELETE_RECORD_FIELDS (graph.py:98/340) when rec_hash (graph.py:269-277) changes on next re-ingest. Tests mirror test_server.py:186-215 (direct INSERT INTO fields plus views.default_row) and test_vcard_sync.py:71-84 / 313-336 (make_cards().replace plus extra_public plus sync; VCardSource.records()). **Files:** `src/people_mind_mcp/views.py` · `src/people_mind_mcp/sources/vcard.py` · `tests/test_server.py` · `tests/test_vcard_sync.py` **Decision:** accept the 1 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`): - add label `svd:go` — approve; Half-B dispatch accepts exactly this spec (open risks accepted) - add label `svd:fire` **beside** `svd:go` — approve AND authorise the Half-B fire from the phone; never on its own - add label `svd:skip` — park it; dispatch refuses it and the issue stays for a human - add label `svd:respec` — discard this spec; the next Half-A run re-produces it with this record as prior-attempt context <sub>Spec: `/Users/piers/.local/state/exhaust/groupthink/specs/2026-11-04-people-related-links-every-blank-organisation-person-as-a-co.md` — next: `codex-svd dispatch --args '<same-json>' --approved-spec-path /Users/piers/.local/state/exhaust/groupthink/specs/2026-11-04-people-related-links-every-blank-organisation-person-as-a-co.md`</sub>
Collaborator

spec-verify-dispatch Half B for dev/people-mind-mcp#64 people-related-links-every-blank-organisation-person-as-a-co completed integration verify.

  • PR: #66
  • Branch: feat/svd-dev-people-mind-mcp-64-people-related-links-every-bl-3ec8eea4
  • Commit: 6b567cdf78
  • Build: none
  • Test: green
  • Reader audit clean: True
  • Spec fidelity: True
  • Ready for merge: True
  • Check ci/woodpecker/pr/validation: green https://ci.groupthink.asia/repos/73/pipeline/29/1
  • Checks: required ci/woodpecker/pr/validation resolved pass by CI-wait poll
  • Warning: Woodpecker validation check is still pending on 6b567cd; re-poll before merge.
  • Warning: Bare system python3 lacks phonenumbers, so collection ran via uv (project venv) instead; this is not a defect.
  • Warning: Legacy blank-row cleanup on peoplemind-piers is a post-deploy check (spec Open Risk), not proven here.
  • CI wait: ci/woodpecker/pr/validation -> pass
  • Decision: review the PR and merge? (codex-svd ship --run-id 20261104T041946Z-3ec8eea4 --confirm-merge)
spec-verify-dispatch Half B for dev/people-mind-mcp#64 people-related-links-every-blank-organisation-person-as-a-co completed integration verify. - PR: https://git.groupthink.asia/dev/people-mind-mcp/pulls/66 - Branch: feat/svd-dev-people-mind-mcp-64-people-related-links-every-bl-3ec8eea4 - Commit: 6b567cdf78efb9be129f201ea51fca21fa4d7472 - Build: none - Test: green - Reader audit clean: True - Spec fidelity: True - Ready for merge: True - Check ci/woodpecker/pr/validation: green https://ci.groupthink.asia/repos/73/pipeline/29/1 - Checks: required ci/woodpecker/pr/validation resolved pass by CI-wait poll - Warning: Woodpecker validation check is still pending on 6b567cd; re-poll before merge. - Warning: Bare system python3 lacks phonenumbers, so collection ran via uv (project venv) instead; this is not a defect. - Warning: Legacy blank-row cleanup on peoplemind-piers is a post-deploy check (spec Open Risk), not proven here. - CI wait: ci/woodpecker/pr/validation -> pass - Decision: review the PR and merge? (`codex-svd ship --run-id 20261104T041946Z-3ec8eea4 --confirm-merge`)
svc-svd-writer 2026-11-04 04:59:55 +00:00
  • closed this issue
  • removed the
    svd:go
    label
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
dev/people-mind-mcp#64
No description provided.