test: consolidate duplicate owner proofs (#16075)

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
DottaandPaperclip authored and GitHub committed 2026-10-14 23:17:13 -05:00
1 parent 8541dfad29
commit 3ea39f75c1
9 files changed
+53 -114

No files matched your search

+1 -19
View File
@@ -12,24 +12,6 @@ describe("isBlobStorePath", () => {
});
describe("bytesToPortableFileEntry", () => {
it("keeps blobs/ entries as base64 octet streams regardless of extension", () => {
const bytes = new Uint8Array([0x00, 0x01, 0x80, 0xfe, 0xff]);
expect(bytesToPortableFileEntry("blobs/4f2d1c9a", bytes)).toEqual({
encoding: "base64",
data: Buffer.from(bytes).toString("base64"),
contentType: "application/octet-stream",
});
});
it("falls back to base64 when bytes are not valid UTF-8", () => {
const invalidUtf8 = new Uint8Array([0x68, 0x69, 0xff, 0xfe, 0xc0]);
expect(bytesToPortableFileEntry("tasks/pap-1/raw-notes", invalidUtf8)).toEqual({
encoding: "base64",
data: Buffer.from(invalidUtf8).toString("base64"),
contentType: "application/octet-stream",
});
});
it("decodes valid UTF-8 entries to text", () => {
const bytes = new TextEncoder().encode("# Notes\n\ncafé ✅\n");
expect(bytesToPortableFileEntry("tasks/pap-1/TASK.md", bytes)).toBe("# Notes\n\ncafé ✅\n");
@@ -38,7 +20,7 @@ describe("bytesToPortableFileEntry", () => {
describe("readZipArchive", () => {
it("round-trips blob and invalid UTF-8 entries byte-exactly", async () => {
const blobBytes = new Uint8Array([0x89, 0x50, 0x4e, 0x47, 0x00, 0xff]);
const blobBytes = new Uint8Array([0x68, 0x69]);
const invalidUtf8 = new Uint8Array([0x68, 0x69, 0xff, 0xfe, 0xc0]);
const archive = createStoredZipArchive(
{
+18
View File
@@ -0,0 +1,18 @@
# Test audit R9: owner-level duplicate consolidation
Base: `77408fa6c3d7c916d7160760eae2144aaa0f8fe7` (#16072). This batch removes nine registered tests and 79 net test lines. It changes no production code. No CI timing claim was measured.
| Retired proof | Keeper and preserved contract | Owner mutation caught by keeper |
| --- | --- | --- |
| CLI ZIP: separate binary blob and invalid UTF-8 fallback cases | Archive round-trip keeps blob bytes and invalid UTF-8 note bytes exact; valid UTF-8 blob input is covered there too. | Bypass blob storage or decode invalid UTF-8 lossily; exact round-trip fails. |
| Daytona: first execute creates a session before the second reuses it | Persistent-shell case checks one created session, a `paperclip-` id, and the same session id for both commands. | Break the id prefix or session-store hit; the keeper fails. |
| Shared account handle: plain `acct-42` acceptance | Whitespace-rejection case retains the exact accepted input and checks it is not trimmed. | Return null for the accepted identifier; the keeper fails. |
| Loopback bind: bare `pnpm dev` rewrite | Loopback-preset case retains the same bare command and checks the rewritten command plus preset behavior. | Stop rewriting the bare command; the keeper fails. |
| Native runner: generic remote-runner acceptance | Remote Dot capability case retains generic-remote acceptance alongside the Dot-specific rejection and acceptance controls. | Require Dot capability for generic remote runners; the keeper fails. |
| Auth route: null Sentry DSN in an unset configuration | Full persisted-user session response already checks `sentryDsn: null` and `sentryEnvironment: null`. | Return an empty string for the DSN; full response equality fails. |
| Discord registration: successful registration before runtime enablement | The 503 refresh case first proves successful registration, capabilities, callback, persisted receipt, token exclusion, and idempotent reconciliation. | Persist the bot token in the receipt; the migrated token-exclusion assertion fails. |
| Slack OAuth: organization grant over-grant provenance | The no-scope refresh case first checks the original database grant before refresh, then retains the post-refresh warning. | Omit OAuth provenance when creating the initial organization grant; the pre-refresh database assertion fails. |
Each mutation was tested against the intended retained assertion. Production owners were restored byte-for-byte after controls. Complete owner candidates passed before restoration. The modified files were then replayed on this exact base in two runs: six owners passed 1,001 tests; after building the local plugin SDK dependency, the two server owners passed 1,691 tests. The final combined total is 2,692 passing tests across all eight changed owners. `git diff --check` passes.
The reductions consolidate proof at an existing owner and keep the distinct boundary controls. They do not claim a specific CI-time reduction; the focused suites still exercise their retained inputs and assertions.
@@ -2142,19 +2142,6 @@ describe("Daytona sandbox provider plugin", () => {
...overrides,
});
it("creates one session on the first execute and reuses it on the next", async () => {
process.env.DAYTONA_API_KEY = "host-key";
const sandbox = createMockSandbox();
mockGet.mockResolvedValue(sandbox);
await plugin.definition.onEnvironmentExecute?.(sessionExecParams());
await plugin.definition.onEnvironmentExecute?.(sessionExecParams());
expect(sandbox.process.createSession).toHaveBeenCalledTimes(1);
const sessionId = sandbox.process.createSession.mock.calls[0]![0] as string;
expect(sessionId).toMatch(/^paperclip-/);
});
it("opens one session when two first commands overlap", async () => {
process.env.DAYTONA_API_KEY = "host-key";
const sandbox = createMockSandbox();
@@ -2541,6 +2528,8 @@ describe("Daytona sandbox provider plugin", () => {
await plugin.definition.onEnvironmentExecute?.(sessionExecParams());
expect(sandbox.process.createSession).toHaveBeenCalledTimes(1);
const sessionId = sandbox.process.createSession.mock.calls[0]![0] as string;
expect(sessionId).toMatch(/^paperclip-/);
const firstSid = sandbox.process.executeSessionCommand.mock.calls[0]![0] as string;
const secondSid = sandbox.process.executeSessionCommand.mock.calls[1]![0] as string;
expect(firstSid).toBe(secondSid);
@@ -3,10 +3,6 @@ import { ACCOUNT_HANDLE_MAX_LENGTH, toAccountHandle } from "./account-handle.js"
import { createUserSecretDefinitionSchema } from "./validators/secret.js";
describe("toAccountHandle", () => {
it("returns the value for a plain identifier", () => {
expect(toAccountHandle("acct-42")).toBe("acct-42");
});
it("returns null for a value that holds a space, such as \"a b\"", () => {
expect(toAccountHandle("a b")).toBeNull();
});
@@ -37,14 +37,6 @@ describe("forceLoopbackBindInCommand", () => {
);
});
it("adds an explicit loopback bind when the command selects none", () => {
// A bare `pnpm dev` lets an old guest runner infer its bind from HOST, so the
// flags must be added rather than assumed.
expect(forceLoopbackBindInCommand("pnpm dev")).toBe(
"pnpm dev --bind loopback",
);
});
it("keeps the legacy lan aliases so dev-service detection still matches", () => {
// `isPaperclipDevRuntimeService` matches `--tailscale-auth` as a substring;
// an explicit `--bind` already beats the alias in every dev-runner version.
-17
View File
@@ -115,23 +115,6 @@ describe("auth routes", () => {
expect(res.body.sentryDsn).toBe("https://public@o0.ingest.sentry.io/1");
});
it("sends a null sentryDsn when SENTRY_DSN is unset", async () => {
delete process.env.SENTRY_DSN;
const app = await createApp(
{
type: "board",
userId: "user-1",
source: "session",
},
baseUser,
);
const res = await request(app).get("/api/auth/get-session");
expect(res.status).toBe(200);
expect(res.body.sentryDsn).toBe(null);
});
it("sends sentryDsn for a board actor when only SENTRY_DSN_FRONTEND is set", async () => {
delete process.env.SENTRY_DSN;
delete process.env.SENTRY_DSN_BACKEND;
@@ -6037,46 +6037,6 @@ describeEmbeddedPostgres("chat channel control-plane integration", () => {
};
}
it("persists registration before enabling the runtime and preserves unrelated commands", async () => {
const f = await registrationFixture();
try {
await f.configure();
const connected = await f.service.get(f.endpoint.id);
expect(connected?.capabilities).toMatchObject({
slashCommands: true,
ephemeralMessages: true,
});
expect(
f.runtime.configurations.get(f.endpoint.id)?.callbacks.onSlashCommand,
).toBeTypeOf("function");
expect(f.calls).toEqual(["GET", "POST"]);
expect(f.commandRows().map((row) => row.name)).toEqual([
"other",
"paperclip",
]);
const [registration] = await db
.select()
.from(chatActions)
.where(
and(
eq(chatActions.endpointId, f.endpoint.id),
eq(chatActions.kind, "discord_command_registration"),
),
);
expect(registration?.status).toBe("processed");
expect(registration?.payload.registration).toMatchObject({
phase: "registered",
});
expect(JSON.stringify(registration)).not.toContain(
f.credentials.botToken,
);
await f.service.reconcileProviderRuntimes();
expect(f.calls).toEqual(["GET", "POST"]);
} finally {
await retireRegistrationFixture(f.service, f.endpoint.id);
}
});
it("keeps mention setup usable on registration failure and upgrades automatically when due", async () => {
const f = await registrationFixture("unavailable");
try {
@@ -6150,6 +6110,37 @@ describeEmbeddedPostgres("chat channel control-plane integration", () => {
)!.callbacks;
expect(originalCallbacks.onMessage).toBeTypeOf("function");
expect(originalCallbacks.onSlashCommand).toBeTypeOf("function");
const connected = await f.service.get(f.endpoint.id);
expect(connected?.capabilities).toMatchObject({
slashCommands: true,
ephemeralMessages: true,
});
expect(
f.runtime.configurations.get(f.endpoint.id)?.callbacks.onSlashCommand,
).toBeTypeOf("function");
expect(f.calls).toEqual(["GET", "POST"]);
expect(f.commandRows().map((row) => row.name)).toEqual([
"other",
"paperclip",
]);
const [registration] = await db
.select()
.from(chatActions)
.where(
and(
eq(chatActions.endpointId, f.endpoint.id),
eq(chatActions.kind, "discord_command_registration"),
),
);
expect(registration?.status).toBe("processed");
expect(registration?.payload.registration).toMatchObject({
phase: "registered",
});
expect(JSON.stringify(registration)).not.toContain(
f.credentials.botToken,
);
await f.service.reconcileProviderRuntimes();
expect(f.calls).toEqual(["GET", "POST"]);
const shutdown = vi.spyOn(original!, "shutdown");
const targetRestart = vi.fn(async () => {
throw new Error(
@@ -10826,20 +10826,14 @@ describeEmbeddedPostgres("tool access service", () => {
};
}
it("records the over-grant on the shared organization grant", async () => {
it("keeps the over-grant warning when a refresh asserts no scope", async () => {
const lane = await connectSharedSlack("channels:read chat:write");
// The organization grant is created before OAuth has any credentials, so it used to be
// the one record with no provenance at all.
expect((await lane.readGrant()).providerTenant?.oauth).toMatchObject({
scopes: ["channels:read", "chat:write"],
scopeSource: "provider",
unrequestedScopes: ["chat:write"],
});
});
it("keeps the over-grant warning when a refresh asserts no scope", async () => {
const lane = await connectSharedSlack("channels:read chat:write");
await lane.refreshWithScope(null);
@@ -2643,12 +2643,6 @@ describe("remote runner build metadata", () => {
prpTransportModes: ["dial_ws_loopback", "dial_wss", "listen_ws"],
};
it("accepts the current contract with the required transport", () => {
expect(() =>
assertRemoteRunnerBuildMetadata(current, "listen_ws"),
).not.toThrow();
});
it("requires an explicit Dot bridge capability only for remote Dot execution", () => {
expect(() => assertRemoteRunnerBuildMetadata(current, "listen_ws", "openai_dot_mcp"))
.toThrow("runner_remote_dot_capability_missing");