Commit Graph
7 Commits
Author SHA1 Message Date
DottaandPaperclip eadc560712 fix(evals): retain usage during bounded gateway shutdown (#17371)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - Product E2E tests use a local gateway to record model usage and
reserve costs.
> - Test cleanup can disconnect a background request before its provider
sends final usage.
> - Immediate abort then leaves the request cost unknown and its full
reservation held.
> - This pull request lets an admitted response finish within a short
drain period.
> - The benefit is better accounting without a new request or a retry.

## Linked Issues or Issue Description

Refs #17365 and #17354.

**What happened?**

Two hosted cases passed, but cleanup canceled background requests before
the gateway received their usage. Both requests kept their full holds. A
local HTTP regression reproduces this loss with OpenAI and Anthropic
responses.

**Expected behavior**

Retain final usage when an already-dispatched response finishes within a
bounded cleanup period. Keep the client outcome canceled. Preserve the
hold when final usage is still unknown.

**Steps to reproduce**

1. Send a request through the eval gateway.
2. Disconnect the client before the provider returns final usage.
3. Close the gateway and let the provider response arrive.
4. Before this fix, the gateway aborts immediately and loses the final
receipt.

**Paperclip version or commit**

Reproduced against master `b6e690044a821faab52d5466db36c4330c754a2d`.

## What Changed

- Drain an already-dispatched response for at most five seconds after a
disconnect. Keep the original provider timeout and campaign deadline.
- Stop forwarding response data to a disconnected client. Stop admission
as soon as shutdown begins.
- Retain `clientDisconnected` on the private receipt and keep the
outcome canceled, even when final usage arrives.
- Make repeated shutdown calls share completion.
- Add HTTP and SSE regression tests. Document the drain and its
accounting limits.

## Verification

- Red: five regression cases failed against the previous gateway
implementation. Four further cases reproduced late cancellation during
review.
- `pnpm test:e2e:runner:unit`: 4,072 Vitest tests and 137 Node contract
tests passed. Two existing Vitest tests were skipped.
- `pnpm exec tsc --noEmit -p tests/runner-e2e/tsconfig.json`: passed.
- `git diff --check`: passed.
- Regressions cover both providers, an interrupted SSE stream, grace
expiry, a shorter provider deadline, no dispatch during interrupted
identity resolution, no new admission, repeated shutdown, client-only
disconnects, and disconnects during each final receipt/ledger write.
- Full repository typecheck, tests, and build passed in [CI run
40026846417](https://github.com/paperclipai/paperclip/actions/runs/40026846417)
on `40ef13bd4d5df6b2ca0a9666fb485adf2a565c28`. Greptile and Paperclip
reviews are both 5/5. No paid model test was run for this change. Live
qualification remains open.

## Risks

- Cleanup can take up to five more seconds. The admitted request can
continue generating during that period, inside its existing reservation
and deadlines.
- An abort does not prove that the provider stopped billing. Missing
usage keeps the unknown hold.
- This change does not establish invoice settlement or rewrite
historical receipts. It changes only the eval gateway.

## Model Used

OpenAI Codex, GPT-6 family, with reasoning, code execution, and tool
use. The host does not expose an exact model build identifier or context
window size for 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 (e.g. `docs/...`, `fix/...`)
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>
2026-10-23 14:36:41 -07:00
DottaandPaperclip b6e690044a feat(evals): allow reviewed bounded provisional accounting (#17365)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - Product E2E campaigns include model, setup, storage and
observability costs.
> - Some billing windows close after the tests and reports finish.
> - Requiring settled receipts for retained storage can block a good
campaign for weeks.
> - A reservation alone does not prove that a pending charge has an
upper bound.
> - This change permits provisional completion only with reviewed
evidence for the exact cost configuration.
> - Reports preserve unknown amounts and holds until later
reconciliation.

## Linked Issues or Issue Description

Refs: #17360, #17354

**What existing behavior does this improve?**

The Product E2E scheduled accounting gate and its retained cost reports.

**Current behavior**

Every pending receipt fails finalization. A completed test can wait
through the retained-storage billing window. The journal has dollar
reservations but no explicit qualification of their bounds.

**Proposed behavior**

Permit provisional completion when all pending charges have reviewed
full-lifecycle bounds, no requests remain in flight, no receipts
conflict, and known costs plus held amounts fit the campaign limit. Keep
all existing holds and receipt-finality rules. Missing evidence still
fails.

**Reason and benefit**

An operator can distinguish delayed but bounded billing from unbounded
or missing costs. The campaign can finish without claiming that its
invoice is settled.

**Breaking changes**

The journal accepts optional bound metadata and an invalidation record.
New reports add an optional bounded-pending count. Current readers
retain old journals and reports without granting them bounds. Older code
must not read new bound-bearing journals. The existing daily/weekly
enable gates and budget amounts stay unchanged.

**Additional context**

This implements the operator-approved provisional-cost policy for the
existing eval harness. It does not change product budgets or the
agent-eval roadmap. A targeted GitHub search found no duplicate open PR.

## What Changed

- Accounting owns a narrow evidence contract: a reviewed audit hash,
exact configuration hash and full-lifecycle scope.
- Gateway reservations retain that evidence before dispatch. Changed
limits or rates fail before dispatch. Unexpected routing, model identity
or excessive usage invalidates a bound durably.
- Operating allowances can carry separately reviewed bounds for each
cost component, including its full storage lifetime. No existing
allowance becomes qualified by default.
- Reports and Braintrust experiment metadata distinguish provisional
accounting, complete receipts, blocked accounting and unavailable
evidence. Public output omits private audit hashes.
- Scheduled finalization allows qualified provisional costs and
explicitly rejects spending overruns, including overruns with complete
receipts.
- Add regressions for legacy data, restarts, late reconciliation,
conflicts, malformed evidence, routing uncertainty and exceeded limits.
Document the evidence and migration boundaries.

## Verification

- Full offline eval-support suite: 4,062 Vitest tests passed, two
existing tests skipped; 137 Node tests passed.
- `pnpm test:e2e:runner:typecheck`: passed.
- `git diff --check`: passed.
- Read the retained hosted qualification journal with the new policy.
All six legacy pending charges remain unqualified. Known cost
`$0.421245200`, held `$19.327680000`, and committed `$19.748925200`
remain unchanged. The journal's SHA-256 is unchanged. The original
failed workflow remains failed.
- No paid models, network provider calls, receipt imports or reservation
releases were used for this verification.
- Rebased onto master `4d90634f74`; 142 targeted tests and typecheck
passed.
- Review reproduced a lost OpenAI input-total limit check when cache
details were missing (1 failed, 47 passed). Fix
`5fef9ba7c149951a51eae468614a4b89f0b3d6db` preserves unpriced provider
usage bounds. Then 178 focused tests, full offline support and typecheck
passed.
- Current-head hosted CI passed:
https://github.com/paperclipai/paperclip/actions/runs/40020746585
(attempt 2). Typecheck, build, all general/Runner/serialized tests and
browser gates are green.
- CI attempt 1 hit a PostgreSQL deadlock in unchanged chat-test cleanup;
its skipped flag restoration caused a second assertion failure. One
failed-jobs-only retry passed. Original failure evidence is preserved in
attempt 1. No paid eval campaign was rerun.
- Greptile reviewed exact head
`5fef9ba7c149951a51eae468614a4b89f0b3d6db` at 5/5; its one finding is
fixed and resolved. The optional Paperclip review is paused and supplied
no assessment.

## Risks

- Evidence hashes bind an audit to a configuration; they do not prove
the audit is true. Operators must review real provider limits, all price
tiers, full resource lifetimes and enforceable infrastructure limits
before configuring bounds.
- Provisional completion is not invoice settlement. Later billing can
reveal overruns, which must be reconciled and inspected. The ledger
cannot stop external billing.
- Existing pilot journals, configured allowances and price cards have no
new bound approval. This PR alone does not qualify or enable recurring
paid work.
- The gateway cannot qualify a canceled Braintrust request without route
confirmation. It preserves that unknown hold.
- No new dependency, secret, repository variable, workflow, schedule or
cloud resource changes.

## Model Used

OpenAI Codex, GPT-6 family. The exact deployment ID and context-window
size are not exposed in this session. Used reasoning, repository tools
and code execution. No paid evaluation model calls were made for this
change.

## 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 (e.g. `docs/...`, `fix/...`)
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>
2026-10-23 13:57:57 -07:00
DottaandPaperclip 17f1e386e8 feat(evals): compare retained Anthropic billing exports (#17360)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - Product E2E evaluations retain request costs and failed attempts in
a journal.
> - Provider exports can arrive later and contain costs at a wider time
scope.
> - Comparing those exports by hand makes repeated accounting work hard
to audit.
> - This change adds a read-only command for the observed Anthropic
export format.
> - It binds the comparison to the retained manifest, journal and exact
export bytes.
> - Operators can see the unmatched amount without assigning it to
canceled requests or releasing their holds.

## Linked Issues or Issue Description

Refs: #17009, #17354

**Problem or motivation**

A hosted campaign retained eight complete model receipts and two
canceled requests. A later provider export covered the campaign, but
comparing its tokens, rounded costs and the journal required a one-off
script. Repeated observations must not be counted twice or treated as
request-level billing proof.

**Proposed solution**

Add a private comparison command for one standard Claude Sonnet 5
campaign and one UTC date. Validate the selected workspace, key label,
model and pricing dimensions. Compare provider totals with one
authoritative observation per request. Retain source hashes and signed
differences. Keep provisional exports, partial receipts and missing
model identities explicit.

**Alternatives considered**

Manual comparisons remain possible but are hard to repeat. Importing a
day total as a request cost would invent attribution. This command
leaves journal and budget mutations to their existing owners.

**Roadmap alignment**

This is a focused operational tool for the existing Product E2E
accounting subsystem. It does not change the product budgeting or
agent-eval roadmap features. A targeted search found no duplicate
billing-comparison PR or issue.

## What Changed

- Add the provider-specific CSV parser, scope checks, token pricing
comparison and private CLI in the Product E2E accounting owner.
- Report complete and partial receipt coverage, source hashes, rounded
provider charges, separate non-model charges, and signed unmatched
amounts.
- Reject ambiguous scopes, unsupported price dimensions, duplicate rows,
contradictory token observations, changed journals and incomplete input.
- Write a new mode-0600 output without replacing existing files or
changing the journal.
- Document the supported export shape and the limits of comparison
evidence.

## Verification

- After rebasing onto master `e48f1867b3b45f74edca4645d640846bcafeee4c`,
104 focused and adjacent tests passed across comparison, ledger,
provider pricing, operating receipts and gateway behavior.
- `pnpm test:e2e:runner:typecheck`: passed after rebase.
- `git diff --check origin/master...HEAD`: passed.
- Ran the actual CLI on retained hosted-campaign CSV exports and
journal. It reproduced the prior manual calculation: provider-token
estimate `$0.428027200`, with `$0.006782000` unmatched to retained
request cost receipts. No provider or network call was made.
- The first retained-data run exposed an empty provider key-status field
and canceled receipts without a returned model identity. Those cases are
now covered by the fixtures; the rerun passed. No request identity or
final charge was invented.
- Regression tests first reproduced loss of token fields on unknown-cost
receipts (2 failed, 13 passed). The repair retains each known field
independently of cost and rejects conflicting equal-authority token
values.
- Full PR CI passed on `f74ef1c31391ee62b686fcf300601e9cf8e73a7e`,
including typecheck, tests, build and browser suites. Greptile and
Paperclip each reviewed that exact head at 5/5 with no remaining
actionable findings.

## Risks

- The initial supported schema is standard global Claude Sonnet 5 with
context buckets at or below 200k, one campaign and one UTC date. Other
provider shapes fail explicitly.
- Matching workspace/key labels does not prove exclusive key use or a
complete provider export. The output remains a comparison and cannot
release a reservation.
- Provider costs are rounded and can lag. The token estimate uses
retained prices and is kept separate from provider charges and non-model
costs.
- Config and exports are private inputs. Output includes hashes instead
of raw key labels. This file is not a public report projection.
- No runtime dependency, schedule, credential, paid execution, journal
format or admission rule changes.

## Model Used

OpenAI Codex, GPT-6 family. The exact deployment ID and context-window
size are not exposed in this session. Used reasoning, repository tools
and code execution. No paid evaluation model calls were made for this
change.

## 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 (e.g. `docs/...`, `fix/...`)
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>
2026-10-23 13:21:46 -07:00
DottaandPaperclip e48f1867b3 fix(evals): correlate canceled gateway requests with their ledger (#17354)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - Product E2E evaluations use a budget ledger and a local model
gateway.
> - The gateway writes each request reservation before it calls a
provider.
> - A client can cancel before the gateway returns response headers.
> - Project-only logging context cannot then bind a late gateway log to
its reservation.
> - This change sends the reserved request identity in Braintrust log
metadata before dispatch.
> - Operators can use that identity to inspect late records without
guessing from time or session order.

## Linked Issues or Issue Description

Refs: #17009

**What happened?**

A hosted evaluation passed its product checks but retained two canceled
requests with no response headers. Later gateway logs had partial usage.
Their time and session matched, but they had no ledger request identity.

**Expected behavior**

A gateway log must carry the ledger request ID even when the client
receives no headers. A log match must not imply final billing.

**Steps to reproduce**

Run the gateway regression with a transport that receives a request and
then cancels before response headers. Before this change, both requests
have the same project-only parent header.

## What Changed

- Add a small Braintrust context encoder owned by the eval gateway
integration. It uses the existing SpanComponentsV4 project-log format
and an allowlist of request, campaign, execution, attempt and phase
metadata.
- Save the exact context in the private request receipt before dispatch.
Send it as the gateway parent header.
- Test both provider routes, repeated identical requests, cancellation
holds and direct-provider isolation.
- Document the lookup field and the limits of historical and partial
evidence.

## Verification

- The new cancellation regressions failed before the change: 2 failed,
37 passed.
- Gateway, operations and tracing checks: 82 passed.
- `pnpm test:e2e:runner:typecheck`: passed after rebuilding stale
generated plugin-SDK types from current master. The initial stale-type
failure remains recorded locally.
- Official Braintrust SDK 3.38.0 decoded the actual generated context.
Its `startSpan` implementation emitted the reserved identity in the
initial LLM log. The check captured logs in memory and forbade all
network calls.
- `git diff --check`: passed.
- Full repository CI passed on
`529446a9295f2dc6fa6499a2f976480d74626097`, including typecheck, tests,
build and both required gates. Greptile is 5/5 on that head; its sole
finding is fixed and resolved.
- The optional Paperclip review turn ended without a final response. Its
check remains queued and provides no review assessment. No passing
review is inferred from it.
- Live hosted acceptance of this header change remains unqualified; no
paid test was dispatched for this fix.

## Risks

- The encoder follows Braintrust's versioned span format. A future
vendor change can require an update. It adds no package dependency.
- A late log can have partial usage. Existing reservations remain held
until valid cost evidence resolves them.
- Historical project-only requests cannot gain the new identity
retroactively.
- Only synthetic eval identifiers enter the new metadata. Credentials,
prompts and responses are excluded. Direct provider routes keep their
current headers.

## Model Used

OpenAI Codex, GPT-6 family. The exact deployment ID and context-window
size are not exposed in this session. Used reasoning, repository tools
and code execution. No paid evaluation model calls were made for this
change.

## 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 (e.g. `docs/...`, `fix/...`)
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>
2026-10-23 12:50:51 -07:00
DottaandPaperclip 59d1b7b43d fix(evals): collect usage when GitHub skips jobs without a runner (#17352)
## Thinking Path

> - Paperclip manages AI agents and their operating budgets.
> - Product E2E runs retain accounting for each campaign.
> - The usage collector reads completed GitHub jobs without rerunning
paid work.
> - GitHub returns a null runner ID for jobs that it skips before
assigning a runner.
> - The collector rejected those jobs and could not retain the completed
campaign inventory.
> - This change accepts that skipped-job representation while preserving
started-job checks.

## Linked Issues or Issue Description

Refs #17009.

**What happened?**

The usage collector rejected completed qualification run 39971835384.
GitHub returned skipped jobs with null runner IDs. The collector
accepted only zero for jobs without a runner.

**Expected behavior**

Retain completed run usage when skipped jobs have a null or zero runner
ID. Do not count VM time for those jobs. Continue to reject missing
runner identity for started jobs.

**Steps to reproduce**

Read the completed first-attempt Product E2E run with
operating-receipts.ts github. Before this fix, a skipped job with
runner_id set to null throws Invalid workflow job identity.

**Paperclip version or commit**

ed3f067dbd.

## What Changed

- Accept a null or zero runner ID only for completed skipped jobs.
- Keep run, attempt, labels and started-job identity validation.
- Test both skipped-job forms and reject absent runner IDs.
- Document the treatment of skipped jobs.

## Verification

- Reproduced the observed null-runner failure: 1 failed, 4 passed.
- Usage collector and operating receipt tests: 17 passed.
- Eval TypeScript check passed.
- Read the same completed hosted run successfully without dispatching or
retrying tests. The inventory retained 1,303 job seconds and 290,156,153
artifact bytes.
- Full hosted CI passed at fb57826c22,
including typecheck, tests, build and browser shards.
- Greptile and Paperclip reviews rated the exact commit 5/5 with no
actionable findings.

## Risks

- The exception applies only when GitHub reports a completed skipped job
and an explicit null or zero runner ID.
- Current usage remains an inventory. This change does not convert it to
a bill, release cost holds, or enable recurrence.

## Model Used

- OpenAI GPT-6 in Codex, with reasoning, repository inspection, code
execution and test tools. The exact backend model identifier 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 (e.g. `docs/...`, `fix/...`)
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>
2026-10-23 11:35:35 -07:00
DottaandPaperclip ed3f067dbd fix(evals): select operating allowance by cadence (#17326)
## Thinking Path

> - Paperclip manages AI agents and their operating budgets.
> - Product E2E runs exercise real agents through a bounded gateway.
> - The daily and weekly selections share one repository configuration
variable.
> - Their different request limits need different operating allowances.
> - The existing parser accepts only one allowance, which cannot
represent both reviewed limits.
> - This change selects the allowance for the actual cadence and retains
all existing validation.

## Linked Issues or Issue Description

Refs #17009.

**What happened?**

The daily selection needs an $11 operating reservation; the weekly
selection needs $21. A shared $21 allowance cannot fit the $20 daily
cap. A shared $11 allowance does not cover the reviewed weekly resource
bound. A configuration containing both allowances was rejected before
paid admission.

**Expected behavior**

Each cadence uses its own reviewed allowance. Missing or malformed
selected allowances stop admission before paid work.

**Steps to reproduce**

Set the operating allowance JSON to an object with daily and weekly
allowances. Prepare either campaign through prepareScheduledCampaign.
Before this change, both calls reject the outer object.

**Paperclip version or commit**

3bd709df8b.

## What Changed

- Accept daily and weekly allowance entries in the existing
configuration variable.
- Select the actual cadence before validating its budget, runner and
expiration.
- Pass only the selected allowance through the existing workflow output.
- Preserve single-allowance compatibility and document the configuration
format.

## Verification

- Reproduced both cadence failures before the fix: 2 failed, 12 passed.
- Focused scheduled operations and operating overhead tests: 20 passed.
- Eval TypeScript check passed.
- Missing selected entries and unknown outer fields fail before creating
a manifest.
- Hosted CI passed at 1c62cc8aeb,
including full typecheck, tests, build and browser shards.
- Greptile and Paperclip reviews both rated the exact commit 5/5 with no
actionable findings.

## Risks

- A map with a missing selected cadence now fails admission. It never
substitutes the other cadence.
- Operators must still provide reviewed rates and resource bounds. This
parser does not prove actual charges.
- This PR does not change limits, credentials, workflow permissions or
enable gates.

## Model Used

- OpenAI GPT-6 in Codex, with reasoning, repository inspection, code
execution and test tools. The exact backend model identifier 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 (e.g. `docs/...`, `fix/...`)
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>
2026-10-23 07:52:41 -07:00
DottaandPaperclip 3bd709df8b Operationalize Product E2E accounting, tracing, and scheduling (#17009)
## Thinking Path

> - Paperclip manages agents and the work they perform.
> - Product E2E tests exercise real agents, tools, setup and cleanup.
> - Repeated runs need retained costs and traces, including failed
attempts.
> - A passing retry must not hide earlier spending or feedback.
> - Recurring work also needs admission limits, private reports and
failure detection.
> - This change supplies those controls while keeping paid activation
behind existing gates.

## Linked Issues or Issue Description

Refs #16996 and #17158. This is the consolidated landing of the reviewed
eval operations stack: #17019, #17024, #17025, #17027, #17030, #17033,
#17035, #17038, #17043, #17044, #17048, #17050, #17051, #17092, #17096,
#17100, #17107, #17109, #17112, #17115, #17117, #17121, #17123, #17127,
#17130, #17133, #17134, #17137, #17140, #17143, #17154. The repository
permits squash merges only. A local rehearsal showed that squashing each
slice into master causes repeated conflicts in dependent slices. This PR
preserves their commits and lands their combined implementation in one
reviewed integration. Superseded slices will close after this merge.

## What Changed

- Retain every attempt's cost receipt, including setup, failures,
interruptions and retries. Separate reported amounts, estimates, missing
costs and reserved capacity in reports and dashboards.
- Add bounded request admission, exact model pricecards, gateway error
accounting, cache policy and reconciliation evidence. Refuse unsupported
routes and requests that cannot fit the allowance.
- Integrate Braintrust gateway traces and OTLP correlation, with secret
filtering and experiment imports. Record phase timing, including setup,
feedback capture and cleanup.
- Collect complaint and suggestion evidence after each attempt,
including recovery after failures. Retain explicit review dispositions
independently from the product grade.
- Add gated daily and weekly selections, measured forecasts,
setup/readiness checks, wall-time limits and retained monitor
notifications. Include declared non-model overhead in admission while
reporting the existing subscription separately.
- Keep recurring history private, bound uploads and retention, and use
isolated archive environments. Keep public publication an explicit
operation. Report and publication jobs install only the committed
lockfile, with scripts disabled and isolated stores; stale pins fail
closed.
- Integrate current master, preserve its Product E2E journey billing and
privacy checks, and test that shared setup receipts do not double-count
estimated agent usage. Preserve upstream fixture repairs.

## Verification

- Complete integration baseline
`0649a5ce7544ab20825c2183d2f421157db49f24` includes master
`a3e1d915a7110a4e115b46396a3f79e6dfb4d05e` and every original stack head
as ancestors.
- On that integration baseline, `pnpm test:e2e:runner:unit`: 4,012
Vitest tests passed, two skipped, across 193 files; all 137 Node
source-contract tests passed.
- Focused billing and Product E2E journey contract checks: 24 tests
passed. They cover estimates, unknown receipts, single-owner setup
costs, browser-only execution and private publication guards.
- Monitor and workflow wiring: all 96 Node tests passed. `node
scripts/check-token-gates.mjs`: all gates clean.
- `pnpm test:e2e:runner:typecheck` passes after the standard Runner
TypeScript build refreshed local declarations. The first attempt
rejected the new master `runner_prepared_launch` union member because
this checkout retained an older generated declaration; the source union
already contained that member.
- Current head `492b0708a1c531a023d9ac10f0f3dc6383cc1754` removes
dependency re-resolution from archive-authorized reporting jobs after
the security scan flagged it. All 15 workflow-security tests pass after
updating the old two-install assertion.
- Hosted [CI run
39965460180](https://github.com/paperclipai/paperclip/actions/runs/39965460180)
passes on the current repaired head, including typecheck, build, general
tests, Runner checks, browser shards and canary dry run. Greptile is 5/5
on this exact head with no unresolved threads. The security scan passes
after the fixed lockfile-resolution thread was resolved.
- Paperclip Review returned a terminal neutral check but an incomplete
0-file assessment on the repaired head: its platform blocked both diff
responses as prompt-injection content. This is not a successful code
review. No bypass or fabricated pass was attempted; current-head
Greptile, security and hosted CI are independent gates.
- No paid test, reservation release or recurring-run activation
accompanies this landing. Live route qualification and invoice
reconciliation remain separate evidence.

<details>
<summary>Retained earlier validation failures</summary>

Earlier broad local runs had two 15-second test timeouts (CLI poll
cadence and Retry validation), one embedded-database setup timeout, and
later PostgreSQL semaphore exhaustion. The exact timed-out tests passed
separately without larger timeouts; the broad-run causes were not
established. Those local failures remain distinct from subsequent hosted
CI results. The independent #17158 fix records its Muse fixture
collision, its UUID correction and hosted verification. Local Muse
execution was also blocked by macOS embedded-PostgreSQL startup. No
historical failure is treated as a successful paid qualification.

</details>

## Risks

- Admission is a local control, not a provider invoice cap. Missing
provider receipts or resource charges retain unknown amounts and holds;
estimates do not become billed dollars.
- The bounded path admits only documented local suites and provider
routes. Ordinary legacy or separate Runner protocol campaigns have
different controls. Merging this code does not qualify additional
routes.
- Recurrence still needs the existing enable gates and current
qualification/allowance evidence. Archive permissions and resources must
match the documented private-environment contract.
- Legacy reports may lack complete attempt or phase evidence. Reports
preserve that limitation and do not infer zero usage from missing data.

## Model Used

OpenAI GPT-6 through Codex, with reasoning, repository tools and code
execution. The exact deployment variant and context-window size are not
exposed by 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 (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass (targeted checks;
full-suite host limitation disclosed above)
- [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>
2026-10-23 07:18:37 -07:00