Skip to content

Enforce task assignees and creator, add Find keys - #9602

Draft
morgmart wants to merge 2 commits into
morganm/channel-accessfrom
morganm/artifact-assignees
Draft

morgmart wants to merge 2 commits into
morganm/channel-accessfrom
morganm/artifact-assignees

Conversation

@morgmart

@morgmart morgmart commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #9582 (channel access). Review only the last two commits; the base branch carries the rest of the stack.

What

The relay now enforces who a task can name, and Find can ask for what the task screens need.

  • Assignees (NIP-AR). ["assignee", <hex pubkey>]: lowercase hex, distinct, at most 4 per revision, people only. Assignees are checked when someone is assigned and when the task moves:
    • A create, move or restore checks every assignee.
    • An update checks only the people it adds, compared with the task's stored current state. Someone who lost access since being assigned doesn't block an unrelated edit, and can't read the task anyway.
    • A checked assignee must be able to read the home the revision puts the task in. Readability uses the same lookup as the channel-access answer (channel_access::can_read), so parents and parent_access count.
  • Creator. ["creator", <hex pubkey>], at most once. On create it must be the signer. Every later revision carries the same creator, or none when the task was created without one.
  • Signer. A known agent can't sign a task save. Agents act through their owner's key with a "via" label. Their comments in the task's conversation are untouched.
  • Stored state. The task's head keeps its creator and current assignees, in migration 0096. Expiring or redacting earlier revisions can't change the rules. An empty list means nobody is assigned; NULL means "saved before this change".
  • Tasks saved before 0096 get their creator and assignees filled on their next save, inside the save's lock. This isn't done as a backfill in the migration, because the migration rules forbid changing existing rows there.
    • The creator is the signer of the first save while that save is still stored. Failing that, it's the current revision's tag. If neither is on hand, the creator stays unknown, and nobody can claim it later.
    • The assignees come from the current revision.
    • A task is never left uneditable. A creator-changed refusal names the creator to resend with.
  • Reason codes. Every refusal reads invalid: <code>:<keys> — <text>, following the relay's existing invalid: policy:nobody — … form. The codes are assignee-unreadable, assignee-agent, too-many-assignees, signer-agent, creator-not-signer and creator-changed. NIP-AR documents them.
  • Find keys for current-state artifact queries:
    • "unassigned": true: only artifacts with no assignee tag. It can't be combined with #assignee.
    • "within": <channel id>: the channel and everything filed under it, down to grandchildren, still limited to what the reader can read.
    • "until": <unix seconds>: revisions created at or before it, newest created_at first. It is inclusive, so the next page starts at the oldest one got and the client drops the repeat.
    • history and head refuse unassigned and within. Incremental reads refuse all three, so a filter is never silently ignored.
  • NIP-11 advertises buzz-artifact-assignees.

Known gaps

  • Agents are recognized only when known. The relay treats a key as an agent only once it has an owner on record. That record is written only from a verified owner attestation (NIP-OA, or a NIP-FI agent assertion), and it is never rewritten. Some agents look like people to the relay:

    • an agent that never presented an attestation
    • a key marked as a bot only by its channel role
    • an agent whose owner's account was hard-deleted

    The app's own rule stays the first line.

  • Hosted agents are covered only if their runner sends the owner attestation when it connects. Nothing in the relay records an owner for them by any other path.

  • The assignee check runs just before the save's transaction. The decision about who counts as added, and the fill for older tasks, happen inside the lock. A removal that lands between the check and the save leaves an assignee who can't read the task, which is the same state as losing access later. The next edit isn't blocked by it.

Testing

  • Postgres tests (artifact_assignee_postgres_tests.rs) through real ingest:
    • Who can be assigned.
      • An outsider is refused by name.
      • A project member is accepted in a child.
      • A move that strands someone is refused, and a move without them is accepted.
      • After someone loses access, a title edit that keeps them is accepted, even once the revision that assigned them has expired.
      • A move or restore that keeps them is refused.
      • Five assignees, an agent assignee, and an agent signer are each refused with their code.
    • The creator is the signer and never changes. This holds through updates, moves, and a delete and restore, with the refusal naming the creator.
    • Tasks saved before 0096 stay editable.
      • A title edit keeps an assignee who lost access.
      • The first save's signer outranks an unverified tag on the current revision.
      • With the first save expired, the current revision's tag is used.
      • With neither on hand, the creator stays unknown and can't be claimed.
    • Find.
      • Searches by assignee and status, and with unassigned, return the right tasks.
      • within reaches a project's grandchildren.
      • until pages newest first with an inclusive edge.
      • Every result stays inside what the reader may read, and an incremental read with the new keys is refused.
  • Unit tests for tag validation and query parsing.
  • Mutation checks: 17 deliberate breaks each turn a test red. They cover the people-added rule, move and restore checking everyone, the cap, both agent checks, the creator rules, the stored state, every step of the fill for older tasks, and the unassigned and until filters.
  • Database tests and every artifact test pass (858). Clippy is clean.

🤖 Generated with Claude Code

The relay now checks the assignee and creator tags on NIP-AR artifacts.
Every assignee must be able to read the home a revision puts the
artifact in, judged with the same lookup as the channel-access answer.
The creator must be the signer on create and stays the same on every
later revision; the artifact head now stores it, so the check survives
retention and redaction.

Find gains `unassigned`, `within` (a channel and what is filed under
it) and `until` (inclusive, newest created first) for current-state
queries. History, head and incremental reads refuse what they cannot
honor.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: morgmart <98432065+morgmart@users.noreply.github.com>
An update is checked only for the assignees it adds, against the head's
stored list; a create, move or restore checks everyone. At most four
assignees, and known agents (an owner on record) can neither be assigned
nor sign a revision. Every refusal carries a stable NIP-AR reason code
and the keys involved.

The head now stores the current assignees as well as the creator. A
head saved before 0096 fills both on its next save, under the lock: the
creator from the first save's signer, else the current tag, else
unknown, so no task becomes uneditable and none can be claimed later.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: morgmart <98432065+morgmart@users.noreply.github.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant