2026-03-20 15:46:01 -05:00
|
|
|
import express from "express";
|
|
|
|
|
import request from "supertest";
|
|
|
|
|
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
|
|
|
|
|
|
|
|
const mockIssueService = vi.hoisted(() => ({
|
|
|
|
|
getById: vi.fn(),
|
2026-04-09 07:07:08 -05:00
|
|
|
assertCheckoutOwner: vi.fn(),
|
2026-03-20 15:46:01 -05:00
|
|
|
update: vi.fn(),
|
|
|
|
|
addComment: vi.fn(),
|
|
|
|
|
findMentionedAgents: vi.fn(),
|
2026-04-07 17:07:10 -05:00
|
|
|
listWakeableBlockedDependents: vi.fn(),
|
|
|
|
|
getWakeableParentAfterChildCompletion: vi.fn(),
|
2026-03-20 15:46:01 -05:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
const mockAccessService = vi.hoisted(() => ({
|
|
|
|
|
canUser: vi.fn(),
|
|
|
|
|
hasPermission: vi.fn(),
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
const mockHeartbeatService = vi.hoisted(() => ({
|
|
|
|
|
wakeup: vi.fn(async () => undefined),
|
|
|
|
|
reportRunActivity: vi.fn(async () => undefined),
|
2026-03-28 10:34:36 -05:00
|
|
|
getRun: vi.fn(async () => null),
|
|
|
|
|
getActiveRunForAgent: vi.fn(async () => null),
|
|
|
|
|
cancelRun: vi.fn(async () => null),
|
2026-03-20 15:46:01 -05:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
const mockAgentService = vi.hoisted(() => ({
|
|
|
|
|
getById: vi.fn(),
|
[codex] Harden execution reliability and heartbeat tooling (#3679)
## Thinking Path
> - Paperclip orchestrates AI agents for zero-human companies
> - Reliable execution depends on heartbeat routing, issue lifecycle
semantics, telemetry, and a fast enough local verification loop to keep
regressions visible
> - The remaining commits on this branch were mostly server/runtime
correctness fixes plus test and documentation follow-ups in that area
> - Those changes are logically separate from the UI-focused
issue-detail and workspace/navigation branches even when they touch
overlapping issue APIs
> - This pull request groups the execution reliability, heartbeat,
telemetry, and tooling changes into one standalone branch
> - The benefit is a focused review of the control-plane correctness
work, including the follow-up fix that restored the implicit
comment-reopen helpers after branch splitting
## What Changed
- Hardened issue/heartbeat execution behavior, including self-review
stage skipping, deferred mention wakes during active execution, stranded
execution recovery, active-run scoping, assignee resolution, and
blocked-to-todo wake resumption
- Reduced noisy polling/logging overhead by trimming issue run payloads,
compacting persisted run logs, silencing high-volume request logs, and
capping heartbeat-run queries in dashboard/inbox surfaces
- Expanded telemetry and status semantics with adapter/model fields on
task completion plus clearer status guidance in docs/onboarding material
- Updated test infrastructure and verification defaults with faster
route-test module isolation, cheaper default `pnpm test`, e2e isolation
from local state, and repo verification follow-ups
- Included docs/release housekeeping from the branch and added a small
follow-up commit restoring the implicit comment-reopen helpers that were
dropped during branch reconstruction
## Verification
- `pnpm vitest run
server/src/__tests__/issue-comment-reopen-routes.test.ts
server/src/__tests__/issue-telemetry-routes.test.ts`
- `pnpm vitest run server/src/__tests__/http-log-policy.test.ts
server/src/__tests__/heartbeat-run-log.test.ts
server/src/__tests__/health.test.ts`
- `server/src/__tests__/activity-service.test.ts`,
`server/src/__tests__/heartbeat-comment-wake-batching.test.ts`, and
`server/src/__tests__/heartbeat-process-recovery.test.ts` were attempted
on this host but the embedded Postgres harness reported
init-script/data-dir problems and skipped or failed to start, so they
are noted as environment-limited
## Risks
- Medium: this branch changes core issue/heartbeat routing and
reopen/wakeup behavior, so regressions would affect agent execution flow
rather than isolated UI polish
- Because it also updates verification infrastructure, reviewers should
pay attention to whether the new tests are asserting the right failure
modes and not just reshaping harness behavior
## Model Used
- OpenAI Codex coding agent (GPT-5-class runtime in Codex CLI; exact
deployed model ID is not exposed in this environment), reasoning
enabled, tool use and local code execution enabled
## Checklist
- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [ ] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [ ] If this change affects the UI, I have included before/after
screenshots
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [x] I will address all Greptile and reviewer comments before
requesting merge
---------
Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-04-14 13:34:52 -05:00
|
|
|
resolveByReference: vi.fn(),
|
2026-03-20 15:46:01 -05:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
const mockLogActivity = vi.hoisted(() => vi.fn(async () => undefined));
|
2026-04-07 17:07:10 -05:00
|
|
|
const mockTxInsertValues = vi.hoisted(() => vi.fn(async () => undefined));
|
|
|
|
|
const mockTxInsert = vi.hoisted(() => vi.fn(() => ({ values: mockTxInsertValues })));
|
|
|
|
|
const mockTx = vi.hoisted(() => ({
|
|
|
|
|
insert: mockTxInsert,
|
|
|
|
|
}));
|
|
|
|
|
const mockDb = vi.hoisted(() => ({
|
|
|
|
|
transaction: vi.fn(async (fn: (tx: typeof mockTx) => Promise<unknown>) => fn(mockTx)),
|
|
|
|
|
}));
|
2026-04-10 22:26:21 -05:00
|
|
|
const mockFeedbackService = vi.hoisted(() => ({
|
|
|
|
|
listIssueVotesForUser: vi.fn(async () => []),
|
|
|
|
|
saveIssueVote: vi.fn(async () => ({ vote: null, consentEnabledNow: false, sharingEnabled: false })),
|
|
|
|
|
}));
|
|
|
|
|
const mockInstanceSettingsService = vi.hoisted(() => ({
|
|
|
|
|
get: vi.fn(async () => ({
|
|
|
|
|
id: "instance-settings-1",
|
|
|
|
|
general: {
|
|
|
|
|
censorUsernameInLogs: false,
|
|
|
|
|
feedbackDataSharingPreference: "prompt",
|
|
|
|
|
},
|
|
|
|
|
})),
|
|
|
|
|
listCompanyIds: vi.fn(async () => ["company-1"]),
|
|
|
|
|
}));
|
|
|
|
|
const mockRoutineService = vi.hoisted(() => ({
|
|
|
|
|
syncRunStatusForIssue: vi.fn(async () => undefined),
|
|
|
|
|
}));
|
2026-03-20 15:46:01 -05:00
|
|
|
|
2026-04-10 22:26:21 -05:00
|
|
|
vi.mock("@paperclipai/shared/telemetry", () => ({
|
|
|
|
|
trackAgentTaskCompleted: vi.fn(),
|
|
|
|
|
trackErrorHandlerCrash: vi.fn(),
|
|
|
|
|
}));
|
2026-04-09 06:12:39 -05:00
|
|
|
|
2026-04-10 22:26:21 -05:00
|
|
|
vi.mock("../telemetry.js", () => ({
|
|
|
|
|
getTelemetryClient: vi.fn(() => ({ track: vi.fn() })),
|
|
|
|
|
}));
|
2026-04-09 06:12:39 -05:00
|
|
|
|
2026-04-10 22:26:21 -05:00
|
|
|
vi.mock("../services/index.js", () => ({
|
|
|
|
|
accessService: () => mockAccessService,
|
|
|
|
|
agentService: () => mockAgentService,
|
|
|
|
|
documentService: () => ({}),
|
|
|
|
|
executionWorkspaceService: () => ({}),
|
|
|
|
|
feedbackService: () => mockFeedbackService,
|
|
|
|
|
goalService: () => ({}),
|
|
|
|
|
heartbeatService: () => mockHeartbeatService,
|
|
|
|
|
instanceSettingsService: () => mockInstanceSettingsService,
|
|
|
|
|
issueApprovalService: () => ({}),
|
|
|
|
|
issueService: () => mockIssueService,
|
|
|
|
|
logActivity: mockLogActivity,
|
|
|
|
|
projectService: () => ({}),
|
|
|
|
|
routineService: () => mockRoutineService,
|
|
|
|
|
workProductService: () => ({}),
|
|
|
|
|
}));
|
2026-03-20 15:46:01 -05:00
|
|
|
|
[codex] Harden execution reliability and heartbeat tooling (#3679)
## Thinking Path
> - Paperclip orchestrates AI agents for zero-human companies
> - Reliable execution depends on heartbeat routing, issue lifecycle
semantics, telemetry, and a fast enough local verification loop to keep
regressions visible
> - The remaining commits on this branch were mostly server/runtime
correctness fixes plus test and documentation follow-ups in that area
> - Those changes are logically separate from the UI-focused
issue-detail and workspace/navigation branches even when they touch
overlapping issue APIs
> - This pull request groups the execution reliability, heartbeat,
telemetry, and tooling changes into one standalone branch
> - The benefit is a focused review of the control-plane correctness
work, including the follow-up fix that restored the implicit
comment-reopen helpers after branch splitting
## What Changed
- Hardened issue/heartbeat execution behavior, including self-review
stage skipping, deferred mention wakes during active execution, stranded
execution recovery, active-run scoping, assignee resolution, and
blocked-to-todo wake resumption
- Reduced noisy polling/logging overhead by trimming issue run payloads,
compacting persisted run logs, silencing high-volume request logs, and
capping heartbeat-run queries in dashboard/inbox surfaces
- Expanded telemetry and status semantics with adapter/model fields on
task completion plus clearer status guidance in docs/onboarding material
- Updated test infrastructure and verification defaults with faster
route-test module isolation, cheaper default `pnpm test`, e2e isolation
from local state, and repo verification follow-ups
- Included docs/release housekeeping from the branch and added a small
follow-up commit restoring the implicit comment-reopen helpers that were
dropped during branch reconstruction
## Verification
- `pnpm vitest run
server/src/__tests__/issue-comment-reopen-routes.test.ts
server/src/__tests__/issue-telemetry-routes.test.ts`
- `pnpm vitest run server/src/__tests__/http-log-policy.test.ts
server/src/__tests__/heartbeat-run-log.test.ts
server/src/__tests__/health.test.ts`
- `server/src/__tests__/activity-service.test.ts`,
`server/src/__tests__/heartbeat-comment-wake-batching.test.ts`, and
`server/src/__tests__/heartbeat-process-recovery.test.ts` were attempted
on this host but the embedded Postgres harness reported
init-script/data-dir problems and skipped or failed to start, so they
are noted as environment-limited
## Risks
- Medium: this branch changes core issue/heartbeat routing and
reopen/wakeup behavior, so regressions would affect agent execution flow
rather than isolated UI polish
- Because it also updates verification infrastructure, reviewers should
pay attention to whether the new tests are asserting the right failure
modes and not just reshaping harness behavior
## Model Used
- OpenAI Codex coding agent (GPT-5-class runtime in Codex CLI; exact
deployed model ID is not exposed in this environment), reasoning
enabled, tool use and local code execution enabled
## Checklist
- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [ ] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [ ] If this change affects the UI, I have included before/after
screenshots
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [x] I will address all Greptile and reviewer comments before
requesting merge
---------
Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-04-14 13:34:52 -05:00
|
|
|
function registerModuleMocks() {
|
|
|
|
|
vi.doMock("@paperclipai/shared/telemetry", () => ({
|
|
|
|
|
trackAgentTaskCompleted: vi.fn(),
|
|
|
|
|
trackErrorHandlerCrash: vi.fn(),
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
vi.doMock("../telemetry.js", () => ({
|
|
|
|
|
getTelemetryClient: vi.fn(() => ({ track: vi.fn() })),
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
vi.doMock("../services/index.js", () => ({
|
|
|
|
|
accessService: () => mockAccessService,
|
|
|
|
|
agentService: () => mockAgentService,
|
|
|
|
|
documentService: () => ({}),
|
|
|
|
|
executionWorkspaceService: () => ({}),
|
|
|
|
|
feedbackService: () => mockFeedbackService,
|
|
|
|
|
goalService: () => ({}),
|
|
|
|
|
heartbeatService: () => mockHeartbeatService,
|
|
|
|
|
instanceSettingsService: () => mockInstanceSettingsService,
|
|
|
|
|
issueApprovalService: () => ({}),
|
|
|
|
|
issueService: () => mockIssueService,
|
|
|
|
|
logActivity: mockLogActivity,
|
|
|
|
|
projectService: () => ({}),
|
|
|
|
|
routineService: () => mockRoutineService,
|
|
|
|
|
workProductService: () => ({}),
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-20 15:46:01 -05:00
|
|
|
function createApp() {
|
|
|
|
|
const app = express();
|
|
|
|
|
app.use(express.json());
|
2026-04-09 06:12:39 -05:00
|
|
|
return app;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function installActor(app: express.Express, actor?: Record<string, unknown>) {
|
|
|
|
|
const [{ issueRoutes }, { errorHandler }] = await Promise.all([
|
[codex] Harden execution reliability and heartbeat tooling (#3679)
## Thinking Path
> - Paperclip orchestrates AI agents for zero-human companies
> - Reliable execution depends on heartbeat routing, issue lifecycle
semantics, telemetry, and a fast enough local verification loop to keep
regressions visible
> - The remaining commits on this branch were mostly server/runtime
correctness fixes plus test and documentation follow-ups in that area
> - Those changes are logically separate from the UI-focused
issue-detail and workspace/navigation branches even when they touch
overlapping issue APIs
> - This pull request groups the execution reliability, heartbeat,
telemetry, and tooling changes into one standalone branch
> - The benefit is a focused review of the control-plane correctness
work, including the follow-up fix that restored the implicit
comment-reopen helpers after branch splitting
## What Changed
- Hardened issue/heartbeat execution behavior, including self-review
stage skipping, deferred mention wakes during active execution, stranded
execution recovery, active-run scoping, assignee resolution, and
blocked-to-todo wake resumption
- Reduced noisy polling/logging overhead by trimming issue run payloads,
compacting persisted run logs, silencing high-volume request logs, and
capping heartbeat-run queries in dashboard/inbox surfaces
- Expanded telemetry and status semantics with adapter/model fields on
task completion plus clearer status guidance in docs/onboarding material
- Updated test infrastructure and verification defaults with faster
route-test module isolation, cheaper default `pnpm test`, e2e isolation
from local state, and repo verification follow-ups
- Included docs/release housekeeping from the branch and added a small
follow-up commit restoring the implicit comment-reopen helpers that were
dropped during branch reconstruction
## Verification
- `pnpm vitest run
server/src/__tests__/issue-comment-reopen-routes.test.ts
server/src/__tests__/issue-telemetry-routes.test.ts`
- `pnpm vitest run server/src/__tests__/http-log-policy.test.ts
server/src/__tests__/heartbeat-run-log.test.ts
server/src/__tests__/health.test.ts`
- `server/src/__tests__/activity-service.test.ts`,
`server/src/__tests__/heartbeat-comment-wake-batching.test.ts`, and
`server/src/__tests__/heartbeat-process-recovery.test.ts` were attempted
on this host but the embedded Postgres harness reported
init-script/data-dir problems and skipped or failed to start, so they
are noted as environment-limited
## Risks
- Medium: this branch changes core issue/heartbeat routing and
reopen/wakeup behavior, so regressions would affect agent execution flow
rather than isolated UI polish
- Because it also updates verification infrastructure, reviewers should
pay attention to whether the new tests are asserting the right failure
modes and not just reshaping harness behavior
## Model Used
- OpenAI Codex coding agent (GPT-5-class runtime in Codex CLI; exact
deployed model ID is not exposed in this environment), reasoning
enabled, tool use and local code execution enabled
## Checklist
- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [ ] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [ ] If this change affects the UI, I have included before/after
screenshots
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [x] I will address all Greptile and reviewer comments before
requesting merge
---------
Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-04-14 13:34:52 -05:00
|
|
|
vi.importActual<typeof import("../routes/issues.js")>("../routes/issues.js"),
|
|
|
|
|
vi.importActual<typeof import("../middleware/index.js")>("../middleware/index.js"),
|
2026-04-09 06:12:39 -05:00
|
|
|
]);
|
2026-03-20 15:46:01 -05:00
|
|
|
app.use((req, _res, next) => {
|
2026-04-08 08:05:35 -05:00
|
|
|
(req as any).actor = actor ?? {
|
2026-03-20 15:46:01 -05:00
|
|
|
type: "board",
|
|
|
|
|
userId: "local-board",
|
|
|
|
|
companyIds: ["company-1"],
|
|
|
|
|
source: "local_implicit",
|
|
|
|
|
isInstanceAdmin: false,
|
|
|
|
|
};
|
|
|
|
|
next();
|
|
|
|
|
});
|
2026-04-07 17:07:10 -05:00
|
|
|
app.use("/api", issueRoutes(mockDb as any, {} as any));
|
2026-03-20 15:46:01 -05:00
|
|
|
app.use(errorHandler);
|
|
|
|
|
return app;
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-09 06:12:39 -05:00
|
|
|
async function normalizePolicy(input: {
|
|
|
|
|
stages: Array<{
|
|
|
|
|
id: string;
|
|
|
|
|
type: "review" | "approval";
|
|
|
|
|
participants: Array<{ type: "agent"; agentId: string } | { type: "user"; userId: string }>;
|
|
|
|
|
}>;
|
|
|
|
|
}) {
|
|
|
|
|
const { normalizeIssueExecutionPolicy } = await import("../services/issue-execution-policy.js");
|
|
|
|
|
return normalizeIssueExecutionPolicy(input);
|
|
|
|
|
}
|
|
|
|
|
|
[codex] harden authenticated routes and issue editor reliability (#3741)
## Thinking Path
> - Paperclip orchestrates AI agents for zero-human companies
> - The control plane depends on authenticated routes enforcing company
boundaries and role permissions correctly
> - This branch also touches the issue detail and markdown editing flows
operators use while handling advisory and triage work
> - Partial issue cache seeds and fragile rich-editor parsing could
leave important issue content missing or blank at the moment an operator
needed it
> - Blocked issues becoming actionable again should wake their assignee
automatically instead of silently staying idle
> - This pull request rebases the advisory follow-up branch onto current
`master`, hardens authenticated route authorization, and carries the
issue-detail/editor reliability fixes forward with regression tests
> - The benefit is tighter authz on sensitive routes plus more reliable
issue/advisory editing and wakeup behavior on top of the latest base
## What Changed
- Hardened authenticated route authorization across agent, activity,
approval, access, project, plugin, health, execution-workspace,
portability, and related server paths, with new cross-tenant and
runtime-authz regression coverage.
- Switched issue detail queries from `initialData` to placeholder-based
hydration so list/quicklook seeds still refetch full issue bodies.
- Normalized advisory-style HTML images before mounting the markdown
editor and strengthened fallback behavior when the rich editor silently
fails or rejects the content.
- Woke assigned agents when blocked issues move back to `todo`, with
route coverage for reopen and unblock transitions.
- Rebasing note: this branch now sits cleanly on top of the latest
`master` tip used for the PR base.
## Verification
- `pnpm exec vitest run ui/src/lib/issueDetailQuery.test.tsx
ui/src/components/MarkdownEditor.test.tsx
server/src/__tests__/issue-comment-reopen-routes.test.ts
server/src/__tests__/activity-routes.test.ts
server/src/__tests__/agent-cross-tenant-authz-routes.test.ts`
- Confirmed `pnpm-lock.yaml` is not part of the PR diff.
- Rebased the branch onto current `public-gh/master` before publishing.
## Risks
- Broad authz tightening may expose existing flows that were relying on
permissive board or agent access and now need explicit grants.
- Markdown editor fallback changes could affect focus or rendering in
edge-case content that mixes HTML-like advisory markup with normal
markdown.
- This verification was intentionally scoped to touched regressions and
did not run the full repository suite.
## Model Used
- OpenAI Codex, GPT-5-based coding agent in the Codex CLI environment
with tool use for terminal, git, and GitHub operations. The exact
runtime model identifier is not exposed inside this session.
## Checklist
- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] If this change affects the UI, it is behavior-only and does not
need before/after screenshots
- [x] I have updated relevant documentation to reflect my changes, or no
documentation changes were needed for these internal fixes
- [x] I have considered and documented any risks above
- [x] I will address all Greptile and reviewer comments before
requesting merge
---------
Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-04-15 08:41:15 -05:00
|
|
|
function makeIssue(status: "todo" | "done" | "blocked") {
|
2026-03-20 15:46:01 -05:00
|
|
|
return {
|
|
|
|
|
id: "11111111-1111-4111-8111-111111111111",
|
|
|
|
|
companyId: "company-1",
|
|
|
|
|
status,
|
|
|
|
|
assigneeAgentId: "22222222-2222-4222-8222-222222222222",
|
|
|
|
|
assigneeUserId: null,
|
|
|
|
|
createdByUserId: "local-board",
|
|
|
|
|
identifier: "PAP-580",
|
|
|
|
|
title: "Comment reopen default",
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
describe("issue comment reopen routes", () => {
|
|
|
|
|
beforeEach(() => {
|
2026-04-09 06:12:39 -05:00
|
|
|
vi.resetModules();
|
[codex] Harden execution reliability and heartbeat tooling (#3679)
## Thinking Path
> - Paperclip orchestrates AI agents for zero-human companies
> - Reliable execution depends on heartbeat routing, issue lifecycle
semantics, telemetry, and a fast enough local verification loop to keep
regressions visible
> - The remaining commits on this branch were mostly server/runtime
correctness fixes plus test and documentation follow-ups in that area
> - Those changes are logically separate from the UI-focused
issue-detail and workspace/navigation branches even when they touch
overlapping issue APIs
> - This pull request groups the execution reliability, heartbeat,
telemetry, and tooling changes into one standalone branch
> - The benefit is a focused review of the control-plane correctness
work, including the follow-up fix that restored the implicit
comment-reopen helpers after branch splitting
## What Changed
- Hardened issue/heartbeat execution behavior, including self-review
stage skipping, deferred mention wakes during active execution, stranded
execution recovery, active-run scoping, assignee resolution, and
blocked-to-todo wake resumption
- Reduced noisy polling/logging overhead by trimming issue run payloads,
compacting persisted run logs, silencing high-volume request logs, and
capping heartbeat-run queries in dashboard/inbox surfaces
- Expanded telemetry and status semantics with adapter/model fields on
task completion plus clearer status guidance in docs/onboarding material
- Updated test infrastructure and verification defaults with faster
route-test module isolation, cheaper default `pnpm test`, e2e isolation
from local state, and repo verification follow-ups
- Included docs/release housekeeping from the branch and added a small
follow-up commit restoring the implicit comment-reopen helpers that were
dropped during branch reconstruction
## Verification
- `pnpm vitest run
server/src/__tests__/issue-comment-reopen-routes.test.ts
server/src/__tests__/issue-telemetry-routes.test.ts`
- `pnpm vitest run server/src/__tests__/http-log-policy.test.ts
server/src/__tests__/heartbeat-run-log.test.ts
server/src/__tests__/health.test.ts`
- `server/src/__tests__/activity-service.test.ts`,
`server/src/__tests__/heartbeat-comment-wake-batching.test.ts`, and
`server/src/__tests__/heartbeat-process-recovery.test.ts` were attempted
on this host but the embedded Postgres harness reported
init-script/data-dir problems and skipped or failed to start, so they
are noted as environment-limited
## Risks
- Medium: this branch changes core issue/heartbeat routing and
reopen/wakeup behavior, so regressions would affect agent execution flow
rather than isolated UI polish
- Because it also updates verification infrastructure, reviewers should
pay attention to whether the new tests are asserting the right failure
modes and not just reshaping harness behavior
## Model Used
- OpenAI Codex coding agent (GPT-5-class runtime in Codex CLI; exact
deployed model ID is not exposed in this environment), reasoning
enabled, tool use and local code execution enabled
## Checklist
- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [ ] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [ ] If this change affects the UI, I have included before/after
screenshots
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [x] I will address all Greptile and reviewer comments before
requesting merge
---------
Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-04-14 13:34:52 -05:00
|
|
|
vi.doUnmock("../routes/issues.js");
|
|
|
|
|
vi.doUnmock("../routes/authz.js");
|
|
|
|
|
vi.doUnmock("../middleware/index.js");
|
|
|
|
|
registerModuleMocks();
|
2026-04-10 22:26:21 -05:00
|
|
|
vi.resetAllMocks();
|
2026-04-09 06:12:39 -05:00
|
|
|
mockIssueService.getById.mockReset();
|
|
|
|
|
mockIssueService.assertCheckoutOwner.mockReset();
|
|
|
|
|
mockIssueService.update.mockReset();
|
|
|
|
|
mockIssueService.addComment.mockReset();
|
|
|
|
|
mockIssueService.findMentionedAgents.mockReset();
|
|
|
|
|
mockIssueService.listWakeableBlockedDependents.mockReset();
|
|
|
|
|
mockIssueService.getWakeableParentAfterChildCompletion.mockReset();
|
|
|
|
|
mockAccessService.canUser.mockReset();
|
|
|
|
|
mockAccessService.hasPermission.mockReset();
|
|
|
|
|
mockHeartbeatService.wakeup.mockReset();
|
|
|
|
|
mockHeartbeatService.reportRunActivity.mockReset();
|
|
|
|
|
mockHeartbeatService.getRun.mockReset();
|
|
|
|
|
mockHeartbeatService.getActiveRunForAgent.mockReset();
|
|
|
|
|
mockHeartbeatService.cancelRun.mockReset();
|
|
|
|
|
mockAgentService.getById.mockReset();
|
[codex] Harden execution reliability and heartbeat tooling (#3679)
## Thinking Path
> - Paperclip orchestrates AI agents for zero-human companies
> - Reliable execution depends on heartbeat routing, issue lifecycle
semantics, telemetry, and a fast enough local verification loop to keep
regressions visible
> - The remaining commits on this branch were mostly server/runtime
correctness fixes plus test and documentation follow-ups in that area
> - Those changes are logically separate from the UI-focused
issue-detail and workspace/navigation branches even when they touch
overlapping issue APIs
> - This pull request groups the execution reliability, heartbeat,
telemetry, and tooling changes into one standalone branch
> - The benefit is a focused review of the control-plane correctness
work, including the follow-up fix that restored the implicit
comment-reopen helpers after branch splitting
## What Changed
- Hardened issue/heartbeat execution behavior, including self-review
stage skipping, deferred mention wakes during active execution, stranded
execution recovery, active-run scoping, assignee resolution, and
blocked-to-todo wake resumption
- Reduced noisy polling/logging overhead by trimming issue run payloads,
compacting persisted run logs, silencing high-volume request logs, and
capping heartbeat-run queries in dashboard/inbox surfaces
- Expanded telemetry and status semantics with adapter/model fields on
task completion plus clearer status guidance in docs/onboarding material
- Updated test infrastructure and verification defaults with faster
route-test module isolation, cheaper default `pnpm test`, e2e isolation
from local state, and repo verification follow-ups
- Included docs/release housekeeping from the branch and added a small
follow-up commit restoring the implicit comment-reopen helpers that were
dropped during branch reconstruction
## Verification
- `pnpm vitest run
server/src/__tests__/issue-comment-reopen-routes.test.ts
server/src/__tests__/issue-telemetry-routes.test.ts`
- `pnpm vitest run server/src/__tests__/http-log-policy.test.ts
server/src/__tests__/heartbeat-run-log.test.ts
server/src/__tests__/health.test.ts`
- `server/src/__tests__/activity-service.test.ts`,
`server/src/__tests__/heartbeat-comment-wake-batching.test.ts`, and
`server/src/__tests__/heartbeat-process-recovery.test.ts` were attempted
on this host but the embedded Postgres harness reported
init-script/data-dir problems and skipped or failed to start, so they
are noted as environment-limited
## Risks
- Medium: this branch changes core issue/heartbeat routing and
reopen/wakeup behavior, so regressions would affect agent execution flow
rather than isolated UI polish
- Because it also updates verification infrastructure, reviewers should
pay attention to whether the new tests are asserting the right failure
modes and not just reshaping harness behavior
## Model Used
- OpenAI Codex coding agent (GPT-5-class runtime in Codex CLI; exact
deployed model ID is not exposed in this environment), reasoning
enabled, tool use and local code execution enabled
## Checklist
- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [ ] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [ ] If this change affects the UI, I have included before/after
screenshots
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [x] I will address all Greptile and reviewer comments before
requesting merge
---------
Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-04-14 13:34:52 -05:00
|
|
|
mockAgentService.resolveByReference.mockReset();
|
2026-04-09 06:12:39 -05:00
|
|
|
mockLogActivity.mockReset();
|
2026-04-10 22:26:21 -05:00
|
|
|
mockFeedbackService.listIssueVotesForUser.mockReset();
|
|
|
|
|
mockFeedbackService.saveIssueVote.mockReset();
|
|
|
|
|
mockInstanceSettingsService.get.mockReset();
|
|
|
|
|
mockInstanceSettingsService.listCompanyIds.mockReset();
|
|
|
|
|
mockRoutineService.syncRunStatusForIssue.mockReset();
|
2026-04-09 06:12:39 -05:00
|
|
|
mockTxInsertValues.mockReset();
|
|
|
|
|
mockTxInsert.mockReset();
|
|
|
|
|
mockDb.transaction.mockReset();
|
|
|
|
|
mockTxInsertValues.mockResolvedValue(undefined);
|
|
|
|
|
mockTxInsert.mockImplementation(() => ({ values: mockTxInsertValues }));
|
|
|
|
|
mockDb.transaction.mockImplementation(async (fn: (tx: typeof mockTx) => Promise<unknown>) => fn(mockTx));
|
|
|
|
|
mockHeartbeatService.wakeup.mockResolvedValue(undefined);
|
|
|
|
|
mockHeartbeatService.reportRunActivity.mockResolvedValue(undefined);
|
|
|
|
|
mockHeartbeatService.getRun.mockResolvedValue(null);
|
|
|
|
|
mockHeartbeatService.getActiveRunForAgent.mockResolvedValue(null);
|
|
|
|
|
mockHeartbeatService.cancelRun.mockResolvedValue(null);
|
|
|
|
|
mockLogActivity.mockResolvedValue(undefined);
|
2026-04-10 22:26:21 -05:00
|
|
|
mockFeedbackService.listIssueVotesForUser.mockResolvedValue([]);
|
|
|
|
|
mockFeedbackService.saveIssueVote.mockResolvedValue({
|
|
|
|
|
vote: null,
|
|
|
|
|
consentEnabledNow: false,
|
|
|
|
|
sharingEnabled: false,
|
|
|
|
|
});
|
|
|
|
|
mockInstanceSettingsService.get.mockResolvedValue({
|
|
|
|
|
id: "instance-settings-1",
|
|
|
|
|
general: {
|
|
|
|
|
censorUsernameInLogs: false,
|
|
|
|
|
feedbackDataSharingPreference: "prompt",
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
mockInstanceSettingsService.listCompanyIds.mockResolvedValue(["company-1"]);
|
|
|
|
|
mockRoutineService.syncRunStatusForIssue.mockResolvedValue(undefined);
|
2026-03-20 15:46:01 -05:00
|
|
|
mockIssueService.addComment.mockResolvedValue({
|
|
|
|
|
id: "comment-1",
|
|
|
|
|
issueId: "11111111-1111-4111-8111-111111111111",
|
|
|
|
|
companyId: "company-1",
|
|
|
|
|
body: "hello",
|
|
|
|
|
createdAt: new Date(),
|
|
|
|
|
updatedAt: new Date(),
|
|
|
|
|
authorAgentId: null,
|
|
|
|
|
authorUserId: "local-board",
|
|
|
|
|
});
|
|
|
|
|
mockIssueService.findMentionedAgents.mockResolvedValue([]);
|
2026-04-07 17:07:10 -05:00
|
|
|
mockIssueService.listWakeableBlockedDependents.mockResolvedValue([]);
|
|
|
|
|
mockIssueService.getWakeableParentAfterChildCompletion.mockResolvedValue(null);
|
2026-04-08 08:05:35 -05:00
|
|
|
mockIssueService.assertCheckoutOwner.mockResolvedValue({ adoptedFromRunId: null });
|
|
|
|
|
mockAccessService.canUser.mockResolvedValue(false);
|
|
|
|
|
mockAccessService.hasPermission.mockResolvedValue(false);
|
|
|
|
|
mockAgentService.getById.mockResolvedValue(null);
|
[codex] Harden execution reliability and heartbeat tooling (#3679)
## Thinking Path
> - Paperclip orchestrates AI agents for zero-human companies
> - Reliable execution depends on heartbeat routing, issue lifecycle
semantics, telemetry, and a fast enough local verification loop to keep
regressions visible
> - The remaining commits on this branch were mostly server/runtime
correctness fixes plus test and documentation follow-ups in that area
> - Those changes are logically separate from the UI-focused
issue-detail and workspace/navigation branches even when they touch
overlapping issue APIs
> - This pull request groups the execution reliability, heartbeat,
telemetry, and tooling changes into one standalone branch
> - The benefit is a focused review of the control-plane correctness
work, including the follow-up fix that restored the implicit
comment-reopen helpers after branch splitting
## What Changed
- Hardened issue/heartbeat execution behavior, including self-review
stage skipping, deferred mention wakes during active execution, stranded
execution recovery, active-run scoping, assignee resolution, and
blocked-to-todo wake resumption
- Reduced noisy polling/logging overhead by trimming issue run payloads,
compacting persisted run logs, silencing high-volume request logs, and
capping heartbeat-run queries in dashboard/inbox surfaces
- Expanded telemetry and status semantics with adapter/model fields on
task completion plus clearer status guidance in docs/onboarding material
- Updated test infrastructure and verification defaults with faster
route-test module isolation, cheaper default `pnpm test`, e2e isolation
from local state, and repo verification follow-ups
- Included docs/release housekeeping from the branch and added a small
follow-up commit restoring the implicit comment-reopen helpers that were
dropped during branch reconstruction
## Verification
- `pnpm vitest run
server/src/__tests__/issue-comment-reopen-routes.test.ts
server/src/__tests__/issue-telemetry-routes.test.ts`
- `pnpm vitest run server/src/__tests__/http-log-policy.test.ts
server/src/__tests__/heartbeat-run-log.test.ts
server/src/__tests__/health.test.ts`
- `server/src/__tests__/activity-service.test.ts`,
`server/src/__tests__/heartbeat-comment-wake-batching.test.ts`, and
`server/src/__tests__/heartbeat-process-recovery.test.ts` were attempted
on this host but the embedded Postgres harness reported
init-script/data-dir problems and skipped or failed to start, so they
are noted as environment-limited
## Risks
- Medium: this branch changes core issue/heartbeat routing and
reopen/wakeup behavior, so regressions would affect agent execution flow
rather than isolated UI polish
- Because it also updates verification infrastructure, reviewers should
pay attention to whether the new tests are asserting the right failure
modes and not just reshaping harness behavior
## Model Used
- OpenAI Codex coding agent (GPT-5-class runtime in Codex CLI; exact
deployed model ID is not exposed in this environment), reasoning
enabled, tool use and local code execution enabled
## Checklist
- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [ ] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [ ] If this change affects the UI, I have included before/after
screenshots
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [x] I will address all Greptile and reviewer comments before
requesting merge
---------
Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-04-14 13:34:52 -05:00
|
|
|
mockAgentService.resolveByReference.mockImplementation(async (_companyId: string, reference: string) => ({
|
|
|
|
|
ambiguous: false,
|
|
|
|
|
agent: {
|
|
|
|
|
id: reference,
|
|
|
|
|
},
|
|
|
|
|
}));
|
2026-03-20 15:46:01 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("treats reopen=true as a no-op when the issue is already open", async () => {
|
|
|
|
|
mockIssueService.getById.mockResolvedValue(makeIssue("todo"));
|
|
|
|
|
mockIssueService.update.mockImplementation(async (_id: string, patch: Record<string, unknown>) => ({
|
|
|
|
|
...makeIssue("todo"),
|
|
|
|
|
...patch,
|
|
|
|
|
}));
|
|
|
|
|
|
2026-04-09 06:12:39 -05:00
|
|
|
const res = await request(await installActor(createApp()))
|
2026-03-20 15:46:01 -05:00
|
|
|
.patch("/api/issues/11111111-1111-4111-8111-111111111111")
|
|
|
|
|
.send({ comment: "hello", reopen: true, assigneeAgentId: "33333333-3333-4333-8333-333333333333" });
|
|
|
|
|
|
|
|
|
|
expect(res.status).toBe(200);
|
2026-04-09 06:12:39 -05:00
|
|
|
expect(res.body.assigneeAgentId).toBe("33333333-3333-4333-8333-333333333333");
|
2026-03-20 15:46:01 -05:00
|
|
|
expect(mockLogActivity).toHaveBeenCalledWith(
|
|
|
|
|
expect.anything(),
|
|
|
|
|
expect.objectContaining({
|
|
|
|
|
action: "issue.updated",
|
|
|
|
|
details: expect.not.objectContaining({ reopened: true }),
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
[codex] Improve issue detail and issue-list UX (#3678)
## Thinking Path
> - Paperclip orchestrates AI agents for zero-human companies
> - A core part of that is the operator experience around reading issue
state, agent chat, and sub-task structure
> - The current branch had a long run of issue-detail and issue-list UX
fixes that all improve how humans follow and steer active work
> - Those changes mostly live in the UI/chat surface and should be
reviewed together instead of mixed with workspace/runtime work
> - This pull request packages the issue-detail, chat, markdown, and
sub-issue list improvements into one standalone change
> - The benefit is a cleaner, less jumpy, more reliable issue workflow
on desktop and mobile without coupling it to unrelated server/runtime
refactors
## What Changed
- Stabilized issue chat runtime wiring, optimistic comment handling,
queued-comment cancellation, and composer anchoring during live updates
- Fixed several issue-detail rendering and navigation regressions
including placeholder bleed, local polling scope, mobile inbox-to-issue
transitions, and visible refresh resets
- Improved markdown and rich-content handling with advisory image
normalization, editor fallback behavior, touch mention recovery, and
`issue:` quicklook links
- Refined sub-issue behavior with parent-derived defaults, current-user
inheritance fixes, empty-state cleanup, and a reusable issue-list
presentation for sub-issues
- Added targeted UI tests for the new issue-detail, chat scroll/message,
placeholder-data, markdown, and issue-list behaviors
## Verification
- `pnpm vitest run ui/src/components/IssueChatThread.test.tsx
ui/src/components/MarkdownEditor.test.tsx
ui/src/components/IssuesList.test.tsx
ui/src/context/LiveUpdatesProvider.test.tsx
ui/src/lib/issue-chat-messages.test.ts
ui/src/lib/issue-chat-scroll.test.ts
ui/src/lib/issue-detail-subissues.test.ts
ui/src/lib/query-placeholder-data.test.tsx
ui/src/hooks/usePaperclipIssueRuntime.test.tsx`
## Risks
- Medium: this branch touches the highest-traffic issue-detail UI paths,
so regressions would show up as chat/thread or sub-issue UX glitches
- The changes are UI-heavy and would benefit from reviewer screenshots
or a quick manual browser pass before merge
## Model Used
- OpenAI Codex coding agent (GPT-5-class runtime in Codex CLI; exact
deployed model ID is not exposed in this environment), reasoning
enabled, tool use and local code execution enabled
## Checklist
- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [ ] If this change affects the UI, I have included before/after
screenshots
- [ ] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [x] I will address all Greptile and reviewer comments before
requesting merge
---------
Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-04-14 12:50:48 -05:00
|
|
|
it("implicitly reopens closed issues via the PATCH comment path when reassigning to an agent", async () => {
|
|
|
|
|
mockIssueService.getById.mockResolvedValue(makeIssue("done"));
|
|
|
|
|
mockIssueService.update.mockImplementation(async (_id: string, patch: Record<string, unknown>) => ({
|
|
|
|
|
...makeIssue("done"),
|
|
|
|
|
...patch,
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
const res = await request(await installActor(createApp()))
|
|
|
|
|
.patch("/api/issues/11111111-1111-4111-8111-111111111111")
|
|
|
|
|
.send({ comment: "hello", assigneeAgentId: "33333333-3333-4333-8333-333333333333" });
|
|
|
|
|
|
|
|
|
|
expect(res.status).toBe(200);
|
|
|
|
|
expect(mockIssueService.update).toHaveBeenCalledWith(
|
|
|
|
|
"11111111-1111-4111-8111-111111111111",
|
|
|
|
|
expect.objectContaining({
|
|
|
|
|
assigneeAgentId: "33333333-3333-4333-8333-333333333333",
|
|
|
|
|
status: "todo",
|
|
|
|
|
actorAgentId: null,
|
|
|
|
|
actorUserId: "local-board",
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
expect(mockLogActivity).toHaveBeenCalledWith(
|
|
|
|
|
expect.anything(),
|
|
|
|
|
expect.objectContaining({
|
|
|
|
|
action: "issue.updated",
|
|
|
|
|
details: expect.objectContaining({
|
|
|
|
|
reopened: true,
|
|
|
|
|
reopenedFrom: "done",
|
|
|
|
|
status: "todo",
|
|
|
|
|
}),
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
[codex] Harden execution reliability and heartbeat tooling (#3679)
## Thinking Path
> - Paperclip orchestrates AI agents for zero-human companies
> - Reliable execution depends on heartbeat routing, issue lifecycle
semantics, telemetry, and a fast enough local verification loop to keep
regressions visible
> - The remaining commits on this branch were mostly server/runtime
correctness fixes plus test and documentation follow-ups in that area
> - Those changes are logically separate from the UI-focused
issue-detail and workspace/navigation branches even when they touch
overlapping issue APIs
> - This pull request groups the execution reliability, heartbeat,
telemetry, and tooling changes into one standalone branch
> - The benefit is a focused review of the control-plane correctness
work, including the follow-up fix that restored the implicit
comment-reopen helpers after branch splitting
## What Changed
- Hardened issue/heartbeat execution behavior, including self-review
stage skipping, deferred mention wakes during active execution, stranded
execution recovery, active-run scoping, assignee resolution, and
blocked-to-todo wake resumption
- Reduced noisy polling/logging overhead by trimming issue run payloads,
compacting persisted run logs, silencing high-volume request logs, and
capping heartbeat-run queries in dashboard/inbox surfaces
- Expanded telemetry and status semantics with adapter/model fields on
task completion plus clearer status guidance in docs/onboarding material
- Updated test infrastructure and verification defaults with faster
route-test module isolation, cheaper default `pnpm test`, e2e isolation
from local state, and repo verification follow-ups
- Included docs/release housekeeping from the branch and added a small
follow-up commit restoring the implicit comment-reopen helpers that were
dropped during branch reconstruction
## Verification
- `pnpm vitest run
server/src/__tests__/issue-comment-reopen-routes.test.ts
server/src/__tests__/issue-telemetry-routes.test.ts`
- `pnpm vitest run server/src/__tests__/http-log-policy.test.ts
server/src/__tests__/heartbeat-run-log.test.ts
server/src/__tests__/health.test.ts`
- `server/src/__tests__/activity-service.test.ts`,
`server/src/__tests__/heartbeat-comment-wake-batching.test.ts`, and
`server/src/__tests__/heartbeat-process-recovery.test.ts` were attempted
on this host but the embedded Postgres harness reported
init-script/data-dir problems and skipped or failed to start, so they
are noted as environment-limited
## Risks
- Medium: this branch changes core issue/heartbeat routing and
reopen/wakeup behavior, so regressions would affect agent execution flow
rather than isolated UI polish
- Because it also updates verification infrastructure, reviewers should
pay attention to whether the new tests are asserting the right failure
modes and not just reshaping harness behavior
## Model Used
- OpenAI Codex coding agent (GPT-5-class runtime in Codex CLI; exact
deployed model ID is not exposed in this environment), reasoning
enabled, tool use and local code execution enabled
## Checklist
- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [ ] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [ ] If this change affects the UI, I have included before/after
screenshots
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [x] I will address all Greptile and reviewer comments before
requesting merge
---------
Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-04-14 13:34:52 -05:00
|
|
|
it("resolves assignee shortnames before updating an issue", async () => {
|
|
|
|
|
mockIssueService.getById.mockResolvedValue(makeIssue("todo"));
|
|
|
|
|
mockIssueService.update.mockImplementation(async (_id: string, patch: Record<string, unknown>) => ({
|
|
|
|
|
...makeIssue("todo"),
|
|
|
|
|
...patch,
|
|
|
|
|
}));
|
|
|
|
|
mockAgentService.resolveByReference.mockResolvedValue({
|
|
|
|
|
ambiguous: false,
|
|
|
|
|
agent: { id: "33333333-3333-4333-8333-333333333333" },
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const res = await request(await installActor(createApp()))
|
|
|
|
|
.patch("/api/issues/11111111-1111-4111-8111-111111111111")
|
|
|
|
|
.send({ comment: "hello", assigneeAgentId: "codexcoder" });
|
|
|
|
|
|
|
|
|
|
expect(res.status).toBe(200);
|
|
|
|
|
expect(mockAgentService.resolveByReference).toHaveBeenCalledWith("company-1", "codexcoder");
|
|
|
|
|
expect(mockIssueService.update).toHaveBeenCalledWith(
|
|
|
|
|
"11111111-1111-4111-8111-111111111111",
|
|
|
|
|
expect.objectContaining({
|
|
|
|
|
assigneeAgentId: "33333333-3333-4333-8333-333333333333",
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("rejects ambiguous assignee shortnames", async () => {
|
|
|
|
|
mockIssueService.getById.mockResolvedValue(makeIssue("todo"));
|
|
|
|
|
mockAgentService.resolveByReference.mockResolvedValue({
|
|
|
|
|
ambiguous: true,
|
|
|
|
|
agent: null,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const res = await request(await installActor(createApp()))
|
|
|
|
|
.patch("/api/issues/11111111-1111-4111-8111-111111111111")
|
|
|
|
|
.send({ assigneeAgentId: "codexcoder" });
|
|
|
|
|
|
|
|
|
|
expect(res.status).toBe(409);
|
|
|
|
|
expect(res.body.error).toContain("ambiguous");
|
|
|
|
|
expect(mockIssueService.update).not.toHaveBeenCalled();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("rejects missing assignee shortnames", async () => {
|
|
|
|
|
mockIssueService.getById.mockResolvedValue(makeIssue("todo"));
|
|
|
|
|
mockAgentService.resolveByReference.mockResolvedValue({
|
|
|
|
|
ambiguous: false,
|
|
|
|
|
agent: null,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const res = await request(await installActor(createApp()))
|
|
|
|
|
.patch("/api/issues/11111111-1111-4111-8111-111111111111")
|
|
|
|
|
.send({ assigneeAgentId: "codexcoder" });
|
|
|
|
|
|
|
|
|
|
expect(res.status).toBe(404);
|
|
|
|
|
expect(res.body.error).toBe("Agent not found");
|
|
|
|
|
expect(mockIssueService.update).not.toHaveBeenCalled();
|
|
|
|
|
});
|
2026-03-20 15:46:01 -05:00
|
|
|
it("reopens closed issues via the PATCH comment path", async () => {
|
|
|
|
|
mockIssueService.getById.mockResolvedValue(makeIssue("done"));
|
|
|
|
|
mockIssueService.update.mockImplementation(async (_id: string, patch: Record<string, unknown>) => ({
|
|
|
|
|
...makeIssue("done"),
|
|
|
|
|
...patch,
|
|
|
|
|
}));
|
|
|
|
|
|
2026-04-09 06:12:39 -05:00
|
|
|
const res = await request(await installActor(createApp()))
|
2026-03-20 15:46:01 -05:00
|
|
|
.patch("/api/issues/11111111-1111-4111-8111-111111111111")
|
|
|
|
|
.send({ comment: "hello", reopen: true, assigneeAgentId: "33333333-3333-4333-8333-333333333333" });
|
|
|
|
|
|
|
|
|
|
expect(res.status).toBe(200);
|
2026-04-04 13:56:04 -05:00
|
|
|
expect(mockIssueService.update).toHaveBeenCalledWith(
|
|
|
|
|
"11111111-1111-4111-8111-111111111111",
|
|
|
|
|
expect.objectContaining({
|
|
|
|
|
assigneeAgentId: "33333333-3333-4333-8333-333333333333",
|
|
|
|
|
status: "todo",
|
|
|
|
|
actorAgentId: null,
|
|
|
|
|
actorUserId: "local-board",
|
|
|
|
|
}),
|
|
|
|
|
);
|
2026-03-20 15:46:01 -05:00
|
|
|
expect(mockLogActivity).toHaveBeenCalledWith(
|
|
|
|
|
expect.anything(),
|
|
|
|
|
expect.objectContaining({
|
|
|
|
|
action: "issue.updated",
|
|
|
|
|
details: expect.objectContaining({
|
|
|
|
|
reopened: true,
|
|
|
|
|
reopenedFrom: "done",
|
|
|
|
|
status: "todo",
|
|
|
|
|
}),
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
});
|
2026-03-28 10:34:36 -05:00
|
|
|
|
[codex] Improve issue detail and issue-list UX (#3678)
## Thinking Path
> - Paperclip orchestrates AI agents for zero-human companies
> - A core part of that is the operator experience around reading issue
state, agent chat, and sub-task structure
> - The current branch had a long run of issue-detail and issue-list UX
fixes that all improve how humans follow and steer active work
> - Those changes mostly live in the UI/chat surface and should be
reviewed together instead of mixed with workspace/runtime work
> - This pull request packages the issue-detail, chat, markdown, and
sub-issue list improvements into one standalone change
> - The benefit is a cleaner, less jumpy, more reliable issue workflow
on desktop and mobile without coupling it to unrelated server/runtime
refactors
## What Changed
- Stabilized issue chat runtime wiring, optimistic comment handling,
queued-comment cancellation, and composer anchoring during live updates
- Fixed several issue-detail rendering and navigation regressions
including placeholder bleed, local polling scope, mobile inbox-to-issue
transitions, and visible refresh resets
- Improved markdown and rich-content handling with advisory image
normalization, editor fallback behavior, touch mention recovery, and
`issue:` quicklook links
- Refined sub-issue behavior with parent-derived defaults, current-user
inheritance fixes, empty-state cleanup, and a reusable issue-list
presentation for sub-issues
- Added targeted UI tests for the new issue-detail, chat scroll/message,
placeholder-data, markdown, and issue-list behaviors
## Verification
- `pnpm vitest run ui/src/components/IssueChatThread.test.tsx
ui/src/components/MarkdownEditor.test.tsx
ui/src/components/IssuesList.test.tsx
ui/src/context/LiveUpdatesProvider.test.tsx
ui/src/lib/issue-chat-messages.test.ts
ui/src/lib/issue-chat-scroll.test.ts
ui/src/lib/issue-detail-subissues.test.ts
ui/src/lib/query-placeholder-data.test.tsx
ui/src/hooks/usePaperclipIssueRuntime.test.tsx`
## Risks
- Medium: this branch touches the highest-traffic issue-detail UI paths,
so regressions would show up as chat/thread or sub-issue UX glitches
- The changes are UI-heavy and would benefit from reviewer screenshots
or a quick manual browser pass before merge
## Model Used
- OpenAI Codex coding agent (GPT-5-class runtime in Codex CLI; exact
deployed model ID is not exposed in this environment), reasoning
enabled, tool use and local code execution enabled
## Checklist
- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [ ] If this change affects the UI, I have included before/after
screenshots
- [ ] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [x] I will address all Greptile and reviewer comments before
requesting merge
---------
Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-04-14 12:50:48 -05:00
|
|
|
it("implicitly reopens closed issues via POST comments when an agent is assigned", async () => {
|
|
|
|
|
mockIssueService.getById.mockResolvedValue(makeIssue("done"));
|
|
|
|
|
mockIssueService.update.mockImplementation(async (_id: string, patch: Record<string, unknown>) => ({
|
|
|
|
|
...makeIssue("done"),
|
|
|
|
|
...patch,
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
const res = await request(await installActor(createApp()))
|
|
|
|
|
.post("/api/issues/11111111-1111-4111-8111-111111111111/comments")
|
|
|
|
|
.send({ body: "hello" });
|
|
|
|
|
|
|
|
|
|
expect(res.status).toBe(201);
|
|
|
|
|
expect(mockIssueService.update).toHaveBeenCalledWith(
|
|
|
|
|
"11111111-1111-4111-8111-111111111111",
|
|
|
|
|
{ status: "todo" },
|
|
|
|
|
);
|
|
|
|
|
expect(mockHeartbeatService.wakeup).toHaveBeenCalledWith(
|
|
|
|
|
"22222222-2222-4222-8222-222222222222",
|
|
|
|
|
expect.objectContaining({
|
|
|
|
|
reason: "issue_reopened_via_comment",
|
|
|
|
|
payload: expect.objectContaining({
|
|
|
|
|
reopenedFrom: "done",
|
|
|
|
|
}),
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("does not implicitly reopen closed issues via POST comments when no agent is assigned", async () => {
|
|
|
|
|
mockIssueService.getById.mockResolvedValue({
|
|
|
|
|
...makeIssue("done"),
|
|
|
|
|
assigneeAgentId: null,
|
|
|
|
|
assigneeUserId: "local-board",
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const res = await request(await installActor(createApp()))
|
|
|
|
|
.post("/api/issues/11111111-1111-4111-8111-111111111111/comments")
|
|
|
|
|
.send({ body: "hello" });
|
|
|
|
|
|
|
|
|
|
expect(res.status).toBe(201);
|
|
|
|
|
expect(mockIssueService.update).not.toHaveBeenCalled();
|
|
|
|
|
});
|
[codex] harden authenticated routes and issue editor reliability (#3741)
## Thinking Path
> - Paperclip orchestrates AI agents for zero-human companies
> - The control plane depends on authenticated routes enforcing company
boundaries and role permissions correctly
> - This branch also touches the issue detail and markdown editing flows
operators use while handling advisory and triage work
> - Partial issue cache seeds and fragile rich-editor parsing could
leave important issue content missing or blank at the moment an operator
needed it
> - Blocked issues becoming actionable again should wake their assignee
automatically instead of silently staying idle
> - This pull request rebases the advisory follow-up branch onto current
`master`, hardens authenticated route authorization, and carries the
issue-detail/editor reliability fixes forward with regression tests
> - The benefit is tighter authz on sensitive routes plus more reliable
issue/advisory editing and wakeup behavior on top of the latest base
## What Changed
- Hardened authenticated route authorization across agent, activity,
approval, access, project, plugin, health, execution-workspace,
portability, and related server paths, with new cross-tenant and
runtime-authz regression coverage.
- Switched issue detail queries from `initialData` to placeholder-based
hydration so list/quicklook seeds still refetch full issue bodies.
- Normalized advisory-style HTML images before mounting the markdown
editor and strengthened fallback behavior when the rich editor silently
fails or rejects the content.
- Woke assigned agents when blocked issues move back to `todo`, with
route coverage for reopen and unblock transitions.
- Rebasing note: this branch now sits cleanly on top of the latest
`master` tip used for the PR base.
## Verification
- `pnpm exec vitest run ui/src/lib/issueDetailQuery.test.tsx
ui/src/components/MarkdownEditor.test.tsx
server/src/__tests__/issue-comment-reopen-routes.test.ts
server/src/__tests__/activity-routes.test.ts
server/src/__tests__/agent-cross-tenant-authz-routes.test.ts`
- Confirmed `pnpm-lock.yaml` is not part of the PR diff.
- Rebased the branch onto current `public-gh/master` before publishing.
## Risks
- Broad authz tightening may expose existing flows that were relying on
permissive board or agent access and now need explicit grants.
- Markdown editor fallback changes could affect focus or rendering in
edge-case content that mixes HTML-like advisory markup with normal
markdown.
- This verification was intentionally scoped to touched regressions and
did not run the full repository suite.
## Model Used
- OpenAI Codex, GPT-5-based coding agent in the Codex CLI environment
with tool use for terminal, git, and GitHub operations. The exact
runtime model identifier is not exposed inside this session.
## Checklist
- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] If this change affects the UI, it is behavior-only and does not
need before/after screenshots
- [x] I have updated relevant documentation to reflect my changes, or no
documentation changes were needed for these internal fixes
- [x] I have considered and documented any risks above
- [x] I will address all Greptile and reviewer comments before
requesting merge
---------
Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-04-15 08:41:15 -05:00
|
|
|
|
|
|
|
|
it("wakes the assignee when an assigned blocked issue moves back to todo", async () => {
|
|
|
|
|
const issue = makeIssue("blocked");
|
|
|
|
|
mockIssueService.getById.mockResolvedValue(issue);
|
|
|
|
|
mockIssueService.update.mockImplementation(async (_id: string, patch: Record<string, unknown>) => ({
|
|
|
|
|
...issue,
|
|
|
|
|
...patch,
|
|
|
|
|
updatedAt: new Date(),
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
const res = await request(await installActor(createApp()))
|
|
|
|
|
.patch("/api/issues/11111111-1111-4111-8111-111111111111")
|
|
|
|
|
.send({ status: "todo" });
|
|
|
|
|
|
|
|
|
|
expect(res.status).toBe(200);
|
|
|
|
|
expect(mockHeartbeatService.wakeup).toHaveBeenCalledWith(
|
|
|
|
|
"22222222-2222-4222-8222-222222222222",
|
|
|
|
|
expect.objectContaining({
|
|
|
|
|
source: "automation",
|
|
|
|
|
triggerDetail: "system",
|
|
|
|
|
reason: "issue_status_changed",
|
|
|
|
|
payload: expect.objectContaining({
|
|
|
|
|
issueId: "11111111-1111-4111-8111-111111111111",
|
|
|
|
|
mutation: "update",
|
|
|
|
|
}),
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
});
|
2026-03-28 10:34:36 -05:00
|
|
|
it("interrupts an active run before a combined comment update", async () => {
|
|
|
|
|
const issue = {
|
|
|
|
|
...makeIssue("todo"),
|
|
|
|
|
executionRunId: "run-1",
|
|
|
|
|
};
|
|
|
|
|
mockIssueService.getById.mockResolvedValue(issue);
|
|
|
|
|
mockIssueService.update.mockImplementation(async (_id: string, patch: Record<string, unknown>) => ({
|
|
|
|
|
...issue,
|
|
|
|
|
...patch,
|
|
|
|
|
}));
|
|
|
|
|
mockHeartbeatService.getRun.mockResolvedValue({
|
|
|
|
|
id: "run-1",
|
|
|
|
|
companyId: "company-1",
|
|
|
|
|
agentId: "22222222-2222-4222-8222-222222222222",
|
|
|
|
|
status: "running",
|
|
|
|
|
});
|
|
|
|
|
mockHeartbeatService.cancelRun.mockResolvedValue({
|
|
|
|
|
id: "run-1",
|
|
|
|
|
companyId: "company-1",
|
|
|
|
|
agentId: "22222222-2222-4222-8222-222222222222",
|
|
|
|
|
status: "cancelled",
|
|
|
|
|
});
|
|
|
|
|
|
2026-04-09 06:12:39 -05:00
|
|
|
const res = await request(await installActor(createApp()))
|
2026-03-28 10:34:36 -05:00
|
|
|
.patch("/api/issues/11111111-1111-4111-8111-111111111111")
|
|
|
|
|
.send({ comment: "hello", interrupt: true, assigneeAgentId: "33333333-3333-4333-8333-333333333333" });
|
|
|
|
|
|
|
|
|
|
expect(res.status).toBe(200);
|
|
|
|
|
expect(mockHeartbeatService.getRun).toHaveBeenCalledWith("run-1");
|
|
|
|
|
expect(mockHeartbeatService.cancelRun).toHaveBeenCalledWith("run-1");
|
|
|
|
|
expect(mockLogActivity).toHaveBeenCalledWith(
|
|
|
|
|
expect.anything(),
|
|
|
|
|
expect.objectContaining({
|
|
|
|
|
action: "heartbeat.cancelled",
|
|
|
|
|
details: expect.objectContaining({
|
|
|
|
|
source: "issue_comment_interrupt",
|
|
|
|
|
issueId: "11111111-1111-4111-8111-111111111111",
|
|
|
|
|
}),
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
});
|
2026-04-07 17:07:10 -05:00
|
|
|
|
|
|
|
|
it("writes decision ids into executionState and inserts the decision inside the transaction", async () => {
|
2026-04-09 06:12:39 -05:00
|
|
|
const policy = await normalizePolicy({
|
2026-04-07 17:07:10 -05:00
|
|
|
stages: [
|
|
|
|
|
{
|
|
|
|
|
id: "aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa",
|
|
|
|
|
type: "approval",
|
|
|
|
|
participants: [{ type: "user", userId: "local-board" }],
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
})!;
|
|
|
|
|
const issue = {
|
|
|
|
|
...makeIssue("todo"),
|
|
|
|
|
status: "in_review",
|
|
|
|
|
assigneeAgentId: null,
|
|
|
|
|
assigneeUserId: "local-board",
|
|
|
|
|
executionPolicy: policy,
|
|
|
|
|
executionState: {
|
|
|
|
|
status: "pending",
|
|
|
|
|
currentStageId: policy.stages[0].id,
|
|
|
|
|
currentStageIndex: 0,
|
|
|
|
|
currentStageType: "approval",
|
|
|
|
|
currentParticipant: { type: "user", userId: "local-board" },
|
|
|
|
|
returnAssignee: { type: "agent", agentId: "22222222-2222-4222-8222-222222222222" },
|
|
|
|
|
completedStageIds: [],
|
|
|
|
|
lastDecisionId: null,
|
|
|
|
|
lastDecisionOutcome: null,
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
mockIssueService.getById.mockResolvedValue(issue);
|
|
|
|
|
mockIssueService.update.mockImplementation(async (_id: string, patch: Record<string, unknown>, tx?: unknown) => ({
|
|
|
|
|
...issue,
|
|
|
|
|
...patch,
|
|
|
|
|
executionState: patch.executionState,
|
|
|
|
|
status: "done",
|
|
|
|
|
completedAt: new Date(),
|
|
|
|
|
updatedAt: new Date(),
|
|
|
|
|
_tx: tx,
|
|
|
|
|
}));
|
|
|
|
|
|
2026-04-09 06:12:39 -05:00
|
|
|
const res = await request(await installActor(createApp()))
|
2026-04-07 17:07:10 -05:00
|
|
|
.patch("/api/issues/11111111-1111-4111-8111-111111111111")
|
|
|
|
|
.send({ status: "done", comment: "Approved for ship" });
|
|
|
|
|
|
|
|
|
|
expect(res.status).toBe(200);
|
|
|
|
|
expect(mockDb.transaction).toHaveBeenCalledTimes(1);
|
|
|
|
|
expect(mockIssueService.update).toHaveBeenCalledWith(
|
|
|
|
|
"11111111-1111-4111-8111-111111111111",
|
|
|
|
|
expect.objectContaining({
|
|
|
|
|
executionState: expect.objectContaining({
|
|
|
|
|
status: "completed",
|
|
|
|
|
lastDecisionId: expect.any(String),
|
|
|
|
|
lastDecisionOutcome: "approved",
|
|
|
|
|
}),
|
|
|
|
|
}),
|
|
|
|
|
mockTx,
|
|
|
|
|
);
|
|
|
|
|
const updatePatch = mockIssueService.update.mock.calls[0]?.[1] as Record<string, any>;
|
|
|
|
|
const decisionId = updatePatch.executionState.lastDecisionId;
|
|
|
|
|
expect(mockTxInsertValues).toHaveBeenCalledWith(
|
|
|
|
|
expect.objectContaining({
|
|
|
|
|
id: decisionId,
|
|
|
|
|
issueId: "11111111-1111-4111-8111-111111111111",
|
|
|
|
|
outcome: "approved",
|
|
|
|
|
body: "Approved for ship",
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
});
|
2026-04-08 08:05:35 -05:00
|
|
|
|
|
|
|
|
it("coerces executor handoff patches into workflow-controlled review wakes", async () => {
|
2026-04-09 09:40:44 -05:00
|
|
|
const policy = await normalizePolicy({
|
2026-04-08 08:05:35 -05:00
|
|
|
stages: [
|
|
|
|
|
{
|
|
|
|
|
id: "aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa",
|
|
|
|
|
type: "review",
|
|
|
|
|
participants: [{ type: "agent", agentId: "33333333-3333-4333-8333-333333333333" }],
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
})!;
|
|
|
|
|
const issue = {
|
|
|
|
|
...makeIssue("todo"),
|
|
|
|
|
status: "in_progress",
|
|
|
|
|
assigneeAgentId: "22222222-2222-4222-8222-222222222222",
|
|
|
|
|
executionPolicy: policy,
|
|
|
|
|
executionState: null,
|
|
|
|
|
};
|
|
|
|
|
mockIssueService.getById.mockResolvedValue(issue);
|
|
|
|
|
mockIssueService.update.mockImplementation(async (_id: string, patch: Record<string, unknown>) => ({
|
|
|
|
|
...issue,
|
|
|
|
|
...patch,
|
|
|
|
|
updatedAt: new Date(),
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
const res = await request(
|
2026-04-09 09:40:44 -05:00
|
|
|
await installActor(createApp(), {
|
2026-04-08 08:05:35 -05:00
|
|
|
type: "agent",
|
|
|
|
|
agentId: "22222222-2222-4222-8222-222222222222",
|
|
|
|
|
companyId: "company-1",
|
|
|
|
|
runId: "run-1",
|
|
|
|
|
}),
|
|
|
|
|
)
|
|
|
|
|
.patch("/api/issues/11111111-1111-4111-8111-111111111111")
|
|
|
|
|
.send({
|
|
|
|
|
status: "in_review",
|
|
|
|
|
assigneeAgentId: null,
|
|
|
|
|
assigneeUserId: "local-board",
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
expect(res.status).toBe(200);
|
|
|
|
|
expect(mockIssueService.update).toHaveBeenCalledWith(
|
|
|
|
|
"11111111-1111-4111-8111-111111111111",
|
|
|
|
|
expect.objectContaining({
|
|
|
|
|
status: "in_review",
|
|
|
|
|
assigneeAgentId: "33333333-3333-4333-8333-333333333333",
|
|
|
|
|
assigneeUserId: null,
|
|
|
|
|
executionState: expect.objectContaining({
|
|
|
|
|
status: "pending",
|
|
|
|
|
currentStageType: "review",
|
|
|
|
|
currentParticipant: expect.objectContaining({
|
|
|
|
|
type: "agent",
|
|
|
|
|
agentId: "33333333-3333-4333-8333-333333333333",
|
|
|
|
|
}),
|
|
|
|
|
returnAssignee: expect.objectContaining({
|
|
|
|
|
type: "agent",
|
|
|
|
|
agentId: "22222222-2222-4222-8222-222222222222",
|
|
|
|
|
}),
|
|
|
|
|
}),
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
expect(mockHeartbeatService.wakeup).toHaveBeenCalledWith(
|
|
|
|
|
"33333333-3333-4333-8333-333333333333",
|
|
|
|
|
expect.objectContaining({
|
|
|
|
|
reason: "execution_review_requested",
|
|
|
|
|
payload: expect.objectContaining({
|
|
|
|
|
issueId: "11111111-1111-4111-8111-111111111111",
|
|
|
|
|
executionStage: expect.objectContaining({
|
|
|
|
|
wakeRole: "reviewer",
|
|
|
|
|
stageType: "review",
|
|
|
|
|
allowedActions: ["approve", "request_changes"],
|
|
|
|
|
}),
|
|
|
|
|
}),
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("wakes the return assignee with execution_changes_requested", async () => {
|
2026-04-09 09:40:44 -05:00
|
|
|
const policy = await normalizePolicy({
|
2026-04-08 08:05:35 -05:00
|
|
|
stages: [
|
|
|
|
|
{
|
|
|
|
|
id: "aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa",
|
|
|
|
|
type: "review",
|
|
|
|
|
participants: [{ type: "agent", agentId: "33333333-3333-4333-8333-333333333333" }],
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
})!;
|
|
|
|
|
const issue = {
|
|
|
|
|
...makeIssue("todo"),
|
|
|
|
|
status: "in_review",
|
|
|
|
|
assigneeAgentId: "33333333-3333-4333-8333-333333333333",
|
|
|
|
|
executionPolicy: policy,
|
|
|
|
|
executionState: {
|
|
|
|
|
status: "pending",
|
|
|
|
|
currentStageId: policy.stages[0].id,
|
|
|
|
|
currentStageIndex: 0,
|
|
|
|
|
currentStageType: "review",
|
|
|
|
|
currentParticipant: { type: "agent", agentId: "33333333-3333-4333-8333-333333333333" },
|
|
|
|
|
returnAssignee: { type: "agent", agentId: "22222222-2222-4222-8222-222222222222" },
|
|
|
|
|
completedStageIds: [],
|
|
|
|
|
lastDecisionId: null,
|
|
|
|
|
lastDecisionOutcome: null,
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
mockIssueService.getById.mockResolvedValue(issue);
|
|
|
|
|
mockIssueService.update.mockImplementation(async (_id: string, patch: Record<string, unknown>) => ({
|
|
|
|
|
...issue,
|
|
|
|
|
...patch,
|
|
|
|
|
updatedAt: new Date(),
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
const res = await request(
|
2026-04-09 09:40:44 -05:00
|
|
|
await installActor(createApp(), {
|
2026-04-08 08:05:35 -05:00
|
|
|
type: "agent",
|
|
|
|
|
agentId: "33333333-3333-4333-8333-333333333333",
|
|
|
|
|
companyId: "company-1",
|
|
|
|
|
runId: "run-2",
|
|
|
|
|
}),
|
|
|
|
|
)
|
|
|
|
|
.patch("/api/issues/11111111-1111-4111-8111-111111111111")
|
|
|
|
|
.send({
|
|
|
|
|
status: "in_progress",
|
|
|
|
|
comment: "Needs another pass",
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
expect(res.status).toBe(200);
|
|
|
|
|
expect(mockHeartbeatService.wakeup).toHaveBeenCalledWith(
|
|
|
|
|
"22222222-2222-4222-8222-222222222222",
|
|
|
|
|
expect.objectContaining({
|
|
|
|
|
reason: "execution_changes_requested",
|
|
|
|
|
payload: expect.objectContaining({
|
|
|
|
|
issueId: "11111111-1111-4111-8111-111111111111",
|
|
|
|
|
executionStage: expect.objectContaining({
|
|
|
|
|
wakeRole: "executor",
|
|
|
|
|
stageType: "review",
|
|
|
|
|
lastDecisionOutcome: "changes_requested",
|
|
|
|
|
allowedActions: ["address_changes", "resubmit"],
|
|
|
|
|
}),
|
|
|
|
|
}),
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
});
|
2026-03-20 15:46:01 -05:00
|
|
|
});
|