Merge branch 'codex/sleep-28-chat-run-milestones' into codex/sleep-29-native-chat-progress

* codex/sleep-28-chat-run-milestones:
  fix(tests): preserve GitHub identity transaction ownership
This commit is contained in:
Dotta committed 2026-10-27 02:30:08 -05:00
commit d5aa995ea7
3 files changed
+30 -6

No files matched your search

@@ -1577,3 +1577,25 @@ Evidence:
Latest-head CI/review and stack reconciliation remain required. These local
passes do not discharge previous cancellation/deadlock evidence or parent review
findings. No merge or host-sleep qualification is claimed.
## Master integration: extracted GitHub credential fixture
Master extracted the credential fixture into a helper shared with project Git
authorization. Its direct `acceptSteeredIdentity(db, ...)` call bypassed the
existing transaction owner. Combined verification reproduced four credential
failures and one project-authorization failure when activation registered work.
The helper now calls `reconcileSteeredIdentity`, which already owns the task/run
locks and transaction. No production transaction contract changed.
The project suite initially skipped all 30 cases because embedded PostgreSQL was
unavailable. It now supports the existing validated external-test-database option
through `PAPERCLIP_PROJECT_GIT_TEST_DATABASE_URL` and closes that pool. Use a fresh
disposable database per run: the suite seeds fixed A/B user IDs. Reusing the red
run's database caused a duplicate-user setup failure; a new database resolved
that fixture setup issue without changing product behavior. All 25 credential
cases and all 30 project-authorization cases then passed on the owning branch.
The original failures remain in `/tmp/sleep-master-credentials-tests.log` and
`/tmp/sleep-master-project-git-external-before.log`; corrected results are in
`/tmp/sleep-master-identity-fixture-tests.log` (credentials) and
`/tmp/sleep-master-project-git-fixed.log` (project authorization).
@@ -1,6 +1,6 @@
import { randomUUID } from "node:crypto";
import { agents, companies, companyMemberships, companySecrets, connectionGrants, heartbeatRuns, issueComments, issues, toolApplications, toolConnectionInstalls, toolConnections, userSecretDefinitions, type Db } from "@paperclipai/db";
import { initializeRunIdentity, reserveSteeredIdentity, acceptSteeredIdentity } from "../../services/run-identity.js";
import { initializeRunIdentity, reserveSteeredIdentity, reconcileSteeredIdentity } from "../../services/run-identity.js";
export function githubCredentialsFixture(getDb: () => Db) {
async function seed() {
@@ -145,7 +145,7 @@ export function githubCredentialsFixture(getDb: () => Db) {
...input,
messageId: id,
});
await acceptSteeredIdentity(db, context!);
await reconcileSteeredIdentity(db, context!);
}
return { seed, grant, switchTo };
}
@@ -1,3 +1,4 @@
import { resolveExternalTestDatabaseUrl } from "./helpers/external-test-database.js";
import express from "express";
import request from "supertest";
import { eq } from "drizzle-orm";
@@ -20,18 +21,19 @@ vi.mock("../services/github-fetch.js", async importOriginal => ({
...await importOriginal<typeof import("../services/github-fetch.js")>(),
ghFetch: vi.fn(async () => new Response(null, { status: 404 })),
}));
const support = await getEmbeddedPostgresTestSupport();
const external = resolveExternalTestDatabaseUrl("PAPERCLIP_PROJECT_GIT_TEST_DATABASE_URL");
const support = external ? { supported: true } : await getEmbeddedPostgresTestSupport();
(support.supported ? describe : describe.skip)("explicit project Git authorization", () => {
let db: ReturnType<typeof createDb>, database: Awaited<ReturnType<typeof startEmbeddedPostgresTestDatabase>>;
const { seed, grant, switchTo } = githubCredentialsFixture(() => db);
beforeAll(async () => {
database = await startEmbeddedPostgresTestDatabase("paperclip-project-git-authorization-");
db = createDb(database.connectionString);
if (!external) database = await startEmbeddedPostgresTestDatabase("paperclip-project-git-authorization-");
db = createDb(external ?? database!.connectionString);
await db.insert(authUsers).values(["A", "B"].map(id => ({
id, name: id, email: `${id}@example.invalid`, createdAt: new Date(), updatedAt: new Date(),
})));
}, 30_000);
afterAll(async () => { await database?.cleanup(); }, 60_000);
afterAll(async () => { await db?.$client.end({ timeout: 1 }); await database?.cleanup(); }, 60_000);
async function projectAuthorizationFixture() {
const input = await seed();
const selected = await grant(input, "A");