Keep one link per Person on a manual event #147

Closed
opened 2026-11-06 21:50:26 +00:00 by svc-agent-writer · 3 comments

This was generated by AI during an SVD gate.

What to build

Make "one link per Person on a manual event" a store rule instead of a read-time collapse.

At the #105 gate (ruling D4, operator word "Accept"), a merge folds a Person's two links on one event into one, and interaction.attribute onto a Person already on the event fails with participant-present. Three paths can still leave two links for one Person: endpoint.unshare, the undo of endpoint.share, and handle.move. people_recent collapses those into one row on read.

Acceptance criteria

  • A unique index on interactions(event_id, person_id) where both are set, added through migrate-on-open in the next free schema version (ADR 0005 Amendment 5 ruling 15).
  • endpoint.unshare, share undo and handle.move fold or refuse instead of creating a second link, with the reason named; their undo restores the prior rows.
  • The read-time collapse in people_recent is removed, and a test proves no path creates a second link.

Blocked by

> *This was generated by AI during an SVD gate.* ## What to build Make "one link per Person on a manual event" a store rule instead of a read-time collapse. At the #105 gate (ruling D4, operator word "Accept"), a merge folds a Person's two links on one event into one, and `interaction.attribute` onto a Person already on the event fails with `participant-present`. Three paths can still leave two links for one Person: `endpoint.unshare`, the undo of `endpoint.share`, and `handle.move`. `people_recent` collapses those into one row on read. ## Acceptance criteria - [ ] A unique index on `interactions(event_id, person_id)` where both are set, added through migrate-on-open in the next free schema version (ADR 0005 Amendment 5 ruling 15). - [ ] `endpoint.unshare`, share undo and `handle.move` fold or refuse instead of creating a second link, with the reason named; their undo restores the prior rows. - [ ] The read-time collapse in `people_recent` is removed, and a test proves no path creates a second link. ## Blocked by - #105
Author
Member

This was generated by AI during triage.

Agent Brief

Category: enhancement
Summary: The store enforces at most one link per Person on a manual event, instead of collapsing duplicates on read.

Current behavior:
The index on interactions(event_id, person_id) exists but is not unique. At the #105 gate (ruling D4), a merge folds a Person's two links on one event into one, and interaction.attribute onto a Person already on the event fails with participant-present. Three paths can still leave two links for one Person on one event:

  • endpoint.unshare;
  • undo of endpoint.share;
  • handle.move.

people_recent hides the duplicates with a DISTINCT on read.

Desired behavior:

  • A unique partial index on interactions(event_id, person_id), where both are set, replaces the existing index. It is added by migrate-on-open in the next free schema version (v21 today; take the next free number if another slice merges first). This follows ADR 0005 Amendment 5 ruling 15.
  • The migration folds any duplicate links that already exist before it creates the index, so it cannot fail on live data.
  • Each of the three paths either folds the second link into the existing one or refuses with a named reason. Pick one per path and say why in the PR. Undo of each path restores the rows that existed before.
  • The read-time collapse in people_recent is removed.

Key interfaces:

  • Store schema version and the migrate-on-open chain.
  • The apply and undo handlers for endpoint.unshare, endpoint.share undo and handle.move.
  • The people_recent participant projection.

Acceptance criteria:

  • The unique index exists after migration, and a migration test starts from a v20 store that holds a duplicate link.
  • Tests drive each of the three paths onto an event where the Person is already present, and prove that only one link results or that the Action refuses with its named reason.
  • Undo of each path restores the prior rows.
  • people_recent no longer de-duplicates, and its existing tests still pass.
  • The required repository checks and the focused worker tests are green.

Out of scope:

  • Merge folding and interaction.attribute. Both already behave as ruled at #105.
  • Links on Interactions without an event_id, such as mail evidence.
  • Any change to the Card App view.

Sequencing:
This slice bumps the schema and touches manual events. Do not run it in parallel with another schema-bumping slice, or with #113.

