paperclip/packages/db/src
Dotta 10d0555189
fix(interactions): authorize resolvers consistently (#11376)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - Issue interactions give agents and people a structured decision
record.
> - Resolver routes used different authorization rules.
> - Some routes blocked valid agents, including task watchdogs with
normal issue access.
> - The API did not show who could resolve a pending interaction.
> - This pull request gives every interaction kind one resolver policy
evaluator.
> - The benefit is a clear decision path with consistent governance and
company isolation.

## Linked Issues or Issue Description

Fixes: #8087

Refs: #7403

Related PR: #11082 proposes board-only confirmation rules. This change
keeps human-only review as an explicit policy.

**What happened?**

Agents could create issue interactions. Some resolver routes still
required board access.

This left valid agent confirmations pending. Task watchdogs could see
the same problem without board identity.

**Expected behavior**

Every interaction kind must use one resolver policy contract.

The contract must support `anyone`, `not_creator`, and `human_only`. It
must also apply all normal governance controls.

**Steps to reproduce**

1. Create a `request_confirmation` interaction as an agent.
2. Resolve it with another authorized agent.
3. Observe the board-only denial.

**Paperclip version or commit**

The problem exists on `master` before this change.

**Deployment mode**

Local development with `pnpm dev`.

## What Changed

- Add canonical policies for `anyone`, `not_creator`, and `human_only`.
- Use one server evaluator for every interaction kind.
- Apply named addressees, company limits, review rules, and task
watchdog scope.
- Charge cross-issue resolutions to the existing per-run action limit.
- Return the effective resolver audience in attention and interaction
data.
- Show the audience, governance choices, and denial reasons in the board
UI.
- Add telemetry, API documents, product documents, and regression
fixtures.
- Add migration provenance for safe legacy behavior.
- Make migration `0218` safe for complete replays and partial prior
runs.

## Product Rules

- An interaction records a response. It does not grant authority for the
next action.
- `anyone` lets any authorized issue participant respond.
- `not_creator` requires a responder other than the interaction creator.
- `human_only` requires an authorized person.
- A named addressee, company policy, or governed action can narrow the
audience.
- These controls cannot widen the audience.
- A task watchdog uses the same rules as an ordinary agent.
- A task watchdog does not receive board authority.
- An agent resolution on another issue uses the shared cross-issue
action limit.
- Legacy pending interactions keep their earlier restrictions.
- The UI shows the effective audience and a permanent denial reason.

## Verification

- `pnpm --filter @paperclipai/db check:migrations`
- `pnpm --filter @paperclipai/db typecheck`
- `pnpm exec vitest run
packages/db/src/issue-thread-interaction-resolver-policy-migration.test.ts`
- The focused PostgreSQL test applies migration `0218` twice.
- The test also completes a partial prior run and preserves existing
provenance.
- The latest GitHub head has 29 successful checks.
- The opt-in Storybook visual check skipped as expected.
- Greptile reports 5/5 with no open comments.

## Risks

- New interaction writes use `anyone` by default.
- Callers must select `not_creator` or `human_only` when they need
stricter review.
- Legacy pending interactions keep the old creator and human
restrictions.
- Migration `0218` fills only missing provenance fields during recovery.
- Cross-issue resolutions can reach the existing action limit.
- The shared evaluator affects every interaction kind.
- Route, service, database, shared contract, and UI tests cover these
rules.

> This work matches the Agent Reviews and Approvals direction in
`ROADMAP.md`. It does not duplicate a planned item.

## Model Used

OpenAI Codex, GPT-5. The runtime does not expose the exact deployment ID
or context window.

The agent used reasoning, repository tools, shell commands, and test
execution.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either linked public issues or described the issue with the
required labels
- [x] I have not referenced internal Paperclip issues or links
- [x] My branch name describes the change and contains no internal
ticket id
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation
- [x] I have considered and documented the risks
- [x] All Paperclip CI gates are green
- [x] Greptile is 5/5 with no open comments
- [x] I will address all Greptile and reviewer comments before
requesting merge

---------

Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-08-16 13:46:50 -05:00
..
migrations fix(interactions): authorize resolvers consistently (#11376) 2026-08-16 13:46:50 -05:00
schema fix(interactions): authorize resolvers consistently (#11376) 2026-08-16 13:46:50 -05:00
adapter-auth-sessions-schema.test.ts Add sandbox device-login for the Codex adapter (#11237) 2026-08-12 08:58:25 -07:00
agent-wakeup-requests-schema.test.ts feat: maintained in_review review-path contract + stalled-review actions (#10675) 2026-08-04 13:54:40 -05:00
backup-lib.test.ts fix(db): use calendar month retention for backups (#3718) 2026-07-24 13:12:43 -05:00
backup-lib.ts fix(db): use calendar month retention for backups (#3718) 2026-07-24 13:12:43 -05:00
backup.ts
built-in-agent-unique-marker-migration.test.ts fix: prevent duplicate built-in agents and self-heal reconciliation (#10223) 2026-07-28 11:12:58 -07:00
check-migration-numbering.ts
check-migration-safety.test.ts feat(db): add migration safety lint 2026-07-07 01:43:12 +00:00
check-migration-safety.ts feat(db): add migration safety lint 2026-07-07 01:43:12 +00:00
client-options.test.ts db: env-configurable client options; parallelize attention feed queries (#10795) 2026-08-04 06:30:36 -07:00
client.test.ts feat(skills): import skills from projects (#9620) 2026-07-15 18:01:44 -05:00
client.ts db: env-configurable client options; parallelize attention feed queries (#10795) 2026-08-04 06:30:36 -07:00
company-secret-proposals-migration.test.ts fix(db): give the last two embedded-Postgres migration tests a timeout (#11313) 2026-08-12 21:30:50 -07:00
connections-v3-schema-core-migration.test.ts feat(connections): add v3 schema core (#9958) 2026-07-21 15:16:26 -05:00
decision-queue-migrations.test.ts feat(decisions): add desk workflow and retention (#10672) 2026-08-02 10:47:03 -05:00
embedded-postgres-error.test.ts
embedded-postgres-error.ts
embedded-postgres-native.test.ts feat(cli): add managed install, update, and service lifecycle (#10045) 2026-07-31 18:52:23 -07:00
embedded-postgres-native.ts
environment-custom-images-schema.test.ts Scope environment custom images to instance environments (#8850) 2026-07-01 23:57:31 -07:00
external-objects-schema.test.ts External object references across issue surfaces (#8512) 2026-06-23 08:27:19 -05:00
heartbeat-context-snapshot-index-migration.test.ts perf(server): cut steady-state DB hot paths in dashboard, attention, and productivity sweeps (#10992) 2026-08-06 11:56:40 -05:00
inbox-archive-agent-policies-migration.test.ts feat(authz): govern agent inbox archive access (#9658) 2026-07-16 09:51:48 -05:00
index.ts feat(mcp) [split 2/8]: add governed access contracts (#9557) 2026-07-14 12:57:20 -05:00
issue-comment-derived-attribution-migration.test.ts fix(db): relocate slow 0126 issue-comment attribution backfill to fast idempotent 0132 (#9108) 2026-07-06 11:41:24 -07:00
issue-comment-on-behalf-migration.test.ts feat(issues): contain cross-issue agent side effects (#10837) 2026-08-04 13:17:49 -05:00
issue-thread-interaction-resolver-policy-migration.test.ts fix(interactions): authorize resolvers consistently (#11376) 2026-08-16 13:46:50 -05:00
migrate.ts
migration-runtime.ts
migration-safety-baseline.ts feat(db): add migration safety lint 2026-07-07 01:43:12 +00:00
migration-status.ts
nested-skill-folders-migration.test.ts feat: organize skills with nested folders and My Skills (#9633) 2026-07-16 15:50:45 -05:00
pipelines-schema.test.ts Add pipeline workflow primitives and operator UI (#7903) 2026-06-26 12:02:44 -05:00
runtime-config.test.ts
runtime-config.ts
seed.ts
status-card-migrations.test.ts fix(db): give the last two embedded-Postgres migration tests a timeout (#11313) 2026-08-12 21:30:50 -07:00
summary-slots-schema.test.ts feat: add built-in summarizer and summary slots (#9713) 2026-07-17 11:03:07 -05:00
table-size-estimates.ts Replace host-to-host Cloud Sync with full-fidelity company Import/Export (#10507) 2026-07-30 11:37:00 -07:00
test-embedded-postgres.test.ts fix(db): harden embedded Postgres test start with bounded retry (#10540) 2026-07-30 22:22:31 -07:00
test-embedded-postgres.ts fix(db): harden embedded Postgres test start with bounded retry (#10540) 2026-07-30 22:22:31 -07:00