Files
PaperClipAI/doc
Devin FoleyandPaperclip e9b579ba6b fix: enforce accounting coverage and recovery regression gates (#15001)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - Durable accounting needs repeatable regression gates and inspectable
operational guidance.
> - Broad suite success alone does not prove that crash recovery or
critical financial invariants are tested.
> - This pull request adds per-module coverage floors, mutation
sentinels and an accounting operations guide.
> - CI detects weakened accounting tests and operators can inspect
failures without guessing.

## Linked Issues or Issue Description

Refs #14548, #5598. Completes the verification for #14997 and #14999.

Stack order: #14989 → #14991 → #14994 → #14997 → #14999 → #15001. Part 6
of 6. Review against `fix/costs-dashboard-accounting`. Merge authorized;
landing in dependency order.

## What Changed

- Add and typecheck focused PostgreSQL tests for crash recovery,
concurrency, receipt replay, reporting and operator recovery, plus
exact-money and provider-import tests.
- Require saved passing results for all four SIGKILL cases and both
historical migration cases; skipped or missing cases fail. The
historical runtime fixture restores bigint and verifies an exact
lifetime total beyond JavaScript’s safe integer range.
- Require each of thirteen accounting service modules to meet its own
coverage thresholds.
- Kill deliberate mutations of receipt deduplication, company isolation,
projection conservation and budget boundaries at their specifically
marked assertions; reject setup errors, timeouts and unrelated failures.
- Retain mutation and coverage evidence on failures and upload it from
the trusted CI workflow.
- Preserve frozen-only installs for canary onboarding, optional E2E,
Storybook visual and live provider evals. Execute regressions that
require stale locks to fail closed without registry resolution; the
existing repository bot owns lockfile refreshes.
- Add a scale benchmark and the final implementation/operations guide,
with spec links introduced alongside the guide.
- Exercise empty-turn recovery through the real usage translator with
legacy/current receipts, complete/incomplete flags, malformed metadata
and counter checks. Keep Cloud-auth fixture teardown hardening in this
test gate.
- Cover ACPX completeness through the real notification translator and
driver, plus additive reservation/dispatch and exact daily-spend
assertions.
- Drain Cloud-auth browser route handlers before teardown.
- Require frozen-only installation in the accounting CI lane and gate
coverage execution on successful installation, so the provider cannot
come from inline registry resolution. Other CI lanes keep their existing
install policy.
- Test fractional status-card and skill-test response costs, invalid
monetary values and integer token counters. Include the additive
accounting OpenAPI assertions.
- Cover missing/malformed/mismatched billing secret designations,
privileged caller roles and inactive or cross-company memberships.
Document dedicated billing-secret setup. Include fractional and large
status-card cost regressions.

## Verification

- `pnpm test:accounting` checks 98% lines, 90% branches, 96% statements
and 96% functions per service module, plus required migration/recovery
evidence and mutation checks.
- `node --test scripts/test-accounting-mutations.test.mjs
scripts/verify-accounting-test-results.test.mjs` passed all 22
gate-harness scenarios.
- Inspect `coverage/accounting/` for coverage and test/mutation
evidence. The benchmark is an explicit operator command, not a timing
threshold in CI.
- All 30 release/workflow shard tests and actionlint pass. The new
regression executes the actual accounting-lane install: a stale lock
exits without any registry resolution; a current lock proceeds. It fails
against the old fallback.

Integrated-stack validation on master `c365a16e346d`: repository-wide
typechecking and production build, token gates, 313 focused accounting
tests, two historical migration tests, four required SIGKILL cases and
four mutation sentinels pass. The thirteen accounting modules meet their
individual coverage floors (aggregate 99.7% lines, 94.82% branches). CI
fixture regressions pass 48 connection-card cases, both recovery release
orders and the personal-connection browser workflow. Final consumer
regressions pass all 28 Browser Use lifecycle, 42 email pipeline and 140
rendered issue-detail cases; local email verification used this
checkout’s bundled skills to avoid an unrelated ancestor skills
directory. Merged-source regressions pass AI connections (107), route
authorization (23), worktree cloning (63) and ACPX execution (221).
Additional checks during stack preparation passed native execution
(565), heartbeat admission (60), OpenCode/checkpoint/failure-path (102),
Codex runner drivers (316) and Costs UI (21). Runtime/connection (644),
adapter/billing (86), all Codex adapter cases (509 passed, one skipped),
dashboard (106), worktree-cloning (63), CLI cost (14) and gate-harness
(48) tests pass. Release workflow tests (18) and actionlint pass;
frozen-install shell regressions confirm current locks proceed and stale
locks fail without retries. The repository lockfile bot must land the
coverage dependency refresh before frozen-install workflows run. All
three accounting browser workflows pass on the current merged tree; the
Storybook build and populated provider/biller smoke check passed earlier
in stack preparation. Landing validation against the six intervening
master changes passes all 282 targeted UI tests, 18 workflow tests and
repository-wide typechecking; Storybook host validation adds 19 passing
cases and 18 live HTTP checks, with UI typechecking and token gates
passing. After master consolidated Cursor support, the one cancellation
overlap preserves both current-budget fencing and the new manual
cancellation identities. All 642 affected
heartbeat/cancellation/native/Cursor tests, repository-wide typechecking
and production build pass after reinstalling the updated ACPX patch. The
rebuilt final tree matches that combined source. Each PR’s standalone,
latest-head CI status is recorded below. Latest-head CI has not yet
passed. Latest-head Greptile sign-off is pending. A fresh Apex review
will be requested for this authorized merge.

## Risks

The focused gate adds CI time and requires PostgreSQL support. Trusted
workflow changes take effect when this PR reaches master. Coverage does
not claim to cover every heartbeat, adapter or browser path.
Frozen-install jobs stop until the repository bot refreshes
pnpm-lock.yaml for the new coverage dependency; no fallback runs
unreviewed dependency code in those jobs.

## Model Used

OpenAI Codex, based on GPT-6, with repository inspection, code editing
and test execution. The exact serving model ID and context window were
not exposed to 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
- [ ] All Paperclip CI gates are green
- [ ] 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-07 07:26:25 -07:00
..
2026-02-16 14:25:00 -06:00