> *This was generated by AI during triage.* ## Agent Brief **Category:** enhancement **Summary:** The store enforces at most one link per Person on a manual event, instead of collapsing duplicates on read. **Current behavior:** The index on `interactions(event_id, person_id)` exists but is not unique. At the #105 gate (ruling D4), a merge folds a Person's two links on one event into one, and `interaction.attribute` onto a Person already on the event fails with `participant-present`. Three paths can still leave two links for one Person on one event: - `endpoint.unshare`; - undo of `endpoint.share`; - `handle.move`. `people_recent` hides the duplicates with a `DISTINCT` on read. **Desired behavior:** - A unique partial index on `interactions(event_id, person_id)`, where both are set, replaces the existing index. It is added by migrate-on-open in the next free schema version (v21 today; take the next free number if another slice merges first). This follows ADR 0005 Amendment 5 ruling 15. - The migration folds any duplicate links that already exist before it creates the index, so it cannot fail on live data. - Each of the three paths either folds the second link into the existing one or refuses with a named reason. Pick one per path and say why in the PR. Undo of each path restores the rows that existed before. - The read-time collapse in `people_recent` is removed. **Key interfaces:** - Store schema version and the migrate-on-open chain. - The apply and undo handlers for `endpoint.unshare`, `endpoint.share` undo and `handle.move`. - The `people_recent` participant projection. **Acceptance criteria:** - [ ] The unique index exists after migration, and a migration test starts from a v20 store that holds a duplicate link. - [ ] Tests drive each of the three paths onto an event where the Person is already present, and prove that only one link results or that the Action refuses with its named reason. - [ ] Undo of each path restores the prior rows. - [ ] `people_recent` no longer de-duplicates, and its existing tests still pass. - [ ] The required repository checks and the focused worker tests are green. **Out of scope:** - Merge folding and `interaction.attribute`. Both already behave as ruled at #105. - Links on Interactions without an `event_id`, such as mail evidence. - Any change to the Card App view. **Sequencing:** This slice bumps the schema and touches manual events. Do not run it in parallel with another schema-bumping slice, or with #113.
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 substrate · dispatch effort high

Run: 20261108T021548Z-50bea2a7

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

Open risks:

  1. Per-path choice, left to the implementer by the triage brief. Lean: FOLD endpoint.unshare and the endpoint.share undo, because no Action removes one event participant, so a refusal would block them until the event is retracted. REFUSE handle.move and its undo with participant-present, because the caller named the row and can leave it out, matching the existing handle-present refusal. Question: does the architect accept fold/fold/refuse, and the reading that 'with the reason named' applies to refusals, with folds recorded in the unshare undo record and explained in the PR? [decision]
  2. The schema-22 migration fold deletes duplicate link rows that pending undo records may name (for example an unshare whose undo window is still open). That undo will answer 'conflict reason=revision interaction=' instead of applying. Question: is an honest conflict acceptable under ruling 14 (undo never restores part of an Action)? Lean: yes; rewriting undo records during the migration is out of scope. [decision]
  3. The Card App split_preview JSON gains participant_present, but card.html (:720-730) does not render it or disable Apply on it (Card App changes are out of scope). A Card-driven handle.move onto an existing participant therefore shows the refusal only after Apply. Question: open a follow-up issue for the Card App preview? [decision]
  4. This slice takes schema 22 on the assumption that no other schema-bumping slice merges first. The triage brief says not to run it in parallel with #113 or another schema slice, but does not say which goes first, and #113's state could not be queried here (gh denied). Question: dispatch now, or wait behind #113 or any in-flight schema slice? If 22 is taken first, re-run Half A and take the next free version (ADR 0005 Am.5 ruling 15). [decision]

