Files
PaperClipAI/packages/db
c938bdfee4 perf(ci): stop printing Postgres TRUNCATE notices in server test shards (#21903)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - The server test suites run on 12 CI shards. Each suite gets a
disposable Postgres database from `packages/db`.
> - Many suites reset their state with `TRUNCATE ... CASCADE`. Postgres
sends one `NOTICE` for each cascaded table.
> - postgres.js prints each notice with `console.log` when a client sets
no `onnotice`. Vitest then carries each line from the worker to the
reporter.
> - On the slowest shard of a recent run, about 600k of the 760k log
lines were these notices. The noise makes the shard slower and the log
hard to read.
> - This pull request sets `client_min_messages = warning` on each
disposable test database. Every client that a suite opens then gets no
notices.
> - The benefit is a shorter slowest server shard and a much smaller
log.

## Linked Issues or Issue Description

Refs #21879 (a separate cause of the same slow shard: missing
shard-duration weights).

**What existing behavior does this improve?**
Disposable test databases send every Postgres `NOTICE` to the test
clients. The test logs print each notice.

**Subsystem affected**
Test database fixtures in `packages/db` (`test-embedded-postgres.ts` and
`test-postgres-admin.ts`). This change touches only test infrastructure.

**Current behavior**
On PR #21872 (run
[43858567594](https://github.com/paperclipai/paperclip/actions/runs/43858567594)),
the longest check was `ci / General tests (server (10/12))` at 768s. The
Vitest step took 722s of that. The other server shards took 597–729s.
The shard log had 760k lines. About 600k lines were `truncate cascades
to table "…"` notices (about 77k notice objects):

| suite | notices |
|---|---|
| heartbeat/workspace-preparation.test.ts | 19,089 |
| agent-timer-deadlines.test.ts | 16,445 |
| idle-incoming-wake.test.ts | 13,846 |
| public-mcp/events-work.test.ts | 13,156 |
| execution-control-work.test.ts | 4,485 |
| 6 more suites | about 10k |

About 20 suites already stop the notices one session at a time (`SET
client_min_messages = warning` or `onnotice = () => {}`).

**Proposed behavior**
The fixture sets `client_min_messages = warning` on the database itself.
It does this for the embedded-cluster path and for the
`PAPERCLIP_TEST_POSTGRES_ADMIN_URL` path. Warnings and errors still
show. A suite that needs notices can lower the level for its own
session.

**Reason and benefit**
The notice-heavy suites ran 15–50% over their manifest weights in this
run (for example, workspace-preparation took 193s against a weight of
173s, and idle-incoming-wake took 40s against 26s). Other suites were
near their weights. Estimate: about 0.5–1 min less on the slowest server
shard. The log on that shard goes from about 760k lines to about 160k
lines. If #21879 also merges, the server lane's critical path should go
from about 12.8 min to about 10–11 min.

**Breaking changes**
None. Only disposable test databases change.

## What Changed

- `packages/db/src/test-postgres-admin.ts`: add
`QUIET_TEST_DATABASE_SQL`. Run it on each new database on the admin-URL
path.
- `packages/db/src/test-embedded-postgres.ts`: run the same statement on
the `paperclip` database at each embedded start. It runs on each start,
not only when the template is built. Thus a template that was cached
before this change also gives a quiet database, and the template key
stays the same.
- `packages/db/src/test-postgres-admin.test.ts`: new test for the
admin-URL path.
- `packages/db/src/test-embedded-postgres.test.ts`: new tests for the
embedded template path and the fresh path.
- Each new test opens a new client, checks `SHOW client_min_messages`,
and runs a `TRUNCATE ... CASCADE`. The test fails if the client gets a
notice.

## Verification

- `cd packages/db && npx vitest run src/test-postgres-admin.test.ts
src/test-embedded-postgres.test.ts`: 2 files, 25 tests pass.
- I changed the statement to `RESET client_min_messages` and ran the new
tests again. All 3 new tests failed. Then I restored the statement.
- `cd packages/db && npx tsc --noEmit -p .`: no errors.
- To measure the time savings, compare the server shard timings of this
PR's CI run with run 43858567594.

## Risks

- Low risk. The change affects only disposable test databases.
Production databases do not use these fixtures.
- A test that expects to receive a `NOTICE` on a new client would now
not get it. Such a test can set `client_min_messages = notice` for its
session. No current suite depends on notices: the full CI run on this PR
passed.
- The time savings is an estimate. The shard planner and other suites
can change the slowest shard.

> For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and
discuss it in `#dev` before opening the PR. Feature PRs that overlap
with planned core work may need to be redirected — check the roadmap
first. See `CONTRIBUTING.md`.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`) by Anthropic, used through Claude
Code as a Paperclip agent with tool use (shell, file edits, GitHub CLI,
CI log inspection). Standard reasoning mode.

## 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

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: devinfoley <139239+devinfoley@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 13:07:15 -08:00
..
2026-03-12 13:09:22 -05:00