Feature #44818
openRecord and display the source of a change (API client, OAuth application, AI agent)
Description
- Problem
More and more changes in Redmine are made by software acting under a real
user's identity: MCP servers and AI agents (#42689), OAuth applications via the
6.1 provider, scripts using a personal API key, mail handlers, or admin
impersonation via X-Redmine-Switch-User. Redmine records all of these exactly
like a change the user made in the browser. There is no way to tell "Jan wrote
this note" from "an agent wrote this note in Jan's name".
Today the only workaround is a signature in the text ("Updated by <model>").
That is visible to everyone regardless of permissions, can't be filtered or
queried, survives quoting and mail, and depends on every client remembering
to add it.
A second problem follows from the first: when an agent acts in your name,
Redmine treats the change as yours, and "Do not notify me about changes I make
myself" suppresses the mail. The person whose name is on the change is the one
person who never finds out about it.
- Proposal
- 1. A "source" on authored content
A short, optional string stored with the content it describes, saying where
that content came from. Values are whatever the client sends (in practice a
model or application name, e.g. `claude-opus-5`), `API` for API requests that
send nothing, `email` for content created by the mail handler (see the open
question below), and empty for the web UI.
It is implemented once, as a model concern (`acts_as_sourced`, or similar),
that stamps the record from the current request's source on save. Core models
opt in; plugin models can opt in the same way.
Core models covered:
| Content | Column | When it is stamped |
| --- | --- | --- |
| Issue | `issues.source` | on creation only (later changes have journals) |
| Issue update / note | `journals.source` | on creation; editing a note re-stamps it |
| Time entry | `time_entries.source` | on creation; rewriting hours or comment re-stamps it, moving it to another date/activity/issue does not |
| Wiki page | `wiki_contents.source` (+ `wiki_content_versions.source`, copied by `create_version`) | every save |
| Forum message | `messages.source` | on creation; editing re-stamps it |
| News | `news.source` | on creation; editing re-stamps it |
| News comment | `comments.source` | on creation |
| Document | `documents.source` | on creation |
| Attachment | `attachments.source` | on upload |
The source is not journalized. It is metadata about a change, not an attribute
whose changes are tracked.
- 2. Setting the source
- Per request, so that one API call stamps everything it creates the same way
(an issue update that also logs time stamps both the journal and the time
entry): * `X-Redmine-Source` header, or * a `source` attribute in the request body (`issue[source]`,
`time_entry[source]`, `wiki_page[source]`, …). The body wins if both are
present. - API request with neither → `API`.
- OAuth request with neither → the OAuth application's name, so attribution
works without the client cooperating. Open question: should an OAuth
client be allowed to override its own application name? - Mail handler → `email`. Open question, needs careful thought: content
created by mail is already attributed to a user, but that user isn't
always the person who wrote it. With `unknown_user=accept` it lands on
Anonymous, with `unknown_user=create` on an account created from the
sender's address, and a forwarded mail or a shared mailbox is attributed
to whoever's address matched. `email` says the content came in by mail,
not whose mail it was. Should the source also carry the sender's address
in those cases, and since that is personal data, who may see it? - Web UI → empty. Nothing changes for normal use.
Anyone who may create the content may set its source. Writing is not gated;
reading is (see below).
- 3. Showing the source
Behind a new permission, "View content source". It is not tied to a module,
like `view_project`, because it spans issues, time tracking, wiki, forums,
news and documents.
- `authoring` takes the source, so every "Added by / Updated by X … ago"
sentence gets it in one place: "Updated by Jan Novák via claude-opus-5
3 days ago". That covers issues, journals, time entries, messages, news and
documents. - Wiki: the "Updated by … ago" line and the page history.
- Notification mails: "Issue #123 has been updated by Jan Novák via …", and
the same for the other mail types. - Activity page and Atom feeds.
- Queries: a Source column and filter on the spent time list, and on the
issue list ("Created via" / "Updated via" filters). - REST API, JSON and XML: `source` on every covered resource. In core this is
one line per `.api.rsb` template.
Users without the permission see exactly what they see today, in the UI, the
API and mails.
- 4. Notifying the person a change was made for
A new user preference, offered only to users who can see sources, shown as an
exception right under "Do not notify me about changes I make myself":
[ ] …except changes made in my name through an integration
When it is on, a change carrying a source other than empty (web) or `API`
reaches its author by mail even though they made it "themselves". Plain `API`
is excluded on purpose: a script running on your own key is your own action,
an agent acting on your behalf is not. Open question: should plain `API` be
a separate choice?
This has to account for how recipients are built today:
- Issues. Writing a note makes its author a watcher (if auto-watch is on),
so the author is already a recipient. `Mailer#mail` then drops them because
of the "own changes" preference. The fix is a check against the source at
that point. No new recipients are added. - Wiki. Core has no auto-watch for wiki edits, so the author of an agent
edit is never a recipient in the first place. `WikiContent#notified_users`
should add the author for sourced changes when the preference is on and they
can see the page. This is the one place where the list of recipients grows. - Forums and news. Same as issues where the author is already a watcher
or recipient; otherwise same as wiki. - Time entries. Redmine sends no mail for time entries, so nothing here.
The source is recorded and shown. - "No events" notification setting. Still sends nothing. The preference
only reverses the "own changes" rule; it does not override a user who
opted out of all mail.
Our plugin does this by restoring the author's address after `Mailer#mail`
has already removed it (issues), and by patching
`WikiContent#notified_users` (wiki). It's the most fragile part of the
plugin. In core it's simple, because core already makes both decisions.
- Why core and not a plugin
We run this as a plugin in production (issues, journals, time entries, wiki,
mail, self-notification, API, permission, tests). It works, but it has to:
- hook `ApplicationHelper#authoring` and find the journal by user + timestamp,
because the helper is given only those two - answer the mail views' `l(:text_issue_added, …)` calls with different keys
to get the source into the opening sentence - restore a recipient after `Mailer#mail` has removed it
- decode, extend and re-encode JSON responses in after_actions (no XML)
- repeat each of these for every content type it covers
These are fragile seams that break when core changes and collide with other
plugins. In core, it's a column per table, one concern, one argument to
`authoring`, one line per API template, and one condition where the own-change
recipient is removed.
It also complements #43881: that ticket records requests for admins; this
records content for users.
I'm happy to prepare a patch against trunk with tests if the direction is
acceptable. It can be split if preferred: (1) concern + issues/journals/time
entries + API, (2) wiki/forums/news/documents/attachments, (3)
self-notification.
No data to display