Change: Schema 22 in store.open_writer: set SCHEMA_VERSION to 22 and rename SCHEMA_21 to SCHEMA_22. Add an EVENT_LINK_FOLDS tuple that runs after the UPGRADES loop and before INDEXES (store.py:352-357). It deletes duplicate (event_id, person_id) links, keeping MIN(id), and drops interactions_event. Replace INDEXES[3] (store.py:188) with CREATE UNIQUE INDEX IF NOT EXISTS interactions_event_person ON interactions(event_id, person_id) WHERE event_id IS NOT NULL; SQLite treats NULLs as distinct, so this enforces 'both set' and keeps the event_id-only query plans. In graph.py, add _fold_endpoint_links shaped like _fold_events (graph.py:417-425). endpoint.unshare folds after the would-remerge checks (between :2482 and :2483) and records 'folded' in its undo record. Unshare undo re-inserts the folded rows under their original ids, mirroring the unmerge event_links restore (graph.py:1266-1276). The share undo's exclusive sweep (graph.py:2570-2577) folds before its UPDATE. handle.move refuses 'failed reason=participant-present item=interaction:' through a new split_plan 'participant_present' list and a new entry in the refusal loop (graph.py:2829-2834); split_preview_text surfaces it (views.py:643,687). handle.move undo answers 'conflict reason=participant-present interaction=' before _move_allocation (graph.py:3053-3062), mirroring the handle-present undo conflict. Remove the MIN(j.id) collapse from views.RECENT (views.py:89-90). Replace the test_duplicate_links_collapse_on_read test that pins two links, and add the migration test (mirror test_archive.py:350-366) and the path tests.

Files: src/people_mind_mcp/store.py · src/people_mind_mcp/graph.py · src/people_mind_mcp/views.py · tests/test_interactions.py

Decision: accept the 4 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-08-keep-one-link-per-person-on-a-manual-event.md — next: codex-svd dispatch --args '<same-json>' --approved-spec-path /Users/piers/.local/state/exhaust/groupthink/specs/2026-11-08-keep-one-link-per-person-on-a-manual-event.md

