Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

fix(open-knowledge): keep untaggable logs in bug reports (PRD-7784) (#3273)

Andrew Mikofalvy7120dc1f61f6
diff --git a/packages/cli/src/commands/bug-report-bundle.test.ts b/packages/cli/src/commands/bug-report-bundle.test.ts
index c6e126612..74916d29e 100644
--- a/packages/cli/src/commands/bug-report-bundle.test.ts
+++ b/packages/cli/src/commands/bug-report-bundle.test.ts
@@ -7,10 +7,12 @@
import { execSync } from 'node:child_process';
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
import { homedir, tmpdir } from 'node:os';
-import { dirname, join, resolve } from 'node:path';
+import { basename, dirname, join, resolve } from 'node:path';
import { afterEach, describe, expect, test } from 'vitest';
import {
+ type BundleLogger,
collectStandardBundle,
+ collectUserLogFiles,
defaultBugReportZipPath,
okBugReportsDir,
} from './bug-report-bundle.ts';
@@ -184,6 +186,25 @@ describe('collectStandardBundle — redaction', () => {
});
});
+// Record shapes of the three writers that share `~/.ok/logs`. Only the CLI
+// logger's pino base carries a `project` field. The desktop logger's base has
+// no such key, and the MCP stderr mirror is plain text rather than JSON — so a
+// slug predicate is *inapplicable* to those two families, not false for them,
+// and cannot decide whether they belong in a bundle.
+const CLI_LOG_MATCHING_SLUG =
+ '{"level":30,"time":"2026-08-05T10:00:00.000Z","pid":51000,"runtime":"cli","project":"bundle-proj","name":"cli","command":"start"}\n';
+const CLI_LOG_OTHER_PROJECT =
+ '{"level":30,"time":"2026-08-04T10:00:00.000Z","pid":50000,"runtime":"cli","project":"someone-else","name":"cli","command":"start"}\n';
+const DESKTOP_LOG_LINE =
+ '{"level":30,"time":"2026-08-05T10:00:00.000Z","pid":46323,"runtime":"desktop","name":"desktop","subsystem":"boot","event":"desktop.boot","version":"0.48.7"}\n';
+const MCP_MIRROR_LINE = '2026-08-05T10:00:00.000Z [mcp] stdio server ready\n';
+// The desktop log is the only sink for the captured renderer console, which can
+// serialize arbitrary application data — including another project's slug in the
+// exact shape the CLI predicate looks for. That coincidence must not reclassify
+// the file, so taggability is decided from the writer that owns the filename and
+// never from the bytes.
+const DESKTOP_LOG_WITH_FOREIGN_SLUG_IN_CONSOLE = `${DESKTOP_LOG_LINE}{"level":30,"time":"2026-08-05T10:00:01.000Z","pid":46323,"runtime":"desktop","name":"desktop","subsystem":"renderer","event":"renderer.console","args":[{"project":"someone-else"}]}\n`;
+
describe('collectStandardBundle — user-level logs', () => {
test('includes .log and rotated .log.N files, skipping other extensions', async () => {
const userLogsDir = makeTmpDir();
@@ -202,8 +223,8 @@ describe('collectStandardBundle — user-level logs', () => {
test('narrows user logs to those mentioning the project slug when any match', async () => {
const userLogsDir = makeTmpDir();
- writeFileSync(join(userLogsDir, 'match.log'), '{"project":"bundle-proj"}\n');
- writeFileSync(join(userLogsDir, 'other.log'), '{"project":"someone-else"}\n');
+ writeFileSync(join(userLogsDir, 'cli.2026-08-05.log'), '{"project":"bundle-proj"}\n');
+ writeFileSync(join(userLogsDir, 'cli.2026-08-04.log'), '{"project":"someone-else"}\n');
const projectDir = makeProjectDir('bundle-proj');
const outputPath = join(makeTmpDir(), 'report.zip');
@@ -215,14 +236,14 @@ describe('collectStandardBundle — user-level logs', () => {
});
const entries = listZipEntries(zipPath);
- expect(entries).toContain('logs/match.log');
- expect(entries).not.toContain('logs/other.log');
+ expect(entries).toContain('logs/cli.2026-08-05.log');
+ expect(entries).not.toContain('logs/cli.2026-08-04.log');
});
test('keeps every user log when none mention the project slug', async () => {
const userLogsDir = makeTmpDir();
- writeFileSync(join(userLogsDir, 'a.log'), 'no slug here\n');
- writeFileSync(join(userLogsDir, 'b.log'), 'none here either\n');
+ writeFileSync(join(userLogsDir, 'cli.2026-08-05.log'), 'no slug here\n');
+ writeFileSync(join(userLogsDir, 'cli.2026-08-04.log'), 'none here either\n');
const projectDir = makeProjectDir('bundle-proj');
const outputPath = join(makeTmpDir(), 'report.zip');
@@ -234,8 +255,292 @@ describe('collectStandardBundle — user-level logs', () => {
});
const entries = listZipEntries(zipPath);
- expect(entries).toContain('logs/a.log');
- expect(entries).toContain('logs/b.log');
+ expect(entries).toContain('logs/cli.2026-08-05.log');
+ expect(entries).toContain('logs/cli.2026-08-04.log');
+ });
+
+ test('keeps log families that cannot carry a project slug when another log matches', async () => {
+ const userLogsDir = makeTmpDir();
+ writeFileSync(join(userLogsDir, 'cli.2026-08-05.log'), CLI_LOG_MATCHING_SLUG);
+ writeFileSync(join(userLogsDir, 'desktop.2026-08-05.log'), DESKTOP_LOG_LINE);
+ writeFileSync(join(userLogsDir, 'mcp.2026-08-05.log'), MCP_MIRROR_LINE);
+ const projectDir = makeProjectDir('bundle-proj');
+ const outputPath = join(makeTmpDir(), 'report.zip');
+
+ const { zipPath, summary } = await collectStandardBundle({
+ projectDir,
+ redact: true,
+ outputPath,
+ userLogsDir,
+ });
+
+ const entries = listZipEntries(zipPath);
+ expect(entries).toContain('logs/cli.2026-08-05.log');
+ expect(entries).toContain('logs/desktop.2026-08-05.log');
+ expect(entries).toContain('logs/mcp.2026-08-05.log');
+
+ // The MANIFEST is the triager's inventory and records only what was
+ // written, so a family missing here is indistinguishable from one that
+ // never existed.
+ const manifest = JSON.parse(readZipEntry(zipPath, 'MANIFEST.json'));
+ expect(manifest.files).toEqual(summary.files);
+ expect(manifest.files).toContain('logs/desktop.2026-08-05.log');
+ expect(manifest.files).toContain('logs/mcp.2026-08-05.log');
+ });
+
+ test('still excludes a project-taggable log belonging to another project', async () => {
+ const userLogsDir = makeTmpDir();
+ writeFileSync(join(userLogsDir, 'cli.2026-08-05.log'), CLI_LOG_MATCHING_SLUG);
+ writeFileSync(join(userLogsDir, 'cli.2026-08-04.log'), CLI_LOG_OTHER_PROJECT);
+ writeFileSync(join(userLogsDir, 'desktop.2026-08-05.log'), DESKTOP_LOG_LINE);
+ writeFileSync(join(userLogsDir, 'mcp.2026-08-05.log'), MCP_MIRROR_LINE);
+ const projectDir = makeProjectDir('bundle-proj');
+ const outputPath = join(makeTmpDir(), 'report.zip');
+
+ const { zipPath } = await collectStandardBundle({
+ projectDir,
+ redact: true,
+ outputPath,
+ userLogsDir,
+ });
+
+ const entries = listZipEntries(zipPath);
+ expect(entries).toContain('logs/cli.2026-08-05.log');
+ expect(entries).toContain('logs/desktop.2026-08-05.log');
+ expect(entries).toContain('logs/mcp.2026-08-05.log');
+ expect(entries).not.toContain('logs/cli.2026-08-04.log');
+ });
+
+ test('keeps a desktop log whose captured console mentions another project', async () => {
+ const userLogsDir = makeTmpDir();
+ writeFileSync(join(userLogsDir, 'cli.2026-08-05.log'), CLI_LOG_MATCHING_SLUG);
+ writeFileSync(
+ join(userLogsDir, 'desktop.2026-08-05.log'),
+ DESKTOP_LOG_WITH_FOREIGN_SLUG_IN_CONSOLE,
+ );
+ const projectDir = makeProjectDir('bundle-proj');
+ const outputPath = join(makeTmpDir(), 'report.zip');
+
+ const { zipPath } = await collectStandardBundle({
+ projectDir,
+ redact: true,
+ outputPath,
+ userLogsDir,
+ });
+
+ const entries = listZipEntries(zipPath);
+ expect(entries).toContain('logs/cli.2026-08-05.log');
+ expect(entries).toContain('logs/desktop.2026-08-05.log');
+ });
+
+ test('keeps a log family the collector does not recognize', async () => {
+ const userLogsDir = makeTmpDir();
+ writeFileSync(join(userLogsDir, 'cli.2026-08-05.log'), CLI_LOG_MATCHING_SLUG);
+ writeFileSync(join(userLogsDir, 'cli.2026-08-04.log'), CLI_LOG_OTHER_PROJECT);
+ writeFileSync(
+ join(userLogsDir, 'future-writer.2026-08-05.log'),
+ 'a writer nobody listed yet\n',
+ );
+ const projectDir = makeProjectDir('bundle-proj');
+ const outputPath = join(makeTmpDir(), 'report.zip');
+
+ const { zipPath } = await collectStandardBundle({
+ projectDir,
+ redact: true,
+ outputPath,
+ userLogsDir,
+ });
+
+ const entries = listZipEntries(zipPath);
+ expect(entries).toContain('logs/future-writer.2026-08-05.log');
+ expect(entries).toContain('logs/cli.2026-08-05.log');
+ expect(entries).not.toContain('logs/cli.2026-08-04.log');
+ });
+
+ test('narrows rotated CLI logs too', async () => {
+ const userLogsDir = makeTmpDir();
+ writeFileSync(join(userLogsDir, 'cli.2026-08-05.log'), CLI_LOG_MATCHING_SLUG);
+ writeFileSync(join(userLogsDir, 'cli.2026-08-04.log.1'), CLI_LOG_OTHER_PROJECT);
+ const projectDir = makeProjectDir('bundle-proj');
+ const outputPath = join(makeTmpDir(), 'report.zip');
+
+ const { zipPath } = await collectStandardBundle({
+ projectDir,
+ redact: true,
+ outputPath,
+ userLogsDir,
+ });
+
+ const entries = listZipEntries(zipPath);
+ expect(entries).toContain('logs/cli.2026-08-05.log');
+ expect(entries).not.toContain('logs/cli.2026-08-04.log.1');
+ });
+
+ test('an unreadable taggable entry does not drop its siblings', async () => {
+ const userLogsDir = makeTmpDir();
+ // A directory named like a log: readdirSync lists it and the extension
+ // filter admits it, but reading it throws EISDIR. Portable and unprivileged,
+ // unlike chmod 000, which no-ops when the suite runs as root.
+ mkdirSync(join(userLogsDir, 'cli.2026-08-04.log'));
+ writeFileSync(join(userLogsDir, 'cli.2026-08-05.log'), CLI_LOG_MATCHING_SLUG);
+ writeFileSync(join(userLogsDir, 'desktop.2026-08-05.log'), DESKTOP_LOG_LINE);
+ const projectDir = makeProjectDir('bundle-proj');
+ const outputPath = join(makeTmpDir(), 'report.zip');
+
+ const { zipPath } = await collectStandardBundle({
+ projectDir,
+ redact: true,
+ outputPath,
+ userLogsDir,
+ });
+
+ expect(existsSync(zipPath)).toBe(true);
+ const entries = listZipEntries(zipPath);
+ expect(entries).toContain('logs/cli.2026-08-05.log');
+ expect(entries).toContain('logs/desktop.2026-08-05.log');
+ expect(entries).not.toContain('logs/cli.2026-08-04.log');
+ });
+
+ test('an unreadable taggable entry does not suppress the keep-all fallback', async () => {
+ const userLogsDir = makeTmpDir();
+ // Same unreadable-directory trick, but now nothing readable carries the
+ // slug. Retaining the undecidable file must not read as a match: if it
+ // does, the "no match keeps everything" fallback never fires and the one
+ // readable CLI log is discarded on a slug decision nobody could make.
+ mkdirSync(join(userLogsDir, 'cli.2026-08-03.log'));
+ writeFileSync(join(userLogsDir, 'cli.2026-08-04.log'), CLI_LOG_OTHER_PROJECT);
+ writeFileSync(join(userLogsDir, 'desktop.2026-08-05.log'), DESKTOP_LOG_LINE);
+ const projectDir = makeProjectDir('bundle-proj');
+ const outputPath = join(makeTmpDir(), 'report.zip');
+
+ const { zipPath } = await collectStandardBundle({
+ projectDir,
+ redact: true,
+ outputPath,
+ userLogsDir,
+ });
+
+ const entries = listZipEntries(zipPath);
+ expect(entries).toContain('logs/cli.2026-08-04.log');
+ expect(entries).toContain('logs/desktop.2026-08-05.log');
+ });
+});
+
+describe('collectUserLogFiles — shared collector', () => {
+ // The full bundle tier reaches the same file set through this exported
+ // collector rather than through collectStandardBundle, so a fix applied at
+ // the bundle call site alone would leave that tier still dropping families.
+ test('keeps log families that cannot carry a project slug', () => {
+ const userLogsDir = makeTmpDir();
+ writeFileSync(join(userLogsDir, 'cli.2026-08-05.log'), CLI_LOG_MATCHING_SLUG);
+ writeFileSync(join(userLogsDir, 'desktop.2026-08-05.log'), DESKTOP_LOG_LINE);
+ writeFileSync(join(userLogsDir, 'mcp.2026-08-05.log'), MCP_MIRROR_LINE);
+
+ const names = collectUserLogFiles('bundle-proj', userLogsDir)
+ .map((f) => basename(f))
+ .sort();
+
+ expect(names).toEqual(['cli.2026-08-05.log', 'desktop.2026-08-05.log', 'mcp.2026-08-05.log']);
+ });
+
+ // Retention alone is satisfied by a collector that ignores the slug
+ // entirely, which would leak another project's command history into a
+ // bundle the user forwards to support. Only an exclusion at this tier
+ // proves the slug argument still reaches the shared filter.
+ test('still narrows the taggable family to the requested project', () => {
+ const userLogsDir = makeTmpDir();
+ writeFileSync(join(userLogsDir, 'cli.2026-08-05.log'), CLI_LOG_MATCHING_SLUG);
+ writeFileSync(join(userLogsDir, 'cli.2026-08-04.log'), CLI_LOG_OTHER_PROJECT);
+ writeFileSync(join(userLogsDir, 'desktop.2026-08-05.log'), DESKTOP_LOG_LINE);
+
+ const names = collectUserLogFiles('bundle-proj', userLogsDir)
+ .map((f) => basename(f))
+ .sort();
+
+ expect(names).toEqual(['cli.2026-08-05.log', 'desktop.2026-08-05.log']);
+ });
+});
+
+describe('collectStandardBundle — narrowing diagnostics', () => {
+ test('counts only the taggable logs the slug ruled out', async () => {
+ const userLogsDir = makeTmpDir();
+ writeFileSync(join(userLogsDir, 'cli.2026-08-05.log'), CLI_LOG_MATCHING_SLUG);
+ writeFileSync(join(userLogsDir, 'cli.2026-08-04.log'), CLI_LOG_OTHER_PROJECT);
+ writeFileSync(join(userLogsDir, 'cli.2026-08-03.log.1'), CLI_LOG_OTHER_PROJECT);
+ writeFileSync(join(userLogsDir, 'desktop.2026-08-05.log'), DESKTOP_LOG_LINE);
+ const projectDir = makeProjectDir('bundle-proj');
+ const outputPath = join(makeTmpDir(), 'report.zip');
+
+ const infoPayloads: Record<string, unknown>[] = [];
+ const logger: BundleLogger = {
+ info: (payload) => {
+ infoPayloads.push(payload);
+ },
+ warn: () => {},
+ };
+
+ await collectStandardBundle({ projectDir, redact: true, outputPath, userLogsDir, logger });
+
+ // The bundled MANIFEST records only what was written, so this count is the
+ // only signal separating "the slug excluded them" from "they never existed".
+ // The retained desktop log must not inflate it: an untaggable family was
+ // never a candidate for exclusion.
+ const collected = infoPayloads.find((p) => 'logFilesExcludedByProjectSlug' in p);
+ expect(collected?.logFilesExcludedByProjectSlug).toBe(2);
+ expect(collected?.logFileCount).toBe(2);
+ });
+});
+
+describe('collectStandardBundle — bundle scope disclosure', () => {
+ test('names the retained user-wide log families in a project-scoped bundle', async () => {
+ const userLogsDir = makeTmpDir();
+ writeFileSync(join(userLogsDir, 'cli.2026-08-05.log'), CLI_LOG_MATCHING_SLUG);
+ writeFileSync(join(userLogsDir, 'desktop.2026-08-05.log'), DESKTOP_LOG_LINE);
+ writeFileSync(join(userLogsDir, 'mcp.2026-08-05.log'), MCP_MIRROR_LINE);
+ const projectDir = makeProjectDir('bundle-proj');
+ const outputPath = join(makeTmpDir(), 'report.zip');
+
+ const { zipPath } = await collectStandardBundle({
+ projectDir,
+ redact: true,
+ outputPath,
+ userLogsDir,
+ });
+
+ // The README header names a single project, so a reader would otherwise
+ // take the whole bundle to be scoped to it. The two families the slug
+ // cannot narrow are per-machine singletons and must say so next to the
+ // "safe to attach" claim they qualify.
+ const readme = readZipEntry(zipPath, 'README.md');
+ expect(readme).toContain('user-wide rather than project-scoped');
+
+ // Scope the entry assertions to the disclosure block: the Contents section
+ // lists every file including the cli log, so asserting over the whole
+ // README would pass whatever the note actually said.
+ const scopeNote = readme.slice(readme.indexOf('Scope: some collected logs'));
+ const listed = scopeNote
+ .split('\n')
+ .filter((l) => l.startsWith('- '))
+ .map((l) => l.slice(2))
+ .sort();
+ expect(listed).toEqual(['logs/desktop.2026-08-05.log', 'logs/mcp.2026-08-05.log']);
+ });
+
+ test('omits the scope note when only project-taggable logs were collected', async () => {
+ const userLogsDir = makeTmpDir();
+ writeFileSync(join(userLogsDir, 'cli.2026-08-05.log'), CLI_LOG_MATCHING_SLUG);
+ const projectDir = makeProjectDir('bundle-proj');
+ const outputPath = join(makeTmpDir(), 'report.zip');
+
+ const { zipPath } = await collectStandardBundle({
+ projectDir,
+ redact: true,
+ outputPath,
+ userLogsDir,
+ });
+
+ const readme = readZipEntry(zipPath, 'README.md');
+ expect(readme).not.toContain('user-wide rather than project-scoped');
});
});
@@ -261,6 +566,11 @@ describe('collectStandardBundle — system-wide (no projectDir)', () => {
const readme = readZipEntry(zipPath, 'README.md');
expect(readme).toContain('Project: (unscoped)');
+
+ // The scope note exists to correct a narrower reading of the bundle. An
+ // unscoped bundle narrows nothing, so there is no such reading to correct
+ // and the note would contradict the header directly above it.
+ expect(readme).not.toContain('user-wide rather than project-scoped');
});
});
diff --git a/packages/cli/src/commands/bug-report-bundle.ts b/packages/cli/src/commands/bug-report-bundle.ts
index bd208d17f..8d99bb03b 100644
--- a/packages/cli/src/commands/bug-report-bundle.ts
+++ b/packages/cli/src/commands/bug-report-bundle.ts
@@ -168,40 +168,89 @@ function collectSysinfo(): Record<string, unknown> {
return info;
}
+// The writers that share `~/.ok/logs`, and whether their record schema can
+// carry a `project` field at all. Only the CLI logger's pino base sets one; the
+// desktop logger's base has no such key and the MCP stderr mirror is plain text
+// rather than JSON — so a slug predicate is *inapplicable* to those families,
+// not false for them, and must not decide whether they belong in a bundle.
+// Anything absent from this table is treated as untaggable and retained, so a
+// new writer joining this directory is collected without a collector change.
+//
+// Each prefix is owned independently, so a rename has three possible homes:
+// cli `packages/cli/src/cli.ts` passes the name to the
+// `<name>.<date>.log` factory in `packages/server/src/file-logger.ts`,
+// which takes it from its caller rather than owning it
+// desktop `packages/desktop/src/main/desktop-logger.ts` hardcodes its own
+// mcp `packages/cli/src/mcp/stderr-mirror.ts` hardcodes its own
+// TypeScript cannot see across those package boundaries, so a rename there has
+// to be mirrored here; a stale entry degrades to "untaggable → retained",
+// never to a dropped file.
+const USER_LOG_FAMILIES = [
+ { prefix: 'cli', projectTagged: true },
+ { prefix: 'desktop', projectTagged: false },
+ { prefix: 'mcp', projectTagged: false },
+] as const satisfies readonly { prefix: string; projectTagged: boolean }[];
+
+// Prefix-anchored rather than suffix-anchored so rotated files (`cli.<date>.log.2`)
+// stay in the family that owns them.
+function isProjectTaggable(file: string): boolean {
+ const name = basename(file);
+ return USER_LOG_FAMILIES.some((f) => f.projectTagged && name.startsWith(`${f.prefix}.`));
+}
+
/**
* User-level log files (`~/.ok/logs/*.log`), optionally narrowed to one
* project. Shared with the full bundle so both report levels harvest the same
* set — on desktop these carry the renderer console, which reaches no other
* sink.
*
- * The slug filter is best-effort: when no file matches it, every file is
- * returned rather than none, because a log that predates project tagging is
- * still better evidence than an empty bundle.
+ * Narrowing reaches only the log families whose records can carry a `project`
+ * field; a family the slug cannot describe survives regardless of it. Within
+ * the taggable family the filter stays best-effort: when no file matches the
+ * slug, every file is returned rather than none, because a log that predates
+ * project tagging is still better evidence than an empty bundle.
*/
export function collectUserLogFiles(projectSlug: string | null, logsDir: string): string[] {
return collectLogs(projectSlug, logsDir).files;
}
-function collectLogs(projectSlug: string | null, logsDir: string): { files: string[] } {
- if (!existsSync(logsDir)) return { files: [] };
+function collectLogs(
+ projectSlug: string | null,
+ logsDir: string,
+): { files: string[]; excludedByProjectSlug: number } {
+ if (!existsSync(logsDir)) return { files: [], excludedByProjectSlug: 0 };
- let files = readdirSync(logsDir)
+ const files = readdirSync(logsDir)
.filter((f) => f.endsWith('.log') || /\.log\.\d+$/.test(f))
.map((f) => join(logsDir, f));
- if (projectSlug && files.length > 0) {
- const filtered = files.filter((f) => {
- try {
- const content = readFileSync(f, 'utf8');
- return content.includes(`"project":"${projectSlug}"`);
- } catch {
- return true;
- }
- });
- if (filtered.length > 0) files = filtered;
- }
+ if (!projectSlug) return { files, excludedByProjectSlug: 0 };
+
+ const taggable = files.filter(isProjectTaggable);
+ // Retention is the fail-safe answer for a log we listed but then couldn't
+ // read: the likeliest cause is a writer rotating it between the readdir and
+ // the open, and an undecidable slug match must not silently discard
+ // evidence. Tracked apart from the matches so that retention stays a
+ // decision about this one file — counted as a match it would also speak for
+ // the whole family, suppressing the keep-everything fallback and discarding
+ // the readable siblings it was meant to protect.
+ const unreadable: string[] = [];
+ const matching = taggable.filter((f) => {
+ try {
+ return readFileSync(f, 'utf8').includes(`"project":"${projectSlug}"`);
+ } catch {
+ unreadable.push(f);
+ return false;
+ }
+ });
+
+ if (matching.length === 0) return { files, excludedByProjectSlug: 0 };
- return { files };
+ const kept = new Set([...matching, ...unreadable]);
+ return {
+ files: files.filter((f) => !isProjectTaggable(f) || kept.has(f)),
+ excludedByProjectSlug: taggable.length - kept.size,
+ };
}
function collectLockDir(cwd: string): { files: string[] } {
@@ -298,7 +347,10 @@ export async function collectStandardBundle(
// Always present so a recipient can distinguish "not an Electron host"
// (null) from a bundle predating the field (absent).
sysinfo.desktop = opts.desktop ?? null;
- const { files: logFiles } = collectLogs(projectSlug, userLogsDir);
+ const { files: logFiles, excludedByProjectSlug: logFilesExcludedByProjectSlug } = collectLogs(
+ projectSlug,
+ userLogsDir,
+ );
const { files: lockFiles } = opts.projectDir ? collectLockDir(opts.projectDir) : { files: [] };
const { files: localSinkFiles } = opts.projectDir
? collectLocalSinkLogs(opts.projectDir)
@@ -307,6 +359,9 @@ export async function collectStandardBundle(
logger?.info(
{
logFileCount: logFiles.length,
+ // The bundled MANIFEST lists only what was written, so without this the
+ // narrowing decision leaves no trace a triager could read.
+ logFilesExcludedByProjectSlug,
lockFileCount: lockFiles.length,
localSinkFileCount: localSinkFiles.length,
},
@@ -392,6 +447,19 @@ export async function collectStandardBundle(
zipfile.addBuffer(Buffer.from(JSON.stringify(manifest, null, 2), 'utf8'), 'MANIFEST.json');
const totalRedacted = redactions.reduce((sum, r) => sum + r.lineCount, 0);
+
+ // The families the slug cannot narrow are per-machine, per-day singletons, so
+ // a project-scoped bundle still carries whatever else the machine was doing
+ // that day. Secret scrubbing does not narrow this — it matches credentials,
+ // not document titles or content — so the scope has to be stated rather than
+ // left to be inferred from the `Project:` header.
+ // Only meaningful against a declared project scope: an unscoped bundle
+ // narrows nothing and is user-wide throughout, so there is no narrower
+ // reading for the note to correct.
+ const userWideLogEntries = projectSlug
+ ? bundleFiles.filter((f) => f.startsWith('logs/') && !isProjectTaggable(f))
+ : [];
+
const readme = [
'# Bug Report Bundle',
'',
@@ -405,6 +473,16 @@ export async function collectStandardBundle(
'',
'## Privacy',
'',
+ ...(userWideLogEntries.length > 0
+ ? [
+ 'Scope: some collected logs are user-wide rather than project-scoped.',
+ 'These are written once per machine per day and can contain activity',
+ 'from other projects open on this machine, including captured console',
+ 'output:',
+ ...userWideLogEntries.map((f) => `- ${f}`),
+ '',
+ ]
+ : []),
...(redact
? [
'This bundle was auto-redacted before packaging.',