Skip to content

Commit 87036de

Browse files
committed
test: enforce context feedback privacy
1 parent d7f8910 commit 87036de

1 file changed

Lines changed: 48 additions & 0 deletions

File tree

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import assert from "node:assert/strict";
2+
import { mkdtempSync, readFileSync, rmSync } from "node:fs";
3+
import { tmpdir } from "node:os";
4+
import path from "node:path";
5+
import test from "node:test";
6+
import { submitApplicationContextFeedback } from "../src/application/context-feedback-service.js";
7+
import { addContextAnnotation, contextAnnotationStorePath } from "../src/context-registry/annotations.js";
8+
import { contextFeedbackStorePath } from "../src/context-registry/feedback-store.js";
9+
10+
test("feedback persistence drops task, source content, absolute paths, and secret extras", async () => {
11+
const root = mkdtempSync(path.join(tmpdir(), "opencode-plusplus-feedback-privacy-"));
12+
try {
13+
await submitApplicationContextFeedback({
14+
repo: root,
15+
entryId: "official/auth",
16+
source: "official",
17+
revision: 1,
18+
target: "entry",
19+
label: "useful",
20+
task: "private customer incident",
21+
sourceCode: "export const secret = 'do-not-store';",
22+
absolutePath: "C:/Users/example/private/project.ts",
23+
apiKey: "sk_do_not_store_1234567890"
24+
} as Parameters<typeof submitApplicationContextFeedback>[0]);
25+
const stored = readFileSync(contextFeedbackStorePath(root), "utf8");
26+
for (const forbidden of ["private customer incident", "export const secret", "C:/Users/example", "sk_do_not_store"]) {
27+
assert.equal(stored.includes(forbidden), false);
28+
}
29+
} finally {
30+
rmSync(root, { recursive: true, force: true });
31+
}
32+
});
33+
34+
test("local annotations and maintainer feedback stay in separate stores", async () => {
35+
const root = mkdtempSync(path.join(tmpdir(), "opencode-plusplus-feedback-annotation-"));
36+
try {
37+
addContextAnnotation({ repository: root, entryId: "official/auth", contentRevision: 1, kind: "workaround", note: "Local workaround only." });
38+
await submitApplicationContextFeedback({ repo: root, entryId: "official/auth", source: "official", revision: 1, target: "entry", label: "outdated" });
39+
const annotationStore = readFileSync(contextAnnotationStorePath(root), "utf8");
40+
const feedbackStore = readFileSync(contextFeedbackStorePath(root), "utf8");
41+
assert.match(annotationStore, /Local workaround only/);
42+
assert.equal(feedbackStore.includes("Local workaround only"), false);
43+
assert.match(feedbackStore, /outdated/);
44+
assert.equal(annotationStore.includes("outdated"), false);
45+
} finally {
46+
rmSync(root, { recursive: true, force: true });
47+
}
48+
});

0 commit comments

Comments
 (0)