feat(logging): record repository, user and viewer on log records

Handlers that resolve an anonymized repository, pull request or gist now
put its public ID on the log context, so request, job and error records
carry repoId, pullRequestId or gistId. The signed-in user's internal _id
(userId) is recorded on account routes. On routes that serve anonymized
content, userId is kept only when the user owns, co-authors or
administers the project; otherwise the record carries viewer "visitor"
or "anonymous" and no userId. The collector, the Redis mirror and the
admin log APIs apply the same rule. Jobs carry repoId and the owner's
userId stamped at enqueue time.

The admin Errors page links repoId to the admin repository search and
userId to the admin user page, which now accepts a user _id.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Thomas DurieuxandClaude Opus 5.5 committed 2026-11-29 12:36:09 +00:00
1 parent 2f38fc6a51
commit 86a35d62f1
22 files changed
+474 -70

No files matched your search

+1 -1
View File
@@ -42,7 +42,7 @@ describe('structured logging privacy and context', function () {
it('sets sandbox job context and preserves success/failure semantics', async () => {
const requestId = randomUUID(), jobId = randomUUID();
const processor = loggedJob('download', async () => {
expect(logContext.getStore()).to.deep.equal({ service: 'worker', requestId, jobId, attempt: 3 });
expect(logContext.getStore()).to.deep.equal({ service: 'worker', requestId, jobId, attempt: 3, repoId: 'private-id' });
throw new Error('fixture failure');
});
try { await processor({ data: { repoId: 'private-id', requestId, logJobId: jobId }, attemptsMade: 2 }); }