fix: preserve onboarding completion and child file handoff

Keep validated completed-onboarding callbacks alive until execution. Send file-producing first work through the child task execution without expanding file authority.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
DottaandPaperclip committed 2026-10-13 18:23:30 -05:00
1 parent ea6c8eb5e1
commit 9546f41e96
11 files changed
+272 -7

No files matched your search

@@ -1,5 +1,76 @@
# Runner defaults: staged delivery
## Current qualification and repair checkpoint — 2026-10-13
Canonical branch: `codex/codex-runner-default`. Delivery:
[#15683](https://github.com/paperclipai/paperclip/pull/15683).
The published baseline `ea6c8eb5e16d61111968f633a66748b397b64a3e` has
53 successful hosted checks, two conditional Storybook skips, required verify
and E2E passes, fresh 5/5 review and 30 resolved threads. Its
[package qualification](https://github.com/paperclipai/paperclip/actions/runs/38478290686)
passes all four native producers and clean Apple Silicon, Intel Mac and Linux
ARM64 consumers. All 18 package source manifests and binary hashes match; no
Codex payload is bundled. The isolated Apple Silicon install and zero-turn native
startup pass, and fresh installed JavaScript applies all 342 migrations through
0343 with confirmed owned cleanup. These are literal baseline results, not proof
of the new repairs. Linux remains GNU libc 2.39 or newer on x64/AArch64; Windows,
Alpine and 32-bit ARM stay deferred. No warm-cache speedup or paid ARM task is
claimed. Docker, Cargo and native builds remain remote.
The [single baseline managed attempt](https://github.com/paperclipai/paperclip/actions/runs/38478333712)
fails completion reporting and the physical child-file assertion; its
[existing report](https://d1p6rlowie26tp.cloudfront.net/runner-e2e/campaigns/gha-38478333712-1/index.html)
remains red. Two runs execute provider turns. A third callback is falsely marked
successful during startup, before any provider turn, because its onboarding
parent is already Done. One unstarted child wake is cancelled. Recovery now
reuses the existing completed-onboarding handoff validator before applying the
issue-terminal backstop. Company, parent origin/status, assignee, completed child
and remaining children must match. Process-death and ownership checks remain.
Three reproduced baseline failures become 103 passing PostgreSQL controls across
the existing recovery suites, with canonical server typecheck passing. Owned
test clusters stop and release their slot. The native file tool correctly remains
bound to its current task: the original run saved a child document but attached
the file to the parent. First-task instructions now send file-producing work
through the child's own execution, dependency and block handoff, then verify and
link the child's result. Document-only and plan-only paths retain their scope.
Two reproduced instruction-contract failures become 15 passing existing asset
and greeting controls; these static checks do not prove model compliance.
All seven baseline managed lease rows are released or expired with successful
cleanup records, and prior company environment settings are restored. A separate
owned-server supervisor reports incomplete descendant cleanup after server exit;
its missing nested cause remains unresolved. Lease records do not prove physical
deletion or settle unknown charges. Existing cost and cleanup holds remain.
Revised-source live acceptance must still check actual turn events, the child's
downloaded physical file, source-correlated completion, follow-up and continuity.
Do not rerun the known failing baseline or weaken its assertions.
The normal staging preparation and exact baseline Core image build complete, but
the deployment check rejects `fleet_campaign_staging_requires_master`. Current
Cloud policy admits only actual master source ancestry, including preview DB
artifacts; a pinned, owned single target has no exception. No staging campaign
starts and no serving-candidate claim is made. A human sequencing decision is
pending: complete Mac and signed managed acceptance before a normal squash,
then qualify the actual merged revision on the owned staging stack, or use a
separate branch-friendly test environment before merge. Do not bypass this gate
or change merge method to preserve preview ancestry. The preview Core image has
verified content identity but no verified signature; the managed image signature
is separately verified. Actual private Cloud composition and fresh warm/cold
signup remain required production-readiness evidence after merge.
Next action: independent matching-source review, affected map checks and publish
the two scoped repairs in one source commit. Freeze that head, require fresh full
CI and 5/5 review, then repeat the existing package/install and single managed
journeys on admitted artifacts. Upgrade the idle local app with full saved
configuration, account and recorded-run-profile comparisons; preserve its data.
Use a fresh ordinary installed instance for automatic first-agent task/follow-up.
The new $100 QA ceiling permits bounded messages with paid concurrency one and
180-second runs; prior unknown-charge and cleanup holds remain separate.
Existing runners never migrate. Normal protected merge is authorized once
applicable gates and the sequencing decision are satisfied. No production or
provisioning-default promotion, local heavy build, new timer or archive is
authorized. Earlier checkpoints below retain their historical source attribution.
## Current Codex merge checkpoint — 2026-10-13
Current published `1173a859baa78af1d382058aa89c25920da25c3d` passes
+11
View File
@@ -172,6 +172,17 @@ The Codex first-task fixture's operator cost guard uses the existing board
agent-configuration PATCH before admitting work. This is not evidence of agent
permission to update its runtime; the listed agent-context checks remain not-run.
Scoped source review: 2026-10-13, the first-task asset correction against
`ea6c8eb5e16d61111968f633a66748b397b64a3e`. The existing
[first-task instructions](../../server/src/onboarding-assets/first-task/skills/first-task/SKILL.md)
send file-producing work through the child's own execution and existing
dependency/block controls. Native `register_deliverable` retains its current-task
binding; this adds no cross-task file-registration authority or permission.
Document-only work may use the existing child-document API inline, and plan-only
approval does not authorize implementation. The existing asset tests check
wording only. The literal baseline live attempt failed child-file delivery and
completion reporting; revised live authorization and execution remain `not-run`.
## `resume`
Review: `baseline`.
+11
View File
@@ -62,6 +62,17 @@ Gaps: Eligible resolutions use native `call_api`. The route retains owner and
management authority, active-run/source-trust checks, board-only outcomes and
reconciliation controls.
Scoped source review: 2026-10-13, recovery correction against
`ea6c8eb5e16d61111968f633a66748b397b64a3e`. The
[recovery service](../../server/src/services/recovery/service.ts) reuses the
existing completed-onboarding handoff validator. It checks the source company,
onboarding origin, Done parent, assignee and Done child, with no unfinished
siblings, before exempting the report from the issue-terminal backstop. Other
terminal work and process-death/controller ownership checks remain enforced.
This internal wake handling adds no recovery-resolution or cross-company agent
authority. Real PostgreSQL regressions cover allowed and rejected bindings;
revised live agent authorization and callback delivery remain `not-run`.
## `source-action`
Review: `baseline`.
+10
View File
@@ -180,6 +180,16 @@ for active/recovered runs. Explicit runner changes use revisions and session
invalidation. Verify saved configuration, current versus historical run identity,
restart and follow-up without granting session-reset authority to an agent.
Scoped source review: 2026-10-13, the recovery correction against
`ea6c8eb5e16d61111968f633a66748b397b64a3e` reuses
[completed onboarding handoff validation](../../server/src/services/chat-completion-delivery.ts)
before applying the issue-terminal backstop. The company, parent origin/status,
assignee, completed child and remaining children must match. Only that backstop
is suppressed for the validated report; process-death and controller/native
ownership checks still apply. No agent gains session or recovery control.
PostgreSQL regressions cover valid native/Legacy callbacks and rejected bindings;
revised live execution and actor authorization remain `not-run`.
Scoped Evidence: `source-only` — the
[native transport](../../packages/paperclip-runner/src/live/runnerd-codex-transport.ts)
joins owned startup before certifying cleanup. Rejected duplicates cannot replace
+15 -2
View File
@@ -95,8 +95,21 @@ continuity. Setup evidence must correlate both lease IDs with the same company,
environment and provider; missing responses or unmatched rows keep cost coverage
unknown. Run this cell only on an eligible target with separately authorized
provider, runtime and cleanup reservations. Its source and mock controls are
prepared; live execution remains unverified. Local cases and automatic selection
remain unchanged.
prepared. The literal `ea6c8eb5e16d61111968f633a66748b397b64a3e` live attempt
failed: the child document existed, but the physical file was attached to the
parent, and recovery stopped the completion callback before a provider turn.
The failed report remains evidence; the revised source still needs live proof.
Local cases and automatic selection remain unchanged.
For accepted file-producing work, verify exactly one self-assigned child with a
self-contained description. The onboarding run must yield through the existing
dependency/block disposition so the child's own execution can publish its file.
Native file registration remains bound to the executing task. On completion,
the original conversation must receive the actual child and downloadable file
links. Document-only child work may finish inline; a plan-only request must not
start implementation. Existing first-task asset controls check the instructions,
not model compliance. Inspect the child's execution, document, downloaded file
and source-correlated completion reply in the real journey.
Leave and resume during harness/runner setup. Confirm the draft retains the
explicit choice and compatible account bindings, old native Codex setup links
+11
View File
@@ -102,6 +102,17 @@ cleanup. The [route regressions](../../server/src/__tests__/issue-recovery-actio
and [heartbeat regression](../../server/src/__tests__/heartbeat-process-recovery.test.ts)
cover this sequence without a live operator recovery claim.
An intentionally Done onboarding parent can still need its validated
child-completion report. Recovery must not mark that callback successful before
execution solely because the parent is Done. The existing
[stale-lock sweep suite](../../server/src/__tests__/recovery-stale-issue-lock-sweep.test.ts)
covers delayed native/Legacy startup, invalid parent/child/company/assignee
bindings and a dead owner. Process-death and ownership backstops remain active.
Repeat the real onboarding journey and correlate callback turn events with its
reply and downloadable child file; status alone does not prove delivery. The
literal `ea6c8eb5e16d61111968f633a66748b397b64a3e` live failure is retained,
and the revised behavior still needs live qualification.
### `run-detail`
Automated: [run workspace recovery](../../ui/src/components/RunWorkspaceRecoverySurface.test.tsx)
+8
View File
@@ -98,6 +98,14 @@ retain their recorded execution configuration; do not infer their runner from a
later edit to the agent. Account/harness branding and execution identity are
different observations, both required in the evidence.
For an onboarding child-completion callback, verify actual session/turn events
and the source-correlated reply. A `succeeded` row alone is insufficient: the
literal `ea6c8eb5e16d61111968f633a66748b397b64a3e` managed attempt was marked
successful during startup without a provider turn. The recovery correction
preserves the existing validated Done-parent handoff; process-death and ownership
checks remain active. Its PostgreSQL controls are separate from the required
revised-source live onboarding and follow-up proof.
## Gotchas
- Model accounts are managed in Apps and inline agent account controls.
@@ -249,6 +249,95 @@ describeEmbeddedPostgres("recovery sweepStaleIssueLocks", () => {
).resolves.toBe("running");
});
async function seedCompletedOnboardingReport(options: {
runtimeMode?: "native" | "legacy";
variant?: "ordinary" | "cancelled" | "wrong_child" | "wrong_reason" | "wrong_agent" | "unfinished_child" | "foreign_child";
} = {}) {
const { companyId, agentId, runningRunId } = await seed();
const issueId = randomUUID();
const childIssueId = randomUUID();
const variant = options.variant;
let childCompanyId = companyId;
if (variant === "foreign_child") {
childCompanyId = randomUUID();
await db.insert(companies).values({
id: childCompanyId,
name: "Other company",
issuePrefix: `T${childCompanyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`,
});
}
await db.insert(issues).values({
id: issueId,
companyId,
title: "Completed onboarding awaiting its child result",
originKind: variant === "ordinary" ? "manual" : "onboarding_first_task",
status: variant === "cancelled" ? "cancelled" : "done",
assigneeAgentId: variant === "wrong_agent" ? null : agentId,
checkoutRunId: runningRunId,
executionRunId: runningRunId,
executionLockedAt: new Date(),
});
await db.insert(issues).values({
id: childIssueId,
companyId: childCompanyId,
title: "Accepted child output",
status: variant === "unfinished_child" ? "in_progress" : "done",
parentId: variant === "foreign_child" ? null : issueId,
});
await db.update(heartbeatRuns).set({
runtimeMode: options.runtimeMode ?? "native",
nativeIssueId: options.runtimeMode === "legacy" ? null : issueId,
processPid: 2_000_000_000,
contextSnapshot: {
issueId,
wakeReason: variant === "wrong_reason" ? "issue_commented" : "issue_children_completed",
completedChildIssueId: variant === "wrong_child" ? randomUUID() : childIssueId,
onboardingCompletion: true,
},
}).where(eq(heartbeatRuns.id, runningRunId));
return { companyId, agentId, issueId, childIssueId, runningRunId };
}
it.each(["native", "legacy"] as const)("preserves a live %s completed-onboarding reporting turn during delayed startup", async runtimeMode => {
const { issueId, runningRunId } = await seedCompletedOnboardingReport({ runtimeMode });
const result = await recoveryService(db, {
enqueueWakeup: vi.fn(),
liveRunExecutions: new Set([runningRunId]),
}).sweepStaleIssueLocks();
expect(result).toEqual({ cleared: 0, issueIds: [], terminalizedRunIds: [] });
expect((await db.select().from(heartbeatRuns).where(eq(heartbeatRuns.id, runningRunId)))[0]?.status).toBe("running");
expect((await db.select().from(issues).where(eq(issues.id, issueId)))[0]).toMatchObject({
status: "done", checkoutRunId: runningRunId, executionRunId: runningRunId,
});
expect(mockTelemetryClient.track).not.toHaveBeenCalled();
});
it.each(["ordinary", "cancelled", "wrong_child", "wrong_reason", "wrong_agent", "unfinished_child", "foreign_child"] as const)("does not exempt an invalid completed-onboarding reporting turn (%s)", async variant => {
const { issueId, runningRunId } = await seedCompletedOnboardingReport({ variant });
const result = await recoveryService(db, {
enqueueWakeup: vi.fn(),
liveRunExecutions: new Set([runningRunId]),
}).sweepStaleIssueLocks();
expect(result.terminalizedRunIds).toEqual([runningRunId]);
expect(result.cleared).toBe(1);
expect((await db.select().from(heartbeatRuns).where(eq(heartbeatRuns.id, runningRunId)))[0]?.status).toBe(variant === "cancelled" ? "cancelled" : "succeeded");
expect((await db.select().from(issues).where(eq(issues.id, issueId)))[0]).toMatchObject({ checkoutRunId: null, executionRunId: null });
});
it("still interrupts a completed-onboarding reporting turn after its process and execution owner are gone", async () => {
const { issueId, runningRunId } = await seedCompletedOnboardingReport();
const result = await recoveryService(db, { enqueueWakeup: vi.fn() }).sweepStaleIssueLocks();
expect(result.terminalizedRunIds).toEqual([runningRunId]);
expect(result.cleared).toBe(1);
expect((await db.select().from(heartbeatRuns).where(eq(heartbeatRuns.id, runningRunId)))[0]).toMatchObject({
status: "interrupted", errorCode: "orphaned_running_run",
});
expect((await db.select().from(issues).where(eq(issues.id, issueId)))[0]).toMatchObject({ checkoutRunId: null, executionRunId: null });
});
it("does not clear when checkoutRunId is terminal but executionRunId is still running", async () => {
const { companyId, agentId, failedRunId, runningRunId } = await seed();
const issueId = randomUUID();
@@ -48,5 +48,8 @@ Work in this order.
4. Carry out the accepted scope.
- For a plan-only request, retain the accepted plan on this task. Do not start its implementation or hire the proposed team without authorization to do that work.
- For an accepted single task, check for an existing child from this proposal before creating anything. Create exactly one child linked to this onboarding task, assign it to yourself, and execute it. On later wakes, continue that same child instead of creating another.
- Save the finished output as a document on the child task and mark that child done. Link it from the onboarding conversation. Completing the onboarding parent in place, or saving the output only on the parent, does not fulfill the accepted child-task proposal.
- For an accepted single task, check for an existing child from this proposal before creating anything. Create exactly one child linked to this onboarding task and assign it to yourself. On later wakes, continue that same child instead of creating another.
- If the accepted child work requires a file deliverable, include the approved scope, document requirements, and requested filenames in a self-contained child description. Delegate the work to the child's own Paperclip execution, even when the child is assigned to yourself. That execution must save the document and publish the requested file on the child before marking it done. Do not create or register that file from the onboarding run, or mark the child done before its execution delivers the file. Native `register_deliverable` is bound to its current task.
- While waiting for that file-producing child, preserve existing blocker IDs and add the child as a dependency. Native runners use `set_dependencies`, then `paperclip_block` with the child agent as owner and child completion as the unblock action; legacy runners use the normal issue API with `blockedByIssueIds` and a blocked disposition. End the turn so the child can execute. Do not poll for its result while holding the onboarding run.
- When child completion resumes the onboarding task, verify the saved child document and retrievable file, then reply with the actual child task and download links. Reuse the recorded result instead of producing another file on the parent or creating another child.
- For document-only child work, you may execute it directly. Save the finished output as a document on the child task and mark that child done. Link it from the onboarding conversation. Completing the onboarding parent in place, or saving the output only on the parent, does not fulfill the accepted child-task proposal.
@@ -93,6 +93,35 @@ describe("first-task proposal mode policy", () => {
expect(skill).toContain("`request_checkbox_confirmation` targeting its saved revision");
expect(skill).toContain("explicit plan requests regardless of the single-task proposal mode");
});
it("hands accepted file-producing child work to its own execution before reporting results", async () => {
const skill = await readFile(new URL("../onboarding-assets/first-task/skills/first-task/SKILL.md", import.meta.url), "utf8");
expect(skill).toContain("If the accepted child work requires a file deliverable");
expect(skill).toContain("self-contained child description");
expect(skill).toContain("requested filenames");
expect(skill).toContain("child's own Paperclip execution");
expect(skill).toContain("even when the child is assigned to yourself");
expect(skill).toContain("Do not create or register that file from the onboarding run");
expect(skill).toContain("`register_deliverable` is bound to its current task");
expect(skill).toContain("preserve existing blocker IDs");
expect(skill).toContain("`set_dependencies`");
expect(skill).toContain("`paperclip_block`");
expect(skill).toContain("`blockedByIssueIds`");
expect(skill).toContain("End the turn so the child can execute");
expect(skill).toContain("Do not poll for its result");
expect(skill).toContain("verify the saved child document and retrievable file");
expect(skill).toContain("actual child task and download links");
});
it("keeps plan-only authorization and document-only child execution distinct from file handoff", async () => {
const skill = await readFile(new URL("../onboarding-assets/first-task/skills/first-task/SKILL.md", import.meta.url), "utf8");
expect(skill).toContain("For a plan-only request, retain the accepted plan on this task");
expect(skill).toContain("Do not start its implementation or hire the proposed team without authorization");
expect(skill).toContain("Create exactly one child linked to this onboarding task");
expect(skill).toContain("For document-only child work, you may execute it directly");
expect(skill).toContain("Save the finished output as a document on the child task and mark that child done");
expect(skill).toContain("On later wakes, continue that same child instead of creating another");
});
});
describe("chief-of-staff persona", () => {
+12 -3
View File
@@ -13,6 +13,7 @@ import {
LEGACY_DISPOSITION_REPAIR_INSTRUCTION, type LegacyDispositionEpisode,
} from "./legacy-continuation.js";
import { hasLiveLegacyController } from "../legacy-controller-lease.js";
import { isCompletedOnboardingHandoffWake } from "../chat-completion-delivery.js";
import { instanceSettingsService } from "../instance-settings.js";
import { isWaitingConversation, settleConversationTurn, deliverConversationComments } from "../agent-conversations.js";
import {
@@ -5938,13 +5939,21 @@ export function recoveryService(
const isTerminalSessionGoalControl =
runContext.resumeIntent === true &&
readNonEmptyString(runContext.goalControlRequestId) !== null;
const issueId = issueIdFromRunContext(run.contextSnapshot);
const preservesTerminalIssueReport = isTerminalSessionGoalControl ||
(issueId !== null && await isCompletedOnboardingHandoffWake(db, {
companyId: run.companyId,
issueId,
agentId: run.agentId,
reason: readNonEmptyString(runContext.wakeReason),
contextSnapshot: runContext,
}));
let issueTerminalStatus: "succeeded" | "cancelled" | null =
isTerminalSessionGoalControl
preservesTerminalIssueReport
? null
: (options?.referencingIssueTerminalStatus ?? null);
const issueId = issueIdFromRunContext(run.contextSnapshot);
if (
!isTerminalSessionGoalControl &&
!preservesTerminalIssueReport &&
!issueTerminalStatus &&
!options?.runReferencedByActiveIssue &&
issueId