## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Native sessions keep a provider process and its work alive across control-plane operations. > - A hidden 15-minute turn deadline stopped work even when the agent timeout was zero. > - A one-hour runner lifetime and fixed connection lease added two more limits. > - Recovery also rejected goal commands because it reconstructed their startup summary with the wrong protocol version. > - This pull request removes implicit duration limits and renews authenticated leases in the harness. > - Healthy sessions can continue without model action or a user interface change. ## Linked Issues or Issue Description Refs #13092 and #12845. Related: #13163 covers sandbox recovery after app restarts; this change covers session duration and lease renewal. **What happened?** A native Codex session stopped after 15 minutes while a tool was still running. The agent had `timeoutSec: 0`. Recovery then rejected a `session.goal.get` startup command with `invalid provider startup ownership fence`. **Expected behavior** An unlimited session keeps working while its provider and authenticated controller remain healthy. Lease maintenance is transparent. Explicit timeouts, cancellation and revoked authority still take effect. **Steps to reproduce** Start a native session with `timeoutSec: 0` and run a tool beyond 15 minutes. Before this fix, the runtime cancels the turn. A recovery startup that uses a goal command also exposes the protocol-version mismatch. ## What Changed - Honor the agent turn timeout. Zero disables the timer. Long explicit durations use timer chunks to avoid Node timer overflow. - Default native runner lifetime to unlimited. Keep bounded startup, reconnect and control-operation deadlines. - Renew leases over the authenticated connection. Persist renewal before the reply. Validate identity, epoch and expiry. Handle duplicate requests and a lost reply on reconnect. - Freeze renewal during warm ownership transitions and terminal handling. - Validate persisted goal startup commands with protocol v2. - Add duration, renewal, ownership, recovery and real-process regression tests. Update runner protocol and recovery docs. - Add no UI components or controls. Renewal requires no model output or user action. ## Verification Current head: `348e369c35c5da8bb8be378f4b35dcf6f40882e7`. [CI run](https://github.com/paperclipai/paperclip/actions/runs/34649767113). - All 32 checks pass on this head. The two Storybook checks are skipped as expected. CI includes full build, typecheck, runner verification, browser suites, server tests and the canary package dry run. - Greptile reports 5/5 on this head. All review threads are resolved, and the security scan passes. - Passed `pnpm -r typecheck` and `pnpm build` locally. - Passed 219 native-runtime and controller tests, including fake-clock tests for three weeks of renewal and 30-day explicit timeouts. Six denial tests confirm that renewal cannot extend expired, revoked or mismatched authority. - Passed 337 executor, cancellation and restart-recovery tests, plus 278 Rust runner-core library tests. - Passed a real runner with a silent fake Codex provider across its original lease expiry. Runner PID, provider PID, thread and active turn stayed unchanged. Warm-attach recovery tests also pass. - Passed all 83 plugin-worker tests and 159 of 161 workspace-runtime tests locally. The two remaining assertions passed with a canonical macOS temporary directory, as did the changed runtime fixture. The full affected server shard passes in CI. - An unchanged GitHub callback-ordering test failed once in CI, passed locally in isolation, and passed its one test-shard retry. The final CI summary is successful. - The full local `pnpm test:run` sweep was interrupted after dependency setup failures and load-related timeouts. Identified failing suites passed in isolated reruns after the dependency repair. The complete test matrix passed remotely in CI. ## Risks - Deploy the controller and runner together to enable renewal. Older peers keep their existing bounded lease behavior. - Unlimited runtime permits long resource use until completion, explicit cancellation, configured timeout or loss of valid authority. - Lease renewal changes authenticated protocol handling. Regression tests cover stale, revoked and mismatched authority, lost replies and warm handoff behavior. - Simulated multi-week tests and a real lease-boundary test do not constitute a weeks-long production soak. ## Model Used OpenAI GPT-6 through Codex, with repository inspection, code execution and TypeScript/Rust test tools. The exact backend revision and context-window size are not exposed in 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 checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [x] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge --------- Co-authored-by: Paperclip <noreply@paperclip.ing>
14 KiB
PRP Compatibility and Versioning Policy
Authority
The JSON Schema files in protocol/schemas/ are the
language-neutral source of truth for the Replay and Local runner executable contract. The
generated TypeScript schema module is checked against those files before every
TypeScript typecheck. Rust consumes the same fixtures and must produce the same
golden parity summaries.
The reviewable architecture and trust boundaries are defined in
architecture.md; durable transport and recovery behavior
is defined in durable-recovery.md. Local runner reuses
the protocol contract for local live events. It adds package-local stdio and
stream envelopes, but it does not add durable transport, persistence, or
production control-plane behavior.
Version fields
| Field | Replay support | Compatibility rule |
|---|---|---|
protocolVersion |
1 |
Required. Negotiate the highest overlapping version; no overlap fails closed. |
fixtureVersion |
1 |
Required by the conformance corpus. Unknown values fail closed. |
event.schemaVersion |
1 |
Required on every event. Unknown values fail closed before reduction. |
capabilities.semanticTools.schemaVersion |
1 |
Optional advertisement. When present, an unknown required version fails closed. |
payload.semantic_tool.schemaVersion |
1 |
Optional on paired semantic tool input/result events. When present, an unknown required version fails closed. |
terminal.stopReason.schemaVersion |
1 |
Optional budget/cost receipt. When present, an unknown required version fails closed. |
Typed schema discriminators |
*.v1 |
Required. Unknown required schema identities fail JSON Schema validation. |
Wire protocol versions and fixture-corpus versions are independent. A fixture format can evolve without changing PRP, and a future PRP version can be represented only after the consumer advertises support for it.
Forward compatibility
- Unknown object properties are accepted and preserved by validation. Reducers ignore fields they do not understand until a later schema version gives those fields defined behavior.
- Unknown required versions, schema discriminators, enum values, and required fields fail closed. A consumer must never guess at their semantics.
- Scripted fixtures bind every event to the fixture run/session, require contiguous controller command order, exactly one unique proposed result, and exactly one unique terminal event.
- The top-level fixture result must equal the
run.result.proposedpayload after canonical key ordering. RepeatedsourceEventIddeliveries must be byte-equivalent after the same normalization.
The forward-compatibility fixture proves that optional fields survive validation without changing the v1 snapshot. The unsupported-version fixture proves that a required v2 protocol cannot be replayed by this consumer.
Within-turn checklist snapshots
plan.updated / paperclip.plan.updated.v1 is a complete, ordered snapshot of
the provider's checklist for one active turn. It is not a Paperclip Plan
document and must never be inferred from assistant prose, Codex proposed-plan
items, or generic TodoWrite output. Every replacement uses the provider turn ID
as planId; PRP sourceSeq, not an optional provider revision, determines
snapshot order. An empty step array clears the checklist, and complete is true
only when a non-empty snapshot contains only completed steps. The legacy
document-coupling fields are always syncStatus: "not_applicable" and
documentRevision: null.
| Qualified adapter profile | Checklist support |
|---|---|
| Direct Codex App Server | turn/plan/updated |
| ACPX Codex | Structured ACP plan entries |
| ACPX Claude | Structured ACP plan entries |
| ACPX Pi | Unavailable; no production-qualified profile is exposed |
| OpenCode | Unsupported until it exposes a structured plan event |
Codex turn/diff/updated is normalized separately as the latest same-turn
workspace.change.updated snapshot. Together these two independent event
families can drive a turn-status UI without changing the public PRP family or
adding a control-plane endpoint.
Provider-neutral semantic receipts
capabilities.semanticToolsadvertises stable operation IDs, availability, required claims, and redaction disposition without naming a provider API.mcp_app.tool_inputandmcp_app.tool_resultmay carry pairedsemantic_toolenvelopes. Correlation IDs must match the containing event; operation ID and idempotency key must match across the pair.- Content is represented by a canonical SHA-256 digest plus allowlisted typed references. Raw credentials, provider payloads, and hidden identifiers do not belong on the wire.
- Result receipts distinguish success, denial, conflict, exact duplicate, unavailable, and failure. They can name the authorization boundary, safe revision, artifact/work-product refs, immutable governed targets, and bounded wake/monitor causality.
terminal.stopReasonrecords budget/cost kind, stable code, retryability, limit class, safe aggregate, and decision receipt.
These fields are trace evidence only. The v1 reducer ignores semantic_tool
payloads, so adding or extending the optional envelope has no projection
effect. Eval trace_completeness treats PRP wire receipts as authoritative when
present and retains the pre-existing scalar fallback for live evidence that has
not yet emitted them.
Provider-neutral structured input
Harness-initiated forms cross PRP as paperclip.runtime_request.v2 with
requestKind: "runtime", type: "input", and an embedded
paperclip.question_set.v1. A submission is always
{ "action": "submit", "response": paperclip.question_response.v1 }.
Codex answer objects, OpenCode answer arrays, and ACP typed content exist only
inside their adapters; origin may retain the provider method and adapter name
for diagnostics but never provider response data.
Question and option order is significant, while answers are keyed by stable
question IDs and selections reference stable option IDs. The canonical modes
are text, single_select, and multi_select. Text validation is repeated at
the untrusted server edge and again against the persisted question set before a
provider receives the translated response.
Every harness adapter must add a
paperclip.question_adapter_fixture.v1 fixture proving its native request
normalizes to the canonical shape and its canonical response can be translated
back. The shared fixture format deliberately contains both native and canonical
objects so adding a provider does not change PRP or the UI contract.
V1 runtime requests and their legacy resolutions remain accepted during the
migration. A request that contains no structured form stays on the legacy path;
once a provider supplies a form, malformed or unsupported fields fail closed
instead of silently degrading. ACPX sidecars advertise only form elicitation
and use sidecar protocol v2 runtime.input_requested / input.resolve frames.
The live lifecycle pauses and resumes the same provider turn. If the provider
process is lost first, Paperclip emits one non-replayable
runtime_request.expired fact and materializes an idempotent durable
ask_user_questions interaction using the identical question set. Explicit
cancellation and already-resolved requests never create that fallback.
Native execution permission compatibility
paperclip.native-execution-input.v4 pins the effective harness permission
policy in the closed provider configuration: approvalPolicy for Codex and
permissionMode for OpenCode and ACPX. The pinned value participates in
provider-session identity, so an incompatible idle or recovered session is
replaced on the next execution. An active turn is never mutated in place.
Persisted v1-v3 inputs remain replayable. Missing Codex and OpenCode policy
fields retain their historical effective behavior. Legacy ACPX
permissionPolicy: "interactive" is interpreted as approve-reads, while a
new v4 ACPX execution defaults to approve-all at the server boundary.
See Adding a harness for the permission catalog, isolation rules, and provider conformance requirements.
Seven conformance fixtures cover artifact success, redacted denial without fallback, stale conflict plus duplicate retry, governed target and continuation causality, budget/cost stop, unknown optional fields, and rejection of an unknown required version. The six accepted fixtures have shared TypeScript and Rust golden parity summaries.
Replay semantics
- Events are applied in fixture order and ordered independently by
(sourceKind, sourceInstanceId, sourceSeq). - A repeated source event ID has no second projection effect.
- A forward source-sequence gap is recorded explicitly; the reducer never invents a missing event.
- An event at or behind the committed source cursor is ignored and recorded as out of order.
- Replaying an already-applied batch leaves the snapshot unchanged.
The CLI and browser import the same replayReplayFixtureText function, so
validation, compatibility errors, and final snapshots cannot drift between the
two surfaces.
Local envelope rules
- Mock-core commands use
paperclip.prp.command.v1over stdin JSONL. - Runner output uses
paperclip.runner.stream.v1over stdout JSONL. - Fake-harness commands use
paperclip.fake_harness.command.v1. - Fake-harness output uses
paperclip.fake_harness.message.v1. - An equivalent repeated
commandIdreturns a duplicate receipt and has no second driver effect. Reuse with different data is rejected. - A new command must use the next contiguous
controllerSeq. - Harness logs are bounded diagnostic data. They are not canonical PRP events.
run.result.proposed,harness.exited, andrun.terminalare separate facts and appear in that order when a semantic result exists.- The live browser rejects an event with an invalid schema, run ID, or session ID before it reaches the reducer.
These envelopes are local Local runner implementation contracts.
Durable wire rules
- The runner opens loopback
ws://or hostname-verifiedwss://, or accepts a preview-proxy connection on its fixed listener, and completes the PRP v1 authenticated handshake before any command result or event. - A one-use bootstrap bearer capability returns a short-lived connection lease
in
welcome. Later connections use that lease. Neither raw capability is durable state. welcome.payload.connectionLeaseRenewalVersion: 1opts into authenticatedlease_renew/lease_renewedcontrol frames. Renewal extends the persisted expiry on the same live authority without restarting provider work. Identity, protocol, and revocation epoch remain fixed; expired or revoked leases cannot renew. See durable recovery for retry and warm-handoff rules. Peers lacking this capability retain their original lease expiry.hello.resumereports the last processed controller sequence, next source sequence, cumulative ACK cursor, and current unacknowledged range.welcomeselects the one overlapping protocol version, returns the core's cumulative ACK cursor, and carries at most one durable pending command.- An event is durable before send. Event IDs and source sequences stay stable across replay and process restart.
- An ACK is cumulative. The runner rejects a cursor behind its durable ACK or beyond its produced source cursor.
- An equal repeated command ID and canonical digest returns its stored result. Reuse with different bytes fails closed and cannot repeat an effect.
- Frames are bounded at 1 MiB and upgrade headers at 16 KiB. Unknown or invalid required protocol data fails closed; malformed JSON is a bounded diagnostic.
Runnerd build-metadata contract v2 advertises the exact transport inventory:
dial_ws_loopback, dial_wss, and listen_ws. Plaintext dial destinations
must resolve entirely to loopback. Public dial targets require TLS trust and
hostname validation; a private CA bundle augments the platform roots and must
be a bounded, private, regular file. Listener mode is fixed to port 43127 and a
single run-bound path. All modes retain the same message/frame bounds and PRP
authentication.
These are package-local Durable recovery and transport rules. Control-plane admission and deployment policy remain separately reviewed work.
Change policy
- Change JSON Schema first.
- Regenerate the TypeScript schema module.
- Add or revise a shared fixture and its golden snapshot/summary.
- Prove TypeScript and Rust parity.
- Update this policy and the normative spike specification when behavior changes.
Breaking changes require a new required version. Additive optional fields may remain in v1 only when old consumers can safely ignore them.
Package-level compatibility
PRP is one independently versioned component of the runner bundle. Catalog,
runner-client, control-plane-adapter, testkit, and eval-corpus compatibility is
declared by PAPERCLIP_RUNNER_COMPATIBILITY and checked before execution by
assertPaperclipRunnerCompatibility. A mismatch fails with
paperclip_runner_incompatible and stable per-issue codes; a provider-specific
tool error is not a compatibility negotiation mechanism.
See ADR 0001 for the component rules and clean-consumer packaging gate.
Evals integration negotiation
The packed ./evals entry point adds a stricter execution preflight for the
App/Evals join. assertPaperclipRunnerEvalCompatibility requires simultaneous
agreement on package semver, runnerd build metadata, a common PRP version,
semantic catalog version and SHA-256 digest, harness-driver contract and
required capabilities, and the native-execution version. It reports
paperclip_runner_eval_incompatible with expected/received values for every
mismatch and must run before launching a provider.
runnerd itself reports paperclip-runner/runnerd-build-metadata/v1 from
--build-metadata. The consumer passes its path and expected content digest to
resolvePaperclipRunnerdArtifact; implicit PATH or source-tree discovery is
not part of the contract. Native attempt output is
paperclip-runner/native-execution/v1, whose parser accepts unknown additive
fields but rejects unknown required versions and inconsistent terminal,
semantic-denial, usage, or transcript facts. Full fields and the deterministic
gate are exercised by the package-local deterministic conformance suite.