Write tools: people_link merge and alias, so deprecated addresses can join a Person #78

Closed
opened 2026-11-04 10:54:52 +00:00 by svc-svd-writer · 2 comments
Collaborator

Outcome

People Mind mounts the people_link write tool with the merge and alias actions, people_undo for links, and people_actions. The Owner or an agent can then merge two Persons, or attach a deprecated email address to a Person as an Attached Handle, without putting that address on a contact card.

Contract

Build to ADR 0005 as amended. Amendment 1 is the shared write-action contract (#97, merged in #121). Amendment 2 is the links contract from the #78 grill of 2026-11-05 (PR #122). Where this body and the ADR differ, the ADR wins.

Context

  • src/people_mind_mcp/server.py mounts read tools only. A write scope and a single auth.write_token_file with one label exist (config.py:61-73, auth.py:51-64). No outbox, Action table, undo record or revision exists yet.
  • ADR 0002 decision 3 says every merge other than an exact shared Handle is a people_link. Today the only way to join two Persons is to put both addresses on one contact card, so the exact-Handle ingest path merges them (graph.py:333-357).
  • That path fails for deprecated addresses. Mail.app autocompletes every address on a card, so a deprecated address on a card is offered again when the Owner writes mail (operator, 2026-11-04, #70).
  • The 2026-11-04 cross-check on starbase-syd (read-only) found deprecated Apple and legacy addresses split across mail-only Persons. Examples: the Kim records in #70, and the robert.fisher0 pair.
  • No sync path deletes a Handle (graph.py:428-438). merge_persons deletes the merged-away Person and keeps nothing an undo could use (graph.py:235-265). The primary email is the lowest-id matchable Handle (views.py:14).

Scope

In scope, from ADR 0005 Amendment 1 (the shared foundation, built once here):

  • the labelled write-token list with bucket grants, and Author and via on every Action (rulings 5 to 7);
  • the outbox and worker, the Action states queued, applied, conflict and failed, and charging when an Action is queued (rulings 4 and 11);
  • client idempotency keys (ruling 9);
  • revisions only for the items #78's kinds touch: the Person revision for merge and its undo, and Handles for alias undo (rulings 8 and 10);
  • undo records, purged when the window ends (ruling 15);
  • people_actions with the ruling 17 columns and filters.

In scope, from ADR 0005 Amendment 2:

  • link.alias (rulings 1 to 4) and link.merge (rulings 5 to 6);
  • merge undo with its would-remerge and superseded refusals, and its feed entries (rulings 7 to 11);
  • the primary-email order (ruling 12);
  • the link cap of 50 a day and the undo cap of 50 a day.

Out of scope:

  • link.split and handle.move (#109);
  • every non-link kind, including people_note;
  • people_forget, which stays unmounted until #55 and #114 land;
  • minting or deploying any token (starbase/iac#345 on git.gen3.dev).

Acceptance criteria

  • With no write token configured, the server mounts no write tool. This is today's behaviour.
  • With two write tokens configured, each Action records its token's label as Author and via as tool.
  • people_link action=alias attaches an unowned email Handle to a named Person. The next contacts pass, and a Mail peer rebuild, keep it on that Person, and a mail record from that address resolves to that Person.
  • alias of a Handle another Person holds ends failed with reason handle-owned, names that Person, and changes nothing.
  • Undo of an alias deletes the Attached Handle. After a mail record has joined through that Handle, the same undo answers conflict with reason evidence-joined.
  • people_link action=merge merges two Persons. people_undo within writes.undo_days restores the merged-away Person under its original id, including field rows that a re-sync rewrote after the merge. The feed shows add for the restored Person and update for the survivor.
  • Merge undo answers conflict with reason would-remerge when the two sides now share an exact Handle, and with reason superseded after a later merge moved the same links.
  • merge with the Owner, and alias onto the Owner, end failed with reason owner.
  • After merging Kim's mail-only Person into Kim's contact Person, the default row's primary email is still the contact-Source address.
  • A retry with the same idempotency key returns the original Action and charges no cap. The same key with a different payload answers Error: idempotency-conflict.
  • A merge sent with a stale Person revision ends conflict and changes nothing.
  • Over 50 links in a day, the tool answers rate_limited and queues nothing.
  • people_actions lists each Action with id | kind | state | author | via | requested | applied | detail, filters by id and state, and shows ids only in detail.

Blocked by

  • None. The contract must be on main (PR #122) before dispatch.

Ruling (2026-11-05)

Grilled 2026-11-05: 16 questions over two rounds; the operator accepted every lean. The rulings are ADR 0005 Amendment 2. Token deployment moved to starbase/iac#345, which keeps the credential act with a human.

Filed under: operator word "accept" sha256:c125d0397b60 (dev/people-mind-mcp #70 deprecated addresses); grill words "accept", "acc", "go"

## Outcome People Mind mounts the `people_link` write tool with the `merge` and `alias` actions, `people_undo` for links, and `people_actions`. The Owner or an agent can then merge two Persons, or attach a deprecated email address to a Person as an Attached Handle, without putting that address on a contact card. ## Contract Build to ADR 0005 as amended. Amendment 1 is the shared write-action contract (#97, merged in #121). Amendment 2 is the links contract from the #78 grill of 2026-11-05 (PR #122). Where this body and the ADR differ, the ADR wins. ## Context - `src/people_mind_mcp/server.py` mounts read tools only. A `write` scope and a single `auth.write_token_file` with one label exist (`config.py:61-73`, `auth.py:51-64`). No outbox, Action table, undo record or revision exists yet. - ADR 0002 decision 3 says every merge other than an exact shared Handle is a `people_link`. Today the only way to join two Persons is to put both addresses on one contact card, so the exact-Handle ingest path merges them (`graph.py:333-357`). - That path fails for deprecated addresses. Mail.app autocompletes every address on a card, so a deprecated address on a card is offered again when the Owner writes mail (operator, 2026-11-04, #70). - The 2026-11-04 cross-check on starbase-syd (read-only) found deprecated Apple and legacy addresses split across mail-only Persons. Examples: the Kim records in #70, and the `robert.fisher0` pair. - No sync path deletes a Handle (`graph.py:428-438`). `merge_persons` deletes the merged-away Person and keeps nothing an undo could use (`graph.py:235-265`). The primary email is the lowest-id matchable Handle (`views.py:14`). ## Scope In scope, from ADR 0005 Amendment 1 (the shared foundation, built once here): - the labelled write-token list with bucket grants, and Author and `via` on every Action (rulings 5 to 7); - the outbox and worker, the Action states `queued`, `applied`, `conflict` and `failed`, and charging when an Action is queued (rulings 4 and 11); - client idempotency keys (ruling 9); - revisions only for the items #78's kinds touch: the Person revision for merge and its undo, and Handles for alias undo (rulings 8 and 10); - undo records, purged when the window ends (ruling 15); - `people_actions` with the ruling 17 columns and filters. In scope, from ADR 0005 Amendment 2: - `link.alias` (rulings 1 to 4) and `link.merge` (rulings 5 to 6); - merge undo with its `would-remerge` and `superseded` refusals, and its feed entries (rulings 7 to 11); - the primary-email order (ruling 12); - the link cap of 50 a day and the undo cap of 50 a day. Out of scope: - `link.split` and `handle.move` (#109); - every non-link kind, including `people_note`; - `people_forget`, which stays unmounted until #55 and #114 land; - minting or deploying any token (starbase/iac#345 on git.gen3.dev). ## Acceptance criteria - [ ] With no write token configured, the server mounts no write tool. This is today's behaviour. - [ ] With two write tokens configured, each Action records its token's label as Author and `via` as `tool`. - [ ] `people_link action=alias` attaches an unowned email Handle to a named Person. The next contacts pass, and a Mail peer rebuild, keep it on that Person, and a mail record from that address resolves to that Person. - [ ] `alias` of a Handle another Person holds ends `failed` with reason `handle-owned`, names that Person, and changes nothing. - [ ] Undo of an alias deletes the Attached Handle. After a mail record has joined through that Handle, the same undo answers `conflict` with reason `evidence-joined`. - [ ] `people_link action=merge` merges two Persons. `people_undo` within `writes.undo_days` restores the merged-away Person under its original id, including field rows that a re-sync rewrote after the merge. The feed shows `add` for the restored Person and `update` for the survivor. - [ ] Merge undo answers `conflict` with reason `would-remerge` when the two sides now share an exact Handle, and with reason `superseded` after a later merge moved the same links. - [ ] `merge` with the Owner, and `alias` onto the Owner, end `failed` with reason `owner`. - [ ] After merging Kim's mail-only Person into Kim's contact Person, the default row's primary email is still the contact-Source address. - [ ] A retry with the same idempotency key returns the original Action and charges no cap. The same key with a different payload answers `Error: idempotency-conflict`. - [ ] A merge sent with a stale Person revision ends `conflict` and changes nothing. - [ ] Over 50 links in a day, the tool answers `rate_limited` and queues nothing. - [ ] `people_actions` lists each Action with `id | kind | state | author | via | requested | applied | detail`, filters by id and state, and shows ids only in `detail`. ## Blocked by - None. The contract must be on `main` (PR #122) before dispatch. ## Ruling (2026-11-05) Grilled 2026-11-05: 16 questions over two rounds; the operator accepted every lean. The rulings are ADR 0005 Amendment 2. Token deployment moved to starbase/iac#345, which keeps the credential act with a human. Filed under: operator word "accept" sha256:c125d0397b60 (dev/people-mind-mcp #70 deprecated addresses); grill words "accept", "acc", "go"
Author
Collaborator

Status: CLEAN after 1 rework round(s) · 0 blocking defect(s) · 0 lens(es) INCONCLUSIVE (could not run) · 0 lens(es) DEGRADED (deterministic denial) · complexity substrate · dispatch effort high

Run: 20261105T112934Z-82b0c5b7

Held because: CLEAN but 10 open risk(s) (2 verification · 8 decision) — HOLD-ALL parks everything. The risks, verbatim:

Open risks:

  1. Error-line format: the ADR writes Error: idempotency-conflict / rate_limited, but the house format is Error: code=<code> (rows.py:16, server.py:92). Lean: keep the house format. Accept, or special-case these two lines to the ADR text? [decision]
  2. handle_claims is a new evidence table the ADR does not name; evidence-joined (ruling 4) and would-remerge (ruling 9) cannot be detected without it. Accept the table, or record an ADR 0005 amendment naming it before dispatch? [decision]
  3. Forget residue: actions.payload_digest is an unsalted sha256 that includes an alias address and outlives a Forget. Accept it now with #55/#114 owning the scrub, or require a keyed digest (a new API-side secret) in this slice? [decision]
  4. Cap window: lean is a rolling 24 h window over actions.requested. Is 'per day' rolling or a UTC calendar day? [decision]
  5. Mail-peer interaction restores and retractions emit no feed row, so they do not bump the Person revision. Must interaction-only changes bump it? [decision]
  6. The legacy auth.write_token_file/write_token_label pair is kept as a one-entry shorthand beside auth.write_tokens. Keep it, or retire it now while no write token is deployed? [decision]
  7. The k8s base prepare step (deploy/k8s/base/deployment.yaml:31-38) routes only read-token to the api container, so a deployed write token would never reach the API. Follow-up issue in this repo, or starbase/iac#345's overlay? [decision]
  8. FastMCP 3.4.11 tool registration and removal in build_app, and per-token list filtering, were read from the installed source, not exercised. Check: test_no_write_token_registers_no_write_tool passes across repeated build_app calls in one process, and tests/test_server.py::test_tools_list_is_exactly_eight_tools_each_untrusted passes unchanged. [verification]
  9. Scope is at 16/16. Every known schema-literal reader, including tests/test_embed.py:64, is now in Primary Files. The residual risk is an unknown test broken by the primary-email reorder or the revision bump; if one appears, report it under deviations instead of editing it. Check: make check green on the branch, the pristine-base failure set unchanged, and the §Primary Files sweep returns no stale schema-10 literal. [verification]
  10. sync --once does not drain the outbox: cli.py left the write set to fit tests/test_embed.py under the ceiling. Deployed sync runs without --once (compose.yaml:5, deployment.yaml:59), so run_forever's action worker applies Actions. Lean: accept, and file a follow-up that adds actions.drain to cli._sync. Accept, or re-slice (e.g. README to its own PR) to bring cli.py back? [decision]

Change: New src/people_mind_mcp/actions.py outbox. It mirrors graph.py's SQL-constant and transaction() style, store.open_positions (store.py:206-233) for the authorizer-limited open_outbox, embed_worker (sync.py:756-770) for the action worker, and server._render (server.py:82-96) for the Error: code= answers. Schema 11 follows the schema-10 precedent through the idempotent UPGRADES/TABLES/INDEXES upgrade block (store.py:163-175), not MIGRATIONS. Rework change: cli.py leaves the write set (sync --once does not drain; the deployed run_forever drains). tests/test_embed.py:64 joins the set for its hardcoded user_version == 10, so the set stays at 16 files.

Files: src/people_mind_mcp/config.py · src/people_mind_mcp/auth.py · src/people_mind_mcp/store.py · src/people_mind_mcp/graph.py · src/people_mind_mcp/actions.py · src/people_mind_mcp/server.py · src/people_mind_mcp/views.py · src/people_mind_mcp/sync.py · tests/test_actions.py · tests/test_auth.py · tests/test_identity.py · tests/test_config_cli.py · tests/test_deploy.py · tests/test_mailpeer.py · tests/test_embed.py · README.md

Write-set divergence: present table wins. structured return named src/people_mind_mcp/config.py, src/people_mind_mcp/auth.py, src/people_mind_mcp/store.py, src/people_mind_mcp/graph.py, src/people_mind_mcp/actions.py, src/people_mind_mcp/server.py, src/people_mind_mcp/views.py, src/people_mind_mcp/sync.py, tests/test_actions.py, tests/test_auth.py, tests/test_identity.py, tests/test_config_cli.py, tests/test_deploy.py, tests/test_mailpeer.py, tests/test_embed.py, README.md, src/people_mind_mcp/cli.py; table names src/people_mind_mcp/config.py, src/people_mind_mcp/auth.py, src/people_mind_mcp/store.py, src/people_mind_mcp/graph.py, src/people_mind_mcp/actions.py, src/people_mind_mcp/server.py, src/people_mind_mcp/views.py, src/people_mind_mcp/sync.py, tests/test_actions.py, tests/test_auth.py, tests/test_identity.py, tests/test_config_cli.py, tests/test_deploy.py, tests/test_mailpeer.py, tests/test_embed.py, README.md.

Decision: accept the 10 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-05-write-tools-people-link-merge-and-alias-so-deprecated-addres.md — next: codex-svd dispatch --args '<same-json>' --approved-spec-path /Users/piers/.local/state/exhaust/groupthink/specs/2026-11-05-write-tools-people-link-merge-and-alias-so-deprecated-addres.md

### ⏸ SVD architect gate: dev/people-mind-mcp#78 write-tools-people-link-merge-and-alias-so-deprecated-addres **Status:** CLEAN after 1 rework round(s) · 0 blocking defect(s) · 0 lens(es) INCONCLUSIVE (could not run) · 0 lens(es) DEGRADED (deterministic denial) · complexity `substrate` · dispatch effort `high` **Run:** `20261105T112934Z-82b0c5b7` **Held because:** CLEAN but 10 open risk(s) (2 verification · 8 decision) — HOLD-ALL parks everything. The risks, verbatim: **Open risks:** 1. Error-line format: the ADR writes `Error: idempotency-conflict` / `rate_limited`, but the house format is `Error: code=<code>` (rows.py:16, server.py:92). Lean: keep the house format. Accept, or special-case these two lines to the ADR text? [decision] 2. handle_claims is a new evidence table the ADR does not name; evidence-joined (ruling 4) and would-remerge (ruling 9) cannot be detected without it. Accept the table, or record an ADR 0005 amendment naming it before dispatch? [decision] 3. Forget residue: actions.payload_digest is an unsalted sha256 that includes an alias address and outlives a Forget. Accept it now with #55/#114 owning the scrub, or require a keyed digest (a new API-side secret) in this slice? [decision] 4. Cap window: lean is a rolling 24 h window over actions.requested. Is 'per day' rolling or a UTC calendar day? [decision] 5. Mail-peer interaction restores and retractions emit no feed row, so they do not bump the Person revision. Must interaction-only changes bump it? [decision] 6. The legacy auth.write_token_file/write_token_label pair is kept as a one-entry shorthand beside [[auth.write_tokens]]. Keep it, or retire it now while no write token is deployed? [decision] 7. The k8s base prepare step (deploy/k8s/base/deployment.yaml:31-38) routes only read-token to the api container, so a deployed write token would never reach the API. Follow-up issue in this repo, or starbase/iac#345's overlay? [decision] 8. FastMCP 3.4.11 tool registration and removal in build_app, and per-token list filtering, were read from the installed source, not exercised. Check: test_no_write_token_registers_no_write_tool passes across repeated build_app calls in one process, and tests/test_server.py::test_tools_list_is_exactly_eight_tools_each_untrusted passes unchanged. [verification] 9. Scope is at 16/16. Every known schema-literal reader, including tests/test_embed.py:64, is now in Primary Files. The residual risk is an unknown test broken by the primary-email reorder or the revision bump; if one appears, report it under deviations instead of editing it. Check: make check green on the branch, the pristine-base failure set unchanged, and the §Primary Files sweep returns no stale schema-10 literal. [verification] 10. `sync --once` does not drain the outbox: cli.py left the write set to fit tests/test_embed.py under the ceiling. Deployed sync runs without --once (compose.yaml:5, deployment.yaml:59), so run_forever's action worker applies Actions. Lean: accept, and file a follow-up that adds actions.drain to cli._sync. Accept, or re-slice (e.g. README to its own PR) to bring cli.py back? [decision] **Change:** New src/people_mind_mcp/actions.py outbox. It mirrors graph.py's SQL-constant and transaction() style, store.open_positions (store.py:206-233) for the authorizer-limited open_outbox, embed_worker (sync.py:756-770) for the action worker, and server._render (server.py:82-96) for the Error: code= answers. Schema 11 follows the schema-10 precedent through the idempotent UPGRADES/TABLES/INDEXES upgrade block (store.py:163-175), not MIGRATIONS. Rework change: cli.py leaves the write set (sync --once does not drain; the deployed run_forever drains). tests/test_embed.py:64 joins the set for its hardcoded user_version == 10, so the set stays at 16 files. **Files:** `src/people_mind_mcp/config.py` · `src/people_mind_mcp/auth.py` · `src/people_mind_mcp/store.py` · `src/people_mind_mcp/graph.py` · `src/people_mind_mcp/actions.py` · `src/people_mind_mcp/server.py` · `src/people_mind_mcp/views.py` · `src/people_mind_mcp/sync.py` · `tests/test_actions.py` · `tests/test_auth.py` · `tests/test_identity.py` · `tests/test_config_cli.py` · `tests/test_deploy.py` · `tests/test_mailpeer.py` · `tests/test_embed.py` · `README.md` **Write-set divergence:** present table wins. structured return named src/people_mind_mcp/config.py, src/people_mind_mcp/auth.py, src/people_mind_mcp/store.py, src/people_mind_mcp/graph.py, src/people_mind_mcp/actions.py, src/people_mind_mcp/server.py, src/people_mind_mcp/views.py, src/people_mind_mcp/sync.py, tests/test_actions.py, tests/test_auth.py, tests/test_identity.py, tests/test_config_cli.py, tests/test_deploy.py, tests/test_mailpeer.py, tests/test_embed.py, README.md, src/people_mind_mcp/cli.py; table names src/people_mind_mcp/config.py, src/people_mind_mcp/auth.py, src/people_mind_mcp/store.py, src/people_mind_mcp/graph.py, src/people_mind_mcp/actions.py, src/people_mind_mcp/server.py, src/people_mind_mcp/views.py, src/people_mind_mcp/sync.py, tests/test_actions.py, tests/test_auth.py, tests/test_identity.py, tests/test_config_cli.py, tests/test_deploy.py, tests/test_mailpeer.py, tests/test_embed.py, README.md. **Decision:** accept the 10 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-05-write-tools-people-link-merge-and-alias-so-deprecated-addres.md` — next: `codex-svd dispatch --args '<same-json>' --approved-spec-path /Users/piers/.local/state/exhaust/groupthink/specs/2026-11-05-write-tools-people-link-merge-and-alias-so-deprecated-addres.md`</sub>
Author
Collaborator

spec-verify-dispatch Half B for dev/people-mind-mcp#78 write-tools-people-link-merge-and-alias-so-deprecated-addres completed integration verify.

  • PR: #128
  • Branch: feat/svd-dev-people-mind-mcp-78-write-tools-people-link-merge-0892ca50
  • Commit: f29439f8ba
  • 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/76/1
  • Checks: required ci/woodpecker/pr/validation resolved pass by CI-wait poll
  • Warning: Container integration tests were not run (4 deselected under make check); the spec does not require them.
  • Warning: Plain python3 -m pytest lacks phonenumbers; collection and tests ran through uv run, as the spec prescribes.
  • CI wait: ci/woodpecker/pr/validation -> pass
  • Rework: 1 round(s), outcome converged
  • Decision: review the PR and merge? (codex-svd ship --run-id 20261105T195711Z-0892ca50 --confirm-merge)
spec-verify-dispatch Half B for dev/people-mind-mcp#78 write-tools-people-link-merge-and-alias-so-deprecated-addres completed integration verify. - PR: https://git.groupthink.asia/dev/people-mind-mcp/pulls/128 - Branch: feat/svd-dev-people-mind-mcp-78-write-tools-people-link-merge-0892ca50 - Commit: f29439f8bab226993be07083940c0708f8b1904d - 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/76/1 - Checks: required ci/woodpecker/pr/validation resolved pass by CI-wait poll - Warning: Container integration tests were not run (4 deselected under make check); the spec does not require them. - Warning: Plain `python3 -m pytest` lacks phonenumbers; collection and tests ran through `uv run`, as the spec prescribes. - CI wait: ci/woodpecker/pr/validation -> pass - Rework: 1 round(s), outcome converged - Decision: review the PR and merge? (`codex-svd ship --run-id 20261105T195711Z-0892ca50 --confirm-merge`)
svc-svd-writer 2026-11-05 20:18:19 +00:00
  • closed this issue
  • removed the
    svd:go
    label
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

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