2026-03-17 11:47:50 -05:00
|
|
|
import express from "express";
|
|
|
|
|
import request from "supertest";
|
|
|
|
|
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
|
|
|
|
|
|
|
|
const mockAgentService = vi.hoisted(() => ({
|
|
|
|
|
getById: vi.fn(),
|
|
|
|
|
update: vi.fn(),
|
2026-03-18 13:18:48 -05:00
|
|
|
create: vi.fn(),
|
2026-03-17 11:47:50 -05:00
|
|
|
resolveByReference: vi.fn(),
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
const mockAccessService = vi.hoisted(() => ({
|
|
|
|
|
canUser: vi.fn(),
|
|
|
|
|
hasPermission: vi.fn(),
|
2026-03-20 07:01:42 -05:00
|
|
|
getMembership: vi.fn(),
|
|
|
|
|
listPrincipalGrants: vi.fn(),
|
|
|
|
|
ensureMembership: vi.fn(),
|
|
|
|
|
setPrincipalPermission: vi.fn(),
|
2026-03-17 11:47:50 -05:00
|
|
|
}));
|
|
|
|
|
|
2026-03-19 07:57:25 -05:00
|
|
|
const mockApprovalService = vi.hoisted(() => ({
|
|
|
|
|
create: vi.fn(),
|
|
|
|
|
}));
|
2026-03-17 11:47:50 -05:00
|
|
|
const mockBudgetService = vi.hoisted(() => ({}));
|
|
|
|
|
const mockHeartbeatService = vi.hoisted(() => ({}));
|
2026-03-18 13:18:48 -05:00
|
|
|
const mockIssueApprovalService = vi.hoisted(() => ({
|
|
|
|
|
linkManyForApproval: vi.fn(),
|
|
|
|
|
}));
|
2026-03-17 11:47:50 -05:00
|
|
|
const mockWorkspaceOperationService = vi.hoisted(() => ({}));
|
2026-03-17 13:42:00 -05:00
|
|
|
const mockAgentInstructionsService = vi.hoisted(() => ({
|
|
|
|
|
getBundle: vi.fn(),
|
|
|
|
|
readFile: vi.fn(),
|
|
|
|
|
updateBundle: vi.fn(),
|
|
|
|
|
writeFile: vi.fn(),
|
|
|
|
|
deleteFile: vi.fn(),
|
|
|
|
|
exportFiles: vi.fn(),
|
|
|
|
|
ensureManagedBundle: vi.fn(),
|
|
|
|
|
materializeManagedBundle: vi.fn(),
|
|
|
|
|
}));
|
2026-03-17 11:47:50 -05:00
|
|
|
|
|
|
|
|
const mockCompanySkillService = vi.hoisted(() => ({
|
|
|
|
|
listRuntimeSkillEntries: vi.fn(),
|
2026-03-18 13:18:48 -05:00
|
|
|
resolveRequestedSkillKeys: vi.fn(),
|
2026-03-17 11:47:50 -05:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
const mockSecretService = vi.hoisted(() => ({
|
|
|
|
|
resolveAdapterConfigForRuntime: vi.fn(),
|
2026-03-17 13:42:00 -05:00
|
|
|
normalizeAdapterConfigForPersistence: vi.fn(async (_companyId: string, config: Record<string, unknown>) => config),
|
2026-03-17 11:47:50 -05:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
const mockLogActivity = vi.hoisted(() => vi.fn());
|
2026-04-03 07:32:54 -05:00
|
|
|
const mockTrackAgentCreated = vi.hoisted(() => vi.fn());
|
|
|
|
|
const mockGetTelemetryClient = vi.hoisted(() => 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
|
|
|
const mockSyncInstructionsBundleConfigFromFilePath = vi.hoisted(() => vi.fn());
|
2026-03-17 11:47:50 -05:00
|
|
|
|
|
|
|
|
const mockAdapter = vi.hoisted(() => ({
|
|
|
|
|
listSkills: vi.fn(),
|
|
|
|
|
syncSkills: 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
|
|
|
vi.mock("@paperclipai/shared/telemetry", () => ({
|
|
|
|
|
trackAgentCreated: mockTrackAgentCreated,
|
|
|
|
|
trackErrorHandlerCrash: vi.fn(),
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
vi.mock("../telemetry.js", () => ({
|
|
|
|
|
getTelemetryClient: mockGetTelemetryClient,
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
vi.mock("../services/index.js", () => ({
|
|
|
|
|
agentService: () => mockAgentService,
|
|
|
|
|
agentInstructionsService: () => mockAgentInstructionsService,
|
|
|
|
|
accessService: () => mockAccessService,
|
|
|
|
|
approvalService: () => mockApprovalService,
|
|
|
|
|
companySkillService: () => mockCompanySkillService,
|
|
|
|
|
budgetService: () => mockBudgetService,
|
|
|
|
|
heartbeatService: () => mockHeartbeatService,
|
|
|
|
|
issueApprovalService: () => mockIssueApprovalService,
|
|
|
|
|
issueService: () => ({}),
|
|
|
|
|
logActivity: mockLogActivity,
|
|
|
|
|
secretService: () => mockSecretService,
|
|
|
|
|
syncInstructionsBundleConfigFromFilePath: mockSyncInstructionsBundleConfigFromFilePath,
|
|
|
|
|
workspaceOperationService: () => mockWorkspaceOperationService,
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
vi.mock("../adapters/index.js", () => ({
|
|
|
|
|
findServerAdapter: vi.fn(() => mockAdapter),
|
|
|
|
|
findActiveServerAdapter: vi.fn(() => mockAdapter),
|
|
|
|
|
listAdapterModels: vi.fn(),
|
|
|
|
|
detectAdapterModel: vi.fn(),
|
|
|
|
|
}));
|
|
|
|
|
|
2026-04-10 22:26:21 -05:00
|
|
|
function registerModuleMocks() {
|
2026-04-09 06:12:39 -05:00
|
|
|
vi.doMock("@paperclipai/shared/telemetry", () => ({
|
|
|
|
|
trackAgentCreated: mockTrackAgentCreated,
|
|
|
|
|
trackErrorHandlerCrash: vi.fn(),
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
vi.doMock("../telemetry.js", () => ({
|
|
|
|
|
getTelemetryClient: mockGetTelemetryClient,
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
vi.doMock("../services/index.js", () => ({
|
|
|
|
|
agentService: () => mockAgentService,
|
|
|
|
|
agentInstructionsService: () => mockAgentInstructionsService,
|
|
|
|
|
accessService: () => mockAccessService,
|
|
|
|
|
approvalService: () => mockApprovalService,
|
|
|
|
|
companySkillService: () => mockCompanySkillService,
|
|
|
|
|
budgetService: () => mockBudgetService,
|
|
|
|
|
heartbeatService: () => mockHeartbeatService,
|
|
|
|
|
issueApprovalService: () => mockIssueApprovalService,
|
|
|
|
|
issueService: () => ({}),
|
|
|
|
|
logActivity: mockLogActivity,
|
|
|
|
|
secretService: () => mockSecretService,
|
[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
|
|
|
syncInstructionsBundleConfigFromFilePath: mockSyncInstructionsBundleConfigFromFilePath,
|
2026-04-09 06:12:39 -05:00
|
|
|
workspaceOperationService: () => mockWorkspaceOperationService,
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
vi.doMock("../adapters/index.js", () => ({
|
|
|
|
|
findServerAdapter: vi.fn(() => mockAdapter),
|
|
|
|
|
findActiveServerAdapter: vi.fn(() => mockAdapter),
|
|
|
|
|
listAdapterModels: vi.fn(),
|
|
|
|
|
detectAdapterModel: vi.fn(),
|
|
|
|
|
}));
|
|
|
|
|
}
|
2026-03-17 11:47:50 -05:00
|
|
|
|
2026-03-18 13:18:48 -05:00
|
|
|
function createDb(requireBoardApprovalForNewAgents = false) {
|
|
|
|
|
return {
|
|
|
|
|
select: vi.fn(() => ({
|
|
|
|
|
from: vi.fn(() => ({
|
|
|
|
|
where: vi.fn(async () => [
|
|
|
|
|
{
|
|
|
|
|
id: "company-1",
|
|
|
|
|
requireBoardApprovalForNewAgents,
|
|
|
|
|
},
|
|
|
|
|
]),
|
|
|
|
|
})),
|
|
|
|
|
})),
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-09 06:12:39 -05:00
|
|
|
async function createApp(db: Record<string, unknown> = createDb()) {
|
|
|
|
|
const [{ agentRoutes }, { 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/agents.js")>("../routes/agents.js"),
|
|
|
|
|
vi.importActual<typeof import("../middleware/index.js")>("../middleware/index.js"),
|
2026-04-09 06:12:39 -05:00
|
|
|
]);
|
2026-03-17 11:47:50 -05:00
|
|
|
const app = express();
|
|
|
|
|
app.use(express.json());
|
|
|
|
|
app.use((req, _res, next) => {
|
|
|
|
|
(req as any).actor = {
|
|
|
|
|
type: "board",
|
|
|
|
|
userId: "local-board",
|
|
|
|
|
companyIds: ["company-1"],
|
|
|
|
|
source: "local_implicit",
|
|
|
|
|
isInstanceAdmin: false,
|
|
|
|
|
};
|
|
|
|
|
next();
|
|
|
|
|
});
|
2026-03-18 13:18:48 -05:00
|
|
|
app.use("/api", agentRoutes(db as any));
|
2026-03-17 11:47:50 -05:00
|
|
|
app.use(errorHandler);
|
|
|
|
|
return app;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function makeAgent(adapterType: string) {
|
|
|
|
|
return {
|
|
|
|
|
id: "11111111-1111-4111-8111-111111111111",
|
|
|
|
|
companyId: "company-1",
|
|
|
|
|
name: "Agent",
|
|
|
|
|
role: "engineer",
|
|
|
|
|
title: "Engineer",
|
|
|
|
|
status: "active",
|
|
|
|
|
reportsTo: null,
|
|
|
|
|
capabilities: null,
|
|
|
|
|
adapterType,
|
|
|
|
|
adapterConfig: {},
|
|
|
|
|
runtimeConfig: {},
|
|
|
|
|
permissions: null,
|
|
|
|
|
updatedAt: new Date(),
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
describe("agent skill 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/agents.js");
|
|
|
|
|
vi.doUnmock("../routes/authz.js");
|
|
|
|
|
vi.doUnmock("../middleware/index.js");
|
2026-04-10 22:26:21 -05:00
|
|
|
registerModuleMocks();
|
2026-04-02 09:11:49 -05:00
|
|
|
vi.resetAllMocks();
|
[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
|
|
|
mockSyncInstructionsBundleConfigFromFilePath.mockImplementation((_agent, config) => config);
|
2026-04-03 07:32:54 -05:00
|
|
|
mockGetTelemetryClient.mockReturnValue({ track: vi.fn() });
|
2026-03-17 11:47:50 -05:00
|
|
|
mockAgentService.resolveByReference.mockResolvedValue({
|
|
|
|
|
ambiguous: false,
|
|
|
|
|
agent: makeAgent("claude_local"),
|
|
|
|
|
});
|
|
|
|
|
mockSecretService.resolveAdapterConfigForRuntime.mockResolvedValue({ config: { env: {} } });
|
|
|
|
|
mockCompanySkillService.listRuntimeSkillEntries.mockResolvedValue([
|
|
|
|
|
{
|
|
|
|
|
key: "paperclipai/paperclip/paperclip",
|
|
|
|
|
runtimeName: "paperclip",
|
|
|
|
|
source: "/tmp/paperclip",
|
|
|
|
|
required: true,
|
|
|
|
|
requiredReason: "required",
|
|
|
|
|
},
|
|
|
|
|
]);
|
2026-03-18 13:18:48 -05:00
|
|
|
mockCompanySkillService.resolveRequestedSkillKeys.mockImplementation(
|
|
|
|
|
async (_companyId: string, requested: string[]) =>
|
|
|
|
|
requested.map((value) =>
|
|
|
|
|
value === "paperclip"
|
|
|
|
|
? "paperclipai/paperclip/paperclip"
|
|
|
|
|
: value,
|
|
|
|
|
),
|
|
|
|
|
);
|
2026-03-17 11:47:50 -05:00
|
|
|
mockAdapter.listSkills.mockResolvedValue({
|
|
|
|
|
adapterType: "claude_local",
|
|
|
|
|
supported: true,
|
|
|
|
|
mode: "ephemeral",
|
|
|
|
|
desiredSkills: ["paperclipai/paperclip/paperclip"],
|
|
|
|
|
entries: [],
|
|
|
|
|
warnings: [],
|
|
|
|
|
});
|
|
|
|
|
mockAdapter.syncSkills.mockResolvedValue({
|
|
|
|
|
adapterType: "claude_local",
|
|
|
|
|
supported: true,
|
|
|
|
|
mode: "ephemeral",
|
|
|
|
|
desiredSkills: ["paperclipai/paperclip/paperclip"],
|
|
|
|
|
entries: [],
|
|
|
|
|
warnings: [],
|
|
|
|
|
});
|
|
|
|
|
mockAgentService.update.mockImplementation(async (_id: string, patch: Record<string, unknown>) => ({
|
|
|
|
|
...makeAgent("claude_local"),
|
|
|
|
|
adapterConfig: patch.adapterConfig ?? {},
|
|
|
|
|
}));
|
2026-03-18 13:18:48 -05:00
|
|
|
mockAgentService.create.mockImplementation(async (_companyId: string, input: Record<string, unknown>) => ({
|
|
|
|
|
...makeAgent(String(input.adapterType ?? "claude_local")),
|
|
|
|
|
...input,
|
|
|
|
|
adapterConfig: input.adapterConfig ?? {},
|
|
|
|
|
runtimeConfig: input.runtimeConfig ?? {},
|
|
|
|
|
budgetMonthlyCents: Number(input.budgetMonthlyCents ?? 0),
|
|
|
|
|
permissions: null,
|
|
|
|
|
}));
|
2026-03-19 07:57:25 -05:00
|
|
|
mockApprovalService.create.mockImplementation(async (_companyId: string, input: Record<string, unknown>) => ({
|
2026-03-18 13:18:48 -05:00
|
|
|
id: "approval-1",
|
|
|
|
|
companyId: "company-1",
|
|
|
|
|
type: "hire_agent",
|
|
|
|
|
status: "pending",
|
|
|
|
|
payload: input.payload ?? {},
|
|
|
|
|
}));
|
2026-03-19 07:57:25 -05:00
|
|
|
mockAgentInstructionsService.materializeManagedBundle.mockImplementation(
|
|
|
|
|
async (agent: Record<string, unknown>, files: Record<string, string>) => ({
|
|
|
|
|
bundle: null,
|
|
|
|
|
adapterConfig: {
|
|
|
|
|
...((agent.adapterConfig as Record<string, unknown> | undefined) ?? {}),
|
|
|
|
|
instructionsBundleMode: "managed",
|
|
|
|
|
instructionsRootPath: `/tmp/${String(agent.id)}/instructions`,
|
|
|
|
|
instructionsEntryFile: "AGENTS.md",
|
|
|
|
|
instructionsFilePath: `/tmp/${String(agent.id)}/instructions/AGENTS.md`,
|
|
|
|
|
promptTemplate: files["AGENTS.md"] ?? "",
|
|
|
|
|
},
|
|
|
|
|
}),
|
|
|
|
|
);
|
2026-03-17 11:47:50 -05:00
|
|
|
mockLogActivity.mockResolvedValue(undefined);
|
2026-03-18 13:18:48 -05:00
|
|
|
mockAccessService.canUser.mockResolvedValue(true);
|
|
|
|
|
mockAccessService.hasPermission.mockResolvedValue(true);
|
2026-03-20 07:01:42 -05:00
|
|
|
mockAccessService.getMembership.mockResolvedValue(null);
|
|
|
|
|
mockAccessService.listPrincipalGrants.mockResolvedValue([]);
|
|
|
|
|
mockAccessService.ensureMembership.mockResolvedValue(undefined);
|
|
|
|
|
mockAccessService.setPrincipalPermission.mockResolvedValue(undefined);
|
2026-03-17 11:47:50 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("skips runtime materialization when listing Claude skills", async () => {
|
|
|
|
|
mockAgentService.getById.mockResolvedValue(makeAgent("claude_local"));
|
|
|
|
|
|
2026-04-09 06:12:39 -05:00
|
|
|
const res = await request(await createApp())
|
2026-03-17 11:47:50 -05:00
|
|
|
.get("/api/agents/11111111-1111-4111-8111-111111111111/skills?companyId=company-1");
|
|
|
|
|
|
|
|
|
|
expect(res.status, JSON.stringify(res.body)).toBe(200);
|
|
|
|
|
expect(mockAdapter.listSkills).toHaveBeenCalledWith(
|
|
|
|
|
expect.objectContaining({
|
|
|
|
|
adapterType: "claude_local",
|
|
|
|
|
config: expect.objectContaining({
|
|
|
|
|
paperclipRuntimeSkills: expect.any(Array),
|
|
|
|
|
}),
|
|
|
|
|
}),
|
|
|
|
|
);
|
2026-04-09 06:12:39 -05:00
|
|
|
}, 10_000);
|
2026-03-17 11:47:50 -05:00
|
|
|
|
2026-04-02 11:45:15 -05:00
|
|
|
it("skips runtime materialization when listing Codex skills", async () => {
|
2026-03-17 11:47:50 -05:00
|
|
|
mockAgentService.getById.mockResolvedValue(makeAgent("codex_local"));
|
|
|
|
|
mockAdapter.listSkills.mockResolvedValue({
|
|
|
|
|
adapterType: "codex_local",
|
|
|
|
|
supported: true,
|
2026-04-02 11:45:15 -05:00
|
|
|
mode: "ephemeral",
|
|
|
|
|
desiredSkills: ["paperclipai/paperclip/paperclip"],
|
|
|
|
|
entries: [],
|
|
|
|
|
warnings: [],
|
|
|
|
|
});
|
|
|
|
|
|
2026-04-09 06:12:39 -05:00
|
|
|
const res = await request(await createApp())
|
2026-04-02 11:45:15 -05:00
|
|
|
.get("/api/agents/11111111-1111-4111-8111-111111111111/skills?companyId=company-1");
|
|
|
|
|
|
|
|
|
|
expect(res.status, JSON.stringify(res.body)).toBe(200);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("keeps runtime materialization for persistent skill adapters", async () => {
|
|
|
|
|
mockAgentService.getById.mockResolvedValue(makeAgent("cursor"));
|
|
|
|
|
mockAdapter.listSkills.mockResolvedValue({
|
|
|
|
|
adapterType: "cursor",
|
|
|
|
|
supported: true,
|
2026-03-17 11:47:50 -05:00
|
|
|
mode: "persistent",
|
|
|
|
|
desiredSkills: ["paperclipai/paperclip/paperclip"],
|
|
|
|
|
entries: [],
|
|
|
|
|
warnings: [],
|
|
|
|
|
});
|
|
|
|
|
|
2026-04-09 06:12:39 -05:00
|
|
|
const res = await request(await createApp())
|
2026-03-17 11:47:50 -05:00
|
|
|
.get("/api/agents/11111111-1111-4111-8111-111111111111/skills?companyId=company-1");
|
|
|
|
|
|
|
|
|
|
expect(res.status, JSON.stringify(res.body)).toBe(200);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("skips runtime materialization when syncing Claude skills", async () => {
|
|
|
|
|
mockAgentService.getById.mockResolvedValue(makeAgent("claude_local"));
|
|
|
|
|
|
2026-04-09 06:12:39 -05:00
|
|
|
const res = await request(await createApp())
|
2026-03-17 11:47:50 -05:00
|
|
|
.post("/api/agents/11111111-1111-4111-8111-111111111111/skills/sync?companyId=company-1")
|
|
|
|
|
.send({ desiredSkills: ["paperclipai/paperclip/paperclip"] });
|
|
|
|
|
|
|
|
|
|
expect(res.status, JSON.stringify(res.body)).toBe(200);
|
|
|
|
|
expect(mockAdapter.syncSkills).toHaveBeenCalled();
|
|
|
|
|
});
|
2026-03-18 13:18:48 -05:00
|
|
|
|
|
|
|
|
it("canonicalizes desired skill references before syncing", async () => {
|
|
|
|
|
mockAgentService.getById.mockResolvedValue(makeAgent("claude_local"));
|
|
|
|
|
|
2026-04-09 06:12:39 -05:00
|
|
|
const res = await request(await createApp())
|
2026-03-18 13:18:48 -05:00
|
|
|
.post("/api/agents/11111111-1111-4111-8111-111111111111/skills/sync?companyId=company-1")
|
|
|
|
|
.send({ desiredSkills: ["paperclip"] });
|
|
|
|
|
|
|
|
|
|
expect(res.status, JSON.stringify(res.body)).toBe(200);
|
|
|
|
|
expect(mockAgentService.update).toHaveBeenCalledWith(
|
|
|
|
|
expect.any(String),
|
|
|
|
|
expect.objectContaining({
|
|
|
|
|
adapterConfig: expect.objectContaining({
|
|
|
|
|
paperclipSkillSync: expect.objectContaining({
|
|
|
|
|
desiredSkills: ["paperclipai/paperclip/paperclip"],
|
|
|
|
|
}),
|
|
|
|
|
}),
|
|
|
|
|
}),
|
|
|
|
|
expect.any(Object),
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("persists canonical desired skills when creating an agent directly", async () => {
|
2026-04-09 06:12:39 -05:00
|
|
|
const res = await request(await createApp())
|
2026-03-18 13:18:48 -05:00
|
|
|
.post("/api/companies/company-1/agents")
|
|
|
|
|
.send({
|
|
|
|
|
name: "QA Agent",
|
|
|
|
|
role: "engineer",
|
|
|
|
|
adapterType: "claude_local",
|
|
|
|
|
desiredSkills: ["paperclip"],
|
|
|
|
|
adapterConfig: {},
|
|
|
|
|
});
|
|
|
|
|
|
2026-04-09 06:12:39 -05:00
|
|
|
expect([200, 201], JSON.stringify(res.body)).toContain(res.status);
|
2026-03-18 13:18:48 -05:00
|
|
|
expect(mockAgentService.create).toHaveBeenCalledWith(
|
|
|
|
|
"company-1",
|
|
|
|
|
expect.objectContaining({
|
|
|
|
|
adapterConfig: expect.objectContaining({
|
|
|
|
|
paperclipSkillSync: expect.objectContaining({
|
|
|
|
|
desiredSkills: ["paperclipai/paperclip/paperclip"],
|
|
|
|
|
}),
|
|
|
|
|
}),
|
|
|
|
|
}),
|
|
|
|
|
);
|
[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
|
|
|
expect(mockTrackAgentCreated).toHaveBeenCalledWith(
|
|
|
|
|
expect.anything(),
|
|
|
|
|
expect.objectContaining({
|
|
|
|
|
agentId: "11111111-1111-4111-8111-111111111111",
|
|
|
|
|
agentRole: "engineer",
|
|
|
|
|
}),
|
|
|
|
|
);
|
2026-03-18 13:18:48 -05:00
|
|
|
});
|
|
|
|
|
|
2026-03-19 07:57:25 -05:00
|
|
|
it("materializes a managed AGENTS.md for directly created local agents", async () => {
|
2026-04-09 06:12:39 -05:00
|
|
|
const res = await request(await createApp())
|
2026-03-19 07:57:25 -05:00
|
|
|
.post("/api/companies/company-1/agents")
|
|
|
|
|
.send({
|
|
|
|
|
name: "QA Agent",
|
|
|
|
|
role: "engineer",
|
|
|
|
|
adapterType: "claude_local",
|
|
|
|
|
adapterConfig: {
|
|
|
|
|
promptTemplate: "You are QA.",
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
2026-04-10 22:26:21 -05:00
|
|
|
expect([200, 201], JSON.stringify(res.body)).toContain(res.status);
|
2026-03-19 07:57:25 -05:00
|
|
|
expect(mockAgentService.update).toHaveBeenCalledWith(
|
|
|
|
|
"11111111-1111-4111-8111-111111111111",
|
|
|
|
|
expect.objectContaining({
|
|
|
|
|
adapterConfig: expect.objectContaining({
|
|
|
|
|
instructionsBundleMode: "managed",
|
|
|
|
|
instructionsEntryFile: "AGENTS.md",
|
|
|
|
|
instructionsFilePath: "/tmp/11111111-1111-4111-8111-111111111111/instructions/AGENTS.md",
|
|
|
|
|
}),
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
expect(mockAgentService.update.mock.calls.at(-1)?.[1]).not.toMatchObject({
|
|
|
|
|
adapterConfig: expect.objectContaining({
|
|
|
|
|
promptTemplate: expect.anything(),
|
|
|
|
|
}),
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2026-03-20 07:38:05 -05:00
|
|
|
it("materializes the bundled CEO instruction set for default CEO agents", async () => {
|
2026-04-09 06:12:39 -05:00
|
|
|
const res = await request(await createApp())
|
2026-03-20 07:38:05 -05:00
|
|
|
.post("/api/companies/company-1/agents")
|
|
|
|
|
.send({
|
|
|
|
|
name: "CEO",
|
|
|
|
|
role: "ceo",
|
|
|
|
|
adapterType: "claude_local",
|
|
|
|
|
adapterConfig: {},
|
|
|
|
|
});
|
|
|
|
|
|
2026-04-10 22:26:21 -05:00
|
|
|
expect([200, 201], JSON.stringify(res.body)).toContain(res.status);
|
2026-03-20 07:38:05 -05:00
|
|
|
expect(mockAgentInstructionsService.materializeManagedBundle).toHaveBeenCalledWith(
|
|
|
|
|
expect.objectContaining({
|
|
|
|
|
id: "11111111-1111-4111-8111-111111111111",
|
|
|
|
|
role: "ceo",
|
|
|
|
|
adapterType: "claude_local",
|
|
|
|
|
}),
|
|
|
|
|
expect.objectContaining({
|
|
|
|
|
"AGENTS.md": expect.stringContaining("You are the CEO."),
|
|
|
|
|
"HEARTBEAT.md": expect.stringContaining("CEO Heartbeat Checklist"),
|
|
|
|
|
"SOUL.md": expect.stringContaining("CEO Persona"),
|
|
|
|
|
"TOOLS.md": expect.stringContaining("# Tools"),
|
|
|
|
|
}),
|
|
|
|
|
{ entryFile: "AGENTS.md", replaceExisting: false },
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
2026-03-20 07:42:36 -05:00
|
|
|
it("materializes the bundled default instruction set for non-CEO agents with no prompt template", async () => {
|
2026-04-09 06:12:39 -05:00
|
|
|
const res = await request(await createApp())
|
2026-03-20 07:42:36 -05:00
|
|
|
.post("/api/companies/company-1/agents")
|
|
|
|
|
.send({
|
|
|
|
|
name: "Engineer",
|
|
|
|
|
role: "engineer",
|
|
|
|
|
adapterType: "claude_local",
|
|
|
|
|
adapterConfig: {},
|
|
|
|
|
});
|
|
|
|
|
|
2026-04-10 22:26:21 -05:00
|
|
|
expect([200, 201], JSON.stringify(res.body)).toContain(res.status);
|
[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
|
|
|
await vi.waitFor(() => {
|
|
|
|
|
expect(mockAgentInstructionsService.materializeManagedBundle).toHaveBeenCalledWith(
|
|
|
|
|
expect.objectContaining({
|
|
|
|
|
id: "11111111-1111-4111-8111-111111111111",
|
|
|
|
|
role: "engineer",
|
|
|
|
|
adapterType: "claude_local",
|
|
|
|
|
}),
|
|
|
|
|
expect.objectContaining({
|
|
|
|
|
"AGENTS.md": expect.stringContaining("Keep the work moving until it's done."),
|
|
|
|
|
}),
|
|
|
|
|
{ entryFile: "AGENTS.md", replaceExisting: false },
|
|
|
|
|
);
|
|
|
|
|
});
|
2026-03-20 07:42:36 -05:00
|
|
|
});
|
|
|
|
|
|
2026-03-18 13:18:48 -05:00
|
|
|
it("includes canonical desired skills in hire approvals", async () => {
|
|
|
|
|
const db = createDb(true);
|
|
|
|
|
|
2026-04-09 06:12:39 -05:00
|
|
|
const res = await request(await createApp(db))
|
2026-03-18 13:18:48 -05:00
|
|
|
.post("/api/companies/company-1/agent-hires")
|
|
|
|
|
.send({
|
|
|
|
|
name: "QA Agent",
|
|
|
|
|
role: "engineer",
|
|
|
|
|
adapterType: "claude_local",
|
|
|
|
|
desiredSkills: ["paperclip"],
|
|
|
|
|
adapterConfig: {},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
expect(res.status, JSON.stringify(res.body)).toBe(201);
|
|
|
|
|
expect(mockApprovalService.create).toHaveBeenCalledWith(
|
|
|
|
|
"company-1",
|
|
|
|
|
expect.objectContaining({
|
|
|
|
|
payload: expect.objectContaining({
|
|
|
|
|
desiredSkills: ["paperclipai/paperclip/paperclip"],
|
|
|
|
|
requestedConfigurationSnapshot: expect.objectContaining({
|
|
|
|
|
desiredSkills: ["paperclipai/paperclip/paperclip"],
|
|
|
|
|
}),
|
|
|
|
|
}),
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
});
|
2026-03-19 07:57:25 -05:00
|
|
|
|
|
|
|
|
it("uses managed AGENTS config in hire approval payloads", async () => {
|
2026-04-09 06:12:39 -05:00
|
|
|
const res = await request(await createApp(createDb(true)))
|
2026-03-19 07:57:25 -05:00
|
|
|
.post("/api/companies/company-1/agent-hires")
|
|
|
|
|
.send({
|
|
|
|
|
name: "QA Agent",
|
|
|
|
|
role: "engineer",
|
|
|
|
|
adapterType: "claude_local",
|
|
|
|
|
adapterConfig: {
|
|
|
|
|
promptTemplate: "You are QA.",
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
expect(res.status, JSON.stringify(res.body)).toBe(201);
|
|
|
|
|
expect(mockApprovalService.create).toHaveBeenCalledWith(
|
|
|
|
|
"company-1",
|
|
|
|
|
expect.objectContaining({
|
|
|
|
|
payload: expect.objectContaining({
|
|
|
|
|
adapterConfig: expect.objectContaining({
|
|
|
|
|
instructionsBundleMode: "managed",
|
|
|
|
|
instructionsEntryFile: "AGENTS.md",
|
|
|
|
|
instructionsFilePath: "/tmp/11111111-1111-4111-8111-111111111111/instructions/AGENTS.md",
|
|
|
|
|
}),
|
|
|
|
|
}),
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
const approvalInput = mockApprovalService.create.mock.calls.at(-1)?.[1] as
|
|
|
|
|
| { payload?: { adapterConfig?: Record<string, unknown> } }
|
|
|
|
|
| undefined;
|
|
|
|
|
expect(approvalInput?.payload?.adapterConfig?.promptTemplate).toBeUndefined();
|
|
|
|
|
});
|
2026-03-17 11:47:50 -05:00
|
|
|
});
|