### ⏸ SVD architect gate: dev/people-mind-mcp#147 keep-one-link-per-person-on-a-manual-event **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 effort `high` **Run:** `20261108T021548Z-50bea2a7` **Held because:** CLEAN but 4 open risk(s) (4 decision) — HOLD-ALL parks everything. The risks, verbatim: **Open risks:** 1. Per-path choice, left to the implementer by the triage brief. Lean: FOLD endpoint.unshare and the endpoint.share undo, because no Action removes one event participant, so a refusal would block them until the event is retracted. REFUSE handle.move and its undo with participant-present, because the caller named the row and can leave it out, matching the existing handle-present refusal. Question: does the architect accept fold/fold/refuse, and the reading that 'with the reason named' applies to refusals, with folds recorded in the unshare undo record and explained in the PR? [decision] 2. The schema-22 migration fold deletes duplicate link rows that pending undo records may name (for example an unshare whose undo window is still open). That undo will answer 'conflict reason=revision interaction=<id>' instead of applying. Question: is an honest conflict acceptable under ruling 14 (undo never restores part of an Action)? Lean: yes; rewriting undo records during the migration is out of scope. [decision] 3. The Card App split_preview JSON gains participant_present, but card.html (:720-730) does not render it or disable Apply on it (Card App changes are out of scope). A Card-driven handle.move onto an existing participant therefore shows the refusal only after Apply. Question: open a follow-up issue for the Card App preview? [decision] 4. This slice takes schema 22 on the assumption that no other schema-bumping slice merges first. The triage brief says not to run it in parallel with #113 or another schema slice, but does not say which goes first, and #113's state could not be queried here (gh denied). Question: dispatch now, or wait behind #113 or any in-flight schema slice? If 22 is taken first, re-run Half A and take the next free version (ADR 0005 Am.5 ruling 15). [decision] **Change:** Schema 22 in store.open_writer: set SCHEMA_VERSION to 22 and rename SCHEMA_21 to SCHEMA_22. Add an EVENT_LINK_FOLDS tuple that runs after the UPGRADES loop and before INDEXES (store.py:352-357). It deletes duplicate (event_id, person_id) links, keeping MIN(id), and drops interactions_event. Replace INDEXES[3] (store.py:188) with CREATE UNIQUE INDEX IF NOT EXISTS interactions_event_person ON interactions(event_id, person_id) WHERE event_id IS NOT NULL; SQLite treats NULLs as distinct, so this enforces 'both set' and keeps the event_id-only query plans. In graph.py, add _fold_endpoint_links shaped like _fold_events (graph.py:417-425). endpoint.unshare folds after the would-remerge checks (between :2482 and :2483) and records 'folded' in its undo record. Unshare undo re-inserts the folded rows under their original ids, mirroring the unmerge event_links restore (graph.py:1266-1276). The share undo's exclusive sweep (graph.py:2570-2577) folds before its UPDATE. handle.move refuses 'failed reason=participant-present item=interaction:<id>' through a new split_plan 'participant_present' list and a new entry in the refusal loop (graph.py:2829-2834); split_preview_text surfaces it (views.py:643,687). handle.move undo answers 'conflict reason=participant-present interaction=<id>' before _move_allocation (graph.py:3053-3062), mirroring the handle-present undo conflict. Remove the MIN(j.id) collapse from views.RECENT (views.py:89-90). Replace the test_duplicate_links_collapse_on_read test that pins two links, and add the migration test (mirror test_archive.py:350-366) and the path tests. **Files:** `src/people_mind_mcp/store.py` · `src/people_mind_mcp/graph.py` · `src/people_mind_mcp/views.py` · `tests/test_interactions.py` **Decision:** accept the 4 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-08-keep-one-link-per-person-on-a-manual-event.md` — next: `codex-svd dispatch --args '<same-json>' --approved-spec-path /Users/piers/.local/state/exhaust/groupthink/specs/2026-11-08-keep-one-link-per-person-on-a-manual-event.md`</sub>
Collaborator

spec-verify-dispatch Half B for dev/people-mind-mcp#147 keep-one-link-per-person-on-a-manual-event completed integration verify.

  • PR: #163
  • Branch: feat/svd-dev-people-mind-mcp-147-keep-one-link-per-person-on-a0330141
  • Commit: 18c4d8928a
  • 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/145/1
  • Checks: required ci/woodpecker/pr/validation resolved pass by CI-wait poll
  • Warning: self-review: ADR 0004 Amendment 4 still describes read-time duplicate collapse -> not fixed: the approved spec explicitly leaves ADR updates out of scope.
  • Warning: Remote check ci/woodpecker/pr/validation is still pending; the runner must re-poll.
  • CI wait: ci/woodpecker/pr/validation -> pass
  • Decision: review the PR and merge? (codex-svd ship --run-id 20261108T052624Z-a0330141 --confirm-merge)
spec-verify-dispatch Half B for dev/people-mind-mcp#147 keep-one-link-per-person-on-a-manual-event completed integration verify. - PR: https://git.groupthink.asia/dev/people-mind-mcp/pulls/163 - Branch: feat/svd-dev-people-mind-mcp-147-keep-one-link-per-person-on-a0330141 - Commit: 18c4d8928ad210dcc283c62ab00fd6b45fe65bc6 - 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/145/1 - Checks: required ci/woodpecker/pr/validation resolved pass by CI-wait poll - Warning: self-review: ADR 0004 Amendment 4 still describes read-time duplicate collapse -> not fixed: the approved spec explicitly leaves ADR updates out of scope. - Warning: Remote check ci/woodpecker/pr/validation is still pending; the runner must re-poll. - CI wait: ci/woodpecker/pr/validation -> pass - Decision: review the PR and merge? (`codex-svd ship --run-id 20261108T052624Z-a0330141 --confirm-merge`)
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#147
No description provided.